Class GLVU
GLVU Utility Functions
GLVU()
class constructor; called by default
[glvu.cpp]
~GLVU()
class destructor; called by default
[glvu.cpp]
int Init(char *WindowTitle,
unsigned int VisualMode,
int WindowStartX, int WindowStartY,
int WindowWidth, int WindowHeight)
Initializes an instance of a GLVU
viewer. Initializes GLUT window and registers per-window default callbacks.
Init()must
be called before any OpenGL calls can be made. [glvu.cpp]
parameters:
char* WindowTitle:
a string for the title bar
unsigned int VisualMode:
int WindowStartX:
int WindowStartY:
int WindowWidth:
int WindowHeight:
return value:
The window ID returned by GLUT.
void BeginFrame()
Resets the projection and view matrices
for a GLVU window and its current Camera. It should be the first call in
a user-provided drawing routine (i.e. display function). [glvu_camview.cpp]
void EndFrame()
Draws the Camera frustra for the
GLVU viewer if that option is turned on, and more importantly, calls glutSwapBuffers().
Thus, this should be the last call in a user-provided drawing routine (i.e.
display function). [glvu_camview.cpp]
void SetAllCams(Vec3f
WorldMin, Vec3f WorldMax,
Vec3f Eye, Vec3f LookAtCntr, Vec3f viewup,
float Yfov, float Aspect, float NearFactor,
float FarFactor)
Initializes all Cameras in a GLVU
viewer. [glvu_camview.cpp]
parameters:
Vec3f WorldMin:
minimum values of an axis-aligned bounding box of the world
Vec3f WorldMax:
maximum values of an axis-aligned bounding box of the world
Vec3f Eye:
starting location of the camera origin (i.e. eyepoint, viewpoint); cannot
equal LookAtCntr
Vec3f LookAtCntr:
starting world point to look towards (usually model center); cannot equal
Eye
Vec3f viewup:
starting world up-vector (usually [0,1,0])
float Yfov:
vertical field-of-view in degrees
float Aspect:
pixel width/height
float NearFactor:
factor multiplied by the radius of the world’s bounding sphere to determine
the distance from the eye to the near plane
float FarFactor:
factor multiplied by the radius of the world’s bounding sphere to determine
the distance from the eye to the far plane
void AllCamsPerspectiveChange(float
Yfov, float Aspect,
float Ndist, float Fdist)
Changes the perspective for all Cameras
in a GLVU viewer. [glvu_camview.cpp]
parameters:
float Yfov:
vertical field-of-view in degrees
float Aspect:
pixel width/height
float Ndist:
distance from the eye to the near plane
float Fdist:
distance from the eye to the far plane
void
AllCamsPerspectiveAspectChange(float
Aspect)
Changes the perspective aspect ratio
for all Cameras in a GLVU viewer; generally used to change the aspect ratio
for a changed window size. [glvu_camview.cpp]
parameter:
float Aspect:
pixel width/height
void AllCamsResetToOrig()
Resets all parameters for all Cameras
in a GLVU viewer. [glvu_camview.cpp]
float* GetModelviewMatrix(float*
M)
Returns the viewing matrix for the
current Camera in the current GLVU viewer; also handles recording and playback
functions. [glvu_camview.cpp]
parameter:
float* M:
pointer which is set to an array of floats which contains the 4x4 viewing
matrix
return value:
A pointer to an array of floats which
contains the 4x4 viewing matrix.
float* GetProjectionMatrix(float*
M)
Returns the viewing matrix for the
current Camera in the current GLVU viewer; also handles recording and playback
functions. [glvu_camview.cpp]
parameter:
float* M:
pointer which is set to an array of floats which contains the 4x4 viewing
matrix
return value:
A pointer to an array of floats which
contains the 4x4 viewing matrix.
void GetPixelRay(int
sx, int sy, int ww, int wh,
Vec3f *Start, Vec3f *Dir)
Returns a ray from the origin of
the current Camera’s coordinate system to the center of the selected pixel.
[glvu_camview.cpp]
parameters:
int sx:
x-coordinate of pixel in screen coordinates ((0,0) at lower-left)
int sy:
y-coordinate of pixel in screen coordinates ((0,0) at lower-left)
int ww:
window width in pixels
int wh:
window height in pixels
Vec3f *Start:
origin of ray (i.e. origin of current Camera’s coordinate system in world
coordinates)
Vec3f *Dir:
direction of ray
void SelectCam(int
WhichCam)
Selects one of a GLVU viewer’s Camera
to be the current Camera. [glvu.hpp – inline]
parameters:
int WhichCam:
index of Camera to supply current view.
Camera* GetCurrentCam()
Returns a pointer to the current
Camera. [glvu.hpp – inline]
return value:
A pointer to the current Camera object.
void SetCurrentCam(Camera
*NewCam)
Sets the current Camera to be a Camera
allocated outside the viewer. [glvu.hpp – inline]
parameters:
Camera *NewCam:
a pointer to a pre-allocated Camera object
Camera* GetCam(int
WhichCam)
Returns a pointer to a specified
Camera. [glvu.hpp – inline]
parameter:
int WhichCam:
index of Camera to return
return value:
A pointer to the specified Camera
object.
int GetInOutMode()
Returns the in/out-looking mode:
whether the user is on the inside looking out or on the inside looking
in. [glvu.hpp – inline]
return value:
0 (false) if in "outside-looking-in"
mode, 1 (true) if in "inside-looking-out" mode.
void SetInOutMode(int
Bool)
Sets the in/out-looking mode. [glvu.hpp
– inline]
parameter:
int Bool:
mode value: 0 (false) for "outside-looking-in" mode, 1 (true) for "inside-looking-out"
mode
void ToggleInOutMode()
Toggles the in/out-looking mode.
[glvu.hpp – inline]
void SetOrigCam(Camera
*Cam)
Sets the GLVU viewer’s "original"
Camera to a new Camera. [glvu.hpp – inline]
parameter:
Camera *Cam:
a pointer to a pre-allocated Camera object.
Vec3f GetViewUp()
Returns the up-vector for the GLVU
viewer. [glvu.hpp – inline]
return value:
A vector object set to the value
of the up-vector.
void SetViewUp(Vec3f
viewup)
Sets the up-vector for the GLVU viewer.
[glvu.hpp – inline]
parameter:
A vector object with the value of
the new up-vector.
void TranslateX(int
OldX, int NewX, int WW)
Function that interprets horizontal
mouse movement as horizontal translation of objects in screen space. [glvu_camview.cpp]
void TranslateY(int
OldY, int NewY, int WH)
Function that interprets vertical
mouse movement as vertical translation of objects in screen space. [glvu_camview.cpp]
void DriveY(int OldY,
int NewY, int WH)
Function that interprets vertical
mouse movement as driving into or out of the screen. [glvu_camview.cpp]
void LookX(int OldX,
int NewX, int WW)
Function that interprets horizontal
mouse movement to change the horizontal viewing direction. [glvu_camview.cpp]
void LookY(int OldY,
int NewY, int WH)
Function that interprets vertical
mouse movement to change the vertical viewing direction. [glvu_camview.cpp]
void TrackBallX(int
OldX, int NewX, int WW)
Function that interprets horizontal
mouse movement to move the world around a trackball. [glvu_camview.cpp]
void TrackBallY(int
OldY, int NewY, int WH)
Function that intreprets vertical
mouse movements to move the world around a trackball. [glvu_camview.cpp]
void StartRecording(char
*FileName)
Starts recording the path traveled
in world and writes the path data to a file. [glvu_camview.cpp]
parameter:
char *Filename:
name of path file.
void EndRecording();
Ends any currently ongoing recording
of path data. [glvu_camview.cpp]
void StartPlayback(char
*FileName)
Starts playback of a previously recorded
path file. [glvu_camview.cpp]
parameter:
char *Filename:
name of path file.
void EndPlayback();
Ends any currently ongoing playback
of path data. [glvu_camview.cpp]
void StopRecordingPlayback()
Ends any currently ongoing path recording
or path playback. [glvu_camview.cpp]
int GetMainMenuID()
Returns integer ID of the GLVU window’s
main menu.
return value:
The menu ID returned by GLUT. [glvu.hpp
–- inline]
int GetWorldNavMode()
Returns current world navigation
mode. [glvu.hpp – inline]
return value:
An integer constant describing the
navigation mode:
-
NAV_MODE_TRACKBALL (0) for ‘trackball’
mode
-
NAV_MODE_DRIVE (1) for ‘drive’ mode
-
NAV_MODE_TRANSLATE (2) for ‘translate’
mode
-
NAV_MODE_LOOK (3) for ‘look’ mode.
void SetWorldNavMode(int
mode)
Sets current world navigation mode.
[glvu.hpp – inline]
parameter:
int mode:
constant denoting desired navigation mode, as described in GetWorldNavMode.
int GetCamDisplayOn(int
WhichCam)
Returns whether
return value:
A boolean value
int IsWorldNavMode()
Returns whether
return value:
A boolean value
int GetLeftButtonDown()
Returns the up/down position
of the left mouse button.
return value:
0 (false) if the left mouse
button is up; 1 (true) if the button is down.
int GetInertiaOn()
Returns the
return value:
0 (false) if ; 1 (true)
int GetInertiaEnabled()
Returns the
return value:
0 (false) if ; 1 (true)
void SetInertiaOn(int
Bool)
Sets the
parameter:
int Bool:
description
void SetInertiaEnabled(int
Bool)
Sets the
parameter:
int Bool:
description here
int GetInertiaDelay()
Gets the in milliseconds.
return value:
delay of inertial in milliseconds.
void SetInertiaDelay(int
msec)
Sets the value of the
parameter:
int msec:
delay in milliseconds
void SetInertiaFunc(void
(*f)(int x, int y))
Sets the function
parameter:
void (*f)(int x, int y):
a pointer to a function with two integer parameters
void (*GetInertiaFunc())
Returns a pointer to the
inertial function
return value:
a pointer
static void
DefaultMouseFunc(int
button, int state,
int x, int y)
Default ... function ...
Used only
parameters:
int button:
int state:
int x:
int y:
static void
DefaultMotionFunc(int
x, int y)
Default function Used only
parameters:
int x:
int y:
static void
DefaultReshapeFunc(int
WW, int WH)
Default function .....
Used only
parameters:
int WW:
int WH:
static void
DefaultDisplayFunc()
Default
static void
DefaultKeyboardFunc(unsigned
char Key, int x, int y)
Default GLUT keyboard function
User calls only when
parameters:
unsigned char Key:
int x:
int y:
static void
DefaultInertiaFunc(int
x, int y)
Default inertial function.
User calls only when
parameters:
int x:
int y:
virtual void Mouse(int
button, int state,
int x, int y)
Default function. Called
only by ; can be overloaded by user classes derived from GLVU
parameters:
int button:
int state:
int x:
int y:
virtual void Motion(int
x, int y)
Default function. Called
only by ; can be overloaded by user classes derived from GLVU
parameters:
int x:
int y:
virtual void Reshape(int
WW, int WH)
Default function. Called
only by ; can be overloaded by user classes derived from GLVU
parameters:
int WW:
int WH:
virtual void Display()
Default function. Called
only by ; can be overloaded by user classes derived from GLVU
virtual void Keyboard(unsigned
char Key, int x, int y)
Default function. Called
only by ; can be overloaded by user classes derived from GLVU
parameters:
unsigned char Key:
int x:
int y:
virtual void Inertia(int
x, int y)
Default function. Called
only by ; can be overloaded by user classes derived from GLVU
parameters:
int x:
int y:
int GetWindowID()
Returns windows ID number
as assigned by GLUT
return value:
An integer
static GLVU* GetGLVU(int
WindowID)
static GLVU* GetGLVU()
Returns a pointer to an
object of class GLVU which has the window with the specified ID number
or the current window
parameters:
int
WindowID:
return value:
A static pointer to
void SnapShot()
Takes a "snapshot" of the
screen; i.e. writes the contents of the framebuffer -- to a .ppm file.
The default filenames are snap1.ppm, snap2.ppm, etc.
void* GetCurrentFont()
Returns
void SetCurrentFont(void
*font)
void SetCurrentFont(int
fontid)
Sets the current font
parameters:
void
*font:
int
fontid:
int GetFontHeight(void
*font)
int GetFontHeight(int
fontid)
int GetFontHeight()
Returns the height (in
pixels) of the selected font. If no font parameter is included (third
form), the height of last selected font is returned.
parameters:
void
*font:
int
fontid:
return value:
The height in pixels of
the selected font.
void Text(int
x, int y, char *format, ...)
Renders a formatted text
string in the current font at a position in the current GLVU window.
parameters:
int x:
The x-coordinate of the text string's left-most position
int y:
The y-coordinate of the text string's bottom position
char *format:
A format string in the same stlye as a printf format string.