Exemple #1
0
 /// <summary>
 /// Configures the game engine placeholder.
 /// </summary>
 void FakeEngine()
 {
     CWindow = new GameClientWindow("SHOULD NEVER SHOW", true)
     {
         Textures    = Textures,
         Models      = Models,
         Animations  = Animations,
         Shaders     = Shaders,
         Rendering3D = Rendering,
         Files       = Files,
         FontSets    = FontSets,
         GLFonts     = Fonts,
         Window      = Window
     };
     CWindow.MainUI              = new ViewUI2D(CWindow);
     CWindow.Engine3D.MainView   = MainWorldView;
     CWindow.Engine3D.ZFar       = ZFar;
     CWindow.Engine3D.ZFarOut    = ZFarOut;
     CWindow.Engine3D.AllowLL    = AllowLL;
     CWindow.Engine3D.Sounds     = Sounds;
     CWindow.Engine3D.FogMaxDist = FogMaxDist;
     Engine = CWindow.Engine3D;
     CVars.r_dynamicshadows.OnChanged += (o, e) => Engine.EnableDynamicShadows = CVars.r_dynamicshadows.ValueB;
     CVars.r_dynamicshadows.OnChanged(null, null);
     CVars.r_znear.OnChanged += (o, e) => Engine.ZNear = CVars.r_znear.ValueF;
     CVars.r_znear.OnChanged(null, null);
     CVars.r_fov.OnChanged += (o, e) => Engine.FOV = CVars.r_fov.ValueF;
     CVars.r_fov.OnChanged(null, null);
     CVars.r_decals.OnChanged += (o, e) => Engine.DisplayDecals = CVars.r_decals.ValueB;
     CVars.r_decals.OnChanged(null, null);
     CVars.r_forwardreflections.OnChanged += (o, e) => Engine.ForwardReflections = CVars.r_forwardreflections.ValueB;
     CVars.r_forwardreflections.OnChanged(null, null);
     CVars.r_forward_lights.OnChanged += (o, e) => Engine.Forward_Lights = CVars.r_forward_lights.ValueB;
     CVars.r_forward_lights.OnChanged(null, null);
     CVars.r_forward_shadows.OnChanged += (o, e) => Engine.Forward_Shadows = CVars.r_forward_shadows.ValueB;
     CVars.r_forward_shadows.OnChanged(null, null);
     CVars.r_forward_normals.OnChanged += (o, e) => Engine.Forward_Normals = CVars.r_forward_normals.ValueB;
     CVars.r_forward_normals.OnChanged(null, null);
     CVars.r_exposure.OnChanged += (o, e) => Engine.Exposure = CVars.r_exposure.ValueF;
     CVars.r_exposure.OnChanged(null, null);
     CVars.r_brighttransp.OnChanged += (o, e) => Engine.Deferred_BrightTransp = CVars.r_brighttransp.ValueB;
     CVars.r_brighttransp.OnChanged(null, null);
     CVars.r_grayscale.OnChanged += (o, e) => Engine.Deferred_Grayscale = CVars.r_grayscale.ValueB;
     CVars.r_grayscale.OnChanged(null, null);
     CVars.r_toonify.OnChanged += (o, e) => Engine.Deferred_Toonify = CVars.r_toonify.ValueB;
     CVars.r_toonify.OnChanged(null, null);
     CVars.r_motionblur.OnChanged += (o, e) => Engine.Deferred_MotionBlur = CVars.r_motionblur.ValueB;
     CVars.r_motionblur.OnChanged(null, null);
     CVars.r_ssao.OnChanged += (o, e) => Engine.Deferred_SSAO = CVars.r_ssao.ValueB;
     CVars.r_ssao.OnChanged(null, null);
     CVars.r_shadows.OnChanged += (o, e) => Engine.Deferred_Shadows = CVars.r_shadows.ValueB;
     CVars.r_shadows.OnChanged(null, null);
     CVars.r_hdr.OnChanged += (o, e) => Engine.Deferred_HDR = CVars.r_hdr.ValueB;
     CVars.r_hdr.OnChanged(null, null);
     CVars.r_transplighting.OnChanged += (o, e) => Engine.Deferred_TransparentLights = CVars.r_transplighting.ValueB;
     CVars.r_transplighting.OnChanged(null, null);
     CVars.r_lighting.OnChanged += (o, e) => Engine.Deferred_Lights = CVars.r_lighting.ValueB;
     CVars.r_lighting.OnChanged(null, null);
     // TODO: Update SunAdjust data
 }
