Search Projects

Tuesday, March 13, 2018

Robot Computer Graphics Program in C

OpenGL is amazing, it have potential of great stuffs from creating a small triangle to big structures. We have seen many robot program in OpenGL. Here we come with another robot computer graphics program in C with the use of OpenGL API.

Features 

  • A human features with hands,legs, neck, head and face drawn with simple approach.
  • A colorful robot with animation made.
  • A dat file created that used as input for certain restrictions which we can't hard code in program.
  • Four header files used -
    1. vars.h - It contains all the global variables used in the program. Also have dimension for the body if the robot.dat is unreadable or not present.
    2. file.h -  This header used for reading input from robot.dat file.
    3. keyboard.h -  As name suggests it contains keyboard input functions.
    4. mouse.h - Same as keyboard.h, it also have mouse input functions.
  • Program uses selection buffer to determine what body part was selected, the judging by button pushed and mouse movement, the proper transformation is executed.

Main Functions

main();                            read data file, initialize glut stuff
     init();                              lighting and material stuff, initialize matrices to identity
     display();                        glut display function (calls display_robot(rendermode))
     display_robot(mode);    call each of the body part functions
     reshape_window();       glut reshape function

     draw_body(mode);        draw the torso and neck
     draw_head(mode);        draw the head and face
     draw_leftarm(mode);     draw all of the left arm
     draw_rightarm(mode);    draw all of the right arm
     draw_leftleg(mode);     draw all of the left leg
     draw_rightleg(mode);    draw all of the right leg

Mouse Interface:
   To translate the robot (x, y direction): click the right mouse button on the torso,
      and drag it around the screen.  Once the button is released, the robot will move (in
      the direction of the vector from where the button was pushed to where it was released)
   To move the robot forward and backward (z direction):
      right click once on the torso to move it forward
      left click once on the torso to move it backward
      note: the amount which the robot moves in the z direction for each click can be
        adjusted using the '-' and '+' keys.  (default == 0.2), each adjustment is by 0.2
   
   To rotate body parts or the torso(about x or y axis):
      left click on the body part you want to rotate. (hold in the button)
        then drag the mouse the direction you want the robot to rotate.
        upon release of the button, the rotation will occur.
        (the amount of rotation is the distance of the drag (in pixels) mod 360)
   To rotate about the z axis:
      click and drag with the middle button.  the amount of rotation is determined
        by the horizontal change (mode 360)

Keyboard Interface:
   Rotations:  push 'q' for x axis, 'w' for y, 'e' for z
               push 'Q' for -x, 'W' for -y, 'E' for -z
               then choose the body part with, 0-9, 'o','p','[',']'
                  0-torso, 1- head, 2-leftupperarm, 3-leftlowerarm, 4-leftwrist
                  5-rightupperarm, 6- rightlowerarm, 7- rightwrist,
                  8-leftupperleg, 9- leftlowerleg, 'o'- left foot,
                  'p'-rightupperleg, '['-rightlowerleg, ']'-right foot
   Translation:
               use same q,w,e and Q,W,E for axis/direction selection
               then push 't' to translate
               use + and - to adjust the amount of translation




Thursday, March 8, 2018

Flag of USA

We have already seen two flags Programs  - OpenGL Flag Hoisting program with Our Indian Tricolor and OpenGL program on flag of South Africa. Today in this post we are going to see another flag program. This flag is about USA.

Challenges

Flag of usa have mainly two parts - one with pattern of stars other the stripes. While maintaining the ration of flag, the pattern has to be drawn in left corner and white and red stripes to rest of the flag. Another problem is the 7 stripes along side of star patterns are smaller in length, we have to keep in mind about it.

Approach

First thing is done by drawing the star with GL_TRIANGLE_FAN, using the proper coordinates and angles. Next we draw the pattern of stars using the for loop function with if else conditions, which determines the alternate between rows of five or six stars.

Define a int variable that holds the value of no of stripes(13). This helps in drawing the stripes in loop as well as determine the number of stripes left. This variable also helps in fixing the length of 7 smaller stripes. Alternate stripe colors is done using the if else, and odd even conditions in it. The GL_QUADS has been used to drawn the stripes.

Unlike our other flag programs here we are displaying the whole screen with flag only. Also there is no pole and no hoisting like we have in Computer graphics OpenGL Flag Hoisting program .  You can watch the video demo of this projects on Youtube.




Source Code

Shoot an email to openglprojects@gmail.com for the Source code of this OpenGL Program, we will sent instruction to get the source code.

Thursday, March 1, 2018

3D Martyr’s Monument -Shaheed Minar

A Very Good 3D Project on Martyr’s Monument (Shaheed Minar) Submitted by Nayeem. It is a 3D Computer Graphics OpenGL projects based on Bangladesh Shaheed Minar or Martyr’s Monument.

Note : - This Projects is submitted by Nayeem through the Submit Your Project which you can too submit as well.



Introduction:

Martyr’s Monument (Shaheed Minar) is based at Dhaka, it was projects idea of teacher of Nayeem from Ahsanullah University of Science and Technology Dept. of Computer Science and Engineering. It is wonderful projects based on the ideal martyrs monuments. It is also a tribute for martyrs and to remember them by laying down flowers to the Martyr’s Monument.

Tools:

For this lab Project, they have used the OpenGL 3. The GLUT library has bee used to access OpenGL function. The basic concept from OpenGL which envolve this 3D Martyr’s Monument project are as follows -
  • Transformation
  • Timer
  • Color
  • Lighting
  • Textures
  • 3d text



Feature: Now we will discuss about the features of this project which are as following -

  • The project showcase the Shaheed Minar Structure of Dhaka with the perfect scale.
  • The structure was design this architecture with perfection with compute graphics using opengl.
  • Different texture like grass, sky and tiles used in this program to give more realistic look.
  • There are two mode in the project which show the structure in Day and Night Lighting combination.
  • There is an option to rotate Shahid Minar at 360o.
  • It also have text display in 3D.

  • Obstacle:

    The main Challenge in completing the project was to find the right coordinate to draw plane for object surface. It was really very challenging finding original coordinate display it perfectly.

    Future work:

    • Add City View and flower dropping on base.
    • Add many peoples around the structure who pay homage by flowers etc.
    • Add boundary and other stuffs.
    • Add more animation to the project.
    • Add sound and music to the project.


    Download:

    You can download the source code of the project from Github as well as report from there.