inline static void fromObj(const Obj& mObj, T& mValue) { const auto& labels(getObj(mObj, "labels")); for(auto iY(0u); iY < getObjSize(labels); ++iY) for(auto iX(0u); iX < getObjSize(labels[iY]); ++iX) mValue.setLabel( getExtr<std::string>(labels[iY][iX]), {iX, iY}); mValue.setTileSize(getExtr<ssvs::Vec2u>(mObj, "tileSize")); }
// Override Move method to implement border limit void Shuttle::Move(float x, float y){ sf::Vector2f curPos = getPosition(); sf::Vector2u curSize = getObjSize(); float curX = curPos.x; float curY = curPos.y; float sizeX = curSize.x; float sizeY = curSize.y; if((curX + x < 0) || (curY + y < 0)){ return; } if((curX + sizeX + x > WINDOW_WIDTH) || (curY + sizeY + y > WINDOW_HEIGHT)){ return; } move(x, y); }
ElysiumEngine::Mesh *ElysiumEngine::loadMeshFromObj(const char *filename) { FILE *file = fopen(filename,"rt"); if(!file) return nullptr; Mesh *output = new Mesh(); getObjSize(file,output->vertexCount,output->indexCount); output->vertices = new VertexData[output->vertexCount]; output->indices = new unsigned int[3 * output->indexCount]; parseOBJ(output,file); fclose(file); //print(output); return output; }
void Shuttle::placeAtBottom(){ sf::Vector2u curSize = getObjSize(); float x = WINDOW_WIDTH / 2 - curSize.x; float y = WINDOW_HEIGHT - curSize.y; Move(x, y); }