Exemple #1
0
 public Vertex(Vector4 position, Vector4 normal, ScreenPosition screenPos, float wc, Vector2F textureCoordinates, Vector4 tangent, Vector4 biNormal)
 {
     Position           = position;
     Normal             = normal;
     ScreenPos          = screenPos;
     Wc                 = wc;
     TextureCoordinates = textureCoordinates;
     Tangent            = tangent;
     BiNormal           = biNormal;
 }
Exemple #2
0
        public void CalculateAfterClipping()
        {
            Wc = Homogenous.W;
            float xNDC = Homogenous.X / Wc;
            float yNDC = Homogenous.Y / Wc;
            float zNDC = Homogenous.Z / Wc;

            float xs = (xNDC + 1) * Width / 2;
            float ys = (1 - yNDC) * Height / 2;
            float zs = (zNDC + 1) / 2;

            ScreenPos = new ScreenPosition((int)xs, (int)ys, zs);
        }
Exemple #3
0
        public Vector2F CalculateScreenCoordinates(Matrix cameraMatrix)
        {
            var h**o = cameraMatrix * Position;

            h**o.Z     = -h**o.Z;
            Homogenous = h**o;
            Wc         = h**o.W;
            float xNDC = h**o.X / Wc;
            float yNDC = h**o.Y / Wc;
            float zNDC = h**o.Z / Wc;

            float xs = (xNDC + 1) * Width / 2;
            float ys = (1 - yNDC) * Height / 2;
            float zs = (zNDC + 1) / 2;

            ScreenPos = new ScreenPosition((int)xs, (int)ys, zs);
            return(new Vector2F(xNDC, yNDC));
        }