fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
1
2
3
|
#ifndef STIM_GL_SPIDER_H
#define STIM_GL_SPIDER_H
|
a9b45efe
Pavel Govyadinov
changes to spider
|
4
|
#include <GL/glew.h>
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
5
|
#include <GL/glut.h>
|
a9b45efe
Pavel Govyadinov
changes to spider
|
6
7
8
|
#include <cuda.h>
#include <cuda_gl_interop.h>
#include <cudaGL.h>
|
1a456186
Pavel Govyadinov
Added directional...
|
9
|
#include <math.h>
|
556c4e15
Pavel Govyadinov
Changed the handl...
|
10
11
12
|
#include "stim/gl/gl_texture.h"
#include "stim/visualization/camera.h"
#include "stim/gl/error.h"
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
13
|
#include "stim/math/mathvec.h"
|
556c4e15
Pavel Govyadinov
Changed the handl...
|
14
15
16
17
|
#include "stim/math/rect.h"
#include "stim/math/matrix.h"
#include "stim/cuda/cost.h"
#include "stim/cuda/glbind.h"
|
c4887649
Pavel Govyadinov
fixed a significa...
|
18
|
#include <stim/visualization/obj.h>
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
19
|
#include <vector>
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
20
|
|
42145f38
Pavel Govyadinov
Fixed the issues ...
|
21
22
23
|
#include <iostream>
#include <fstream>
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
24
25
26
27
28
|
/* Technically since gl_spider inherits from gl_texture, we could
call the init with a path to an image stack, and upload
the images while creating the spider (calling init) */
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
29
30
31
32
|
namespace stim
{
template<typename T>
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
33
|
class gl_spider
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
34
35
|
{
//doen't use gl_texture really, just needs the GLuint id.
|
4cefeb6d
Pavel Govyadinov
Changes to the re...
|
36
|
//doesn't even need the texture iD really.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
37
|
private:
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
38
39
|
stim::vec<float> p; //vector designating the position of the spider.
stim::vec<float> d; //vector designating the orientation of the spider
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
40
|
//always a unit vector.
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
41
|
stim::vec<float> m; //magnitude of the spider vector.
|
4cefeb6d
Pavel Govyadinov
Changes to the re...
|
42
43
|
//mag[0] = length.
//mag[1] = width.
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
44
45
46
47
48
49
50
51
|
std::vector<stim::vec<float> > dV;
std::vector<stim::vec<float> > pV;
std::vector<stim::vec<float> > mV;
//currentTransform
stim::matrix<float, 4> cT;
GLuint texID;
stim::vec<float> S;
stim::vec<float> R;
|
a9b45efe
Pavel Govyadinov
changes to spider
|
52
|
cudaGraphicsResource_t resource;
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
53
|
|
db3c28c9
Pavel Govyadinov
Implemented glDis...
|
54
|
GLuint dList;
|
a9b45efe
Pavel Govyadinov
changes to spider
|
55
56
|
GLuint fboID;
GLuint texbufferID;
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
57
|
int numSamples;
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
58
|
float stepsize = 3.0;
|
c4887649
Pavel Govyadinov
fixed a significa...
|
59
|
int current_cost;
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
60
61
62
63
64
65
66
|
/// Method for finding the best scale for the spider.
/// changes the x, y, z size of the spider to minimize the cost
/// function.
void
findOptimalDirection()
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
67
|
setMatrix();
|
db3c28c9
Pavel Govyadinov
Implemented glDis...
|
68
|
glCallList(dList);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
69
|
int best = getCost();
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
70
71
72
73
|
stim::vec<float> next(
dV[best][0]*S[0]*R[0],
dV[best][1]*S[1]*R[1],
dV[best][2]*S[2]*R[2],
|
d4721000
Pavel Govyadinov
changes with debu...
|
74
|
0);
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
75
|
next = (cT*next).norm();
|
80d3850d
Pavel Govyadinov
test
|
76
|
//next = (cT*next);
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
77
78
79
|
setPosition( p[0]+next[0]*m[0]/stepsize,
p[1]+next[1]*m[0]/stepsize,
p[2]+next[2]*m[0]/stepsize);
|
556c4e15
Pavel Govyadinov
Changed the handl...
|
80
|
setDirection(next[0], next[1], next[2]);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
81
82
|
}
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
83
84
85
|
/// Method for finding the best d for the spider.
/// Not sure if necessary since the next p for the spider
/// will be at d * m.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
86
87
88
|
void
findOptimalPosition()
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
89
|
setMatrix();
|
db3c28c9
Pavel Govyadinov
Implemented glDis...
|
90
|
glCallList(dList+1);
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
91
|
int best = getCost();
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
92
93
94
95
96
|
stim::vec<float> next(
pV[best][0],
pV[best][1],
pV[best][2],
1);
|
ef64ebad
Pavel Govyadinov
fixed a small mis...
|
97
|
next = cT*next;
|
d4721000
Pavel Govyadinov
changes with debu...
|
98
99
|
setPosition(
next[0]*S[0]*R[0],
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
100
|
next[1]*S[1]*R[1],
|
d4721000
Pavel Govyadinov
changes with debu...
|
101
102
|
next[2]*S[2]*R[2]
);
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
103
104
|
}
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
105
106
107
|
/// Method for finding the best scale for the spider.
/// changes the x, y, z size of the spider to minimize the cost
/// function. */
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
108
109
110
|
void
findOptimalScale()
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
111
|
setMatrix();
|
db3c28c9
Pavel Govyadinov
Implemented glDis...
|
112
|
glCallList(dList+2);
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
113
|
int best = getCost();
|
d4721000
Pavel Govyadinov
changes with debu...
|
114
|
setMagnitude(m[0]*mV[best][0]);
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
115
116
|
}
|
f31bf86d
Pavel Govyadinov
Added skeleton fu...
|
117
118
119
120
|
void
branchDetection()
{
Bind();
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
121
|
setMatrix();
|
f31bf86d
Pavel Govyadinov
Added skeleton fu...
|
122
123
|
glCallList(dList+3);
|
c4887649
Pavel Govyadinov
fixed a significa...
|
124
|
// int best = getCost();
|
f31bf86d
Pavel Govyadinov
Added skeleton fu...
|
125
126
127
|
}
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
128
129
|
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
130
|
void
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
131
|
Optimize()
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
132
|
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
133
|
/*find the optimum d and scale */
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
134
|
}
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
135
|
|
a9b45efe
Pavel Govyadinov
changes to spider
|
136
|
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
137
138
139
140
141
142
143
144
|
//--------------------------------------------------------------------------//
//---------------------TEMPLATE CREATION METHODS----------------------------//
//--------------------------------------------------------------------------//
///@param solidAngle, the size of the arc to sample.
///Method for populating the vector arrays with sampled vectors.
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
145
|
///uses the default d vector <0,0,1>
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
146
|
void
|
25580fe7
Pavel Govyadinov
minor bug fix in ...
|
147
|
genDirectionVectors(float solidAngle = M_PI)
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
148
|
{
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
149
150
|
//ofstream file;
//file.open("dvectors.txt");
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
151
|
//Set up the vectors necessary for Rectangle creation.
|
22e7d0c5
Pavel Govyadinov
Minor changes in ...
|
152
153
154
155
156
|
vec<float> Y(1.0,0.0,0.0);
vec<float> pos(0.0,0.0,0.0);
vec<float> mag(1.0, 1.0, 1.0);
vec<float> dir(0.0, 0.0, 1.0);
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
157
158
|
//Set up the variable necessary for vector creation.
vec<float> d_s = d.cart2sph().norm();
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
159
|
vec<float> temp(0,0,0);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
160
|
int dim = (sqrt(numSamples)-1)/2;
|
25580fe7
Pavel Govyadinov
minor bug fix in ...
|
161
162
163
|
float p0 = -M_PI;
float dt = solidAngle/(2.0 * ((float)dim + 1.0));
float dp = p0/(2.0*((float)dim + 1.0));
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
164
165
166
167
|
glNewList(dList, GL_COMPILE);
//Loop over the space
int idx = 0;
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
168
169
|
for(int i = -dim; i <= dim; i++){
for(int j = -dim; j <= dim; j++){
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
170
|
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
171
|
//Create linear index
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
172
|
idx = (j+dim)+(i+dim)*((dim*2)+1);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
173
|
temp[0] = d_s[0]; //rotate vector
|
25580fe7
Pavel Govyadinov
minor bug fix in ...
|
174
175
|
temp[1] = d_s[1]+dp*(float) i;
temp[2] = d_s[2]+dt*(float) j;
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
176
177
|
temp = (temp.sph2cart()).norm(); //back to cart
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
178
179
180
181
182
183
184
185
186
187
188
189
|
dV.push_back(temp);
if(cos(Y.dot(temp))< 0.087){ Y[0] = 0.0; Y[1] = 1.0;}
else{Y[0] = 1.0; Y[1] = 0.0;}
hor = stim::rect<float>(mag,
pos, temp,
((Y.cross(temp)).cross(temp)).norm());
ver = stim::rect<float>(mag,
pos, temp,
hor.n());
UpdateBuffer(0.0, 0.0+idx*10.0);
CHECK_OPENGL_ERROR
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
190
191
|
}
}
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
192
|
glEndList();
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
193
|
}
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
194
|
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
195
196
197
|
///@param solidAngle, the size of the arc to sample.
///Method for populating the buffer with the sampled texture.
///uses the default vector <0,0,0>
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
198
|
void
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
199
|
genPositionVectors(float delta = 0.2)
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
200
|
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
201
202
203
204
205
206
207
|
//Set up the vectors necessary for Rectangle creation.
vec<float> Y(1.0,0.0,0.0);
vec<float> pos(0.0,0.0,0.0);
vec<float> mag(1.0, 1.0, 1.0);
vec<float> dir(0.0, 0.0, 1.0);
//Set up the variable necessary for vector creation.
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
208
|
vec<float> temp(0,0,0);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
209
210
|
int dim = (sqrt(numSamples)-1)/2;
stim::rect<float> samplingPlane =
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
211
|
stim::rect<float>(p, d);
|
d4721000
Pavel Govyadinov
changes with debu...
|
212
|
samplingPlane.scale(mag[0]*delta, mag[0]*delta);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
213
|
float step = 1.0/(dim);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
214
|
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
215
216
217
218
|
//Loop over the samples, keeping the original p sample
//in the center of the resulting texture.
int idx;
glNewList(dList+1, GL_COMPILE);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
219
220
221
|
for(int i = -dim; i <= dim; i++){
for(int j = -dim; j <= dim; j++){
//Create linear index
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
222
|
idx = (j+dim)+(i+dim)*((dim*2)+1);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
223
224
225
226
227
|
temp = samplingPlane.p(
0.5+step*i,
0.5+step*j
);
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
228
229
230
231
232
233
234
235
236
237
|
pV.push_back(temp);
hor = stim::rect<float>(mag,
temp, dir,
((Y.cross(d)).cross(d))
.norm());
ver = stim::rect<float>(mag,
temp, dir,
hor.n());
UpdateBuffer(0.0, 0.0+idx*10.0);
CHECK_OPENGL_ERROR
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
238
239
|
}
}
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
240
|
glEndList();
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
241
242
243
244
|
}
///@param solidAngle, the size of the arc to sample.
///Method for populating the buffer with the sampled texture.
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
245
|
///uses the default m <1,1,0>
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
246
247
248
249
|
void
genMagnitudeVectors(float delta = 0.5)
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
250
251
252
253
254
255
256
|
//Set up the vectors necessary for Rectangle creation.
vec<float> Y(1.0,0.0,0.0);
vec<float> pos(0.0,0.0,0.0);
vec<float> mag(1.0, 1.0, 1.0);
vec<float> dir(0.0, 0.0, 1.0);
//Set up the variable necessary for vector creation.
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
257
258
259
260
261
|
int dim = (sqrt(numSamples)-1)/2;
float min = 1.0-delta;
float max = 1.0+delta;
float step = (max-min)/(numSamples-1);
float factor;
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
262
|
vec<float> temp(0.0,0.0,0.0);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
263
|
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
264
|
glNewList(dList+2, GL_COMPILE);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
265
266
|
for(int i = 0; i < numSamples; i++){
//Create linear index
|
d4721000
Pavel Govyadinov
changes with debu...
|
267
|
factor = (min+step*i)*mag[0];
|
db3c28c9
Pavel Govyadinov
Implemented glDis...
|
268
|
temp = factor;
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
269
270
271
272
273
274
275
276
277
278
|
mV.push_back(temp);
hor = stim::rect<float>(temp,
pos, dir,
((Y.cross(d)).cross(d))
.norm());
ver = stim::rect<float>(temp,
pos, dir,
hor.n());
UpdateBuffer(0.0, 0.0+i*10.0);
CHECK_OPENGL_ERROR
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
279
|
}
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
280
|
glEndList();
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
281
|
}
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
282
283
|
///@param v_x x-coordinate in buffer-space,
///@param v_y y-coordinate in buffer-space.
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
284
285
|
///Samples the texturespace and places a sample in the provided coordinates
///of bufferspace.
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
286
287
288
|
void
UpdateBuffer(float v_x, float v_y)
{
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
289
290
291
292
293
|
float len = 10.0;
stim::vec<float>p1;
stim::vec<float>p2;
stim::vec<float>p3;
stim::vec<float>p4;
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
294
|
p1 = hor.p(1,1);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
295
|
p2 = hor.p(1,0);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
296
|
p3 = hor.p(0,0);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
297
|
p4 = hor.p(0,1);
|
5e7c7581
Pavel Govyadinov
Debugging build f...
|
298
|
glBegin(GL_QUADS);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
299
|
glTexCoord3f(
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
300
301
302
303
|
p1[0],
p1[1],
p1[2]
);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
304
305
|
glVertex2f(v_x,v_y);
glTexCoord3f(
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
306
307
308
309
|
p2[0],
p2[1],
p2[2]
);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
310
311
|
glVertex2f(v_x+len, v_y);
glTexCoord3f(
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
312
313
314
315
|
p3[0],
p3[1],
p3[2]
);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
316
317
|
glVertex2f(v_x+len, v_y+len);
glTexCoord3f(
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
318
319
320
|
p4[0],
p4[1],
p4[2]
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
321
|
);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
322
323
|
glVertex2f(v_x, v_y+len);
glEnd();
|
5e7c7581
Pavel Govyadinov
Debugging build f...
|
324
|
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
325
|
p1 = ver.p(1,1);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
326
|
p2 = ver.p(1,0);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
327
|
p3 = ver.p(0,0);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
328
|
p4 = ver.p(0,1);
|
5e7c7581
Pavel Govyadinov
Debugging build f...
|
329
|
glBegin(GL_QUADS);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
330
|
glTexCoord3f(
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
331
332
333
334
|
p1[0],
p1[1],
p1[2]
);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
335
336
|
glVertex2f(v_x+len, v_y);
glTexCoord3f(
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
337
338
339
340
|
p2[0],
p2[1],
p2[2]
);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
341
342
|
glVertex2f(v_x+2*len, v_y);
glTexCoord3f(
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
343
344
345
346
|
p3[0],
p3[1],
p3[2]
);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
347
348
|
glVertex2f(v_x+2*len, v_y+len);
glTexCoord3f(
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
349
350
351
352
|
p4[0],
p4[1],
p4[2]
);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
353
|
glVertex2f(v_x+len, v_y+len);
|
5e7c7581
Pavel Govyadinov
Debugging build f...
|
354
|
glEnd();
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
355
|
}
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
356
|
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
357
|
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
358
|
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
359
360
361
|
//--------------------------------------------------------------------------//
//--------------------------------GL METHODS--------------------------------//
//--------------------------------------------------------------------------//
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
362
|
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
|
///@param width sets the width of the buffer.
///@param height sets the height of the buffer.
///Function for setting up the 2D buffer that stores the samples.
void
GenerateFBO(unsigned int width, unsigned int height)
{
glGenFramebuffers(1, &fboID);
glBindFramebuffer(GL_FRAMEBUFFER, fboID);
int numChannels = 1;
unsigned char* texels = new unsigned char[width * height * numChannels];
glGenTextures(1, &texbufferID);
glBindTexture(GL_TEXTURE_2D, texbufferID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE,
width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, texels);
delete[] texels;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
384
|
}
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
385
|
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
386
387
|
///Method for controling the buffer and texture binding in order to properly
///do the render to texture.
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
388
|
void
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
389
|
Bind()
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
390
|
{
|
5f81932b
David Mayerich
restored Pavel's ...
|
391
|
float len = 10.0;
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
392
393
394
395
396
397
398
399
400
401
402
|
glBindFramebuffer(GL_FRAMEBUFFER, fboID);//set up GL buffer
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
texbufferID,
0);
glBindFramebuffer(GL_FRAMEBUFFER, fboID);
GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
glDrawBuffers(1, DrawBuffers);
glBindTexture(GL_TEXTURE_2D, texbufferID);
|
5e7c7581
Pavel Govyadinov
Debugging build f...
|
403
|
glClearColor(1,1,1,1);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
404
|
glClear(GL_COLOR_BUFFER_BIT);
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
405
406
407
408
409
410
411
412
|
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0,0,2.0*len, numSamples*len);
gluOrtho2D(0.0,2.0*len,0.0,numSamples*len);
glEnable(GL_TEXTURE_3D);
glBindTexture(GL_TEXTURE_3D, texID);
|
957a4248
Pavel Govyadinov
renamed getSample...
|
413
|
|
5e7c7581
Pavel Govyadinov
Debugging build f...
|
414
|
CHECK_OPENGL_ERROR
|
5f81932b
David Mayerich
restored Pavel's ...
|
415
416
|
}
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
417
|
///Method for Unbinding all of the texture resources
|
5f81932b
David Mayerich
restored Pavel's ...
|
418
419
420
421
422
423
424
425
426
|
void
Unbind()
{
//Finalize GL_buffer
glBindTexture(GL_TEXTURE_3D, 0);
glDisable(GL_TEXTURE_3D);
glBindFramebuffer(GL_FRAMEBUFFER,0);
glBindTexture(GL_TEXTURE_2D, 0);
}
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
427
|
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
428
429
|
///Method for using the gl manipulation to alighn templates from
///Template space (-0.5 0.5) to Texture space (0.0, 1.0),
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
430
431
|
///Based on the p of the spider in real space (arbitrary).
void setMatrix()
|
5f81932b
David Mayerich
restored Pavel's ...
|
432
|
{
|
d4721000
Pavel Govyadinov
changes with debu...
|
433
|
float curTrans[16];
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
434
|
stim::vec<float> rot = getRotation(d);
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
435
436
|
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
437
|
glScalef(1.0/S[0]/R[0], 1.0/S[1]/R[1], 1.0/S[2]/R[2]);
|
d4721000
Pavel Govyadinov
changes with debu...
|
438
439
|
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
440
441
442
|
glTranslatef(p[0],
p[1],
p[2]);
|
a506d41f
Pavel Govyadinov
fixed the methods...
|
443
|
|
d4721000
Pavel Govyadinov
changes with debu...
|
444
|
glRotatef(rot[0], rot[1], rot[2], rot[3]);
|
a506d41f
Pavel Govyadinov
fixed the methods...
|
445
|
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
446
|
glScalef(m[0],
|
d4721000
Pavel Govyadinov
changes with debu...
|
447
|
m[0],
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
448
|
m[0]);
|
a506d41f
Pavel Govyadinov
fixed the methods...
|
449
|
|
ef64ebad
Pavel Govyadinov
fixed a small mis...
|
450
451
|
glGetFloatv(GL_TEXTURE_MATRIX, curTrans);
cT.set(curTrans);
|
a506d41f
Pavel Govyadinov
fixed the methods...
|
452
|
// printTransform();
|
556c4e15
Pavel Govyadinov
Changed the handl...
|
453
|
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
454
455
|
CHECK_OPENGL_ERROR
glMatrixMode(GL_MODELVIEW);
|
5f81932b
David Mayerich
restored Pavel's ...
|
456
|
}
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
457
458
|
|
5f81932b
David Mayerich
restored Pavel's ...
|
459
|
|
42145f38
Pavel Govyadinov
Fixed the issues ...
|
460
461
462
463
464
|
//--------------------------------------------------------------------------//
//--------------------------------CUDA METHODS------------------------------//
//--------------------------------------------------------------------------//
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
465
466
|
/// Method for registering the texture with Cuda for shared
/// access.
|
42145f38
Pavel Govyadinov
Fixed the issues ...
|
467
468
469
470
471
472
473
474
475
476
477
478
479
|
void
createResource()
{
HANDLE_ERROR(
cudaGraphicsGLRegisterImage(
&resource,
texbufferID,
GL_TEXTURE_2D,
//CU_GRAPHICS_REGISTER_FLAGS_NONE)
cudaGraphicsMapFlagsReadOnly)
);
}
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
480
|
///Method for freeing the texture from Cuda for gl access.
|
42145f38
Pavel Govyadinov
Fixed the issues ...
|
481
482
483
484
485
486
487
488
|
void
destroyResource()
{
HANDLE_ERROR(
cudaGraphicsUnregisterResource(resource)
);
}
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
489
490
|
///Entry-point into the cuda code for calculating the cost
/// of a given samples array (in texture form)
|
42145f38
Pavel Govyadinov
Fixed the issues ...
|
491
492
493
494
|
int
getCost()
{
createResource();
|
edd4ab2d
Pavel Govyadinov
Cleaned up more a...
|
495
|
stim::vec<int> cost = get_cost(resource, numSamples);
|
42145f38
Pavel Govyadinov
Fixed the issues ...
|
496
|
destroyResource();
|
c4887649
Pavel Govyadinov
fixed a significa...
|
497
498
499
|
// if (cost[1] >= 80)
// exit(0);
current_cost = cost[1];
|
edd4ab2d
Pavel Govyadinov
Cleaned up more a...
|
500
|
return cost[0];
|
a9f956be
Pavel Govyadinov
Fixed the cost fu...
|
501
502
|
}
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
503
|
public:
|
13c2a7d4
Pavel Govyadinov
some changes to t...
|
504
505
506
|
stim::rect<float> hor;
stim::rect<float> ver;
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
507
508
509
510
511
|
//--------------------------------------------------------------------------//
//-----------------------------CONSTRUCTORS---------------------------------//
//--------------------------------------------------------------------------//
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
512
513
514
|
///@param samples, the number of samples this spider is going to use.
///best results if samples is can create a perfect root.
///Default Constructor
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
515
|
gl_spider
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
516
|
(int samples = 1089)
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
517
|
{
|
80d3850d
Pavel Govyadinov
test
|
518
519
520
521
522
|
p = vec<float>(0.0, 0.0, 0.0);
d = vec<float>(0.0, 0.0, 1.0);
m = vec<float>(1.0, 1.0);
S = vec<float>(1.0, 1.0, 1.0);
R = vec<float>(1.0, 1.0, 1.0);
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
523
524
525
|
//setPosition(0.0,0.0,0.0);
//setDirection(0.0,0.0,1.0);
//setMagnitude(1.0);
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
526
|
numSamples = samples;
|
4cefeb6d
Pavel Govyadinov
Changes to the re...
|
527
528
|
}
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
529
|
///temporary constructor for convenience, will be removed in further updates.
|
13c2a7d4
Pavel Govyadinov
some changes to t...
|
530
531
|
gl_spider
(float pos_x, float pos_y, float pos_z, float dir_x, float dir_y, float dir_z,
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
532
|
float mag_x, int numSamples = 1089)
|
13c2a7d4
Pavel Govyadinov
some changes to t...
|
533
|
{
|
80d3850d
Pavel Govyadinov
test
|
534
535
|
p = vec<float>(pos_x, pos_y, pos_z);
d = vec<float>(dir_x, dir_y, dir_z);
|
d4721000
Pavel Govyadinov
changes with debu...
|
536
|
m = vec<float>(mag_x, mag_x, mag_x);
|
80d3850d
Pavel Govyadinov
test
|
537
538
|
S = vec<float>(1.0,1.0,1.0);
R = vec<float>(1.0,1.0,1.0);
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
539
540
541
|
//setPosition(pos_x, pos_y, pos_z);
//setDirection(dir_x, dir_y, dir_z);
//setMagnitude(mag_x);
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
542
|
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
543
|
}
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
544
545
546
547
548
549
550
551
552
|
~gl_spider
(void)
{
Unbind();
glDeleteTextures(1, &texbufferID);
glDeleteBuffers(1, &fboID);
}
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
553
|
///@param GLuint id texture that is going to be sampled.
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
554
|
///Attached the spider to the texture with the given GLuint ID.
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
555
|
///Samples in the default d acting as the init method.
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
556
|
///Also acts an init.
|
a9b45efe
Pavel Govyadinov
changes to spider
|
557
|
void
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
558
|
attachSpider(GLuint id)
|
a9b45efe
Pavel Govyadinov
changes to spider
|
559
560
|
{
texID = id;
|
5f81932b
David Mayerich
restored Pavel's ...
|
561
|
GenerateFBO(20, numSamples*10);
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
562
563
|
setDims(0.6, 0.6, 1.0);
setSize(512.0, 512.0, 426.0);
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
564
|
setMatrix();
|
db3c28c9
Pavel Govyadinov
Implemented glDis...
|
565
|
dList = glGenLists(3);
|
db3c28c9
Pavel Govyadinov
Implemented glDis...
|
566
|
glListBase(dList);
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
567
|
Bind();
|
c4887649
Pavel Govyadinov
fixed a significa...
|
568
|
genDirectionVectors(5*M_PI/4);
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
569
570
|
genPositionVectors();
genMagnitudeVectors();
|
f31bf86d
Pavel Govyadinov
Added skeleton fu...
|
571
|
DrawCylinder();
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
572
|
Unbind();
|
a39577bf
Pavel Govyadinov
Changes to the sp...
|
573
|
}
|
5f81932b
David Mayerich
restored Pavel's ...
|
574
|
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
575
576
577
|
//--------------------------------------------------------------------------//
//-----------------------------ACCESS METHODS-------------------------------//
//--------------------------------------------------------------------------//
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
578
|
///Returns the p vector.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
579
|
vec<float>
|
a39577bf
Pavel Govyadinov
Changes to the sp...
|
580
|
getPosition()
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
581
|
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
582
|
return p;
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
583
584
|
}
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
585
|
///Returns the d vector.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
586
|
vec<float>
|
a39577bf
Pavel Govyadinov
Changes to the sp...
|
587
|
getDirection()
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
588
|
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
589
|
return d;
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
590
591
|
}
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
592
|
///Returns the m vector.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
593
|
vec<float>
|
a39577bf
Pavel Govyadinov
Changes to the sp...
|
594
|
getMagnitude()
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
595
|
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
596
|
return m;
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
597
598
|
}
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
599
600
|
///@param vector pos, the new p.
///Sets the p vector to input vector pos.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
601
602
603
|
void
setPosition(vec<float> pos)
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
604
|
p = pos;
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
605
|
}
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
606
607
608
609
|
///@param x x-coordinate.
///@param y y-coordinate.
///@param z z-coordinate.
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
610
|
///Sets the p vector to the input float coordinates x,y,z.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
611
612
613
|
void
setPosition(float x, float y, float z)
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
614
615
616
|
p[0] = x;
p[1] = y;
p[2] = z;
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
617
|
}
|
887a3e49
Pavel Govyadinov
fixed some order ...
|
618
|
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
619
620
|
///@param vector dir, the new d.
///Sets the d vector to input vector dir.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
621
622
623
|
void
setDirection(vec<float> dir)
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
624
|
d = dir;
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
625
626
|
}
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
627
628
629
|
///@param x x-coordinate.
///@param y y-coordinate.
///@param z z-coordinate.
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
630
|
///Sets the d vector to the input float coordinates x,y,z.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
631
632
633
|
void
setDirection(float x, float y, float z)
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
634
635
636
|
d[0] = x;
d[1] = y;
d[2] = z;
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
637
|
}
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
638
|
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
639
640
|
///@param vector dir, the new d.
///Sets the m vector to the input vector mag.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
641
642
643
|
void
setMagnitude(vec<float> mag)
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
644
645
|
m[0] = mag[0];
m[1] = mag[0];
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
646
647
|
}
|
385d2447
Pavel Govyadinov
Checkpoint: Conve...
|
648
|
///@param mag size of the sampled region.
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
649
|
///Sets the m vector to the input mag for both templates.
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
650
|
void
|
5f81932b
David Mayerich
restored Pavel's ...
|
651
|
setMagnitude(float mag)
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
652
|
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
653
654
|
m[0] = mag;
m[1] = mag;
|
c4887649
Pavel Govyadinov
fixed a significa...
|
655
|
// m[2] = mag;
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
656
|
}
|
5f81932b
David Mayerich
restored Pavel's ...
|
657
|
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
658
659
660
661
662
663
664
665
666
|
void
setDims(float x, float y, float z)
{
S[0] = x;
S[1] = y;
S[2] = z;
}
|
b710b044
Pavel Govyadinov
Added more tempor...
|
667
|
void
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
668
|
setSize(float x, float y, float z)
|
b710b044
Pavel Govyadinov
Added more tempor...
|
669
|
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
670
671
672
|
R[0] = x;
R[1] = y;
R[2] = z;
|
b710b044
Pavel Govyadinov
Added more tempor...
|
673
674
|
}
|
f304d6de
Pavel Govyadinov
added rotation to...
|
675
676
677
|
///@param dir, the vector to which we are rotating
///given a vector to align to, finds the required
///axis and angle for glRotatef
|
5eeaf941
Pavel Govyadinov
changer to the ba...
|
678
|
stim::vec<float>
|
f304d6de
Pavel Govyadinov
added rotation to...
|
679
680
|
getRotation(stim::vec<float> dir)
{
|
d4721000
Pavel Govyadinov
changes with debu...
|
681
682
683
684
|
stim::vec<float> out(0.0,0.0,0.0,0.0);
stim::vec<float> from(0.0,0.0,1.0);
out[0] = acos(dir.dot(from))*180/M_PI;
if(out[0] < 1.0){
|
f304d6de
Pavel Govyadinov
added rotation to...
|
685
686
687
688
689
|
out[0] = 0.0;
out[1] = 0.0;
out[2] = 0.0;
out[3] = 1.0;
} else {
|
d4721000
Pavel Govyadinov
changes with debu...
|
690
|
stim::vec<float> temp(0.0, 0.0, 0.0);;
|
f304d6de
Pavel Govyadinov
added rotation to...
|
691
692
693
694
695
|
temp = (from.cross(dir)).norm();
out[1] = temp[0];
out[2] = temp[1];
out[3] = temp[2];
}
|
f304d6de
Pavel Govyadinov
added rotation to...
|
696
697
|
return out;
}
|
f304d6de
Pavel Govyadinov
added rotation to...
|
698
|
|
db3c28c9
Pavel Govyadinov
Implemented glDis...
|
699
700
|
///Function to get back the framebuffer Object attached to the spider.
///For external access.
|
a9b45efe
Pavel Govyadinov
changes to spider
|
701
702
703
704
705
|
GLuint
getFB()
{
return fboID;
}
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
706
|
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
707
708
709
710
711
712
713
714
715
|
//--------------------------------------------------------------------------//
//-----------------------------TEMPORARY METHODS----------------------------//
//--------------------------------------------------------------------------//
///temporary Method necessary for visualization and testing.
void
Update()
{
vec<float> Y(1.0,0.0,0.0);
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
716
|
if(cos(Y.dot(d))< 0.087){
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
717
|
Y[0] = 0.0; Y[1] = 1.0;}
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
718
719
720
|
hor = stim::rect<float>(m, p, d.norm(),
((Y.cross(d)).cross(d)).norm());
ver = stim::rect<float>(m, p, d.norm(),
|
266aa74a
Pavel Govyadinov
CHECKPOINT: Minor...
|
721
722
723
724
|
hor.n());
}
|
c4887649
Pavel Govyadinov
fixed a significa...
|
725
|
int
|
13c2a7d4
Pavel Govyadinov
some changes to t...
|
726
727
|
Step()
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
728
|
Bind();
|
42145f38
Pavel Govyadinov
Fixed the issues ...
|
729
|
findOptimalDirection();
|
d4721000
Pavel Govyadinov
changes with debu...
|
730
731
|
findOptimalPosition();
findOptimalScale();
|
c4887649
Pavel Govyadinov
fixed a significa...
|
732
|
// branchDetection();
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
733
|
Unbind();
|
c4887649
Pavel Govyadinov
fixed a significa...
|
734
|
return current_cost;
|
13c2a7d4
Pavel Govyadinov
some changes to t...
|
735
|
}
|
a9b45efe
Pavel Govyadinov
changes to spider
|
736
|
|
556c4e15
Pavel Govyadinov
Changed the handl...
|
737
738
739
740
|
void
printTransform()
{
|
8e56a0a7
Pavel Govyadinov
Added the propose...
|
741
|
std::cout << cT << std::endl;
|
b710b044
Pavel Govyadinov
Added more tempor...
|
742
|
}
|
a9b45efe
Pavel Govyadinov
changes to spider
|
743
|
|
42145f38
Pavel Govyadinov
Fixed the issues ...
|
744
745
746
747
748
|
/* Method for initializing the cuda devices, necessary only
there are multiple cuda devices */
void
initCuda()
{
|
2a18be6d
Pavel Govyadinov
New comments and ...
|
749
|
stim::cudaSetDevice();
|
42145f38
Pavel Govyadinov
Fixed the issues ...
|
750
751
752
|
//GLint max;
//glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
//std::cout << max << std::endl;
|
a9b45efe
Pavel Govyadinov
changes to spider
|
753
|
}
|
f31bf86d
Pavel Govyadinov
Added skeleton fu...
|
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
|
//--------------------------------------------------------------------------//
//-----------------------------EXPERIMENTAL METHODS-------------------------//
//--------------------------------------------------------------------------//
void
DrawCylinder()
{
Bind();
glNewList(dList+3, GL_COMPILE);
float z0 = -0.5; float z1 = 0.5; float r0 = 0.5;
float x,y;
float xold = 0.5; float yold = 0.5;
float step = 360.0/numSamples;
int j = 0;
glEnable(GL_TEXTURE_3D);
glBindTexture(GL_TEXTURE_3D, texID);
glBegin(GL_QUAD_STRIP);
for(float i = step; i <= 360.0; i += step)
{
x=r0*cos(i*2.0*M_PI/360.0);
y=r0*sin(i*2.0*M_PI/360.0);
glTexCoord3f(x,y,z0);
|
22e7d0c5
Pavel Govyadinov
Minor changes in ...
|
777
|
glVertex2f(0.0, j*0.1+0.1);
|
f31bf86d
Pavel Govyadinov
Added skeleton fu...
|
778
|
glTexCoord3f(x,y,z1);
|
22e7d0c5
Pavel Govyadinov
Minor changes in ...
|
779
|
glVertex2f(20.0, j*0.1+0.1);
|
f31bf86d
Pavel Govyadinov
Added skeleton fu...
|
780
|
glTexCoord3f(xold,yold,z1);
|
22e7d0c5
Pavel Govyadinov
Minor changes in ...
|
781
|
glVertex2f(20.0, j*0.1);
|
f31bf86d
Pavel Govyadinov
Added skeleton fu...
|
782
|
glTexCoord3f(xold,yold,z0);
|
22e7d0c5
Pavel Govyadinov
Minor changes in ...
|
783
|
glVertex2f(0.0, j*0.1);
|
f31bf86d
Pavel Govyadinov
Added skeleton fu...
|
784
785
786
787
788
789
790
791
|
xold=x;
yold=y;
j++;
}
glEnd();
glEndList();
Unbind();
}
|
4cefeb6d
Pavel Govyadinov
Changes to the re...
|
792
|
};
|
fb0bc2f1
Pavel Govyadinov
added the gl_spid...
|
793
794
|
}
#endif
|