pfViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
NAME
pfViewer, viewAll - Abstract base class for all pfViewers
FUNCTION SPECIFICATION
#include <Performer/pfx/pfViewer.h>
pfViewer::pfViewer(pfPipe* p=NULL, int numChannels=1,
int stereoMode=PFVIEWER_MONO, int *attrs = NULL);
static pfType * pfViewer::getClassType(void);
pfLightSource* pfViewer::getHeadLight() const;
void pfViewer::setHeadLight(pfLightSource *headlight);
pfEarthSky * pfViewer::getESky() const;
void pfViewer::setESky(pfEarthSky *eSky);
void pfViewer::loadModel(char *filename, int optimize = 1);
void pfViewer::setSceneGraph(pfNode *newRoot,
int optimize = 0);
pfNode * pfViewer::getSceneGraph() const;
pfChannel * pfViewer::getChannel(int i = 0);
int pfViewer::getNumChannels() const;
pfPipeWindow* pfViewer::getPipeWindow() const;
void pfViewer::resetToHomePosition();
void pfViewer::saveHomePosition();
pfScene* pfViewer::getScene(int whichChannel = 0) const;
int pfViewer::getWidth() const;
int pfViewer::getHeight() const;
void pfViewer::setWidth(int width);
void pfViewer::setHeight(int height);
void pfViewer::setWinSizes(int width, int height);
void pfViewer::setOriginSize(int origX, int origY,
orig width, int height);
Page 1
pfViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
void pfViewer::getXOrigin() const;
void pfViewer::getYOrigin() const;
Window pfViewer::getXWin();
Window pfViewer::getGXWin();
void pfViewer::setDisplay(Display *);
Display* pfViewer::getDisplay() const;
pfCoord& pfViewer::getView();
void pfViewer::setInterOcularDistance(float distance);
void pfViewer::setConvergenceRatio(float ratio);
void pfViewer::setView(pfCoord& view);
pfDrawAction * pfViewer::getDrawAction(int i = 0);
void pfViewer::setDrawAction(int i,
pfDrawAction *drawAction);
int pfViewer::getStereoMode();
void viewAll();
virtual void pfViewer::show();
void pfViewer::setLoadNewModelFlag(int flag);
void pfViewer::setLoadFilename(const char *filename);
void pfViewer::setXWin(Window win);
void pfViewer::setGXWin(Window win);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfViewer is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfViewer. This is also true for
ancestor classes of class pfObject.
void* pfObject::operator new(size_t);
void* pfObject::operator new(size_t, pfFluxMemory *fmem);
void pfObject::setUserData(void *data);
void pfObject::setUserData(int slot, void *data);
void* pfObject::getUserData(pfObject *obj);
Page 2
pfViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
void* pfObject::getUserData(pfObject *obj, int slot);
int pfObject::getNumUserData();
Since the class pfObject is itself derived from the parent class
pfMemory, objects of class pfViewer can also be used with these functions
designed for objects of class pfMemory.
void* pfMemory::getData(const void *ptr);
pfType * pfMemory::getType();
int pfMemory::isOfType(pfType *type);
int pfMemory::isExactType(pfType *type);
const char * pfMemory::getTypeName();
int pfMemory::copy(pfMemory *src);
int pfMemory::compare(const pfMemory *mem);
void pfMemory::print(uint which, uint verbose, char *prefix,
FILE *file);
int pfMemory::getArena(void *ptr);
void* pfMemory::getArena();
int pfMemory::ref();
int pfMemory::unref();
int pfMemory::unrefDelete();
int pfMemory::unrefGetRef();
int pfMemory::getRef();
int pfMemory::checkDelete();
int pfMemory::isFluxed();
void * pfMemory::getArena();
int pfMemory::getSize();
DESCRIPTION
A pfViewer is an abstract base class which derives from pfObject. It is
the base class used to derive all other pfViewer classes including
pfGUIViewer, pfSimpleViewer, pfMotifViewer, pfGTKViewer, etc ... It works
hand in hand with the pfViewerManager and in fact, cannot exist without
it. When creating a pfViewer with new, in addition to creating a new
viewer, you are also registering it with the pfViewerManager.
Creation and use of the viewer's derived from this class is similar to
that of dealing with a pfPipeWindow however there are some notable
differences. For starters, you should not specify channel draw callbacks
for the channels associated with the pfPipeWindow that is encapsulated by
your pfViewer. Instead, you should set the user data on the pfViewer and
create your own pfDrawAction. By default, a pfSimpleDrawAction is created
for all pfViewers. This
can be changed via the pfViewer::setDrawAction() method.
The default constructor (pfViewer::pfViewer(pfPipe *p=NULL,int
numChannels=1,int stereoMode=PFVIEWER_MONO)) for the pfViewer class is
protected and accepts three arguments, p which is a pointer to a pfPipe
to be used for creating the pipe window encapsulated by this class,
numChannels which specifies how many channels should be created on this
pipe window and finally, stereoMode which can one of PFVIEWER_MONO,
Page 3
pfViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
PFVIEWER_QUAD_BUFFERED_STEREO or PFVIEWER_ TOP_BOTTOM_STEREO. By default,
one channel is created on the first pipe and of type PFVIEWER_MONO. In
addition to setting up the pfPipeWindow and channels, the process of
creating a pfViewer also sets the near and far planes for the channels,
the scene to be used, the earth sky model and takes over the draw
callback functions.
At the root of the scene graph by default is simply a pfLightSource
located at (-1.0f, -1.0f, 2.0f), with a white diffuse component. The near
and far planes are set to 0.1f and 10000.0f respectively and last but not
least, the vertical FOV is set to 45.0f degrees with the horizontal FOV
set to match the window aspect ratio. The initial viewpoint is (0.0f,
-1.0f, 1.0f.)
The method pfViewer::getHeadLight() returns a pointer to a pfLightSource
that is used to illuminate the scene. It is basically the first child of
the pfScene associaed with the channel(s.) The associated set method (-
pfViewer::setHeadLight()) simply replaces this child. In order to get rid
of the light in the scene, simply call this method with a NULL argument.
The method pfViewer::getESky() returns a pointer to the Earth/Sky model
associated with the channels(s.) in the scene. It may be set with the
pfViewer::setESky() method.
The method pfViewer::loadModel(char *filename,int optimize = 1) accepts
two arguments. The first is the name of the filename to load and use as
replacement for the scene graph, and the second is a flag indicating
whether or not to optimize the model using the pfd utilities. An
alternate method for setting the scene graph is via
pfViewer::setSceneGraph(pfNode *newRoot,int optimize = 0) which accepts
two arguments, the first, newRoot indicates the pointer to the new pfNode
to be
used as the root of the scene graph, and the second argument, optimize,
indicating whether or not the scene graph should be optimized before
being set as root of the pfScene. Note that the light that exists as the
first child will not get replaced during this operation. See
pfViewer::setHeadLight() above for more information about how to
manipulate the light source in the scene.
The method pfViewer::getSceneGraph() returns the root of the scene graph
as a pfNode pointer.
The method pfViewer::getNumChannels() returns the number of channels
managed by this pfViewer. Note that the number returned by this routine
may be different that the number of channels that are managed by the
underlying pfPipeWindow; this can happen if you add a gui interface via
the pfui routines or if you call pfPipeWindow::addChan() directly. You
may also use pfViewer::getChannel(int i=0) to retrieve the individual
channels.
The method pfViewer::getPipeWindow() returns a pointer to the
pfPipeWindow that was created and/or used for the construction of the
Page 4
pfViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
given pfViewer. Note that you should not specify a callback function for
the pipe window for the opening of the pipe window (via
pfPipeWindow::setConfigFunc()) as this is used internally.
The method pfViewer::resetToHomePosition() resets the view to the
viewpoint that was last set via the method pfViewer::saveHomePosition.
The method pfViewer::getScene(int n = 0) returns the pointer to the
pfScene associated with the n'th channel managed by the pfPipeWindow.
The methods pfViewer::getWidth() and pfViewer::getHeight() return the
width and height of the rendering areas used by the given pfViewer. The
associated methods pfViewer::setWidth(int) and pfViewer::setHeight(int)
set the width and height of the window. Alternatively, you may set the
width and height simultaneously via pfViewer::setWinSizes(int width,int
height). Last but not least, you may also set the origin of the window
and the dimensions simultaneously v ia pfViewer::setOriginSize(). The
origin of the viewer may be retrieved via pfViewer::getXOrigin() and
pfViewer::getYOrigin().
The method pfViewer::getXWin() returns the Window id of the window used
by the pipe window as WS Window. The associated method
pfViewer::getGXWin() returns the Window id of the window used by the pipe
window as the WS Drawable. Note that in order to derive classes from
pfGUIViewer one must specify these values via pfViewer::setXWin() and
pfViewer::setGXWin(). More information about how to do this is given in
the man page for pfGUIViewer(3).
The method pfViewer::getView() returns the viewpoint currently associated
with the channel(s) managed by the pipe window. The associated method
pfViewer::setView(pfCoord& view) can be used to set the view point.
The method pfViewer::getDrawAction(int i = 0) returns a pointer to the
pfDrawAction used to render the scene. There are as many draw actions as
there are channels unless the viewer is in stereo mode in which case
there are only half as many. By default, a pfSimpleDrawAction is assigned
to all channels. The parameter i can be used to retrieve the i'th draw
action. Conversely, the draw action may be set via
pfViewer::setDrawAction(int i,pfDrawAction *drawAction).
The method pfViewer::getStereoMode() returns the value of the third
parameter passed to the constructor of this class, listed above.
The method pfViewer::viewAll() computes the bounding box for the geometry
in the scene and adjusts the viewpoint for all channels so that all of
the geometry in the scene is visible.
The method pfViewer::show() gets invoked by the pfViewerManager and
should not be invoked directly. More detail about this method can be
found in the man page for pfGUIViewer.
The method pfViewer::setDisplay(Display*) must be called by all classes
Page 5
pfViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
which derive from pfViewer. This value is used by the pfPipeWindow in
conjunction with the window ID and drawable ID in order to determine
where the rendering shall take place.
The method pfViewer::getDisplay() returns the value set via
pfViewer::setDisplay(). By default, this is NULL.
The methods pfViewer::setInterOcularDistance() and
pfViewer::setConvergenceRatio() are used to set the channel offsets for
stereo viewing. By default the convergence is set to 0.2 and the
interocular distance is set to 2.0. Note that unless a stereo visual is
requested, setting these values will have no effect.
NOTES
Much of the sharing attributes that channels posses is not being used in
the beta however this functionality will be used in future releases and
the API for setting/getting some of the values will no doubt change as
well.
The libpfx source code, object code and documentation are provided as
unsupported software. Routines are subject to change in future releases.
The most recent version of this software may be found at the following
URL: http://oss.sgi.com/projects/performer/.
BUGS
Visual attributes should be set on a per pipe viewer basis. For now, the
last viewer which creates and specifies a visual will take priority.
SEE ALSO
pfMotifViewer, pfViewkitViewer, pfGTKViewer, pfGUIViewer, pfDrawAction,
pfSimpleDrawAction, pfViewerManager
Page 6