-
Notifications
You must be signed in to change notification settings - Fork 0
/
obj_object.h
73 lines (53 loc) · 1.29 KB
/
obj_object.h
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
63
64
65
66
67
68
69
70
71
72
73
#ifndef OBJ_OBJECT_H
#define OBJ_OBJECT_H
#include "object.h"
#include "vector.h"
//#define USE_KD_TREE_OBJ
//unsigned nObjDepth = 3;
///
/// class ObjObject
///
/// NOTE: Triangle intersection logic is in this class
///
class ObjObject : public Object
{
public:
ObjObject(float fReflR = 1.f, float fRefrR = 0.f, float fRefrK = 1.f, float fEmitR = 1.0);
~ObjObject();
ObjType getObjType()
{ return OBJ_CPU; }
bool load(char *pObjPath);
void scale(float x, float y, float z);
void translate(float x, float y, float z);
void rotate(float angle, vect3d& axis);
void setSmooth(bool bSmooth);
bool isHit(Ray &ray, vect3d &pNormal, float *pt, vect3d *pTexColor = NULL);
#ifdef USE_KD_TREE_OBJ
void buildKdTree();
#endif
// For GPU use
unsigned getTriCount()
{ return _nTriNum; }
Triangle *getTriangle(unsigned inx)
{ return _triangles[inx]; }
//
protected:
void updateBBox();
public:
bool _bSmooth;
bool _bHasVNorm;
protected:
///
/// NOTE: As you may know, GLM stores all data collectively and makes reference into the arrays
/// when rendering. However, this memory reference can slow down my rendering a lot due to
/// the overly memory access.
///
unsigned _nTriNum;
Triangle **_triangles;
public:
// kd-tree
#ifdef USE_KD_TREE_OBJ
kd_node *_pKdNode;
#endif
};
#endif