Esempio n. 1
0
    void m_WheelModel_reinitialize()
    {
        m_wheel_mesh_sections_count = m_spokes_count * (m_wheel_mesh_additional_sections_count + 1);

        m_rim_base_sections = new Points3D[m_wheel_mesh_sections_count + 1];
        for (int i = 0; i < m_wheel_mesh_sections_count; ++i)
        {
            m_rim_base_sections[i] = new Points3D();
            m_rim_base_sections[i].addPoint(new Vector3D(0, -0.015, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(-0.008, -0.015, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(-0.008, -0.020, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(-0.010, -0.020, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(-0.010, -0.010, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(-0.005, 0, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(0.005, 0, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(0.010, -0.010, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(0.010, -0.020, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(0.008, -0.020, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(0.008, -0.015, 0));
            m_rim_base_sections[i].addPoint(new Vector3D(0, -0.015, 0));
        }

        int base_section_point_count = m_rim_base_sections[0].points_count;

        double[][] rough_wave_x    = new double [base_section_point_count][];
        double[][] rough_wave_y    = new double [base_section_point_count][];
        int        rough_min_range = (m_wheel_mesh_sections_count / m_spokes_count) * 3;
        int        rough_max_range = (m_wheel_mesh_sections_count / m_spokes_count) * 6;

        for (int i = 0; i < base_section_point_count; ++i)
        {
            rough_wave_x[i] = SplineInterpolator.generateRoughLoopedCurve(m_wheel_mesh_sections_count, rough_min_range, rough_max_range, m_rim_rough_size);
            rough_wave_y[i] = SplineInterpolator.generateRoughLoopedCurve(m_wheel_mesh_sections_count, rough_min_range, rough_max_range, m_rim_rough_size);
        }

        for (int i = 0; i < m_wheel_mesh_sections_count; ++i)
        {
            for (int j = 1; j < base_section_point_count - 1; ++j)   //exclude seam

            {
                m_rim_base_sections[i][j] += new Vector3D(rough_wave_x[j][i], rough_wave_y[j][i], 0);
            }
        }

        m_rim_base_sections[m_wheel_mesh_sections_count] = m_rim_base_sections[0].copy();

        m_WheelModel = new WheelModel(m_spokes_count, m_cross_count, m_rim_d, m_hub_d, m_axle_length, m_l_dish, m_r_dish);
        for (int i = 0; i < m_WheelModel.spokes_count; ++i)
        {
            m_WheelModel_spokes_rev90_offset[i] = UnityEngine.Random.Range(0, 4);
        }

        m_WheelModel_random_unbalance();
    }