Subversion Repositories gelsvn

Rev

Rev 324 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 324 Rev 393
1
#ifndef __BOUNDINGNODE_H
1
#ifndef __BOUNDINGNODE_H
2
#define __BOUNDINGNODE_H
2
#define __BOUNDINGNODE_H
3
 
3
 
4
#include <vector>
4
#include <vector>
5
#include "CGLA/Vec3f.h"
5
#include "CGLA/Vec3f.h"
6
#include "Ray.h"
6
#include "Ray.h"
7
#include "Triangle.h"
7
#include "Triangle.h"
8
#include "AABox.h"
8
#include "AABox.h"
9
#include "OBox.h"
9
#include "OBox.h"
10
 
10
 
11
namespace Geometry
11
namespace Geometry
12
{
12
{
13
 
13
 
14
/// Abstract BOUNDINGNODE node.
14
/// Abstract BOUNDINGNODE node.
15
template<class BoxType>
15
template<class BoxType>
16
class BoundingNode: public BoxType
16
class BoundingNode: public BoxType
17
{
17
{
18
 public:
18
 public:
19
	
19
	
20
	BoundingNode(const BoxType& box): BoxType(box) {}
20
	BoundingNode(const BoxType& box): BoxType(box) {}
21
	virtual ~BoundingNode() {}
21
	virtual ~BoundingNode() {}
22
 
22
 
23
	/// Count number of intersections from a point in a given direction
23
	/// Count number of intersections from a point in a given direction
24
	virtual int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const=0;
24
	virtual int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const=0;
25
 
25
 
26
	/// Find the surface intersection point
26
	/// Find the surface intersection point
27
	virtual bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const=0;
27
	virtual bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const=0;
28
 
28
 
29
	virtual void intersect(Ray& r) const = 0;
29
	virtual void intersect(Ray& r) const = 0;
30
 
30
 
31
	/** For a given point, return the min and max square distance and the
31
	/** For a given point, return the min and max square distance and the
32
			sign. Non-leafs return zero for the sign. Leaves
32
			sign. Non-leafs return zero for the sign. Leaves
33
			return the square of the true distance as both min and max. */
33
			return the square of the true distance as both min and max. */
34
	virtual void sq_distance(const CGLA::Vec3f&, float&, float&, float&) const;
34
	virtual void sq_distance(const CGLA::Vec3f&, float&, float&, float&) const;
35
	
35
	
36
	static BoundingNode* build(std::vector<Triangle>& triangles);
36
	static BoundingNode* build(std::vector<Triangle>& triangles);
37
};
37
};
38
 
38
 
39
}
39
}
40
#endif
40
#endif
41
 
41