Beispiel #1
0
        public CubeMapTexture(String texturePath, CubeMapType type)
        {
            if (!texturePath.EndsWith("/"))
            {
                texturePath += "/";
            }

            this.type = type;
            textures  = new int[1];
            Gl.glGenTextures(1, textures);
            Gl.glBindTexture(Gl.GL_TEXTURE_CUBE_MAP, textures[0]);

            Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
            Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_LINEAR);
            Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP_TO_EDGE);
            Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP_TO_EDGE);
            Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_TEXTURE_WRAP_R, Gl.GL_CLAMP_TO_EDGE);

            Pixmap pixmap;

            for (int i = 0; i < 6; i++)
            {
                // Load this texture map
                Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_GENERATE_MIPMAP, Gl.GL_TRUE);
                pixmap = new Pixmap(texturePath + path[i] + ".bmp");
                Gl.glTexImage2D(cube[i], 0, pixmap.Bpp, pixmap.Width, pixmap.Height, 0, pixmap.getFormat(), Gl.GL_UNSIGNED_BYTE, pixmap.Data);
            }
        }
Beispiel #2
0
        public CubeMapTexture(String texturePath, CubeMapType type)
        {
            if (!texturePath.EndsWith("/"))
                texturePath += "/";

            this.type = type;
            textures = new int[1];
            Gl.glGenTextures(1, textures);
            Gl.glBindTexture(Gl.GL_TEXTURE_CUBE_MAP, textures[0]);

            Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
            Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_LINEAR);
            Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP_TO_EDGE);
            Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP_TO_EDGE);
            Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_TEXTURE_WRAP_R, Gl.GL_CLAMP_TO_EDGE);

            Pixmap pixmap;

            for(int i = 0; i < 6; i++)
            {
                // Load this texture map
                Gl.glTexParameteri(Gl.GL_TEXTURE_CUBE_MAP, Gl.GL_GENERATE_MIPMAP, Gl.GL_TRUE);
                pixmap = new Pixmap(texturePath + path[i] + ".bmp");
                Gl.glTexImage2D(cube[i], 0, pixmap.Bpp, pixmap.Width, pixmap.Height, 0, pixmap.getFormat(), Gl.GL_UNSIGNED_BYTE, pixmap.Data);
            }
        }
Beispiel #3
0
    // private void UpdateFPSCounter()
    // {
    //  // Update FPS counter
    //  if (fpsText != null && fpsText.gameObject.activeSelf)
    //  {
    //      // Maintain a running average of the last N frame deltas, for a more stable frame counter.
    //      m_frameDeltas[m_curFrameDelta++] = Time.deltaTime;
    //      if (m_curFrameDelta >= 10)
    //          m_curFrameDelta = 0;
    //      float totalFrameDelta = 0.0f;
    //      for (int i = 0; i < 10; i++)
    //          totalFrameDelta += m_frameDeltas[i];
    //      fpsText.text = string.Format("{0}", Mathf.Round(totalFrameDelta != 0.0f ? (float)NumFrameDeltas / totalFrameDelta : 0));
    //  }
    // }

    private void ResetToDefaults()
    {
        worldCameraPitch           = m_initialWorldCameraPitch;
        worldCameraRoll            = m_initialWorldCameraRoll;
        cubeMapType                = CubeMapType.Cube1024;
        antiAliasingType           = AntiAliasingType.SSAA_2X;
        QualitySettings.vSyncCount = 1;
        backFadeIntensity          = DefBackFadeIntensity;
        crescentFadeIntensity      = DefCrescentFadeIntensity;
        crescentFadeRadius         = DefCrescentFadeRadius;
        crescentFadeOffset         = DefCrescentFadeOffset;
    }
