Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Game Mechanics / Re: Jbullet to 3ds max on: 2010-01-04 21:00:38
Solved. The model loads fine.
 Tongue
2  Game Development / Game Mechanics / Jbullet to 3ds max on: 2009-12-29 16:13:46
Hi there.
I am trying to export animation from jBullet to 3ds max.
But the final animation in 3ds max is ending a bit joggy.

This is what I am doing inside jbullet:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
//Paint the window and render the objects
public void clientMoveAndDisplay() {
        gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        float ms = getDeltaTimeMicroseconds();

        if(dynamicsWorld != null && !idle) {
            dynamicsWorld.stepSimulation(1 / 30);
           
        }

        renderme();
    }


Now grab the objects flagged to export animation and get their world transform.
Is this right??

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
    //in the main render flow

      for(int i = 0; i < numObjects; i++) {
            final CollisionObject colObj = dynamicsWorld.getCollisionObjectArray().get(i);
            final RigidBody body = RigidBody.upcast(colObj);

            if(body != null && body.getMotionState() != null) {
                final DefaultMotionState myMotionState = (DefaultMotionState) body.getMotionState();
                debugTransform.set(myMotionState.graphicsWorldTrans);
                if(body.getRecordAnimation()) {
                    Transform t3d = new Transform();
                    myMotionState.getWorldTransform(t3d);
                    AnimationCache.record(body, t3d);
                }
           }
     }
       


1  
2  
3  
4  
5  
//This class save the animation's frameNumber and the current transformation
//AnimationCache class
public static void record(final CollisionObject collisionObject, final Transform worldTransform) {
        objects.get(collisionObject).add(new FrameInfo(frameCounter, worldTransform));
}


Then save the animation to a file on this format
pos.x pos.y pos.z quat.x quat.y quat.z quat.w

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public static void saveAnimation() throws IOException {
        final Iterator<CollisionObject> itObj = objects.keySet().iterator();
        while(itObj.hasNext()) {
            final CollisionObject collisionObject = itObj.next();
            final BufferedWriter output = new BufferedWriter(new FileWriter(".\\out\\" + collisionObject.getName() + ".dat"));
            output.write(collisionObject.getName() + "\n");
            output.write(objects.get(collisionObject).size() + "\n");
            for(final FrameInfo frameInfo : objects.get(collisionObject)) {
                final Transform t = frameInfo.getWorldTransform();
                final Quat4f quat = new Quat4f();
                t.getRotation(quat);
                String transformation = t.origin.x + " " + t.origin.y + " " + t.origin.z + " " + quat.x + " " + quat.y + " " + quat.z + " " + quat.w;
                output.write(/* frameInfo.getFrame() + " " + */transformation + " \n");

            }
            output.close();
        }
    }


And finally read everything from maxscript like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
while not eof f2 AND not errorState do (
         --Based on 6 items per line...will give screwy results if that is not the case
               
        object.pos.controller = bezier_position ()
   object.rotation.controller = bezier_rotation ()
               
   at time frameNumber object.pos.x = readValue f2
   at time frameNumber object.pos.z = readValue f2
   at time frameNumber object.pos.y = readValue f2
                 
   qt = quat (readValue f2) (readValue f2) (readValue f2) (readValue f2)
   at time frameNumber object.rotation = qt
)


And here is the snippet of the list generated by the jBullet implementation:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
-7.000207 2.9911888 2.999814 -4.107783E-4 -1.7762213E-5 4.1528684E-4 0.9999998 
-7.000335 2.9798827 2.9997628 -5.624294E-4 1.0352664E-5 5.876959E-4 0.99999964
-7.0012197 2.9665523 2.9996061 -0.0011199893 2.864436E-4 0.00124055 0.99999857
-7.004677 2.9636376 2.9993298 -0.0012620256 2.5463334E-4 7.622685E-4 0.99999887
-7.008398 2.967768 2.999191 -0.0017345948 4.2187166E-4 3.6495627E-4 0.99999833
-7.009858 2.9741921 2.9996693 -0.0017635843 3.577837E-4 4.8657088E-4 0.9999983
-7.0134134 2.9883368 3.001272 -0.0018693976 5.0782727E-4 2.7283697E-4 0.9999981
-7.014315 2.9899888 3.0029392 -0.0017539648 5.522331E-4 4.9749546E-4 0.99999815
-7.0163903 2.9918454 3.0063407 -4.3341625E-4 2.313659E-4 1.04258484E-4 0.9999999
-7.017004 2.9897406 3.008818 -3.0255402E-4 1.4276913E-4 7.255005E-4 0.99999964
-7.018611 2.987876 3.0144236 8.316229E-4 3.0872683E-4 0.0018217392 0.9999979
-7.018618 2.9887652 3.0165792 0.0014158944 2.9269894E-4 0.0022854072 0.99999636
-7.0169835 2.9905205 3.0216334 0.0020224128 2.823276E-4 0.0018376223 0.9999962
-7.0154414 2.9912636 3.022513 0.0020788629 3.1878965E-4 0.0013048297 0.9999969
-7.01305 2.9930182 3.02532 0.0021114894 2.6886715E-4 0.0010094913 0.9999972
-7.0108914 2.9941247 3.0269902 0.0020880918 4.7242292E-4 7.5766357E-4 0.99999744
-7.008967 2.9946783 3.0278869 0.0019483349 4.068205E-4 5.989755E-4 0.99999785
-7.0068746 2.9948816 3.0285518 0.0018824388 3.313562E-4 4.2963063E-4 0.99999803
-7.004844 2.9937909 3.028725 0.0021439963 2.1812133E-4 9.0445035E-5 0.9999977
-7.0037045 2.9930723 3.026589 0.0017745745 2.460887E-4 1.0532421E-4 0.9999984
-7.0023766 2.9934387 3.0235438 0.0014615756 2.557883E-4 -9.372302E-5 0.99999887
-7.0013795 2.9943132 3.0198746 0.0010445961 1.3627057E-4 1.0653105E-4 0.9999994
-6.9992614 2.9947402 3.0183303 6.200564E-4 6.1223796E-4 6.866971E-5 0.9999996
-6.9988275 2.9947445 3.019064 7.8080187E-4 3.2051373E-4 -3.2027478E-5 0.99999964


