Archive Pages Design$type=blogging

A Moving Mesh

Are you looking to something, that easy to implement for your CGV project? Then you are here going...

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.

COMMENTS

Name

3D Bi-Cycle 3D Game 3D Laptop 3D Objects 3D Projects 3D Zoo Algorithm Android Aquarium Bellman-Ford Algorithm Block Breaker Blockshooting Bucket Sort C# Chess Clock Code Blocks Colors Complex Project Complex Projects Crab Pong Cross Zero DSAV Escapa First Come First Serve Fluids Font Demo Games Gear Motion GlutDino Glutplane Graphics Editor iOS iPhone Java Java OpenGL Graphics Programming Light Torus Linked List Ludo Board Game Mancala board games Memory blocks game Memory Game Menu Mickey Mouse Minesweeper Miniature Steam Engine moth Motion Blur MoveLight moving car Moving Ship Multiplex Networking Based Project Nuclear Power Plant Olympic opengl c++ examples OpenGL ES OpenGL Tutorial Origami OS Based Projects Paint Paper Folding Particles Drop Path Finding ping pong Pong Game Project Report Projects Report Puzzles qix like Random Flowing lines Rigid Body Rings Robot sample c++ opengl code Screen Saver Screen Saver Ship Shadow Cube Shadowfun Ship Iceberg Simple Drawing Simple Haloed Lined Wireframe Simple Move Light Simple Project Simulation SNAKE XENZIA GAME Solar system Sorting Sphere Spot Light Swing Stars Taj Mahal The Edge Game Tic Tac Toe Tower of Hanoi Traffic Signal Transformation Triangular Animation Tutorial water ripple effects Whirlpool
false
ltr
item
OpenGL Projects: A Moving Mesh
A Moving Mesh
https://4.bp.blogspot.com/-UzeDk0cUOIE/Vxu62OAv9qI/AAAAAAAAHqU/ezRisui9pXcu0u7wqLbEv2R2Ob0V7y1iACLcB/s400/a%2Bmoving%2Bmesh.PNG
https://4.bp.blogspot.com/-UzeDk0cUOIE/Vxu62OAv9qI/AAAAAAAAHqU/ezRisui9pXcu0u7wqLbEv2R2Ob0V7y1iACLcB/s72-c/a%2Bmoving%2Bmesh.PNG
OpenGL Projects
http://www.openglprojects.in/2016/04/a-moving-mesh.html
http://www.openglprojects.in/
http://www.openglprojects.in/
http://www.openglprojects.in/2016/04/a-moving-mesh.html
true
2020194800836807725
UTF-8
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago