Example #1
0
 /// <summary>
 /// Called when the user releases the mouse button on a hotspot
 /// </summary>
 /// <param name="hotSpot"></param>
 /// <param name="view"></param>
 public override void OnHotSpotDragEnd(HotSpotBase hotSpot, VisionViewBase view)
 {
     if (hotSpot == _hotSpotSizeX)
     {
         if (_hotSpotSizeX.HasChanged)
         {
             float fNewSize = _hotSpotSizeX.CurrentDistance;
             this.BoxSizeX = _hotSpotSizeX.StartDistance;                                                      // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSizeX", fNewSize)); // send an action which sets the property from old value to new one
         }
     }
     if (hotSpot == _hotSpotSizeY)
     {
         if (_hotSpotSizeY.HasChanged)
         {
             float fNewSize = _hotSpotSizeY.CurrentDistance;
             this.BoxSizeY = _hotSpotSizeY.StartDistance;                                                      // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSizeY", fNewSize)); // send an action which sets the property from old value to new one
         }
     }
     if (hotSpot == _hotSpotSizeZ)
     {
         if (_hotSpotSizeZ.HasChanged)
         {
             float fNewSize = _hotSpotSizeZ.CurrentDistance;
             this.BoxSizeZ = _hotSpotSizeZ.StartDistance;                                                      // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSizeZ", fNewSize)); // send an action which sets the property from old value to new one
         }
     }
 }
        public override void OnHotSpotDragEnd(HotSpotBase hotSpot, VisionViewBase view)
        {
            base.OnHotSpotDragEnd(hotSpot, view);

            if (hotSpot == _hotSpotWindSpeed)
            {
                Vector3F vNewSpeed = _hotSpotWindSpeed.CurrentPosition;
                Vector3F vOldSpeed = _hotSpotWindSpeed.StartPosition;
                if (WindInLocalSpace)
                {
                    Matrix3F rot = Matrix3F.Transpose(RotationMatrix);
                    vNewSpeed = Matrix3F.Transform(rot, vNewSpeed);
                    vOldSpeed = Matrix3F.Transform(rot, vOldSpeed);
                }
                WindSpeed = vOldSpeed;                                                                              // set old value for the action
                EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "WindSpeed", vNewSpeed)); // send an action which sets the property from old value to new one
            }
            else if (hotSpot == _hotSpotLightSamplingOffset)
            {
                Vector3F vNewOffset = _hotSpotLightSamplingOffset.CurrentPosition;
                Vector3F vOldOffset = _hotSpotLightSamplingOffset.StartPosition;

                LightSamplingOffset = vOldOffset;                                                                              // set old value for the action
                EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "LightSamplingOffset", vNewOffset)); // send an action which sets the property from old value to new one
            }
        }
Example #3
0
            public override void OnClicked(VisionViewBase view)
            {
                base.OnClicked(view);
                if (TerrainEditor.CurrentSelection == null)
                {
                    return;
                }
                ITerrainClipboardObject data = (EditorManager.ActiveComponent.Clipboard == null) ? null
          : EditorManager.ActiveComponent.Clipboard.Data as ITerrainClipboardObject;

                if (data == null)
                {
                    return;
                }

                TerrainSelectionShape selShape = (TerrainSelectionShape)this.Owner;
                float fRadX = data.OriginalExtent.GetSizeX() * 0.5f;
                float fRadY = data.OriginalExtent.GetSizeY() * 0.5f;

                GroupAction action = new GroupAction("adjust selection size");

                action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MinX", fRadX)); // min values are also positive
                action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MinY", fRadY));
                action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MaxX", fRadX));
                action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MaxY", fRadY));
                EditorManager.Actions.Add(action);
            }
            public override IShapeVisitor.VisitResult Visit(CSharpFramework.Shapes.ShapeBase shape)
            {
                if (!shape.Modifiable)
                {
                    return(VisitResult.VisitOk);
                }
                bool bAddAction = false;

                if (shape is EntityShape)
                {
                    if (!((EntityShape)shape).CastDynamicShadows)
                    {
                        bAddAction = true;
                    }
                }

                if (shape is StaticMeshShape)
                {
                    if (!((StaticMeshShape)shape).CastDynamicShadows)
                    {
                        bAddAction = true;
                    }
                }

                if (bAddAction)
                {
                    Action.Add(SetPropertyAction.CreateSetPropertyAction(shape, "CastDynamicShadows", true));
                }

                return(VisitResult.VisitOk);
            }
