Author Topic: setOrientation of child Objects  (Read 2172 times)

Offline Dinin

  • byte
  • *
  • Posts: 28
    • View Profile
setOrientation of child Objects
« 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: setOrientation of child Objects
« Reply #1 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?

Offline Dinin

  • byte
  • *
  • Posts: 28
    • View Profile
Re: setOrientation of child Objects
« Reply #2 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 ?
« Last Edit: May 19, 2012, 09:27:33 pm by Dinin »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: setOrientation of child Objects
« Reply #3 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.