OpenMiner/source/world/Block.cpp

37 lines
888 B
C++
Raw Normal View History

2015-02-06 01:44:16 +01:00
/*
* =====================================================================================
*
* Filename: Block.cpp
*
2018-06-05 01:24:54 +02:00
* Description:
2015-02-06 01:44:16 +01:00
*
* Version: 1.0
* Created: 29/12/2014 04:56:17
* Revision: none
* Compiler: gcc
*
* Author: Quentin BAZIN, <quent42340@gmail.com>
2018-06-05 01:24:54 +02:00
* Company:
2015-02-06 01:44:16 +01:00
*
* =====================================================================================
*/
#include "Block.hpp"
Block::Block(u32 id) {
2015-02-06 01:44:16 +01:00
m_id = id;
}
glm::vec4 Block::getTexCoords() {
const u16 textureWidth = 256;
const u16 textureHeight = 256;
2018-06-05 01:24:54 +02:00
2015-02-06 01:44:16 +01:00
float textureX = m_id % (textureWidth / 16) * 16.0f / textureWidth;
float textureY = m_id / (textureWidth / 16) * 16.0f / textureHeight;
2018-06-05 01:24:54 +02:00
2015-02-06 01:44:16 +01:00
return glm::vec4(textureX,
textureY,
textureX + 16.0f / textureWidth,
textureY + 16.0f / textureHeight);
}