Author Topic: irregular shape collision  (Read 2536 times)

0 Members and 1 Guest are viewing this topic.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
irregular shape collision
« on: May 31, 2021, 02:16:10 pm »
I'm also interested in colliding objects. However, I don’t care if you use trigonometry or not. I want to start playing the car, but first I should get to know the physical part of the solid body. I'm throwing a dice, is that how it rolls? When this is done, it may follow that the cube is a car.
For now, I’m trying to collide objects in 2d. This is similar to the adjacent topic: “2D ball collisions without trigonometry” For me, it’s already complicated where you are.
I came up with a simpler thing, but unfortunately it’s not good for car gaming, but it can be good for smaller 2d games.

IT IS VERY IMPORTANT THAT THE SUBJECT IS IRREGULAR! (I can't detect a car as a rectangle)

I thought a lot, with a pencil in my hand, tossed, dropped to see how it could be done as easily as possible in a collision. No trigonometry.

An object is defined by 3 things: X-vector, Y-vector, Rotate –vector

If the collision can be avoided by negating the X-vector, negate it and move on
If not, see if negating the Y-vector avoids a collision. If so, negate it and move on.
If not, see to see if you can avoid collision by negating the direction of rotation.

Around the three things, one is sure to resolve the collision and the object goes on.
This, if we look closely, cheats a lot. In addition, inertia, momentum, impulse does not transmit. This is not good for car play.
On the other hand, the environment I did is good for anyone who likes to develop it. you can put the physical part between the do: loops of the “boss” loop. Everything is blocked, nothing else needs to be addressed. You can specify any image, making sensory dots from the edges of the image. The distance between the sensor points is adjustable.
I hope you have an idea for someone to be realistic. Translating your process into 3D could provide a very good foundation for your car game. (or an fps game where if you shoot into the wall, the bricks will realistically fly apart)

  [ You are not allowed to view this attachment ]  


« Last Edit: May 31, 2021, 04:20:26 pm by MasterGy »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: irregular shape collision
« Reply #1 on: May 31, 2021, 04:10:14 pm »
Hungarian? Cool... Google translate will take care of this one...
Logic is the beginning of wisdom.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: irregular shape collision
« Reply #2 on: May 31, 2021, 04:21:24 pm »
sorry, I didn't copy a good one. (I was also amazed at how quickly my browser translates back to my own language)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: irregular shape collision
« Reply #3 on: May 31, 2021, 04:24:17 pm »
Download and ran the program. Irregular shape collision. Nicely done. The math is way over my head but it ran very smoothly. Well done.
Logic is the beginning of wisdom.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: irregular shape collision
« Reply #4 on: June 01, 2021, 05:39:23 pm »
I dealt with it, I found it interesting. I refined the image conversion to the sensors and managed to crop a lot of calculations so it can handle more objects. The speed of processing is not determined by the number of objects, but by the total circumference of the objects.
As I wrote: 3 options resolve the collision
negation of x-vector
negation of y-vector
rotation-negation
at least 1 of the three solves the problem in each case
sometimes 2 would solve the problem, but since it examines it in order, sometimes you would have to apply the other 2.
This should figure out what logic you use from the three or two, when which one is correct. If this could be resolved, the collision would be more realistic.



https://drive.google.com/file/d/1CstsxpPJ5amhPoUiI0kfAtyawdoifqu6/view?usp=sharing
« Last Edit: June 01, 2021, 05:46:29 pm by MasterGy »