weight/mass independent spinning result using torque?

katzenjoghurt

26-09-2007 13:30:18

Hi! :D

Oh my... I'm a physics loser, baby, so why don't you kill me? :lol:

Is there a way to turn a Body by a certain degree independent of it's weight?
-or-
which would be an even better solution for me:
Is there an X so that the resulting spinning in degrees caused by
Body->addTorque(Vector3(torqueX,torqueY,torqueZ) *X );
is independent of the body's mass and size?

So that both bodys...
Body1 = mScene->createBody(meshFile,new NxOgre::CubeShape(100,200,100), pos, "mass: 15");
Body2 = mScene->createBody(meshFile,new NxOgre::CubeShape(10,10,10), pos, "mass: 10");


...

Body1->addTorque(Vector3(torqueX,torqueY,torqueZ) *X1 );
Body2->addTorque(Vector3(torqueX,torqueY,torqueZ) *X2 );
would turn around the - let's say y axis - with the same degree?

betajaen

26-09-2007 14:16:59

You could try Actor::moveGlobalOrientation()

katzenjoghurt

26-09-2007 15:20:02

Hm... tried Body->moveGlobalPosition(Vector3(0,90,0));
to test.... before fiddling around with quaternions.

Nothing happened.

Hmhm...


I might be completely wrong... as i said ... physics really, really aren't my strength ... but isn't somehow the weight of the object calculated via mass and object size, which comes into play when using torque? Thought I could somehow use this weight as a factor when applying the torque.

betajaen

26-09-2007 15:39:10

Perhaps moveGlobalOrientation/Position only works with Kinematic Actors.

You could try multiplying the quaternion with the mass of the Actor.

katzenjoghurt

26-09-2007 19:15:26

I try doing...

Body->addTorque(Vector3(torqueX,torqueY,torqueZ) * shape_Height* shape_Length * shape_Width * mass / 10000.0);

...which works out somehow.

While turning I will try to raise the ang'dampening. The closer it reaches the wanted spinning degree the higher the dampening.

I'll see ... hum hum ... quite wild... quite flubby ...

betajaen

26-09-2007 19:17:29

Why the shape_? and the 10000? Seems unneeded since you have the mass?

katzenjoghurt

26-09-2007 19:39:51

I'm confused ...

I thought of mass being more something like a material density which I define in the beginning here:
Body = mScene->createBody(meshFile,new NxOgre::CubeShape(10,10,10), pos, "mass: 10");

so that

Body->getMass()

would return 10, being completely independent of the object's size. :?:

betajaen

26-09-2007 19:43:52

No. Your talking about density; "density: 10" (10 kg per metre - I believe), which is converted into mass via the volume of the shape. So a 1x1x1 metre cube is 10 kilograms (1*1*1*10), and a 2x2x2 is 80 (2*2*2 * 10).

Otherwise with "mass:10" makes the mass of the actor to 10 kilograms, regardless of shape.

katzenjoghurt

26-09-2007 19:49:24

ahhh! So it's overridden with the mass parameter. Thx. Now it makes sense.


Though I still wonder why the object's getting more sluggish, when applying a torque on a bigger model although I've overridden the mass with the parameter.

Body1 = mScene->createBody(meshFile,new NxOgre::CubeShape(10,10,10), pos, "mass: 10");
Body2 = mScene->createBody(meshFile,new NxOgre::CubeShape(30,30,30), pos, "mass: 10");

Body1->addTorque(Vector3(0,30000,0));
Body2->addTorque(Vector3(0,30000,0));






Body2 being more sluggish than Body1...

betajaen

26-09-2007 19:52:38

Intresting. What does getMass() say on both of those Actors?

katzenjoghurt

26-09-2007 20:11:12

They both return 10.

Here's the code:




...

myBodyX05 = mScene->createBody("edelguppy.mesh",new NxOgre::CubeShape(10,10,10),Vector3(100,340.5,-650), "mass: 10");
myBodyX06 = mScene->createBody("edelguppy.mesh",new NxOgre::CubeShape(20,20,20),Vector3(150,340.5,-650), "mass: 10");


...



bool AppFrameListener::frameStarted(const FrameEvent& evt)
{

passedTime+=evt.timeSinceLastFrame;

if (passedTime>=5.0)
{

myBodyX05->setLinearDamping(0.2);
myBodyX05->setAngularDamping(2.0);
myBodyX06->setLinearDamping(0.2);
myBodyX06->setAngularDamping(2.0);
myBodyX05->addTorque(Vector3(0,30000,0));
myBodyX06->addTorque(Vector3(0,30000,0));
passedTime=0;
}

debugOverlay->guiAngle->setCaption("Fish Mass: " + StringConverter::toString(myBodyX06->getMass()));
return true;
}



(Okay .. the set damping stuff shouldn't be in frameStarted... but anyway :) )


And here's the corresponding vid showing the result:
http://wwwstud.ira.uka.de/~s_walser/fischies.avi

(The second fishes mass is given out in the last line of the lower left debug window)

betajaen

26-09-2007 20:52:41

I'm just as knowledgeable about physics as you (well maybe a bit more).

But with I remember with helicopter blades the nearer to the center of the helicopter the slow the blade is moving. Perhaps added torque is the same, since the shape is bigger than the other, then perhaps the torque should be proportional to the bigger shape; BiggerShapeTorque =30,000 * (1 + (20/30)) = 50,000

See if that works.

katzenjoghurt

26-09-2007 21:13:34

50.000 was a bit too weak. ... 120.000 hit the spot ... :?

Even minutes later the two guys are abolutely synchronous.

Hmmm... makes sense. 8 times the size => 8 times the torque.
(edit: ooops... no, would have been 4 times the torque... uhm ...)

myBodyX05->addTorque(Vector3(0,30000,0)); //*(100*100*10*5000)/1000);
myBodyX06->addTorque(Vector3(0,120000,0)); //*(100*100*10*5000)/1000);


http://wwwstud.ira.uka.de/~s_walser/fischies2.avi


so (shape_Height* shape_Length * shape_Width) / 1000 seems like a good factor...

I'll check this tomorrow with other sizes.

NickM

26-09-2007 21:43:56

Couldn't you change the NxForceMode so that it ignores the mass totally?

addTorque(const Ogre::Vector3& torque, NxForceMode mode = NX_FORCE, bool wakeup = true);

katzenjoghurt

26-09-2007 21:52:13

hmmm...

NxForceMode

Parameter to addForce*() calls, determines the exact operation that is carried out.


See also:
NxActor.addForce() NxActor.addTorque()
Enumerator:
NX_FORCE parameter has unit of mass * distance/ time^2, i.e. a force
NX_IMPULSE parameter has unit of mass * distance /time
NX_VELOCITY_CHANGE parameter has unit of distance / time, i.e. the effect is mass independent: a velocity change.
NX_SMOOTH_IMPULSE same as NX_IMPULSE but the effect is applied over all substeps. Use this for motion controllers that repeatedly apply an impulse.
NX_SMOOTH_VELOCITY_CHANGE same as NX_VELOCITY_CHANGE but the effect is applied over all substeps. Use this for motion controllers that repeatedly apply an impulse.
NX_ACCELERATION parameter has unit of distance/ time^2, i.e. an acceleration. It gets treated just like a force except the mass is not divided out before integration.


I will try NX_VELOCITY_CHANGE tomorrow then ...

betajaen

26-09-2007 22:20:53

Well I was close. My second idea was going to fiddle around with the Force Modes, but NickM got it first.

katzenjoghurt

27-09-2007 09:52:11

Thank you, guys!!! :D

All of the mass independent force modes do the trick.


Yet... (yeah!) .... one more ... (I hope) last question:
Do you have any idea how I might make the object turn quicker?

No matter if I do...

myBodyX05->addTorque(Vector3(0,10,0), NX_VELOCITY_CHANGE );
or
myBodyX04->addTorque(Vector3(0,300000000000,0), NX_VELOCITY_CHANGE );

They both have the same rotation speed as speed is already maxed. Torque seems to reach from Vector3([0-10], [0-10], [0-10]) now.

Maximum speed would be this:

http://wwwstud.ira.uka.de/~s_walser/fischies4.avi

Changing the dampening values of course only leads to a faster stop or no stop at all when set to 0 having no inpact on the initial max. speed.

hm.... :?

betajaen

27-09-2007 09:58:21

Have you tried stacking it?

myBodyX05->addTorque(Vector3(0,10,0), NX_VELOCITY_CHANGE );
myBodyX05->addTorque(Vector3(0,10,0), NX_VELOCITY_CHANGE );


Otherwise my "trick" could do it; Volume Multiplier * Acceleration.

p.s. Nice Fish. :D

katzenjoghurt

27-09-2007 10:09:59

Have you tried stacking it?

Yep. Didn't work. Thought he'd only update it once per frame.
So i tried setting the ang. damping to zero.
It always kept the same speed instead of becoming faster every 5 sec with a new torque applied.

Otherwise my "trick" could do it; Volume Multiplier * Acceleration.

Uhm... didn't get that one. Might you explain it to old katzenjoghurt a bit more detailed? :D


p.s. Nice Fish. :D

Thx! Passed this one to the artist. :D

betajaen

27-09-2007 10:12:02

Hmm. What happens if you add the second stacked torque without the NX_VELOCITY_CHANGE?

katzenjoghurt

27-09-2007 10:15:20

They are still completely synchronous then.

myBodyX05->setLinearDamping(0.2);
myBodyX05->setAngularDamping(2.0);
myBodyX06->setLinearDamping(0.2);
myBodyX06->setAngularDamping(2.0);
myBodyX05->addTorque(Vector3(0,10,0), NX_VELOCITY_CHANGE );

myBodyX05->addTorque(Vector3(0,300000000000,0));

myBodyX06->addTorque(Vector3(0,300000000000,0), NX_VELOCITY_CHANGE );

betajaen

27-09-2007 10:30:35

Alright going back to the old code:

myBodyX05->addTorque(Vector3(0,30000,0)); //*(100*100*10*5000)/1000);
myBodyX06->addTorque(Vector3(0,120000,0)); //*(100*100*10*5000)/1000);
myBodyX06->addTorque(Vector3(0,1200,0)); // + 1200;

katzenjoghurt

27-09-2007 11:10:11

*scratches his head*

don't know what should have happened but ...


if (passedTime>=5.0)
{

myBodyX05->setLinearDamping(0.2);
myBodyX05->setAngularDamping(2.0);
myBodyX06->setLinearDamping(0.2);
myBodyX06->setAngularDamping(2.0);

myBodyX05->addTorque(Vector3(0,30000,0));
myBodyX06->addTorque(Vector3(0,120000,0));
myBodyX06->addTorque(Vector3(0,1200,0)); // + 1200;
passedTime=0;
}


here ... http://wwwstud.ira.uka.de/~s_walser/fischies5.avi

(X06 is a bit faster)


==========


if (passedTime>=5.0)
{

myBodyX05->setLinearDamping(0.2);
myBodyX05->setAngularDamping(2.0);
myBodyX06->setLinearDamping(0.2);
myBodyX06->setAngularDamping(2.0);

myBodyX05->addTorque(Vector3(0,30000,0)); //*(100*100*10*5000)/1000);
myBodyX06->addTorque(Vector3(0,120000,0)); //*(100*100*10*5000)/1000);
myBodyX06->addTorque(Vector3(0,120000,0)); // + 1200;
myBodyX06->addTorque(Vector3(0,120000,0)); // + 1200;
myBodyX06->addTorque(Vector3(0,120000,0)); // + 1200;
myBodyX06->addTorque(Vector3(0,120000,0)); // + 1200;
myBodyX06->addTorque(Vector3(0,120000,0)); // + 1200;

passedTime=0;
}



results in:

http://wwwstud.ira.uka.de/~s_walser/fischies6.avi

(X06 again a bit faster but still no hurricane)

betajaen

27-09-2007 11:24:27

Well your adding some torque, not setting it. Imagine running your hand across a globe, moving it faster and faster. That's what it's doing.

If you want the Second fish to spin twice as fast as the first one:

myBodyX06->addTorque(Vector3(0,120000,0));
myBodyX06->addTorque(Vector3(0,120000,0));

katzenjoghurt

27-09-2007 11:31:28

but it doesn't do that (or it does but reaches it's limit)... please look above. :(
(edited my last posting)

katzenjoghurt

28-09-2007 02:17:42

I don't get it.

addForce(Vector) isn't limited.
Putting a high value here results in the fish disappearing with supersonic speed in the sky... why is there a fixed value in addTorque()? :?:

katzenjoghurt

29-09-2007 14:40:34

oh maaan .... finally.... and it was so obvious....

myBodyX06->setMaxAngularVelocity(40);

...and everything's fine afterwards.


Anyway... thx a lot for your support, betajaen and Essex! :D

betajaen

29-09-2007 14:45:59

Different solution than I expected, we should of read the PhysX documentation a bit more closely. ;)

katzenjoghurt

29-09-2007 14:54:09

just flipped through the body members once more ... read getMaxVelo.... and there it was ... a setMaxVelo ... and even the neighbours must have heared the loud clap coming from my forehead.