示例#1
0
        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);
        }
示例#2
0
        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);
        }