Example #1
0
        public virtual void RestoreDMeshSO(FScene scene, TypedAttribSet attributes, DMeshSO so)
        {
            DMesh3 mesh = RestoreDMesh(attributes);

            so.Create(mesh, scene.DefaultSOMaterial);
            RestoreSOInfo(so, attributes);
            RestoreTransform(so, attributes);
            RestoreMaterial(so, attributes);
        }
Example #2
0
        override public SceneObject Duplicate()
        {
            DMeshSO copy     = new DMeshSO();
            DMesh3  copyMesh = new DMesh3(mesh);

            copy.Create(copyMesh, this.GetAssignedSOMaterial());
            copy.SetLocalFrame(
                this.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords);
            copy.SetLocalScale(this.GetLocalScale());
            return(copy);
        }
Example #3
0
        /// <summary>
        /// called internally by Duplicate() and DuplicateSubtype(),
        /// override to add things you want to duplicate
        /// </summary>
        protected virtual void duplicate_to(DMeshSO copy)
        {
            DMesh3 copyMesh = new DMesh3(mesh);

            copy.Create(copyMesh, this.GetAssignedSOMaterial());
            copy.SetLocalFrame(
                this.GetLocalFrame(CoordSpace.ObjectCoords), CoordSpace.ObjectCoords);
            copy.SetLocalScale(this.GetLocalScale());
            copy.enable_shadows = this.enable_shadows;
            copy.enable_spatial = this.enable_spatial;
        }
Example #4
0
        public MeshReferenceSO GetMeshReference(SOMaterial defaultMaterial)
        {
            MeshReferenceSO ref_group = new MeshReferenceSO();

            ref_group.MeshReferencePath = sSourcePath;
            ref_group.Create();
            ref_group.Name = UniqueNames.GetNext("MeshReference");

            foreach (ImportedObject obj in SceneObjects)
            {
                DMeshSO meshSO = new DMeshSO();
                meshSO.Create(obj.mesh,
                              (obj.material == null) ? defaultMaterial : obj.material);
                meshSO.Name = UniqueNames.GetNext("ImportMesh");
                ref_group.AddChild(meshSO);
            }

            return(ref_group);
        }
Example #5
0
        // add the meshes we have read into SceneObjects list to the given Scene
        public void AppendReadMeshesToScene(FScene scene, bool bSaveHistory)
        {
            if (ImportBehavior == ImportMode.AsMeshReference)
            {
                MeshReferenceSO ref_group = GetMeshReference(scene.DefaultMeshSOMaterial);

                var change = new AddSOChange()
                {
                    scene = scene, so = ref_group
                };
                if (bSaveHistory)
                {
                    scene.History.PushChange(change);
                }
                else
                {
                    change.Apply();
                }
            }
            else
            {
                foreach (ImportedObject obj in SceneObjects)
                {
                    DMeshSO meshSO = new DMeshSO();
                    meshSO.Create(obj.mesh, (obj.material == null) ? scene.DefaultMeshSOMaterial : obj.material);
                    meshSO.Name = UniqueNames.GetNext("ImportMesh");

                    var change = new AddSOChange()
                    {
                        scene = scene, so = meshSO
                    };
                    if (bSaveHistory)
                    {
                        scene.History.PushChange(change);
                    }
                    else
                    {
                        change.Apply();
                    }
                }
            }
        }
Example #6
0
        // converts input GameObject into a DMeshSO. Original GameObject is not used by DMeshSO,
        // so it can be destroyed.
        // [TODO] transfer materials!!
        public static SceneObject WrapMeshGameObject(GameObject wrapGO, FContext context, bool bDestroyOriginal, bool bPreserveColor = true)
        {
            SOMaterial overrideMaterial = null;

            if (bPreserveColor)
            {
                if (wrapGO.GetMaterial() != null)
                {
                    overrideMaterial = MaterialUtil.FromUnityMaterial(wrapGO.GetMaterial());
                }
            }
            var wrapperSO = ImportExistingUnityMesh(wrapGO, context.Scene, true, true, true,
                                                    (mesh, material) => {
                DMeshSO gso     = new DMeshSO();
                var useMaterial = (overrideMaterial != null) ? overrideMaterial : material;
                return(gso.Create(UnityUtil.UnityMeshToDMesh(mesh, false), useMaterial));
            });

            if (bDestroyOriginal)
            {
                wrapGO.Destroy();
            }
            return(wrapperSO);
        }