コード例 #1
0
 public void OnAdditionToSpace(ISpace newSpace)
 {
     foreach(OperationalMachine o in machines)
         newSpace.Add(o);
     foreach(BaseModel m in models)
         newSpace.Add(m);
 }
コード例 #2
0
 void ISpaceObject.OnAdditionToSpace(ISpace newSpace)
 {
     //if(Ent != null)
     newSpace.Add(Ent);
     //else
     //    newSpace.Add(mesh);
 }
コード例 #3
0
ファイル: Wheel.cs プロジェクト: rc183/igf
        internal void OnAdditionToSpace(ISpace space)
        {
            //Make sure it doesn't collide with anything.

            shape.OnAdditionToSpace(space);
            shape.UpdateDetectorPosition(); //Need to put the detectors in appropriate locations before adding since otherwise overloads the broadphase
            space.Add(shape.detector);
        }
コード例 #4
0
 public override void OnAdditionToSpace(ISpace s)
 {
     foreach(WeldJoint j in joints)
         s.Add(j);
     s.Add(baseJoint);
     base.OnAdditionToSpace(s);
 }
コード例 #5
0
ファイル: Vehicle.cs プロジェクト: rc183/igf
 /// <summary>
 /// Sets up the vehicle's information when being added to the space.
 /// Called automatically when the space adds the vehicle.
 /// </summary>
 /// <param name="newSpace">New owning space.</param>
 public override void OnAdditionToSpace(ISpace newSpace)
 {
     newSpace.Add(body);
     foreach (Wheel wheel in Wheels)
     {
         wheel.OnAdditionToSpace(newSpace);
     }
 }
コード例 #6
0
ファイル: EntityMover.cs プロジェクト: dsmo7206/Lemma
 /// <summary>
 /// Adds the motors to the space.  Called automatically.
 /// </summary>
 public override void OnAdditionToSpace(ISpace newSpace)
 {
     newSpace.Add(LinearMotor);
 }
コード例 #7
0
 void ISpaceObject.OnAdditionToSpace(ISpace newSpace)
 {
     //newSpace.Add(m1);
     //newSpace.Add(m2);
     if(motor != null)
         newSpace.Add(motor);
     newSpace.Add(Ent);
     GameManager.Space.DuringForcesUpdateables.Starting += updateVelocities;
 }
コード例 #8
0
 public override void OnAdditionToSpace(ISpace newSpace)
 {
     foreach(WeldJoint j in joints)
         newSpace.Add(j);
     base.OnAdditionToSpace(newSpace);
 }
コード例 #9
0
 public override void OnAdditionToSpace(ISpace newSpace)
 {
     newSpace.Add(linearMotor);
     newSpace.Add(angularMotor);
 }
コード例 #10
0
 /// <summary>
 /// Adds the BeltPiece to an ISpace.
 /// </summary>
 /// <param name="newSpace"></param>
 public void OnAdditionToSpace(ISpace newSpace)
 {
     foreach(BaseModel m in models.Union(tubes))
         newSpace.Add(m);
 }
コード例 #11
0
 public virtual void OnAdditionToSpace(ISpace newSpace)
 {
     foreach(BaseModel m in modelList)
         if(m.Ent.Space == null)
             newSpace.Add(m);
     foreach(Tube t in tubeList)
         newSpace.Add(t);
     foreach(Button b in inputs.FindAll(v => { return v is Button; }))
         if(b.Model.Ent.Space == null)
             newSpace.Add(b);
     (newSpace as Space).DuringForcesUpdateables.Starting += updateVelocities;
 }
コード例 #12
0
ファイル: GameLevel.cs プロジェクト: jorik041/space-blok-wp
        public void LoadLevel(String fileName)
        {
            // Load level data
            GameLevelContent levelData = Game.Content.Load <GameLevelContent>(fileName);
            int blocksCount            = levelData.BlocksCount();

            // List of blocks chapes for compound body
            List <CompoundShapeEntry> shapes = new List <CompoundShapeEntry>();

            // Create block groups and block physics
            foreach (BlockGroupData blockGroup in levelData.BlockGroups)
            {
                // Create block group
                LoadBlockType(blockGroup.BlockTypeName, blocksCount);

                // Create physical representation of blocks in this group
                Vector3    scale;
                Quaternion rotation;
                Vector3    translation;
                foreach (BlockData blockData in blockGroup.Blocks)
                {
                    // Extract size, position and orientation values from block data transform
                    blockData.Transform.Decompose(out scale, out rotation, out translation);
                    blockData.Scale = scale;

                    // Create physical shape of the block to be part of compound body of blocks
                    BoxShape blockShape = new BoxShape(scale.X, scale.Y, scale.Z);

                    // Create compound shape entry for compund body of blocks
                    CompoundShapeEntry entry = new CompoundShapeEntry(blockShape, new RigidTransform(translation, rotation));
                    shapes.Add(entry);
                }
            }

            // Create compound body
            compoundBody = new CompoundBody(shapes, COMPOUND_BODY_MASS);

            compoundBody.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Continuous;
            compoundBody.AngularDamping     = COMPOUND_BODY_ANGULAR_DAMPING;

            // Compound body has Position and LocalPosition (in Collision information)
            // Position property is position of mass center in global space - it is calculated automatically.
            // LocalPosition property is position of geometry of the body in its local space.
            // So in order to create compound body which is rotated around desired position ((0,0,0) for now)
            // We should switch Position and LocalPosition properties of our compound body.
            compoundBody.CollisionInformation.LocalPosition = compoundBody.Position;
            compoundBody.Position = Vector3.Zero;

            // Add constraint prevents compound body from moving
            constraint = new MaximumLinearSpeedConstraint(compoundBody, 0.0f);

            // Create collision group for removed blocks
            removedBlocksGroup = new CollisionGroup();

            // Create blocks
            int childCollidableIndex = 0;

            foreach (BlockGroupData blockGroup in levelData.BlockGroups)
            {
                Matrix localPosTransform = Matrix.CreateTranslation(compoundBody.CollisionInformation.LocalPosition);

                foreach (BlockData blockData in blockGroup.Blocks)
                {
                    // Obtain block type and instanced mesh for the block
                    BlockType blockType = blockTypes[blockGroup.BlockTypeName];
                    InstancedMesh <VertexData> instancedMesh = blockInstancedMeshes[blockGroup.BlockTypeName];

                    // Obtain physics body (a part of compound body) for the block
                    CompoundChild child = compoundBody.CollisionInformation.Children[childCollidableIndex];

                    // Create instance of the block in instanced mesh
                    InstancedMesh <VertexData> .Instance instance = instancedMesh.AppendInstance(Matrix.CreateScale(blockData.Scale) * child.Entry.LocalTransform.Matrix * localPosTransform);

                    // Store new block instance to the list
                    Block block = new Block(blockType, instance, child);
                    blocks.Add(block);

                    block.Scale = blockData.Scale;

                    childCollidableIndex++;
                }
            }

            // Add compound body and its constraints to physics space
            space.Add(compoundBody);
            space.Add(constraint);
        }
コード例 #13
0
 public override void OnAdditionToSpace(ISpace newSpace)
 {
     //Add any supplements to the space too.
     newSpace.Add(Body);
     //This character controller requires the standard implementation of Space.
     ((Space)newSpace).BoundingBoxUpdater.Finishing += ExpandBoundingBox;
 }
コード例 #14
0
        public override void OnAdditionToSpace(ISpace newSpace)
        {
            //Add any supplements to the space too.
            newSpace.Add(Body);
            newSpace.Add(HorizontalMotionConstraint);
            newSpace.Add(VerticalMotionConstraint);
            //This character controller requires the standard implementation of Space.
            ((Space)newSpace).BoundingBoxUpdater.Finishing += ExpandBoundingBox;

            Body.AngularVelocity = new Vector3();
            Body.LinearVelocity = new Vector3();
        }
コード例 #15
0
 //protected void resetVelocities()
 //{
 //    foreach(BaseModel m in modelList)
 //        m.ReturnToInitialVelocities();
 //    foreach(Tube m in tubeList)
 //        m.ReturnToInitialVelocities();
 //}
 public override void OnAdditionToSpace(ISpace s)
 {
     //foreach(RotateMotor m in motorList)
     //    s.Add(m);
     foreach(WeldJoint j in joints)
         s.Add(j);
     s.Add(baseJoint);
     base.OnAdditionToSpace(s);
 }
コード例 #16
0
 public void OnAdditionToSpace(ISpace newSpace)
 {
     newSpace.Add(Model);
     newSpace.Add(joint);
     Model.Ent.CollisionInformation.Events.PairTouching += onCollision;
 }
コード例 #17
0
 public override void OnAdditionToSpace(ISpace s)
 {
     s.Add(baseJoint);
     s.Add(rotateJoint);
     foreach(WeldJoint j in welds)
         s.Add(j);
     base.OnAdditionToSpace(s);
 }