Exemple #1
0
        private void AddArena()
        {
            BoxShapeProperties tBoxShape  = null;
            SingleShapeEntity  tBoxEntity = null;

            tBoxShape             = new BoxShapeProperties(500f, new Pose(), new Vector3(5f, 0.25f, 0.25f));
            tBoxEntity            = new SingleShapeEntity(new BoxShape(tBoxShape), new Vector3(0f, 0.5f, 2.63f));
            tBoxEntity.State.Name = "arena top";
            SimulationEngine.GlobalInstancePort.Insert(tBoxEntity);

            BoxShapeProperties lBoxShape  = null;
            SingleShapeEntity  lBoxEntity = null;

            lBoxShape             = new BoxShapeProperties(500f, new Pose(), new Vector3(0.25f, 0.25f, 5f));
            lBoxEntity            = new SingleShapeEntity(new BoxShape(lBoxShape), new Vector3(-2.63f, 0.5f, 0f));
            lBoxEntity.State.Name = "arena left";
            SimulationEngine.GlobalInstancePort.Insert(lBoxEntity);

            BoxShapeProperties rBoxShape  = null;
            SingleShapeEntity  rBoxEntity = null;

            rBoxShape             = new BoxShapeProperties(500f, new Pose(), new Vector3(0.25f, 0.25f, 5f));
            rBoxEntity            = new SingleShapeEntity(new BoxShape(rBoxShape), new Vector3(2.63f, 0.5f, 0f));
            rBoxEntity.State.Name = "arena right";
            SimulationEngine.GlobalInstancePort.Insert(rBoxEntity);

            BoxShapeProperties bBoxShape  = null;
            SingleShapeEntity  bBoxEntity = null;

            bBoxShape             = new BoxShapeProperties(500f, new Pose(), new Vector3(5f, 0.25f, 0.25f));
            bBoxEntity            = new SingleShapeEntity(new BoxShape(bBoxShape), new Vector3(0f, 0.5f, -2.63f));
            bBoxEntity.State.Name = "arena bottom";
            SimulationEngine.GlobalInstancePort.Insert(bBoxEntity);
        }