Example #5
0
        /// <summary>
        /// Overridden function
        /// </summary>
        public override void PerformRelevantOperation(string name, int iShapeIndex, int iShapeCount)
        {
            if (name == "Activate Postprocessing")
            {
                Activate();
                return;
            }
            if (name == ShapeObject3D.RELEVANTOP_SHAPENAME_AS_KEY)
            {
                // start a group
                if (iShapeIndex == 0)
                {
                    EditorManager.Actions.StartGroup("Name as Key");
                }

                EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Key", ShapeName));

                // close group action
                if (iShapeIndex == iShapeCount - 1)
                {
                    EditorManager.Actions.EndGroup();
                }
                return;
            }

            base.PerformRelevantOperation(name, iShapeIndex, iShapeCount);
        }
Example #6
0
        public override void PerformRelevantOperation(string name, int iShapeIndex, int iShapeCount)
        {
            base.PerformRelevantOperation(name, iShapeIndex, iShapeCount);


            if (name == RO_ADJUST_BBOX)
            {
                ShapeLink src = GetVisibilityLinkSource();
                if (src == null || src.Links.Count == 0)
                {
                    return;
                }

                BoundingBox newbbox = new BoundingBox();
                foreach (LinkTarget tgt in src.Links)
                {
                    BoundingBox bbox = tgt.OwnerShape.AbsoluteBoundingBox;
                    if (bbox != null && bbox.Valid)
                    {
                        newbbox.AddBox(bbox);
                    }
                }
                if (newbbox.Valid)
                {
                    EditorManager.Actions.StartGroup(RO_ADJUST_BBOX);
                    Vector3F size = new Vector3F(newbbox.SizeX, newbbox.SizeY, newbbox.SizeZ);
                    EditorManager.Actions.Add(new MoveShapeAction(this, this.Position, newbbox.Center));
                    EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSize", size));

                    EditorManager.Actions.EndGroup();
                }
            }

            if (name == RO_LINK_TO_TOUCHING_SHAPES || name == RO_LINK_TO_SHAPES_INSIDE)
            {
                EvaluateBBoxLinksVisitor visitor = new EvaluateBBoxLinksVisitor(this, name == RO_LINK_TO_TOUCHING_SHAPES);
                foreach (Layer layer in EditorManager.Scene.Layers)
                {
                    if (layer.Modifiable)
                    {
                        layer.Root.RunVisitor(visitor);
                    }
                }

                if (visitor.RelevantTargets.Count > 0)
                {
                    LinkSource linkSrc = GetVisibilityLinkSource();
                    EditorManager.Actions.StartGroup(name);
                    foreach (LinkTarget target in visitor.RelevantTargets)
                    {
                        EditorManager.Actions.Add(new LinkAction(linkSrc, target));
                    }

                    EditorManager.Actions.EndGroup();
                }
            }
        }
 /// <summary>
 /// Called when the user releases the mouse button on a hotspot
 /// </summary>
 /// <param name="hotSpot"></param>
 /// <param name="view"></param>
 public override void OnHotSpotDragEnd(HotSpotBase hotSpot, VisionViewBase view)
 {
     if (hotSpot == _hotSpotHeight)
     {
         if (_hotSpotHeight.HasChanged)
         {
             float fNewHeight = _hotSpotHeight.CurrentDistance;
             Height = _hotSpotHeight.StartDistance;                                                            // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Height", fNewHeight)); // send an action which sets the property from old value to new one
         }
     }
 }
