Is it possible to set a different mass or weight for 1 side of a cube RigidBody?

Hi, anybody knows how I could achieve this? : I have a cube RigidBodyControl (tied to a j3o model) and that cube has a mass and gravity occurs just fine, but sometimes the cube lands on undesirable faces. I would like the cube to always land on 1 predictable side. How could I achieve this? Any ideas? I was wondering if it was possible to define 500% of the mass on that face of the cube RigidBodyControl so that almost everytime the cube lands on that face rather than the 5 others and even if it did, it would roll back into that predictable face down.

Any ideas?

Thx

You could offse the cube,
As far as I know the center of mass is the local 0,0,0 per default.
So offset the collisionshape (compound shape should help here) and the visible one, and it should archive your desired results.

(-> Alternativly you could in fly apply a bit torque to manipulate it more subtil, however the calcualtions are a bit more complex)

1 Like

How would offsetting the collisionshape help the shape fall on a predictable face? Can you elaborate on this a little?

ALSO: I was thinking (while I was sleeping last night) that I could use a dome shape instead of a cube, so that the bottom of the dome would be the predicted downward face. When the object collides with the TerrainQuad, it would roll until definitely stopping on its bottom face. The problem with this solution is that it does not seem to be possible to make dome collision shapes in JME3. Am I wrong on this?

@Empire Phoenix said: As far as I know the center of mass is the local 0,0,0 per default.

So when offseted the center is not in the middle of the cube anymore.

There are ConvexCollision shapes/ Hullcxollision shapes, you could do the dome yourself with that.

OK I think I visualize what shifting the center of mass would do. I’m now trying to follow this tutorial made by @normen 4 years ago (lol?) but PhysicsNode seems to not exist anymore.

https://code.google.com/p/jbullet-jme/wiki/CenterOfMass

Not sure how to go from there…

Thx

Well just use a normal node, and the controls on that, should work as far as I know.

having one side of cube heavier is not a solution, it is not useful until air friction is in place, NOT gravity (!). you may try to add torque to desired heading (for example top of cube to up vector), the torque will increace angular velocity towards desired heading and oscilated around it

if you want to stop rotation at specified heading, use PID control which i described here http://hub.jmonkeyengine.org/forum/topic/quaternions-torque-and-direction/

Well assuming its a dice, having one side hevyer it would work by manipulatiing the bouncing around part, once it hits the bord.
Still I would suggest manipulationg torque as well.

@.Ben. said: OK I think I visualize what shifting the center of mass would do. I'm now trying to follow this tutorial made by @normen 4 years ago (lol?) but PhysicsNode seems to not exist anymore.

https://code.google.com/p/jbullet-jme/wiki/CenterOfMass

Not sure how to go from there…

Thx

Whats to laugh about that? And the principle still works, instead of a PhysicsNode you have a PhysicsControl.

If you place the center of gravity (CoG) far enough (even outside the cube) then it will rotate up no matter what unless it perfectly lands exactly on the opposite side. Even if you placed it on its side it would rotate up.

I don’t know if you can place the CoG outside the cube but it would solve OP’s problem.

1 Like
@normen said: Whats to laugh about that? And the principle still works, instead of a PhysicsNode you have a PhysicsControl.

Nothing is really funny about it, sorry if it sounded like I was making fun of it, I’m really not. I’m trying to understand how to do that by following a tutorial and it’s not even using classes that EXIST anymore. A lot changed in 3-4 years I guess, that’s all.

Thanks for pointing out “instead of a PhysicsNode you have a PhysicsControl.”

I’ll try this later on along with other people’s suggestions and come back here with results.

Thx all.

@.Ben. said: Nothing is really funny about it, sorry if it sounded like I was making fun of it, I'm really not. I'm trying to understand how to do that by following a tutorial and it's not even using classes that EXIST anymore. A lot changed in 3-4 years I guess, that's all.

Thanks for pointing out “instead of a PhysicsNode you have a PhysicsControl.”

I’ll try this later on along with other people’s suggestions and come back here with results.

Thx all.

Well bullet-jme was for jME2, jME3 has bullet built in.

anyway, why do you want to cheat with that cube? what about different approach, instead of cheating motion, you can predict motion with math, but it will be hard :slight_smile:

@Ascaria said: anyway, why do you want to cheat with that cube? what about different approach, instead of cheating motion, you can predict motion with math, but it will be hard :)

Heheh… logically reduced, that translates as: “Why do it the easy way when you can do it the hard way?”

@pspeed said: Heheh... logically reduced, that translates as: "Why do it the easy way when you can do it the hard way?"

Actually, how about doing the rolling in the background, saving position and rotation every few frames. and remember wich side ended up.
Then just replay that, with a cube where the uv map is so adjusted that the desired number is up.

This kind of cheating will be really unnoticable, as the physic behaviour does not look weird

This will work if you know a or so in advance that you need a dice roll (Pro tip, fake the necessary time, by playing a animation with putting the dice in a cub and shacking it ^^).
The background could be at super speed, using manual physic stepping in a while loop with a seperate physicspace, so it would be really fast.

1 Like
@Ascaria said: anyway, why do you want to cheat with that cube? what about different approach, instead of cheating motion, you can predict motion with math, but it will be hard :)

I like the concept, but that could end up being as easy as using a MotionPath right? I could put a couple keyframes and let the engine animate the model as if it was responding to the RigidBodyControl physics while in fact, it would be a simple animation without any physics at all. But that brings me to an older question I asked on this forum but nobody answered it: Can we animate rotation just like we do for translation or is MotionPath only usable with translation?

EDIT: Using Quaternion.slerp() I think I could mix that with MotionPath and basically not use Physics or RigidBodyControl AT ALL for this animation and predict exactly how it will land on the ground (the good side up). I’ll try this later on and come back here to post results. Thx all for your valuable inputs.

anyway why do you want to force dice to do what you want to do? why would not be better enjoyment if dice do what it can and game will fit into dice’s need ?

@Ascaria said: anyway why do you want to force dice to do what you want to do? why would not be better enjoyment if dice do what it can and game will fit into dice's need ?

He never said it was dice. Not that it isn’t, but he never said it was… so it’s a leap to make any assumptions about enjoyment, re: dice rolls.

@pspeed said: He never said it was dice. Not that it isn't, but he never said it was... so it's a leap to make any assumptions about enjoyment, re: dice rolls.

He also did not say why he had such a strange request to force physics to do what he want and not what it is supposed to do :slight_smile: so we cannot suggest another possible solution to overcome problem without this requirement :slight_smile:

i have possibly most weirdest fantastic awful idea how to do this

make 2 models

  1. your cube
  2. sphere cutted on side by plane (i think in 3ds max its “boolean” and some settings)

use 1. as model and 2. as hull collision shape

but you cannot detect collisions with hull collision shape

and it will be mostly sphere :confused: thats very bad idea :smiley: forget it :smiley:

1 Like