GActor NewMeshActor(CGfxMesh mesh) { var rc = CEngine.Instance.RenderContext; var actor = new EngineNS.GamePlay.Actor.GActor(); actor.ActorId = Guid.NewGuid(); var placement = new EngineNS.GamePlay.Component.GPlacementComponent(); actor.Placement = placement; var meshComp = new EngineNS.GamePlay.Component.GMeshComponent(); meshComp.SetSceneMesh(rc.ImmCommandList, mesh); actor.AddComponent(meshComp); return(actor); }
async System.Threading.Tasks.Task <GActor> NewMeshActor(CGfxMeshPrimitives meshPri) { var rc = CEngine.Instance.RenderContext; var actor = new EngineNS.GamePlay.Actor.GActor(); actor.ActorId = Guid.NewGuid(); var placement = new EngineNS.GamePlay.Component.GPlacementComponent(); actor.Placement = placement; var meshComp = new EngineNS.GamePlay.Component.GMeshComponent(); var mesh = CEngine.Instance.MeshManager.CreateMesh(rc, meshPri); var mtl = await EngineNS.CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(rc, RName.GetRName("Material/defaultmaterial.instmtl")); for (int i = 0; i < mesh.MtlMeshArray.Length; ++i) { await mesh.SetMaterialInstanceAsync(rc, (uint)i, mtl, null); } meshComp.SetSceneMesh(rc.ImmCommandList, mesh); actor.AddComponent(meshComp); return(actor); }