{ 2, -0.18f, 0.25f } // next birst
} ;
void World :: drawPostObjects ( Views view, const Cameras
camera, const Arrays post ) const
{
float haloSize = 20; float flareSize = 30;
// save current state glPushAttrib ( GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT |
GL_STENCIL_BUFFER_BIT ); glEnable ( GL_BLEND );
glDisable ( GL_DEPTH_TEST ); glDepthMask ( GL_FALSE ) ;
// setup drawing mode view.startOrtho ();
view.blendFunc ( View :: bmSrcAlpha, View :: bmOne );
for ( Array :: Iterator it = post.getlterator (); !it.end (); ++it )
{
Light * light = dynamic_cast <Light *> ( it.value () );
if ( light == NULL ) continue;
// it's a light source, now
// get screen coordinates of it

Добавляем эффекты

Vector3D loc ( camera.mapToScreen
( light -> getPos () ) ) ,-float dist=camera.getPos ().distanceTo ( light -> getPos () );
// draw the halo if ( light -> testFlag ( LF_HAS_HALO ) ) {
Vector4D color ( light -> getColor () / ( 1 + 0.3f * dist ) );
color.w = 0.4f; // make it not too bright
draw2dRect ( view, loc, Vector2D
( haloSize, haloSize ) , color, haloTexture ) ,-
}
if ( light -> testFlag ( LF_HAS_LENS_FLARE ) ) {
Vector3D c (view.getWidtht) * 0.5f,
view.getHeight() * 0.5f, 1); Vector3D v (c - loc);
for ( int i = 0; i < sizeof ( flareTable ) / sizeof ( flareTable [0] ); i++ )
{
Vector3D p (c + flareTable [i].lengthScale * v );
Vector4D color (light -> getColor () ) ;
float size (flareSize *
flareTable [i] . imageScale ) ,-
color.w = 0.6f;
// make it not too bright
draw2dRect ( view, p, Vector2D ( size, size ), color, lensFlareTexture [flareTable [i].index] );
}
}
}
view. endOrtho () ,-glPopAttrib ();

ДОБАВЛЯЕМ МОДЕЛИ

Модели Помимо статической геометрии, т. е. набора многоугольников, задающих стены, пол, лестницы и т. п., часто возникает необходимость работы с целыми группами граней, объединенных в один объект. Таким объектом может быть ваза с цветами на столе (как, впрочем, и сам стол), оружие, противники и т. п. Во всех этих случаях возникает необходимость в объектах, представленных набором большого числа небольших граней (обычно треугольников).


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