mirror of
https://github.com/leozide/leocad
synced 2024-12-27 21:58:37 +01:00
Support exporting flexible parts. Fixes #157.
This commit is contained in:
parent
602dfeb8b6
commit
3070d25663
9 changed files with 149 additions and 104 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#ifndef Q_FALLTHROUGH
|
#ifndef Q_FALLTHROUGH
|
||||||
#define Q_FALLTHROUGH(); // fall through
|
#define Q_FALLTHROUGH(); // fall through
|
||||||
|
|
|
@ -3124,17 +3124,7 @@ void lcModel::GetPartsListForStep(lcStep Step, int DefaultColorIndex, lcPartsLis
|
||||||
void lcModel::GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcArray<lcModelPartsEntry>& ModelParts) const
|
void lcModel::GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcArray<lcModelPartsEntry>& ModelParts) const
|
||||||
{
|
{
|
||||||
for (lcPiece* Piece : mPieces)
|
for (lcPiece* Piece : mPieces)
|
||||||
{
|
Piece->GetModelParts(WorldMatrix, DefaultColorIndex, ModelParts);
|
||||||
if (!Piece->IsVisibleInSubModel())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int ColorIndex = Piece->mColorIndex;
|
|
||||||
|
|
||||||
if (ColorIndex == gDefaultColor)
|
|
||||||
ColorIndex = DefaultColorIndex;
|
|
||||||
|
|
||||||
Piece->mPieceInfo->GetModelParts(lcMul(Piece->mModelWorld, WorldMatrix), ColorIndex, ModelParts);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::GetSelectionInformation(int* Flags, lcArray<lcObject*>& Selection, lcObject** Focus) const
|
void lcModel::GetSelectionInformation(int* Flags, lcArray<lcObject*>& Selection, lcObject** Focus) const
|
||||||
|
|
|
@ -91,13 +91,6 @@ struct lcModelHistoryEntry
|
||||||
QString Description;
|
QString Description;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lcModelPartsEntry
|
|
||||||
{
|
|
||||||
lcMatrix44 WorldMatrix;
|
|
||||||
PieceInfo* Info;
|
|
||||||
int ColorIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
class lcModel
|
class lcModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -863,6 +863,28 @@ bool lcPiece::IsVisibleInSubModel() const
|
||||||
return (mStepHide == LC_STEP_MAX) && !(mState & LC_PIECE_HIDDEN);
|
return (mStepHide == LC_STEP_MAX) && !(mState & LC_PIECE_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcPiece::GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcArray<lcModelPartsEntry>& ModelParts) const
|
||||||
|
{
|
||||||
|
if (!IsVisibleInSubModel())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int ColorIndex = mColorIndex;
|
||||||
|
|
||||||
|
if (ColorIndex == gDefaultColor)
|
||||||
|
ColorIndex = DefaultColorIndex;
|
||||||
|
|
||||||
|
if (!mMesh)
|
||||||
|
mPieceInfo->GetModelParts(lcMul(mModelWorld, WorldMatrix), ColorIndex, ModelParts);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lcModelPartsEntry& ModelPartsEntry = ModelParts.Add();
|
||||||
|
ModelPartsEntry.WorldMatrix = WorldMatrix;
|
||||||
|
ModelPartsEntry.ColorIndex = DefaultColorIndex;
|
||||||
|
ModelPartsEntry.Info = const_cast<PieceInfo*>(mPieceInfo);
|
||||||
|
ModelPartsEntry.Mesh = mMesh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const lcBoundingBox& lcPiece::GetBoundingBox() const
|
const lcBoundingBox& lcPiece::GetBoundingBox() const
|
||||||
{
|
{
|
||||||
if (!mMesh)
|
if (!mMesh)
|
||||||
|
|
|
@ -396,6 +396,7 @@ public:
|
||||||
const char* GetName() const override;
|
const char* GetName() const override;
|
||||||
bool IsVisible(lcStep Step) const;
|
bool IsVisible(lcStep Step) const;
|
||||||
bool IsVisibleInSubModel() const;
|
bool IsVisibleInSubModel() const;
|
||||||
|
void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcArray<lcModelPartsEntry>& ModelParts) const;
|
||||||
void Initialize(const lcMatrix44& WorldMatrix, lcStep Step);
|
void Initialize(const lcMatrix44& WorldMatrix, lcStep Step);
|
||||||
const lcBoundingBox& GetBoundingBox() const;
|
const lcBoundingBox& GetBoundingBox() const;
|
||||||
void CompareBoundingBox(lcVector3& Min, lcVector3& Max) const;
|
void CompareBoundingBox(lcVector3& Min, lcVector3& Max) const;
|
||||||
|
|
|
@ -354,6 +354,7 @@ void PieceInfo::GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorInd
|
||||||
ModelPartsEntry.WorldMatrix = WorldMatrix;
|
ModelPartsEntry.WorldMatrix = WorldMatrix;
|
||||||
ModelPartsEntry.ColorIndex = DefaultColorIndex;
|
ModelPartsEntry.ColorIndex = DefaultColorIndex;
|
||||||
ModelPartsEntry.Info = const_cast<PieceInfo*>(this);
|
ModelPartsEntry.Info = const_cast<PieceInfo*>(this);
|
||||||
|
ModelPartsEntry.Mesh = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PieceInfo::UpdateBoundingBox(std::vector<lcModel*>& UpdatedModels)
|
void PieceInfo::UpdateBoundingBox(std::vector<lcModel*>& UpdatedModels)
|
||||||
|
|
|
@ -22,6 +22,14 @@ enum lcPieceInfoState
|
||||||
LC_PIECEINFO_LOADED
|
LC_PIECEINFO_LOADED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct lcModelPartsEntry
|
||||||
|
{
|
||||||
|
lcMatrix44 WorldMatrix;
|
||||||
|
PieceInfo* Info;
|
||||||
|
lcMesh* Mesh;
|
||||||
|
int ColorIndex;
|
||||||
|
};
|
||||||
|
|
||||||
class lcSynthInfo;
|
class lcSynthInfo;
|
||||||
|
|
||||||
class PieceInfo
|
class PieceInfo
|
||||||
|
|
|
@ -615,8 +615,8 @@ void Project::GetModelParts(lcArray<lcModelPartsEntry>& ModelParts)
|
||||||
if (mModels.IsEmpty())
|
if (mModels.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int ModelIdx = 0; ModelIdx < mModels.GetSize(); ModelIdx++)
|
for (lcModel* Model : mModels)
|
||||||
mModels[ModelIdx]->CalculateStep(LC_STEP_MAX);
|
Model->CalculateStep(LC_STEP_MAX);
|
||||||
|
|
||||||
mModels[0]->GetModelParts(lcMatrix44Identity(), gDefaultColor, ModelParts);
|
mModels[0]->GetModelParts(lcMatrix44Identity(), gDefaultColor, ModelParts);
|
||||||
|
|
||||||
|
@ -958,10 +958,9 @@ void Project::Export3DStudio(const QString& FileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
int NumPieces = 0;
|
int NumPieces = 0;
|
||||||
for (int PartIdx = 0; PartIdx < ModelParts.GetSize(); PartIdx++)
|
for (const lcModelPartsEntry& ModelPart : ModelParts)
|
||||||
{
|
{
|
||||||
PieceInfo* Info = ModelParts[PartIdx].Info;
|
lcMesh* Mesh = !ModelPart.Mesh ? ModelPart.Info->GetMesh() : ModelPart.Mesh;
|
||||||
lcMesh* Mesh = Info->GetMesh();
|
|
||||||
|
|
||||||
if (!Mesh || Mesh->mIndexType == GL_UNSIGNED_INT)
|
if (!Mesh || Mesh->mIndexType == GL_UNSIGNED_INT)
|
||||||
continue;
|
continue;
|
||||||
|
@ -985,7 +984,7 @@ void Project::Export3DStudio(const QString& FileName)
|
||||||
File.WriteU16(Mesh->mNumVertices);
|
File.WriteU16(Mesh->mNumVertices);
|
||||||
|
|
||||||
lcVertex* Verts = (lcVertex*)Mesh->mVertexData;
|
lcVertex* Verts = (lcVertex*)Mesh->mVertexData;
|
||||||
const lcMatrix44& ModelWorld = ModelParts[PartIdx].WorldMatrix;
|
const lcMatrix44& ModelWorld = ModelPart.WorldMatrix;
|
||||||
|
|
||||||
for (int VertexIdx = 0; VertexIdx < Mesh->mNumVertices; VertexIdx++)
|
for (int VertexIdx = 0; VertexIdx < Mesh->mNumVertices; VertexIdx++)
|
||||||
{
|
{
|
||||||
|
@ -1054,7 +1053,7 @@ void Project::Export3DStudio(const QString& FileName)
|
||||||
if (Section->PrimitiveType != LC_MESH_TRIANGLES && Section->PrimitiveType != LC_MESH_TEXTURED_TRIANGLES)
|
if (Section->PrimitiveType != LC_MESH_TRIANGLES && Section->PrimitiveType != LC_MESH_TEXTURED_TRIANGLES)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int MaterialIndex = Section->ColorIndex == gDefaultColor ? ModelParts[PartIdx].ColorIndex : Section->ColorIndex;
|
int MaterialIndex = Section->ColorIndex == gDefaultColor ? ModelPart.ColorIndex : Section->ColorIndex;
|
||||||
|
|
||||||
File.WriteU16(0x4130); // CHK_MSH_MAT_GROUP
|
File.WriteU16(0x4130); // CHK_MSH_MAT_GROUP
|
||||||
File.WriteU32(6 + MaterialNameLength + 1 + 2 + 2 * Section->NumIndices / 3);
|
File.WriteU32(6 + MaterialNameLength + 1 + 2 + 2 * Section->NumIndices / 3);
|
||||||
|
@ -1266,18 +1265,27 @@ void Project::ExportCOLLADA(const QString& FileName)
|
||||||
|
|
||||||
Stream << "</library_materials>\r\n";
|
Stream << "</library_materials>\r\n";
|
||||||
Stream << "<library_geometries>\r\n";
|
Stream << "<library_geometries>\r\n";
|
||||||
QSet<PieceInfo*> AddedPieces;
|
std::set<lcMesh*> AddedMeshes;
|
||||||
|
|
||||||
for (const lcModelPartsEntry& Entry : ModelParts)
|
auto GetMeshID = [](const lcModelPartsEntry& ModelPart)
|
||||||
{
|
{
|
||||||
PieceInfo* Info = Entry.Info;
|
PieceInfo* Info = ModelPart.Info;
|
||||||
|
|
||||||
if (AddedPieces.contains(Info))
|
|
||||||
continue;
|
|
||||||
AddedPieces.insert(Info);
|
|
||||||
|
|
||||||
QString ID = QString(Info->mFileName).replace('.', '_');
|
QString ID = QString(Info->mFileName).replace('.', '_');
|
||||||
lcMesh* Mesh = Info->GetMesh();
|
|
||||||
|
if (ModelPart.Mesh)
|
||||||
|
ID += "_" + QString::number((quintptr)ModelPart.Mesh, 16);
|
||||||
|
|
||||||
|
return ID;
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const lcModelPartsEntry& ModelPart : ModelParts)
|
||||||
|
{
|
||||||
|
lcMesh* Mesh = !ModelPart.Mesh ? ModelPart.Info->GetMesh() : ModelPart.Mesh;
|
||||||
|
|
||||||
|
if (!AddedMeshes.insert(Mesh).second)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QString ID = GetMeshID(ModelPart);
|
||||||
|
|
||||||
if (!Mesh)
|
if (!Mesh)
|
||||||
Mesh = gPlaceholderMesh;
|
Mesh = gPlaceholderMesh;
|
||||||
|
@ -1387,15 +1395,14 @@ void Project::ExportCOLLADA(const QString& FileName)
|
||||||
Stream << "<library_visual_scenes>\r\n";
|
Stream << "<library_visual_scenes>\r\n";
|
||||||
Stream << "\t<visual_scene id=\"DefaultScene\">\r\n";
|
Stream << "\t<visual_scene id=\"DefaultScene\">\r\n";
|
||||||
|
|
||||||
for (const lcModelPartsEntry& Entry : ModelParts)
|
for (const lcModelPartsEntry& ModelPart : ModelParts)
|
||||||
{
|
{
|
||||||
PieceInfo* Info = Entry.Info;
|
QString ID = GetMeshID(ModelPart);
|
||||||
QString ID = QString(Info->mFileName).replace('.', '_');
|
|
||||||
|
|
||||||
Stream << "\t\t<node>\r\n";
|
Stream << "\t\t<node>\r\n";
|
||||||
Stream << "\t\t\t<matrix>\r\n";
|
Stream << "\t\t\t<matrix>\r\n";
|
||||||
|
|
||||||
const lcMatrix44& Matrix = Entry.WorldMatrix;
|
const lcMatrix44& Matrix = ModelPart.WorldMatrix;
|
||||||
Stream << QString("\t\t\t\t%1 %2 %3 %4\r\n").arg(QString::number(Matrix[0][0]), QString::number(Matrix[1][0]), QString::number(Matrix[2][0]), QString::number(Matrix[3][0]));
|
Stream << QString("\t\t\t\t%1 %2 %3 %4\r\n").arg(QString::number(Matrix[0][0]), QString::number(Matrix[1][0]), QString::number(Matrix[2][0]), QString::number(Matrix[3][0]));
|
||||||
Stream << QString("\t\t\t\t%1 %2 %3 %4\r\n").arg(QString::number(Matrix[0][1]), QString::number(Matrix[1][1]), QString::number(Matrix[2][1]), QString::number(Matrix[3][1]));
|
Stream << QString("\t\t\t\t%1 %2 %3 %4\r\n").arg(QString::number(Matrix[0][1]), QString::number(Matrix[1][1]), QString::number(Matrix[2][1]), QString::number(Matrix[3][1]));
|
||||||
Stream << QString("\t\t\t\t%1 %2 %3 %4\r\n").arg(QString::number(Matrix[0][2]), QString::number(Matrix[1][2]), QString::number(Matrix[2][2]), QString::number(Matrix[3][2]));
|
Stream << QString("\t\t\t\t%1 %2 %3 %4\r\n").arg(QString::number(Matrix[0][2]), QString::number(Matrix[1][2]), QString::number(Matrix[2][2]), QString::number(Matrix[3][2]));
|
||||||
|
@ -1406,7 +1413,7 @@ void Project::ExportCOLLADA(const QString& FileName)
|
||||||
Stream << "\t\t\t\t<bind_material>\r\n";
|
Stream << "\t\t\t\t<bind_material>\r\n";
|
||||||
Stream << "\t\t\t\t\t<technique_common>\r\n";
|
Stream << "\t\t\t\t\t<technique_common>\r\n";
|
||||||
|
|
||||||
lcMesh* Mesh = Info->GetMesh();
|
lcMesh* Mesh = !ModelPart.Mesh ? ModelPart.Info->GetMesh() : ModelPart.Mesh;
|
||||||
|
|
||||||
if (!Mesh)
|
if (!Mesh)
|
||||||
Mesh = gPlaceholderMesh;
|
Mesh = gPlaceholderMesh;
|
||||||
|
@ -1421,7 +1428,7 @@ void Project::ExportCOLLADA(const QString& FileName)
|
||||||
const char* SourceColorName = gColorList[Section->ColorIndex].SafeName;
|
const char* SourceColorName = gColorList[Section->ColorIndex].SafeName;
|
||||||
const char* TargetColorName;
|
const char* TargetColorName;
|
||||||
if (Section->ColorIndex == gDefaultColor)
|
if (Section->ColorIndex == gDefaultColor)
|
||||||
TargetColorName = gColorList[Entry.ColorIndex].SafeName;
|
TargetColorName = gColorList[ModelPart.ColorIndex].SafeName;
|
||||||
else
|
else
|
||||||
TargetColorName = gColorList[Section->ColorIndex].SafeName;
|
TargetColorName = gColorList[Section->ColorIndex].SafeName;
|
||||||
|
|
||||||
|
@ -2155,26 +2162,29 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<lcMesh*> AddedMeshes;
|
||||||
|
|
||||||
if (!LGEOPath.isEmpty())
|
if (!LGEOPath.isEmpty())
|
||||||
{
|
{
|
||||||
POVFile.WriteLine("#include \"lg_defs.inc\"\n#include \"lg_color.inc\"\n\n");
|
POVFile.WriteLine("#include \"lg_defs.inc\"\n#include \"lg_color.inc\"\n\n");
|
||||||
|
|
||||||
for (int PartIdx = 0; PartIdx < ModelParts.GetSize(); PartIdx++)
|
for (const lcModelPartsEntry& ModelPart : ModelParts)
|
||||||
{
|
{
|
||||||
PieceInfo* Info = ModelParts[PartIdx].Info;
|
if (ModelPart.Mesh)
|
||||||
|
|
||||||
for (int CheckIdx = 0; CheckIdx < ModelParts.GetSize(); CheckIdx++)
|
|
||||||
{
|
|
||||||
if (ModelParts[CheckIdx].Info != Info)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (CheckIdx != PartIdx)
|
auto Search = PieceTable.find(ModelPart.Info);
|
||||||
break;
|
if (Search == PieceTable.end())
|
||||||
|
continue;
|
||||||
|
|
||||||
auto Search = PieceTable.find(Info);
|
lcMesh* Mesh = ModelPart.Info->GetMesh();
|
||||||
|
|
||||||
|
if (!Mesh)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!AddedMeshes.insert(Mesh).second)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (Search != PieceTable.end())
|
|
||||||
{
|
|
||||||
const std::pair<char[LC_PIECE_NAME_LEN], int>& Entry = Search->second;
|
const std::pair<char[LC_PIECE_NAME_LEN], int>& Entry = Search->second;
|
||||||
if (Entry.first[0])
|
if (Entry.first[0])
|
||||||
{
|
{
|
||||||
|
@ -2183,10 +2193,6 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
POVFile.WriteLine("\n");
|
POVFile.WriteLine("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2218,25 +2224,40 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||||
for (int ColorIdx = 0; ColorIdx < NumColors; ColorIdx++)
|
for (int ColorIdx = 0; ColorIdx < NumColors; ColorIdx++)
|
||||||
ColorTablePointer[ColorIdx] = ColorTable[ColorIdx].data();
|
ColorTablePointer[ColorIdx] = ColorTable[ColorIdx].data();
|
||||||
|
|
||||||
for (int PartIdx = 0; PartIdx < ModelParts.GetSize(); PartIdx++)
|
auto GetMeshName = [](const lcModelPartsEntry& ModelPart, char* Name)
|
||||||
{
|
{
|
||||||
PieceInfo* Info = ModelParts[PartIdx].Info;
|
strcpy(Name, ModelPart.Info->mFileName);
|
||||||
lcMesh* Mesh = Info->GetMesh();
|
|
||||||
std::pair<char[LC_PIECE_NAME_LEN], int>& Entry = PieceTable[Info];
|
|
||||||
|
|
||||||
if (!Mesh || Entry.first[0])
|
for (char* c = Name; *c; c++)
|
||||||
|
if (*c == '-' || *c == '.')
|
||||||
|
*c = '_';
|
||||||
|
|
||||||
|
if (ModelPart.Mesh)
|
||||||
|
{
|
||||||
|
char Suffix[32];
|
||||||
|
sprintf(Suffix, "_%p", ModelPart.Mesh);
|
||||||
|
strcat(Name, Suffix);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const lcModelPartsEntry& ModelPart : ModelParts)
|
||||||
|
{
|
||||||
|
lcMesh* Mesh = !ModelPart.Mesh ? ModelPart.Info->GetMesh() : ModelPart.Mesh;
|
||||||
|
|
||||||
|
if (!AddedMeshes.insert(Mesh).second)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!Mesh)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
char Name[LC_PIECE_NAME_LEN];
|
char Name[LC_PIECE_NAME_LEN];
|
||||||
char* Ptr;
|
GetMeshName(ModelPart, Name);
|
||||||
|
|
||||||
strcpy(Name, Info->mFileName);
|
|
||||||
while ((Ptr = strchr(Name, '-')))
|
|
||||||
*Ptr = '_';
|
|
||||||
while ((Ptr = strchr(Name, '.')))
|
|
||||||
*Ptr = '_';
|
|
||||||
|
|
||||||
|
if (!ModelPart.Mesh)
|
||||||
|
{
|
||||||
|
std::pair<char[LC_PIECE_NAME_LEN], int>& Entry = PieceTable[ModelPart.Info];
|
||||||
sprintf(Entry.first, "lc_%s", Name);
|
sprintf(Entry.first, "lc_%s", Name);
|
||||||
|
}
|
||||||
|
|
||||||
Mesh->ExportPOVRay(POVFile, Name, &ColorTablePointer[0]);
|
Mesh->ExportPOVRay(POVFile, Name, &ColorTablePointer[0]);
|
||||||
|
|
||||||
|
@ -2287,16 +2308,15 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||||
sprintf(Line, "light_source{ <%f, %f, %f>\n color rgb 0.5\n area_light 200, 200, 10, 10\n jitter\n}\n\n", 2.0f * Radius + Center.x, 0.0f * Radius + Center.y, -2.0f * Radius + Center.z);
|
sprintf(Line, "light_source{ <%f, %f, %f>\n color rgb 0.5\n area_light 200, 200, 10, 10\n jitter\n}\n\n", 2.0f * Radius + Center.x, 0.0f * Radius + Center.y, -2.0f * Radius + Center.z);
|
||||||
POVFile.WriteLine(Line);
|
POVFile.WriteLine(Line);
|
||||||
|
|
||||||
for (int PartIdx = 0; PartIdx < ModelParts.GetSize(); PartIdx++)
|
for (const lcModelPartsEntry& ModelPart : ModelParts)
|
||||||
{
|
{
|
||||||
PieceInfo* Info = ModelParts[PartIdx].Info;
|
int Color = ModelPart.ColorIndex;
|
||||||
std::pair<char[LC_PIECE_NAME_LEN], int>& Entry = PieceTable[Info];
|
|
||||||
int Color;
|
|
||||||
|
|
||||||
Color = ModelParts[PartIdx].ColorIndex;
|
|
||||||
const char* Suffix = lcIsColorTranslucent(Color) ? "_clear" : "";
|
const char* Suffix = lcIsColorTranslucent(Color) ? "_clear" : "";
|
||||||
|
const float* f = ModelPart.WorldMatrix;
|
||||||
|
|
||||||
const float* f = ModelParts[PartIdx].WorldMatrix;
|
if (!ModelPart.Mesh)
|
||||||
|
{
|
||||||
|
std::pair<char[LC_PIECE_NAME_LEN], int>& Entry = PieceTable[ModelPart.Info];
|
||||||
|
|
||||||
if (Entry.second & LGEO_PIECE_SLOPE)
|
if (Entry.second & LGEO_PIECE_SLOPE)
|
||||||
{
|
{
|
||||||
|
@ -2308,11 +2328,21 @@ bool Project::ExportPOVRay(const QString& FileName)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!Info || !Info->GetMesh())
|
if (!ModelPart.Info || !ModelPart.Info->GetMesh())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sprintf(Line, "object {\n %s%s\n texture { %s }\n matrix <%.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f>\n}\n",
|
sprintf(Line, "object {\n %s%s\n texture { %s }\n matrix <%.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f>\n}\n",
|
||||||
Entry.first, Suffix, ColorTable[Color].data(), -f[5], -f[4], -f[6], -f[1], -f[0], -f[2], f[9], f[8], f[10], f[13] / 25.0f, f[12] / 25.0f, f[14] / 25.0f);
|
Entry.first, Suffix, ColorTable[Color].data(), -f[5], -f[4], -f[6], -f[1], -f[0], -f[2], f[9], f[8], f[10], f[13] / 25.0f, f[12] / 25.0f, f[14] / 25.0f);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char Name[LC_PIECE_NAME_LEN];
|
||||||
|
GetMeshName(ModelPart, Name);
|
||||||
|
|
||||||
|
sprintf(Line, "object {\n lc_%s%s\n texture { %s }\n matrix <%.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f>\n}\n",
|
||||||
|
Name, Suffix, ColorTable[Color].data(), -f[5], -f[4], -f[6], -f[1], -f[0], -f[2], f[9], f[8], f[10], f[13] / 25.0f, f[12] / 25.0f, f[14] / 25.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
POVFile.WriteLine(Line);
|
POVFile.WriteLine(Line);
|
||||||
|
@ -2377,14 +2407,14 @@ void Project::ExportWavefront(const QString& FileName)
|
||||||
MaterialFile.WriteLine(Line);
|
MaterialFile.WriteLine(Line);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int PartIdx = 0; PartIdx < ModelParts.GetSize(); PartIdx++)
|
for (const lcModelPartsEntry& ModelPart : ModelParts)
|
||||||
{
|
{
|
||||||
lcMesh* Mesh = ModelParts[PartIdx].Info->GetMesh();
|
lcMesh* Mesh = !ModelPart.Mesh ? ModelPart.Info->GetMesh() : ModelPart.Mesh;
|
||||||
|
|
||||||
if (!Mesh)
|
if (!Mesh)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const lcMatrix44& ModelWorld = ModelParts[PartIdx].WorldMatrix;
|
const lcMatrix44& ModelWorld = ModelPart.WorldMatrix;
|
||||||
lcVertex* Verts = (lcVertex*)Mesh->mVertexData;
|
lcVertex* Verts = (lcVertex*)Mesh->mVertexData;
|
||||||
|
|
||||||
for (int VertexIdx = 0; VertexIdx < Mesh->mNumVertices; VertexIdx++)
|
for (int VertexIdx = 0; VertexIdx < Mesh->mNumVertices; VertexIdx++)
|
||||||
|
@ -2397,14 +2427,14 @@ void Project::ExportWavefront(const QString& FileName)
|
||||||
OBJFile.WriteLine("#\n\n");
|
OBJFile.WriteLine("#\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int PartIdx = 0; PartIdx < ModelParts.GetSize(); PartIdx++)
|
for (const lcModelPartsEntry& ModelPart : ModelParts)
|
||||||
{
|
{
|
||||||
lcMesh* Mesh = ModelParts[PartIdx].Info->GetMesh();
|
lcMesh* Mesh = !ModelPart.Mesh ? ModelPart.Info->GetMesh() : ModelPart.Mesh;
|
||||||
|
|
||||||
if (!Mesh)
|
if (!Mesh)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const lcMatrix44& ModelWorld = ModelParts[PartIdx].WorldMatrix;
|
const lcMatrix44& ModelWorld = ModelPart.WorldMatrix;
|
||||||
lcVertex* Verts = (lcVertex*)Mesh->mVertexData;
|
lcVertex* Verts = (lcVertex*)Mesh->mVertexData;
|
||||||
|
|
||||||
for (int VertexIdx = 0; VertexIdx < Mesh->mNumVertices; VertexIdx++)
|
for (int VertexIdx = 0; VertexIdx < Mesh->mNumVertices; VertexIdx++)
|
||||||
|
@ -2419,16 +2449,15 @@ void Project::ExportWavefront(const QString& FileName)
|
||||||
|
|
||||||
for (int PartIdx = 0; PartIdx < ModelParts.GetSize(); PartIdx++)
|
for (int PartIdx = 0; PartIdx < ModelParts.GetSize(); PartIdx++)
|
||||||
{
|
{
|
||||||
PieceInfo* Info = ModelParts[PartIdx].Info;
|
|
||||||
|
|
||||||
sprintf(Line, "g Piece%.3d\n", PartIdx);
|
sprintf(Line, "g Piece%.3d\n", PartIdx);
|
||||||
OBJFile.WriteLine(Line);
|
OBJFile.WriteLine(Line);
|
||||||
|
|
||||||
lcMesh* Mesh = Info->GetMesh();
|
const lcModelPartsEntry& ModelPart = ModelParts[PartIdx];
|
||||||
|
lcMesh* Mesh = !ModelPart.Mesh ? ModelPart.Info->GetMesh() : ModelPart.Mesh;
|
||||||
|
|
||||||
if (Mesh)
|
if (Mesh)
|
||||||
{
|
{
|
||||||
Mesh->ExportWavefrontIndices(OBJFile, ModelParts[PartIdx].ColorIndex, vert);
|
Mesh->ExportWavefrontIndices(OBJFile, ModelPart.ColorIndex, vert);
|
||||||
vert += Mesh->mNumVertices;
|
vert += Mesh->mNumVertices;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ equals(QT_MAJOR_VERSION, 5) {
|
||||||
}
|
}
|
||||||
|
|
||||||
INCLUDEPATH += qt common
|
INCLUDEPATH += qt common
|
||||||
CONFIG += precompile_header incremental c++11
|
CONFIG += precompile_header incremental c++11 force_debug_info
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
RC_FILE = qt/leocad.rc
|
RC_FILE = qt/leocad.rc
|
||||||
|
|
Loading…
Reference in a new issue