/// <summary> /// Create space camera /// </summary> /// <param name="setCameraPos">Set camera pos</param> public SpaceCamera(BaseGame game, Vector3 setCameraPos) : base(game) { pos = setCameraPos; // Assign keys. Warning: This is VERY slow, never use it // inside any render loop (getting Settings, etc.)! moveLeftKey = GameSettings.Default.MoveLeftKey; moveRightKey = GameSettings.Default.MoveRightKey; moveForwardKey = GameSettings.Default.MoveForwardKey; moveBackwardKey = GameSettings.Default.MoveBackwardKey; //rollLeftKey = GameSettings.Default.RollLeftKey; //rollRightKey = GameSettings.Default.RollRightKey; // Also assign mouse sensibility mouseSensibility = 2.5f - 2.0f * GameSettings.Default.ControllerSensibility; if (mouseSensibility < 0.5f) mouseSensibility = 0.5f; }
/// <summary> /// Create space camera /// </summary> /// <param name="setCameraPos">Set camera pos</param> /// <param name="setLookPos">Set look pos</param> public SpaceCamera(BaseGame game, Vector3 setCameraPos, Vector3 setLookPos) : this(game, setCameraPos) { // Calculate rotation quaternion from look pos SetLookAt(setCameraPos, setLookPos, DefaultCameraUp); }
/// <summary> /// Render single pass shader /// </summary> /// <param name="renderDelegate">Render delegate</param> public void RenderSinglePassShader( BaseGame.RenderDelegate renderDelegate) { // Start effect (current technique should be set) effect.Begin(SaveStateMode.None); // Start first pass effect.CurrentTechnique.Passes[0].Begin(); // Render renderDelegate(); // End pass and shader effect.CurrentTechnique.Passes[0].End(); effect.End(); }
/// <summary> /// Render /// </summary> /// <param name="techniqueName">Technique name</param> /// <param name="renderDelegate">Render delegate</param> public void Render(string techniqueName, BaseGame.RenderDelegate renderDelegate) { Render(null, techniqueName, renderDelegate); }
/*unused, always specify a technique name /// <summary> /// Render /// </summary> /// <param name="renderDelegate">Render delegate</param> public void Render(BaseGame.RenderDelegate renderDelegate) { SetParameters(); //not supported or bug, no multiple techniques possible yet: //effect.Technique = "SpecularPerPixel"; // Start shader effect.Begin(EffectStateOptions.Default); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { // Render each pass pass.Begin(); renderDelegate(); pass.End(); } // foreach (pass) // End shader effect.End(); } // Render(renderDelegate) */ /*unused, always specify a technique name /// <summary> /// Render /// </summary> /// <param name="setMat">Set matrix</param> /// <param name="renderDelegate">Render delegate</param> public void Render(Material setMat, BaseGame.RenderDelegate renderDelegate) { SetParameters(setMat); //not supported or bug, no multiple techniques possible yet: //effect.Technique = "SpecularPerPixel"; // Start shader effect.Begin(EffectStateOptions.Default); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { // Render each pass pass.Begin(); renderDelegate(); pass.End(); } // foreach (pass) // End shader effect.End(); } // Render(setMat, renderDelegate) */ /// <summary> /// Render /// </summary> /// <param name="setMat">Set matrix</param> /// <param name="passName">Pass name</param> /// <param name="renderDelegate">Render delegate</param> public void Render(Material setMat, string techniqueName, BaseGame.RenderDelegate renderDelegate) { SetParameters(setMat); // Can we do the requested technique? // For graphic cards not supporting ps2.0, fall back to ps1.1 if (BaseGame.CanUsePS20 == false && techniqueName.EndsWith("20")) // Use same technique without the 20 ending! techniqueName = techniqueName.Substring(0, techniqueName.Length - 2); // Start shader effect.CurrentTechnique = effect.Techniques[techniqueName]; effect.Begin(SaveStateMode.None); // Render all passes (usually just one) //foreach (EffectPass pass in effect.CurrentTechnique.Passes) for (int num = 0; num < effect.CurrentTechnique.Passes.Count; num++) { EffectPass pass = effect.CurrentTechnique.Passes[num]; pass.Begin(); renderDelegate(); pass.End(); } // foreach (pass) // End shader effect.End(); }
/// <summary> /// Create screenshot capturer /// </summary> /// <param name="setGame">Set game</param> public ScreenshotCapturer(BaseGame setGame) : base(setGame) { game = setGame; screenshotNum = GetCurrentScreenshotNum(); }