www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: thiamant on October 07, 2010, 07:48:15 pm

Title: Scaling objects dynamically
Post by: thiamant on October 07, 2010, 07:48:15 pm
I'm trying to scale a model dynamically when the model is already running and visible. Do I have to rebuild the object or something like that? After calling .scale() method the object disappears and I can only see the framebuffer empty (with the background colour).
Title: Re: Scaling objects dynamically
Post by: EgonOlsen on October 07, 2010, 08:44:06 pm
Then you are most likely using scale() wrong. Can you post some code?
Title: Re: Scaling objects dynamically
Post by: thiamant on October 07, 2010, 09:34:36 pm
Code: [Select]
object.disableLazyTransformations();
object.scale(1.5f);
object.enableLazyTransformations();

I do this in the onDraw method if certains conditions are met. This is done before this code:

Code: [Select]
fb.clear(skycolor);
world.renderScene(fb);
world.draw(fb);
Title: Re: Scaling objects dynamically
Post by: EgonOlsen on October 07, 2010, 09:36:35 pm
Remember that scale() is cummulative...try setScale() instead.
Title: Re: Scaling objects dynamically
Post by: thiamant on October 08, 2010, 10:56:01 pm
OK. I'm trying to use setScale and apparently it's scaling correctly. The problem is that I don't appreciate any distance increase from the center of the model. Imagine a theatre and the camera pointing to a door from the center of the theatre. When scaling the whole object the door should be seen far away but it's not. I've tried increasing the FOV but with higher values the optical effect is just too bad.

Any ideas about why this is happening and possible solutions? Maybe I'm just getting the concept wrong (scaling effect and such).
Title: Re: Scaling objects dynamically
Post by: EgonOlsen on October 08, 2010, 11:03:18 pm
Maybe you are looking at the center of the object, which doesn't change when scaling the whole thing around it? Or maybe the effect is just too subtle because the location in view already is pretty far away. Some screen shots might help to understand this better...
Title: Re: Scaling objects dynamically
Post by: K24A3 on September 29, 2011, 01:53:57 pm
I use Object3D.setScale() to rescale an object, but the mesh is not scaled with the object.

I realize that I can delete the object and reload it with the new scale value, but I would like to avoid that.

What function do I call to recreate the mesh on the fly based on the new scale?
(It doesn't matter if the function takes a second or two)
Title: Re: Scaling objects dynamically
Post by: EgonOlsen on September 29, 2011, 08:32:58 pm
It should be possible to abuse the rotateMesh-method for this. Set your scale, call rotateMesh(), set it back to 1.
Title: Re: Scaling objects dynamically
Post by: K24A3 on September 30, 2011, 10:08:49 am
rotateMesh() did the trick, thanks.