VisualObject * object = (VisualObject *) it.value ();
if ( object -> isTransparent () ) continue;
if ( viewFrustrum.contains ( object -> getBoundingBox () ) )
object -> draw ( view, camera, viewFrustrum, fog ) ;
}
// now render transparent polygons BspRenderlnfo info;
ObjectSortlnfo transpObjects [MAX_TRANSPARENT_OBJECTS]; int count = 0;
info.view = &view;
info.viewFrustrum = &viewFrustrum; info.camera = &camera;
info.tempPoly = &tempPoly;
info.post = &post;
// build list of transparent objects for ( it = obj ects. getlterator () ; lit. end (),- ++it ) {
VisualObject * object = (VisualObject *) it.value ();
if ( object -> isTransparent () && count < MAX_TRANSPARENT_OBJECTS )
{
Добавляем эффекты
transpObjects[count ].key= object->getPos() &
camera.getViewDir (); transpObjects[count++].object = object;
}
}
// now sort it
qsort ( transpObjects, count, sizeof ( ObjectSortlnfo ), objectCompFunc );
// render tree and all transparent objects renderTree ( root, info, transpObjects, count ); processLights ( camera, viewFrustrum, post );
view.unlock (); // commit drawing
if ( IsTest )
glDisable ( GL_STENCIL_TEST );
}
void StencilSubScene :: renderTree ( BspNode * node,
BspRenderlnfo& info, ObjectSortlnfo list [], int count ) const
{
if ( node == NULL ) {
for ( int i = 0; i < count; i++ ) list[i].object->draw(*info.view, *info.camera,
*info.viewFrustrum, fog );
return;
}
// build list of front and back objects ObjectSortlnfo front [MAX_TRANSPARENT__OBJECTS]; ObjectSortlnfo back [MAX_TRANSPARENT_OBJECTS]; int frontCount = 0;
int backCount = 0;
for ( int i = 0; i < count; i++ )
if ( node -> classify ( list [i].object -> getPos () ) == IN_FRONT )
front [frontCount++] = list [i];
else
back [backCount++] = list [i] ;
А. В. Боресков. Графика трехмерной компьютерной игры \
II now render the tree if ( node -> classify ( info.camera -> getPos () ) == IN„FRONT )