Exemple #2
0
        private void AddCube(Vector3 position)
        {
            BoxShapeProperties cBoxShape  = null;
            SingleShapeEntity  cBoxEntity = null;

            cBoxShape             = new BoxShapeProperties(2.0f, new Pose(), new Vector3(0.5f, 0.5f, 0.5f));
            cBoxEntity            = new SingleShapeEntity(new BoxShape(cBoxShape), position);
            cBoxEntity.State.Name = "cube:" + Guid.NewGuid().ToString();
            SimulationEngine.GlobalInstancePort.Insert(cBoxEntity);
        }
        void insertrod()
        {
            Shape             rod     = new CapsuleShape(new CapsuleShapeProperties(1000, new Pose(), .008f, 3));
            SingleShapeEntity hangrod = new SingleShapeEntity(rod, new Vector3(0, 1, .05f));

            hangrod.State.Name = "hangrod";
            hangrod.Rotation   = new Microsoft.Xna.Framework.Vector3(0, 0, 90);
            //hangrod.State.Pose.Orientation = new Quaternion(0, 0, 1, 1);
            hangrod.State.Flags = EntitySimulationModifiers.Kinematic;
            SimulationEngine.GlobalInstancePort.Insert(hangrod);
        }
        public void AddBoundaries(float dimX, float dimY)
        {
            //Right Wall
            Vector3 dimensions = new Vector3(.5f, .5f, dimY);
            Vector3 position = new Vector3(dimX, .5f, -(dimY / 2f));
            BoxShapeProperties tBoxShape = new BoxShapeProperties(10000000f, new Pose(), dimensions);
            tBoxShape.Material = new MaterialProperties("tbox", 0.4f, 0.4f, 0.6f);
            tBoxShape.DiffuseColor = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
            SingleShapeEntity tBoxEntity = new SingleShapeEntity(new BoxShape(tBoxShape), position); ;
            tBoxEntity.State.Assets.DefaultTexture = "env2.bmp";
            tBoxEntity.State.Name = "Wall";

            //Top Wall
            Vector3 dimensions2 = new Vector3(dimX - 1, .5f, .5f);
            Vector3 position2 = new Vector3((dimX / 2f), .5f, 0);
            BoxShapeProperties tBoxShape2 = new BoxShapeProperties(10000000f, new Pose(), dimensions2);
            tBoxShape2.Material = new MaterialProperties("tbox", 0.4f, 0.4f, 0.6f);
            tBoxShape2.DiffuseColor = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
            SingleShapeEntity tBoxEntity2 = new SingleShapeEntity(new BoxShape(tBoxShape2), position2); ;
            tBoxEntity2.State.Assets.DefaultTexture = "env2.bmp";
            tBoxEntity2.State.Name = "Wall2";

            //Bottom Wall
            Vector3 dimensions3 = new Vector3(dimX - 1, .5f, .5f);
            Vector3 position3 = new Vector3((dimX / 2f), .5f, -dimY);
            BoxShapeProperties tBoxShape3 = new BoxShapeProperties(10000000f, new Pose(), dimensions3);
            tBoxShape3.Material = new MaterialProperties("tbox", 0.4f, 0.4f, 0.6f);
            tBoxShape3.DiffuseColor = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
            SingleShapeEntity tBoxEntity3 = new SingleShapeEntity(new BoxShape(tBoxShape3), position3); ;
            tBoxEntity3.State.Assets.DefaultTexture = "env2.bmp";
            tBoxEntity3.State.Name = "Wall3";

            //Left Wall
            Vector3 dimensions4 = new Vector3(.5f, .5f, dimY);
            Vector3 position4 = new Vector3(0, .5f, -(dimY / 2f));
            BoxShapeProperties tBoxShape4 = new BoxShapeProperties(10000000f, new Pose(), dimensions4);
            tBoxShape4.Material = new MaterialProperties("tbox", 0.4f, 0.4f, 0.6f);
            tBoxShape4.DiffuseColor = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
            SingleShapeEntity tBoxEntity4 = new SingleShapeEntity(new BoxShape(tBoxShape4), position4); ;
            tBoxEntity4.State.Assets.DefaultTexture = "env2.bmp";
            tBoxEntity4.State.Name = "Wall4";

            SimulationEngine.GlobalInstancePort.Insert(tBoxEntity);
            SimulationEngine.GlobalInstancePort.Insert(tBoxEntity2);
            SimulationEngine.GlobalInstancePort.Insert(tBoxEntity3);
            SimulationEngine.GlobalInstancePort.Insert(tBoxEntity4);

            this.BoundaryList.Add(tBoxEntity);
            this.BoundaryList.Add(tBoxEntity2);
            this.BoundaryList.Add(tBoxEntity3);
            this.BoundaryList.Add(tBoxEntity4);
        }
Exemple #5
0
        void AddDomino(Vector3 startPosition, int pieces)
        {
            Vector3 dim     = new Vector3(0.5f, 1.0f, 0.15f);
            float   spacing = 0.45f;

            for (int i = 0; i < pieces; i++)
            {
                Vector3 pos = new Vector3(0,
                                          0.02f, i * spacing) + startPosition;

                BoxShapeProperties shape = null;

                shape          = new BoxShapeProperties(10f, new Pose(), dim);
                shape.Material = new MaterialProperties("domino", 0.2f, 0.5f, 0.5f);

                SingleShapeEntity entity = new SingleShapeEntity(new BoxShape(shape), pos);
                entity.State.Name = "Domino Box:" + i.ToString();
                SimulationEngine.GlobalInstancePort.Insert(entity);
            }
        }
Exemple #6
0
        // TT -- Changed to add a height and color
