3d gun fps
#1
Posted 02 August 2012 - 02:59 AM
#2
Posted 02 August 2012 - 04:02 AM
Several ways, actually. Let's start with the most obvious and least useful, then move to the useful ones.Hey, is it possible to make a kind of 3d hud? I made a 3d model for the gun in my fps, but with rotations is no way precise, it should alway be in the same exact position in the screen, thing that never happens with 3d rotations, so is possible to make a kind of 3d hud? To show the gun always in the same position? The gun is a 3d model.
- Use transformations to keep the gun in the right spot and pointing in the right direction. Use d3d_transform_add_rotation_axis and some math.
- Set an orthogonal projection and draw a gun sprite.
- Set a new perspective projection (at <0,0,0> facing toward <1,0,0> no matter where the other projection is or what direction it's facing) and draw the gun model there without additional transformations.
#3
Posted 02 August 2012 - 02:10 PM
Transformations are so bad, is incredibly hard to keep the gun in the same position using them...Several ways, actually. Let's start with the most obvious and least useful, then move to the useful ones.
Hey, is it possible to make a kind of 3d hud? I made a 3d model for the gun in my fps, but with rotations is no way precise, it should alway be in the same exact position in the screen, thing that never happens with 3d rotations, so is possible to make a kind of 3d hud? To show the gun always in the same position? The gun is a 3d model.
- Use transformations to keep the gun in the right spot and pointing in the right direction. Use d3d_transform_add_rotation_axis and some math.
- Set an orthogonal projection and draw a gun sprite.
- Set a new perspective projection (at <0,0,0> facing toward <1,0,0> no matter where the other projection is or what direction it's facing) and draw the gun model there without additional transformations.
The gun isnt a sprite, is a 3d model.
Sounds great, won't be able to make the gun be in the character's hand (the character is drawn without head and the 3d projection where the eyes should be, so you will see the hand with nothing in it) but still sounds like the best way..
Could you please explain a good way to do the 1 or the 3?
#4
Posted 02 August 2012 - 08:40 PM
Why? You know where the "camera" is, you know what direction it's facing. You know which direction is up. Rotate the gun to point in the direction the camera is facing (using 2 transformations if you can't figure out how with 1), rotate it again to have the correct up vector, and translate it to the camera's position. You can even combine all the rotations into a single one, if you know how.Transformations are so bad, is incredibly hard to keep the gun in the same position using them...
I gathered. However, if you're really unable to use transformations, rendering the gun model to a sprite and drawing that may be easiest for you.The gun isnt a sprite, is a 3d model.
Draw the hand in the same way or just use method 1 with the hand's set of transformations.Sounds great, won't be able to make the gun be in the character's hand (the character is drawn without head and the 3d projection where the eyes should be, so you will see the hand with nothing in it) but still sounds like the best way..
3 has already been explained. Go read it again. Notice how explicit the instructions are.Could you please explain a good way to do the 1 or the 3?
#5
Posted 02 August 2012 - 09:11 PM
The 3 is explicit, but when i try to draw the main projection, draw the gun, draw the second projection, it shows only the last projection...
#6
Posted 02 August 2012 - 09:59 PM
That could mean so many things. Also pointless. The calculations will be extremely similar to, if not exactly the same as, the calculations to have the gun face in the direction of the camera.Yes, i know where the camera is and where is looking at, of course. And to rotate the gun according to the camera isnt a problem, the fact is that the gun should move also, it should be in the exact position on screen wherever you are looking at...
The 3 is explicit, but when i try to draw the main projection, draw the gun, draw the second projection, it shows only the last projection...
Edited by Gamer3D, 02 August 2012 - 11:11 PM.
#7
Posted 02 August 2012 - 11:11 PM
#8
Posted 03 August 2012 - 10:39 PM
d3d_set_projection_ext is what im using, but if i set 2 projections it shows only the second, plus how could i let it know that of the second projection should show ONLY the gun?That could mean so many things. Also pointless. The calculations will be extremely similar to, if not exactly the same as, the calculations to have the gun face in the direction of the camera.
Yes, i know where the camera is and where is looking at, of course. And to rotate the gun according to the camera isnt a problem, the fact is that the gun should move also, it should be in the exact position on screen wherever you are looking at...The 3 is explicit, but when i try to draw the main projection, draw the gun, draw the second projection, it shows only the last projection...
Did you set an orthogonal projection BEFORE setting the second? Because that messes it up for some reason.Use d3d_set_projection_ext. Just setting another projection, on the other hand, works fine.
#9
Posted 04 August 2012 - 04:24 AM
d3d_set_projection_ext is what im using, but if i set 2 projections it shows only the second, plus how could i let it know that of the second projection should show ONLY the gun?
Ah. That's where the disconnect is. The correct order is:
- Set primary projection.
- Draw everything that you want the primary projection to show.
- Set secondary projection.
- Draw gun.
It sounds like you have this order:
- Set primary projection.
- Set secondary projection.
- Draw everything that you want the primary projection to show.
- Draw gun.
#10
Posted 04 August 2012 - 11:24 AM
Aww then it could be a problem because is not drawn everything from the same object, there's different objects with his draw event, obviously the camera draws first, so everything is drawn after the last projction i set...
d3d_set_projection_ext is what im using, but if i set 2 projections it shows only the second, plus how could i let it know that of the second projection should show ONLY the gun?
Ah. That's where the disconnect is. The correct order is:
- Set primary projection.
- Draw everything that you want the primary projection to show.
- Set secondary projection.
- Draw gun.
It sounds like you have this order:
- Set primary projection.
- Set secondary projection.
- Draw everything that you want the primary projection to show.
- Draw gun.
#11
Posted 04 August 2012 - 09:20 PM
Gamemaker draw order is determined by the depth variable. Give the camera a ridiculously high depth and the gun-drawing/gun-projection object a ridiculously low depth.Aww then it could be a problem because is not drawn everything from the same object, there's different objects with his draw event, obviously the camera draws first, so everything is drawn after the last projction i set...
#12
Posted 07 August 2012 - 02:22 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











