コード例 #1
0
 public void Execute()
 {
     if (!cancelled)
     {
         float scale = app.Config.MarkerPointScale;
         Vector3 scaleVec = new Vector3(scale, scale, scale);
         Vector3 rotVec = new Vector3(0, rotation, 0);
         if (placing)
         {
             // we need to place the object (which is handled asynchronously) before we can create it
             dragObject = new DisplayObject(name, app,"Drag", app.Scene, meshName, location, scaleVec, rotVec, null);
             dragObject.MaterialName = "directional_marker.orange";
             dragObject.ScaleWithCameraDistance = true;
             // set up mouse capture and callbacks for placing the object
             new DragHelper(app, new DragComplete(DragCallback), dragObject);
         }
         else
         {
             if (waypoint == null)
             {
                 // object has already been placed, so create it now
                 waypoint = new Waypoint(name, parent, app, location, rotVec);
             }
             parent.Add(waypoint);
             for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
             {
                 app.SelectedObject[i].Node.UnSelect();
             }
             if (waypoint.Node != null)
             {
                 waypoint.Node.Select();
             }
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// This overload is used when adding points to an existing Collection.
 /// </summary>
 /// <param name="worldEditor"></param>
 /// <param name="displayObject"></param>
 /// <param name="validate"></param>
 /// <param name="Complete"></param>
 /// <param name="points"></param>
 public MultiPointInsertHelper(WorldEditor worldEditor, DisplayObject displayObject, MultiPointInsertValidate validate, MultiPointInsertComplete complete, List<Vector3> points, int index)
 {
     app = worldEditor;
     dragObject = displayObject;
     completeCallback = complete;
     validateCallback = validate;
     this.points = points;
     this.index = index;
     dragHelper = new DragHelper(app, dragObject, new DragComplete(DragCallback));
 }
コード例 #3
0
        /// <summary>
        /// Use this constructor when dragging an existing object, or one that needs rotation or scaling.
        /// </summary>
        /// <param name="worldEditor"></param>
        /// <param name="displayObject"></param>
        /// <param name="callback"></param>
        public DragHelper(WorldEditor worldEditor, DisplayObject displayObject, DragComplete callback)
        {
            app = worldEditor;
            dragObject = displayObject;
            dragCallback = callback;
            disposeDragObject = false;
            but = app.MouseSelectButton;

            // set up mouse capture and callbacks for placing the object
            app.InterceptMouse(new MouseMoveIntercepter(DragMove), new MouseButtonIntercepter(DragButtonDown), new MouseButtonIntercepter(DragButtonUp), new MouseCaptureLost(DragCaptureLost), true);
        }
コード例 #4
0
        /// <summary>
        /// Use this overload for placing points for roads and boundaries 
        /// </summary>
        /// <param name="worldEditor"></param>
        /// <param name="displayObject"></param>
        /// <param name="validate"></param>
        /// <param name="complete"></param>
        public MultiPointPlacementHelper(WorldEditor worldEditor, DisplayObject displayObject, MultiPointValidate validate, MultiPointComplete complete)
        {
            app = worldEditor;
            dragObject = displayObject;
            completeCallback = complete;
            validateCallback = validate;

            points = new List<Vector3>();

            dragHelper = new DragHelper(app, dragObject, new DragComplete(DragCallback));
        }
コード例 #5
0
        public void Execute()
        {
            if (placing)
            {
                switch (((IObjectInsert)(parent.Parent)).ObjectType)
                {
                    case "Road":
                        dragObject = new DisplayObject("RoadDrag", app, "Dragging", app.Scene, app.Config.RoadPointMeshName, Vector3.Zero, Vector3.UnitScale, Vector3.Zero, null);
                        dragObject.MaterialName = app.Config.RoadPointMaterial;
                        break;
                    case "Region":
                        dragObject = new DisplayObject("RegionDrag", app, "Dragging", app.Scene, app.Config.RegionPointMeshName, Vector3.Zero, Vector3.UnitScale, Vector3.Zero, null);
                        dragObject.MaterialName = app.Config.RegionPointMaterial;
                        break;
                }
                new MultiPointInsertHelper(app, dragObject, new MultiPointInsertValidate(PointValidate), new MultiPointInsertComplete(PointPlacementComplete), parent.VectorList, index);

                placing = false;
            }
        }
コード例 #6
0
 public void Dispose()
 {
     if (displayObject != null)
     {
         displayObject.Dispose();
         displayObject = null;
     }
 }
コード例 #7
0
        public void RemoveFromScene()
        {
            if (inScene)
            {
                inScene = false;
                foreach (IWorldObject child in children)
                {
                    child.RemoveFromScene();
                }

                displayObject.Dispose();
                displayObject = null;
            }
        }
コード例 #8
0
        public StaticObject(String objectName, IWorldContainer parentContainer, WorldEditor worldEditor, string meshName, Vector3 position, Vector3 scale, Vector3 rotation)
        {
            name = objectName;
            parent = parentContainer;
            app = worldEditor;

            children = new List<IWorldObject>();
            this.SetDirection(rotation.y, 90f);
            this.scale = scale;
            this.location = position;
            this.meshName = meshName;
            this.nameValuePairs = new NameValueObject();
            this.terrainOffset = 0f;

            displayObject = null;

            subMeshes = new SubMeshCollection(meshName);
        }
コード例 #9
0
        public void AddToScene()
        {
            if (!inScene)
            {
                if (!offsetFound)
                {
                    terrainOffset = location.y - app.GetTerrainHeight(location.x, location.z);
                    offsetFound = true;
                }
                inScene = true;
                displayObject = new DisplayObject(this, name, app, "StaticObject", app.Scene, meshName, location, scale, orientation, subMeshes);
                displayObject.TerrainOffset = this.terrainOffset;
                displayObject.Highlight = highlight;
                displayObject.CastShadows = castShadows;

                // Create the list of triangles used to query mouse hits
                if (displayObject.Entity.Mesh.TriangleIntersector == null)
                    displayObject.Entity.Mesh.CreateTriangleIntersector();
            }
            foreach (IWorldObject child in children)
            {
                child.AddToScene();
                if (child is ParticleEffect)
                {
                    (child as ParticleEffect).Orientation = orientation;
                }
            }
        }
コード例 #10
0
        public void RemoveFromScene()
        {
            app.GlobalDirectionalLight = null;
            if (displayObject != null)
            {
                displayObject.Dispose();
            }
            displayObject = null;

            inScene = false;
        }
コード例 #11
0
 public void Dispose()
 {
     if (disp != null)
     {
         disp.Dispose();
         disp = null;
     }
 }
コード例 #12
0
        private void UpdateShowCircles()
        {
            if (app.DisplayPointLightCircles)
            {
                if (HalfAttenuationRadius < AttenuationRange)
                {
                    if (halfCircleObject == null)
                    {
                        halfCircleObject = new DisplayObject(String.Format("{0}-halfAttenuationCircle", this.Name), app, "PointLightCircle", scene, app.Assets.assetFromName(app.Config.PointLightCircleMeshName).AssetName, this.Position, Vector3.UnitScale, Vector3.Zero, null);
                        halfCircleObject.MaterialName = "world_editor_light_ring.lightRing.green";
                    }
                }
                else
                {
                    if (halfCircleObject != null)
                    {
                        halfCircleObject.Dispose();
                        halfCircleObject = null;
                    }
                }
                if (QuarterAttenuationRadius < AttenuationRange)
                {
                    if (quarterCircleObject == null)
                    {
                        quarterCircleObject = new DisplayObject(String.Format("{0}-quarterAttenutationCircle", this.Name), app, "PointLightCircle", scene, app.Assets.assetFromName(app.Config.PointLightCircleMeshName).AssetName, this.Position, Vector3.UnitScale, Vector3.Zero, null);
                        quarterCircleObject.MaterialName = "world_editor_light_ring.lightRing.yellow";
                    }
                }
                else
                {
                    if (quarterCircleObject != null)
                    {
                        quarterCircleObject.Dispose();
                        quarterCircleObject = null;
                    }
                }

                if (maxCircleObject == null)
                {
                    maxCircleObject = new DisplayObject(String.Format("{0}-maxAttenuationCircle", this.Name), app, "PointLightCircle", scene, app.Assets.assetFromName(app.Config.PointLightCircleMeshName).AssetName, this.Position, Vector3.UnitScale, Vector3.Zero, null);
                    maxCircleObject.MaterialName = "world_editor_light_ring.lightRing.red";
                }
                if (halfCircleObject != null)
                {
                    halfCircleObject.Scale = new Vector3(HalfAttenuationRadius, HalfAttenuationRadius, HalfAttenuationRadius);
                }
                if (quarterCircleObject != null)
                {
                    quarterCircleObject.Scale = new Vector3(QuarterAttenuationRadius, QuarterAttenuationRadius, QuarterAttenuationRadius);
                }
                maxCircleObject.Scale = new Vector3(attenuationRange, attenuationRange, attenuationRange);
            }
            else
            {
                showCircles = false;
                if (halfCircleObject != null)
                {
                    halfCircleObject.Dispose();
                    halfCircleObject = null;
                }
                if (quarterCircleObject != null)
                {
                    quarterCircleObject.Dispose();
                    quarterCircleObject = null;
                }
                if (maxCircleObject != null)
                {
                    maxCircleObject.Dispose();
                    maxCircleObject = null;
                }
            }
        }
コード例 #13
0
        private void UpdateShowCircles()
        {
            if (app.DisplayPointLightCircles)
            {

                if (HalfAttenuationRadius < AttenuationRange)
                {
                    if (halfCircleObject == null)
                    {
                        halfCircleObject = new DisplayObject(String.Format("{0}-halfAttenuationCircle", this.Name), app, "PointLightCircle", scene, app.Assets.assetFromName(app.Config.PointLightCircleMeshName).AssetName, this.Position, Vector3.UnitScale, Vector3.Zero, null);
                        halfCircleObject.MaterialName = "world_editor_light_ring.lightRing.green";
                    }
                }
                else
                {
                    if (halfCircleObject != null)
                    {
                        halfCircleObject.Dispose();
                        halfCircleObject = null;
                    }
                }
                if (QuarterAttenuationRadius < AttenuationRange)
                {
                    if (quarterCircleObject == null)
                    {
                        quarterCircleObject = new DisplayObject(String.Format("{0}-quarterAttenutationCircle", this.Name), app, "PointLightCircle", scene, app.Assets.assetFromName(app.Config.PointLightCircleMeshName).AssetName, this.Position, Vector3.UnitScale, Vector3.Zero, null);
                        quarterCircleObject.MaterialName = "world_editor_light_ring.lightRing.yellow";
                    }
                }
                else
                {
                    if (quarterCircleObject != null)
                    {
                        quarterCircleObject.Dispose();
                        quarterCircleObject = null;
                    }
                }

                if (maxCircleObject == null)
                {
                    maxCircleObject = new DisplayObject(String.Format("{0}-maxAttenuationCircle", this.Name), app, "PointLightCircle", scene, app.Assets.assetFromName(app.Config.PointLightCircleMeshName).AssetName, this.Position, Vector3.UnitScale, Vector3.Zero, null);
                    maxCircleObject.MaterialName = "world_editor_light_ring.lightRing.red";

                }
                if (halfCircleObject != null)
                {
                    halfCircleObject.Scale = new Vector3(HalfAttenuationRadius, HalfAttenuationRadius, HalfAttenuationRadius);
                }
                if (quarterCircleObject != null)
                {
                    quarterCircleObject.Scale = new Vector3(QuarterAttenuationRadius, QuarterAttenuationRadius, QuarterAttenuationRadius);
                }
                maxCircleObject.Scale = new Vector3(attenuationRange, attenuationRange, attenuationRange);

            }
            else
            {
                showCircles = false;
                if (halfCircleObject != null)
                {
                    halfCircleObject.Dispose();
                    halfCircleObject = null;
                }
                if (quarterCircleObject != null)
                {
                    quarterCircleObject.Dispose();
                    quarterCircleObject = null;
                }
                if (maxCircleObject != null)
                {
                    maxCircleObject.Dispose();
                    maxCircleObject = null;
                }

            }
        }
コード例 #14
0
        public void AddToScene()
        {
            if (app.DisplayMarkerPoints)
            {
                if (!offsetFound)
                {
                    float terrainHeight = app.GetTerrainHeight(Position.x, Position.z);
                    terrainOffset = position.y - terrainHeight;
                }
                Vector3 scaleVec = new Vector3(app.Config.MarkerPointScale, app.Config.MarkerPointScale, app.Config.MarkerPointScale);
                this.disp = new DisplayObject(this, name, app, "waypoint", app.Scene, app.Config.MarkerPointMeshName, position, scaleVec, this.orientation, null);
                this.disp.TerrainOffset = this.terrainOffset;
                if (customColor)
                {
                    this.disp.MaterialName = customMaterialName;
                }
                else
                {
                    this.disp.MaterialName = app.Config.MarkerPointMaterial;
                }

                foreach (IWorldObject child in children)
                {
                    child.AddToScene();
                    if (child is ParticleEffect)
                    {
                        (child as ParticleEffect).Orientation = orientation;
                    }
                }
                if (disp.Entity.Mesh.TriangleIntersector == null)
                    disp.Entity.Mesh.CreateTriangleIntersector();

                inScene = true;
            }
            else
            {
                foreach (IWorldObject child in children)
                {
                    if (app.DisplayParticleEffects && child is ParticleEffect && app.WorldRoot != null)
                    {
                        child.AddToScene();
                        (child as ParticleEffect).Orientation = orientation;
                    }
                }
            }
        }
コード例 #15
0
 private void DisplayPointLightMarker()
 {
     displayObject = new DisplayObject((IWorldObject)this, app, name, "Point Light", scene, app.Assets.assetFromName(app.Config.PointLightMeshName).AssetName, position, new Vector3(1, 1, 1), new Vector3(0, 0, 0), null);
     displayObject.TerrainOffset = this.terrainOffset;
 }
コード例 #16
0
        /// <summary>
        /// Use this constructor when you want the DragHelper to create the displayObject for you
        /// based on the meshName.
        /// </summary>
        /// <param name="worldEditor"></param>
        /// <param name="meshName"></param>
        /// <param name="callback"></param>
        public DragHelper(WorldEditor worldEditor, String meshName, DragComplete callback)
        {
            app = worldEditor;
            dragObject = new DisplayObject(meshName, app, "Drag", app.Scene, meshName, location,
                new Vector3(1,1,1), new Vector3(0,0,0), null);
            dragCallback = callback;
            disposeDragObject = true;
            but = app.MouseSelectButton;

            // set up mouse capture and callbacks for placing the object
            app.InterceptMouse(new MouseMoveIntercepter(DragMove), new MouseButtonIntercepter(DragButtonDown), new MouseButtonIntercepter(DragButtonUp), new MouseCaptureLost(DragCaptureLost), true);
        }
コード例 #17
0
 public DisplayParticleSystem(String name, SceneManager scene, string particleSystemName, float velocityScale, float particleScale, DisplayObject displayObject, string attachmentPointName)
 {
     this.name  = name;
     this.scene = scene;
     this.particleSystemName  = particleSystemName;
     this.particleScale       = particleScale;
     this.velocityScale       = velocityScale;
     this.displayObject       = displayObject;
     this.attachmentPointName = attachmentPointName;
     attached = true;
     AddToScene();
 }
コード例 #18
0
        /// <summary>
        /// Use this overload to place multiple Static Objects.  It allows the static objects placed to be placed on other objects.
        /// </summary>
        /// <param name="worldEditor"></param>
        /// <param name="displayObject"></param>
        /// <param name="validate"></param>
        /// <param name="complete"></param>
        public MultiPointPlacementHelper(WorldEditor worldEditor, MultiPointValidate validate, DisplayObject displayObject, MultiPointComplete complete)
        {
            app              = worldEditor;
            dragObject       = displayObject;
            completeCallback = complete;
            validateCallback = validate;

            points = new List <Vector3>();


            dragHelper = new DragHelper(app, new DragComplete(DragCallback), dragObject);
        }
コード例 #19
0
        public void Execute()
        {
            if (region == null)
            {
                region = new Boundary(parent, app, name, priority);
            }
            parent.Add(region);
            for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
            {
                app.SelectedObject[i].Node.UnSelect();
            }
            if (region.Node != null)
            {
                region.Node.Select();
            }

            if (placing)
            {
                dragMarker = new DisplayObject("RegionDrag", app, "Dragging", app.Scene, app.Config.RegionPointMeshName, Vector3.Zero, Vector3.UnitScale, Vector3.Zero, null);
                dragMarker.MaterialName = app.Config.RegionPointMaterial;
                dragMarker.ScaleWithCameraDistance = true;
                new MultiPointPlacementHelper(app, dragMarker, new MultiPointValidate(PointValidate), new MultiPointComplete(PointPlacementComplete));

                placing = false;
            }
        }
コード例 #20
0
        public void AddToScene()
        {
            if ((type == MPPointType.Boundary && app.DisplayBoundaryMarkers) || (type == MPPointType.Road && app.DisplayRoadMarkers))
            {
                if (!inScene)
                {

                    Vector3 scaleVec = new Vector3(1, 1, 1);
                    Vector3 rotVec = new Vector3(0, 0, 0);
                    displayObject = new DisplayObject(this, app, Name, "MultiPoint", app.Scene, meshName, position, scaleVec, rotVec, null);
                    displayObject.MaterialName = meshMaterial;
                    displayObject.TerrainOffset = this.terrainOffset;

                    if (displayObject.Entity.Mesh.TriangleIntersector == null)
                        displayObject.Entity.Mesh.CreateTriangleIntersector();
                    inScene = true;
                }
            }
        }
コード例 #21
0
        public void Execute()
        {
            if (!cancelled)
            {
                if (placing)
                {
                    // we need to place the object (which is handled asynchronously) before we can create it
                    dragObject = new DisplayObject(name, app, "Drag", app.Scene, app.Assets.assetFromName(app.Config.PointLightMeshName).AssetName, location, new Vector3(1,1,1), new Vector3(0,0,0), null);
                    dragObject.TerrainOffset = app.Config.DefaultPointLightHeight;

                    new DragHelper(app, new DragComplete(DragCallback), dragObject);
                }
                else
                {
                    // object has already been placed, so create it now
                    // only create it if it doesn't exist already
                    if (pointLight == null)
                    {
                        pointLight = new PointLight(app, parent, scene, name, specular, diffuse, location);
                    }
                    parent.Add(pointLight);
                    for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
                    {
                        app.SelectedObject[i].Node.UnSelect();
                    }
                    if (pointLight.Node != null)
                    {
                        pointLight.Node.Select();
                    }
                }
            }
        }
コード例 #22
0
 private void RemovePointLightMarker()
 {
     if (displayObject != null)
     {
         displayObject.Dispose();
         displayObject = null;
     }
 }
コード例 #23
0
        public void AddToScene()
        {
            float x = parent.FocusLocation.x;
            float z = parent.FocusLocation.z;

            Vector3 location = new Vector3(x, app.GetTerrainHeight(x, z) + 2000, z);
            displayObject = new DisplayObject(String.Format("{0}-{1}", parent.Name, "DirectionalLight"), app,"DirectionalLight", app.Scene, (app.Assets.assetFromName(app.Config.DirectionalLightMeshName)).AssetName, location, new Vector3(1, 1, 1), this.Orientation, null);
            inScene = true;

            UpdateOrientation();

            if (displayObject.Entity.Mesh.TriangleIntersector == null)
                displayObject.Entity.Mesh.CreateTriangleIntersector();
        }
コード例 #24
0
 public DisplayParticleSystem(String name, SceneManager scene, string particleSystemName, float velocityScale, float particleScale, DisplayObject displayObject, string attachmentPointName)
 {
     this.name = name;
     this.scene = scene;
     this.particleSystemName = particleSystemName;
     this.particleScale = particleScale;
     this.velocityScale = velocityScale;
     this.displayObject = displayObject;
     this.attachmentPointName = attachmentPointName;
     attached = true;
     AddToScene();
 }
コード例 #25
0
        public void Execute()
        {
            if (!cancelled)
            {
                Vector3 scaleVec = new Vector3(scale, scale, scale);
                Vector3 rotVec = new Vector3(0, rotation, 0);
                if (placing)
                {
                    // we need to place the object (which is handled asynchronously) before we can create it
                    dragObject = new DisplayObject(name, app, "Drag", app.Scene, meshName, location, scaleVec, rotVec, null);

                    if (placeMultiple)
                    {
                        new MultiPointPlacementHelper(app, ObjectValidate, dragObject, ObjectPlacementComplete);
                        cancelled = true;
                    }
                    else
                    {
                        new DragHelper(app, new DragComplete(DragCallback), dragObject, false);
                    }
                }
                else
                {
                    // object has already been placed, so create it now
                    // only create it if it doesn't exist already
                    if (staticObject == null)
                    {
                        staticObject = new StaticObject(name, parent, app, meshName, location, scaleVec, rotVec);
                    }
                    parent.Add(staticObject);
                    for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
                    {
                        if (app.SelectedObject[i] != null && app.SelectedObject[i].Node != null)
                        {
                            app.SelectedObject[i].Node.UnSelect();
                        }
                    }
                    if (staticObject.Node != null)
                    {
                        staticObject.Node.Select();
                    }
                }
            }
        }
コード例 #26
0
 public void RemoveFromScene()
 {
     if (inScene)
     {
         inScene = false;
         disp.Dispose();
         disp = null;
     }
     foreach (IWorldObject child in children)
     {
         if (child is ParticleEffect && app.DisplayParticleEffects && updating && (parent as WorldObjectCollection).InScene)
         {
             continue;
         }
         child.RemoveFromScene();
     }
 }
コード例 #27
0
 public void RemoveFromScene()
 {
     if (inScene || displayObject != null)
     {
         if (displayObject != null)
         {
             displayObject.Dispose();
             displayObject = null;
         }
     }
     inScene = false;
 }
コード例 #28
0
 private void DisplayPointLightMarker()
 {
     displayObject = new DisplayObject((IWorldObject)this, app, name, "Point Light", scene, app.Assets.assetFromName(app.Config.PointLightMeshName).AssetName, position, new Vector3(1, 1, 1), new Vector3(0, 0, 0), null);
     displayObject.TerrainOffset = this.terrainOffset;
 }