PLIB 1.8.5+ r2173 from http://plib.svn.sourceforge.net/svnroot/plib/trunk
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<TITLE>A Simple Scene Graph API for OpenGL.</TITLE>
|
||||
</HEAD>
|
||||
<BODY text="#B5A642" link="#8FFF8F" vlink="#18A515" alink="#20336B"
|
||||
bgcolor="#005000" background="../marble.png">
|
||||
|
||||
<H2>ssgContext</H2>
|
||||
A 'context' is a set of parameters that relate to rendering
|
||||
one SSG image. It contains the camera parameters and some
|
||||
default state information.
|
||||
<pre>
|
||||
|
||||
class ssgContext
|
||||
{
|
||||
ssgContext () ;
|
||||
void forceBasicState () { basicState -> force () ; }
|
||||
|
||||
void makeCurrent () ;
|
||||
int isCurrent () ;
|
||||
|
||||
void overrideTexture ( int on_off ) ;
|
||||
void overrideCullface ( int on_off ) ;
|
||||
int textureOverridden () { return ovTexture ; }
|
||||
int cullfaceOverridden () { return ovCullface ; }
|
||||
void setCullface ( int on_off ) { cullFace = on_off ; }
|
||||
int cullfaceIsEnabled () { return cullFace ; }
|
||||
|
||||
sgFrustum *getFrustum () { return frustum ; }
|
||||
|
||||
void getNearFar ( float *n, float *f ) ;
|
||||
void getFOV ( float *w, float *h ) ;
|
||||
void getOrtho ( float *w, float *h ) ;
|
||||
void setNearFar ( float n, float f ) ;
|
||||
void setOrtho ( float w, float h ) ;
|
||||
void setFOV ( float w, float h ) ;
|
||||
|
||||
int isOrtho () { return orthographic ; }
|
||||
|
||||
void getCameraPosition ( sgVec3 pos ) ;
|
||||
void setCamera ( sgMat4 mat ) ;
|
||||
void setCamera ( sgCoord *coord ) ;
|
||||
|
||||
void loadProjectionMatrix () ;
|
||||
void loadModelviewMatrix () ;
|
||||
|
||||
void getProjectionMatrix ( sgMat4 dst ) ;
|
||||
void getModelviewMatrix ( sgMat4 dst ) ;
|
||||
|
||||
void clrClipPlane ( int i ) ;
|
||||
void setClipPlane ( int i, sgVec4 plane ) ;
|
||||
int isSetClipPlane ( int i ) ;
|
||||
float *getClipPlane ( int i ) ;
|
||||
} ;
|
||||
|
||||
</pre>
|
||||
In all 3D rendering, you need the concept of a virtual camera - or
|
||||
eyepoint. This is set up in SSG with the following calls:
|
||||
<pre>
|
||||
|
||||
void ssgContext::setFOV ( float w, float h ) ;
|
||||
void ssgContext::setNearFar( float n, float f ) ;
|
||||
void ssgContext::setCamera ( sgCoord *coord ) ;
|
||||
|
||||
</pre>
|
||||
The setFOV call sets up the vertical and horizontal fields
|
||||
of view (in degrees), setNearFar sets the near and far
|
||||
clip planes (in whatever units your model is built in).
|
||||
Finally, you can position the virtual camera relative to
|
||||
the database origin using setCamera.
|
||||
<p>
|
||||
Very often, an SSG program contains other non-SSG routines that
|
||||
are accessing OpenGL state. Even a menu drawn using PUI or an
|
||||
overlay in raw OpenGL or using FNT will change the current
|
||||
state of OpenGL. Since SSG does 'lazy' state changes (only
|
||||
updating those states that need to be changed) - it will be
|
||||
fooled into no setting some things that some ssgLeaf nodes
|
||||
really need.
|
||||
<p>
|
||||
This isn't a problem so long as the application doesn't change states
|
||||
DURING ssgCullAndDraw (by using derived class member functions, callbacks,
|
||||
etc). If you need to do that then be sure to call forceBasicState()
|
||||
before you return to SSG.
|
||||
<pre>
|
||||
|
||||
void ssgContext::forceBasicState ( void ) ;
|
||||
|
||||
</pre>
|
||||
<p>
|
||||
During testing, you sometimes need to disable texture rendering,
|
||||
or backface culling:
|
||||
<pre>
|
||||
|
||||
void ssgContext::overrideTexture ( int on_off ) ;
|
||||
void ssgContext::overrideCullface ( int on_off ) ;
|
||||
|
||||
</pre>
|
||||
The six standard OpenGL user-defined clipping planes
|
||||
can be setup and managed automatically using these
|
||||
calls:
|
||||
<pre>
|
||||
|
||||
void clrClipPlane ( int i ) ;
|
||||
void setClipPlane ( int i, sgVec4 plane ) ;
|
||||
int isSetClipPlane ( int i ) ;
|
||||
float *getClipPlane ( int i ) ;
|
||||
|
||||
</pre>
|
||||
setClipPlane takes the number of the plane (0 through 5) and
|
||||
a plane equation which will be applied at the next cull/draw
|
||||
cycle. clrClipPlane removes a clip plane. isSetClipPlane inquires
|
||||
about whether the i'th plane is turned on and getClipPlane returns
|
||||
the plane that's currently set as the i'th plane.
|
||||
<p>
|
||||
Once you have your context set up as you'd like, you have to
|
||||
make it become the 'current' context.
|
||||
<pre>
|
||||
|
||||
void ssgContext::makeCurrent () ;
|
||||
|
||||
</pre>
|
||||
There is a non-class function:
|
||||
<pre>
|
||||
|
||||
ssgContext *ssgGetCurrentContext() ;
|
||||
|
||||
</pre>
|
||||
...which returns the current context.
|
||||
<p>
|
||||
The 'ssgContext' class was not present in PLIB 1.0.xx, so (for
|
||||
backwards compatibility) there is an initial context assigned
|
||||
inside ssgInit(). In addition to the member functions of ssgContext,
|
||||
there are a number of equivelent global functions that are
|
||||
equivelent to ssgGetCurrentContext()->member_function(). These
|
||||
functions are deprecated for new code:
|
||||
<pre>
|
||||
|
||||
inline void ssgForceBasicState () ;
|
||||
inline void ssgGetCameraPosition ( sgVec3 pos ) ;
|
||||
inline void ssgOverrideTexture ( int on_off ) ;
|
||||
inline void ssgOverrideCullface ( int on_off ) ;
|
||||
inline void ssgGetNearFar ( float *n, float *f ) ;
|
||||
inline void ssgGetFOV ( float *w, float *h ) ;
|
||||
inline void ssgSetFOV ( float w, float h ) ;
|
||||
inline void ssgSetOrtho ( float w, float h ) ;
|
||||
inline void ssgSetNearFar ( float n, float f ) ;
|
||||
inline void ssgSetCamera ( sgMat4 mat ) ;
|
||||
inline void ssgSetCamera ( sgCoord *coord ) ;
|
||||
inline void ssgLoadProjectionMatrix () ;
|
||||
inline void ssgLoadProjectionMatrix ( sgFrustum *f ) ;
|
||||
inline void ssgGetProjectionMatrix ( sgMat4 dst ) ;
|
||||
inline void ssgGetModelviewMatrix ( sgMat4 dst ) ;
|
||||
inline void ssgLoadModelviewMatrix () ;
|
||||
inline void ssgLoadModelviewMatrix ( sgMat4 mat ) ;
|
||||
|
||||
</pre>
|
||||
|
||||
|
||||
<hr>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td width="33%" align="left"><a href="state.html"><= previous =</a></td>
|
||||
<td width="34%" align="center"><a href="index.html">Return to SSG Index</a></td>
|
||||
<td width="33%" align="right"><a href="non_class.html">= next =></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="http://validator.w3.org/check/referer"><img border="0" src="../valid-html40.png" alt="Valid HTML 4.0!" height="31" width="88"></a>
|
||||
<td>
|
||||
<ADDRESS>
|
||||
<A HREF="http://www.sjbaker.org">
|
||||
Steve J. Baker.</A>
|
||||
<<A HREF="mailto:sjbaker1@airmail.net">sjbaker1@airmail.net</A>>
|
||||
</ADDRESS>
|
||||
</table>
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
Reference in New Issue
Block a user