public HeightFieldObject(Vector3D origin, MaterialShader shader, Vector2D size, Bitmap bitmapSrc)
            : base(origin, shader, -1)
        {
            this.bitmapSrc = bitmapSrc;
            // calculate bounds
            areaExtent = size;
            Vector2D halfSize = size * 0.5;
            areaStart = origin - halfSize;
            areaEnd = origin + halfSize;
            double szLen = size.Length();
            radius = Math.Sqrt((szLen * szLen) + (1.1 * 1.1)) / 2;

            hField = HeightField.FromBitmap(bitmapSrc);

            onePx = new Vector2D(areaExtent.X / hField.Width, areaExtent.Y / hField.Height);

            this.origin.Y = 0.5;

            zMin = 0;
            zTop = 1;

            rectangles = new Rectangle3D[]
            {
                new Rectangle3D(new Vector3D(areaStart.X, zTop, areaStart.Y), new Vector3D(areaEnd.X, zTop, areaEnd.Y),
                                new PlaneD(new Vector3D(0, 1, 0), -zTop)),           // top
                new Rectangle3D(new Vector3D(areaStart.X, zMin, areaStart.Y), new Vector3D(areaEnd.X, zMin, areaEnd.Y),
                                new PlaneD(new Vector3D(0, -1, 0), zMin)),          // bottom
                new Rectangle3D(new Vector3D(areaStart.X, zMin, areaStart.Y), new Vector3D(areaStart.X, zTop, areaEnd.Y), 
                                new PlaneD(new Vector3D(-1, 0, 0), halfSize.X)),    // left
                new Rectangle3D(new Vector3D(areaEnd.X, zMin, areaStart.Y), new Vector3D(areaEnd.X, zTop, areaEnd.Y),
                                new PlaneD(new Vector3D(1, 0, 0), -halfSize.X)),     // right
                new Rectangle3D(new Vector3D(areaStart.X, zMin, areaStart.Y), new Vector3D(areaEnd.X, zTop, areaStart.Y),
                                new PlaneD(new Vector3D(0, 0, -1), halfSize.Y)),    // front 
                new Rectangle3D(new Vector3D(areaStart.X, zMin, areaEnd.Y), new Vector3D(areaEnd.X, zTop, areaEnd.Y),
                                new PlaneD(new Vector3D(0, 0, 1), -halfSize.Y)),     // back
            };
        }
        public TriangleGroupSceneObject(Vector3D origin, MaterialShader shader, double radius)
            : base(origin, shader, radius)
        {
            // determine scaling factor
            double scale = Math.Sqrt((radius * radius) / 2);
            this.radius *= 2;
            points = new Vector3D[] { new Vector3D(-1, -1, 1), new Vector3D(-1, 1, 1),
                                      new Vector3D(1, 1, 1), new Vector3D(1, -1, 1),
                                      new Vector3D(-1, -1, -1), new Vector3D(-1, 1, -1),
                                      new Vector3D(1, 1, -1), new Vector3D(1, -1, -1)  };
            
            // tansform points
            for (int i = 0; i < points.Length; i++)
            {
                points[i].X *= scale;
                points[i].X += origin.X;
                points[i].Y *= scale;
                points[i].Y += origin.Y;
                points[i].Z *= scale;
                points[i].Z += origin.Z;
            }

            triangles = new Triangle[] { new Triangle(4, 7, 6), new Triangle(6, 5, 4),
                                         new Triangle(2, 3, 0), new Triangle(0, 1, 2),
                                         new Triangle(1, 0, 4), new Triangle(4, 5, 1),
                                         new Triangle(7, 3, 2), new Triangle(2, 6, 7),
                                         new Triangle(0, 3, 7), new Triangle(7, 4, 0),
                                         new Triangle(6, 2, 1), new Triangle(1, 5, 6) };

            tCoords = new Vector2D[] { new Vector2D(0, 0), new Vector2D(0, 1), new Vector2D(1, 1), 
                                       new Vector2D(1, 1), new Vector2D(1, 0), new Vector2D(0, 0), 
            };

            CalcFaceNormals();
            CalcVertexNormals();
        }
 public SphereSceneObject(Vector3D origin, MaterialShader shader, double radius)
     : base(origin, shader, radius)
 {
 }
 public OpticalSceneObject(Vector3D origin, MaterialShader shader, double radius)
 {
     this.origin = origin;
     this.shader = shader;
     this.radius = radius;
 }
        public TriangleGroupSceneObject(Vector3D origin, Vector3D scale, MaterialShader shader)
            : base(origin, shader, 0)
        {
            points = new Vector3D[] { new Vector3D(0, 0, 1), new Vector3D(0, 1, 1),
                                      new Vector3D(1, 1, 1), new Vector3D(1, 0, 1),
                                      new Vector3D(0, 0, 0), new Vector3D(0, 1, 0),
                                      new Vector3D(1, 1, 0), new Vector3D(1, 0, 0)  };

            // tansform points
            for (int i = 0; i < points.Length; i++)
            {
                points[i].X *= scale.X;
                points[i].X += origin.X;
                points[i].Y *= scale.Y;
                points[i].Y += origin.Y;
                points[i].Z *= scale.Z;
                points[i].Z += origin.Z;
            }

            triangles = new Triangle[] { new Triangle(4, 7, 6), new Triangle(6, 5, 4),
                                         new Triangle(0, 3, 2), new Triangle(2, 1, 0),
                                         new Triangle(4, 0, 1), new Triangle(1, 5, 4),
                                         new Triangle(7, 3, 2), new Triangle(2, 6, 7),
                                         new Triangle(7, 3, 0), new Triangle(0, 4, 7),
                                         new Triangle(6, 2, 1), new Triangle(1, 5, 6) };

            CalcFaceNormals();
            CalcVertexNormals();
        }