コード例 #1
0
    // now use time as input variable, to change one mesh at this time
    private void ModifyMidMeshes(int which)
    {
        if (which >= stockmidList.Count)
        {
            return;
        }

        List <float> allMid  = stockmidList[which];
        List <float> openMid = stockmidList[0];
        int          many    = System.Math.Min(allMid.Count, cubesPerMesh);//stockmidList[0].Coun

        try {
            if (which < stockmidList.Count)
            {
                var vertices  = meshes[which].vertices;       // new Vector3[24];
                var triangles = meshes[which].triangles;      // new int[36];
                var normals   = meshes[which].normals;        // new Vector3[24];
                var uv        = meshes[which].uv;             // new Vector2[24];

                for (int stocki = 0; stocki < many; stocki++) // iterates through all stocks
                {
                    if (first)
                    {
                        log("ModifyMid", "stock:" + stocki);
                    }
                    float y_return = (allMid[stocki] - openMid[stocki]) * 10000 / openMid[stocki]; // in bps
                    MeshCube.AddCube(ref vertices, ref triangles, ref normals, ref uv, stocki,     //which
                                     new Vector3(which * spaceRange, y_return, stocki * spaceRange * 10), defaultParticleSize);

                    /*
                     * for (int j = 0; j < 24; j++)  {
                     *  meshes[stocki].vertices[which * 24 + j] = vertices[j];
                     *  meshes[stocki].normals[which * 24 + j] = normals[j];
                     *  meshes[stocki].uv[which * 24 + j] = uv[j];
                     * }
                     * for (int j = 0; j < 36; j++)  {
                     *  meshes[stocki].triangles[which*36+j] = triangles[j];
                     * }
                     */

                    //meshes[which].Optimize();
                }
                meshes[which].vertices  = vertices;
                meshes[which].triangles = triangles;
                meshes[which].normals   = normals;

                meshes[which].uv = uv;

                meshes[which].RecalculateBounds();
            }
        } catch (System.IndexOutOfRangeException e) {
            log("exception", e.ToString());
        }
        first = false;
    }
コード例 #2
0
ファイル: Renderer.cs プロジェクト: EvgenL/Wpf_3d_Viewer
        private void DebugInit()
        {
            var cube = new MeshCube();
            //cube.Scale(2f);
            //processedObjects.Add(cube);

            //var testMesh = FileLoader.ReadMeshFromObj("models/notebook/Lowpoly_Notebook_2.obj");
            var testMesh = FileLoader.ReadMeshFromObj("models/barrel.obj");

            processedObjects.Add(testMesh);
        }
コード例 #3
0
    // now use time as input variable, to change one mesh at this time
    private void ModifyMidMeshes(int which)
    {
        if (which >= stockmidList.Count)
        {
            return;
        }

        List <float> allMid  = stockmidList[which];
        List <float> openMid = stockmidList[0];
        int          many    = allMid.Count;

        for (int stocki = 0; stocki < many; stocki++)    // iterates through all stocks
        {
            if (which < stockmidList.Count)
            {
                var vertices  = meshes[which].vertices;                                        // new Vector3[24];
                var triangles = meshes[which].triangles;                                       // new int[36];
                var normals   = meshes[which].normals;                                         // new Vector3[24];
                var uv        = meshes[which].uv;                                              // new Vector2[24];

                float y_return = (allMid[stocki] - openMid[stocki]) * 10000 / openMid[stocki]; // in bps
                MeshCube.AddCube(ref vertices, ref triangles, ref normals, ref uv, stocki,     //which
                                 new Vector3(which * spaceRange, y_return, stocki * spaceRange * 10), defaultParticleSize);

                /*
                 * for (int j = 0; j < 24; j++)  {
                 *  meshes[stocki].vertices[which * 24 + j] = vertices[j];
                 *  meshes[stocki].normals[which * 24 + j] = normals[j];
                 *  meshes[stocki].uv[which * 24 + j] = uv[j];
                 * }
                 * for (int j = 0; j < 36; j++)  {
                 *  meshes[stocki].triangles[which*36+j] = triangles[j];
                 * }
                 */
                meshes[which].vertices  = vertices;
                meshes[which].triangles = triangles;
                meshes[which].normals   = normals;

                meshes[which].uv = uv;

                meshes[which].RecalculateBounds();
                meshes[which].Optimize();
            }
        }
    }