Exemple #2
0
        /// <summary>
        /// Calculates the texture update.
        /// </summary>
        /// <param name="cont">The controller.</param>
        /// <param name="timeNow">The current time.</param>
        /// <param name="tclient">The game client.</param>
        public void CalcTexture(VRController cont, double timeNow, GameClientWindow tclient)
        {
            if (timeNow == CTime)
            {
                return;
            }
            CTime = timeNow;
            tclient.Shaders.ColorMultShader.Bind();
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, FBO);
            GL.Disable(EnableCap.CullFace);
            GL.Viewport(0, 0, 512, 512);
            GL.ClearBuffer(ClearBuffer.Color, 0, new float[] { 0.5f, 0.5f, 0.5f, 1.0f });
            GL.ActiveTexture(TextureUnit.Texture0);
            BaseTexture.Bind();
            Matrix4 basic = Matrix4.CreateOrthographicOffCenter(-1, 1, -1, 1, -1, 1);

            GL.UniformMatrix4(1, false, ref basic);
            GL.UniformMatrix4(2, false, ref id);
            tclient.Engine3D.Rendering.RenderRectangle(-1, -1, 1, 1);
            bool touched = cont.Touched.HasFlag(VRButtons.TRACKPAD);
            bool pressed = cont.Pressed.HasFlag(VRButtons.TRACKPAD);

            if (touched || pressed)
            {
                BaseTexture.Engine.White.Bind();
                tclient.Engine3D.Rendering.SetColor(pressed ? PressSpotColor : TouchSpotColor, tclient.Engine3D.MainView);
                Vector2 hsize = pressed ? PressSpotHalfSize : TouchSpotHalfSize;
                tclient.Engine3D.Rendering.RenderRectangle(cont.TrackPad.X - hsize.X, cont.TrackPad.Y - hsize.X, cont.TrackPad.X + hsize.X, cont.TrackPad.Y + hsize.Y);
            }
            GL.BindTexture(TextureTarget.Texture2D, 0);
            tclient.Engine3D.Rendering.SetColor(Color4.White, tclient.Engine3D.MainView);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, tclient.Engine3D.MainView.cFBO);
            GL.Enable(EnableCap.CullFace);
            tclient.Engine3D.MainView.FixVP();
        }
 /// <summary>
 /// Prepares the model system.
 /// </summary>
 /// <param name="engine">Animation engine.</param>
 /// <param name="tclient">Backing client.</param>
 public void Init(AnimationEngine engine, GameClientWindow tclient)
 {
     TheClient    = tclient;
     AnimEngine   = engine;
     Handler      = new ModelHandler();
     LoadedModels = new Dictionary <string, Model>(128);
     AddDefaults();
 }
Exemple #4
0
 /// <summary>
 /// Starts the game.
 /// </summary>
 public void Start()
 {
     Client = new GameClientWindow(threed: false);
     Client.Engine2D.UseLightEngine = true;
     Client.OnWindowLoad           += Engine_WindowLoad;
     Client.Engine2D.Zoom           = 0.1f;
     Client.Start();
 }
Exemple #5
0
 /// <summary>
 /// Starts the game.
 /// </summary>
 public void Start()
 {
     Client = new GameClientWindow(threed: true);
     Client.OnWindowLoad                   += Engine_WindowLoad;
     Client.Engine3D.Forward_Shadows        = true;
     Client.Engine3D.EnforceAudio           = false;
     Client.Engine3D.MainView.ShadowTexSize = () => 1024;
     Client.Engine3D.Source                 = this;
     Client.Start(GameWindowFlags.Default);
 }
Exemple #6
0
 /// <summary>
 /// Runs the game.
 /// </summary>
 public void Run()
 {
     // Create a window, 2D mode by default.
     Window = new GameClientWindow(threed: false);
     // Add an event for when the window is set up but not loaded yet.
     Window.OnWindowSetUp += WindowSetup;
     // Add an event to listen for when the window loads.
     Window.OnWindowLoad += WindowLoad;
     // Start the client systems.
     Window.Start();
 }
 /// <summary>
 /// Prepares the model system.
 /// </summary>
 /// <param name="engine">Animation engine.</param>
 /// <param name="tclient">Backing client.</param>
 public void Init(AnimationEngine engine, GameClientWindow tclient)
 {
     TheClient    = tclient;
     AnimEngine   = engine;
     Handler      = new ModelHandler();
     LoadedModels = new List <Model>();
     Cube         = GenerateCube();
     LoadedModels.Add(Cube);
     Cylinder = GetModel("cylinder");
     Sphere   = GetModel("sphere");
 }
 /// <summary>
 /// Prepares the model system.
 /// </summary>
 /// <param name="engine">Animation engine.</param>
 /// <param name="tclient">Backing client.</param>
 public void Init(AnimationEngine engine, GameClientWindow tclient)
 {
     TheClient    = tclient;
     AnimEngine   = engine;
     Handler      = new ModelHandler();
     LoadedModels = new Dictionary <string, Model>(128);
     Cube         = GenerateCube();
     LoadedModels.Add("cube", Cube);
     Cylinder = GetModel("cylinder");
     Sphere   = GetModel("sphere");
 }
Exemple #9
0
        /// <summary>
        /// Tries to initialize VR - returns the VR support object, or null if loading failed.
        /// </summary>
        /// <param name="tclient">The game client.</param>
        /// <returns>VR, if any.</returns>
        public static VRSupport TryInit(GameClientWindow tclient)
        {
            if (!Available())
            {
                return(null);
            }
            EVRInitError err = EVRInitError.None;
            VRSupport    vrs = new VRSupport()
            {
                TheClient = tclient, VR = OpenVR.Init(ref err)
            };

            if (err != EVRInitError.None)
            {
                SysConsole.Output(OutputType.INFO, "VR error: " + err + ": " + OpenVR.GetStringForHmdError(err));
                return(null);
            }
            vrs.Start();
            return(vrs);
        }
Exemple #10
0
 /// <summary>
 /// Constructs a screen that covers a specific portion of the game window.
 /// </summary>
 /// <param name="client">The client game window.</param>
 /// <param name="pos">The position of the element.</param>
 public UIScreen(GameClientWindow client, UIPositionHelper pos) : base(pos)
 {
     _Client = client;
 }