Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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  
  [Odejava] Centre Of Gravity Prob  (Read 2513 times)
0 Members and 1 Guest are viewing this topic.
Offline darkprophet

Senior Devvie




Go Go Gadget Arms


« Posted 2005-04-13 14:05:11 »

Hi all,
Im having a little difficulty with the centre of gravity:

When i do this:

1  
body.setMassParameters(mass, 0, -10, 0, 1, 1, 1, 0, 0, 0);


I get this:

1  
ODE Message 2: vector has zero size (ode/src/odemath.cpp:128)


repeatidly and the whole body shakes and wobbles and eventually flies off the screen.

Any ideas what im doing wrong? Btw, im changing its mass properties after ive added it to the world/space

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #1 - Posted 2005-04-14 04:16:53 »

Have you tried altering it before adding it to the world?

I wounder if you are getting the error because your last three numbers are 0?

Do you understand what effect the inertia matrix has?  I've read this page:  http://ode.org/ode-latest-userguide.html#sec_6_3_0 but it doesn't explain that.

Will.

Offline darkprophet

Senior Devvie




Go Go Gadget Arms


« Reply #2 - Posted 2005-04-14 13:22:38 »

well, i dont understand the inertia matrix, and ive read the same thing you have read before i posted this.

It seems the problem with the error disappears when instead of the 1's, i use the actual mass. But then, the centre of gravity has no effect at all on the object...

I'l try setting the centre of gravity before adding it...

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 darkprophet

Senior Devvie




Go Go Gadget Arms


« Reply #3 - Posted 2005-04-14 13:46:14 »

Ok, when i set it like:

1  
body.setMassParameters(mass, 0, -10, 1, 1, 1, 0, 0, 0);


before i add it to the world, i get a new error:

1  
ODE Message 2: center of mass inconsistent with mass parameters (ode/src/mass.cpp:68)


However, when i change the 0's to 1's also before adding it, i get teh same error as before, which is:

1  
 ODE Message 2: vector has zero size (ode/src/odemath.cpp:128) 


DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline Vikstar

Senior Newbie





« Reply #4 - Posted 2005-04-14 23:01:51 »

First of all, the inertia tensor that you give is for a sphere. Is this what you want? You can find the inertia tensors for various objects here: http://scienceworld.wolfram.com/physics/MomentofInertia.html

As for the errors, I don't think your allowed to have the centre of gravity different from (0,0,0). However, there is a workaround: http://q12.org/pipermail/ode/2005-March/015372.html

Also, from memory, you may have to use adjustMass() to set the actual mass after using setMassParameters().
Offline darkprophet

Senior Devvie




Go Go Gadget Arms


« Reply #5 - Posted 2005-04-16 08:38:05 »

Sorry, i need a box, so i obviously need to change the inertia tensor.

But because this is for a car, there is no way for me to make it more stable by lowering the centre of gravity?!

This seems rather stupid as one of Ode's main advantages is that its good for vehicles...

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline arne

Senior Devvie




money is the worst drug- we should not let it rule


« Reply #6 - Posted 2005-04-16 18:11:37 »

maybe you should use a GeomTransform?

Arne

PS: My thread about it being buggy was garbage, because GeomsTransforms start working fine, when you start simulating. At least It seems to me so now Wink

:: JOODE :: Xith3d :: OdeJava ::
Offline darkprophet

Senior Devvie




Go Go Gadget Arms


« Reply #7 - Posted 2005-04-16 19:53:19 »

Geom transform encapsulates a Geom and shifts it position, so it can work. This is a good idea, i.e. to offset the entire Body, but if the functionality is already in there in terms of dMassParameters and its buggy, i would rather fix it instead of having a workaround...

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline ewills

Junior Devvie




Java skeletal animation systems rock!


« Reply #8 - Posted 2005-04-17 15:48:37 »

Yes... It's a little troubling that we can't easily adjust a BodyS COM.  This sure seems like an ODE bug.  I would hope the ODE people are working on fixing this.
Offline harryk

Senior Newbie




Stone golems rock!


« Reply #9 - Posted 2005-04-18 12:11:34 »

From the ODE-docs: "When assigning a mass to a rigid body, the center of mass must be (0,0,0) relative to the body's position. But in fact this limitation has been in ODE from the start, so we can now regard it as a ``feature'' Smiley "

So.. I'm guessing, if its regarded as a feature its not likely to get fixed in the near future.

But I'm also trying to build a car and it is difficult to get it stable since the CM is way to high. Placing the geomtry lower using a geomtransform is not a good solution, since the geoms are also used for collision testing and the actual 3D-model the geoms are representing, is placed higher. One solution would be to have a displaced geom representing the mass of the car, and another geom for collisiontesting which I would set the position and orientation according to the mass-geometry minus the displacement. But this feels like a bad solution Smiley Any other ideas?

Has anyone implemented a arcade-feel car using odejava? I'd like some examples other than the cars in the test-package.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ewills

Junior Devvie




Java skeletal animation systems rock!


« Reply #10 - Posted 2005-04-18 20:32:01 »

Nice feature Smiley  Hmm...  At one point, I wanted to make a box difficult to tip over so I set its COM way under ground.  I could have sworn that moving the COM helped... maybe not Smiley

As for the car, it seems like you could use a GeomTransform to move the car geometry significantly above the Body.  The geometry is used for collision detection, so the geometry should rest on the ground and the Body (and COM) should be below that.

Edit:
Just checked my code... I also made the MOI insanely high.  That would account for the box not tipping over Smiley
Offline darkprophet

Senior Devvie




Go Go Gadget Arms


« Reply #11 - Posted 2005-04-19 08:31:33 »

Looks like im going to have to fake COM! Basically, fake down force...

Dang it! Angry

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline darkprophet

Senior Devvie




Go Go Gadget Arms


« Reply #12 - Posted 2005-05-02 07:38:35 »

Ok, thought of a good solution to this problem!

Take a box (as a car or something), the box will be top heavy and the car rolls around alot because i can't change the COM (i know this is a fact, ive tried it!).

So the solution is (that i have not tried yet) is to stuff the bottom box by a smaller, much heavier box that has the same width and length as the big box, but not the same height. That height can vary to vary the centre of gravity.

Then simply create a JointFixed between them two boxes and viola...you have a lowered centre of gravity!

Lets hope this works!  Smiley

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline ewills

Junior Devvie




Java skeletal animation systems rock!


« Reply #13 - Posted 2005-05-02 17:11:57 »

I have modified all of my code to get COMs working.  Here's the strategy:

Add the COM to each Body's position when I initially position it.

Attach the Geom using a GeomTransform that is offset by the negation of the COM.

It's working great!  A total hack and I wish Body.setMassParameters worked in ODE, but it's working great Smiley
Offline darkprophet

Senior Devvie




Go Go Gadget Arms


« Reply #14 - Posted 2005-05-03 13:50:51 »

only problem is that it cant be modified during runtime Sad

But your strategy sure is a heck of a lot better than mine Smiley

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline ewills

Junior Devvie




Java skeletal animation systems rock!


« Reply #15 - Posted 2005-05-03 14:05:20 »

I actually do allow modification of the COM during runtime.  In my experience, both a Body's position and a GeomTransform's offset can be adjusted between collision and step calls.  Modifying a GeomTransform's offset seems to work pretty well, but modifying a Body's position causes discontinuities (understandably).  So long story short, it works if you occasionally need to make an adjustment, but not if you to constantly vary your COM (why would you want to do this anyway?).
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.

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

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

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

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

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

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

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (114 views)
2014-11-26 15:22:04

toopeicgaming1999 (102 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
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!