コード例 #4
0
    private void ModifyStockListMeshes(int which)
    {
        int many = goMeshes.Length;

        for (int stocki = 0; stocki < many; stocki++)    // i iterates through all stocks
        {
            var samples = stockLists[stocki];
            if (which < Counts[stocki])
            {
                var vertices  = meshes[stocki].vertices;  // new Vector3[24];
                var triangles = meshes[stocki].triangles; // new int[36];
                var normals   = meshes[stocki].normals;   // new Vector3[24];
                var uv        = meshes[stocki].uv;        // new Vector2[24];

                float init     = samples[0].open;
                float open     = samples[which].open;
                float y_return = (open - init) * 10000 / init; // in bps
                MeshCube.AddCube(ref vertices, ref triangles, ref normals, ref uv, which,
                                 new Vector3(which * spaceRange, y_return, stocki * spaceRange * 10), defaultParticleSize);

                /*
                 * for (int j = 0; j < 24; j++)  {
                 *  meshes[stocki].vertices[which * 24 + j] = vertices[j];
                 *  meshes[stocki].normals[which * 24 + j] = normals[j];
                 *  meshes[stocki].uv[which * 24 + j] = uv[j];
                 * }
                 * for (int j = 0; j < 36; j++)  {
                 *  meshes[stocki].triangles[which*36+j] = triangles[j];
                 * }
                 */
                meshes[stocki].vertices  = vertices;
                meshes[stocki].triangles = triangles;
                meshes[stocki].normals   = normals;

                meshes[stocki].uv = uv;

                meshes[stocki].RecalculateBounds();
                meshes[stocki].Optimize();
            }
        }
    }
