mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
Experimental conditional line support.
This commit is contained in:
parent
a6d3df04b0
commit
6e602174c0
6 changed files with 110 additions and 40 deletions
|
@ -953,7 +953,50 @@ void lcContext::DrawMeshSection(lcMesh* Mesh, lcMeshSection* Section)
|
|||
}
|
||||
}
|
||||
|
||||
DrawIndexedPrimitives(Section->PrimitiveType, Section->NumIndices, Mesh->mIndexType, IndexBufferOffset + Section->IndexOffset);
|
||||
bool DrawConditional = false;
|
||||
|
||||
if (Section->PrimitiveType != LC_MESH_CONDITIONAL_LINES)
|
||||
{
|
||||
GLenum PrimitiveType = (Section->PrimitiveType == LC_MESH_TRIANGLES || Section->PrimitiveType == LC_MESH_TEXTURED_TRIANGLES) ? GL_TRIANGLES : GL_LINES;
|
||||
DrawIndexedPrimitives(PrimitiveType, Section->NumIndices, Mesh->mIndexType, IndexBufferOffset + Section->IndexOffset);
|
||||
}
|
||||
else if (DrawConditional)
|
||||
{
|
||||
FlushState();
|
||||
lcMatrix44 WorldViewProjectionMatrix = lcMul(mWorldMatrix, mViewProjectionMatrix);
|
||||
float* VertexBuffer = (float*)Mesh->mVertexData;
|
||||
|
||||
if (Mesh->mIndexType == GL_UNSIGNED_SHORT)
|
||||
{
|
||||
lcuint16* Indices = (lcuint16*)((char*)Mesh->mIndexData + Section->IndexOffset);
|
||||
|
||||
for (int i = 0; i < Section->NumIndices; i += 4)
|
||||
{
|
||||
lcVector3 p1 = lcMul31(lcVector3(VertexBuffer[Indices[i] * 3], VertexBuffer[Indices[i] * 3 + 1], VertexBuffer[Indices[i] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p2 = lcMul31(lcVector3(VertexBuffer[Indices[i + 1] * 3], VertexBuffer[Indices[i + 1] * 3 + 1], VertexBuffer[Indices[i + 1] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p3 = lcMul31(lcVector3(VertexBuffer[Indices[i + 2] * 3], VertexBuffer[Indices[i + 2] * 3 + 1], VertexBuffer[Indices[i + 2] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p4 = lcMul31(lcVector3(VertexBuffer[Indices[i + 3] * 3], VertexBuffer[Indices[i + 3] * 3 + 1], VertexBuffer[Indices[i + 3] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
|
||||
if (((p1.y - p2.y) * (p3.x - p1.x) + (p2.x - p1.x) * (p3.y - p1.y)) * ((p1.y - p2.y) * (p4.x - p1.x) + (p2.x - p1.x) * (p4.y - p1.y)) >= 0)
|
||||
DrawIndexedPrimitives(GL_LINES, 2, Mesh->mIndexType, IndexBufferOffset + Section->IndexOffset + i * sizeof(lcuint16));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lcuint32* Indices = (lcuint32*)((char*)Mesh->mIndexData + Section->IndexOffset);
|
||||
|
||||
for (int i = 0; i < Section->NumIndices; i += 4)
|
||||
{
|
||||
lcVector3 p1 = lcMul31(lcVector3(VertexBuffer[Indices[i] * 3], VertexBuffer[Indices[i] * 3 + 1], VertexBuffer[Indices[i] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p2 = lcMul31(lcVector3(VertexBuffer[Indices[i + 1] * 3], VertexBuffer[Indices[i + 1] * 3 + 1], VertexBuffer[Indices[i + 1] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p3 = lcMul31(lcVector3(VertexBuffer[Indices[i + 2] * 3], VertexBuffer[Indices[i + 2] * 3 + 1], VertexBuffer[Indices[i + 2] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p4 = lcMul31(lcVector3(VertexBuffer[Indices[i + 3] * 3], VertexBuffer[Indices[i + 3] * 3 + 1], VertexBuffer[Indices[i + 3] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
|
||||
if (((p1.y - p2.y) * (p3.x - p1.x) + (p2.x - p1.x) * (p3.y - p1.y)) * ((p1.y - p2.y) * (p4.x - p1.x) + (p2.x - p1.x) * (p4.y - p1.y)) >= 0)
|
||||
DrawIndexedPrimitives(GL_LINES, 2, Mesh->mIndexType, IndexBufferOffset + Section->IndexOffset + i * sizeof(lcuint32));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lcContext::DrawOpaqueMeshes(const lcArray<lcRenderMesh>& OpaqueMeshes)
|
||||
|
@ -976,7 +1019,7 @@ void lcContext::DrawOpaqueMeshes(const lcArray<lcRenderMesh>& OpaqueMeshes)
|
|||
lcMeshSection* Section = &Mesh->mLods[LodIndex].Sections[SectionIdx];
|
||||
int ColorIndex = Section->ColorIndex;
|
||||
|
||||
if (Section->PrimitiveType == GL_TRIANGLES)
|
||||
if (Section->PrimitiveType == LC_MESH_TRIANGLES || Section->PrimitiveType == LC_MESH_TEXTURED_TRIANGLES)
|
||||
{
|
||||
if (ColorIndex == gDefaultColor)
|
||||
ColorIndex = RenderMesh.ColorIndex;
|
||||
|
|
|
@ -843,6 +843,7 @@ static int LibraryMeshSectionCompare(lcMergeSection const& First, lcMergeSection
|
|||
LC_MESH_TEXTURED_TRIANGLES,
|
||||
LC_MESH_LINES,
|
||||
LC_MESH_TEXTURED_LINES,
|
||||
LC_MESH_CONDITIONAL_LINES
|
||||
};
|
||||
|
||||
for (int PrimitiveType = 0; PrimitiveType < LC_MESH_NUM_PRIMITIVE_TYPES; PrimitiveType++)
|
||||
|
@ -1071,7 +1072,7 @@ lcMesh* lcPiecesLibrary::CreateMesh(PieceInfo* Info, lcLibraryMeshData& MeshData
|
|||
lcLibraryMeshSection* SetupSection = MergeSection.Shared ? MergeSection.Shared : MergeSection.Lod;
|
||||
|
||||
DstSection.ColorIndex = SetupSection->mColor;
|
||||
DstSection.PrimitiveType = (SetupSection->mPrimitiveType == LC_MESH_TRIANGLES || SetupSection->mPrimitiveType == LC_MESH_TEXTURED_TRIANGLES) ? GL_TRIANGLES : GL_LINES;
|
||||
DstSection.PrimitiveType = SetupSection->mPrimitiveType;
|
||||
DstSection.NumIndices = 0;
|
||||
DstSection.Texture = SetupSection->mTexture;
|
||||
|
||||
|
@ -1137,7 +1138,7 @@ lcMesh* lcPiecesLibrary::CreateMesh(PieceInfo* Info, lcLibraryMeshData& MeshData
|
|||
|
||||
if (Info)
|
||||
{
|
||||
if (DstSection.PrimitiveType == GL_TRIANGLES)
|
||||
if (DstSection.PrimitiveType == LC_MESH_TRIANGLES || DstSection.PrimitiveType == LC_MESH_TEXTURED_TRIANGLES)
|
||||
{
|
||||
if (DstSection.ColorIndex == gDefaultColor)
|
||||
Info->mFlags |= LC_PIECE_HAS_DEFAULT;
|
||||
|
@ -1163,7 +1164,7 @@ lcMesh* lcPiecesLibrary::CreateMesh(PieceInfo* Info, lcLibraryMeshData& MeshData
|
|||
lcLibraryMeshSection* SrcSection = MeshData.mSections[SectionIdx];
|
||||
|
||||
DstSection.ColorIndex = SrcSection->mColor;
|
||||
DstSection.PrimitiveType = (SrcSection->mPrimitiveType == LC_MESH_TRIANGLES || SrcSection->mPrimitiveType == LC_MESH_TEXTURED_TRIANGLES) ? GL_TRIANGLES : GL_LINES;
|
||||
DstSection.PrimitiveType = SrcSection->mPrimitiveType;
|
||||
DstSection.NumIndices = SrcSection->mIndices.GetSize();
|
||||
DstSection.Texture = SrcSection->mTexture;
|
||||
|
||||
|
@ -1189,7 +1190,7 @@ lcMesh* lcPiecesLibrary::CreateMesh(PieceInfo* Info, lcLibraryMeshData& MeshData
|
|||
*Index++ = SrcSection->mIndices[IndexIdx];
|
||||
}
|
||||
|
||||
if (DstSection.PrimitiveType == GL_TRIANGLES)
|
||||
if (DstSection.PrimitiveType == LC_MESH_TRIANGLES || DstSection.PrimitiveType == LC_MESH_TEXTURED_TRIANGLES)
|
||||
{
|
||||
if (DstSection.ColorIndex == gDefaultColor)
|
||||
Info->mFlags |= LC_PIECE_HAS_DEFAULT;
|
||||
|
@ -1534,7 +1535,7 @@ bool lcPiecesLibrary::ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransf
|
|||
if (sscanf(Line, "%d %d", &LineType, &ColorCode) != 2)
|
||||
continue;
|
||||
|
||||
if (LineType < 1 || LineType > 4)
|
||||
if (LineType < 1 || LineType > 5)
|
||||
continue;
|
||||
|
||||
if (ColorCode == 0)
|
||||
|
@ -1750,6 +1751,19 @@ bool lcPiecesLibrary::ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransf
|
|||
else
|
||||
MeshData.AddLine(MeshDataType, LineType, ColorCode, Points, Optimize);
|
||||
} break;
|
||||
|
||||
case 5:
|
||||
{
|
||||
sscanf(Line, "%d %i %f %f %f %f %f %f %f %f %f %f %f %f", &LineType, &Dummy, &Points[0].x, &Points[0].y, &Points[0].z,
|
||||
&Points[1].x, &Points[1].y, &Points[1].z, &Points[2].x, &Points[2].y, &Points[2].z, &Points[3].x, &Points[3].y, &Points[3].z);
|
||||
|
||||
Points[0] = lcMul31(Points[0], CurrentTransform);
|
||||
Points[1] = lcMul31(Points[1], CurrentTransform);
|
||||
Points[2] = lcMul31(Points[2], CurrentTransform);
|
||||
Points[3] = lcMul31(Points[3], CurrentTransform);
|
||||
|
||||
MeshData.AddLine(MeshDataType, LineType, ColorCode, Points, Optimize);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1795,7 +1809,7 @@ void lcLibraryMeshData::TestQuad(int* QuadIndices, const lcVector3* Vertices)
|
|||
}
|
||||
}
|
||||
|
||||
lcLibraryMeshSection* lcLibraryMeshData::AddSection(lcMeshDataType MeshDataType, LC_MESH_PRIMITIVE_TYPE PrimitiveType, lcuint32 ColorCode, lcTexture* Texture)
|
||||
lcLibraryMeshSection* lcLibraryMeshData::AddSection(lcMeshDataType MeshDataType, lcMeshPrimitiveType PrimitiveType, lcuint32 ColorCode, lcTexture* Texture)
|
||||
{
|
||||
lcArray<lcLibraryMeshSection*>& Sections = mSections[MeshDataType];
|
||||
lcLibraryMeshSection* Section;
|
||||
|
@ -1825,7 +1839,7 @@ void lcLibraryMeshData::AddVertices(lcMeshDataType MeshDataType, int VertexCount
|
|||
*VertexBuffer = &Vertices[CurrentSize];
|
||||
}
|
||||
|
||||
void lcLibraryMeshData::AddIndices(lcMeshDataType MeshDataType, LC_MESH_PRIMITIVE_TYPE PrimitiveType, lcuint32 ColorCode, int IndexCount, lcuint32** IndexBuffer)
|
||||
void lcLibraryMeshData::AddIndices(lcMeshDataType MeshDataType, lcMeshPrimitiveType PrimitiveType, lcuint32 ColorCode, int IndexCount, lcuint32** IndexBuffer)
|
||||
{
|
||||
lcLibraryMeshSection* Section = AddSection(MeshDataType, PrimitiveType, ColorCode, NULL);
|
||||
lcArray<lcuint32>& Indices = Section->mIndices;
|
||||
|
@ -1838,7 +1852,8 @@ void lcLibraryMeshData::AddIndices(lcMeshDataType MeshDataType, LC_MESH_PRIMITIV
|
|||
|
||||
void lcLibraryMeshData::AddLine(lcMeshDataType MeshDataType, int LineType, lcuint32 ColorCode, const lcVector3* Vertices, bool Optimize)
|
||||
{
|
||||
LC_MESH_PRIMITIVE_TYPE PrimitiveType = (LineType == 2) ? LC_MESH_LINES : LC_MESH_TRIANGLES;
|
||||
lcMeshPrimitiveType PrimitiveTypes[4] = { LC_MESH_LINES, LC_MESH_TRIANGLES, LC_MESH_TRIANGLES, LC_MESH_CONDITIONAL_LINES };
|
||||
lcMeshPrimitiveType PrimitiveType = PrimitiveTypes[LineType - 2];
|
||||
lcLibraryMeshSection* Section = AddSection(MeshDataType, PrimitiveType, ColorCode, NULL);
|
||||
|
||||
int QuadIndices[4] = { 0, 1, 2, 3 };
|
||||
|
@ -1848,7 +1863,7 @@ void lcLibraryMeshData::AddLine(lcMeshDataType MeshDataType, int LineType, lcuin
|
|||
|
||||
int Indices[4] = { -1, -1, -1, -1 };
|
||||
|
||||
for (int IndexIdx = 0; IndexIdx < LineType; IndexIdx++)
|
||||
for (int IndexIdx = 0; IndexIdx < lcMin(LineType, 4); IndexIdx++)
|
||||
{
|
||||
const lcVector3& Position = Vertices[QuadIndices[IndexIdx]];
|
||||
lcArray<lcVertex>& VertexArray = mVertices[MeshDataType];
|
||||
|
@ -1877,6 +1892,16 @@ void lcLibraryMeshData::AddLine(lcMeshDataType MeshDataType, int LineType, lcuin
|
|||
|
||||
switch (LineType)
|
||||
{
|
||||
case 5:
|
||||
if (Indices[0] != Indices[1] && Indices[0] != Indices[2] && Indices[0] != Indices[3] && Indices[1] != Indices[2] && Indices[1] != Indices[3] && Indices[2] != Indices[3])
|
||||
{
|
||||
Section->mIndices.Add(Indices[0]);
|
||||
Section->mIndices.Add(Indices[1]);
|
||||
Section->mIndices.Add(Indices[2]);
|
||||
Section->mIndices.Add(Indices[3]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (Indices[0] != Indices[2] && Indices[0] != Indices[3] && Indices[2] != Indices[3])
|
||||
{
|
||||
|
@ -1893,6 +1918,7 @@ void lcLibraryMeshData::AddLine(lcMeshDataType MeshDataType, int LineType, lcuin
|
|||
Section->mIndices.Add(Indices[2]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (Indices[0] != Indices[1])
|
||||
{
|
||||
|
@ -1905,7 +1931,7 @@ void lcLibraryMeshData::AddLine(lcMeshDataType MeshDataType, int LineType, lcuin
|
|||
|
||||
void lcLibraryMeshData::AddTexturedLine(lcMeshDataType MeshDataType, int LineType, lcuint32 ColorCode, const lcLibraryTextureMap& Map, const lcVector3* Vertices, bool Optimize)
|
||||
{
|
||||
LC_MESH_PRIMITIVE_TYPE PrimitiveType = (LineType == 2) ? LC_MESH_TEXTURED_LINES : LC_MESH_TEXTURED_TRIANGLES;
|
||||
lcMeshPrimitiveType PrimitiveType = (LineType == 2) ? LC_MESH_TEXTURED_LINES : LC_MESH_TEXTURED_TRIANGLES;
|
||||
lcLibraryMeshSection* Section = AddSection(MeshDataType, PrimitiveType, ColorCode, Map.Texture);
|
||||
|
||||
int QuadIndices[4] = { 0, 1, 2, 3 };
|
||||
|
|
|
@ -10,15 +10,6 @@
|
|||
class PieceInfo;
|
||||
class lcZipFile;
|
||||
|
||||
enum LC_MESH_PRIMITIVE_TYPE
|
||||
{
|
||||
LC_MESH_LINES,
|
||||
LC_MESH_TRIANGLES,
|
||||
LC_MESH_TEXTURED_LINES,
|
||||
LC_MESH_TEXTURED_TRIANGLES,
|
||||
LC_MESH_NUM_PRIMITIVE_TYPES
|
||||
};
|
||||
|
||||
enum lcZipFileType
|
||||
{
|
||||
LC_ZIPFILE_OFFICIAL,
|
||||
|
@ -29,7 +20,7 @@ enum lcZipFileType
|
|||
class lcLibraryMeshSection
|
||||
{
|
||||
public:
|
||||
lcLibraryMeshSection(LC_MESH_PRIMITIVE_TYPE PrimitiveType, lcuint32 Color, lcTexture* Texture)
|
||||
lcLibraryMeshSection(lcMeshPrimitiveType PrimitiveType, lcuint32 Color, lcTexture* Texture)
|
||||
: mIndices(1024, 1024)
|
||||
{
|
||||
mPrimitiveType = PrimitiveType;
|
||||
|
@ -41,7 +32,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
LC_MESH_PRIMITIVE_TYPE mPrimitiveType;
|
||||
lcMeshPrimitiveType mPrimitiveType;
|
||||
lcuint32 mColor;
|
||||
lcTexture* mTexture;
|
||||
lcArray<lcuint32> mIndices;
|
||||
|
@ -78,9 +69,9 @@ public:
|
|||
mSections[MeshDataIdx].DeleteAll();
|
||||
}
|
||||
|
||||
lcLibraryMeshSection* AddSection(lcMeshDataType MeshDataType, LC_MESH_PRIMITIVE_TYPE PrimitiveType, lcuint32 ColorCode, lcTexture* Texture);
|
||||
lcLibraryMeshSection* AddSection(lcMeshDataType MeshDataType, lcMeshPrimitiveType PrimitiveType, lcuint32 ColorCode, lcTexture* Texture);
|
||||
void AddVertices(lcMeshDataType MeshDataType, int VertexCount, int* BaseVertex, lcVertex** VertexBuffer);
|
||||
void AddIndices(lcMeshDataType MeshDataType, LC_MESH_PRIMITIVE_TYPE PrimitiveType, lcuint32 ColorCode, int IndexCount, lcuint32** IndexBuffer);
|
||||
void AddIndices(lcMeshDataType MeshDataType, lcMeshPrimitiveType PrimitiveType, lcuint32 ColorCode, int IndexCount, lcuint32** IndexBuffer);
|
||||
void AddLine(lcMeshDataType MeshDataType, int LineType, lcuint32 ColorCode, const lcVector3* Vertices, bool Optimize);
|
||||
void AddTexturedLine(lcMeshDataType MeshDataType, int LineType, lcuint32 ColorCode, const lcLibraryTextureMap& Map, const lcVector3* Vertices, bool Optimize);
|
||||
void AddMeshData(const lcLibraryMeshData& Data, const lcMatrix44& Transform, lcuint32 CurrentColorCode, lcLibraryTextureMap* TextureMap, lcMeshDataType OverrideDestIndex);
|
||||
|
|
|
@ -94,7 +94,7 @@ void lcMesh::CreateBox()
|
|||
Section->ColorIndex = gDefaultColor;
|
||||
Section->IndexOffset = 0;
|
||||
Section->NumIndices = 36;
|
||||
Section->PrimitiveType = GL_TRIANGLES;
|
||||
Section->PrimitiveType = LC_MESH_TRIANGLES;
|
||||
Section->Texture = NULL;
|
||||
|
||||
*Indices++ = 0; *Indices++ = 1; *Indices++ = 2;
|
||||
|
@ -119,7 +119,7 @@ void lcMesh::CreateBox()
|
|||
Section->ColorIndex = gEdgeColor;
|
||||
Section->IndexOffset = 36 * 2;
|
||||
Section->NumIndices = 24;
|
||||
Section->PrimitiveType = GL_LINES;
|
||||
Section->PrimitiveType = LC_MESH_LINES;
|
||||
Section->Texture = NULL;
|
||||
|
||||
*Indices++ = 0; *Indices++ = 1; *Indices++ = 1; *Indices++ = 2;
|
||||
|
@ -147,7 +147,7 @@ bool lcMesh::MinIntersectDist(const lcVector3& Start, const lcVector3& End, floa
|
|||
{
|
||||
lcMeshSection* Section = &mLods[LC_MESH_LOD_HIGH].Sections[SectionIdx];
|
||||
|
||||
if (Section->PrimitiveType != GL_TRIANGLES)
|
||||
if (Section->PrimitiveType != LC_MESH_TRIANGLES && Section->PrimitiveType != LC_MESH_TEXTURED_TRIANGLES)
|
||||
continue;
|
||||
|
||||
IndexType* Indices = (IndexType*)mIndexData + Section->IndexOffset / sizeof(IndexType);
|
||||
|
@ -186,7 +186,7 @@ bool lcMesh::IntersectsPlanes(const lcVector4 Planes[6])
|
|||
{
|
||||
lcMeshSection* Section = &mLods[LC_MESH_LOD_HIGH].Sections[SectionIdx];
|
||||
|
||||
if (Section->PrimitiveType != GL_TRIANGLES)
|
||||
if (Section->PrimitiveType != LC_MESH_TRIANGLES && Section->PrimitiveType != LC_MESH_TEXTURED_TRIANGLES)
|
||||
continue;
|
||||
|
||||
IndexType* Indices = (IndexType*)mIndexData + Section->IndexOffset / sizeof(IndexType);
|
||||
|
@ -221,7 +221,7 @@ void lcMesh::ExportPOVRay(lcFile& File, const char* MeshName, const char* ColorT
|
|||
{
|
||||
lcMeshSection* Section = &mLods[LC_MESH_LOD_HIGH].Sections[SectionIdx];
|
||||
|
||||
if (Section->PrimitiveType != GL_TRIANGLES)
|
||||
if (Section->PrimitiveType != LC_MESH_TRIANGLES && Section->PrimitiveType != LC_MESH_TEXTURED_TRIANGLES)
|
||||
continue;
|
||||
|
||||
IndexType* Indices = (IndexType*)mIndexData + Section->IndexOffset / sizeof(IndexType);
|
||||
|
@ -264,7 +264,7 @@ void lcMesh::ExportWavefrontIndices(lcFile& File, int DefaultColorIndex, int Ver
|
|||
{
|
||||
lcMeshSection* Section = &mLods[LC_MESH_LOD_HIGH].Sections[SectionIdx];
|
||||
|
||||
if (Section->PrimitiveType != GL_TRIANGLES)
|
||||
if (Section->PrimitiveType != LC_MESH_TRIANGLES && Section->PrimitiveType != LC_MESH_TEXTURED_TRIANGLES)
|
||||
continue;
|
||||
|
||||
IndexType* Indices = (IndexType*)mIndexData + Section->IndexOffset / sizeof(IndexType);
|
||||
|
@ -325,15 +325,15 @@ bool lcMesh::FileLoad(lcMemFile& File)
|
|||
lcMeshSection& Section = mLods[LodIdx].Sections[SectionIdx];
|
||||
|
||||
lcuint32 ColorCode, IndexOffset;
|
||||
lcuint16 Triangles, Length;
|
||||
lcuint16 PrimtiveType, Length;
|
||||
|
||||
if (!File.ReadU32(&ColorCode, 1) || !File.ReadU32(&IndexOffset, 1) || !File.ReadU32(&NumIndices, 1) || !File.ReadU16(&Triangles, 1))
|
||||
if (!File.ReadU32(&ColorCode, 1) || !File.ReadU32(&IndexOffset, 1) || !File.ReadU32(&NumIndices, 1) || !File.ReadU16(&PrimtiveType, 1))
|
||||
return false;
|
||||
|
||||
Section.ColorIndex = lcGetColorIndex(ColorCode);
|
||||
Section.IndexOffset = IndexOffset;
|
||||
Section.NumIndices = NumIndices;
|
||||
Section.PrimitiveType = Triangles ? GL_TRIANGLES : GL_LINES;
|
||||
Section.PrimitiveType = (lcMeshPrimitiveType)PrimtiveType;
|
||||
|
||||
if (!File.ReadU16(&Length, 1))
|
||||
return false;
|
||||
|
@ -390,7 +390,7 @@ bool lcMesh::FileSave(lcMemFile& File)
|
|||
File.WriteU32(lcGetColorCode(Section.ColorIndex));
|
||||
File.WriteU32(Section.IndexOffset);
|
||||
File.WriteU32(Section.NumIndices);
|
||||
File.WriteU16(Section.PrimitiveType == GL_TRIANGLES ? 1 : 0);
|
||||
File.WriteU16(Section.PrimitiveType);
|
||||
|
||||
if (Section.Texture)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,17 @@
|
|||
#include "lc_math.h"
|
||||
|
||||
#define LC_MESH_FILE_ID LC_FOURCC('M', 'E', 'S', 'H')
|
||||
#define LC_MESH_FILE_VERSION 0x0110
|
||||
#define LC_MESH_FILE_VERSION 0x0111
|
||||
|
||||
enum lcMeshPrimitiveType
|
||||
{
|
||||
LC_MESH_LINES,
|
||||
LC_MESH_TRIANGLES,
|
||||
LC_MESH_TEXTURED_LINES,
|
||||
LC_MESH_TEXTURED_TRIANGLES,
|
||||
LC_MESH_CONDITIONAL_LINES,
|
||||
LC_MESH_NUM_PRIMITIVE_TYPES
|
||||
};
|
||||
|
||||
struct lcVertex
|
||||
{
|
||||
|
@ -22,7 +32,7 @@ struct lcMeshSection
|
|||
int ColorIndex;
|
||||
int IndexOffset;
|
||||
int NumIndices;
|
||||
int PrimitiveType;
|
||||
lcMeshPrimitiveType PrimitiveType;
|
||||
lcTexture* Texture;
|
||||
};
|
||||
|
||||
|
|
|
@ -779,7 +779,7 @@ void Project::Export3DStudio(const QString& FileName)
|
|||
{
|
||||
lcMeshSection* Section = &Mesh->mLods[LC_MESH_LOD_HIGH].Sections[SectionIdx];
|
||||
|
||||
if (Section->PrimitiveType != GL_TRIANGLES)
|
||||
if (Section->PrimitiveType != LC_MESH_TRIANGLES && Section->PrimitiveType != LC_MESH_TEXTURED_TRIANGLES)
|
||||
continue;
|
||||
|
||||
NumTriangles += Section->NumIndices / 3;
|
||||
|
@ -791,7 +791,7 @@ void Project::Export3DStudio(const QString& FileName)
|
|||
{
|
||||
lcMeshSection* Section = &Mesh->mLods[LC_MESH_LOD_HIGH].Sections[SectionIdx];
|
||||
|
||||
if (Section->PrimitiveType != GL_TRIANGLES)
|
||||
if (Section->PrimitiveType != LC_MESH_TRIANGLES && Section->PrimitiveType != LC_MESH_TEXTURED_TRIANGLES)
|
||||
continue;
|
||||
|
||||
lcuint16* Indices = (lcuint16*)Mesh->mIndexData + Section->IndexOffset / sizeof(lcuint16);
|
||||
|
@ -811,7 +811,7 @@ void Project::Export3DStudio(const QString& FileName)
|
|||
{
|
||||
lcMeshSection* Section = &Mesh->mLods[LC_MESH_LOD_HIGH].Sections[SectionIdx];
|
||||
|
||||
if (Section->PrimitiveType != GL_TRIANGLES)
|
||||
if (Section->PrimitiveType != LC_MESH_TRIANGLES && Section->PrimitiveType != LC_MESH_TEXTURED_TRIANGLES)
|
||||
continue;
|
||||
|
||||
int MaterialIndex = Section->ColorIndex == gDefaultColor ? ModelParts[PartIdx].ColorIndex : Section->ColorIndex;
|
||||
|
|
Loading…
Add table
Reference in a new issue