diff --git a/src/easymesh/easymesh-parser.y b/src/easymesh/easymesh-parser.y index dd797410..381df7b6 100644 --- a/src/easymesh/easymesh-parser.y +++ b/src/easymesh/easymesh-parser.y @@ -235,7 +235,6 @@ primitive_command: | T_STAR iv fv fv { mc.m_mesh.AppendStar($2, $3, $4); } | T_EXPANDEDSTAR iv fv fv fv { mc.m_mesh.AppendExpandedStar($2, $3, $4, $5); } | T_EXPANDEDSTAR iv fv fv { mc.m_mesh.AppendExpandedStar($2, $3, $4); } - | T_DISC iv fv bv { mc.m_mesh.AppendDisc($2, $3, $4); } | T_DISC iv fv { mc.m_mesh.AppendDisc($2, $3); } | T_TRIANGLE fv bv { mc.m_mesh.AppendSimpleTriangle($2, $3); } diff --git a/src/generated/easymesh-parser.cpp b/src/generated/easymesh-parser.cpp index ebf4a39d..6fd3d8c5 100644 --- a/src/generated/easymesh-parser.cpp +++ b/src/generated/easymesh-parser.cpp @@ -1158,168 +1158,168 @@ namespace lol { case 115: /* Line 677 of lalr1.cc */ -#line 239 "easymesh/easymesh-parser.y" +#line 238 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendDisc((yysemantic_stack_[(4) - (2)].ival), (yysemantic_stack_[(4) - (3)].fval), (yysemantic_stack_[(4) - (4)].bval)); } break; case 116: /* Line 677 of lalr1.cc */ -#line 240 "easymesh/easymesh-parser.y" +#line 239 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendDisc((yysemantic_stack_[(3) - (2)].ival), (yysemantic_stack_[(3) - (3)].fval)); } break; case 117: /* Line 677 of lalr1.cc */ -#line 241 "easymesh/easymesh-parser.y" +#line 240 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendSimpleTriangle((yysemantic_stack_[(3) - (2)].fval), (yysemantic_stack_[(3) - (3)].bval)); } break; case 118: /* Line 677 of lalr1.cc */ -#line 242 "easymesh/easymesh-parser.y" +#line 241 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendSimpleTriangle((yysemantic_stack_[(2) - (2)].fval)); } break; case 119: /* Line 677 of lalr1.cc */ -#line 243 "easymesh/easymesh-parser.y" +#line 242 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendSimpleQuad((yysemantic_stack_[(3) - (2)].fval), (yysemantic_stack_[(3) - (3)].bval)); } break; case 120: /* Line 677 of lalr1.cc */ -#line 244 "easymesh/easymesh-parser.y" +#line 243 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendSimpleQuad((yysemantic_stack_[(2) - (2)].fval)); } break; case 121: /* Line 677 of lalr1.cc */ -#line 245 "easymesh/easymesh-parser.y" +#line 244 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendCog((yysemantic_stack_[(11) - (2)].ival), (yysemantic_stack_[(11) - (3)].fval), (yysemantic_stack_[(11) - (4)].fval), (yysemantic_stack_[(11) - (5)].fval), (yysemantic_stack_[(11) - (6)].fval), (yysemantic_stack_[(11) - (7)].fval), (yysemantic_stack_[(11) - (8)].fval), (yysemantic_stack_[(11) - (9)].fval), (yysemantic_stack_[(11) - (10)].fval), (yysemantic_stack_[(11) - (11)].bval)); } break; case 122: /* Line 677 of lalr1.cc */ -#line 246 "easymesh/easymesh-parser.y" +#line 245 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendCog((yysemantic_stack_[(10) - (2)].ival), (yysemantic_stack_[(10) - (3)].fval), (yysemantic_stack_[(10) - (4)].fval), (yysemantic_stack_[(10) - (5)].fval), (yysemantic_stack_[(10) - (6)].fval), (yysemantic_stack_[(10) - (7)].fval), (yysemantic_stack_[(10) - (8)].fval), (yysemantic_stack_[(10) - (9)].fval), (yysemantic_stack_[(10) - (10)].fval)); } break; case 123: /* Line 677 of lalr1.cc */ -#line 247 "easymesh/easymesh-parser.y" +#line 246 "easymesh/easymesh-parser.y" { mc.m_mesh.AppendCog((yysemantic_stack_[(9) - (2)].ival), (yysemantic_stack_[(9) - (3)].fval), (yysemantic_stack_[(9) - (4)].fval), (yysemantic_stack_[(9) - (5)].fval), (yysemantic_stack_[(9) - (6)].fval), (yysemantic_stack_[(9) - (7)].fval), (yysemantic_stack_[(9) - (8)].fval), (yysemantic_stack_[(9) - (9)].fval)); } break; case 124: /* Line 677 of lalr1.cc */ -#line 252 "easymesh/easymesh-parser.y" +#line 251 "easymesh/easymesh-parser.y" { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); } break; case 125: /* Line 677 of lalr1.cc */ -#line 253 "easymesh/easymesh-parser.y" +#line 252 "easymesh/easymesh-parser.y" { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); } break; case 126: /* Line 677 of lalr1.cc */ -#line 254 "easymesh/easymesh-parser.y" +#line 253 "easymesh/easymesh-parser.y" { (yyval.fval) = (float)(yysemantic_stack_[(1) - (1)].ival); } break; case 127: /* Line 677 of lalr1.cc */ -#line 255 "easymesh/easymesh-parser.y" +#line 254 "easymesh/easymesh-parser.y" { (yyval.fval) = -(float)(yysemantic_stack_[(2) - (2)].ival); } break; case 128: /* Line 677 of lalr1.cc */ -#line 259 "easymesh/easymesh-parser.y" +#line 258 "easymesh/easymesh-parser.y" { (yyval.ival) = (yysemantic_stack_[(1) - (1)].ival); } break; case 129: /* Line 677 of lalr1.cc */ -#line 260 "easymesh/easymesh-parser.y" +#line 259 "easymesh/easymesh-parser.y" { (yyval.ival) = -(yysemantic_stack_[(2) - (2)].ival); } break; case 130: /* Line 677 of lalr1.cc */ -#line 261 "easymesh/easymesh-parser.y" +#line 260 "easymesh/easymesh-parser.y" { (yyval.ival) = (int)(yysemantic_stack_[(1) - (1)].fval); } break; case 131: /* Line 677 of lalr1.cc */ -#line 262 "easymesh/easymesh-parser.y" +#line 261 "easymesh/easymesh-parser.y" { (yyval.ival) = -(int)(yysemantic_stack_[(2) - (2)].fval); } break; case 132: /* Line 677 of lalr1.cc */ -#line 267 "easymesh/easymesh-parser.y" +#line 266 "easymesh/easymesh-parser.y" { (yyval.vval)[0] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[2] = (yysemantic_stack_[(3) - (2)].fval); } break; case 133: /* Line 677 of lalr1.cc */ -#line 268 "easymesh/easymesh-parser.y" +#line 267 "easymesh/easymesh-parser.y" { (yyval.vval)[0] = (yysemantic_stack_[(5) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(5) - (3)].fval); (yyval.vval)[2] = (yysemantic_stack_[(5) - (4)].fval); } break; case 134: /* Line 677 of lalr1.cc */ -#line 272 "easymesh/easymesh-parser.y" +#line 271 "easymesh/easymesh-parser.y" { (yyval.vval)[0] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[2] = (yysemantic_stack_[(3) - (2)].fval); (yyval.vval)[3] = (yysemantic_stack_[(3) - (2)].fval); } break; case 135: /* Line 677 of lalr1.cc */ -#line 273 "easymesh/easymesh-parser.y" +#line 272 "easymesh/easymesh-parser.y" { (yyval.vval)[0] = (yysemantic_stack_[(6) - (2)].fval); (yyval.vval)[1] = (yysemantic_stack_[(6) - (3)].fval); (yyval.vval)[2] = (yysemantic_stack_[(6) - (4)].fval); (yyval.vval)[3] = (yysemantic_stack_[(6) - (5)].fval); } break; case 136: /* Line 677 of lalr1.cc */ -#line 278 "easymesh/easymesh-parser.y" +#line 277 "easymesh/easymesh-parser.y" { (yyval.bval) = (yysemantic_stack_[(1) - (1)].bval); } break; case 137: /* Line 677 of lalr1.cc */ -#line 279 "easymesh/easymesh-parser.y" +#line 278 "easymesh/easymesh-parser.y" { (yyval.bval) = !!(yysemantic_stack_[(1) - (1)].ival); } break; case 138: /* Line 677 of lalr1.cc */ -#line 280 "easymesh/easymesh-parser.y" +#line 279 "easymesh/easymesh-parser.y" { (yyval.bval) = !!(yysemantic_stack_[(1) - (1)].fval); } break; @@ -1940,9 +1940,9 @@ namespace lol { 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, - 233, 234, 235, 236, 237, 239, 240, 241, 242, 243, - 244, 245, 246, 247, 252, 253, 254, 255, 259, 260, - 261, 262, 267, 268, 272, 273, 278, 279, 280 + 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 246, 251, 252, 253, 254, 258, 259, + 260, 261, 266, 267, 271, 272, 277, 278, 279 }; // Print the state stack on the debug stream. @@ -2042,7 +2042,7 @@ namespace lol { /* Line 1055 of lalr1.cc */ -#line 283 "easymesh/easymesh-parser.y" +#line 282 "easymesh/easymesh-parser.y" void lol::EasyMeshParser::error(const EasyMeshParser::location_type& l, diff --git a/test/EasyMeshDictionnary.js b/test/EasyMeshDictionnary.js index 5f277a52..0a9d4fc0 100644 --- a/test/EasyMeshDictionnary.js +++ b/test/EasyMeshDictionnary.js @@ -1,6 +1,7 @@ //------------------------------------------------------------------------- //Command vars operations //------------------------------------------------------------------------- +CmdVar("[ ]", ["Opens a new context,\nevery operations between the braces will only be done to the vertices added since the start of this context."]); CmdVar("float", ["Fraction value", "0.0"]); CmdVar("int", ["No decimal value", "0"]); CmdVar("bool", ["Boolean value", "true/false", "1/0"]); diff --git a/test/data/mesh-buffer.txt b/test/data/mesh-buffer.txt index e5d2a698..f9c435ee 100644 --- a/test/data/mesh-buffer.txt +++ b/test/data/mesh-buffer.txt @@ -1,15 +1,6 @@ -sc#f8f afcb 1 1 1 0 - - - - - - - - - - +sc#fff ab 2 tx 2 tz 1 splt 6 bdzy -90 +//splt 0 //test //[sc#f8f ab 1 splt 4 twy 90] diff --git a/test/meshviewer.cpp b/test/meshviewer.cpp index bcd9e9e1..7e8fc6f6 100644 --- a/test/meshviewer.cpp +++ b/test/meshviewer.cpp @@ -41,6 +41,8 @@ static int const TEXTURE_WIDTH = 256; #define FOV_CLAMP 120.f #define ZOM_SPEED 3.f #define ZOM_CLAMP 20.f +#define HST_SPEED .5f +#define HST_CLAMP 1.f #define WITH_TEXTURE 0 @@ -126,6 +128,7 @@ public: MessageService::Setup(MSG_MAX); // Mesh Setup + m_render_max = vec2(-.9f, 6.1f); m_mesh_id = 0; m_mesh_id1 = 0.f; m_default_texture = NULL; @@ -144,22 +147,24 @@ public: m_pos_mesh = vec2::zero; m_pos_speed = vec2::zero; m_screen_offset = vec2::zero; + m_hist_scale = vec2(.13f, .03f); + m_hist_scale_mesh = vec2(.0f); + m_hist_scale_speed = vec2(.0f); m_camera = new Camera(); m_camera->SetView(vec3(0.f, 0.f, 10.f), vec3(0.f, 0.f, 0.f), vec3(0.f, 1.f, 0.f)); m_camera->SetProjection(0.f, .0001f, 2000.f, WIDTH * SCREEN_W, RATIO_HW); - //m_camera->SetScreenScale(vec2(10.f)); m_camera->UseShift(true); g_scene->PushCamera(m_camera); //Lights setup m_lights << new Light(); - m_lights.Last()->SetPosition(vec4(4.f, -1.f, -4.f, 1.f)); + m_lights.Last()->SetPosition(vec4(4.f, -1.f, -4.f, 0.f)); m_lights.Last()->SetColor(vec4(.0f, .2f, .5f, 1.f)); Ticker::Ref(m_lights.Last()); m_lights << new Light(); - m_lights.Last()->SetPosition(vec4(8.f, 2.f, 6.f, 1.f)); + m_lights.Last()->SetPosition(vec4(8.f, 2.f, 6.f, 0.f)); m_lights.Last()->SetColor(vec4(1.f, 1.f, 1.f, 1.f)); Ticker::Ref(m_lights.Last()); @@ -208,6 +213,7 @@ public: //Camera update bool is_pos = false; bool is_fov = false; + bool is_hsc = false; vec2 tmp = vec2::zero; #if !__native_client__ @@ -222,6 +228,7 @@ public: vec2 rot = (!is_pos && !is_fov)?(tmp):(vec2(.0f)); rot = vec2(rot.x, rot.y); vec2 pos = (is_pos && !is_fov)?(tmp):(vec2(.0f)); pos = -vec2(pos.y, pos.x); vec2 fov = (!is_pos && is_fov)?(tmp):(vec2(.0f)); fov = vec2(-fov.x, fov.y); + vec2 hsc = vec2(0.f); //speed m_rot_speed = damp(m_rot_speed, rot * ROT_SPEED, .2f, seconds); @@ -231,6 +238,7 @@ public: m_fov_speed = damp(m_fov_speed, fov.x * FOV_SPEED * fov_factor, .2f, seconds); float zom_factor = 1.f + lol::pow((m_zoom_mesh / ZOM_CLAMP) * 1.f, 2.f); m_zoom_speed = damp(m_zoom_speed, fov.y * ZOM_SPEED * zom_factor, .2f, seconds); + m_hist_scale_speed = damp(m_hist_scale_speed, hsc * HST_SPEED, .2f, seconds); m_rot += m_rot_speed * seconds; @@ -241,6 +249,7 @@ public: m_pos += m_pos_speed * seconds; m_fov += m_fov_speed * seconds; m_zoom += m_zoom_speed * seconds; + m_hist_scale += m_hist_scale_speed * seconds; } #endif //!__native_client__ @@ -250,6 +259,8 @@ public: SmoothClamp(m_pos.y, -POS_CLAMP, POS_CLAMP, POS_CLAMP * .1f)); float fov_mesh = SmoothClamp(m_fov, 0.f, FOV_CLAMP, FOV_CLAMP * .1f); float zoom_mesh = SmoothClamp(m_zoom, 0.f, ZOM_CLAMP, ZOM_CLAMP * .1f); + vec2 hist_scale_mesh = vec2(SmoothClamp(m_hist_scale.x, 0.f, HST_CLAMP, HST_CLAMP * .1f), + SmoothClamp(m_hist_scale.y, 0.f, HST_CLAMP, HST_CLAMP * .1f)); #if !__native_client__ if (m_controller->GetKey(KEY_CAM_RESET).IsDown()) @@ -263,6 +274,7 @@ public: m_pos_mesh = vec2(damp(m_pos_mesh.x, pos_mesh.x, .2f, seconds), damp(m_pos_mesh.y, pos_mesh.y, .2f, seconds)); m_fov_mesh = damp(m_fov_mesh, fov_mesh, .2f, seconds); m_zoom_mesh = damp(m_zoom_mesh, zoom_mesh, .2f, seconds); + m_hist_scale_mesh = damp(m_hist_scale_mesh, hist_scale_mesh, .2f, seconds); //Mesh mat calculation m_mat = mat4(quat::fromeuler_xyz(vec3(m_rot_mesh, .0f))); @@ -445,8 +457,8 @@ public: { #if WITH_TEXTURE m_meshes[i]->MeshConvert(new DefaultShaderData(((1 << VertexUsage::Position) | (1 << VertexUsage::Normal) | - (1 << VertexUsage::Color) | (1 << VertexUsage::TexCoord)), - m_texture_shader, true)); + (1 << VertexUsage::Color) | (1 << VertexUsage::TexCoord)), + m_texture_shader, true)); #else m_meshes[i]->MeshConvert(); #endif //WITH_TEXTURE @@ -454,19 +466,23 @@ public: mat4 save_proj = m_camera->GetProjection(); float j = -(float)(m_meshes.Count() - (i + 1)) + (-m_mesh_id1 + (float)(m_meshes.Count() - 1)); - if (m_meshes[i]->GetMeshState() > MeshRender::NeedConvert) + if (m_mesh_id1 - m_render_max[0] > (float)i && m_mesh_id1 - m_render_max[1] < (float)i && + m_meshes[i]->GetMeshState() > MeshRender::NeedConvert) { + float a_j = lol::abs(j); + float i_trans = (a_j * a_j * m_hist_scale_mesh.x + a_j * m_hist_scale_mesh.x) * .5f; + float i_scale = clamp(1.f - (m_hist_scale_mesh.y * (m_mesh_id1 - (float)i)), 0.f, 1.f); mat4 new_proj = //Y object Offset mat4::translate(x * m_screen_offset.x + y * m_screen_offset.y) * //Mesh Pos Offset mat4::translate((x * m_pos_mesh.x * RATIO_HW + y * m_pos_mesh.y) * 2.f * (1.f + .5f * m_zoom_mesh / SCREEN_LIMIT)) * //Mesh count offset - mat4::translate(x * RATIO_HW * 2.f * j) * + mat4::translate(x * RATIO_HW * 2.f * (j + i_trans)) * //Align right meshes mat4::translate(x - x * RATIO_HW) * //Mesh count scale - //mat4::scale(1.f - .2f * j * (1.f / (float)m_meshes.Count())) * + mat4::scale(vec3(vec2(i_scale), 1.f)) * //Camera projection save_proj; m_camera->SetProjection(new_proj); @@ -498,9 +514,13 @@ private: vec2 m_pos; vec2 m_pos_mesh; vec2 m_pos_speed; + vec2 m_hist_scale; + vec2 m_hist_scale_mesh; + vec2 m_hist_scale_speed; vec2 m_screen_offset; //Mesh infos + vec2 m_render_max; int m_mesh_id; float m_mesh_id1; Array m_meshes;