Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Sat Apr 27, 2024 10:10 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Jul 10, 2006 5:44 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Again in having problems since i need relative positions.
I'm working in a dinamyc camera controlled by the user with the second stick of the playstation2 joypad.
Right now i can read the position of the stick but if i apply those values directly to the position of the car the values are apply in real world coordinates. And so the camera it not well aligned with the car.

I mean, having:
SSX ( second stick x value)
SSY ( second stick y value)
CAR (NAME OF THE MAIN ELEMENT OF THE CAR)
How can i get the desired effect?

I have made a new function to do this but it's not working properly. Really it's a hack of another function.
Here it goes:
Code:
void raydium_camera_follow_element_name(char *name, GLfloat tension,GLfloat dx,GLfloat dy)
{
//put in the headers
GLfloat basetension;
//vars
GLfloat *pos;
GLfloat mpos[3];
GLfloat *vel;
GLfloat cam[3];

basetension=2.f;

// get element position
pos=raydium_ode_element_pos_get_name(name);
vel=raydium_ode_element_linearvelocity_get_name(name);

// get position of camera in world coords
raydium_ode_element_RelPointPos_name(name,-1,0,0,cam);

// correct z pos (always at top of the car, for example)
cam[2]=pos[2]+0.4;

mpos[0]=pos[0]+vel[0];
mpos[1]=pos[1]+vel[1];
mpos[2]=pos[2]+vel[2];

//raydium_camera_replace();
raydium_camera_smooth(cam[0]-dx*2,cam[1]-dy,cam[2],mpos[1],-mpos[2],mpos[0],
             70-(vel[0]+vel[1]+vel[2]),0,raydium_frame_time*tension/0.5);
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 7:09 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
It the work of raydium_ode_element_RelPointPos_name(). This function generates a (x,y,z) position in world coords from a local point of an element. Make this local point "turning" over the car, and you're ok :)

If you look at the camera code of ManiaDrive, you just have to change arguments -1,0,0 (it means: "at the rear of the car") with yours for the line:
raydium_ode_element_RelPointPos_name("corps",-1,0,0,cam);


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 194 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group