Example #1
0
        private static void DrawAtlas_ONE(Vector2[] atlasRect, hgMesh.MeshSet meshSet, int boneIndex, Vector3[] vs, int colorIndex)
        {
            int save_vsize = (meshSet != null) ? meshSet.vclist.Count : 0;

            // Vertex
            meshSet.vlist.AddRange(vs);

            // Vcolor
            var ncolor = hglHtmlColor.IndexToVColor(colorIndex);

            ncolor.a = 17f / 64f - 1f / 128f;
            meshSet.vclist.AddRange(new Color[] { ncolor, ncolor, ncolor, ncolor });

            // Triangle
            meshSet.trilist.AddRange(new int[] { save_vsize, save_vsize + 1, save_vsize + 3 });
            meshSet.trilist.AddRange(new int[] { save_vsize, save_vsize + 3, save_vsize + 2 });

            /* uv
             *  0--1
             |  |
             |  2--3
             |
             */
            meshSet.uvlist.AddRange(atlasRect);

            // bone weights
            if (boneIndex < 0)
            {
                throw new SystemException("Unexpected!");
            }
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[0]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[1]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[2]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[3]
        }
Example #2
0
        private static Transform CreateBone(hgMesh.MeshSet ms, string nm, int index, Transform parent, Vector3 localPos, bool bCalcBindPose)
        {
            var bone = new GameObject(nm + index.ToString()).transform;

            bone.transform.parent = parent;
            bone.localRotation    = Quaternion.identity;
            bone.localScale       = Vector3.one;
            if (float.IsNaN(localPos.x) || float.IsNaN(localPos.y) || float.IsNaN(localPos.z))
            {
                throw new SystemException("LocalPos Has NANs. Unexpected!");
            }
            bone.localPosition = localPos;
            Matrix4x4 bp = Matrix4x4.identity;

            if (bCalcBindPose)
            {
                bp = bone.worldToLocalMatrix * parent.localToWorldMatrix;
            }
            ms.bnlist.Add(bone);
            ms.bplist.Add(bp);
            return(bone);
        }
Example #3
0
        /*
         *  Management of Atlas Objects
         */


        public static void Create(hgMesh.CD_IMAGE cd, Func <int> getBoneIndex, hgMesh.MeshSet ms)
        {
            int boneIndex = getBoneIndex();

            hgRect r = new hgRect(cd.inner_v);

            Vector2[] atlas_r;
            hgAtlasInfoData.RECTPATTERN pattern;
            hgAtlasInfoData.StrechMode  mode;
            int[]   size;
            Vector2 perfectSize;

            cd.atlasInfo.GetRect(cd.atlasName, out perfectSize, out atlas_r, out pattern, out size, out mode);
            hgMeshAtlas.DrawAtlas_Sub4(pattern, atlas_r, size, perfectSize, ms, boneIndex, cd.inner_v, cd.colorIndex, mode, false);

            var abone = CreateBone(ms, cd.atlasName + ".", boneIndex, cd.bone, new Vector3(r.center.x, r.center.y, 0), true);

            if (cd.xe != null)
            {
                cd.xe.bone1 = abone;
            }
        }
