Files
BlitzNext/Runtime/blitz3d/model.hpp
T

155 lines
2.5 KiB
C++
Raw Normal View History

2014-01-31 08:23:00 +13:00
#ifndef MODEL_H
#define MODEL_H
2019-01-18 15:55:06 +01:00
#include "brush.hpp"
#include "object.hpp"
#include "rendercontext.hpp"
2014-01-31 08:23:00 +13:00
class Sprite;
class Terrain;
class PlaneModel;
class Q3BSPModel;
2019-01-18 17:04:17 +01:00
class Model : public Object {
public:
enum { RENDER_SPACE_LOCAL = 0, RENDER_SPACE_WORLD = 1 };
enum {
COLLISION_GEOMETRY_DEFAULT = 0,
COLLISION_GEOMETRY_TRIS = 1,
COLLISION_GEOMETRY_BOX = 2,
COLLISION_GEOMETRY_SPHERE = 3
2014-01-31 08:23:00 +13:00
};
2019-01-18 17:04:17 +01:00
enum { QUEUE_OPAQUE = 0, QUEUE_TRANSPARENT = 1 };
2014-01-31 08:23:00 +13:00
Model();
2019-01-18 17:04:17 +01:00
Model(const Model& m);
2014-01-31 08:23:00 +13:00
//Entity interface
2019-01-18 17:04:17 +01:00
Model* getModel()
{
return this;
}
2014-01-31 08:23:00 +13:00
//Object interface
void capture();
2019-01-18 17:04:17 +01:00
bool beginRender(float tween);
2014-01-31 08:23:00 +13:00
//Model interface
2019-01-18 17:04:17 +01:00
virtual void setRenderBrush(const Brush& b) {}
virtual bool render(const RenderContext& rc)
{
return false;
}
virtual void renderQueue(int type);
virtual Sprite* getSprite()
{
return 0;
}
virtual Terrain* getTerrain()
{
return 0;
}
virtual PlaneModel* getPlaneModel()
{
return 0;
}
virtual MeshModel* getMeshModel()
{
return 0;
}
virtual MD2Model* getMD2Model()
{
return 0;
}
virtual Q3BSPModel* getBSPModel()
{
return 0;
}
virtual void setBrush(const Brush& b)
{
brush = b;
w_brush = true;
}
virtual void setColor(const Vector& c)
{
brush.setColor(c);
w_brush = true;
}
virtual void setAlpha(float a)
{
brush.setAlpha(a);
w_brush = true;
}
virtual void setShininess(float t)
{
brush.setShininess(t);
w_brush = true;
}
virtual void setTexture(int i, const Texture& t, int f)
{
brush.setTexture(i, t, f);
w_brush = true;
}
virtual void setBlend(int n)
{
brush.setBlend(n);
w_brush = true;
}
virtual void setFX(int n)
{
brush.setFX(n);
w_brush = true;
}
const Brush& getBrush() const
{
return brush;
}
void setRenderSpace(int n)
{
space = n;
}
int getRenderSpace() const
{
return space;
}
void setAutoFade(float nr, float fr)
{
auto_fade_nr = nr;
auto_fade_fr = fr;
auto_fade = true;
}
bool doAutoFade(const Vector& eye);
void enqueue(gxMesh* mesh, int first_vert, int vert_cnt, int first_tri, int tri_cnt);
void enqueue(gxMesh* mesh, int first_vert, int vert_cnt, int first_tri, int tri_cnt, const Brush& b);
int queueSize(int type) const
{
return queues[type].size();
}
private:
2014-01-31 08:23:00 +13:00
class MeshQueue;
2019-01-18 17:04:17 +01:00
int space;
Brush brush, render_brush;
2014-01-31 08:23:00 +13:00
mutable bool w_brush;
2019-01-18 17:04:17 +01:00
float captured_alpha, tweened_alpha;
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
bool auto_fade;
float auto_fade_nr, auto_fade_fr;
2014-01-31 08:23:00 +13:00
vector<MeshQueue*> queues[2];
2019-01-18 17:04:17 +01:00
void enqueue(MeshQueue* q);
2014-01-31 08:23:00 +13:00
};
#endif