Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var stockMidList = MarketDataParser.LoadStocksMid();

            var stocks = MarketDataParser.LoadStocks();

            foreach (var stock_samples in stocks)
            {
                foreach (var sample in stock_samples)
                {
                    //Console.WriteLine(sample);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
    void NewCreateMidMeshes()
    {
        stockmidList = MarketDataParser.LoadStocksMid();
        int maxSamples = stockmidList.Count;

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

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

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


        int NMeshes = 100;

//        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];


        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;
            }
        }

        print("Meshes created");
    }
Ejemplo n.º 3
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");
    }