28 #ifndef __FREEWRL_VIEWER_H__
29 #define __FREEWRL_VIEWER_H__
31 #include "quaternion.h"
32 void fwl_set_viewer_type(
const int type);
33 int fwl_setNavMode(
char *mode);
41 #define RELEASE "RELEASE"
44 #define KEYS_HANDLED 12
47 #define VIEWER_STEREO_OFF 0
48 #define VIEWER_STEREO_SHUTTERGLASSES 1
49 #define VIEWER_STEREO_SIDEBYSIDE 2
50 #define VIEWER_STEREO_ANAGLYPH 3
51 #define VIEWER_STEREO_UPDOWN 4
58 #define STRING_SIZE 256
61 #define IN_FILE "C:/tmp/inpdev.txt"
63 #define IN_FILE "/tmp/inpdev"
65 #define IN_FILE_BYTES 100
71 #define QUAT_W_OFFSET 26
72 #define QUAT_X_OFFSET 35
73 #define QUAT_Y_OFFSET 44
74 #define QUAT_Z_OFFSET 53
77 #define VIEWER_TRANSITION_TELEPORT 0
78 #define VIEWER_TRANSITION_LINEAR 1
79 #define VIEWER_TRANSITION_ANIMATE 2
82 #define CALCULATE_EXAMINE_DISTANCE \
87 xd = (float) viewer->currentPosInModel.x; \
88 yd = (float) viewer->currentPosInModel.y; \
89 zd = (float) viewer->currentPosInModel.z; \
90 test = sqrt (xd*xd+yd*yd+zd*zd); \
92 viewer->Dist = test; \
95 #define INITIATE_SLERP \
96 if (viewer->transitionType != VIEWER_TRANSITION_TELEPORT) { \
97 viewer->SLERPing = TRUE; \
98 viewer->startSLERPtime = TickTime(); \
99 memcpy (&viewer->startSLERPPos, &viewer->Pos, sizeof (struct point_XYZ)); \
100 memcpy (&viewer->startSLERPAntiPos, &viewer->AntiPos, sizeof (struct point_XYZ)); \
101 memcpy (&viewer->startSLERPQuat, &viewer->Quat, sizeof (Quaternion)); \
102 memcpy (&viewer->startSLERPAntiQuat, &viewer->AntiQuat, sizeof (Quaternion)); \
103 memcpy (&viewer->startSLERPbindTimeQuat, &viewer->bindTimeQuat, sizeof (Quaternion)); \
104 memcpy (&viewer->startSLERPprepVPQuat, &viewer->prepVPQuat, sizeof (Quaternion)); \
105 } else { viewer->SLERPing = FALSE; }
108 #define INITIATE_POSITION \
109 xd = vp->position.c[0]-vp->centerOfRotation.c[0]; \
110 yd = vp->position.c[1]-vp->centerOfRotation.c[1]; \
111 zd = vp->position.c[2]-vp->centerOfRotation.c[2]; \
112 viewer->Dist = sqrt (xd*xd+yd*yd+zd*zd);
114 #define INITIATE_ROTATION_ORIGIN \
115 viewer->examine.Origin.x = vp->centerOfRotation.c[0]; \
116 viewer->examine.Origin.y = vp->centerOfRotation.c[1]; \
117 viewer->examine.Origin.z = vp->centerOfRotation.c[2];
119 #define INITIATE_POSITION_ANTIPOSITION \
120 viewer->Pos.x = vp->position.c[0]; \
121 viewer->Pos.y = vp->position.c[1]; \
122 viewer->Pos.z = vp->position.c[2]; \
123 viewer->AntiPos.x = vp->position.c[0]; \
124 viewer->AntiPos.y = vp->position.c[1]; \
125 viewer->AntiPos.z = vp->position.c[2]; \
126 viewer->currentPosInModel.x = vp->position.c[0]; \
127 viewer->currentPosInModel.y = vp->position.c[1]; \
128 viewer->currentPosInModel.z = vp->position.c[2]; \
129 vrmlrot_to_quaternion (&viewer->Quat,vp->orientation.c[0], \
130 vp->orientation.c[1],vp->orientation.c[2],-vp->orientation.c[3]); \
131 vrmlrot_to_quaternion (&viewer->bindTimeQuat,vp->orientation.c[0], \
132 vp->orientation.c[1],vp->orientation.c[2],-vp->orientation.c[3]); \
133 vrmlrot_to_quaternion (&q_i,vp->orientation.c[0], \
134 vp->orientation.c[1],vp->orientation.c[2],-vp->orientation.c[3]); \
135 quaternion_inverse(&(viewer->AntiQuat),&q_i); \
136 vrmlrot_to_quaternion(&viewer->prepVPQuat,vp->orientation.c[0],vp->orientation.c[1],vp->orientation.c[2],-vp->orientation.c[3]);
188 double Velocity[2][3];
221 int eitherDominantEye;
222 double stereoParameter;
240 int SLERPing2justStarted;
243 double startSLERPtime;
251 double transitionTime;
262 double startSLERPDist, endSLERPDist;
269 int doExamineModeDistanceCalculations;
273 double orthoField[4];
276 int screenOrientation;
281 double backgroundPlane ;
282 GLDOUBLE fieldofview;
291 void viewer_default(
void);
293 void Viewer_anaglyph_setSide(
int iside);
294 void Viewer_anaglyph_clearSides();
295 void fwl_init_StereoDefaults(
void);
297 void viewer_postGLinit_init(
void);
302 int fwl_get_headlight();
303 void fwl_toggle_headlight();
306 void set_eyehalf(
const double eyehalf,
const double eyehalfangle);
307 void resolve_pos(
void);
308 void getViewpointExamineDistance(
void);
314 void viewer_togl(
double fieldofview);
316 void handle(
const int mev,
const unsigned int button,
const float x,
const float y);
317 void handle_key(
const char key,
double keytime);
318 void handle_keyrelease (
const char key,
double keytime);
320 void set_stereo_offset0();
328 void increment_pos(
struct point_XYZ *vec);
333 void bind_Fog(
struct X3D_Fog *node);
335 extern float eyedist;
336 extern float screendist;
338 void getCurrentSpeed(
void);
339 void getCurrentPosInModel (
int addInAntiPos);
341 void toggle_collision(
void);
342 void viewer_lastP_clear(
void);
343 void avatar2BoundViewpointVerticalAvatar(GLDOUBLE *matA2BVVA, GLDOUBLE *matBVVA2A);
345 void toggleOrSetStereo(
int type);
346 void setAnaglyphSideColor(
char val,
int iside);
347 void updateEyehalf(
void);
348 void viewer_level_to_bound(
void);
350 int getAnaglyphPrimarySide(
int primary,
int iside);
351 void setAnaglyphPrimarySide(
int primary,
int iside);
352 int viewer_getKeyChord();
353 void viewer_setKeyChord(
int chord);