• Advertisement
Sign in to follow this  

Translate with edge detection

This topic is 3380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, an extreme noob here, I been sifting through tutorials for my practical exam and I would like some help trying to translate an image with view port edge detection. First of all The entire image (a car) should translate with commands from the keyboard until it reaches the end of the screen and bounces off (in both directions)Right now it doesn't move at all except for the wheels spinning.

void drawCar() 
{

   glColor3f(1,1,1);
   glPushMatrix();
   glTranslatef(translateX, translateY, translateZ);
   glLineWidth(2);

   glLineWidth(1);
   glPopMatrix();

   glScalef(2,2,2); //Size of Car

   glColor3f(0.5f,0.5f,0.0f);//Car Body

   glPushMatrix();
   glScalef(5,1,2);
   glLineWidth(2);
   glutSolidCube(1);
   glLineWidth(1);
   glPopMatrix();
   
   glPushMatrix();//Car windows

  translateX=0.5;
  translateY=0.75;
  translateZ=0;

   glTranslatef(translateX, translateY, translateZ);
   glScalef(2,0.5,1.8);
   glLineWidth(4);
   glutWireCube(1);
   glLineWidth(1);
   glPopMatrix();
   
   glColor3f(0.4,0.4,1);

   glPushMatrix();//Back Wheel number 1

	translateX=2.3;
	translateY=-0.4;
	translateZ=1.3;

    glTranslatef(translateX, translateY, translateZ);

   glRotatef(angle, xAxis, yAxis, zAxis);//Rotate Wheel  
   glutSolidTorus(0.2,0.33,24,12);
   glPopMatrix();

///Define other wheels


Here are the keyboard commands
switch (key)
			{
				case GLUT_KEY_LEFT : 	  
							  
								angle += 5.0f;//Angle for wheel rotation	
								xAxis = 0.0f; yAxis = 0.0f; zAxis = 1.0f; travel = 0;
                                while (translateX < 15)
								{
								translateX = translateX +1;//Move Car forward 
								translateY =0.0f;
								translateZ = 0.0f;
								}
								
								break;

Some help would be greatly appreciated. Practical next week!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement