本文整理汇总了C++中DataManager::getTileSheetCoords方法的典型用法代码示例。如果您正苦于以下问题:C++ DataManager::getTileSheetCoords方法的具体用法?C++ DataManager::getTileSheetCoords怎么用?C++ DataManager::getTileSheetCoords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataManager
的用法示例。
在下文中一共展示了DataManager::getTileSheetCoords方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createCube
void Chunk::createCube(int _x, int _y, int _z, std::vector<float> *_vertexes, std::vector<float> *_normals, std::vector<float> *_colours, std::vector<float> *_textureCoords, bool _allActive /*= false*/)
{
if (!m_pBlocks[_x][_y][_z].isActive()) return;
sf::Vector3f p1 = sf::Vector3f((_x + 0) * BLOCK_SIZE, (_y + 0) * BLOCK_SIZE, (_z + 1) * BLOCK_SIZE);
sf::Vector3f p2 = sf::Vector3f((_x + 1) * BLOCK_SIZE, (_y + 0) * BLOCK_SIZE, (_z + 1) * BLOCK_SIZE);
sf::Vector3f p3 = sf::Vector3f((_x + 1) * BLOCK_SIZE, (_y + 1) * BLOCK_SIZE, (_z + 1) * BLOCK_SIZE);
sf::Vector3f p4 = sf::Vector3f((_x + 0) * BLOCK_SIZE, (_y + 1) * BLOCK_SIZE, (_z + 1) * BLOCK_SIZE);
sf::Vector3f p5 = sf::Vector3f((_x + 1) * BLOCK_SIZE, (_y + 0) * BLOCK_SIZE, (_z + 0) * BLOCK_SIZE);
sf::Vector3f p6 = sf::Vector3f((_x + 0) * BLOCK_SIZE, (_y + 0) * BLOCK_SIZE, (_z + 0) * BLOCK_SIZE);
sf::Vector3f p7 = sf::Vector3f((_x + 0) * BLOCK_SIZE, (_y + 1) * BLOCK_SIZE, (_z + 0) * BLOCK_SIZE);
sf::Vector3f p8 = sf::Vector3f((_x + 1) * BLOCK_SIZE, (_y + 1) * BLOCK_SIZE, (_z + 0) * BLOCK_SIZE);
sf::Vector3f n;
sf::Vector2f tex;
DataManager *data = m_ChunkManager->getDataManager();
Block::BlockType btype = m_pBlocks[_x][_y][_z].getType();
bool front = true;
bool back = true;
bool left = true;
bool right = true;
bool top = true;
bool bottom = true;
if (!_allActive)
{
if (_x > 0)
{
if (m_pBlocks[_x - 1][_y][_z].isActive())
{
left = false;
}
}
if (_x + 1 < CHUNK_SIZE)
{
if (m_pBlocks[_x + 1][_y][_z].isActive())
{
right = false;
}
}
if (_y > 0)
{
if (m_pBlocks[_x][_y - 1][_z].isActive())
{
bottom = false;
}
}
if (_y + 1 < CHUNK_SIZE)
{
if (m_pBlocks[_x][_y + 1][_z].isActive())
{
top = false;
}
}
if (_z > 0)
{
if (m_pBlocks[_x][_y][_z - 1].isActive())
{
back = false;
}
}
if (_z + 1 < CHUNK_SIZE)
{
if (m_pBlocks[_x][_y][_z + 1].isActive())
{
front = false;
}
}
}
if (front)
{
//~ Front
n = sf::Vector3f(0.0f, 0.0f, 1.0f);
//~ Triangle 1 {1, 2, 3}
_vertexes->push_back(p1.x); _vertexes->push_back(p1.y); _vertexes->push_back(p1.z);
_normals->push_back(n.x); _normals->push_back(n.y); _normals->push_back(n.z);
_colours->push_back(0.0f); _colours->push_back(1.0f); _colours->push_back(0.0f);
tex = Block::getTexCoords(data->getTileSheetCoords(btype, Block::FaceIndex::FRO), Block::VertIndex::BOT_LEF);
_textureCoords->push_back(tex.x); _textureCoords->push_back(tex.y);
_vertexes->push_back(p2.x); _vertexes->push_back(p2.y); _vertexes->push_back(p2.z);
_normals->push_back(n.x); _normals->push_back(n.y); _normals->push_back(n.z);
_colours->push_back(0.0f); _colours->push_back(1.0f); _colours->push_back(0.0f);
tex = Block::getTexCoords(data->getTileSheetCoords(btype, Block::FaceIndex::FRO), Block::VertIndex::BOT_RIG);
_textureCoords->push_back(tex.x); _textureCoords->push_back(tex.y);
_vertexes->push_back(p3.x); _vertexes->push_back(p3.y); _vertexes->push_back(p3.z);
_normals->push_back(n.x); _normals->push_back(n.y); _normals->push_back(n.z);
_colours->push_back(0.0f); _colours->push_back(1.0f); _colours->push_back(0.0f);
tex = Block::getTexCoords(data->getTileSheetCoords(btype, Block::FaceIndex::FRO), Block::VertIndex::TOP_RIG);
_textureCoords->push_back(tex.x); _textureCoords->push_back(tex.y);
//~ Triangle 2 {1, 3, 4}
_vertexes->push_back(p1.x); _vertexes->push_back(p1.y); _vertexes->push_back(p1.z);
_normals->push_back(n.x); _normals->push_back(n.y); _normals->push_back(n.z);
_colours->push_back(0.0f); _colours->push_back(1.0f); _colours->push_back(0.0f);
//.........这里部分代码省略.........