Jump to content
  • Advertisement

Archived

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

vic

problems with gun positioning!!

This topic is 6586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Or you could draw the gun before moving the camera about.

- Peter

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you make the gun rotate up and down, as if it where rotation left and right, hell, its practicaly the same as the code for making the gun rotate left and right when you turn. The only difference is, whn you look up, you will be looking above the gun, and it will be out of your sight, so all you have to do then, is move the gun upwards a small ammount, according to how far you looked up.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you make the gun rotate up and down, as if it where rotation left and right, hell, its practicaly the same as the code for making the gun rotate left and right when you turn. The only difference is, whn you look up, you will be looking above the gun, and it will be out of your sight, so all you have to do then, is move the gun upwards a small ammount, according to how far you looked up.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!