@@ -157,8 +157,9 @@ primitive_command: | |||||
| T_DISC args3 { mc.m_mesh.AppendDisc((int)$2.f0, $2.f1, (int)$2.f2); } | | T_DISC args3 { mc.m_mesh.AppendDisc((int)$2.f0, $2.f1, (int)$2.f2); } | ||||
| T_TRIANGLE args2 { mc.m_mesh.AppendSimpleTriangle($2.f0, (int)$2.f1); } | | T_TRIANGLE args2 { mc.m_mesh.AppendSimpleTriangle($2.f0, (int)$2.f1); } | ||||
| T_QUAD args2 { mc.m_mesh.AppendSimpleQuad($2.f0, (int)$2.f1); } | | T_QUAD args2 { mc.m_mesh.AppendSimpleQuad($2.f0, (int)$2.f1); } | ||||
| T_COG args8 { mc.m_mesh.AppendCog((int)$2.f0, $2.f1, $2.f2, $2.f3, | |||||
$2.f4, $2.f5, $2.f6, (int)$2.f7); } | |||||
| T_COG args8 { mc.m_mesh.AppendCog((int)$2.f0, $2.f1, | |||||
$2.f2 / 2, $2.f3 / 2, $2.f2, $2.f3, $2.f4, | |||||
$2.f5, $2.f6, (int)$2.f7); } | |||||
; | ; | ||||
args1: number { $$.f0 = $1; } ; | args1: number { $$.f0 = $1; } ; | ||||
@@ -782,34 +782,43 @@ void EasyMesh::AppendSimpleQuad(vec2 p1, vec2 p2, float z, int fade) | |||||
ComputeNormals(m_indices.Count() - 6, 6); | ComputeNormals(m_indices.Count() - 6, 6); | ||||
} | } | ||||
void EasyMesh::AppendCog(int nbsides, float h, float r1, float r2, float r12, | |||||
float r22, float sidemul, int offset) | |||||
void EasyMesh::AppendCog(int nbsides, float h, float r10, float r20, | |||||
float r1, float r2, float r12, float r22, | |||||
float sidemul, int offset) | |||||
{ | { | ||||
int ibase = m_indices.Count(); | int ibase = m_indices.Count(); | ||||
int vbase = m_vert.Count(); | int vbase = m_vert.Count(); | ||||
AddVertex(vec3(0.f, h * .5f, 0.f)); | |||||
AddVertex(vec3(0.f, h * -.5f, 0.f)); | |||||
SetCurVertColor(m_color2); | |||||
/* FIXME: enforce this some other way */ | |||||
if (r12 < 0) | |||||
{ | |||||
r10 *= 2.5; | |||||
r20 *= 2.5; | |||||
h = -h; | |||||
} | |||||
mat3 rotmat = mat3::rotate(180.0f / nbsides, 0.f, 1.f, 0.f); | mat3 rotmat = mat3::rotate(180.0f / nbsides, 0.f, 1.f, 0.f); | ||||
mat3 smat1 = mat3::rotate(sidemul * 180.0f / nbsides, 0.f, 1.f, 0.f); | mat3 smat1 = mat3::rotate(sidemul * 180.0f / nbsides, 0.f, 1.f, 0.f); | ||||
mat3 smat2 = mat3::rotate(sidemul * -360.0f / nbsides, 0.f, 1.f, 0.f); | mat3 smat2 = mat3::rotate(sidemul * -360.0f / nbsides, 0.f, 1.f, 0.f); | ||||
vec3 p[8]; | |||||
vec3 p[12]; | |||||
p[0] = vec3(r1, h * .5f, 0.f); | |||||
p[0] = vec3(r10, h * .5f, 0.f); | |||||
p[1] = rotmat * p[0]; | p[1] = rotmat * p[0]; | ||||
p[2] = smat1 * (rotmat * vec3(r1 + r12, h * .5f, 0.f)); | |||||
p[3] = smat2 * (rotmat * p[2]); | |||||
p[4] = vec3(r2, h * -.5f, 0.f); | |||||
p[5] = rotmat * p[4]; | |||||
p[6] = smat1 * (rotmat * vec3(r2 + r22, h * -.5f, 0.f)); | |||||
p[7] = smat2 * (rotmat * p[6]); | |||||
p[2] = vec3(r1, h * .5f, 0.f); | |||||
p[3] = rotmat * p[2]; | |||||
p[4] = smat1 * (rotmat * vec3(r1 + r12, h * .5f, 0.f)); | |||||
p[5] = smat2 * (rotmat * p[4]); | |||||
p[6] = vec3(r20, h * -.5f, 0.f); | |||||
p[7] = rotmat * p[6]; | |||||
p[8] = vec3(r2, h * -.5f, 0.f); | |||||
p[9] = rotmat * p[8]; | |||||
p[10] = smat1 * (rotmat * vec3(r2 + r22, h * -.5f, 0.f)); | |||||
p[11] = smat2 * (rotmat * p[10]); | |||||
if (offset & 1) | if (offset & 1) | ||||
for (int n = 0; n < 8; n++) | |||||
for (int n = 0; n < 12; n++) | |||||
p[n] = rotmat * p[n]; | p[n] = rotmat * p[n]; | ||||
rotmat = rotmat * rotmat; | rotmat = rotmat * rotmat; | ||||
@@ -818,28 +827,34 @@ void EasyMesh::AppendCog(int nbsides, float h, float r1, float r2, float r12, | |||||
{ | { | ||||
/* Each vertex will share three faces, so three different | /* Each vertex will share three faces, so three different | ||||
* normals, therefore we add each vertex three times. */ | * normals, therefore we add each vertex three times. */ | ||||
for (int n = 0; n < 24; n++) | |||||
for (int n = 0; n < 3 * 12; n++) | |||||
{ | { | ||||
AddVertex(p[n / 3]); | AddVertex(p[n / 3]); | ||||
if (n / 3 >= 4) | |||||
if (n / 3 >= 6) | |||||
SetCurVertColor(m_color2); | SetCurVertColor(m_color2); | ||||
} | } | ||||
int j = 24 * i, k = 24 * ((i + 1) % nbsides); | |||||
int j = 3 * 12 * i, k = 3 * 12 * ((i + 1) % nbsides); | |||||
/* The top and bottom faces */ | /* The top and bottom faces */ | ||||
AppendQuad(0, j + 2, j + 5, k + 2, vbase); | |||||
AppendQuad(1, k + 14, j + 17, j + 14, vbase); | |||||
AppendQuad(j + 5, j + 8, j + 11, k + 2, vbase); | |||||
AppendQuad(k + 14, j + 23, j + 20, j + 17, vbase); | |||||
/* The side quads */ | |||||
AppendQuad(j + 6, j + 3, j + 15, j + 18, vbase); | |||||
AppendQuad(j + 9, j + 7, j + 19, j + 21, vbase); | |||||
AppendQuad(j + 12, j + 10, j + 22, j + 24, vbase); | |||||
AppendQuad(k + 4, j + 13, j + 25, k + 16, vbase); | |||||
for (int n = 0; n < 8; n++) | |||||
AppendQuad(j, j + 6, j + 9, j + 3, vbase); | |||||
AppendQuad(j + 21, j + 27, j + 24, j + 18, vbase); | |||||
AppendQuad(j + 3, j + 9, k + 6, k, vbase); | |||||
AppendQuad(k + 18, k + 24, j + 27, j + 21, vbase); | |||||
AppendQuad(j + 9, j + 12, j + 15, k + 6, vbase); | |||||
AppendQuad(k + 24, j + 33, j + 30, j + 27, vbase); | |||||
/* The inner side quads */ | |||||
AppendQuad(j + 1, j + 4, j + 22, j + 19, vbase); | |||||
AppendQuad(j + 5, k + 2, k + 20, j + 23, vbase); | |||||
/* The outer side quads */ | |||||
AppendQuad(j + 10, j + 7, j + 25, j + 28, vbase); | |||||
AppendQuad(j + 13, j + 11, j + 29, j + 31, vbase); | |||||
AppendQuad(j + 16, j + 14, j + 32, j + 34, vbase); | |||||
AppendQuad(k + 8, j + 17, j + 35, k + 26, vbase); | |||||
for (int n = 0; n < 12; n++) | |||||
p[n] = rotmat * p[n]; | p[n] = rotmat * p[n]; | ||||
} | } | ||||
@@ -86,8 +86,8 @@ public: | |||||
void AppendSimpleTriangle(float size, int fade = 0); | void AppendSimpleTriangle(float size, int fade = 0); | ||||
void AppendSimpleQuad(float size, int fade = 0); | void AppendSimpleQuad(float size, int fade = 0); | ||||
void AppendSimpleQuad(vec2 p1, vec2 p2, float z = 0.f, int fade = 0); | void AppendSimpleQuad(vec2 p1, vec2 p2, float z = 0.f, int fade = 0); | ||||
void AppendCog(int nbsides, float h, float r1, float r2, | |||||
float r12, float r22, float sidemul, int offset); | |||||
void AppendCog(int nbsides, float h, float r10, float r20, float r1, | |||||
float r2, float r12, float r22, float sidemul, int offset); | |||||
private: | private: | ||||
vec4 m_color, m_color2; | vec4 m_color, m_color2; | ||||
@@ -707,84 +707,85 @@ namespace lol { | |||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 160 "easymesh/easymesh-parser.y" | #line 160 "easymesh/easymesh-parser.y" | ||||
{ mc.m_mesh.AppendCog((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (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, (int)(yysemantic_stack_[(2) - (2)].args).f7); } | |||||
{ mc.m_mesh.AppendCog((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, | |||||
(yysemantic_stack_[(2) - (2)].args).f2 / 2, (yysemantic_stack_[(2) - (2)].args).f3 / 2, (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, (int)(yysemantic_stack_[(2) - (2)].args).f7); } | |||||
break; | break; | ||||
case 50: | case 50: | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 164 "easymesh/easymesh-parser.y" | |||||
#line 165 "easymesh/easymesh-parser.y" | |||||
{ (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); } | { (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); } | ||||
break; | break; | ||||
case 51: | case 51: | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 165 "easymesh/easymesh-parser.y" | |||||
#line 166 "easymesh/easymesh-parser.y" | |||||
{ (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f1 = (yysemantic_stack_[(2) - (2)].fval); } | { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f1 = (yysemantic_stack_[(2) - (2)].fval); } | ||||
break; | break; | ||||
case 52: | case 52: | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 166 "easymesh/easymesh-parser.y" | |||||
#line 167 "easymesh/easymesh-parser.y" | |||||
{ (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f2 = (yysemantic_stack_[(2) - (2)].fval); } | { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f2 = (yysemantic_stack_[(2) - (2)].fval); } | ||||
break; | break; | ||||
case 53: | case 53: | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 167 "easymesh/easymesh-parser.y" | |||||
#line 168 "easymesh/easymesh-parser.y" | |||||
{ (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f3 = (yysemantic_stack_[(2) - (2)].fval); } | { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f3 = (yysemantic_stack_[(2) - (2)].fval); } | ||||
break; | break; | ||||
case 54: | case 54: | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 168 "easymesh/easymesh-parser.y" | |||||
#line 169 "easymesh/easymesh-parser.y" | |||||
{ (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f4 = (yysemantic_stack_[(2) - (2)].fval); } | { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f4 = (yysemantic_stack_[(2) - (2)].fval); } | ||||
break; | break; | ||||
case 55: | case 55: | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 169 "easymesh/easymesh-parser.y" | |||||
#line 170 "easymesh/easymesh-parser.y" | |||||
{ (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f5 = (yysemantic_stack_[(2) - (2)].fval); } | { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f5 = (yysemantic_stack_[(2) - (2)].fval); } | ||||
break; | break; | ||||
case 56: | case 56: | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 170 "easymesh/easymesh-parser.y" | |||||
#line 171 "easymesh/easymesh-parser.y" | |||||
{ (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f6 = (yysemantic_stack_[(2) - (2)].fval); } | { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f6 = (yysemantic_stack_[(2) - (2)].fval); } | ||||
break; | break; | ||||
case 57: | case 57: | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 171 "easymesh/easymesh-parser.y" | |||||
#line 172 "easymesh/easymesh-parser.y" | |||||
{ (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f7 = (yysemantic_stack_[(2) - (2)].fval); } | { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f7 = (yysemantic_stack_[(2) - (2)].fval); } | ||||
break; | break; | ||||
case 58: | case 58: | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 174 "easymesh/easymesh-parser.y" | |||||
#line 175 "easymesh/easymesh-parser.y" | |||||
{ (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); } | { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); } | ||||
break; | break; | ||||
case 59: | case 59: | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 175 "easymesh/easymesh-parser.y" | |||||
#line 176 "easymesh/easymesh-parser.y" | |||||
{ (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); } | { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); } | ||||
break; | break; | ||||
/* Line 677 of lalr1.cc */ | /* Line 677 of lalr1.cc */ | ||||
#line 788 "generated/easymesh-parser.cpp" | |||||
#line 789 "generated/easymesh-parser.cpp" | |||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
@@ -1205,7 +1206,7 @@ namespace lol { | |||||
121, 122, 123, 124, 125, 126, 127, 128, 129, 130, | 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, | ||||
131, 132, 133, 134, 135, 136, 137, 141, 144, 145, | 131, 132, 133, 134, 135, 136, 137, 141, 144, 145, | ||||
147, 149, 151, 152, 153, 155, 157, 158, 159, 160, | 147, 149, 151, 152, 153, 155, 157, 158, 159, 160, | ||||
164, 165, 166, 167, 168, 169, 170, 171, 174, 175 | |||||
165, 166, 167, 168, 169, 170, 171, 172, 175, 176 | |||||
}; | }; | ||||
// Print the state stack on the debug stream. | // Print the state stack on the debug stream. | ||||
@@ -1298,11 +1299,11 @@ namespace lol { | |||||
} // lol | } // lol | ||||
/* Line 1053 of lalr1.cc */ | /* Line 1053 of lalr1.cc */ | ||||
#line 1302 "generated/easymesh-parser.cpp" | |||||
#line 1303 "generated/easymesh-parser.cpp" | |||||
/* Line 1055 of lalr1.cc */ | /* Line 1055 of lalr1.cc */ | ||||
#line 178 "easymesh/easymesh-parser.y" | |||||
#line 179 "easymesh/easymesh-parser.y" | |||||
void lol::EasyMeshParser::error(const EasyMeshParser::location_type& l, | void lol::EasyMeshParser::error(const EasyMeshParser::location_type& l, | ||||
@@ -44,7 +44,8 @@ public: | |||||
{ | { | ||||
m_angle = 0; | m_angle = 0; | ||||
m_mesh.Compile("sc#ffb scb#ffb acg 12 10 30 30 5 5 0.1 0"); | |||||
//m_mesh.Compile("sc#ffb scb#ffb acg 12 10 30 30 5 5 0.1 0"); | |||||
m_mesh.Compile("sc#ffb scb#ffb acg 12 10 30 30 -5 -5 0.1 0"); | |||||
#if 0 | #if 0 | ||||
m_mesh.Compile("sc#8d3 [ato40 10 40 rx20 ry130 tx30]"); | m_mesh.Compile("sc#8d3 [ato40 10 40 rx20 ry130 tx30]"); | ||||