コード例 #5
0
 /// <summary>
 /// Translates a mesh into a wired drawable object
 /// </summary>
 /// <param name="mesh">The mesh to draw</param>
 /// <param name="x">The x-position of the meshs FLB</param>
 /// <param name="y">The y-position of the meshs FLB</param>
 /// <param name="z">The z-position of the meshs FLB</param>
 /// <param name="thickness">The thickness of the edges</param>
 /// <returns>The newly composed drawable object</returns>
 public static ModelVisual3D TranslateWired(MeshCube mesh, double x, double y, double z, double thickness)
 {
     // Init frame model container
     ModelVisual3D model = new ModelVisual3D();
コード例 #6
0
        /// <summary>
        /// Translates a mesh into a solid drawable object
        /// </summary>
        /// <param name="mesh">The mesh to translate</param>
        /// <param name="color">The color to use for the object</param>
        /// <param name="offSetX">An optional offset by which the object gets shifted along the x-axis</param>
        /// <param name="offSetY">An optional offset by which the object gets shifted along the y-axis</param>
        /// <param name="offSetZ">An optional offset by which the object gets shifted along the z-axis</param>
        /// <param name="brushType">Indicates the brush to use</param>
        /// <param name="text">The text which is drawn on the object</param>
        /// <param name="hazMatBrush">A brush declaring the class of hazardous materials</param>
        /// <param name="handlingBrush">A brush indicating the handling class of the object</param>
        /// <returns>The newly composed drawable object</returns>
        public static ModelVisual3D Translate(
            MeshCube mesh,
            Color color,
            double offSetX           = 0,
            double offSetY           = 0,
            double offSetZ           = 0,
            BrushType brushType      = BrushType.Plain,
            string text              = null,
            ImageBrush hazMatBrush   = null,
            ImageBrush handlingBrush = null)
        {
            // Init
            BoxVisual3D box = new BoxVisual3D();

            box.Center = new Point3D(
                (mesh.RelPosition.X + mesh.Length / 2.0) + offSetX,
                (mesh.RelPosition.Y + mesh.Width / 2.0) + offSetY,
                (mesh.RelPosition.Z + mesh.Height / 2.0) + offSetZ);
            box.Length = mesh.Length;
            box.Width  = mesh.Width;
            box.Height = mesh.Height;
            // Add brush based on supplied type
            box.Material = brushType switch
            {
                BrushType.Plain => new DiffuseMaterial(GeneratePlainBrush(color)),
                BrushType.StripedWhite => new DiffuseMaterial(GenerateStripeBrush(color, Colors.White)),
                BrushType.StripedBlack => new DiffuseMaterial(GenerateStripeBrush(color, Colors.Black)),
                BrushType.CheckeredWhite => new DiffuseMaterial(GenerateCheckerBrush(color, Colors.White)),
                BrushType.CheckeredBlack => new DiffuseMaterial(GenerateCheckerBrush(color, Colors.Black)),
                _ => new DiffuseMaterial(GeneratePlainBrush(color)),
            };
            // Draw text on brush if supplied
            if (text != null && text != "")
            {
                if (handlingBrush == null && hazMatBrush == null)
                {
                    box.Children.Add(CreateTextLabel3D(
                                         text,
                                         Brushes.Black,
                                         false,
                                         mesh.Width / 1.1,
                                         mesh.Length / 1.1,
                                         new Point3D(
                                             offSetX + mesh.RelPosition.X + mesh.Length / 2.0,
                                             offSetY + mesh.RelPosition.Y + mesh.Width / 2.0,
                                             offSetZ + mesh.RelPosition.Z + mesh.Height + 0.001),
                                         new Vector3D(0, -1, 0),
                                         new Vector3D(1, 0, 0)));
                }
                else
                {
                    box.Children.Add(CreateTextLabel3D(
                                         text,
                                         Brushes.Black,
                                         false,
                                         mesh.Width / 1.1,
                                         (mesh.Length / 2.0) / 1.1,
                                         new Point3D(
                                             offSetX + mesh.RelPosition.X + (3.0 * (mesh.Length / 4.0)),
                                             offSetY + mesh.RelPosition.Y + mesh.Width / 2.0,
                                             offSetZ + mesh.RelPosition.Z + mesh.Height + 0.001),
                                         new Vector3D(0, -1, 0),
                                         new Vector3D(1, 0, 0)));
                }
            }
            // Draw handling icon on brush if supplied
            if (handlingBrush != null)
            {
                box.Children.Add(CreateImageLabel3D(
                                     handlingBrush,
                                     Math.Min(mesh.Length / 2.0, mesh.Width / 2.0) / 1.1,
                                     Math.Min(mesh.Length / 2.0, mesh.Width / 2.0) / 1.1,
                                     new Point3D(
                                         offSetX + mesh.RelPosition.X + (1.0 * (mesh.Length / 4.0)),
                                         offSetY + mesh.RelPosition.Y + (1.0 * (mesh.Width / 4.0)),
                                         offSetZ + mesh.RelPosition.Z + mesh.Height + 0.001),
                                     new Vector3D(0, -1, 0),
                                     new Vector3D(1, 0, 0)));
            }
            // Draw material icon on brush if supplied
            if (hazMatBrush != null)
            {
                box.Children.Add(CreateImageLabel3D(
                                     hazMatBrush,
                                     Math.Min(mesh.Length / 2.0, mesh.Width / 2.0) / 1.1,
                                     Math.Min(mesh.Length / 2.0, mesh.Width / 2.0) / 1.1,
                                     new Point3D(
                                         offSetX + mesh.RelPosition.X + (1.0 * (mesh.Length / 4.0)),
                                         offSetY + mesh.RelPosition.Y + (3.0 * (mesh.Width / 4.0)),
                                         offSetZ + mesh.RelPosition.Z + mesh.Height + 0.001),
                                     new Vector3D(0, -1, 0),
                                     new Vector3D(1, 0, 0)));
            }


            // Return it
            return(box);
        }
コード例 #7
0
    void CreateMidMeshes()
    {
        stockmidList = MarketDataParser.LoadStocksMid();
        int maxSamples = stockmidList.Count;

        log("createMidMeshes", "entry");
        int stocksToRender = System.Math.Min(stockmidList[0].Count, cubesPerMesh);

        print("stockCount=" + stocksToRender + ", cubersPerMesh=" + cubesPerMesh);


        int NMeshes = 100;

        if (maxSamples > NMeshes)
        {
            maxSamples = NMeshes;
        }
        goMeshes = new GameObject[NMeshes]; // maxSamples//[stocksToRender];
        meshes   = new Mesh[NMeshes];       // stocksToRender];

        // GaussianRandom gaussianRandom = new GaussianRandom();

        List <Color> mesh_colors = new List <Color> {
            Color.red, Color.green, Color.blue, Color.yellow
        };
        int color_choices = mesh_colors.Count;

        Counts = new int[stocksToRender];
        for (int t = 0; t < maxSamples; t++)     //cubesPerMesh &&
                                                 //
        {
            log("createMidMeshes", "item:" + t);
            GameObject go = new GameObject("Mesh " + t);//GameObject.CreatePrimitive(PrimitiveType.Cube); //
            go.transform.parent = transform;
            MeshFilter mf   = go.AddComponent <MeshFilter>();
            Mesh       mesh = new Mesh();
            //        mesh.MarkDynamic();   // don't think it changes often anymore if we change the mesh to be across stocks
            mf.mesh = mesh;
            Renderer rend = go.AddComponent <MeshRenderer>();
            rend.material       = material;
            rend.material.color = mesh_colors[t % color_choices];

            var vertices     = new Vector3[24 * cubesPerMesh];
            var triangles    = new int[36 * cubesPerMesh];
            var normals      = new Vector3[24 * cubesPerMesh];
            var colors       = new Color[24 * cubesPerMesh];
            int vertex_group = 10 * 24;
            for (int c = 0; c < colors.Length / vertex_group; ++c)
            {
                var a_color = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f));
                for (int k = 0; k < vertex_group; ++k)
                {
                    colors[vertex_group * c + k] = a_color;
                }
            }
            var uv = new Vector2[24 * cubesPerMesh];

            float x_time = 0, y_return = 0;
            // TODO: cubesPerMesh might be smaller than the sample count
            //for (int t = 0; t < cubesPerMesh && t < maxSamples; t++) {
            for (int iStock = 0; iStock < stocksToRender; iStock++)
            {
                // x=> screen x
                // y=> screen y
                // z=> depth

                //x = (float)(gaussianRandom.NextGaussian() * spaceRange);
                //z = (float)(gaussianRandom.NextGaussian() * spaceRange);
                //y = (float)(0.1*x + 0.2*z + gaussianRandom.NextGaussian() * 0.5 * spaceRange );

                x_time += spaceRange;

                print("Adding x_time=" + x_time
                      + ", y_price=" + y_return
                      + ", z_stock" + iStock);
                MeshCube.AddCube(ref vertices, ref triangles, ref normals, ref uv, iStock,
                                 new Vector3(x_time, 0, iStock * spaceRange * 10), defaultParticleSize / 2);
            }

            mesh.vertices  = vertices;
            mesh.triangles = triangles;
            mesh.normals   = normals;
            mesh.colors    = colors;
            mesh.uv        = uv;
            mesh.RecalculateBounds();
            mesh.Optimize();
            for (int k = 0; k < 5; k++)
            {
                print("k=" + k);
                print("vertices: " + mesh.vertices[k]);
                print("triangles: " + mesh.triangles[k]);
                print("normals: " + mesh.normals[k]);
                print("uv: " + mesh.uv[k]);
                print("colors: " + mesh.colors[k]);
            }

            goMeshes[t] = go;
            meshes[t]   = mesh;
        }
        log("createMidMeshes", "exit");
        print("Meshes created");
    }
