Exemple #1
0
        /// <summary>   Initializes a new instance of the ObjectCube class. </summary>
        ///
        /// <param name="cube"> The cube. </param>
        public ObjectCube(ObjectCube cube)
        {
            width  = cube.width;
            height = cube.height;
            depth  = cube.depth;

            origin = new Point3D(cube.origin.X, cube.origin.Y, cube.origin.Z);
        }
Exemple #2
0
        /// <summary>   Initializes a new instance of the ObjectCube class. </summary>
        ///
        /// <param name="cube"> The cube. </param>
        public ObjectCube(ObjectCube cube)
        {
            width = cube.width;
            height = cube.height;
            depth = cube.depth;

            origin = new Point3D(cube.origin.X, cube.origin.Y, cube.origin.Z);
        }
Exemple #3
0
        /// <summary>   Adds a cube to mesh. </summary>
        ///
        /// <param name="p0">           The p 0. </param>
        /// <param name="w">            The width. </param>
        /// <param name="h">            The height. </param>
        /// <param name="d">            The double to process. </param>
        /// <param name="mesh">         The mesh. </param>
        /// <param name="useTexture">   true to use texture. </param>
        public static void addCubeToMesh(Point3D p0, double w, double h, double d,
                                         MeshGeometry3D mesh, bool useTexture)
        {
            ObjectCube cube = new ObjectCube(p0, w, h, d);

            double maxDimension = Math.Max(d, Math.Max(w, h));

            PointCollection textureCoordinatesCollection = new PointCollection();

            ObjectRectangle front  = cube.Front();
            ObjectRectangle back   = cube.Back();
            ObjectRectangle right  = cube.Right();
            ObjectRectangle left   = cube.Left();
            ObjectRectangle top    = cube.Top();
            ObjectRectangle bottom = cube.Bottom();

            if (useTexture)
            {
                Point3D extents = front.getDimensions();

                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                      extents.Y / maxDimension);
                extents = back.getDimensions();
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                      extents.Y / maxDimension);
                extents = right.getDimensions();
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                      extents.Y / maxDimension);
                extents = left.getDimensions();
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                      extents.Y / maxDimension);
                extents = top.getDimensions();
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                      extents.Y / maxDimension);
                extents = bottom.getDimensions();
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                      extents.Y / maxDimension);
            }

            front.addToMesh(mesh);
            back.addToMesh(mesh);
            right.addToMesh(mesh);
            left.addToMesh(mesh);
            top.addToMesh(mesh);
            bottom.addToMesh(mesh);

            if (useTexture)
            {
                mesh.TextureCoordinates = textureCoordinatesCollection;
            }
        }
Exemple #4
0
        /// <summary>   Adds a cube to mesh. </summary>
        ///
        /// <param name="p0">           The p 0. </param>
        /// <param name="w">            The width. </param>
        /// <param name="h">            The height. </param>
        /// <param name="d">            The double to process. </param>
        /// <param name="mesh">         The mesh. </param>
        /// <param name="useTexture">   true to use texture. </param>
        public static void addCubeToMesh(Point3D p0, double w, double h, double d,
            MeshGeometry3D mesh, bool useTexture)
        {
            ObjectCube cube = new ObjectCube(p0, w, h, d);

            double maxDimension = Math.Max(d, Math.Max(w, h));

            PointCollection textureCoordinatesCollection = new PointCollection();

            ObjectRectangle front = cube.Front();
            ObjectRectangle back = cube.Back();
            ObjectRectangle right = cube.Right();
            ObjectRectangle left = cube.Left();
            ObjectRectangle top = cube.Top();
            ObjectRectangle bottom = cube.Bottom();

            if (useTexture)
            {
                Point3D extents = front.getDimensions();
                
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                         extents.Y / maxDimension);
                extents = back.getDimensions();
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                         extents.Y / maxDimension);
                extents = right.getDimensions();
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                         extents.Y / maxDimension);
                extents = left.getDimensions();
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                         extents.Y / maxDimension);
                extents = top.getDimensions();
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                         extents.Y / maxDimension);
                extents = bottom.getDimensions();
                addTextureCoordinates(textureCoordinatesCollection, extents.X / maxDimension,
                                         extents.Y / maxDimension);
            }

            front.addToMesh(mesh);
            back.addToMesh(mesh);
            right.addToMesh(mesh);
            left.addToMesh(mesh);
            top.addToMesh(mesh);
            bottom.addToMesh(mesh);

            if (useTexture)
            {
                mesh.TextureCoordinates = textureCoordinatesCollection;
            }

        }