Exemplo n.º 1
0
        void Viewport_TickLogic(EditorCommon.ViewPort.ViewPortControl vpc)
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;

            if (vpc.World != null)
            {
                vpc.World.CheckVisible(rc.ImmCommandList, vpc.Camera);
                vpc.World.Tick();
            }
            vpc.RPolicy.TickLogic(null, rc);

            var designRect   = new EngineNS.RectangleF(0, 0, Viewport.GetViewPortWidth(), Viewport.GetViewPortHeight());
            var tempClipRect = designRect;

            if (mUVAnim != null && mImage2D != null)
            {
                mUVAnim.CheckAndAutoReferenceFromTemplateUVAnim();
                bool frameChanged;
                var  frame = mUVAnim.GetUVFrame(EngineNS.Support.Time.GetTickCount(), out frameChanged);
                if (frameChanged || mForceUpdateFrame)
                {
                    using (var posData = EngineNS.Support.NativeListProxy <EngineNS.Vector3> .CreateNativeList())
                        using (var uvData = EngineNS.Support.NativeListProxy <EngineNS.Vector2> .CreateNativeList())
                        {
                            frame.UpdateVertexes(posData, ref designRect, ref tempClipRect);
                            frame.UpdateUVs(uvData, ref designRect, ref tempClipRect);
                            mImage2D.RenderMatrix = EngineNS.Matrix.Scaling(tempClipRect.Width, tempClipRect.Height, 1) * EngineNS.Matrix.Translate(tempClipRect.Left, tempClipRect.Top, 0.0f);
                            mImage2D.SetUV(uvData, rc.ImmCommandList);
                            mImage2D.SetVertexBuffer(posData, rc.ImmCommandList);

                            mForceUpdateFrame = false;
                        }
                }
            }
        }
Exemplo n.º 2
0
        async Task InitViewport(EditorCommon.ViewPort.ViewPortControl vpCtrl)
        {
            if (mViewPortInited)
            {
                return;
            }
            mViewPortInited = true;
            var rc = EngineNS.CEngine.Instance.RenderContext;

            mRP_EditorMobile = new EngineNS.Graphics.RenderPolicy.CGfxRP_EditorMobile();
            var width  = (uint)vpCtrl.GetViewPortWidth();
            var height = (uint)vpCtrl.GetViewPortHeight();
            await mRP_EditorMobile.Init(rc, width, height, Viewport.Camera, vpCtrl.DrawHandle);

            vpCtrl.RPolicy = mRP_EditorMobile;

            mRP_EditorMobile.mHitProxy.mEnabled = false;

            Viewport.SizeChanged += Viewport_SizeChanged;
            vpCtrl.TickLogicEvent = Viewport_TickLogic;
            Viewport.SetDrawPanelMouseWheelCallback(Viewport_MouseWheel);
            Viewport.SetDrawPanelMouseDownCallback(Viewport_MouseDown);
            Viewport.SetDrawPanelMouseUpCallback(Viewport_MouseUp);
            Viewport.SetDrawPanelMouseMoveCallback(Viewport_MouseMove);
            Viewport.SetDrawPanelDragEnterCallback(Viewport_DragEnter);
            Viewport.SetDrawPanelDragLeaveCallback(Viewport_DragLeave);
            Viewport.SetDrawPanelDragOverCallback(Viewport_DragOver);
            Viewport.SetDrawPanelDragDropCallback(Viewport_DragDrop);
        }
Exemplo n.º 3
0
 public void BindViewPort(EditorCommon.ViewPort.ViewPortControl viewport)
 {
     mViewport              = viewport;
     viewport.DAddActor    -= Viewport_DAddActor;
     viewport.DAddActor    += Viewport_DAddActor;
     viewport.DRemoveActor -= Viewport_DRemoveActor;
     viewport.DRemoveActor += Viewport_DRemoveActor;
 }
Exemplo n.º 4
0
        public async System.Threading.Tasks.Task OnDragLeaveViewport(EditorCommon.ViewPort.ViewPortControl viewport, EventArgs e)
        {
            if (mPreviewActor != null)
            {
                await mPreviewActor.AwaitLoad();
            }

            viewport.World.RemoveActor(mPreviewActor.mPreviewActor.ActorId);
            viewport.World.DefaultScene.RemoveActor(mPreviewActor.mPreviewActor.ActorId);
        }
