因为用到了Ogre的Vector3,所以首先需要配置Ogre的环境,在这里不再赘述。
下面这是AABB头文件: aabb.h
#ifndef AABB3_H
#define AABB3_H
#include "OgreOde_Core.h"
#include "OgreOde_Prefab.h"
#include "OgreOde_Loader.h"
class cAABB3
{
public:
Ogre::Vector3 min,max;
public:
//query for dimentions
Ogre::Vector3 size() const {return max - min;}
Ogre::Real x_size() {return max.x - min.x;}
Ogre::Real y_size() {return max.y - min.y;}
Ogre::Real z_size() {return max.z - min.z;}
Ogre::Vector3 center() const {return (min + max)*0.5f;}
//返回8个顶点中的一个
Ogre::Vector3 corner(int i) const;
//清空包围盒
void empty();
//add a point to the box
void add(const Ogre::Vector3 &p);
//add an AABB to the box
void add(const cAABB3 &box);
//return true if the box is empty
bool is_empty() const;
//return true if the box contains a point
bool contains(const Ogre::Vector3 &p) const;
//return the closte