demo map and weapon

This commit is contained in:
h4570
2022-07-31 16:24:46 +02:00
parent 834d57ea32
commit 12dd72f15e
28 changed files with 781 additions and 18 deletions
+61
View File
@@ -0,0 +1,61 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include "states/game/debug_object.hpp"
#include <loaders/3d/tyrobj/tyrobj_loader.hpp>
#include <file/file_utils.hpp>
using Tyra::Color;
using Tyra::FileUtils;
using Tyra::TyrobjLoader;
namespace Demo {
DebugObject::DebugObject(TextureRepository* repo) {
TyrobjLoader loader;
auto* data =
loader.load(FileUtils::fromCwd("game/models/debug.obj"), 1, .5F, true);
data->normalsEnabled = false;
data->textureCoordsEnabled = false;
mesh = new StaticMesh(*data);
delete data;
mesh->getMaterial(0)->color = Color(192.0F, 32.0F, 32.0F, 128.0F);
rotator = 0.0F;
allocateOptions();
pair = new RendererStaticPair{mesh, options};
}
void DebugObject::setPosition(const Vec4& v) {
mesh->translation.identity();
mesh->rotation.identity();
mesh->translation.translate(v);
mesh->rotation.rotateX(rotator);
mesh->rotation.rotateY(rotator);
mesh->rotation.rotateZ(rotator);
rotator += 0.05F;
if (rotator >= 360.0F) rotator = 0.0F;
}
DebugObject::~DebugObject() {
delete mesh;
delete options;
delete pair;
}
void DebugObject::allocateOptions() {
options = new StaPipOptions();
options->shadingType = Tyra::TyraShadingGouraud;
options->blendingEnabled = false;
options->antiAliasingEnabled = false;
}
} // namespace Demo