problem with perspective correction
2 posters
problem with perspective correction
Hello! I am newbie in SIO2.
I've applied rotation by X
I've found out that possible to use
And also found that function sio2InitGL(); already has this hint.
I've applied rotation by X
- Code:
sio2TransformRotateX( sio2->_SIO2camera->_SIO2transform,
ROT_X );
I've found out that possible to use
- Code:
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
And also found that function sio2InitGL(); already has this hint.
alexanderlonsky- Posts : 24
Join date : 2009-06-11
Re: problem with perspective correction
Camera is working with a direction vector... check tutorial09... or simply use sio2LookAt instead of sio2CameraRender, however you'll have to handle physic manually...
Re: problem with perspective correction
At the beginning of description of tutorial09 I've read about sound and haven't read end of description about camera...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...
thanks! will try
alexanderlonsky- Posts : 24
Join date : 2009-06-11
Re: problem with perspective correction
sio2interactive, sorry but still have problem
I've watched tutorial09 and got some code from there but added rotation by X.
after sio2Normalize function I've got due to debug -
Also tried rewrite code(move the camera itself using the Transform and simple geometry), but same result.
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 );
after sio2Normalize function I've got due to debug -
result picture -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
everything is normal, but seems that camera has been moved to a distance by Y(save cube's brinks for vision ), image -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
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 );
alexanderlonsky- Posts : 24
Join date : 2009-06-11
Re: problem with perspective correction
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!!?!?!?
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!!?!?!?
Re: problem with perspective correction
it is fov of camera that I got from sio2 model that created in blender
alexanderlonsky- Posts : 24
Join date : 2009-06-11
Re: problem with perspective correction
its just values from debugger, not my code
values for vision that all(direction, location etc) is normal but picture...
values for vision that all(direction, location etc) is normal but picture...
alexanderlonsky- Posts : 24
Join date : 2009-06-11
Re: problem with perspective correction
Just check like in example tutorial4 you will have the code to rotate and move the camera...
Re: problem with perspective correction
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
sorry for boring
alexanderlonsky- Posts : 24
Join date : 2009-06-11
Re: problem with perspective correction
simply - left/right rotation everywhere in tutorials is great, but up/down - problem
alexanderlonsky- Posts : 24
Join date : 2009-06-11
Re: problem with perspective correction
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
Re: problem with perspective correction
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 =)
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
Re: problem with perspective correction
Or simply use sio2LookAt instead of sio2CameraRender... sio2CameraRender is faster but sio2LookAt is easier to use...
Re: problem with perspective correction
ok, thanks again
alexanderlonsky- Posts : 24
Join date : 2009-06-11
Similar topics
» md2 problem!
» Camera problems
» Lights and rotated object
» sio2InitGL problem
» Passing Through Static Object (Beating my iPod seems to help)
» Camera problems
» Lights and rotated object
» sio2InitGL problem
» Passing Through Static Object (Beating my iPod seems to help)
Permissions in this forum:
You cannot reply to topics in this forum
|
|