Child Position??

Blitz3D Forums/Blitz3D Programming/Child Position??

TheMan(Posted 2003) [#1]
Hi, how can I get the real position of a Child entity, when I use Entityx#(),Entityy#() and Entityz#() command with the entity returned by getchild() it return the parent position. also how can I unattach child ??

Thanks


fredborg(Posted 2003) [#2]
EntityX(child,True) and EntityParent child,0 will do the trick...


TheMan(Posted 2003) [#3]
I tried those commands, and EntityX(child,true) still return 0.0 position which it is the parent position


GfK(Posted 2003) [#4]
Fredborg is correct, however, when you export to 3DS format from Milkshape (and probably some other modelling packages too), the axis of all children in the hierarchy is set to 0,0,0. Try rotating one of the children and see what happens. You'll no doubt see that the child is being rotated around the centre of the entire object.

So how do you get around this? No idea. :/ Maybe try exporting to a different format, or use different modelling software?


fredborg(Posted 2003) [#5]
Gimme da codes :) You must be doing something wrong...


TheMan(Posted 2003) [#6]
Fredborg idea works now, the child is no longer attached to the parent but its axis of rotation is the same as the previous parent!! so how I can get the real position of the object, and then shift the the rotation axis into the centre of the object..

thanks


TheMan(Posted 2003) [#7]
any idea guys ?!


Ken Lynch(Posted 2003) [#8]
The only way to get the centre is to calculate from the entity's vertices.

Add up all the X coords, divide by number of vertices to give the centre X.
Do the same for Y and Z.
Subtract these X,Y and Z values from all the vertices and then reposition the entity (locally) using the same X,Y and Z values.

I may have gone wrong in there somewhere, it's very early in the morning.

Of course, this only gives the average centre, which may not be what you want for some of the entities. It would be better to try and export the models in a different format that didn't recentre the children.


BHoltzman(Posted 2003) [#9]
I've got Deep Exploration, if you don't have too many models to translate then I may be able to help you with their translations.

Let me know if you're interested.

From,

Ben


Bot Builder(Posted 2003) [#10]
Using a similar method to Ken Lynch's, sometimes it's best to get minimum and maximum xyz, get the middle of this and apply a movemesh only with the result of the average inverted when you use it in movemesh.


TheMan(Posted 2003) [#11]
I will try to implement this today,