Exemplo n.º 5
0
        public async System.Threading.Tasks.Task OnDragOverViewport(EditorCommon.ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e)
        {
            if (mPreviewActor != null)
            {
                await mPreviewActor.AwaitLoad();
            }

            var viewPortPos = viewport.PointFromScreen(new System.Windows.Point(e.X, e.Y));
            var pos         = viewport.GetPickRayLineCheckPosition((float)viewPortPos.X, (float)viewPortPos.Y);

            mPreviewActor.mPreviewActor.Placement.Location = pos;
        }
Exemplo n.º 6
0
        public async System.Threading.Tasks.Task OnMainWindowCreated(EditorCommon.ViewPort.ViewPortControl editViewport)
        {
            if (EditorInited == true)
            {
                return;
            }
            EditorInited = true;

            var gameDesc = new EngineNS.Editor.CEditorInstanceDesc();

            gameDesc.SceneName = gameDesc.DefaultMapName;

            await InitDefaultResource(gameDesc);

            EngineNS.Thread.Async.TaskLoader.Release(ref WaitContext, this);

            var editor = GameEditorInstance as CEditorInstance;
            await editor?.InitEditor(editViewport, gameDesc);
        }
Exemplo n.º 7
0
        async Task InitViewPort(EditorCommon.ViewPort.ViewPortControl vpCtrl)
        {
            if (mViewPortInited)
            {
                return;
            }
            mViewPortInited = true;
            var rc = EngineNS.CEngine.Instance.RenderContext;

            mRP_EditorMobile = new EngineNS.Graphics.RenderPolicy.CGfxRP_EditorMobile();
            var width  = (uint)vpCtrl.GetViewPortWidth();
            var height = (uint)vpCtrl.GetViewPortHeight();
            await mRP_EditorMobile.Init(rc, width, height, Viewport.Camera, vpCtrl.DrawHandle);

            vpCtrl.RPolicy = mRP_EditorMobile;

            mRP_EditorMobile.mHitProxy.mEnabled = false;

            vpCtrl.TickLogicEvent = Viewport_TickLogic;
        }
Exemplo n.º 8
0
        public async System.Threading.Tasks.Task OnDragDropViewport(EditorCommon.ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e)
        {
            GParticleComponent component = new GParticleComponent();
            var param = new EngineNS.Editor.PlantableItemCreateActorParam()
            {
                Location = new EngineNS.Vector3(0, 0, 0),
            };
            var dropActor = await component.CreateActor(param, this.ResourceName);

            //var dropActor = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(this.ResourceName);
            dropActor.SpecialName = EngineNS.GamePlay.SceneGraph.GSceneGraph.GeneratorActorSpecialNameInEditor(this.ResourceName.PureName(), viewport.World);
            EngineNS.CEngine.Instance.HitProxyManager.MapActor(dropActor);
            var viewPortPos = viewport.PointFromScreen(new System.Windows.Point(e.X, e.Y));
            var pos         = viewport.GetPickRayLineCheckPosition((float)viewPortPos.X, (float)viewPortPos.Y);

            dropActor.Placement.Location = pos;
            var selActors = new List <EditorCommon.ViewPort.ViewPortControl.SelectActorData>(viewport.GetSelectedActors());

            var redoAction = new Action <object>((obj) =>
            {
                viewport.World.AddActor(dropActor);
                viewport.World.DefaultScene.AddActor(dropActor);
                viewport.SelectActor(dropActor);
            });

            redoAction.Invoke(null);
            EditorCommon.UndoRedo.UndoRedoManager.Instance.AddCommand("WorldEditOperation", null, redoAction, null, (obj) =>
            {
                viewport.World.RemoveActor(dropActor.ActorId);
                viewport.World.DefaultScene.RemoveActor(dropActor.ActorId);
                dropActor.Selected = false;
                viewport.SelectActors(selActors.ToArray());
            }, "添加对象");

            if (mPreviewActor != null)
            {
                await mPreviewActor.AwaitLoad();
            }
            viewport.World.RemoveActor(mPreviewActor.mPreviewActor.ActorId);
            viewport.World.DefaultScene.RemoveActor(mPreviewActor.mPreviewActor.ActorId);
        }
