aboutsummaryrefslogtreecommitdiffstats
path: root/dev/MinGfx/docs/html/classmingfx_1_1_uni_cam.html
blob: 4b17e190cdce97a63f843df339a7717b7d1a27b6 (plain) (blame)
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
<!-- HTML header for doxygen 1.8.9.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<title>MinGfx Toolkit: mingfx::UniCam Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">MinGfx Toolkit
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacemingfx.html">mingfx</a></li><li class="navelem"><a class="el" href="classmingfx_1_1_uni_cam.html">UniCam</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classmingfx_1_1_uni_cam-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">mingfx::UniCam Class Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This implements a user interface for controlling the camera with the mouse. </p>
<p>It is a special interface inspired by the "Unicam" technique developed by Zeleznik et al. <br  />
</p>
<p>The key feature is that this interface makes it possible to control camera pan, dolly, and rotation with only a single mouse button. That is quite useful because it leaves the other mouse buttons free for pointing, sketching, or other interaction techniques.</p>
<p>The only downside of this technique is that it can take some time to learn. In order to enjoy it, you will need to read these brief instructions on how to Pan, Dolly, Rotate, and Spin:</p>
<ul>
<li>Pan: Click and drag horizontally with the mouse. Once you make an initial horizontal movement you can than pan up and down as well, but the key to entering pan mode is to start with a horizontal movement.</li>
<li>Dolly: Click and drag vertically with the mouse. The initial movement must be vertical. If you click on some object in the scene, then the speed of dollying is set so that the object will come all the up to the camera lens if you drag the mouse to the bottom of the screen.</li>
<li>Rotate: Start with a quick click and release to set the center of rotation. <br  />
 This is most useful if you click on some object in the scene. You will see a black dot appear to mark the center of rotation. If you click on the background then a center of rotation will be selected for you. It will be a point straight ahead and at a depth 4.0 units away. The depth can be adjusted for your application with <a class="el" href="classmingfx_1_1_uni_cam.html#a71e0351ac19a18b9c02215a60dc51068" title="This sets the depth of the center of rotation for the case when the user&#39;s click does not intersect a...">set_default_depth()</a>. Once your center of rotation is established, move your mouse away a bit and then click and drag to do a trackball rotatation of the scene around this point. Come to a stop before letting go of the mouse button in order to avoid entering the spin state!</li>
