[BloodyMess] PlaneGeometry Rotation

ironwolf151

10-05-2009 20:01:59

Hi all,

I have a problem to rotate a planegeometry.
I have this :

this->_Ground = this->_NxScene->createSceneGeometry(new NxOgre::PlaneGeometry(0, NxOgre::Real3(0, 1, 0)), NxOgre::Matrix44(NxOgre::Matrix44::IDENTITY));


But i don't know how i can rotate it , i looked in the documentation but i didn't find anything.
I found how to rotate an OGRE3DBody , but i don't know to rotate a NxOgre::SceneGeometry.
So i tried to do something else , but i obtain an error when i launch the application :

this->_RenderSystem->createBody(new NxOgre::PlaneGeometry(0, NxOgre::Real3(0, 1, 0)), NxOgre::Real3(0, 0, 0), "plane.mesh");

And the error is locate in the method : extern inline Matrix44 getGlobalPose(NxActor* actor)

extern inline Matrix44 getGlobalPose(NxActor* actor)
{
Matrix44 matrix;
actor->getGlobalPose().getRowMajor44(matrix.ptr()); // get method return NULL.
return matrix;
}


So , how can i create and rotate a Plane please ?

Thanks

betajaen

10-05-2009 20:04:44

Just change the normal (direction the plane is facing).

new NxOgre::PlaneGeometry(0, NxOgre::Real3(1, 0, 0))

Or just change the pose of the actor (the matrix at the end of the create function)

But do not put it in a Body; Geometry shapes stay in Scene Geometries.

ironwolf151

10-05-2009 20:07:32

Okay, but the problem is that i don't want to rotate it at the creation but during the game.
Indeed i would like to rotate it when i mouve the mouse for example.

That's why i looked for a method to rotate it :s

betajaen

10-05-2009 21:10:50

You really can't rotate it after it's been created. It's static, it cannot be changed.

What are you trying to do? Perhaps I can come up with an alternate

ironwolf151

10-05-2009 21:17:32

I'm working on a game like Kororinpa.
The gameplay is simple, we played a ball in a labyrinth.
But to move the ball the player rotate the world , so if the player rotate the world on the left , the ball will roll on the left.

That's why i'm looking to rotate the plane.

betajaen

10-05-2009 21:20:40

Oh that's just easy; You can fake it by changing gravity and modifying the "background" meshes so they rotate. So it looks like the maze is rotating when it's not.

ironwolf151

10-05-2009 21:23:40

Ok i see, i'll try it.

thanks ;)

ironwolf151

13-05-2009 00:13:09

Hi,

I tried the solution you gave me.
But i have 2 problems , the first one is a mathematic problem , so i'll find it i hope.
Indeed , to set a good gravity i need to find the good equation , because i have a rotation angle on the axis x and z.
So depending on the angle i have to set the gravity on each axis.

With a little calcul i obtain this result : gravity = (9.8 * cos (90 - angle)) / cos(angle)
But this is incorect.
This is the first problem , but i think i forgot a little thing.

And the second problem is with the setGravity method.
Sometimes when i set a gravity , nothing change , like if there war an error when i set the gravity.
For example when i set the gravity with theses values : Real3( -2.141*10^-7 , -9.8 , 0); (it is just test values).
I obtain this screen where we can see a red box on the sphere. So i conclued my values are wrong , but why ?

Moreover if i set the first value at 1 and not -2.141... there are no problems , the red box don't appear and the ball move.

So , if there is a easier method to calcul the gravity depending the angle what is it please ?
And why sometimes a red box appear in the sphere and so the gravity don't work ?

Thanks

betajaen

13-05-2009 00:31:59

You may have better results with multiplying the vector with a quaternion, something along the lines of;

Real3 v(1,1,1);
Quaternion q(1,0,0,0); // you fill this in.
Real grav = v * q;
grav.normalise(); // may not be needed.
grav *= -9.8f


Your Actor may have fallen asleep, wake it up and see what happens.