Ejemplo n.º 1
0
        public void OnCheckVisible(CCommandList cmd, GSceneGraph scene, CGfxCamera camera, CheckVisibleParam param)
        {
            if (HostSet == null)
            {
                throw new InvalidOperationException("");
            }
            var bitSet = HostSet.PvsData[PvsIndex];

            if (scene.PVSActors != null && scene.PVSActors.Length == bitSet.BitCount)
            {
                for (int i = 0; i < bitSet.BitCount; i++)
                {
                    if (!bitSet.IsBit(i))
                    {
                        continue;
                    }

                    Actor.GActor actor = scene.PVSActors[i];
                    if (actor.NeedCheckVisible(param) == false)
                    {
                        continue;
                    }
                    if (param.FrustumCulling && actor.CheckContain(camera.CullingFrustum, true) == CGfxCamera.CFrustum.CONTAIN_TYPE.CONTAIN_TEST_OUTER)
                    {
                        continue;
                    }

                    actor.OnCheckVisible(cmd, scene, camera, param);
                }
            }
        }
Ejemplo n.º 2
0
 public void AddScene(RName name, SceneGraph.GSceneGraph sg)
 {
     lock (Scenes)
     {
         Scenes.Add(name, sg);
     }
 }
Ejemplo n.º 3
0
        public void Cleanup()
        {
            var it = Scenes.Values.GetEnumerator();

            while (it.MoveNext())
            {
                it.Current.Cleanup();
            }
            it.Dispose();
            Scenes.Clear();

            var it2 = Actors.Values.GetEnumerator();

            while (it2.MoveNext())
            {
                it2.Current.OnRemoveWorld(this);
            }
            it2.Dispose();
            Actors.Clear();
            Cleanup_Editor();
            mDefaultScene = null;
        }
Ejemplo n.º 4
0
 public void SetDefaultScene(Guid sceneId)
 {
     mDefaultScene = FindScene(sceneId);
 }
Ejemplo n.º 5
0
 public virtual void OnSceneCleanup(GSceneGraph scene)
 {
 }
Ejemplo n.º 6
0
 public virtual void OnSceneTick(GSceneGraph scene)
 {
 }
Ejemplo n.º 7
0
 public virtual async System.Threading.Tasks.Task OnSceneLoaded(GSceneGraph scene)
 {
     await Thread.AsyncDummyClass.DummyFunc();
 }
Ejemplo n.º 8
0
        public virtual async System.Threading.Tasks.Task <bool> InitEnvWithScene(UInt32 w, UInt32 h,
                                                                                 [Editor.Editor_RNameType(Editor.Editor_RNameTypeAttribute.Scene)]
                                                                                 RName map, bool startDraw = true)
        {
            if (w == 0)
            {
                w = 128;
            }
            if (h == 0)
            {
                h = 128;
            }
            if (map == null)
            {
                map = RName.EmptyName;
            }
            mWidth  = w;
            mHeight = h;
            var rc = EngineNS.CEngine.Instance.RenderContext;

            mCamera = new EngineNS.Graphics.CGfxCamera();
            mCamera.Init(rc, false);

            mCamera.PerspectiveFovLH(mCamera.mDefaultFoV, (float)mWidth, (float)mHeight, 0.1f, 1000.0f);
            mCamera.BeforeFrame();
            //mCamera.SwapBuffer(false);

            Vector3 Eye = new Vector3();

            Eye.SetValue(0.0f, 50.0f, -30.0f);
            Vector3 At = new Vector3();

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

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

            mRP_OffScreen           = new EngineNS.Graphics.RenderPolicy.CGfxRP_OffScreen();
            mRP_OffScreen.OnDrawUI += (CCommandList cmd, Graphics.View.CGfxScreenView view) =>
            {
                if (UIHost != null)
                {
                    UIHost.Draw(CEngine.Instance.RenderContext, cmd, view);
                }
            };
            await mRP_OffScreen.Init(rc, mWidth, mHeight, mCamera, IntPtr.Zero);

            UIHost.Initializer.Id = 1;
            UIHost.WindowSize     = new SizeF(mWidth, mHeight);

            mWorld = new EngineNS.GamePlay.GWorld();

            if (false == mWorld.Init())
            {
                return(false);
            }

            mWorld.CheckVisibleParam.UsePVS = false;
            SceneGraph.GSceneGraph scene = null;
            IO.XndHolder           xnd   = await IO.XndHolder.LoadXND(map.Address + "/scene.map");

            if (xnd == null)
            {
                scene = await GamePlay.SceneGraph.GSceneGraph.CreateSceneGraph(this.World, typeof(GamePlay.SceneGraph.GSceneGraph), new SceneGraph.GSceneGraphDesc());

                mWorld.AddScene(map, scene);
            }
            else
            {
                var type = Rtti.RttiHelper.GetTypeFromSaveString(xnd.Node.GetName());
                if (type == null)
                {
                    return(false);
                }
                scene = await GamePlay.SceneGraph.GSceneGraph.CreateSceneGraph(this.World, type, null);

                if (false == await scene.LoadXnd(rc, xnd.Node, map))
                {
                    return(false);
                }

                if (scene != null)
                {
                    World.AddScene(map, scene);
                    mWorld.SetDefaultScene(scene.SceneId);

                    if (mWorld.DefaultScene.SunActor != null)
                    {
                        var sunComp = mWorld.DefaultScene?.SunActor.GetComponent <EngineNS.GamePlay.Component.GDirLightComponent>();
                        if (sunComp != null)
                        {
                            sunComp.View = mRP_OffScreen.BaseSceneView;
                        }
                    }
                    if (scene.McSceneGetter != null && scene.McSceneGetter.Get(false) != null)
                    {
                        await scene.McSceneGetter.Get(false).OnSceneLoaded(scene);

                        scene.McSceneGetter.Get(false).OnRegisterInput();
                    }
                }
            }

            if (startDraw)
            {
                this.Start();
            }

            return(true);
        }