<li>Spin: For some fun, try "throwing" the scene so that it continues to rotate even after you let go. To do this, start a rotation and then let go of the mouse button while your mouse is still moving. To stop spinning just click and release the mouse once to "catch" the scene.</li>
</ul>
<p>Example usage: </p><div class="fragment"><div class="line"><span class="comment">// Create a global or member variable in your MyGraphicsApp class:</span></div>
<div class="line"><a class="code" href="classmingfx_1_1_uni_cam.html#a6e7771961011f573b2e2249f602b2d2e">UniCam</a> unicam_;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> MyGraphicsApp::OnLeftMouseDown(<span class="keyword">const</span> Point2 &amp;pos) {</div>
<div class="line">    Point2 mouse_xy = PixelsToNormalizedDeviceCoords(pos);</div>
<div class="line">    <span class="keywordtype">float</span> mouse_z = ReadZValueAtPixel(pos);</div>
<div class="line">    unicam_.OnButtonDown(mouse_xy, mouse_z);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> MyGraphicsApp::OnLeftMouseDrag(<span class="keyword">const</span> Point2 &amp;pos, <span class="keyword">const</span> Vector2 &amp;delta) {</div>
<div class="line">    Point2 mouse_xy = PixelsToNormalizedDeviceCoords(pos);</div>
<div class="line">    unicam_.OnDrag(mouse_xy);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> MyGraphicsApp::OnLeftMouseUp(<span class="keyword">const</span> Point2 &amp;pos) {</div>
<div class="line">    Point2 mouse_xy = PixelsToNormalizedDeviceCoords(pos);</div>
<div class="line">    unicam_.OnButtonUp(mouse_xy);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> MyGraphicsApp::InitOpenGL() {</div>
<div class="line">    projMatrix_ = Matrix4::perspective(30, aspect_ratio(), 1, 20);</div>
<div class="line">    unicam_.set_view_matrix(Matrix4::lookAt(Point3(2.5,1,2.5), Point3(0,0,0), Vector3(0,1,0)););</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> MyGraphicsApp::DrawOpenGL() {</div>
<div class="line">    <span class="comment">// draw your scene using the view matrix from UniCam</span></div>
<div class="line">    Matrix4 proj_matrix = <a class="code" href="classmingfx_1_1_matrix4.html#a0e34aee86758a0397074590b87712c5e">Matrix4::Perspective</a>(60, aspect_ratio(), 0.001, 10);;</div>
<div class="line">    Matrix4 <a class="code" href="classmingfx_1_1_uni_cam.html#af7e7276f9390ec57ca577092c99d6ca3">view_matrix</a> = uniCam.view_matrix();</div>
<div class="line">    Matrix4 model_matrix = Matrix4::RotateY(to_radians(45.0));</div>
<div class="line">    quickShapes.DrawCube(model_matrix, view_matirx, proj_matrix, Color(1,1,1));</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// tell unicam to draw itself (i.e., the small sphere that marks the center of</span></div>
<div class="line">    <span class="comment">// rotation when in rotation mode)</span></div>
<div class="line">    unicam_.Draw(proj_matrix);</div>
<div class="line">}</div>
<div class="ttc" id="aclassmingfx_1_1_matrix4_html_a0e34aee86758a0397074590b87712c5e"><div class="ttname"><a href="classmingfx_1_1_matrix4.html#a0e34aee86758a0397074590b87712c5e">mingfx::Matrix4::Perspective</a></div><div class="ttdeci">static Matrix4 Perspective(float fov_y_in_degrees, float aspect_ratio, float near_plane_dist, float far_plane_dist)</div><div class="ttdoc">Returns a perspective projection matrix equivalent to the one gluPerspective creates.</div></div>
<div class="ttc" id="aclassmingfx_1_1_uni_cam_html_a6e7771961011f573b2e2249f602b2d2e"><div class="ttname"><a href="classmingfx_1_1_uni_cam.html#a6e7771961011f573b2e2249f602b2d2e">mingfx::UniCam::UniCam</a></div><div class="ttdeci">UniCam()</div><div class="ttdoc">Creates a UniCam object with an initial view matrix = identity.</div></div>
<div class="ttc" id="aclassmingfx_1_1_uni_cam_html_af7e7276f9390ec57ca577092c99d6ca3"><div class="ttname"><a href="classmingfx_1_1_uni_cam.html#af7e7276f9390ec57ca577092c99d6ca3">mingfx::UniCam::view_matrix</a></div><div class="ttdeci">Matrix4 view_matrix()</div><div class="ttdoc">Access the camera view matrix created by the UniCam interactions via this method and use it to draw t...</div></div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="unicam_8h_source.html#l00105">105</a> of file <a class="el" href="unicam_8h_source.html">unicam.h</a>.</p>
</div>
<p><code>#include &lt;<a class="el" href="unicam_8h_source.html">unicam.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a6e7771961011f573b2e2249f602b2d2e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#a6e7771961011f573b2e2249f602b2d2e">UniCam</a> ()</td></tr>
<tr class="memdesc:a6e7771961011f573b2e2249f602b2d2e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a <a class="el" href="classmingfx_1_1_uni_cam.html" title="This implements a user interface for controlling the camera with the mouse.">UniCam</a> object with an initial view matrix = identity.  <a href="classmingfx_1_1_uni_cam.html#a6e7771961011f573b2e2249f602b2d2e">More...</a><br /></td></tr>
<tr class="separator:a6e7771961011f573b2e2249f602b2d2e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af507e639c4bceb4c79e21a6f80c48d07"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#af507e639c4bceb4c79e21a6f80c48d07">UniCam</a> (const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;initialViewMatrix)</td></tr>
<tr class="memdesc:af507e639c4bceb4c79e21a6f80c48d07"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a <a class="el" href="classmingfx_1_1_uni_cam.html" title="This implements a user interface for controlling the camera with the mouse.">UniCam</a> object with the supplied initial view matrix.  <a href="classmingfx_1_1_uni_cam.html#af507e639c4bceb4c79e21a6f80c48d07">More...</a><br /></td></tr>
<tr class="separator:af507e639c4bceb4c79e21a6f80c48d07"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af98022627bcb52dbf54779cfaeb6ff7e"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#af98022627bcb52dbf54779cfaeb6ff7e">~UniCam</a> ()</td></tr>
<tr class="separator:af98022627bcb52dbf54779cfaeb6ff7e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a85afba6e8792636f3c6ba2433db1c52f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#a85afba6e8792636f3c6ba2433db1c52f">OnButtonDown</a> (const <a class="el" href="classmingfx_1_1_point2.html">Point2</a> &amp;normalizedMousePos, float mouseZ)</td></tr>
<tr class="memdesc:a85afba6e8792636f3c6ba2433db1c52f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attach this to whatever mouse button you wish, for example, call this from within <a class="el" href="classmingfx_1_1_graphics_app.html#a903f94b82cc10f32039ff3f2ba368a9c" title="If the mouse button was pressed down since the last frame, then this function will be called to notif...">GraphicsApp::OnRightMouseDown()</a>. If your mousePos is reported in pixels, you will need to convert it to normalized device coordinates before passing it on to this routine. The depth buffer value for the pixel under the mouse is also needed. If you are using <a class="el" href="classmingfx_1_1_graphics_app.html" title="This is the main application base class for the MinGfx Toolkit.">GraphicsApp</a>, you can access both of these as follows:  <a href="classmingfx_1_1_uni_cam.html#a85afba6e8792636f3c6ba2433db1c52f">More...</a><br /></td></tr>
<tr class="separator:a85afba6e8792636f3c6ba2433db1c52f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a33f1b41fcf53ea78ca2b3640902c5bbe"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#a33f1b41fcf53ea78ca2b3640902c5bbe">OnDrag</a> (const <a class="el" href="classmingfx_1_1_point2.html">Point2</a> &amp;normalizedMousePos)</td></tr>
<tr class="memdesc:a33f1b41fcf53ea78ca2b3640902c5bbe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attach this to the corresponding mouse move event, for example, call this from within <a class="el" href="classmingfx_1_1_graphics_app.html#a00ad5039af2f428a08fe45751a9731c7" title="If the mouse button is held down and the mouse has moved in the past frame then this function will be...">GraphicsApp::OnRightMouseDrag()</a>. If your mousePos is reported in pixels, you will need to convert it to normalized device coordinates before passing it on to this routine. Within <a class="el" href="classmingfx_1_1_graphics_app.html" title="This is the main application base class for the MinGfx Toolkit.">GraphicsApp</a>, use:  <a href="classmingfx_1_1_uni_cam.html#a33f1b41fcf53ea78ca2b3640902c5bbe">More...</a><br /></td></tr>
<tr class="separator:a33f1b41fcf53ea78ca2b3640902c5bbe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2a9431dc3943c8dc485994d88ce2a58a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#a2a9431dc3943c8dc485994d88ce2a58a">OnButtonUp</a> (const <a class="el" href="classmingfx_1_1_point2.html">Point2</a> &amp;normalizedMousePos)</td></tr>
<tr class="memdesc:a2a9431dc3943c8dc485994d88ce2a58a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attach this to the corresponding button up event, for example, call this from within <a class="el" href="classmingfx_1_1_graphics_app.html#ad7c33791c44afc87ce789874f3002ca3" title="If the mouse button was released since the last frame, then this function will be called to notify yo...">GraphicsApp::OnRightMouseUp()</a>. If your mousePos is reported in pixels, you will need to convert it to normalized device coordinates before passing it on to this routine. Within <a class="el" href="classmingfx_1_1_graphics_app.html" title="This is the main application base class for the MinGfx Toolkit.">GraphicsApp</a>, use:  <a href="classmingfx_1_1_uni_cam.html#a2a9431dc3943c8dc485994d88ce2a58a">More...</a><br /></td></tr>
<tr class="separator:a2a9431dc3943c8dc485994d88ce2a58a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aab253d966af52ac277ac51194745085c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#aab253d966af52ac277ac51194745085c">AdvanceAnimation</a> (double dt)</td></tr>
<tr class="memdesc:aab253d966af52ac277ac51194745085c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attach this to a callback that can be used to control animation. Within <a class="el" href="classmingfx_1_1_graphics_app.html#a9e2b4cd7eeabe1ace9d5e9220349fbaa" title="Called once per frame.">GraphicsApp::UpdateSimulation()</a>, use:  <a href="classmingfx_1_1_uni_cam.html#aab253d966af52ac277ac51194745085c">More...</a><br /></td></tr>
<tr class="separator:aab253d966af52ac277ac51194745085c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae45f3c80c205a539baeb4f1b8787777d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#ae45f3c80c205a539baeb4f1b8787777d">Draw</a> (const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;projectionMatrix)</td></tr>
<tr class="memdesc:ae45f3c80c205a539baeb4f1b8787777d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Finally, attach this to your draw callback routine. Within <a class="el" href="classmingfx_1_1_graphics_app.html#a5a858fd10651f7617491f37b49dbf8ca" title="Override this to draw graphics using raw OpenGL 2D or 3D graphics calls.">GraphicsApp::DrawUsingOpenGL()</a>, use:  <a href="classmingfx_1_1_uni_cam.html#ae45f3c80c205a539baeb4f1b8787777d">More...</a><br /></td></tr>
<tr class="separator:ae45f3c80c205a539baeb4f1b8787777d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af7e7276f9390ec57ca577092c99d6ca3"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#af7e7276f9390ec57ca577092c99d6ca3">view_matrix</a> ()</td></tr>
<tr class="memdesc:af7e7276f9390ec57ca577092c99d6ca3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Access the camera view matrix created by the <a class="el" href="classmingfx_1_1_uni_cam.html" title="This implements a user interface for controlling the camera with the mouse.">UniCam</a> interactions via this method and use it to draw the geometry in your scence. For example, within <a class="el" href="classmingfx_1_1_graphics_app.html#a5a858fd10651f7617491f37b49dbf8ca" title="Override this to draw graphics using raw OpenGL 2D or 3D graphics calls.">GraphicsApp::DrawUsingOpenGL()</a>, you might have:  <a href="classmingfx_1_1_uni_cam.html#af7e7276f9390ec57ca577092c99d6ca3">More...</a><br /></td></tr>
<tr class="separator:af7e7276f9390ec57ca577092c99d6ca3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a65d5735b4b3a8e38f2b30df4133cadd2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classmingfx_1_1_point3.html">Point3</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#a65d5735b4b3a8e38f2b30df4133cadd2">eye</a> ()</td></tr>
<tr class="memdesc:a65d5735b4b3a8e38f2b30df4133cadd2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the "eye" point (i.e., focal point) of the camera in world space coordinates.  <a href="classmingfx_1_1_uni_cam.html#a65d5735b4b3a8e38f2b30df4133cadd2">More...</a><br /></td></tr>
<tr class="separator:a65d5735b4b3a8e38f2b30df4133cadd2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8363576bf0f85c74d80ced697bd73d40"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classmingfx_1_1_vector3.html">Vector3</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#a8363576bf0f85c74d80ced697bd73d40">look</a> ()</td></tr>
<tr class="memdesc:a8363576bf0f85c74d80ced697bd73d40"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the look direction (i.e., -Z axis of the camera matrix) in world space coordinates.  <a href="classmingfx_1_1_uni_cam.html#a8363576bf0f85c74d80ced697bd73d40">More...</a><br /></td></tr>
<tr class="separator:a8363576bf0f85c74d80ced697bd73d40"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6b17bab82595ca468a3c638512011e5b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#a6b17bab82595ca468a3c638512011e5b">set_view_matrix</a> (<a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> viewMatrix)</td></tr>
<tr class="memdesc:a6b17bab82595ca468a3c638512011e5b"><td class="mdescLeft">&#160;</td><td class="mdescRight">This is not required, but you may use this if you wish to set an initial view matrix or reset the view matrix.  <a href="classmingfx_1_1_uni_cam.html#a6b17bab82595ca468a3c638512011e5b">More...</a><br /></td></tr>
<tr class="separator:a6b17bab82595ca468a3c638512011e5b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a71e0351ac19a18b9c02215a60dc51068"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_uni_cam.html#a71e0351ac19a18b9c02215a60dc51068">set_default_depth</a> (float d)</td></tr>
<tr class="memdesc:a71e0351ac19a18b9c02215a60dc51068"><td class="mdescLeft">&#160;</td><td class="mdescRight">This sets the depth of the center of rotation for the case when the user's click does not intersect any geometry. It defaults to 4 units, but the right value to use depends very much on the current scene. For example, you could set a very good value by calculating the current centroid of your scene and the finding the depth of this point (the distance along the look vector) relative to the camera.  <a href="classmingfx_1_1_uni_cam.html#a71e0351ac19a18b9c02215a60dc51068">More...</a><br /></td></tr>
<tr class="separator:a71e0351ac19a18b9c02215a60dc51068"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a6e7771961011f573b2e2249f602b2d2e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6e7771961011f573b2e2249f602b2d2e">&#9670;&nbsp;</a></span>UniCam() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">mingfx::UniCam::UniCam </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Creates a <a class="el" href="classmingfx_1_1_uni_cam.html" title="This implements a user interface for controlling the camera with the mouse.">UniCam</a> object with an initial view matrix = identity. </p>

</div>
</div>
<a id="af507e639c4bceb4c79e21a6f80c48d07"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af507e639c4bceb4c79e21a6f80c48d07">&#9670;&nbsp;</a></span>UniCam() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">mingfx::UniCam::UniCam </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;&#160;</td>
          <td class="paramname"><em>initialViewMatrix</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Creates a <a class="el" href="classmingfx_1_1_uni_cam.html" title="This implements a user interface for controlling the camera with the mouse.">UniCam</a> object with the supplied initial view matrix. </p>

</div>
</div>
<a id="af98022627bcb52dbf54779cfaeb6ff7e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af98022627bcb52dbf54779cfaeb6ff7e">&#9670;&nbsp;</a></span>~UniCam()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual mingfx::UniCam::~UniCam </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="aab253d966af52ac277ac51194745085c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aab253d966af52ac277ac51194745085c">&#9670;&nbsp;</a></span>AdvanceAnimation()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::UniCam::AdvanceAnimation </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>dt</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Attach this to a callback that can be used to control animation. Within <a class="el" href="classmingfx_1_1_graphics_app.html#a9e2b4cd7eeabe1ace9d5e9220349fbaa" title="Called once per frame.">GraphicsApp::UpdateSimulation()</a>, use: </p>
<div class="fragment"><div class="line">uniCam.AdvanceAnimation(dt);</div>
</div><!-- fragment --> 
</div>
</div>
<a id="ae45f3c80c205a539baeb4f1b8787777d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae45f3c80c205a539baeb4f1b8787777d">&#9670;&nbsp;</a></span>Draw()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::UniCam::Draw </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;&#160;</td>
          <td class="paramname"><em>projectionMatrix</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Finally, attach this to your draw callback routine. Within <a class="el" href="classmingfx_1_1_graphics_app.html#a5a858fd10651f7617491f37b49dbf8ca" title="Override this to draw graphics using raw OpenGL 2D or 3D graphics calls.">GraphicsApp::DrawUsingOpenGL()</a>, use: </p>
<div class="fragment"><div class="line">uniCam.Draw(projMatrix);</div>
</div><!-- fragment --> 
</div>
</div>
<a id="a65d5735b4b3a8e38f2b30df4133cadd2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a65d5735b4b3a8e38f2b30df4133cadd2">&#9670;&nbsp;</a></span>eye()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classmingfx_1_1_point3.html">Point3</a> mingfx::UniCam::eye </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the "eye" point (i.e., focal point) of the camera in world space coordinates. </p>

</div>
</div>
<a id="a8363576bf0f85c74d80ced697bd73d40"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8363576bf0f85c74d80ced697bd73d40">&#9670;&nbsp;</a></span>look()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classmingfx_1_1_vector3.html">Vector3</a> mingfx::UniCam::look </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the look direction (i.e., -Z axis of the camera matrix) in world space coordinates. </p>

</div>
</div>
<a id="a85afba6e8792636f3c6ba2433db1c52f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a85afba6e8792636f3c6ba2433db1c52f">&#9670;&nbsp;</a></span>OnButtonDown()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::UniCam::OnButtonDown </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_point2.html">Point2</a> &amp;&#160;</td>
          <td class="paramname"><em>normalizedMousePos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>mouseZ</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Attach this to whatever mouse button you wish, for example, call this from within <a class="el" href="classmingfx_1_1_graphics_app.html#a903f94b82cc10f32039ff3f2ba368a9c" title="If the mouse button was pressed down since the last frame, then this function will be called to notif...">GraphicsApp::OnRightMouseDown()</a>. If your mousePos is reported in pixels, you will need to convert it to normalized device coordinates before passing it on to this routine. The depth buffer value for the pixel under the mouse is also needed. If you are using <a class="el" href="classmingfx_1_1_graphics_app.html" title="This is the main application base class for the MinGfx Toolkit.">GraphicsApp</a>, you can access both of these as follows: </p>
<div class="fragment"><div class="line">Point2 mouse_xy = PixelsToNormalizedDeviceCoords(mouse_in_pixels);</div>
<div class="line"><span class="keywordtype">float</span> mouse_z = ReadZValueAtPixel(mouse_in_pixels);</div>
<div class="line">uniCam.OnButtonDown(mouse_xy, mouse_z);</div>
</div><!-- fragment --> 
</div>
</div>
<a id="a2a9431dc3943c8dc485994d88ce2a58a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2a9431dc3943c8dc485994d88ce2a58a">&#9670;&nbsp;</a></span>OnButtonUp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::UniCam::OnButtonUp </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_point2.html">Point2</a> &amp;&#160;</td>
          <td class="paramname"><em>normalizedMousePos</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Attach this to the corresponding button up event, for example, call this from within <a class="el" href="classmingfx_1_1_graphics_app.html#ad7c33791c44afc87ce789874f3002ca3" title="If the mouse button was released since the last frame, then this function will be called to notify yo...">GraphicsApp::OnRightMouseUp()</a>. If your mousePos is reported in pixels, you will need to convert it to normalized device coordinates before passing it on to this routine. Within <a class="el" href="classmingfx_1_1_graphics_app.html" title="This is the main application base class for the MinGfx Toolkit.">GraphicsApp</a>, use: </p>
<div class="fragment"><div class="line">Point2 mouse_xy = PixelsToNormalizedDeviceCoords(mouse_in_pixels);</div>
<div class="line">uniCam.OnButtonUp(mouse_xy);</div>
</div><!-- fragment --> 
</div>
</div>
<a id="a33f1b41fcf53ea78ca2b3640902c5bbe"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a33f1b41fcf53ea78ca2b3640902c5bbe">&#9670;&nbsp;</a></span>OnDrag()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::UniCam::OnDrag </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_point2.html">Point2</a> &amp;&#160;</td>
          <td class="paramname"><em>normalizedMousePos</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Attach this to the corresponding mouse move event, for example, call this from within <a class="el" href="classmingfx_1_1_graphics_app.html#a00ad5039af2f428a08fe45751a9731c7" title="If the mouse button is held down and the mouse has moved in the past frame then this function will be...">GraphicsApp::OnRightMouseDrag()</a>. If your mousePos is reported in pixels, you will need to convert it to normalized device coordinates before passing it on to this routine. Within <a class="el" href="classmingfx_1_1_graphics_app.html" title="This is the main application base class for the MinGfx Toolkit.">GraphicsApp</a>, use: </p>
<div class="fragment"><div class="line">Point2 mouse_xy = PixelsToNormalizedDeviceCoords(mouse_in_pixels);</div>
<div class="line">uniCam.OnDrag(mouse_xy);</div>
</div><!-- fragment --> 
</div>
</div>
<a id="a71e0351ac19a18b9c02215a60dc51068"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a71e0351ac19a18b9c02215a60dc51068">&#9670;&nbsp;</a></span>set_default_depth()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::UniCam::set_default_depth </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>d</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This sets the depth of the center of rotation for the case when the user's click does not intersect any geometry. It defaults to 4 units, but the right value to use depends very much on the current scene. For example, you could set a very good value by calculating the current centroid of your scene and the finding the depth of this point (the distance along the look vector) relative to the camera. </p>

</div>
</div>
<a id="a6b17bab82595ca468a3c638512011e5b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6b17bab82595ca468a3c638512011e5b">&#9670;&nbsp;</a></span>set_view_matrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::UniCam::set_view_matrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a>&#160;</td>
          <td class="paramname"><em>viewMatrix</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This is not required, but you may use this if you wish to set an initial view matrix or reset the view matrix. </p>

</div>
</div>
<a id="af7e7276f9390ec57ca577092c99d6ca3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af7e7276f9390ec57ca577092c99d6ca3">&#9670;&nbsp;</a></span>view_matrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> mingfx::UniCam::view_matrix </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Access the camera view matrix created by the <a class="el" href="classmingfx_1_1_uni_cam.html" title="This implements a user interface for controlling the camera with the mouse.">UniCam</a> interactions via this method and use it to draw the geometry in your scence. For example, within <a class="el" href="classmingfx_1_1_graphics_app.html#a5a858fd10651f7617491f37b49dbf8ca" title="Override this to draw graphics using raw OpenGL 2D or 3D graphics calls.">GraphicsApp::DrawUsingOpenGL()</a>, you might have: </p>
<div class="fragment"><div class="line">Matrix4 P = <a class="code" href="classmingfx_1_1_matrix4.html#a0e34aee86758a0397074590b87712c5e">Matrix4::Perspective</a>(30, aspect_ratio(), 1, 20);</div>
<div class="line">Matrix4 V = unicam.view_matrix();</div>
<div class="line">Matrix4 M = Matrix4::RotateY(<a class="code" href="classmingfx_1_1_gfx_math.html#a1336de2695bc3bb750b23fb0ea211637">GfxMath::ToRadians</a>(45.0));</div>
<div class="line">quick_shapes.DrawCube(M, V, P, Color(1,1,1));</div>
<div class="ttc" id="aclassmingfx_1_1_gfx_math_html_a1336de2695bc3bb750b23fb0ea211637"><div class="ttname"><a href="classmingfx_1_1_gfx_math.html#a1336de2695bc3bb750b23fb0ea211637">mingfx::GfxMath::ToRadians</a></div><div class="ttdeci">static float ToRadians(float degrees)</div></div>
</div><!-- fragment --> 
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>src/<a class="el" href="unicam_8h_source.html">unicam.h</a></li>
</ul>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.9.1
</small></address>
</body>
</html>