Changeset 2404
- Timestamp:
- Feb 13, 2013, 3:57:13 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/easymesh/easymesh-parser.y
r2350 r2404 148 148 T_CYLINDER args6 { mc.m_mesh.AppendCylinder((int)$2.f0, $2.f1, 149 149 $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); } 151 154 | T_BOX args3 { mc.m_mesh.AppendBox(vec3($2.f0, $2.f1, $2.f2)); } 152 155 | T_SMOOTHCHAMFBOX args4 { mc.m_mesh.AppendSmoothChamfBox(vec3($2.f0, $2.f1, … … 154 157 | T_FLATCHAMFBOX args4 { mc.m_mesh.AppendFlatChamfBox(vec3($2.f0, $2.f1, 155 158 $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); } 158 160 | T_CAPSULE args3 { mc.m_mesh.AppendCapsule($2.f0, $2.f1, $2.f2); } 159 161 | T_TORUS args3 { mc.m_mesh.AppendTorus((int)$2.f0, $2.f1, $2.f2); } -
trunk/src/easymesh/easymesh.cpp
r2380 r2404 48 48 //----------------------------------------------------------------------------- 49 49 EasyMesh::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)) 51 52 { 52 53 m_cursors.Push(0, 0); … … 479 480 (csg_operation == CSGUsage::SubstractLoss && 480 481 ((mesh_id == 0 && tri_list[k].m1 == LEAF_BACK) || mesh_id == 1)) || 481 //csga : CSGAnd() -> Inside +Inside482 //csga : CSGAnd() -> m0_Inside + m1_Inside 482 483 (csg_operation == CSGUsage::And && tri_list[k].m1 == LEAF_FRONT)) 483 484 { … … 488 489 if (//csgs : CSGSubstract() -> m0_Outside + m1_Inside-inverted 489 490 (csg_operation == CSGUsage::Substract && mesh_id == 1 && tri_list[k].m1 == LEAF_BACK) || 490 //csgx : CSGXor() -> Outside/Inside-inverted + Outside/Inside-inverted491 //csgx : CSGXor() -> m0_Outside/m0_Inside-inverted + m1_Outside/m1_Inside-inverted 491 492 (csg_operation == CSGUsage::Xor && tri_list[k].m1 == LEAF_BACK)) 492 493 { … … 546 547 //DONE for the splitting ! 547 548 } 548 549 549 550 550 //----------------------------------------------------------------------------- … … 750 750 vec3 v_dir = normalize(cross(m_vert[m_indices[cur_tri]].m2, v01)); 751 751 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); 753 753 //Final calculations 754 754 uv[2] = texu_dir * dot(v01, v02) + texv_dir * dot(v_dir, v02); … … 777 777 for (int j = 0; j < 3; j++) 778 778 { 779 #if 0779 #if 1 780 780 //This finds triangle that are connected to this triangle 781 781 vert_dict.FindConnectedTriangles(ivec2(v[j], v[(j + 1) % 3]), tri_list, tri_check, &tri_done); … … 788 788 else if (uv_set == 3) 789 789 { 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 /* 790 801 bool tri_present = false; 791 802 for (int j = 0; j < tri_done.Count(); j++) … … 795 806 tri_done << cur_tri; 796 807 tri_check.Remove(0); 808 */ 797 809 } 798 810 … … 822 834 823 835 //----------------------------------------------------------------------------- 836 void 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 //----------------------------------------------------------------------------- 824 843 void EasyMesh::SetCurVertNormal(vec3 const &normal) 825 844 { … … 831 850 { 832 851 m_vert[m_vert.Count() - 1].m3 = color; 852 } 853 854 //----------------------------------------------------------------------------- 855 void 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 833 861 } 834 862 … … 841 869 842 870 //----------------------------------------------------------------------------- 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);871 void EasyMesh::RotateX(float angle) { Rotate(angle, vec3(1, 0, 0)); } 872 void EasyMesh::RotateY(float angle) { Rotate(angle, vec3(0, 1, 0)); } 873 void EasyMesh::RotateZ(float angle) { Rotate(angle, vec3(0, 0, 1)); } 874 875 //----------------------------------------------------------------------------- 876 void EasyMesh::Rotate(float angle, vec3 const &axis) 877 { 878 mat3 m = mat3::rotate(angle, axis); 851 879 for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) 852 880 { … … 907 935 for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) 908 936 { 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); 911 939 } 912 940 } … … 917 945 for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) 918 946 { 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); 921 949 } 922 950 } … … 927 955 for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++) 928 956 { 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); 931 959 } 932 960 } … … 980 1008 //----------------------------------------------------------------------------- 981 1009 void 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 984 1018 int vbase = m_vert.Count(); 985 1019 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); 987 1021 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)); 988 1025 989 1026 /* Construct normal */ … … 1001 1038 for (int i = 0; i < nsides; i++) 1002 1039 { 1003 AddVertex(p1); SetCurVertNormal(n); 1004 AddVertex(p2); SetCurVertNormal(n); 1040 AddVertex(p1); SetCurVertNormal(n); SetCurVertTexCoord(uv1); 1041 AddVertex(p2); SetCurVertNormal(n); SetCurVertTexCoord(uv2); 1005 1042 SetCurVertColor(m_color2); 1006 1043 … … 1013 1050 } 1014 1051 1015 p1 = rotmat * p1; 1016 p2 = rotmat * p2; 1052 p1 = rotmat * p1; uv1 += uvadd; 1053 p2 = rotmat * p2; uv2 += uvadd; 1017 1054 1018 1055 if (!smooth) 1019 1056 { 1020 AddVertex(p1); SetCurVertNormal(n); 1021 AddVertex(p2); SetCurVertNormal(n); 1057 AddVertex(p1); SetCurVertNormal(n); SetCurVertTexCoord(uv1); 1058 AddVertex(p2); SetCurVertNormal(n); SetCurVertTexCoord(uv2); 1022 1059 SetCurVertColor(m_color2); 1023 1060 … … 1029 1066 n = rotmat * n; 1030 1067 } 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 //----------------------------------------------------------------------------- 1093 void EasyMesh::AppendSphere(int ndivisions, float r) 1094 { 1095 AppendCapsule(ndivisions, 0.f, r); 1031 1096 } 1032 1097 … … 1037 1102 1038 1103 Array<vec3> vertices; 1104 float uv_h = 0; 1105 float uv_r = 0; 1039 1106 1040 1107 /* FIXME: we don't know how to handle even-divided capsules, so we 1041 1108 * force the count to be odd. */ 1042 1109 if (h) 1110 { 1043 1111 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 } 1044 1116 1045 1117 /* Fill in the icosahedron vertices, rotating them so that there … … 1084 1156 p[0] + vc, 1085 1157 p[0] + vb + vc }; 1158 vec2 uv[4]; 1086 1159 1087 1160 /* FIXME: when we normalise here, we get a volume that is slightly … … 1089 1162 * the midradius. */ 1090 1163 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 */ 1094 1183 if (h > 0.f) 1095 1184 { … … 1099 1188 1100 1189 /* 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) 1102 1194 { 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 } 1115 1224 } 1116 1225 … … 1129 1238 1130 1239 //----------------------------------------------------------------------------- 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 //-----------------------------------------------------------------------------1140 1240 void EasyMesh::AppendTorus(int ndivisions, float r1, float r2) 1141 1241 { … … 1152 1252 int i2 = (i + di) % nidiv; 1153 1253 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); 1155 1257 float y = 0.5f * (r2 - r1) * (float)lol::sin(2.0 * M_PI * i2 / nidiv); 1156 1258 float z = 0.0f; 1157 1259 1260 //Center circle 1158 1261 float ca = (float)lol::cos(2.0 * M_PI * j2 / njdiv); 1159 1262 float sa = (float)lol::sin(2.0 * M_PI * j2 / njdiv); 1263 1264 //Actual location 1160 1265 float x2 = x * ca - z * sa; 1161 1266 float z2 = z * ca + x * sa; 1162 1267 1163 1268 AddVertex(vec3(x2, y, z2)); 1269 SetCurVertTexCoord(vec2((float)(i + di) / (float)nidiv, (float)(j + dj) / (float)nidiv)); 1164 1270 } 1165 1271 … … 1203 1309 vec3 d = size * 0.5f; 1204 1310 1311 //Side vertices 1205 1312 AddVertex(vec3(-d.x, -d.y, -d.z - chamf)); 1313 SetCurVertTexCoord(vec2(0.f, .5f)); 1206 1314 AddVertex(vec3(-d.x, +d.y, -d.z - chamf)); 1315 SetCurVertTexCoord(vec2(0.f, 0.f)); 1207 1316 AddVertex(vec3(+d.x, +d.y, -d.z - chamf)); 1317 SetCurVertTexCoord(vec2(.5f, 0.f)); 1208 1318 AddVertex(vec3(+d.x, -d.y, -d.z - chamf)); 1319 SetCurVertTexCoord(vec2(.5f, .5f)); 1209 1320 1210 1321 AddVertex(vec3(-d.x - chamf, -d.y, +d.z)); 1322 SetCurVertTexCoord(vec2(.5f, 0.5f)); 1211 1323 AddVertex(vec3(-d.x - chamf, +d.y, +d.z)); 1324 SetCurVertTexCoord(vec2(.5f, 0.f)); 1212 1325 AddVertex(vec3(-d.x - chamf, +d.y, -d.z)); 1326 SetCurVertTexCoord(vec2(1.f, 0.f)); 1213 1327 AddVertex(vec3(-d.x - chamf, -d.y, -d.z)); 1328 SetCurVertTexCoord(vec2(1.f, .5f)); 1214 1329 1215 1330 AddVertex(vec3(+d.x, -d.y, +d.z + chamf)); 1331 SetCurVertTexCoord(vec2(0.f, .5f)); 1216 1332 AddVertex(vec3(+d.x, +d.y, +d.z + chamf)); 1333 SetCurVertTexCoord(vec2(0.f, 0.f)); 1217 1334 AddVertex(vec3(-d.x, +d.y, +d.z + chamf)); 1335 SetCurVertTexCoord(vec2(.5f, 0.f)); 1218 1336 AddVertex(vec3(-d.x, -d.y, +d.z + chamf)); 1337 SetCurVertTexCoord(vec2(.5f, .5f)); 1219 1338 1220 1339 AddVertex(vec3(+d.x + chamf, -d.y, -d.z)); 1340 SetCurVertTexCoord(vec2(.5f, .5f)); 1221 1341 AddVertex(vec3(+d.x + chamf, +d.y, -d.z)); 1342 SetCurVertTexCoord(vec2(.5f, .0f)); 1222 1343 AddVertex(vec3(+d.x + chamf, +d.y, +d.z)); 1344 SetCurVertTexCoord(vec2(1.f, .0f)); 1223 1345 AddVertex(vec3(+d.x + chamf, -d.y, +d.z)); 1224 1346 SetCurVertTexCoord(vec2(1.f, .5f)); 1347 1348 //Bottom vertices 1225 1349 AddVertex(vec3(-d.x, -d.y - chamf, +d.z)); 1350 SetCurVertTexCoord(vec2(0.f, 1.f)); 1226 1351 AddVertex(vec3(-d.x, -d.y - chamf, -d.z)); 1352 SetCurVertTexCoord(vec2(0.f, .5f)); 1227 1353 AddVertex(vec3(+d.x, -d.y - chamf, -d.z)); 1354 SetCurVertTexCoord(vec2(.5f, .5f)); 1228 1355 AddVertex(vec3(+d.x, -d.y - chamf, +d.z)); 1229 1356 SetCurVertTexCoord(vec2(.5f, 1.f)); 1357 1358 //Top vertices 1230 1359 AddVertex(vec3(-d.x, +d.y + chamf, -d.z)); 1360 SetCurVertTexCoord(vec2(0.f, 1.f)); 1231 1361 AddVertex(vec3(-d.x, +d.y + chamf, +d.z)); 1362 SetCurVertTexCoord(vec2(0.f, .5f)); 1232 1363 AddVertex(vec3(+d.x, +d.y + chamf, +d.z)); 1364 SetCurVertTexCoord(vec2(.5f, .5f)); 1233 1365 AddVertex(vec3(+d.x, +d.y + chamf, -d.z)); 1366 SetCurVertTexCoord(vec2(.5f, 1.f)); 1234 1367 1235 1368 /* The 6 quads on each side of the box */ … … 1289 1422 int fade, int fade2) 1290 1423 { 1424 //TODO: It would probably be good to think of another way of UV painting this, like "branch repeating" 1291 1425 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)); 1294 1429 1295 1430 mat3 rotmat = mat3::rotate(180.0f / nbranches, 0.f, 1.f, 0.f); 1296 1431 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; 1299 1436 rotmat = rotmat * rotmat; 1300 1437 1301 1438 for (int i = 0; i < nbranches; i++) 1302 1439 { 1303 AddVertex(p1); 1440 AddVertex(p1); SetCurVertTexCoord(uv1.xz + vec2(.5f)); 1304 1441 if (fade2) 1305 1442 SetCurVertColor(m_color2); 1306 1443 1307 AddVertex(p2); 1444 AddVertex(p2); SetCurVertTexCoord(uv2.xz + vec2(.5f)); 1308 1445 if (fade) 1309 1446 SetCurVertColor(m_color2); … … 1312 1449 vbase); 1313 1450 1314 p1 = rotmat * p1; 1315 p2 = rotmat * p2; 1451 p1 = rotmat * p1; uv1 = rotmat * uv1; 1452 p2 = rotmat * p2; uv2 = rotmat * uv2; 1316 1453 } 1317 1454 } … … 1322 1459 { 1323 1460 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)); 1326 1464 1327 1465 mat3 rotmat = mat3::rotate(180.0f / nbranches, 0.f, 1.f, 0.f); 1328 1466 vec3 p1(r1, 0.f, 0.f), p2(r2, 0.f, 0.f), 1329 1467 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; 1333 1475 rotmat = rotmat * rotmat; 1334 1476 1335 1477 for (int i = 0; i < nbranches; i++) 1336 1478 { 1337 AddVertex(p1); 1338 AddVertex(p2); 1339 AddVertex(p3); SetCurVert Color(m_color2);1340 AddVertex(p4); SetCurVert Color(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); 1341 1483 1342 1484 int j = (i + 1) % nbranches; … … 1345 1487 AppendQuad(4 * j + 1, 4 * i + 2, 4 * i + 4, 4 * j + 3, vbase); 1346 1488 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; 1351 1493 } 1352 1494 } … … 1357 1499 int vbase = m_vert.Count(); 1358 1500 1359 AddVertex(vec3(0.f, 0.f, 0.f)); 1501 AddVertex(vec3(0.f, 0.f, 0.f)); SetCurVertTexCoord(vec2(.5f, .5f)); 1360 1502 1361 1503 mat3 rotmat = mat3::rotate(360.0f / nsides, 0.f, 1.f, 0.f); 1362 1504 vec3 p1(r, 0.f, 0.f); 1505 vec3 uv(.5f, .0f, .0f); 1363 1506 1364 1507 for (int i = 0; i < nsides; i++) 1365 1508 { 1366 AddVertex(p1); 1509 AddVertex(p1); SetCurVertTexCoord(uv.xz + vec2(.5f, .5f)); 1367 1510 if (fade) 1368 1511 SetCurVertColor(m_color2); 1369 1512 AppendTriangle(0, i + 1, ((i + 1) % nsides) + 1, vbase); 1370 1513 p1 = rotmat * p1; 1514 uv = rotmat * uv; 1371 1515 } 1372 1516 } … … 1378 1522 vec3 p(0.f, 0.f, size); 1379 1523 1380 AddVertex(p); 1524 AddVertex(p); SetCurVertTexCoord(vec2(.5f, 0.133975f)); 1381 1525 p = m * p; 1382 AddVertex(p); 1526 AddVertex(p); SetCurVertTexCoord(vec2(1.f, 1.f)); 1383 1527 if (fade) 1384 1528 SetCurVertColor(m_color2); 1385 1529 p = m * p; 1386 AddVertex(p); 1530 AddVertex(p); SetCurVertTexCoord(vec2(0.f, 1.f)); 1387 1531 if (fade) 1388 1532 SetCurVertColor(m_color2); … … 1400 1544 void EasyMesh::AppendSimpleQuad(vec2 p1, vec2 p2, float z, int fade) 1401 1545 { 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)); 1405 1549 if (fade) 1406 1550 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)); 1408 1552 if (fade) 1409 1553 SetCurVertColor(m_color2); 1410 1554 1411 AppendQuad( 3, 2, 1, 0, m_vert.Count() - 4);1555 AppendQuad(0, 1, 2, 3, m_vert.Count() - 4); 1412 1556 ComputeNormals(m_indices.Count() - 6, 6); 1413 1557 } … … 1431 1575 vec3 p[12]; 1432 1576 1577 //Upper points 1433 1578 p[0] = vec3(r10, h * .5f, 0.f); 1434 1579 p[1] = rotmat * p[0]; … … 1438 1583 p[5] = smat2 * (rotmat * p[4]); 1439 1584 1585 //Lower points 1440 1586 p[6] = vec3(r20, h * -.5f, 0.f); 1441 1587 p[7] = rotmat * p[6]; … … 1451 1597 rotmat = rotmat * rotmat; 1452 1598 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 1453 1697 for (int i = 0; i < nbsides; i++) 1454 1698 { 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 1455 1751 /* Each vertex will share three faces, so three different 1456 1752 * normals, therefore we add each vertex three times. */ 1457 1753 for (int n = 0; n < 3 * 12; n++) 1458 1754 { 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) 1461 1781 SetCurVertColor(m_color2); 1462 1782 } 1463 1783 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 1484 1792 for (int n = 0; n < 12; n++) 1485 1793 p[n] = rotmat * p[n]; -
trunk/src/easymesh/easymesh.h
r2379 r2404 79 79 }; 80 80 81 struct 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 81 96 class EasyMesh 82 97 { … … 99 114 void MeshCsg(CSGUsage csg_operation); 100 115 public: 116 /* [cmd:csgu] Performs a Union operation as (mesh0_Outside + mesh1_Outside) */ 101 117 void CsgUnion() { MeshCsg(CSGUsage::Union); } 118 /* [cmd:csgs] Performs a Substract operation as (mesh0_Outside + mesh1_Inside-inverted) */ 102 119 void CsgSubstract() { MeshCsg(CSGUsage::Substract); } 120 /* [cmd:csgsl] Performs a Substract operation without keeping the mesh1 part */ 103 121 void CsgSubstractLoss() { MeshCsg(CSGUsage::SubstractLoss); } 122 /* [cmd:csga] Performs an And operation as (mesh0_Inside + mesh1_Inside) */ 104 123 void CsgAnd() { MeshCsg(CSGUsage::And); } 124 /* [cmd:csgx] Performs a Xor operation as (m0_Outside/m0_Inside-inverted + m1_Outside/m1_Inside-inverted) */ 105 125 void CsgXor() { MeshCsg(CSGUsage::Xor); } 106 126 107 127 public: 128 /* [cmd:[] from this point onward, any operation will not be performed on previous vertices */ 108 129 void OpenBrace(); 130 /* [cmd:]] Merge current vertices with previous context */ 109 131 void CloseBrace(); 110 132 /* [cmd:tsw] When activation, on negative-scaling, normal fixing will not occur */ 111 133 void ToggleScaleWinding(); 134 /* [cmd:sc] Set vertices color */ 112 135 void SetCurColor(vec4 const &color); 136 /* [cmd:scb] Set vertices color 2 */ 113 137 void SetCurColor2(vec4 const &color); 114 138 115 139 private: 140 //------------------------------------------------------------------------- 141 //Internal : Basic triangle/vertex operations 142 //------------------------------------------------------------------------- 116 143 void AddVertex(vec3 const &coord); 117 144 void AddDuplicateVertex(int i); … … 121 148 void AppendTriangleDuplicateVerts(int i1, int i2, int i3, int base); 122 149 void ComputeNormals(int start, int vcount); 123 public: 150 public: //DEBUG 124 151 void ComputeTexCoord(float uv_scale, int uv_offset); 152 153 //------------------------------------------------------------------------- 154 //Vertices operations 155 //------------------------------------------------------------------------- 125 156 void SetVertColor(vec4 const &color); 157 void SetTexCoordData(vec2 const &new_offset, vec2 const &new_scale); 126 158 127 159 void SetCurVertNormal(vec3 const &normal); 128 160 void SetCurVertColor(vec4 const &color); 161 void SetCurVertTexCoord(vec2 const &texcoord); 129 162 130 163 public: … … 132 165 //Mesh transform operations 133 166 //------------------------------------------------------------------------- 167 168 /* [cmd:t/tx/ty/tz] Translate vertices 169 - v : Translation quantity. 170 */ 134 171 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 */ 139 186 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 */ 140 196 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 */ 141 202 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 */ 142 208 void TaperZ(float x, float y, float zoff); 209 /* [cmd:s/sx/sy/sz] Scale vertices 210 - s : scale quantity. 211 */ 143 212 void Scale(vec3 const &s); 213 /* [cmd:mx] Mirror vertices through X-plane 214 Acts as an OpenBrace 215 */ 144 216 void MirrorX(); 217 /* [cmd:my] Mirror vertices through Y-plane 218 Acts as an OpenBrace 219 */ 145 220 void MirrorY(); 221 /* [cmd:mz] Mirror vertices through Z-plane 222 Acts as an OpenBrace 223 */ 146 224 void MirrorZ(); 225 /* [no-cmd] Duplicates vertices and scale duplicate 226 Acts as an OpenBrace 227 */ 147 228 void DupAndScale(vec3 const &s); 229 /* [cmd:ch] Performs a chamfer operation //TODO : Make it work. 230 - f : Chamfer quantity. 231 */ 148 232 void Chamfer(float f); 149 233 … … 151 235 //Mesh shape operations 152 236 //------------------------------------------------------------------------- 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 */ 153 247 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 */ 155 259 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 */ 157 265 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 */ 158 271 void AppendBox(vec3 const &size, float chamf = 0.f); 272 //Same as AppendBox 159 273 void AppendSmoothChamfBox(vec3 const &size, float chamf); 274 //Same as AppendBox 160 275 void AppendFlatChamfBox(vec3 const &size, float chamf); 276 //Same as AppendBox 161 277 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 */ 162 286 void AppendStar(int nbranches, float r1, float r2, 163 287 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 */ 164 295 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 */ 165 301 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 */ 166 306 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 */ 167 311 void AppendSimpleQuad(float size, int fade = 0); 312 private: 313 //complex version of above one 168 314 void AppendSimpleQuad(vec2 p1, vec2 p2, float z = 0.f, int fade = 0); 315 public: 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 */ 169 327 void AppendCog(int nbsides, float h, float r10, float r20, float r1, 170 328 float r2, float r12, float r22, float sidemul, int offset); … … 202 360 //When this flag is up, negative scaling will not invert faces. 203 361 bool m_ignore_winding_on_scale; 362 //Texture coordinate modifiers. 363 vec2 m_texcoord_offset; 364 vec2 m_texcoord_scale; 204 365 205 366 /* FIXME: put this in a separate class so that we can copy meshes. */ -
trunk/src/easymesh/shinydebugUV.lolfx
r2379 r2404 51 51 void main(void) 52 52 { 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)); 54 92 } 55 93 -
trunk/src/generated/easymesh-parser.cpp
r2318 r2404 36 36 /* First part of user declarations. */ 37 37 38 /* Line 293of lalr1.cc */38 /* Line 310 of lalr1.cc */ 39 39 #line 1 "easymesh/easymesh-parser.y" 40 40 … … 62 62 63 63 64 /* Line 293of lalr1.cc */64 /* Line 310 of lalr1.cc */ 65 65 #line 66 "generated/easymesh-parser.cpp" 66 66 … … 70 70 /* User implementation prologue. */ 71 71 72 /* Line 299of lalr1.cc */72 /* Line 316 of lalr1.cc */ 73 73 #line 66 "easymesh/easymesh-parser.y" 74 74 … … 79 79 80 80 81 /* Line 299of lalr1.cc */81 /* Line 316 of lalr1.cc */ 82 82 #line 83 "generated/easymesh-parser.cpp" 83 83 … … 94 94 #endif 95 95 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 ends98 the previous symbol: RHS[0] (always defined). */99 100 #define YYRHSLOC(Rhs, K) ((Rhs)[K])101 #ifndef YYLLOC_DEFAULT102 # 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 #endif115 116 96 /* Suppress unused-variable warnings by "using" E. */ 117 97 #define YYUSE(e) ((void) (e)) … … 165 145 namespace lol { 166 146 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 169 150 170 151 /* Return YYSTR after stripping away unnecessary quotes and … … 205 186 } 206 187 188 #endif 207 189 208 190 /// Build a parser object. … … 305 287 #endif 306 288 307 inline bool308 EasyMeshParser::yy_pact_value_is_default_ (int yyvalue)309 {310 return yyvalue == yypact_ninf_;311 }312 313 inline bool314 EasyMeshParser::yy_table_value_is_error_ (int yyvalue)315 {316 return yyvalue == yytable_ninf_;317 }318 319 289 int 320 290 EasyMeshParser::parse () … … 338 308 location_type yylloc; 339 309 /// The locations where the error started and ended. 340 location_type yyerror_range[ 3];310 location_type yyerror_range[2]; 341 311 342 312 /// $$. … … 376 346 /* Try to take a decision without lookahead. */ 377 347 yyn = yypact_[yystate]; 378 if (yy _pact_value_is_default_ (yyn))348 if (yyn == yypact_ninf_) 379 349 goto yydefault; 380 350 … … 409 379 if (yyn <= 0) 410 380 { 411 if (yy _table_value_is_error_ (yyn))412 381 if (yyn == 0 || yyn == yytable_ninf_) 382 goto yyerrlab; 413 383 yyn = -yyn; 414 384 goto yyreduce; … … 466 436 case 7: 467 437 468 /* Line 6 90of lalr1.cc */438 /* Line 677 of lalr1.cc */ 469 439 #line 90 "easymesh/easymesh-parser.y" 470 440 { mc.m_mesh.OpenBrace(); } … … 473 443 case 8: 474 444 475 /* Line 6 90of lalr1.cc */445 /* Line 677 of lalr1.cc */ 476 446 #line 94 "easymesh/easymesh-parser.y" 477 447 { mc.m_mesh.CloseBrace(); } … … 480 450 case 14: 481 451 482 /* Line 6 90of lalr1.cc */452 /* Line 677 of lalr1.cc */ 483 453 #line 109 "easymesh/easymesh-parser.y" 484 454 { 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)); } … … 487 457 case 15: 488 458 489 /* Line 6 90of lalr1.cc */459 /* Line 677 of lalr1.cc */ 490 460 #line 110 "easymesh/easymesh-parser.y" 491 461 { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val); … … 496 466 case 16: 497 467 498 /* Line 6 90of lalr1.cc */468 /* Line 677 of lalr1.cc */ 499 469 #line 113 "easymesh/easymesh-parser.y" 500 470 { 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)); } … … 503 473 case 17: 504 474 505 /* Line 6 90of lalr1.cc */475 /* Line 677 of lalr1.cc */ 506 476 #line 114 "easymesh/easymesh-parser.y" 507 477 { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val); … … 512 482 case 18: 513 483 514 /* Line 6 90of lalr1.cc */484 /* Line 677 of lalr1.cc */ 515 485 #line 120 "easymesh/easymesh-parser.y" 516 486 { mc.m_mesh.Chamfer((yysemantic_stack_[(2) - (2)].args).f0); } … … 519 489 case 19: 520 490 521 /* Line 6 90of lalr1.cc */491 /* Line 677 of lalr1.cc */ 522 492 #line 121 "easymesh/easymesh-parser.y" 523 493 { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, 0, 0)); } … … 526 496 case 20: 527 497 528 /* Line 6 90of lalr1.cc */498 /* Line 677 of lalr1.cc */ 529 499 #line 122 "easymesh/easymesh-parser.y" 530 500 { mc.m_mesh.Translate(vec3(0, (yysemantic_stack_[(2) - (2)].args).f0, 0)); } … … 533 503 case 21: 534 504 535 /* Line 6 90of lalr1.cc */505 /* Line 677 of lalr1.cc */ 536 506 #line 123 "easymesh/easymesh-parser.y" 537 507 { mc.m_mesh.Translate(vec3(0, 0, (yysemantic_stack_[(2) - (2)].args).f0)); } … … 540 510 case 22: 541 511 542 /* Line 6 90of lalr1.cc */512 /* Line 677 of lalr1.cc */ 543 513 #line 124 "easymesh/easymesh-parser.y" 544 514 { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); } … … 547 517 case 23: 548 518 549 /* Line 6 90of lalr1.cc */519 /* Line 677 of lalr1.cc */ 550 520 #line 125 "easymesh/easymesh-parser.y" 551 521 { mc.m_mesh.RotateX((yysemantic_stack_[(2) - (2)].args).f0); } … … 554 524 case 24: 555 525 556 /* Line 6 90of lalr1.cc */526 /* Line 677 of lalr1.cc */ 557 527 #line 126 "easymesh/easymesh-parser.y" 558 528 { mc.m_mesh.RotateY((yysemantic_stack_[(2) - (2)].args).f0); } … … 561 531 case 25: 562 532 563 /* Line 6 90of lalr1.cc */533 /* Line 677 of lalr1.cc */ 564 534 #line 127 "easymesh/easymesh-parser.y" 565 535 { mc.m_mesh.RotateZ((yysemantic_stack_[(2) - (2)].args).f0); } … … 568 538 case 26: 569 539 570 /* Line 6 90of lalr1.cc */540 /* Line 677 of lalr1.cc */ 571 541 #line 128 "easymesh/easymesh-parser.y" 572 542 { mc.m_mesh.TaperX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } … … 575 545 case 27: 576 546 577 /* Line 6 90of lalr1.cc */547 /* Line 677 of lalr1.cc */ 578 548 #line 129 "easymesh/easymesh-parser.y" 579 549 { mc.m_mesh.TaperY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } … … 582 552 case 28: 583 553 584 /* Line 6 90of lalr1.cc */554 /* Line 677 of lalr1.cc */ 585 555 #line 130 "easymesh/easymesh-parser.y" 586 556 { mc.m_mesh.TaperZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } … … 589 559 case 29: 590 560 591 /* Line 6 90of lalr1.cc */561 /* Line 677 of lalr1.cc */ 592 562 #line 131 "easymesh/easymesh-parser.y" 593 563 { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, 1.0, 1.0)); } … … 596 566 case 30: 597 567 598 /* Line 6 90of lalr1.cc */568 /* Line 677 of lalr1.cc */ 599 569 #line 132 "easymesh/easymesh-parser.y" 600 570 { mc.m_mesh.Scale(vec3(1.0, (yysemantic_stack_[(2) - (2)].args).f0, 1.0)); } … … 603 573 case 31: 604 574 605 /* Line 6 90of lalr1.cc */575 /* Line 677 of lalr1.cc */ 606 576 #line 133 "easymesh/easymesh-parser.y" 607 577 { mc.m_mesh.Scale(vec3(1.0, 1.0, (yysemantic_stack_[(2) - (2)].args).f0)); } … … 610 580 case 32: 611 581 612 /* Line 6 90of lalr1.cc */582 /* Line 677 of lalr1.cc */ 613 583 #line 134 "easymesh/easymesh-parser.y" 614 584 { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); } … … 617 587 case 33: 618 588 619 /* Line 6 90of lalr1.cc */589 /* Line 677 of lalr1.cc */ 620 590 #line 135 "easymesh/easymesh-parser.y" 621 591 { mc.m_mesh.MirrorX(); } … … 624 594 case 34: 625 595 626 /* Line 6 90of lalr1.cc */596 /* Line 677 of lalr1.cc */ 627 597 #line 136 "easymesh/easymesh-parser.y" 628 598 { mc.m_mesh.MirrorY(); } … … 631 601 case 35: 632 602 633 /* Line 6 90of lalr1.cc */603 /* Line 677 of lalr1.cc */ 634 604 #line 137 "easymesh/easymesh-parser.y" 635 605 { mc.m_mesh.MirrorZ(); } … … 638 608 case 36: 639 609 640 /* Line 6 90of lalr1.cc */610 /* Line 677 of lalr1.cc */ 641 611 #line 138 "easymesh/easymesh-parser.y" 642 612 { mc.m_mesh.RadialJitter((yysemantic_stack_[(2) - (2)].args).f0); } … … 645 615 case 37: 646 616 647 /* Line 6 90of lalr1.cc */617 /* Line 677 of lalr1.cc */ 648 618 #line 139 "easymesh/easymesh-parser.y" 649 619 { mc.m_mesh.ToggleScaleWinding(); } … … 652 622 case 38: 653 623 654 /* Line 6 90of lalr1.cc */624 /* Line 677 of lalr1.cc */ 655 625 #line 140 "easymesh/easymesh-parser.y" 656 626 { mc.m_mesh.CsgUnion(); } … … 659 629 case 39: 660 630 661 /* Line 6 90of lalr1.cc */631 /* Line 677 of lalr1.cc */ 662 632 #line 141 "easymesh/easymesh-parser.y" 663 633 { mc.m_mesh.CsgSubstract(); } … … 666 636 case 40: 667 637 668 /* Line 6 90of lalr1.cc */638 /* Line 677 of lalr1.cc */ 669 639 #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" 670 647 { mc.m_mesh.CsgAnd(); } 671 648 break; 672 649 673 case 4 1:674 675 /* Line 6 90of lalr1.cc */676 #line 14 3"easymesh/easymesh-parser.y"650 case 42: 651 652 /* Line 677 of lalr1.cc */ 653 #line 144 "easymesh/easymesh-parser.y" 677 654 { mc.m_mesh.CsgXor(); } 678 655 break; 679 656 680 case 4 2:681 682 /* Line 6 90of lalr1.cc */683 #line 14 7"easymesh/easymesh-parser.y"657 case 43: 658 659 /* Line 677 of lalr1.cc */ 660 #line 148 "easymesh/easymesh-parser.y" 684 661 { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, 685 662 (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" 693 679 { mc.m_mesh.AppendBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); } 694 680 break; 695 681 696 case 4 4:697 698 /* Line 6 90of lalr1.cc */699 #line 15 1"easymesh/easymesh-parser.y"682 case 46: 683 684 /* Line 677 of lalr1.cc */ 685 #line 155 "easymesh/easymesh-parser.y" 700 686 { mc.m_mesh.AppendSmoothChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, 701 687 (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); } 702 688 break; 703 689 704 case 4 5:705 706 /* Line 6 90of lalr1.cc */707 #line 15 3"easymesh/easymesh-parser.y"690 case 47: 691 692 /* Line 677 of lalr1.cc */ 693 #line 157 "easymesh/easymesh-parser.y" 708 694 { mc.m_mesh.AppendFlatChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, 709 695 (yysemantic_stack_[(2) - (2)].args).f2), (yysemantic_stack_[(2) - (2)].args).f3); } 710 696 break; 711 697 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" 724 709 { mc.m_mesh.AppendCapsule((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } 725 710 break; 726 711 727 case 48:728 729 /* Line 6 90of lalr1.cc */730 #line 1 58"easymesh/easymesh-parser.y"712 case 50: 713 714 /* Line 677 of lalr1.cc */ 715 #line 161 "easymesh/easymesh-parser.y" 731 716 { mc.m_mesh.AppendTorus((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); } 732 717 break; 733 718 734 case 49:735 736 /* Line 6 90of lalr1.cc */737 #line 1 59"easymesh/easymesh-parser.y"719 case 51: 720 721 /* Line 677 of lalr1.cc */ 722 #line 162 "easymesh/easymesh-parser.y" 738 723 { mc.m_mesh.AppendStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, 739 724 (int)(yysemantic_stack_[(2) - (2)].args).f3, (int)(yysemantic_stack_[(2) - (2)].args).f4); } 740 725 break; 741 726 742 case 5 0:743 744 /* Line 6 90of lalr1.cc */745 #line 16 1"easymesh/easymesh-parser.y"727 case 52: 728 729 /* Line 677 of lalr1.cc */ 730 #line 164 "easymesh/easymesh-parser.y" 746 731 { mc.m_mesh.AppendExpandedStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, 747 732 (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3); } 748 733 break; 749 734 750 case 5 1:751 752 /* Line 6 90of lalr1.cc */753 #line 16 3"easymesh/easymesh-parser.y"735 case 53: 736 737 /* Line 677 of lalr1.cc */ 738 #line 166 "easymesh/easymesh-parser.y" 754 739 { mc.m_mesh.AppendDisc((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (int)(yysemantic_stack_[(2) - (2)].args).f2); } 755 740 break; 756 741 757 case 5 2:758 759 /* Line 6 90of lalr1.cc */760 #line 16 4"easymesh/easymesh-parser.y"742 case 54: 743 744 /* Line 677 of lalr1.cc */ 745 #line 167 "easymesh/easymesh-parser.y" 761 746 { mc.m_mesh.AppendSimpleTriangle((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); } 762 747 break; 763 748 764 case 5 3:765 766 /* Line 6 90of lalr1.cc */767 #line 16 5"easymesh/easymesh-parser.y"749 case 55: 750 751 /* Line 677 of lalr1.cc */ 752 #line 168 "easymesh/easymesh-parser.y" 768 753 { mc.m_mesh.AppendSimpleQuad((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); } 769 754 break; 770 755 771 case 5 4:772 773 /* Line 6 90of lalr1.cc */774 #line 16 6"easymesh/easymesh-parser.y"756 case 56: 757 758 /* Line 677 of lalr1.cc */ 759 #line 169 "easymesh/easymesh-parser.y" 775 760 { mc.m_mesh.AppendCog((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, 776 761 (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, … … 778 763 break; 779 764 780 case 5 5:781 782 /* Line 6 90of lalr1.cc */783 #line 17 1"easymesh/easymesh-parser.y"765 case 57: 766 767 /* Line 677 of lalr1.cc */ 768 #line 174 "easymesh/easymesh-parser.y" 784 769 { (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); } 785 770 break; 786 771 787 case 5 6:788 789 /* Line 6 90of lalr1.cc */790 #line 17 2"easymesh/easymesh-parser.y"772 case 58: 773 774 /* Line 677 of lalr1.cc */ 775 #line 175 "easymesh/easymesh-parser.y" 791 776 { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f1 = (yysemantic_stack_[(2) - (2)].fval); } 792 777 break; 793 778 794 case 5 7:795 796 /* Line 6 90of lalr1.cc */797 #line 17 3"easymesh/easymesh-parser.y"779 case 59: 780 781 /* Line 677 of lalr1.cc */ 782 #line 176 "easymesh/easymesh-parser.y" 798 783 { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f2 = (yysemantic_stack_[(2) - (2)].fval); } 799 784 break; 800 785 801 case 58:802 803 /* Line 6 90of lalr1.cc */804 #line 17 4"easymesh/easymesh-parser.y"786 case 60: 787 788 /* Line 677 of lalr1.cc */ 789 #line 177 "easymesh/easymesh-parser.y" 805 790 { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f3 = (yysemantic_stack_[(2) - (2)].fval); } 806 791 break; 807 792 808 case 59:809 810 /* Line 6 90of lalr1.cc */811 #line 17 5"easymesh/easymesh-parser.y"793 case 61: 794 795 /* Line 677 of lalr1.cc */ 796 #line 178 "easymesh/easymesh-parser.y" 812 797 { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f4 = (yysemantic_stack_[(2) - (2)].fval); } 813 798 break; 814 799 815 case 6 0:816 817 /* Line 6 90of lalr1.cc */818 #line 17 6"easymesh/easymesh-parser.y"800 case 62: 801 802 /* Line 677 of lalr1.cc */ 803 #line 179 "easymesh/easymesh-parser.y" 819 804 { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f5 = (yysemantic_stack_[(2) - (2)].fval); } 820 805 break; 821 806 822 case 6 1:823 824 /* Line 6 90of lalr1.cc */825 #line 1 77"easymesh/easymesh-parser.y"807 case 63: 808 809 /* Line 677 of lalr1.cc */ 810 #line 180 "easymesh/easymesh-parser.y" 826 811 { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f6 = (yysemantic_stack_[(2) - (2)].fval); } 827 812 break; 828 813 829 case 6 2:830 831 /* Line 6 90of lalr1.cc */832 #line 1 78"easymesh/easymesh-parser.y"814 case 64: 815 816 /* Line 677 of lalr1.cc */ 817 #line 181 "easymesh/easymesh-parser.y" 833 818 { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f7 = (yysemantic_stack_[(2) - (2)].fval); } 834 819 break; 835 820 836 case 6 3:837 838 /* Line 6 90of lalr1.cc */839 #line 1 79"easymesh/easymesh-parser.y"821 case 65: 822 823 /* Line 677 of lalr1.cc */ 824 #line 182 "easymesh/easymesh-parser.y" 840 825 { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f8 = (yysemantic_stack_[(2) - (2)].fval); } 841 826 break; 842 827 843 case 6 4:844 845 /* Line 6 90of lalr1.cc */846 #line 18 0"easymesh/easymesh-parser.y"828 case 66: 829 830 /* Line 677 of lalr1.cc */ 831 #line 183 "easymesh/easymesh-parser.y" 847 832 { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f9 = (yysemantic_stack_[(2) - (2)].fval); } 848 833 break; 849 834 850 case 6 5:851 852 /* Line 6 90of lalr1.cc */853 #line 18 3"easymesh/easymesh-parser.y"835 case 67: 836 837 /* Line 677 of lalr1.cc */ 838 #line 186 "easymesh/easymesh-parser.y" 854 839 { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); } 855 840 break; 856 841 857 case 6 6:858 859 /* Line 6 90of lalr1.cc */860 #line 18 4"easymesh/easymesh-parser.y"842 case 68: 843 844 /* Line 677 of lalr1.cc */ 845 #line 187 "easymesh/easymesh-parser.y" 861 846 { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); } 862 847 break; … … 864 849 865 850 866 /* Line 6 90of lalr1.cc */867 #line 8 68"generated/easymesh-parser.cpp"851 /* Line 677 of lalr1.cc */ 852 #line 853 "generated/easymesh-parser.cpp" 868 853 default: 869 854 break; 870 855 } 871 /* User semantic actions sometimes alter yychar, and that requires872 that yytoken be updated with the new translation. We take the873 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 action876 invokes YYABORT, YYACCEPT, or YYERROR immediately after altering877 yychar. In the case of YYABORT or YYACCEPT, an incorrect878 destructor might then be invoked immediately. In the case of879 YYERROR, subsequent parser actions might lead to an incorrect880 destructor call or verbose syntax error message before the881 lookahead is translated. */882 856 YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); 883 857 … … 903 877 `------------------------------------*/ 904 878 yyerrlab: 905 /* Make sure we have latest lookahead translation. See comments at906 user semantic actions for why this is necessary. */907 yytoken = yytranslate_ (yychar);908 909 879 /* If not already recovering from an error, report this error. */ 910 880 if (!yyerrstatus_) 911 881 { 912 882 ++yynerrs_; 913 if (yychar == yyempty_)914 yytoken = yyempty_;915 883 error (yylloc, yysyntax_error_ (yystate, yytoken)); 916 884 } 917 885 918 yyerror_range[ 1] = yylloc;886 yyerror_range[0] = yylloc; 919 887 if (yyerrstatus_ == 3) 920 888 { … … 951 919 goto yyerrorlab; 952 920 953 yyerror_range[ 1] = yylocation_stack_[yylen - 1];921 yyerror_range[0] = yylocation_stack_[yylen - 1]; 954 922 /* Do not reclaim the symbols of the rule which action triggered 955 923 this YYERROR. */ … … 968 936 { 969 937 yyn = yypact_[yystate]; 970 if ( !yy_pact_value_is_default_ (yyn))938 if (yyn != yypact_ninf_) 971 939 { 972 940 yyn += yyterror_; … … 983 951 YYABORT; 984 952 985 yyerror_range[ 1] = yylocation_stack_[0];953 yyerror_range[0] = yylocation_stack_[0]; 986 954 yydestruct_ ("Error: popping", 987 955 yystos_[yystate], … … 992 960 } 993 961 994 yyerror_range[ 2] = yylloc;962 yyerror_range[1] = yylloc; 995 963 // Using YYLLOC is tempting, but would change the location of 996 964 // the lookahead. YYLOC is available though. 997 YYLLOC_DEFAULT (yyloc, yyerror_range, 2);965 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); 998 966 yysemantic_stack_.push (yylval); 999 967 yylocation_stack_.push (yyloc); … … 1018 986 yyreturn: 1019 987 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); 1027 989 1028 990 /* Do not reclaim the symbols of the rule which action triggered … … 1043 1005 // Generate an error message. 1044 1006 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_) 1082 1014 { 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 } 1107 1047 } 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; 1136 1052 } 1137 1053 … … 1143 1059 EasyMeshParser::yypact_[] = 1144 1060 { 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, 1151 1067 -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, 1155 1069 -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 1157 1073 }; 1158 1074 1159 /* YYDEFACT[S] -- default r eduction number in state S. Performed when1160 YYTABLE doesn't specify something else to do. Zero means the1161 default is anerror. */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. */ 1162 1078 const unsigned char 1163 1079 EasyMeshParser::yydefact_[] = … … 1165 1081 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 1166 1082 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, 1168 1084 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 1 9, 23, 26, 29, 20, 24, 27, 30, 21, 25,1172 2 8, 31, 22, 32, 36, 18, 0, 0, 42, 43,1173 44, 45, 46, 47, 4 9, 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, 61085 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 1177 1093 }; 1178 1094 1179 1095 /* YYPGOTO[NTERM-NUM]. */ 1180 const s igned char1096 const short int 1181 1097 EasyMeshParser::yypgoto_[] = 1182 1098 { 1183 1099 -10, -10, -4, -10, -10, -10, -10, 9, -10, -10, 1184 -10, 4 4, 40, 118, 125, 23, 21, -10, -10, -10,1100 -10, 45, 25, 121, 128, 33, 26, 32, -10, -10, 1185 1101 -10, -9 1186 1102 }; … … 1190 1106 EasyMeshParser::yydefgoto_[] = 1191 1107 { 1192 -1, 4 1, 42, 43, 44, 111, 45, 46, 47, 48,1193 49, 53, 54, 55, 76, 77, 78, 90, 91, 92,1194 9 3, 571108 -1, 42, 43, 44, 45, 113, 46, 47, 48, 49, 1109 50, 54, 55, 56, 77, 78, 79, 80, 93, 94, 1110 95, 58 1195 1111 }; 1196 1112 1197 1113 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 1198 1114 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. */ 1200 1116 const signed char EasyMeshParser::yytable_ninf_ = -1; 1201 1117 const unsigned char … … 1205 1121 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1206 1122 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, 1213 1152 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1214 1153 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 1215 1154 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 1242 1160 }; 1243 1161 … … 1251 1169 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 1252 1170 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 1253 4 5, 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 6 1, 59, 61, 61, 59, 59, 62, 63, 64, 61,1257 6 2, 62, 62, 61, 63, 62, 61, 60, 60, 64,1258 6 5, 66, 67, 68, 61, 0, 0, 50, 50, 55,1259 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,1260 46, 531171 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 1261 1179 }; 1262 1180 … … 1271 1189 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 1272 1190 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 1273 295, 296, 297, 298, 299, 91, 93, 451191 295, 296, 297, 298, 299, 300, 91, 93, 45 1274 1192 }; 1275 1193 #endif … … 1279 1197 EasyMeshParser::yyr1_[] = 1280 1198 { 1281 0, 4 8, 49, 50, 50, 51, 51, 52, 53, 54,1282 5 4, 55, 55, 55, 56, 56, 56, 56, 57, 57,1283 5 7, 57, 57, 57, 57, 57, 57, 57, 57, 57,1284 5 7, 57, 57, 57, 57, 57, 57, 57, 57, 57,1285 5 7, 57, 58, 58, 58, 58, 58, 58, 58, 58,1286 5 8, 58, 58, 58, 58, 59, 60, 61, 62, 63,1287 6 4, 65, 66, 67, 68, 69, 691199 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 1288 1206 }; 1289 1207 … … 1296 1214 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1297 1215 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, 21216 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 1301 1219 }; 1302 1220 … … 1312 1230 "T_ROTATEZ", "T_TAPERZ", "T_SCALEZ", "T_MIRRORZ", "T_TRANSLATE", 1313 1231 "T_SCALE", "T_TOGGLESCALEWINDING", "T_RADIALJITTER", "T_CSGUNION", 1314 "T_CSGSUBSTRACT", "T_CSG AND", "T_CSGXOR", "T_CHAMFER", "T_CYLINDER",1315 "T_ BOX", "T_SMOOTHCHAMFBOX", "T_FLATCHAMFBOX", "T_SPHERE", "T_CAPSULE",1316 "T_S TAR", "T_EXPANDEDSTAR", "T_DISC", "T_TRIANGLE", "T_QUAD", "T_COG",1317 "T_T ORUS", "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 "args 10", "number", 01232 "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 1323 1241 }; 1324 1242 #endif … … 1329 1247 EasyMeshParser::yyrhs_[] = 1330 1248 { 1331 49, 0, -1, 50, 0, -1, 51, -1, 51, 50,1332 -1, 5 4, -1, 52, 50, 53, -1, 45, -1, 46,1333 -1, 5 5, -1, 54, 55, -1, 56, -1, 57, -1,1334 5 8, -1, 3, 62, -1, 3, 44, -1, 4, 62,1335 -1, 4, 4 4, -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, 6 1, -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, 2 9, 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 1350 1268 }; 1351 1269 … … 1359 1277 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 1360 1278 80, 83, 86, 89, 91, 93, 95, 98, 100, 102, 1361 104, 106, 108, 11 1, 114, 117, 120, 123, 126, 129,1362 13 2, 135, 138, 141, 144, 147, 149, 152, 155, 158,1363 16 1, 164, 167, 170, 173, 176, 1781279 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 1364 1282 }; 1365 1283 … … 1372 1290 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 1373 1291 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 1374 142, 143, 14 7, 150, 151, 153, 155, 157, 158, 159,1375 161, 16 3, 164, 165, 166, 171, 172, 173, 174, 175,1376 17 6, 177, 178, 179, 180, 183, 1841292 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 1377 1295 }; 1378 1296 … … 1418 1336 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1419 1337 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1420 2, 2, 2, 2, 2, 4 7, 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, 4 5, 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, 1426 1344 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1427 1345 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, … … 1443 1361 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 1444 1362 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 1446 1365 }; 1447 1366 if ((unsigned int) t <= yyuser_token_number_max_) … … 1452 1371 1453 1372 const int EasyMeshParser::yyeof_ = 0; 1454 const int EasyMeshParser::yylast_ = 1 59;1373 const int EasyMeshParser::yylast_ = 163; 1455 1374 const int EasyMeshParser::yynnts_ = 22; 1456 1375 const int EasyMeshParser::yyempty_ = -2; 1457 const int EasyMeshParser::yyfinal_ = 9 5;1376 const int EasyMeshParser::yyfinal_ = 97; 1458 1377 const int EasyMeshParser::yyterror_ = 1; 1459 1378 const int EasyMeshParser::yyerrcode_ = 256; 1460 const int EasyMeshParser::yyntokens_ = 4 8;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; 1463 1382 const EasyMeshParser::token_number_type EasyMeshParser::yyundef_token_ = 2; 1464 1383 … … 1466 1385 } // lol 1467 1386 1468 /* Line 1 136of lalr1.cc */1469 #line 1 470"generated/easymesh-parser.cpp"1470 1471 1472 /* Line 1 138of lalr1.cc */1473 #line 1 87"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" 1474 1393 1475 1394 -
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. */ 2 2 3 3 /* Skeleton interface for Bison LALR(1) parsers in C++ … … 41 41 #include <iostream> 42 42 #include "stack.hh" 43 44 45 namespace 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 43 57 #include "location.hh" 44 58 … … 61 75 #endif 62 76 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) \ 83 do { \ 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 63 96 64 97 namespace lol { 65 98 66 /* Line 3 5of lalr1.cc */67 #line 68"generated/easymesh-parser.h"99 /* Line 34 of lalr1.cc */ 100 #line 101 "generated/easymesh-parser.h" 68 101 69 102 /// A Bison parser. … … 76 109 { 77 110 78 /* Line 3 5of lalr1.cc */111 /* Line 34 of lalr1.cc */ 79 112 #line 36 "easymesh/easymesh-parser.y" 80 113 … … 86 119 87 120 88 /* Line 3 5of lalr1.cc */89 #line 90"generated/easymesh-parser.h"121 /* Line 34 of lalr1.cc */ 122 #line 123 "generated/easymesh-parser.h" 90 123 }; 91 124 #else … … 123 156 T_CSGUNION = 279, 124 157 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 144 178 }; 145 179 … … 215 249 location_stack_type yylocation_stack_; 216 250 217 /// Whether the given \c yypact_ value indicates a defaulted state.218 /// \param yyvalue the value to check219 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 check223 static bool yy_table_value_is_error_ (int yyvalue);224 225 251 /// Internal symbol numbers. 226 252 typedef unsigned char token_number_type; … … 230 256 static const signed char yypact_ninf_; 231 257 232 /// For a state, default r eduction number.258 /// For a state, default rule to reduce. 233 259 /// Unless\a yytable_ specifies something else to do. 234 260 /// Zero means the default is an error. 235 261 static const unsigned char yydefact_[]; 236 262 237 static const s igned charyypgoto_[];263 static const short int yypgoto_[]; 238 264 static const signed char yydefgoto_[]; 239 265 … … 261 287 #endif 262 288 289 #if YYERROR_VERBOSE 263 290 /// 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 265 293 266 294 #if YYDEBUG … … 320 348 } // lol 321 349 322 /* Line 3 5of lalr1.cc */323 #line 3 24"generated/easymesh-parser.h"350 /* Line 34 of lalr1.cc */ 351 #line 352 "generated/easymesh-parser.h" 324 352 325 353 -
trunk/src/generated/easymesh-scanner.cpp
r2318 r2404 331 331 (yy_c_buf_p) = yy_cp; 332 332 333 #define YY_NUM_RULES 5 1334 #define YY_END_OF_BUFFER 5 2333 #define YY_NUM_RULES 52 334 #define YY_END_OF_BUFFER 53 335 335 /* This struct is not used in this scanner, 336 336 but its presence is necessary. */ … … 340 340 flex_int32_t yy_nxt; 341 341 }; 342 static yyconst flex_int16_t yy_accept[8 2] =342 static yyconst flex_int16_t yy_accept[83] = 343 343 { 0, 344 0, 0, 5 2, 50, 49, 48, 50, 50, 45, 50,345 4 4, 46, 47, 50, 50, 50, 50, 17, 7, 0,346 0, 4 4, 44, 0, 27, 28, 31, 0, 0, 34,347 3 5, 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, 348 348 10, 1, 14, 15, 16, 0, 0, 4, 5, 6, 349 0, 0, 4 4, 0, 30, 32, 0, 0, 0, 39,350 0, 2, 11, 12, 13, 18, 4 0, 29, 33, 36,351 3 7, 25, 24, 23, 26, 41, 0, 42, 0, 43,352 0349 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 353 353 } ; 354 354 … … 366 366 11, 1, 12, 1, 1, 1, 13, 14, 15, 16, 367 367 368 17, 18, 19, 20, 1, 21, 1, 1, 22, 1,369 2 3, 24, 25, 26, 27, 28, 29, 1, 30, 31,370 3 2, 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, 371 371 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 372 372 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … … 385 385 } ; 386 386 387 static yyconst flex_int32_t yy_meta[3 4] =387 static yyconst flex_int32_t yy_meta[35] = 388 388 { 0, 389 389 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 390 390 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 391 391 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 392 1, 1, 1 392 1, 1, 1, 1 393 393 } ; 394 394 395 static yyconst flex_int16_t yy_base[9 0] =395 static yyconst flex_int16_t yy_base[91] = 396 396 { 0, 397 0, 0, 11 1, 112, 112, 112, 0, 27, 29, 102,398 3 1, 112, 112, 35, 20, 11, 24, 39, 60, 0,399 10 1, 51, 57, 70, 112, 64, 112, 81, 92, 112,400 64, 83, 112, 86, 112, 112, 112, 112, 112, 112,401 11 2, 90, 112, 112, 112, 49, 73, 112, 112, 112,402 0, 9 3, 91, 73, 112, 112, 82, 81, 74, 112,403 7 1, 112, 112, 112, 112, 112, 0, 112, 112, 112,404 11 2, 112, 112, 112, 112, 0, 0, 0, 0, 112,405 11 2, 88, 87, 84, 83, 67, 64, 62, 44397 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 406 406 } ; 407 407 408 static yyconst flex_int16_t yy_def[9 0] =408 static yyconst flex_int16_t yy_def[91] = 409 409 { 0, 410 8 1, 1, 81, 81, 81, 81, 82, 81, 81, 81,411 8 1, 81, 81, 81, 81, 81, 81, 81, 81, 83,412 8 1, 81, 81, 81, 81, 81, 81, 81, 81, 81,413 8 1, 81, 81, 81, 81, 81, 81, 81, 81, 81,414 8 1, 81, 81, 81, 81, 81, 81, 81, 81, 81,415 8 4, 81, 81, 81, 81, 81, 81, 81, 81, 81,416 8 1, 81, 81, 81, 81, 81, 85, 81, 81, 81,417 8 1, 81, 81, 81, 81, 86, 87, 88, 89, 81,418 0, 81, 81, 81, 81, 81, 81, 81, 81410 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 419 419 } ; 420 420 421 static yyconst flex_int16_t yy_nxt[14 6] =421 static yyconst flex_int16_t yy_nxt[149] = 422 422 { 0, 423 423 4, 5, 6, 7, 8, 9, 10, 11, 4, 4, 424 424 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 2 7, 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 8 1, 81, 81, 81, 81, 81, 81, 81, 81, 81,437 8 1, 81, 81, 81, 81, 81, 81, 81, 81, 81,438 8 1, 81, 81, 81, 81425 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 439 439 } ; 440 440 441 static yyconst flex_int16_t yy_chk[14 6] =441 static yyconst flex_int16_t yy_chk[149] = 442 442 { 0, 443 443 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 444 444 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 445 445 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, 1 8, 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 5 2, 61, 47, 42, 34, 32, 29, 28, 21, 10,455 3, 81, 81, 81, 81, 81, 81, 81, 81, 81,456 8 1, 81, 81, 81, 81, 81, 81, 81, 81, 81,457 8 1, 81, 81, 81, 81, 81, 81, 81, 81, 81,458 8 1, 81, 81, 81, 81446 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 459 459 } ; 460 460 … … 671 671 { 672 672 yy_current_state = (int) yy_def[yy_current_state]; 673 if ( yy_current_state >= 8 2)673 if ( yy_current_state >= 83 ) 674 674 yy_c = yy_meta[(unsigned int) yy_c]; 675 675 } … … 677 677 ++yy_cp; 678 678 } 679 while ( yy_current_state != 8 1);679 while ( yy_current_state != 82 ); 680 680 yy_cp = (yy_last_accepting_cpos); 681 681 yy_current_state = (yy_last_accepting_state); … … 820 820 YY_RULE_SETUP 821 821 #line 77 "easymesh/easymesh-scanner.l" 822 { return token::T_CSGSUBSTRACTLOSS; } 823 YY_BREAK 824 case 26: 825 YY_RULE_SETUP 826 #line 78 "easymesh/easymesh-scanner.l" 822 827 { return token::T_CSGAND; } 823 828 YY_BREAK 824 case 2 6:825 YY_RULE_SETUP 826 #line 7 8"easymesh/easymesh-scanner.l"829 case 27: 830 YY_RULE_SETUP 831 #line 79 "easymesh/easymesh-scanner.l" 827 832 { return token::T_CSGXOR; } 828 833 YY_BREAK 829 case 2 7:830 YY_RULE_SETUP 831 #line 8 0"easymesh/easymesh-scanner.l"834 case 28: 835 YY_RULE_SETUP 836 #line 81 "easymesh/easymesh-scanner.l" 832 837 { return token::T_BOX; } 833 838 YY_BREAK 834 case 2 8:835 YY_RULE_SETUP 836 #line 8 1"easymesh/easymesh-scanner.l"839 case 29: 840 YY_RULE_SETUP 841 #line 82 "easymesh/easymesh-scanner.l" 837 842 { return token::T_CYLINDER; } 838 843 YY_BREAK 839 case 29:840 YY_RULE_SETUP 841 #line 8 2"easymesh/easymesh-scanner.l"844 case 30: 845 YY_RULE_SETUP 846 #line 83 "easymesh/easymesh-scanner.l" 842 847 { return token::T_CAPSULE; } 843 848 YY_BREAK 844 case 3 0:845 YY_RULE_SETUP 846 #line 8 3"easymesh/easymesh-scanner.l"849 case 31: 850 YY_RULE_SETUP 851 #line 84 "easymesh/easymesh-scanner.l" 847 852 { return token::T_COG; } 848 853 YY_BREAK 849 case 3 1:850 YY_RULE_SETUP 851 #line 8 4"easymesh/easymesh-scanner.l"854 case 32: 855 YY_RULE_SETUP 856 #line 85 "easymesh/easymesh-scanner.l" 852 857 { return token::T_DISC; } 853 858 YY_BREAK 854 case 3 2:855 YY_RULE_SETUP 856 #line 8 5"easymesh/easymesh-scanner.l"859 case 33: 860 YY_RULE_SETUP 861 #line 86 "easymesh/easymesh-scanner.l" 857 862 { return token::T_EXPANDEDSTAR; } 858 863 YY_BREAK 859 case 3 3:860 YY_RULE_SETUP 861 #line 8 6"easymesh/easymesh-scanner.l"864 case 34: 865 YY_RULE_SETUP 866 #line 87 "easymesh/easymesh-scanner.l" 862 867 { return token::T_FLATCHAMFBOX; } 863 868 YY_BREAK 864 case 3 4:865 YY_RULE_SETUP 866 #line 8 7"easymesh/easymesh-scanner.l"869 case 35: 870 YY_RULE_SETUP 871 #line 88 "easymesh/easymesh-scanner.l" 867 872 { return token::T_QUAD; } 868 873 YY_BREAK 869 case 3 5:870 YY_RULE_SETUP 871 #line 8 8"easymesh/easymesh-scanner.l"874 case 36: 875 YY_RULE_SETUP 876 #line 89 "easymesh/easymesh-scanner.l" 872 877 { return token::T_STAR; } 873 878 YY_BREAK 874 case 3 6:875 YY_RULE_SETUP 876 #line 89"easymesh/easymesh-scanner.l"879 case 37: 880 YY_RULE_SETUP 881 #line 90 "easymesh/easymesh-scanner.l" 877 882 { return token::T_SMOOTHCHAMFBOX; } 878 883 YY_BREAK 879 case 3 7:880 YY_RULE_SETUP 881 #line 9 0"easymesh/easymesh-scanner.l"884 case 38: 885 YY_RULE_SETUP 886 #line 91 "easymesh/easymesh-scanner.l" 882 887 { return token::T_SPHERE; } 883 888 YY_BREAK 884 case 3 8:885 YY_RULE_SETUP 886 #line 9 1"easymesh/easymesh-scanner.l"889 case 39: 890 YY_RULE_SETUP 891 #line 92 "easymesh/easymesh-scanner.l" 887 892 { return token::T_TRIANGLE; } 888 893 YY_BREAK 889 case 39:890 YY_RULE_SETUP 891 #line 9 2"easymesh/easymesh-scanner.l"894 case 40: 895 YY_RULE_SETUP 896 #line 93 "easymesh/easymesh-scanner.l" 892 897 { return token::T_TORUS; } 893 898 YY_BREAK 894 case 4 0:895 YY_RULE_SETUP 896 #line 9 4"easymesh/easymesh-scanner.l"899 case 41: 900 YY_RULE_SETUP 901 #line 95 "easymesh/easymesh-scanner.l" 897 902 { 898 903 uint32_t tmp = std::strtol(yytext + 1, NULL, 16); … … 903 908 return token::COLOR; } 904 909 YY_BREAK 905 case 4 1:906 YY_RULE_SETUP 907 #line 10 1"easymesh/easymesh-scanner.l"910 case 42: 911 YY_RULE_SETUP 912 #line 102 "easymesh/easymesh-scanner.l" 908 913 { 909 914 uint32_t tmp = std::strtol(yytext + 1, NULL, 16); … … 914 919 return token::COLOR; } 915 920 YY_BREAK 916 case 4 2:917 YY_RULE_SETUP 918 #line 10 8"easymesh/easymesh-scanner.l"921 case 43: 922 YY_RULE_SETUP 923 #line 109 "easymesh/easymesh-scanner.l" 919 924 { 920 925 yylval->u32val = 0xffu … … 922 927 return token::COLOR; } 923 928 YY_BREAK 924 case 4 3:925 YY_RULE_SETUP 926 #line 11 2"easymesh/easymesh-scanner.l"929 case 44: 930 YY_RULE_SETUP 931 #line 113 "easymesh/easymesh-scanner.l" 927 932 { 928 933 yylval->u32val = (uint32_t)std::strtol(yytext + 1, NULL, 16); 929 934 return token::COLOR; } 930 935 YY_BREAK 931 case 4 4:932 YY_RULE_SETUP 933 #line 11 5"easymesh/easymesh-scanner.l"936 case 45: 937 YY_RULE_SETUP 938 #line 116 "easymesh/easymesh-scanner.l" 934 939 { 935 940 yylval->fval = std::atof(yytext); return token::NUMBER; } 936 941 YY_BREAK 937 case 4 5:938 YY_RULE_SETUP 939 #line 11 7"easymesh/easymesh-scanner.l"942 case 46: 943 YY_RULE_SETUP 944 #line 118 "easymesh/easymesh-scanner.l" 940 945 { return token_type('-'); } 941 946 YY_BREAK 942 case 4 6:943 YY_RULE_SETUP 944 #line 11 8"easymesh/easymesh-scanner.l"947 case 47: 948 YY_RULE_SETUP 949 #line 119 "easymesh/easymesh-scanner.l" 945 950 { return token_type('['); } 946 951 YY_BREAK 947 case 4 7:948 YY_RULE_SETUP 949 #line 1 19"easymesh/easymesh-scanner.l"952 case 48: 953 YY_RULE_SETUP 954 #line 120 "easymesh/easymesh-scanner.l" 950 955 { return token_type(']'); } 951 956 YY_BREAK 952 case 48:953 YY_RULE_SETUP954 #line 120 "easymesh/easymesh-scanner.l"955 { /* ignore this */ }956 YY_BREAK957 957 case 49: 958 /* rule 49 can match eol */959 958 YY_RULE_SETUP 960 959 #line 121 "easymesh/easymesh-scanner.l" … … 962 961 YY_BREAK 963 962 case 50: 963 /* rule 50 can match eol */ 964 964 YY_RULE_SETUP 965 965 #line 122 "easymesh/easymesh-scanner.l" 966 { /* ignore this */ } 967 YY_BREAK 968 case 51: 969 YY_RULE_SETUP 970 #line 123 "easymesh/easymesh-scanner.l" 966 971 { return token::T_ERROR; } 967 972 YY_BREAK 968 case 5 1:969 YY_RULE_SETUP 970 #line 12 4"easymesh/easymesh-scanner.l"973 case 52: 974 YY_RULE_SETUP 975 #line 125 "easymesh/easymesh-scanner.l" 971 976 ECHO; 972 977 YY_BREAK 973 #line 97 4"generated/easymesh-scanner.cpp"978 #line 979 "generated/easymesh-scanner.cpp" 974 979 case YY_STATE_EOF(INITIAL): 975 980 yyterminate(); … … 1353 1358 { 1354 1359 yy_current_state = (int) yy_def[yy_current_state]; 1355 if ( yy_current_state >= 8 2)1360 if ( yy_current_state >= 83 ) 1356 1361 yy_c = yy_meta[(unsigned int) yy_c]; 1357 1362 } … … 1381 1386 { 1382 1387 yy_current_state = (int) yy_def[yy_current_state]; 1383 if ( yy_current_state >= 8 2)1388 if ( yy_current_state >= 83 ) 1384 1389 yy_c = yy_meta[(unsigned int) yy_c]; 1385 1390 } 1386 1391 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1387 yy_is_jam = (yy_current_state == 8 1);1392 yy_is_jam = (yy_current_state == 82); 1388 1393 1389 1394 return yy_is_jam ? 0 : yy_current_state; … … 1872 1877 #define YYTABLES_NAME "yytables" 1873 1878 1874 #line 12 4"easymesh/easymesh-scanner.l"1879 #line 125 "easymesh/easymesh-scanner.l" 1875 1880 1876 1881 -
trunk/test/MeshViewer.cpp
r2379 r2404 302 302 if (!m_meshes.Last().m1.Compile(cmd.C())) 303 303 m_meshes.Pop(); 304 else305 m_meshes.Last().m1.ComputeTexCoord(0.2f, 2);304 //else 305 // m_meshes.Last().m1.ComputeTexCoord(0.2f, 2); 306 306 } 307 307 } -
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] 5 12 6 13 //[sc#ff2 asph 2 10 10 10] 7 14 //[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] 10 17 //[sc#fff afcb 7 7 7 .25] 11 18 //[sc#ff2 afcb 7 7 7 .25 t 1 1 1]
Note: See TracChangeset
for help on using the changeset viewer.