//        void AddWall(int startRow, int startCol, int endRow, int endCol)
//        {
//            AddWall(startRow, startCol, endRow, endCol, DefaultHeight);
//        }

        // Adds a long wall in the maze grid
        // Useful for reducing number of elements in simulation for better performance
        // TT -- Note that the existing code used height to refer to the
        // depth of the wall. Therefore the real height is called boxSize.
        void AddWall(int startRow, int startCol, int endRow, int endCol, float boxSize, BasicColor color)
        {
            int width = Math.Abs(endCol - startCol) + 1;
            int height = Math.Abs(endRow - startRow) + 1;

            float realWidth = (width * _state.GridSpacing) - (_state.GridSpacing - _state.WallBoxSize*_state.GridSpacing);
            float realHeight = (height * _state.GridSpacing) - (_state.GridSpacing - _state.WallBoxSize*_state.GridSpacing);

            //because the box is placed relative to the center of mass
            float widthOffset = (Math.Abs(endCol - startCol) * _state.GridSpacing) / 2;
            float heightOffset = -(Math.Abs(endRow - startRow) * _state.GridSpacing) / 2;

            if (_UseSphere[(byte)color])
            {
                // This object is a Sphere
                SphereShapeProperties cSphereShape = null;
                SingleShapeEntity sphere = null;
                float radius;

                radius = (float)(_state.SphereScale * Math.Sqrt(realWidth * realWidth + realHeight * realHeight) / 2.0f);

                // create simple entity, with a single shape
                cSphereShape = new SphereShapeProperties(
                    // TT -- Change to infinite mass so that the walls
                    // do not "blow apart" if you bump them!
                    // TT Oct 2006 -- Allow user to specify this
                    _WallMasses[(byte)color], // mass in kilograms.
                    new Pose(),     // relative pose
                    radius);        // radius
                cSphereShape.Material = new MaterialProperties("gsphere", 0.9f, 0.05f, 0.1f);
                cSphereShape.Material.Advanced = new MaterialAdvancedProperties();
                cSphereShape.Material.Advanced.RestitutionCombineMode = CoefficientsCombineMode.Max;
                cSphereShape.Material.Advanced.FrictionCombineMode = CoefficientsCombineMode.Min;
                cSphereShape.Material.Advanced.Spring = new SpringProperties();
                cSphereShape.Material.Advanced.Spring.SpringCoefficient = 0.9f;
                cSphereShape.Material.Advanced.Spring.DamperCoefficient = 0.1f;
                cSphereShape.Advanced = new ShapeAdvancedProperties();
                cSphereShape.Advanced.PhysicsCalculationPasses = 20.0f;
                //cSphereShape.Advanced.MassSpaceIntertiaTensor = new Vector3(1.0f, 0.0f, 1.0f);
                // TT - These do not seem to have much effect
                //cSphereShape.MassDensity.AngularDamping = 0.0f;
                //cSphereShape.MassDensity.LinearDamping = 0.0f;
                //cSphereShape.MassDensity.Mass = _WallMasses[(byte)color];
                //cSphereShape.MassDensity.Density = 0.1f;

                // Set the color of the sphere according to the bitmap image
                // or the specified color if no bitmap
                if (_WallTextures[(byte)color] == "")
                {
                    // TT - Changed for October CTP because DiffuseColor
                    // is a Vector4, but my WallColors are Vector3
                    //cBoxShape.DiffuseColor = _WallColors[(byte)color];
                    cSphereShape.DiffuseColor.X = (float)(_WallColors[(byte)color].X / 255.0);
                    cSphereShape.DiffuseColor.Y = (float)(_WallColors[(byte)color].Y / 255.0);
                    cSphereShape.DiffuseColor.Z = (float)(_WallColors[(byte)color].Z / 255.0);
                    cSphereShape.DiffuseColor.W = 1.0f;
                }
                else
                    cSphereShape.TextureFileName = _WallTextures[(byte)color];

                sphere = new SingleShapeEntity(new SphereShape(cSphereShape),
                    new Vector3((startCol * -_state.GridSpacing) - widthOffset,
                                radius*2,
                                -(startRow * _state.GridSpacing) + heightOffset)
                    );

                // Name the entity. All entities must have unique names
                sphere.State.Name = "ball_" + startRow + "_" + startCol;

                // Insert entity in simulation.  
                _simEnginePort.Insert(sphere);

                /*
                SphereShapeProperties cSphereShape = null;
                SingleShapeEntity sphere = null;
                float radius;

                radius = (float)(_state.SphereScale * Math.Sqrt(realWidth * realWidth + realHeight * realHeight) / 2.0f);

                // create simple entity, with a single shape
                cSphereShape = new SphereShapeProperties(
                        1.0f,   // mass in kilograms.
                        new Pose(),     // relative pose
                        radius);    // radius
                cSphereShape.Material = new MaterialProperties("gsphere", 1.0f, 0.01f, 0.01f);
                sphere = new SingleShapeEntity(new SphereShape(cSphereShape),
                    new Vector3((startCol * -_state.GridSpacing) - widthOffset,
                                radius,
                                -(startRow * _state.GridSpacing) + heightOffset)
                    );

                // Name the entity. All entities must have unique names
                sphere.State.Name = "ball_" + startRow + "_" + startCol;

                // Insert entity in simulation.  
                _simEnginePort.Insert(sphere);
                 */
            }
            else
            {
                // This object is a wall (stretched cube)
                Vector3 dimensions =
                    new Vector3(realWidth, boxSize * _state.HeightScale, realHeight);
                        // Dimensions are in meters
                BoxShapeProperties cBoxShape = null;
                SingleShapeEntity box = null;

                cBoxShape = new BoxShapeProperties(
                    // TT -- Change to infinite mass so that the walls
                    // do not "blow apart" if you bump them!
                    // TT Oct 2006 -- Allow user to specify this
                        _WallMasses[(byte)color], // mass in kilograms.
                        new Pose(),     // relative pose
                        dimensions);    // dimensions
//                cBoxShape = new BoxShapeProperties(0, new Pose(), dimensions);
                // Walls have the same properties as the ground
                cBoxShape.Material = new MaterialProperties("gbox", 0.8f, 0.5f, 0.8f);
                // Set the color of the box according to the bitmap image
                // or the specified color if no bitmap
                if (_WallTextures[(byte)color] == "")
                {
                    // TT - Changed for October CTP because DiffuseColor
                    // is a Vector4, but my WallColors are Vector3
                    //cBoxShape.DiffuseColor = _WallColors[(byte)color];
                    cBoxShape.DiffuseColor.X = (float)(_WallColors[(byte)color].X / 255.0);
                    cBoxShape.DiffuseColor.Y = (float)(_WallColors[(byte)color].Y / 255.0);
                    cBoxShape.DiffuseColor.Z = (float)(_WallColors[(byte)color].Z / 255.0);
                    cBoxShape.DiffuseColor.W = 0.5f;
                }
                else
                    cBoxShape.TextureFileName = _WallTextures[(byte)color];
                    
                // Raul
                if (color == BasicColor.White)
                {
                    cBoxShape.TextureFileName = "bricks_4.jpg";
                }
                if (color == BasicColor.Red)
                {
                    cBoxShape.TextureFileName = "wood2.jpg";
                }

                box = new SingleShapeEntity(new BoxShape(cBoxShape),
                    new Vector3((startCol * -_state.GridSpacing) - widthOffset,
                                boxSize * _state.HeightScale / 2,
                                -(startRow * _state.GridSpacing) + heightOffset)
                    );
                // Name the entity. All entities must have unique names
                box.State.Name = "wall_" + startRow + "_" + startCol;
                _simEnginePort.Insert(box);
            }

            BlockCounter++;
        }
