public override async System.Threading.Tasks.Task <ImageSource[]> GetSnapshotImage(bool forceCreate) { if (mIsGenerationSnapshot == true) { return(null); } var snapShotFile = ResourceName.Address + EditorCommon.Program.SnapshotExt; if (forceCreate == false) { var imgSource = await EditorCommon.ImageInit.GetImage(snapShotFile); if (imgSource != null) { return(imgSource); } } mIsGenerationSnapshot = true; var rc = CEngine.Instance.RenderContext; var meshSource = CEngine.Instance.MeshPrimitivesManager.GetMeshPrimitives(rc, ResourceName, true); var curMesh = CEngine.Instance.MeshManager.CreateMesh(rc, meshSource /*, EditorCommon.SnapshotProcess.SnapshotCreator.GetShadingEnv()*/); if (curMesh == null) { mIsGenerationSnapshot = false; return(null); } var mtl = EngineNS.CEngine.Instance.MaterialInstanceManager.DefaultMaterialInstance; for (UInt32 i = 0; i < curMesh.MtlMeshArray.Length; i++) { await curMesh.SetMaterialInstanceAsync(EngineNS.CEngine.Instance.RenderContext, i, mtl, null); } var snapShorter = new EditorCommon.SnapshotProcess.SnapshotCreator();//EngineNS.Editor.SnapshotCreator();// snapShorter.SkyName = EngineNS.RName.GetRName("Mesh/sky.gms"); snapShorter.FloorName = EngineNS.RName.GetRName(@"editor/floor.gms"); var eye = new EngineNS.Vector3(); eye.SetValue(1.6f, 1.5f, -3.6f); var at = new EngineNS.Vector3(); at.SetValue(0.0f, 0.0f, 0.0f); var up = new EngineNS.Vector3(); up.SetValue(0.0f, 1.0f, 0.0f); await snapShorter.InitEnviroment(); snapShorter.Camera.LookAtLH(eye, at, up); var actor = EngineNS.GamePlay.Actor.GActor.NewMeshActorDirect(curMesh); actor.Placement.Location = new Vector3(0, -0.5f, 0); curMesh.PreUse(true);//就这个地方用,别的地方别乱用,效率不好 snapShorter.World.AddActor(actor); snapShorter.World.GetScene(RName.GetRName("SnapshorCreator")).AddActor(actor); snapShorter.FocusActor = actor; await snapShorter.SaveToFile(snapShotFile, 1, curMesh.Editor_GetSnapshortFrameNumber()); mIsGenerationSnapshot = false; return(await EditorCommon.ImageInit.GetImage(snapShotFile)); }
public override async Task <ImageSource[]> GetSnapshotImage(bool forceCreate) { if (mIsGenerationSnapshot == true) { return(null); } var snapShotFile = ResourceName.Address + EditorCommon.Program.SnapshotExt; if (forceCreate == false) { var imgSource = await EditorCommon.ImageInit.GetImage(snapShotFile); if (imgSource != null) { return(imgSource); } } if (mIsGenerationSnapshot == true) { return(null); } mIsGenerationSnapshot = true; var rc = CEngine.Instance.RenderContext; var mCurMesh = await CEngine.Instance.MeshManager.CreateMeshAsync(rc, ResourceName /*, EditorCommon.SnapshotProcess.SnapshotCreator.GetShadingEnv()*/); if (mCurMesh == null) { mIsGenerationSnapshot = false; return(null); } var snapShorter = new EditorCommon.SnapshotProcess.SnapshotCreator();//EngineNS.Editor.SnapshotCreator();// snapShorter.SkyName = EngineNS.RName.GetRName("Mesh/sky.gms"); snapShorter.FloorName = EngineNS.RName.GetRName(@"editor/floor.gms"); var eye = new EngineNS.Vector3(); eye.SetValue(1.6f, 1.5f, -3.6f); var at = new EngineNS.Vector3(); at.SetValue(0.0f, 0.0f, 0.0f); var up = new EngineNS.Vector3(); up.SetValue(0.0f, 1.0f, 0.0f); await snapShorter.InitEnviroment(); snapShorter.Camera.LookAtLH(eye, at, up); var actor = EngineNS.GamePlay.Actor.GActor.NewMeshActorDirect(mCurMesh); mCurMesh.PreUse(true);//就这个地方用,别的地方别乱用,效率不好 snapShorter.World.AddActor(actor); snapShorter.World.GetScene(RName.GetRName("SnapshorCreator")).AddActor(actor); snapShorter.FocusActor = actor; actor.Placement.Location = new Vector3(0, 0, 0); await snapShorter.SaveToFile(snapShotFile, 1, mCurMesh.Editor_GetSnapshortFrameNumber()); mIsGenerationSnapshot = false; return(await EditorCommon.ImageInit.GetImage(snapShotFile)); }