Search Projects

Monday, April 30, 2012

The Taj Mahal



Description:  No need description of this project as previously in the tutorial to build mini project on Taj Mahal most of the things were told. Let's remind few things like the Taj Mahal project is based on keeping cubes and spheres in place to build the gumbazz and the minars. Here two forms are made with one for outer and other the wire farmed, for inner one, with the tombs inside it.

Usages: 

Mouse interaction :  Right click to see the options
                                Taj : To see the outer Taj with full-spaced walled building.
                                Wired Taj : Wired Taj, with tomb inside which is made visible.
                                Exit : Quit program
Keyboard interaction: 
                                 w : Increase animation for Wired Taj
                                 e :  Decrease animation for Taj
                                 r :  Decrease animation for Wired Taj
                                 t :  Increase animation for Taj


Project Code:

Sunday, April 29, 2012

Shadowfun : Program to make fun with shadow of different objects





Description:  
This program demonstrates a light source and object of arbitrary geometry 
casing a shadow on arbitrary geometry.  The program uses OpenGL's feedback, stencil, and boundary tessellation support.

In other word it poses shadow of the different objects selected over the walls. There are two views in which one is normal say our eyes and other the object's eye. It look cool when you choose the object eye to view. Keeping the lights on/off make the things more delicate. There are many other things that is included in this with vast amount of understanding to implement those.

Usages:  Right click to see the options

Object shape : Selects the below objects with sub-menu selection
                           Torus
                           Cube
                           Sphere
                           Icosahedron
                           Double Torus
  Viewpoint :
                           Normal view : Normal Display
                           Light source view : Display as from the eyes of the objects (light source).
  Render mode :

                             With shadow : Shadow view on/off
                             With front shadow volume : Only Front shadow
                             With back shadow volume : Only Back shadow
                              Without shadow : No shadow
                              Without light : Light on/off
                              2D shadow boundary :  2d shadow boundaries.
  Action :
                  Spin object : Spin the objects.
                  Swing light : Swing the lights.
                  Stop : Stop
  Step rotate : increment the steps of movement.
  Quit : Exit Program.

Download : Project code


Those who want to works it on the Linux or Unix can compiles the code as below :

cc -o shadowfun shadowfun.c -lglut -lGLU -lGL -lXmu -lXext -lX11 -lm 

make sure you have OpenGl libray in the file system, if not get installed it.

Saturday, April 28, 2012

Fluid Filtration : a demo working of filtration of fluids


Description:  As name suggest this project will demo the filtration process of water or the other fluids. In this project a simple box which is the container is made with handle on the side. The simple line diagram is used to make the container box, for which appropriate functions is used. It is similar like drawing any polygons, the normals and vertices are precisely designed to make the accurate cuboidal box. Similarly with other polygon the filters is designed.
The animation of the fluid is designed with controlling the drawing of polygon mainly rectangular with proper vertices and normals, this is used within the loop. Also apart from animation of fluids in the pipes, the project adds additional controls to move the whole things - container and the fluids within the pipes along an axis with mouse.

Usages: Hold the mouse button to move the  container and the fluids within the pipes. As You leave the mouse the movements will stop. To move in forward hold left mouse button and fro backward hold right mouse button.

Download : Project code*

*There is some bug in the program so sometime it might not works like left and right mouse button didn't work or it will shows no respond .

Friday, April 27, 2012

Rigid Body Transformation : A project demonstrate Rotation, Scaling, Transformation



Description:  Rigid Body Transformations is one of  the most important applications in computer graphics.  It means Rotation, Scaling, Transformation of 3-Dimensional objects, like teapot, torus, cone, cube and octahedron. It also includes changes of background colors and rotations, including the 3 ways, like of  x-axis, y-axis and z-axis.The above operation can be done by using mouse interface.

A part from this a small header section is there at the top, which contains informations, like project name with it associates. The angle and velocity of rotation, is indicated on the header bar. A timer is also placed on header, which shows the times elapse as the program executed.


