Пример #1
0
            public override IShapeVisitor.VisitResult Visit(ShapeBase shape)
            {
                if (shape is StaticMeshGroupShape)
                {
                    StaticMeshGroupShape groupShape = shape as StaticMeshGroupShape;

                    if (groupShape == _ignoreShape || groupShape.ExportFileName == null || groupShape.ExportFileName == "")
                    {
                        return(VisitResult.VisitOk);
                    }

                    if (groupShape.ExportFileName.StartsWith(_searchExportFileName))
                    {
                        int    newIndex  = -1;
                        string remaining = groupShape.ExportFileName.Substring(_searchExportFileName.Length);
                        if (remaining.Length > 0)
                        {
                            try
                            {
                                newIndex = Convert.ToInt32(remaining);
                            }
                            catch (Exception)
                            {
                                newIndex = -1;
                            }
                        }
                        if (newIndex > _maxIndex)
                        {
                            _maxIndex = newIndex;
                        }
                    }
                }
                return(VisitResult.VisitOk);
            }
Пример #2
0
 public EvaluateBBoxLinksVisitor(StaticMeshGroupShape shape, bool bTouching)
 {
     _shape     = shape;
     _srcLink   = (LinkSource)_shape.GetGroupStaticMeshesLinkSource();
     _bTouching = bTouching;
     visBBox    = _shape.AbsoluteBoundingBox;
 }
Пример #3
0
        public override ShapeBase CreateShapeInstance()
        {
            StaticMeshGroupShape group = new StaticMeshGroupShape("StaticMeshGroup");

            group.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
            return(group);
        }
Пример #4
0
        /// <summary>
        /// This function must be overridden, since we have to reset the hotspots
        /// </summary>
        /// <returns></returns>
        public override ShapeBase Clone()
        {
            StaticMeshGroupShape copy = (StaticMeshGroupShape)base.Clone();

            System.Diagnostics.Debug.Assert(!copy.Selected); // turned off in ShapeBase
            copy.ExportFileName = null;

     #if (MESHGROUP_USE_LINKING)
            copy._hotSpotSizeX = null;
            copy._hotSpotSizeY = null;
            copy._hotSpotSizeZ = null;
    #endif
            return(copy);
        }
 public EvaluateBBoxLinksVisitor(StaticMeshGroupShape shape, bool bTouching)
 {
   _shape = shape;
   _srcLink = (LinkSource)_shape.GetGroupStaticMeshesLinkSource();
   _bTouching = bTouching;
   visBBox = _shape.AbsoluteBoundingBox;
 }
 public override ShapeBase CreateShapeInstance()
 {
   StaticMeshGroupShape group = new StaticMeshGroupShape("StaticMeshGroup");
   group.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
   return group;
 }  
        public override void OnSceneEvent(SceneEventArgs e)
        {
            base.OnSceneEvent(e);
            if (!Active || !ExportShape || EngineBox == null)
            {
                return;
            }

            if (e.action == SceneEventArgs.Action.BeforeExport || e.action == SceneEventArgs.Action.BeforePrefabBinaryExport)
            {
                // If this static mesh group has another *active* static mesh group as a predecessor, don't do anything.
                // (Otherwise, this group's children would end up both in the parent mesh group *and* in this mesh group.)
                ShapeBase predecessor = Parent;
                while (predecessor != null)
                {
                    StaticMeshGroupShape parentGroup = predecessor as StaticMeshGroupShape;
                    if (parentGroup != null && parentGroup.Active)
                    {
                        return;
                    }
                    predecessor = predecessor.Parent;
                }

                ShapeCollection shapes = GetRelevantShapes();
                if (shapes == null || shapes.Count == 0)
                {
                    return;
                }
                string name;
                string fileextension = ".vmesh";
                if (string.IsNullOrEmpty(_exportFileName))
                {
                    //use UID
                    name = string.Format("SM_{0:x8}_{1:x8}", ParentLayer.LayerID, this.LocalID);
                }
                else
                {
                    name = _exportFileName;
                }
                name += fileextension;

                string filename = null;
                if (e is ExportSceneEventArgs)
                {
                    filename = Path.Combine(((ExportSceneEventArgs)e).ExportInfo.AbsoluteExportDataFolder, name);
                }
                else
                {
                    // this path is taken by BeforePrefabBinaryExport
                    PropertyInfo property = EditorManager.Scene.GetType().GetProperty("AbsoluteZoneExportFolder");
                    if (property != null)
                    {
                        filename = property.GetValue(EditorManager.Scene, null) as string;
                    }
                    if (string.IsNullOrEmpty(filename))
                    {
                        return;
                    }
                    filename = Path.Combine(filename, name);
                }
                filename = EditorManager.Project.MakeRelative(filename);

                EngineBox.fCombinedFarClipDist      = -1.0f;
                EngineBox.iCombinedVisibleBitmask   = 0;
                EngineBox.iCombinedCollisionBitmask = 0;
                EngineBox.bCombinedStaticShadows    = false;
                EngineBox.bCombinedDynamicShadows   = false;

                foreach (StaticMeshShape shape in shapes)
                {
                    if (StaticMeshShape.UsesCollisionGroups)
                    {
                        EngineBox.iCombinedCollisionBitmask = shape.EngineMesh.GetCollisionFilter();
                    }
                    else
                    {
                        EngineBox.iCombinedCollisionBitmask |= (uint)shape.CollisionBitmask;
                    }
                    EngineBox.iCombinedVisibleBitmask |= (uint)shape.VisibleBitmask;
                    EngineBox.fCombinedFarClipDist     = Math.Max(EngineBox.fCombinedFarClipDist, shape.FarClipDistance);
                    EngineBox.bCombinedStaticShadows  |= shape.CastStaticShadows;
                    EngineBox.bCombinedDynamicShadows |= shape.CastDynamicShadows;
                }

                EngineBox.BeginExport(shapes, filename);
                return;
            }
            if (e.action == SceneEventArgs.Action.AfterExport || e.action == SceneEventArgs.Action.AfterPrefabBinaryExport)
            {
                EngineBox.EndExport();
                return;
            }
        }