Files
BlitzNext/Runtime/blitz3d/object.hpp
T

137 lines
2.6 KiB
C++
Raw Normal View History

2019-01-18 21:26:42 +01:00
#pragma once
2014-01-31 08:23:00 +13:00
#include <vector>
2019-01-18 21:26:42 +01:00
#include "animation.hpp"
2019-01-18 15:55:06 +01:00
#include "collision.hpp"
2019-01-18 17:04:17 +01:00
#include "entity.hpp"
2014-01-31 08:23:00 +13:00
class gxSound;
2019-01-18 21:26:42 +01:00
class gxChannel;
class Animator;
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
struct ObjCollision {
Object* with;
Vector coords;
2014-01-31 08:23:00 +13:00
Collision collision;
};
2019-01-18 17:04:17 +01:00
class Object : public Entity {
public:
2014-01-31 08:23:00 +13:00
typedef std::vector<const ObjCollision*> Collisions;
Object();
2019-01-18 17:04:17 +01:00
Object(const Object& object);
2014-01-31 08:23:00 +13:00
~Object();
//Entity interface
2019-01-18 17:04:17 +01:00
Object* getObject()
{
return this;
}
Entity* clone()
{
return new Object(*this);
}
2014-01-31 08:23:00 +13:00
//deep object copy!
2019-01-18 17:04:17 +01:00
Object* copy();
2014-01-31 08:23:00 +13:00
//called by user
void reset();
2019-01-18 17:04:17 +01:00
void setCollisionType(int type);
void setCollisionRadii(const Vector& radii);
void setCollisionBox(const Box& box);
void setOrder(int n)
{
order = n;
}
void setPickGeometry(int n)
{
pick_geom = n;
}
void setObscurer(bool t)
{
obscurer = t;
}
void setAnimation(const Animation& t)
{
anim = t;
}
void setAnimator(Animator* t);
gxChannel* emitSound(gxSound* sound);
2014-01-31 08:23:00 +13:00
//overridables!
2019-01-18 17:04:17 +01:00
virtual bool collide(const Line& line, float radius, ::Collision* curr_coll, const Transform& t)
{
return false;
}
2014-01-31 08:23:00 +13:00
virtual void capture();
2019-01-18 17:04:17 +01:00
virtual void animate(float e);
virtual bool beginRender(float tween);
2014-01-31 08:23:00 +13:00
virtual void endRender();
//for use by world
2019-01-18 17:04:17 +01:00
void beginUpdate(float elapsed);
void addCollision(const ObjCollision* c);
2014-01-31 08:23:00 +13:00
void endUpdate();
//accessors
2019-01-18 17:04:17 +01:00
int getCollisionType() const;
const Vector& getCollisionRadii() const;
const Box& getCollisionBox() const;
int getOrder() const
{
return order;
}
const Vector& getVelocity() const;
const Collisions& getCollisions() const;
const Transform& getRenderTform() const;
const Transform& getPrevWorldTform() const;
int getPickGeometry() const
{
return pick_geom;
}
int getObscurer() const
{
return obscurer;
}
Animation getAnimation() const
{
return anim;
}
Animator* getAnimator() const
{
return animator;
}
Object* getLastCopy() const
{
return last_copy;
}
private:
int coll_type;
int order;
Vector coll_radii;
Collisions colls;
bool captured;
Box coll_box;
int pick_geom;
bool obscurer;
float elapsed;
Vector velocity;
2019-01-18 21:26:42 +01:00
std::vector<gxChannel*> channels;
2019-01-18 17:04:17 +01:00
Vector capt_pos, capt_scl;
Quat capt_rot;
mutable Object* last_copy;
2014-01-31 08:23:00 +13:00
2019-01-18 17:04:17 +01:00
Transform prev_tform;
Transform captured_tform, tween_tform;
2014-01-31 08:23:00 +13:00
mutable Transform render_tform;
2019-01-18 17:04:17 +01:00
mutable bool render_tform_valid;
2014-01-31 08:23:00 +13:00
Animation anim;
2019-01-18 17:04:17 +01:00
Animator* animator;
2014-01-31 08:23:00 +13:00
void updateSounds();
};