Search Projects

Monday, January 25, 2016

Torpedo OpenGL Code Example

Torpedo are basically self-propelled weapon cylindrical shaped (more like a cigar-shaped), which can be fired either underwater or above water fired from ship, submarine. It  designed to detonate either on contact with its target or in proximity to it.

Today we are presenting the OpenGL Code Example for Torpedo. We are going to draw Torpedo in Visula Studio C++ using opengl graphics API. This program is an enhancement of torpedo with a texturing of the body and the blades. This Program is written by Sumanta Guha. We are presenting the same version of code with no modification.


Understand the Problem

Every project we do, first we have to analyze the problem. So first we have know the structure of torpedo. After that we have do decide how the design can be drawn using the available objects in OpenGL API. We done with the design of Torpedo, we have give the motion with some keyword functions.

Design the structure of torpedo

Our Torpedo will have the following parts -
  • A cylindrical body with hemi-spherical front face.
  • 3 rotating blades attached to shaft at the back face.
  • 3 curved fins attached in middle of body at equal distance.
There separate functions/routine defines of each of the objects for this OpenGL Code Example program. For draw hemi-sphere we have separate routine, which uses the latitudinal triangle strip, cos and sine function with proper logic. For blades the chessboard structure is used. While the whole body is give stripes with two different colors.

Bezire curves is used for the blades. The Control points for a propeller blade Bezier surface and Control points for the texture co-ordinates Bezier surface is defined. These are used for giving a textures to the blades and the body.

Interaction in the Program

Without having the user interaction in a program, it make the whole experience a dull one. The OpenGL Code Example program for Torpedo have the keyword interactions.

  1. Press space to toggle between animation on and off.
  2. Press the x, X, to rotate the viewpoint in the x-direction both forward and backward.
  3. Press the y, Y, to rotate the viewpoint in the x-direction both forward and backward.
  4. Press the z, Z, to rotate the viewpoint in the x-direction both forward and backward.
This is done by adding animation function to the display and giving the key their role for motion. You can download the whole Torpedo OpenGL Program Code with the link given below.


2 comments:

  1. Please send the source code for this project to geethapbdvt@gmail.com

    ReplyDelete