Changeset 2404


Ignore:
Timestamp:
Feb 13, 2013, 3:57:13 PM (10 years ago)
Author:
touky
Message:

easymesh: all operations now generate UVs for the mesh.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/easymesh/easymesh-parser.y

    r2350 r2404  
    148148    T_CYLINDER args6       { mc.m_mesh.AppendCylinder((int)$2.f0, $2.f1,
    149149                                                 $2.f2, $2.f3,
    150                                                  (int)$2.f4, (int)$2.f5); }
     150                                                 (int)$2.f4, (int)$2.f5, 0); }
     151  | T_CYLINDER args7       { mc.m_mesh.AppendCylinder((int)$2.f0, $2.f1,
     152                                                 $2.f2, $2.f3,
     153                                                 (int)$2.f4, (int)$2.f5, (int)$2.f6); }
    151154  | T_BOX args3            { mc.m_mesh.AppendBox(vec3($2.f0, $2.f1, $2.f2)); }
    152155  | T_SMOOTHCHAMFBOX args4 { mc.m_mesh.AppendSmoothChamfBox(vec3($2.f0, $2.f1,
     
    154157  | T_FLATCHAMFBOX args4   { mc.m_mesh.AppendFlatChamfBox(vec3($2.f0, $2.f1,
    155158                                                          $2.f2), $2.f3); }
    156   | T_SPHERE args4         { mc.m_mesh.AppendSphere($2.f0,
    157                                                vec3($2.f1, $2.f2, $2.f3)); }
     159  | T_SPHERE args2         { mc.m_mesh.AppendSphere($2.f0, $2.f1); }
    158160  | T_CAPSULE args3        { mc.m_mesh.AppendCapsule($2.f0, $2.f1, $2.f2); }
    159161  | T_TORUS args3          { mc.m_mesh.AppendTorus((int)$2.f0, $2.f1, $2.f2); }
  • trunk/src/easymesh/easymesh.cpp

    r2380 r2404  
    4848//-----------------------------------------------------------------------------
    4949EasyMesh::EasyMesh()
    50   : m_color(0), m_color2(0), m_ignore_winding_on_scale(0)
     50  : m_color(0), m_color2(0), m_ignore_winding_on_scale(0),
     51    m_texcoord_offset(vec2(.0f)), m_texcoord_scale(vec2(1.f))
    5152{
    5253    m_cursors.Push(0, 0);
     
    479480                        (csg_operation == CSGUsage::SubstractLoss &&
    480481                            ((mesh_id == 0 && tri_list[k].m1 == LEAF_BACK) || mesh_id == 1)) ||
    481                         //csga : CSGAnd() -> Inside + Inside
     482                        //csga : CSGAnd() -> m0_Inside + m1_Inside
    482483                        (csg_operation == CSGUsage::And && tri_list[k].m1 == LEAF_FRONT))
    483484                    {
     
    488489                    if (//csgs : CSGSubstract() -> m0_Outside + m1_Inside-inverted
    489490                        (csg_operation == CSGUsage::Substract && mesh_id == 1 && tri_list[k].m1 == LEAF_BACK) ||
    490                         //csgx : CSGXor() -> Outside/Inside-inverted + Outside/Inside-inverted
     491                        //csgx : CSGXor() -> m0_Outside/m0_Inside-inverted + m1_Outside/m1_Inside-inverted
    491492                        (csg_operation == CSGUsage::Xor && tri_list[k].m1 == LEAF_BACK))
    492493                    {
     
    546547    //DONE for the splitting !
    547548}
    548 
    549549
    550550//-----------------------------------------------------------------------------
     
    750750            vec3 v_dir = normalize(cross(m_vert[m_indices[cur_tri]].m2, v01));
    751751            vec2 texu_dir = uv[1] - uv[0];
    752             vec2 texv_dir = vec2(texu_dir.y, -texu_dir.x);
     752            vec2 texv_dir = vec2(texu_dir.y, texu_dir.x);
    753753            //Final calculations
    754754            uv[2] = texu_dir * dot(v01, v02) + texv_dir * dot(v_dir, v02);
     
    777777            for (int j = 0; j < 3; j++)
    778778            {
    779 #if 0
     779#if 1
    780780                //This finds triangle that are connected to this triangle
    781781                vert_dict.FindConnectedTriangles(ivec2(v[j], v[(j + 1) % 3]), tri_list, tri_check, &tri_done);
     
    788788        else if (uv_set == 3)
    789789        {
     790            for (int j = 0; j < 3; j++)
     791            {
     792                m_vert[tri_list[cur_tri]].m4     = vec2(-1.0f);
     793                m_vert[tri_list[cur_tri + 1]].m4 = vec2(-1.0f);
     794                m_vert[tri_list[cur_tri + 2]].m4 = vec2(-1.0f);
     795            }
     796   
     797            //uv[0] = vec2(-1.0f);
     798            //uv[1] = vec2(-1.0f);
     799            //uv[2] = vec2(-1.0f);
     800            /*
    790801            bool tri_present = false;
    791802            for (int j = 0; j < tri_done.Count(); j++)
     
    795806                tri_done << cur_tri;
    796807            tri_check.Remove(0);
     808            */
    797809        }
    798810
     
    822834
    823835//-----------------------------------------------------------------------------
     836void EasyMesh::SetTexCoordData(vec2 const &new_offset, vec2 const &new_scale)
     837{
     838    m_texcoord_offset = new_offset;
     839    m_texcoord_scale = new_scale;
     840}
     841
     842//-----------------------------------------------------------------------------
    824843void EasyMesh::SetCurVertNormal(vec3 const &normal)
    825844{
     
    831850{
    832851    m_vert[m_vert.Count() - 1].m3 = color;
     852}
     853
     854//-----------------------------------------------------------------------------
     855void EasyMesh::SetCurVertTexCoord(vec2 const &texcoord)
     856{
     857#if VERTEX_USEAGE == VU_BONES
     858#elif VERTEX_USEAGE == VU_TEX_UV
     859    m_vert[m_vert.Count() - 1].m4 = (texcoord * m_texcoord_scale) + m_texcoord_offset;
     860#endif
    833861}
    834862
     
    841869
    842870//-----------------------------------------------------------------------------
    843 void EasyMesh::RotateX(float t) { Rotate(t, vec3(1, 0, 0)); }
    844 void EasyMesh::RotateY(float t) { Rotate(t, vec3(0, 1, 0)); }
    845 void EasyMesh::RotateZ(float t) { Rotate(t, vec3(0, 0, 1)); }
    846 
    847 //-----------------------------------------------------------------------------
    848 void EasyMesh::Rotate(float t, vec3 const &axis)
    849 {
    850     mat3 m = mat3::rotate(t, axis);
     871void EasyMesh::RotateX(float angle) { Rotate(angle, vec3(1, 0, 0)); }
     872void EasyMesh::RotateY(float angle) { Rotate(angle, vec3(0, 1, 0)); }
     873void EasyMesh::RotateZ(float angle) { Rotate(angle, vec3(0, 0, 1)); }
     874
     875//-----------------------------------------------------------------------------
     876void EasyMesh::Rotate(float angle, vec3 const &axis)
     877{
     878    mat3 m = mat3::rotate(angle, axis);
    851879    for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++)
    852880    {
     
    907935    for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++)
    908936    {
    909         m_vert[i].m1.y *= 1.f + (y * m_vert[i].m1.x + xoff);
    910         m_vert[i].m1.z *= 1.f + (z * m_vert[i].m1.x + xoff);
     937        m_vert[i].m1.y *= 1.f + (y * abs(m_vert[i].m1.x) + xoff);
     938        m_vert[i].m1.z *= 1.f + (z * abs(m_vert[i].m1.x) + xoff);
    911939    }
    912940}
     
    917945    for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++)
    918946    {
    919         m_vert[i].m1.x *= 1.f + (x * m_vert[i].m1.y + yoff);
    920         m_vert[i].m1.z *= 1.f + (z * m_vert[i].m1.y + yoff);
     947        m_vert[i].m1.x *= 1.f + (x * abs(m_vert[i].m1.y) + yoff);
     948        m_vert[i].m1.z *= 1.f + (z * abs(m_vert[i].m1.y) + yoff);
    921949    }
    922950}
     
    927955    for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++)
    928956    {
    929         m_vert[i].m1.x *= 1.f + (x * m_vert[i].m1.z + zoff);
    930         m_vert[i].m1.y *= 1.f + (y * m_vert[i].m1.z + zoff);
     957        m_vert[i].m1.x *= 1.f + (x * abs(m_vert[i].m1.z) + zoff);
     958        m_vert[i].m1.y *= 1.f + (y * abs(m_vert[i].m1.z) + zoff);
    931959    }
    932960}
     
    9801008//-----------------------------------------------------------------------------
    9811009void EasyMesh::AppendCylinder(int nsides, float h, float r1, float r2,
    982                     int dualside, int smooth)
    983 {
     1010                              int dualside, int smooth, int close)
     1011{
     1012    //SAVE
     1013    vec4 Saved_Color = m_color;
     1014    vec4 Saved_Color2 = m_color2;
     1015    vec2 Save_texcoord_offset = m_texcoord_offset;
     1016    vec2 Save_texcoord_scale = m_texcoord_scale;
     1017
    9841018    int vbase = m_vert.Count();
    9851019
    986     mat3 rotmat = mat3::rotate(360.0f / nsides, 0.f, 1.f, 0.f);
     1020    mat3 rotmat = mat3::rotate(360.0f / (float)nsides, 0.f, 1.f, 0.f);
    9871021    vec3 p1(r1, -h * .5f, 0.f), p2(r2, h * .5f, 0.f), n;
     1022    vec2 uv1(.0f, .0f), uv2(.0f, 1.0f), uvadd(1.0f / (float)nsides, .0f);
     1023    if (close)
     1024        SetTexCoordData(vec2(.0f), vec2(1.0f, .5f));
    9881025
    9891026    /* Construct normal */
     
    10011038    for (int i = 0; i < nsides; i++)
    10021039    {
    1003         AddVertex(p1); SetCurVertNormal(n);
    1004         AddVertex(p2); SetCurVertNormal(n);
     1040        AddVertex(p1); SetCurVertNormal(n); SetCurVertTexCoord(uv1);
     1041        AddVertex(p2); SetCurVertNormal(n); SetCurVertTexCoord(uv2);
    10051042        SetCurVertColor(m_color2);
    10061043
     
    10131050        }
    10141051
    1015         p1 = rotmat * p1;
    1016         p2 = rotmat * p2;
     1052        p1 = rotmat * p1; uv1 += uvadd;
     1053        p2 = rotmat * p2; uv2 += uvadd;
    10171054
    10181055        if (!smooth)
    10191056        {
    1020             AddVertex(p1); SetCurVertNormal(n);
    1021             AddVertex(p2); SetCurVertNormal(n);
     1057            AddVertex(p1); SetCurVertNormal(n); SetCurVertTexCoord(uv1);
     1058            AddVertex(p2); SetCurVertNormal(n); SetCurVertTexCoord(uv2);
    10221059            SetCurVertColor(m_color2);
    10231060
     
    10291066        n = rotmat * n;
    10301067    }
     1068
     1069    if (close)
     1070    {
     1071        //START
     1072        OpenBrace();
     1073        //LOWER DISC
     1074        SetTexCoordData(vec2(.0f, .5f), vec2(.5f, .5f));
     1075        SetCurColor(m_color);
     1076        AppendDisc(nsides, r1);
     1077        Translate(vec3(.0f, h, .0f));
     1078        RotateX(180.0f);
     1079        //UPPER DISC
     1080        SetTexCoordData(vec2(.5f, .5f), vec2(.5f, .5f));
     1081        SetCurColor(m_color2);
     1082        AppendDisc(nsides, r2);
     1083        Translate(vec3(.0f, h * .5f, .0f));
     1084        CloseBrace();
     1085    }
     1086    //RESTORE
     1087    SetCurColor(Saved_Color);
     1088    SetCurColor2(Saved_Color2);
     1089    SetTexCoordData(Save_texcoord_offset, Save_texcoord_scale);
     1090}
     1091
     1092//-----------------------------------------------------------------------------
     1093void EasyMesh::AppendSphere(int ndivisions, float r)
     1094{
     1095    AppendCapsule(ndivisions, 0.f, r);
    10311096}
    10321097
     
    10371102
    10381103    Array<vec3> vertices;
     1104    float uv_h = 0;
     1105    float uv_r = 0;
    10391106
    10401107    /* FIXME: we don't know how to handle even-divided capsules, so we
    10411108     * force the count to be odd. */
    10421109    if (h)
     1110    {
    10431111        ndivisions |= 1;
     1112        //calculate uv h&r percents
     1113        uv_h = (float)h / (float)(h + r * 2);
     1114        uv_r = (float)r / (float)(h + r * 2);
     1115    }
    10441116
    10451117    /* Fill in the icosahedron vertices, rotating them so that there
     
    10841156                         p[0] + vc,
    10851157                         p[0] + vb + vc };
     1158            vec2 uv[4];
    10861159
    10871160            /* FIXME: when we normalise here, we get a volume that is slightly
     
    10891162             * the midradius. */
    10901163            for (int k = 0; k < 4; k++)
    1091                 p[k] = normalize(p[k]) * r;
    1092 
    1093             /* If this is a capsule, grow in the Z direction */
     1164            {
     1165                //keep normalized until the end of the UV calculations
     1166                p[k] = normalize(p[k]);
     1167
     1168                uv[k].x = (lol::atan2(p[k].z, p[k].x) + (float)M_PI) / ((float)M_PI * 2.f);
     1169                if (abs(p[k].y) >= 1.0f)
     1170                    uv[k].x = -1.f;
     1171                uv[k].y = (lol::atan2(p[k].y, dot(p[k], normalize(p[k] * vec3(1.f,0.f,1.f)))) + (float)M_PI_2) / (float)M_PI;
     1172                if (h)
     1173                {
     1174                    if (uv[k].y > .5f)
     1175                        uv[k].y = uv_r + uv_h + (uv[k].y - .5f) * uv_r * 2.f;
     1176                    else
     1177                        uv[k].y *= uv_r * 2.f;
     1178                }
     1179                p[k] *= r;
     1180            }
     1181
     1182            /* If this is a capsule, grow in the Y direction */
    10941183            if (h > 0.f)
    10951184            {
     
    10991188
    11001189            /* Add zero, one or two triangles */
    1101             if (y < line - 1)
     1190            int id[] = { 0, 1, 2,
     1191                         1, 3 ,2 };
     1192            int l = 6;
     1193            while ((l -= 3) >= 0)
    11021194            {
    1103                 AddVertex(p[0]);
    1104                 AddVertex(p[1]);
    1105                 AddVertex(p[2]);
    1106                 AppendTriangle(0, 2, 1, m_vert.Count() - 3);
    1107             }
    1108 
    1109             if (y < line - 2)
    1110             {
    1111                 AddVertex(p[1]);
    1112                 AddVertex(p[3]);
    1113                 AddVertex(p[2]);
    1114                 AppendTriangle(0, 2, 1, m_vert.Count() - 3);
     1195                if ((l == 0 && y < line - 1) || (l == 3 && y < line - 2))
     1196                {
     1197                    int k = -1;
     1198                    while (++k < 3)
     1199                    {
     1200                        int rid[] = { id[k + l], id[(k + 1) % 3 + l] };
     1201                        if (uv[rid[0]].x >= .0f &&
     1202                            uv[rid[1]].x >= .0f &&
     1203                            abs(uv[rid[0]].x - uv[rid[1]].x) > .5f)
     1204                        {
     1205                            if (uv[rid[0]].x < uv[rid[1]].x)
     1206                                uv[rid[0]].x += 1.0f;
     1207                            else
     1208                                uv[rid[1]].x += 1.0f;
     1209                        }
     1210                    }
     1211                    k = -1;
     1212                    while (++k < 3)
     1213                    {
     1214                        int rid[] = { id[k + l], id[(k + 1) % 3 + l], id[(k + 2) % 3 + l] };
     1215                        AddVertex(p[rid[0]]);
     1216                        if (uv[rid[0]].x < .0f)
     1217                            SetCurVertTexCoord(vec2((uv[rid[1]].x + uv[rid[2]].x) * .5f,
     1218                                                    uv[rid[0]].y));
     1219                        else
     1220                            SetCurVertTexCoord(uv[rid[0]]);
     1221                    }
     1222                    AppendTriangle(0, 2, 1, m_vert.Count() - 3);
     1223                }
    11151224            }
    11161225
     
    11291238
    11301239//-----------------------------------------------------------------------------
    1131 void EasyMesh::AppendSphere(int ndivisions, vec3 const &size)
    1132 {
    1133     OpenBrace();
    1134     AppendCapsule(ndivisions, 0.f, 1.f);
    1135     Scale(size);
    1136     CloseBrace();
    1137 }
    1138 
    1139 //-----------------------------------------------------------------------------
    11401240void EasyMesh::AppendTorus(int ndivisions, float r1, float r2)
    11411241{
     
    11521252            int i2 = (i + di) % nidiv;
    11531253            int j2 = (j + dj) % njdiv;
    1154             float x = 0.5f * (r1 + r2) + 0.5f * (r2 - r1) * (float)lol::cos(2.0 * M_PI * i2 / nidiv);
     1254
     1255            //Location on the donut
     1256            float x = 0.5f * (r2 - r1) * (float)lol::cos(2.0 * M_PI * i2 / nidiv) + 0.5f * (r1 + r2);
    11551257            float y = 0.5f * (r2 - r1) * (float)lol::sin(2.0 * M_PI * i2 / nidiv);
    11561258            float z = 0.0f;
    11571259
     1260            //Center circle
    11581261            float ca = (float)lol::cos(2.0 * M_PI * j2 / njdiv);
    11591262            float sa = (float)lol::sin(2.0 * M_PI * j2 / njdiv);
     1263
     1264            //Actual location
    11601265            float x2 = x * ca - z * sa;
    11611266            float z2 = z * ca + x * sa;
    11621267
    11631268            AddVertex(vec3(x2, y, z2));
     1269            SetCurVertTexCoord(vec2((float)(i + di) / (float)nidiv, (float)(j + dj) / (float)nidiv));
    11641270        }
    11651271
     
    12031309    vec3 d = size * 0.5f;
    12041310
     1311    //Side vertices
    12051312    AddVertex(vec3(-d.x, -d.y, -d.z - chamf));
     1313    SetCurVertTexCoord(vec2(0.f, .5f));
    12061314    AddVertex(vec3(-d.x, +d.y, -d.z - chamf));
     1315    SetCurVertTexCoord(vec2(0.f, 0.f));
    12071316    AddVertex(vec3(+d.x, +d.y, -d.z - chamf));
     1317    SetCurVertTexCoord(vec2(.5f, 0.f));
    12081318    AddVertex(vec3(+d.x, -d.y, -d.z - chamf));
     1319    SetCurVertTexCoord(vec2(.5f, .5f));
    12091320
    12101321    AddVertex(vec3(-d.x - chamf, -d.y, +d.z));
     1322    SetCurVertTexCoord(vec2(.5f, 0.5f));
    12111323    AddVertex(vec3(-d.x - chamf, +d.y, +d.z));
     1324    SetCurVertTexCoord(vec2(.5f, 0.f));
    12121325    AddVertex(vec3(-d.x - chamf, +d.y, -d.z));
     1326    SetCurVertTexCoord(vec2(1.f, 0.f));
    12131327    AddVertex(vec3(-d.x - chamf, -d.y, -d.z));
     1328    SetCurVertTexCoord(vec2(1.f, .5f));
    12141329
    12151330    AddVertex(vec3(+d.x, -d.y, +d.z + chamf));
     1331    SetCurVertTexCoord(vec2(0.f, .5f));
    12161332    AddVertex(vec3(+d.x, +d.y, +d.z + chamf));
     1333    SetCurVertTexCoord(vec2(0.f, 0.f));
    12171334    AddVertex(vec3(-d.x, +d.y, +d.z + chamf));
     1335    SetCurVertTexCoord(vec2(.5f, 0.f));
    12181336    AddVertex(vec3(-d.x, -d.y, +d.z + chamf));
     1337    SetCurVertTexCoord(vec2(.5f, .5f));
    12191338
    12201339    AddVertex(vec3(+d.x + chamf, -d.y, -d.z));
     1340    SetCurVertTexCoord(vec2(.5f, .5f));
    12211341    AddVertex(vec3(+d.x + chamf, +d.y, -d.z));
     1342    SetCurVertTexCoord(vec2(.5f, .0f));
    12221343    AddVertex(vec3(+d.x + chamf, +d.y, +d.z));
     1344    SetCurVertTexCoord(vec2(1.f, .0f));
    12231345    AddVertex(vec3(+d.x + chamf, -d.y, +d.z));
    1224 
     1346    SetCurVertTexCoord(vec2(1.f, .5f));
     1347
     1348    //Bottom vertices
    12251349    AddVertex(vec3(-d.x, -d.y - chamf, +d.z));
     1350    SetCurVertTexCoord(vec2(0.f, 1.f));
    12261351    AddVertex(vec3(-d.x, -d.y - chamf, -d.z));
     1352    SetCurVertTexCoord(vec2(0.f, .5f));
    12271353    AddVertex(vec3(+d.x, -d.y - chamf, -d.z));
     1354    SetCurVertTexCoord(vec2(.5f, .5f));
    12281355    AddVertex(vec3(+d.x, -d.y - chamf, +d.z));
    1229 
     1356    SetCurVertTexCoord(vec2(.5f, 1.f));
     1357
     1358    //Top vertices
    12301359    AddVertex(vec3(-d.x, +d.y + chamf, -d.z));
     1360    SetCurVertTexCoord(vec2(0.f, 1.f));
    12311361    AddVertex(vec3(-d.x, +d.y + chamf, +d.z));
     1362    SetCurVertTexCoord(vec2(0.f, .5f));
    12321363    AddVertex(vec3(+d.x, +d.y + chamf, +d.z));
     1364    SetCurVertTexCoord(vec2(.5f, .5f));
    12331365    AddVertex(vec3(+d.x, +d.y + chamf, -d.z));
     1366    SetCurVertTexCoord(vec2(.5f, 1.f));
    12341367
    12351368    /* The 6 quads on each side of the box */
     
    12891422                          int fade, int fade2)
    12901423{
     1424    //TODO: It would probably be good to think of another way of UV painting this, like "branch repeating"
    12911425    int vbase = m_vert.Count();
    1292 
    1293     AddVertex(vec3(0.f, 0.f, 0.f));
     1426    float maxr = max(r1, r2);
     1427
     1428    AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f));
    12941429
    12951430    mat3 rotmat = mat3::rotate(180.0f / nbranches, 0.f, 1.f, 0.f);
    12961431    vec3 p1(r1, 0.f, 0.f), p2(r2, 0.f, 0.f);
    1297 
    1298     p2 = rotmat * p2;
     1432    vec3 uv1(0.f, 0.f, -.5f * ((float)r1 / maxr)),
     1433         uv2(0.f, 0.f, -.5f * ((float)r2 / maxr));
     1434
     1435    p2 = rotmat * p2; uv2 = rotmat * uv2;
    12991436    rotmat = rotmat * rotmat;
    13001437
    13011438    for (int i = 0; i < nbranches; i++)
    13021439    {
    1303         AddVertex(p1);
     1440        AddVertex(p1); SetCurVertTexCoord(uv1.xz + vec2(.5f));
    13041441        if (fade2)
    13051442            SetCurVertColor(m_color2);
    13061443
    1307         AddVertex(p2);
     1444        AddVertex(p2); SetCurVertTexCoord(uv2.xz + vec2(.5f));
    13081445        if (fade)
    13091446            SetCurVertColor(m_color2);
     
    13121449                   vbase);
    13131450
    1314         p1 = rotmat * p1;
    1315         p2 = rotmat * p2;
     1451        p1 = rotmat * p1; uv1 = rotmat * uv1;
     1452        p2 = rotmat * p2; uv2 = rotmat * uv2;
    13161453    }
    13171454}
     
    13221459{
    13231460    int vbase = m_vert.Count();
    1324 
    1325     AddVertex(vec3(0.f, 0.f, 0.f));
     1461    float maxr = (float)max(max(r1, r2), max(r1 + extrar, r2 + extrar));
     1462
     1463    AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f));
    13261464
    13271465    mat3 rotmat = mat3::rotate(180.0f / nbranches, 0.f, 1.f, 0.f);
    13281466    vec3 p1(r1, 0.f, 0.f), p2(r2, 0.f, 0.f),
    13291467         p3(r1 + extrar, 0.f, 0.f), p4(r2 + extrar, 0.f, 0.f);;
    1330 
    1331     p2 = rotmat * p2;
    1332     p4 = rotmat * p4;
     1468    vec3 uv1(0.f, 0.f, -.5f * ((float)r1 / maxr)),
     1469         uv2(0.f, 0.f, -.5f * ((float)r2 / maxr)),
     1470         uv3(0.f, 0.f, -.5f * ((float)(r1 + extrar) / maxr)),
     1471         uv4(0.f, 0.f, -.5f * ((float)(r2 + extrar) / maxr));
     1472
     1473    p2 = rotmat * p2; uv2 = rotmat * uv2;
     1474    p4 = rotmat * p4; uv4 = rotmat * uv4;
    13331475    rotmat = rotmat * rotmat;
    13341476
    13351477    for (int i = 0; i < nbranches; i++)
    13361478    {
    1337         AddVertex(p1);
    1338         AddVertex(p2);
    1339         AddVertex(p3); SetCurVertColor(m_color2);
    1340         AddVertex(p4); SetCurVertColor(m_color2);
     1479        AddVertex(p1); SetCurVertTexCoord(uv1.xz + vec2(.5f));
     1480        AddVertex(p2); SetCurVertTexCoord(uv2.xz + vec2(.5f));
     1481        AddVertex(p3); SetCurVertTexCoord(uv3.xz + vec2(.5f)); SetCurVertColor(m_color2);
     1482        AddVertex(p4); SetCurVertTexCoord(uv4.xz + vec2(.5f)); SetCurVertColor(m_color2);
    13411483
    13421484        int j = (i + 1) % nbranches;
     
    13451487        AppendQuad(4 * j + 1, 4 * i + 2, 4 * i + 4, 4 * j + 3, vbase);
    13461488
    1347         p1 = rotmat * p1;
    1348         p2 = rotmat * p2;
    1349         p3 = rotmat * p3;
    1350         p4 = rotmat * p4;
     1489        p1 = rotmat * p1; uv1 = rotmat * uv1;
     1490        p2 = rotmat * p2; uv2 = rotmat * uv2;
     1491        p3 = rotmat * p3; uv3 = rotmat * uv3;
     1492        p4 = rotmat * p4; uv4 = rotmat * uv4;
    13511493    }
    13521494}
     
    13571499    int vbase = m_vert.Count();
    13581500
    1359     AddVertex(vec3(0.f, 0.f, 0.f));
     1501    AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f));
    13601502
    13611503    mat3 rotmat = mat3::rotate(360.0f / nsides, 0.f, 1.f, 0.f);
    13621504    vec3 p1(r, 0.f, 0.f);
     1505    vec3 uv(.5f, .0f, .0f);
    13631506
    13641507    for (int i = 0; i < nsides; i++)
    13651508    {
    1366         AddVertex(p1);
     1509        AddVertex(p1); SetCurVertTexCoord(uv.xz + vec2(.5f, .5f));
    13671510        if (fade)
    13681511            SetCurVertColor(m_color2);
    13691512        AppendTriangle(0, i + 1, ((i + 1) % nsides) + 1, vbase);
    13701513        p1 = rotmat * p1;
     1514        uv = rotmat * uv;
    13711515    }
    13721516}
     
    13781522    vec3 p(0.f, 0.f, size);
    13791523
    1380     AddVertex(p);
     1524    AddVertex(p); SetCurVertTexCoord(vec2(.5f, 0.133975f));
    13811525    p = m * p;
    1382     AddVertex(p);
     1526    AddVertex(p); SetCurVertTexCoord(vec2(1.f, 1.f));
    13831527    if (fade)
    13841528        SetCurVertColor(m_color2);
    13851529    p = m * p;
    1386     AddVertex(p);
     1530    AddVertex(p); SetCurVertTexCoord(vec2(0.f, 1.f));
    13871531    if (fade)
    13881532        SetCurVertColor(m_color2);
     
    14001544void EasyMesh::AppendSimpleQuad(vec2 p1, vec2 p2, float z, int fade)
    14011545{
    1402     AddVertex(vec3(p2.x, z, -p1.y));
    1403     AddVertex(vec3(p2.x, z, -p2.y));
    1404     AddVertex(vec3(p1.x, z, -p2.y));
     1546    AddVertex(vec3(p2.x, z, -p1.y)); SetCurVertTexCoord(vec2(0.f, 1.f));
     1547    AddVertex(vec3(p2.x, z, -p2.y)); SetCurVertTexCoord(vec2(0.f, 0.f));
     1548    AddVertex(vec3(p1.x, z, -p2.y)); SetCurVertTexCoord(vec2(1.f, 0.f));
    14051549    if (fade)
    14061550        SetCurVertColor(m_color2);
    1407     AddVertex(vec3(p1.x, z, -p1.y));
     1551    AddVertex(vec3(p1.x, z, -p1.y)); SetCurVertTexCoord(vec2(1.f, 1.f));
    14081552    if (fade)
    14091553        SetCurVertColor(m_color2);
    14101554
    1411     AppendQuad(3, 2, 1, 0, m_vert.Count() - 4);
     1555    AppendQuad(0, 1, 2, 3, m_vert.Count() - 4);
    14121556    ComputeNormals(m_indices.Count() - 6, 6);
    14131557}
     
    14311575    vec3 p[12];
    14321576
     1577    //Upper points
    14331578    p[0] = vec3(r10, h * .5f, 0.f);
    14341579    p[1] = rotmat * p[0];
     
    14381583    p[5] = smat2 * (rotmat * p[4]);
    14391584
     1585    //Lower points
    14401586    p[6] = vec3(r20, h * -.5f, 0.f);
    14411587    p[7] = rotmat * p[6];
     
    14511597    rotmat = rotmat * rotmat;
    14521598
     1599    //UV base computation
     1600    float maxr = max(max(r1 + r12, r2 + r22), max(r10, r20));
     1601    float InLn = length(p[1] - p[0]);
     1602    float CogLn[8] = { .0f, .0f, .0f, .0f, .0f, .0f, .0f, .0f };
     1603    for (int i = 0; i < 3; i++)
     1604    {
     1605        for (int j = 0, k = 2; j < 8 && k < 12; j += 4, k += 6)
     1606        {
     1607            CogLn[j + i] = length(p[k + i + 1] - p[k + i]);
     1608            CogLn[j + 3] += CogLn[j + i];
     1609            if (i == 1) //Add 3to4 twice since it's automatically completed by +1 loop.
     1610                CogLn[j + 3] += CogLn[j + i];
     1611        }
     1612    }
     1613
     1614    //Choose the biggest cog length
     1615    int CogSrc = (CogLn[7] > CogLn[3])?(4):(0);
     1616    CogLn[3] = CogLn[CogSrc + 3];
     1617    for (int i = 0; i < 3; i++)
     1618        CogLn[i] = CogLn[CogSrc + i] / CogLn[CogSrc + 3];
     1619
     1620    //Calculate Cog Modifiers
     1621    vec2 InUV[2] = { vec2(.0f), vec2(.5f) };
     1622    vec2 CogUV[2] = { vec2(.0f), vec2(.5f) };
     1623    vec2 upadd = vec2(.25f, .75f);
     1624    vec2 lowadd = vec2(.75f, .75f);
     1625    {
     1626        if (h < InLn)
     1627        {
     1628            InUV[0].x  = 1.0f;
     1629            InUV[0].y  = h / InLn;
     1630            InUV[1].x  = .0f;
     1631            InUV[1].y -= InUV[0].y * .5f;
     1632        }
     1633        else
     1634        {
     1635            InUV[0].x  = InLn / h;
     1636            InUV[0].y  = 1.0f;
     1637            InUV[1].x -= InUV[0].x * .5f;
     1638            InUV[1].y = .0f;
     1639        }
     1640        if (h < CogLn[3])
     1641        {
     1642            CogUV[0].x  = 1.0f;
     1643            CogUV[0].y  = h / CogLn[3];
     1644            CogUV[1].x  = .0f;
     1645            CogUV[1].y -= CogUV[0].y * .5f;
     1646        }
     1647        else
     1648        {
     1649            CogUV[0].x  = CogLn[3] / h;
     1650            CogUV[0].y  = 1.0f;
     1651            CogUV[1].x -= CogUV[0].x * .5f;
     1652            CogUV[1].y  = .0f;
     1653        }
     1654        if (InUV[0].x + CogUV[0].x < .5f)
     1655        {
     1656            InUV[1].x = .0f;
     1657            CogUV[1].x = .5f - CogUV[0].x;
     1658            upadd  = vec2(.75f, .25f);
     1659            lowadd = vec2(.75f, .75f);
     1660        }
     1661        else if (InUV[0].y + CogUV[0].y < .5f)
     1662        {
     1663            InUV[1].y = .0f;
     1664            CogUV[1].y = .5f - CogUV[0].y;
     1665        }
     1666        else
     1667        {
     1668            InUV[0] *= .5f;
     1669            InUV[1] *= .5f;
     1670            CogUV[0] *= .5f;
     1671            CogUV[1] *= .5f;
     1672            InUV[1] += vec2(.5f, .0f);
     1673        }
     1674    }
     1675
     1676    //Build UV tab
     1677    vec2 uv[12]; float CogSz;
     1678    //Upper points
     1679    CogSz = 1.0f - CogLn[1];
     1680    uv[0]  = vec2(0.f,   0.f) * InUV[0]  + InUV[1];
     1681    uv[1]  = vec2(1.f,   0.f) * InUV[0]  + InUV[1];
     1682    uv[5]  = vec2(CogSz, 0.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[2];
     1683    uv[4]  = vec2(CogSz, 0.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[1];
     1684    uv[3]  = vec2(CogSz, 0.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[0];
     1685    uv[2]  = vec2(0.f,   0.f) * CogUV[0] + CogUV[1];
     1686
     1687    //Lower points
     1688    CogSz = 1.0f - CogLn[1];
     1689    uv[6]  = vec2(0.f,   1.f) * InUV[0]  + InUV[1];
     1690    uv[7]  = vec2(1.f,   1.f) * InUV[0]  + InUV[1];
     1691    uv[11] = vec2(CogSz, 1.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[2];
     1692    uv[10] = vec2(CogSz, 1.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[1];
     1693    uv[ 9] = vec2(CogSz, 1.f) * CogUV[0] + CogUV[1]; CogSz -= CogLn[0];
     1694    uv[ 8] = vec2(0.f,   1.f) * CogUV[0] + CogUV[1];
     1695
     1696    //Gear generation loop
    14531697    for (int i = 0; i < nbsides; i++)
    14541698    {
     1699        int j = 3 * 12 * i,
     1700            k = 3 * 12 * ((i + 1) % nbsides);
     1701
     1702        int q[] = { /* The top and bottom faces */
     1703                    j, j, j, j, 
     1704                    j, j, j, j,
     1705                    j, j, k, k,     
     1706                    k, k, j, j,
     1707                    j, j, j, k, 
     1708                    k, j, j, j,
     1709                    /* The inner side quads */
     1710                    j, j, j, j,
     1711                    j, k, k, j,
     1712                    /* The outer side quads */
     1713                    j, j, j, j,
     1714                    j, j, j, j,
     1715                    j, j, j, j,
     1716                    k, j, j, k
     1717                    };
     1718        int m[] = { /* The top and bottom faces */
     1719                    0,  2,  3,  1,
     1720                    7,  9,  8,  6,
     1721                    1,  3,  2,  0,
     1722                    6,  8,  9,  7,
     1723                    3,  4,  5,  2,
     1724                    8, 11, 10,  9,
     1725                    /* The inner side quads */
     1726                    0,  1,  7,  6,
     1727                    1,  0,  6,  7,
     1728                    /* The outer side quads */
     1729                    3,  2,  8,  9,
     1730                    4,  3,  9, 10,
     1731                    5,  4, 10, 11,
     1732                    2,  5, 11, 8
     1733                    };
     1734        int a[] = { /* The top and bottom faces */
     1735                    0, 0, 0, 0,
     1736                    0, 0, 0, 0,
     1737                    0, 0, 0, 0,
     1738                    0, 0, 0, 0,
     1739                    0, 0, 0, 0,
     1740                    0, 0, 0, 0,
     1741                    /* The inner side quads */
     1742                    1, 1, 1, 1,
     1743                    2, 2, 2, 2,
     1744                    /* The outer side quads */
     1745                    1, 1, 1, 1,
     1746                    1, 2, 2, 1,
     1747                    1, 2, 2, 1,
     1748                    2, 2, 2, 2
     1749                    };
     1750
    14551751        /* Each vertex will share three faces, so three different
    14561752         * normals, therefore we add each vertex three times. */
    14571753        for (int n = 0; n < 3 * 12; n++)
    14581754        {
    1459             AddVertex(p[n / 3]);
    1460             if (n / 3 >= 6)
     1755            int d = n / 3;
     1756            int m = d % 6;
     1757            AddVertex(p[d]);
     1758            if (n % 3 == 0) //Top-Bottom logic
     1759            {
     1760                vec2 tmp = (p[d].xz / maxr);
     1761                vec2 add;
     1762                if (d >= 6)
     1763                {
     1764                    tmp *= -1.0f;
     1765                    add = lowadd;
     1766                }
     1767                else
     1768                    add = upadd;
     1769                SetCurVertTexCoord(tmp * vec2(.25f) + add);
     1770            }
     1771            else if (m == 0 || m == 1) //inner Logic
     1772                SetCurVertTexCoord(uv[d]);
     1773            else //Cog logic
     1774            {
     1775                if (m == 2 && n % 3 == 2)
     1776                    SetCurVertTexCoord(vec2(1.f, (d == 2)?(0.f):(1.f)) * CogUV[0] + CogUV[1]);
     1777                else
     1778                    SetCurVertTexCoord(uv[d]);
     1779            }
     1780            if (d >= 6)
    14611781                SetCurVertColor(m_color2);
    14621782        }
    14631783
    1464         int j = 3 * 12 * i, k = 3 * 12 * ((i + 1) % nbsides);
    1465 
    1466         /* The top and bottom faces */
    1467         AppendQuad(j, j + 6, j + 9, j + 3, vbase);
    1468         AppendQuad(j + 21, j + 27, j + 24, j + 18, vbase);
    1469         AppendQuad(j + 3, j + 9, k + 6, k, vbase);
    1470         AppendQuad(k + 18, k + 24, j + 27, j + 21, vbase);
    1471         AppendQuad(j + 9, j + 12, j + 15, k + 6, vbase);
    1472         AppendQuad(k + 24, j + 33, j + 30, j + 27, vbase);
    1473 
    1474         /* The inner side quads */
    1475         AppendQuad(j + 1, j + 4, j + 22, j + 19, vbase);
    1476         AppendQuad(j + 5, k + 2, k + 20, j + 23, vbase);
    1477 
    1478         /* The outer side quads */
    1479         AppendQuad(j + 10, j + 7, j + 25, j + 28, vbase);
    1480         AppendQuad(j + 13, j + 11, j + 29, j + 31, vbase);
    1481         AppendQuad(j + 16, j + 14, j + 32, j + 34, vbase);
    1482         AppendQuad(k + 8, j + 17, j + 35, k + 26, vbase);
    1483 
     1784        int l = -4;
     1785        while ((l += 4) < 48)
     1786            AppendQuad(q[l + 0] + m[l + 0] * 3 + a[l + 0],
     1787                       q[l + 1] + m[l + 1] * 3 + a[l + 1],
     1788                       q[l + 2] + m[l + 2] * 3 + a[l + 2],
     1789                       q[l + 3] + m[l + 3] * 3 + a[l + 3],
     1790                       vbase);
     1791       
    14841792        for (int n = 0; n < 12; n++)
    14851793            p[n] = rotmat * p[n];
  • trunk/src/easymesh/easymesh.h

    r2379 r2404  
    7979};
    8080
     81struct MeshBuildOperation
     82{
     83    enum Value
     84    {
     85        Scale_Winding   = 1 << 0,
     86
     87        All     = 0xffffffff
     88    }
     89    m_value;
     90
     91    inline MeshBuildOperation(Value v) : m_value(v) {}
     92    inline MeshBuildOperation(uint64_t i) : m_value((Value)i) {}
     93    inline operator Value() { return m_value; }
     94};
     95
    8196class EasyMesh
    8297{
     
    99114    void MeshCsg(CSGUsage csg_operation);
    100115public:
     116    /* [cmd:csgu] Performs a Union operation as (mesh0_Outside + mesh1_Outside) */
    101117    void CsgUnion()         { MeshCsg(CSGUsage::Union); }
     118    /* [cmd:csgs] Performs a Substract operation as (mesh0_Outside + mesh1_Inside-inverted) */
    102119    void CsgSubstract()     { MeshCsg(CSGUsage::Substract); }
     120    /* [cmd:csgsl] Performs a Substract operation without keeping the mesh1 part */
    103121    void CsgSubstractLoss() { MeshCsg(CSGUsage::SubstractLoss); }
     122    /* [cmd:csga] Performs an And operation as (mesh0_Inside + mesh1_Inside) */
    104123    void CsgAnd()           { MeshCsg(CSGUsage::And); }
     124    /* [cmd:csgx] Performs a Xor operation as (m0_Outside/m0_Inside-inverted + m1_Outside/m1_Inside-inverted) */
    105125    void CsgXor()           { MeshCsg(CSGUsage::Xor); }
    106126
    107127public:
     128    /* [cmd:[] from this point onward, any operation will not be performed on previous vertices */
    108129    void OpenBrace();
     130    /* [cmd:]] Merge current vertices with previous context */
    109131    void CloseBrace();
    110 
     132    /* [cmd:tsw] When activation, on negative-scaling, normal fixing will not occur */
    111133    void ToggleScaleWinding();
     134    /* [cmd:sc] Set vertices color */
    112135    void SetCurColor(vec4 const &color);
     136    /* [cmd:scb] Set vertices color 2 */
    113137    void SetCurColor2(vec4 const &color);
    114138
    115139private:
     140    //-------------------------------------------------------------------------
     141    //Internal : Basic triangle/vertex operations
     142    //-------------------------------------------------------------------------
    116143    void AddVertex(vec3 const &coord);
    117144    void AddDuplicateVertex(int i);
     
    121148    void AppendTriangleDuplicateVerts(int i1, int i2, int i3, int base);
    122149    void ComputeNormals(int start, int vcount);
    123 public:
     150public: //DEBUG
    124151    void ComputeTexCoord(float uv_scale, int uv_offset);
     152
     153    //-------------------------------------------------------------------------
     154    //Vertices operations
     155    //-------------------------------------------------------------------------
    125156    void SetVertColor(vec4 const &color);
     157    void SetTexCoordData(vec2 const &new_offset, vec2 const &new_scale);
    126158
    127159    void SetCurVertNormal(vec3 const &normal);
    128160    void SetCurVertColor(vec4 const &color);
     161    void SetCurVertTexCoord(vec2 const &texcoord);
    129162
    130163public:
     
    132165    //Mesh transform operations
    133166    //-------------------------------------------------------------------------
     167
     168    /* [cmd:t/tx/ty/tz] Translate vertices
     169        - v : Translation quantity.
     170     */
    134171    void Translate(vec3 const &v);
    135     void RotateX(float t);
    136     void RotateY(float t);
    137     void RotateZ(float t);
    138     void Rotate(float t, vec3 const &axis);
     172    /* See Rotate */
     173    void RotateX(float angle);
     174    /* See Rotate */
     175    void RotateY(float angle);
     176    /* See Rotate */
     177    void RotateZ(float angle);
     178    /* [cmd:r/rx/ry/rz] Rotate vertices
     179        - angle : rotation quantity.
     180        - axis : rotation axis.
     181     */
     182    void Rotate(float angle, vec3 const &axis);
     183    /* [cmd:rj] Randomly move vertices along Origin-to-vertex as o2v *= (1.0 + rand(r))
     184        - r : jitter maximum value.
     185     */
    139186    void RadialJitter(float r);
     187    //TODO : twist
     188    //TODO : bend
     189    //TODO : stretch
     190    //TODO : shear
     191    /* [cmd:tax] multiply y&z by (1.0 + (n * x + xoff))
     192        - y : value of n for y.
     193        - z : value of n for z.
     194        - xoff : value of xoff.
     195     */
    140196    void TaperX(float y, float z, float xoff);
     197    /* [cmd:tay] multiply x&z by (1.0 + (n * y + yoff))
     198        - x : value of n for x.
     199        - z : value of n for z.
     200        - yoff : value of yoff.
     201     */
    141202    void TaperY(float x, float z, float yoff);
     203    /* [cmd:taz] multiply x&y by (1.0 + (n * z + zoff))
     204        - x : value of n for x.
     205        - y : value of n for y.
     206        - zoff : value of zoff.
     207     */
    142208    void TaperZ(float x, float y, float zoff);
     209    /* [cmd:s/sx/sy/sz] Scale vertices
     210        - s : scale quantity.
     211     */
    143212    void Scale(vec3 const &s);
     213    /* [cmd:mx] Mirror vertices through X-plane
     214        Acts as an OpenBrace
     215     */
    144216    void MirrorX();
     217    /* [cmd:my] Mirror vertices through Y-plane
     218        Acts as an OpenBrace
     219     */
    145220    void MirrorY();
     221    /* [cmd:mz] Mirror vertices through Z-plane
     222        Acts as an OpenBrace
     223     */
    146224    void MirrorZ();
     225    /* [no-cmd] Duplicates vertices and scale duplicate
     226        Acts as an OpenBrace
     227     */
    147228    void DupAndScale(vec3 const &s);
     229    /* [cmd:ch] Performs a chamfer operation //TODO : Make it work.
     230        - f : Chamfer quantity.
     231     */
    148232    void Chamfer(float f);
    149233
     
    151235    //Mesh shape operations
    152236    //-------------------------------------------------------------------------
     237
     238    /* [cmd:ac] Cylinder centered on (0,0,0) with BBox [-max(r1, r2), -.5*h, -max(r1, r2)][max(r1, r2), .5*h, max(r1, r2)]
     239        - nbsides : Number of sides.
     240        - h : Height of the cylinder.
     241        - r1 : Lower radius. TODO:convert to diameter to be coherent with other funcs
     242        - r2 : Upper radius. TODO:convert to diameter to be coherent with other funcs
     243        - dualside : if (1) will also create inner sides : TOOD:TOREMOVE?? : needed ?
     244        - smooth : if (1) will smooth normals : TOOD:TOREMOVE : smooth should be handled elsewhere
     245        - close : if (1) will add discs to close the cylinder
     246     */
    153247    void AppendCylinder(int nsides, float h, float r1, float r2,
    154                         int dualside, int smooth);
     248                        int dualside, int smooth, int close);
     249    /* [cmd:asph] Sphere centered on (0,0,0) with BBox [-size][size]
     250        - ndivisions : number of subdivisions each Sphere triangle will sustain.
     251        - size : size of the Sphere.
     252     */
     253    void AppendSphere(int ndivisions, float r);
     254    /* [cmd:acap] Capsule centered on (0,0,0) with BBox [-r, -(r+h) ,-r][r, (r+h) ,r]
     255        - ndivisions : number of subdivisions each Sphere triangle will sustain.
     256        - h : Inner height.
     257        - r : Radius. TODO:convert to diameter to be coherent with other funcs
     258     */
    155259    void AppendCapsule(int ndivisions, float h, float r);
    156     void AppendSphere(int ndivisions, vec3 const &size);
     260    /* [cmd:ato] Torus centered on (0,0,0) with BBox [-r2][r2]
     261        - ndivisions : number of subdivisions of the torus.
     262        - r1 : Inner radius. TODO:convert to diameter to be coherent with other funcs
     263        - r2 : Outer radius. TODO:convert to diameter to be coherent with other funcs
     264     */
    157265    void AppendTorus(int ndivisions, float r1, float r2);
     266    /* [cmd:ab] Box centered on (0,0,0) with BBox [-.5 * size][.5 * size]
     267        - size : size of the box.
     268        - chamf : size of the chamfer.
     269        - smooth : if (1) will smooth normals : TOOD:TOREMOVE : smooth should be handled elsewhere
     270     */
    158271    void AppendBox(vec3 const &size, float chamf = 0.f);
     272    //Same as AppendBox
    159273    void AppendSmoothChamfBox(vec3 const &size, float chamf);
     274    //Same as AppendBox
    160275    void AppendFlatChamfBox(vec3 const &size, float chamf);
     276    //Same as AppendBox
    161277    void AppendBox(vec3 const &size, float chamf, bool smooth);
     278    /* [cmd:as]
     279       Append a Star centered on (0,0,0) contained within a disc of "max(r1, r2)" radius.
     280        - nbranches : Number of branches.
     281        - r1 : Length of the branches.
     282        - r2 : Length of the "branch" located between r1-branches.
     283        - fade : if (1) in-between branches use Color2.
     284        - fade2 : if (1) Star branches use Color2.
     285     */
    162286    void AppendStar(int nbranches, float r1, float r2,
    163287                    int fade = 0, int fade2 = 0);
     288    /* [cmd:aes] Star centered on (0,0,0) contained within a disc of "max(max(r1, r2), max(r1 + extrar, r2 + extrar))" radius.
     289       Expanded star branches use Color2.
     290        - nbranches : Number of branches.
     291        - r1 : Length of the branches.
     292        - r2 : Length of the "branch" located between r1-branches.
     293        - extrar : Extra length added to expand all branches.
     294     */
    164295    void AppendExpandedStar(int nbranches, float r1, float r2, float extrar);
     296    /* [cmd:ad] Disc centered on (0,0,0) with BBox [-size][size]
     297        - nbsides : Number of sides.
     298        - r : Radius. TODO:convert to diameter to be coherent with other funcs
     299        - fade : if (1) Outer vertices will use Color2
     300     */
    165301    void AppendDisc(int nsides, float r, int fade = 0);
     302    /* [cmd:at] Triangle centered on (0,0,0) contained within a disc of "size" radius.
     303        - size : Size of vector : origin-TO-vertex.
     304        - fade : if (1) 2nd & 3rd Vertices will use Color2
     305     */
    166306    void AppendSimpleTriangle(float size, int fade = 0);
     307    /* [cmd:aq] Quad centered on (0,0,0) contained within BBox [-size,0,-size][size,0,size]
     308        - size : Size of quad.
     309        - fade : if (1) 3rd & 4th Vertices will use Color2
     310     */
    167311    void AppendSimpleQuad(float size, int fade = 0);
     312private:
     313    //complex version of above one
    168314    void AppendSimpleQuad(vec2 p1, vec2 p2, float z = 0.f, int fade = 0);
     315public:
     316    /* [cmd:acg] Gear centered on (0,0,0) contained within BBox [-max(r1,r2), -.5*h, -max(r1, r2)][max(r1, r2), .5*h, max(r1, r2)]
     317        - h : Height of the Gear.
     318        - r10 : Upper Inner radius.
     319        - r20 : Lower Inner radius.
     320        - r1  : Upper Outer radius.
     321        - r2  : Lower Outer radius.
     322        - r12 : Upper Cog radius.
     323        - r22 : Lower Cog radius.
     324        - sidemul : multiplier for the size of the cogs.
     325        - offset : useless
     326     */
    169327    void AppendCog(int nbsides, float h, float r10, float r20, float r1,
    170328                   float r2, float r12, float r22, float sidemul, int offset);
     
    202360    //When this flag is up, negative scaling will not invert faces.
    203361    bool m_ignore_winding_on_scale;
     362    //Texture coordinate modifiers.
     363    vec2 m_texcoord_offset;
     364    vec2 m_texcoord_scale;
    204365
    205366    /* FIXME: put this in a separate class so that we can copy meshes. */
  • trunk/src/easymesh/shinydebugUV.lolfx

    r2379 r2404  
    5151void main(void)
    5252{
    53     gl_FragColor = vec4(mod(pass_TexCoord.x, 1.0f), 0.2, mod(pass_TexCoord.y, 1.0), 1.0) * length(normalize(pass_Color.xyz)) * length(normalize(pass_TNormal));
     53    float mode = 0.0;
     54    if (mode == 0.0)
     55    {
     56        gl_FragColor = vec4(mod(pass_TexCoord.x, 1.0f),
     57                            0.1,
     58                            mod(pass_TexCoord.y, 1.0), 1.0);
     59    }
     60    else
     61    {
     62        float col = ((mod(mode, 2.0) == 1)?(mod(pass_TexCoord.x, 1.0)):(mod(pass_TexCoord.y, 1.0)));
     63        if (mode == 1 || mode == 2)
     64        {
     65            if (col > 1.0/3.0) gl_FragColor.r = 0.0;
     66            else gl_FragColor.r = min(col, 1.0/3.0);
     67            if (col > 2.0/3.0) gl_FragColor.g = 0.0;
     68            else gl_FragColor.g = min(max(col, 1.0/3.0) - 1.0/3.0, 1.0/3.0);
     69            gl_FragColor.b = min(max(col, 2.0/3.0) - 2.0/3.0, 1.0/3.0);
     70        }
     71        else if (mode == 3 || mode == 4)
     72        {
     73            if (col > 0.5) gl_FragColor.r = 0.0;
     74            else gl_FragColor.r = min(col, 0.5);
     75            gl_FragColor.g = min(max(col, 0.5) - 0.5, 0.5);
     76            gl_FragColor.b = 0.1;
     77        }
     78        else if (mode == 5 || mode == 6)
     79        {
     80            gl_FragColor.r = col;
     81            gl_FragColor.g = 0.1;
     82            gl_FragColor.b = 0.1;
     83        }
     84    }
     85
     86    gl_FragColor.a = 1.0;
     87    gl_FragColor *=
     88                 //= pass_Color *
     89                    length(normalize(pass_TexCoord)) *
     90                    length(normalize(pass_Color.xyz)) *
     91                    length(normalize(pass_TNormal));
    5492}
    5593
  • trunk/src/generated/easymesh-parser.cpp

    r2318 r2404  
    3636/* First part of user declarations.  */
    3737
    38 /* Line 293 of lalr1.cc  */
     38/* Line 310 of lalr1.cc  */
    3939#line 1 "easymesh/easymesh-parser.y"
    4040
     
    6262
    6363
    64 /* Line 293 of lalr1.cc  */
     64/* Line 310 of lalr1.cc  */
    6565#line 66 "generated/easymesh-parser.cpp"
    6666
     
    7070/* User implementation prologue.  */
    7171
    72 /* Line 299 of lalr1.cc  */
     72/* Line 316 of lalr1.cc  */
    7373#line 66 "easymesh/easymesh-parser.y"
    7474
     
    7979
    8080
    81 /* Line 299 of lalr1.cc  */
     81/* Line 316 of lalr1.cc  */
    8282#line 83 "generated/easymesh-parser.cpp"
    8383
     
    9494#endif
    9595
    96 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
    97    If N is 0, then set CURRENT to the empty location which ends
    98    the previous symbol: RHS[0] (always defined).  */
    99 
    100 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
    101 #ifndef YYLLOC_DEFAULT
    102 # define YYLLOC_DEFAULT(Current, Rhs, N)                               \
    103  do                                                                    \
    104    if (N)                                                              \
    105      {                                                                 \
    106        (Current).begin = YYRHSLOC (Rhs, 1).begin;                      \
    107        (Current).end   = YYRHSLOC (Rhs, N).end;                        \
    108      }                                                                 \
    109    else                                                                \
    110      {                                                                 \
    111        (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end;        \
    112      }                                                                 \
    113  while (false)
    114 #endif
    115 
    11696/* Suppress unused-variable warnings by "using" E.  */
    11797#define YYUSE(e) ((void) (e))
     
    165145namespace lol {
    166146
    167 /* Line 382 of lalr1.cc  */
    168 #line 169 "generated/easymesh-parser.cpp"
     147/* Line 379 of lalr1.cc  */
     148#line 149 "generated/easymesh-parser.cpp"
     149#if YYERROR_VERBOSE
    169150
    170151  /* Return YYSTR after stripping away unnecessary quotes and
     
    205186  }
    206187
     188#endif
    207189
    208190  /// Build a parser object.
     
    305287#endif
    306288
    307   inline bool
    308   EasyMeshParser::yy_pact_value_is_default_ (int yyvalue)
    309   {
    310     return yyvalue == yypact_ninf_;
    311   }
    312 
    313   inline bool
    314   EasyMeshParser::yy_table_value_is_error_ (int yyvalue)
    315   {
    316     return yyvalue == yytable_ninf_;
    317   }
    318 
    319289  int
    320290  EasyMeshParser::parse ()
     
    338308    location_type yylloc;
    339309    /// The locations where the error started and ended.
    340     location_type yyerror_range[3];
     310    location_type yyerror_range[2];
    341311
    342312    /// $$.
     
    376346    /* Try to take a decision without lookahead.  */
    377347    yyn = yypact_[yystate];
    378     if (yy_pact_value_is_default_ (yyn))
     348    if (yyn == yypact_ninf_)
    379349      goto yydefault;
    380350
     
    409379    if (yyn <= 0)
    410380      {
    411         if (yy_table_value_is_error_ (yyn))
    412           goto yyerrlab;
     381        if (yyn == 0 || yyn == yytable_ninf_)
     382        goto yyerrlab;
    413383        yyn = -yyn;
    414384        goto yyreduce;
     
    466436          case 7:
    467437
    468 /* Line 690 of lalr1.cc  */
     438/* Line 677 of lalr1.cc  */
    469439#line 90 "easymesh/easymesh-parser.y"
    470440    { mc.m_mesh.OpenBrace(); }
     
    473443  case 8:
    474444
    475 /* Line 690 of lalr1.cc  */
     445/* Line 677 of lalr1.cc  */
    476446#line 94 "easymesh/easymesh-parser.y"
    477447    { mc.m_mesh.CloseBrace(); }
     
    480450  case 14:
    481451
    482 /* Line 690 of lalr1.cc  */
     452/* Line 677 of lalr1.cc  */
    483453#line 109 "easymesh/easymesh-parser.y"
    484454    { mc.m_mesh.SetCurColor(vec4((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); }
     
    487457  case 15:
    488458
    489 /* Line 690 of lalr1.cc  */
     459/* Line 677 of lalr1.cc  */
    490460#line 110 "easymesh/easymesh-parser.y"
    491461    { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val);
     
    496466  case 16:
    497467
    498 /* Line 690 of lalr1.cc  */
     468/* Line 677 of lalr1.cc  */
    499469#line 113 "easymesh/easymesh-parser.y"
    500470    { mc.m_mesh.SetCurColor2(vec4((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); }
     
    503473  case 17:
    504474
    505 /* Line 690 of lalr1.cc  */
     475/* Line 677 of lalr1.cc  */
    506476#line 114 "easymesh/easymesh-parser.y"
    507477    { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val);
     
    512482  case 18:
    513483
    514 /* Line 690 of lalr1.cc  */
     484/* Line 677 of lalr1.cc  */
    515485#line 120 "easymesh/easymesh-parser.y"
    516486    { mc.m_mesh.Chamfer((yysemantic_stack_[(2) - (2)].args).f0); }
     
    519489  case 19:
    520490
    521 /* Line 690 of lalr1.cc  */
     491/* Line 677 of lalr1.cc  */
    522492#line 121 "easymesh/easymesh-parser.y"
    523493    { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, 0, 0)); }
     
    526496  case 20:
    527497
    528 /* Line 690 of lalr1.cc  */
     498/* Line 677 of lalr1.cc  */
    529499#line 122 "easymesh/easymesh-parser.y"
    530500    { mc.m_mesh.Translate(vec3(0, (yysemantic_stack_[(2) - (2)].args).f0, 0)); }
     
    533503  case 21:
    534504
    535 /* Line 690 of lalr1.cc  */
     505/* Line 677 of lalr1.cc  */
    536506#line 123 "easymesh/easymesh-parser.y"
    537507    { mc.m_mesh.Translate(vec3(0, 0, (yysemantic_stack_[(2) - (2)].args).f0)); }
     
    540510  case 22:
    541511
    542 /* Line 690 of lalr1.cc  */
     512/* Line 677 of lalr1.cc  */
    543513#line 124 "easymesh/easymesh-parser.y"
    544514    { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
     
    547517  case 23:
    548518
    549 /* Line 690 of lalr1.cc  */
     519/* Line 677 of lalr1.cc  */
    550520#line 125 "easymesh/easymesh-parser.y"
    551521    { mc.m_mesh.RotateX((yysemantic_stack_[(2) - (2)].args).f0); }
     
    554524  case 24:
    555525
    556 /* Line 690 of lalr1.cc  */
     526/* Line 677 of lalr1.cc  */
    557527#line 126 "easymesh/easymesh-parser.y"
    558528    { mc.m_mesh.RotateY((yysemantic_stack_[(2) - (2)].args).f0); }
     
    561531  case 25:
    562532
    563 /* Line 690 of lalr1.cc  */
     533/* Line 677 of lalr1.cc  */
    564534#line 127 "easymesh/easymesh-parser.y"
    565535    { mc.m_mesh.RotateZ((yysemantic_stack_[(2) - (2)].args).f0); }
     
    568538  case 26:
    569539
    570 /* Line 690 of lalr1.cc  */
     540/* Line 677 of lalr1.cc  */
    571541#line 128 "easymesh/easymesh-parser.y"
    572542    { mc.m_mesh.TaperX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
     
    575545  case 27:
    576546
    577 /* Line 690 of lalr1.cc  */
     547/* Line 677 of lalr1.cc  */
    578548#line 129 "easymesh/easymesh-parser.y"
    579549    { mc.m_mesh.TaperY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
     
    582552  case 28:
    583553
    584 /* Line 690 of lalr1.cc  */
     554/* Line 677 of lalr1.cc  */
    585555#line 130 "easymesh/easymesh-parser.y"
    586556    { mc.m_mesh.TaperZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
     
    589559  case 29:
    590560
    591 /* Line 690 of lalr1.cc  */
     561/* Line 677 of lalr1.cc  */
    592562#line 131 "easymesh/easymesh-parser.y"
    593563    { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, 1.0, 1.0)); }
     
    596566  case 30:
    597567
    598 /* Line 690 of lalr1.cc  */
     568/* Line 677 of lalr1.cc  */
    599569#line 132 "easymesh/easymesh-parser.y"
    600570    { mc.m_mesh.Scale(vec3(1.0, (yysemantic_stack_[(2) - (2)].args).f0, 1.0)); }
     
    603573  case 31:
    604574
    605 /* Line 690 of lalr1.cc  */
     575/* Line 677 of lalr1.cc  */
    606576#line 133 "easymesh/easymesh-parser.y"
    607577    { mc.m_mesh.Scale(vec3(1.0, 1.0, (yysemantic_stack_[(2) - (2)].args).f0)); }
     
    610580  case 32:
    611581
    612 /* Line 690 of lalr1.cc  */
     582/* Line 677 of lalr1.cc  */
    613583#line 134 "easymesh/easymesh-parser.y"
    614584    { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
     
    617587  case 33:
    618588
    619 /* Line 690 of lalr1.cc  */
     589/* Line 677 of lalr1.cc  */
    620590#line 135 "easymesh/easymesh-parser.y"
    621591    { mc.m_mesh.MirrorX(); }
     
    624594  case 34:
    625595
    626 /* Line 690 of lalr1.cc  */
     596/* Line 677 of lalr1.cc  */
    627597#line 136 "easymesh/easymesh-parser.y"
    628598    { mc.m_mesh.MirrorY(); }
     
    631601  case 35:
    632602
    633 /* Line 690 of lalr1.cc  */
     603/* Line 677 of lalr1.cc  */
    634604#line 137 "easymesh/easymesh-parser.y"
    635605    { mc.m_mesh.MirrorZ(); }
     
    638608  case 36:
    639609
    640 /* Line 690 of lalr1.cc  */
     610/* Line 677 of lalr1.cc  */
    641611#line 138 "easymesh/easymesh-parser.y"
    642612    { mc.m_mesh.RadialJitter((yysemantic_stack_[(2) - (2)].args).f0); }
     
    645615  case 37:
    646616
    647 /* Line 690 of lalr1.cc  */
     617/* Line 677 of lalr1.cc  */
    648618#line 139 "easymesh/easymesh-parser.y"
    649619    { mc.m_mesh.ToggleScaleWinding(); }
     
    652622  case 38:
    653623
    654 /* Line 690 of lalr1.cc  */
     624/* Line 677 of lalr1.cc  */
    655625#line 140 "easymesh/easymesh-parser.y"
    656626    { mc.m_mesh.CsgUnion(); }
     
    659629  case 39:
    660630
    661 /* Line 690 of lalr1.cc  */
     631/* Line 677 of lalr1.cc  */
    662632#line 141 "easymesh/easymesh-parser.y"
    663633    { mc.m_mesh.CsgSubstract(); }
     
    666636  case 40:
    667637
    668 /* Line 690 of lalr1.cc  */
     638/* Line 677 of lalr1.cc  */
    669639#line 142 "easymesh/easymesh-parser.y"
     640    { mc.m_mesh.CsgSubstractLoss(); }
     641    break;
     642
     643  case 41:
     644
     645/* Line 677 of lalr1.cc  */
     646#line 143 "easymesh/easymesh-parser.y"
    670647    { mc.m_mesh.CsgAnd(); }
    671648    break;
    672649
    673   case 41:
    674 
    675 /* Line 690 of lalr1.cc  */
    676 #line 143 "easymesh/easymesh-parser.y"
     650  case 42:
     651
     652/* Line 677 of lalr1.cc  */
     653#line 144 "easymesh/easymesh-parser.y"
    677654    { mc.m_mesh.CsgXor(); }
    678655    break;
    679656
    680   case 42:
    681 
    682 /* Line 690 of lalr1.cc  */
    683 #line 147 "easymesh/easymesh-parser.y"
     657  case 43:
     658
     659/* Line 677 of lalr1.cc  */
     660#line 148 "easymesh/easymesh-parser.y"
    684661    { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
    685662                                                 (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3,
    686                                                  (int)(yysemantic_stack_[(2) - (2)].args).f4, (int)(yysemantic_stack_[(2) - (2)].args).f5); }
    687     break;
    688 
    689   case 43:
    690 
    691 /* Line 690 of lalr1.cc  */
    692 #line 150 "easymesh/easymesh-parser.y"
     663                                                 (int)(yysemantic_stack_[(2) - (2)].args).f4, (int)(yysemantic_stack_[(2) - (2)].args).f5, 0); }
     664    break;
     665
     666  case 44:
     667
     668/* Line 677 of lalr1.cc  */
     669#line 151 "easymesh/easymesh-parser.y"
     670    { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
     671                                                 (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3,
     672                                                 (int)(yysemantic_stack_[(2) - (2)].args).f4, (int)(yysemantic_stack_[(2) - (2)].args).f5, (int)(yysemantic_stack_[(2) - (2)].args).f6); }
     673    break;
     674
     675  case 45:
     676
     677/* Line 677 of lalr1.cc  */
     678#line 154 "easymesh/easymesh-parser.y"
    693679    { mc.m_mesh.AppendBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
    694680    break;
    695681
    696   case 44:
    697 
    698 /* Line 690 of lalr1.cc  */
    699 #line 151 "easymesh/easymesh-parser.y"
     682  case 46:
     683
     684/* Line 677 of lalr1.cc  */
     685#line 155 "easymesh/easymesh-parser.y"
    700686    { mc.m_mesh.AppendSmoothChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
    701687                                                            (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); }
    702688    break;
    703689
    704   case 45:
    705 
    706 /* Line 690 of lalr1.cc  */
    707 #line 153 "easymesh/easymesh-parser.y"
     690  case 47:
     691
     692/* Line 677 of lalr1.cc  */
     693#line 157 "easymesh/easymesh-parser.y"
    708694    { mc.m_mesh.AppendFlatChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
    709695                                                          (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); }
    710696    break;
    711697
    712   case 46:
    713 
    714 /* Line 690 of lalr1.cc  */
    715 #line 155 "easymesh/easymesh-parser.y"
    716     { mc.m_mesh.AppendSphere((yysemantic_stack_[(2) - (2)].args).f0,
    717                                                vec3((yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); }
    718     break;
    719 
    720   case 47:
    721 
    722 /* Line 690 of lalr1.cc  */
    723 #line 157 "easymesh/easymesh-parser.y"
     698  case 48:
     699
     700/* Line 677 of lalr1.cc  */
     701#line 159 "easymesh/easymesh-parser.y"
     702    { mc.m_mesh.AppendSphere((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1); }
     703    break;
     704
     705  case 49:
     706
     707/* Line 677 of lalr1.cc  */
     708#line 160 "easymesh/easymesh-parser.y"
    724709    { mc.m_mesh.AppendCapsule((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
    725710    break;
    726711
    727   case 48:
    728 
    729 /* Line 690 of lalr1.cc  */
    730 #line 158 "easymesh/easymesh-parser.y"
     712  case 50:
     713
     714/* Line 677 of lalr1.cc  */
     715#line 161 "easymesh/easymesh-parser.y"
    731716    { mc.m_mesh.AppendTorus((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
    732717    break;
    733718
    734   case 49:
    735 
    736 /* Line 690 of lalr1.cc  */
    737 #line 159 "easymesh/easymesh-parser.y"
     719  case 51:
     720
     721/* Line 677 of lalr1.cc  */
     722#line 162 "easymesh/easymesh-parser.y"
    738723    { mc.m_mesh.AppendStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2,
    739724                                             (int)(yysemantic_stack_[(2) - (2)].args).f3, (int)(yysemantic_stack_[(2) - (2)].args).f4); }
    740725    break;
    741726
    742   case 50:
    743 
    744 /* Line 690 of lalr1.cc  */
    745 #line 161 "easymesh/easymesh-parser.y"
     727  case 52:
     728
     729/* Line 677 of lalr1.cc  */
     730#line 164 "easymesh/easymesh-parser.y"
    746731    { mc.m_mesh.AppendExpandedStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
    747732                                                     (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); }
    748733    break;
    749734
    750   case 51:
    751 
    752 /* Line 690 of lalr1.cc  */
    753 #line 163 "easymesh/easymesh-parser.y"
     735  case 53:
     736
     737/* Line 677 of lalr1.cc  */
     738#line 166 "easymesh/easymesh-parser.y"
    754739    { mc.m_mesh.AppendDisc((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (int)(yysemantic_stack_[(2) - (2)].args).f2); }
    755740    break;
    756741
    757   case 52:
    758 
    759 /* Line 690 of lalr1.cc  */
    760 #line 164 "easymesh/easymesh-parser.y"
     742  case 54:
     743
     744/* Line 677 of lalr1.cc  */
     745#line 167 "easymesh/easymesh-parser.y"
    761746    { mc.m_mesh.AppendSimpleTriangle((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); }
    762747    break;
    763748
    764   case 53:
    765 
    766 /* Line 690 of lalr1.cc  */
    767 #line 165 "easymesh/easymesh-parser.y"
     749  case 55:
     750
     751/* Line 677 of lalr1.cc  */
     752#line 168 "easymesh/easymesh-parser.y"
    768753    { mc.m_mesh.AppendSimpleQuad((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); }
    769754    break;
    770755
    771   case 54:
    772 
    773 /* Line 690 of lalr1.cc  */
    774 #line 166 "easymesh/easymesh-parser.y"
     756  case 56:
     757
     758/* Line 677 of lalr1.cc  */
     759#line 169 "easymesh/easymesh-parser.y"
    775760    { mc.m_mesh.AppendCog((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
    776761                                 (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3, (yysemantic_stack_[(2) - (2)].args).f4, (yysemantic_stack_[(2) - (2)].args).f5, (yysemantic_stack_[(2) - (2)].args).f6,
     
    778763    break;
    779764
    780   case 55:
    781 
    782 /* Line 690 of lalr1.cc  */
    783 #line 171 "easymesh/easymesh-parser.y"
     765  case 57:
     766
     767/* Line 677 of lalr1.cc  */
     768#line 174 "easymesh/easymesh-parser.y"
    784769    { (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); }
    785770    break;
    786771
    787   case 56:
    788 
    789 /* Line 690 of lalr1.cc  */
    790 #line 172 "easymesh/easymesh-parser.y"
     772  case 58:
     773
     774/* Line 677 of lalr1.cc  */
     775#line 175 "easymesh/easymesh-parser.y"
    791776    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f1 = (yysemantic_stack_[(2) - (2)].fval); }
    792777    break;
    793778
    794   case 57:
    795 
    796 /* Line 690 of lalr1.cc  */
    797 #line 173 "easymesh/easymesh-parser.y"
     779  case 59:
     780
     781/* Line 677 of lalr1.cc  */
     782#line 176 "easymesh/easymesh-parser.y"
    798783    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f2 = (yysemantic_stack_[(2) - (2)].fval); }
    799784    break;
    800785
    801   case 58:
    802 
    803 /* Line 690 of lalr1.cc  */
    804 #line 174 "easymesh/easymesh-parser.y"
     786  case 60:
     787
     788/* Line 677 of lalr1.cc  */
     789#line 177 "easymesh/easymesh-parser.y"
    805790    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f3 = (yysemantic_stack_[(2) - (2)].fval); }
    806791    break;
    807792
    808   case 59:
    809 
    810 /* Line 690 of lalr1.cc  */
    811 #line 175 "easymesh/easymesh-parser.y"
     793  case 61:
     794
     795/* Line 677 of lalr1.cc  */
     796#line 178 "easymesh/easymesh-parser.y"
    812797    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f4 = (yysemantic_stack_[(2) - (2)].fval); }
    813798    break;
    814799
    815   case 60:
    816 
    817 /* Line 690 of lalr1.cc  */
    818 #line 176 "easymesh/easymesh-parser.y"
     800  case 62:
     801
     802/* Line 677 of lalr1.cc  */
     803#line 179 "easymesh/easymesh-parser.y"
    819804    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f5 = (yysemantic_stack_[(2) - (2)].fval); }
    820805    break;
    821806
    822   case 61:
    823 
    824 /* Line 690 of lalr1.cc  */
    825 #line 177 "easymesh/easymesh-parser.y"
     807  case 63:
     808
     809/* Line 677 of lalr1.cc  */
     810#line 180 "easymesh/easymesh-parser.y"
    826811    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f6 = (yysemantic_stack_[(2) - (2)].fval); }
    827812    break;
    828813
    829   case 62:
    830 
    831 /* Line 690 of lalr1.cc  */
    832 #line 178 "easymesh/easymesh-parser.y"
     814  case 64:
     815
     816/* Line 677 of lalr1.cc  */
     817#line 181 "easymesh/easymesh-parser.y"
    833818    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f7 = (yysemantic_stack_[(2) - (2)].fval); }
    834819    break;
    835820
    836   case 63:
    837 
    838 /* Line 690 of lalr1.cc  */
    839 #line 179 "easymesh/easymesh-parser.y"
     821  case 65:
     822
     823/* Line 677 of lalr1.cc  */
     824#line 182 "easymesh/easymesh-parser.y"
    840825    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f8 = (yysemantic_stack_[(2) - (2)].fval); }
    841826    break;
    842827
    843   case 64:
    844 
    845 /* Line 690 of lalr1.cc  */
    846 #line 180 "easymesh/easymesh-parser.y"
     828  case 66:
     829
     830/* Line 677 of lalr1.cc  */
     831#line 183 "easymesh/easymesh-parser.y"
    847832    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f9 = (yysemantic_stack_[(2) - (2)].fval); }
    848833    break;
    849834
    850   case 65:
    851 
    852 /* Line 690 of lalr1.cc  */
    853 #line 183 "easymesh/easymesh-parser.y"
     835  case 67:
     836
     837/* Line 677 of lalr1.cc  */
     838#line 186 "easymesh/easymesh-parser.y"
    854839    { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); }
    855840    break;
    856841
    857   case 66:
    858 
    859 /* Line 690 of lalr1.cc  */
    860 #line 184 "easymesh/easymesh-parser.y"
     842  case 68:
     843
     844/* Line 677 of lalr1.cc  */
     845#line 187 "easymesh/easymesh-parser.y"
    861846    { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); }
    862847    break;
     
    864849
    865850
    866 /* Line 690 of lalr1.cc  */
    867 #line 868 "generated/easymesh-parser.cpp"
     851/* Line 677 of lalr1.cc  */
     852#line 853 "generated/easymesh-parser.cpp"
    868853        default:
    869854          break;
    870855      }
    871     /* User semantic actions sometimes alter yychar, and that requires
    872        that yytoken be updated with the new translation.  We take the
    873        approach of translating immediately before every use of yytoken.
    874        One alternative is translating here after every semantic action,
    875        but that translation would be missed if the semantic action
    876        invokes YYABORT, YYACCEPT, or YYERROR immediately after altering
    877        yychar.  In the case of YYABORT or YYACCEPT, an incorrect
    878        destructor might then be invoked immediately.  In the case of
    879        YYERROR, subsequent parser actions might lead to an incorrect
    880        destructor call or verbose syntax error message before the
    881        lookahead is translated.  */
    882856    YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
    883857
     
    903877  `------------------------------------*/
    904878  yyerrlab:
    905     /* Make sure we have latest lookahead translation.  See comments at
    906        user semantic actions for why this is necessary.  */
    907     yytoken = yytranslate_ (yychar);
    908 
    909879    /* If not already recovering from an error, report this error.  */
    910880    if (!yyerrstatus_)
    911881      {
    912882        ++yynerrs_;
    913         if (yychar == yyempty_)
    914           yytoken = yyempty_;
    915883        error (yylloc, yysyntax_error_ (yystate, yytoken));
    916884      }
    917885
    918     yyerror_range[1] = yylloc;
     886    yyerror_range[0] = yylloc;
    919887    if (yyerrstatus_ == 3)
    920888      {
     
    951919      goto yyerrorlab;
    952920
    953     yyerror_range[1] = yylocation_stack_[yylen - 1];
     921    yyerror_range[0] = yylocation_stack_[yylen - 1];
    954922    /* Do not reclaim the symbols of the rule which action triggered
    955923       this YYERROR.  */
     
    968936      {
    969937        yyn = yypact_[yystate];
    970         if (!yy_pact_value_is_default_ (yyn))
     938        if (yyn != yypact_ninf_)
    971939        {
    972940          yyn += yyterror_;
     
    983951        YYABORT;
    984952
    985         yyerror_range[1] = yylocation_stack_[0];
     953        yyerror_range[0] = yylocation_stack_[0];
    986954        yydestruct_ ("Error: popping",
    987955                     yystos_[yystate],
     
    992960      }
    993961
    994     yyerror_range[2] = yylloc;
     962    yyerror_range[1] = yylloc;
    995963    // Using YYLLOC is tempting, but would change the location of
    996964    // the lookahead.  YYLOC is available though.
    997     YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
     965    YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
    998966    yysemantic_stack_.push (yylval);
    999967    yylocation_stack_.push (yyloc);
     
    1018986  yyreturn:
    1019987    if (yychar != yyempty_)
    1020       {
    1021         /* Make sure we have latest lookahead translation.  See comments
    1022            at user semantic actions for why this is necessary.  */
    1023         yytoken = yytranslate_ (yychar);
    1024         yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval,
    1025                      &yylloc);
    1026       }
     988      yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
    1027989
    1028990    /* Do not reclaim the symbols of the rule which action triggered
     
    10431005  // Generate an error message.
    10441006  std::string
    1045   EasyMeshParser::yysyntax_error_ (int yystate, int yytoken)
    1046   {
    1047     std::string yyres;
    1048     // Number of reported tokens (one for the "unexpected", one per
    1049     // "expected").
    1050     size_t yycount = 0;
    1051     // Its maximum.
    1052     enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
    1053     // Arguments of yyformat.
    1054     char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
    1055 
    1056     /* There are many possibilities here to consider:
    1057        - If this state is a consistent state with a default action, then
    1058          the only way this function was invoked is if the default action
    1059          is an error action.  In that case, don't check for expected
    1060          tokens because there are none.
    1061        - The only way there can be no lookahead present (in yytoken) is
    1062          if this state is a consistent state with a default action.
    1063          Thus, detecting the absence of a lookahead is sufficient to
    1064          determine that there is no unexpected or expected token to
    1065          report.  In that case, just report a simple "syntax error".
    1066        - Don't assume there isn't a lookahead just because this state is
    1067          a consistent state with a default action.  There might have
    1068          been a previous inconsistent state, consistent state with a
    1069          non-default action, or user semantic action that manipulated
    1070          yychar.
    1071        - Of course, the expected token list depends on states to have
    1072          correct lookahead information, and it depends on the parser not
    1073          to perform extra reductions after fetching a lookahead from the
    1074          scanner and before detecting a syntax error.  Thus, state
    1075          merging (from LALR or IELR) and default reductions corrupt the
    1076          expected token list.  However, the list is correct for
    1077          canonical LR with one exception: it will still contain any
    1078          token that will not be accepted due to an error action in a
    1079          later state.
    1080     */
    1081     if (yytoken != yyempty_)
     1007  EasyMeshParser::yysyntax_error_ (int yystate, int tok)
     1008  {
     1009    std::string res;
     1010    YYUSE (yystate);
     1011#if YYERROR_VERBOSE
     1012    int yyn = yypact_[yystate];
     1013    if (yypact_ninf_ < yyn && yyn <= yylast_)
    10821014      {
    1083         yyarg[yycount++] = yytname_[yytoken];
    1084         int yyn = yypact_[yystate];
    1085         if (!yy_pact_value_is_default_ (yyn))
    1086           {
    1087             /* Start YYX at -YYN if negative to avoid negative indexes in
    1088                YYCHECK.  In other words, skip the first -YYN actions for
    1089                this state because they are default actions.  */
    1090             int yyxbegin = yyn < 0 ? -yyn : 0;
    1091             /* Stay within bounds of both yycheck and yytname.  */
    1092             int yychecklim = yylast_ - yyn + 1;
    1093             int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
    1094             for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
    1095               if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
    1096                   && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
    1097                 {
    1098                   if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
    1099                     {
    1100                       yycount = 1;
    1101                       break;
    1102                     }
    1103                   else
    1104                     yyarg[yycount++] = yytname_[yyx];
    1105                 }
    1106           }
     1015        /* Start YYX at -YYN if negative to avoid negative indexes in
     1016           YYCHECK.  */
     1017        int yyxbegin = yyn < 0 ? -yyn : 0;
     1018
     1019        /* Stay within bounds of both yycheck and yytname.  */
     1020        int yychecklim = yylast_ - yyn + 1;
     1021        int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
     1022        int count = 0;
     1023        for (int x = yyxbegin; x < yyxend; ++x)
     1024          if (yycheck_[x + yyn] == x && x != yyterror_)
     1025            ++count;
     1026
     1027        // FIXME: This method of building the message is not compatible
     1028        // with internationalization.  It should work like yacc.c does it.
     1029        // That is, first build a string that looks like this:
     1030        // "syntax error, unexpected %s or %s or %s"
     1031        // Then, invoke YY_ on this string.
     1032        // Finally, use the string as a format to output
     1033        // yytname_[tok], etc.
     1034        // Until this gets fixed, this message appears in English only.
     1035        res = "syntax error, unexpected ";
     1036        res += yytnamerr_ (yytname_[tok]);
     1037        if (count < 5)
     1038          {
     1039            count = 0;
     1040            for (int x = yyxbegin; x < yyxend; ++x)
     1041              if (yycheck_[x + yyn] == x && x != yyterror_)
     1042                {
     1043                  res += (!count++) ? ", expecting " : " or ";
     1044                  res += yytnamerr_ (yytname_[x]);
     1045                }
     1046          }
    11071047      }
    1108 
    1109     char const* yyformat = 0;
    1110     switch (yycount)
    1111       {
    1112 #define YYCASE_(N, S)                         \
    1113         case N:                               \
    1114           yyformat = S;                       \
    1115         break
    1116         YYCASE_(0, YY_("syntax error"));
    1117         YYCASE_(1, YY_("syntax error, unexpected %s"));
    1118         YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
    1119         YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
    1120         YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
    1121         YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
    1122 #undef YYCASE_
    1123       }
    1124 
    1125     // Argument number.
    1126     size_t yyi = 0;
    1127     for (char const* yyp = yyformat; *yyp; ++yyp)
    1128       if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
    1129         {
    1130           yyres += yytnamerr_ (yyarg[yyi++]);
    1131           ++yyp;
    1132         }
    1133       else
    1134         yyres += *yyp;
    1135     return yyres;
     1048    else
     1049#endif
     1050      res = YY_("syntax error");
     1051    return res;
    11361052  }
    11371053
     
    11431059  EasyMeshParser::yypact_[] =
    11441060  {
    1145         -3,    19,    28,    26,    26,    26,    26,   -10,    26,    26,
    1146       26,    26,   -10,    26,    26,    26,    26,   -10,    26,    26,
    1147      -10,    26,   -10,   -10,   -10,   -10,    26,    26,    26,    26,
    1148       26,    26,    26,    26,    26,    26,    26,    26,    26,    26,
    1149      -10,    41,    49,    -3,    -3,    81,   -10,   -10,   -10,   -10,
    1150      -10,   -10,    26,    26,    26,    26,   -10,   -10,   -10,   -10,
     1061        -3,    29,    31,    16,    16,    16,    16,   -10,    16,    16,
     1062      16,    16,   -10,    16,    16,    16,    16,   -10,    16,    16,
     1063     -10,    16,   -10,   -10,   -10,   -10,   -10,    16,    16,    16,
     1064      16,    16,    16,    16,    16,    16,    16,    16,    16,    16,
     1065      16,   -10,    42,    50,    -3,    -3,    83,   -10,   -10,   -10,
     1066     -10,   -10,   -10,    16,    16,    16,    16,   -10,   -10,   -10,
    11511067     -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,
    1152      -10,   -10,   -10,   -10,   -10,   -10,    26,    26,   -10,   -10,
    1153      -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,    26,
    1154       26,    26,    26,   -10,   -10,   -10,   -10,   -10,     5,   -10,
     1068     -10,   -10,   -10,   -10,   -10,   -10,   -10,    16,    16,    16,
    11551069     -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,
    1156      -10,   -10
     1070     -10,    16,    16,    16,    16,   -10,   -10,   -10,   -10,   -10,
     1071       5,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,   -10,
     1072     -10,   -10,   -10,   -10
    11571073  };
    11581074
    1159   /* YYDEFACT[S] -- default reduction number in state S.  Performed when
    1160      YYTABLE doesn't specify something else to do.  Zero means the
    1161      default is an error.  */
     1075  /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
     1076     doesn't specify something else to do.  Zero means the default is an
     1077     error.  */
    11621078  const unsigned char
    11631079  EasyMeshParser::yydefact_[] =
     
    11651081         0,     0,     0,     0,     0,     0,     0,    33,     0,     0,
    11661082       0,     0,    34,     0,     0,     0,     0,    35,     0,     0,
    1167       37,     0,    38,    39,    40,    41,     0,     0,     0,     0,
     1083      37,     0,    38,    39,    40,    41,    42,     0,     0,     0,
    11681084       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
    1169        7,     0,     0,     3,     0,     5,     9,    11,    12,    13,
    1170       65,    15,     0,     0,     0,     0,    14,    55,    17,    16,
    1171       19,    23,    26,    29,    20,    24,    27,    30,    21,    25,
    1172       28,    31,    22,    32,    36,    18,     0,     0,    42,    43,
    1173       44,    45,    46,    47,    49,    50,    51,    52,    53,     0,
    1174        0,     0,     0,    54,    48,     1,     2,     4,     0,    10,
    1175       66,    56,    57,    58,    59,    60,    61,    62,    63,    64,
    1176       8,     6
     1085       0,     7,     0,     0,     3,     0,     5,     9,    11,    12,
     1086      13,    67,    15,     0,     0,     0,     0,    14,    57,    17,
     1087      16,    19,    23,    26,    29,    20,    24,    27,    30,    21,
     1088      25,    28,    31,    22,    32,    36,    18,     0,     0,    43,
     1089      44,    45,    46,    47,    48,    49,    51,    52,    53,    54,
     1090      55,     0,     0,     0,     0,    56,    50,     1,     2,     4,
     1091       0,    10,    68,    58,    59,    60,    61,    62,    63,    64,
     1092      65,    66,    8,     6
    11771093  };
    11781094
    11791095  /* YYPGOTO[NTERM-NUM].  */
    1180   const signed char
     1096  const short int
    11811097  EasyMeshParser::yypgoto_[] =
    11821098  {
    11831099       -10,   -10,    -4,   -10,   -10,   -10,   -10,     9,   -10,   -10,
    1184      -10,    44,    40,   118,   125,    23,    21,   -10,   -10,   -10,
     1100     -10,    45,    25,   121,   128,    33,    26,    32,   -10,   -10,
    11851101     -10,    -9
    11861102  };
     
    11901106  EasyMeshParser::yydefgoto_[] =
    11911107  {
    1192         -1,    41,    42,    43,    44,   111,    45,    46,    47,    48,
    1193       49,    53,    54,    55,    76,    77,    78,    90,    91,    92,
    1194       93,    57
     1108        -1,    42,    43,    44,    45,   113,    46,    47,    48,    49,
     1109      50,    54,    55,    56,    77,    78,    79,    80,    93,    94,
     1110      95,    58
    11951111  };
    11961112
    11971113  /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    11981114     positive, shift that token.  If negative, reduce the rule which
    1199      number is the opposite.  If YYTABLE_NINF_, syntax error.  */
     1115     number is the opposite.  If zero, do what YYDEFACT says.  */
    12001116  const signed char EasyMeshParser::yytable_ninf_ = -1;
    12011117  const unsigned char
     
    12051121      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
    12061122      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
    1207       31,    32,    33,    34,    35,    36,    37,    38,    39,    97,
    1208       98,    95,    40,   100,   101,   102,   103,    60,    61,    96,
    1209       63,   110,    64,    65,    99,    67,    84,    68,    69,    89,
    1210       71,     0,    50,    51,     0,    74,    52,   104,   105,    50,
    1211       75,    50,    58,    52,     0,    52,    87,    88,     0,     0,
    1212      106,   107,   108,   109,     1,     2,     3,     4,     5,     6,
     1123      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
     1124      99,   100,    97,    41,   102,   103,   104,   105,    61,    62,
     1125      98,    64,   112,    65,    66,   101,    68,    84,    69,    70,
     1126      51,    72,    89,    90,    53,    91,    75,    86,   106,   107,
     1127     108,    92,    76,    51,    52,    51,    59,    53,     0,    53,
     1128       0,     0,   108,   109,   110,   111,     1,     2,     3,     4,
     1129       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
     1130      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
     1131      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
     1132      35,    36,    37,    38,    39,    40,    63,     0,     0,    57,
     1133      60,    67,     0,     0,     0,     0,    71,     0,     0,    73,
     1134      74,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     1135      81,     0,     0,     0,    85,     0,     0,    88,    82,    83,
     1136       0,    96,     0,    87
     1137  };
     1138
     1139  /* YYCHECK.  */
     1140  const signed char
     1141  EasyMeshParser::yycheck_[] =
     1142  {
     1143         3,     4,     5,     6,     7,     8,     9,    10,    11,    12,
     1144      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
     1145      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
     1146      33,    34,    35,    36,    37,    38,    39,    40,    41,    42,
     1147      44,    45,     0,    46,    53,    54,    55,    56,     3,     4,
     1148       0,     6,    47,     8,     9,    46,    11,    32,    13,    14,
     1149      44,    16,    37,    38,    48,    39,    21,    34,    77,    78,
     1150      79,    39,    27,    44,    45,    44,    45,    48,    -1,    48,
     1151      -1,    -1,    91,    92,    93,    94,     3,     4,     5,     6,
    12131152       7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
    12141153      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
    12151154      27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
    1216       37,    38,    39,    62,     0,     0,    56,    59,    66,     0,
    1217        0,     0,     0,    70,     0,     0,    72,    73,     0,     0,
    1218        0,     0,     0,     0,     0,     0,    79,     0,     0,     0,
    1219       83,     0,     0,    86,    80,    81,    82,    94,     0,    85
    1220   };
    1221 
    1222   /* YYCHECK.  */
    1223   const signed char
    1224   EasyMeshParser::yycheck_[] =
    1225   {
    1226          3,     4,     5,     6,     7,     8,     9,    10,    11,    12,
    1227       13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
    1228       23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
    1229       33,    34,    35,    36,    37,    38,    39,    40,    41,    43,
    1230       44,     0,    45,    52,    53,    54,    55,     3,     4,     0,
    1231        6,    46,     8,     9,    45,    11,    33,    13,    14,    38,
    1232       16,    -1,    43,    44,    -1,    21,    47,    76,    77,    43,
    1233       26,    43,    44,    47,    -1,    47,    36,    37,    -1,    -1,
    1234       89,    90,    91,    92,     3,     4,     5,     6,     7,     8,
    1235        9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
    1236       19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
    1237       29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
    1238       39,    40,    41,     5,    -1,    -1,     1,     2,    10,    -1,
    1239       -1,    -1,    -1,    15,    -1,    -1,    18,    19,    -1,    -1,
    1240       -1,    -1,    -1,    -1,    -1,    -1,    28,    -1,    -1,    -1,
    1241       32,    -1,    -1,    35,    29,    30,    31,    39,    -1,    34
     1155      37,    38,    39,    40,    41,    42,     5,    -1,    -1,     1,
     1156       2,    10,    -1,    -1,    -1,    -1,    15,    -1,    -1,    18,
     1157      19,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
     1158      29,    -1,    -1,    -1,    33,    -1,    -1,    36,    30,    31,
     1159      -1,    40,    -1,    35
    12421160  };
    12431161
     
    12511169      22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
    12521170      32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
    1253       45,    49,    50,    51,    52,    54,    55,    56,    57,    58,
    1254       43,    44,    47,    59,    60,    61,    62,    69,    44,    62,
    1255       59,    59,    61,    59,    59,    59,    61,    59,    59,    59,
    1256       61,    59,    61,    61,    59,    59,    62,    63,    64,    61,
    1257       62,    62,    62,    61,    63,    62,    61,    60,    60,    64,
    1258       65,    66,    67,    68,    61,     0,     0,    50,    50,    55,
    1259       69,    69,    69,    69,    69,    69,    69,    69,    69,    69,
    1260       46,    53
     1171      42,    46,    50,    51,    52,    53,    55,    56,    57,    58,
     1172      59,    44,    45,    48,    60,    61,    62,    63,    70,    45,
     1173      63,    60,    60,    62,    60,    60,    60,    62,    60,    60,
     1174      60,    62,    60,    62,    62,    60,    60,    63,    64,    65,
     1175      66,    62,    63,    63,    61,    62,    64,    63,    62,    61,
     1176      61,    65,    66,    67,    68,    69,    62,     0,     0,    51,
     1177      51,    56,    70,    70,    70,    70,    70,    70,    70,    70,
     1178      70,    70,    47,    54
    12611179  };
    12621180
     
    12711189     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
    12721190     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
    1273      295,   296,   297,   298,   299,    91,    93,    45
     1191     295,   296,   297,   298,   299,   300,    91,    93,    45
    12741192  };
    12751193#endif
     
    12791197  EasyMeshParser::yyr1_[] =
    12801198  {
    1281          0,    48,    49,    50,    50,    51,    51,    52,    53,    54,
    1282       54,    55,    55,    55,    56,    56,    56,    56,    57,    57,
    1283       57,    57,    57,    57,    57,    57,    57,    57,    57,    57,
    1284       57,    57,    57,    57,    57,    57,    57,    57,    57,    57,
    1285       57,    57,    58,    58,    58,    58,    58,    58,    58,    58,
    1286       58,    58,    58,    58,    58,    59,    60,    61,    62,    63,
    1287       64,    65,    66,    67,    68,    69,    69
     1199         0,    49,    50,    51,    51,    52,    52,    53,    54,    55,
     1200      55,    56,    56,    56,    57,    57,    57,    57,    58,    58,
     1201      58,    58,    58,    58,    58,    58,    58,    58,    58,    58,
     1202      58,    58,    58,    58,    58,    58,    58,    58,    58,    58,
     1203      58,    58,    58,    59,    59,    59,    59,    59,    59,    59,
     1204      59,    59,    59,    59,    59,    59,    59,    60,    61,    62,
     1205      63,    64,    65,    66,    67,    68,    69,    70,    70
    12881206  };
    12891207
     
    12961214       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    12971215       2,     2,     2,     1,     1,     1,     2,     1,     1,     1,
    1298        1,     1,     2,     2,     2,     2,     2,     2,     2,     2,
    1299        2,     2,     2,     2,     2,     1,     2,     2,     2,     2,
    1300        2,     2,     2,     2,     2,     1,     2
     1216       1,     1,     1,     2,     2,     2,     2,     2,     2,     2,
     1217       2,     2,     2,     2,     2,     2,     2,     1,     2,     2,
     1218       2,     2,     2,     2,     2,     2,     2,     1,     2
    13011219  };
    13021220
     
    13121230  "T_ROTATEZ", "T_TAPERZ", "T_SCALEZ", "T_MIRRORZ", "T_TRANSLATE",
    13131231  "T_SCALE", "T_TOGGLESCALEWINDING", "T_RADIALJITTER", "T_CSGUNION",
    1314   "T_CSGSUBSTRACT", "T_CSGAND", "T_CSGXOR", "T_CHAMFER", "T_CYLINDER",
    1315   "T_BOX", "T_SMOOTHCHAMFBOX", "T_FLATCHAMFBOX", "T_SPHERE", "T_CAPSULE",
    1316   "T_STAR", "T_EXPANDEDSTAR", "T_DISC", "T_TRIANGLE", "T_QUAD", "T_COG",
    1317   "T_TORUS", "T_ERROR", "NUMBER", "COLOR", "'['", "']'", "'-'", "$accept",
    1318   "mesh_description", "mesh_expression_list", "mesh_expression",
    1319   "mesh_open", "mesh_close", "mesh_command_list", "mesh_command",
    1320   "color_command", "transform_command", "primitive_command", "args1",
    1321   "args2", "args3", "args4", "args5", "args6", "args7", "args8", "args9",
    1322   "args10", "number", 0
     1232  "T_CSGSUBSTRACT", "T_CSGSUBSTRACTLOSS", "T_CSGAND", "T_CSGXOR",
     1233  "T_CHAMFER", "T_CYLINDER", "T_BOX", "T_SMOOTHCHAMFBOX", "T_FLATCHAMFBOX",
     1234  "T_SPHERE", "T_CAPSULE", "T_STAR", "T_EXPANDEDSTAR", "T_DISC",
     1235  "T_TRIANGLE", "T_QUAD", "T_COG", "T_TORUS", "T_ERROR", "NUMBER", "COLOR",
     1236  "'['", "']'", "'-'", "$accept", "mesh_description",
     1237  "mesh_expression_list", "mesh_expression", "mesh_open", "mesh_close",
     1238  "mesh_command_list", "mesh_command", "color_command",
     1239  "transform_command", "primitive_command", "args1", "args2", "args3",
     1240  "args4", "args5", "args6", "args7", "args8", "args9", "args10", "number", 0
    13231241  };
    13241242#endif
     
    13291247  EasyMeshParser::yyrhs_[] =
    13301248  {
    1331         49,     0,    -1,    50,     0,    -1,    51,    -1,    51,    50,
    1332       -1,    54,    -1,    52,    50,    53,    -1,    45,    -1,    46,
    1333       -1,    55,    -1,    54,    55,    -1,    56,    -1,    57,    -1,
    1334       58,    -1,     3,    62,    -1,     3,    44,    -1,     4,    62,
    1335       -1,     4,    44,    -1,    28,    59,    -1,     5,    59,    -1,
    1336       10,    59,    -1,    15,    59,    -1,    20,    61,    -1,     6,
    1337       59,    -1,    11,    59,    -1,    16,    59,    -1,     7,    61,
    1338       -1,    12,    61,    -1,    17,    61,    -1,     8,    59,    -1,
    1339       13,    59,    -1,    18,    59,    -1,    21,    61,    -1,     9,
    1340       -1,    14,    -1,    19,    -1,    23,    59,    -1,    22,    -1,
    1341       24,    -1,    25,    -1,    26,    -1,    27,    -1,    29,    64,
    1342       -1,    30,    61,    -1,    31,    62,    -1,    32,    62,    -1,
    1343       33,    62,    -1,    34,    61,    -1,    41,    61,    -1,    35,
    1344       63,    -1,    36,    62,    -1,    37,    61,    -1,    38,    60,
    1345       -1,    39,    60,    -1,    40,    68,    -1,    69,    -1,    59,
    1346       69,    -1,    60,    69,    -1,    61,    69,    -1,    62,    69,
    1347       -1,    63,    69,    -1,    64,    69,    -1,    65,    69,    -1,
    1348       66,    69,    -1,    67,    69,    -1,    43,    -1,    47,    69,
    1349       -1
     1249        50,     0,    -1,    51,     0,    -1,    52,    -1,    52,    51,
     1250      -1,    55,    -1,    53,    51,    54,    -1,    46,    -1,    47,
     1251      -1,    56,    -1,    55,    56,    -1,    57,    -1,    58,    -1,
     1252      59,    -1,     3,    63,    -1,     3,    45,    -1,     4,    63,
     1253      -1,     4,    45,    -1,    29,    60,    -1,     5,    60,    -1,
     1254      10,    60,    -1,    15,    60,    -1,    20,    62,    -1,     6,
     1255      60,    -1,    11,    60,    -1,    16,    60,    -1,     7,    62,
     1256      -1,    12,    62,    -1,    17,    62,    -1,     8,    60,    -1,
     1257      13,    60,    -1,    18,    60,    -1,    21,    62,    -1,     9,
     1258      -1,    14,    -1,    19,    -1,    23,    60,    -1,    22,    -1,
     1259      24,    -1,    25,    -1,    26,    -1,    27,    -1,    28,    -1,
     1260      30,    65,    -1,    30,    66,    -1,    31,    62,    -1,    32,
     1261      63,    -1,    33,    63,    -1,    34,    61,    -1,    35,    62,
     1262      -1,    42,    62,    -1,    36,    64,    -1,    37,    63,    -1,
     1263      38,    62,    -1,    39,    61,    -1,    40,    61,    -1,    41,
     1264      69,    -1,    70,    -1,    60,    70,    -1,    61,    70,    -1,
     1265      62,    70,    -1,    63,    70,    -1,    64,    70,    -1,    65,
     1266      70,    -1,    66,    70,    -1,    67,    70,    -1,    68,    70,
     1267      -1,    44,    -1,    48,    70,    -1
    13501268  };
    13511269
     
    13591277      50,    53,    56,    59,    62,    65,    68,    71,    74,    77,
    13601278      80,    83,    86,    89,    91,    93,    95,    98,   100,   102,
    1361      104,   106,   108,   111,   114,   117,   120,   123,   126,   129,
    1362      132,   135,   138,   141,   144,   147,   149,   152,   155,   158,
    1363      161,   164,   167,   170,   173,   176,   178
     1279     104,   106,   108,   110,   113,   116,   119,   122,   125,   128,
     1280     131,   134,   137,   140,   143,   146,   149,   152,   154,   157,
     1281     160,   163,   166,   169,   172,   175,   178,   181,   183
    13641282  };
    13651283
     
    13721290     122,   123,   124,   125,   126,   127,   128,   129,   130,   131,
    13731291     132,   133,   134,   135,   136,   137,   138,   139,   140,   141,
    1374      142,   143,   147,   150,   151,   153,   155,   157,   158,   159,
    1375      161,   163,   164,   165,   166,   171,   172,   173,   174,   175,
    1376      176,   177,   178,   179,   180,   183,   184
     1292     142,   143,   144,   148,   151,   154,   155,   157,   159,   160,
     1293     161,   162,   164,   166,   167,   168,   169,   174,   175,   176,
     1294     177,   178,   179,   180,   181,   182,   183,   186,   187
    13771295  };
    13781296
     
    14181336       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    14191337       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1420        2,     2,     2,     2,     2,    47,     2,     2,     2,     2,
    1421        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1422        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1423        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1424        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    1425        2,    45,     2,    46,     2,     2,     2,     2,     2,     2,
     1338       2,     2,     2,     2,     2,    48,     2,     2,     2,     2,
     1339       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     1340       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     1341       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     1342       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     1343       2,    46,     2,    47,     2,     2,     2,     2,     2,     2,
    14261344       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    14271345       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     
    14431361      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
    14441362      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
    1445       35,    36,    37,    38,    39,    40,    41,    42,    43,    44
     1363      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
     1364      45
    14461365    };
    14471366    if ((unsigned int) t <= yyuser_token_number_max_)
     
    14521371
    14531372  const int EasyMeshParser::yyeof_ = 0;
    1454   const int EasyMeshParser::yylast_ = 159;
     1373  const int EasyMeshParser::yylast_ = 163;
    14551374  const int EasyMeshParser::yynnts_ = 22;
    14561375  const int EasyMeshParser::yyempty_ = -2;
    1457   const int EasyMeshParser::yyfinal_ = 95;
     1376  const int EasyMeshParser::yyfinal_ = 97;
    14581377  const int EasyMeshParser::yyterror_ = 1;
    14591378  const int EasyMeshParser::yyerrcode_ = 256;
    1460   const int EasyMeshParser::yyntokens_ = 48;
    1461 
    1462   const unsigned int EasyMeshParser::yyuser_token_number_max_ = 299;
     1379  const int EasyMeshParser::yyntokens_ = 49;
     1380
     1381  const unsigned int EasyMeshParser::yyuser_token_number_max_ = 300;
    14631382  const EasyMeshParser::token_number_type EasyMeshParser::yyundef_token_ = 2;
    14641383
     
    14661385} // lol
    14671386
    1468 /* Line 1136 of lalr1.cc  */
    1469 #line 1470 "generated/easymesh-parser.cpp"
    1470 
    1471 
    1472 /* Line 1138 of lalr1.cc  */
    1473 #line 187 "easymesh/easymesh-parser.y"
     1387/* Line 1053 of lalr1.cc  */
     1388#line 1389 "generated/easymesh-parser.cpp"
     1389
     1390
     1391/* Line 1055 of lalr1.cc  */
     1392#line 190 "easymesh/easymesh-parser.y"
    14741393
    14751394
  • trunk/src/generated/easymesh-parser.h

    r2318 r2404  
    1 /* A Bison parser, made by GNU Bison 2.5.  */
     1/* A Bison parser, made by GNU Bison 2.4.2.  */
    22
    33/* Skeleton interface for Bison LALR(1) parsers in C++
     
    4141#include <iostream>
    4242#include "stack.hh"
     43
     44
     45namespace lol {
     46
     47/* Line 34 of lalr1.cc  */
     48#line 49 "generated/easymesh-parser.h"
     49  class position;
     50  class location;
     51
     52} // lol
     53
     54/* Line 34 of lalr1.cc  */
     55#line 56 "generated/easymesh-parser.h"
     56
    4357#include "location.hh"
    4458
     
    6175#endif
    6276
     77/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
     78   If N is 0, then set CURRENT to the empty location which ends
     79   the previous symbol: RHS[0] (always defined).  */
     80
     81#ifndef YYLLOC_DEFAULT
     82# define YYLLOC_DEFAULT(Current, Rhs, N)                \
     83do {                                                    \
     84  if (N)                                                \
     85    {                                                   \
     86      (Current).begin = (Rhs)[1].begin;                 \
     87      (Current).end   = (Rhs)[N].end;                   \
     88    }                                                   \
     89  else                                                  \
     90    {                                                   \
     91      (Current).begin = (Current).end = (Rhs)[0].end;   \
     92    }                                                   \
     93} while (false)
     94#endif
     95
    6396
    6497namespace lol {
    6598
    66 /* Line 35 of lalr1.cc  */
    67 #line 68 "generated/easymesh-parser.h"
     99/* Line 34 of lalr1.cc  */
     100#line 101 "generated/easymesh-parser.h"
    68101
    69102  /// A Bison parser.
     
    76109    {
    77110
    78 /* Line 35 of lalr1.cc  */
     111/* Line 34 of lalr1.cc  */
    79112#line 36 "easymesh/easymesh-parser.y"
    80113
     
    86119
    87120
    88 /* Line 35 of lalr1.cc  */
    89 #line 90 "generated/easymesh-parser.h"
     121/* Line 34 of lalr1.cc  */
     122#line 123 "generated/easymesh-parser.h"
    90123    };
    91124#else
     
    123156     T_CSGUNION = 279,
    124157     T_CSGSUBSTRACT = 280,
    125      T_CSGAND = 281,
    126      T_CSGXOR = 282,
    127      T_CHAMFER = 283,
    128      T_CYLINDER = 284,
    129      T_BOX = 285,
    130      T_SMOOTHCHAMFBOX = 286,
    131      T_FLATCHAMFBOX = 287,
    132      T_SPHERE = 288,
    133      T_CAPSULE = 289,
    134      T_STAR = 290,
    135      T_EXPANDEDSTAR = 291,
    136      T_DISC = 292,
    137      T_TRIANGLE = 293,
    138      T_QUAD = 294,
    139      T_COG = 295,
    140      T_TORUS = 296,
    141      T_ERROR = 297,
    142      NUMBER = 298,
    143      COLOR = 299
     158     T_CSGSUBSTRACTLOSS = 281,
     159     T_CSGAND = 282,
     160     T_CSGXOR = 283,
     161     T_CHAMFER = 284,
     162     T_CYLINDER = 285,
     163     T_BOX = 286,
     164     T_SMOOTHCHAMFBOX = 287,
     165     T_FLATCHAMFBOX = 288,
     166     T_SPHERE = 289,
     167     T_CAPSULE = 290,
     168     T_STAR = 291,
     169     T_EXPANDEDSTAR = 292,
     170     T_DISC = 293,
     171     T_TRIANGLE = 294,
     172     T_QUAD = 295,
     173     T_COG = 296,
     174     T_TORUS = 297,
     175     T_ERROR = 298,
     176     NUMBER = 299,
     177     COLOR = 300
    144178   };
    145179
     
    215249    location_stack_type yylocation_stack_;
    216250
    217     /// Whether the given \c yypact_ value indicates a defaulted state.
    218     /// \param yyvalue   the value to check
    219     static bool yy_pact_value_is_default_ (int yyvalue);
    220 
    221     /// Whether the given \c yytable_ value indicates a syntax error.
    222     /// \param yyvalue   the value to check
    223     static bool yy_table_value_is_error_ (int yyvalue);
    224 
    225251    /// Internal symbol numbers.
    226252    typedef unsigned char token_number_type;
     
    230256    static const signed char yypact_ninf_;
    231257
    232     /// For a state, default reduction number.
     258    /// For a state, default rule to reduce.
    233259    /// Unless\a  yytable_ specifies something else to do.
    234260    /// Zero means the default is an error.
    235261    static const unsigned char yydefact_[];
    236262
    237     static const signed char yypgoto_[];
     263    static const short int yypgoto_[];
    238264    static const signed char yydefgoto_[];
    239265
     
    261287#endif
    262288
     289#if YYERROR_VERBOSE
    263290    /// Convert the symbol name \a n to a form suitable for a diagnostic.
    264     static std::string yytnamerr_ (const char *n);
     291    virtual std::string yytnamerr_ (const char *n);
     292#endif
    265293
    266294#if YYDEBUG
     
    320348} // lol
    321349
    322 /* Line 35 of lalr1.cc  */
    323 #line 324 "generated/easymesh-parser.h"
     350/* Line 34 of lalr1.cc  */
     351#line 352 "generated/easymesh-parser.h"
    324352
    325353
  • trunk/src/generated/easymesh-scanner.cpp

    r2318 r2404  
    331331        (yy_c_buf_p) = yy_cp;
    332332
    333 #define YY_NUM_RULES 51
    334 #define YY_END_OF_BUFFER 52
     333#define YY_NUM_RULES 52
     334#define YY_END_OF_BUFFER 53
    335335/* This struct is not used in this scanner,
    336336   but its presence is necessary. */
     
    340340        flex_int32_t yy_nxt;
    341341        };
    342 static yyconst flex_int16_t yy_accept[82] =
     342static yyconst flex_int16_t yy_accept[83] =
    343343    {   0,
    344         0,    0,   52,   50,   49,   48,   50,   50,   45,   50,
    345        44,   46,   47,   50,   50,   50,   50,   17,    7,    0,
    346         0,   44,   44,    0,   27,   28,   31,    0,    0,   34,
    347        35,   38,    3,    0,   19,   20,   21,   22,    8,    9,
     344        0,    0,   53,   51,   50,   49,   51,   51,   46,   51,
     345       45,   47,   48,   51,   51,   51,   51,   17,    7,    0,
     346        0,   45,   45,    0,   28,   29,   32,    0,    0,   35,
     347       36,   39,    3,    0,   19,   20,   21,   22,    8,    9,
    348348       10,    1,   14,   15,   16,    0,    0,    4,    5,    6,
    349         0,    0,   44,    0,   30,   32,    0,    0,    0,   39,
    350         0,    2,   11,   12,   13,   18,   40,   29,   33,   36,
    351        37,   25,   24,   23,   26,   41,    0,   42,    0,   43,
    352         0
     349        0,    0,   45,    0,   31,   33,    0,    0,    0,   40,
     350        0,    2,   11,   12,   13,   18,   41,   30,   34,   37,
     351       38,   26,   24,   23,   27,   42,   25,    0,   43,    0,
     352       44,    0
    353353    } ;
    354354
     
    366366       11,    1,   12,    1,    1,    1,   13,   14,   15,   16,
    367367
    368        17,   18,   19,   20,    1,   21,    1,    1,   22,    1,
    369        23,   24,   25,   26,   27,   28,   29,    1,   30,   31,
    370        32,   33,    1,    1,    1,    1,    1,    1,    1,    1,
     368       17,   18,   19,   20,    1,   21,    1,   22,   23,    1,
     369       24,   25,   26,   27,   28,   29,   30,    1,   31,   32,
     370       33,   34,    1,    1,    1,    1,    1,    1,    1,    1,
    371371        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    372372        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
     
    385385    } ;
    386386
    387 static yyconst flex_int32_t yy_meta[34] =
     387static yyconst flex_int32_t yy_meta[35] =
    388388    {   0,
    389389        1,    1,    1,    1,    1,    1,    1,    2,    2,    2,
    390390        1,    1,    2,    2,    2,    2,    2,    2,    1,    1,
    391391        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    392         1,    1,    1
     392        1,    1,    1,    1
    393393    } ;
    394394
    395 static yyconst flex_int16_t yy_base[90] =
     395static yyconst flex_int16_t yy_base[91] =
    396396    {   0,
    397         0,    0,  111,  112,  112,  112,    0,   27,   29,  102,
    398        31,  112,  112,   35,   20,   11,   24,   39,   60,    0,
    399       101,   51,   57,   70,  112,   64,  112,   81,   92,  112,
    400        64,   83,  112,   86,  112,  112,  112,  112,  112,  112,
    401       112,   90,  112,  112,  112,   49,   73,  112,  112,  112,
    402         0,   93,   91,   73,  112,  112,   82,   81,   74,  112,
    403        71,  112,  112,  112,  112,  112,    0,  112,  112,  112,
    404       112,  112,  112,  112,  112,    0,    0,    0,    0,  112,
    405       112,   88,   87,   84,   83,   67,   64,   62,   44
     397        0,    0,  113,  114,  114,  114,    0,   28,   30,  104,
     398       32,  114,  114,   36,   27,   11,   25,   41,   35,    0,
     399      103,   69,   70,   76,  114,   47,  114,   82,   94,  114,
     400       46,   84,  114,   88,  114,  114,  114,  114,  114,  114,
     401      114,   92,  114,  114,  114,   56,   74,  114,  114,  114,
     402        0,   96,   95,   76,  114,  114,   85,   83,   76,  114,
     403       70,  114,  114,  114,  114,  114,    0,  114,  114,  114,
     404      114,  114,   73,  114,  114,    0,  114,    0,    0,    0,
     405      114,  114,   92,   91,   90,   89,   83,   70,   68,   39
    406406    } ;
    407407
    408 static yyconst flex_int16_t yy_def[90] =
     408static yyconst flex_int16_t yy_def[91] =
    409409    {   0,
    410        81,    1,   81,   81,   81,   81,   82,   81,   81,   81,
    411        81,   81,   81,   81,   81,   81,   81,   81,   81,   83,
    412        81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
    413        81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
    414        81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
    415        84,   81,   81,   81,   81,   81,   81,   81,   81,   81,
    416        81,   81,   81,   81,   81,   81,   85,   81,   81,   81,
    417        81,   81,   81,   81,   81,   86,   87,   88,   89,   81,
    418         0,   81,   81,   81,   81,   81,   81,   81,   81
     410       82,    1,   82,   82,   82,   82,   83,   82,   82,   82,
     411       82,   82,   82,   82,   82,   82,   82,   82,   82,   84,
     412       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
     413       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
     414       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
     415       85,   82,   82,   82,   82,   82,   82,   82,   82,   82,
     416       82,   82,   82,   82,   82,   82,   86,   82,   82,   82,
     417       82,   82,   82,   82,   82,   87,   82,   88,   89,   90,
     418       82,    0,   82,   82,   82,   82,   82,   82,   82,   82
    419419    } ;
    420420
    421 static yyconst flex_int16_t yy_nxt[146] =
     421static yyconst flex_int16_t yy_nxt[149] =
    422422    {   0,
    423423        4,    5,    6,    7,    8,    9,   10,   11,    4,    4,
    424424       12,   13,   14,    4,   15,    4,    4,    4,    4,    4,
    425         4,   16,    4,    4,    4,   17,   18,   19,    4,    4,
    426         4,    4,    4,   21,   22,   21,   22,   21,   22,   33,
    427        24,   35,   36,   37,   38,   80,   34,   24,   25,   26,
    428        27,   28,   29,   42,   39,   40,   41,   21,   22,   30,
    429        24,   31,   32,   79,   23,   78,   24,   24,   77,   43,
    430        44,   45,   46,   24,   52,   52,   54,   53,   58,   63,
    431        64,   65,   55,   72,   76,   67,   47,   59,   51,   20,
    432        48,   49,   50,   71,   70,   69,   68,   73,   53,   74,
    433 
    434        53,   75,   66,   62,   61,   60,   57,   56,   23,   23,
    435        81,    3,   81,   81,   81,   81,   81,   81,   81,   81,
    436        81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
    437        81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
    438        81,   81,   81,   81,   81
     425        4,    4,   16,    4,    4,    4,   17,   18,   19,    4,
     426        4,    4,    4,    4,   21,   22,   21,   22,   21,   22,
     427       81,   24,   35,   36,   37,   38,   33,   46,   24,   25,
     428       26,   27,   28,   29,   34,   42,   39,   40,   41,   54,
     429       58,   30,   47,   31,   32,   55,   48,   49,   50,   80,
     430       59,   79,   43,   44,   45,   21,   22,   23,   24,   24,
     431       52,   52,   72,   53,   78,   24,   24,   63,   64,   65,
     432       76,   67,   51,   20,   77,   71,   70,   73,   69,   74,
     433
     434       68,   75,   53,   53,   66,   62,   61,   60,   57,   56,
     435       23,   23,   82,    3,   82,   82,   82,   82,   82,   82,
     436       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
     437       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
     438       82,   82,   82,   82,   82,   82,   82,   82
    439439    } ;
    440440
    441 static yyconst flex_int16_t yy_chk[146] =
     441static yyconst flex_int16_t yy_chk[149] =
    442442    {   0,
    443443        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    444444        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    445445        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    446         1,    1,    1,    8,    8,    9,    9,   11,   11,   15,
    447        11,   16,   16,   16,   17,   89,   15,   11,   14,   14,
    448        14,   14,   14,   18,   17,   17,   17,   22,   22,   14,
    449        22,   14,   14,   88,   23,   87,   23,   22,   86,   18,
    450        18,   18,   19,   23,   24,   24,   26,   24,   31,   46,
    451        46,   46,   26,   61,   85,   84,   19,   31,   83,   82,
    452        19,   19,   19,   59,   58,   57,   54,   61,   53,   61,
    453 
    454        52,   61,   47,   42,   34,   32,   29,   28,   21,   10,
    455         3,   81,   81,   81,   81,   81,   81,   81,   81,   81,
    456        81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
    457        81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
    458        81,   81,   81,   81,   81
     446        1,    1,    1,    1,    8,    8,    9,    9,   11,   11,
     447       90,   11,   16,   16,   16,   17,   15,   19,   11,   14,
     448       14,   14,   14,   14,   15,   18,   17,   17,   17,   26,
     449       31,   14,   19,   14,   14,   26,   19,   19,   19,   89,
     450       31,   88,   18,   18,   18,   22,   22,   23,   22,   23,
     451       24,   24,   61,   24,   87,   22,   23,   46,   46,   46,
     452       86,   85,   84,   83,   73,   59,   58,   61,   57,   61,
     453
     454       54,   61,   53,   52,   47,   42,   34,   32,   29,   28,
     455       21,   10,    3,   82,   82,   82,   82,   82,   82,   82,
     456       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
     457       82,   82,   82,   82,   82,   82,   82,   82,   82,   82,
     458       82,   82,   82,   82,   82,   82,   82,   82
    459459    } ;
    460460
     
    671671                                {
    672672                                yy_current_state = (int) yy_def[yy_current_state];
    673                                 if ( yy_current_state >= 82 )
     673                                if ( yy_current_state >= 83 )
    674674                                        yy_c = yy_meta[(unsigned int) yy_c];
    675675                                }
     
    677677                        ++yy_cp;
    678678                        }
    679                 while ( yy_current_state != 81 );
     679                while ( yy_current_state != 82 );
    680680                yy_cp = (yy_last_accepting_cpos);
    681681                yy_current_state = (yy_last_accepting_state);
     
    820820YY_RULE_SETUP
    821821#line 77 "easymesh/easymesh-scanner.l"
     822{ return token::T_CSGSUBSTRACTLOSS; }
     823        YY_BREAK
     824case 26:
     825YY_RULE_SETUP
     826#line 78 "easymesh/easymesh-scanner.l"
    822827{ return token::T_CSGAND; }
    823828        YY_BREAK
    824 case 26:
    825 YY_RULE_SETUP
    826 #line 78 "easymesh/easymesh-scanner.l"
     829case 27:
     830YY_RULE_SETUP
     831#line 79 "easymesh/easymesh-scanner.l"
    827832{ return token::T_CSGXOR; }
    828833        YY_BREAK
    829 case 27:
    830 YY_RULE_SETUP
    831 #line 80 "easymesh/easymesh-scanner.l"
     834case 28:
     835YY_RULE_SETUP
     836#line 81 "easymesh/easymesh-scanner.l"
    832837{ return token::T_BOX; }
    833838        YY_BREAK
    834 case 28:
    835 YY_RULE_SETUP
    836 #line 81 "easymesh/easymesh-scanner.l"
     839case 29:
     840YY_RULE_SETUP
     841#line 82 "easymesh/easymesh-scanner.l"
    837842{ return token::T_CYLINDER; }
    838843        YY_BREAK
    839 case 29:
    840 YY_RULE_SETUP
    841 #line 82 "easymesh/easymesh-scanner.l"
     844case 30:
     845YY_RULE_SETUP
     846#line 83 "easymesh/easymesh-scanner.l"
    842847{ return token::T_CAPSULE; }
    843848        YY_BREAK
    844 case 30:
    845 YY_RULE_SETUP
    846 #line 83 "easymesh/easymesh-scanner.l"
     849case 31:
     850YY_RULE_SETUP
     851#line 84 "easymesh/easymesh-scanner.l"
    847852{ return token::T_COG; }
    848853        YY_BREAK
    849 case 31:
    850 YY_RULE_SETUP
    851 #line 84 "easymesh/easymesh-scanner.l"
     854case 32:
     855YY_RULE_SETUP
     856#line 85 "easymesh/easymesh-scanner.l"
    852857{ return token::T_DISC; }
    853858        YY_BREAK
    854 case 32:
    855 YY_RULE_SETUP
    856 #line 85 "easymesh/easymesh-scanner.l"
     859case 33:
     860YY_RULE_SETUP
     861#line 86 "easymesh/easymesh-scanner.l"
    857862{ return token::T_EXPANDEDSTAR; }
    858863        YY_BREAK
    859 case 33:
    860 YY_RULE_SETUP
    861 #line 86 "easymesh/easymesh-scanner.l"
     864case 34:
     865YY_RULE_SETUP
     866#line 87 "easymesh/easymesh-scanner.l"
    862867{ return token::T_FLATCHAMFBOX; }
    863868        YY_BREAK
    864 case 34:
    865 YY_RULE_SETUP
    866 #line 87 "easymesh/easymesh-scanner.l"
     869case 35:
     870YY_RULE_SETUP
     871#line 88 "easymesh/easymesh-scanner.l"
    867872{ return token::T_QUAD; }
    868873        YY_BREAK
    869 case 35:
    870 YY_RULE_SETUP
    871 #line 88 "easymesh/easymesh-scanner.l"
     874case 36:
     875YY_RULE_SETUP
     876#line 89 "easymesh/easymesh-scanner.l"
    872877{ return token::T_STAR; }
    873878        YY_BREAK
    874 case 36:
    875 YY_RULE_SETUP
    876 #line 89 "easymesh/easymesh-scanner.l"
     879case 37:
     880YY_RULE_SETUP
     881#line 90 "easymesh/easymesh-scanner.l"
    877882{ return token::T_SMOOTHCHAMFBOX; }
    878883        YY_BREAK
    879 case 37:
    880 YY_RULE_SETUP
    881 #line 90 "easymesh/easymesh-scanner.l"
     884case 38:
     885YY_RULE_SETUP
     886#line 91 "easymesh/easymesh-scanner.l"
    882887{ return token::T_SPHERE; }
    883888        YY_BREAK
    884 case 38:
    885 YY_RULE_SETUP
    886 #line 91 "easymesh/easymesh-scanner.l"
     889case 39:
     890YY_RULE_SETUP
     891#line 92 "easymesh/easymesh-scanner.l"
    887892{ return token::T_TRIANGLE; }
    888893        YY_BREAK
    889 case 39:
    890 YY_RULE_SETUP
    891 #line 92 "easymesh/easymesh-scanner.l"
     894case 40:
     895YY_RULE_SETUP
     896#line 93 "easymesh/easymesh-scanner.l"
    892897{ return token::T_TORUS; }
    893898        YY_BREAK
    894 case 40:
    895 YY_RULE_SETUP
    896 #line 94 "easymesh/easymesh-scanner.l"
     899case 41:
     900YY_RULE_SETUP
     901#line 95 "easymesh/easymesh-scanner.l"
    897902{
    898903        uint32_t tmp = std::strtol(yytext + 1, NULL, 16);
     
    903908        return token::COLOR; }
    904909        YY_BREAK
    905 case 41:
    906 YY_RULE_SETUP
    907 #line 101 "easymesh/easymesh-scanner.l"
     910case 42:
     911YY_RULE_SETUP
     912#line 102 "easymesh/easymesh-scanner.l"
    908913{
    909914        uint32_t tmp = std::strtol(yytext + 1, NULL, 16);
     
    914919        return token::COLOR; }
    915920        YY_BREAK
    916 case 42:
    917 YY_RULE_SETUP
    918 #line 108 "easymesh/easymesh-scanner.l"
     921case 43:
     922YY_RULE_SETUP
     923#line 109 "easymesh/easymesh-scanner.l"
    919924{
    920925        yylval->u32val = 0xffu
     
    922927        return token::COLOR; }
    923928        YY_BREAK
    924 case 43:
    925 YY_RULE_SETUP
    926 #line 112 "easymesh/easymesh-scanner.l"
     929case 44:
     930YY_RULE_SETUP
     931#line 113 "easymesh/easymesh-scanner.l"
    927932{
    928933        yylval->u32val = (uint32_t)std::strtol(yytext + 1, NULL, 16);
    929934        return token::COLOR; }
    930935        YY_BREAK
    931 case 44:
    932 YY_RULE_SETUP
    933 #line 115 "easymesh/easymesh-scanner.l"
     936case 45:
     937YY_RULE_SETUP
     938#line 116 "easymesh/easymesh-scanner.l"
    934939{
    935940        yylval->fval = std::atof(yytext); return token::NUMBER; }
    936941        YY_BREAK
    937 case 45:
    938 YY_RULE_SETUP
    939 #line 117 "easymesh/easymesh-scanner.l"
     942case 46:
     943YY_RULE_SETUP
     944#line 118 "easymesh/easymesh-scanner.l"
    940945{ return token_type('-'); }
    941946        YY_BREAK
    942 case 46:
    943 YY_RULE_SETUP
    944 #line 118 "easymesh/easymesh-scanner.l"
     947case 47:
     948YY_RULE_SETUP
     949#line 119 "easymesh/easymesh-scanner.l"
    945950{ return token_type('['); }
    946951        YY_BREAK
    947 case 47:
    948 YY_RULE_SETUP
    949 #line 119 "easymesh/easymesh-scanner.l"
     952case 48:
     953YY_RULE_SETUP
     954#line 120 "easymesh/easymesh-scanner.l"
    950955{ return token_type(']'); }
    951956        YY_BREAK
    952 case 48:
    953 YY_RULE_SETUP
    954 #line 120 "easymesh/easymesh-scanner.l"
    955 { /* ignore this */ }
    956         YY_BREAK
    957957case 49:
    958 /* rule 49 can match eol */
    959958YY_RULE_SETUP
    960959#line 121 "easymesh/easymesh-scanner.l"
     
    962961        YY_BREAK
    963962case 50:
     963/* rule 50 can match eol */
    964964YY_RULE_SETUP
    965965#line 122 "easymesh/easymesh-scanner.l"
     966{ /* ignore this */ }
     967        YY_BREAK
     968case 51:
     969YY_RULE_SETUP
     970#line 123 "easymesh/easymesh-scanner.l"
    966971{ return token::T_ERROR; }
    967972        YY_BREAK
    968 case 51:
    969 YY_RULE_SETUP
    970 #line 124 "easymesh/easymesh-scanner.l"
     973case 52:
     974YY_RULE_SETUP
     975#line 125 "easymesh/easymesh-scanner.l"
    971976ECHO;
    972977        YY_BREAK
    973 #line 974 "generated/easymesh-scanner.cpp"
     978#line 979 "generated/easymesh-scanner.cpp"
    974979case YY_STATE_EOF(INITIAL):
    975980        yyterminate();
     
    13531358                        {
    13541359                        yy_current_state = (int) yy_def[yy_current_state];
    1355                         if ( yy_current_state >= 82 )
     1360                        if ( yy_current_state >= 83 )
    13561361                                yy_c = yy_meta[(unsigned int) yy_c];
    13571362                        }
     
    13811386                {
    13821387                yy_current_state = (int) yy_def[yy_current_state];
    1383                 if ( yy_current_state >= 82 )
     1388                if ( yy_current_state >= 83 )
    13841389                        yy_c = yy_meta[(unsigned int) yy_c];
    13851390                }
    13861391        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
    1387         yy_is_jam = (yy_current_state == 81);
     1392        yy_is_jam = (yy_current_state == 82);
    13881393
    13891394        return yy_is_jam ? 0 : yy_current_state;
     
    18721877#define YYTABLES_NAME "yytables"
    18731878
    1874 #line 124 "easymesh/easymesh-scanner.l"
     1879#line 125 "easymesh/easymesh-scanner.l"
    18751880
    18761881
  • trunk/test/MeshViewer.cpp

    r2379 r2404  
    302302                if (!m_meshes.Last().m1.Compile(cmd.C()))
    303303                    m_meshes.Pop();
    304                 else
    305                     m_meshes.Last().m1.ComputeTexCoord(0.2f, 2);
     304                //else
     305                //    m_meshes.Last().m1.ComputeTexCoord(0.2f, 2);
    306306            }
    307307        }
  • trunk/test/MeshViewerBuffer.txt

    r2379 r2404  
    1 [sc#88f ab 4 4 4]
    2 //[sc#ff2 asph 2 4 4 4]
    3 //[sc#ff2 acap 2 4 4]
    4 //[sc#ff2 ac 12 4 4 4 0 0]
     1[sc#88f ab 4 4 4 tx 4 ab 4 4 4 tx -2 tax .4 .4 0]
     2//[sc#ff2 asph 2 4 tx 4 tax 1 1 0]
     3//[sc#ff2 acap 1 4 4]
     4//[sc#ff2 scb#ff2 ac 10 4 4 4 0 0 1]
     5//[sc#ff2 scb#ff2 ad 10 4 0]
     6//[sc#ff2 scb#ff2 ato 40 1 4]
     7//[sc#ff2 scb#2ff at 4 1]
     8//[sc#ff2 scb#2ff aq 4 0]
     9//[sc#ff2 scb#2ff aes 5 3 6 2]
     10//[sc#ff2 scb#2ff as 5 2 5 0 0]
     11//[sc#ff2 scb#2ff acg 2 10 .1 .1 .4 .4 .1 .1 0 1]
    512
    613//[sc#ff2 asph 2 10 10 10]
    714//[sc#400 asph 2 10 10 10 t 2 2 2 csgs]
    8 //[sc#88f afcb 10 10 10 .25 tx 0 sc 0.1]
    9 //[sc#22f afcb 10 10 10 .25 t 2 2 2 csgs]
     15//[sc#88f afcb 10 10 10 .25 tx 0]
     16//[sc#fff afcb 10 10 10 .25 t 2 2 2]
    1017//[sc#fff afcb 7 7 7 .25]
    1118//[sc#ff2 afcb 7 7 7 .25 t 1 1 1]
Note: See TracChangeset for help on using the changeset viewer.