Exemplo n.º 9
0
        public async System.Threading.Tasks.Task OnDragEnterViewport(EditorCommon.ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e)
        {
            if (mPreviewActor != null)
            {
                await mPreviewActor.AwaitLoad();
            }
            else
            {
                mPreviewActor = new EditorCommon.ViewPort.PreviewActorContainer();
                GParticleComponent component = new GParticleComponent();
                var param = new EngineNS.Editor.PlantableItemCreateActorParam()
                {
                    Location = new EngineNS.Vector3(0, 0, 0),
                };
                mPreviewActor.mPreviewActor = await component.CreateActor(param, this.ResourceName);

                var viewPortPos = viewport.PointFromScreen(new System.Windows.Point(e.X, e.Y));
                var pos         = viewport.GetPickRayLineCheckPosition((float)viewPortPos.X, (float)viewPortPos.Y);
                mPreviewActor.mPreviewActor.Placement.Location = pos;
                mPreviewActor.ReleaseWaitContext();
            }
            mPreviewActor.mPreviewActor.Tag = new EditorCommon.Controls.Outliner.InvisibleInOutliner();
            viewport.AddActor(mPreviewActor.mPreviewActor);
        }
Exemplo n.º 10
0
        void Viewport_TickLogic(EditorCommon.ViewPort.ViewPortControl vpc)
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;

            if (vpc.World != null)
            {
                vpc.World.CheckVisible(rc.ImmCommandList, vpc.Camera);
                vpc.World.Tick();
            }
            vpc.RPolicy.TickLogic(null, rc);

            var idMat = EngineNS.Matrix.Identity;

            mGridlineImage2D?.UpdateForEditerMode(rc);

            //EngineNS.SizeF tagDesignSize;
            //var scale = EngineNS.CEngine.Instance.UIManager.Config.GetDPIScaleAndDesignSize(mWindowDesignSize.Width, mWindowDesignSize.Height, out tagDesignSize);
            var scale = 1.0f;

            mWindowRectUIShow?.Commit(rc.ImmCommandList, ref idMat, 1.0f);

            UpdatePanelRectsShow();
            foreach (var rect in mPanelRectsShow.Values)
            {
                rect.Commit(rc.ImmCommandList, ref idMat, 1.0f);
            }

            HostDesignPanel?.CurrentUI?.Commit(rc.ImmCommandList, ref mControlRenderMat, scale);
            mMousePointAtUIRectShow?.Commit(rc.ImmCommandList, ref idMat, 1.0f);
            UpdateSelectedRectShow();
            foreach (var data in mSelectedUIDatas.Values)
            {
                data.ShowRect?.Commit(rc.ImmCommandList, ref idMat, 1.0f);
            }
            mSlotOperator?.Commit(rc.ImmCommandList);
        }