Example #8
0
 /// <summary>
 /// Overridden function
 /// </summary>
 /// <param name="hotSpot"></param>
 /// <param name="view"></param>
 public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view)
 {
     if (hotSpot == _hotSpotVolume)
     {
         if (_hotSpotVolume.HasChanged)
         {
             float fNewVal = _hotSpotVolume.CurrentDistance;
             Volume = _hotSpotVolume.StartDistance; // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Volume", fNewVal));
         }
     }
     if (hotSpot == _hotSpotFadeMin)
     {
         if (_hotSpotFadeMin.HasChanged)
         {
             float fNewVal = _hotSpotFadeMin.CurrentDistance;
             MinDistance = _hotSpotFadeMin.StartDistance; // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "MinDistance", fNewVal));
         }
     }
     if (hotSpot == _hotSpotFadeMax)
     {
         if (_hotSpotFadeMax.HasChanged)
         {
             float fNewVal = _hotSpotFadeMax.CurrentDistance;
             MaxDistance = _hotSpotFadeMax.StartDistance; // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "MaxDistance", fNewVal));
         }
     }
     if (hotSpot == _hotSpotOuterCone)
     {
         if (_hotSpotOuterCone.HasChanged)
         {
             float fNewAngle = _hotSpotOuterCone.CurrentAngle;
             ConeOutside = _hotSpotOuterCone.StartAngle; // set old angle for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "ConeOutside", fNewAngle));
         }
     }
     if (hotSpot == _hotSpotInnerCone)
     {
         if (_hotSpotInnerCone.HasChanged)
         {
             float fNewAngle = _hotSpotInnerCone.CurrentAngle;
             ConeInside = _hotSpotInnerCone.StartAngle; // set old angle for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "ConeInside", fNewAngle));
         }
     }
 }
Example #9
0
 /// <summary>
 /// Overridden function
 /// </summary>
 /// <param name="hotSpot"></param>
 /// <param name="view"></param>
 public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view)
 {
     if (hotSpot == _hotSpotConeAngleX)
     {
         if (_hotSpotConeAngleX.HasChanged)
         {
             float fNewAngle = _hotSpotConeAngleX.CurrentAngle;
             ConeAngleX = _hotSpotConeAngleX.StartAngle; // set old angle for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "ConeAngleX", fNewAngle));
         }
     }
     if (hotSpot == _hotSpotConeAngleY)
     {
         if (_hotSpotConeAngleY.HasChanged)
         {
             float fNewAngle = _hotSpotConeAngleY.CurrentAngle;
             ConeAngleY = _hotSpotConeAngleY.StartAngle; // set old angle for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "ConeAngleY", fNewAngle));
         }
     }
     if (hotSpot == _hotSpotLength)
     {
         if (_hotSpotLength.HasChanged)
         {
             float fNewDist = _hotSpotLength.CurrentDistance;
             Length = _hotSpotLength.StartDistance; // set old angle for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Length", fNewDist));
         }
     }
     if (hotSpot == _hotSpotFadeOutDist1)
     {
         if (_hotSpotFadeOutDist1.HasChanged)
         {
             float fNewDist = _hotSpotFadeOutDist1.CurrentDistance - _hotSpotLength.CurrentDistance;
             FadeOutDistance = _hotSpotFadeOutDist1.StartDistance - _hotSpotLength.CurrentDistance;;
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "FadeOutDistance", fNewDist));
         }
     }
     if (hotSpot == _hotSpotFadeOutDist2)
     {
         if (_hotSpotFadeOutDist2.HasChanged)
         {
             float fNewDist = _hotSpotLength.CurrentDistance - _hotSpotFadeOutDist2.CurrentDistance;
             FadeOutDistance = _hotSpotLength.CurrentDistance - _hotSpotFadeOutDist2.StartDistance;
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "FadeOutDistance", fNewDist));
         }
     }
 }
 public override void OnHotSpotDragEnd(HotSpotBase hotSpot, VisionViewBase view)
 {
     base.OnHotSpotDragEnd(hotSpot, view);
     if (hotSpot == _hotSpotStartPoint)
     {
         Vector3F vNewPos = _hotSpotStartPoint.CurrentPosition + Position;
         _vStartPoint = _hotSpotStartPoint.StartPosition;                                                   // set old value for the action
         EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "StartPoint", vNewPos)); // send an action which sets the property from old value to new one
     }
     else if (hotSpot == _hotSpotEndPoint)
     {
         Vector3F vNewPos = _hotSpotEndPoint.CurrentPosition + Position;
         _vEndPoint = _hotSpotEndPoint.StartPosition;                                                     // set old value for the action
         EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "EndPoint", vNewPos)); // send an action which sets the property from old value to new one
     }
 }
Example #11
0
        public override void Perform2DViewAction(Scene2DView view, GroupAction parent, string action)
        {
            base.Perform2DViewAction(view, parent, action);
            BoundingBox box = view.SelectionMarqueeWorldBox;

            if (action == VA_AS_SELECTION && box.Valid)
            {
                Vector3F center = box.Center;
                float    fRadX  = box.SizeX * 0.5f;
                float    fRadY  = box.SizeY * 0.5f;
                parent.Add(new MoveShapeAction(this, this.Position, center));
                parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MinX", fRadX)); // min values are also positive
                parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MinY", fRadY));
                parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MaxX", fRadX));
                parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MaxY", fRadY));
            }
        }
