eqemu

diff src/bvol.h @ 4:3d3656360a82

rendering properly, added picking, almost done...
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 17 Jul 2014 08:51:17 +0300
parents
children 2656099aff12
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/bvol.h	Thu Jul 17 08:51:17 2014 +0300
     1.3 @@ -0,0 +1,36 @@
     1.4 +#ifndef BVOL_H_
     1.5 +#define BVOL_H_
     1.6 +
     1.7 +#include "vmath.h"
     1.8 +
     1.9 +struct HitPoint {
    1.10 +	float t;
    1.11 +	Vector3 pos;
    1.12 +};
    1.13 +
    1.14 +class BVolume {
    1.15 +public:
    1.16 +	virtual ~BVolume() {}
    1.17 +
    1.18 +	virtual bool intersect(const Ray &ray, HitPoint *hit) const = 0;
    1.19 +};
    1.20 +
    1.21 +class BSphere : public BVolume {
    1.22 +private:
    1.23 +	Vector3 center;
    1.24 +	float radius;
    1.25 +
    1.26 +public:
    1.27 +	BSphere();
    1.28 +	explicit BSphere(const Vector3 &c, float rad = 1.0);
    1.29 +
    1.30 +	void set_center(const Vector3 &center);
    1.31 +	const Vector3 &get_center() const;
    1.32 +
    1.33 +	void set_radius(float rad);
    1.34 +	float get_radius() const;
    1.35 +
    1.36 +	bool intersect(const Ray &ray, HitPoint *hit) const;
    1.37 +};
    1.38 +
    1.39 +#endif	// BVOL_H_