Usages:  Right click to see the options


 Rotation On : Set the rotation in the object.               
 Translation :
                         X - axis Translation On : Move objects in x-direction.
                         Y - axis Translation On : Move objects in y-direction.
                         Z - axis Translation On : Move objects in z-direction.
 Objects : Selects the below mentioned objects with sub-menu selection

                           Teapot
                          Cone
                          Cube
                          Torus
                         Octahedran
 Change Background :  Selects the colours mentioned below with sub-menu selection

                       Red 
                       Blue
                       Green 
                       Black
 Scaling On:  Put the scaling on objects.

Download : Project code

Thursday, April 26, 2012

Glutplane : Draw Planes with computer graphics in OpenGL

glutplane

Description:  There are many things we can play with paper. In our childhood we used to make things like ships, planes, frogs, birds etc. with the paper. That was just only child's play but still have creativity in it. There are complex things that can be made with paper. There are many branches of this, in which people use their creative mind to make things with papers like paper cutting or origami.

The projects on simple paper folding was demonstrated earlier, along with the video for the origami project. Now introducing the another paper creative work, with computer graphics. With figure you would have easily get that the project deals with making the planes. Simple figure planes are created in different types of colours. The projects allows to add more planes and also to remove them from the screen. It also allow to see static planes or watch them flying on the screen.

Basic Trigonometric functions has been used to bend the shape to make it look like plane. Also to have diffrent colours at the time of adding the planes, random function is used to select the colours randomly.  This same function is utilized for animation of the planes in different speed and directions. While for more glutVisibilityFunc is used for static or animation turns.

Usages: Right Click to see the options


Add plane : Add new plane from the screen in random colours.
Remove plane : Remove already present plane from the screen.
Motion : To keep the animation or movement on/off.
Quit : Exit program

Project Code: Download

Wednesday, April 25, 2012

Create Multiple instances of Stars


Description : Program to demonstrate the use of display lists: loads a shape using display lists then calls several instances. Also demonstrates the use of glutIdleFunc to animate the shapes.
 This program uses display lists to create multiple instances of a single object. The object used here is Star. Stars are created using the polygons with different points, which can be alerted.  The multiple instances of stars are called with the number of stars which too can be changed.

usages :
Mouse interaction

Right mouse button: Speed up the animation.
Middle mouse button: Slow down the animation.
Left mouse button: Reset to the default speed.

Keyboard interaction 


r: Speed up the animation.
t: Slow down the animation.
y: Reset to the default speed.
q: quit program.

Video demo


Download : Project code*

* If you have edited something, modified the program discuss about.

Saturday, April 21, 2012

Dynamic Sorting Algorithm Visualizer : Computer Graphics Project


Sorting can be defined as arranging list, number, or any times in an systematic way in a certain order of sequence having comparable properties. In simple word Sorting  is the process to rearrange the items of a given list in Ascending Order/Descending Order.

Previously in our Computer Graphics Project blog we have discussed about Bucket sort program a sorting program. In that Computer Graphics Project program the user uses to provide two input array to store and show the sorting process and result, while in this project the sorting is show dynamically with Circles representing the input list to sort. 


Description: The underlying concept of sorting algorithm includes the comparisons, swapping of elements, and assignments. The DSAV ( Dynamic Sorting Algorithm Visualizer ),  Visualizes the Bubble Sort Algorithm. In this algorithm, comparisons starts from the first two elements of the array and finding the largest item and move (or bubble) it to the top. With each subsequent iteration, find the next largest item and bubble it up towards the top of the array. 

This DSA Visualizer depicts the swapping of elements by swapping the circles (which are the items of the array in our case), for each item different radii of circle is generated according to the value of the item. This swapping process occurs for at the max of n iterations. Thus at the end of nth iteration,  the array of elements are sorted in the ascending order which is the desired output of the DSAV. Below is the logic or say short algorithm of  the Dynamic Sorting Algorithm Visualizer Computer Graphics Project.

