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); }
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); }
/// <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; }
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); }
// 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(); } } } }
// 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); }