sio2CameraRender ...why all those operations? :)
2 posters
sio2CameraRender ...why all those operations? :)
Hi! I looked in sio2CameraRender months ago and in v 1.4.0 there is a part of code that didn't changed and it "squeezes" my brain. I don't understand why are you doing all that operations when you have all the time that "vec3 v" initialized to ( 0, 0, 1 ) ?
This part of the code:
A lot of terms will dissapear if you do the "0"-s and "1"-s computations from v and remove the redundant terms in these equations.
Also mat[ 8 ] is always zero and mat[ 15 ] = 1.0f is not necessary.
In the end you will have something more simpler:
This part of the code:
- Code:
v.x =
v.y = 0.0f;
v.z = 1.0f;
_SIO2camera->_SIO2transform->mat[ 0 ] = ( _SIO2camera->_SIO2transform->dir->y * v.z ) - ( _SIO2camera->_SIO2transform->dir->z * v.y );
_SIO2camera->_SIO2transform->mat[ 4 ] = ( _SIO2camera->_SIO2transform->dir->z * v.x ) - ( _SIO2camera->_SIO2transform->dir->x * v.z );
_SIO2camera->_SIO2transform->mat[ 8 ] = ( _SIO2camera->_SIO2transform->dir->x * v.y ) - ( _SIO2camera->_SIO2transform->dir->y * v.x );
_SIO2camera->_SIO2transform->mat[ 1 ] = ( _SIO2camera->_SIO2transform->mat[ 4 ] * _SIO2camera->_SIO2transform->dir->z ) -
( _SIO2camera->_SIO2transform->mat[ 8 ] * _SIO2camera->_SIO2transform->dir->y );
_SIO2camera->_SIO2transform->mat[ 5 ] = ( _SIO2camera->_SIO2transform->mat[ 8 ] * _SIO2camera->_SIO2transform->dir->x ) -
( _SIO2camera->_SIO2transform->mat[ 0 ] * _SIO2camera->_SIO2transform->dir->z );
_SIO2camera->_SIO2transform->mat[ 9 ] = ( _SIO2camera->_SIO2transform->mat[ 0 ] * _SIO2camera->_SIO2transform->dir->y ) -
( _SIO2camera->_SIO2transform->mat[ 4 ] * _SIO2camera->_SIO2transform->dir->x );
_SIO2camera->_SIO2transform->mat[ 2 ] = -_SIO2camera->_SIO2transform->dir->x;
_SIO2camera->_SIO2transform->mat[ 6 ] = -_SIO2camera->_SIO2transform->dir->y;
_SIO2camera->_SIO2transform->mat[ 10 ] = -_SIO2camera->_SIO2transform->dir->z;
_SIO2camera->_SIO2transform->mat[ 15 ] = 1.0f;
A lot of terms will dissapear if you do the "0"-s and "1"-s computations from v and remove the redundant terms in these equations.
Also mat[ 8 ] is always zero and mat[ 15 ] = 1.0f is not necessary.
In the end you will have something more simpler:
- Code:
_SIO2camera->_SIO2transform->mat[ 0 ] = _SIO2camera->_SIO2transform->dir->y
_SIO2camera->_SIO2transform->mat[ 4 ] = - _SIO2camera->_SIO2transform->dir->x;
_SIO2camera->_SIO2transform->mat[ 1 ] = ( _SIO2camera->_SIO2transform->mat[ 4 ] * _SIO2camera->_SIO2transform->dir->z );
_SIO2camera->_SIO2transform->mat[ 5 ] = - ( _SIO2camera->_SIO2transform->mat[ 0 ] * _SIO2camera->_SIO2transform->dir->z );
_SIO2camera->_SIO2transform->mat[ 9 ] = ( _SIO2camera->_SIO2transform->mat[ 0 ] * _SIO2camera->_SIO2transform->dir->y ) -
( _SIO2camera->_SIO2transform->mat[ 4 ] * _SIO2camera->_SIO2transform->dir->x );
_SIO2camera->_SIO2transform->mat[ 2 ] = -_SIO2camera->_SIO2transform->dir->x;
_SIO2camera->_SIO2transform->mat[ 6 ] = -_SIO2camera->_SIO2transform->dir->y;
_SIO2camera->_SIO2transform->mat[ 10 ] = -_SIO2camera->_SIO2transform->dir->z;
glDisable- Posts : 3
Join date : 2009-03-11
Re: sio2CameraRender ...why all those operations? :)
Haven't tested it, but it look about right... personally I never use sio2CameraRender and use sio2LookAt... that's probably why I never go back in it to check
Permissions in this forum:
You cannot reply to topics in this forum
|
|