NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CameraControls.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2011, NVIDIA Corporation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA Corporation nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "3d/CameraControls.hpp"
29 #include "3d/Mesh.hpp"
30 #include "io/StateDump.hpp"
31 
32 using namespace FW;
33 
34 //------------------------------------------------------------------------
35 
36 static const F32 s_mouseRotateSpeed = 0.005f;
37 static const F32 s_mouseStrafeSpeed = -0.005f;
38 static const F32 s_keyRotateSpeed = 1.0f;
39 static const F32 s_inclinationLimit = 0.2f; // avoid looking directly up or down when aligned
40 
41 //------------------------------------------------------------------------
42 
44 : m_commonControls (commonControls),
45  m_features (features),
46  m_window (NULL),
47  m_enableMovement (true),
48 
49  m_dragLeft (false),
50  m_dragMiddle (false),
51  m_dragRight (false),
52  m_alignY (false),
53  m_alignZ (false)
54 {
55  initDefaults();
56  if ((m_features & Feature_StereoControls) != 0 && !GLContext::isStereoAvailable())
57  m_features &= ~Feature_StereoControls;
58 }
59 
60 //------------------------------------------------------------------------
61 
63 {
64 }
65 
66 //------------------------------------------------------------------------
67 
69 {
70  if (!m_commonControls)
71  fail("CameraControls attached to a window without CommonControls!");
72  CommonControls& cc = *m_commonControls;
73  FW_ASSERT(m_window == ev.window || ev.type == Window::EventType_AddListener);
74 
75  // Initialize movement.
76 
77  Mat3f orient = getOrientation();
78  Vec3f rotate = 0.0f;
79  Vec3f move = 0.0f;
80 
81  // Handle events.
82 
83  switch (ev.type)
84  {
86  FW_ASSERT(!m_window);
87  m_window = ev.window;
88  m_timer.unstart();
89  m_dragLeft = false;
90  m_dragMiddle = false;
91  m_dragRight = false;
92 
93  cc.addStateObject(this);
95  repaint();
96  return false;
97 
99  cc.removeStateObject(this);
101  repaint();
102  m_window = NULL;
103  return false;
104 
106  if (ev.key == FW_KEY_MOUSE_LEFT) m_dragLeft = true;
107  if (ev.key == FW_KEY_MOUSE_MIDDLE) m_dragMiddle = true;
108  if (ev.key == FW_KEY_MOUSE_RIGHT) m_dragRight = true;
109  if (ev.key == FW_KEY_WHEEL_UP) m_speed *= 1.2f;
110  if (ev.key == FW_KEY_WHEEL_DOWN) m_speed /= 1.2f;
111  break;
112 
114  if (ev.key == FW_KEY_MOUSE_LEFT) m_dragLeft = false;
115  if (ev.key == FW_KEY_MOUSE_MIDDLE) m_dragMiddle = false;
116  if (ev.key == FW_KEY_MOUSE_RIGHT) m_dragRight = false;
117  break;
118 
120  {
121  Vec3f delta = Vec3f((F32)ev.mouseDelta.x, (F32)-ev.mouseDelta.y, 0.0f);
122  if (m_dragLeft) rotate += delta * s_mouseRotateSpeed;
123  if (m_dragMiddle) move += delta * m_speed * s_mouseStrafeSpeed;
124  if (m_dragRight) move += Vec3f(0.0f, 0.0f, (F32)ev.mouseDelta.y) * m_speed * s_mouseStrafeSpeed;
125  }
126  break;
127 
129  {
130  F32 timeDelta = m_timer.end();
131  F32 boost = cc.getKeyBoost();
132  Vec3f rotateTmp = 0.0f;
133  bool alt = m_window->isKeyDown(FW_KEY_ALT);
134 
135  if (m_window->isKeyDown(FW_KEY_A) || (m_window->isKeyDown(FW_KEY_LEFT) && alt)) move.x -= 1.0f;
136  if (m_window->isKeyDown(FW_KEY_D) || (m_window->isKeyDown(FW_KEY_RIGHT) && alt)) move.x += 1.0f;
137  if (m_window->isKeyDown(FW_KEY_F) || m_window->isKeyDown(FW_KEY_PAGE_DOWN)) move.y -= 1.0f;
138  if (m_window->isKeyDown(FW_KEY_R) || m_window->isKeyDown(FW_KEY_PAGE_UP)) move.y += 1.0f;
139  if (m_window->isKeyDown(FW_KEY_W) || (m_window->isKeyDown(FW_KEY_UP) && alt)) move.z -= 1.0f;
140  if (m_window->isKeyDown(FW_KEY_S) || (m_window->isKeyDown(FW_KEY_DOWN) && alt)) move.z += 1.0f;
141 
142  if (m_window->isKeyDown(FW_KEY_LEFT) && !alt) rotateTmp.x -= 1.0f;
143  if (m_window->isKeyDown(FW_KEY_RIGHT) && !alt) rotateTmp.x += 1.0f;
144  if (m_window->isKeyDown(FW_KEY_DOWN) && !alt) rotateTmp.y -= 1.0f;
145  if (m_window->isKeyDown(FW_KEY_UP) && !alt) rotateTmp.y += 1.0f;
146  if (m_window->isKeyDown(FW_KEY_E) || m_window->isKeyDown(FW_KEY_HOME)) rotateTmp.z -= 1.0f;
147  if (m_window->isKeyDown(FW_KEY_Q) || m_window->isKeyDown(FW_KEY_INSERT)) rotateTmp.z += 1.0f;
148 
149  move *= timeDelta * m_speed * boost;
150  rotate += rotateTmp * timeDelta * s_keyRotateSpeed * boost;
151  }
152  break;
153 
154  default:
155  break;
156  }
157 
158  // Apply movement.
159 
160  if (m_enableMovement)
161  {
162  if (!move.isZero())
163  m_position += orient * move;
164 
165  if (rotate.x != 0.0f || rotate.y != 0.0f)
166  {
167  Vec3f tmp = orient.col(2) * cos(rotate.x) - orient.col(0) * sin(rotate.x);
168  m_forward = (orient.col(1) * sin(rotate.y) - tmp * cos(rotate.y)).normalized();
169  if (!m_keepAligned)
170  m_up = (orient.col(1) * cos(rotate.y) + tmp * sin(rotate.y)).normalized();
171  else if (-m_forward.cross(m_up).dot(tmp.cross(m_up).normalized()) < s_inclinationLimit)
172  m_forward = -tmp.normalized();
173  }
174 
175  if (rotate.z != 0.0f && !m_keepAligned)
176  {
177  Vec3f up = orient.transposed() * m_up;
178  m_up = orient * Vec3f(up.x * cos(rotate.z) - sin(rotate.z), up.x * sin(rotate.z) + up.y * cos(rotate.z), up.z);
179  }
180  }
181 
182  // Apply alignment.
183 
184  if (m_alignY)
185  m_up = Vec3f(0.0f, 1.0f, 0.0f);
186  m_alignY = false;
187 
188  if (m_alignZ)
189  m_up = Vec3f(0.0f, 0.0f, 1.0f);
190  m_alignZ = false;
191 
192  // Update stereo mode.
193 
194  if (hasFeature(Feature_StereoControls))
195  {
196  GLContext::Config config = m_window->getGLConfig();
197  config.isStereo = (m_enableStereo && GLContext::isStereoAvailable());
198  m_window->setGLConfig(config);
199  }
200 
201  // Repaint continuously.
202 
203  if (ev.type == Window::EventType_Paint)
204  repaint();
205  return false;
206 }
207 
208 //------------------------------------------------------------------------
209 
211 {
212  initDefaults();
213  d.pushOwner("CameraControls");
214  d.get(m_position, "m_position");
215  d.get(m_forward, "m_forward");
216  d.get(m_up, "m_up");
217  d.get(m_keepAligned, "m_keepAligned");
218  d.get(m_speed, "m_speed");
219  d.get(m_fov, "m_fov");
220  d.get(m_near, "m_near");
221  d.get(m_far, "m_far");
222  d.get(m_enableStereo, "m_enableStereo");
223  d.get(m_stereoSeparation, "m_stereoSeparation");
224  d.get(m_stereoConvergence, "m_stereoConvergence");
225  d.popOwner();
226 }
227 
228 //------------------------------------------------------------------------
229 
231 {
232  d.pushOwner("CameraControls");
233  d.set(m_position, "m_position");
234  d.set(m_forward, "m_forward");
235  d.set(m_up, "m_up");
236  d.set(m_keepAligned, "m_keepAligned");
237  d.set(m_speed, "m_speed");
238  d.set(m_fov, "m_fov");
239  d.set(m_near, "m_near");
240  d.set(m_far, "m_far");
241  d.set(m_enableStereo, "m_enableStereo");
242  d.set(m_stereoSeparation, "m_stereoSeparation");
243  d.set(m_stereoConvergence, "m_stereoConvergence");
244  d.popOwner();
245 }
246 
247 //------------------------------------------------------------------------
248 
250 {
251  Mat3f r;
252  r.col(2) = -m_forward.normalized();
253  r.col(0) = m_up.cross(r.col(2)).normalized();
254  r.col(1) = ((Vec3f)r.col(2)).cross(r.col(0)).normalized();
255  return r;
256 }
257 
258 //------------------------------------------------------------------------
259 
261 {
262  Mat3f orient = getOrientation();
263  Mat4f r;
264  r.setCol(0, Vec4f(orient.col(0), 0.0f));
265  r.setCol(1, Vec4f(orient.col(1), 0.0f));
266  r.setCol(2, Vec4f(orient.col(2), 0.0f));
267  r.setCol(3, Vec4f(m_position, 1.0f));
268  return r;
269 }
270 
271 //------------------------------------------------------------------------
272 
274 {
275  Mat3f orient = getOrientation();
276  Vec3f pos = orient.transposed() * m_position;
277  Mat4f r;
278  r.setRow(0, Vec4f(orient.col(0), -pos.x));
279  r.setRow(1, Vec4f(orient.col(1), -pos.y));
280  r.setRow(2, Vec4f(orient.col(2), -pos.z));
281  return r;
282 }
283 
284 //------------------------------------------------------------------------
285 
287 {
288  m_position = m.col(3).toCartesian();
289  m_forward = -normalize(Vec4f(m.col(2)).getXYZ());
290 
291  if (!m_keepAligned)
292  m_up = normalize(Vec4f(m.col(1)).getXYZ());
293 }
294 
295 //------------------------------------------------------------------------
296 
298 {
299  m_position = Vec3f(0.0f, 0.0f, 1.5f);
300  m_forward = Vec3f(0.0f, 0.0f, -1.0f);
301  m_up = Vec3f(0.0f, 1.0f, 0.0f);
302 
303  m_keepAligned = false;
304  m_speed = 0.2f;
305  m_fov = 73.7f;
306  m_near = 0.001f;
307  m_far = 3.0f;
308 
309  m_enableStereo = false;
310  m_stereoSeparation = 0.004f;
311  m_stereoConvergence = 0.015f;
312 }
313 
314 //------------------------------------------------------------------------
315 
317 {
318  FW_ASSERT(mesh);
319  Vec3f lo, hi;
320  mesh->getBBox(lo, hi);
321 
322  Vec3f center = (lo + hi) * 0.5f;
323  F32 size = (hi - lo).max();
324  if (size <= 0.0f)
325  return;
326 
327  m_position = center + Vec3f(0.0f, 0.0f, size * 0.75f);
328  m_forward = Vec3f(0.0f, 0.0f, -1.0f);
329  m_up = Vec3f(0.0f, 1.0f, 0.0f);
330 
331  m_speed = size * 0.1f;
332  m_near = size * 0.0005f;
333  m_far = size * 1.5f;
334 
335  m_stereoSeparation = size * 0.002f;
336 }
337 
338 //------------------------------------------------------------------------
339 
341 {
342  String sig;
343  sig += '"';
344  encodeFloat(sig, m_position.x);
345  encodeFloat(sig, m_position.y);
346  encodeFloat(sig, m_position.z);
347  encodeDirection(sig, m_forward);
348  encodeDirection(sig, m_up);
349  encodeFloat(sig, m_speed);
350  encodeFloat(sig, m_fov);
351  encodeFloat(sig, m_near);
352  encodeFloat(sig, m_far);
353  encodeBits(sig, (m_keepAligned) ? 1 : 0);
354  sig += "\",";
355  return sig;
356 }
357 
358 //------------------------------------------------------------------------
359 
361 {
362  const char* src = sig.getPtr();
363  while (*src == ' ' || *src == '\t' || *src == '\n') src++;
364  if (*src == '"') src++;
365 
366  F32 px = decodeFloat(src);
367  F32 py = decodeFloat(src);
368  F32 pz = decodeFloat(src);
369  Vec3f forward = decodeDirection(src);
370  Vec3f up = decodeDirection(src);
371  F32 speed = decodeFloat(src);
372  F32 fov = decodeFloat(src);
373  F32 znear = decodeFloat(src);
374  F32 zfar = decodeFloat(src);
375  bool keepAligned = (decodeBits(src) != 0);
376 
377  if (*src == '"') src++;
378  if (*src == ',') src++;
379  while (*src == ' ' || *src == '\t' || *src == '\n') src++;
380  if (*src)
381  setError("CameraControls: Invalid signature!");
382 
383  if (hasError())
384  return;
385 
386  m_position = Vec3f(px, py, pz);
387  m_forward = forward;
388  m_up = up;
389  m_speed = speed;
390  m_fov = fov;
391  m_near = znear;
392  m_far = zfar;
393  m_keepAligned = keepAligned;
394 }
395 
396 //------------------------------------------------------------------------
397 
399 {
400  printf("position ");
401  m_position.print();
402  printf(" forward ");
403  m_forward.print();
404  printf(" up ");
405  m_up.print();
406  printf(" FOV %.2f , near %.2f , far %.2f\n", m_fov, m_near, m_far);
407 }
408 
409 //------------------------------------------------------------------------
410 
412 {
413  CommonControls& cc = *m_commonControls;
414 
415  if (hasFeature(Feature_AlignYButton))
416  cc.addButton(&m_alignY, FW_KEY_NONE, "Align camera to Y-axis");
417  if (hasFeature(Feature_AlignZButton))
418  cc.addButton(&m_alignZ, FW_KEY_NONE, "Align camera to Z-axis");
419  if (hasFeature(Feature_KeepAlignToggle))
420  cc.addToggle(&m_keepAligned, FW_KEY_NONE, "Retain camera alignment");
421  if (hasFeature(Feature_SpeedSlider))
422  cc.addSlider(&m_speed, 1.0e-3f, 1.0e4f, true, FW_KEY_PLUS, FW_KEY_MINUS, "Camera speed (+/-, mouse wheel) = %g units/sec", 0.05f);
423 
424  cc.beginSliderStack();
425  if (hasFeature(Feature_FOVSlider))
426  cc.addSlider(&m_fov, 1.0f, 179.0f, false, FW_KEY_NONE, FW_KEY_NONE, "Camera FOV = %.1f degrees", 0.2f);
427  if (hasFeature(Feature_NearSlider))
428  cc.addSlider(&m_near, 1.0e-3f, 1.0e6f, true, FW_KEY_NONE, FW_KEY_NONE, "Camera near = %g units", 0.05f);
429  if (hasFeature(Feature_FarSlider))
430  cc.addSlider(&m_far, 1.0e-3f, 1.0e6f, true, FW_KEY_NONE, FW_KEY_NONE, "Camera far = %g units", 0.05f);
431  cc.endSliderStack();
432 
433  if (hasFeature(Feature_StereoControls))
434  {
435  cc.addToggle(&m_enableStereo, FW_KEY_NONE, "Enable stereoscopic 3D");
436  cc.beginSliderStack();
437  cc.addSlider(&m_stereoSeparation, 1.0e-3f, 1.0e3f, true, FW_KEY_NONE, FW_KEY_NONE, "Stereo separation = %g units");
438  cc.addSlider(&m_stereoConvergence, 1.0e-4f, 1.0f, true, FW_KEY_NONE, FW_KEY_NONE, "Stereo convergence = %g units");
439  cc.endSliderStack();
440  }
441 }
442 
443 //------------------------------------------------------------------------
444 
446 {
447  CommonControls& cc = *m_commonControls;
448  cc.removeControl(&m_keepAligned);
449  cc.removeControl(&m_speed);
450  cc.removeControl(&m_fov);
451  cc.removeControl(&m_near);
452  cc.removeControl(&m_far);
453  cc.removeControl(&m_enableStereo);
454  cc.removeControl(&m_stereoSeparation);
455  cc.removeControl(&m_stereoConvergence);
456 }
457 
458 //------------------------------------------------------------------------
459 
460 void CameraControls::encodeBits(String& dst, U32 v)
461 {
462  FW_ASSERT(v < 64);
463  int base = (v < 12) ? '/' : (v < 38) ? 'A' - 12 : 'a' - 38;
464  dst += (char)(v + base);
465 }
466 
467 //------------------------------------------------------------------------
468 
469 U32 CameraControls::decodeBits(const char*& src)
470 {
471  if (*src >= '/' && *src <= ':') return *src++ - '/';
472  if (*src >= 'A' && *src <= 'Z') return *src++ - 'A' + 12;
473  if (*src >= 'a' && *src <= 'z') return *src++ - 'a' + 38;
474  setError("CameraControls: Invalid signature!");
475  return 0;
476 }
477 
478 //------------------------------------------------------------------------
479 
480 void CameraControls::encodeFloat(String& dst, F32 v)
481 {
482  U32 bits = floatToBits(v);
483  for (int i = 0; i < 32; i += 6)
484  encodeBits(dst, (bits >> i) & 0x3F);
485 }
486 
487 //------------------------------------------------------------------------
488 
489 F32 CameraControls::decodeFloat(const char*& src)
490 {
491  U32 bits = 0;
492  for (int i = 0; i < 32; i += 6)
493  bits |= decodeBits(src) << i;
494  return bitsToFloat(bits);
495 }
496 
497 //------------------------------------------------------------------------
498 
499 void CameraControls::encodeDirection(String& dst, const Vec3f& v)
500 {
501  Vec3f a(abs(v.x), abs(v.y), abs(v.z));
502  int axis = (a.x >= max(a.y, a.z)) ? 0 : (a.y >= a.z) ? 1 : 2;
503 
504  Vec3f tuv;
505  switch (axis)
506  {
507  case 0: tuv = v; break;
508  case 1: tuv = Vec3f(v.y, v.z, v.x); break;
509  default: tuv = Vec3f(v.z, v.x, v.y); break;
510  }
511 
512  int face = axis | ((tuv.x >= 0.0f) ? 0 : 4);
513  if (tuv.y == 0.0f && tuv.z == 0.0f)
514  {
515  encodeBits(dst, face | 8);
516  return;
517  }
518 
519  encodeBits(dst, face);
520  encodeFloat(dst, tuv.y / abs(tuv.x));
521  encodeFloat(dst, tuv.z / abs(tuv.x));
522 }
523 
524 //------------------------------------------------------------------------
525 
526 Vec3f CameraControls::decodeDirection(const char*& src)
527 {
528  int face = decodeBits(src);
529  Vec3f tuv;
530  tuv.x = ((face & 4) == 0) ? 1.0f : -1.0f;
531  tuv.y = ((face & 8) == 0) ? decodeFloat(src) : 0.0f;
532  tuv.z = ((face & 8) == 0) ? decodeFloat(src) : 0.0f;
533  tuv = tuv.normalized();
534 
535  switch (face & 3)
536  {
537  case 0: return tuv;
538  case 1: return Vec3f(tuv.z, tuv.x, tuv.y);
539  default: return Vec3f(tuv.y, tuv.z, tuv.x);
540  }
541 }
542 
543 //------------------------------------------------------------------------
#define FW_KEY_PAGE_UP
Definition: Keys.hpp:135
void addStateObject(StateObject *obj)
U32 floatToBits(F32 a)
Definition: Math.hpp:95
const GLContext::Config & getGLConfig(void) const
Definition: Window.hpp:112
#define NULL
Definition: Defs.hpp:39
Mat4f getWorldToCamera(void) const
void removeGUIControls(void)
#define FW_KEY_MOUSE_RIGHT
Definition: Keys.hpp:39
FW_CUDA_FUNC void setRow(int r, const VectorBase< T, L, V > &v)
const char * getPtr(void) const
Definition: String.hpp:51
#define FW_KEY_DOWN
Definition: Keys.hpp:75
#define FW_KEY_NONE
Definition: Keys.hpp:37
CameraControls(CommonControls *commonControls=NULL, U32 features=Feature_Default)
#define FW_KEY_LEFT
Definition: Keys.hpp:125
void getBBox(Vec3f &lo, Vec3f &hi) const
Definition: Mesh.cpp:597
#define FW_KEY_PAGE_DOWN
Definition: Keys.hpp:134
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v GLuint v GLenum GLenum GLenum GLuint GLint level GLsizei GLuint framebuffers GLuint const GLchar name GLenum GLintptr GLsizeiptr GLvoid data GLuint GLenum GLint param GLuint GLenum GLint param GLhandleARB programObj GLenum GLenum GLsizei GLsizei height GLenum GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid pixels GLint GLsizei const GLfloat value GLint GLfloat GLfloat v1 GLint GLfloat GLfloat GLfloat v2 GLint GLsizei const GLfloat value GLint GLsizei GLboolean const GLfloat value GLuint program GLuint GLfloat GLfloat GLfloat z GLuint GLint GLenum GLboolean normalized
Definition: DLLImports.inl:365
void setError(const char *fmt,...)
Definition: Defs.cpp:253
FW_CUDA_FUNC F64 cos(F64 a)
Definition: Math.hpp:49
#define FW_KEY_S
Definition: Keys.hpp:211
void unstart(void)
Definition: Timer.hpp:43
void addToggle(bool *target, const String &key, const String &title, bool *dirtyNotify=NULL)
void beginSliderStack(void)
void addSlider(F32 *target, F32 minValue, F32 maxValue, bool isExponential, const String &increaseKey, const String &decreaseKey, const String &format, F32 speed=0.25f, bool *dirtyNotify=NULL)
Vec2i mouseDelta
Definition: Window.hpp:75
F32 getKeyBoost(void) const
Window * window
Definition: Window.hpp:79
#define FW_KEY_RIGHT
Definition: Keys.hpp:143
void popOwner(void)
Definition: StateDump.hpp:52
void removeStateObject(StateObject *obj)
static bool isStereoAvailable(void)
Definition: GLContext.hpp:210
#define FW_KEY_WHEEL_DOWN
Definition: Keys.hpp:42
FW_CUDA_FUNC bool isZero(void) const
Definition: Math.hpp:141
#define FW_KEY_D
Definition: Keys.hpp:196
#define FW_KEY_PLUS
Definition: Keys.hpp:171
FW_CUDA_FUNC T dot(const VectorBase< T, L, V > &v) const
Definition: Math.hpp:185
Mat4f getCameraToWorld(void) const
float F32
Definition: Defs.hpp:89
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr const GLvoid GLenum usage GLuint shader GLenum type GLsizei const GLuint framebuffers GLsizei const GLuint renderbuffers GLuint v
Definition: DLLImports.inl:329
#define FW_KEY_F
Definition: Keys.hpp:198
#define FW_KEY_R
Definition: Keys.hpp:210
void set(const StateDump &other)
Definition: StateDump.hpp:49
virtual void writeState(StateDump &d) const
#define FW_KEY_W
Definition: Keys.hpp:215
FW_CUDA_FUNC S transposed(void) const
Definition: Math.hpp:953
FW_CUDA_FUNC T max(const VectorBase< T, L, S > &v)
Definition: Math.hpp:462
#define FW_KEY_MOUSE_MIDDLE
Definition: Keys.hpp:40
FW_CUDA_FUNC S32 abs(S32 a)
Definition: Math.hpp:41
#define FW_ASSERT(X)
Definition: Defs.hpp:67
FW_CUDA_FUNC Vec3f cross(const Vec3f &v) const
Definition: Math.hpp:340
F32 end(void)
Definition: Timer.hpp:69
bool isKeyDown(const String &key) const
Definition: Window.hpp:128
String encodeSignature(void) const
Mat3f getOrientation(void) const
FW_CUDA_FUNC const Vector< T, L > & col(int c) const
Definition: Math.hpp:526
void setCameraToWorld(const Mat4f &m)
#define FW_KEY_ALT
Definition: Keys.hpp:55
unsigned int U32
Definition: Defs.hpp:85
bool hasError(void)
Definition: Defs.cpp:289
void addButton(bool *target, const String &key, const String &title, bool *dirtyNotify=NULL)
F32 bitsToFloat(U32 a)
Definition: Math.hpp:96
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction f
Definition: DLLImports.inl:88
#define FW_KEY_A
Definition: Keys.hpp:193
FW_CUDA_FUNC F32 cross(const Vec2f &a, const Vec2f &b)
Definition: Math.hpp:481
#define FW_KEY_INSERT
Definition: Keys.hpp:114
void setGLConfig(const GLContext::Config &config)
Definition: Window.cpp:195
#define FW_KEY_HOME
Definition: Keys.hpp:113
void initForMesh(const MeshBase *mesh)
void printf(const char *fmt,...)
Definition: Defs.cpp:225
FW_CUDA_FUNC S normalize(const VectorBase< T, L, S > &v, T len=(T) 1)
Definition: Math.hpp:460
void pushOwner(const String &id)
Definition: StateDump.hpp:51
#define FW_KEY_MOUSE_LEFT
Definition: Keys.hpp:38
FW_CUDA_FUNC S normalized(T len=(T) 1) const
Definition: Math.hpp:144
virtual void readState(StateDump &d)
#define FW_KEY_WHEEL_UP
Definition: Keys.hpp:41
EventType type
Definition: Window.hpp:69
FW_CUDA_FUNC F64 sin(F64 a)
Definition: Math.hpp:48
#define FW_KEY_UP
Definition: Keys.hpp:150
const Array< U8 > * get(const String &id) const
Definition: StateDump.cpp:77
#define FW_KEY_Q
Definition: Keys.hpp:209
void decodeSignature(const String &sig)
void print(void) const
Definition: Math.hpp:137
#define FW_KEY_MINUS
Definition: Keys.hpp:173
void fail(const char *fmt,...)
Definition: Defs.cpp:304
FW_CUDA_FUNC void setCol(int c, const VectorBase< T, L, V > &v)
Definition: Math.hpp:576
#define FW_KEY_E
Definition: Keys.hpp:197
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr size
Definition: DLLImports.inl:319
void removeControl(const void *target)
virtual bool handleEvent(const Window::Event &ev)
virtual ~CameraControls(void)