FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
HelloT5Cube/HelloT5Cube.cpp at master · patrickdown/HelloT5Cube · GitHub
patrickdown
/
HelloT5Cube
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
5
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
HelloT5Cube
/
HelloT5Cube.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
546 lines (444 loc) · 17.6 KB
Breadcrumbs
HelloT5Cube
/
HelloT5Cube.cpp
Copy path
File metadata and controls
546 lines (444 loc) · 17.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
#
include
<
iostream
>
#
include
<
t5wrapper/Conversions.h
>
#
include
<
glapplication/Transform.h
>
#
include
"
HelloT5Cube.h
"
#
include
"
VertexDefinition.h
"
/*
***************************************************************************
Get static data defined in InlineVertexData and InlineShaderCode
****************************************************************************
*/
std::span<
const
VertexPC>
GetCubeVertices
();
const
char
*
GetVertexShaderCode
(
bool
multiview =
false
);
const
char
*
GetFragmentShaderCode
();
/*
***************************************************************************
Set up for window and OpenGL context creation.
****************************************************************************
*/
bool
HelloT5Cube::InitializeApplication
()
{
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MAJOR
,
4
);
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MINOR
,
6
);
glfwWindowHint
(
GLFW_OPENGL_PROFILE
,
GLFW_OPENGL_CORE_PROFILE
);
std::cout <<
"
Press P to dump pose.
"
<< std::endl;
return
true
;
}
/*
***************************************************************************
After the window and GL context are created try to get a pair of T5 glasses
and set up assets for rendering.
****************************************************************************
*/
bool
HelloT5Cube::InitializeContext
()
{
if
(glDebug)
{
EnableDebug
();
std::cerr <<
"
OpenGL debugging enabled
"
<< std::endl;
}
//
All T5 init in here
if
(!
InitializeT5
())
return
false
;
if
(GLAD_GL_OVR_multiview2)
std::cerr <<
"
OVR_multiview2 supported
"
<< std::endl;
isMultiviewCapable = GLAD_GL_OVR_multiview2;
useMultiview = useMultiview && isMultiviewCapable;
copyMultviewTextures = useMultiview && copyMultviewTextures;
if
(useMultiview) {
std::cerr <<
"
Rendering using OVR_multiview2
"
<< std::endl;
}
if
(copyMultviewTextures) {
std::cerr <<
"
Copying multiview layers to single textures
"
<< std::endl;
}
//
Compile shaders
cubeShader = MakeOwned<
GLW
::ShaderProgram>();
if
(!cubeShader->
Compile
(
GetVertexShaderCode
(useMultiview),
GetFragmentShaderCode
()))
{
std::cerr << cubeShader->
GetErrorMessage
() << std::endl;
return
false
;
}
//
Setup vertex arrays
cubeVertexBuffer = MakeOwned<
GLW
::Buffer>();
cubeVertexBuffer->
Create
();
cubeVertexBuffer->
StoreData
(
GetCubeVertices
());
cubeVertexArrays = MakeOwned<
GLW
::VertexArray>();
cubeVertexArrays->
Create
();
cubeVertexArrays->
AttachBuffer
(*cubeVertexBuffer, cubeShader->
GetAttribLocation
(
"
vPos
"
), VertexPC::positionMem);
cubeVertexArrays->
AttachBuffer
(*cubeVertexBuffer, cubeShader->
GetAttribLocation
(
"
vCol
"
), VertexPC::colorMem);
//
Setup frame buffers for stereo
if
(useMultiview) {
stereoEyeDisplay.
InitializeMultiview
(defaultWidth, defaultHeight,
2
);
leftLayerTexture = stereoEyeDisplay.
GetTextureLayer
(
0
);
rightLayerTexture = stereoEyeDisplay.
GetTextureLayer
(
1
);
rightLayerFramebuffer = MakeOwned<
GLW
::Framebuffer>();
rightLayerFramebuffer->
Create
();
rightLayerFramebuffer->
ColorAttachment
(*rightLayerTexture);
rightLayerFramebuffer->
DrawBuffers
(
0
);
if
(!rightLayerFramebuffer->
IsReady
()) {
std::cerr <<
"
blitFramebuffer:
"
<< rightLayerFramebuffer->
GetErrorMessage
() << std::endl;
return
false
;
}
leftLayerFramebuffer = MakeOwned<
GLW
::Framebuffer>();
leftLayerFramebuffer->
Create
();
leftLayerFramebuffer->
ColorAttachment
(*leftLayerTexture);
leftLayerFramebuffer->
DrawBuffers
(
0
);
if
(!leftLayerFramebuffer->
IsReady
()) {
std::cerr <<
"
blitFramebuffer:
"
<< leftLayerFramebuffer->
GetErrorMessage
() << std::endl;
return
false
;
}
leftEyeDisplay.
Initialize
(defaultWidth, defaultHeight,
false
);
rightEyeDisplay.
Initialize
(defaultWidth, defaultHeight,
false
);
}
else
{
leftEyeDisplay.
Initialize
(defaultWidth, defaultHeight);
rightEyeDisplay.
Initialize
(defaultWidth, defaultHeight);
}
float
ipd = glasses->
GetIpd
();
leftEyePose.
SetPosition
(-ipd /
2
.
0f
,
0
,
0
);
rightEyePose.
SetPosition
(ipd /
2
.
0f
,
0
,
0
);
glEnable
(
GL_CULL_FACE
);
glEnable
(
GL_DEPTH_TEST
);
return
true
;
}
/*
***************************************************************************
Initialize a framebuffer to be a render target.
****************************************************************************
*/
bool
HelloT5Cube::DisplaySurface::Initialize
(
int
width,
int
height,
bool
hasDepth)
{
this
->
width
= width;
this
->
height
= height;
//
Make a texture to hold the image that will be passed to the glasses
texture = MakeOwned<
GLW
::Texture>();
texture->
Create
(
GL_TEXTURE_2D
);
texture->
SetTextureStorage
(
GL_RGBA8
, width, height);
texture->
SetMinFilter
(
GL_LINEAR
);
texture->
SetMagFilter
(
GL_LINEAR
);
if
(hasDepth) {
//
Make a depth buffer
depth = MakeOwned<
GLW
::Texture>();
depth->
Create
(
GL_TEXTURE_2D
);
depth->
SetDepthStorage
(width, height);
depth->
SetMinFilter
(
GL_LINEAR
);
depth->
SetMagFilter
(
GL_LINEAR
);
}
//
Attach texture and depth
framebuffer = MakeOwned<
GLW
::Framebuffer>();
framebuffer->
Create
();
framebuffer->
ColorAttachment
(*texture);
if
(hasDepth) {
framebuffer->
DepthAttachment
(*depth);
}
framebuffer->
DrawBuffers
(
0
);
if
(!framebuffer->
IsReady
())
{
std::cerr <<
"
Framebuffer:
"
<< framebuffer->
GetErrorMessage
() << std::endl;
return
false
;
}
return
true
;
}
/*
***************************************************************************
Initialize a framebuffer to be a render target.
****************************************************************************
*/
bool
HelloT5Cube::DisplaySurface::InitializeMultiview
(
int
width,
int
height,
int
layers) {
this
->
width
= width;
this
->
height
= height;
this
->
layers
= layers;
//
Make a texture to hold the image that will be passed to the glasses
texture = MakeOwned<
GLW
::Texture>();
texture->
Create
(
GL_TEXTURE_2D_ARRAY
);
texture->
SetTextureStorage
(
GL_RGBA8
, width, height, layers);
texture->
SetMinFilter
(
GL_LINEAR
);
texture->
SetMagFilter
(
GL_LINEAR
);
//
Make a depth buffer
depth = MakeOwned<
GLW
::Texture>();
depth->
Create
(
GL_TEXTURE_2D_ARRAY
);
depth->
SetDepthStorage
(width, height, layers);
depth->
SetMinFilter
(
GL_LINEAR
);
depth->
SetMagFilter
(
GL_LINEAR
);
//
Attach texture and depth
framebuffer = MakeOwned<
GLW
::Framebuffer>();
framebuffer->
Create
();
framebuffer->
Bind
(
GL_DRAW_FRAMEBUFFER
);
framebuffer->
ColorAttachmentMultiview
(*texture,
0
, layers);
framebuffer->
DepthAttachmentMultiview
(*depth,
0
, layers);
framebuffer->
DrawBuffers
(
0
);
framebuffer->
Unbind
(
GL_DRAW_FRAMEBUFFER
);
if
(!framebuffer->
IsReady
()) {
std::cerr <<
"
Multiview Framebuffer:
"
<< framebuffer->
GetErrorMessage
() << std::endl;
return
false
;
}
return
true
;
}
/*
***************************************************************************
Bind framebuffer for drawing
****************************************************************************
*/
void
HelloT5Cube::DisplaySurface::BeginDraw
()
{
framebuffer->
Bind
(
GL_DRAW_FRAMEBUFFER
);
glViewport
(
0
,
0
, width, height);
}
/*
***************************************************************************
Bind default framebuffer for drawing
****************************************************************************
*/
void
HelloT5Cube::DisplaySurface::EndDraw
()
{
glBindFramebuffer
(
GL_DRAW_FRAMEBUFFER
,
0
);
}
/*
***************************************************************************
Used to mirror the rendered image to the display
****************************************************************************
*/
void
HelloT5Cube::DisplaySurface::BlitToScreen
(
int
dstWidth,
int
dstHeight)
{
framebuffer->
BlitToScreen
(
0
,
0
, width, height,
0
,
0
, dstWidth, dstHeight,
GL_COLOR_BUFFER_BIT
,
GL_NEAREST
);
}
void
HelloT5Cube::DisplaySurface::BlitToFrameBuffer
(
GLW
::Framebuffer& dstFramebuffer,
int
dstHeight,
int
dstWidth) {
framebuffer->
BlitToFramebuffer
(dstFramebuffer,
0
,
0
, width, height,
0
,
0
, dstWidth, dstHeight,
GL_COLOR_BUFFER_BIT
,
GL_NEAREST
);
}
void
HelloT5Cube::DisplaySurface::BlitFromFrameBuffer
(
GLW
::Framebuffer& dstFramebuffer) {
dstFramebuffer.
BlitToFramebuffer
(*framebuffer,
0
,
0
, width, height,
0
,
0
, width, height,
GL_COLOR_BUFFER_BIT
,
GL_NEAREST
);
}
Owned<
GLW
::Texture>
HelloT5Cube::DisplaySurface::GetTextureLayer
(
int
layer) {
return
texture->
CreateView
(
GL_TEXTURE_2D
,
GL_RGBA8
,
0
,
1
, layer,
1
);
}
/*
***************************************************************************
'P' key dumps a head pose to standard out
****************************************************************************
*/
void
HelloT5Cube::OnKey
(
int
key,
int
scancode,
int
action,
int
mods)
{
Application::OnKey
(key, scancode, action, mods);
if
(key ==
GLFW_KEY_P
&& action ==
GLFW_PRESS
)
isOutputingOnePoseFrame =
true
;
}
/*
***************************************************************************
Initialize the T5 context, get a list of glasses, connect to the first
one found.
There might be delays in starting the service and the main gui shouldn't be hung
up waiting. So in a real application parts of this should probably be an done
in a non blocking way as part of the render loop.
****************************************************************************
*/
bool
HelloT5Cube::InitializeT5
()
{
context = MakeOwned<
T5W
::Context>();
auto
result = context->
Create
(windowTitle,
"
0.0.1
"
);
if
(result !=
T5_SUCCESS
)
{
std::cerr <<
"
Error:
"
<<
t5GetResultMessage
(result) << std::endl;
return
false
;
}
serviceVersion = context->
GetServiceVersion
();
std::cout <<
"
Service version:
"
<< serviceVersion << std::endl;
auto
glassesResult = context->
GetConnectedGlasses
();
if
(!glassesResult.
TryGet
(glassesIDList))
{
std::cerr <<
"
Error:
"
<< glassesResult.
GetErrorMessage
() << std::endl;
return
false
;
}
for
(
auto
glassesID : glassesIDList)
{
std::cout <<
"
Found glasses:
"
<< glassesID << std::endl;
}
if
(glassesIDList.
size
() >
0
)
{
if
(!
ConnectGlasses
(glassesIDList[
0
]))
return
false
;
}
else
{
std::cerr <<
"
Didn't find any glasses
"
<< std::endl;
return
false
;
}
return
true
;
}
/*
***************************************************************************
Connect one pair of T5 glasses by ID.
There might be delays in getting connected and the main gui shouldn't be hung
up waiting. So in a real application parts of this should probably be an done
in a non blocking way as part of the render loop.
****************************************************************************
*/
bool
HelloT5Cube::ConnectGlasses
(std::string glassesID)
{
glasses = MakeOwned<
T5W
::Glasses>();
auto
err = glasses->
Create
(*context, glassesID);
if
(err !=
T5_SUCCESS
)
{
std::cerr <<
"
Error: [
"
<<
t5GetResultMessage
(err) <<
"
] creating glasses
"
<< glassesID << std::endl;
return
false
;
}
std::cout <<
"
Created glasses:
"
<< glassesID << std::endl;
std::cout <<
"
Glasses
"
<< glassesID <<
"
state:
"
<<
GetConnectionText
(glasses->
GetConnectionState
()) << std::endl;
err = glasses->
Acquire
(windowTitle);
if
(err !=
T5_SUCCESS
)
{
std::cerr <<
"
Error: [
"
<<
t5GetResultMessage
(err) <<
"
] acquiring glasses
"
<< glassesID << std::endl;
return
false
;
}
std::cout <<
"
Glasses
"
<< glassesID <<
"
state:
"
<<
GetConnectionText
(glasses->
GetConnectionState
()) << std::endl;
for
(;;)
{
err = glasses->
EnsureReady
();
if
(err ==
T5_SUCCESS
)
break
;
if
(err ==
T5_ERROR_TRY_AGAIN
)
continue
;
std::cerr <<
"
Error: [
"
<<
t5GetResultMessage
(err) <<
"
] readying glasses
"
<< glassesID << std::endl;
return
false
;
}
std::cout <<
"
Glasses
"
<< glassesID <<
"
state:
"
<<
GetConnectionText
(glasses->
GetConnectionState
()) << std::endl;
err = glasses->
InitGlassesOpenGLContext
(useMultiview && !copyMultviewTextures);
if
(err !=
T5_SUCCESS
)
{
std::cerr <<
"
Error: [
"
<<
t5GetResultMessage
(err) <<
"
] initializing OpenGL for glasses
"
<< glassesID << std::endl;
return
false
;
}
std::cout <<
"
IPD =
"
<< glasses->
GetIpd
() << std::endl;
return
true
;
}
/*
***************************************************************************
This is the main loop
A real application should be watching for glasses connection and disconnection
and handling those event. It should probably also be watching for parameter
changes like IPD.
****************************************************************************
*/
void
HelloT5Cube::Update
()
{
UpdateGlassesPose
();
Render
();
SendFramesToGlasses
();
}
/*
***************************************************************************
Read the pose from the glasses and set the application headPose transform.
It will also dump the pose to standard out when 'P' is pressed.
****************************************************************************
*/
void
HelloT5Cube::UpdateGlassesPose
()
{
auto
poseResult = glasses->
GetGlassesPose
();
T5_GlassesPose pose;
isPoseValid = poseResult.
TryGet
(pose);
if
(isPoseValid)
{
isPoseValid =
true
;
auto
position =
T5W::toGLM
(pose.
posGLS_GBD
);
auto
orientation =
T5W::toGLM
(pose.
rotToGLS_GBD
);
headPose.
SetPosition
(position);
headPose.
SetOrientation
(orientation);
if
(isOutputingOnePoseFrame)
{
auto
xAxis =
glm::rotate
(orientation,
glm::vec3
(
1
,
0
,
0
));
auto
yAxis =
glm::rotate
(orientation,
glm::vec3
(
0
,
1
,
0
));
auto
zAxis =
glm::rotate
(orientation,
glm::vec3
(
0
,
0
,
1
));
std::cout <<
"
Pos = (
"
<< position.
x
<<
"
,
"
<< position.
y
<<
"
,
"
<< position.
z
<<
"
)
"
<< std::endl;
std::cout <<
"
xAxis = (
"
<< xAxis.
x
<<
"
,
"
<< xAxis.
y
<<
"
,
"
<< xAxis.
z
<<
"
)
"
<< std::endl;
std::cout <<
"
yAxis = (
"
<< yAxis.
x
<<
"
,
"
<< yAxis.
y
<<
"
,
"
<< yAxis.
z
<<
"
)
"
<< std::endl;
std::cout <<
"
zAxis = (
"
<< zAxis.
x
<<
"
,
"
<< zAxis.
y
<<
"
,
"
<< zAxis.
z
<<
"
)
"
<< std::endl;
isOutputingOnePoseFrame =
false
;
}
}
if
(isPoseValid.
IsChanged
())
{
std::cout << (isPoseValid ?
"
Gained tracking
"
:
"
Lost tracking
"
) << std::endl;
}
}
/*
***************************************************************************
Render the scene. The view matrix is composed from three transforms.
gameboardPose - represents the pose of the gameboard in world frame
headPose - represents the pose of the glasses/head in the gameboard frame
leftEyePose/righteyePose - represents the offset of the eye in head frame
****************************************************************************
*/
void
HelloT5Cube::Render
()
{
const
float
ratio = defaultWidth / (
float
)defaultHeight;
//
Rotate cube
GLApp::Transform modelTran;
modelTran.
SetEuler
(
0
,
0
, (
float
)
glfwGetTime
());
modelTran.
SetScale
(
0
.
1f
);
//
Model to world
auto
modelMat = modelTran.
MatrixToParentFrame
();
//
World to eye
auto
viewLeftMat = leftEyePose.
MatrixToLocalFrame
() * headPose.
MatrixToLocalFrame
() * gameboardPose.
MatrixToLocalFrame
();
auto
viewRightMat = rightEyePose.
MatrixToLocalFrame
() * headPose.
MatrixToLocalFrame
() * gameboardPose.
MatrixToLocalFrame
();
//
Perspective projection
auto
perspectiveProj =
glm::perspective
(
glm::radians
(defaultFOV), ratio,
0
.
1f
,
100
.
0f
);
cubeShader->
Use
();
cubeVertexArrays->
Bind
();
//
Render left eye
auto
mvpLeft = perspectiveProj * viewLeftMat * modelMat;
//
Render right eye
auto
mvpRight = perspectiveProj * viewRightMat * modelMat;
int
width =
0
;
int
height =
0
;
GetFramebufferSize
(width, height);
if
(useMultiview) {
glm::highp_mat4 mvpArr[
2
];
mvpArr[
0
] = mvpLeft;
mvpArr[
1
] = mvpRight;
cubeShader->
Set
(
"
MVP
"
, mvpArr);
stereoEyeDisplay.
BeginDraw
();
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glDrawArrays
(
GL_TRIANGLES
,
0
,
36
);
stereoEyeDisplay.
EndDraw
();
leftEyeDisplay.
BlitFromFrameBuffer
(*leftLayerFramebuffer);
rightEyeDisplay.
BlitFromFrameBuffer
(*rightLayerFramebuffer);
rightEyeDisplay.
BlitToScreen
(width, height);
}
else
{
cubeShader->
Set
(
"
MVP
"
, mvpLeft);
leftEyeDisplay.
BeginDraw
();
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glDrawArrays
(
GL_TRIANGLES
,
0
,
36
);
leftEyeDisplay.
EndDraw
();
cubeShader->
Set
(
"
MVP
"
, mvpRight);
rightEyeDisplay.
BeginDraw
();
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glDrawArrays
(
GL_TRIANGLES
,
0
,
36
);
rightEyeDisplay.
EndDraw
();
//
Blit right eye to display
rightEyeDisplay.
BlitToScreen
(width, height);
}
}
/*
***************************************************************************
Send the rendered textures and the pose they were rendered as to the glasses
for projection.
****************************************************************************
*/
void
HelloT5Cube::SendFramesToGlasses
()
{
T5_Result result;
if
(isPoseValid)
{
T5_FrameInfo frameInfo;
frameInfo.
vci
.
startY_VCI
= -
tan
(
glm::radians
(defaultFOV) *
0
.
5f
);
frameInfo.
vci
.
startX_VCI
= frameInfo.
vci
.
startY_VCI
* leftEyeDisplay.
width
/ (
float
)leftEyeDisplay.
height
;
frameInfo.
vci
.
width_VCI
= -
2
.
0f
* frameInfo.
vci
.
startX_VCI
;
frameInfo.
vci
.
height_VCI
= -
2
.
0f
* frameInfo.
vci
.
startY_VCI
;
frameInfo.
texWidth_PIX
= leftEyeDisplay.
width
;
frameInfo.
texHeight_PIX
= leftEyeDisplay.
height
;
if
(useMultiview && !copyMultviewTextures)
{
frameInfo.
leftTexHandle
= stereoEyeDisplay.
texture
->
HandleAsVoidPtr
();
frameInfo.
rightTexHandle
=
0
;
}
else
{
frameInfo.
leftTexHandle
= leftEyeDisplay.
texture
->
HandleAsVoidPtr
();
frameInfo.
rightTexHandle
= rightEyeDisplay.
texture
->
HandleAsVoidPtr
();
}
auto
leftPos = leftEyePose.
TransformPointToParentFrame
(
glm::vec3
(
0
,
0
,
0
));
leftPos = headPose.
TransformPointToParentFrame
(leftPos);
frameInfo.
posLVC_GBD
=
T5W::toT5
(leftPos);
frameInfo.
rotToLVC_GBD
=
T5W::toT5
(headPose.
GetOrientation
());
auto
rightPos = rightEyePose.
TransformPointToParentFrame
(
glm::vec3
(
0
,
0
,
0
));
rightPos = headPose.
TransformPointToParentFrame
(rightPos);
frameInfo.
posRVC_GBD
=
T5W::toT5
(rightPos);
frameInfo.
rotToRVC_GBD
=
T5W::toT5
(headPose.
GetOrientation
());
frameInfo.
isUpsideDown
=
false
;
frameInfo.
isSrgb
=
false
;
result = glasses->
SendFrameToGlasses
(frameInfo);
isFrameSent = (result ==
T5_SUCCESS
);
if
(isFrameSent.
IsChanged
())
{
if
(!isFrameSent)
{
std::cerr <<
"
Stopped sending frames because:
"
<<
t5GetResultMessage
(result) << std::endl;
}
else
{
std::cerr <<
"
Started sending frames
"
<< std::endl;
}
}
frameCounter++;
}
}
Back
|
FazBrowse Home
|
New Git URL