game_maker
Knave
Saudi Arabia
83 Posts |
Posted - Jun 17 2004 : 7:22:39 PM
|
Hi
I've seen an example for this in Almar's home page
and I have learned another method for the test from SuperC Here : http://www.vbgamer.com/msgboard/topic.asp?TOPIC_ID=143
soo here is my test
Download Attachment: TriangleCollision.zip 2.86 KB |
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Jun 18 2004 : 12:02:44 AM
|
It doesn't always work. Here is a picture of what I'm talking about.
Download Attachment: failedtest.jpg 21.02 KB
|
|
|
game_maker
Knave
Saudi Arabia
83 Posts |
Posted - Jun 18 2004 : 10:37:38 AM
|
Yes,True and this is also happening to the code in Almar's home page
that's why I added Accuracy
if you put Accuracy = 256 for example you will have 99.99% (we can say 100%) it will test 256 point (in triangle) |
|
|
Sr. Guapo
Swordmaster
USA
272 Posts |
Posted - Jun 18 2004 : 5:51:19 PM
|
But it will be much slower... |
|
|
game_maker
Knave
Saudi Arabia
83 Posts |
Posted - Jun 18 2004 : 6:52:32 PM
|
Also True, because we know speed = k / accuracy
You can not (or let say) it's very hard to bind or find a relation between a curve (circle) and poly (triangle) and that's what both test's do
Will if we can find the center of our triangle and make a radius and so a circle then check circler collision if true then check our test
I didn't bring a new Idea for collision the Idea is totally same the procedures is sort of different |
|
|
VBBR
Moderator
Brazil
617 Posts |
Posted - Jun 19 2004 : 08:28:50 AM
|
Do you know how to find the center point of a triangle? |
Whatever. Who knows... |
|
|
Sr. Guapo
Swordmaster
USA
272 Posts |
Posted - Jun 19 2004 : 1:29:41 PM
|
There is a way to do it geometrically... It involves bisecting all the sides of the triagle and drawing perpendicular lines through the points. Assuming all goes well, that will give a point that can create a perfect circumscribed circle, the circumscribed midpoint (BTW, If you do a similar thing with the angles, you will get the INSCRIBED midpoint) I'm sure there is a way to do it algebraically, also... Try google
|
|
|
VBBR
Moderator
Brazil
617 Posts |
Posted - Jun 19 2004 : 3:23:34 PM
|
Yeah, I remembered that but I didn't remember exactly if it were the sides of the triangle or the angles or whatever That is what happens if you last about 2 years without seeing a similar thing in school... |
Whatever. Who knows... |
|
|
Sr. Guapo
Swordmaster
USA
272 Posts |
Posted - Jun 19 2004 : 3:52:56 PM
|
You could just calculate 2 of the side midpoints (very easy since you know the endpoints) and the slope of each of those segments, then you can find the perpendicular lines and their intersection. It may be a little computationally expensive, but as long as you aren't doing it for 100,000 triangles per frame you should be okay... |
|
|
VBBR
Moderator
Brazil
617 Posts |
Posted - Jun 19 2004 : 4:00:02 PM
|
Probably it will be needed only once, as long as the triangle shape doesn't change. I will try to do that with this example. |
Whatever. Who knows... |
|
|
VBBR
Moderator
Brazil
617 Posts |
Posted - Jun 19 2004 : 4:17:28 PM
|
See, I just corrected the problem this code had just by adding a point-in-circle test for each vertex Also added an FPS counter. Get it here... EDIT: Also, using this pre-check, an accuracy of 16 should be more than enough. 8 is already good (acceptable) for not very precise checking. (I have tested both)
Download Attachment: TriangleCollision.zip 3.47 KB
Gotta work on the center-point calculation now... |
Whatever. Who knows... |
Edited by - VBBR on Jun 19 2004 4:30:26 PM |
|
|
Serpwidgets
Neophyte
1 Posts |
|
game_maker
Knave
Saudi Arabia
83 Posts |
Posted - Jun 19 2004 : 5:36:17 PM
|
Nice
this would increase some accuracy at corners
hmmmm, I have add a Circle to Circle Collision to fast our collision
OK now we have :
- Point in Triangle Test
- Point in Circle Test
- Circle-Circle Test
We need all of them to perform a nice Trinagle-Circle test
Download Attachment: Triangle Collision.zip 3.33 KB |
|
|
game_maker
Knave
Saudi Arabia
83 Posts |
Posted - Jun 19 2004 : 5:40:05 PM
|
you can avoid sin & cos functions if you identify your accuracy (you know what I mean ? )
BTW : is there an use for this test (I never programmed 2D Game) |
Edited by - game_maker on Jun 19 2004 5:50:50 PM |
|
|
VBBR
Moderator
Brazil
617 Posts |
Posted - Jun 19 2004 : 6:29:27 PM
|
I have just made a small modification, put an "Abs" before the subtract operations in the distance calculations. We must work with absolute values because if you put negative numbers it will go crazy
Download Attachment: Triangle Collision.zip 3.55 KB |
Whatever. Who knows... |
|
|
game_maker
Knave
Saudi Arabia
83 Posts |
|