示例#1
0
        internal override void createProduct(SimObjectBase instance, BulletScene scene)
        {
            btCompoundShape      shape     = new btCompoundShape(0.0f);
            ReshapeableRigidBody rigidBody = new ReshapeableRigidBody(this, scene, shape, instance.Translation, instance.Rotation);

            instance.addElement(rigidBody);
        }
示例#2
0
 public IntPtr create(BulletScene obj, BulletSceneDefinition definition)
 {
     handle = GCHandle.Alloc(obj);
     fixed(BulletSceneInfo *info = &definition.sceneInfo)
     {
         return(BulletScene_CreateBulletScene(info, managedTickCallback, GCHandle.ToIntPtr(handle)));
     }
 }
 public TypedConstraintElement(String name, BulletScene scene, RigidBody rbA, RigidBody rbB)
     : base(name)
 {
     constraint = IntPtr.Zero;
     this.rbA   = rbA;
     this.rbB   = rbB;
     this.scene = scene;
     active     = true;
     enabled    = false;
 }
 public override void registerScene(SimSubScene subscene, SimObjectBase instance)
 {
     if (subscene.hasSimElementManagerType(typeof(BulletScene)))
     {
         BulletScene sceneManager = subscene.getSimElementManager <BulletScene>();
         sceneManager.getBulletFactory().addRigidBody(this, instance);
     }
     else
     {
         Log.Default.sendMessage("Cannot add RigidBodyDefinition {0} to SimSubScene {1} because it does not contain a BulletSceneManager.", LogLevel.Warning, BulletInterface.PluginName, Name, subscene.Name);
     }
 }
        internal override void createProduct(SimObjectBase instance, BulletScene scene)
        {
            BulletShapeRepository repository = BulletInterface.Instance.ShapeRepository;

            if (repository.containsValidCollection(ShapeName))
            {
                btCollisionShape shape = repository.getCollection(ShapeName).CollisionShape;
                if (constructionInfo.m_mass != 0.0f)
                {
                    shape.calculateLocalInertia(constructionInfo.m_mass, ref constructionInfo.m_localInertia);
                }
                RigidBody rigidBody = new RigidBody(this, scene, shape, instance.Translation, instance.Rotation);
                instance.addElement(rigidBody);
            }
            else
            {
                Log.Default.sendMessage("Could not find collision shape named {0}.", LogLevel.Warning, "BulletPlugin", ShapeName);
            }
        }
示例#6
0
 public void renderDebug(SimSubScene subScene)
 {
     if (enabled)
     {
         BulletScene sceneManager = subScene.getSimElementManager <BulletScene>();
         if (sceneManager != null)
         {
             sceneManager.drawDebug(drawingSurface);
         }
     }
     else if (firstFrameDisabled)
     {
         BulletScene sceneManager = subScene.getSimElementManager <BulletScene>();
         if (sceneManager != null)
         {
             sceneManager.clearDebug(drawingSurface);
         }
         firstFrameDisabled = false;
     }
 }
示例#7
0
        protected override void link()
        {
            base.link();

            SimObject rigidBodySimObject = Owner.getOtherSimObject(rigidBodySimObjectName);

            if (rigidBodySimObject == null)
            {
                blacklist("Cannot find rigidBodySimObject '{0}'", rigidBodySimObjectName);
            }

            RigidBody rigidBody = rigidBodySimObject.getElement(rigidBodyName) as RigidBody;

            if (rigidBody == null)
            {
                blacklist("Cannot find rigid body '{0}' rigidBodySimObject '{1}'", rigidBodyName, rigidBodySimObjectName);
            }

            bulletScene = rigidBody.Scene;
            bulletScene.AutoSynchronizeAfterUpdate = false;
        }
示例#8
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);
        }
示例#9
0
 internal abstract void createStaticProduct(SimObjectBase instance, BulletScene scene);
示例#10
0
 protected override TypedConstraintElement createConstraint(RigidBody rbA, RigidBody rbB, SimObjectBase instance, BulletScene scene)
 {
     if (rbA != null && rbB != null)
     {
         return(new FixedConstraintElement(this, instance, rbA, rbB, scene));
     }
     return(null);
 }
 public FixedConstraintElement(FixedConstraintDefinition definition, SimObjectBase instance, RigidBody rbA, RigidBody rbB, BulletScene scene)
     : base(definition.Name, scene, rbA, rbB)
 {
     setConstraint(btFixedConstraint_Create(rbA.NativeRigidBody, rbB.NativeRigidBody, instance.Rotation, instance.Translation));
 }
 public Generic6DofConstraintElement(Generic6DofConstraintDefinition definition, SimObjectBase instance, RigidBody rbA, RigidBody rbB, BulletScene scene)
     : base(definition.Name, scene, rbA, rbB)
 {
     setConstraint(btGeneric6DofConstraint_Create(rbA.NativeRigidBody, rbB.NativeRigidBody, instance.Rotation, instance.Translation, definition.translationMotor, definition.xRotMotor, definition.yRotMotor, definition.zRotMotor));
 }
 internal override void createStaticProduct(Engine.ObjectManagement.SimObjectBase instance, BulletScene scene)
 {
 }
 public void createStaticProduct(BulletScene scene)
 {
     element.createStaticProduct(instance, scene);
 }
 internal override void createStaticProduct(SimObjectBase instance, BulletScene scene)
 {
 }
        internal override void createProduct(Engine.ObjectManagement.SimObjectBase instance, BulletScene scene)
        {
            RigidBody rbA = null;
            RigidBody rbB = null;

            SimObject other = instance.getOtherSimObject(RigidBodyASimObject);

            if (other != null)
            {
                rbA = other.getElement(RigidBodyAElement) as RigidBody;
            }

            other = instance.getOtherSimObject(RigidBodyBSimObject);
            if (other != null)
            {
                rbB = other.getElement(RigidBodyBElement) as RigidBody;
            }

            TypedConstraintElement element = createConstraint(rbA, rbB, instance, scene);

            if (element != null)
            {
                instance.addElement(element);
            }
        }
 protected abstract TypedConstraintElement createConstraint(RigidBody rbA, RigidBody rbB, SimObjectBase instance, BulletScene scene);
示例#18
0
 public BulletFactory(BulletScene scene)
 {
     this.scene = scene;
 }
 public ReshapeableRigidBody(ReshapeableRigidBodyDefinition description, BulletScene scene, btCompoundShape collisionShape, Vector3 initialTrans, Quaternion initialRot)
     : base(description, scene, collisionShape, initialTrans, initialRot)
 {
     this.compoundShape = collisionShape;
 }