setScale doesn't seem to work for serialized objects.

Started by zammbi, March 05, 2012, 11:10:50 PM

Previous topic - Next topic

zammbi

I was converting one of my models from 3ds to a serialized object with jBush. Basically just a simple swap but setScale in my code doesn't seem to work(works fine for the 3ds model). I even scaled it in jBush also but that had no effect.

Is this some kind of bug or am I missing something?

EgonOlsen

setScale() just modifies the rotation matrix. I don't see why this shouldn't work on serialized objects...it actually has nothing to do with the way the object has been created!? Can you create a test case for this?


zammbi

Odd new problem when I leave out 'build' method it crashes. Its mostly your helloworld example, but just loading the stadium model.

Quote03-06 12:00:10.842: I/jPCT-AE(3523): [ 1330988410844 ] - WARNING: There's a problem with the object list not being consistent during rendering. This is often caused by concurrent modification of jPCT objects on a thread different from the rendering thread!
03-06 12:00:10.842: I/jPCT-AE(3523): [ 1330988410846 ] - ERROR: java.lang.NullPointerException
03-06 12:00:10.842: I/jPCT-AE(3523):    at com.threed.jpct.Object3D.transformVertices(Object3D.java:6316)
03-06 12:00:10.842: I/jPCT-AE(3523):    at com.threed.jpct.World.renderScene(World.java:1105)
03-06 12:00:10.842: I/jPCT-AE(3523):    at com.threed.jpct.example.HelloWorld$MyRenderer.onDrawFrame(HelloWorld.java:251)
03-06 12:00:10.842: I/jPCT-AE(3523):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1127)
03-06 12:00:10.842: I/jPCT-AE(3523):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:975)
03-06 12:00:10.862: W/dalvikvm(3523): threadid=43: thread exiting with uncaught exception (group=0x2aaca408)
03-06 12:00:10.862: E/AndroidRuntime(3523): Uncaught handler: thread GLThread 22 exiting due to uncaught exception
03-06 12:00:10.862: E/AndroidRuntime(3523): java.lang.RuntimeException: [ 1330988410846 ] - ERROR: java.lang.NullPointerException
03-06 12:00:10.862: E/AndroidRuntime(3523):    at com.threed.jpct.Object3D.transformVertices(Object3D.java:6316)
03-06 12:00:10.862: E/AndroidRuntime(3523):    at com.threed.jpct.World.renderScene(World.java:1105)
03-06 12:00:10.862: E/AndroidRuntime(3523):    at com.threed.jpct.example.HelloWorld$MyRenderer.onDrawFrame(HelloWorld.java:251)
03-06 12:00:10.862: E/AndroidRuntime(3523):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1127)
03-06 12:00:10.862: E/AndroidRuntime(3523):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:975)
03-06 12:00:10.862: E/AndroidRuntime(3523):    at com.threed.jpct.Logger.log(Logger.java:189)
03-06 12:00:10.862: E/AndroidRuntime(3523):    at com.threed.jpct.Logger.log(Logger.java:148)
03-06 12:00:10.862: E/AndroidRuntime(3523):    at com.threed.jpct.World.renderScene(World.java:1121)
03-06 12:00:10.862: E/AndroidRuntime(3523):    at com.threed.jpct.example.HelloWorld$MyRenderer.onDrawFrame(HelloWorld.java:251)
03-06 12:00:10.862: E/AndroidRuntime(3523):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1127)
03-06 12:00:10.862: E/AndroidRuntime(3523):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:975)
03-06 12:00:10.872: I/dalvikvm(3523): threadid=7: reacting to signal 3
03-06 12:00:10.882: I/dalvikvm(3523): Wrote stack trace to '/data/anr/traces.txt'

Eclipse project: http://www.mediafire.com/?8eaklsygi06jnp1

However it seems it scales fine in this example which is annoying... So trying to figure out what's the difference.

zammbi

Ok found where the problem happens.

It's when I merge the object. It removes the scale, your right it has nothing to do with serialized objects.
Object3D.mergeObjects(ground, model);

How do I keep the scale when I merge? There is no scaleMesh method that I can see.

EgonOlsen

You can use rotateMesh() for this. It also applies the scale, because the scale is part of that matrix.

zammbi

QuoteYou can use rotateMesh() for this. It also applies the scale, because the scale is part of that matrix.
Ah thanks.
I hope that crash helps.

EgonOlsen

Quote from: zammbi on March 06, 2012, 07:27:46 AM
I hope that crash helps.
Which version of jPCT is that? Object3D don't even have this line:


at com.threed.jpct.Object3D.transformVertices(Object3D.java:[b]6316[/b])


:o

zammbi

That was the current link on the site and just editing the example. However it did crash the beta version also. Do you want the stack trace of that one?

