Scaling objects dynamically

Started by thiamant, October 07, 2010, 07:48:15 PM

Previous topic - Next topic

thiamant

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).

EgonOlsen

Then you are most likely using scale() wrong. Can you post some code?

thiamant

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:

fb.clear(skycolor);
world.renderScene(fb);
world.draw(fb);

EgonOlsen

Remember that scale() is cummulative...try setScale() instead.

thiamant

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).

EgonOlsen

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...

K24A3

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)

EgonOlsen

#7
It should be possible to abuse the rotateMesh-method for this. Set your scale, call rotateMesh(), set it back to 1.

K24A3

rotateMesh() did the trick, thanks.