-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
131 lines (99 loc) · 2.97 KB
/
Copy pathmain.cpp
File metadata and controls
131 lines (99 loc) · 2.97 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <vart/scene.h>
#include <vart/light.h>
#include <vart/arrow.h>
#include <vart/meshobject.h>
#include <vart/sphere.h>
#include <vart/contrib/viewerglutogl.h>
#include <vart/contrib/mousecontrol.h>
#include <iostream>
using namespace std;
using namespace VART;
class Pyramids : public MeshObject{
public:
Pyramids(){
vector<double> vertices({
0,0,0,
-1,1,-1,
1,1,-1,
1,1,1,
-1,1,1,
-1,-1,-1,
1,-1,-1,
1,-1,1,
-1,-1,1,
});
vector<unsigned int> base({
3,2,1,4,
5,6,7,8
});
vector<unsigned int> sides({
3,4,0,
4,1,0,
1,2,0,
2,3,0,
7,0,8,
8,0,5,
5,0,6,
6,0,7
});
vertCoordVec = vertices;
VART::Mesh meshBase;
meshBase.type = VART::Mesh::QUADS;
meshBase.indexVec = base;
meshBase.material = VART::Material::PLASTIC_GREEN();
meshList.push_back(meshBase);
VART::Mesh meshSides;
meshSides.indexVec = sides;
meshSides.type = VART::Mesh::TRIANGLES;
meshSides.material = VART::Material::PLASTIC_GREEN();
meshList.push_back(meshSides);
ComputeBoundingBox();
ComputeRecursiveBoundingBox();
ComputeVertexNormals();
}
};
// Define the click handler
class ClickHandlerClass : public VART::MouseControl::ClickHandler
{
public:
ClickHandlerClass() {
}
virtual ~ClickHandlerClass() {};
virtual void OnClick() {
if (mouseCtrlPtr->LastClickIsDown()) {
}
}
};
// The application itself:
int main(int argc, char* argv[])
{
VART::ViewerGlutOGL::Init(&argc, argv); // Initialize GLUT
static VART::Scene scene; // create a scene
static VART::ViewerGlutOGL viewer; // create a viewer (application window)
// create a camera (scene observer)
VART::Camera camera(VART::Point4D(0,0,6),VART::Point4D::ORIGIN(),VART::Point4D::Y());
Pyramids pyramids;
scene.AddObject(&pyramids);
// // Create some objects
// VART::Arrow arrowX(2);
// VART::Arrow arrowY(VART::Point4D::ORIGIN(), VART::Point4D::Y()*2);
// VART::Arrow arrowZ(VART::Point4D::ORIGIN(), VART::Point4D::Z()*2);
// // Initialize scene objects
// arrowX.SetMaterial(VART::Material::PLASTIC_RED());
// arrowY.SetMaterial(VART::Material::PLASTIC_GREEN());
// arrowZ.SetMaterial(VART::Material::PLASTIC_BLUE());
// // Build the scene graph
// scene.AddObject(&arrowX);
// scene.AddObject(&arrowY);
// scene.AddObject(&arrowZ);
// Add lights and cameras to the scene
scene.AddLight(VART::Light::BRIGHT_AMBIENT());
scene.AddCamera(&camera);
// Set up the viewer
viewer.SetTitle("V-ART arrow example");
viewer.SetScene(scene); // attach the scene
// Run application
scene.DrawLightsOGL(); // Set OpenGL's lights' state
VART::ViewerGlutOGL::MainLoop(); // Enter main loop (event loop) and never return
return 0;
}