move/rotate Mesh problem

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
madball
Posts: 2
Joined: Fri Oct 24, 2008 7:05 pm

move/rotate Mesh problem

Post by madball »

Hi,

first I like to say that I really like the bepu engine and that the samples are a very big help ,

here my problem, I need to rotate a nonDynamic entity "ingame" that I want to use as part of a 3D menu. At the moment I use/modify code of the samples of the 0.6.2 version. First I wanted to use a rotation matrix but that didn't work, and now I had the idea to use the box.rotate function to rotate my entity with it.

My Code :

startSimulation(int sim):

Box entitybox = new Box(new Vector3(0, 0, 0), 1.5f, 1.5f, 1.5f);

entityRenderer.displayModels.Add(new DisplayModel(entity, entitybox));

space.add(entitybox);



at the Update method:

if (mouse is over entitybox and press left mouse button)
{

entitybox.rotate(new Vector3(0, 30, 0));
}

the problem is that if the raycast hits the entitybox, a error System.NullReferenceException occurs.

Now it would be great if somebody could give me a hint or a better solution to rotate my mesh/entity. Sorry for my rusty english, I hope my post is understandable.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: move/rotate Mesh problem

Post by Norbo »

In what way did the entity.orientationMatrix property not work? You could also try the entity.orientationQuaternion.

For the null reference, it looks like you are accidently creating a local Entity variable in your startSimulation method with the same name as your class level variable. The method's scope will use the method's version of the variable, so the class level variable never gets set and stays null.
madball
Posts: 2
Joined: Fri Oct 24, 2008 7:05 pm

Re: move/rotate Mesh problem

Post by madball »

hooray, suddenly it works now with the entity.orientationQuaternion, thank you Norbo
Post Reply