#pragma once #include "core.h" #include "DirectXCore.h" #include // Core material class. Ideally, this should be extended to include more material attributes that can be // recovered from Assimp, but this handles the basics. class Material { public: Material(wstring materialName, XMFLOAT4 diffuseColour, XMFLOAT4 specularColour, float shininess, float opacity, ComPtr texture ); ~Material(); inline wstring GetMaterialName() { return _materialName; } inline XMFLOAT4 GetDiffuseColour() { return _diffuseColour; } inline XMFLOAT4 GetSpecularColour() { return _specularColour; } inline float GetShininess() { return _shininess; } inline float GetOpacity() { return _opacity; } inline ComPtr GetTexture() { return _texture; } private: wstring _materialName; XMFLOAT4 _diffuseColour; XMFLOAT4 _specularColour; float _shininess; float _opacity; ComPtr _texture; }; // Basic SubMesh class. A Mesh consists of one or more sub-meshes. The submesh provides everything that is needed to // draw the sub-mesh. class SubMesh { public: SubMesh(ComPtr vertexBuffer, ComPtr indexBuffer, size_t vertexCount, size_t indexCount, shared_ptr material); ~SubMesh(); inline ComPtr GetVertexBuffer() { return _vertexBuffer; } inline ComPtr GetIndexBuffer() { return _indexBuffer; } inline shared_ptr GetMaterial() { return _material; } inline size_t GetVertexCount() { return _vertexCount; } inline size_t GetIndexCount() { return _indexCount; } private: ComPtr _vertexBuffer; ComPtr _indexBuffer; shared_ptr _material; size_t _vertexCount; size_t _indexCount; }; // The core Mesh class. A Mesh corresponds to a scene in ASSIMP. A mesh consists of one or more sub-meshes. class Node { public: inline void SetName(wstring name) { _name = name; } inline wstring GetName() { return _name; } inline size_t GetMeshCount() { return _meshIndices.size(); } inline unsigned int GetMesh(unsigned int index) { return _meshIndices[index]; } inline void AddMesh(unsigned int meshIndex) { _meshIndices.push_back(meshIndex); } inline size_t GetChildrenCount() { return _children.size(); } inline shared_ptr GetChild(unsigned int index) { return _children[index]; } inline void AddChild(shared_ptr node) { _children.push_back(node); } private: wstring _name; vector _meshIndices; vector> _children; }; class Mesh { public: size_t GetSubMeshCount(); shared_ptr GetSubMesh(unsigned int i); void AddSubMesh(shared_ptr subMesh); shared_ptr GetRootNode(); void SetRootNode(shared_ptr node); private: vector> _subMeshList; shared_ptr _rootNode; };