Example #12
0
 /// <summary>
 /// Overridden function
 /// </summary>
 /// <param name="hotSpot"></param>
 /// <param name="view"></param>
 public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view)
 {
     if (hotSpot == _hotSpotGravity)
     {
         if (_hotSpotGravity.HasChanged)
         {
             float fNewVal = _hotSpotGravity.CurrentDistance;
             Gravity = _hotSpotGravity.StartDistance; // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Gravity", fNewVal));
         }
     }
     if (hotSpot == _hotSpotLightGridOfs)
     {
         Vector3F vNewPos = _hotSpotLightGridOfs.CurrentPosition;
         LightGridSampleOfs = _hotSpotLightGridOfs.StartPosition;                                                   // set old value for the action
         EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "LightGridSampleOfs", vNewPos)); // send an action which sets the property from old value to new one
     }
 }
        public void testClassNameUndo()
        {
            LoadEntityShapeTestScene();

            // verify that undoing EntityClass modifications does correctly restore the EntityProperties
            object  oldEntityProperties = _entityShape.EntityProperties;
            IAction myAction            = SetPropertyAction.CreateSetPropertyAction(_entityShape, "EntityClass", "CubeMapHandle_cl");

            myAction.Do();
            Assert.IsTrue(!object.ReferenceEquals(_entityShape.EntityProperties, oldEntityProperties));
            object newEntityProperties = _entityShape.EntityProperties;

            myAction.Undo();
            Assert.AreSame(oldEntityProperties, _entityShape.EntityProperties);

            myAction.Do();
            Assert.AreSame(newEntityProperties, _entityShape.EntityProperties);
        }
        public void TestRestoreLinks()
        {
            // load a different scene for this test
            TestManager.Helpers.OpenSceneFromFile(Path.Combine(TestManager.Helpers.TestDataDir, @"EntityShapeTest\RestoreLink.scene"));

            EntityShape entity = EditorManager.Scene.FindShapeByName("Entity") as EntityShape;

            Assert.IsNotNull(entity);

            // the map has an anim entity which is attached to a path
            Assert.AreEqual(entity.EntityClass, "AnimEntity_cl");
            Assert.AreEqual(entity.LinkSources.Count, 1);
            Assert.AreEqual(entity.LinkTargets.Count, 0);
            Assert.AreEqual(entity.LinkBidirections.Count, 0);

            // verify the link is there
            LinkSource linkSrc = (LinkSource)entity.LinkSources[0];

            Assert.AreEqual(linkSrc.Links.Count, 1);
            LinkTarget linkTgt   = (LinkTarget)linkSrc.Links[0];
            PathShape  pathShape = linkTgt.OwnerShape as PathShape;

            Assert.IsNotNull(pathShape);
            Assert.AreEqual(pathShape.LinkTargets.Count, 1);
            Assert.AreEqual(pathShape.LinkTargets[0].Links.Count, 1);

            // setting a new entity class removes the link
            IAction myAction = SetPropertyAction.CreateSetPropertyAction(entity, "EntityClass", "VisBaseEntity_cl");

            myAction.Do();
            Assert.AreEqual(entity.LinkSources.Count, 0);
            Assert.AreEqual(pathShape.LinkTargets.Count, 1);
            Assert.AreEqual(pathShape.LinkTargets[0].Links.Count, 0); // not conected to entity anymore

            // now the link should be restored again
            myAction.Undo();
            Assert.AreEqual(entity.LinkSources.Count, 1);
            Assert.AreEqual(entity.LinkSources[0].Links.Count, 1);
            Assert.AreEqual(entity.LinkSources[0].Links[0].OwnerShape, pathShape);
            Assert.AreEqual(pathShape.LinkTargets.Count, 1);
            Assert.AreEqual(pathShape.LinkTargets[0].Links.Count, 1);
        }