Exemple #7
0
        //TT -- Changed to include height and color
//        void AddWall(int row, int col)
//        {
//            AddWall(row, col, DefaultHeight, BasicColor.White);
//        }

        // Adds a simple cube at a specified location in the maze grid
        void AddWall(int row, int col, float height, BasicColor color)
        {

            // TT Oct-2006 - Add an option to use a sphere instead of a cube
            if (_UseSphere[(byte)color])
            {
                SphereShapeProperties cSphereShape = null;
                SingleShapeEntity sphere = null;
                float radius;

                radius = _state.SphereScale *  height / 2.0f;

                // create simple entity, with a single shape
                cSphereShape = new SphereShapeProperties(
                    // TT -- Change to infinite mass so that the walls
                    // do not "blow apart" if you bump them!
                    // TT Oct 2006 -- Allow user to specify this
                        _WallMasses[(byte)color], // mass in kilograms.
                        new Pose(),     // relative pose
                        radius);    // radius
                cSphereShape.Material = new MaterialProperties("gsphere", 1.0f, 0.01f, 0.01f);
                // Set the color of the sphere according to the bitmap image
                // or the specified color if no bitmap
                if (_WallTextures[(byte)color] == "")
                {
                    // TT - Changed for October CTP because DiffuseColor
                    // is a Vector4, but my WallColors are Vector3
                    //cBoxShape.DiffuseColor = _WallColors[(byte)color];
                    cSphereShape.DiffuseColor.X = (float)(_WallColors[(byte)color].X / 255.0);
                    cSphereShape.DiffuseColor.Y = (float)(_WallColors[(byte)color].Y / 255.0);
                    cSphereShape.DiffuseColor.Z = (float)(_WallColors[(byte)color].Z / 255.0);
                    cSphereShape.DiffuseColor.W = 1.0f;
                }
                else
                    cSphereShape.TextureFileName = _WallTextures[(byte)color];

                sphere = new SingleShapeEntity(new SphereShape(cSphereShape),
                    new Vector3((col * -_state.GridSpacing),
                            radius,
                            -(row * _state.GridSpacing)));

                // Name the entity. All entities must have unique names
                sphere.State.Name = "ball_" + row + "_" + col;

                // Insert entity in simulation.  
                _simEnginePort.Insert(sphere);
            }
            else
            {
                // Dimensions are in meters
                Vector3 dimensions =
                    new Vector3(_state.WallBoxSize * _state.GridSpacing,
                            height * _state.HeightScale,
                            _state.WallBoxSize * _state.GridSpacing);
                BoxShapeProperties cBoxShape = null;
                SingleShapeEntity box = null;

                // create simple immovable entity, with a single shape
                cBoxShape = new BoxShapeProperties(
                    // TT -- Change to infinite mass so that the walls
                    // do not "blow apart" if you bump them!
                    // TT Oct 2006 -- Allow user to specify this
                        _WallMasses[(byte)color], // mass in kilograms.
                        new Pose(),     // relative pose
                        dimensions);    // dimensions
                cBoxShape.Material = new MaterialProperties("gbox", 1.0f, 0.4f, 0.5f);
                // Set the color of the box according to the bitmap image
                // or the specified color if no bitmap
                if (_WallTextures[(byte)color] == "")
                {
                    // TT - Changed for October CTP because DiffuseColor
                    // is a Vector4, but my WallColors are Vector3
                    //cBoxShape.DiffuseColor = _WallColors[(byte)color];
                    cBoxShape.DiffuseColor.X = (float)(_WallColors[(byte)color].X / 255.0);
                    cBoxShape.DiffuseColor.Y = (float)(_WallColors[(byte)color].Y / 255.0);
                    cBoxShape.DiffuseColor.Z = (float)(_WallColors[(byte)color].Z / 255.0);
                    cBoxShape.DiffuseColor.W = 0.5f;
                }
                else
                    cBoxShape.TextureFileName = _WallTextures[(byte)color];

                box = new SingleShapeEntity(new BoxShape(cBoxShape),
                    new Vector3(col * -_state.GridSpacing,
                            height * _state.HeightScale / 2,
                            -(row * _state.GridSpacing)));

                // Name the entity. All entities must have unique names
                box.State.Name = "wall_" + row + "_" + col;

                // Insert entity in simulation.  
                _simEnginePort.Insert(box);
            }

            BlockCounter++;
        }
