[fixed]Matrix question

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
kaos
Posts: 155
Joined: Tue Aug 12, 2008 8:25 pm
Location: Spain

[fixed]Matrix question

Post by kaos »

I have a trasformation matrix and viewmatrix in opengl for one program in .net with opentk

I copy all values of this matrix

Copy projection matrix

Copy world matrix

view matrix indentity( opengl work 2 )

then driver->set projection
driver-> set view
dricer-> set world

drawmesbuffer

and the result are very very diferent ¿what I'm doing worng?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Matrix question

Post by hybrid »

Irrlicht uses a left-handed coord system, while opengl uses a right-handed one by default. I'm not sure if you captured all necessary setup for using the right-handed matrices with default Irrlicht rendering methods.
kaos
Posts: 155
Joined: Tue Aug 12, 2008 8:25 pm
Location: Spain

Re: Matrix question

Post by kaos »

No, I think that no. Thanks,

But I have other question, matrix multiplication have diferents values than other librarie's matrix(small but exist). ¿there are any method of optimization in core ?
kaos
Posts: 155
Joined: Tue Aug 12, 2008 8:25 pm
Location: Spain

Re: Matrix question

Post by kaos »

I found the problem, this functions would can put in matrix.h

Code: Select all

        template <class T>
        inline CMatrix4<T>& CMatrix4<T>::setRotationAxisLH( const T& angle, const vector3d<T>& axis )
        {
 
                const f64 c   = cos( angle );
                const f64 s   = sin( angle );
                const f64 t   = 1.0 - c;
 
                const f64 tx  = t * axis.X;
 
                M[0] = tx * axis.X + c;
                M[1] = tx * axis.Y - s * axis.Z;
                M[2] = tx * axis.Z + s * axis.Y;
                M[3] = 0.0;
 
                const f64 ty  = t * axis.Y;
 
                M[4] = ty * axis.X + s * axis.Z;
                M[5] = ty * axis.Y + c;
                M[6] = ty * axis.Z - s * axis.X;
                M[7] = 0.0;
 
                const f64 tz  = t * axis.Z;
 
                M[8]  = tz * axis.X - s * axis.Y;
                M[9]  = tz * axis.Z + s * axis.X;
                M[10] = tz * axis.Z + c;
                M[11] = 0.0;
 
                M[12] = 0.0;
                M[13] = 0.0;
                M[14] = 0.0;
                M[15] = 1.0;
 
#if defined ( USE_MATRIX_TEST )
                definitelyIdentityMatrix=false;
#endif
                return *this;
        }
 
        template <class T>
        inline CMatrix4<T>& CMatrix4<T>::setRotationAxisRH( const T& angle, const vector3d<T>& axis )
        {
 
                const f64 c   = cos( angle );
                const f64 s   = sin( angle );
                const f64 t   = 1.0 - c;
 
                const f64 tx  = t * axis.X;
 
                M[0] = tx * axis.X + c;
                M[1] = tx * axis.Y + s * axis.Z;
                M[2] = tx * axis.Z - s * axis.Y;
                M[3] = 0.0;
 
                const f64 ty  = t * axis.Y;
 
                M[4] = ty * axis.X - s * axis.Z;
                M[5] = ty * axis.Y + c;
                M[6] = ty * axis.Z + s * axis.X;
                M[7] = 0.0;
 
                const f64 tz  = t * axis.Z;
 
                M[8]  = tz * axis.X + s * axis.Y;
                M[9]  = tz * axis.Z - s * axis.X;
                M[10] = tz * axis.Z + c;
                M[11] = 0.0;
 
                M[12] = 0.0;
                M[13] = 0.0;
                M[14] = 0.0;
                M[15] = 1.0;
 
#if defined ( USE_MATRIX_TEST )
                definitelyIdentityMatrix=false;
#endif
                return *this;
        }
Post Reply