protected void InitMesh()
    {
        // Init Meshes and the Renderer
        SkinnedMeshRenderer renderer = this.gameObject.GetComponent <SkinnedMeshRenderer>();
        Mesh mesh = MeshMaker.Cylinder(width, length, segmentCount, meshSides);

        Vector3[]    vertices    = mesh.vertices;
        BoneWeight[] boneWeights = new BoneWeight[vertices.Length];
        Matrix4x4[]  bindPoses   = new Matrix4x4[segments.Length];

        for (int i = 0; i < boneWeights.Length; i++)
        {
            int id = Mathf.RoundToInt(-vertices[i].y / SegmentLength);
            boneWeights[i].boneIndex0 = id;
            boneWeights[i].weight0    = 1;
        }
        mesh.boneWeights = boneWeights;

        for (int i = 0; i < segments.Length; i++)
        {
            bindPoses[i] = segments[i].worldToLocalMatrix * transform.localToWorldMatrix;
        }


        mesh.bindposes      = bindPoses;
        renderer.bones      = segments;
        renderer.sharedMesh = mesh;

        renderer.localBounds = new Bounds(new Vector3(0, -length / 2, 0),
                                          new Vector3(width, length, width));

        renderer.allowOcclusionWhenDynamic = false;
        renderer.updateWhenOffscreen       = true;
        renderer.sharedMaterial            = material;
    }