opengl program moving train
#5

opengl program moving train

Design and Implementation

For developing the train - it's bogies and engine we have defined a simple function. In this simple opengl projects example we are coding this function so we can make any no trains, by just calling it. The following is sample code for drawing train -

void TRAINS(int x1,int y1,int a,int b)
{
int i=0; glBegin(GL_QUADS);
glColor3f(0,0.0,1.0); //ENGINE
glVertex2f(x1,y1); //lengh of engine=60;height of engine=30;
glColor3f(0,0.0,1.0);
glVertex2f(x1+60,y1);
glColor3f(1.0,0.0,0.0);
glVertex2f(x1+60,y1-30);
glColor3f(0,0.0,0.0);
glVertex2f(x1,y1-30);
glEnd();
while(i<3) {
glBegin(GL_QUADS); //BOGIES
glColor3f(1.0,0.0,0.0); //For right train a=795,b=510
glVertex2f(a,b);
glColor3f(1.0,0.0,0.0);
glVertex2f(a+60,b);
glColor3f(1.0,0.0,0.0);
glVertex2f(a+60,b-20);
glColor3f(1.0,0.0,0.0);
glVertex2f(a,b-20);
glEnd();
a+=65; i++;
}
}

This function can be called any where hence easy to create the sample trains. In similar fashion we have different functions for Sky, Environments and Tracks. You can download the free cg source code below. All the things made in the opengl projects example have used primitive opengl objects.

Next level of difficulty is to move the whole Train - bogies and engine. For the motion of train we have logically used the call-list, push-pop matrix and the most important Clock() function. The clock() is defined in <time.h> header so you need to include it as well in the project.

clock_t goal = mseconds + clock(); while (goal > clock());

Our new function will help the train runs according a time level else we may go so fast or so slow. We have fixed a goal and add certain time for it to move the objects. The above code is called in a function and we give the parameter mseconds according to our requirement of speed we want.
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: opengl, open gl code for moving train, electricity generation using salvaged air from moving train pdf download, electricity from moving train, source code moving train in computer grapics, wrirw opengl program for a moving train, snowman opengl program abstracton vtu old question papers,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Messages In This Thread
opengl program moving train - by Guest - 05-11-2012, 10:07 PM
RE: opengl program moving train - by Guest - 08-03-2013, 03:07 PM
RE: opengl program moving train - by Guest - 26-07-2013, 10:20 AM
RE: opengl program moving train - by Guest - 18-04-2016, 07:34 PM
RE: opengl program moving train - by dhanabhagya - 21-04-2016, 10:46 AM

Possibly Related Threads...
Thread Author Replies Views Last Post
  opengl source code for butterfly 3 3,276 14-05-2018, 08:57 AM
Last Post: Akshatha k
  program code of solar tracking system using 8051 microcontroller 6 23,387 03-05-2018, 09:30 PM
Last Post: Guest
  project physics class 12 on moving coil galvanometer 3 26,668 04-01-2018, 10:59 AM
Last Post: dhanabhagya
  project report for mancala game in opengl 2 1,264 05-06-2017, 11:24 AM
Last Post: jaseela123d
  computer graphics projects using opengl free download 3 1,392 01-05-2017, 02:33 PM
Last Post: jaseela123d
  opengl source code for cpu scheduling algorithms 1 1,146 25-03-2017, 11:43 AM
Last Post: jaseela123d
  source code of go back n arq on opengl 1 1,172 20-03-2017, 12:08 PM
Last Post: jaseela123d
  seminar report on bullet train 1 1,007 16-03-2017, 12:51 PM
Last Post: jaseela123d
  queue implementation in opengl 1 562 10-03-2017, 02:48 PM
Last Post: jaseela123d
  six leg kinematic moving machine theory 1 716 09-03-2017, 04:23 PM
Last Post: jaseela123d

Forum Jump: