Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-----------------------------------------*\
- | md5animation.h |
- | |
- | |
- \*-----------------------------------------*/
- #ifndef _MD5ANIMATION_H_
- #define _MD5ANIMATION_H_
- #include <D3D11.h>
- #include <D3DX11.h>
- #include <D3DX10math.h>
- #include <xnamath.h>
- #include <vector>
- #include <fstream>
- #include <iostream>
- #include <string>
- #include <cstring>
- #include <Windows.h>
- using namespace std;
- #pragma comment(lib, "d3d11.lib")
- #pragma comment(lib, "d3dx11.lib")
- #include "Texture.h"
- class md5animation
- {
- private:
- //Overloaded VertexType Structure
- //Stores information sent to shader
- //Stores Vertices start weight index value - Will not be sent to shader
- //Stores number of weights per vertex bound - Will not be sent to shader
- struct VertexType
- {
- VertexType(){}
- VertexType(float x, float y, float z,
- float u, float v,
- float nx, float ny, float nz,
- float tx, float ty, float tz)
- : pos(x, y, z), texCoord(u, v),
- normal(nx, ny, nz),tangent(tx, ty, tz){}
- XMFLOAT3 pos;
- XMFLOAT2 texCoord;
- XMFLOAT3 normal;
- XMFLOAT3 tangent;
- XMFLOAT3 biTangent;
- //Will not be sent to shader
- int StartWeight;
- int WeightCount;
- };
- //Joint
- //Stores Joint information for the md5mesh file
- struct Joint
- {
- std::wstring name;
- int parentID;
- XMFLOAT3 pos;
- XMFLOAT4 orientation;
- };
- //Weight
- //Stores Weight information for the md5mesh file
- struct Weight
- {
- int jointID;
- float bias;
- XMFLOAT3 pos;
- };
- //Model Subset
- //Stores various information for md5mesh file, most of them vectors
- //Includes a brand new vertex and index buffer
- struct ModelSubset
- {
- int texArrayIndex;
- int numTriangles;
- std::vector<VertexType> vertices;
- std::vector<DWORD> indices;
- std::vector<Weight> weights;
- std::vector<XMFLOAT3> positions;
- ID3D11Buffer* vertBuff;
- ID3D11Buffer* indexBuff;
- };
- //Model 3D
- //Stores information that applies to the model as a whole
- struct Model3D
- {
- int numSubsets;
- int numJoints;
- std::vector<Joint> joints;
- std::vector<ModelSubset> subsets;
- };
- //cbPerObject
- //Create effects constant buffer's structure
- struct cbPerObject
- {
- XMMATRIX WVP;
- XMMATRIX World;
- //These will be used for the pixel shader
- XMFLOAT4 difColor;
- BOOL hasTexture;
- //Because of HLSL structure packing, we will use windows BOOL
- //instead of bool because HLSL packs things into 4 bytes, and
- //bool is only one byte, where BOOL is 4 bytes
- BOOL hasNormMap;
- };
- public:
- //Public
- md5animation();
- ~md5animation();
- bool Init(ID3D11Device*, WCHAR*, WCHAR*);
- void Render(ID3D11DeviceContext*);
- void Shutdown();
- int GetIndexCount();
- ID3D11ShaderResourceView* GetTexture();
- private:
- bool InitBuffers(ID3D11Device*);
- void ShutdownBuffers();
- void RenderBuffers(ID3D11DeviceContext*);
- bool LoadTexture(ID3D11Device*, WCHAR*);
- void ReleaseTexture();
- bool LoadMD5Model(ID3D11Device*,
- std::wstring filename,
- Model3D& MD5Model,
- std::vector<ID3D11ShaderResourceView*>& shaderResourceViewArray,
- std::vector<std::wstring> texFileNameArray);
- void ReleaseModel();
- private:
- ID3D11Buffer *m_vertexBuffer;
- ID3D11Buffer* m_indexBuffer;
- ID3D11Buffer* cbPerObjectBuffer;
- int m_vertexCount;
- int m_indexCount;
- XMMATRIX m_smilesWorld; //World Matrix
- Model3D m_NewMD5Model; //Model Data
- Texture* m_texture; //Texture Data
- cbPerObject m_cbPerObj; //Constant Buffer
- //Textures and Material variables, used for all mesh's loaded
- std::vector<ID3D11ShaderResourceView*> m_meshSRV;
- std::vector<std::wstring> m_textureNameArray;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement