Setting entity position of a mesh

Blitz3D Forums/Blitz3D Beginners Area/Setting entity position of a mesh

Shifty Geezer(Posted 2005) [#1]
Is there anyway to set the entity position of a mesh when you've used functions like PositionMesh? Say I create a cube mesh at (0,0,0) and move it to (10,10,10), if I create another box and parent it to cube mesh and then use MoveEntity (cube_mesh,5,5,5), the child box is positioned (-10,-10,-10) from the parent mesh.

Ideally if I use PositionMesh() the entity position will be updated also. I can't use PositionEntity as I'm using ODE's mesh collision and need the vertices moved.


Andy(Posted 2005) [#2]
http://www.blitzbasic.co.nz/b3ddocs/command.php?name=PositionMesh&ref=comments


Andy


Shifty Geezer(Posted 2005) [#3]
I don't think you understand. I already use PositionMesh to move my vertices, but that doesn't update the Entity's position. Another example...

box=CreateCube() ; creates a cube at 0,0,0
PositionEntity box,5,10,15
a=EntityX(box)
b=EntityY(box)
c=EntityZ(box)

After this, a=5, b=10, c=15. Now if I try...

box=CreateCube() ; creates a cube at 0,0,0
PositionMesh box,5,10,15
a=EntityX(box)
b=EntityY(box)
c=EntityZ(box)

a, b and c = 0.

I want a way to set the entity's position the same amount I move the mesh, while keeping the mesh inthe same place I move it with PositionMesh, so that in the above example a=5, b=10, c=15 after the PositionMesh()


Ross C(Posted 2005) [#4]
Only way to do this really, is have a pivot and move that at the same time as the mesh. MoveEntity and PositionEntity move the actual entity/meshes axis. So, move a pivot at the same time as the mesh is all i can think of...


DH(Posted 2005) [#5]
Ross is correct.

Moving the mesh keeps the Global position of the mesh the same and merely translates the geometry.

To get around this you have to keep track of this yourself. Either have the entity refferenced in a type list and alter it's fields to where you moved the mesh to, or use pivots and move the pivot so it can keep a 'record' of where the mesh is at.