コード例 #1
0
ファイル: hgMesh.cs プロジェクト: NNNIC/hug-unity-browser
 public static void GetNextRightVertexUV(List <CD> list, int index, MeshSet meshSet, ref Vector3 leftOfBase, int boneIndex /*= -1*/)
 {
     if (list[index] is CD_CHAR)
     {
         CD_CHAR.GetNextRightVertexUV(list, index, meshSet, ref leftOfBase, boneIndex);
     }
     else if (list[index] is CD_IMAGE)
     {
         //CD_IMAGE.GetNextRightVertexUV(list, index, meshSet, ref leftOfBase);
         Vector3 nextLeftOfBase;
         CD_IMAGE.GetNextRightVertexUV(list, index, meshSet, CD_IMAGE.POSMODE.LEFOFBASE, leftOfBase, out nextLeftOfBase, boneIndex);
         leftOfBase = nextLeftOfBase;
     }
     else
     {
     }
 }
コード例 #2
0
ファイル: hgMesh.cs プロジェクト: NNNIC/hug-unity-browser
            public static void GetNextRightVertexUV(List <CD> list, int index, MeshSet meshSet, POSMODE mode, Vector3 pos, out Vector3 nextLeftOfBase, int boneIndex /* = -1*/)
            {
                nextLeftOfBase = Vector3.zero;
                CD_IMAGE cd = (CD_IMAGE)list[index];

                //int save_vsize = (meshSet!=null) ? meshSet.vclist.Count : 0;
                float width  = cd.width;
                float height = cd.height;

                if (cd.width == 0 || cd.height == 0)
                {
                    if (cd.src == SOURCE.ATLAS)
                    {
                        cd.atlasInfo.GetPerfectSize(cd.atlasName, out width, out height);
                    }
                    else
                    {
                        width  = cd.texture.width;
                        height = cd.texture.height;
                    }
                }


                /*
                 *      ^---------->
                 * yAdvance|
                 *          width
                 +----+
                 |    | height
                 |   yoff->+----+
                 |
                 | Base  o---------->
                 |         ^       ^
                 |        xoff     xAdvance
                 */

                switch (mode)
                {
                case POSMODE.LEFOFBASE: nextLeftOfBase = pos; break;

                case POSMODE.TOPLEFT:   nextLeftOfBase = pos + (-cd.y_advance) * Vector3.up;  break;

                case POSMODE.TOPRIGHT:  nextLeftOfBase = pos - (-cd.y_advance) * Vector3.up + (-cd.x_advance) * Vector3.right; break;
                }
                cd.leftBase = nextLeftOfBase;
                Vector3 imageTopLeft = nextLeftOfBase + new Vector3(cd.x_offset, cd.y_offset, 0) + height * Vector3.up;

                // Vertex
                Vector3[] vs = new Vector3[4];
                vs[0] = imageTopLeft;
                vs[1] = vs[0] + width * Vector3.right;
                vs[2] = imageTopLeft + height * Vector3.down;
                vs[3] = vs[2] + width * Vector3.right;

                cd.inner_v = vs;

                // next left of base
                nextLeftOfBase += (cd.x_offset + width + cd.hspace) * Vector3.right;

                /* outer_v
                 *
                 */
                Vector3[] outer_v = new Vector3[4];
                outer_v[0] = cd.leftBase + cd.y_advance * Vector3.up;
                outer_v[1] = outer_v[0] + cd.x_advance * Vector3.right;
                outer_v[2] = cd.leftBase;
                outer_v[3] = outer_v[2] + cd.x_advance * Vector3.right;
                cd.outer_v = outer_v;

                //
                if (meshSet != null)
                {
                    if (cd.src == SOURCE.ATLAS)
                    {
                        if (cd.isBonedAtlas)
                        {
                            cd.bone = meshSet.bnlist[boneIndex];
                            meshSet.atlasList.Add(cd);
                        }
                        else
                        {
                            int[]     size;
                            Vector2[] r;
                            hgAtlasInfoData.RECTPATTERN pattern;
                            hgAtlasInfoData.StrechMode  smode;
                            Vector2 perfectSize;
                            cd.atlasInfo.GetRect(cd.atlasName, out perfectSize, out r, out pattern, out size, out smode);
                            hgMeshAtlas.DrawAtlas_Sub4(pattern, r, size, perfectSize, meshSet, boneIndex, vs, cd.colorIndex, smode, false);
                        }
                    }
                    else
                    { // SOURCE.IMAGE
                        cd.bone = meshSet.bnlist[boneIndex];
                        meshSet.imageList.Add(cd);
                    }
                }
            }