Sign in to follow this  
da-funk

OpenGL Help, adding a weapon model to a shooter.

Recommended Posts

Hello people, I'm a noob at opengl but as a final project at college i decided to make a simple shooter (very simple one). so i made the world and everything, i used glLookAt() function to explore the world with camera , and now i wanted to add a gun model instead of the mouse cursor, that means i want a 3d gun model (.MD2 / .3DS / .MD3) to be fixed at the bottom/center of the screen like a real shooter. i tried to use GL_PERSPECTIVE to achieve that , but i never get the desired outcome. i'll add code and everything needed ! please , i'm running out of time... Thanks for your time.

Share this post


Link to post
Share on other sites
Hi,

After you draw the scene, use glLoadIdentity() to reset your matrices and display the gun like you would do to just render the gun.

Share this post


Link to post
Share on other sites
hey, thanks for the fast response.
i tried what you told me to like so:

.
. // rest of the scene
.
drawGunSight();

glLoadIdentity();
m16->Draw(); // draw 3ds weapon model


and i don't see the gun at all.

i made sure he would be painted in the right place.

Share this post


Link to post
Share on other sites
you may be rendering the gun outside the clipping area of your screen.

What are are near and far clipping planes set to?

Render your gun with an offset so that it shows up infront of your camera rather than at the location of the camera.

Share this post


Link to post
Share on other sites
Hey, wow thanks guys finally i made it, i got the gun up and running, but as i progress a new problem arise , now the gun won't stop reloading(bullets) and shooting animation .. i tried to set the animation number for a different int other then 0 , but still nothing , it keeps moving. here is the code i used.


glLoadIdentity(); //clear the matrix
glTranslatef(0.05 , -.03, -.1); // pos of gun
glRotatef(205.0 , 0.0 , 1.0 , 0.0);
glRotatef(-15.0 , 1.0 , 0.0 , 0.0);
glRotatef(-5.0 , .0 , 0.0 , 1.0);
Pickup.DrawModel ( bAnimated ? timesec : 0.0 ); //draw md2 model

the definition of timesec is like so:

CTimer::GetInstance()->Update();
float timesec = CTimer::GetInstance()->GetTimeMSec() / 1000.0;

i'm sure there's a smarter way of doing that :) , thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this