Archived

This topic is now archived and is closed to further replies.

Xzibit

Ok im trying to do this and.....

Recommended Posts

Ok, i have a parmid then i have a background that made a square im having problems roateing just the parmid on top of the background when i do it the background moves and the parmid but i cannot get the background to just stay still... Also when the program plays for a few mins the parmid gets really really fast please help me --------------------------- X to da Z!

Share this post


Link to post
Share on other sites
G''day!

Assuming you''re using D3D (though I''m sure it''s similar in OpenGL) it sounds like you''re setting the world matrix once. Since you''re setting the world matrix up to rotate the pyramid, the background does as well.

Set your Matrix to the Identity (D3DXMatrixIdentity(&mat))
Set it as the World Matrix (m_device->SetTransform(D3DTS_WORLD,&mat);
Draw your background
Set your matrix for the rotation
Set it as your world matrix
Draw your pyramid.

I don''t know why it would be getting faster as time goes on, could you post the relevant piece of code?



Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT );
glClearColor(0.5f,0.5f,0.5f,1.0f); // We''ll Clear To The Color Of The Fog ( Modified )


glPushMatrix();
blah=0.0;
glBegin(GL_QUADS); // Start Drawing A Quad
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Quad
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Quad
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f( 1.0f,-1.0f, -1.0f); // Bottom Right Of The Quad
glColor3f(1.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, -1.0f); // Bottom Left Of The Quad
glEnd(); // Done Drawing The Quad

glPopMatrix();
glRotatef(theta,0.01f,0.3f,0.00f); // Rotate The Pyramid On It''s Y Axis
glPushMatrix();
theta+=0.001;
glBegin( GL_TRIANGLES );
glColor3f(0.5f,0.0f,0.0f); // Red
glVertex3f( 0.0f, 0.5f, 0.0f); // Top Of Triangle (Front)
glColor3f(0.0f,0.5f,0.0f); // Green
glVertex3f(-0.5f,-0.5f, 0.5f); // Left Of Triangle (Front)
glColor3f(0.0f,0.0f,0.5f); // Blue
glVertex3f( 0.5f,-0.5f, 0.5f); // Right Of Triangle (Front)


glColor3f(0.5f,0.0f,0.0f); // Red
glVertex3f( 0.0f, 0.5f, 0.0f); // Top Of Triangle (Right)
glColor3f(0.0f,0.0f,0.5f); // Blue
glVertex3f( 0.5f,-0.5f, 0.5f); // Left Of Triangle (Right)
glColor3f(0.0f,0.5f,0.0f); // Green
glVertex3f( 0.5f,-0.5f, -0.5f); // Right Of Triangle (Right)

glColor3f(0.5f,0.0f,0.0f); // Red
glVertex3f( 0.0f, 0.5f, 0.0f); // Top Of Triangle (Back)
glColor3f(0.0f,0.5f,0.0f); // Green
glVertex3f( 0.5f,-0.5f, -0.5f); // Left Of Triangle (Back)
glColor3f(0.0f,0.0f,0.5f); // Blue
glVertex3f(-0.5f,-0.5f, -0.5f); // Right Of Triangle (Back)

glColor3f(0.5f,0.0f,0.0f); // Red
glVertex3f( 0.0f, 0.5f, 0.0f); // Top Of Triangle (Left)
glColor3f(0.0f,0.0f,0.5f); // Blue
glVertex3f(-0.5f,-0.5f,-0.5f); // Left Of Triangle (Left)
glColor3f(0.0f,0.5f,0.0f); // Green
glVertex3f(-0.5f,-0.5f, 0.5f); // Right Of Triangle (Left)


glEnd();
SwapBuffers( hDC );
glPopMatrix();

thats the gl animation im using

---------------------------
X to da Z!

Share this post


Link to post
Share on other sites
are u using reseting the matrix with glLoadIdentity()

im guessing you''re not
so when u go

glRotatef(theta,0.01f,0.3f,0.00f);
glPushMatrix();
theta+=0.001;

its having an accumulating effect

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites