Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
games submitted by our members
Games in WIP (563)
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  
  Collision detection on jointed objects  (Read 1908 times)
0 Members and 1 Guest are viewing this topic.
Offline mkiki

Junior Newbie




Java games rock!


« Posted 2004-04-12 15:27:58 »

Hi,
I'm new to Ode & OdeJava (Hi Level API), and I notice that the collisions between 2 jointed bodies are not reported.
I have a very simple wordl with two boxes connected by an edge with a hinge joint, and when rotating around this joint, the boxes interpenetrate. If I remove the joint, though, they do not.
I recompiled all the OdeJava library, and noticed  the following code in the nearCallback function of odejava.cpp:

// ignore if the two bodies are connected by a joint
if (b1 && b2 && dAreConnectedExcluding (b1,b2,dJointTypeContact)) return;

This test will prevent collision between jointed bodies to be reported. If I comment it out, my boxes behave OK.
Am I doing something wrong, or should the test rather ignore the collision if the bodies do not have any contatct joints ?

Thanks,
-Alex


Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #1 - Posted 2004-04-13 22:52:02 »

looks like you've either found a bug or a feature Wink

Jani will hopefully soon clarify the intend of that code Smiley

If it's not too much trouble can you post a small test case?  Using the IssueZilla (http://odejava.dev.java.net/) is probably the best place to file bugs.

Will.

Offline Jani Laakso

Junior Member




Do it with Java!


« Reply #2 - Posted 2004-04-14 08:38:20 »

Quote
Hi,
I'm new to Ode & OdeJava (Hi Level API), and I notice that the collisions between 2 jointed bodies are not reported.


This is the current behaviour of Odejava.

Quote

following code in the nearCallback function of odejava.cpp:

// ignore if the two bodies are connected by a joint
if (b1 && b2 && dAreConnectedExcluding (b1,b2,dJointTypeContact)) return;


Current nearCallback is an example, it won't work on all simulations. It does however suit fine for many simulations. The biggest questionable nearCallback 'feature' is this "ignore jointed bodies" part that you have found. Easiest way is to offer two different callbacks on Odejava in order to satisfy most users needs.

Some people like to ignore bodies that are connected to each other with a joint, e.g. a car wheel should not hit to chassis at any case when wheel is connected to the car chassis with an joint.  This is how current Odejava nearCallback acts.

Some people would like to handle also these kind of collisions, this is your case and Odejava does not work this way.

Fast fix would be for me to add various nearCallbacks to Odejava but this is not too sound solution. I would have to think this a bit before implementing anything. Pure java collision class on Odejava (java nearCallback) is most flexible way to define your callback but it's also the slowest. Also it's not quite yet finished, even though it's easy to finish.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline mkiki

Junior Newbie




Java games rock!


« Reply #3 - Posted 2004-04-14 19:23:27 »

Ok, thanks for your answers.
I guess I'll start using my own callback function :-)
Thanks again,
-Alex

Offline Fuseboy

Junior Newbie




Java games rock!


« Reply #4 - Posted 2004-04-15 23:00:06 »

I'd like to throw in my support for collision detection between jointed objects.  This is pretty important to my in-game entity.  If you're concerned about speed with the callback on the Java side, perhaps this could be supplied as a flag to the C++ side?
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #5 - Posted 2004-04-16 01:01:50 »

an extra boolean argument to the method would probably work - don't think JNI works well with global "flags".  You _could_ have a seperate binary but that seems pointless.

Will.

Offline Jani Laakso

Junior Member




Do it with Java!


« Reply #6 - Posted 2004-04-19 15:00:41 »

I'll resolve this "problem" the next time I compile new Odejava library. Probably I'll throw in one or couple switch that affect to the callback.

Also autodisabling needs to be committed and new collision classes, these have been waiting on my Eclipse project for a month now..
Offline ck

Junior Newbie





« Reply #7 - Posted 2007-10-16 12:27:43 »

I'll resolve this "problem" the next time I compile new Odejava library. Probably I'll throw in one or couple switch that affect to the callback.

Also autodisabling needs to be committed and new collision classes, these have been waiting on my Eclipse project for a month now..

Hi!
I need collision detection between joinded objects. Now has been a while since this was posted. Has something changed on this topic?

How can I generate those contact points if two joined bodies collides?

Thanx,
Christian
Offline ck

Junior Newbie





« Reply #8 - Posted 2007-10-16 13:11:51 »

Ok,.... anyhow I found out that there is a class "PureJavaCollision", where I can implement my own calback function. I have no idea how to do it. Could anyone help please!?

As I know, I have to extend the class mentioned above and implement the callback like this:

public void nearCallback(int arg0, int arg1) {
      
      OdeConstants. SWIGTYPE_p_dGeomID o1 = Ode.dSpaceGetGeom(space.getId(), arg0);
      SWIGTYPE_p_dGeomID o2 = Ode.dSpaceGetGeom(space.getId(), arg1);
      
      if ( o1 != null && o2 != null) {
//          colliding two non-space geoms, so generate contact
//          points between o1 and o2
         int num_contact = dCollide (o1,o2,16,contact_array,skip);
      }
   }


As I said, I have no further idea....

Thanx,
Christian
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.

Grunnt (18 views)
2014-09-23 14:38:19

radar3301 (14 views)
2014-09-21 23:33:17

BurntPizza (31 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (29 views)
2014-09-20 20:14:06

BurntPizza (33 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (75 views)
2014-09-10 13:57:51

TehJavaDev (105 views)
2014-09-10 06:39:09
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!