-
Notifications
You must be signed in to change notification settings - Fork 0
/
vxTextured_UT.cpp
128 lines (100 loc) · 2.61 KB
/
vxTextured_UT.cpp
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
/**
*
* file vxTextured_UT.cpp
*
* This test file is a part of VoxelBrain software.
*
* (c) Nanyang Technological University
*
* Author: Konstantin Levinski
*
*/
#include <gtest/gtest.h>
#include "vxTextured.h"
#include "vxAction.h"
#include "vxOpenGlTools.h"
#include "vxDrawSphere.h"
#include "vxDrawSurface.h"
#include "vxLoader.h"
#include "vxSurface.h"
#include "vxMotion.h"
#include "vxRay.h"
#include "vxProjection.h"
/*
TEST(MAIN, Textured){
//TODO - remove if done in vxDrawSphere_UT.h
FastVolume vol;
MgzLoader mri(vol);
EXPECT_TRUE(mri.Load("data/brainmask.mgz"));
Textured tex;
tex.texturing_fastvolume = &vol;
struct TexturedSphere: Action {
FastVolume * vol;
Textured * tex;
struct MovingAction: Action {
V3f center;
MovingAction():center(0,0,0){};
void Do(){
Intersection isct = IntersectRaySphere(GetMotion()->sight, V3f(0,0,0), 60);
if(isct.hit){
center = GetMotion()->sight.Travel(isct.distance);
};
}
}pointer;
void Draw(){
DrawSphereFunction( pointer.center, 30, 30, tex);
glColor4f(0.5f,0.5f,0.5f,0.5f);
glDisable(GL_TEXTURE);
DrawSphere(V3f(0,0,0), 60, 60).Draw();
};
TexturedSphere(FastVolume * _vol, Textured * _tex):vol(_vol), tex(_tex){};
} scene(&vol, &tex);
scene.pointer.bind(GLFW_KEY_RCTRL);
GetScene()->run( & scene);
};
*/
//TODO - figure out where to drop this shit.
V3f center;
Surface surf;
FastVolume vol;
Textured tex;
struct SurfacePointer: Action {
void Do(){
Intersection isct = IntersectRaySurface(GetMotion()->sight, &surf);
if(isct.hit){
center = GetMotion()->sight.Travel(isct.distance);
center *= 0.8;
};
};
} sphere_placer;
struct PushingAction: Action {
void Do(){
Intersection isct = IntersectRaySphere(GetMotion()->sight, center, 30);
if(isct.hit){
V3f pos = GetMotion()->sight.Travel(isct.distance);
PushPoint(surf, pos);
FixNormals(surf);
AnalyzeSurface(surf, vol);
};
}
} pusher;
TEST(MAIN, BrainTextured){
//TODO - remove if done in vxDrawSphere_UT.h
MgzLoader mri(vol);
EXPECT_TRUE(mri.Load("data/brainmask.mgz"));
EXPECT_TRUE(read_surface_binary(surf, "data/lh.pial"));
tex.texturing_fastvolume = &vol;
AnalyzeSurface(surf, vol);
struct TexturedSphere: public Action {
void Draw(){
DrawSphereFunction( center, 30, 30, &tex);
glColor4f(0.5f,0.5f,0.5f,0.5f);
SortSurface(&surf, GetProjection()->Z());
DrawSurface(surf);
};
} scene;
sphere_placer.bind(GLFW_KEY_RCTRL);
pusher.bind(GLFW_KEY_F2);
GetScene()->run( & scene );
};
//End of vxTextured_UT.cpp