TreeCollision AccessViolationException with SceneNode

amennelet

10-09-2009 15:07:35

Hi,

I get an AccessViolationException when I create a body using a TreeCollision created with a SceneNode.

Vector3 railPosition = new Vector3(position.x, position.y - 0.7f, position.z);
RailEntity = LocalSceneManager.CreateEntity("Rail" + this.GetHashCode().ToString(), "RailTapis.mesh");
RailSceneNode = LocalSceneManager.RootSceneNode.CreateChildSceneNode(railPosition);
RailSceneNode.AttachObject(RailEntity);
RailSceneNode.SetScale(sizeSection);

MogreNewt.CollisionPrimitives.TreeCollision railColl = new MogreNewt.CollisionPrimitives.TreeCollision(world, RailSceneNode, true);
// AccessViolationException
MogreNewt.Body railBody = new MogreNewt.Body(world, railColl);
railColl.Dispose();
railBody.AttachToNode(RailSceneNode);
railBody.SetPositionOrientation(railPosition, Quaternion.IDENTITY);


If I use the Entity it's working fine (except that I can't scale the collision according to the scene node size).
Is anybody encounter the same problem, or am I doing something wrong?

Alex

GantZ

10-09-2009 17:49:24

just test it, i got the same error. which version of Mogrenewt do you use ? (i use the 2.0 version)

as a work around, it usually better to use the treecollisionsceneparser (work the same way that a regular collision object, apart the fact that you need to call parsescene before affect it to a body)

by a first glance at the code, it seem that there is some deprecated, redundant code in the treecollision class, i will see how to fix that later. thanks for the report.

amennelet

10-09-2009 18:32:09

I use the 1.4.8 version.

It works with the TreeCollisionSceneParser.
I've tried the TreeCollision on another object, and I get no gravity at all... and an AccessViolationException is throw on the application shutdown.

anyway thank you for your help.
Alex

GantZ

10-09-2009 19:43:19

I've tried the TreeCollision on another object, and I get no gravity at all

it is the expected behavior, Treecollision only work for static object, from the newton doc :

When a TreeCollision is assigned to a body the mass of the body is ignored in all dynamics calculations. This makes the body behave as a static body.

http://newtondynamics.com/wiki/index.php5?title=Collision_primitives

amennelet

11-09-2009 08:18:35

Yes, I've read that after my post.

Thank you.
Alex