Example #4
0
        public static void DrawAtlas_REPEAT(Vector2[] atlasUvs, Vector2 atlasSize, Vector2 offset, hgMesh.MeshSet meshSet, int boneIndex, Vector3[] vs, int colorIndex)
        {
            List <REPEATDATA> list = new List <REPEATDATA>();

            Vector3 startPos = vs[0];

            Vector2 uvOffset = Vector2.zero;
            {
                int ix = (int)offset.x % (int)atlasSize.x;
                int iy = (int)offset.y % (int)atlasSize.y;

                float x = ix > 0 ? atlasSize.x - ix : 0;
                float y = iy > 0 ? atlasSize.y - iy : 0;
                uvOffset = new Vector2(x, y);
            }

            const int loopmax = 1000;

            for (var i = 0; i <= loopmax; i++)
            {
                if (i == loopmax)
                {
                    throw new SystemException("Unexpected! Too much Loop at DrawAtlas_REPEAT");
                }
                REPEATDATA d = REPEATDATA.Create(startPos, vs, uvOffset, atlasSize, atlasUvs);
                list.Add(d);
                if (d.vs[3].x >= vs[3].x)
                {
                    if (d.vs[3].y <= vs[3].y)
                    {
                        break;
                    }
                    startPos = d.vs[3].y * Vector3.up + vs[0].x * Vector3.right;
                }
                else
                {
                    startPos = d.vs[1];
                }
            }

            if (meshSet == null)
            {
                return;
            }
            foreach (var d in list)
            {
                int save_vsize = meshSet.vclist.Count;

                // Vertex
                meshSet.vlist.AddRange(d.vs);

                // Vcolor
                var ncolor = hglHtmlColor.IndexToVColor(colorIndex);
                ncolor.a = 17f / 64f - 1f / 128f;
                meshSet.vclist.AddRange(new Color[] {
                    ncolor, ncolor, ncolor, ncolor,
                });

                // Triangle
                meshSet.trilist.AddRange(new int[] { save_vsize, save_vsize + 1, save_vsize + 3 });
                meshSet.trilist.AddRange(new int[] { save_vsize, save_vsize + 3, save_vsize + 2 });

                /* uv
                 *  0--1
                 |  |
                 |  2--3
                 |
                 */
                meshSet.uvlist.AddRange(d.uvs);

                // bone weights
                if (boneIndex < 0)
                {
                    throw new SystemException("Unexpected!");
                }
                meshSet.bwlist.Add(new BoneWeight()
                {
                    boneIndex0 = boneIndex, weight0 = 1
                });                                                                       // v[0]
                meshSet.bwlist.Add(new BoneWeight()
                {
                    boneIndex0 = boneIndex, weight0 = 1
                });                                                                       // v[1]
                meshSet.bwlist.Add(new BoneWeight()
                {
                    boneIndex0 = boneIndex, weight0 = 1
                });                                                                       // v[2]
                meshSet.bwlist.Add(new BoneWeight()
                {
                    boneIndex0 = boneIndex, weight0 = 1
                });                                                                       // v[3]
            }
        }
Example #5
0
        public static void DrawAtlas_Sub4(hgAtlasInfoData.RECTPATTERN pattern, Vector2[] atlasRect, int[] size, Vector2 perfectSize, hgMesh.MeshSet meshSet, int boneIndex, Vector3[] vs, int colorIndex, hgAtlasInfoData.StrechMode mode, bool frameOnly /*=false*/)
        {
            switch (pattern)
            {
            case hgAtlasInfoData.RECTPATTERN.ONE:            DrawAtlas_ONE(atlasRect, meshSet, boneIndex, vs, colorIndex); break;

            case hgAtlasInfoData.RECTPATTERN.THREEHORIZON:   DrawAtlas_HORIZON(atlasRect, size, perfectSize, meshSet, boneIndex, vs, colorIndex, mode); break;

            case hgAtlasInfoData.RECTPATTERN.THREEVERTIACAL: DrawAtlas_VERTICAL(atlasRect, size, perfectSize, meshSet, boneIndex, vs, colorIndex, mode); break;

            case hgAtlasInfoData.RECTPATTERN.NINE:           DrawAtlas_NINE(atlasRect, size, perfectSize, meshSet, boneIndex, vs, colorIndex, mode, frameOnly); break;
            }
        }
