Advertisement

Collision Detecting

Started by January 12, 2001 06:12 PM
32 comments, last by Running_Wolf 24 years ago
wavarian: The line that says, "if ((x1 > 0.0) && (x1 < 0.0))" is part of my code to see if the point is in my quad. It still stands to reason that I need to make them equal to. I just wanted to make sure that we were talking about the saem thing.
L.I.G. == Life Is Good
I wrote a simple collision for wall 90 degree from the floors
quad walls can be angled but 90 degrees to floor.

I send the code for testing, if i get a reply.

BGCJR
Game Core
Advertisement
BGCJR: I would like to see that code to compare it to what I have already. Thanks a lot.

wAVaRiaN: I got it working a bit better. Now it almost works. I can get caught on either side of the quad and when I am not ''looking'' straight at the quad I can move. But I get caught and can''t move whenever I ''look'' at the quad no matter what my distance is. I put the code into a class and made some other files that I use. If you want to see the code just tell me and I will e-mail you a ZIP file containing my project. It is in VC++ 6.0 Service Pack 2. Thanks a lot.
L.I.G. == Life Is Good
Whats the point in putting if((x1<=0.0)&&(x1>=0.0)) why don''t you just put if(x1==0.0)
Its fine doing it like that in that example anon, but when the values change, it is required.

Running_Wolf: Unfortunately i don''t program in c++, guessing is my way through that language, and i doubt i would understand anything else written in it.. :/


There are other ways of determining whether or not a point is in the polygon''s space, and they were mentioned before. You should try those, they''re not only more accurate but also quite easy to implement.

-- Wav
wAVaRiaN: Well, I have got it almost working as mentioned before. I have got a function that figures if the point is inside the polygon. If it is then I find the distance. If the distance is less than -0.2 and greater than 0.2 then it returns a 1. Else it returns a 0. I know that it works, I just get stopped no matter how far I am from the plane.
L.I.G. == Life Is Good
Advertisement
wAVaRiaN: Sorry I made a mistake. I return a 1 if it is >= -0.2 and <= 0.2. But for some reason whenever I look at the plane. It is always true. This makes me think that my distance math is still bad. Here is the line where is find the final distance.

distance = nx*xintersect + ny*yintersect + nz*zintersect + d;

nx, nz, nz are the plane''s normals.
xintersect, yintersect, zintersect are the result of
x1 = x2 + (d*dv1)
y1 = y2 + (d*dv2)
z1 = z2 + (d*dv3)

and d is the result of
D = -(N.x*P1.x + N.y*P1.y + N.z*P1.z)
L.I.G. == Life Is Good
wAVaRiaN: I got it to work!!! Thanks a lot for your help!
L.I.G. == Life Is Good
Hey, cool.. Now go out there and make us all an excellent game to play. =P

Is there a way to limit the number of poly to check for collisions? For instance, if you were walking for is there a way that I can cast a ray and have it tell me which poly it crosses and then check distance from that one? Did that make any sense?

Also, everybody talks about poly hiding. About how you hide the polygons not seen on screen and don''t draw them thus increasing performance. How do I do this? Is there a tutorial about how it works anywhere?
L.I.G. == Life Is Good

This topic is closed to new replies.

Advertisement