2022-09-23 15:54:49 +00:00
|
|
|
#include "model_mesh.h"
|
2019-09-21 22:12:11 +00:00
|
|
|
#include "version.h"
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <QFile>
|
|
|
|
#include <QTextStream>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <cmath>
|
2018-03-10 06:57:14 +00:00
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
float ModelMesh::m_defaultMetalness = 0.0;
|
|
|
|
float ModelMesh::m_defaultRoughness = 1.0;
|
2018-10-09 02:19:12 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh::ModelMesh(const ModelMesh& mesh)
|
|
|
|
: m_triangleVertices(nullptr)
|
|
|
|
, m_triangleVertexCount(0)
|
|
|
|
, m_textureImage(nullptr)
|
2018-05-10 09:16:22 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
if (nullptr != mesh.m_triangleVertices && mesh.m_triangleVertexCount > 0) {
|
2022-09-23 15:54:49 +00:00
|
|
|
this->m_triangleVertices = new ModelOpenGLVertex[mesh.m_triangleVertexCount];
|
2018-06-11 14:24:25 +00:00
|
|
|
this->m_triangleVertexCount = mesh.m_triangleVertexCount;
|
|
|
|
for (int i = 0; i < mesh.m_triangleVertexCount; i++)
|
|
|
|
this->m_triangleVertices[i] = mesh.m_triangleVertices[i];
|
2018-05-10 09:16:22 +00:00
|
|
|
}
|
2018-06-11 14:24:25 +00:00
|
|
|
if (nullptr != mesh.m_textureImage) {
|
|
|
|
this->m_textureImage = new QImage(*mesh.m_textureImage);
|
|
|
|
}
|
2018-10-09 02:19:12 +00:00
|
|
|
if (nullptr != mesh.m_normalMapImage) {
|
|
|
|
this->m_normalMapImage = new QImage(*mesh.m_normalMapImage);
|
|
|
|
}
|
2022-09-24 13:31:49 +00:00
|
|
|
if (nullptr != mesh.m_metalnessRoughnessAmbientOcclusionMapImage) {
|
|
|
|
this->m_metalnessRoughnessAmbientOcclusionMapImage = new QImage(*mesh.m_metalnessRoughnessAmbientOcclusionMapImage);
|
2018-11-11 09:13:46 +00:00
|
|
|
this->m_hasMetalnessInImage = mesh.m_hasMetalnessInImage;
|
|
|
|
this->m_hasRoughnessInImage = mesh.m_hasRoughnessInImage;
|
|
|
|
this->m_hasAmbientOcclusionInImage = mesh.m_hasAmbientOcclusionInImage;
|
|
|
|
}
|
2018-06-11 14:24:25 +00:00
|
|
|
this->m_vertices = mesh.m_vertices;
|
|
|
|
this->m_faces = mesh.m_faces;
|
|
|
|
this->m_triangulatedVertices = mesh.m_triangulatedVertices;
|
2019-07-10 12:09:46 +00:00
|
|
|
this->m_meshId = mesh.meshId();
|
2018-06-11 14:24:25 +00:00
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
void ModelMesh::removeColor()
|
2020-01-05 05:05:07 +00:00
|
|
|
{
|
|
|
|
delete this->m_textureImage;
|
|
|
|
this->m_textureImage = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-01-05 05:05:07 +00:00
|
|
|
delete this->m_normalMapImage;
|
|
|
|
this->m_normalMapImage = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2022-09-24 13:31:49 +00:00
|
|
|
delete this->m_metalnessRoughnessAmbientOcclusionMapImage;
|
|
|
|
this->m_metalnessRoughnessAmbientOcclusionMapImage = nullptr;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-01-05 05:05:07 +00:00
|
|
|
this->m_hasMetalnessInImage = false;
|
|
|
|
this->m_hasRoughnessInImage = false;
|
|
|
|
this->m_hasAmbientOcclusionInImage = false;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2020-01-05 05:05:07 +00:00
|
|
|
for (int i = 0; i < this->m_triangleVertexCount; ++i) {
|
2022-10-18 09:35:04 +00:00
|
|
|
auto& vertex = this->m_triangleVertices[i];
|
2020-01-05 05:05:07 +00:00
|
|
|
vertex.colorR = 1.0;
|
|
|
|
vertex.colorG = 1.0;
|
|
|
|
vertex.colorB = 1.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh::ModelMesh(ModelOpenGLVertex* triangleVertices, int vertexNum)
|
|
|
|
: m_triangleVertices(triangleVertices)
|
|
|
|
, m_triangleVertexCount(vertexNum)
|
|
|
|
, m_textureImage(nullptr)
|
2018-06-11 14:24:25 +00:00
|
|
|
{
|
2018-05-10 09:16:22 +00:00
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh::ModelMesh(const std::vector<dust3d::Vector3>& vertices,
|
|
|
|
const std::vector<std::vector<size_t>>& triangles,
|
|
|
|
const std::vector<std::vector<dust3d::Vector3>>& triangleVertexNormals,
|
|
|
|
const dust3d::Color& color,
|
2020-10-18 05:52:15 +00:00
|
|
|
float metalness,
|
2022-10-07 20:26:30 +00:00
|
|
|
float roughness,
|
2022-10-23 03:14:30 +00:00
|
|
|
const std::vector<std::tuple<dust3d::Color, float /*metalness*/, float /*roughness*/>>* vertexProperties,
|
|
|
|
const std::vector<std::array<dust3d::Vector2, 3>>* triangleUvs)
|
2019-02-18 12:57:18 +00:00
|
|
|
{
|
2021-11-18 14:58:01 +00:00
|
|
|
m_triangleVertexCount = (int)triangles.size() * 3;
|
2022-09-23 15:54:49 +00:00
|
|
|
m_triangleVertices = new ModelOpenGLVertex[m_triangleVertexCount];
|
2019-02-18 12:57:18 +00:00
|
|
|
int destIndex = 0;
|
|
|
|
for (size_t i = 0; i < triangles.size(); ++i) {
|
2022-10-23 03:14:30 +00:00
|
|
|
std::array<dust3d::Vector2, 3> uvs = {};
|
|
|
|
if (nullptr != triangleUvs) {
|
|
|
|
uvs = triangleUvs->at(i);
|
|
|
|
}
|
2019-02-18 12:57:18 +00:00
|
|
|
for (auto j = 0; j < 3; j++) {
|
2021-11-18 14:58:01 +00:00
|
|
|
int vertexIndex = (int)triangles[i][j];
|
2022-10-18 09:35:04 +00:00
|
|
|
const dust3d::Vector3* srcVert = &vertices[vertexIndex];
|
|
|
|
const dust3d::Vector3* srcNormal = &(triangleVertexNormals)[i][j];
|
|
|
|
ModelOpenGLVertex* dest = &m_triangleVertices[destIndex];
|
2019-02-18 12:57:18 +00:00
|
|
|
dest->posX = srcVert->x();
|
|
|
|
dest->posY = srcVert->y();
|
|
|
|
dest->posZ = srcVert->z();
|
2022-10-23 03:14:30 +00:00
|
|
|
dest->texU = uvs[j][0];
|
|
|
|
dest->texV = uvs[j][1];
|
2019-02-18 12:57:18 +00:00
|
|
|
dest->normX = srcNormal->x();
|
|
|
|
dest->normY = srcNormal->y();
|
|
|
|
dest->normZ = srcNormal->z();
|
2022-10-07 20:26:30 +00:00
|
|
|
if (nullptr == vertexProperties) {
|
|
|
|
dest->colorR = color.r();
|
|
|
|
dest->colorG = color.g();
|
|
|
|
dest->colorB = color.b();
|
|
|
|
dest->alpha = color.alpha();
|
|
|
|
dest->metalness = metalness;
|
|
|
|
dest->roughness = roughness;
|
|
|
|
} else {
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& property = (*vertexProperties)[vertexIndex];
|
2022-10-07 20:26:30 +00:00
|
|
|
dest->colorR = std::get<0>(property).r();
|
|
|
|
dest->colorG = std::get<0>(property).g();
|
|
|
|
dest->colorB = std::get<0>(property).b();
|
|
|
|
dest->alpha = std::get<0>(property).alpha();
|
|
|
|
dest->metalness = std::get<1>(property);
|
|
|
|
dest->roughness = std::get<2>(property);
|
|
|
|
}
|
2019-02-18 12:57:18 +00:00
|
|
|
dest->tangentX = 0;
|
|
|
|
dest->tangentY = 0;
|
|
|
|
dest->tangentZ = 0;
|
|
|
|
destIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh::ModelMesh(dust3d::Object& object)
|
|
|
|
: m_triangleVertices(nullptr)
|
|
|
|
, m_triangleVertexCount(0)
|
|
|
|
, m_textureImage(nullptr)
|
2018-05-10 09:16:22 +00:00
|
|
|
{
|
2020-11-17 14:31:51 +00:00
|
|
|
m_meshId = object.meshId;
|
|
|
|
m_vertices = object.vertices;
|
|
|
|
m_faces = object.triangleAndQuads;
|
2022-09-22 13:07:27 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
std::map<std::pair<dust3d::Uuid, dust3d::Uuid>, const dust3d::ObjectNode*> nodeMap;
|
2022-09-22 13:07:27 +00:00
|
|
|
for (size_t i = 0; i < object.nodes.size(); ++i) {
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& node = object.nodes[i];
|
|
|
|
nodeMap.insert({ { node.partId, node.nodeId }, &node });
|
2022-09-22 13:07:27 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2021-11-18 14:58:01 +00:00
|
|
|
m_triangleVertexCount = (int)object.triangles.size() * 3;
|
2022-09-23 15:54:49 +00:00
|
|
|
m_triangleVertices = new ModelOpenGLVertex[m_triangleVertexCount];
|
2018-05-10 09:16:22 +00:00
|
|
|
int destIndex = 0;
|
2020-11-17 14:31:51 +00:00
|
|
|
const auto triangleVertexNormals = object.triangleVertexNormals();
|
|
|
|
const auto triangleVertexUvs = object.triangleVertexUvs();
|
|
|
|
const auto triangleTangents = object.triangleTangents();
|
2021-11-18 14:58:01 +00:00
|
|
|
const dust3d::Vector3 defaultNormal = dust3d::Vector3(0, 0, 0);
|
|
|
|
const dust3d::Vector2 defaultUv = dust3d::Vector2(0, 0);
|
|
|
|
const dust3d::Vector3 defaultTangent = dust3d::Vector3(0, 0, 0);
|
2020-11-17 14:31:51 +00:00
|
|
|
for (size_t i = 0; i < object.triangles.size(); ++i) {
|
2022-10-18 09:35:04 +00:00
|
|
|
const auto& triangleColor = &object.triangleColors[i];
|
2018-10-26 23:04:45 +00:00
|
|
|
for (auto j = 0; j < 3; j++) {
|
2021-11-18 14:58:01 +00:00
|
|
|
int vertexIndex = (int)object.triangles[i][j];
|
2022-10-18 09:35:04 +00:00
|
|
|
const dust3d::Vector3* srcVert = &object.vertices[vertexIndex];
|
|
|
|
const dust3d::Vector3* srcNormal = &defaultNormal;
|
2018-10-26 23:04:45 +00:00
|
|
|
if (triangleVertexNormals)
|
|
|
|
srcNormal = &(*triangleVertexNormals)[i][j];
|
2022-10-18 09:35:04 +00:00
|
|
|
const dust3d::Vector2* srcUv = &defaultUv;
|
2018-10-26 23:04:45 +00:00
|
|
|
if (triangleVertexUvs)
|
|
|
|
srcUv = &(*triangleVertexUvs)[i][j];
|
2022-10-18 09:35:04 +00:00
|
|
|
const dust3d::Vector3* srcTangent = &defaultTangent;
|
2018-10-26 23:04:45 +00:00
|
|
|
if (triangleTangents)
|
|
|
|
srcTangent = &(*triangleTangents)[i];
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelOpenGLVertex* dest = &m_triangleVertices[destIndex];
|
2021-11-18 14:58:01 +00:00
|
|
|
dest->colorR = triangleColor->r();
|
|
|
|
dest->colorG = triangleColor->g();
|
|
|
|
dest->colorB = triangleColor->b();
|
|
|
|
dest->alpha = triangleColor->alpha();
|
2018-10-26 23:04:45 +00:00
|
|
|
dest->posX = srcVert->x();
|
|
|
|
dest->posY = srcVert->y();
|
|
|
|
dest->posZ = srcVert->z();
|
|
|
|
dest->texU = srcUv->x();
|
|
|
|
dest->texV = srcUv->y();
|
|
|
|
dest->normX = srcNormal->x();
|
|
|
|
dest->normY = srcNormal->y();
|
|
|
|
dest->normZ = srcNormal->z();
|
2022-09-22 13:07:27 +00:00
|
|
|
auto findNode = nodeMap.find(object.vertexSourceNodes[vertexIndex]);
|
|
|
|
if (findNode != nodeMap.end()) {
|
|
|
|
dest->metalness = findNode->second->metalness;
|
|
|
|
dest->roughness = findNode->second->roughness;
|
|
|
|
} else {
|
|
|
|
dest->metalness = m_defaultMetalness;
|
|
|
|
dest->roughness = m_defaultRoughness;
|
|
|
|
}
|
2018-10-26 23:04:45 +00:00
|
|
|
dest->tangentX = srcTangent->x();
|
|
|
|
dest->tangentY = srcTangent->y();
|
|
|
|
dest->tangentZ = srcTangent->z();
|
|
|
|
destIndex++;
|
2018-05-10 09:16:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelMesh::ModelMesh()
|
|
|
|
: m_triangleVertices(nullptr)
|
|
|
|
, m_triangleVertexCount(0)
|
|
|
|
, m_textureImage(nullptr)
|
2018-09-18 06:22:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
ModelMesh::~ModelMesh()
|
2018-03-10 06:57:14 +00:00
|
|
|
{
|
2018-03-19 13:56:10 +00:00
|
|
|
delete[] m_triangleVertices;
|
|
|
|
m_triangleVertexCount = 0;
|
2018-05-10 09:16:22 +00:00
|
|
|
delete m_textureImage;
|
2018-10-09 02:19:12 +00:00
|
|
|
delete m_normalMapImage;
|
2022-09-24 13:31:49 +00:00
|
|
|
delete m_metalnessRoughnessAmbientOcclusionMapImage;
|
2018-03-10 06:57:14 +00:00
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
const std::vector<dust3d::Vector3>& ModelMesh::vertices()
|
2018-03-20 07:56:49 +00:00
|
|
|
{
|
|
|
|
return m_vertices;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
const std::vector<std::vector<size_t>>& ModelMesh::faces()
|
2018-03-20 07:56:49 +00:00
|
|
|
{
|
|
|
|
return m_faces;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
const std::vector<dust3d::Vector3>& ModelMesh::triangulatedVertices()
|
2018-04-26 02:23:22 +00:00
|
|
|
{
|
|
|
|
return m_triangulatedVertices;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
ModelOpenGLVertex* ModelMesh::triangleVertices()
|
2018-03-10 06:57:14 +00:00
|
|
|
{
|
2018-03-19 13:56:10 +00:00
|
|
|
return m_triangleVertices;
|
2018-03-10 06:57:14 +00:00
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
int ModelMesh::triangleVertexCount()
|
2018-03-10 06:57:14 +00:00
|
|
|
{
|
2018-03-19 13:56:10 +00:00
|
|
|
return m_triangleVertexCount;
|
2018-03-10 06:57:14 +00:00
|
|
|
}
|
2018-03-19 13:56:10 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void ModelMesh::setTextureImage(QImage* textureImage)
|
2018-05-10 09:16:22 +00:00
|
|
|
{
|
|
|
|
m_textureImage = textureImage;
|
|
|
|
}
|
2018-03-19 13:56:10 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
const QImage* ModelMesh::textureImage()
|
2018-05-10 09:16:22 +00:00
|
|
|
{
|
|
|
|
return m_textureImage;
|
|
|
|
}
|
2018-10-09 02:19:12 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
QImage* ModelMesh::takeTextureImage()
|
2022-09-24 13:31:49 +00:00
|
|
|
{
|
|
|
|
auto image = m_textureImage;
|
|
|
|
m_textureImage = nullptr;
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void ModelMesh::setNormalMapImage(QImage* normalMapImage)
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
m_normalMapImage = normalMapImage;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
const QImage* ModelMesh::normalMapImage()
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
return m_normalMapImage;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
QImage* ModelMesh::takeNormalMapImage()
|
2022-09-24 13:31:49 +00:00
|
|
|
{
|
|
|
|
auto image = m_normalMapImage;
|
|
|
|
m_normalMapImage = nullptr;
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
const QImage* ModelMesh::metalnessRoughnessAmbientOcclusionMapImage()
|
2022-09-24 13:31:49 +00:00
|
|
|
{
|
|
|
|
return m_metalnessRoughnessAmbientOcclusionMapImage;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
QImage* ModelMesh::takeMetalnessRoughnessAmbientOcclusionMapImage()
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
2022-09-24 13:31:49 +00:00
|
|
|
auto image = m_metalnessRoughnessAmbientOcclusionMapImage;
|
|
|
|
m_metalnessRoughnessAmbientOcclusionMapImage = nullptr;
|
|
|
|
return image;
|
2018-10-09 02:19:12 +00:00
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void ModelMesh::setMetalnessRoughnessAmbientOcclusionMapImage(QImage* image)
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
2022-09-24 13:31:49 +00:00
|
|
|
m_metalnessRoughnessAmbientOcclusionMapImage = image;
|
2018-10-09 02:19:12 +00:00
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
bool ModelMesh::hasMetalnessInImage()
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
return m_hasMetalnessInImage;
|
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
void ModelMesh::setHasMetalnessInImage(bool hasInImage)
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
m_hasMetalnessInImage = hasInImage;
|
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
bool ModelMesh::hasRoughnessInImage()
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
return m_hasRoughnessInImage;
|
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
void ModelMesh::setHasRoughnessInImage(bool hasInImage)
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
m_hasRoughnessInImage = hasInImage;
|
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
bool ModelMesh::hasAmbientOcclusionInImage()
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
return m_hasAmbientOcclusionInImage;
|
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
void ModelMesh::setHasAmbientOcclusionInImage(bool hasInImage)
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
m_hasAmbientOcclusionInImage = hasInImage;
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void ModelMesh::exportAsObj(QTextStream* textStream)
|
2019-03-20 11:04:37 +00:00
|
|
|
{
|
2022-10-18 09:35:04 +00:00
|
|
|
auto& stream = *textStream;
|
2019-09-21 22:12:11 +00:00
|
|
|
stream << "# " << APP_NAME << " " << APP_HUMAN_VER << endl;
|
|
|
|
stream << "# " << APP_HOMEPAGE_URL << endl;
|
2022-10-18 09:35:04 +00:00
|
|
|
for (std::vector<dust3d::Vector3>::const_iterator it = vertices().begin(); it != vertices().end(); ++it) {
|
2021-11-18 14:58:01 +00:00
|
|
|
stream << "v " << QString::number((*it).x()) << " " << QString::number((*it).y()) << " " << QString::number((*it).z()) << endl;
|
2019-03-20 11:04:37 +00:00
|
|
|
}
|
2022-10-18 09:35:04 +00:00
|
|
|
for (std::vector<std::vector<size_t>>::const_iterator it = faces().begin(); it != faces().end(); ++it) {
|
2019-03-20 11:04:37 +00:00
|
|
|
stream << "f";
|
2022-10-18 09:35:04 +00:00
|
|
|
for (std::vector<size_t>::const_iterator subIt = (*it).begin(); subIt != (*it).end(); ++subIt) {
|
2021-11-18 14:58:01 +00:00
|
|
|
stream << " " << QString::number((1 + *subIt));
|
2019-03-20 11:04:37 +00:00
|
|
|
}
|
|
|
|
stream << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void ModelMesh::exportAsObj(const QString& filename)
|
2018-10-09 02:19:12 +00:00
|
|
|
{
|
|
|
|
QFile file(filename);
|
|
|
|
if (file.open(QIODevice::WriteOnly)) {
|
|
|
|
QTextStream stream(&file);
|
2019-03-20 11:04:37 +00:00
|
|
|
exportAsObj(&stream);
|
2018-10-09 02:19:12 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-07 06:27:58 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
void ModelMesh::updateTriangleVertices(ModelOpenGLVertex* triangleVertices, int triangleVertexCount)
|
2019-09-21 14:30:27 +00:00
|
|
|
{
|
|
|
|
delete[] m_triangleVertices;
|
|
|
|
m_triangleVertices = 0;
|
|
|
|
m_triangleVertexCount = 0;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2019-09-21 14:30:27 +00:00
|
|
|
m_triangleVertices = triangleVertices;
|
|
|
|
m_triangleVertexCount = triangleVertexCount;
|
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
quint64 ModelMesh::meshId() const
|
2019-07-10 12:09:46 +00:00
|
|
|
{
|
|
|
|
return m_meshId;
|
|
|
|
}
|
|
|
|
|
2022-09-23 15:54:49 +00:00
|
|
|
void ModelMesh::setMeshId(quint64 id)
|
2019-07-10 12:09:46 +00:00
|
|
|
{
|
|
|
|
m_meshId = id;
|
|
|
|
}
|