EgonOlsen


zammbi

Basically the same, but different line numbers.

Quote03-07 09:36:10.628: I/jPCT-AE(8844): OpenGL vendor:     Qualcomm
03-07 09:36:10.628: I/jPCT-AE(8844): OpenGL renderer:   Adreno 200
03-07 09:36:10.628: I/jPCT-AE(8844): OpenGL version:    OpenGL ES-CM 1.1
03-07 09:36:10.628: I/jPCT-AE(8844): OpenGL renderer initialized (using 2 texture stages)
03-07 09:36:10.638: I/jPCT-AE(8844): Adding Lightsource: 0
03-07 09:36:10.648: I/jPCT-AE(8844): Loading Texture...
03-07 09:36:10.648: I/jPCT-AE(8844): Loading Texture...
03-07 09:36:11.088: I/jPCT-AE(8844): Loading Texture...
03-07 09:36:11.278: I/jPCT-AE(8844): Normal vectors calculated in 2ms!
03-07 09:36:11.378: I/jPCT-AE(8844): Memory usage before compacting: 7763 KB used out of 8135 KB. Max. memory available to the VM is 24576 KB.
03-07 09:36:11.658: I/jPCT-AE(8844): Memory usage after compacting: 7749 KB used out of 8135 KB. Max. memory available to the VM is 24576 KB.
03-07 09:36:11.658: I/jPCT-AE(8844): Saving master Activity!
03-07 09:36:11.668: I/jPCT-AE(8844): Subobject of object 0/object2 compiled to flat fixed point data using 48 vertices in 3ms!
03-07 09:36:11.668: I/jPCT-AE(8844): Object 0/object2 compiled to 1 subobjects in 9ms!
03-07 09:36:11.668: I/jPCT-AE(8844): Object 'object2' uses one texture set!
03-07 09:36:11.678: I/jPCT-AE(8844): [ 1331066171678 ] - WARNING: There's a problem with the object list not being consistent during rendering. This is often caused by concurrent modification of jPCT objects on a thread different from the rendering thread!
03-07 09:36:11.678: I/jPCT-AE(8844): [ 1331066171685 ] - ERROR: java.lang.NullPointerException
03-07 09:36:11.678: I/jPCT-AE(8844):    at com.threed.jpct.Object3D.transformVertices(Object3D.java:5783)
03-07 09:36:11.678: I/jPCT-AE(8844):    at com.threed.jpct.World.renderScene(World.java:1047)
03-07 09:36:11.678: I/jPCT-AE(8844):    at com.threed.jpct.example.HelloWorld$MyRenderer.onDrawFrame(HelloWorld.java:267)
03-07 09:36:11.678: I/jPCT-AE(8844):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332)
03-07 09:36:11.678: I/jPCT-AE(8844):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
03-07 09:36:11.698: W/dalvikvm(8844): threadid=8: thread exiting with uncaught exception (group=0x40020ac0)
03-07 09:36:11.728: E/AndroidRuntime(8844): FATAL EXCEPTION: GLThread 9
03-07 09:36:11.728: E/AndroidRuntime(8844): java.lang.RuntimeException: [ 1331066171685 ] - ERROR: java.lang.NullPointerException
03-07 09:36:11.728: E/AndroidRuntime(8844):    at com.threed.jpct.Object3D.transformVertices(Object3D.java:5783)
03-07 09:36:11.728: E/AndroidRuntime(8844):    at com.threed.jpct.World.renderScene(World.java:1047)
03-07 09:36:11.728: E/AndroidRuntime(8844):    at com.threed.jpct.example.HelloWorld$MyRenderer.onDrawFrame(HelloWorld.java:267)
03-07 09:36:11.728: E/AndroidRuntime(8844):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332)
03-07 09:36:11.728: E/AndroidRuntime(8844):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
03-07 09:36:11.728: E/AndroidRuntime(8844):    at com.threed.jpct.Logger.log(Logger.java:189)
03-07 09:36:11.728: E/AndroidRuntime(8844):    at com.threed.jpct.Logger.log(Logger.java:148)
03-07 09:36:11.728: E/AndroidRuntime(8844):    at com.threed.jpct.World.renderScene(World.java:1062)
03-07 09:36:11.728: E/AndroidRuntime(8844):    at com.threed.jpct.example.HelloWorld$MyRenderer.onDrawFrame(HelloWorld.java:267)
03-07 09:36:11.728: E/AndroidRuntime(8844):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332)
03-07 09:36:11.728: E/AndroidRuntime(8844):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)

EgonOlsen

I think that i've fixed this. Please re-download the beta jar and give it a try. I've obviously never tested this combination...it doesn't happen if you load the model from a file or call either build() or compile() on a deserialized one.