Horde3D

Next-Generation Graphics Engine
It is currently 08.04.2025, 19:39

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: ODE rotations problem
PostPosted: 16.06.2008, 15:54 
Offline

Joined: 09.05.2008, 19:02
Posts: 18
I am attempting to use ODE physics and Horde3D but am having considerable problems with orientating the object within the world.

Code:
// get the possition, offset of bounding box and orientation
    SGZVECTOR pos = ODEWorld->getPos(odeIndex);
    SGZVECTOR offset = ODEWorld->getOffset(odeIndex);
    const float* q = ODEWorld->getQuaternion(odeIndex);

// create matrix's
    Matrix4f mat = Matrix4f();
    Matrix4f qMat(q);

// perform matrix concatination
    mat.translate(-offset.x, -offset.y, -offset.z);
    mat = mat * qMat;
    mat.translate(pos.x, pos.y, pos.z);

// place object
    bool temp = Horde3D::setNodeTransformMatrix(  (NodeHandle)lua_tonumber(Lua, 1), mat.x);

there are very weird effects of the objects appearing to scale in iratic fashions though without the quaternian matrix being taken into acount the objects are placed correctly


Top
 Profile  
Reply with quote  
PostPosted: 16.06.2008, 20:08 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
There seems to be a problem in your code. ODEWorld->getQuaternion probably returns a 4-tuple of floats. Matrix4f has a constructor that takes a float pointer but it expects a linearized matrix with 16 floats. You should probably init an instance of the Quaternion class with the 4 values you get from ODE and feed that to a Matrix4f constructor.


Top
 Profile  
Reply with quote  
PostPosted: 17.06.2008, 10:35 
Offline

Joined: 09.05.2008, 19:02
Posts: 18
That was indead my problem, long day with stuff not working makes you blind to the obvious


Top
 Profile  
Reply with quote  
PostPosted: 19.06.2008, 16:30 
Offline

Joined: 09.05.2008, 19:02
Posts: 18
Also anyone wanting to take note the quaternions thrown out of ode are in order w,x,y,z and the quaternions in horde are x,y,z,w this along with having to perform the matrix concatination in the order mat = q*mat.

These got me as well so thought i would share for others in future


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 48 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group