コード例 #8
0
    void CreateStockListMeshes()
    {
        stockLists = MarketDataParser.LoadStocks();
        int maxSamples = 0;

        foreach (var list in stockLists)
        {
            if (maxSamples < list.Count)
            {
                maxSamples = list.Count;
            }
        }

        particles = new Particle[maxSamples];
        for (int i = 0; i < particles.Length; i++)
        {
            particles[i].size  = defaultParticleSize;
            particles[i].color = defaultParticleColor;
        }

        int stocksToRender = stockLists.Count;

        print("stockCount=" + stockLists.Count + ", cubersPerMesh=" + cubesPerMesh);

        goMeshes = new GameObject[stockLists.Count];
        meshes   = new Mesh[stockLists.Count];

        GaussianRandom gaussianRandom = new GaussianRandom();

        List <Color> mesh_colors = new List <Color> {
            Color.red, Color.green, Color.blue, Color.yellow
        };
        int color_choices = mesh_colors.Count;

        Counts = new int[stockLists.Count];
        for (int i = 0; i < stockLists.Count; i++)
        {
            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube); //new GameObject("Mesh " + i);
            go.transform.parent = transform;
            MeshFilter mf   = go.AddComponent <MeshFilter>();
            Mesh       mesh = new Mesh();
            mesh.MarkDynamic();
            mf.mesh = mesh;
            Renderer rend = go.AddComponent <MeshRenderer>();
            rend.material       = material;
            rend.material.color = mesh_colors[i % color_choices];



            var vertices     = new Vector3[24 * cubesPerMesh];
            var triangles    = new int[36 * cubesPerMesh];
            var normals      = new Vector3[24 * cubesPerMesh];
            var colors       = new Color[24 * cubesPerMesh];
            int vertex_group = 10 * 24;
            var uv           = new Vector2[24 * cubesPerMesh];

            for (int c = 0; c < colors.Length / vertex_group; ++c)
            {
                var a_color = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f));
                for (int k = 0; k < vertex_group; ++k)
                {
                    colors[vertex_group * c + k] = a_color;
                }
            }


            float x_time = 0, y_return = 0;
            // TODO: cubesPerMesh might be smaller than the sample count
            var samples = stockLists[i];
            Counts[i] = samples.Count;
            for (int j = 0; j < cubesPerMesh && j < samples.Count; j++)
            {
                // x=> screen x
                // y=> screen y
                // z=> depth

                //x = (float)(gaussianRandom.NextGaussian() * spaceRange);
                //z = (float)(gaussianRandom.NextGaussian() * spaceRange);
                //y = (float)(0.1*x + 0.2*z + gaussianRandom.NextGaussian() * 0.5 * spaceRange );

                x_time += spaceRange;
                float init = samples[0].open;
                float open = samples[j].open;
                y_return = (open - init) * 10000 / init; // in bps

                print("Adding x_time=" + x_time
                      + ", y_price=" + y_return
                      + ", z_stock" + i);
                MeshCube.AddCube(ref vertices, ref triangles, ref normals, ref uv, j,
                                 new Vector3(x_time, 0, i * spaceRange * 10), defaultParticleSize / 2);
            }

            mesh.vertices  = vertices;
            mesh.triangles = triangles;
            mesh.normals   = normals;
            mesh.colors    = colors;
            mesh.uv        = uv;
            mesh.RecalculateBounds();
            mesh.Optimize();
            for (int k = 0; k < 5; k++)
            {
                print("k=" + k);
                print("vertices: " + mesh.vertices[k]);
                print("triangles: " + mesh.triangles[k]);
                print("normals: " + mesh.normals[k]);
                print("uv: " + mesh.uv[k]);
                print("colors: " + mesh.colors[k]);
            }

            goMeshes[i] = go;
            meshes[i]   = mesh;
        }

        print("Meshes created");
    }
