Pārlūkot izejas kodu

EZMesh : Added Vertices{Merge|Separate} and PostBuildNormal.

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> pirms 11 gadiem
vecāks
revīzija
b608607dba
10 mainītis faili ar 1322 papildinājumiem un 1101 dzēšanām
  1. +7
    -1
      src/easymesh/easymesh-parser.y
  2. +8
    -2
      src/easymesh/easymesh-scanner.l
  3. +214
    -148
      src/easymesh/easymesh.cpp
  4. +24
    -6
      src/easymesh/easymesh.h
  5. +548
    -513
      src/generated/easymesh-parser.cpp
  6. +68
    -64
      src/generated/easymesh-parser.h
  7. +406
    -357
      src/generated/easymesh-scanner.cpp
  8. +14
    -10
      test/data/mesh-buffer.txt
  9. +8
    -0
      test/easymeshdictionnary.js
  10. +25
    -0
      test/meshviewer.cpp

+ 7
- 1
src/easymesh/easymesh-parser.y Parādīt failu

@@ -46,11 +46,13 @@
%start mesh_description

%token T_LOOP T_COLOR T_ACOLOR T_BCOLOR T_VCOLOR
%token T_TOGGLESCALEWINDING T_TOGGLEQUADWEIGHTING T_TOGGLEPOSTBUILDNORMAL T_TOGGLEVERTNOCLEANUP
%token T_VERTMERGE T_VERTSEPARATE

%token T_TRANSLATEX T_ROTATEX T_TAPERX T_TWISTX T_SHEARX T_STRETCHX T_BENDXY T_BENDXZ T_SCALEX T_MIRRORX
%token T_TRANSLATEY T_ROTATEY T_TAPERY T_TWISTY T_SHEARY T_STRETCHY T_BENDYX T_BENDYZ T_SCALEY T_MIRRORY
%token T_TRANSLATEZ T_ROTATEZ T_TAPERZ T_TWISTZ T_SHEARZ T_STRETCHZ T_BENDZX T_BENDZY T_SCALEZ T_MIRRORZ
%token T_TRANSLATE T_ROTATE T_SCALE T_TOGGLESCALEWINDING T_TOGGLEQUADWEIGHTING T_RADIALJITTER T_SPLITTRIANGLE T_SMOOTHMESH
%token T_TRANSLATE T_ROTATE T_SCALE T_RADIALJITTER T_SPLITTRIANGLE T_SMOOTHMESH
%token T_DUPLICATE
%token T_CSGUNION T_CSGSUBSTRACT T_CSGSUBSTRACTLOSS T_CSGAND T_CSGXOR
%token T_CHAMFER
@@ -233,6 +235,10 @@ transform_command:
| T_SMOOTHMESH iv iv iv { mc.m_mesh.SmoothMesh($2, $3, $4); }
| T_TOGGLESCALEWINDING { mc.m_mesh.ToggleScaleWinding(); }
| T_TOGGLEQUADWEIGHTING { mc.m_mesh.ToggleQuadWeighting(); }
| T_TOGGLEPOSTBUILDNORMAL { mc.m_mesh.TogglePostBuildNormal(); }
| T_TOGGLEVERTNOCLEANUP { mc.m_mesh.ToggleVerticeNoCleanup(); }
| T_VERTMERGE { mc.m_mesh.VerticesMerge(); }
| T_VERTSEPARATE { mc.m_mesh.VerticesSeparate(); }
;

primitive_command:


+ 8
- 2
src/easymesh/easymesh-scanner.l Parādīt failu

@@ -54,13 +54,19 @@ typedef lol::EasyMeshParser::token_type token_type;
(csgx|csgxor) { return token::T_CSGXOR; }

(lp|loop) { return token::T_LOOP; }
(tsw|tglscalewind) { return token::T_TOGGLESCALEWINDING; }
(tqw|tglquadweight) { return token::T_TOGGLEQUADWEIGHTING; }
(sc|setcolor) { return token::T_COLOR; }
(sca|setcolora) { return token::T_ACOLOR; }
(scb|setcolorb) { return token::T_BCOLOR; }
(scv|setcolorv) { return token::T_VCOLOR; }

