Thursday, March 29, 2012

3D Zoo in OpenGL Computer Graphics

Description: In this project a 3D zoo has been build which consist of a dinosaurs, a bird, an aquarium with a  3D gesture and surrounding walls. The project implements the basic 3D animation of the dinosaurs, bird and the fishes. It even renders the walls and other objects like grass, stones, woods, water etc very well. The project used the Alpha transparency and Collision detection. With keyboard and the mouse you can move around the zoo and see the things which are happening.

You can learn how to build a dinosaurs with by going to following program link

Usages: Mouse and Keyboards (find in the link given below)
Downloads: link below

Watch the video below, that shows the entire project round up mean while and read more about this project on the creator website. You can find the usages as well as the Download links from the Creator website.





Bucket Sort : A project demonstartes sorting

Abstract

Sorting is process of arranging the numbers in an order say ascending/descending orders. There are various methods through which numbers can be sorted. Idea of sorting can be implemented in OpenGL, to show sorting graphically. This project implement the idea of sorting. It used Bucket Array to implement the sorting, hence named as Bucket Sort .

Description

In the Bucket Sort, first user is asked to enter the number of elements and the elements. Those elements are stored in an array called Input Array. A temporary Bucket Array is taken which stores the preference for the sorting. According tho the value of the Bucket Array changes is made in the Input Array. After having all the values used up numbers get sorted and sorted values is displayed. Each changes is displayed correspondingly.

Source code Download link



Sunday, March 25, 2012

How to add front screen in your OpenGL Project

In VTU lab for Computer Graphics, developing a mini-project is part of it. While developing CG mini-projects using OpenGL, there is need to present the project well. One must add front screen to the project which show the names of college, projects, guides and the project developers. It is good to have front screen as it provides introduction of the project.

There are many ways of adding front screen to the project. Here I explains, the basic way of adding front screen to the mini-project. Typically what looks in the picture below. Let's get started.

front screen in OpenGL mini-project



Simple keyboard interaction to start with

First set a variable, initialized it to zero.        
int flag=0;


Write a function called frontscreen, which contains all the details which you want to display.

void frontscreen(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0,0,1);
drawstring(20.0,90.0,0.0,"NAME OF THE COLLEGE ");
glColor3f(0.7,0,1);
drawstring(21,82,0.0,"DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING");
glColor3f(1,0.5,0);
drawstring(38,70,0.0,"A MINI PROJECT ON");
glColor3f(1,0,0);
drawstring(40,60,0.0,"PROJECT TITLE");
glColor3f(1,0.5,0);
drawstring(20,50,0.0,"BY:");
glColor3f(0.5,0,0.5);
drawstring(10,40,0.0,"NAME FIRST           (USN)");
drawstring(10,34,0.0,"NAME SECOND         (USN)");
glColor3f(1,0.5,0);
drawstring(68,50,0.0,"GUIDES:");
glColor3f(0.5,0.2,0.2);
drawstring(63,40,0.0,"GUIDE NAME FIRST");
drawstring(63,34,0.0,"GUIDE NAME SECOND");
glColor3f(1,0.1,1);
drawstring(32,10,0.0,"PRESS ENTER TO START");
glFlush();
}

Next is to write the code for the keyboard interaction which let user start the program. As in our case we have taken 'enter' key as our starting point. So when user press the 'enter' program leave the front page and start executing the main part of the project. Different keys may be assign for this job. Let's code a function called
myKeyboardFunc. This function will set flag value to 1  if the assigned key is press, thus making the way for displaying the main ideology of project.


void myKeyboardFunc( unsigned char key, int x, int y )

{
switch(key)
{
case 13:if(flag==0) //Ascii of 'enter' key is 13
flag=1;
break;
       }
    mydisplay();
}

The
mydisplay() function is called which will display the program execution on the screen. In this function we check the flag value and display according to that. If flag is not set to 1 (mean user has not pressed the key assign to start), front screen will display and if it set to 1 (mean user had started the program by pressing assigned key), the project will execute for what it is mean for. The code is simple as given below.

void mydisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
if(flag==0)
frontscreen ();
if(flag==1)
display();
}

The display() called above should contained and properly designed (coded) according to the requirement of the project. Functions need to be adjusted as one develop the project, so precaution must be taken and adjustment can be made to codes to make sure project work properly.

Note :  drawstring in above will display the strings so proper function need to be call for this. Also make sure  you must call 'glutDisplayFunc(mydisplay)' and 'glutKeyboardFunc(myKeyboardFunc)', in main function. Also do not confuse with display and mydisplay in main.

Saturday, March 10, 2012

Make Simple Paper Folding [Origami] using OpenGL


Origami is Japanese word, made up of - 'ori' means folding and 'kami' means paper. It is one of the traditional art of Japan, where things are made using the papers. In this art paper can be folded or sculpted in any way to make the items like - animals, birds, boats, ships, planes and other objects. No cutting and gluing is allowed. To know more about Origami read on Wikipedia.


Description: This project is simple one where one just Fold the paper and Unfold it. This project demo the entire process of folding as well as unfolding. Each folding section has been curved with the line, can be seen on the figure above. The single paper is divided into 8 cross sections and each folding position is marked. Each sates has been enumerated. The list of points make it possible to make the fold with recognizing what state to follow. While rendering and movement is done easily but folding with good angle specification is need. Motion of the Paper while it get fold(unfold) make more sense as it make more visibility to user.


Usages: Right click to see the menu, choose the option
             
               Reverse direction : Reverse the direction in which the paper is getting fold(unfold).
               Toggle motion : Motion on/off.
               Toggle spinning : Spin on/off.
               Quit : Exit the program.


Project Code: Download