WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Changing parent without changing absolute global position? (https://forum.worldviz.com/showthread.php?t=5044)

The SundanceKid 05-21-2014 01:45 PM

Changing parent without changing absolute global position?
 
Hi,

I'm trying to set an object's parent without changing its global absolute position.

Whenever I set the object's parent, its position resets to [0, 0, 0] on its parent's relative coordinate system (its position becomes the same as its parents position).

How do I get around this? I have tried many things, such as finding the object's position on the absolute global coordinate system, setting the object's parent, and then setting the object's position back to the one I found earlier. This doesn't seem to work.

Another seemingly easy way to do this would be to find the object's position relative to its soon-to-be parent's position, but I can't do this because they are not in the same hierarchy—I have to subtract both positions on the absolute global coordinate system. Then, of course, I set the object's parent and move it back to the correct position that I just went through the work of finding.

All of these ways don't work.

How do I set and object's parent without changing it's global position?

farshizzo 05-21-2014 02:04 PM

Getting the global position before re-parenting and restoring it after should work. Can you post the code you are using?

The SundanceKid 05-23-2014 02:43 PM

Quote:

Originally Posted by farshizzo (Post 16115)
Getting the global position before re-parenting and restoring it after should work. Can you post the code you are using?

I have done this and it restores the position correctly, but it appears that the object is no longer parented to the correct one anymore. After restoring the position it appears that the object is parented to the world, rather than the object I want it to be parented to.

I'm sorry, but I am not allowed to post any of the code.

Thanks for the help.


All times are GMT -7. The time now is 08:21 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC