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?
[fixed]Matrix question
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Matrix question
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.
Re: Matrix question
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 ?
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 ?
Re: Matrix question
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;
}