Exemplo n.º 1
0
        public void FlattenItem(ref IINode itemNode)
        {
            AnimationGroupList animationGroupList = new AnimationGroupList();

            animationGroupList.LoadFromData(Loader.Core.RootNode);

            if (itemNode == null)
            {
                string message = "Flattening nodes of scene not supported...";
                logger?.RaiseMessage(message, 0);
            }
            else
            {
                string message = $"Flattening child nodes of {itemNode.Name}...";
                logger?.RaiseMessage(message, 0);
                List <IINode> flattenableNodes = new List <IINode>();
                if (IsMeshFlattenable(itemNode, animationGroupList, ref flattenableNodes))
                {
                    itemNode = itemNode.FlattenHierarchyMS();
                }
                else
                {
                    string msg = $"{itemNode.Name} cannot be flatten, check the content of his hierarchy.";
                    logger?.RaiseWarning(msg, 0);
                }
            }
        }
Exemplo n.º 2
0
        public void ExportClosedContainers()
        {
            List <IILayer>           containerLayers = new List <IILayer>();
            List <IIContainerObject> sceneContainers = Tools.GetAllContainers();

            foreach (IIContainerObject containerObject in sceneContainers)
            {
                if (!containerObject.IsInherited)
                {
                    continue;
                }
                containerLayers.Clear();
                if (!containerObject.LoadContainer)
                {
                    logger?.RaiseWarning($"Impossible to load container {containerObject.ContainerNode.Name}...");
                }
                if (!containerObject.UnloadContainer)
                {
                    logger?.RaiseWarning($"Impossible to update container {containerObject.ContainerNode.Name}...");
                }
                if (!containerObject.MakeUnique)
                {
                    logger?.RaiseWarning($"Impossible to make unique container{containerObject.ContainerNode.Name}...");
                }
                int resolvePropertySet = 0;
                if (containerObject.ContainerNode.GetUserPropBool("flightsim_resolved", ref resolvePropertySet) && resolvePropertySet > 0)
                {
                    logger?.RaiseCriticalError($"{containerObject.ContainerNode.Name} has an invalid object property 'flightsim_resolved', " +
                                               $"remove it manually trough Right Click -> Object Properties -> UserDefined  and save the scene");
                }
                containerLayers = containerObject.GetContainerLayers();
                foreach (var layer in containerLayers)
                {
                    layer.Hide(false, false);
                }
                foreach (IINode node in containerObject.ContainerNode.NodeTree())
                {
                    node.Hide(false);
                }

                logger?.Print($"Update and merge container {containerObject.ContainerNode.Name}...", Color.Green);
            }
            AnimationGroupList.LoadDataFromAllContainers();

            foreach (IIContainerObject containerObject in sceneContainers)
            {
                // this property must be set to false at the and on the export of a containers
                // saving the scene with the property stored end to conflict and error on the IDresolved for multiple inherited containers
                containerObject.ContainerNode.SetUserPropBool("flightsim_resolved", false);
            }
        }
Exemplo n.º 3
0
 public void MergeAllXrefRecords()
 {
     if (Loader.IIObjXRefManager.RecordCount <= 0)
     {
         return;
     }
     while (Loader.IIObjXRefManager.RecordCount > 0)
     {
         var record = Loader.IIObjXRefManager.GetRecord(0);
         logger?.Print($"Merge XRef record {record.SrcFile.FileName}...", Color.Black);
         Loader.IIObjXRefManager.MergeRecordIntoScene(record);
         //todo: load data from animation helper of xref scene merged
         //to prevent to load animations from helper created without intention
     }
     AnimationGroupList.LoadDataFromAnimationHelpers();
 }
Exemplo n.º 4
0
        private bool IsMeshFlattenable(IINode node, AnimationGroupList animationGroupList, ref List <IINode> flattenableNodes)
        {
            //a node can't be flatten if:
            //- is marked as not flattenable
            //- is hidden
            //- is not selected when exportOnlyselected is checked
            //- is part of animation group
            //- is linked to animated node

            if (node.IsMarkedAsNotFlattenable())
            {
                logger?.RaiseWarning($"{node.Name} is marked as not flattenable");
                return(false);
            }


            if (node.IsRootNode)
            {
                for (int i = 0; i < node.NumChildren; i++)
                {
                    IINode n = node.GetChildNode(i);
                    return(IsMeshFlattenable(n, animationGroupList, ref flattenableNodes));
                }
                return(false);
            }


            if (!exportParameters.exportHiddenObjects && node.IsNodeHidden(false))
            {
                logger?.RaiseWarning($"{node.Name} is hidden");
                return(false);
            }


            if (node.IsNodeTreeAnimated())
            {
                string message = $"{node.Name} can't be flatten, his hierarchy contains animated node";
                logger?.RaiseWarning(message, 0);
                for (int i = 0; i < node.NumChildren; i++)
                {
                    IINode n = node.GetChildNode(i);
                    return(IsMeshFlattenable(n, animationGroupList, ref flattenableNodes));
                }
                return(false);
            }

            if (node.IsInAnimationGroups(animationGroupList))
            {
                string message = $"{node.Name} can't be flatten, because is part of an AnimationGroup";
                logger?.RaiseWarning(message, 0);
                for (int i = 0; i < node.NumChildren; i++)
                {
                    IINode n = node.GetChildNode(i);
                    return(IsMeshFlattenable(n, animationGroupList, ref flattenableNodes));
                }
                return(false);
            }

            flattenableNodes.Add(node);
            return(true);
        }