Пример #1
0
        public void PreProcessChunks()
        {
            Profiler.BeginSample("PreProcessChunks");

            // Recalculate camera frustum planes
            Planes.CalculateFrustumPlanes(m_camera, m_cameraPlanes);

            // Update clipmap based on range values
            UpdateRanges();

            // Update viewer position
            UpdateViewerPosition();

            Profiler.EndSample();
        }
Пример #2
0
        void Update()
        {
            // Rotation
            if (Input.GetMouseButton(1))
            {
                rot = new Vector2(
                    rot.x + Input.GetAxis("Mouse X") * 3,
                    rot.y + Input.GetAxis("Mouse Y") * 3
                    );

                cam.transform.localRotation  = Quaternion.AngleAxis(rot.x, Vector3.up);
                cam.transform.localRotation *= Quaternion.AngleAxis(rot.y, Vector3.left);
            }

            //Movement
            bool turbo = Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift);

            cam.transform.position += cam.transform.forward * 40 * (turbo ? 3 : 1) * Input.GetAxis("Vertical") * Time.deltaTime;
            cam.transform.position += cam.transform.right * 40 * (turbo ? 3 : 1) * Input.GetAxis("Horizontal") * Time.deltaTime;

            if (objRenderer != null && txt != null)
            {
                Planes.CalculateFrustumPlanes(cam, planes);
                Bounds b = objRenderer.bounds;
                Planes.TestPlanesResult res = Planes.TestPlanesAABB2(planes, ref b);
                switch (res)
                {
                case Planes.TestPlanesResult.Outside:
                    txt.text = "Outside";
                    break;

                case Planes.TestPlanesResult.Inside:
                    txt.text = "Inside";
                    break;

                default:
                    txt.text = "PartialyInside";
                    break;
                }
            }
        }
Пример #3
0
        public void PreProcessChunks()
        {
            Profiler.BeginSample("PreProcessChunks");

            // Recalculate camera frustum planes
            Planes.CalculateFrustumPlanes(m_camera, m_cameraPlanes);

            // Update clipmap based on range values
            UpdateRanges();

            // Update viewer position
            UpdateViewerPosition();

            // Update clipmap offsets based on the viewer position
            m_clipmap.SetOffset(
                m_viewerPos.x / Env.ChunkSize,
                m_viewerPos.y / Env.ChunkSize,
                m_viewerPos.z / Env.ChunkSize
                );


            Profiler.EndSample();
        }