Author Topic: Child object transformation  (Read 3396 times)

Offline CarlosMB89

  • byte
  • *
  • Posts: 15
    • View Profile
Child object transformation
« on: July 22, 2015, 03:25:45 pm »
Hello Olsen

My doubt is about world transformation matrix of child objects 3D.

I want to add an object (objectChild) with a specific orientation and position to another object (objectParent) which has been rotated and translated in the world space. My problem is that when I add my objectChild to the objectParent, the current position and orientation of the objectChild changes due to the tranformationMatrix of the objectParent.

Is there any way to add the objectChild and  doesn't change its position and orientation at the moment of adding it to the parent??

Thanks in advance.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Child object transformation
« Reply #1 on: July 22, 2015, 04:06:35 pm »
That's the whole point of creating child/parent relations between objects. Why do you want to add an object child but don't apply the parent's transformations to it?

Offline CarlosMB89

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Child object transformation
« Reply #2 on: July 22, 2015, 04:32:34 pm »
My case is that I have a robot with 6 articulation (objects) and each object is child of the previous one, so if I move one articulation the rest of the objects will move too.

What I want to do is to add an object to the end articulation(object), so it will move with the rest of articulations.

My problem is that when I add that object as a child of the end articulation, it is placed to another position and orientation different of the previous it  had before being added.

I don,t know how to avoid it.

Thanks

Offline CarlosMB89

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Child object transformation
« Reply #3 on: July 22, 2015, 04:37:29 pm »
I want that when I add an object to the end articulation, it will be drawn with the previous orientation and in the center of the end articulation.

Offline Gatobot14

  • int
  • **
  • Posts: 64
    • View Profile
Re: Child object transformation
« Reply #4 on: July 22, 2015, 05:16:42 pm »
why dont use bones?? using parent/child you have to position very careful your objects to get the desire rotations/tranlations,
with bones you only have to get the joint and move it

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Child object transformation
« Reply #5 on: July 22, 2015, 11:36:06 pm »
You could try to move your objects into position, then do something like

Code: [Select]
obj.translateMesh();
obj.rotateMesh();
obj.clearRotation();
obj.clearTranslation();
obj.build();

However, this also affects the rotation pivot and the center, so you might have to adjust these as well. But apart from that, I'm not sure why you have this problem in the first place. Maybe it helps to reverse the process, i.e. create all your child/parent relations and then move the objects to their position started with the first in the hierarchy and working your way down.

Offline CarlosMB89

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Child object transformation
« Reply #6 on: July 24, 2015, 11:00:01 am »
Thanks Egon

I reversed the position to the initial one and I add the new object. It worked.

Thanks