(tsw|tglscalewind) { return token::T_TOGGLESCALEWINDING; }
(tqw|tglquadweight) { return token::T_TOGGLEQUADWEIGHTING; }
(tpbn|tglpstbuildnormal) { return token::T_TOGGLEPOSTBUILDNORMAL; }
(tvnc|tglvertnocleanup) { return token::T_TOGGLEVERTNOCLEANUP; }

(vm|vertmerge) { return token::T_VERTMERGE; }
(vs|vertseparate) { return token::T_VERTSEPARATE; }

(tx|translatex) { return token::T_TRANSLATEX; }
(ty|translatey) { return token::T_TRANSLATEY; }
(tz|translatez) { return token::T_TRANSLATEZ; }


+ 214
- 148
src/easymesh/easymesh.cpp Parādīt failu

@@ -453,6 +453,15 @@ bool EasyMesh::Compile(char const *command)
BD()->Enable(MeshBuildOperation::CommandExecution);
ExecuteCmdStack();
BD()->Disable(MeshBuildOperation::CommandExecution);

if (!BD()->IsEnabled(MeshBuildOperation::PreventVertCleanup))
VerticesCleanup();

if (BD()->IsEnabled(MeshBuildOperation::PostBuildComputeNormals))
ComputeNormals(0, m_indices.Count());