Example #15
0
 /// <summary>
 /// Overridden function
 /// </summary>
 /// <param name="hotSpot"></param>
 /// <param name="view"></param>
 public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view)
 {
     if (hotSpot == _hotSpotSizeX)
     {
         if (_hotSpotSizeX.HasChanged)
         {
             float fNewVal = _hotSpotSizeX.CurrentDistance;
             SizeX = _hotSpotSizeX.StartDistance; // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "SizeX", fNewVal));
         }
     }
     if (hotSpot == _hotSpotSizeY)
     {
         if (_hotSpotSizeY.HasChanged)
         {
             float fNewVal = _hotSpotSizeY.CurrentDistance;
             SizeY = _hotSpotSizeY.StartDistance; // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "SizeY", fNewVal));
         }
     }
 }
 /// <summary>
 /// Overridden function
 /// </summary>
 /// <param name="hotSpot"></param>
 /// <param name="view"></param>
 public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view)
 {
     if (hotSpot == _hotSpotReverbMin)
     {
         if (_hotSpotReverbMin.HasChanged)
         {
             float fNewVal = _hotSpotReverbMin.CurrentDistance;
             MinDistance = _hotSpotReverbMin.StartDistance; // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "MinDistance", fNewVal));
         }
     }
     if (hotSpot == _hotSpotReverbMax)
     {
         if (_hotSpotReverbMax.HasChanged)
         {
             float fNewVal = _hotSpotReverbMax.CurrentDistance;
             MaxDistance = _hotSpotReverbMax.StartDistance; // set old value for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "MaxDistance", fNewVal));
         }
     }
 }
Example #17
0
        /// <summary>
        /// Called when the user releases the mouse button on a hotspot
        /// </summary>
        /// <param name="hotSpot"></param>
        /// <param name="view"></param>
        public override void OnHotSpotDragEnd(HotSpotBase hotSpot, VisionViewBase view)
        {
            if (hotSpot == _hotSpotX)
            {
                if (_hotSpotX.HasChanged)
                {
                    float fNewX = _hotSpotX.CurrentDistance;
                    Size = new Vector2F(_hotSpotX.StartDistance, Size.Y);                                                            // set old value for the action
                    EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Size", new Vector2F(fNewX, Size.Y))); // send an action which sets the property from old value to new one
                }
            }

            if (hotSpot == _hotSpotY)
            {
                if (_hotSpotY.HasChanged)
                {
                    float fNewY = _hotSpotY.CurrentDistance;
                    Size = new Vector2F(Size.X, _hotSpotY.StartDistance);                                                            // set old value for the action
                    EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Size", new Vector2F(Size.X, fNewY))); // send an action which sets the property from old value to new one
                }
            }

            if (hotSpot == _hotSpotXY)
            {
                if (_hotSpotXY.HasChanged)
                {
                    float ratio = Size.Y / Size.X;
                    //compute old value
                    float oldX = _hotSpotXY.StartDistance / (float)System.Math.Sqrt(ratio * ratio + 1.0f);
                    float oldY = oldX * ratio;
                    Size = new Vector2F(oldX, oldY); // set old value for the action

                    //compute new value
                    float newX = _hotSpotXY.CurrentDistance / (float)System.Math.Sqrt(ratio * ratio + 1.0f);
                    float newY = ratio * newX;
                    EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Size", new Vector2F(newX, newY))); // send an action which sets the property from old value to new one
                }
            }
        }
 /// <summary>
 /// Overridden function
 /// </summary>
 /// <param name="hotSpot"></param>
 /// <param name="view"></param>
 public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view)
 {
     if (hotSpot == _hotSpotConeAngleX)
     {
         if (_hotSpotConeAngleX.HasChanged)
         {
             float fNewAngle = _hotSpotConeAngleX.CurrentAngle;
             CameraAngleX = _hotSpotConeAngleX.StartAngle; // set old angle for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "CameraAngleX", fNewAngle));
         }
     }
     if (hotSpot == _hotSpotConeAngleY)
     {
         if (_hotSpotConeAngleY.HasChanged)
         {
             float fNewAngle = _hotSpotConeAngleY.CurrentAngle;
             CameraAngleY = _hotSpotConeAngleY.StartAngle; // set old angle for the action
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "CameraAngleY", fNewAngle));
         }
     }
     if (hotSpot == _hotSpotNearClip)
     {
         if (_hotSpotNearClip.HasChanged)
         {
             float fNewDist = _hotSpotNearClip.CurrentDistance;
             this.NearClipDistance = _hotSpotNearClip.StartDistance;
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "NearClipDistance", fNewDist));
         }
     }
     if (hotSpot == _hotSpotFarClip)
     {
         if (_hotSpotFarClip.HasChanged)
         {
             float fNewDist = _hotSpotFarClip.CurrentDistance;
             this.FarClipDistance = _hotSpotFarClip.CurrentDistance;
             EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "FarClipDistance", fNewDist));
         }
     }
 }
