Beispiel #1
0
        public override void Update(uint frame)
        {
            if (!WaterSceneNode.Visible)
                return;

            Reference.Viewer.AvatarManager.VisibleName(false);

            float waterheight = 0;
            if (Reference.Viewer.ProtocolManager.AvatarConnection.m_user.Network.CurrentSim != null)
            {
                waterheight = Reference.Viewer.ProtocolManager.AvatarConnection.m_user.Network.CurrentSim.WaterHeight;
            }
            WaterSceneNode.Position = new Vector3D(128, waterheight, 128);
            WaterSceneNode.Visible = false;

            // *****************************************
            // REFRACTION MAP
            // *****************************************
            Reference.VideoDriver.SetRenderTarget(RefractionMap, true, true, Color.Blue);
            Plane3Df refractionClipPlane = new Plane3Df(0, WaterSceneNode.Position.Y + 0.1f, 0, 0, -1, 0);
            Reference.VideoDriver.SetClipPlane(0, refractionClipPlane, true);

            try
            {
                Reference.SceneManager.DrawAll();
            }
            catch (AccessViolationException)
            {
                VUtil.LogConsole(this.ToString() + "[ACCESSVIOLATION]", "Update REFRACTION MAP");
            }

            // *****************************************
            // REFLECTION MAP
            // *****************************************
            Reference.VideoDriver.SetRenderTarget(ReflectionMap, true, true, Color.Blue);
            CameraSceneNode currentCamera = Reference.SceneManager.ActiveCamera;
            Camera.FarValue = currentCamera.FarValue;
            Camera.FOV = currentCamera.FOV;

            Vector3D position = currentCamera.Position;
            position.Y = -position.Y + 2 * WaterSceneNode.Position.Y;
            Camera.Position = position;

            Vector3D target = currentCamera.Target;
            target.Y = -target.Y + 2 * WaterSceneNode.Position.Y;
            Camera.Target = target;

            Reference.SceneManager.ActiveCamera = Camera;

            Plane3Df reflectionClipPlane = new Plane3Df(0, WaterSceneNode.Position.Y - 0.1f, 0, 0, 1, 0);
            Reference.VideoDriver.SetClipPlane(0, reflectionClipPlane, true);

            try
            {
                Reference.SceneManager.DrawAll();
            }
            catch (AccessViolationException)
            {
                VUtil.LogConsole(this.ToString() + "[ACCESSVIOLATION]", "Update REFLECTION MAP");
            }

            // *****************************************
            // RESUME
            // *****************************************
            Reference.SceneManager.ActiveCamera = currentCamera;
            Reference.VideoDriver.SetRenderTarget(null, true, true, Color.White);
            Reference.VideoDriver.EnableClipPlane(0, false);

            WaterSceneNode.Visible = true;

            Reference.Viewer.AvatarManager.VisibleName(true);

            base.Update(frame);
        }
Beispiel #2
0
 public bool SetClipPlane(int index, Plane3Df plane, bool enable)
 {
     return VideoDriver_SetClipPlane(_raw, index, plane.ToUnmanaged(), enable);
 }