示例#1
0
        private Vec4 Normalize(Vec4 color)
        {
            Vec4 res = new Vec4(0);

            res.x = color.x / 255.0f;
            res.y = color.y / 255.0f;
            res.z = color.z / 255.0f;
            res.w = color.w > 1.0f ? color.w / 100.0f : color.w;
            return(res);
        }
示例#2
0
 public Mat4(float v00, float v01, float v02, float v03,
             float v04, float v05, float v06, float v07,
             float v08, float v09, float v10, float v11,
             float v12, float v13, float v14, float v15)
 {
     row0 = new Vec4(v00, v01, v02, v03);
     row1 = new Vec4(v04, v05, v06, v07);
     row2 = new Vec4(v08, v09, v10, v11);
     row3 = new Vec4(v12, v13, v14, v15);
 }
示例#3
0
        public Mat4 Mat4(Vec4 v)
        {
            Mat4 result = new Mat4(0);
            var  temp   = Mat3();

            result[0] = new Vec4(temp[0], 0.0f);
            result[1] = new Vec4(temp[1], 0.0f);
            result[2] = new Vec4(temp[2], 0.0f);
            result[3] = v;

            return(result);
        }
示例#4
0
        public static Vec4 operator *(Vec4 v, Mat4 m)
        {
            Vec4 result = new Vec4(0);

            for (int r = 0; r < 4; ++r)
            {
                for (int c = 0; c < 4; ++c)
                {
                    result[r] += m[r][c] * v[c];
                }
            }
            return(result);
        }
示例#5
0
 public Vec4 this[int i] {
     get {
         if (i == 0)
         {
             return(row0);
         }
         if (i == 1)
         {
             return(row1);
         }
         if (i == 2)
         {
             return(row2);
         }
         if (i == 3)
         {
             return(row3);
         }
         return(new Vec4(0));
     }
     set {
         if (i == 0)
         {
             row0 = value;
         }
         else if (i == 1)
         {
             row1 = value;
         }
         else if (i == 2)
         {
             row2 = value;
         }
         else if (i == 3)
         {
             row3 = value;
         }
     }
 }
示例#6
0
 private extern static void DrawColor(Vec4 color);
示例#7
0
 public float Distance(Vec4 other)
 {
     return(MathF.Sqrt(this.DistanceSqrt(other)));
 }
示例#8
0
 public Color(Vec3 color)
 {
     this.color = new Vec4(color / 255.0f, 1.0f);
 }
示例#9
0
 public Color(uint r, uint g, uint b, uint a = 100)
 {
     this.color = new Vec4(r / 255.0f, g / 255.0f, b / 255.0f, a / 100.0f);
 }
示例#10
0
 public float DistanceSqrt(Vec4 other)
 {
     return(MathF.Pow(other.x - this.x, 2) + MathF.Pow(other.y - this.y, 2) + MathF.Pow(other.z - this.z, 2) + MathF.Pow(other.w - this.w, 2));
 }
示例#11
0
 public Vec2(Vec4 v)
 {
     this.x = v.x;
     this.y = v.y;
 }
示例#12
0
 public float Dot(Vec4 other)
 {
     return((this.x * other.x) + (this.y * other.y) + (this.z * other.z) + (this.w * other.w));
 }
示例#13
0
 public Vec3(Vec4 v)
 {
     this.x = v.x;
     this.y = v.y;
     this.z = v.z;
 }
示例#14
0
 public Color(Vec4 color)
 {
     this.color = Normalize(color);
 }
示例#15
0
 public void SetVec4(int location, Vec4 val)
 {
     SetVec4(this, location, val);
 }
示例#16
0
 private extern static void SetVec4(Shader shader, int location, Vec4 val);
示例#17
0
 public void SetColor(Vec4 color)
 {
     this.color = Normalize(color);
 }