Exemple #8
0
        private void AddArena()
        {
            BoxShapeProperties tBoxShape = null;
            SingleShapeEntity tBoxEntity = null;
            tBoxShape = new BoxShapeProperties(500f, new Pose(), new Vector3(5f, 0.25f, 0.25f));
            tBoxEntity = new SingleShapeEntity(new BoxShape(tBoxShape), new Vector3(0f, 0.5f, 2.63f));
            tBoxEntity.State.Name = "arena top";
            SimulationEngine.GlobalInstancePort.Insert(tBoxEntity);

            BoxShapeProperties lBoxShape = null;
            SingleShapeEntity lBoxEntity = null;
            lBoxShape = new BoxShapeProperties(500f, new Pose(), new Vector3(0.25f, 0.25f, 5f));
            lBoxEntity = new SingleShapeEntity(new BoxShape(lBoxShape), new Vector3(-2.63f, 0.5f, 0f));
            lBoxEntity.State.Name = "arena left";
            SimulationEngine.GlobalInstancePort.Insert(lBoxEntity);

            BoxShapeProperties rBoxShape = null;
            SingleShapeEntity rBoxEntity = null;
            rBoxShape = new BoxShapeProperties(500f, new Pose(), new Vector3(0.25f, 0.25f, 5f));
            rBoxEntity = new SingleShapeEntity(new BoxShape(rBoxShape), new Vector3(2.63f, 0.5f, 0f));
            rBoxEntity.State.Name = "arena right";
            SimulationEngine.GlobalInstancePort.Insert(rBoxEntity);

            BoxShapeProperties bBoxShape = null;
            SingleShapeEntity bBoxEntity = null;
            bBoxShape = new BoxShapeProperties(500f, new Pose(), new Vector3(5f, 0.25f, 0.25f));
            bBoxEntity = new SingleShapeEntity(new BoxShape(bBoxShape), new Vector3(0f, 0.5f, -2.63f));
            bBoxEntity.State.Name = "arena bottom";
            SimulationEngine.GlobalInstancePort.Insert(bBoxEntity);
        }