BD()->Disable(MeshBuildOperation::PostBuildComputeNormals);
BD()->Disable(MeshBuildOperation::PreventVertCleanup);
}
return res;
}
@@ -490,155 +499,47 @@ bool EasyMesh::Compile(char const *command)
//-----------------------------------------------------------------------------
void EasyMesh::ExecuteCmdStack()
{
#define DO_EXEC_CMD(MESH_CMD, FUNC_PARAMS) \
case EasyMeshCmdType::MESH_CMD: \
{ EZM_CALL_FUNC FUNC_PARAMS; break; }

for (BD()->Cmdi() = 0; BD()->Cmdi() < BD()->CmdStack().GetCmdNb(); ++BD()->Cmdi())
{
switch (BD()->CmdStack().GetCmd(BD()->Cmdi()))
{
case EasyMeshCmdType::MeshCsg:
{
EZM_CALL_FUNC(MeshCsg, CSGUsage);
break;
}
case EasyMeshCmdType::LoopStart:
{
EZM_CALL_FUNC(LoopStart, int);
break;
}
case EasyMeshCmdType::LoopEnd:
{
EZM_CALL_FUNC(LoopEnd);
break;
}
case EasyMeshCmdType::OpenBrace:
{
EZM_CALL_FUNC(OpenBrace);
break;
}
case EasyMeshCmdType::CloseBrace:
{
EZM_CALL_FUNC(CloseBrace);
break;
}
case EasyMeshCmdType::ScaleWinding:
{
EZM_CALL_FUNC(ToggleScaleWinding);
break;
}
case EasyMeshCmdType::QuadWeighting:
{
EZM_CALL_FUNC(ToggleQuadWeighting);
break;
}
case EasyMeshCmdType::SetColorA:
{
EZM_CALL_FUNC(SetCurColorA, vec4);
break;
}
case EasyMeshCmdType::SetColorB:
{
EZM_CALL_FUNC(SetCurColorB, vec4);
break;
}
case EasyMeshCmdType::SetVertColor:
{
EZM_CALL_FUNC(SetVertColor, vec4);
break;
}
case EasyMeshCmdType::Translate:
{
EZM_CALL_FUNC(Translate, vec3);
break;
}
case EasyMeshCmdType::Rotate:
{
EZM_CALL_FUNC(Rotate, float, vec3);
break;
}
case EasyMeshCmdType::RadialJitter:
{
EZM_CALL_FUNC(RadialJitter, float);
break;
}
case EasyMeshCmdType::MeshTranform:
{
EZM_CALL_FUNC(DoMeshTransform, MeshTransform, Axis, Axis, float, float, float, bool);
break;
}
case EasyMeshCmdType::Scale:
{
EZM_CALL_FUNC(Scale, vec3);
break;
}
case EasyMeshCmdType::DupAndScale:
{
EZM_CALL_FUNC(DupAndScale, vec3, bool);
break;
}
case EasyMeshCmdType::Chamfer:
{
EZM_CALL_FUNC(Chamfer, float);
break;
}
case EasyMeshCmdType::SplitTriangles:
{
EZM_CALL_FUNC(SplitTriangles, int);
break;
}
case EasyMeshCmdType::SmoothMesh:
{
EZM_CALL_FUNC(SmoothMesh, int, int, int);
break;
}
case EasyMeshCmdType::AppendCylinder:
{
EZM_CALL_FUNC(AppendCylinder, int, float, float, float, bool, bool, bool);
break;
}
case EasyMeshCmdType::AppendCapsule:
{
EZM_CALL_FUNC(AppendCapsule, int, float, float);
break;
}
case EasyMeshCmdType::AppendTorus:
{
EZM_CALL_FUNC(AppendTorus, int, float, float);
break;
}
case EasyMeshCmdType::AppendBox:
{
EZM_CALL_FUNC(AppendBox, vec3, float, bool);
break;
}
case EasyMeshCmdType::AppendStar:
{
EZM_CALL_FUNC(AppendStar, int, float, float, bool, bool);
break;
}
case EasyMeshCmdType::AppendExpandedStar:
{
EZM_CALL_FUNC(AppendExpandedStar, int, float, float, float);
break;
}
case EasyMeshCmdType::AppendDisc:
{
EZM_CALL_FUNC(AppendDisc, int, float, bool);
break;
}
case EasyMeshCmdType::AppendSimpleTriangle:
{
EZM_CALL_FUNC(AppendSimpleTriangle, float, bool);
break;
}
case EasyMeshCmdType::AppendSimpleQuad:
{
EZM_CALL_FUNC(AppendSimpleQuad, vec2, vec2, float, bool);
break;
}
case EasyMeshCmdType::AppendCog:
{
EZM_CALL_FUNC(AppendCog, int, float, float, float, float, float, float, float, float, bool);
break;
}
DO_EXEC_CMD(MeshCsg, (MeshCsg, CSGUsage))
DO_EXEC_CMD(LoopStart, (LoopStart, int))
DO_EXEC_CMD(LoopEnd, (LoopEnd))
DO_EXEC_CMD(OpenBrace, (OpenBrace))
DO_EXEC_CMD(CloseBrace, (CloseBrace))
DO_EXEC_CMD(ScaleWinding, (ToggleScaleWinding))
DO_EXEC_CMD(QuadWeighting, (ToggleQuadWeighting))
DO_EXEC_CMD(PostBuildNormal, (TogglePostBuildNormal))
DO_EXEC_CMD(PreventVertCleanup, (ToggleVerticeNoCleanup))
DO_EXEC_CMD(VerticesMerge, (VerticesMerge))
DO_EXEC_CMD(VerticesSeparate, (VerticesSeparate))
DO_EXEC_CMD(SetColorA, (SetCurColorA, vec4))
DO_EXEC_CMD(SetColorB, (SetCurColorB, vec4))
DO_EXEC_CMD(SetVertColor, (SetVertColor, vec4))
DO_EXEC_CMD(Translate, (Translate, vec3))
DO_EXEC_CMD(Rotate, (Rotate, float, vec3))
DO_EXEC_CMD(RadialJitter, (RadialJitter, float))
DO_EXEC_CMD(MeshTranform, (DoMeshTransform, MeshTransform, Axis, Axis, float, float, float, bool))
DO_EXEC_CMD(Scale, (Scale, vec3))
DO_EXEC_CMD(DupAndScale, (DupAndScale, vec3, bool))
DO_EXEC_CMD(Chamfer, (Chamfer, float))
DO_EXEC_CMD(SplitTriangles, (SplitTriangles, int))
DO_EXEC_CMD(SmoothMesh, (SmoothMesh, int, int, int))
DO_EXEC_CMD(AppendCylinder, (AppendCylinder, int, float, float, float, bool, bool, bool))
DO_EXEC_CMD(AppendCapsule, (AppendCapsule, int, float, float))
DO_EXEC_CMD(AppendTorus, (AppendTorus, int, float, float))
DO_EXEC_CMD(AppendBox, (AppendBox, vec3, float, bool))
DO_EXEC_CMD(AppendStar, (AppendStar, int, float, float, bool, bool))
DO_EXEC_CMD(AppendExpandedStar, (AppendExpandedStar, int, float, float, float))
DO_EXEC_CMD(AppendDisc, (AppendDisc, int, float, bool))
DO_EXEC_CMD(AppendSimpleTriangle, (AppendSimpleTriangle, float, bool))
DO_EXEC_CMD(AppendSimpleQuad, (AppendSimpleQuad, vec2, vec2, float, bool))
DO_EXEC_CMD(AppendCog, (AppendCog, int, float, float, float, float, float, float, float, float, bool))
default:
ASSERT(0, "Unknown command pseudo bytecode");
}
@@ -775,8 +676,6 @@ bool EasyMesh::SetRender(bool should_render)
//-------------------
// "Collisions" functions
//-------------------
#define VX_ALONE -2
#define VX_MASTER -1

//-----------------------------------------------------------------------------
//helpers func to retrieve a vertex.
@@ -1121,6 +1020,7 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation)
m_cursors.Last().m1 = m_vert.Count();
m_cursors.Last().m2 = m_indices.Count();

VerticesCleanup();
//DONE for the splitting !
}

