www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Dinin on May 19, 2012, 07:39:50 pm

Title: setOrientation of child Objects
Post by: Dinin on May 19, 2012, 07:39:50 pm
Hi !

I'm trying to make a Object3D always facing away from Camera.
So i do:
Code: [Select]
object.SetOrientation(camera.getDirection(), camera.getUpVector())
this works fine, but when i add this object as child to a parentobject this doesn't work any more.

Any suggestions ?

thx and greeds
Dinin
Title: Re: setOrientation of child Objects
Post by: EgonOlsen on May 19, 2012, 08:51:48 pm
Don't add it as a child then... ;) The setOrientation()-method works on the local rotation matrix of the object. It can't take the rotation of it's parents into account. What's the reason why you want to make this object a child of some other?
Title: Re: setOrientation of child Objects
Post by: Dinin on May 19, 2012, 09:13:39 pm
Because it should 'follow' this object.
So that the translations of the parentobject affect also this object and the child object remains exactly on this position 'on' the parentobject.

btw. is it possible to addChild without changing the translation of the childobject ?
Title: Re: setOrientation of child Objects
Post by: EgonOlsen on May 19, 2012, 11:57:35 pm
In that case, you might want to ad your parent/child relation by hand in your own code. The way the engine does it, the complete transformations of the parent will be executed on the child. This doesn't seem to be what you want.