Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - AGP

Pages: [1] 2 3 ... 15
Support / Environment Mapping with Software
« on: February 06, 2018, 06:40:35 pm »
One of my ships is shiny. I have a vague memory of talking to you about environment mapping with the software renderer. I fully expected that the environment map would not work with the software renderer, but my expectation was that the diffuse map would be completely replaced by the environment map and that the environment map would be treated as diffuse. This is not so. Ambient map acts like the ambient map but the diffuse channel disappears. To that end, I tried writing the following method. But obviously, the result is that the ambient map is just colored by the diffuse. My question, then, is since the environment mapping is already performing as expected, would it be possible to just make the diffuse channel work with it?

Code: [Select]
     private void combineAmbientAndDiffuse() {
Texture tex = TextureManager.getInstance().getTexture("EnvironmentMap");
tex.add(TextureManager.getInstance().getTexture("Starfighter.png"), .5f);

Support / Drawing a Graphic on a Separate Thread
« on: February 01, 2018, 03:35:33 am »
Hardware renderer in (lwjgl's frame) fullscreen throws a RuntimeException ("No OpenGL context found in the current thread."). I created a WorldProcessor with two threads as well as tried it the lwjgl way (GLContext.useContext()). Neither worked.

Support / Interact2D
« on: January 16, 2018, 08:38:03 pm »
I'm trying to make a little level editor. Right now, all it will do is to allow you to position some enemies by clicking on the 3d map. I'm not very interested in the y coordinate, because they will place themselves relative to the floor's height). But the following code always places the enemiies in the same (marked) spot:

Code: [Select]
     public void mouseClicked(MouseEvent e) {
Point p = e.getPoint();
SimpleVector p3d = Interact2D.reproject2D3DWS(camera, buffer, p.x, p.y);
System.out.println("p3d: "+p3d);
p3d.y = -2000f;
objects[numberOfObjects++] = Primitives.getCube(100f);

Support / Does TextureManager Operate on a Parallel Thread?
« on: January 12, 2018, 05:45:37 pm »
If so, how do I wait for it? My app is failing to find a texture after it's been added to the TextureManager.

Support / rotateMesh Bug
« on: January 10, 2018, 03:16:28 pm »
The following code doesn't crash with Object3D.rotateY(...) but crashes with a NullPointerException on Object3D.rotateMesh().

Code: [Select]
if (ship instanceof Blah) {

Support / Too Bright With Software Renderer
« on: December 20, 2017, 06:52:49 am »
I even wrote the following (where "amount" refers to color intensity for all three colors):

Code: [Select]
int amount = 15;
float attenuation = 3.6f, dist = 1f;
theWorld.setAmbientLight(25, 25, 25);//-20
if (b.usesRenderer(IRenderer.RENDERER_OPENGL)) {
theWorld.setAmbientLight(125, 125, 125);//-20
     amount = 55;
     attenuation = 3600f;
     dist = 10f;
else Config.lightMul = 1;

Support / Loader.loadOBJ Problem
« on: October 31, 2017, 08:33:08 pm »
Code: [Select]
System.out.println("\n\n\nWarcraft.loadObject: "+fileName +" Is the mtl null? "+(mtlFile==null));
System.out.println("Is loadOBJ(fileName, mtlFile) null? "+(Loader.loadOBJ(fileName, mtlFile, .5f)==null));

Warcraft.loadObject: buildings\castle_construction0.obj Is the mtl null? false
Exception in thread "main" java.lang.NullPointerException
        at java.util.Hashtable.put(Unknown Source)
        at com.threed.jpct.Loader.loadOBJ(
        at com.threed.jpct.Loader.loadOBJ(
        at Warcraft.loadObject(
        at Worker.moveTowardsDest(
        at Warcraft.loop(
        at Warcraft.<init>(
        at Warcraft.main(

I've opened the file in Blender and it loads just fine.

Support / Fog Of War Transparency With Software
« on: October 12, 2017, 03:02:14 am »
I''m writing a strategy game and can't seem to properly paint a transparent PNG on my fog (so that its edges are rounded). The logic for the texture placement is sound and has been tested. But all I get is solid black.

Code: [Select]
if (!TextureManager.getInstance().containsTexture("fog-top")) {
     TextureManager.getInstance().addTexture("fog-top", new Texture("Assets"+File.separator+"fog-top.png", true));
     TextureManager.getInstance().addTexture("fog-left", new Texture("Assets"+File.separator+"fog-left.png", true));
     TextureManager.getInstance().addTexture("fog-right", new Texture("Assets"+File.separator+"fog-right.png", true));
     TextureManager.getInstance().addTexture("fog-bottom", new Texture("Assets"+File.separator+"fog-bottom.png", true));

Support / ERROR: Texture '--*--BlittingWrapper_internal--*--' not found!
« on: October 04, 2017, 03:30:02 am »
Is this a jpct error? If so, what is it? I'm using the software renderer here.

Support / Polyline.setLineLength?
« on: September 23, 2017, 01:12:44 am »
I'm writing the following for my son (sorry about the captured frame-rate). The thing about Polyline.update(...) is that it's expensive to always create a new array (I suppose that I could store it, then edit it but that's quirky), and it's inconvenient. Also, the following is the code that increases the length of my laser (deltaTime*10f breaks the numbers by being making them too large):

Code: [Select]
SimpleVector pos = bridge.getTransformedCenter();
pos.y -= 160f;
SimpleVector forward = bridge.getZAxis();
laserLength *= (1f+(deltaTime*6f));
laser.update(new SimpleVector[]{pos, pos.calcAdd(new SimpleVector(forward.x*laserLength, forward.y*laserLength, forward.z*laserLength))});

Support / LWJGL 3+
« on: September 19, 2017, 06:09:52 am »
I've found no AWTGLCanvas in my brief exploration of its docs. I have, however, found this:
Code: [Select] It's kind of funny the notion of someone going, "do you know what Java needs? Malloc. I miss malloc." LOL

Anyway, is there any chance that you might implement your own AWTGLCanvas from that? At some point, you have to recognize the need to update (either to the newer LWJGL or otherwise to jOGL or a third--to me unknown--wrapper). Right?

Bones / Scale Problem?
« on: August 29, 2017, 10:04:27 pm »
I have a class called Bone, as defined in the following code. It's used as a bridge between the JSON-serialized format I created and Bones.

Code: [Select]
class Bone {
    protected String name;
    protected SimpleVector position;
    protected Matrix transform;
    protected int index, parentIndex;
    public Bone(String name, SimpleVector position, Matrix transform, int index, int parentIndex) { = name;
        this.position = position;
        this.transform = transform;
        this.index = index;
        this.parentIndex = parentIndex;
    public boolean hasParent () {
        return this.parentIndex >= 0;
    public String toString () {
        return + ": " + this.position;

When I print its values as follows, I get perfectly reasonable numbers (values ranging from -30 to +120).

Code: [Select]
System.out.println(newBone.toString() +": "+newBone.index);
But, after creating my AnimatedGroup, as follows, the values range between -Infinity to +Infinity, with NaNs thrown in there for good measure.

Code: [Select]
    public static AnimatedGroup loadGroup(JsonLoader jsonLoader) {
        MaxBonesClip[] clips = Importer.getMaxBonesClips(jsonLoader);
        MaxBonesImporter jImporter = new MaxBonesImporter(jsonLoader, clips);
        ArrayList<ArrayList> objects = jImporter.getList();
        ArrayList<Bone> bones = jImporter.getBones();
        ArrayList<ArrayList> objectsBonesReferences = jImporter.getBonesReferences(); // for all objects, respects the same order of objects
        Animated3D anObject = null;
        SimpleVector center = null;
        Skeleton skeleton = Importer.makeSkeleton(bones);
        SkeletonPose pose = new SkeletonPose(skeleton);
        Animated3D[] list = new Animated3D[objects.size()];
        for (int i = 0; i < objects.size(); i++) {
            ArrayList<ArrayList> theObject = objects.get(i);
            if (bones == null || bones.size() <= 0) {
                Logger.log("Problem: no bones. Try loadObject(String) instead.");
                return null;
            anObject = makeAnimated3D(pose, objectsBonesReferences.get(i), theObject, new File(jsonLoader.getMainFileName()).getParent());
            list[i] = anObject;
        System.out.println("To test: "+bones.get(JSONFrame.BONE_INDEX_TO_TEST));
        AnimatedGroup asGroup = new AnimatedGroup(list);
        asGroup.setSkinClipSequence(getSkinClipSequence(jImporter, anObject.getSkeleton()));
        return asGroup;
    private static Animated3D makeAnimated3D(SkeletonPose pose, ArrayList<BoneReference> boneRefs, ArrayList<ArrayList> theImportedObject, String absolutePath) {
        ArrayList<ArrayList> vertices = theImportedObject.get(0);
        ArrayList<String> diffuseAndNormal = theImportedObject.get(3);
        int verticesCount = vertices.size();
        //skeletonDebugger = new SkeletonDebugger(pose, 0f, 1f);
        float[][] weights = new float[verticesCount][Importer.MAX_JOINTS_PER_VERTEX];
        short[][] jointIndices = new short[verticesCount][Importer.MAX_JOINTS_PER_VERTEX];
        int[] verticesCounters = new int[verticesCount];
        for (int i = 0; i < verticesCount; i++) verticesCounters[i] = 0;
        for (BoneReference aBoneRef: boneRefs) {
            int vertexRef = aBoneRef.vertexIndexReference;
            int verticesCounter = verticesCounters[vertexRef];
            if (verticesCounter < Importer.MAX_JOINTS_PER_VERTEX) {
                weights[vertexRef][verticesCounter] = aBoneRef.vertexWeight;
                jointIndices[vertexRef][verticesCounter] = aBoneRef.boneIndexReference;
        SkinData skin = new SkinData(weights, jointIndices);
        if (!TextureManager.getInstance().containsTexture(diffuseAndNormal.get(0)))
        TextureManager.getInstance().addTexture(diffuseAndNormal.get(0), new Texture(absolutePath +File.separator+diffuseAndNormal.get(0)));
        MeshData meshData = makeMeshData(theImportedObject);
        Animated3D anAnimated = new Animated3D(meshData, skin, pose);
        return anAnimated;

These prints produce NaNs, and the infinities:
Code: [Select]
        for (int h = 0; h < asGroup.getSize(); h++) {
            Animated3D temp = asGroup.get(h);
            Skeleton s = asGroup.get(h).getSkeletonPose().getSkeleton();

            for (int i = 0; i < s.getNumberOfJoints(); i++) {

                //temp.animateSkin(frame, sequence);

Bones / SkeletonDebugger Auto-Scale Feature?
« on: August 18, 2017, 10:19:15 pm »
I've been stuck for weeks on what has to be the last stages of my file format. I load the whole thing into bones without a problem, but animating it is something else altogether. When I try to use the SkeletonDebugger, I get an "ERROR: Invalid scale!" message. When I animate it, the center of the object doesn't change but it disappears entirely. No further errors as the animation runs, but no visible object, even with culling set to false.

I can't figure this error out (especially since I can reimport the object back into 3ds max and succesfully play its animations). Would it be possible to add some logic such that SkeletonHelper would automatically rescale this invalid scale?

Support / Shadows
« on: August 14, 2017, 06:04:38 am »
Egon, I'd really like to solve the shadow-map movement issue in jpct. I've put out finishing a nice little RPG game for a couple of years because of it. The following shows the problem I get when I move the sun:

Support / Wall Collision
« on: August 12, 2017, 12:10:26 am »
I'm trying to use the following code. In this case, the walls and the floor are different entities. Collision with the floor is handled separately and works fine. When I do get a collision with the walls, which is not always, I get printouts like "Collided and not with ground. Direction: (-7.939828, -2.0494497) Return route: (5.188492, -2.2546387)." Why would I not at least get the reverse of my direction? How should I do this, instead?

In loop():
Code: [Select]
     camera.moveCamera(Camera.CAMERA_MOVEIN, MOVE_SPEED);

Code: [Select]
    private void wallCollision(float MOVE_SPEED) {
SimpleVector cameraZ = camera.getZAxis();
SimpleVector direction = new SimpleVector(cameraZ.x*MOVE_SPEED, cameraZ.y*MOVE_SPEED, cameraZ.z*MOVE_SPEED);
SimpleVector newDirection = collide(direction);
     private SimpleVector collide(SimpleVector directionToHead) {
SimpleVector direction = theWorld.checkCollisionEllipsoid(camera.getPosition(), directionToHead, ELLIPSOID_RADIUS, 5);//.5f, 2f, .5f), 5
if (directionToHead.x != direction.x || directionToHead.z != direction.z) {
     float multiplier = 1f;
     direction.x*= multiplier;
     direction.z*= multiplier;
System.out.println("Collided and not with ground. Direction: ("+directionToHead.x +", "+directionToHead.z +") Return route: ("+direction.x +", "+direction.z +").");
     camera.moveCamera(direction, 1f);
return direction;

Pages: [1] 2 3 ... 15