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

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?

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?

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

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++) {
     int frame = i;
     Object3D anObject = list[i];
     Mesh aMesh = anObject.getMesh();
     NoBoneAnimation anAnimation = animations.get(i);
     String 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;
Object3D anObject = makeAnimated3D(pose, objectsBonesReferences.get(i), theObject);

Pages: 1 [2] 3 4 ... 15