Jump to content



automotive movement camera in glut

  • You cannot reply to this topic
2 replies to this topic

#1 adritill   Members   -  Reputation: 100

Like
0Likes
Like

Posted 22 February 2012 - 03:40 PM

hello, i know how to place a camera and look to somewhere with gluLookAt function, but now i have a wheel like this http://www.artesanum...noria-46979.jpg coded and i want to place a camera into the one box and travel with it, how could i implement that?
my wheel does a 360º movement and then it returns another -360º and repeat this pattern.

Ad:

#2 FXACE   Members   -  Reputation: 157

Like
0Likes
Like

Posted 22 February 2012 - 06:55 PM

>> "position of box per frame" + "camera's position"...

Note:
1. initialize "position of your camera" at {x:0,y:0,z:0};
2. initialize "position of box" which would be relative to wheel object.
3. each time-line/frame "position of box per frame" = "position of box" * "rotation matrix of wheel".

the end.

Best wishes, FXACE.

#3 adritill   Members   -  Reputation: 100

Like
0Likes
Like

Posted 24 February 2012 - 03:44 AM

so this is the wheel code:
void wheel()
{
if(er==1)vr-=1;
else vr+=1;
if(vr>360)er=1;
else if(vr<-360) er=2;

glColor3d(1,1,0);

glPushMatrix();
glTranslatef(-230,-5,250);
glScalef(18,18,18);

glPushMatrix();
glTranslatef(10,4,-8.3);
glRotatef(vr,0,0,1);
glColor3d(sin(luz/9),1,0); c=1;
glutWireTorus(0.3,2.2,6,stacks);

glColor3d(1,0,0);
for(i=0;i<30;i++)
{
glPushMatrix();
glRotatef(90,0,1,0);
glRotatef(12*i,1,0,0);
glutWireCone(0,1.89,2,1);
glPopMatrix();
}

// Creamos los asientos
for(i=0;i<=12;i++)
{
glPushMatrix();
glColor3d(0,1,1);
glRotatef(90,0,1,0);
glRotatef(30*i,1,0,0);
glTranslatef(0,2.4,0);
glTranslatef(-0.2,0,0);
glRotatef(270,1,0,0);
glutSolidCone(0.05,0.5,slices,stacks);
glTranslatef(0.4,0,0);
glutSolidCone(0.05,0.5,slices,stacks);
glTranslatef(-0.2,0,0.5);
glRotatef(vr,1,0,0);
glutSolidCube(0.37);
glTranslatef(0,0.1,0);
glutSolidCube(0.25);
glPopMatrix();
}

glutSolidCone(0.2,0.7,slices,stacks);
glRotatef(180,1,0,0);
glutSolidCone(0.2,0.7,slices,stacks);
glPopMatrix();

glPushMatrix();
glColor3d(1,1,1);
glTranslatef(10,4,-9);
glRotatef(90,0,1,0);
glutSolidSphere(0.1,slices,stacks);
glTranslatef(-1.4,0,0);
glutSolidSphere(0.1,slices,stacks);
glTranslatef(0,-3.4,0);
glRotatef(180,0,1,1);
glutSolidCone(0.2,3.4,slices,stacks);
glColor3d(0,0,1);
glutSolidCube(0.8);
glTranslatef(-1.4,0,0);
glColor3d(1,1,1);
glutSolidCone(0.2,3.4,slices,stacks);
glColor3d(0,0,1);
glutSolidCube(0.8);
glPopMatrix();
glPopMatrix();
}

how would the camera be ?? negative of translation/rotation ?






We are working on generating results for this topic
PARTNERS