Skip to main content
gamedev.net
🔒 Locked

problems with gun positioning!!

Started by vic Nov 28, 2000 at 6:01 AM 7 replies 750+ views
Original Post
vic
vic
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
Strylinys
Strylinys
Two things you could do.

1. Make the gun a flat texture that stays on the screen at all times... No depth testing or whatever...

2. Rotate the gun on the x-axis however many degrees you have the camera looking up. Then, if the gun rotates but doesn''t stay on the screen, then you''ll just have to shift it vertically a bit.

S.
vic
vic
well the problem is that i dunno whats happening i dont have much to try with..

after the list is compiled i guess i could display the gun only by doing this:

glPushMatrix()
glLoadIdentity()
glCallList(WEAPON_INDEX)
glPopMatrix();

it would reset the matrix and the weapon would stick to the camera...

well the problem is that this doesnt work.. the weapon doesnt show on the screen, unless i do a glTranslatef(CamX, CamY, CamZ)
and remove the line glLoadIdentity()

but by doing this the weapon will take the world transformations, and when i rotate the camera horizontally or vertically the weapon wont move, it will be as a object in the world... i cant really see why that doesnt work..
could it be the way i compile the list? maybe gluCylinder?
honestly, im losing it here.. have no idea for such a thing.. should be simple, thats what i thought when i started =) not true eheh
well let me know if anyone have any solution or know about this!
thanks in advance
kashey
kashey
are you stuped(both)
you wanna to rotate weapon??? in y axis????
you write
glRotatef(yRotation, 0.0f, 1.0f, 0.0f);
yes it good
but why you think that you need to use 0,1,0 parameters
y-axis is not rigth thing you use


you must use parameters as 0,0,1

and call rotate up to 2
x and z axis

weapon is not you!
weapon is path of the world

aloso if you realy wanna do smb look like quake you must stop using this shit(glu)

just bild you own vertex model.

and bild main class, wich will provide all operation(rendering,collusion detection and others)
and all problem will fly away

alse you might you BPS tree or smb look like it
kashey-deadless

cool programer
vic
vic
hi kashey

well, i was just trying whatever pumped in my head that i thought could make it work..
anyway about using glu shit, well its a fast way to get your ideas to show up on the screen.. when i get this to work, then ill make it work with my own weapon models, for now i just want to make it work!

also BSP or whatever you mentioned, i dont need that for a damn simple weapon.. its just a weapon to stick to the camera''s movements, a simple backface culling algo would be enough to remove invisible faces of the weapon''s model, since the weapon wont roll, or anything like that.. it will just stay there, with sum simple movements as you walk.. but ill add it later when i get the gun to work

well but thanks for the comments anyway..
vic
vic
yeah i changed my mind and deleted all that cylinder stuff..
now im loading a 3d model and using it..
well actually now it works, just im still wondering why didnt work with the cylinder shit... ah well, forget it less trouble in my head...

anyway i know what u talking about but i didnt want it like that.. i knew it should be stuck to the camera, with no need for rotations or crap like i did.. well now its ok, and i guess this is the best way.. and fast

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.