Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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]
 

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

The first screenshot will be displayed as a thumbnail.

pw (22 views)
2014-07-24 01:59:36

Riven (20 views)
2014-07-23 21:16:32

Riven (17 views)
2014-07-23 21:07:15

Riven (20 views)
2014-07-23 20:56:16

ctomni231 (48 views)
2014-07-18 06:55:21

Zero Volt (44 views)
2014-07-17 23:47:54

danieldean (35 views)
2014-07-17 23:41:23

MustardPeter (38 views)
2014-07-16 23:30:00

Cero (53 views)
2014-07-16 00:42:17

Riven (52 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!