Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Math Question

Author
Message
haliop
User Banned
Posted: 22nd Jun 2009 09:26
hello all
a long time since i posted on the forums
i have recently continued to work on my game.

a little explanation about it:

Multiplayer Top View Shooter, 2 teams, vehicles.

like battlefield.

so , i am working with DarkGDK , not basic , but its about the same , so i thought , why not posting here some questions

as we all know , the Collision Detection in DarkGDK sux.
so i'm searching for a new Collision System , but i want to build it from Scratch , i have found , that when you build it your own way , you can get to much higer cpu detail then other systems , the problem is, Time.

but , for now i'll continue on trying it.

so , the game uses the Engine 2D not 3D.
for now , i use Lines to Quare the targeted Sprite , so i'll see the Collision Data in real time , the lines highlight the corners and from corner to corner , like a square.
but what happens is , that when i use RotateSprite , the lines get all messed up, here is the code:


and some images :








Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 22nd Jun 2009 11:04 Edited at: 22nd Jun 2009 11:47
Hmm Try using this method. Rotation of a point about an origin.



There ya go that should do it.
haliop
User Banned
Posted: 22nd Jun 2009 13:21
wow , tnx man
i'll try it right now.
btw , can you give me your name / nick name
i'll add you to credits.
thank you , nadav.
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 22nd Jun 2009 13:28
No problem at all man.

Pillarofire
haliop
User Banned
Posted: 22nd Jun 2009 13:30
Pillarofire Tnx man.
it works. now i can find collision information easier , dude , you are awesome!.
this is my MSN nadavros1@gmail.com
give me your name so i can Credit you.
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 22nd Jun 2009 13:40 Edited at: 22nd Jun 2009 13:48
Cheers.
haliop
User Banned
Posted: 22nd Jun 2009 21:20
hi i have another question for you

i started building up a Collision Algo
basicly all Ifs but i think i need something else in there
i just dont know exactly what it is:

this is what i did:



so , as you can see i am making the player vehicle first
then i loop through the other objects / vehicles on the map.

so what i did , is , i actually picked a corner and check how it works , as long as the other car dosent rotate i can collide with it with ease , but when it rotates the collision dosent seem to work.

you can also see a dbCos , i tried to calculate the Angle between my Vehicle and the Other Vehicle , then if collide i have the exact angle of the hit. then the other vehicle goes to dbrotatesprite +1 until the angle reaches 0 or as low as 3 or something , that way the Cars or Object i will hit , will rotate in a nicely look like phisic .. which is actually trigo..
but , i didnt accomplished that.. that dosent work but.. ohh well back to math school

well if you can help..
and if you have any thoughts about my collision system , with the use of corners.
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 23rd Jun 2009 01:24
This is a complicated question but I'll do my best to solve it.

Basically you want to check each vertex of box1 against being inside box2. Then each vertex of box2 against box1. As soon as one returns true then there is collision.

How do you do that? Well you could check that the line created by the vertex and the point of the wall where that said line will be perpendicular, is the same sign as the perpendicular line created by the center and the said wall.
haliop
User Banned
Posted: 23rd Jun 2009 15:04
yeah i still dont get it
i have added some more Ifs , but again.. it just mess up when one of the sprites is rotated...


this is for calculating the UpLeftX point with other points and Lines...
but , what happens is , that once the other cars are rotated too much or not too much but just not 90 or 270 , like 85 or so..
one car overlap another ... so it dosent work
i still think i need a math equation here somewhere i think the Ifs will not do it right , unless i'll have some accurate numbers..

well im not a math man.. what should i do?
im really considering on buying DarkPhisics .. but that means that my game will not be 2D , but 3D with a box for each car or even a model..

my idea on how to keep it in 2D but actually use 3D phisics , is to
create Boxes with the XY size of the Car Sprites,
then i'll add like 10 Z size , and make them move and collide , so it would look just like 2D , but with 3D phisics , i think its simple to do with DarkPhisics , but still , i want to know if there is any other way.. if not , 3D here i come

