コード例 #1
0
        public void And_sphere(string id, string type, DataTable dataTable)
        {
            IMatrix transformation  = Matrix4x4.Identity;
            var     refractiveIndex = 1.0;

            foreach (var row in dataTable.Rows)
            {
                var cells = row.Cells.ToArray();
                switch (cells[0].Value)
                {
                case "material.refractive_index":
                    refractiveIndex = double.Parse(cells[1].Value);
                    break;

                case "transform":
                {
                    var entries = cells[1].Value
                                  .Split(new char[] { ',', ')', '(', ' ' }, System.StringSplitOptions.RemoveEmptyEntries)
                                  .ToArray();

                    switch (entries[0])
                    {
                    case "scaling":
                        transformation = MatrixOperations.Multiply(transformation,
                                                                   MatrixOperations.Geometry3D.Scale(
                                                                       double.Parse(entries[1]),
                                                                       double.Parse(entries[2]),
                                                                       double.Parse(entries[3])));
                        break;

                    case "translation":
                        transformation = MatrixOperations.Multiply(transformation,
                                                                   MatrixOperations.Geometry3D.Translation(
                                                                       double.Parse(entries[1]),
                                                                       double.Parse(entries[2]),
                                                                       double.Parse(entries[3])));
                        break;

                    default:
                        throw new NotImplementedException();
                    }

                    break;
                }

                default:
                    throw new NotImplementedException();
                }
            }

            switch (type)
            {
            case "sphere":
                figure[id] = new SphereFigure(transformation, MaterialConstants.Default);
                break;

            case "glass_sphere":
                figure[id] = SphereTest.create_glass_sphere(transformation, refractiveIndex);
                break;

            default:
                throw new NotImplementedException(type);
            }
        }
コード例 #2
0
 public void Given_glass_sphere(string id)
 {
     figure[id] = SphereTest.create_glass_sphere(MatrixOperations.Identity(4), 1.5);
 }