Java-Gaming.org Hi !
 Featured games (83) games approved by the League of Dukes Games in Showcase (522) Games in Android Showcase (127) games submitted by our members Games in WIP (589) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Home Help Search Login Register
 Show Posts Pages: [1]
 1 Java Game APIs & Engines / JOGL Development / Some help with collision detection on: 2007-07-06 23:51:54 Hi All,I am having a lot of difficulty with collision detection. Actually, I'm not certain if it's a problem with collision detection specifically or something I just don't understand about OpenGL. I have adapted Oleg Dopertchouk's example from "Simple Bounding-Sphere Collision Detection" for a Java game using JOGL. ( Thanks to Oleg! ) Here is my method:boolean sphereTest(AbstractGameObject obj1, AbstractGameObject obj2){// Relative velocityVector3D dv = Vector3D.substract(obj2.getVelocity(),obj1.getVelocity());// Relative positionVector3D dp = Vector3D.substract(obj2.getPosition(),obj1.getPosition());//Minimal distance squaredfloat r = (obj1.getWidth() / 2) + (obj2.getWidth() / 2);//dP^2-r^2float pp = dp.x * dp.x + dp.y * dp.y + dp.z * dp.z - r*r;//(1)Check if the spheres are already intersectingif ( pp < 0 ) return true;//dP*dVfloat pv = dp.x * dv.x + dp.y * dv.y + dp.z * dv.z;//(2)Check if the spheres are moving away from each otherif ( pv >= 0 ) return false;//dV^2float vv = dv.x * dv.x + dv.y * dv.y + dv.z * dv.z;//(3)Check if the spheres can intersect within 1 frameif ( (pv + vv) <= 0 && (vv + 2 * pv + pp) >= 0 ) return false;//tmin = -dP*dV/dV*2//the time when the distance between the spheres is minimalfloat tmin = -pv/vv;//Discriminant/(4*dV^2) = -(dp^2-r^2+dP*dV*tmin)return ( pp + pv * tmin > 0 );}Now this works like a charm if obj2 is sitting at 0.0f,0.0f,0.0f, but the further down on the screen obj2 is ( for example -.5f on the y axis ) obj1 collides sooner. Way to soon. And the further down it is the sooner it collides. If obj2 is further up the screen from the center ( for example .5f on the y axis ) then the collision happens way too late. It's very odd to me. The output of my tracing is:Ball 0.0,-0.57959735,0.0 w=0.06 h=0.06 collided with TestBlocker 0.0,-0.5,0.0 w=0.1 h=0.05Unless I am missing something, the above output looks correct, however the 2 objects are miles from each other. Can anyone give me hints as to what the problem might be?Many thanks!-B
 2 Game Development / Newbie & Debugging Questions / Re: Game programming books on: 2004-04-08 19:05:21 Thanks for the link, but this in no way answers my questions.
 3 Java Game APIs & Engines / Java 3D / Re: OpenGL or DirectX? on: 2004-04-08 14:19:38 So you're saying that it's a configuration option or a method call that specifies to use OpenGL or DirectX?It would seem since Java 3D is not specific on the underlying API, it would be better to use something like JOGL if you want to strictly use OpenGL.  Am I wrong?
 4 Game Development / Newbie & Debugging Questions / Game programming books on: 2004-04-08 14:14:14 Hello,   I have just begun digging into Java games and I am trying to get all the information I can. Does anyone have suggestions for good books? I have heard many good things about "Developing Games in Java" by David Brackeen. This guy also has a web site with examples of games he has written which look pretty cool.     Also, which API's are most commonly used for Java game development. I have heard of this JOGL.  Has anyone here used it?   many thanks, Barry
 5 Java Game APIs & Engines / Java 3D / OpenGL or DirectX? on: 2004-04-08 12:19:21 From the Java3D FAQ What is Java3D? "...It uses either DirectX or the OpenGL low level API to take advantage of 3D hardware acceleration." Can someone tell me what this means? Does it use both? I thought you had to use one or the other. I am a gaming beginner....thanks,Barry
 Pages: [1]
 Add your game by posting it in the WIP section, or publish it in Showcase. The first screenshot will be displayed as a thumbnail.
 xFryIx (62 views) 2014-11-13 12:34:49 digdugdiggy (41 views) 2014-11-12 21:11:50 digdugdiggy (36 views) 2014-11-12 21:10:15 digdugdiggy (30 views) 2014-11-12 21:09:33 kovacsa (53 views) 2014-11-07 19:57:14 TehJavaDev (56 views) 2014-11-03 22:04:50 BurntPizza (55 views) 2014-11-03 18:54:52 moogie (70 views) 2014-11-03 06:22:04 CopyableCougar4 (71 views) 2014-11-01 23:36:41 DarkCart (156 views) 2014-11-01 14:51:03
 theagentd 29x basil_ 27x BurntPizza 23x princec 17x Spasi 17x Riven 15x pitbuller 15x HeroesGraveDev 14x KevinWorkman 13x SHC 11x Grunnt 10x kpars 10x gouessej 10x Nate 9x kevglass 9x Longarmx 9x
 Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27Resources for WIP games2014-08-01 16:20:17Resources for WIP games2014-08-01 16:19:50List of Learning Resources2014-07-31 16:29:50List of Learning Resources2014-07-31 16:26:06
 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