Author Topic: setScale doesn't seem to work for serialized objects.  (Read 7968 times)

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
setScale doesn't seem to work for serialized objects.
« on: March 05, 2012, 11:10:50 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: setScale doesn't seem to work for serialized objects.
« Reply #1 on: March 05, 2012, 11:19:28 pm »
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?

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: setScale doesn't seem to work for serialized objects.
« Reply #2 on: March 05, 2012, 11:40:09 pm »
Ok, I'll create one now.

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: setScale doesn't seem to work for serialized objects.
« Reply #3 on: March 06, 2012, 12:04:24 am »
Odd new problem when I leave out 'build' method it crashes. Its mostly your helloworld example, but just loading the stadium model.

Quote
03-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.
« Last Edit: March 06, 2012, 12:06:20 am by zammbi »

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: setScale doesn't seem to work for serialized objects.
« Reply #4 on: March 06, 2012, 12:14:28 am »
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.
Code: [Select]
Object3D.mergeObjects(ground, model);
How do I keep the scale when I merge? There is no scaleMesh method that I can see.
« Last Edit: March 06, 2012, 04:51:11 am by zammbi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: setScale doesn't seem to work for serialized objects.
« Reply #5 on: March 06, 2012, 07:00:48 am »
You can use rotateMesh() for this. It also applies the scale, because the scale is part of that matrix.

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: setScale doesn't seem to work for serialized objects.
« Reply #6 on: March 06, 2012, 07:27:46 am »
Quote
You 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: setScale doesn't seem to work for serialized objects.
« Reply #7 on: March 06, 2012, 08:14:52 pm »
I hope that crash helps.
Which version of jPCT is that? Object3D don't even have this line:

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

 :o

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: setScale doesn't seem to work for serialized objects.
« Reply #8 on: March 06, 2012, 08:46:28 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: setScale doesn't seem to work for serialized objects.
« Reply #9 on: March 06, 2012, 08:48:29 pm »
Yes, that would help...

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: setScale doesn't seem to work for serialized objects.
« Reply #10 on: March 06, 2012, 09:32:20 pm »
Basically the same, but different line numbers.

Quote
03-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)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: setScale doesn't seem to work for serialized objects.
« Reply #11 on: March 06, 2012, 10:04:34 pm »
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.

Offline zammbi

  • float
  • ****
  • Posts: 361
    • View Profile
Re: setScale doesn't seem to work for serialized objects.
« Reply #12 on: March 06, 2012, 10:28:55 pm »
No longer crashes  :)