Original Post
Hello,
I have a lil problem here.. im into building a lil game a la quake, but i
cant get a correct positioning for my gun!
The 3d model of the gun is simply a cilinder made with gluCylinder..
My problem is that the gun move with the camera only in the -x axis but if i
look up or down the gun seems to stay with the world...
well i have pitch & yaw as values taken from the mouse movement... the thing
is that i cant get the gun to move with the viewer like quake or any other
game does... anyone have any idea?
I create the gun as a display list aswell.. what i do is this:
// Create the weapon''s display list
void CWeapons::CreateWeapon1(int index)
{
glPushMatrix();
glDisable(GL_CULL_FACE);
glNewList(index, GL_COMPILE);
glDisable(GL_DEPTH_TEST);
// Base color
glColor4f(0.8f, 0.8f, 1.0f, 1.0f);
// Use weapon texture
Texture.bind();
// Draw textured cylinder
GLUquadricObj* pQuadric1;
pQuadric1 = gluNewQuadric();
gluQuadricTexture(pQuadric1, TRUE);
gluCylinder(pQuadric1, 10.003, 10.004, 20.06, 25, 1);
gluCylinder(pQuadric1, 0.400, 0.404, 3.06, 25, 1);
// Delete quadric object
gluDeleteQuadric(pQuadric1);
glEnable(GL_DEPTH_TEST);
glEndList();
glEnable(GL_CULL_FACE);
}
Now in the rendering loop i do this:
void Render()
{
///////////////////////////////////////////////////////////////////
// Draw weapon
////////////////////////////////////////////////////////////////////
glPushMatrix();
glTranslatef(xpos, ypos, zpos);
// Create weapon
Weapons.CreateWeapon1(WEAPON_INDEX);
// Move with camera
float yRotation = radians(-yaw);
glRotatef(yRotation, 0.0f, 1.0f, 0.0f);
glTranslatef(1.0f, -1.0f, -0.65f);
// Call weapon list
glCallList(WEAPON_INDEX);
glPopMatrix();
}
anyone can help me out here?
thanks in advance