Exemplo n.º 1
0
        public void AddMaterial(Mat mat)
        {
            this.map.Add(mat.Name, mat);

            this.streamWriter.Write(string.Format(en_US, "newmtl {0}", mat.Name));
            this.streamWriter.WriteLine();
            if (mat.Ambient != null)
            {
                ITuple3_Float c = mat.Ambient.AsTupleFloat();
                this.streamWriter.Write(string.Format(en_US, "  Ka {0:F3} {1:F3} {2:F3}", c.X, c.Y, c.Z));
                this.streamWriter.WriteLine();
            }
            if (mat.Diffuse != null)
            {
                ITuple3_Float c = mat.Diffuse.AsTupleFloat();
                this.streamWriter.Write(string.Format(en_US, "  Kd {0:F3} {1:F3} {2:F3}", c.X, c.Y, c.Z));
                this.streamWriter.WriteLine();
            }
            if (mat.Specular != null)
            {
                ITuple3_Float c = mat.Specular.AsTupleFloat();
                this.streamWriter.Write(string.Format(en_US, "  Ks {0:F3} {1:F3} {2:F3}", c.X, c.Y, c.Z));
                this.streamWriter.WriteLine();
            }
            this.streamWriter.Write(string.Format(en_US, "  illum {0}", (int)mat.Model));
            this.streamWriter.WriteLine();
        }
Exemplo n.º 2
0
        public Color3f(IColor3 other)
        {
            ITuple3_Float _other = other.AsTupleFloat();

            this.Red   = _other.X;
            this.Green = _other.Y;
            this.Blue  = _other.Z;
        }
Exemplo n.º 3
0
        public Color4f(IColor3 other, float alpha)
        {
            ITuple3_Float _other = other.AsTupleFloat();

            this.Red   = _other.X;
            this.Green = _other.Y;
            this.Blue  = _other.Z;
            this.Alpha = alpha;
        }
Exemplo n.º 4
0
        public static ITuple3_Float AsTupleFloat(this IColor3 v)
        {
            ITuple3_Float ret = v as ITuple3_Float;

            if (ret != null)
            {
                return(ret);
            }
            return(VectorUtils.Convert <IColor3, ITuple3_Float>(v));
        }
Exemplo n.º 5
0
        public void TestConvert_ColorByte()
        {
            // Colors

            {
                ITuple3_Float v = VectorUtils.Convert <ITuple3_Float>(new Color3b(0, 128, 255));
                Assert.IsTrue(v.X.EpsilonEquals(0) && v.Y.EpsilonEquals(0.5f, 0.01f) && v.Z.EpsilonEquals(1));
            }
            {
                ITuple3_Byte v = VectorUtils.Convert <ITuple3_Byte>(new Color3b(0, 128, 255));
                Assert.IsTrue(v.X == 0 && v.Y == 128 && v.Z == 255);
            }
        }
Exemplo n.º 6
0
        public void TestConvert_Double()
        {
            // 2D - vectors

            {
                ITuple2_Float v = VectorUtils.Convert <ITuple2_Float>(new Vector2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }
            {
                ITuple2_Integer v = VectorUtils.Convert <ITuple2_Integer>(new Vector2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }
            {
                ITuple2_Byte v = VectorUtils.Convert <ITuple2_Byte>(new Vector2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }

            {
                ITuple2_Float v = VectorUtils.Convert <ITuple2_Float>(new BuffVector2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }
            {
                ITuple2_Integer v = VectorUtils.Convert <ITuple2_Integer>(new BuffVector2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }
            {
                ITuple2_Byte v = VectorUtils.Convert <ITuple2_Byte>(new BuffVector2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }

            // 2D - points

            {
                ITuple2_Float v = VectorUtils.Convert <ITuple2_Float>(new Point2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }
            {
                ITuple2_Integer v = VectorUtils.Convert <ITuple2_Integer>(new Point2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }
            {
                ITuple2_Byte v = VectorUtils.Convert <ITuple2_Byte>(new Point2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }

            {
                ITuple2_Float v = VectorUtils.Convert <ITuple2_Float>(new BuffPoint2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }
            {
                ITuple2_Integer v = VectorUtils.Convert <ITuple2_Integer>(new BuffPoint2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }
            {
                ITuple2_Byte v = VectorUtils.Convert <ITuple2_Byte>(new BuffPoint2d(1, 2));
                Assert.IsTrue(v.X == 1 && v.Y == 2);
            }

            // 3D - vectors

            {
                ITuple3_Float v = VectorUtils.Convert <ITuple3_Float>(new Vector3d(1, 2, 3));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3);
            }
            {
                ITuple3_Byte v = VectorUtils.Convert <ITuple3_Byte>(new Vector3d(1, 2, 3));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3);
            }

            {
                ITuple3_Float v = VectorUtils.Convert <ITuple3_Float>(new BuffVector3d(1, 2, 3));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3);
            }
            {
                ITuple3_Byte v = VectorUtils.Convert <ITuple3_Byte>(new BuffVector3d(1, 2, 3));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3);
            }

            // 3D - points

            {
                ITuple3_Float v = VectorUtils.Convert <ITuple3_Float>(new Point3d(1, 2, 3));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3);
            }
            {
                ITuple3_Byte v = VectorUtils.Convert <ITuple3_Byte>(new Point3d(1, 2, 3));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3);
            }

            {
                ITuple3_Float v = VectorUtils.Convert <ITuple3_Float>(new BuffPoint3d(1, 2, 3));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3);
            }
            {
                ITuple3_Byte v = VectorUtils.Convert <ITuple3_Byte>(new BuffPoint3d(1, 2, 3));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3);
            }

            // 4D - vectors

            {
                ITuple4_Float v = VectorUtils.Convert <ITuple4_Float>(new Vector4d(1, 2, 3, 4));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4);
            }
            {
                ITuple4_Byte v = VectorUtils.Convert <ITuple4_Byte>(new Vector4d(1, 2, 3, 4));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4);
            }

            {
                ITuple4_Float v = VectorUtils.Convert <ITuple4_Float>(new BuffVector4d(1, 2, 3, 4));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4);
            }
            {
                ITuple4_Byte v = VectorUtils.Convert <ITuple4_Byte>(new BuffVector4d(1, 2, 3, 4));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4);
            }

            // 4D - points

            {
                ITuple4_Float v = VectorUtils.Convert <ITuple4_Float>(new Point4d(1, 2, 3, 4));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4);
            }
            {
                ITuple4_Byte v = VectorUtils.Convert <ITuple4_Byte>(new Point4d(1, 2, 3, 4));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4);
            }

            {
                ITuple4_Float v = VectorUtils.Convert <ITuple4_Float>(new BuffPoint4d(1, 2, 3, 4));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4);
            }
            {
                ITuple4_Byte v = VectorUtils.Convert <ITuple4_Byte>(new BuffPoint4d(1, 2, 3, 4));
                Assert.IsTrue(v.X == 1 && v.Y == 2 && v.Z == 3 && v.W == 4);
            }
        }
Exemplo n.º 7
0
        bool IEquatable <IColor3> .Equals(IColor3 other)
        {
            ITuple3_Float _other = other.AsTupleFloat();

            return(this.Equals(_other.X, _other.Y, _other.Z));
        }
Exemplo n.º 8
0
        bool IEpsilonEquatable <IColor3> .EpsilonEquals(IColor3 other, double epsilon)
        {
            ITuple3_Float _other = other.AsTupleFloat();

            return(this.EpsilonEquals(_other.X, _other.Y, _other.Z, (float)epsilon));
        }