コード例 #9
0
    private void NewModifyMidMeshes(int which)
    {
        if (which >= stockmidList.Count)
        {
            return;
        }
        if (which <= startFrom)
        {
            frameCount++;
            return;
        }

        log("NewModifyMid", "lastFrame = " + frameCount);
        frameCount = 0;
        startFrom  = which;

        List <float> allMid      = stockmidList[which];
        List <float> openMid     = stockmidList[0];
        List <Color> mesh_colors = new List <Color> {
            Color.red, Color.green, Color.blue, Color.yellow
        };
        int color_choices = mesh_colors.Count;
        int many          = System.Math.Min(allMid.Count, cubesPerMesh);//stockmidList[0].Coun

        try {
            if (which < stockmidList.Count)
            {
                log("createMidMeshes", "item:" + which);
                GameObject go = new GameObject("Mesh " + which);//GameObject.CreatePrimitive(PrimitiveType.Cube); //
                go.transform.parent = transform;
                MeshFilter mf   = go.AddComponent <MeshFilter>();
                Mesh       mesh = new Mesh();
                //        mesh.MarkDynamic();   // don't think it changes often anymore if we change the mesh to be across stocks
                mf.mesh = mesh;
                Renderer rend = go.AddComponent <MeshRenderer>();
                rend.material       = material;
                rend.material.color = mesh_colors[which % color_choices];

                var vertices  = new Vector3[24 * cubesPerMesh];
                var triangles = new int[36 * cubesPerMesh];
                var normals   = new Vector3[24 * cubesPerMesh];
                var colors    = new Color[24 * cubesPerMesh];

                var uv = new Vector2[24 * cubesPerMesh];


                for (int stocki = 0; stocki < many; stocki++)    // iterates through all stocks
                {
                    if (first)
                    {
                        log("ModifyMid", "stock:" + stocki);
                    }



                    float   y_return    = (allMid[stocki] - openMid[stocki]) * 10000 / openMid[stocki]; // in bps
                    Vector3 newLocation = new Vector3(which * spaceRange, y_return, stocki * spaceRange * 10);

                    Vector3 worldPt = transform.TransformPoint(newLocation);
                    MeshCube.AddCube(ref vertices, ref triangles, ref normals, ref uv, stocki, //which
                                     worldPt,                                                  // GetVertexWorldPosition(newLocation, transform),
                                     defaultParticleSize);


                    //meshes[which].Optimize();
                }

                mesh.vertices  = vertices;
                mesh.triangles = triangles;
                mesh.normals   = normals;
                mesh.colors    = colors;
                mesh.uv        = uv;
                mesh.RecalculateBounds();
                mesh.Optimize();
            }
        } catch (System.IndexOutOfRangeException e) {
            log("exception", e.ToString());
        }
        first = false;
    }
