📄 game.cc
字号:
#define USEOLDFILTERS 1
void GameRenderFilters(const CameraQuery& camq)
{
#if USEOLDFILTERS
GameConnection* connection = GameConnection::getConnectionToServer();
F32 damageFlash = 0;
F32 whiteOut = 0;
F32 blackOut = 0;
if(connection)
{
damageFlash = connection->getDamageFlash();
whiteOut = connection->getWhiteOut();
blackOut = connection->getBlackOut();
}
ShapeBase* psb = dynamic_cast<ShapeBase*>(camq.object);
if (psb != NULL) {
if (damageFlash > 0.0) {
if (damageFlash > 0.76)
damageFlash = 0.76f;
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1, 0, 0, damageFlash);
glBegin(GL_TRIANGLE_FAN);
glVertex3f(-1, -1, 0);
glVertex3f(-1, 1, 0);
glVertex3f( 1, 1, 0);
glVertex3f( 1, -1, 0);
glEnd();
glDisable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
if (whiteOut > 0.0) {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1.0f, 1.0f, 0.92f, (whiteOut > 1.0f ? 1.0f : whiteOut));
glBegin(GL_TRIANGLE_FAN);
glVertex3f(-1, -1, 0);
glVertex3f(-1, 1, 0);
glVertex3f( 1, 1, 0);
glVertex3f( 1, -1, 0);
glEnd();
glDisable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
if (blackOut > 0.0) {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.0f, 0.0f, 0.0f, (blackOut > 1.0f ? 1.0f : blackOut));
glBegin(GL_TRIANGLE_FAN);
glVertex3f(-1, -1, 0);
glVertex3f(-1, 1, 0);
glVertex3f( 1, 1, 0);
glVertex3f( 1, -1, 0);
glEnd();
glDisable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
F32 invincible = psb->getInvincibleEffect();
if (invincible > 0.0) {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0, 0, 1, (invincible > 1.0f ? 1.0f : invincible));
glBegin(GL_TRIANGLE_FAN);
glVertex3f(-1, -1, 0);
glVertex3f(-1, 1, 0);
glVertex3f( 1, 1, 0);
glVertex3f( 1, -1, 0);
glEnd();
glDisable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
if (WaterBlock::mCameraSubmerged)
{
if (WaterBlock::isWater(WaterBlock::mSubmergedType))
{
// view filter for camera below the water surface
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glDisable(GL_TEXTURE_2D);
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//celestial
// glColor4f(.2, .6, .6, .3);
if(gCelestials) // <sami>
{
F32 i = gCelestials->GetIntensity();
glColor4f(.2 * i, .6 * i, .6 * i, .3);
}
else
{
glColor4f(.2, .6, .6, .3);
}
//celestial end
glBegin(GL_TRIANGLE_FAN);
glVertex3f(-1, -1, 0);
glVertex3f(-1, 1, 0);
glVertex3f( 1, 1, 0);
glVertex3f( 1, -1, 0);
glEnd();
glDisable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
else if (WaterBlock::isLava(WaterBlock::mSubmergedType))
{
gLavaFX.render();
}
else if (WaterBlock::isQuicksand(WaterBlock::mSubmergedType))
{
}
}
WaterBlock::mCameraSubmerged = false;
WaterBlock::mSubmergedType = 0;
}
#else
//
// Need to build a filter for damage, invincibility, underwater, whiteout... ect
//
// Damage, Whiteout, and invincible effects have constant color with variable
// alpha values. The water filter has a constant color and alpha value. This
// looks kinda tricky, and it is. See Frohn for more details Jett-
// first get the game connection for this player
GameConnection* connection = GameConnection::getConnectionToServer();
bool addWaterFilter = false;
bool addLavaFilter = false;
F32 maxDamageFilter = 0.77;
F32 damageFlash = 0.f; ColorF damageFilterColor(1.f, 0.f, 0.f, 0.f);
F32 whiteOut = 0.f; ColorF whiteoutFilterColor(1.f, 1.f, 1.f, 0.f);
F32 waterFilter = 0.f; ColorF waterFilterColor(0.2, 0.6, 0.6, 0.6);
F32 invincible = 0.f; ColorF invincibleFilterColor(0.f, 0.f, 1.f, 0.f);
// final color and alpha of filter + an adder
ColorF Xcolor(0.f, 0.f, 0.f, 1.f);
if(connection)
{
// grab the damage flash alpha value
damageFlash = connection->getDamageFlash();
if( damageFlash > maxDamageFilter )
damageFlash = maxDamageFilter;
damageFilterColor.alpha = damageFlash;
// grab the whiteout value
whiteoutFilterColor.alpha = connection->getWhiteOut();
// need to grab the player obj to get inv. alpha value
ShapeBase* psb = dynamic_cast<ShapeBase*>(camq.object);
if(psb != NULL)
invincibleFilterColor.alpha = psb->getInvincibleEffect();
// determine if we need to add in our water filter (constant color and alpha)
if( WaterBlock::mCameraSubmerged )
{
if( WaterBlock::isWater( WaterBlock::mSubmergedType ) )
addWaterFilter = true;
else if( WaterBlock::isLava( WaterBlock::mSubmergedType))
addLavaFilter = true;
}
// compute the final color and alpha
Xcolor = ( Xcolor * ( 1 - damageFilterColor.alpha ) ) + ( damageFilterColor * damageFilterColor.alpha );
Xcolor.alpha = Xcolor.alpha * ( 1 - damageFilterColor.alpha );
Xcolor = ( Xcolor * ( 1 - whiteoutFilterColor.alpha ) ) + ( whiteoutFilterColor * whiteoutFilterColor.alpha );
Xcolor.alpha = Xcolor.alpha * ( 1 - whiteoutFilterColor.alpha );
Xcolor = ( Xcolor * ( 1 - invincibleFilterColor.alpha ) ) + ( invincibleFilterColor * invincibleFilterColor.alpha );
Xcolor.alpha = Xcolor.alpha * ( 1 - invincibleFilterColor.alpha );
// if were sitting in water, then add that filter in as well.
if(addWaterFilter)
{
Xcolor = ( Xcolor * ( 1 - waterFilterColor.alpha ) ) + ( waterFilterColor * waterFilterColor.alpha );
Xcolor.alpha = Xcolor.alpha * ( 1 - waterFilterColor.alpha );
}
// draw our filter with final color
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glColor4f(Xcolor.red, Xcolor.blue, Xcolor.blue, Xcolor.alpha);
glBegin(GL_TRIANGLE_FAN);
glVertex3f(-1, -1, 0);
glVertex3f(-1, 1, 0);
glVertex3f( 1, 1, 0);
glVertex3f( 1, -1, 0);
glEnd();
glDisable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
// if were under lava, apply appropriate texture
if( addLavaFilter )
{
gLavaFX.render();
}
WaterBlock::mCameraSubmerged = false;
WaterBlock::mSubmergedType = 0;
}
#endif
}
void GameRenderWorld()
{
PROFILE_START(GameRenderWorld);
FrameAllocator::setWaterMark(0);
#if defined(TORQUE_GATHER_METRICS) && TORQUE_GATHER_METRICS > 1
TextureManager::smTextureCacheMisses = 0;
#endif
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glClear(GL_DEPTH_BUFFER_BIT);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
dglSetCanonicalState();
gClientSceneGraph->renderScene();
glDisable(GL_DEPTH_TEST);
collisionTest.render();
#if defined(TORQUE_GATHER_METRICS) && TORQUE_GATHER_METRICS > 1
Con::setFloatVariable("Video::texResidentPercentage",
TextureManager::getResidentFraction());
Con::setIntVariable("Video::textureCacheMisses",
TextureManager::smTextureCacheMisses);
#endif
AssertFatal(FrameAllocator::getWaterMark() == 0, "Error, someone didn't reset the water mark on the frame allocator!");
FrameAllocator::setWaterMark(0);
PROFILE_END();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -