parent
ad244c4659
commit
820aa90406
|
@ -367,6 +367,11 @@ HEADERS += src/preferences.h
|
||||||
SOURCES += src/bonenameconverter.cpp
|
SOURCES += src/bonenameconverter.cpp
|
||||||
HEADERS += src/bonenameconverter.h
|
HEADERS += src/bonenameconverter.h
|
||||||
|
|
||||||
|
SOURCES += src/toolmesh.cpp
|
||||||
|
HEADERS += src/toolmesh.h
|
||||||
|
|
||||||
|
HEADERS += src/shadervertex.h
|
||||||
|
|
||||||
SOURCES += src/main.cpp
|
SOURCES += src/main.cpp
|
||||||
|
|
||||||
HEADERS += src/version.h
|
HEADERS += src/version.h
|
||||||
|
|
|
@ -843,6 +843,7 @@ void Document::splitPartByNode(std::vector<std::vector<QUuid>> *groups, QUuid no
|
||||||
{
|
{
|
||||||
const SkeletonNode *node = findNode(nodeId);
|
const SkeletonNode *node = findNode(nodeId);
|
||||||
std::set<QUuid> visitMap;
|
std::set<QUuid> visitMap;
|
||||||
|
visitMap.insert(nodeId);
|
||||||
for (auto edgeIt = node->edgeIds.begin(); edgeIt != node->edgeIds.end(); edgeIt++) {
|
for (auto edgeIt = node->edgeIds.begin(); edgeIt != node->edgeIds.end(); edgeIt++) {
|
||||||
std::vector<QUuid> group;
|
std::vector<QUuid> group;
|
||||||
const SkeletonEdge *edge = findEdge(*edgeIt);
|
const SkeletonEdge *edge = findEdge(*edgeIt);
|
||||||
|
|
|
@ -19,14 +19,14 @@ MeshLoader::MeshLoader(const MeshLoader &mesh) :
|
||||||
{
|
{
|
||||||
if (nullptr != mesh.m_triangleVertices &&
|
if (nullptr != mesh.m_triangleVertices &&
|
||||||
mesh.m_triangleVertexCount > 0) {
|
mesh.m_triangleVertexCount > 0) {
|
||||||
this->m_triangleVertices = new Vertex[mesh.m_triangleVertexCount];
|
this->m_triangleVertices = new ShaderVertex[mesh.m_triangleVertexCount];
|
||||||
this->m_triangleVertexCount = mesh.m_triangleVertexCount;
|
this->m_triangleVertexCount = mesh.m_triangleVertexCount;
|
||||||
for (int i = 0; i < mesh.m_triangleVertexCount; i++)
|
for (int i = 0; i < mesh.m_triangleVertexCount; i++)
|
||||||
this->m_triangleVertices[i] = mesh.m_triangleVertices[i];
|
this->m_triangleVertices[i] = mesh.m_triangleVertices[i];
|
||||||
}
|
}
|
||||||
if (nullptr != mesh.m_edgeVertices &&
|
if (nullptr != mesh.m_edgeVertices &&
|
||||||
mesh.m_edgeVertexCount > 0) {
|
mesh.m_edgeVertexCount > 0) {
|
||||||
this->m_edgeVertices = new Vertex[mesh.m_edgeVertexCount];
|
this->m_edgeVertices = new ShaderVertex[mesh.m_edgeVertexCount];
|
||||||
this->m_edgeVertexCount = mesh.m_edgeVertexCount;
|
this->m_edgeVertexCount = mesh.m_edgeVertexCount;
|
||||||
for (int i = 0; i < mesh.m_edgeVertexCount; i++)
|
for (int i = 0; i < mesh.m_edgeVertexCount; i++)
|
||||||
this->m_edgeVertices[i] = mesh.m_edgeVertices[i];
|
this->m_edgeVertices[i] = mesh.m_edgeVertices[i];
|
||||||
|
@ -49,7 +49,7 @@ MeshLoader::MeshLoader(const MeshLoader &mesh) :
|
||||||
this->m_triangulatedFaces = mesh.m_triangulatedFaces;
|
this->m_triangulatedFaces = mesh.m_triangulatedFaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshLoader::MeshLoader(Vertex *triangleVertices, int vertexNum) :
|
MeshLoader::MeshLoader(ShaderVertex *triangleVertices, int vertexNum) :
|
||||||
m_triangleVertices(triangleVertices),
|
m_triangleVertices(triangleVertices),
|
||||||
m_triangleVertexCount(vertexNum),
|
m_triangleVertexCount(vertexNum),
|
||||||
m_edgeVertices(nullptr),
|
m_edgeVertices(nullptr),
|
||||||
|
@ -63,14 +63,14 @@ MeshLoader::MeshLoader(const std::vector<QVector3D> &vertices, const std::vector
|
||||||
const QColor &color)
|
const QColor &color)
|
||||||
{
|
{
|
||||||
m_triangleVertexCount = triangles.size() * 3;
|
m_triangleVertexCount = triangles.size() * 3;
|
||||||
m_triangleVertices = new Vertex[m_triangleVertexCount];
|
m_triangleVertices = new ShaderVertex[m_triangleVertexCount];
|
||||||
int destIndex = 0;
|
int destIndex = 0;
|
||||||
for (size_t i = 0; i < triangles.size(); ++i) {
|
for (size_t i = 0; i < triangles.size(); ++i) {
|
||||||
for (auto j = 0; j < 3; j++) {
|
for (auto j = 0; j < 3; j++) {
|
||||||
int vertexIndex = triangles[i][j];
|
int vertexIndex = triangles[i][j];
|
||||||
const QVector3D *srcVert = &vertices[vertexIndex];
|
const QVector3D *srcVert = &vertices[vertexIndex];
|
||||||
const QVector3D *srcNormal = &(triangleVertexNormals)[i][j];
|
const QVector3D *srcNormal = &(triangleVertexNormals)[i][j];
|
||||||
Vertex *dest = &m_triangleVertices[destIndex];
|
ShaderVertex *dest = &m_triangleVertices[destIndex];
|
||||||
dest->colorR = color.redF();
|
dest->colorR = color.redF();
|
||||||
dest->colorG = color.greenF();
|
dest->colorG = color.greenF();
|
||||||
dest->colorB = color.blueF();
|
dest->colorB = color.blueF();
|
||||||
|
@ -103,7 +103,7 @@ MeshLoader::MeshLoader(Outcome &outcome) :
|
||||||
m_faces = outcome.triangleAndQuads;
|
m_faces = outcome.triangleAndQuads;
|
||||||
|
|
||||||
m_triangleVertexCount = outcome.triangles.size() * 3;
|
m_triangleVertexCount = outcome.triangles.size() * 3;
|
||||||
m_triangleVertices = new Vertex[m_triangleVertexCount];
|
m_triangleVertices = new ShaderVertex[m_triangleVertexCount];
|
||||||
int destIndex = 0;
|
int destIndex = 0;
|
||||||
const auto triangleVertexNormals = outcome.triangleVertexNormals();
|
const auto triangleVertexNormals = outcome.triangleVertexNormals();
|
||||||
const auto triangleVertexUvs = outcome.triangleVertexUvs();
|
const auto triangleVertexUvs = outcome.triangleVertexUvs();
|
||||||
|
@ -125,7 +125,7 @@ MeshLoader::MeshLoader(Outcome &outcome) :
|
||||||
const QVector3D *srcTangent = &defaultTangent;
|
const QVector3D *srcTangent = &defaultTangent;
|
||||||
if (triangleTangents)
|
if (triangleTangents)
|
||||||
srcTangent = &(*triangleTangents)[i];
|
srcTangent = &(*triangleTangents)[i];
|
||||||
Vertex *dest = &m_triangleVertices[destIndex];
|
ShaderVertex *dest = &m_triangleVertices[destIndex];
|
||||||
dest->colorR = triangleColor->redF();
|
dest->colorR = triangleColor->redF();
|
||||||
dest->colorG = triangleColor->greenF();
|
dest->colorG = triangleColor->greenF();
|
||||||
dest->colorB = triangleColor->blueF();
|
dest->colorB = triangleColor->blueF();
|
||||||
|
@ -152,7 +152,7 @@ MeshLoader::MeshLoader(Outcome &outcome) :
|
||||||
edgeCount += face.size();
|
edgeCount += face.size();
|
||||||
}
|
}
|
||||||
m_edgeVertexCount = edgeCount * 2;
|
m_edgeVertexCount = edgeCount * 2;
|
||||||
m_edgeVertices = new Vertex[m_edgeVertexCount];
|
m_edgeVertices = new ShaderVertex[m_edgeVertexCount];
|
||||||
size_t edgeVertexIndex = 0;
|
size_t edgeVertexIndex = 0;
|
||||||
for (size_t faceIndex = 0; faceIndex < outcome.triangleAndQuads.size(); ++faceIndex) {
|
for (size_t faceIndex = 0; faceIndex < outcome.triangleAndQuads.size(); ++faceIndex) {
|
||||||
const auto &face = outcome.triangleAndQuads[faceIndex];
|
const auto &face = outcome.triangleAndQuads[faceIndex];
|
||||||
|
@ -160,8 +160,8 @@ MeshLoader::MeshLoader(Outcome &outcome) :
|
||||||
for (size_t x = 0; x < 2; ++x) {
|
for (size_t x = 0; x < 2; ++x) {
|
||||||
size_t sourceIndex = face[(i + x) % face.size()];
|
size_t sourceIndex = face[(i + x) % face.size()];
|
||||||
const QVector3D *srcVert = &outcome.vertices[sourceIndex];
|
const QVector3D *srcVert = &outcome.vertices[sourceIndex];
|
||||||
Vertex *dest = &m_edgeVertices[edgeVertexIndex];
|
ShaderVertex *dest = &m_edgeVertices[edgeVertexIndex];
|
||||||
memset(dest, 0, sizeof(Vertex));
|
memset(dest, 0, sizeof(ShaderVertex));
|
||||||
dest->colorR = 0.0;
|
dest->colorR = 0.0;
|
||||||
dest->colorG = 0.0;
|
dest->colorG = 0.0;
|
||||||
dest->colorB = 0.0;
|
dest->colorB = 0.0;
|
||||||
|
@ -191,6 +191,8 @@ MeshLoader::~MeshLoader()
|
||||||
m_triangleVertexCount = 0;
|
m_triangleVertexCount = 0;
|
||||||
delete[] m_edgeVertices;
|
delete[] m_edgeVertices;
|
||||||
m_edgeVertexCount = 0;
|
m_edgeVertexCount = 0;
|
||||||
|
delete[] m_toolVertices;
|
||||||
|
m_toolVertexCount = 0;
|
||||||
delete m_textureImage;
|
delete m_textureImage;
|
||||||
delete m_normalMapImage;
|
delete m_normalMapImage;
|
||||||
delete m_metalnessRoughnessAmbientOcclusionImage;
|
delete m_metalnessRoughnessAmbientOcclusionImage;
|
||||||
|
@ -216,7 +218,7 @@ const std::vector<TriangulatedFace> &MeshLoader::triangulatedFaces()
|
||||||
return m_triangulatedFaces;
|
return m_triangulatedFaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vertex *MeshLoader::triangleVertices()
|
ShaderVertex *MeshLoader::triangleVertices()
|
||||||
{
|
{
|
||||||
return m_triangleVertices;
|
return m_triangleVertices;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +228,7 @@ int MeshLoader::triangleVertexCount()
|
||||||
return m_triangleVertexCount;
|
return m_triangleVertexCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vertex *MeshLoader::edgeVertices()
|
ShaderVertex *MeshLoader::edgeVertices()
|
||||||
{
|
{
|
||||||
return m_edgeVertices;
|
return m_edgeVertices;
|
||||||
}
|
}
|
||||||
|
@ -236,6 +238,16 @@ int MeshLoader::edgeVertexCount()
|
||||||
return m_edgeVertexCount;
|
return m_edgeVertexCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShaderVertex *MeshLoader::toolVertices()
|
||||||
|
{
|
||||||
|
return m_toolVertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MeshLoader::toolVertexCount()
|
||||||
|
{
|
||||||
|
return m_toolVertexCount;
|
||||||
|
}
|
||||||
|
|
||||||
void MeshLoader::setTextureImage(QImage *textureImage)
|
void MeshLoader::setTextureImage(QImage *textureImage)
|
||||||
{
|
{
|
||||||
m_textureImage = textureImage;
|
m_textureImage = textureImage;
|
||||||
|
|
|
@ -1,36 +1,13 @@
|
||||||
#ifndef DUST3D_MESH_LOADER_H
|
#ifndef DUST3D_MESH_LOADER_H
|
||||||
#define DUST3D_MESH_LOADER_H
|
#define DUST3D_MESH_LOADER_H
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QOpenGLFunctions>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QVector3D>
|
#include <QVector3D>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include "outcome.h"
|
#include "outcome.h"
|
||||||
|
#include "shadervertex.h"
|
||||||
#pragma pack(push)
|
|
||||||
#pragma pack(1)
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GLfloat posX;
|
|
||||||
GLfloat posY;
|
|
||||||
GLfloat posZ;
|
|
||||||
GLfloat normX;
|
|
||||||
GLfloat normY;
|
|
||||||
GLfloat normZ;
|
|
||||||
GLfloat colorR;
|
|
||||||
GLfloat colorG;
|
|
||||||
GLfloat colorB;
|
|
||||||
GLfloat texU;
|
|
||||||
GLfloat texV;
|
|
||||||
GLfloat metalness;
|
|
||||||
GLfloat roughness;
|
|
||||||
GLfloat tangentX;
|
|
||||||
GLfloat tangentY;
|
|
||||||
GLfloat tangentZ;
|
|
||||||
} Vertex;
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
struct TriangulatedFace
|
struct TriangulatedFace
|
||||||
{
|
{
|
||||||
|
@ -45,14 +22,16 @@ public:
|
||||||
const std::vector<std::vector<QVector3D>> &triangleVertexNormals,
|
const std::vector<std::vector<QVector3D>> &triangleVertexNormals,
|
||||||
const QColor &color=Qt::white);
|
const QColor &color=Qt::white);
|
||||||
MeshLoader(Outcome &outcome);
|
MeshLoader(Outcome &outcome);
|
||||||
MeshLoader(Vertex *triangleVertices, int vertexNum);
|
MeshLoader(ShaderVertex *triangleVertices, int vertexNum);
|
||||||
MeshLoader(const MeshLoader &mesh);
|
MeshLoader(const MeshLoader &mesh);
|
||||||
MeshLoader();
|
MeshLoader();
|
||||||
~MeshLoader();
|
~MeshLoader();
|
||||||
Vertex *triangleVertices();
|
ShaderVertex *triangleVertices();
|
||||||
int triangleVertexCount();
|
int triangleVertexCount();
|
||||||
Vertex *edgeVertices();
|
ShaderVertex *edgeVertices();
|
||||||
int edgeVertexCount();
|
int edgeVertexCount();
|
||||||
|
ShaderVertex *toolVertices();
|
||||||
|
int toolVertexCount();
|
||||||
const std::vector<QVector3D> &vertices();
|
const std::vector<QVector3D> &vertices();
|
||||||
const std::vector<std::vector<size_t>> &faces();
|
const std::vector<std::vector<size_t>> &faces();
|
||||||
const std::vector<QVector3D> &triangulatedVertices();
|
const std::vector<QVector3D> &triangulatedVertices();
|
||||||
|
@ -74,10 +53,12 @@ public:
|
||||||
void exportAsObj(const QString &filename);
|
void exportAsObj(const QString &filename);
|
||||||
void exportAsObj(QTextStream *textStream);
|
void exportAsObj(QTextStream *textStream);
|
||||||
private:
|
private:
|
||||||
Vertex *m_triangleVertices = nullptr;
|
ShaderVertex *m_triangleVertices = nullptr;
|
||||||
int m_triangleVertexCount = 0;
|
int m_triangleVertexCount = 0;
|
||||||
Vertex *m_edgeVertices = nullptr;
|
ShaderVertex *m_edgeVertices = nullptr;
|
||||||
int m_edgeVertexCount = 0;
|
int m_edgeVertexCount = 0;
|
||||||
|
ShaderVertex *m_toolVertices = nullptr;
|
||||||
|
int m_toolVertexCount = 0;
|
||||||
std::vector<QVector3D> m_vertices;
|
std::vector<QVector3D> m_vertices;
|
||||||
std::vector<std::vector<size_t>> m_faces;
|
std::vector<std::vector<size_t>> m_faces;
|
||||||
std::vector<QVector3D> m_triangulatedVertices;
|
std::vector<QVector3D> m_triangulatedVertices;
|
||||||
|
|
|
@ -98,7 +98,7 @@ void ModelMeshBinder::paint(ModelShaderProgram *program)
|
||||||
m_vboTriangle.destroy();
|
m_vboTriangle.destroy();
|
||||||
m_vboTriangle.create();
|
m_vboTriangle.create();
|
||||||
m_vboTriangle.bind();
|
m_vboTriangle.bind();
|
||||||
m_vboTriangle.allocate(m_mesh->triangleVertices(), m_mesh->triangleVertexCount() * sizeof(Vertex));
|
m_vboTriangle.allocate(m_mesh->triangleVertices(), m_mesh->triangleVertexCount() * sizeof(ShaderVertex));
|
||||||
m_renderTriangleVertexCount = m_mesh->triangleVertexCount();
|
m_renderTriangleVertexCount = m_mesh->triangleVertexCount();
|
||||||
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
||||||
f->glEnableVertexAttribArray(0);
|
f->glEnableVertexAttribArray(0);
|
||||||
|
@ -108,13 +108,13 @@ void ModelMeshBinder::paint(ModelShaderProgram *program)
|
||||||
f->glEnableVertexAttribArray(4);
|
f->glEnableVertexAttribArray(4);
|
||||||
f->glEnableVertexAttribArray(5);
|
f->glEnableVertexAttribArray(5);
|
||||||
f->glEnableVertexAttribArray(6);
|
f->glEnableVertexAttribArray(6);
|
||||||
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
|
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), 0);
|
||||||
f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(3 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(3 * sizeof(GLfloat)));
|
||||||
f->glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(6 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(6 * sizeof(GLfloat)));
|
||||||
f->glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(9 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(9 * sizeof(GLfloat)));
|
||||||
f->glVertexAttribPointer(4, 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(11 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(4, 1, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(11 * sizeof(GLfloat)));
|
||||||
f->glVertexAttribPointer(5, 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(12 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(5, 1, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(12 * sizeof(GLfloat)));
|
||||||
f->glVertexAttribPointer(6, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(13 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(6, 3, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(13 * sizeof(GLfloat)));
|
||||||
m_vboTriangle.release();
|
m_vboTriangle.release();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ void ModelMeshBinder::paint(ModelShaderProgram *program)
|
||||||
m_vboEdge.destroy();
|
m_vboEdge.destroy();
|
||||||
m_vboEdge.create();
|
m_vboEdge.create();
|
||||||
m_vboEdge.bind();
|
m_vboEdge.bind();
|
||||||
m_vboEdge.allocate(m_mesh->edgeVertices(), m_mesh->edgeVertexCount() * sizeof(Vertex));
|
m_vboEdge.allocate(m_mesh->edgeVertices(), m_mesh->edgeVertexCount() * sizeof(ShaderVertex));
|
||||||
m_renderEdgeVertexCount = m_mesh->edgeVertexCount();
|
m_renderEdgeVertexCount = m_mesh->edgeVertexCount();
|
||||||
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
||||||
f->glEnableVertexAttribArray(0);
|
f->glEnableVertexAttribArray(0);
|
||||||
|
@ -133,13 +133,13 @@ void ModelMeshBinder::paint(ModelShaderProgram *program)
|
||||||
f->glEnableVertexAttribArray(4);
|
f->glEnableVertexAttribArray(4);
|
||||||
f->glEnableVertexAttribArray(5);
|
f->glEnableVertexAttribArray(5);
|
||||||
f->glEnableVertexAttribArray(6);
|
f->glEnableVertexAttribArray(6);
|
||||||
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
|
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), 0);
|
||||||
f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(3 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(3 * sizeof(GLfloat)));
|
||||||
f->glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(6 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(6 * sizeof(GLfloat)));
|
||||||
f->glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(9 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(9 * sizeof(GLfloat)));
|
||||||
f->glVertexAttribPointer(4, 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(11 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(4, 1, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(11 * sizeof(GLfloat)));
|
||||||
f->glVertexAttribPointer(5, 1, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(12 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(5, 1, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(12 * sizeof(GLfloat)));
|
||||||
f->glVertexAttribPointer(6, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void *>(13 * sizeof(GLfloat)));
|
f->glVertexAttribPointer(6, 3, GL_FLOAT, GL_FALSE, sizeof(ShaderVertex), reinterpret_cast<void *>(13 * sizeof(GLfloat)));
|
||||||
m_vboEdge.release();
|
m_vboEdge.release();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -200,7 +200,7 @@ void RigGenerator::generate()
|
||||||
|
|
||||||
// Create mesh for demo
|
// Create mesh for demo
|
||||||
|
|
||||||
Vertex *triangleVertices = new Vertex[m_outcome->triangles.size() * 3];
|
ShaderVertex *triangleVertices = new ShaderVertex[m_outcome->triangles.size() * 3];
|
||||||
int triangleVerticesNum = 0;
|
int triangleVerticesNum = 0;
|
||||||
const QVector3D defaultUv = QVector3D(0, 0, 0);
|
const QVector3D defaultUv = QVector3D(0, 0, 0);
|
||||||
const QVector3D defaultTangents = QVector3D(0, 0, 0);
|
const QVector3D defaultTangents = QVector3D(0, 0, 0);
|
||||||
|
@ -210,7 +210,7 @@ void RigGenerator::generate()
|
||||||
if (nullptr != triangleTangents)
|
if (nullptr != triangleTangents)
|
||||||
sourceTangent = &(*triangleTangents)[triangleIndex];
|
sourceTangent = &(*triangleTangents)[triangleIndex];
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
Vertex ¤tVertex = triangleVertices[triangleVerticesNum++];
|
ShaderVertex ¤tVertex = triangleVertices[triangleVerticesNum++];
|
||||||
const auto &sourcePosition = inputVerticesPositions[sourceTriangle[i]];
|
const auto &sourcePosition = inputVerticesPositions[sourceTriangle[i]];
|
||||||
const auto &sourceColor = inputVerticesColors[sourceTriangle[i]];
|
const auto &sourceColor = inputVerticesColors[sourceTriangle[i]];
|
||||||
const auto *sourceNormal = &defaultUv;
|
const auto *sourceNormal = &defaultUv;
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef DUST3D_SHADER_VERTEX_H
|
||||||
|
#define DUST3D_SHADER_VERTEX_H
|
||||||
|
#include <QOpenGLFunctions>
|
||||||
|
|
||||||
|
#pragma pack(push)
|
||||||
|
#pragma pack(1)
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GLfloat posX;
|
||||||
|
GLfloat posY;
|
||||||
|
GLfloat posZ;
|
||||||
|
GLfloat normX;
|
||||||
|
GLfloat normY;
|
||||||
|
GLfloat normZ;
|
||||||
|
GLfloat colorR;
|
||||||
|
GLfloat colorG;
|
||||||
|
GLfloat colorB;
|
||||||
|
GLfloat texU;
|
||||||
|
GLfloat texV;
|
||||||
|
GLfloat metalness;
|
||||||
|
GLfloat roughness;
|
||||||
|
GLfloat tangentX;
|
||||||
|
GLfloat tangentY;
|
||||||
|
GLfloat tangentZ;
|
||||||
|
} ShaderVertex;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#endif
|
|
@ -59,11 +59,11 @@ MeshLoader *SkinnedMeshCreator::createMeshFromTransform(const std::vector<QMatri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vertex *triangleVertices = new Vertex[m_outcome.triangles.size() * 3];
|
ShaderVertex *triangleVertices = new ShaderVertex[m_outcome.triangles.size() * 3];
|
||||||
int triangleVerticesNum = 0;
|
int triangleVerticesNum = 0;
|
||||||
for (size_t triangleIndex = 0; triangleIndex < m_outcome.triangles.size(); triangleIndex++) {
|
for (size_t triangleIndex = 0; triangleIndex < m_outcome.triangles.size(); triangleIndex++) {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
Vertex ¤tVertex = triangleVertices[triangleVerticesNum++];
|
ShaderVertex ¤tVertex = triangleVertices[triangleVerticesNum++];
|
||||||
const auto &sourcePosition = transformedPositions[triangleIndex][i];
|
const auto &sourcePosition = transformedPositions[triangleIndex][i];
|
||||||
const auto &sourceColor = m_triangleColors[triangleIndex];
|
const auto &sourceColor = m_triangleColors[triangleIndex];
|
||||||
const auto &sourceNormal = transformedPoseNormals[triangleIndex][i];
|
const auto &sourceNormal = transformedPoseNormals[triangleIndex][i];
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include "toolmesh.h"
|
||||||
|
|
||||||
|
void ToolMesh::addNode(const QVector3D &position, float radius, const QMatrix4x4 &transform)
|
||||||
|
{
|
||||||
|
m_nodes.push_back({position, radius, transform});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolMesh::generate()
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
ShaderVertex *ToolMesh::takeShaderVertices(int *shaderVertexCount)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return nullptr;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef DUST3D_TOOL_MESH_H
|
||||||
|
#define DUST3D_TOOL_MESH_H
|
||||||
|
#include <QVector3D>
|
||||||
|
#include <QMatrix4x4>
|
||||||
|
#include <vector>
|
||||||
|
#include "shadervertex.h"
|
||||||
|
|
||||||
|
class ToolMesh
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void addNode(const QVector3D &position, float radius, const QMatrix4x4 &transform);
|
||||||
|
void generate();
|
||||||
|
ShaderVertex *takeShaderVertices(int *shaderVertexCount);
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Node
|
||||||
|
{
|
||||||
|
QVector3D position;
|
||||||
|
float radius;
|
||||||
|
QMatrix4x4 transform;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Node> m_nodes;
|
||||||
|
ShaderVertex *m_shaderVertices = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue