[ODE] Re: ode to directx coordinates and orientation

Ivan Bolcina ivan.bolcina at volja.net
Tue Oct 22 02:03:01 2002


Hi,slipch.


Thank you VERY much.  It works great.
So for anyone interested, here is transformation from ODE quaternion to
DirectX's.

D3DXQUATERNION convertQuaternion(const dReal *in)
{
   D3DXQUATERNION out;
  out.x=(float)in[1];
  out.y=(float)in[2];
  out.z=(float)in[3];
  out.w=(float)in[0];
  return out;
}



Ukraine is actually very near slovenia. Slovenia, Hungary, Ukraine.
Najlepsa hvala se enkrat in uzivaj se naprej. Lep pozdrav,ivan.


----- Original Message -----
From: "slipch" <slipch@gsc-game.kiev.ua>
To: "Ivan Bolcina" <ivan.bolcina@volja.net>
Sent: Tuesday, October 22, 2002 9:40 AM
Subject: Re: ode to directx coordinates and orientation


> Hello Ivan,
>
> Monday, October 21, 2002, 10:13:36 PM, you wrote:
>
> IB> //from ode to directx
> IB> D3DXVECTOR3 convertVector(const dReal *in)
> IB> {
> IB> D3DXVECTOR3 out;
> IB> out.x=in[0];
> IB> out.y=in[1];
> IB> out.z=in[2];
> IB> return out;
> IB> }
>
> IB> //from ode to directx
>
> IB> D3DXQUATERNION convertQuaternion(const dReal *in)
> IB> {
> IB> D3DXQUATERNION out;
> IB> out.x=(float)in[0];
> IB> out.y=(float)in[1];
> IB> out.z=(float)in[2];
> IB> out.w=-(float)in[3];
> IB> return out;
> IB> }
>
>
> IB> So ODE is doing steps on objects and then I need to display it with
directx in corrent position and orientation. Position seem to be ok, but
orientation.....
>
> IB> btw, I see you are professional game developer. How does it feel like?
>     I am doing my best to be it but I am only in the start :).
>     I translate DirectX transforms to ode and vise versa and
>     everything works right (As I already tell you it need to transpose
DirectX matrix before
>     set it as ODE rotation matrix.). But I have never translate
>     Quaternion.
>     Following DirectX doc quaternion is
>
>     q.x = sin(theta/2) * axis.x
>     q.y = sin(theta/2) * axis.y
>     q.z = sin(theta/2) * axis.z
>     q.w = cos(theta/2)
>
>     From ODE doc:
>
>     A quaternion is four numbers [cos(theta/2) sin(theta/2)*u]
>     where theta is a rotation angle and `u' is a unit length rotation
axis.
>
>     May be the problem in sequence cos(theta/2) - last in DIrectX and
>     first in ODE.  Then
>
>  D3DXQUATERNION convertQuaternion(const dReal *in)
>  {
>  D3DXQUATERNION out;
> out.x=(float)in[1];
> out.y=(float)in[2];
> out.z=(float)in[3];
> out.w=(float)in[0];
> return out;
> }
>
> IB> Lep pozdrav in dobro se imej tam v mrzli Rusiji. :-)
>     It is nearly understandable.
>     I am from Ukraine indeed.
>
>     Nashi najkrashi pobazsannya! :)
>
>
> --
> Best regards,
>  slipch                            mailto:slipch@gsc-game.kiev.ua
>