The position seems to be quite right but the rotation is jumpy.

What I am doing wrong? Is the frequency calling the stepSimulation method? I have to do something else with the quarternions before exporting?
3  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 2009-12-25 19:07:41
The only Demo I found is the MovingConcaveDemo(bunny thing) that reads a static array of vertices and faces indexes.

So I've been trying to write my own Model Loader based on that structure(vertices and indexes). The routing reads the data from a file generated from a maxscript exporter I wrote.
And it didn't worked.

The exception below just keep coming and I cannot figure it out.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
java.lang.IndexOutOfBoundsException
   at java.nio.Buffer.checkIndex(Buffer.java:520)
   at java.nio.DirectByteBuffer.getFloat(DirectByteBuffer.java:806)
   at com.bulletphysics.collision.shapes.ByteBufferVertexData.getVertex(ByteBufferVertexData.java:58)
   at com.bulletphysics.extras.gimpact.TrimeshPrimitiveManager.get_vertex(TrimeshPrimitiveManager.java:121)
   at com.bulletphysics.extras.gimpact.TrimeshPrimitiveManager.get_primitive_triangle(TrimeshPrimitiveManager.java:138)
   at com.bulletphysics.extras.gimpact.TrimeshPrimitiveManager.get_primitive_box(TrimeshPrimitiveManager.java:128)
   at com.bulletphysics.extras.gimpact.GImpactBvh.buildSet(GImpactBvh.java:127)
   at com.bulletphysics.extras.gimpact.GImpactShapeInterface.calcLocalAABB(GImpactShapeInterface.java:204)
   at com.bulletphysics.extras.gimpact.GImpactShapeInterface.updateBound(GImpactShapeInterface.java:71)
   at com.bulletphysics.extras.gimpact.GImpactMeshShape.calcLocalAABB(GImpactMeshShape.java:237)
   at com.bulletphysics.extras.gimpact.GImpactShapeInterface.updateBound(GImpactShapeInterface.java:71)
   at br.com.rsl.temp.ModelLoader.buildTriMesh(ModelLoader.java:45)


The data generated looks like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
6
0.0 -0.907649 0.419731
0.0 -0.907649 0.419731
0.0 -0.907649 0.419731
0.900354 0.0 0.435159
0.0 0.907649 0.419731
0.0 0.0 -1.0
8
1.0 2.0 3.0
1.0 3.0 4.0
1.0 4.0 5.0
1.0 5.0 2.0
2.0 6.0 3.0
3.0 6.0 4.0
4.0 6.0 5.0
5.0 6.0 2.0

6 vertices and 8 faces.
It's a simple piramid. A primitive in 3ds max.

It seems the problem is floating around the "vertex stride" thing. Which I am using the same value(4 * 3) from the bunny example: MovingConcaveDemo.java:111

Why is 4*3? And why the ByteBuffer objects are being created by multiplying the vertices and indexes by 4?
1  
ByteBuffer.allocateDirect(indexes.length * 4).order(ByteOrder.nativeOrder());


How can I determine an adaptive way to load my custom models?


Please help me.

And merry christmas to all of you.

Thank you.
4  Game Development / Game Mechanics / Re: Java port of Bullet Physics Library on: 2009-12-21 17:28:56
It's possible to load a custom model and use its mesh to run some simulations?

Thank you.
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (106 views)
2013-05-17 21:29:12

alaslipknot (114 views)
2013-05-16 21:24:48

gouessej (143 views)
2013-05-16 00:53:38

gouessej (139 views)
2013-05-16 00:17:58

theagentd (151 views)
2013-05-15 15:01:13

theagentd (135 views)
2013-05-15 15:00:54

StreetDoggy (179 views)
2013-05-14 15:56:26

kutucuk (202 views)
2013-05-12 17:10:36

kutucuk (203 views)
2013-05-12 15:36:09

UnluckyDevil (209 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.353 seconds with 21 queries.