Search Projects

Wednesday, April 27, 2016

OpenGL Clipping Plane Example

In this blog post we are going to learn about the usage of clipping planes in OpenGL.  This opengl clipping plane example will help you understand the basics of planes along with the axes. The program we are going to show is interactive as well as educative. It will helps you out where you will be able to formulate plane in space as well as able to create a clipping plane in OpenGL.


You might know many algorithm including the cohen sutherland line clipping algorithm, which is in the program list for Lab in VTU 6th Sem CSE CGV. The plane clipping algorithm is similar to that. You can Download the opengl clipping plane example source code and easily understand the program what it trying to do, easy to manipulate the algorithm.

Following is interactive function in the program (also printed in the program itself)-


1' - toggle x=0 halfplane
2' - toggle y=0 halfplane
3' - toggle z=0 halfplane
j', 'l' - translate x=0 halfplane (when toggled)
',', 'i' - translate y=0 halfplane (when toggled)
u', 'm' - translate z=0 halfplane (when toggled)
x', 'y', 'z' - reverse the corresponding half plane
-', '=' - rotate about y-axis
(Left/Right) mouse buttons - rotate about y-axis
[', ']' - rotate viewpoint about x-axis
f' - toggle fill/wireframe drawmode


Download the Full Source Code

Sunday, April 24, 2016

2d line Man OpenGL

There are many projects you are in 2d and many are in 3d. You might like 3d projects but there are few 2d projects which is very good not due to it's heavy coding but due to simplicity. There is no need to show off rather with some simple idea you can make the projects like we have the 2d line man.

The 2d line man is a very simple projects where with the help of line, the man figure is drawn. After drawing the figure it has been given the motion. You can see the demo in the below image.


\

Saturday, April 23, 2016

A Moving Mesh

Are you looking to something, that easy to implement for your CGV project?
Then you are here going to get a simple program you to can add something to it and make a good workable project. This program is called Moving Mesh.

The Moving mesh is like what we use to have in DD when TV lost the signal and we get a cross horizontal moving long rectangle in different color moving fast. You can view the same in image below.



Let Program the Moving Mesh

First we are going to add all the Header files and global variable will be declare.
#include<glut.h>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

static  GLdouble  viewer[]={0,0,5};
float dx=0.5,dy=0.5;
float angle=0;


To draw a mesh we are defining the mesh() function which uses the concept of looping and draw with help of vertices (primitive function). The code is given below -

void mesh()
{
float a=0.5,b=0.5,c=1;
            float  i, j;
            for(i=0;i<15;i+=dx)
            for(j=0;j<15;j+=dy)
            {
            glBegin(GL_POLYGON);
            glColor3f(a,b,c*fabs(sin(100*i+angle)));
            glVertex2f( i, j);
            glVertex2f( i+dx, j);
            glVertex2f( i+dx, j+dy);
            glVertex2f( i, j+dy);
            glVertex2f( i, j);
            glEnd();
            }
}
Now Display the Mesh with the display function as given below. Also we make sure the mesh continues to display and work well, we defined the idel and reshape functions.

void display()
{
            glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
            glLoadIdentity();
            gluLookAt(viewer[0],viewer[1],viewer[2],0,0,0,0,1,0);
            glTranslated(4,4,-5);
            mesh();
            glFlush();
            glutSwapBuffers();
} void idle()
{
angle++;
if(angle>360) angle=0;
glutPostRedisplay();
}
void myReshape(int w,int h)
{
            glViewport(0,0,w,h);
            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            glOrtho(-2,20,-2,20,-10,20);
            glMatrixMode(GL_MODELVIEW);
}


Now time for the main program which is as usual almost same for all the C/C++ OpenGL Programs.

int main(int argc,char **argv)
{

glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow("A Moving Mesh");
glutDisplayFunc(display);
glutReshapeFunc(myReshape);
glutIdleFunc(idle);
glClearColor(1.0,1.0,1.0,1.0);
glEnable(GL_DEPTH_TEST);
glutMainLoop();
return 0;
}


You can add something to this program and make it interactive, like a keyboard or mouse function to start and stop motion.

Monday, April 18, 2016

Copter Computer Graphics Game Project

A Computer Graphics Mini PROJECT ON COPTER GAME Submitted in partial fulfillment of the requirements for the award of degree of Bachelor of Engineeringin Computer Science and Engineering - Submitted by SANTHOSH of Vivekananda Institute of Technology, GUDIMAVU, KUMBALGODU Bangalore.

