Пример #1
0
 public static CD_CHAR CreateSpaceChar(CD referCd, hglParser.Element e)
 {
     if (referCd != null)
     {
         CD_CHAR        refcd = (CD_CHAR)referCd;
         hgMesh.CD_CHAR cd    = new hgMesh.CD_CHAR(e);
         cd.bmFont     = refcd.bmFont;
         cd.code       = ' ';
         cd.fontSize   = refcd.fontSize;
         cd.vspace     = refcd.vspace;
         cd.hspace     = refcd.hspace;
         cd.colorIndex = 0;
         return(cd);
     }
     else if (e != null)
     {
         hgMesh.CD_CHAR cd = new hgMesh.CD_CHAR(e);
         cd.bmFont     = e.GetTags().m_htmlRender.m_renderInfo.m_bmFont.m_bmFonrData;
         cd.code       = ' ';
         cd.fontSize   = e.thisStyle.GetFloat(StyleKey.font_size, float.NaN);
         cd.vspace     = 0;
         cd.hspace     = 0;
         cd.colorIndex = 0;
         return(cd);
     }
     return(null);
 }
Пример #2
0
            private static Vector3 CreateOneFontMesh(CD icd, MeshSet meshSet, Vector3 leftOfBase, int size, int _base, int width, int height, int xoffset, int yoffset, int xadvance, int chnl, Vector2[] uvs, out Vector3[] inner_v, out Vector3[] localv, bool isEffect, int boneIndex /*=-1*/)
            {
                CD_CHAR cd         = (CD_CHAR)icd;
                int     save_vsize = meshSet != null ?  meshSet.vlist.Count : 0;
                float   factor     = (float)cd.fontSize / (float)size;
                float   bold_v     = cd.bold ? width * s_bold_ratio * factor : 0;
                float   italic_v   = cd.italic ? Mathf.Cos((90 - s_italicAngle) * Mathf.Deg2Rad) * height * factor : 0;

                localv = CreateOneMesh_sub(cd, meshSet, ref leftOfBase, _base, size, width, height, xoffset, yoffset, xadvance, factor, bold_v, italic_v, out inner_v, boneIndex);

                if (meshSet != null)
                {
                    // VColor
                    var ncolor = isEffect && cd.effectColorIndex >= 0 ? hglHtmlColor.IndexToVColor(cd.effectColorIndex) :  hglHtmlColor.IndexToVColor(cd.colorIndex);
                    //if (color2!=null) ncolor = (Color)color2;

                    switch (chnl) // use alpha for chnl
                    {
                    case 1: ncolor.a = 0;    break;

                    case 2: ncolor.a = 1f / 64f - 1f / 128f; break;

                    case 4: ncolor.a = 2f / 64f - 1f / 128f; break;

                    case 8: ncolor.a = 3f / 64f - 1f / 128f; break;
                    }
                    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
                    meshSet.uvlist.AddRange(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]
                }
                // next left of base
                return(leftOfBase);
            }
Пример #3
0
 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
     {
     }
 }
Пример #4
0
            public static void GetNextRightVertexUV(List <CD> list, int index, MeshSet meshSet, ref Vector3 leftOfBase, int boneIndex /*= -1*/)
            {
                Vector3[] outer_v = null;
                Vector3[] inner_v = null;

                CD base_cd = (list != null && index < list.Count) ? list[index] : null;

                if (base_cd == null)
                {
                    throw new SystemException("ERROR UNEXPECTED");
                }

                CD_CHAR cd = (base_cd is CD_CHAR) ? (CD_CHAR)base_cd : null;

                if (cd == null)
                {
                    return;
                }

                CD      base_firstCd = index - 1 >= 0 ? list[index - 1] : null;
                CD_CHAR firstCd      = (base_firstCd != null) && (base_firstCd is CD_CHAR) ? (CD_CHAR)base_firstCd : null;

                int size, _base, width, height, xoffset, yoffset, xadvance, chnl;

                Vector2[] uvs;
                if (cd.bmFont.GetInfo(cd.code, (firstCd != null ?  firstCd.code : '\x0'), out size, out _base, out uvs, out width, out height, out xoffset, out yoffset, out xadvance, out chnl))
                {
                    if (meshSet != null)
                    {
                        Vector3[] tmp_innerv;
                        Vector3[] tmp_localv;
                        switch (cd.effect)
                        {
                        case CD_CHAR.Effect.SHADOW:
                        {   //shadow
                            int x = (int)cd.effect_val.x;  int y = (int)cd.effect_val.y;
                            CreateOneFontMesh(cd, meshSet, leftOfBase, size, _base, width, height, xoffset + x, yoffset + y, xadvance, chnl, uvs, out tmp_innerv, out tmp_localv, true, boneIndex);
                        }
                        break;

                        case CD_CHAR.Effect.OUTLINE:
                        {   //outline
                            int w = (int)cd.effect_val.x;  int y = w;  var quality = (int)cd.effect_val.y;
                            for (int ix = -w; ix <= w; ix++)
                            {
                                for (int iy = -y; iy <= y; iy++)
                                {
                                    if (quality != 0)
                                    {
                                        if ((ix >= -w + 1 && ix <= w - 1)
                                            &&
                                            (iy >= -y + 1 && iy <= y - 1)
                                            )
                                        {
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        if ((ix >= -w + 1 && ix <= w - 1)
                                            ||
                                            (iy >= -y + 1 && iy <= y - 1)
                                            )
                                        {
                                            continue;
                                        }
                                    }
                                    CreateOneFontMesh(cd, meshSet, leftOfBase, size, _base, width, height, xoffset + ix, yoffset + iy, xadvance, chnl, uvs, out tmp_innerv, out tmp_localv, true, boneIndex);
                                }
                            }
                        }
                        break;
                        }
                    }
                    cd.leftBase = leftOfBase;
                    leftOfBase  = CreateOneFontMesh(cd, meshSet, leftOfBase, size, _base, width, height, xoffset, yoffset, xadvance, chnl, uvs, out inner_v, out outer_v, false, boneIndex);
                }
                cd.inner_v = inner_v;
                cd.outer_v = outer_v;
            }