mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-20 21:35:12 +00:00
fix compilation, model is a 3D drawable
This commit is contained in:
@@ -8,46 +8,47 @@
|
||||
#include "Model/Model.hpp"
|
||||
#include "Exceptions/RayError.hpp"
|
||||
|
||||
RAY::Model::Model(const std::string &filePath, const RAY::Vector3 &position, const RAY::Vector3 &rotationAxis, float rotationAngle, const RAY::Vector3 &scale):
|
||||
ADrawable3D(position, WHITE), _model(LoadModel(filename.c_str()), position, rotationAxis, rotationAngle, scale)
|
||||
RAY::Drawables::Drawables3D::Model::Model(const std::string &filename, const RAY::Vector3 &position, const RAY::Vector3 &rotationAxis, float rotationAngle, const RAY::Vector3 &scale):
|
||||
ADrawable3D(position, WHITE), _model(LoadModel(filename.c_str())),
|
||||
_rotationAxis(rotationAxis), _rotationAngle(rotationAngle), _scale(scale)
|
||||
{
|
||||
}
|
||||
|
||||
RAY::Model::Model(const Mesh &mesh):
|
||||
_model(LoadModelFromMesh(mesh))
|
||||
RAY::Drawables::Drawables3D::Model::Model(const Mesh &mesh)
|
||||
: ADrawable3D({0, 0, 0}, WHITE), _model(LoadModelFromMesh(mesh))
|
||||
{
|
||||
}
|
||||
|
||||
RAY::Model::~Model()
|
||||
RAY::Drawables::Drawables3D::Model::~Model()
|
||||
{
|
||||
this->unload();
|
||||
}
|
||||
|
||||
bool RAY::Model::load(const std::string &filename)
|
||||
bool RAY::Drawables::Drawables3D::Model::load(const std::string &filename)
|
||||
{
|
||||
this->_model = LoadModel(filename.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Model::load(const Mesh &mesh)
|
||||
bool RAY::Drawables::Drawables3D::Model::load(const Mesh &mesh)
|
||||
{
|
||||
this->_model = LoadModelFromMesh(mesh);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Model::unload()
|
||||
bool RAY::Drawables::Drawables3D::Model::unload()
|
||||
{
|
||||
UnloadModel(this->_model);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Model::unloadKeepMeshes()
|
||||
bool RAY::Drawables::Drawables3D::Model::unloadKeepMeshes()
|
||||
{
|
||||
UnloadModelKeepMeshes(_model);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Model::setAnimation(const RAY::ModelAnimation &animation)
|
||||
bool RAY::Drawables::Drawables3D::Model::setAnimation(const RAY::ModelAnimation &animation)
|
||||
{
|
||||
if (!IsModelAnimationValid(this->_model, animation))
|
||||
throw RAY::Exception::NotCompatibleError("The animation is not compatible with the model");
|
||||
@@ -55,56 +56,56 @@ bool RAY::Model::setAnimation(const RAY::ModelAnimation &animation)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Model::setTextureToMaterial(RAY::Model::MaterialType materialType, const RAY::Texture &texture)
|
||||
bool RAY::Drawables::Drawables3D::Model::setTextureToMaterial(RAY::Drawables::Drawables3D::Model::MaterialType materialType, const RAY::Texture &texture)
|
||||
{
|
||||
SetMaterialTexture(&this->_model.materials[materialType], materialType, texture);
|
||||
return true;
|
||||
}
|
||||
|
||||
RAY::Model::operator ::Model() const
|
||||
RAY::Drawables::Drawables3D::Model::operator ::Model() const
|
||||
{
|
||||
return this->_model;
|
||||
}
|
||||
|
||||
int RAY::Model::getBoneCount() const
|
||||
int RAY::Drawables::Drawables3D::Model::getBoneCount() const
|
||||
{
|
||||
return this->_model.boneCount;
|
||||
}
|
||||
|
||||
RAY::Model &RAY::Model::setRotationAngle(float rotationAngle)
|
||||
RAY::Drawables::Drawables3D::Model &RAY::Drawables::Drawables3D::Model::setRotationAngle(float rotationAngle)
|
||||
{
|
||||
this->_rotationAngle = rotationAngle;
|
||||
return *this;
|
||||
}
|
||||
|
||||
float RAY::Model::getRotationAngle(void)
|
||||
float RAY::Drawables::Drawables3D::Model::getRotationAngle(void)
|
||||
{
|
||||
return this->_rotationAngle;
|
||||
}
|
||||
|
||||
RAY::Model &RAY::Model::setRotationAxix(const RAY::Vector3 &scale)
|
||||
RAY::Drawables::Drawables3D::Model &RAY::Drawables::Drawables3D::Model::setRotationAxis(const RAY::Vector3 &scale)
|
||||
{
|
||||
this->_scale = scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const RAY::Vector3 &RAY::Model::getRotationAxix(void)
|
||||
const RAY::Vector3 &RAY::Drawables::Drawables3D::Model::getRotationAxis(void)
|
||||
{
|
||||
return this->_rotationAxis;
|
||||
}
|
||||
|
||||
RAY::Model &RAY::Model::setScale(const RAY::Vector3 &scale)
|
||||
RAY::Drawables::Drawables3D::Model &RAY::Drawables::Drawables3D::Model::setScale(const RAY::Vector3 &scale)
|
||||
{
|
||||
this->_scale = scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const RAY::Vector3 &RAY::Model::getScale(void)
|
||||
const RAY::Vector3 &RAY::Drawables::Drawables3D::Model::getScale(void)
|
||||
{
|
||||
return this->_scale;
|
||||
}
|
||||
|
||||
void RAY::Model::drawOn(RAY::Window &)
|
||||
void RAY::Drawables::Drawables3D::Model::drawOn(RAY::Window &)
|
||||
{
|
||||
DrawModelEx(this->_model, this->_position, this->_rotationAxis, this->_rotationAngle, this->_scale, this->_color);
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <raylib.h>
|
||||
#include <vector>
|
||||
|
||||
namespace RAY {
|
||||
namespace RAY::Drawables::Drawables3D {
|
||||
//! @brief Basic 3D Model type
|
||||
class Model: public IRessource, public Drawables::ADrawable3D {
|
||||
public:
|
||||
@@ -24,7 +24,7 @@ namespace RAY {
|
||||
|
||||
//! @brief Create an model, loading a file
|
||||
//! @param filePath: path to file to load
|
||||
Model(const std::string &filePath, const RAY::Vector3 &position, const RAY::Vector3 &rotationAxis = RAY::Vector3(0, 1, 0), float rotationAngle = 0, const RAY::Vector3 &scale = RAY::Vector3(1, 1, 1));
|
||||
Model(const std::string &filePath, const RAY::Vector3 &position = {0, 0, 0}, const RAY::Vector3 &rotationAxis = RAY::Vector3(0, 1, 0), float rotationAngle = 0, const RAY::Vector3 &scale = RAY::Vector3(1, 1, 1));
|
||||
|
||||
//! @brief Create an model, loading a file
|
||||
//! @param mesh: mesh to load
|
||||
@@ -69,10 +69,10 @@ namespace RAY {
|
||||
float getRotationAngle(void);
|
||||
|
||||
//! @brief Set Rotation Axis
|
||||
Model &setRotationAxix(const RAY::Vector3 &scale);
|
||||
Model &setRotationAxis(const RAY::Vector3 &scale);
|
||||
|
||||
//! @return rotation axis
|
||||
const RAY::Vector3 & getRotationAxix(void);
|
||||
const RAY::Vector3 & getRotationAxis(void);
|
||||
|
||||
//! @brief Set Scale
|
||||
Model &setScale(const RAY::Vector3 &scale);
|
||||
@@ -80,6 +80,8 @@ namespace RAY {
|
||||
//! @return Scale
|
||||
const RAY::Vector3 & getScale(void);
|
||||
|
||||
void drawOn(RAY::Window &) override;
|
||||
|
||||
private:
|
||||
//! @brief Raw data from raylib
|
||||
::Model _model;
|
||||
|
||||
@@ -20,11 +20,14 @@
|
||||
#include "Drawables/Texture.hpp"
|
||||
|
||||
namespace RAY {
|
||||
class Model;
|
||||
//! @brief Window manager
|
||||
namespace Drawables {
|
||||
class IDrawable;
|
||||
class ADrawable3D;
|
||||
namespace Drawables3D
|
||||
{
|
||||
class Model;
|
||||
}
|
||||
}
|
||||
class Window {
|
||||
public:
|
||||
|
||||
@@ -55,7 +55,8 @@ int demo()
|
||||
RAY::TraceLog::setLevel(LOG_WARNING);
|
||||
RAY::Window &window = RAY::Window::getInstance(screenWidth, screenHeight, "Bidibidibop", FLAG_WINDOW_RESIZABLE);
|
||||
RAY::Image icon("assets/icon.png");
|
||||
RAY::Model model(modelPath);
|
||||
RAY::Vector3 position(0.0f, 0.0f, 0.0f); // Set model position
|
||||
RAY::Drawables::Drawables3D::Model model(modelPath, position, RAY::Vector3(1.0f, 20, 0.0f), -180.0f, RAY::Vector3( 3.0f, 3.0f, 3.0f ));
|
||||
RAY::Camera::Camera3D camera(RAY::Vector3(10.0f, 10.0f, 10.0f),
|
||||
RAY::Vector3(0.0f, 0.0f, 0.0f),
|
||||
RAY::Vector3(0.0f, 1.0f, 0.0f),
|
||||
@@ -75,7 +76,6 @@ int demo()
|
||||
RAY::Drawables::Drawables3D::Grid grid(10, 1.0f);
|
||||
RAY::Drawables::Drawables2D::Text instructionText("PRESS SPACE to PLAY MODEL ANIMATION", 10, {10, 20} , MAROON);
|
||||
size_t animationIndex = 0;
|
||||
RAY::Vector3 position(0.0f, 0.0f, 0.0f); // Set model position
|
||||
|
||||
model.setTextureToMaterial(MAP_DIFFUSE, texture);
|
||||
window.setIcon(icon);
|
||||
@@ -117,7 +117,7 @@ int demo()
|
||||
window.clear();
|
||||
window.useCamera(camera);
|
||||
|
||||
window.draw(model, position, RAY::Vector3(1.0f, 20, 0.0f), -180.0f, RAY::Vector3( 3.0f, 3.0f, 3.0f ));
|
||||
window.draw(model);
|
||||
|
||||
window.draw(grid);
|
||||
window.draw(circle);
|
||||
|
||||
Reference in New Issue
Block a user