Exemple #9
0
 private void AddCube(Vector3 position)
 {
     BoxShapeProperties cBoxShape = null;
     SingleShapeEntity cBoxEntity = null;
     cBoxShape = new BoxShapeProperties(2.0f, new Pose(), new Vector3(0.5f, 0.5f, 0.5f));
     cBoxEntity = new SingleShapeEntity(new BoxShape(cBoxShape), position);
     cBoxEntity.State.Name = "cube:" + Guid.NewGuid().ToString();
     SimulationEngine.GlobalInstancePort.Insert(cBoxEntity);
 }
        HumanoidEntity CreateHumanoid(string name, Vector3 initialPosition)
        {
            Dictionary <string, VisualEntity> humanoidShapes = new Dictionary <string, VisualEntity>();
            string prefix = name + "_";

            foreach (HumanoidShapeDescriptor desc in ShapeDescriptors)
            {
                Shape newShape = null;


                newShape = new BoxShape(new BoxShapeProperties(
                                            desc.Name + " Shape", (float)desc.mass, new Pose(), new Vector3((float)desc.xSize, (float)desc.ySize, (float)desc.zSize)));

                // newShape = new ConvexMeshShape(new ConvexMeshShapeProperties(desc.Name + "Shape", desc.mesh));


                SingleShapeEntity shapeEntity = null;

                /*
                 * SimplifiedConvexMeshEnvironmentEntity shapeEntity = null;
                 * if (desc.Name == _parentName)
                 * {
                 *   shapeEntity = new HumanoidEntity(newShape, new Vector3(
                 *       (float)desc.xPosition + initialPosition.X,
                 *       (float)desc.yPosition + initialPosition.Y,
                 *       (float)desc.zPosition + initialPosition.Z),desc.mesh);
                 * }
                 * else
                 * {
                 *   shapeEntity = new SegmentEntity(newShape, new Vector3(
                 *       (float)desc.xPosition + initialPosition.X,
                 *       (float)desc.yPosition + initialPosition.Y,
                 *       (float)desc.zPosition + initialPosition.Z),desc.mesh);
                 * }
                 */

                if (desc.Name == _parentName)
                {
                    shapeEntity = new HumanoidEntity(newShape, new Vector3(
                                                         (float)desc.xPosition + initialPosition.X,
                                                         (float)desc.yPosition + initialPosition.Y,
                                                         (float)desc.zPosition + initialPosition.Z));
                }
                else
                {
                    shapeEntity = new SegmentEntity(newShape, new Vector3(
                                                        (float)desc.xPosition + initialPosition.X,
                                                        (float)desc.yPosition + initialPosition.Y,
                                                        (float)desc.zPosition + initialPosition.Z));
                }

                shapeEntity.State.Name             = prefix + desc.Name;
                shapeEntity.State.Pose.Orientation = UIMath.EulerToQuaternion(new xna.Vector3((float)desc.xRotation, (float)desc.yRotation, (float)desc.zRotation));
                if (!string.IsNullOrEmpty(desc.mesh))
                {
                    shapeEntity.State.Assets.Mesh = desc.mesh;
                }
                shapeEntity.MeshScale    = new Vector3(.001f, .001f, .001f);
                shapeEntity.MeshRotation = new Vector3(desc.xRotation, desc.yRotation, desc.zRotation);
                shapeEntity.Flags        = VisualEntityProperties.DoCompletePhysicsShapeUpdate;

                //  shapeEntity.State.Flags |= EntitySimulationModifiers.Kinematic;
                humanoidShapes.Add(shapeEntity.State.Name, shapeEntity);
            }

            // now set up the Parent/Child relationships
            foreach (ParentChild rel in Relationships)
            {
                string Dof = rel.Dof;
                JointAngularProperties angular = new JointAngularProperties();

                if (Dof == "Twist")
                {
                    angular.TwistMode  = JointDOFMode.Free;
                    angular.TwistDrive = new JointDriveProperties(JointDriveMode.Position, new SpringProperties(500000, 1000, 0), 1000000);
                    // angular.TwistDrive.Mode = JointDriveMode.Velocity;
                }

                if (Dof == "Swing1")
                {
                    angular.Swing1Mode = JointDOFMode.Free;
                    angular.SwingDrive = new JointDriveProperties(JointDriveMode.Position, new SpringProperties(500000, 1000, 0), 1000000);
                    //angular.SwingDrive.Mode = JointDriveMode.Velocity;
                }

                if (Dof == "Swing2")
                {
                    angular.Swing2Mode = JointDOFMode.Free;
                    angular.SwingDrive = new JointDriveProperties(JointDriveMode.Position, new SpringProperties(500000, 1000, 0), 1000000);
                    // angular.SwingDrive.Mode = JointDriveMode.Velocity;
                }

                EntityJointConnector[] connectors = new EntityJointConnector[]
                {
                    new EntityJointConnector(humanoidShapes[prefix + rel.Child], rel.ChildNormal, rel.ChildAxis, rel.ChildConnect),
                    new EntityJointConnector(humanoidShapes[prefix + rel.Parent], rel.ParentNormal, rel.ParentAxis, rel.ParentConnect)
                };

                SegmentEntity child = (SegmentEntity)humanoidShapes[prefix + rel.Child];
                child.CustomJoint            = new Joint();
                child.CustomJoint.State      = new JointProperties(angular, connectors);
                child.CustomJoint.State.Name = rel.JointName;
                child.Flags = VisualEntityProperties.DoCompletePhysicsShapeUpdate;



                humanoidShapes[prefix + rel.Parent].InsertEntityGlobal(humanoidShapes[prefix + rel.Child]);
            }


            HumanoidEntity retValue = (HumanoidEntity)humanoidShapes[prefix + _parentName];



            // retValue.State.MassDensity.CenterOfMass = new Pose(new Vector3(0.05f,1.05f,0), new Quaternion(0,0,0,1));
            retValue.State.Flags = EntitySimulationModifiers.Kinematic;
            retValue.State.Name  = name;

            return(retValue);
        }
        private void AddBase(ref Vector3 position)
        {
            var baseShape = new BoxShape(new BoxShapeProperties(
                                             "base", // name
                                             150, // mass kg
                                             new Pose(new Vector3(0, BaseHeight/2, 0), new Quaternion(0, 0, 0, 1)),
                                             new Vector3(BaseRadius*2, BaseHeight, BaseRadius*2)
                                             ));

            _baseEntity = new SingleShapeEntity(baseShape, position);
            _baseEntity.State.Name = State.Name + " Base";
            _baseEntity.State.Flags |= EntitySimulationModifiers.Kinematic; // make the base immobile
            _baseEntity.State.Assets.Mesh = @"RobotArm_Base.obj";
            _baseEntity.Parent = this;
            _baseEntity.MeshTranslation = new Vector3(0, 0.004f, 0); // move above ground
            InsertEntity(_baseEntity);
        }
