Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        static public Object3D CreateTriangleObject(Primitive3D primitive, int coloringMode)
        {
            Object3D container = new Object3D();

            Color[,] colors = { { Colors.Red,   Colors.Green, Colors.Blue,    Colors.Yellow },
                                { Colors.Green, Colors.Cyan,  Colors.Magenta, Colors.Orange } };

            Point3DCollection positions = primitive.Mesh.Positions;
            Int32Collection   indices   = primitive.Mesh.TriangleIndices;
            Random            randy     = new Random();

            for (int i = 0; i < indices.Count; i += 3)
            {
                Triangle triangle = new Triangle();
                container.Children.Add(triangle);
                triangle.P1 = positions[indices[i]];
                triangle.P2 = positions[indices[i + 1]];
                triangle.P3 = positions[indices[i + 2]];

                Color color = coloringMode == 0 ? GetColor(randy) : colors[coloringMode - 1, i % 4];
                triangle.DiffuseMaterial.Brush = new SolidColorBrush(color);
            }

            container.ScaleX    = primitive.ScaleX;
            container.ScaleY    = primitive.ScaleY;
            container.ScaleZ    = primitive.ScaleZ;
            container.Position  = primitive.Position;
            container.Rotation1 = primitive.Rotation1;
            container.Rotation2 = primitive.Rotation2;

            return(container);
        }
Ejemplo n.º 2
0
        void AddBoundingBox(Object3D obj, ref Rect bounds)
        {
            if (obj == null)
            {
                return;
            }

            Primitive3D primitive = obj as Primitive3D;

            if (primitive != null)
            {
                bounds.Union(primitive.GetBoundingBox());
            }

            foreach (var child in obj.Children)
            {
                AddBoundingBox(child as Object3D, ref bounds);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 static public Object3D CreateTriangleObject(Primitive3D primitive)
 {
     return(CreateTriangleObject(primitive, 0));
 }