Example #19
0
        /// <summary>
        /// This function converts all physX related entities/components to new Havok plugin
        /// </summary>
        void MigrateToHavokComponents()
        {
            // PhysX plugin is still loaded? Then don't do anything
            IEditorPluginModule physXPlugin = EditorManager.GetPluginByName("PhysXEditorPlugin.EditorPlugin");

            if (physXPlugin != null && physXPlugin.Initialized)
            {
                return;
            }

            // collect all physX specific components
            ShapeComponentCollection physXComponents = new ShapeComponentCollection();
            ShapeCollection          physXEntities   = new ShapeCollection();

            foreach (Layer layer in EditorManager.Scene.Layers)
            {
                if (layer.Modifiable && layer.Loaded)
                {
                    AddPhysXComponentsRecursive(physXComponents, physXEntities, layer.Root);
                }
            }

            if (physXComponents.Count == 0 && physXEntities.Count == 0)
            {
                return;
            }

            // prompt a dialog
            DialogResult res = EditorManager.ShowMessageBox("nVidia PhysX binding specific components/entities have been found in loaded layers.\n\nShould these be permanently converted to Havok components?", "nVidia PhysX plugin not loaded", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res != DialogResult.Yes)
            {
                return;
            }

            int iConvertedCount = 0;

            // build a list of actions for the component replacement
            if (physXComponents.Count > 0)
            {
                GroupAction actions = new GroupAction("Migrate to Havok components");
                foreach (ShapeComponent oldComp in physXComponents)
                {
                    ShapeComponent newComp = null;
                    if (oldComp.DisplayName == "vPhysXRigidBody")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokRigidBody");
                        MigrateRigidBodyProperties(oldComp, newComp);
                    }
                    else if (oldComp.DisplayName == "vPhysXCharacterController")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokCharacterController");
                        MigrateCharacterControllerProperties(oldComp, newComp);
                    }
                    if (newComp == null)
                    {
                        continue;
                    }
                    // action to remove the old component and add the new one
                    actions.Add(new RemoveShapeComponentAction((ShapeBase)oldComp.Owner, oldComp));
                    actions.Add(new AddShapeComponentAction((ShapeBase)oldComp.Owner, newComp));
                    iConvertedCount++;
                }
                // trigger the conversion action
                EditorManager.Actions.Add(actions);
            }

            if (physXEntities.Count > 0)
            {
                GroupAction actions = new GroupAction("Migrate entities classes");
                foreach (EntityShape entity in physXEntities)
                {
                    ShapeComponent newComp = null;
                    if (entity.EntityClass == "vPhysXEntity")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "vHavokRigidBody");
                        MigratePhysXEntityProperties(entity.EntityProperties, newComp);
                    }
                    else if (entity.EntityClass == "LineFollowerEntity_cl")
                    {
                        newComp = (ShapeComponent)EditorManager.EngineManager.ComponentClassManager.CreateCollection(null, "VLineFollowerComponent");
                        MigrateLineFollowerEntityProperties(entity.EntityProperties, newComp);
                    }
                    if (newComp == null)
                    {
                        continue;
                    }
                    // we convert to base entity class and attach a component instead
                    actions.Add(SetPropertyAction.CreateSetPropertyAction(entity, "EntityClass", "VisBaseEntity_cl"));
                    actions.Add(new AddShapeComponentAction(entity, newComp));
                    iConvertedCount++;
                }
                // trigger the conversion action
                EditorManager.Actions.Add(actions);
            }

            EditorManager.ShowMessageBox(iConvertedCount.ToString() + " Component(s) have been successfully converted.\n\nSince physics engine have quite different behavior, the parameters might have to be tweaked to match old behavior.", "PhysX to Havok component conversion", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #20
0
 private void toolStripButton_VisBlocker_Click(object sender, EventArgs e)
 {
     EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(_settings, "VisualizeBlockerVolumes", !_settings.VisualizeBlockerVolumes));
     SetHavokPhysicsParams();
 }
Example #21
0
 private void toolStripButton_VisController_Click(object sender, EventArgs e)
 {
     EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(_settings, "VisualizeCharacterControllers", !_settings.VisualizeCharacterControllers));
     SetHavokPhysicsParams();
 }