Example #1
0
        void fillOutDefinition(RigidBodyDefinition definition)
        {
            float mass = getInvMass();

            if (mass > 0.0f)
            {
                definition.Mass = 1.0f / mass;
            }
            else
            {
                definition.Mass = 0.0f;
            }
            definition.AngularDamping           = getAngularDamping();
            definition.AngularSleepingThreshold = getAngularSleepingThreshold();
            definition.Friction                = getFriction();
            definition.LinearDamping           = getLinearDamping();
            definition.LinearSleepingThreshold = getLinearSleepingThreshold();
            definition.Restitution             = getRestitution();
            definition.LinearVelocity          = getLinearVelocity();
            definition.AngularVelocity         = getAngularVelocity();
            definition.CurrentActivationState  = getActivationState();
            definition.AnisotropicFriction     = getAnisotropicFriction();
            definition.DeactivationTime        = getDeactivationTime();
            definition.Flags                = getCollisionFlags();
            definition.HitFraction          = getHitFraction();
            definition.ShapeName            = shapeName;
            definition.MaxContactDistance   = motionState.MaxContactDistance;
            definition.CollisionFilterGroup = collisionFilterGroup;
            definition.CollisionFilterMask  = collisionFilterMask;
            definition.StayLocalTransform   = StayLocalTransform;
            definition.LinearFactor         = LinearFactor;
            definition.AngularFactor        = AngularFactor;
        }
Example #2
0
        public override SimElementDefinition saveToDefinition()
        {
            RigidBodyDefinition definition = new RigidBodyDefinition(Name);

            fillOutDefinition(definition);
            return(definition);
        }
Example #3
0
        public unsafe RigidBody(RigidBodyDefinition description, BulletScene scene, btCollisionShape collisionShape, Vector3 initialTrans, Quaternion initialRot)
            : base(description.Name)
        {
            this.scene           = scene;
            shapeName            = description.ShapeName;
            collisionFilterMask  = description.CollisionFilterMask;
            collisionFilterGroup = description.CollisionFilterGroup;
            StayLocalTransform   = description.StayLocalTransform;
            motionState          = scene.createMotionState(this, description.MaxContactDistance, ref initialTrans, ref initialRot);

            rigidBody = btRigidBody_Create(ref description.constructionInfo, motionState.motionState, collisionShape.BulletShape);

            setLinearVelocity(description.LinearVelocity);
            setAngularVelocity(description.AngularVelocity);
            forceActivationState(description.CurrentActivationState);
            setAnisotropicFriction(description.AnisotropicFriction);
            setDeactivationTime(description.DeactivationTime);
            setCollisionFlags(description.Flags);
            setHitFraction(description.HitFraction);
            LinearFactor  = description.LinearFactor;
            AngularFactor = description.AngularFactor;

            RigidBodyManager.add(rigidBody, this);
        }
Example #4
0
 internal void addRigidBody(RigidBodyDefinition definition, SimObjectBase instance)
 {
     rigidBodies.Add(new BulletFactoryEntry(instance, definition));
 }