Global child positions

Blitz3D Forums/Blitz3D Programming/Global child positions

Ross C(Posted 2008) [#1]
I'm having a problem with loading in an animatedb3d purely so i can use find childto get the various pieces of the model. I have a turret cannon as on of the children, BUT, it's global position is the same the centre of the combined mesh, because the mesh has been offset.

So, finding entityx() etc etc, gives me 0,0,0
Using entityx()+TRUE flag, gives me the 0,0,0 of the combined mesh. Basically 0,0,0 if i just load it in.

Problem is my turrent as i said, it offset from the 0,0,0, so any attempts to rotate it, cause the centre of rotation to be at 0,0,0 of the comined mesh locally, instead of rotating using the centre of the geometry.

The only way round this i can see is:

Run through all the vertices, and get the centre point in local co-ords from that.
FitMesh around the 0,0,0 locally.
The PositionEntity at the centre co-ords i found.

Is there an easier way?


Dreamora(Posted 2008) [#2]
Well, yes: Deparent the turrent, use movemesh to offset it from its 0,0,0 again, reparent it to the tank or whatever it is.
That if it is pure mesh

Simpler: use bones, attache the turrent to a bone and findchild the bone (can be freefloating) and rotate that one :)


Moraldi(Posted 2008) [#3]
Due to my poor English I am not sure if got your problem but here is my advice:
Try to construct the model during loading time:
1. Load the base mesh
2. Create a pivot (in the position you like)
3. Load the turret cannon parented to the pivot
etc.
In this way you can rotate the turret by rotating the pivot...


Ross C(Posted 2008) [#4]
I'd like to avoid using pivots if possible :o)

Sounds like a better idea dreamora :o) Get the centre point in local space. Movemesh by that amount, moveentity by the negative of that amount.

Thanks guys :o)