arskrald/AR-3/Assets/Intrinsics_script.cs

66 lines
1.9 KiB
C#
Raw Permalink Normal View History

2019-03-04 17:07:53 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Intrinsics_script : MonoBehaviour
{
private Camera camera;
private Matrix4x4 mat;
// Start is called before the first frame update
void Start()
{
camera = Camera.main;
var fx = 825.43306f;
fx = 30f;
var cx = 301.38953f;
cx = 0.5f;
var fy = 827.13187f;
fy = 50f;
var cy = 226.14987f;
cy = 10f;
var w = 640f;
var h = 480f;
var n = camera.nearClipPlane;
var f = camera.farClipPlane;
mat = new Matrix4x4(new Vector4((2 * fx) / w, 0, ((-2 * cx) / w) + 1, 0),
new Vector4(0, (2 * fy) / h, ((-2 * cy) / h) + 1, 0),
new Vector4(0, 0, -((f + n) / (f - n)), -((2 * f * n) / (f - n))),
new Vector4(0, 0, -1, 0)).transpose;
/*mat = new Matrix4x4(new Vector4(840.01807f, 0, 0, 0),
new Vector4(0, 839.97010f, 0, 0),
new Vector4(336.13803f, 233.38745f, 1, 0),
new Vector4(0, 0, 0, 1));*/
Vector4 column1 = new Vector4(731.02189f, 0f, 0f, 0f);
Vector4 column2 = new Vector4(0f, 733.00744f, 0f, 0f);
Vector4 column3 = new Vector4(372.63904f, 226.81776f, 1f, 0f);
Vector4 column4 = new Vector4(0f, 0f, 0f, 1f);
//mat = new Matrix4x4(column1, column2, column3, column4);
print(camera.projectionMatrix);
//camera.projectionMatrix = mat;
print(camera.projectionMatrix);
mat = camera.projectionMatrix;
}
// Update is called once per frame
void Update()
{
Matrix4x4 p = mat;
p.m01 += Mathf.Sin(Time.time * 1.2F) * 0.1F;
p.m10 += Mathf.Sin(Time.time * 1.5F) * 0.1F;
camera.projectionMatrix = p;
}
}