Beispiel #1
0
    // ================================================================ //

    protected void  update_optical_zoom()
    {
        if (this.optical_zoom != this.optical_zoom_current)
        {
            float near  = this.GetComponent <Camera>().nearClipPlane;
            float far   = this.GetComponent <Camera>().farClipPlane;
            float top   = Mathf.Tan(this.GetComponent <Camera>().fieldOfView / 2.0f * Mathf.Deg2Rad) * near;
            float right = this.GetComponent <Camera>().aspect *top;

            switch (this.optical_zoom)
            {
            case OPTICAL_ZOOM._2BY2_0_0:
            {
                Matrix4x4 m = CameraModule.createFrustumProjectionMatrix(0.0f, -right, top, 0.0f, near, far);

                this.GetComponent <Camera>().projectionMatrix = m;
            }
            break;

            case OPTICAL_ZOOM._2BY2_1_0:
            {
                Matrix4x4 m = CameraModule.createFrustumProjectionMatrix(right, 0.0f, top, 0.0f, near, far);

                this.GetComponent <Camera>().projectionMatrix = m;
            }
            break;

            case OPTICAL_ZOOM._2BY2_0_1:
            {
                Matrix4x4 m = CameraModule.createFrustumProjectionMatrix(0.0f, -right, 0.0f, -top, near, far);

                this.GetComponent <Camera>().projectionMatrix = m;
            }
            break;

            case OPTICAL_ZOOM._2BY2_1_1:
            {
                Matrix4x4 m = CameraModule.createFrustumProjectionMatrix(right, 0.0f, 0.0f, -top, near, far);

                this.GetComponent <Camera>().projectionMatrix = m;
            }
            break;

            case OPTICAL_ZOOM.AS_IS:
            {
                Matrix4x4 m = CameraModule.createFrustumProjectionMatrix(right, -right, top, -top, near, far);

                this.GetComponent <Camera>().projectionMatrix = m;
            }
            break;

            default:
            case OPTICAL_ZOOM.OFF:
            {
                this.GetComponent <Camera>().ResetProjectionMatrix();
            }
            break;
            }

            this.optical_zoom_current = this.optical_zoom;
        }
    }
Beispiel #2
0
	// ================================================================ //
	
	protected void	update_optical_zoom()
	{
		if(this.optical_zoom != this.optical_zoom_current) {

			float	near  = this.camera.nearClipPlane;
			float	far   = this.camera.farClipPlane;
			float	top   = Mathf.Tan(this.camera.fieldOfView/2.0f*Mathf.Deg2Rad)*near;
			float	right = this.camera.aspect*top;

			switch(this.optical_zoom) {

				case OPTICAL_ZOOM._2BY2_0_0:
				{
					Matrix4x4	m = CameraModule.createFrustumProjectionMatrix(0.0f, -right, top, 0.0f, near, far);
			
					this.camera.projectionMatrix = m;
				}
				break;

				case OPTICAL_ZOOM._2BY2_1_0:
				{
					Matrix4x4	m = CameraModule.createFrustumProjectionMatrix(right, 0.0f, top, 0.0f, near, far);
			
					this.camera.projectionMatrix = m;
				}
				break;

				case OPTICAL_ZOOM._2BY2_0_1:
				{
					Matrix4x4	m = CameraModule.createFrustumProjectionMatrix(0.0f, -right, 0.0f, -top, near, far);
			
					this.camera.projectionMatrix = m;
				}
				break;

				case OPTICAL_ZOOM._2BY2_1_1:
				{
					Matrix4x4	m = CameraModule.createFrustumProjectionMatrix(right, 0.0f, 0.0f, -top, near, far);
			
					this.camera.projectionMatrix = m;
				}
				break;

				case OPTICAL_ZOOM.AS_IS:
				{
					Matrix4x4	m = CameraModule.createFrustumProjectionMatrix(right, -right, top, -top, near, far);
			
					this.camera.projectionMatrix = m;
				}
				break;

				default:
				case OPTICAL_ZOOM.OFF:
				{
					this.camera.ResetProjectionMatrix();
				}
				break;
			}

			this.optical_zoom_current = this.optical_zoom;
		}
	}