-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimitive.h
96 lines (83 loc) · 1.56 KB
/
Primitive.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#pragma once
#include "glmath.h"
#include "Color.h"
enum PrimitiveTypes
{
Primitive_Point,
Primitive_Line,
Primitive_Plane,
Primitive_Cube,
Primitive_Sphere,
Primitive_Cylinder
};
class Primitive
{
public:
Primitive();
virtual void Render() const;
virtual void InnerRender() const;
void SetPos(float x, float y, float z);
void SetRotation(float angle, const vec3 &u);
void Scale(float x, float y, float z);
PrimitiveTypes GetType() const;
public:
Color color;
mat4x4 transform;
bool axis,wire;
protected:
PrimitiveTypes type;
};
// ============================================
class Cube : public Primitive
{
public :
Cube();
Cube(float sizeX, float sizeY, float sizeZ);
void InnerRender() const;
void Size(float x, float y, float z);
public:
vec3 size;
};
// ============================================
class Sphere : public Primitive
{
public:
Sphere();
Sphere(float radius);
void InnerRender() const;
public:
float radius;
};
// ============================================
class Cylinder : public Primitive
{
public:
Cylinder();
Cylinder(float radius, float height);
void InnerRender() const;
public:
float radius;
float height;
};
// ============================================
class Line : public Primitive
{
public:
Line();
Line(float x, float y, float z);
void InnerRender() const;
public:
vec3 origin;
vec3 destination;
};
// ============================================
class Plane : public Primitive
{
public:
Plane();
Plane(float x, float y, float z, float d);
void InnerRender() const;
public:
vec3 normal;
float constant;
};