Esempio n. 1
0
        public async Task <GActor> CreateActor(Editor.PlantableItemCreateActorParam param)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var rc = EngineNS.CEngine.Instance.RenderContext;

            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement    = placement;
            placement.Location = param.Location;
            placement.Rotation = EngineNS.Quaternion.GetQuaternion(Vector3.UnitZ, -Vector3.UnitY);
            actor.SpecialName  = "SunActor";

            var initializer = new GDirLightComponentInitializer();

            initializer.SpecialName = "LightData";
            await SetInitializer(rc, actor, actor, initializer);

            this.View = param.View;

            var meshComp     = new EngineNS.GamePlay.Component.GMeshComponent();
            var meshCompInit = new EngineNS.GamePlay.Component.GMeshComponent.GMeshComponentInitializer();

            meshCompInit.SpecialName = "VisualMesh";
            meshCompInit.MeshName    = EngineNS.RName.GetRName("editor/sun.gms", EngineNS.RName.enRNameType.Game);
            var test = meshComp.SetInitializer(rc, actor, actor, meshCompInit);

            actor.AddComponent(meshComp);

            actor.AddComponent(this);
            return(actor);
        }
Esempio n. 2
0
        public override async Task <GActor> CreateActor(PlantableItemCreateActorParam param)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var rc = EngineNS.CEngine.Instance.RenderContext;

            var actorInit = new GActor.GActorInitializer();

            actorInit.InPVS = false;
            var actor = new GActor();

            actor.SetInitializer(actorInit);
            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement    = placement;
            placement.Location = param.Location;

            var init = new AgentGeomBoxComponentInitializer();

            init.SpecialName = "AgentStart";
            await SetInitializer(rc, actor, actor, init);

            actor.AddComponent(this);
            return(actor);
        }
        public override async Task <GamePlay.Actor.GActor> CreateActor(Editor.PlantableItemCreateActorParam param)
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;

            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement    = placement;
            placement.Location = param.Location;

            var init = new OctreeVolumeComponentInitializer();

            init.SpecialName = "VolumeData";
            await SetInitializer(rc, actor, actor, init);

            if (mActorOctree == null)
            {
                mActorOctree = new Octree();
                mActorOctree.LinkedActorId = actor.ActorId;
            }

            mLineMeshComponent.Host = actor;
            var mat = actor.Placement.WorldMatrix;

            mLineMeshComponent.OnUpdateDrawMatrix(ref mat);
            //var aabb = new BoundingBox(-0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f);
            //BoundingBox.Merge(ref actor.LocalBoundingBox, ref aabb, out actor.LocalBoundingBox);

            actor.AddComponent(this);
            return(actor);
        }
Esempio n. 4
0
        public EngineNS.GamePlay.Actor.GActor CreateNavActor()
        {
            NavAreaActor         = new EngineNS.GamePlay.Actor.GActor();
            NavAreaActor.ActorId = Guid.NewGuid();
            EngineNS.GamePlay.Component.GPlacementComponent component = new EngineNS.GamePlay.Component.GPlacementComponent();
            var placement = new GamePlay.Component.GPlacementComponent();

            NavAreaActor.Placement = placement;
            return(NavAreaActor);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public async Task <Actor.GActor> CreateActor(Editor.PlantableItemCreateActorParam param)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var rc = EngineNS.CEngine.Instance.RenderContext;

            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement    = placement;
            placement.Location = param.Location;
            placement.Rotation = EngineNS.Quaternion.GetQuaternion(Vector3.UnitZ, -Vector3.UnitY);

            var meshComp     = new EngineNS.GamePlay.Component.GMeshComponent();
            var meshCompInit = new EngineNS.GamePlay.Component.GMeshComponent.GMeshComponentInitializer();

            meshCompInit.SpecialName = "EditorShow";
            meshCompInit.MeshName    = EngineNS.RName.GetRName("meshes/pointlight.gms", EngineNS.RName.enRNameType.Editor);
            await meshComp.SetInitializer(rc, actor, actor, meshCompInit);

            meshComp.HideInGame = true;
            actor.AddComponent(meshComp);

            meshComp                 = new EngineNS.GamePlay.Component.GMeshComponent();
            meshCompInit             = new EngineNS.GamePlay.Component.GMeshComponent.GMeshComponentInitializer();
            meshCompInit.SpecialName = "SphereVolumeShow";
            meshCompInit.MeshName    = EngineNS.RName.GetRName("meshes/sphere_wireframe.gms", EngineNS.RName.enRNameType.Editor);
            await meshComp.SetInitializer(rc, actor, actor, meshCompInit);

            meshComp.HideInGame = true;
            actor.AddComponent(meshComp);


            var initializer = new GPointLightComponentInitializer();

            initializer.SpecialName = "PointLightComponent";
            await SetInitializer(rc, actor, actor, initializer);

            actor.AddComponent(this);
            actor.AcceptLights = false;

            return(actor);
        }