Example #6
0
        private static void DrawAtlas_NINE(Vector2[] auv, int[] size, Vector2 perfectSize, hgMesh.MeshSet meshSet, int boneIndex, Vector3[] vs, int colorIndex, hgAtlasInfoData.StrechMode mode, bool frameOnly)
        {
            int save_vsize = (meshSet != null) ? meshSet.vclist.Count : 0;

            float w = vs[1].x - vs[0].x;
            float h = vs[0].y - vs[2].y;

            /*
             *  y [00][01][02][03]
             |                  } tx
             | [04][05][06][07]
             |                  } ch
             | [08][09][10][11]
             |                  } bx
             | [12][13][14][15]
             |  o--x V   V   V
             |   |   |
             |       lx  cw  rx
             */
            float tx = size[0]; //auv[0].y - auv[4].y;
            float bx = size[1]; //auv[8].y - auv[12].y;
            float lx = size[2]; //auv[1].x - auv[0].x;
            float rx = size[3]; //auv[3].x - auv[2].x;

            float cw = perfectSize.x - (lx + rx); if (cw < 0)
            {
                throw new SystemException("ERROR: UNEXPECTED ATLAS EDGE INFO:TYPE NINE EDGE #H");
            }
            float cwh = cw / 2f;
            float ch  = perfectSize.y - (tx + bx); if (ch < 0)
            {
                throw new SystemException("ERROR: UNEXPECTED ATLAS EDGE INFO:TYPE NINE EDGE #V");
            }
            float chh = ch / 2f;

            Vector3[] nvs = null;
            if (mode == hgAtlasInfoData.StrechMode.STRECH_CENTER)
            {
                if (h < tx + bx || w < lx + rx)
                {
                    Vector2[] nv = new Vector2[]
                    {
                        auv[5], auv[6],
                        auv[9], auv[10]
                    };
                    DrawAtlas_ONE(nv, meshSet, boneIndex, vs, colorIndex);
                    return;
                }
                nvs = new Vector3[]
                {
                    /*00*/ vs[0],
                    /*01*/ vs[0] + lx * Vector3.right,
                    /*02*/ vs[1] - rx * Vector3.right,
                    /*03*/ vs[1],

                    /*04*/ vs[0] - tx * Vector3.up,
                    /*05*/ vs[0] + lx * Vector3.right - tx * Vector3.up,
                    /*06*/ vs[1] - rx * Vector3.right - tx * Vector3.up,
                    /*07*/ vs[1] - tx * Vector3.up,

                    /*08*/ vs[2] + bx * Vector3.up,
                    /*09*/ vs[2] + lx * Vector3.right + bx * Vector3.up,
                    /*10*/ vs[3] - lx * Vector3.right + bx * Vector3.up,
                    /*11*/ vs[3] + bx * Vector3.up,

                    /*12*/ vs[2],
                    /*13*/ vs[2] + lx * Vector3.right,
                    /*14*/ vs[3] - lx * Vector3.right,
                    /*15*/ vs[3]
                };
            }
            else
            {
                if (w < cw || h < ch)
                {
                    Vector2[] nv = new Vector2[]
                    {
                        auv[0], auv[3],
                        auv[12], auv[15]
                    };
                    DrawAtlas_ONE(nv, meshSet, boneIndex, vs, colorIndex);
                    return;
                }

                /*
                 *      ctrX
                 |
                 | vs [0] [-] [-] [1]
                 +--- --- ---+
                 |   |   |   |
                 | [-] [-] [-] [-] <--ctrTY
                 | ctrY--> |   |   |   |
                 | [-] [-] [-] [-] <--ctrBY
                 |   |   |   |
                 +--- --- ---+
                 | [2] [-] [-] [3]
                 |   |
                 | ctrRX
                 |    ctrLX
                 */
                var ctrX  = (vs[0].x + vs[1].x) / 2;
                var ctrLX = ctrX - cwh;
                var ctrRX = ctrX + cwh;
                var ctrY  = (vs[0].y + vs[2].y) / 2f;
                var ctrTY = ctrY + chh;
                var ctrBY = ctrY - chh;

                nvs = new Vector3[]
                {
                    /*00*/ vs[0],
                    /*01*/ ctrLX *Vector3.right + vs[0].y * Vector3.up,
                    /*02*/ ctrRX *Vector3.right + vs[0].y * Vector3.up,
                    /*03*/ vs[1],

                    /*04*/ vs[0].x * Vector3.right + ctrTY * Vector3.up,
                    /*05*/ ctrLX *Vector3.right + ctrTY * Vector3.up,
                    /*06*/ ctrLX *Vector3.right + ctrTY * Vector3.up,
                    /*07*/ vs[1].x * Vector3.right + ctrTY * Vector3.up,

                    /*08*/ vs[2].x * Vector3.right + ctrBY * Vector3.up,
                    /*09*/ ctrLX *Vector3.right + ctrBY * Vector3.up,
                    /*10*/ ctrRX *Vector3.right + ctrBY * Vector3.up,
                    /*11*/ vs[3].x * Vector3.right + ctrBY * Vector3.up,

                    /*12*/ vs[2],
                    /*13*/ ctrLX *Vector3.right + vs[2].y * Vector3.up,
                    /*14*/ ctrRX *Vector3.right + vs[2].y * Vector3.up,
                    /*15*/ vs[3]
                };
            }

            // Vertex
            meshSet.vlist.AddRange(nvs);

            // Vcolor
            var ncolor = hglHtmlColor.IndexToVColor(colorIndex);

            ncolor.a = 17f / 64f - 1f / 128f;
            meshSet.vclist.AddRange(new Color[] {
                ncolor, ncolor, ncolor, ncolor,
                ncolor, ncolor, ncolor, ncolor,
                ncolor, ncolor, ncolor, ncolor,
                ncolor, ncolor, ncolor, ncolor,
            });

            // Triangles
            meshSet.trilist.AddRange(new int[] { save_vsize + 0, save_vsize + 1, save_vsize + 5 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 0, save_vsize + 5, save_vsize + 4 });

            meshSet.trilist.AddRange(new int[] { save_vsize + 1, save_vsize + 2, save_vsize + 6 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 1, save_vsize + 6, save_vsize + 5 });

            meshSet.trilist.AddRange(new int[] { save_vsize + 2, save_vsize + 3, save_vsize + 7 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 2, save_vsize + 7, save_vsize + 6 });
            /**/

            meshSet.trilist.AddRange(new int[] { save_vsize + 4, save_vsize + 5, save_vsize + 9 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 4, save_vsize + 9, save_vsize + 8 });

            if (frameOnly == false)
            {
                meshSet.trilist.AddRange(new int[] { save_vsize + 5, save_vsize + 6, save_vsize + 10 });
                meshSet.trilist.AddRange(new int[] { save_vsize + 5, save_vsize + 10, save_vsize + 9 });
            }
            meshSet.trilist.AddRange(new int[] { save_vsize + 6, save_vsize + 7, save_vsize + 11 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 6, save_vsize + 11, save_vsize + 10 });
            /**/

            meshSet.trilist.AddRange(new int[] { save_vsize + 8, save_vsize + 9, save_vsize + 13 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 8, save_vsize + 13, save_vsize + 12 });

            meshSet.trilist.AddRange(new int[] { save_vsize + 9, save_vsize + 10, save_vsize + 14 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 9, save_vsize + 14, save_vsize + 13 });

            meshSet.trilist.AddRange(new int[] { save_vsize + 10, save_vsize + 11, save_vsize + 15 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 10, save_vsize + 15, save_vsize + 14 });

            /* uv
             */
            meshSet.uvlist.AddRange(auv);

            // bone weights
            if (boneIndex < 0)
            {
                throw new SystemException("Unexpected!");
            }
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[0]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[1]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[2]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[3]

            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[4]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[5]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[6]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[7]

            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[8]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[9]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[10]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[11]

            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[12]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[13]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[14]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[15]
        }