Exemple #12
0
	    private void PopulateWorld()
        {
            AddSky();
            AddGround();
     //       AddBlocks();

            // Add an overhead camera
       //     AddCamera();

            // Create and place the dominos
         //   SpawnIterator(CreateDominos);

            // Create a LynxL6Arm Entity positioned at the origin
            var robotArm = new SimulatedRobotArmEntity(RobotArmEntityName, new Vector3(0, 0, 0));
            SimulationEngine.GlobalInstancePort.Insert(robotArm);

	        var targetProps = new SphereShapeProperties(0, new Pose(), 0.0025f);
	        var shape = new SphereShape(targetProps);
	        shape.State.DiffuseColor = new Vector4(0.1f, 0f, 1f, 1f);
            _moveTargetEntity = new SingleShapeEntity(shape, new Vector3(0f, 0.2f, 0.1f));
	        _moveTargetEntity.State.Name = "Move To Target";
	        SimulationEngine.GlobalInstancePort.Insert(_moveTargetEntity);
        }
        public void AddFood(Vector3 position_passed, string name)
        {
            Vector3 position = new Vector3(position_passed.X, position_passed.Z, -(position_passed.Y));
            SingleShapeEntity food = new SingleShapeEntity(
               new SphereShape(
                  new SphereShapeProperties(5, // mass in kg
                  new Pose(), // pose of shape within entity
                  .1f)), //default radius
               position);

            food.SphereShape.SphereState.Material =
               new MaterialProperties("sphereMaterial", 0.5f, 0.4f, 0.5f);

            // Name the entity
            food.State.Name = name;

            // Insert entity in simulation.
            SimulationEngine.GlobalInstancePort.Insert(food);
            this.FoodList.Add(food);
        }
        public void AddObstacle(Vector3 dimension_passed, Vector3 position_passed, string name)
        {
            Vector3 position = new Vector3(position_passed.X, position_passed.Z, -(position_passed.Y));
            Vector3 dimension = new Vector3(dimension_passed.X, dimension_passed.Z, -(dimension_passed.Y));
            BoxShapeProperties tBoxShape = new BoxShapeProperties(10000f, new Pose(), dimension);
            tBoxShape.Material = new MaterialProperties("tbox", 0.4f, 0.4f, 0.6f);
            tBoxShape.DiffuseColor = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
            SingleShapeEntity Obstacle = new SingleShapeEntity(new BoxShape(tBoxShape), position); ;
            Obstacle.State.Assets.DefaultTexture = "env2.bmp";
            Obstacle.State.Name = name;

            SimulationEngine.GlobalInstancePort.Insert(Obstacle);
            this.BoundaryList.Add(Obstacle);
        }
Exemple #15
0
        void AddBox(Vector3 position, string name)
        {
            Vector3 dimensions =
                new Vector3(3.0f, 0.3f, 0.3f); // meters

            // create simple movable entity, with a single shape
            /*SingleShapeEntity box = new SingleShapeEntity(
                new BoxShape(
                    new BoxShapeProperties(
                    10000000000, // mass in kilograms.
                    new Pose(), // relative pose
                    dimensions)), // dimensions
                position);

            box.State.MassDensity.Mass = 0;
            box.State.MassDensity.Density = 0;

            // Name the entity. All entities must have unique names
            box.State.Name = name;

            // Insert entity in simulation.  
            //SimulationEngine.GlobalInstancePort.Insert(box);
            _simEnginePort.Insert(box); */

            SingleShapeEntity box = new SingleShapeEntity(new BoxShape(
                    new BoxShapeProperties(
                    10000000000, // mass in kilograms.
                    new Pose(), // relative pose
                    dimensions)),
                   position);

            // Name the entity. All entities must have unique names
            box.State.Name = name;

            // Insert entity in simulation.  
            _simEnginePort.Insert(box);

        }