i guess when i started working on this , i got too excited and thought well 2D is not that Hard , but i have no Math Education what so ever , except the ordinary stuff like 1 + 1 = 2

well , pillarofire , if you can help me handle 2D , well that would be extremmly awesome cause then , i will be able to start working on the Map / Level file
if not , i guess the 3D Z size 10 will work. (and later on 3D car models with Motors .. if i already have the DarkPhisics why not create more advanced setting right?

well , until next time.. i'll be thinking on Phisics 2D / 3D
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 23rd Jun 2009 15:52
I'm working on it. I have pretty much re-invented a point class to make it easier, but I'm still getting a bug in the calculation of the normal from an arbitrary point. I've read several articles on Constructive Solid Geometry and have realized exactly how to perform this solution. Its now just a matter of coding and debugging. I haven't given up.
haliop
User Banned
Posted: 23rd Jun 2009 16:53
wow man , thats awesome.!!!!!!!!
i cant wait.
hi dude , whats your msn?
im nadavros1@gmail.com
haliop
User Banned
Posted: 24th Jun 2009 22:51 Edited at: 24th Jun 2009 22:57
news:

after working on the Collision a bit more
i found a way to check each vertex point with other vehicles lines.

so , you check each point and you get results.
so far ,its not working as well as i expected it to , but i'm on the way there,

some of the code:

creating all Collision Networks, and saving XY points into an ARRAY:


then Checking Collosion
i = current Object/ Vehicle checking with other objects.
Y = the other objects
VP = Vertex Point , each point has its own calculation.


the CheckCollision(i,Y,VP)



ok , so its still not 100 percent , but i feel that im just about the see it. hope i will finish this soon.

pillarofire , check if this make any sense to you

edit:
when looking at Check Collision , see that first
i try to find out if the other object is rotated or not , but i'm not using the dbSpriteAngle to figure it out , instead ,
i check if the TopLeft X corner has a Smaller value then the Topright X corner , this means , that the Object is facing up
if it was facing down , then the TopRight X Value will be Smaller then the TopLeft X value.

i sat on this the whole day , im not sure if this is the right and best way to do it , but it should work im just missing something.
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 24th Jun 2009 22:57
Hmm, Ive have discovered the bug I had mentioned previously with my calculations. There was an error in returning the sign. But I fixed it, so here is the complete source file I used to make this. Play around with it, its pretty cool on its own, but if you can understand it, you will have to adapt it to you own vehicles, and then things should be pretty simple from there. I used an excellent source for help with the math.

[ http://softsurfer.com/Archive/algorithm_0102/algorithm_0102.htm

So I can't take all the credit.

Here is the code:

haliop
User Banned
Posted: 25th Jun 2009 10:48
ok , so as we spoke yesterday
i have begun working on the Collision Setup for the cars
from the code you posted up.

now first thing first , i do not and i repeat i do not understand how it works , i just know it works so i use it , im not a math guy or anything.. i still have a lot to learn.

so , for now , the first thing i did
is to setup the boxes ,
so vehicle one is box 1 , vehicle two is box 2
but can i use an array????

meaning

in the main game loop
wihtout an array i do this:



now , if i'll use an array or something

i will be able to do this:


so , i dont really understand patterns as you did , i have alot to learn in C++ , but ,
is there a way to put those boxes in an Array of an ID, then as i wrote in the loop ,it will be much easier then to

Collision(box1,box2) and then Collision (box2,box3) and so on and on.. thinkig in one Map i have about 32 vehicles , and that is without counting the Buildings and other collidable objects.
haliop
User Banned
Posted: 25th Jun 2009 11:11 Edited at: 25th Jun 2009 11:12
this is what i meant:



and.. it dosent work

Login to post a reply

Server time is: 2024-10-01 05:47:21
Your offset time is: 2024-10-01 05:47:21