PDA

View Full Version : Smooth Rotation of large triangle mesh

Mario1982
10-20-2009, 07:18 AM
Hello,

I've written a program that loads wavefront files to perform some manipulations on a triangle mesh with roughly 50k triangles.

The problem i am having is that when i rotate about the Y and Z axis the rotation jitters like a slideshow, when i rotate around the X axis it is very smooth.

My question is this: Is there any article or method to achieve a smoothe rotation?

Thank you.

marshats
10-20-2009, 12:01 PM
Maybe looking at a previous post will help -- see post #261909 (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&amp;Number=261909#Post2619 09) and the replies about using dt to scale time.

Or maybe that is irrelevant. It is hard to say without a snippet of code. Can you show the relevant display() code?

Brolingstanz
10-20-2009, 02:06 PM
Make sure you're not doing something silly like axis == Y || axis == Z ? WobbleHorribly() : RotateSmoothly();

Go ahead and laugh but I've done things like that before.

Mario1982
10-22-2009, 04:01 AM
I first pick up the events that give me X and Y coordinates on mousedown on the screen and depending on the direction the mouse is moving (using mouse move event) set the relevant rotX, rotY to rotate by 2 in that direction. Then after in the draw function i set rotX Y and Z to 0 so it doesnt continue to rotate if the mouse button is left down.

As for rotZ uses the X coordinate but only when the middle mouse is down.

void __fastcall TmainForm::drawMesh()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

if(currmesh!=0)
{
glTranslatef(0,0,zoom);

if(b_GUIMouseDown)
{
glRotatef(rotX, 1, 0, 0);
glRotatef(rotY, 0, 1, 0);
glRotatef(rotZ, 0, 0, 1);

rotX=rotY=rotZ=0;
}

// after this i call the draw class which just draws the triangle
// mesh on the screen at this location
...
}

What i find strange is why its smooth on one of the axis and jittery on the other two.

Mario1982
10-22-2009, 06:44 AM
Hi,

Thanks for all your posts after taking a look at the recommended reading by marshats i went throught my code and found that i call the draw function for certain transformations in this class so when i try to rotate im drawing mutiple times. Now its smooth. I missed this because there is a large amount of code and it takes a while to go through.

Thank you again.