Bekas
12-09-2006 01:55:56
When calculating the triangles, TreeCollision only takes into account the scale of the provided SceneNode not position/orientation. I would submit a patch but the fix is too trivial so I'm just reporting it.
HexiDave
12-09-2006 04:40:46
I'd imagine that's because when the scale command is used, it modifies the vertex data directly, so that it doesn't add an extra calculation each frame - however, position/orientation are transformations done per frame anyways and are based on the parent node - attaching the TreeCollision as a body to the same node as where the data originated should put it 1 for 1 position/orientation.
Bekas
12-09-2006 09:34:27
TreeCollision is used with static data like walls, you are not supposed to move a TreeCollision body; if you move it the vertices will be invalid.
walaber
12-09-2006 18:02:02
you are supposed to create a Body with the Tree Collision Object, and then call setPositionOrientation() on the Body with the position and orientation of the SceneNode you created it from.
Bekas
12-09-2006 19:11:22
Oops!
my mistake then, sorry.
The reason I got into this "TreeCollision doesn't follow SceneNode" is because to do a simple ray cast with OgreNewt without involving physics (ie. for object picking) you do it like this:
Vector3 startRay = camera.Position;
Vector3 endRay = startRay + camera.Direction * 1000;
MogreNewt.World newtonWorld = new World();
Collision col = new MogreNewt.CollisionPrimitives.TreeCollision(newtonWorld, objectNode, false);
Vector3 normal;
int colID;
float distance = MogreNewt.CollisionTool.CollisionRayCast(col, startRay, endRay, out normal, out colID);
So since CollisionRayCast accepts just the collision object, there's no way to apply transformation/translation to the triangles.
Should there be an additional boolean parameter to indicate that the TreeCollision should take into account Node's position/orientation or is there a better way?
[
edit] Ah, it's the ray that should get transformed and put into the local space of the collision, never mind..
[/
edit]