Java-Gaming.org Hi !
 Featured games (83) games approved by the League of Dukes Games in Showcase (522) Games in Android Showcase (127) games submitted by our members Games in WIP (590) 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 1709 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

You cannot reply to this message, because it is very, very old.

 Add your game by posting it in the WIP section, or publish it in Showcase. The first screenshot will be displayed as a thumbnail.
 trollwarrior1 (29 views) 2014-11-22 12:13:56 xFryIx (71 views) 2014-11-13 12:34:49 digdugdiggy (50 views) 2014-11-12 21:11:50 digdugdiggy (44 views) 2014-11-12 21:10:15 digdugdiggy (38 views) 2014-11-12 21:09:33 kovacsa (62 views) 2014-11-07 19:57:14 TehJavaDev (67 views) 2014-11-03 22:04:50 BurntPizza (64 views) 2014-11-03 18:54:52 moogie (80 views) 2014-11-03 06:22:04 CopyableCougar4 (79 views) 2014-11-01 23:36:41
 theagentd 29x basil_ 27x HeroesGraveDev 23x BurntPizza 22x Riven 19x Spasi 18x princec 17x KevinWorkman 13x SHC 11x kpars 11x Grunnt 10x gouessej 10x Nate 9x Longarmx 9x CopyableCougar4 8x LiquidNitrogen 8x
 Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27Resources for WIP games2014-08-01 16:20:17Resources for WIP games2014-08-01 16:19:50List of Learning Resources2014-07-31 16:29:50List of Learning Resources2014-07-31 16:26:06
 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