FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

sio2CameraRender ...why all those operations? :)

2 posters

Go down

sio2CameraRender ...why all those operations? :) Empty sio2CameraRender ...why all those operations? :)

Post  glDisable Tue Aug 25, 2009 11:53 am

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:

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

Back to top Go down

sio2CameraRender ...why all those operations? :) Empty Re: sio2CameraRender ...why all those operations? :)

Post  sio2interactive Tue Aug 25, 2009 4:42 pm

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 Wink
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum