Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (753) Games in Android Showcase (228) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 collision detection on diagonal planes  (Read 2873 times) 0 Members and 1 Guest are viewing this topic.
Serethos

Junior Devvie

Java games rock!

 « Posted 2005-01-09 12:57:08 »

im thinking about a proper way of adding to my arkanoid game some not  only rectangle like bricks. so it should be possible (like in a flipper) to have diagonal collision, e.g. if a brick is hexagonal or turned with 30°.

the only way to do proper collision detection i see is to calculate (or perhaps better store) the normal of each side of the object.

i only want to go sure tehres no better way ...
KONI

Junior Devvie

Java games rock!

 « Reply #1 - Posted 2005-01-09 15:09:38 »

in my demo of "destructible terrain" in the java2d forum, I was using the following method:

- check for collision
- normalize the speed vector
- backtrace the trajectory until exact collision point found
- do an approximation on the angle of the surface:
calculate dy/dx of a small surface, like from collision point - 2 to collision point + 2. On cp + 2 and cp - 2, we always go up or down to find the exact surface point (up if inside object and down if outside object). this gives you the surface angle

I know this method isn't perfect but worked great in our case. There could be some errors on extreme situations where you hit the edge of something.
tom
 « Reply #2 - Posted 2005-01-09 16:43:08 »

Asuming the ball is round, the collision normal is always (center of ball)  -  (exact point of collison between ball and wall).

But to get the point of collision you may need to store the normals of the bricks. Depends on how you do your collisions.

Serethos

Junior Devvie

Java games rock!

 « Reply #3 - Posted 2005-01-10 18:30:32 »

im still in my planning phase, so some thought may be unfinished.
if all bricks were standard rectangles i needed only to test if the point on which the direction*speed vector is pointing lies within the bounding box.

now for the polygons. tom, you got a main problem:
even if i store all normales for each plane i additionally need to know the exact intersection point.
i only know one way to test this, to calculate the intersection of both lines (the one is the plane itself, the other is the line following the ball's direction vector).
but line intersection is pretty expensive so i want to consider all possible methods before using them ...
KONI

Junior Devvie

Java games rock!

 « Reply #4 - Posted 2005-01-10 19:27:02 »

Quote
im still in my planning phase, so some thought may be unfinished.
if all bricks were standard rectangles i needed only to test if the point on which the direction*speed vector is pointing lies within the bounding box.

now for the polygons. tom, you got a main problem:
even if i store all normales for each plane i additionally need to know the exact intersection point.
i only know one way to test this, to calculate the intersection of both lines (the one is the plane itself, the other is the line following the ball's direction vector).
but line intersection is pretty expensive so i want to consider all possible methods before using them ...

what about what I wrote ?
Serethos

Junior Devvie

Java games rock!

 « Reply #5 - Posted 2005-01-11 05:49:29 »

ohhh, im very sorry, i overstepped your suggestion

but i didnt really get the clue. you have to explain it carefully.

- check for collision:
yes, thats the main problem. do you mean a precollision over bounding boxes ?

- normalize the speed vector
up to now i realize movement over an always normalized direction vector and a speed scalar

- backtrace trajectory
sure, but the question is, with which method ?
for tracing the collision point (and later calculating the gradient of the small surface) i only see the method of line intersection
KONI

Junior Devvie

Java games rock!

 « Reply #6 - Posted 2005-01-11 16:11:56 »

In my destructible terrain demo, I use a collision map and check with the position of the object if it is a collision or not.

I hope this topic is about how to react physically to an object collidion with a vertical plane instead of being a "how to know if an object has collided" topic.

Because what I wrote was mainly how to react and not how to detect a collision.
Serethos

Junior Devvie

Java games rock!

 « Reply #7 - Posted 2005-01-12 06:00:42 »

thats the pronlem. perhaps i did not mention it clearly, but i have never taken a collision map into view for arkanoid style game.
so i really have to widen the topic to, which is the probably best way to test ball to diagonal spheres collision.
Pages: [1]
 ignore  |  Print

 ivj94 (579 views) 2018-03-24 14:47:39 ivj94 (42 views) 2018-03-24 14:46:31 ivj94 (346 views) 2018-03-24 14:43:53 Solater (59 views) 2018-03-17 05:04:08 nelsongames (104 views) 2018-03-05 17:56:34 Gornova (122 views) 2018-03-02 22:15:33 buddyBro (663 views) 2018-02-28 16:59:18 buddyBro (88 views) 2018-02-28 16:45:17 xxMrPHDxx (491 views) 2017-12-31 17:17:51 xxMrPHDxx (727 views) 2017-12-31 17:15:51
 philfrei 12x KaiHH 10x SHC 10x NuclearPixels 10x Zemlaynin 10x Guerra2442 6x Spasi 6x ByerN 6x VaTTeRGeR 4x ags1 4x orangepascal 4x theagentd 4x kreagoth 3x chrislo27 3x mesterh 3x ndnwarrior15 3x
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org