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.

problem with perspective correction

2 posters

Go down

problem with perspective correction Empty problem with perspective correction

Post  alexanderlonsky Sat Jun 13, 2009 7:22 pm

Hello! I am newbie in SIO2.
I've applied rotation by X
Code:
sio2TransformRotateX( sio2->_SIO2camera->_SIO2transform,
                      ROT_X );
But have incorrect perspective.
I've found out that possible to use
Code:
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
But don't know where in my code I have to put this string.
And also found that function sio2InitGL(); already has this hint.

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  sio2interactive Sat Jun 13, 2009 7:47 pm

Camera is working with a direction vector... check tutorial09... or simply use sio2LookAt instead of sio2CameraRender, however you'll have to handle physic manually...
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  alexanderlonsky Sat Jun 13, 2009 8:33 pm

sio2interactive wrote:Camera is working with a direction vector... check tutorial09... or simply use sio2LookAt instead of sio2CameraRender, however you'll have to handle physic manually...
At the beginning of description of tutorial09 I've read about sound and haven't read end of description about camera...

thanks! will try

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  alexanderlonsky Sat Jun 20, 2009 7:18 pm

sio2interactive, sorry but still have problem
I've watched tutorial09 and got some code from there but added rotation by X.
Code:

if( object )
   {
      if( ROTZ_DIR > 0 )
      {
         SMOOTH_Z -= 1.0f * sio2->_SIO2window->d_time;
         ROTZ += SMOOTH_Z;
      }
      else if( ROTZ_DIR < 0 )
      {
         SMOOTH_Z -= 1.0f * sio2->_SIO2window->d_time;
         ROTZ -= SMOOTH_Z;
      }
      if( SMOOTH_Z < 0.0f )
      {
         SMOOTH_Z = 0.0f;
         ROTZ_DIR = 0;
      }
      
      if( ROTX_DIR > 0 )
      {
         SMOOTH_X -= 1.0f * sio2->_SIO2window->d_time;
         ROTX += SMOOTH_X;
      }
      else if( ROTX_DIR < 0 )
      {
         SMOOTH_X -= 1.0f * sio2->_SIO2window->d_time;
         ROTX -= SMOOTH_X;
      }
      
      if( SMOOTH_X < 0.0f )
      {
         SMOOTH_X = 0.0f;
         ROTX_DIR = 0;
      }
      
      vec3 tmp_pos;
      
      sio2Rotate3D( object->_SIO2transform->loc, -ROTX, ROTZ, 0.1f, &tmp_pos );
      object->_SIO2transform->rot->z = ROTZ;
      object->_SIO2transform->rot->x = ROTX;
      
      sio2TransformBindMatrix( object->_SIO2transform );
      
      sio2->_SIO2camera->_SIO2transform->loc->x = tmp_pos.x;
      sio2->_SIO2camera->_SIO2transform->loc->y = tmp_pos.y;
      sio2->_SIO2camera->_SIO2transform->loc->z = tmp_pos.z;
      
      tmp_pos.x = object->_SIO2transform->loc->x;
      tmp_pos.y = object->_SIO2transform->loc->y;
      tmp_pos.z = object->_SIO2transform->loc->z;
      
      sio2Vec3Diff( &tmp_pos,
                sio2->_SIO2camera->_SIO2transform->loc,
                sio2->_SIO2camera->_SIO2transform->dir );
      
      
      sio2Normalize( sio2->_SIO2camera->_SIO2transform->dir,
                 sio2->_SIO2camera->_SIO2transform->dir );
              sio2CameraRender( sio2->_SIO2camera );
   
         sio2CameraUpdateFrustum( sio2->_SIO2camera );

I don't have problem with rotation by Z but have a huge problem with rotation by X -
after sio2Normalize function I've got due to debug -
object->_SIO2transform->rot == {0, 0, 0}
sio2->_SIO2camera->_SIO2transform->dir == {0, 1, 0}
sio2->_SIO2camera->_SIO2transform->loc == {0, 1.84, 1.18}
sio2->_SIO2camera->fov == 49
result picture -
problem with perspective correction Picture5

object->_SIO2transform->rot = {86.13, 0, -0.75}
sio2->_SIO2camera->_SIO2transform->dir = {0.0008, 0.067, 0.997}
sio2->_SIO2camera->_SIO2transform->loc = {-8.8e-05, 1.94, 1.08}
sio2->_SIO2camera->fov == 49
everything is normal, but seems that camera has been moved to a distance by Y(save cube's brinks for vision ), image -
problem with perspective correction Picture6
Also tried rewrite code(move the camera itself using the Transform and simple geometry), but same result.
Code:

                sio2->_SIO2camera->_SIO2transform->loc->x = object->_SIO2transform->loc->x;
      sio2->_SIO2camera->_SIO2transform->loc->y = object->_SIO2transform->loc->y;
      sio2->_SIO2camera->_SIO2transform->loc->z = object->_SIO2transform->loc->z + 0.48f;

      sio2->_SIO2camera->_SIO2transform->dir->x =  cosf( object->_SIO2transform->rot->x * SIO2_DEG_TO_RAD ) *  cosf( (object->_SIO2transform->rot->z + 90) * SIO2_DEG_TO_RAD );

      sio2->_SIO2camera->_SIO2transform->dir->y =  cosf( object->_SIO2transform->rot->x * SIO2_DEG_TO_RAD ) *  sinf( (object->_SIO2transform->rot->z + 90) * SIO2_DEG_TO_RAD );

      sio2->_SIO2camera->_SIO2transform->dir->z = sinf( object->_SIO2transform->rot->x * SIO2_DEG_TO_RAD );
Help me, please...

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  sio2interactive Sat Jun 20, 2009 7:27 pm

Are you really using:

object->_SIO2transform->rot == {0, 0, 0}
sio2->_SIO2camera->_SIO2transform->dir == {0, 1, 0}
sio2->_SIO2camera->_SIO2transform->loc == {0, 1.84, 1.18}
sio2->_SIO2camera->fov == 49

in your code!!?!?!?
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  alexanderlonsky Sat Jun 20, 2009 7:29 pm

it is fov of camera that I got from sio2 model that created in blender

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  alexanderlonsky Sat Jun 20, 2009 7:31 pm

its just values from debugger, not my code
values for vision that all(direction, location etc) is normal but picture...

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  sio2interactive Sat Jun 20, 2009 7:32 pm

Just check like in example tutorial4 you will have the code to rotate and move the camera...
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  alexanderlonsky Sat Jun 20, 2009 7:36 pm

yes, before I got code from tutorial04, but rotation by Z was normal, rotation by X also brings to perspective incorrection. You said me to watch tutorial09, and also - rotation by X also brings to perspective incorrection.
sorry for boring

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  alexanderlonsky Sat Jun 20, 2009 7:39 pm

simply - left/right rotation everywhere in tutorials is great, but up/down - problem

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  sio2interactive Sat Jun 20, 2009 7:48 pm

Its nothing to do with the perspective... you are simply not calculating correctly your direction vector and normalize it... Check back some linear algebra tutorials if you feel rusty Wink
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  alexanderlonsky Sat Jun 20, 2009 7:55 pm

before my skills in algebra was not bad.
The first of all - I used code from tutorials for direction vector, second - calculated independently and got same problem.
Ok, thanks, will try =)

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  sio2interactive Sat Jun 20, 2009 8:02 pm

Or simply use sio2LookAt instead of sio2CameraRender... sio2CameraRender is faster but sio2LookAt is easier to use...
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  alexanderlonsky Sat Jun 20, 2009 8:07 pm

ok, thanks again

alexanderlonsky

Posts : 24
Join date : 2009-06-11

Back to top Go down

problem with perspective correction Empty Re: problem with perspective correction

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

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