Logic of sorting :
If not in the process of swapping of 2 circles then only get 2 new circles to swap.
While the counter_i < 10
While counter_j <9
If the a[counter_j] > a[counter_j]
Swap 2 circles
Once exchanged goto swap
Increment counter_j
                   Increment counter_i
            Swap:
             Print which circles are getting swapped.
            Call swap_circles function again with counter_j and counter_j+1 values.
            Mark the end of the function sort.


Usages: First the window generate will ask 'press enter to continue.....' ; press enter key
Menu is written with what to do on the screen it self.

Following is what keyboard will do after it get pressed - 

s  :      To start sorting
r :       To randomizes the sorted list
esc :   Exit

Project Code and Report for the program :

Video Demo

Wednesday, April 18, 2012

Build Taj Mahal mini projects in OpenGL, Computer Graphics

Taj Mahal (ताज महल), is the symbol of love. It  is a white Marble mausoleum located in Agra, INDIA. It was built by Mughal emperor Shah Jahan in memory of his third wife, Mumtaz Mahal. For more info read wikipedia.

Here, we are going to develop basic structure of Taj Mahal in computer graphics. In this tutorial I will tell how to make Taj like structure using the OpenGL. We will develop simple structure, not exactly same as it looks in real but some what idealistic. This project is mainly mean for the VTU Computer Graphics mini-projects.




Taj Mahal is basically a structure with many minars and gumbazz. We will use the simple objects like spheres and cubes to build these units. First for the main part we use box or a large cube and then point small sphere over them. Thereafter, we place a small cubical structure with very low height, a egg like sphere is also placed over it. Similarly,we going to place four long minars over each four corners.

We are also developing the wired framed structure of the Taj as well. In the wired framed Taj, the large cube block will go transparent and the two tombs will be place in the middle with small cubes.

Lets start coding!



/* Draw the bottom box */
glPushMatrix();
glScaled(0.8,0.04,0.8);
glTranslatef(0.0,-30.2,0.0);
glutSolidCube(7.0);
glPopMatrix();

    //main cube
    glTranslatef(0.0,-.6,0.0);
glutSolidCube(2.0);

//main gumbazz
glPushMatrix();
glScaled(0.8,1.0,0.8);
glTranslatef(0.0,1.5,0.0);
glutSolidSphere(0.8,80,120);
glPopMatrix();

glTranslatef(0.0,1.0,0.0);
glScaled(1.2,0.25,1.2);
glutSolidCube(0.9);

//gumbaz pointer

glPushMatrix();
glScaled(0.03,0.5,0.03);
glTranslatef(0.0,10.8,0.0);
glutSolidSphere(0.4,80,120);
glPopMatrix();

//Minars
glPushMatrix();
glTranslated(2,-1.9,2);
glScaled(.2,10.5,.2);
glutSolidSphere(0.4,80,120);
glPopMatrix();

//minar's sphere
glPushMatrix();
glTranslated(2,0.8,2);
glScaled(0.3,1.5,0.3);
glutSolidSphere(0.4,80,120);
glPopMatrix();

//Minars
glPushMatrix();
glTranslated(-2,-1.9,2);
glScaled(.2,10.5,.2);
glutSolidSphere(0.4,80,120);
glPopMatrix();

//minar's sphere
glPushMatrix();
glTranslated(-2,0.8,2);
glScaled(0.3,1.5,0.3);
glutSolidSphere(0.4,80,120);
glPopMatrix();


//Minars
glPushMatrix();
glTranslated(-2,-1.9,-2);
glScaled(.2,10.5,.2);
glutSolidSphere(0.4,80,120);
glPopMatrix();

//minar's sphere
glPushMatrix();
glTranslated(-2,0.8,-2);
glScaled(0.3,1.5,0.3);
glutSolidSphere(0.4,80,120);
glPopMatrix();

