Example #1
0
 public void UpdateBuffers()
 {
     CurrentColorTex.LoadRawTextureData(SaberSalientNative.GetColorBuf(native), bufferSize);
     CurrentDepthTex.LoadRawTextureData(SaberSalientNative.GetDepthBuf(native), bufferSize);
     CurrentColorTex.Apply();
     CurrentDepthTex.Apply();
 }
Example #2
0
        public Matrix4x4 GetMvpTransform()
        {
            if (SaberSalientNative.GetCurrentTransform(native, mvpTransformRaw) != 0)
            {
                return(mvpTransform);
            }

            for (int i = 0; i < 16; i++)
            {
                mvpTransform[i] = mvpTransformRaw[i];
            }

            return(mvpTransform);
        }
Example #3
0
        private SaberSalient()
        {
            if (SaberSalientNative.Init(out native) != 0)
            {
                native = IntPtr.Zero;
                throw new ExternalException("Could not init native saber-saliend.dll");
            }
            mvpTransformRaw = new float[16];
            mvpTransform    = Matrix4x4.identity;

            positionRaw = new float[3];
            rotationRaw = new float[9];
            mvTransform = Matrix4x4.identity;
            pTransform  = Matrix4x4.zero;

            if (SaberSalientNative.GetCameraIntrinsics(native, Camera) != 0)
            {
                throw new ExternalException("Could not get camera intrinsics in native saber-saliend.dll");
            }

            Logger.Log("Initialized SaberSalient camera: " + Camera.width + " " + Camera.height);
            float near = 0.1f;
            float far  = 10.0f;

            pTransform.m00 = 2 * Camera.fx / Camera.width;
            pTransform.m11 = 2 * Camera.fy / Camera.height;
            pTransform.m22 = -(far + near) / (far - near);
            pTransform.m32 = -1;
            pTransform.m23 = 2 * far * near / (near - far);

            CurrentColorTex = new Texture2D(Camera.width, Camera.height, TextureFormat.ARGB32, false, false);
            CurrentDepthTex = new Texture2D(Camera.width, Camera.height, TextureFormat.RFloat, false, true);
            bufferSize      = Camera.width * Camera.height * 4;

            ab = AssetBundle.LoadFromMemory(Utils.GetResource(System.Reflection.Assembly.GetExecutingAssembly(), "CameraPlus.Resources.sabersalient"));
            // AssetBundle.LoadFromFile("G:\\prorgamming\\CameraPlus\\CameraPlus\\Resources\\sabersalient");
            if (ab == null)
            {
                throw new NullReferenceException("SaberSalientOverlayed - No AssetBundle!");
            }
        }
Example #4
0
        public Matrix4x4 GetMvTransform()
        {
            if (SaberSalientNative.GetCurrentPosition(native, positionRaw) != 0)
            {
                return(mvTransform);
            }

            if (SaberSalientNative.GetCurrentRotation(native, rotationRaw) != 0)
            {
                return(mvTransform);
            }

            for (int i = 0; i < 3; i++)
            {
                mvTransform[12 + i] = positionRaw[i];
                for (int j = 0; j < 3; j++)
                {
                    mvTransform[i + 4 * j] = rotationRaw[i + 3 * j];
                }
            }

            return(mvTransform);
        }