forked from gameprogcpp/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMesh.h
More file actions
62 lines (59 loc) · 1.96 KB
/
Mesh.h
File metadata and controls
62 lines (59 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// ----------------------------------------------------------------
// From Game Programming in C++ by Sanjay Madhav
// Copyright (C) 2017 Sanjay Madhav. All rights reserved.
//
// Released under the BSD License
// See LICENSE in root directory for full details.
// ----------------------------------------------------------------
#pragma once
#include <vector>
#include <string>
#include "Collision.h"
#include "VertexArray.h"
class Mesh
{
public:
Mesh();
~Mesh();
// Load/unload mesh
bool Load(const std::string& fileName, class Renderer* renderer);
void Unload();
// Get the vertex array associated with this mesh
VertexArray* GetVertexArray() { return mVertexArray; }
// Get a texture from specified index
class Texture* GetTexture(size_t index);
// Get name of shader
const std::string& GetShaderName() const { return mShaderName; }
// Get file name
const std::string& GetFileName() const { return mFileName; }
// Get object space bounding sphere radius
float GetRadius() const { return mRadius; }
// Get object space bounding box
const AABB& GetBox() const { return mBox; }
// Get specular power of mesh
float GetSpecPower() const { return mSpecPower; }
// Save the mesh in binary format
void SaveBinary(const std::string& fileName, const void* verts,
uint32_t numVerts, VertexArray::Layout layout,
const uint32_t* indices, uint32_t numIndices,
const std::vector<std::string>& textureNames,
const AABB& box, float radius,
float specPower);
// Load in the mesh from binary format
bool LoadBinary(const std::string& fileName, class Renderer* renderer);
private:
// AABB collision
AABB mBox;
// Textures associated with this mesh
std::vector<class Texture*> mTextures;
// Vertex array associated with this mesh
VertexArray* mVertexArray;
// Name of shader specified by mesh
std::string mShaderName;
// Name of mesh file
std::string mFileName;
// Stores object space bounding sphere radius
float mRadius;
// Specular power of surface
float mSpecPower;
};