Example #7
0
        private static void DrawAtlas_VERTICAL(Vector2[] auv, int[] size, Vector2 perfectSize, hgMesh.MeshSet meshSet, int boneIndex, Vector3[] vs, int colorIndex, hgAtlasInfoData.StrechMode mode)
        {
            int save_vsize = (meshSet != null) ? meshSet.vclist.Count : 0;

            //float w  = vs[1].x - vs[0].x;
            float h = vs[0].y - vs[2].y;

            /*
             *  [0][1]
             *         } tx
             *  [2][3]
             *         } ch
             *  [4][5]
             *         } bx
             *  [6][7]
             */
            float tx = size[0]; //auv[0].y - auv[2].y;
            float bx = size[1]; //auv[4].y - auv[6].y;
            float ch = perfectSize.y - (tx + bx); if (ch < 0)
            {
                throw new SystemException("ERROR: UNEXPECTED ATLAS EDGE INFO:TYPE VERTICAL");
            }
            float chh = ch / 2f;

            Vector3[] nvs = null;

            if (mode == hgAtlasInfoData.StrechMode.STRECH_EDGE)
            {
                if (h < tx + bx)
                {
                    Vector2[] nv = new Vector2[]
                    {
                        auv[2], auv[3],
                        auv[4], auv[5]
                    };
                    DrawAtlas_ONE(nv, meshSet, boneIndex, vs, colorIndex);
                    return;
                }
                nvs = new Vector3[]
                {
                    /*0*/ vs[0],
                    /*1*/ vs[1],
                    /*2*/ vs[0] - tx * Vector3.up,
                    /*3*/ vs[1] - tx * Vector3.up,
                    /*4*/ vs[2] + bx * Vector3.up,
                    /*5*/ vs[3] + bx * Vector3.up,
                    /*6*/ vs[2],
                    /*7*/ vs[3]
                };
            }
            else
            {
                if (h < ch)
                {
                    Vector2[] nv = new Vector2[]
                    {
                        auv[0], auv[1],
                        auv[6], auv[7]
                    };
                    DrawAtlas_ONE(nv, meshSet, boneIndex, vs, colorIndex);
                    return;
                }

                /*
                 *
                 *
                 * vs [0]  [1]
                 +---+
                 |   |
                 |---|<---ctrTY
                 | ctrY--->|   |
                 |---|<---ctrBY
                 |   |
                 +---+
                 | [2]  [3]
                 */

                var ctrY  = (vs[0].y + vs[2].y) / 2f;
                var ctrTY = ctrY + chh;
                var ctrBY = ctrY - chh;
                nvs = new Vector3[]
                {
                    /*0*/ vs[0],
                    /*1*/ vs[1],
                    /*2*/ vs[0].x * Vector3.right + ctrTY * Vector3.up,
                    /*3*/ vs[1].x * Vector3.right + ctrTY * Vector3.up,
                    /*4*/ vs[0].x * Vector3.right + ctrBY * Vector3.up,
                    /*5*/ vs[1].x * Vector3.right + ctrBY * Vector3.up,
                    /*6*/ vs[2],
                    /*7*/ vs[3]
                };
            }
            // Vertex
            meshSet.vlist.AddRange(nvs);

            // Vcolor
            var ncolor = hglHtmlColor.IndexToVColor(colorIndex);

            ncolor.a = 17f / 64f - 1f / 128f;
            meshSet.vclist.AddRange(new Color[] { ncolor, ncolor, ncolor, ncolor, ncolor, ncolor, ncolor, ncolor });

            // Triangle
            meshSet.trilist.AddRange(new int[] { save_vsize + 0, save_vsize + 1, save_vsize + 3 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 0, save_vsize + 3, save_vsize + 2 });

            meshSet.trilist.AddRange(new int[] { save_vsize + 2, save_vsize + 3, save_vsize + 5 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 2, save_vsize + 5, save_vsize + 4 });

            meshSet.trilist.AddRange(new int[] { save_vsize + 4, save_vsize + 5, save_vsize + 7 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 4, save_vsize + 7, save_vsize + 6 });

            /* uv
             */
            meshSet.uvlist.AddRange(auv);

            // bone weights
            if (boneIndex < 0)
            {
                throw new SystemException("Unexpected!");
            }
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[0]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[1]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[2]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[3]

            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[4]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[5]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[6]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[7]
        }
