Advertisement

Elementary collision in a 3D-World

Started by August 27, 2001 12:41 PM
7 comments, last by cruiz 23 years, 5 months ago
Hi People out there! Yes I have work with the GLTutorial in this 3D-World. Now i have made my own world. A really really big world! (just fun!) And now i want to make collisions. With bottom, wall and ceiling. (ok with ceiling probably not ) I had read the Tutorial with the collisions and balls, too. And I tried already to make something with Vectors but without success! :O I hope You out there can give me some useful tricks and tips! TNX to all replies: C.Ruiz
Just an idea, but assuming that all objects in your world have some sort of vector associated with the movement, you can think of all your walls as planes (not vectors) with the formulae ax + by + cz = 0...

Using some 3d maths, you can then work out what side of the plane your objects are on, and also determine distance from those planes.

Then all you need to do is change the movement vector of the object whenever it reaches a specified minimum distance from those planes (i.e 0.0f)
Advertisement
just a quick correction:

the plane equation BeachBoy referred to should be:

ax + by + cz + d = 0;

-Mezz
Yeah, sorry forgot the d
Thanks Mezz...
First i wanna thank you people.
But really really sorry I don''t know what
to do with ax+by+cz+d=0
What is a b c d
and what is x y z?
Ok again: SORRY!
I''m at school and i think this theory is not known for me!
Ok. I have thought:
In my World I have the vertices with 18Points for a quad. Is this correct?
I mean a triangle take 9Points. And a quad are 2 triangles.
(again sorry but i''m triying to build this problem from the beginning )
Ok What is now a b c d?
I have thought the corners are a b c d and x y z is my cameraposition.

I really thanks to all that posts now, cause I now thats it''s probably a little bit
hard to explain!
Probably you can give me a Link or so to a mathpage where is a good Tutorial
where I can read the theory!

Ok again: TNX to all of you: C.Ruiz
Um, okay...
Lets see if I can explain planes a bit...
First of all you''ll need to read up on dot product, normal vectors...

Then,
Take some point P(x, y, z) that lies on our plane... (Any point)
Let the 2 vectors (r) and (r0) be the position vectors of (P) and (P0) respectively...
Then r-r0 is represented by the vector (P0 -> P)
The normal vector (n) is orthogonal to any point in the plane, so we have
n . (r - r0) = 0 -> n . r = n . r0

Now let n = (a, b, c), r = (x, y, z), r0 (x0, y0, z0)
Therefore,
(a, b, c) . (x - x0, y - y0, z - z0) = 0
Therefore,
a(x - x0) + b(y - y0) + c(z - z0) = 0
Therefore,
ax + by + cz - ax0 - by0 - cz0 = 0

Let d = -ax0 -by0 - cz0
Therefore, ax + by + cz + d = 0

Sorry about the long explanation, but thats the maths behind it
And as best as I can explain it. It does take some knowledge of vectors... I hope you can struggle through it... If not, feel free to email me
Advertisement
Hi I was just wondering what ur native language is (hopefully not english) cuz maybe it would be easier to explain because some people probably know it.

BTW do u have a spastic eyelid or something?

-David-
If he''s from South Africa, what do you think is his native language? Of course, Americans can''t know that.
He explained as he explained, if you don''t understand, ask your MAMA!
Hi people!
First I wanna thank you BeachBoy!
(for your information: my native language
is german. Probably I can''t write very well english
but I understand everything!)

Ok I have read your Formulas.
And I''m reading now two books about Vectorgeometry.
Here another Information to you: I''m 15years old and in
the high-school. I had vvectorgeometry, but only the very basics!
People People Please: Don''t think that because I''m 15 or so
I can''t program or do mathematics, ok?

Ok. I have understand the formula. (TNX again! )
Now my problem is in the code to say
what is the normal and how to do now the collision and so on.
I''m working on it. Probably you out there have other some
good tricks, tips, links or other commentairs that could have.

I gonna sure report my status.
Tnx again to all people!
Greets from europe: C.Ruiz

This topic is closed to new replies.

Advertisement