AABB包围盒算法

因为用到了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
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值