Files
tyra-linux/demo/src/states/game/ship/ship.cpp
T
2022-08-24 19:50:11 +02:00

51 lines
1.2 KiB
C++

/*
# _____ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licensed under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include "states/game/ship/ship.hpp"
using Tyra::FileUtils;
using Tyra::ObjLoader;
using Tyra::ObjLoaderOptions;
namespace Demo {
Ship::Ship(TextureRepository* repo) {
ObjLoader loader;
ObjLoaderOptions objOptions;
objOptions.flipUVs = true;
objOptions.scale = 200.0F;
auto data =
loader.load(FileUtils::fromCwd("game/models/ship/ship.obj"), objOptions);
mesh = new StaticMesh(data.get());
for (std::size_t i = 0; i < mesh->materials.size(); i++) {
mesh->materials[i]->ambient /= 2.0F;
mesh->materials[i]->ambient.a = 128.0F;
}
mesh->setPosition(Vec4(-800.0F, 10.0F, -2500.0F));
allocateOptions();
pair = new RendererStaticPair{mesh, options};
}
Ship::~Ship() {
delete mesh;
delete options;
delete pair;
}
void Ship::allocateOptions() { options = new StaPipOptions(); }
} // namespace Demo