@@ -1148,6 +1048,30 @@ void EasyMesh::ToggleQuadWeighting()
BD()->Toggle(MeshBuildOperation::QuadWeighting);
}

//-----------------------------------------------------------------------------
void EasyMesh::TogglePostBuildNormal()
{
if (BD()->IsEnabled(MeshBuildOperation::CommandRecording))
{
BD()->CmdStack().AddCmd(EasyMeshCmdType::PostBuildNormal);
return;
}

BD()->Toggle(MeshBuildOperation::PostBuildComputeNormals);
}

//-----------------------------------------------------------------------------
void EasyMesh::ToggleVerticeNoCleanup()
{
if (BD()->IsEnabled(MeshBuildOperation::CommandRecording))
{
BD()->CmdStack().AddCmd(EasyMeshCmdType::PreventVertCleanup);
return;
}

BD()->Toggle(MeshBuildOperation::PreventVertCleanup);
}

//-----------------------------------------------------------------------------
void EasyMesh::SetCurColor(vec4 const &color)
{
@@ -1308,6 +1232,13 @@ void EasyMesh::AppendTriangleDuplicateVerts(int i1, int i2, int i3, int base)
//-----------------------------------------------------------------------------
void EasyMesh::ComputeNormals(int start, int vcount)
{
if (BD()->IsEnabled(MeshBuildOperation::CommandExecution) &&
BD()->IsEnabled(MeshBuildOperation::PostBuildComputeNormals))
return;

Array< Array<vec3> > normals;
normals.Resize(m_vert.Count());
for (int i = 0; i < vcount; i += 3)
{
vec3 v0 = m_vert[m_indices[start + i + 2]].m_coord
@@ -1317,8 +1248,143 @@ void EasyMesh::ComputeNormals(int start, int vcount)
vec3 n = normalize(cross(v1, v0));

for (int j = 0; j < 3; j++)
m_vert[m_indices[start + i + j]].m_normal = n;
normals[m_indices[start + i + j]] << n;
}

for (int i = 0; i < normals.Count(); i++)
{
if (normals[i].Count() > 0)
{
//remove doubles
for (int j = 0; j < normals[i].Count(); ++j)
for (int k = j + 1; k < normals[i].Count(); ++k)
if (1.f - dot(normals[i][k], normals[i][j]) < .00001f)
normals[i].Remove(k--);

vec3 newv = vec3::zero;
for (int j = 0; j < normals[i].Count(); ++j)
newv += normals[i][j];
m_vert[i].m_normal = normalize(newv / (float)normals[i].Count());
}
}
}

//-----------------------------------------------------------------------------
void EasyMesh::VerticesCleanup()
{
Array<int> vert_ids;
vert_ids.Resize(m_vert.Count(), 0);

//1: Remove triangles with two vertices on each other
for (int i = 0; i < m_indices.Count(); i += 3)
{
bool remove = false;
for (int j = 0; !remove && j < 3; ++j)
if (length(m_vert[m_indices[i + j]].m_coord - m_vert[m_indices[i + (j + 1) % 3]].m_coord) < .00001f)
remove = true;
if (remove)
{
m_indices.RemoveSwap(i, 3);
i -= 3;
}
else
{
//1.5: Mark all used vertices
for (int j = 0; j < 3; ++j)
vert_ids[m_indices[i + j]] = 1;
}
}

//2: Remove all unused vertices
Array<VertexData> old_vert = m_vert;
int shift = 0;
m_vert.Empty();
for (int i = 0; i < vert_ids.Count(); ++i)
{
//Unused vertex, update the shift quantity instead of keeping it.
if (vert_ids[i] == 0)
shift++;
else
m_vert << old_vert[i];
//Always mark it with the shift quantity
vert_ids[i] = shift;
}

//3: Update the indices
for (int i = 0; i < m_indices.Count(); ++i)
m_indices[i] -= vert_ids[m_indices[i]];
}

//-----------------------------------------------------------------------------
void EasyMesh::VerticesMerge()
{
if (BD()->IsEnabled(MeshBuildOperation::CommandRecording))
{
BD()->CmdStack().AddCmd(EasyMeshCmdType::VerticesMerge);
return;
}

//1: Crunch all vertices in the dictionnary
VertexDictionnary vert_dict;
for (int i = m_cursors.Last().m1; i < m_vert.Count(); i++)
vert_dict.AddVertex(i, m_vert[i].m_coord);

//2: Update the indices
for (int i = 0; i < m_indices.Count(); ++i)
{
int master = vert_dict.FindVertexMaster(m_indices[i]);
if (master >= 0)
m_indices[i] = master;
}

//2: Cleanup
VerticesCleanup();
}

//-----------------------------------------------------------------------------
void EasyMesh::VerticesSeparate()
{
if (BD()->IsEnabled(MeshBuildOperation::CommandRecording))
{
BD()->CmdStack().AddCmd(EasyMeshCmdType::VerticesSeparate);
return;
}

Array< Array<int> > new_ids;
Array<int> vert_ids;
vert_ids.Resize(m_vert.Count(), 0);

//1: Mark all used vertices
for (int i = 0; i < m_indices.Count(); ++i)
vert_ids[m_indices[i]]++;

//2: Update the vertices
int vbase = m_cursors.Last().m1;
int vcount = m_vert.Count();
new_ids.Resize(vcount);
for (int i = vbase; i < vcount; i++)
{
while (vert_ids[i] > 1)
{
//Add duplicate
new_ids[i] << m_vert.Count();
AddDuplicateVertex(i);
vert_ids[i]--;
}
}

//3: Update the indices
for (int i = 0; i < m_indices.Count(); ++i)
{
if (new_ids[m_indices[i]].Count())
{
int j = new_ids[m_indices[i]].Pop();
m_indices[i] = j;
}
}

//4: Cleanup
VerticesCleanup();
}

//-----------------------------------------------------------------------------


+ 24
- 6
src/easymesh/easymesh.h Parādīt failu

@@ -201,11 +201,13 @@ struct MeshBuildOperation
enum Value
{
//When this flag is up, negative scaling will not invert faces.
ScaleWinding = (1 << 0),
CommandRecording = (1 << 1),
CommandExecution = (1 << 2),
QuadWeighting = (1 << 3),
IgnoreQuadWeighting = (1 << 4),
ScaleWinding = (1 << 0),
CommandRecording = (1 << 1),
CommandExecution = (1 << 2),
QuadWeighting = (1 << 3),
IgnoreQuadWeighting = (1 << 4),
PostBuildComputeNormals = (1 << 5),
PreventVertCleanup = (1 << 6),

All = 0xffffffff
}
@@ -229,10 +231,15 @@ struct EasyMeshCmdType

ScaleWinding,
QuadWeighting,
PostBuildNormal,
PreventVertCleanup,
SetColorA,
SetColorB,
SetVertColor,

VerticesMerge,
VerticesSeparate,

Translate,
Rotate,
RadialJitter,
@@ -702,6 +709,10 @@ public:
void ToggleScaleWinding();
/* [cmd:tqw] When active, quad will have a fifth center vertex */
void ToggleQuadWeighting();
/* [cmd:tpbn] When active, normal will be computed after the build */
void TogglePostBuildNormal();
/* [cmd:tpbn] When active, normal will be computed after the build */
void ToggleVerticeNoCleanup();
/* [cmd:sc] Set both color */
void SetCurColor(vec4 const &color);
/* [cmd:sca] Set base color A */
@@ -726,6 +737,13 @@ private:
void AppendTriangle(int i1, int i2, int i3, int base);
void AppendTriangleDuplicateVerts(int i1, int i2, int i3, int base);
void ComputeNormals(int start, int vcount);
public:
/* Remove all unused */
void VerticesCleanup();
/* Merge vertices AKA: smooth */
void VerticesMerge();
/* Merge vertices AKA: Flat */
void VerticesSeparate();
public: //DEBUG
void ComputeTexCoord(float uv_scale, int uv_offset);

@@ -984,7 +1002,7 @@ public:
int GetVertexCount() { return m_vert.Count(); }
vec3 const &GetVertexLocation(int i) { return m_vert[i].m_coord; }

private:
//private:
Array<uint16_t> m_indices;
Array<VertexData> m_vert;



+ 548
- 513
src/generated/easymesh-parser.cpp
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 68
- 64
src/generated/easymesh-parser.h Parādīt failu

@@ -141,69 +141,73 @@ namespace lol {
T_ACOLOR = 260,
T_BCOLOR = 261,
T_VCOLOR = 262,
T_TRANSLATEX = 263,
T_ROTATEX = 264,
T_TAPERX = 265,
T_TWISTX = 266,
T_SHEARX = 267,
T_STRETCHX = 268,
T_BENDXY = 269,
T_BENDXZ = 270,
T_SCALEX = 271,
T_MIRRORX = 272,
T_TRANSLATEY = 273,
T_ROTATEY = 274,
T_TAPERY = 275,
T_TWISTY = 276,
T_SHEARY = 277,
T_STRETCHY = 278,
T_BENDYX = 279,
T_BENDYZ = 280,
T_SCALEY = 281,
T_MIRRORY = 282,
T_TRANSLATEZ = 283,
T_ROTATEZ = 284,
T_TAPERZ = 285,
T_TWISTZ = 286,
T_SHEARZ = 287,
T_STRETCHZ = 288,
T_BENDZX = 289,
T_BENDZY = 290,
T_SCALEZ = 291,
T_MIRRORZ = 292,
T_TRANSLATE = 293,
T_ROTATE = 294,
T_SCALE = 295,
T_TOGGLESCALEWINDING = 296,
T_TOGGLEQUADWEIGHTING = 297,
T_RADIALJITTER = 298,
T_SPLITTRIANGLE = 299,
T_SMOOTHMESH = 300,
T_DUPLICATE = 301,
T_CSGUNION = 302,
T_CSGSUBSTRACT = 303,
T_CSGSUBSTRACTLOSS = 304,
T_CSGAND = 305,
T_CSGXOR = 306,
T_CHAMFER = 307,
T_CYLINDER = 308,
T_BOX = 309,
T_SMOOTHCHAMFBOX = 310,
T_FLATCHAMFBOX = 311,
T_SPHERE = 312,
T_CAPSULE = 313,
T_STAR = 314,
T_EXPANDEDSTAR = 315,
T_DISC = 316,
T_TRIANGLE = 317,
T_QUAD = 318,
T_COG = 319,
T_TORUS = 320,
T_ERROR = 321,
F_NUMBER = 322,
I_NUMBER = 323,
BOOLEAN = 324,
COLOR = 325
T_TOGGLESCALEWINDING = 263,
T_TOGGLEQUADWEIGHTING = 264,
T_TOGGLEPOSTBUILDNORMAL = 265,
T_TOGGLEVERTNOCLEANUP = 266,
T_VERTMERGE = 267,
T_VERTSEPARATE = 268,
T_TRANSLATEX = 269,
T_ROTATEX = 270,
T_TAPERX = 271,
T_TWISTX = 272,
T_SHEARX = 273,
T_STRETCHX = 274,
T_BENDXY = 275,
T_BENDXZ = 276,
T_SCALEX = 277,
T_MIRRORX = 278,
T_TRANSLATEY = 279,
T_ROTATEY = 280,
T_TAPERY = 281,
T_TWISTY = 282,
T_SHEARY = 283,
T_STRETCHY = 284,
T_BENDYX = 285,
T_BENDYZ = 286,
T_SCALEY = 287,
T_MIRRORY = 288,
T_TRANSLATEZ = 289,
T_ROTATEZ = 290,
T_TAPERZ = 291,
T_TWISTZ = 292,
T_SHEARZ = 293,
T_STRETCHZ = 294,
T_BENDZX = 295,
T_BENDZY = 296,
T_SCALEZ = 297,
T_MIRRORZ = 298,
T_TRANSLATE = 299,
T_ROTATE = 300,
T_SCALE = 301,
T_RADIALJITTER = 302,
T_SPLITTRIANGLE = 303,
T_SMOOTHMESH = 304,
T_DUPLICATE = 305,
T_CSGUNION = 306,
T_CSGSUBSTRACT = 307,
T_CSGSUBSTRACTLOSS = 308,
T_CSGAND = 309,
T_CSGXOR = 310,
T_CHAMFER = 311,
T_CYLINDER = 312,
T_BOX = 313,
T_SMOOTHCHAMFBOX = 314,
T_FLATCHAMFBOX = 315,
T_SPHERE = 316,
T_CAPSULE = 317,
T_STAR = 318,
T_EXPANDEDSTAR = 319,
T_DISC = 320,
T_TRIANGLE = 321,
T_QUAD = 322,
T_COG = 323,
T_TORUS = 324,
T_ERROR = 325,
F_NUMBER = 326,
I_NUMBER = 327,
BOOLEAN = 328,
COLOR = 329
};

};
@@ -377,7 +381,7 @@ namespace lol {
} // lol