コード例 #10
0
        /// <summary>
        /// Generates the vertex corresponding to the supplied ID
        /// </summary>
        /// <param name="mesh">The mesh for which the vertex shall be generated</param>
        /// <param name="vertexID">The ID of the vertex</param>
        /// <returns>The generated vertex</returns>
        private static MeshPoint GenerateVertex(MeshCube mesh, int vertexID)
        {
            // Initiate vertex point
            MeshPoint point = null;

            switch (vertexID)
            {
            case 0:
            {
                // Center
                point = new MeshPoint()
                {
                    VertexID = 0,
                    X        = mesh.Length / 2.0,
                    Y        = mesh.Width / 2.0,
                    Z        = mesh.Height / 2.0
                };
            }
            break;

            case 1:
            {
                // Front left bottom
                point = new MeshPoint()
                {
                    VertexID = 1,
                    X        = 0,
                    Y        = 0,
                    Z        = 0
                };
            }
            break;

            case 2:
            {
                // Front right bottom
                point = new MeshPoint()
                {
                    VertexID = 2,
                    X        = mesh.Length,
                    Y        = 0,
                    Z        = 0
                };
            }
            break;

            case 3:
            {
                // Rear left bottom
                point = new MeshPoint()
                {
                    VertexID = 3,
                    X        = 0,
                    Y        = mesh.Width,
                    Z        = 0
                };
            }
            break;

            case 4:
            {
                // Rear right bottom
                point = new MeshPoint()
                {
                    VertexID = 4,
                    X        = mesh.Length,
                    Y        = mesh.Width,
                    Z        = 0
                };
            }
            break;

            case 5:
            {
                // Front left top
                point = new MeshPoint()
                {
                    VertexID = 5,
                    X        = 0,
                    Y        = 0,
                    Z        = mesh.Height
                };
            }
            break;

            case 6:
            {
                // Front right top
                point = new MeshPoint()
                {
                    VertexID = 6,
                    X        = mesh.Length,
                    Y        = 0,
                    Z        = mesh.Height
                };
            }
            break;

            case 7:
            {
                // Rear left top
                point = new MeshPoint()
                {
                    VertexID = 7,
                    X        = 0,
                    Y        = mesh.Width,
                    Z        = mesh.Height
                };
            }
            break;

            case 8:
            {
                // Rear right top
                point = new MeshPoint()
                {
                    VertexID = 8,
                    X        = mesh.Length,
                    Y        = mesh.Width,
                    Z        = mesh.Height
                };
            }
            break;

            default:
                throw new ArgumentException("No vertex with ID " + vertexID + " defined");
            }
            return(point);
        }
