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

DP

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  
 
 
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.

Mr.CodeIt (10 views)
2014-12-27 04:03:04

TheDudeFromCI (13 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (85 views)
2014-12-05 12:39:02

SHC (95 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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
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!