Esempio n. 7
0
        public override async Task <GamePlay.Actor.GActor> CreateActor(Editor.PlantableItemCreateActorParam param)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var rc = EngineNS.CEngine.Instance.RenderContext;

            var actor = new EngineNS.GamePlay.Actor.GActor();

            actor.ActorId = Guid.NewGuid();
            var placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            actor.Placement    = placement;
            placement.Location = param.Location;
            placement.Rotation = EngineNS.Quaternion.GetQuaternion(Vector3.UnitZ, -Vector3.UnitY);

            var meshComp     = new EngineNS.GamePlay.Component.GMeshComponent();
            var meshCompInit = new EngineNS.GamePlay.Component.GMeshComponent.GMeshComponentInitializer();

            meshCompInit.SpecialName = "EditorShow";
            meshCompInit.MeshName    = EngineNS.RName.GetRName("meshes/go_on.gms", EngineNS.RName.enRNameType.Editor);
            await meshComp.SetInitializer(rc, actor, actor, meshCompInit);

            meshComp.HideInGame                = true;
            meshComp.Placement.InheritScale    = false;
            meshComp.Placement.InheritRotation = false;
            actor.AddComponent(meshComp);

            var init = new BoxComponentInitializer();

            init.SpecialName = "NavMeshBoundVolume";
            await SetInitializer(rc, actor, actor, init);

            mLineMeshComponent.Host = actor;
            var mat = actor.Placement.WorldMatrix;

            mLineMeshComponent.OnUpdateDrawMatrix(ref mat);

            actor.AddComponent(this);

            return(actor);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public async System.Threading.Tasks.Task CreateActor()
        {
            if (HostActor != null)
            {
                return;
            }

            EngineNS.GamePlay.Component.GPlacementComponent placement = new EngineNS.GamePlay.Component.GPlacementComponent();

            var rc = EngineNS.CEngine.Instance.RenderContext;

            EngineNS.GamePlay.Actor.GActor actor = new EngineNS.GamePlay.Actor.GActor();
            actor.ActorId = new Guid();
            await placement.SetInitializer(rc, actor, actor, placement.mPlacementData);

            placement.SpecialName = "Placement";

            placement.Location = new EngineNS.Vector3(0, 0, 0);
            actor.AddComponent(placement);

            actor.LocalBoundingBox.Minimum = new EngineNS.Vector3(-1, -1, -1);
            actor.LocalBoundingBox.Maximum = new EngineNS.Vector3(1, 1, 1);
            //actor.AddComponent(this);

            //EngineNS.GamePlay.Component.GMeshComponent.GMeshComponentInitializer initializer = new EngineNS.GamePlay.Component.GMeshComponent.GMeshComponentInitializer();
            //EngineNS.GamePlay.Component.GMeshComponent meshcomponent = new EngineNS.GamePlay.Component.GMeshComponent();
            //initializer.MeshName = EngineNS.RName.GetRName("ParticleResource/models/sphere.gms");
            //await meshcomponent.SetInitializer(rc, actor, actor, initializer);
            //meshcomponent.SpecialName = "mesh";
            //actor.AddComponent(meshcomponent);
            HostActor = actor;

            HostActor.PlacementChange     -= PlacementChange;
            HostActor.PlacementChange     += PlacementChange;
            HostActor.NeedRefreshNavgation = true;
        }