Archived

This topic is now archived and is closed to further replies.

ARID

Simulation HELP

Recommended Posts

I am building a driveing simulation for my US first team (We build robots) I am building this sim to help train the drivers. Well heres the prolbem. I am trying to make a setting where the driver is in the control terminal. So his view can do one of two things eather not move at all or fallow the movement of the robot. I would prefer to have the view track the robot (like a person watching it as it moves around not track as in a flying camera overhead). This poses a problem (I am useing this as an introduction to future programing indevors so I can get used to gameish programing) I want the user to control the robot useing a mouse or joystick (simple Direct Input which I don't realy need help with) the robot starts faceing the same direction as you then can move in any direction forward of backward and turn so my problem is how would I go about allowing the robot to move in all thease directions without moveing the camera (i am vermiliar with Vectors, cross products, and dot products so the math won't confuse me if you tell me what it does I can figure out what does what) If i moved the camera it would be easier I would just translate and rotate the whole world. So give me a little help here. ()xxx)(:::::::::::> It's not Cheating, It's useing your opertunitys to your advantage <::::::::::(xxx() Edited by - ARID on January 27, 2001 8:44:24 PM

Share this post


Link to post
Share on other sites
Just bringing the post to the top I REALY need help with this one. I was thinking of useing the glLookAt but i''m not shure that would work.

A man walks into a bar.....ouch!?! Ya get it, do ya huh huh well....awww I give up.

Share this post


Link to post
Share on other sites
I don''t understand the difference between a camera tracking it from overhead and a person following it. Is the main difference that the person''s view would be at an angle while the camera would have an exact bird''s eye view?

If so, then gluLookAt would probably the easiest thing to use. Say you wanted the camera to be 5 units below the robot on the y axis and 5 above the floor on the z axis. You could track the robot with the following line: gluLookAt(robot.x, robot.y - 5, 5, robot.x, robot.y, robot.z, 0, 1, 0);

the first three parameters specify the location of the camera, the second three a point that the camera is ''looking at,'' and the last three an ''up vector.'' The up vector essentially dictates what direction should be ''up'' when drawn to the screen; in this case the up vector will make the positive y axis go up. I _think_ that this vector should be orthogonal to the vector from the position to the ''look at'' point but it seems to work fine even when it''s not.

Share this post


Link to post
Share on other sites
I musn''t have been vey clear i''m sory about that. What I need to do is not have the player move at all he cant move he''s stuck in the players station on the playing surface this means he can only look at the robot not move from the starting point. so how would I control the robot so It moves I am very stumped.

A man walks into a bar.....ouch!?! Ya get it, do ya huh huh well....awww I give up.

Share this post


Link to post
Share on other sites
I know that. I mean in the gameworld the camera "never moves" think of the player as a spectator he stands in one spot and moves the robot.

Share this post


Link to post
Share on other sites
I don''t know anything about OpenGL, but don''t you have an Object-World transformation matrix which converts your object''s local coordinate system (centered around the origin of the object) to the world coordinate system. Just alter this matrix, translation to move the object and rotation to rotate it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Cant you just use gluLookAt to look AT your robot from where you ARE. It seems you already have the values to plug right into the method.

Pete

Share this post


Link to post
Share on other sites
Ahh well I think i've figured it out to an exstent I think this will work. But when I run it i just get a black screen.

   int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing

{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer


glLoadIdentity(); // Reset The Current Modelview Matrix

glTranslatef(-1.25f,-1.0f,-0.5f);
glRotatef(180,0.0f,1.0f,0.0f);
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(2.5f, 0.0f, 0.0f); //Front bottom right

glVertex3f(2.5f, 0.5f, 0.0f); //Front top right

glVertex3f(-2.5f, 0.5f, 0.0f); //Front top left

glVertex3f(-2.5f, 0.0f, 0.0f); //Front bottom left


//glColor3f(1.0f,1.0f,1.0f);

//glVertex3f(2.5f, 0.5f, 0.0f); //Glass bottom right

//glVertex3f(2.5f, 1.5f, 0.0f); //Glass top right

//glVertex3f(-2.5f, 1.5f, 0.0f); //Glass top left

//glVertex3f(-2.5f, 0.5f, 0.0f); //Glass bottom left


glColor3f(0.25f, 0.25f, 0.25f);
glVertex3f(2.5f, 0.5f, 0.0f); //Sill forward right

glVertex3f(2.5f, 0.5f, 0.25f); //Sill Rear right

glVertex3f(-2.5f, 0.5f, 0.25f); //Sill rear left

glVertex3f(-2.5f, 0.5f, 0.0f); //Sill forward left

glEnd();

glTranslatef(-1.25f, -1.0f, -11.0f);
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(2.5f, 0.0f, 0.0f); //Front bottom right

glVertex3f(2.5f, 0.5f, 0.0f); //Front top right

glVertex3f(-2.5f, 0.5f, 0.0f); //Front top left

glVertex3f(-2.5f, 0.0f, 0.0f); //Front bottom left


glColor3f(1.0f,1.0f,1.0f);
glVertex3f(2.5f, 0.5f, 0.0f); //Glass bottom right

glVertex3f(2.5f, 1.5f, 0.0f); //Glass top right

glVertex3f(-2.5f, 1.5f, 0.0f); //Glass top left

glVertex3f(-2.5f, 0.5f, 0.0f); //Glass bottom left


glColor3f(0.25f, 0.25f, 0.25f);
glVertex3f(2.5f, 0.5f, 0.0f); //Sill forward right

glVertex3f(2.5f, 0.5f, 0.25f); //Sill Rear right

glVertex3f(-2.5f, 0.5f, 0.25f); //Sill rear left

glVertex3f(-2.5f, 0.5f, 0.0f); //Sill forward left

glEnd();

glTranslatef(-1.25f,-1.0f,-5.5f);
glRotatef(0,0.0f,0.0f,0.0f);
glBegin(GL_QUADS);
glColor3f(0.5f, 0.5f, 1.0f); // Purpleish floor

glVertex3f(-5.0f, 0.0f, 2.5f); //Floor top left

glVertex3f(-5.0f, 0.0f, -2.5f); //Floor bottom left

glVertex3f(5.0f, 0.0f, -2.5f); //Floor bottom right

glVertex3f(5.0f, 0.0f, 2.5f); //Floor top right


glColor3f(0.2f, 0.2f, 0.2f); //Grey side

glVertex3f(-5.0f, 0.5f, -2.5f); //Forward top left

glVertex3f(-5.0f, 0.0f, -2.5f); //Forward bottom left

glVertex3f(5.0f, 0.0f, -2.5f); //Forward bottom right

glVertex3f(5.0f, 0.5f, -2.5f); //Forward top right


glColor3f(0.2f, 0.2f, 0.2f); //Grey side

glVertex3f(-5.0f, 0.5f, 2.5f); //Back top left

glVertex3f(-5.0f, 0.0f, 2.5f); //Back bottom left

glVertex3f(5.0f, 0.0f, 2.5f); //Back bottom right

glVertex3f(5.0f, 0.5f, 2.5f); //Back top right

glEnd();

glPushMatrix;
glLoadIdentity;
glColor3f(1.0f,1.0f,0.0f);
glTranslatef(xpos, -1.0f, zpos);
glRotatef(heading,0.0,1.0,0.0);
glBegin(GL_QUADS);
glVertex3f(-0.75f, 0.0f, 0.5f); //Base rear left

glVertex3f(-0.75f, 0.0f, -0.5f); //Base forward left

glVertex3f(0.75f, 0.0f, -0.5f); //Base forward right

glVertex3f(0.75f, 0.0f, 0.5f); //Base rear right


glVertex3f(0.75f, 0.0f, 0.5f); //Top rear right

glVertex3f(0.75f, 0.0f, -0.5f); //Top forward right

glVertex3f(-0.75f, 0.5f, -0.5f); //Top forward left

glVertex3f(-0.75f, 0.5f, 0.5f); //Top rear left


glVertex3f(-0.75f, 0.5f, 0.5f); //Back rear top

glVertex3f(-0.75f, 0.0f, 0.5f); //Back rear bottom

glVertex3f(-0.75f, 0.0f, -0.5f); //Back forward bottom

glVertex3f(-0.75f, 0.5f, -0.5f); //Back forward top

glEnd();
glPopMatrix;
return TRUE;
}


A man walks into a bar.....ouch!?! Ya get it, do ya huh huh well....awww I give up.

Edited by - ARID on January 31, 2001 8:58:16 PM

Edited by - ARID on January 31, 2001 9:00:14 PM

Share this post


Link to post
Share on other sites