Beispiel #4
0
    private void LoadSettingsFromFile(string filename)
    {
        if (File.Exists(filename))
        {
            string[] lines = File.ReadAllLines(filename);
            foreach (string line in lines)
            {
                if (line.IndexOf('=') == -1)
                {
                    continue;
                }
                string[] parts = line.Split('=');
                if (parts.Length < 2)
                {
                    continue;
                }
                string setting = parts[0].Trim();
                string value   = parts[1].Trim();

                if (string.Compare(setting, "cameraOrientationAngle", true) == 0)
                {
                    if (!float.TryParse(value, out cameraOrientationAngle))
                    {
                        cameraOrientationAngle = WorldCameraDefPitch;
                    }
                    cameraOrientationAngle = Mathf.Clamp(cameraOrientationAngle, WorldCameraMinPitch, WorldCameraMaxPitch) - 90f;
                }
                else if (string.Compare(setting, "DomeNorthOrientation", true) == 0)
                {
                    if (!float.TryParse(setting, out DomeNorthOrientation))
                    {
                        DomeNorthOrientation = WorldCameraDefRoll;
                    }
                    DomeNorthOrientation = Mathf.Clamp(DomeNorthOrientation, WorldCameraMinRoll, WorldCameraMaxRoll);
                }
                else if (string.Compare(setting, "cubeMapType", true) == 0)
                {
                    int cubeMapSize;
                    if (int.TryParse(value, out cubeMapSize))
                    {
                        switch (cubeMapSize)
                        {
                        case 512: cubeMapType = CubeMapType.Cube512; break;

                        case 1024: cubeMapType = CubeMapType.Cube1024; break;

                        case 2048: cubeMapType = CubeMapType.Cube2048; break;

                        case 4096: cubeMapType = CubeMapType.Cube4096; break;

                        case 8192: cubeMapType = CubeMapType.Cube8192; break;

                        default: goto case 1024;
                        }
                    }
                    else
                    {
                        cubeMapType = CubeMapType.Cube1024;
                    }
                }
                else if (string.Compare(setting, "antiAliasingType", true) == 0)
                {
                    if (string.Compare(value, "Off", true) == 0)
                    {
                        antiAliasingType = AntiAliasingType.Off;
                    }
                    else if (string.Compare(value, "SSAA_4X", true) == 0)
                    {
                        antiAliasingType = AntiAliasingType.SSAA_4X;
                    }
                    else
                    {
                        antiAliasingType = AntiAliasingType.SSAA_2X;
                    }
                }
                else if (string.Compare(setting, "vSync", true) == 0)
                {
                    int vSyncCount = 0;
                    if (!int.TryParse(value, out vSyncCount))
                    {
                        vSyncCount = 1;
                    }
                    if (vSyncCount != 0 && vSyncCount != 1)
                    {
                        vSyncCount = 1;
                    }
                    QualitySettings.vSyncCount = vSyncCount;
                }
            }
        }
    }