Example #8
0
        /*
         *                              point index
         +-----+                     [00][01][02][03]
         | | | | } topPx
         |-----|                     [04][05][06][07]
         | | | |
         |-----|                     [08][09][10][11]
         | | | | } botPx
         +-----+                     [12][13][14][15]
         |   |
         |  rightPx
         |  LeftPx
         |
         */
        private static void DrawAtlas_HORIZON(Vector2[] auv, int[] size, Vector2 perfectSize, hgMesh.MeshSet meshSet, int boneIndex, Vector3[] vs, int colorIndex, hgAtlasInfoData.StrechMode mode)
        {
            int save_vsize = (meshSet != null) ? meshSet.vclist.Count : 0;

            float w = vs[1].x - vs[0].x;
            //float h  = vs[0].y - vs[1].y;

            /*
             *  [0][1][2][3]
             *  [4][5][6][7]
             *    V  V  V
             *    lx |  |
             *       cw |
             *          rx
             */
            float lx = size[2]; //auv[1].x - auv[0].x;
            float rx = size[3]; //auv[3].x - auv[2].x;
            float cw = perfectSize.x - (lx + rx); if (cw < 0)
            {
                throw new SystemException("ERROR: UNEXPECTED ATLAS EDGE INFO:TYPE HORIZON");
            }
            float cwh = cw / 2f;

            Vector3[] nvs = null;
            if (mode == hgAtlasInfoData.StrechMode.STRECH_CENTER)
            {
                if (w < lx + rx)
                {
                    Vector2[] nv = new Vector2[]
                    {
                        auv[1], auv[2],
                        auv[5], auv[6]
                    };
                    DrawAtlas_ONE(nv, meshSet, boneIndex, vs, colorIndex);
                    return;
                }
                nvs = new Vector3[]
                {
                    /*0*/ vs[0],
                    /*1*/ vs[0] + lx * Vector3.right,
                    /*2*/ vs[1] - rx * Vector3.right,
                    /*3*/ vs[1],
                    /*4*/ vs[2],
                    /*5*/ vs[2] + lx * Vector3.right,
                    /*6*/ vs[3] - lx * Vector3.right,
                    /*7*/ vs[3]
                };
            }
            else
            {
                if (w < cw)
                {
                    Vector2[] nv = new Vector2[]
                    {
                        auv[0], auv[3],
                        auv[4], auv[7]
                    };
                    DrawAtlas_ONE(nv, meshSet, boneIndex, vs, colorIndex);
                    return;
                }

                /*
                 *              ctrX
                 |
                 | vs   [0]      v       [1]
                 +---------------+
                 |    |     |    |
                 +---------------+
                 |     [2]   ^     ^    [3]
                 |     |
                 |    ctrRX
                 |          ctrLX
                 |
                 */

                var ctrX  = (vs[0].x + vs[1].x) / 2;
                var ctrLX = ctrX - cwh;
                var ctrRX = ctrX + cwh;

                nvs = new Vector3[]
                {
                    /*0*/ vs[0],
                    /*1*/ vs[0].y * Vector3.up + ctrLX * Vector3.right,
                    /*2*/ vs[0].y * Vector3.up + ctrRX * Vector3.right,
                    /*3*/ vs[1],
                    /*4*/ vs[2],
                    /*5*/ vs[2].y * Vector3.up + ctrLX * Vector3.right,
                    /*6*/ vs[2].y * Vector3.up + ctrRX * Vector3.right,
                    /*7*/ vs[3]
                };
            }

            // Vertex
            meshSet.vlist.AddRange(nvs);

            // Vcolor
            var ncolor = hglHtmlColor.IndexToVColor(colorIndex);

            ncolor.a = 17f / 64f - 1f / 128f;
            meshSet.vclist.AddRange(new Color[] { ncolor, ncolor, ncolor, ncolor, ncolor, ncolor, ncolor, ncolor });

            // Triangle
            meshSet.trilist.AddRange(new int[] { save_vsize + 0, save_vsize + 1, save_vsize + 5 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 0, save_vsize + 5, save_vsize + 4 });

            meshSet.trilist.AddRange(new int[] { save_vsize + 1, save_vsize + 2, save_vsize + 6 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 1, save_vsize + 6, save_vsize + 5 });

            meshSet.trilist.AddRange(new int[] { save_vsize + 2, save_vsize + 3, save_vsize + 7 });
            meshSet.trilist.AddRange(new int[] { save_vsize + 2, save_vsize + 7, save_vsize + 6 });

            /* uv
             */
            meshSet.uvlist.AddRange(auv);

            // bone weights
            if (boneIndex < 0)
            {
                throw new SystemException("Unexpected!");
            }
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[0]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[1]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[2]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[3]

            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[4]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[5]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[6]
            meshSet.bwlist.Add(new BoneWeight()
            {
                boneIndex0 = boneIndex, weight0 = 1
            });                                                                       // v[7]
        }