cntrl/src/render/models.hpp

59 lines
1.8 KiB
C++

#pragma once
#include "raylib.h"
// Low-poly GLB actors authored in Blender (tools/blender/build_enemies.py).
// All models are metres, origin at the feet, facing +Z (the game camera).
// The set-dressing models share the same one-mesh / painted-vertex pipeline.
enum class ActorModel {
Guard, HissStaff, MoldSpore, HissBrute, Shard,
Hotline, TV, Pedestal, Duck, Cabinet, Crate, Debris,
Count
};
class ModelBank {
public:
void init();
void shutdown();
bool ready() const { return ready_; }
// Frame-wide shader uniforms (time / corruption / camera).
void begin_frame(float time, float corruption, Vector3 camera_pos);
// Draws one actor. `flash` is a 0..1 hit flash; `yaw` rotates around Y.
// `outline` adds a back-face ink silhouette (guard / bosses, not the horde).
void draw(ActorModel id, Vector3 pos, float yaw, float scale, Color tint,
float flash = 0.0f, bool outline = false, float walk = 0.0f,
float stagger = 0.0f, float phase = 0.0f);
// Per-model visual height, used for health bars / floating labels.
static float height(ActorModel id);
private:
struct Entry {
Model model{};
bool loaded = false;
};
static const char* file_name(ActorModel id);
void draw_fallback(ActorModel id, Vector3 pos, float yaw, float scale, Color tint);
Entry entries_[static_cast<int>(ActorModel::Count)];
Shader shader_{};
Texture2D ramp_{};
int loc_time_ = -1;
int loc_flash_ = -1;
int loc_corruption_ = -1;
int loc_camera_ = -1;
int loc_outline_ = -1;
int loc_ramp_ = -1;
int loc_walk_ = -1;
int loc_stagger_ = -1;
int loc_phase_ = -1;
int loc_rig_ = -1;
int loc_rig_scale_ = -1;
int loc_rig_mode_ = -1;
bool shader_ok_ = false;
bool ready_ = false;
};