ResetWorldToCameraMatrix() public method

Make the rendering position reflect the camera's position in the scene.

public ResetWorldToCameraMatrix ( ) : void
return void
コード例 #1
0
 // callback to be called before any culling
 public void PreCullAdjustFOV(Camera cam)
 {
     if (cam == thisCamera)
     {
         cam.fieldOfView = 70;
         //These are needed for the FOV change to take effect.
         cam.ResetWorldToCameraMatrix();
         cam.ResetProjectionMatrix();
     }
 }
コード例 #2
0
 static public int ResetWorldToCameraMatrix(IntPtr l)
 {
     try {
         UnityEngine.Camera self = (UnityEngine.Camera)checkSelf(l);
         self.ResetWorldToCameraMatrix();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #3
0
 static public int ResetWorldToCameraMatrix(IntPtr l)
 {
     try{
         UnityEngine.Camera self = (UnityEngine.Camera)checkSelf(l);
         self.ResetWorldToCameraMatrix();
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #4
0
ファイル: CubeMapper.cs プロジェクト: imclab/CubeMapRenderer
    void EndCubeFaceRender(Cubemap target, CubemapFace f, int mipLevel, Camera cam, bool aa)
    {
        // read pixels into destination
        int size = target.width >> mipLevel;
        Texture2D tempTex = new Texture2D (size, size);
        tempTex.ReadPixels(new Rect(0,0,size,size), 0,0, false);
        //Debug.Log (mipLevel);
        target.SetPixels(tempTex.GetPixels(), f, mipLevel);
        Object.DestroyImmediate(tempTex);

        // cleanup camera
        RenderTexture.ReleaseTemporary(cam.targetTexture);
        cam.targetTexture = null;
        cam.ResetWorldToCameraMatrix();
    }
コード例 #5
0
        private void SetupCamera()
        {
            cam.ResetWorldToCameraMatrix();
            cam.ResetProjectionMatrix();

            cam.allowHDR  = true;
            cam.allowMSAA = false;
            cam.allowDynamicResolution = true;
            cam.useOcclusionCulling    = true;

            cam.stereoTargetEye = StereoTargetEyeMask.None;

            cam.orthographic  = false;
            cam.nearClipPlane = (float)GetParameters().clip.near;
            cam.farClipPlane  = (float)GetParameters().clip.far;
            cam.cullingMask   = LayerMask.GetMask("Default");

            var targetRT = new RenderTexture(GetParameters().image_width, GetParameters().image_height, targetRTdepth, targetRTformat, targetRTrwmode)
            {
                name            = targetRTname,
                dimension       = UnityEngine.Rendering.TextureDimension.Tex2D,
                antiAliasing    = 1,
                useMipMap       = false,
                useDynamicScale = false,
                wrapMode        = TextureWrapMode.Clamp,
                filterMode      = FilterMode.Bilinear,
            };

            cam.targetTexture = targetRT;

            var camHFov = (float)GetParameters().horizontal_fov *Mathf.Rad2Deg;
            var camVFov = DeviceHelper.HorizontalToVerticalFOV(camHFov, cam.aspect);

            cam.fieldOfView = camVFov;

            // Invert projection matrix for gazebo msg
            var projMatrix   = DeviceHelper.MakeCustomProjectionMatrix(camHFov, camVFov, cam.nearClipPlane, cam.farClipPlane);
            var invertMatrix = Matrix4x4.Scale(new Vector3(1, -1, 1));

            cam.projectionMatrix = projMatrix * invertMatrix;

            cam.enabled = false;
            // cam.hideFlags |= HideFlags.NotEditable;

            camData.AllocateTexture(GetParameters().image_width, GetParameters().image_height, GetParameters().image_format);
        }
コード例 #6
0
    void RenderText(Camera cam)
    {
        // don't render if no GUILayer
        var guiLayer = cam.GetComponent<GUILayer>();
        if (guiLayer == null || !guiLayer.enabled)
            return;
        // our layer is culled
        if ((cam.cullingMask & (1<<gameObject.layer)) == 0)
            return;

        UpdateMesh();
        if (mesh == null)
            return;
        UpdateMaterial();

        GL.PushMatrix();
        GL.LoadPixelMatrix();
        mat.SetPass(0);

        var camRect = cam.pixelRect;
        var pos = transform.position;
        pos.x = camRect.x + pos.x * camRect.width + pixelOffset.x;
        pos.y = camRect.y + pos.y * camRect.height + pixelOffset.y;
        pos.z = 0;
        pos += EasyFontUtilities.CalcAnchorOffset(mesh, anchor);
        pos.x = Mathf.Round(pos.x);
        pos.y = Mathf.Round(pos.y);

        var scale = characterSize;
        var mtx = Matrix4x4.TRS(pos, Quaternion.identity, new Vector3(scale,-scale,scale));

        // Note: DrawMeshNow sets up current camera's view matrix;
        // so make sure that's identity and reset it afterwards
        cam.worldToCameraMatrix = Matrix4x4.identity;
        Graphics.DrawMeshNow(mesh, mtx);
        cam.ResetWorldToCameraMatrix();
        GL.PopMatrix();
    }
コード例 #7
0
ファイル: _CameraShake.cs プロジェクト: xiatianjin/Tank
		private void ResetState(Transform cachedTransform, Camera cam)
		{
			cam.ResetWorldToCameraMatrix();
			
			shakeRect.x = 0;
			shakeRect.y = 0;
			
			states[cam].Clear();
		}
コード例 #8
0
ファイル: CameraFX.cs プロジェクト: HexHash/LegacyRust
 internal static void ApplyTransitionAlterations(Camera camera, CameraFX fx, bool useFX)
 {
     Matrix4x4G matrix4x4G;
     Matrix4x4G matrix4x4G1;
     if (!useFX)
     {
         camera.ExtractCameraMatrixWorldToCamera(out matrix4x4G);
         camera.ExtractCameraMatrixProjection(out matrix4x4G1);
         int num = CameraFX.g_trans.Update(ref matrix4x4G, ref matrix4x4G1);
         if ((num & 1) == 1)
         {
             camera.ResetWorldToCameraMatrix();
             camera.worldToCameraMatrix = matrix4x4G.f;
         }
         if ((num & 2) == 2)
         {
             camera.ResetProjectionMatrix();
             camera.projectionMatrix = matrix4x4G1.f;
         }
     }
     else
     {
         int num1 = CameraFX.g_trans.Update(ref fx.worldToCameraMatrix, ref fx.projectionMatrix);
         if ((num1 & 1) == 1)
         {
             camera.worldToCameraMatrix = fx.worldToCameraMatrix.f;
             Matrix4x4G.Inverse(ref fx.worldToCameraMatrix, out fx.cameraToWorldMatrix);
         }
         if ((num1 & 2) == 2)
         {
             camera.projectionMatrix = fx.projectionMatrix.f;
         }
     }
 }