train in opengl program
#1

Please send tha open CL code for moving train
Reply
#2

Creating a train in computer graphics is not that hard but logical. In this post we will see an example of OpenGL projects on trains. Our goal is to develop a simple cg projects for the execution of train. Here we have to draw the following things -

• Train - bogies and engine
• Train tracks
• Sky with surroundings (Environment)
After finishing the drawing our next objective would be to give movement to the train. As we are going to draw a simple train so that our track will be a straight not zigzag shaped.

Code:
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 therefore easy to create sample trains. Similarly we have different functions for Sky, Environments and Tracks. You can download the free cg source code below. All things done in the example of opengl projects have used opengl primitive objects.

The next level of difficulty is to move all the Train - bogies and the engine. For the movement of the train we have logically used the call list, the push-pop matrix and the Clock () function more important. The clock () is defined in the <time.h> header, so you must also include it in the project.

Clock_t goal = mseconds + clock (); While (meta> clock ());

Our new function will help the train to operate according to a level of time, otherwise we can go so fast or so slow. We set a target and add some time to move objects. The above code is called in a function and we give it the mseconds parameter according to our speed requirement we want.

That's all that ended things. I just summed up the example of Running Train Opengl Projects while you can easily understand things when you start running the program.
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
Tagged Pages: opengl project on train source code,
Popular Searches: opengl program for a moving train in c download in, train in opengl program, opengl program moving train, opengl program for a moving train in c, opengl program for a moving train ubuntu, vb program coding for train reserve, computer graphics program for moving train in opengl,

[-]
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)

Possibly Related Threads...
Thread Author Replies Views Last Post
  Train Ticket 0 1,870 26-11-2020, 12:26 AM
Last Post:
  program for ticket reservation using multithreading in java 0 1,084 08-10-2018, 10:00 AM
Last Post: Guest
  reservation program using queue in c 0 611 04-10-2018, 07:58 PM
Last Post: Guest
  c graphics program for moving train with output 0 539 03-08-2018, 02:20 PM
Last Post: Guest
  ppt of train distance indicator for unguarded level crossing 0 437 11-07-2018, 08:18 AM
Last Post: Guest
  opengl source code for rocket launch 0 573 08-06-2018, 08:32 AM
Last Post: Guest
  source code of bellman ford algorithm in opengl 0 671 24-05-2018, 12:47 AM
Last Post: Guest
  code for airshow using opengl 0 512 20-05-2018, 11:56 AM
Last Post: Guest
  opengl project for simulation dam 0 588 17-05-2018, 01:57 PM
Last Post: Guest
  project report bellman ford algorithm using opengl 0 686 17-05-2018, 01:39 PM
Last Post: Guest

Forum Jump: