Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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  
  GeomTransform problems  (Read 1496 times)
0 Members and 1 Guest are viewing this topic.
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Posted 2004-10-07 21:56:34 »

When I create a GeomBox and attach it to a Body, collision detection and response works fine.  Here's the code:

GeomBox gb = new GeomBox(1.0f, 1.0f, 1.0f);
World       w  = ...
Body         b  = new Body(null, w, gb);

When I encapsulate the GeomBox within a GeomTransform,  collision detection no longer works.  Here's the modified code:

GeomBox           gb = new GeomBox(1.0f, 1.0f, 1.0f);
GeomTransform gt = new GeomTransform();
gt.setEncapsulatedGeom(gb);

World       w  = ...
Body         b  = new Body(null, w, gt);

Does anyone know what I'm doing wrong?
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #1 - Posted 2004-10-08 00:08:55 »

are you adding it to a space?

Will.

Offline jirafaveloz

Junior Newbie




Java games rock!


« Reply #2 - Posted 2004-10-08 13:04:38 »

I have some problems with GeomTransforms too. Trying to run the MultiGeomTest demo, this appears:

ODE Message 2:  inertia must be positive definite <ode/scr/ode.cpp:410>

I created some geometries like the example class (MultiGeomExample in odejava test directory) but don't seem to be useful.

Any idea?

I was attempting to build some multiple geometries bodies. I tried to attach several geometries to a body but they aren't displayed (using Xith3D HighLevelApiExample and SimpleExample demos). I also created 3 bodies and tried to link them using a fixed joint. They are indeed displayed but the interaction and behavior in not correct. They put together during a free fall. How can I really create  a multiple geometry body and display it?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #3 - Posted 2004-10-08 19:20:52 »

In both cases, I call space.addBodyGeoms(b).  I get a warning if I try to add the encapsulated geom.

I am also trying to create a body with multiple geometries  Smiley
Offline ewills

Junior Member




Java skeletal animation systems rock!


« Reply #4 - Posted 2004-10-09 01:17:44 »

Got it working!  The problem seems to be related to the way that the body's mass and inertia parameters are set.   GeomTransform doesn't seem to operate correctly after I set body mass using adjustMass.  Conversely, I'm not having any problems with GeomTransform after setting the body's mass and inertial parameters using setMassParameters.   Cheesy
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #5 - Posted 2004-10-09 03:01:17 »

Quote
I created some geometries like the example class (MultiGeomExample in odejava test directory) but don't seem to be useful.


Care to elaborate?  The Multi geom test demo look correct to me - I see a box with a rectangle at a set transform.

Quote

I also created 3 bodies and tried to link them using a fixed joint. They are indeed displayed but the interaction and behavior in not correct. They put together during a free fall. How can I really create  a multiple geometry body and display it?


They should really be created using GeomTransform.  Fixed joints shouldn't be used unless there is a compelling reason and certainly not as a substitute for GeomTransform.  I use GeomTransform extensivly and it works well.

Will.

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #6 - Posted 2004-10-09 03:04:36 »

Quote
Got it working!  The problem seems to be related to the way that the body's mass and inertia parameters are set.   GeomTransform doesn't seem to operate correctly after I set body mass using adjustMass.  Conversely, I'm not having any problems with GeomTransform after setting the body's mass and inertial parameters using setMassParameters.   Cheesy


Glad you worked it out.  I've had a few moments like that before too.  It is very important to realise that despite the fact Odejava is object orientated, ODE is not and requires calls to be made in a specific order as you have found out.  Most of my "strange" problems have all related to mass.

Will.

Offline jirafaveloz

Junior Newbie




Java games rock!


« Reply #7 - Posted 2004-10-09 16:11:52 »

Thanks for the setMassParameters tip. It is very useful  Nevertheless, I still have problems with the HighLevelApiExample shown by Xith3D. I added this in the initObjects() method in HighLevelApiExample.java:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
Geombox myBox1 = new GeomBox(depth,length,height);
Geombox myBox2= new GeomBox(depth,length,height);

myBoxBody = new Body("myBody1", world);            
myBoxBody.addGeom(myBox1);
GeomTransform  myTransform = new GeomTransform();
myTransform.setEncapsulatedGeom(myBox2);
myBoxBody.addGeom(myTransform);
myBoxBody.setMassParameters(1f,0f,0f,0f,0.01f,0.01f,0.01f,0.01f,0.01f,0.01f);
           
myBoxBodyId = myBoxBody.getGeom().getNativeAddr();
     
space.addBodyGeoms(myBoxBody);
myBox1.setPosition(  1.5f, 0f, 6.5f);
myBox2.setPosition( -1.5f, 0f, 6.5f);
           
myBoxBody.setPosition(0f,0f,6.5f);



and added this in iterateContacts(), too:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
      if(contact.getGeomID2() == myBoxBody){
              contact.getPosition(pos);
              contact.getNormal(normal);
              contact.setMode(Ode.dContactBounce | Ode.dContactApprox1);
              contact.setBounce(1.25f);
              contact.setBounceVel(0.2f);
              contact.setMu(0f);
                   
              System.err.println(
                        "B: "
                        + i
                        + " myBoxBody  hits geom "
                        + contact.getGeomID1()
                        + "\n  d="
                        + contact.getDepth()
                        + "\n  pos="
                        + pos
                        + "\n  normal="
                        + normal);
      }


The SimpleExample of Xith3D was not modified. Both classes were compiled without errors or warnings. When I execute the HighLevelApiExample.class everything seems to be OK and there in no exceptions. Execute this class only produces DOS command lines. But executing SimpleExample.class, everything is OK before [/b]the first contact of  myBoxBody with the box defined in HighLevelApiExample that is above the sphere. When the contact occurs, all the bodies displayed disappear.

Any idea?
What am I doing wrong?

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.

atombrot (27 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
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!