代码拉取完成,页面将自动刷新
#ifndef MODELLOADER_H
#define MODELLOADER_H
#include <string>
#include <QMatrix4x4>
#include <vector>
#include <QFile>
#include <QSharedPointer>
#include <QDir>
struct aiScene;
struct aiNode;
struct aiMesh;
struct aiMaterial;
struct MaterialInfo
{
QString Name;
QVector3D Ambient;
QVector3D Diffuse;
QVector3D Specular;
float Shininess;
};
struct LightInfo
{
QVector4D Position;
QVector3D Intensity;
};
struct Mesh
{
QString name;
unsigned int indexCount;
unsigned int indexOffset;
QSharedPointer<MaterialInfo> material;
};
struct Node
{
QString name;
QMatrix4x4 transformation;
QVector<QSharedPointer<Mesh> > meshes;
QVector<Node> nodes;
};
class ModelLoader
{
public:
enum PathType {
RelativePath,
AbsolutePath
};
ModelLoader(bool transformToUnitCoordinates = true);
bool Load(QString filePath, PathType pathType);
void getBufferData( QVector<float> **vertices, QVector<float> **normals,
QVector<unsigned int> **indices);
void getTextureData( QVector<QVector<float> > **textureUV, // For texture mapping
QVector<float> **tangents, QVector<float> **bitangents);// For normal mapping
QSharedPointer<Node> getNodeData() { return m_rootNode; }
// Texture information
int numUVChannels() { return m_textureUV.size(); }
int numUVComponents(int channel) { return m_textureUVComponents.at(channel); }
private:
QSharedPointer<MaterialInfo> processMaterial(aiMaterial *mater);
QSharedPointer<Mesh> processMesh(aiMesh *mesh);
void processNode(const aiScene *scene, aiNode *node, Node *parentNode, Node &newNode);
void transformToUnitCoordinates();
void findObjectDimensions(Node *node, QMatrix4x4 transformation, QVector3D &minDimension, QVector3D &maxDimension);
QVector<float> m_vertices;
QVector<float> m_normals;
QVector<unsigned int> m_indices;
QVector<QVector<float> > m_textureUV; // multiple channels
QVector<float> m_tangents;
QVector<float> m_bitangents;
QVector<unsigned int > m_textureUVComponents; // multiple channels
QVector<QSharedPointer<MaterialInfo> > m_materials;
QVector<QSharedPointer<Mesh> > m_meshes;
QSharedPointer<Node> m_rootNode;
bool m_transformToUnitCoordinates;
};
#endif // MODELLOADER_H
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。