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

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

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

4
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

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

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

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

8
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

9
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;
     }

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

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

12
Bones / My Format
« on: May 25, 2017, 04:01:30 am »
Raft, I sent you and Egon a screenshot of my Max exporter. My format, which comes out of 3ds max fully JSON-serialized, comes with three types of animation: vertex animation for expressions, skin animation, and a third kind, which is vertex animations in place of skin animations. Now there's two reasons for the third kind: no need for a bone structure should I use the format in other platforms and, more urgently, because although I can import a model whose joints distort it intuitively, I have never been able to play a skin animation either in Bones or in Blender (or, for that matter, in a Java port of Animadead which I made). The only thing I'm exporting, having tried everything else, are the euler angles per joint per animation frame. I'm convinced that that's enough, but I can't get it to work. The weights all appear to be the same as they are in Max. I would like your help in fixing this (there's really no other reasonable way to export skinned models out of Max and into Bones anymore now that OgreMax is dead).

13
Support / How to import vertex animations
« on: May 09, 2017, 02:12:21 pm »
As you know, Egon, I'm writing that JSON-serialized file format. Right now, I'm working on the vertex animations. I've stored the frames in a file. The current version of the method looks like the following. But the trouble now is that the only idea I have is to clone the only Mesh instance I have and distort it with a vertex controller. But that doesn't really seem right to me.

Code: [Select]
     public static Object3D loadVertexAnimated(String fileName) {
        NoBonesImporter jImporter = new NoBonesImporter();
        ArrayList<ArrayList> objects = jImporter.getList(fileName);
ArrayList<NoBoneAnimation> importedAnimations = jImporter.getAnimations(fileName);
Object3D[] list = Object3D[objects.size()];
for (int i = 0; i < objects.size(); i++) {
     ArrayList<ArrayList> theObject = objects.get(i);
     ArrayList<ArrayList> importedVertices = theObject.get(0);
             ArrayList<ArrayList> importedUVs = theObject.get(1);
             ArrayList<ArrayList> importedFaces = theObject.get(2);
             float[] coordinates = makeCoordinates(importedVertices);
             float[] uvs = makeUVs(importedUVs);
             int[] indices = makeIndices(importedFaces);
     Object3D anObject = new Object3D(coordinates, uvs, indices,0);
     list[i] = anObject;

        }

int numTriangles = importedVertices.size(), numFrames = importedAnimations.size();
for (i = 0; i < numFrames; i++) {
     tmp.clearObject();
     int frame = i;
     Object3D anObject = list[i];
     Mesh aMesh = anObject.getMesh();
     NoBoneAnimation anAnimation = animations.get(i);
     String name = anAnimation.name;
     int numFrames = anAnimation.frames.size();
     Animation animation = new Animation(numFrames);

     for (ArrayList<ArrayList> importedVertices: anAnimation.frames) {
// Create a new mesh with vertex controller?
SimpleVector[] vertices = SimpleVector[importedVertices.size()];
for (int j = 0; j < vertices.length; j++) {
      SimpleVector v = new SimpleVector(vert.get(0), vert.get(1), vert.get(2));
vertices[j] = v;
      }
animation.addKeyFrame(...);
     }
}
Object3D anObject = makeAnimated3D(pose, objectsBonesReferences.get(i), theObject);
     }

14
Support / Rotation Towards 3D Point
« on: March 07, 2017, 09:10:49 pm »
The following isn't working. How come?

Code: [Select]
     public void rotateTowards(SimpleVector towards) {
SimpleVector directionVector = new SimpleVector(towards.x -model.getTransformedCenter().x, towards.y -model.getTransformedCenter().y, towards.z -model.getTransformedCenter().z).normalize();//WON'T WORK WITH OR WITHOUT NORMALIZE()
Matrix rotationMatrix = directionVector.getRotationMatrix();
if (this instanceof Worker)
     ((Worker)this).setRotationMatrix(rotationMatrix);
else model.setRotationMatrix(rotationMatrix);
     }

15
Support / PolygonManager.getTransformedVertex is Unreliable
« on: February 24, 2017, 05:02:18 pm »
The following is supposed to test if a character is over a particular square in a 2d array of planes (as created from the ExtendedPrimitives class). It doesn't work. The previous version of this method compared the centers of all planes and it worked (but looked terrible). I should note that I'm using the software renderer.

Code: [Select]
     public java.awt.Point boardSpaceFromWorld(SimpleVector ws) {
for (int y = 0; y < planes[0].length; y++) {
     for (int x = 0; x < planes.length; x++) {
Object3D plane = planes[x][y];
PolygonManager polyMan = plane.getPolygonManager();
SimpleVector[] vertices = new SimpleVector[6];
vertices[0] = polyMan.getTransformedVertex(0, 0);//, plane.getInverseWorldTransformation(), new SimpleVector());
vertices[1] = polyMan.getTransformedVertex(0, 1);//, plane.getInverseWorldTransformation(), new SimpleVector());
vertices[2] = polyMan.getTransformedVertex(0, 2);//, plane.getInverseWorldTransformation(), new SimpleVector());
vertices[3] = polyMan.getTransformedVertex(1, 0);//, plane.getInverseWorldTransformation(), new SimpleVector());
vertices[4] = polyMan.getTransformedVertex(1, 1);//, plane.getInverseWorldTransformation(), new SimpleVector());
vertices[5] = polyMan.getTransformedVertex(1, 2);//, plane.getInverseWorldTransformation(), new SimpleVector());
float minX = Float.MAX_VALUE, maxX = Float.MIN_VALUE, minZ = Float.MAX_VALUE, maxZ = Float.MIN_VALUE;
for (int i = 0; i < 6; i++) {
     if (minX > vertices[i].x)
minX = vertices[i].x;
     if (maxX < vertices[i].x)
maxX = vertices[i].x;
     if (minZ > vertices[i].z)
minZ = vertices[i].z;
     if (maxZ < vertices[i].z)
maxZ = vertices[i].z;
}
if (ws.x > minX && ws.x <= maxX && ws.z > minZ && ws.z <= maxZ)
     return new java.awt.Point(x, y);
     }
}
return new java.awt.Point();
     }

Pages: [1] 2 3 ... 14