コード例 #11
0
        /// <summary>
        /// Generates the given vertex for the given component of a piece
        /// </summary>
        /// <param name="piece">The piece the component belongs to</param>
        /// <param name="vertexID">The ID of the vertex to generate</param>
        /// <param name="component">The component the vertex is generated for</param>
        /// <returns>The newly generated vertex</returns>
        public static MeshPoint GenerateVertex(int vertexID, MeshCube component, Piece piece)
        {
            // Initiate vertex point
            MeshPoint point = null;

            switch (vertexID)
            {
            case 0:
            {
                // Center
                point = new MeshPoint()
                {
                    VertexID    = 0,
                    ParentPiece = piece,
                    X           = component.RelPosition.X + (component.Length / 2.0),
                    Y           = component.RelPosition.Y + (component.Width / 2.0),
                    Z           = component.RelPosition.Z + (component.Height / 2.0),
                };
            }
            break;

            case 1:
            {
                // Front left bottom
                point = new MeshPoint()
                {
                    VertexID    = 1,
                    ParentPiece = piece,
                    X           = component.RelPosition.X,
                    Y           = component.RelPosition.Y,
                    Z           = component.RelPosition.Z,
                };
            }
            break;

            case 2:
            {
                // Front right bottom
                point = new MeshPoint()
                {
                    VertexID    = 2,
                    ParentPiece = piece,
                    X           = component.RelPosition.X + component.Length,
                    Y           = component.RelPosition.Y,
                    Z           = component.RelPosition.Z,
                };
            }
            break;

            case 3:
            {
                // Rear left bottom
                point = new MeshPoint()
                {
                    VertexID    = 3,
                    ParentPiece = piece,
                    X           = component.RelPosition.X,
                    Y           = component.RelPosition.Y + component.Width,
                    Z           = component.RelPosition.Z,
                };
            }
            break;

            case 4:
            {
                // Rear right bottom
                point = new MeshPoint()
                {
                    VertexID    = 4,
                    ParentPiece = piece,
                    X           = component.RelPosition.X + component.Length,
                    Y           = component.RelPosition.Y + component.Width,
                    Z           = component.RelPosition.Z,
                };
            }
            break;

            case 5:
            {
                // Front left top
                point = new MeshPoint()
                {
                    VertexID    = 5,
                    ParentPiece = piece,
                    X           = component.RelPosition.X,
                    Y           = component.RelPosition.Y,
                    Z           = component.RelPosition.Z + component.Height,
                };
            }
            break;

            case 6:
            {
                // Front right top
                point = new MeshPoint()
                {
                    VertexID    = 6,
                    ParentPiece = piece,
                    X           = component.RelPosition.X + component.Length,
                    Y           = component.RelPosition.Y,
                    Z           = component.RelPosition.Z + component.Height,
                };
            }
            break;

            case 7:
            {
                // Rear left top
                point = new MeshPoint()
                {
                    VertexID    = 7,
                    ParentPiece = piece,
                    X           = component.RelPosition.X,
                    Y           = component.RelPosition.Y + component.Width,
                    Z           = component.RelPosition.Z + component.Height,
                };
            }
            break;

            case 8:
            {
                // Rear right top
                point = new MeshPoint()
                {
                    VertexID    = 8,
                    ParentPiece = piece,
                    X           = component.RelPosition.X + component.Length,
                    Y           = component.RelPosition.Y + component.Width,
                    Z           = component.RelPosition.Z + component.Height,
                };
            }
            break;

            default:
                throw new ArgumentException("No vertex with ID " + vertexID + " defined");
            }
            return(point);
        }