Exemplo n.º 11
0
        public async System.Threading.Tasks.Task InitEditor(MainWindow window, EngineNS.GamePlay.GGameInstanceDesc desc)
        {
            var RHICtx = EngineNS.CEngine.Instance.RenderContext;
            await EngineNS.CEngine.Instance.OnEngineInited();

            await InitGame(desc);

            MainEdViewport = window.MainCtrl.VP1;
            MainEdViewport.InitEnviroment();

            Vector3 Eye = new Vector3();

            Eye.SetValue(0.0f, 1.5f, -3.6f);
            Vector3 At = new Vector3();

            At.SetValue(0.0f, 1.0f, 0.0f);
            Vector3 Up = new Vector3();

            Up.SetValue(0.0f, 1.0f, 0.0f);
            MainEdViewport.Camera.LookAtLH(Eye, At, Up);

            MainEdViewport.World = this.World;
            //MainEdViewport.RPolicy = new EngineNS.Graphics.CGfxRPolicy_Default();
            MainEdViewport.RPolicy = new EngineNS.Graphics.RenderPolicy.CGfxRP_UFOMobile();
            //MainEdViewport.RPolicy = new EngineNS.Graphics.RenderPolicy.CGfxRP_UFOMobileNPR();


            //((EngineNS.Graphics.CGfxRPolicy_Default)MainEdViewport.RPolicy).Init(RHICtx, (uint)MainEdViewport.GetWidth(), (uint)MainEdViewport.GetHeight(), MainEdViewport.Camera, MainEdViewport.DrawHandle);
            ((EngineNS.Graphics.RenderPolicy.CGfxRP_UFOMobile)MainEdViewport.RPolicy).Init(RHICtx, (uint)MainEdViewport.GetWidth(), (uint)MainEdViewport.GetHeight(), MainEdViewport.Camera, MainEdViewport.DrawHandle);
            //((EngineNS.Graphics.RenderPolicy.CGfxRP_UFOMobileNPR)MainEdViewport.RPolicy).Init(RHICtx, (uint)MainEdViewport.GetWidth(), (uint)MainEdViewport.GetHeight(), MainEdViewport.Camera, MainEdViewport.DrawHandle);


            MainEdViewport.TickLogicEvent = TickMainEdViewport;


            //var fbxName = RName.GetRName("Mesh/text.fbx");
            //CreateFromFBX(fbxName);
            //fbxName = RName.GetRName("Mesh/batmanrun.fbx");
            //CreateFromFBX(fbxName);

            //TheBox = await CreateMeshActorAsync(this.World, desc.SceneName
            //    , RName.GetRName("Mesh/tutor_elf_majestic.gms")
            //    , new Vector3(0, -0.5f, -5.0f)
            //    , new Vector3(1, 1, 1) * 0.01f);

            var meshes = new List <RName>()
            {
                RName.GetRName("Mesh/mannequin_geo_arm_l.gms"),
                RName.GetRName("Mesh/mannequin_geo_arm_r.gms"),
                RName.GetRName("Mesh/mannequin_geo_calf_l.gms"),
                RName.GetRName("Mesh/mannequin_geo_calf_r.gms"),
                RName.GetRName("Mesh/mannequin_geo_chest.gms"),
                RName.GetRName("Mesh/mannequin_geo_foot_l.gms"),
                RName.GetRName("Mesh/mannequin_geo_foot_r.gms"),
                RName.GetRName("Mesh/mannequin_geo_forearm_l.gms"),
                RName.GetRName("Mesh/mannequin_geo_forearm_r.gms"),
                RName.GetRName("Mesh/mannequin_geo_hand_l.gms"),
                RName.GetRName("Mesh/mannequin_geo_hand_r.gms"),
                RName.GetRName("Mesh/mannequin_geo_head.gms"),
                RName.GetRName("Mesh/mannequin_geo_logo.gms"),
                RName.GetRName("Mesh/mannequin_geo_lower_torso.gms"),
                RName.GetRName("Mesh/mannequin_geo_neck.gms"),
                RName.GetRName("Mesh/mannequin_geo_pelvis.gms"),
                RName.GetRName("Mesh/mannequin_geo_thigh_l.gms"),
                RName.GetRName("Mesh/mannequin_geo_thigh_r.gms"),
            };

            {
                ActorRoom = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName("Mesh/room.gms"));

                ActorRoom.Placement.Location = new Vector3(0.0f, 0.0f, 0.0f);
                ActorRoom.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, 0.0f);
                ActorRoom.Placement.Scale   /= 40.0f;
                this.World.AddActor(ActorRoom);
                this.World.Scenes[desc.SceneName].AddActor(ActorRoom);


                ActorFont0 = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName("Mesh/text.gms"));

                ActorFont0.Placement.Location = new Vector3(0.0f, 1.8f, 3.0f);
                ActorFont0.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitX, 3.14f);
                ActorFont0.Placement.Scale   /= 100.0f;
                this.World.AddActor(ActorFont0);
                this.World.Scenes[desc.SceneName].AddActor(ActorFont0);


                ActorBeauty0 = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName("Mesh/tutor_elf_majestic.gms"));

                ActorBeauty0.Placement.Location = new Vector3(-2.5f, 0.0f, 0.0f);
                ActorBeauty0.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, 1.57f);
                ActorBeauty0.Placement.Scale   /= 100;
                this.World.AddActor(ActorBeauty0);
                this.World.Scenes[desc.SceneName].AddActor(ActorBeauty0);


                ActorBeauty1 = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName("Mesh/tutor_elf_majestic.gms"));

                ActorBeauty1.Placement.Location = new Vector3(-1.5f, 0.0f, 0.0f);
                ActorBeauty1.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, -1.57f);
                ActorBeauty1.Placement.Scale   /= 100;
                this.World.AddActor(ActorBeauty1);
                this.World.Scenes[desc.SceneName].AddActor(ActorBeauty1);


                ActorBeautyNew0 = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName("Mesh/meimei.gms"));

                ActorBeautyNew0.Placement.Location = new Vector3(1.5f, 0.0f, 0.0f);
                ActorBeautyNew0.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, 1.57f);
                ActorBeautyNew0.Placement.Scale   /= 40;
                this.World.AddActor(ActorBeautyNew0);
                this.World.Scenes[desc.SceneName].AddActor(ActorBeautyNew0);

                ActorBeautyNew1 = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName("Mesh/meimei.gms"));

                ActorBeautyNew1.Placement.Location = new Vector3(2.5f, 0.0f, 0.0f);
                ActorBeautyNew1.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, -1.57f);
                ActorBeautyNew1.Placement.Scale   /= 40;
                this.World.AddActor(ActorBeautyNew1);
                this.World.Scenes[desc.SceneName].AddActor(ActorBeautyNew1);


                ActorBeautyNew2 = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName("Mesh/mm.gms"));

                ActorBeautyNew2.Placement.Location = new Vector3(3.5f, 0.0f, 0.0f);
                ActorBeautyNew2.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, 1.57f);
                ActorBeautyNew2.Placement.Scale   /= 40;
                this.World.AddActor(ActorBeautyNew2);
                this.World.Scenes[desc.SceneName].AddActor(ActorBeautyNew2);

                ActorBeautyNew3 = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName("Mesh/mm.gms"));

                ActorBeautyNew3.Placement.Location = new Vector3(4.5f, 0.0f, 0.0f);
                ActorBeautyNew3.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, -1.57f);
                ActorBeautyNew3.Placement.Scale   /= 40;
                this.World.AddActor(ActorBeautyNew3);
                this.World.Scenes[desc.SceneName].AddActor(ActorBeautyNew3);

                ActorBeautyNew4 = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName("Mesh/mmhair05.gms"));

                ActorBeautyNew4.Placement.Location = new Vector3(0.5f, 0.0f, 0.0f);
                ActorBeautyNew4.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, -1.57f);
                ActorBeautyNew4.Placement.Scale   /= 40;
                this.World.AddActor(ActorBeautyNew4);
                this.World.Scenes[desc.SceneName].AddActor(ActorBeautyNew4);

                ActorBeautyNew5 = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(RName.GetRName("Mesh/mmhair05.gms"));

                ActorBeautyNew5.Placement.Location = new Vector3(-0.5f, 0.0f, 0.0f);
                ActorBeautyNew5.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, 1.57f);
                ActorBeautyNew5.Placement.Scale   /= 40;
                this.World.AddActor(ActorBeautyNew5);
                this.World.Scenes[desc.SceneName].AddActor(ActorBeautyNew5);



                var EyeMesh = await CEngine.Instance.MeshManager.CreateMeshAsync(RHICtx, RName.GetRName("Mesh/sphere001.gms"));

                ActorEye0 = EngineNS.GamePlay.Actor.GActor.NewMeshActor(EyeMesh);
                ActorEye0.Placement.Location = new Vector3(-20.0f, 0.0f, 0.0f);
                ActorEye0.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, 1.57f);
                ActorEye0.Placement.Scale   /= 2;
                this.World.AddActor(ActorEye0);
                this.World.Scenes[desc.SceneName].AddActor(ActorEye0);

                EyeMesh = await CEngine.Instance.MeshManager.CreateMeshAsync(RHICtx, RName.GetRName("Mesh/eye0.gms"));

                ActorEye1 = EngineNS.GamePlay.Actor.GActor.NewMeshActor(EyeMesh);
                ActorEye1.Placement.Location = new Vector3(-24.0f, 0.0f, 0.0f);
                ActorEye1.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, 1.57f);
                ActorEye1.Placement.Scale   /= 1;
                this.World.AddActor(ActorEye1);
                this.World.Scenes[desc.SceneName].AddActor(ActorEye1);

                EyeMesh = await CEngine.Instance.MeshManager.CreateMeshAsync(RHICtx, RName.GetRName("Mesh/eye3.gms"));

                ActorEye2 = EngineNS.GamePlay.Actor.GActor.NewMeshActor(EyeMesh);
                ActorEye2.Placement.Location = new Vector3(-28.0f, 0.0f, 0.0f);
                ActorEye2.Placement.Rotation = Quaternion.RotationAxis(Vector3.UnitY, 1.57f);
                ActorEye2.Placement.Scale   /= 1;
                this.World.AddActor(ActorEye2);
                this.World.Scenes[desc.SceneName].AddActor(ActorEye2);
            }

            //{
            //    await CreateMeshActorAsync(this.World, desc.SceneName
            //        , RName.GetRName("Mesh/kianac5.gms")
            //        , new Vector3(0.0f, 0.0f, 0.0f)
            //        , new Vector3(1, 1, 1));

            //    await CreateMeshActorAsync(this.World, desc.SceneName
            //        , RName.GetRName("Mesh/kianac5.gms")
            //        , new Vector3(1.5f, 0.0f, 0.0f)
            //        , Quaternion.RotationAxis(Vector3.UnitY, 3.14f)
            //        , new Vector3(1, 1, 1));


            //    await CreateMeshActorAsync(this.World, desc.SceneName
            //        , RName.GetRName("Mesh/unitsphere.gms")
            //        , new Vector3(-15.0f, 1.0f, 0.0f)
            //        , new Vector3(1, 1, 1));


            //    var gmsName = RName.GetRName("Mesh/delishatest.gms");
            //    var animationName = RName.GetRName("Mesh/delisha" + CEngineDesc.AnimationSegementExtension);
            //    //var gmsName = RName.GetRName("Mesh/batman_highpoly_1.gms");
            //    //var animationName = RName.GetRName("Mesh/batman_highpoly_1" + CEngineDesc.AnimationSegementExtension);

            //    TheActor = await CreateMeshActorAsync(this.World, desc.SceneName
            //        , gmsName
            //        , new Vector3(8.0f, 0.0f, 0.0f)
            //        , Vector3.UnitXYZ * 0.1f);
            //    var animation = CreateAnimation(TheActor, animationName);
            //    animation.PlayRate = 1.0f;
            //    CreateLegAndFootIK(TheActor);
            //}


            //TheBox = await CreateMeshActorAsync(this.World, desc.SceneName
            //    , RName.GetRName("Mesh/unitbox.gms")
            //    , new Vector3(0, -0.5f, -5.0f)
            //    , new Vector3(10, 1, 10));

            var skyMesh = await CEngine.Instance.MeshManager.CreateMeshAsync(RHICtx, RName.GetRName("Mesh/sky.gms"));

            TheSky = EngineNS.GamePlay.Actor.GActor.NewMeshActor(skyMesh);
            TheSky.Placement.Scale = new Vector3(0.3F, 0.3F, 0.3F);
            this.World.AddActor(TheSky);
            this.World.Scenes[desc.SceneName].AddActor(TheSky);

            //////var particle = new EngineNS.Bricks.Particle.McParticleHelper().CreateParticleActor();
            //////this.World.AddActor(particle);
            //////this.World.Scenes[desc.SceneName].AddActor(particle);

            CEngine.Instance.TickManager.AddTickInfo(this);

            bool doUnitTest = false;

            if (doUnitTest)
            {
                await DoUnitTest();
            }

            //var start = new Vector3(350, 350, 0);
            //var ldr = new EngineNS.Bricks.GraphDrawer.GraphLinesHelper();
            //await ldr.Init(start);
            //LineDrawer = ldr;

            EngineNS.Profiler.NativeMemory.BeginProfile();

            mInitialized = true;
        }
