Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Discrete Time Issue - Overlapping  (Read 1821 times)
0 Members and 1 Guest are viewing this topic.
Offline Daz

Senior Newbie

Java games rock!

« Posted 2005-02-21 22:28:20 »

Hi, i'm implementing a snooker game, and i am onto doing the ball-to-ball collision, the problem is when a collision has been detected in my game, the 2 balls are slightly overlapping, as it hasn't detected the collision in time, does anyone have any ideas on how to deal with this overlapping?

Do i need some kind of step-by-step method, or another thread running?

Offline harryk

Senior Newbie

Stone golems rock!

« Reply #1 - Posted 2005-02-22 06:10:27 »

have you tried decreasing the time step and/or setting the stepInteractions to a higher value? are you using step or stepFast?
Offline darkprophet

Senior Devvie

Go Go Gadget Arms

« Reply #2 - Posted 2005-02-22 06:19:58 »

The collision type that you are doing currenlty is called "static collision detection" i.e only when they touch, do you know they are touching. Which makes sense in first person shooters or whatever.

But for a snooker, game, i would opt for "dynamic collision detection". However, this is a little bit more complex than static, but it does provide you with a very powerful collision system..

The idea behind it is to preempt a collision by using the directional matrix of the object and ray casting forwards in that direction (across all extremeties ofcourse, not just the centre of the ball). Find out if the ray is going to collide with any other ball. If so, you can find out the distance between them. From that distance, and given the speed of the snooker ball (you have to work that one out yourself im afraid using speed = distance/time, the time is the interpolation between the current aned last frame, distance is the distance covered between the current and last frame).

Using speed = distance/time. GIven the speed, and the distance between the objects, you can find out when the objects will collide. And decrement that counter by the interpolation everytime, untill you get to 0 or around that figure and do your collision response.

A complication arrises when the two objects are moving. So you need to work out if they are going to intersect and where. Say a ball is moving at 1mph east (located at (-1, 0, 0)) and a ball is traveling north at 1mph located (0, -1, 0) then they are definetly going to collide. So you need to make adjustments as necessary.

That would be my solution. But there is another solution to the problem. And that is to find the distance between the two objects before collision, if the distance is less than a given threshold, then they have collided and you should initiate your response.

Choose whichever is more suitable to your needs.


Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline harryk

Senior Newbie

Stone golems rock!

« Reply #3 - Posted 2005-02-22 06:21:36 »

oh, thought you where using ODE, my bad Wink
perhaps you should though, it would make things easier  Grin
Offline Vikstar

Senior Newbie

« Reply #4 - Posted 2005-02-25 09:06:40 »

I wouldn't use ODE for a snooker game. How much experience do you have with physics/maths? Maybe you could create your own engine, doesn't need to be extensive, since your only using spheres and lines. I would do the dynamic collision thing mentioned a couple of posts earlier, however you will also need to take into account deceleration due to friction, not only the velocity.

Just brainstorming right now, I would set the a start state at each collision, use current positions and velocities to find the next collision and the positions and velocities of the balls at [just after?] that next collision. A collision includes ball-to-ball and ball-to-wall collisions, maybe include pocketing as a collision. I would then interpolate (with changes in velocity due to friction) intermediate positions of all the balls between the two collisions and play each interpolation to the user per frame. (Note, you can use interpolated velocities for motion blur if you wish).

Once you have this first prototype working correctly, I would then move on to allowing the balls to spin, which includes curved paths on the table, which is a big step from simple straight-line motions between collisions.

One very hard problem with snooker is when you have more than two balls collide with eachother at exactly the same time. However, with dynamic collision this will hardly ever happen, so you probably don't need to watch out for it.
Pages: [1]
  ignore  |  Print  

hadezbladez (294 views)
2018-11-16 13:46:03

hadezbladez (164 views)
2018-11-16 13:41:33

hadezbladez (295 views)
2018-11-16 13:35:35

hadezbladez (75 views)
2018-11-16 13:32:03

EgonOlsen (2156 views)
2018-06-10 19:43:48

EgonOlsen (2183 views)
2018-06-10 19:43:44

EgonOlsen (1370 views)
2018-06-10 19:43:20

DesertCoockie (1987 views)
2018-05-13 18:23:11

nelsongames (1630 views)
2018-04-24 18:15:36

nelsongames (2278 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!