PDA

View Full Version : Shooting



01-11-2001, 12:39 PM
how can i make my engine shoot like a normal game like quake3?

Michael Steinberg
01-11-2001, 12:43 PM
What do you mean?
You mean, take a gun and shoot?
Give any weapon a normal at which the patrons (?) exit. Randomly change it a bit. Take it as a line and look for any intersections with polys in world and models.
You could also take the gravity and the speed of the shot thing in account.

Michael Steinberg
01-11-2001, 12:44 PM
Of, course, if you would take speed in account, you'll not take it as a line but as a bunch of straights (?). And then test wether this straight intersects any geometry.

01-11-2001, 01:02 PM
how do i now where the gun is pointing at
at the centerof the screen duhh
but where is that
how can i calculate that?

Elixer
01-11-2001, 02:19 PM
You want to calculate the center of the screen/window? Err just do screenX/2 & screenY/2. That will put you in the center.

Or do you mean after you do some rotations? In that case, you can tell which direction your pointing by using a matrix, and taking elements 8,9,10 which will show you which direction your pointing. (but that is a bit advanced)

01-12-2001, 08:06 AM
okay
but can you please type the code
i know what you mean but don't exactly know how to do that

Michael Steinberg
01-12-2001, 08:28 AM
Since I'm coping with OpenGL like matrices that is not correct. In that case, elements 3,7,11 will give the z-axis (which is front-vector for me).

Elixer
01-12-2001, 09:49 AM
Michael, is correct, it is 2,6,10.


(Oh, as for the code, x=scrnX/2 y=scrnY/2. Or did you mean the matrix way?)


[This message has been edited by Elixer (edited 01-12-2001).]

Michael Steinberg
01-12-2001, 10:22 AM
I was actually wrong. It has to be 2, 6 and 10.

01-13-2001, 09:44 AM
how do i get those matrixes
en with the screen x and y coords
i don't know how to calc the world coord for that point

Michael Steinberg
01-13-2001, 05:35 PM
I assume that you have any faces of the world defined in world coordinates. You have your position well defined.
I always have my own exemplar of the "fov" modelview matrix and load it up to opengl. But you can also get the matrix with glGetFloatv(...), I think.
Oh, and I made a mistake, it has to be the indexes 2,6,10, as elixer stated.

Elixer
01-13-2001, 10:16 PM
Well, to get a matrix from openGL pipeline, do: glGetFloatv(GL_MODELVIEW_MATRIX, mat); where mat is float mat[16].

For what it is worth, check out the long thread about this very subject about matrix.

To some it up, openGL matrix is:
0 4 8 12
1 5 9 13
2 6 10 14
3 7 11 15
1st 3 in row 1 =x 1st 3 in row 2=y and so on. Remember these are vectors. (xyz for each). 12,13,14 is the translation.
It is better to read other thread to understand better though.
So you want to take the z which is the direction, and add it to get new position of the particle your shooting.



[This message has been edited by Elixer (edited 01-13-2001).]

plucky
01-14-2001, 09:56 AM
i had been having a lot of trouble understanding matrices as well, until i ran across these two articles online :

update:: (this is also a really good article) http://www.gamedev.net/reference/articles/article695.asp
http://www.gamedev.net/hosted/3dgraphics/tutorial/points/transformations.htm
http://web2.airmail.net/sjbaker1/matrices_can_be_your_friends.html

so take a look at those, and hopefully things will be a bit clearer (oh by the way, i think there is an error in the 2nd article, it says that matrices in opengl are stored with the first row being 0,1,2,3 when i'm pretty sure the first row is 0,4,8,12.. so just ignore that part http://www.opengl.org/discussion_boards/ubb/smile.gif


[This message has been edited by plucky (edited 01-14-2001).]

01-15-2001, 10:14 AM
thanx i shall look at that now