Пример #1
0
    // 腰围
    private void scaleWaistGrith(float scale)
    {
        Vector3[] old    = sizedMesh.vertices;
        Vector3[] tmp    = templateMesh.vertices;
        Vector3[] tmpLen = templateLenMesh.vertices;
        ArrayList vertex = templateBody.vertexIndexsPerBone [HumanBone.Pelvis];
        float     top    = planes.getPlaneHeight("PlaneWaistTop");
        float     waist  = planes.getPlaneHeight("PlaneWaist");
        float     bottom = planes.getPlaneHeight("PlaneWaistBottom");
        float     height = top - bottom;
        float     std    = ControlPoints.wasitBezier.getBezierPoint((waist - bottom) / height).z;

        for (int i = 0; i < vertex.Count; ++i)
        {
            if (tmp [(int)vertex [i]].y <top && tmp [(int)vertex [i]].y> bottom)
            {
                float   ratio         = (tmp [(int)vertex [i]].y - bottom) / height;
                float   p             = (ControlPoints.wasitBezier.getBezierPoint(ratio).z - std) / 5.0f + 1.0f;
                Vector3 projectNormal = AuxMath.projectOnPlane(templateMesh.normals [(int)vertex [i]], Vector3.up);
                float   cosAngel      = Vector3.Dot(projectNormal.normalized, Vector3.forward);
                //float sinAngel_square = 1.0f - cosAngel * cosAngel;
                float k = (scale - 1.0f) * cosAngel +
                          Mathf.Sqrt((scale - 1.0f) * (scale - 1.0f) * cosAngel * cosAngel + 2 * scale - 1);
                old [(int)vertex [i]] = tmpLen [(int)vertex [i]] +
                                        (templateMesh.normals [(int)vertex [i]] * (k - 1.0f) * measurement [HumanSize.Waist_Grith] * p);
            }
        }
        sizedMesh.vertices = old;
    }
Пример #2
0
    // 臀围
    private void scaleHipGrith(float scale)
    {
        Vector3[] old    = sizedMesh.vertices;
        Vector3[] tmp    = templateMesh.vertices;
        Vector3[] tmpLen = templateLenMesh.vertices;
        ArrayList vertex = templateBody.vertexIndexsPerBone [HumanBone.Pelvis];
        float     top    = planes.getPlaneHeight("PlaneHipTop");

        float[] topPlane = planes.getControlPlane("PlaneHipTop");
        float   hip      = planes.getPlaneHeight("PlaneHip");
        float   bottom   = planes.getPlaneHeight("PlaneHipBottom");
        float   height   = top - bottom;
        float   std      = ControlPoints.hipBezier.getBezierPoint((hip - bottom) / height).z;

        for (int i = 0; i < vertex.Count; ++i)
        {
            if (!AuxMath.isAbovePlane(tmp [(int)vertex [i]], topPlane) && tmp [(int)vertex [i]].y > bottom)
            {
                float   ratio         = (tmp [(int)vertex [i]].y - bottom) / height;
                float   p             = (ControlPoints.hipBezier.getBezierPoint(ratio).z - std) / 5.0f + 1.0f;
                Vector3 projectNormal = AuxMath.projectOnPlane(templateMesh.normals [(int)vertex [i]], Vector3.up);
                float   cosAngel      = Vector3.Dot(projectNormal.normalized, Vector3.back);
                float   k             = (scale - 1.0f) * cosAngel +
                                        Mathf.Sqrt((scale - 1.0f) * (scale - 1.0f) * cosAngel * cosAngel + 2 * scale - 1);
                old [(int)vertex [i]] = tmpLen [(int)vertex [i]] +
                                        (templateMesh.normals [(int)vertex [i]] * (k - 1.0f) * measurement [HumanSize.Hip_Grith] * p);
            }
        }
        sizedMesh.vertices = old;
    }
Пример #3
0
    // 胸围
    private void scaleBustGrith(float scale)
    {
        Vector3[] old    = sizedMesh.vertices;
        Vector3[] tmp    = templateMesh.vertices;
        Vector3[] tmpLen = templateLenMesh.vertices;
        ArrayList vertex = templateBody.vertexIndexsPerBone [HumanBone.Spine2];

        float[] top         = planes.getControlPlane("PlaneBustTop");
        float[] topL        = planes.getControlPlane("PlaneBustTopLeft");
        float[] topR        = planes.getControlPlane("PlaneBustTopRight");
        float[] bust        = planes.getControlPlane("PlaneBust");
        float[] bottom      = planes.getControlPlane("PlaneBustBottom");
        Vector3 busthNormal = new Vector3(bust [0], bust [1], bust [2]);

        // Scale the left thigh
        for (int i = 0; i < vertex.Count; ++i)
        {
            if (AuxMath.isAbovePlane(tmp [(int)vertex [i]], top) !=
                AuxMath.isAbovePlane(tmp [(int)vertex [i]], bottom))
            {
                if (!AuxMath.isAbovePlane(tmp [(int)vertex [i]], topL) &&
                    !AuxMath.isAbovePlane(tmp [(int)vertex [i]], topR))
                {
                    Vector3 projectNormal = AuxMath.projectOnPlane(templateMesh.normals [(int)vertex [i]],
                                                                   busthNormal);
                    float cosAngel = Vector3.Dot(projectNormal.normalized, Vector3.forward);
                    float k        = (scale - 1.0f) * cosAngel +
                                     Mathf.Sqrt((scale - 1.0f) * (scale - 1.0f) * cosAngel * cosAngel + 2 * scale - 1);
                    old [(int)vertex [i]] = tmpLen [(int)vertex [i]] +
                                            (templateMesh.normals [(int)vertex [i]] * (k - 1.0f) * measurement [HumanSize.Bust_Grith]);
                }
            }
        }
        sizedMesh.vertices = old;
    }
Пример #4
0
    // 大腿围
    private void scaleThighGrith(float scale)
    {
        Vector3[] old    = sizedMesh.vertices;
        Vector3[] tmp    = templateMesh.vertices;
        Vector3[] tmpLen = templateLenMesh.vertices;
        ArrayList vertex = templateBody.vertexIndexsPerBone [HumanBone.L_Thigh];

        float[] top         = planes.getControlPlane("PlaneThighTopLeft");
        float[] thigh       = planes.getControlPlane("PlaneThigh");
        float[] bottom      = planes.getControlPlane("PlaneThighBottom");
        Vector3 thighNormal = new Vector3(thigh [0], thigh [1], thigh [2]);

        // Scale the left thigh
        for (int i = 0; i < vertex.Count; ++i)
        {
            if (AuxMath.isAbovePlane(tmp [(int)vertex [i]], top) !=
                AuxMath.isAbovePlane(tmp [(int)vertex [i]], bottom))
            {
                Vector3 projectNormal = AuxMath.projectOnPlane(templateMesh.normals [(int)vertex [i]],
                                                               thighNormal);
                float cosAngel = Vector3.Dot(projectNormal.normalized, Vector3.back);
                float k        = (scale - 1.0f) * cosAngel +
                                 Mathf.Sqrt((scale - 1.0f) * (scale - 1.0f) * cosAngel * cosAngel + 2 * scale - 1);
                old [(int)vertex [i]] = tmpLen [(int)vertex [i]] +
                                        (templateMesh.normals [(int)vertex [i]] * (k - 1.0f) * measurement [HumanSize.Thigh_Grith]);
            }
        }
        // Scale the Right Thigh
        vertex = templateBody.vertexIndexsPerBone [HumanBone.R_Thigh];
        top    = planes.getControlPlane("PlaneThighTopRight");
        for (int i = 0; i < vertex.Count; ++i)
        {
            if (AuxMath.isAbovePlane(tmp [(int)vertex [i]], top) !=
                AuxMath.isAbovePlane(tmp [(int)vertex [i]], bottom))
            {
                Vector3 projectNormal = AuxMath.projectOnPlane(templateMesh.normals [(int)vertex [i]],
                                                               thighNormal);
                float cosAngel = Vector3.Dot(projectNormal.normalized, Vector3.back);
                float k        = (scale - 1.0f) * cosAngel +
                                 Mathf.Sqrt((scale - 1.0f) * (scale - 1.0f) * cosAngel * cosAngel + 2 * scale - 1);
                old [(int)vertex [i]] = tmpLen [(int)vertex [i]] +
                                        (templateMesh.normals [(int)vertex [i]] * (k - 1.0f) * measurement [HumanSize.Thigh_Grith]);
            }
        }
        sizedMesh.vertices = old;
    }