class StencilSubScene : public SubScene {
private:
Array opaqueFaces; // opaque and floating
// faces/mirrors/portals // are stored here
BspNode * root; // transparent faces/mirrors
// are stored in the bsp tree
public:
StencilSubScene ( const char * theName ) :
SubScene ( theName ), opaqueFaces ( "opaque Faces" )
{
root = NULL;
metaClass = kclasslnstance;
}
-StencilSubScene ()

Пишем портальный рендерер (часть III)

{
if ( root != NULL )
deleteBspTree ( root );
}
virtual bool isOk () const {
return opaqueFaces.isOk () && SubScene :: isOk ();
}
virtual int init () ;
virtual void render ( Views view, const Cameras
camera, const Frustrums frustrum ) const;
virtual bool shouldBeSorted ( const Polygon3D * poly )
const;
static int curStencilVal;
static MetaClass classlnstance;
protected:
struct BspRenderlnfo {
View * view;
const Camera * camera; const Frustrum * viewFrustrum; Polygon3D * tempPoly;
Array * post;
} ;
struct ObjectSortlnfo
{
VisualObject * object; Float key;
};
friend static int _cdecl objectCompFunc ( const void *
eleml, const void * elem2 );
void drawPolygon ( const Polygon3D& ) const;
void renderTree ( BspNode * node, BspRenderlnfo& info,
ObjectSortlnfo list [], int count )
const;
II draw poly to stencil only, using inc op on // depth and stencil pass // draws only to stencil buffer void incStencil ( const Polygon3D& ) const;
// restore stencil by using dec op on stencil // pass. Draws only to stencil buffer void decStencil ( const Polygon3D& ) const;
// set depth values to that of given polygon // on stencil pass
// modifies only depth and stencil buffers void setDepth ( const Polygon3D& ) const;
// clear depth values to max depth in visible // points of poly. Draws only on depth buffer, // does not touch frame buffer, // sets stencil to visible points of poly void clearDepth ( const Cameras, const Polygon3D& )

⇐ Предыдущая| |Следующая ⇒