/// <summary>
        /// 加上天空 , 太阳
        /// </summary>
        void AddSky()
        {
            //加上天空
            SkyDomeEntity sky = new SkyDomeEntity("skydome.dds", "sky_diff.dds");

            SimulationEngine.GlobalInstancePort.Insert(sky);

            //用平行光源模拟太阳
            LightSourceEntity sun = new LightSourceEntity();

            sun.State.Name = "Sun";
            sun.Type       = LightSourceEntityType.Directional;
            sun.Color      = new Vector4(0.8f, 0.8f, 0.8f, 1);
            sun.Direction  = new Vector3(0.5f, -.75f, 0.5f);
            SimulationEngine.GlobalInstancePort.Insert(sun);
        }
Esempio n. 2
0
        void AddSky()
        {
            // Add a sky using a static texture. We will use the sky texture
            // to do per pixel lighting on each simulation visual entity
            SkyDomeEntity sky = new SkyDomeEntity("skydome.dds", "sky_diff.dds");

            SimulationEngine.GlobalInstancePort.Insert(sky);

            // Add a directional light to simulate the sun.
            LightSourceEntity sun = new LightSourceEntity();

            sun.State.Name = "Sun";
            sun.Type       = LightSourceEntityType.Directional;
            sun.Color      = new Vector4(0.8f, 0.8f, 0.8f, 1);
            sun.Direction  = new Vector3(0.5f, -.75f, 0.5f);
            SimulationEngine.GlobalInstancePort.Insert(sun);
        }
Esempio n. 3
0
        private VisualEntity CreateEntity(Vector3 entityPosition, VisualEntity entityParent, Entities entityType)
        {
            VisualEntity e = null;

            #region Create Entity
            switch (entityType)
            {
            case Entities.HeightFieldEntity:
            {
                e = new HeightFieldEntity("ground", "03RamieSc.dds", new
                                          MaterialProperties("ground", 0.8f, 0.5f, 0.8f));
            } break;

            case Entities.SkyDomeEntity:
            {
                e = new SkyDomeEntity("skydome.dds", "sky_diff.dds");
                SimulationEngine.GlobalInstancePort.Insert(e);
            } break;

            case Entities.LightSourceEntity:
            {
                var lightEntity = new LightSourceEntity();
                e = lightEntity;
                lightEntity.State.Name          = "LightSourceEntity";
                lightEntity.Type                = LightSourceEntityType.Directional;
                lightEntity.Color               = new Vector4(.8f, .8f, .8f, 1);
                lightEntity.State.Pose.Position = new Vector3(0, 1, 0);
                lightEntity.Direction           = new Vector3(0, -1, 0);
                e.Flags = e.Flags | VisualEntityProperties.DisableRendering;
            } break;

            case Entities.MotorBaseWithDrive:
            {
                e            = new MotorBaseWithDrive(entityPosition);
                e.State.Name = "MotorBaseWithDrive";
                MakeNameUnique(e);
            } break;

            case Entities.SimulatedBrightnessSensorEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }
                else
                {
                    e            = new SimulatedBrightnessSensorEntity(32, 32, 2.0f * (float)Math.PI / 180.0f);
                    e.State.Name = "SimulatedBrightnessSensorEntity";
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedColorSensorEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }
                else
                {
                    e            = new SimulatedColorSensorEntity(32, 32, 2.0f * (float)Math.PI / 180.0f);
                    e.State.Name = "SimulatedColorSensorEntity";
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedCompassEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }

                else
                {
                    e            = new SimulatedCompassEntity();
                    e.State.Name = "SimulatedCompassEntity";
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedGPSEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }

                else
                {
                    e            = new SimulatedGPSEntity();
                    e.State.Name = "SimulatedGPSEntity";
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedIREntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }

                else
                {
                    e              = new SimulatedIREntity(new Pose(entityPosition));
                    e.State.Name   = "SimulatedIREntity";
                    e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedLRFEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }
                else
                {
                    e              = new SimulatedLRFEntity(new Pose(entityPosition));
                    e.State.Name   = "SimulatedLRFEntity";
                    e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedSonarEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }
                else
                {
                    e              = new SimulatedSonarEntity(new Pose(entityPosition));
                    e.State.Name   = "SimulatedSonarEntity";
                    e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedWebcamEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }
                else
                {
                    e = new SimulatedWebcamEntity(entityPosition,
                                                  320, 240, 45.0f * (float)Math.PI / 180.0f);
                    e.State.Name = "SimulatedWebcamEntity";
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;
            }
            #endregion

            return(e);
        }