Beispiel #5
0
    private void LoadSettingsFromFile(string filename)
    {
        ResetToDefaults();

        if (File.Exists(filename))
        {
            string[] lines = File.ReadAllLines(filename);
            foreach (string line in lines)
            {
                if (line.IndexOf('=') == -1)
                {
                    continue;
                }
                string[] parts = line.Split('=');
                if (parts.Length < 2)
                {
                    continue;
                }
                string setting = parts[0].Trim();
                string value   = parts[1].Trim();

                if (string.Compare(setting, "worldCameraPitch", true) == 0)
                {
                    if (!float.TryParse(value, out worldCameraPitch))
                    {
                        worldCameraPitch = WorldCameraDefPitch;
                    }
                    worldCameraPitch = Mathf.Clamp(worldCameraPitch, WorldCameraMinPitch, WorldCameraMaxPitch);
                }
                else if (string.Compare(setting, "worldCameraRoll", true) == 0)
                {
                    if (!float.TryParse(setting, out worldCameraRoll))
                    {
                        worldCameraRoll = WorldCameraDefRoll;
                    }
                    worldCameraRoll = Mathf.Clamp(worldCameraRoll, WorldCameraMinRoll, WorldCameraMaxRoll);
                }
                else if (string.Compare(setting, "cubeMapType", true) == 0)
                {
                    int cubeMapSize;
                    if (int.TryParse(value, out cubeMapSize))
                    {
                        switch (cubeMapSize)
                        {
                        case 512: cubeMapType = CubeMapType.Cube512; break;

                        case 1024: cubeMapType = CubeMapType.Cube1024; break;

                        case 2048: cubeMapType = CubeMapType.Cube2048; break;

                        case 4096: cubeMapType = CubeMapType.Cube4096; break;

                        case 8192: cubeMapType = CubeMapType.Cube8192; break;

                        default: goto case 1024;
                        }
                    }
                    else
                    {
                        cubeMapType = CubeMapType.Cube1024;
                    }
                }
                else if (string.Compare(setting, "antiAliasingType", true) == 0)
                {
                    if (string.Compare(value, "Off", true) == 0)
                    {
                        antiAliasingType = AntiAliasingType.Off;
                    }
                    else if (string.Compare(value, "SSAA_4X", true) == 0)
                    {
                        antiAliasingType = AntiAliasingType.SSAA_4X;
                    }
                    else
                    {
                        antiAliasingType = AntiAliasingType.SSAA_2X;
                    }
                }
                else if (string.Compare(setting, "vSync", true) == 0)
                {
                    int vSyncCount = 0;
                    if (!int.TryParse(value, out vSyncCount))
                    {
                        vSyncCount = 1;
                    }
                    if (vSyncCount != 0 && vSyncCount != 1)
                    {
                        vSyncCount = 1;
                    }
                    QualitySettings.vSyncCount = vSyncCount;
                }
                else if (string.Compare(setting, "backFadeIntensity", true) == 0)
                {
                    if (!float.TryParse(value, out backFadeIntensity))
                    {
                        backFadeIntensity = DefBackFadeIntensity;
                    }
                    backFadeIntensity = Mathf.Clamp01(backFadeIntensity);
                }
                else if (string.Compare(setting, "crescentFadeIntensity", true) == 0)
                {
                    if (!float.TryParse(value, out crescentFadeIntensity))
                    {
                        crescentFadeIntensity = DefCrescentFadeIntensity;
                    }
                    crescentFadeIntensity = Mathf.Clamp01(crescentFadeIntensity);
                }
                else if (string.Compare(setting, "crescentFadeRadius", true) == 0)
                {
                    if (!float.TryParse(value, out crescentFadeRadius))
                    {
                        crescentFadeRadius = DefCrescentFadeRadius;
                    }
                    crescentFadeRadius = Mathf.Clamp01(crescentFadeRadius);
                }
                else if (string.Compare(setting, "crescentFadeOffset", true) == 0)
                {
                    if (!float.TryParse(value, out crescentFadeOffset))
                    {
                        crescentFadeOffset = DefCrescentFadeOffset;
                    }
                    crescentFadeOffset = Mathf.Clamp(crescentFadeOffset, -1.0f, +1.0f);
                }
            }
        }
    }
