本文整理汇总了C++中ogre::ColourValue::saturate方法的典型用法代码示例。如果您正苦于以下问题:C++ ColourValue::saturate方法的具体用法?C++ ColourValue::saturate怎么用?C++ ColourValue::saturate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::ColourValue
的用法示例。
在下文中一共展示了ColourValue::saturate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createChunk
void CubeWorld::createChunk (Ogre::ManualObject* MeshChunk, const int StartX, const int StartY, const int StartZ)
{
block_t LastBlock = 0;
//Ogre::ManualObject* MeshChunk = new Ogre::ManualObject("MeshMatChunk" + Ogre::StringConverter::toString(m_ChunkID));
//MeshChunk->begin("TerrainImage");
int iVertex = 0;
block_t Block;
block_t Block1;
/* Only create visible faces of each chunk */
block_t DefaultBlock = 1;
int SX = 0;
int SY = 0;
int SZ = 0;
int MaxSize = WORLD_SIZE;
float V1, V2;
float BlockLight;
Ogre::ColourValue BlockColory1; //Top face
Ogre::ColourValue BlockColory2; //Bottom face
Ogre::ColourValue BlockColorx1; //Sunset face
Ogre::ColourValue BlockColorx2; //Sunrise face
Ogre::ColourValue BlockColorz; //Front/back faces
for (int z = StartZ; z < CHUNK_SIZE + StartZ; ++z)
{
for (int y = StartY; y < CHUNK_SIZE + StartY; ++y)
{
for (int x = StartX; x < CHUNK_SIZE + StartX; ++x)
{
Block = GetBlock(x,y,z);
if (Block == 0) continue; // Ignore air blocks
if (Block == 5) continue; // Ignore water blocks
//Compute the block's texture coordinates
V1 = 0.25f * (float)(Block - 1);
V2 = V1 + 0.25f;
BlockLight = GetBlockLight(x, y, z) / 255.0f; //For the two x faces
float BlockLight1 = BlockLight * 0.9f; //For the two z faces
float BlockLight2 = BlockLight * 0.8f; //For the two y faces
// std::cerr << "*** BlockLight: " << BlockLight << std::endl;
// std::cerr << "*** BlockLight1: " << BlockLight1 << std::endl;
// std::cerr << "*** BlockLight2: " << BlockLight2 << std::endl;
float BaseLight = GetBlockLight(x, y, z) / 255.0f;
float Factor;
if (m_LightAngle >= 0 && m_LightAngle <= 180)
Factor = sin(m_LightAngle * 3.1415926f / 180.0f);
else
Factor = 0;
if (Factor < 0.1f)
Factor = 0.1f;
BlockColory1 = m_LightColor * (Factor * BaseLight) + m_AmbientColor;
BlockColory1.saturate();
BlockColory2 = m_LightColor * (Factor / 2.0f * BaseLight) + m_AmbientColor;
BlockColory2.saturate();
BlockColorz = m_LightColor * (Factor * 0.70f * BaseLight) + m_AmbientColor;
BlockColorz.saturate();
BlockColorz *= 0.80f;
if (m_LightAngle >= 315 || m_LightAngle <= 45)
Factor = fabs(cos(m_LightAngle * 3.1415926f / 180.0f));
else
Factor = fabs(sin(m_LightAngle * 3.1415926f / 180.0f));
if (Factor < 0.1f)
Factor = 0.1f;
BlockColorx1 = m_LightColor * (Factor * 0.80f * BaseLight) + m_AmbientColor;
BlockColorx1.saturate();
BlockColorx1 *= 0.95f;
if (m_LightAngle >= 135 && m_LightAngle <= 225)
Factor = fabs(cos(m_LightAngle * 3.1415926f / 180.0f));
else
Factor = fabs(sin(m_LightAngle * 3.1415926f / 180.0f));
if (Factor < 0.1f)
Factor = 0.1f;
BlockColorx2 = m_LightColor * (Factor * 0.80f * BaseLight) + m_AmbientColor;
BlockColorx2.saturate();
BlockColorx2 *= 0.95f;
Block1 = DefaultBlock;
if (x > SX)
Block1 = GetBlock(x-1,y,z);
//x-1
if (g_BlockInfo[Block1].Transparent)
{
MeshChunk->position(x, y, z+1); MeshChunk->normal(-1,0,0); MeshChunk->textureCoord(0, V2); MeshChunk->colour(BlockColorx1);
MeshChunk->position(x, y+1, z+1); MeshChunk->normal(-1,0,0); MeshChunk->textureCoord(1, V2); MeshChunk->colour(BlockColorx1);
MeshChunk->position(x, y+1, z); MeshChunk->normal(-1,0,0); MeshChunk->textureCoord(1, V1); MeshChunk->colour(BlockColorx1);
MeshChunk->position(x, y, z); MeshChunk->normal(-1,0,0); MeshChunk->textureCoord(0, V1); MeshChunk->colour(BlockColorx1);
MeshChunk->triangle(iVertex, iVertex+1, iVertex+2);
MeshChunk->triangle(iVertex+2, iVertex+3, iVertex);
//.........这里部分代码省略.........