void ScatterSky::_getSunColor( ColorF *outColor ) { PROFILE_SCOPE( ScatterSky_GetSunColor ); U32 count = 0; ColorF tmpColor( 0, 0, 0 ); VectorF tmpVec( 0, 0, 0 ); tmpVec = mLightDir; tmpVec.x *= smEarthRadius + smAtmosphereRadius; tmpVec.y *= smEarthRadius + smAtmosphereRadius; tmpVec.z *= smEarthRadius + smAtmosphereRadius; tmpVec.z -= smAtmosphereRadius; for ( U32 i = 0; i < 10; i++ ) { _getColor( tmpVec, &tmpColor ); (*outColor) += tmpColor; tmpVec.x += (smEarthRadius * 0.5f) + (smAtmosphereRadius * 0.5f); count++; } if ( count > 0 ) (*outColor) /= count; }
void SfmlHandler::drawBlock(int x, int y, eColor color){ // Create a Rectangle sf::RectangleShape block(sf::Vector2f(BLOCK_SIZE ,BLOCK_SIZE)); block.setPosition(x * BLOCK_SIZE, y * BLOCK_SIZE); block.setFillColor(_getColor(color)); _window->draw(block); }
void ScatterSky::_getFogColor( ColorF *outColor ) { PROFILE_SCOPE( ScatterSky_GetFogColor ); VectorF scatterPos( 0, 0, 0 ); F32 sunBrightness = mSkyBrightness; mSkyBrightness *= 0.25f; F32 yaw = 0, pitch = 0, originalYaw = 0; VectorF fwd( 0, 1.0f, 0 ); MathUtils::getAnglesFromVector( fwd, yaw, pitch ); originalYaw = yaw; pitch = mDegToRad( 10.0f ); ColorF tmpColor( 0, 0, 0 ); U32 i = 0; for ( i = 0; i < 10; i++ ) { MathUtils::getVectorFromAngles( scatterPos, yaw, pitch ); scatterPos.x *= smEarthRadius + smAtmosphereRadius; scatterPos.y *= smEarthRadius + smAtmosphereRadius; scatterPos.z *= smEarthRadius + smAtmosphereRadius; scatterPos.y -= smEarthRadius; _getColor( scatterPos, &tmpColor ); (*outColor) += tmpColor; if ( i <= 5 ) yaw += mDegToRad( 5.0f ); else { originalYaw += mDegToRad( -5.0f ); yaw = originalYaw; } yaw = mFmod( yaw, M_2PI_F ); } if ( i > 0 ) (*outColor) /= i; mSkyBrightness = sunBrightness; }
void ScatterSky::_getAmbientColor( ColorF *outColor ) { PROFILE_SCOPE( ScatterSky_GetAmbientColor ); ColorF tmpColor( 0, 0, 0, 0 ); U32 count = 0; // Disable mieScattering for purposes of calculating the ambient color. F32 oldMieScattering = mMieScattering; mMieScattering = 0.0f; for ( U32 i = 0; i < mSkyPoints.size(); i++ ) { Point3F pnt( mSkyPoints[i] ); _getColor( pnt, &tmpColor ); (*outColor) += tmpColor; count++; } if ( count > 0 ) (*outColor) /= count; mMieScattering = oldMieScattering; }