Torque

Mar 2, 2010 at 1:01 PM

Hi, I have implemented the physic engine to my game since I want to see if this one works better then the one I am using.

But when I was using Torque on a rigid body nothing happened, is it not fully working or why isn't anythnig moving?

force, velocity and rotation works fine however, but not torque. I am using a sphere

Coordinator
Mar 3, 2010 at 5:12 AM

Torque should work fine.  A few things that may help:

- Is the torque you are applying big enough?

- Is damping or friction removing the torque you are applying?

- is the rigid body active (not static or disabled)?

- Is the rigidbody so big or "heavy" (mass/density) that the torque is doing little more than nothing?

- Is the interia tensor set to something besides all zeros?

If these are all true, you can post the code that creates the rigidbody and collisionsphere and I'll see if I can help with the issue.  Good luck!

Mar 3, 2010 at 11:05 AM

- Is the torque you are applying big enough?
body.ApplyWorldTorque(v3 * 200000000.0f);//tested with big numbers, so yes

- Is damping or friction removing the torque you are applying? // tested to try to move it when it was flying in the air, so yes

- is the rigid body active (not static or disabled)?

body.Activate();
                body.ApplyWorldTorque(v3 * 200000000.0f);
                body.Activate();

//just to make sure it is active i tested with this when it didn't work, but no difference, so i guess yes

- Is the rigidbody so big or "heavy" (mass/density) that the torque is doing little more than nothing?
//the mass is the default = 1.0f;

- Is the interia tensor set to something besides all zeros?
doesn't know what inertia tensor is, so i doesn't think i touched it.

 

Here is the code anyway,

public RigidBody CreateBalls(Vector3 position, float radius)
        {
            CollisionSphere cs = new CollisionSphere();
            cs.Radius = radius;
            //cs.Position = position;
            //CollisionGroup group = new CollisionGroup();
            //group.CollisionShapes.Add(cs);
            RigidBody rb = new RigidBody();
            rb.CollisionGroup.CollisionShapes.Add(cs);
            rb.Position = position;
            rb.Flags = RigidBodyFlags.None;
            physic.RigidBodies.Add(rb);
            //physic.CollisionSystem.CollisionGroups.Add(rb.CollisionGroup);

            return rb;
        }

I use the default for the settings(like friction and all) even if i have tested adding manually also.

Hope you can find the problem there, thanks

Coordinator
Mar 3, 2010 at 2:26 PM

I think (hope) I see the issue.  call rb.CalculateMassProperties(1.0f); right before you add the rigid body to the physics engine.  this will calculate a mass and inertia tensor for the rigid body based on density and the collision shapes attached to the rigid body's collision group.

This interiaTensor is sort of the mass for angular movement.  It determines how easy (or hard) it is to make the rigid body rotate.  After you call CalculateMassProperties, rb.InertiaTensor and rb.Mass get set.  You may have to adjust all your applied impulses and forces after this since these values will now be different.

Let me know if that worked for you.

Mar 3, 2010 at 5:31 PM

It works, thanks