//Minars
glPushMatrix();
glTranslated(2,-1.9,-2);
glScaled(.2,10.5,.2);
glutSolidSphere(0.4,80,120);
glPopMatrix();
 
//minar's sphere
glPushMatrix();
glTranslated(2,0.8,-2);
glScaled(0.3,1.5,0.3);
glutSolidSphere(0.4,80,120);
glPopMatrix();

//short Minars
glPushMatrix();
glTranslated(0.6,-0.5,0.6);
glScaled(.2,11.5,.2);
glutSolidSphere(0.2,80,120);
glPopMatrix();

//short minar's sphere
glPushMatrix();
glTranslated(0.6,0.5,0.6);
glScaled(0.3,1.5,0.3);
glutSolidSphere(0.4,80,120);
glPopMatrix();

//short Minars
glPushMatrix();
glTranslated(0.6,-0.5,-0.6);
glScaled(.2,11.5,.2);
glutSolidSphere(0.2,80,120);
glPopMatrix();

//short minar's sphere
glPushMatrix();
glTranslated(0.6,0.5,-0.6);
glScaled(0.3,1.5,0.3);
glutSolidSphere(0.4,80,120);
glPopMatrix();

//short Minars
glPushMatrix();
glTranslated(-0.6,-0.5,-0.6);
glScaled(.2,11.5,.2);
glutSolidSphere(0.2,80,120);
glPopMatrix();

//short minar's sphere
glPushMatrix();
glTranslated(-0.6,0.5,-0.6);
glScaled(0.3,1.5,0.3);
glutSolidSphere(0.4,80,120);
glPopMatrix();

//short Minars
glPushMatrix();
glTranslated(-0.6,-0.5,0.6);
glScaled(.2,11.5,.2);
glutSolidSphere(0.2,80,120);
glPopMatrix();

//short minar's sphere
glPushMatrix();
glTranslated(-0.6,0.5,0.6);
glScaled(0.3,1.5,0.3);
glutSolidSphere(0.4,80,120);
glPopMatrix();



Project Docs : 

Saturday, April 14, 2012

Tutorial How to display strings in OpenGL mini projects

In the previous post, which highlights on making a front screen for the OpenGL mini projects a function called drawstring was shown but didn't explained well as it was assumed to be understood easily by the students but few of them demand it's code, which was not there. To help them out and sort the error they have,  here I made a simple tutorial to show, how we can display a string in the projects.

To display strings in the project we can make function in different ways, call the defined front in OpenGL API. How to code is depend on the coder, what he want to do with the string and how he want to display it. Matter of fact is that the necessary things is to make sure once a function is made it must be flexible enough that Front sizes and the colours can be changed easily when ever needed, wherever needed. Keeping in the mind that A simple function is code, of which stepwise process is defined below. You can also see the different fonts demo.



First declared  a indentifire that will hold the current font type -

void *currentfont;

After the declaration of this, we define a function which will change the fonts or say set the font which we can to to display with the strings. Code for this is easy, just make a function called setFont(), code given below -


void setFont(void *font)
{
currentfont=font;                      // Set the currentfont to the font
}


Sunday, April 1, 2012

A mini project on Clock using OpenGL





Description: The Project is idea to display the clock with computer graphics.  This project just used the local time, fetching from the computer and display it on screen. This project  implements the wall clock with the round circular board and three conic geometrics which forms the different (sec, min & hour) hands. Small cubes are also made for the minutes, while each hour is represented with a large block. Digit display of the clock timing is also placed at the bottom.
The 'localtime(&ltime)'  function is used to get the local time. With proper maths and conversion of the time for sec, min and hours the graphical hands are made to make movement. This project made two views one ortho and other perspective.

Usages: Right click for the options
                     About the Project : Display information about the project
                     Toggle Ortho/Perspective view : Switch between the Ortho and Perspective views.
                     Light on/off : For light on clock and off it.
                      Quit : Exit program.

Project Code: Download