Esempio n. 4
0
        public VisualEntity CreateEntity(Vector3 entityPosition, VisualEntity entityParent, Entities entityType)
        {
            VisualEntity e = null;

            #region Create Entity
            switch (entityType)
            {
                case Entities.HeightFieldEntity:
                    {
                        e = new HeightFieldEntity("ground", "03RamieSc.dds", new
                            MaterialProperties("ground", 0.8f, 0.5f, 0.8f));

                    } break;
                case Entities.SkyDomeEntity:
                    {
                        e = new SkyDomeEntity("skydome.dds", "sky_diff.dds");
                        SimulationEngine.GlobalInstancePort.Insert(e);
                    } break;
                case Entities.LightSourceEntity:
                    {
                        var lightEntity = new LightSourceEntity();
                        e = lightEntity;
                        lightEntity.State.Name = "LightSourceEntity";
                        lightEntity.Type = LightSourceEntityType.Directional;
                        lightEntity.Color = new Vector4(.8f, .8f, .8f, 1);
                        lightEntity.State.Pose.Position = new Vector3(0, 1, 0);
                        lightEntity.Direction = new Vector3(0, -1, 0);
                        e.Flags = e.Flags | VisualEntityProperties.DisableRendering;

                    } break;
                case Entities.MotorBaseWithDrive:
                    {
                        e = new MotorBaseWithDrive(entityPosition);
                        e.State.Name = "MotorBaseWithDrive";
                        MakeNameUnique(e);

                        //Inserting Actual Rover instead of Simple Simulatd Robot.
                        //Needs to be tested

                        /*ColladaToMSRS e = new ColladaToMSRS(@"C:\.....\collada\rover.dae");
                        foreach (VisualEntity entity in e.Entities)
                        {
                            SimulationEngine.GlobalInstancePort.Insert(entity);
                        }*/

                    } break;
                case Entities.SimulatedBrightnessSensorEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }
                        else
                        {
                            e = new SimulatedBrightnessSensorEntity(32, 32, 2.0f * (float)Math.PI / 180.0f);
                            e.State.Name = "SimulatedBrightnessSensorEntity";
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;
                case Entities.SimulatedColorSensorEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }
                        else
                        {
                            e = new SimulatedColorSensorEntity(32, 32, 2.0f * (float)Math.PI / 180.0f);
                            e.State.Name = "SimulatedColorSensorEntity";
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;
                case Entities.SimulatedCompassEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }

                        else
                        {
                            e = new SimulatedCompassEntity();
                            e.State.Name = "SimulatedCompassEntity";
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;

                case Entities.SimulatedGPSEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }

                        else
                        {
                            e = new SimulatedGPSEntity();
                            e.State.Name = "SimulatedGPSEntity";
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;

                case Entities.SimulatedIREntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }

                        else
                        {
                            e = new SimulatedIREntity(new Pose(entityPosition));
                            e.State.Name = "SimulatedIREntity";
                            e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;
                case Entities.SimulatedLRFEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }
                        else
                        {
                            e = new SimulatedLRFEntity(new Pose(entityPosition));
                            e.State.Name = "SimulatedLRFEntity";
                            e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                            MakeNameUnique(e);
                            //EntityUIService newservice = new EntityUIService();
                            //newservice.AddBoeBot(new Vector3(1,0,1));
                            //CreateService(laserrangefinder.Contract.Identifier,
                                //Microsoft.Robotics.Simulation.Partners.CreateEntityPartner("http://localhost/" + e.State.Name));
                            entityParent.InsertEntity(e);

                        }

                    } break;
                case Entities.SimulatedSonarEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }
                        else
                        {
                            e = new SimulatedSonarEntity(new Pose(entityPosition));
                            e.State.Name = "SimulatedSonarEntity";
                            e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;
                case Entities.SimulatedWebcamEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }
                        else
                        {
                            e = new SimulatedWebcamEntity(entityPosition,
                                320, 240, 45.0f * (float)Math.PI / 180.0f);
                            e.State.Name = "SimulatedWebcamEntity";
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);

                        }

                    } break;
            }
            #endregion

            return e;
        }
Esempio n. 5
0
     void AddSun()
     {
         // Add a directional light to simulate the sun.
         LightSourceEntity sun = new LightSourceEntity();
         sun.State.Name = "Sun";
         sun.Type = LightSourceEntityType.Directional;
         sun.Color = new Vector4(1.0f, 1.0f, 1.0f, 1);
         sun.Direction = new Vector3(-1.0f, -1.0f, 0.5f);
         SimulationEngine.GlobalInstancePort.Insert(sun);
 
     }
Esempio n. 6
0
        void AddSky()
        {
            // Add a sky using a static texture. We will use the sky texture
            // to do per pixel lighting on each simulation visual entity
            SkyDomeEntity sky = new SkyDomeEntity("skydome.dds", "sky_diff.dds");
            SimulationEngine.GlobalInstancePort.Insert(sky);

            // Add a directional light to simulate the sun.
            LightSourceEntity sun = new LightSourceEntity();
            sun.State.Name = "Sun";
            sun.Type = LightSourceEntityType.Directional;
            sun.Color = new Vector4(0.7f, 0.7f, 0.7f, 1);
            sun.Direction = new Vector3(0.5f, -.75f, 0.5f);
            SimulationEngine.GlobalInstancePort.Insert(sun);
        }