39 lines
915 B
C++
39 lines
915 B
C++
#pragma once
|
|
#include <iostream>
|
|
#include "resourceManager.h"
|
|
|
|
class tileSet
|
|
{
|
|
Texture tileSheet;
|
|
glm::ivec2 dims;
|
|
|
|
public:
|
|
tileSet(const Texture &texture, glm::ivec2 tileDims)
|
|
: tileSheet(texture), dims(tileDims) {}
|
|
|
|
glm::vec4 getUVs(int index)
|
|
{
|
|
int tileX = index % dims.x;
|
|
int tileY = index / dims.x;
|
|
|
|
glm::vec4 UV;
|
|
UV.x = tileX / (float)dims.x;
|
|
UV.y = tileY / (float)dims.y;
|
|
UV.z = UV.x + 1.0f / dims.x;
|
|
UV.w = UV.y - 1.0f / dims.y;
|
|
return UV;
|
|
}
|
|
glm::vec4 getUVsExtended(int index, int lengthX, int lengthY)
|
|
{
|
|
int tileX = index % dims.x;
|
|
int tileY = index / dims.x;
|
|
int secondTileX = lengthX % dims.x;
|
|
std::cout << "secondTileX: " << secondTileX << "\n";
|
|
glm::vec4 UV;
|
|
UV.x = tileX / (float)dims.x;
|
|
UV.y = tileY / (float)dims.y;
|
|
UV.z = UV.x + (float)secondTileX / dims.x;
|
|
UV.w = UV.y - (float)lengthY / dims.y;
|
|
return UV;
|
|
}
|
|
}; |