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 ... 14
1
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:
https://www.dropbox.com/s/r73iukqn0wdtcjs/LE.jpg?dl=0

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);
objects[numberOfObjects-1].build();
objects[numberOfObjects-1].translate(p3d);
theWorld.addObject(objects[numberOfObjects-1]);
     }

2
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.

3
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) {
     ship.body.rotateY((float)Math.PI*.5f);
     ship.body.rotateMesh();
     ship.body.clearRotation();
}

4
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;

5
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));

Produces:
Quote
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(Loader.java:819)
        at com.threed.jpct.Loader.loadOBJ(Loader.java:508)
        at Warcraft.loadObject(Warcraft.java:250)
        at Worker.moveTowardsDest(Character.java:393)
        at Warcraft.loop(Warcraft.java:320)
        at Warcraft.<init>(Warcraft.java:163)
        at Warcraft.main(Warcraft.java:1058)

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

6
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));
}

7
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.

8
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))});

https://www.youtube.com/watch?v=ui6R1ZDcEqI

9
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]
https://javadoc.lwjgl.org/org/lwjgl/system/jawt/JAWT.html 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?

10
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) {
        this.name = 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.name + ": " + 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;
        scaleBones(bones);
        invertBonesCoords(bones);
        Skeleton skeleton = Importer.makeSkeleton(bones);
        SkeletonPose pose = new SkeletonPose(skeleton);
        pose.updateTransforms();
       
        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.");
                java.awt.Toolkit.getDefaultToolkit().beep();
                return null;
            }
            anObject = makeAnimated3D(pose, objectsBonesReferences.get(i), theObject, new File(jsonLoader.getMainFileName()).getParent());
            anObject.build();
            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;
                verticesCounters[vertexRef]++;
            }
        }
        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);
        anAnimated.setTexture(diffuseAndNormal.get(0));
        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++) {
                System.out.println(temp.getSkinClipSequence().getClip(0).getSkeleton().getJoint(i).getBindPose().toString());

                //temp.applySkeletonPose();
                //temp.animateSkin(frame, sequence);
                //temp.applyAnimation();
            }
        }

11
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?

12
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:

https://www.youtube.com/watch?v=Z3KdV7mqEHY

13
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]
     wallCollision(MOVE_SPEED);
     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) {
ground.setVisibility(false);
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 +").");
Toolkit.getDefaultToolkit().beep();
     camera.moveCamera(direction, 1f);
}
ground.setVisibility(true);
return direction;
     }

14
Support / Only thing rendered is the SkyBox
« on: June 11, 2017, 02:11:43 am »
And even that won't turn with the camera. The screen is being redrawn, the accelerometer data is being updated, and so on and so forth. onDrawFrame calls a loopIteration() method that only rotatesCameraY by a given amount, then redraws the screen. But the SkyBox doesn't rotate. It's the weirdest thing, but it should be a known issue (something that I'm doing wrong that's already been done). Right?

15
Support / Oculus VR SDK
« on: June 06, 2017, 05:45:14 pm »
Has anyone ever done an example using Android Studio and the Oculus VR SDK?

Pages: [1] 2 3 ... 14