void ComponentDrawFlare::draw (CameraObject* camera) { PlaceableObject *placeable = checkedCast<PlaceableObject*>(getOwner()); if (!placeable) return; for (DTuint i = 0; i < NUM_FLARES; ++i) { if (_mat[i].isNull()) continue; Color c = _mat[i]->getColor(); c.setAFloat(_alpha); _mat[i]->setColor(c); } Vector3 projected_point = camera->projectPoint (placeable->getTranslation()); if (projected_point.z > 1.0F) return; Vector3 flare_vec = (Vector3(0.0F, 0.0F, 0.0F) - projected_point) * 2.0F; DTfloat aspect = System::getRenderer()->getViewportAspect(); DrawBatcherQuads b; for (DTuint i = 0; i < NUM_FLARES; ++i) { if (_mat[i].isNull()) continue; DTfloat size = _size[i]; Matrix4 transform = Matrix4::identity(); transform.setTranslation(projected_point + flare_vec * _pos[i]); // TODO: Why is this backwards? b.batchBegin (_mat[i].get(), Matrix4::identity(), DrawBatcherQuads::FMT_V | DrawBatcherQuads::FMT_T1 | DrawBatcherQuads::FMT_C); b.vertex ( transform * Vector3(-size,-size*aspect,0.0F), Texcoord2(0.0F,0.0F), Color(_alpha,_alpha,_alpha,_alpha) ); b.vertex ( transform * Vector3(size,-size*aspect,0.0F), Texcoord2(1.0F,0.0F), Color(_alpha,_alpha,_alpha,_alpha) ); b.vertex ( transform * Vector3(size,size*aspect,0.0F), Texcoord2(1.0F,1.0F), Color(_alpha,_alpha,_alpha,_alpha) ); b.vertex ( transform * Vector3(-size,size*aspect,0.0F), Texcoord2(0.0F,1.0F), Color(_alpha,_alpha,_alpha,_alpha) ); b.batchEnd(); } b.flush(); }