Beispiel #6
0
    //----------------------------------------------------------------------------------------------------
    // PRIVATE
    //----------------------------------------------------------------------------------------------------

    private void ProcessOperatorControls()
    {
        // Operator controls!

        bool shiftDown = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

        if (shiftDown)
        {
            // [F1] and [F2] increase/decrease FOV
            if (Input.GetKeyUp(KeyCode.F1))
            {
                FOV = Mathf.Max(FOV - FOVIncrement, MinFOV);
            }
            else if (Input.GetKeyUp(KeyCode.F2))
            {
                FOV = Mathf.Min(FOV + FOVIncrement, MaxFOV);
            }
            // [F3] and [F4] control world camera pitch.
            else if (Input.GetKeyUp(KeyCode.F3))
            {
                worldCameraPitch += RotationIncrement;
            }
            else if (Input.GetKeyUp(KeyCode.F4))
            {
                worldCameraPitch -= RotationIncrement;
            }
            // [F5] and [F6] control world camera roll.
            else if (Input.GetKeyUp(KeyCode.F5))
            {
                worldCameraRoll += RotationIncrement;
            }
            else if (Input.GetKeyUp(KeyCode.F6))
            {
                worldCameraRoll -= RotationIncrement;
            }
            // [F7] and [F8] control cube map size.
            else if (Input.GetKeyUp(KeyCode.F7))
            {
                if (cubeMapType > CubeMapType.Cube512)
                {
                    cubeMapType = (CubeMapType)((int)cubeMapType / 2);
                }
            }
            else if (Input.GetKeyUp(KeyCode.F8))
            {
                if (cubeMapType < CubeMapType.Cube8192)
                {
                    cubeMapType = (CubeMapType)((int)cubeMapType * 2);
                }
            }
            // [F9] cycles through AA modes.
            else if (Input.GetKeyUp(KeyCode.F9))
            {
                switch (antiAliasingType)
                {
                case AntiAliasingType.Off:
                    antiAliasingType = AntiAliasingType.SSAA_2X;
                    break;

                case AntiAliasingType.SSAA_2X:
                    antiAliasingType = AntiAliasingType.SSAA_4X;
                    break;

                default:
                    antiAliasingType = AntiAliasingType.Off;
                    break;
                }
            }
            // [F10] toggles V-sync.
            else if (Input.GetKeyUp(KeyCode.F10))
            {
                if (QualitySettings.vSyncCount == 0)
                {
                    QualitySettings.vSyncCount = 1;
                }
                else
                {
                    QualitySettings.vSyncCount = 0;
                }
            }
            // [F11] save current dome controller parameters as the default settings.
            else if (Input.GetKeyUp(KeyCode.F11))
            {
                SaveDefaultSettings();
            }
            // [F12] resets all dome controller parameters to default settings.
            else if (Input.GetKeyUp(KeyCode.F12))
            {
                LoadDefaultSettings();
            }
        }

        bool ctrlDown = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand);

        if (ctrlDown)
        {
            // [F1] and [F2] control back fade intensity.
            if (Input.GetKeyUp(KeyCode.F1))
            {
                backFadeIntensity = Mathf.Clamp01(backFadeIntensity - FadeIntensityIncrement);
            }
            else if (Input.GetKeyUp(KeyCode.F2))
            {
                backFadeIntensity = Mathf.Clamp01(backFadeIntensity + FadeIntensityIncrement);
            }
            // [F3] and [F4] control crescent fade intensity.
            else if (Input.GetKeyUp(KeyCode.F3))
            {
                crescentFadeIntensity = Mathf.Clamp01(crescentFadeIntensity - FadeIntensityIncrement);
            }
            else if (Input.GetKeyUp(KeyCode.F4))
            {
                crescentFadeIntensity = Mathf.Clamp01(crescentFadeIntensity + FadeIntensityIncrement);
            }
            // [F5] and [F6] control crescent fade radius.
            else if (Input.GetKeyUp(KeyCode.F5))
            {
                crescentFadeRadius = Mathf.Clamp01(crescentFadeRadius - FadeRadiusIncrement);
            }
            else if (Input.GetKeyUp(KeyCode.F6))
            {
                crescentFadeRadius = Mathf.Clamp01(crescentFadeRadius + FadeRadiusIncrement);
            }
            // [F7] and [F8] control crescent fade offset.
            else if (Input.GetKeyUp(KeyCode.F7))
            {
                crescentFadeOffset = Mathf.Clamp(crescentFadeOffset - FadeOffsetIncrement, -1, +1);
            }
            else if (Input.GetKeyUp(KeyCode.F8))
            {
                crescentFadeOffset = Mathf.Clamp(crescentFadeOffset + FadeOffsetIncrement, -1, +1);
            }
            else if (Input.GetKeyUp(KeyCode.F9))
            {
                // if (fpsText != null)
                //  fpsText.gameObject.SetActive(!fpsText.gameObject.activeSelf);
            }
            else if (Input.GetKeyUp(KeyCode.F11))
            {
                SaveProductSettings();
            }
            else if (Input.GetKeyUp(KeyCode.F12))
            {
                LoadProductSettings();
            }
        }
    }