/* Line 34 of lalr1.cc */
#line 381 "generated/easymesh-parser.h"
#line 385 "generated/easymesh-parser.h"





+ 406
- 357
src/generated/easymesh-scanner.cpp
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 14
- 10
test/data/mesh-buffer.txt Parādīt failu

@@ -1,9 +1,10 @@
addlight 0 position (4 -4 0) color #fff
//addlight 0 position (1 -.5 1.5) color #fff
addlight 1 position (0 0 6) color #bfb
clearcolor #d0d
clearcolor #ddd
showgizmo true
showlight true


//SCENE SETUP END

//addlight 0.0 position (1 0 1) color #0ff
@@ -11,17 +12,17 @@ showlight true

//custom setmesh "sc#f00 ab 2 ty 1.5 ab 2"
custom setmesh "
//tqw
//CMD TEST
sc#0f0 ab 5
//sc#0f0 asph 1 10
//sc#0f0 ab 10
//sc#0f0 afcb 1 -.2
//sc#0f0 acg 8 1 1 1 2 2 1.5 1.5 -.4
//sc#0f0 as 6 1 2
//sc#0f0 scb#f00 aes 6 1 2 2
//sc#0f0 ac 6 1 1
//sc#0f0 ac 6 5 2 2 false true true
//sc#0f0 aq 1
//splt 2 smth 4 0 1
@@ -48,6 +49,14 @@ sc#0f0 ab 5
//sc#0f0 ab 2 ty 1.5 ab 2
//sc#00f ab 2 ty 1.5 ab 2
[sc#88f afcb 10 10 10 .25 tx 0]
csgs [sc#fff afcb 10 10 10 .25 t 2 2 2]
//[sc#fff afcb 7 7 7 .25]
//[sc#ff2 afcb 7 7 7 .25 t 1 1 1 csgs]
"
//splt 0
@@ -92,8 +101,3 @@ sc#0f0 ab 5
//[sc#ff2 asph 2 10 10 10]
//[sc#400 asph 2 10 10 10 t 2 2 2 csgs]
//[sc#88f afcb 10 10 10 .25 tx 0]
//[sc#fff afcb 10 10 10 .25 t 2 2 2 csgs]
//[sc#fff afcb 7 7 7 .25]
//[sc#ff2 afcb 7 7 7 .25 t 1 1 1 csgs]

+ 8
- 0
test/easymeshdictionnary.js Parādīt failu

@@ -25,12 +25,20 @@ CmdType(["csgx", "csgxor"], "Performs a Xor operation as :\n(current_scope_Outs
//-------------------------------------------------------------------------
CmdType(["tsw", "tglscalewind"], "When active, on negative-scaling,\nnormal-vector correction will not occur\nDefault : Inactive");
CmdType(["tqw", "tglquadweight"], "When active, quad will have a fifth center vertex\nDefault : Inactive");
CmdType(["tpbn", "tglpstbuildnormal"], "When active, normal will be only computed after all the command\nDefault : Inactive");
CmdType(["tvnc", "tglvertnocleanup"], "When active, vertices cleanup will not be done at the end of all the commands\nDefault : Inactive");
CmdType(["sc", "setcolor"], "Set A & B color", [CmdArg("color", "color")]);
CmdType(["sca", "setcolora"], "Set A color", [CmdArg("color", "color")]);
CmdType(["scb", "setcolorb"], "Set B color", [CmdArg("color", "color")]);
CmdType(["scv", "setcolorv"], "Set the color of all vertices in this scope", [CmdArg("color", "color")]);
CmdType(["lp", "loop"], "Performs a loop with the code in the braces.\nDoesn't open a new scope.", [CmdArg("int", "loopnb"), CmdArg("[ ]", "Loop command")]);

//-------------------------------------------------------------------------
//Vertices operations
//-------------------------------------------------------------------------
CmdType(["vm", "vertmerge"], "Will merge all the same face vertices");
CmdType(["vs", "vertseparate"], "Will separate all the same face vertices");

//-------------------------------------------------------------------------
//Mesh transform operations
//-------------------------------------------------------------------------


+ 25
- 0
test/meshviewer.cpp Parādīt failu

@@ -729,6 +729,8 @@ public:
#endif //ALL_FEATURES
}
}

//Scene setup update
if (m_ssetup)
{
m_camera->SetProjection(mat_gizmo);
@@ -756,6 +758,29 @@ public:
}
m_camera->SetProjection(save_proj);
}