Exemplo n.º 12
0
        public void TickMainEdViewport(EditorCommon.ViewPort.ViewPortControl vpc)
        {
            if (!mInitialized)
            {
                return;
            }
            if (EditorCommon.GamePlay.Instance.IsInPIEMode)
            {
                return;
            }
            //if (vpc.Camera.mSceneView == null)
            //    return;

            //if(testDoing==false)
            //{
            //    TestAwait();
            //}

            var RHICtx = EngineNS.CEngine.Instance.RenderContext;

            //Vector3 Eye = new Vector3();
            //Eye.SetValue(0.0f, 1.5f, -15.0f);
            //Vector3 At = new Vector3();
            //At.SetValue(0.0f, 1.0f, 0.0f);
            //Vector3 Up = new Vector3();
            //Up.SetValue(0.0f, 1.0f, 0.0f);
            //vpc.Camera.LookAtLH(Eye, At, Up);

            this.World.CheckVisible(RHICtx, vpc.Camera);
            this.World.Tick();
            vpc.RPolicy?.TickLogic(vpc.Camera.mSceneView, RHICtx);

            if (true)
            {
                t += (float)EngineNS.MathHelper.V_PI * 0.0125f * EngineNS.CEngine.Instance.EngineElapseTime / 1000;

                //TheActor.Placement.Rotation = EngineNS.Quaternion.RotationAxis(EngineNS.Vector3.UnitY, t);

                //if (TheBox.Placement.Location.X < 1)
                //    dir.X = -dir.X;
                //if (TheBox.Placement.Location.X > 4)
                //    dir.X = -dir.X;
                //if (TheBox.Placement.Location.Z < 1)
                //    dir.Z = -dir.Z;
                //if (TheBox.Placement.Location.Z > 4)
                //    dir.Z = -dir.Z;



                //TheBox.Placement.Location += dir * 0.08f;
                //lookAt.TargetPosition = TheBox.Placement.Location;
                //var trans = TheActor.Placement.Transform;
                //trans.Inverse();
                //var absLoc = TheBox.Placement.Location;
                //var loc = Vector3.TransformCoordinate(absLoc, trans);
                //ccdIk.TargetPosition = loc;



                // var meshComp = TheActor.GetComponent<EngineNS.GamePlay.Component.GMeshComponent>();
                //var varIndex = meshComp.mSceneMesh.FindVar(0, "vMeshColor");

                //var vMeshColor = new EngineNS.Color4(1.0f, (float)System.Math.Sin(t), 0.7f, 0.7f);
                //meshComp.mSceneMesh.SetVar(0, varIndex, vMeshColor, 0);

                //var skinModifier = meshComp.mSceneMesh.MdfQueue.FindModifier<EngineNS.Graphics.Mesh.CGfxSkinModifier>();
                //if (skinModifier != null)
                //{
                //    skinModifier.SetToRenderStream(meshComp.mSceneMesh);
                //    //var animBlender = skinModifier.Skeleton.AnimBlender;
                //    //if (animBlender != null)
                //    //{
                //    //    animBlender.UpdateNodes(EngineNS.CEngine.Instance.EngineTime);
                //    //    animBlender.BlendActions();
                //    //    //skinModifier.Skeleton.SetTransforms(meshComp.mSceneMesh);
                //    //}
                //}

                //unsafe
                //{
                //    varIndex = meshComp.mSceneMesh.FindVar(0, "PLight");
                //    if (varIndex > 0)
                //    {
                //        LightStruct light = new LightStruct();
                //        light.Shiness = 1;

                //        meshComp.mSceneMesh.SetVarValue(0, varIndex, &light, sizeof(LightStruct), 0);
                //    }
                //}
                if (vpc.Camera.mSceneView != null && LineDrawer != null)
                {
                    var pass = LineDrawer.CreateRenderPass(vpc.Camera.mSceneView);
                    pass.ViewPort = vpc.Camera.mSceneView.Viewport;
                    vpc.Camera.mSceneView.SendPassToCorrectRenderLayer(EngineNS.Graphics.ERenderLayer.RL_Translucent, pass);
                }
            }

            if (DoCaptureMemory)
            {
                var memStat = EngineNS.Profiler.NativeMemory.CurrentProfiler.CaptureMemory();
                DoCaptureMemory = false;
                if (mPrevStat != null)
                {
                    var delta = EngineNS.Profiler.NativeMemory.CurrentProfiler.GetDelta(mPrevStat, memStat);
                    foreach (var i in delta)
                    {
                        System.Diagnostics.Debug.WriteLine($"{i.Key}: Size={i.Value.Size};Count={i.Value.Count}");
                    }
                }
                mPrevStat = memStat;

                System.Diagnostics.Debug.WriteLine($"Total Alloc Count = {EngineNS.Profiler.NativeMemory.CurrentProfiler.TotalCount - TotalAllocCount}");
                TotalAllocCount = EngineNS.Profiler.NativeMemory.CurrentProfiler.TotalCount;
            }
        }