vrshoot

diff src/object.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/object.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,56 @@
     1.4 +#ifndef OBJECT_H_
     1.5 +#define OBJECT_H_
     1.6 +
     1.7 +#include <list>
     1.8 +#include "xform_node.h"
     1.9 +#include "mesh.h"
    1.10 +#include "material.h"
    1.11 +
    1.12 +enum DrawMode {
    1.13 +	DRAW_DEFAULT,
    1.14 +	DRAW_WIREFRAME,
    1.15 +	DRAW_VERTICES
    1.16 +};
    1.17 +
    1.18 +
    1.19 +class Object : public XFormNode {
    1.20 +private:
    1.21 +	Mesh *mesh;	///< no ownership, just keeping the pointer around
    1.22 +	static DrawMode draw_mode;
    1.23 +
    1.24 +	bool setup_bones(long msec) const;
    1.25 +
    1.26 +public:
    1.27 +	Material material;
    1.28 +
    1.29 +	Object();
    1.30 +
    1.31 +	/// destroy this object and all the hierarchy of objects hanging below it
    1.32 +	void destroy_all();
    1.33 +
    1.34 +	void set_mesh(Mesh *m);
    1.35 +	Mesh *get_mesh();
    1.36 +	const Mesh *get_mesh() const;
    1.37 +
    1.38 +	/// get all the meshes of the subtree rooted in this object @{
    1.39 +	std::list<Mesh*> get_all_meshes();
    1.40 +	std::list<const Mesh*> get_all_meshes() const;
    1.41 +	/// @}
    1.42 +
    1.43 +	/// counts the polygons of the mesh of this object and all it's descendants
    1.44 +	long count_polys() const;
    1.45 +
    1.46 +	AABox get_aabbox() const;
    1.47 +	Sphere get_bsphere() const;
    1.48 +
    1.49 +	void apply_xform(long msec = 0);
    1.50 +
    1.51 +	void draw(long msec = 0) const;
    1.52 +
    1.53 +	bool intersect(const Ray &ray, HitPoint *hit = 0) const;
    1.54 +
    1.55 +	/// this is mostly for tools, to allow drawing only the wireframe or vertices
    1.56 +	static DrawMode set_draw_mode(DrawMode mode);
    1.57 +};
    1.58 +
    1.59 +#endif	// OBJECT_H_