#if 0 //Debug normal draw
for (int i = m_meshes.Count() - 1; 0 <= i && i < m_meshes.Count(); i++)
{
for (int j = 0; j < m_meshes[i]->m_indices.Count(); j += 3)
{
VertexData v[3] = { m_meshes[i]->m_vert[m_meshes[i]->m_indices[j ]],
m_meshes[i]->m_vert[m_meshes[i]->m_indices[j+1]],
m_meshes[i]->m_vert[m_meshes[i]->m_indices[j+2]]
};
for (int k = 0; k < 3; k++)
Debug::DrawLine((m_mat * mat4::translate(v[k].m_coord)).v3.xyz,
(m_mat * mat4::translate(v[(k+1)%3].m_coord)).v3.xyz, vec4(vec3((v[k].m_coord.z + 1.f)*.5f),1.f));
}
for (int j = 0; j < m_meshes[i]->m_vert.Count(); j++)
{
VertexData &v = m_meshes[i]->m_vert[m_meshes[i]->m_indices[j]];
Debug::DrawLine((m_mat * mat4::translate(v.m_coord)).v3.xyz,
(m_mat * mat4::translate(v.m_coord)).v3.xyz +
(m_mat * vec4(v.m_normal * 5.f, 0.f)).xyz, vec4(lol::abs(v.m_normal), 1.f));
}
}
#endif
}

private:


Notiek ielāde…
Atcelt
Saglabāt