# Thread: Bounding spheres but Walls :))

1. ## Bounding spheres but Walls :))

We can simply use bounding spheres for collision detection but walls?

)

2. ## Re: Bounding spheres but Walls :))

Hey man...
i'm actually writing a collision detection to my engine. but i found a bug that i really can't explain.
Here is the problem.
i'm using two cubes to implementation.
when i move one of the cubes around and he touchs another one, my collision system detects the event but sometimes a consider distance to each other and another time when they are face to face. and i write the code over and over. How did your collision system works ??? use a spheres around the objects ??

And, are you work with Delphi correct ???

[]'s

[This message has been edited by Gelero (edited 07-05-2000).]

3. ## Re: Bounding spheres but Walls :))

Yes guy you know immortal delphi ehehe

himmm you say that you wrote the code over and over
hım

the thing that you must do is

our first cube's sphere's radius is r1
second sphere's raidus is r2

first sphere's position is x1,y1,z1
second sphere's position is x2,y2,z2

you must calculate

R:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));

if R<r1+r2 then collision is occured...

but the walls the topis signs it )=) and i am asking it , walls?

when we strike the walls how can i detect the striking )) ?

regards
bye

5. ## Re: Bounding spheres but Walls :))

I know this is getting more off the topic, but you don't really need to do the sqrt when you check the distance between the two objects....well, at least as long as you store the radius squared of each of the objects you are checking collision against. Simple optimisation, but if you have a slow computer or are doing lots of distance checks, it can add up to a lot of savings.

6. ## Re: Bounding spheres but Walls :))

A simple sphere-plane collision check is this, extend a line from the center of the sphere to a point P in the plane of the wall. Parameterize this line by d so that at the center of the sphere d=0 and on the surface of the sphere where the line intersect the sphere d=1. Then solve for the parameter d of point P. If 0<=d(P)<=1, then the sphere collides. Another note, this line is parallel to the normal of the wall as well. You can make the parameter on the sphere equal the radius R instead of 1 if you also change the check to 0<=d(P)<=R.

Also to be absoultely correct, you should also check to see if P lies within or on (inclusive) the boundary of the wall.

[This message has been edited by DFrey (edited 07-06-2000).]

7. ## Re: Bounding spheres but Walls :))

Nice...
you in your last post, you wrote that you`re drawing walls and walls, but if i draw a lot of walls here, ohh god, there`s a XT in my front..
And my computer it`s a PII, 466 MHZ, 64M and no 3D Card. It's not a super machine but i really guess that i can reach more...
Can I ???

[]'s

8. ## Re: Bounding spheres but Walls :))

Galero I think my way is best for you and your machine )

hım dfrey says some way but the way must support the sky by wall i dont know what can i explain

in q3 if we strike to a wall and if our angle between wall's plane and camera vector is not 90 degree we sky by the wall

x:=x+sin(angle);
y:=y+cos(angle);

did anyone understand something from this the simple function? if yes good and please help me ) i know all of techniques but i can add a way to another hum

)

regards

9. ## Re: Bounding spheres but Walls :))

Excuse me! )

x:=x+sin(angle);
z:=z+cos(angle);

y is for jumping or flying for camera )

10. ## Re: Bounding spheres but Walls :))

Yeah...
So can you provide me some source...
just to take a look...

thanx

[]'s

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•