This Computer graphics Project is inpired by most famous game on Android - Flappy Birds.It is similar to that insded of touch, we are using mouse button and bird is replaced by the helicopter.


SOFTWARE REQUIREMENTS SPECIFICATION:


This section attempts to bring out the requirements and specifications as given out by the Vishweshwaraiah Technological University for the completion of the package.

Minimum requirements expected are cursor movement, editing picture objects  like point, line, circle, ellipse and polygons. Transformations on objects/selected area should be possible.. User should be able to open the package do the required opearations and exit from the environment.
Good user interface, which can be GUI ,Menu based, should be provided.. Should use all most all the graphical input technologies for efficient programming and interact through various input devices. Should be a device independent package that is able to compile and create an executable.

EXTERNAL INTERFACE REQUIREMENTS:


User Interface:   

The interface for the 2D package  requires for the user to have a mouse connected, and the corresponding drivers software and header files installed.

For the convenience of the user, there are menus and sub –menus  displayed on the screen.

Menus

The Menus  consists of various operations related to drawing on the area specified. It also has the 'clear' option for clearing the screen and also change the background color.
Palettes Color palette, which displays the different colors available to the user. He/she can pick the required color by clicking anywhere in the window specified.

Hardware Interface:

The standard output device, as mentioned earlier has been assumed to be a color monitor. It is quite essential for any graphics package to have this, as provision of color options to the user is a must. The mouse, the main input device, has to be functional. A keyboard is also required.
Apart from these hardware requirements, there should be sufficient hard disk space and primary memory available for proper working of the package.

Software Interface:

The editor has been implemented on the windows platform and mainly requires an appropriate version of the compiler to be installed and functional. Though it has been implemented on windows, it is pretty much platform independent with the restriction that there is support for the execution of C++ files.

IMPLEMENTATION


This project developed uses basic Brute force methods to work. This contains a varying x-coordinate and y-coordinate for every point of the object drawn with two variables holding 0 displacements initially.

This displacement decreases if mouse is passive else if left mouse button is held down then x-displacement is increased and if right mouse button is held down y-displacement is increased hence the copter is controlled on the scenario.



The same is with the obstacles, there are 4 pre-defined obstacles and a random function which selects one of the 4 pre-defined obstacles which has to be released and there is no y displacement for the obstacles. There may be at the most two obstacles at any given time which are controlled by two index variables. Switching is of the variables is done whenever an obstacle leaves the scene.

There are two limits one at the top and the other at the bottom whose values are updated every time according to the location of the copter  i.e. whether the copter is above or below an obstacle or not. There are 2 more limits which are unaffected one is to the right extremity and other to the left extremity which note that the chopper does not go beyond the window extremes.

A function is maintained so as to display the score of the player. Here we have made use of concepts of translation and scaling along with use of push and pop matrix functions and conversion of integer to ascii for displaying numbers.

We have even used a temporary file so as to maintain track of the high score scored, the file gets created if it does not exist and initializes the high score to 0 for the first time after which the high score is automatically read from the temporary file.

We have maintained an exit flag so as to take decision whether the player is still playing or whether he is out in the game so as to control the end of the game. If this flag is set the players score is shown on the output screen.

We use the concept of Double buffering so as to avoid flickering image rendering. A mouse function is used for giving input interfacing.

Maintenance & Future Enhancements:   

Improved memory requirements may allow us to introduce more obstacles and other external environments.
This may also be upgraded to develop 3-D aircraft simulations using 3-D model and some concepts of physics, lighting and perspective vision which were hindered in the current project due to time constraints.
This may also be interfaced with keyboard for movement and mouse for shooting thus implementing flight war game.
This may also be upgraded with sound effects so as to bring it to the interest of the user.

Source code and Report


You can purchase this Project source code along with the Report at a minimal Cost of Rs 400 via Bank Transfer(Detials on the Payment page) or Rs 500 via Mobikwik or Paytm to mobileno 7022162923. To contact us before doing the payment else there will be delay in delivery.

Sunday, April 10, 2016

Airplane Takeoff computer graphics projects

Airplane Landing opengl projects for vtu computer graphics lab.
This simple opengl computer graphics program in which, the airplane do a take off in the air. After take off the airplane fly in air. This a very simple program as explain will show airplane take off from it's runway.

Airplane Takeoff computer graphics projects

As seen in the figure from the output of the Airplane Takeoff computer graphics projects, c program you can see the three objects - sky, airplane and runway. All these objects are designed with simple opengl graphics objects. Do download the projects and tell us if you have something to add to it, we are going to publish the modified program on this blog.

Download the Program.