DirectX下 Viewing Frustum 的详细实现
-w' < x' < w'
#define __FrustumH__
{
public:
~Frustum();
void CalculateFrustum( D3DXMATRIX ViewMatrix, D3DXMATRIX ProjectMatrix );
bool PointInFrustum( D3DXVECTOR3 Point );
// This holds the A B C and D values for each side of our frustum.
D3DXPLANE FrustumPlane[6];
};
#include <D3dx9math.h>
enum FrustumSide { RIGHT, LEFT, BOTTOM, TOP, FRONT, BACK };
Frustum::Frustum()
{
}
{
}
/
/ This extracts our frustum from the projection and view matrix.
/
/ CALCULATE FRUSTUM \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
{
D3DXMATRIX ComboMatrix;
D3DXMatrixMultiply( &ComboMatrix, &ViewMatrix, &ProjectMatrix );
FrustumPlane[RIGHT].a = ComboMatrix._14 - ComboMatrix._11;
FrustumPlane[RIGHT].b = ComboMatrix._24 - ComboMatrix._21;
FrustumPlane[RIGHT].c = ComboMatrix._34 - ComboMatrix._31;
FrustumPlane[RIGHT].d = ComboMatrix._44 - ComboMatrix._41;
//normalize
D3DXPlaneNormalize( &FrustumPlane[RIGHT], &FrustumPlane[RIGHT] );
FrustumPlane[LEFT].a = ComboMatrix._14 + ComboMatrix._11;
FrustumPlane[LEFT].b = ComboMatrix._24 + ComboMatrix._21;
FrustumPlane[LEFT].c = ComboMatrix._34 + ComboMatrix._31;
FrustumPlane[LEFT].d = ComboMatrix._44 + ComboMatrix._41;
D3DXPlaneNormalize( &FrustumPlane[LEFT], &FrustumPlane[LEFT] );
FrustumPlane[BOTTOM].a = ComboMatrix._14 + ComboMatrix._12;
FrustumPlane[BOTTOM].b = ComboMatrix._24 + ComboMatrix._22;
FrustumPlane[BOTTOM].c = ComboMatrix._34 + ComboMatrix._32;
FrustumPlane[BOTTOM].d = ComboMatrix._44 + ComboMatrix._42;
D3DXPlaneNormalize( &FrustumPlane[BOTTOM], &FrustumPlane[BOTTOM] );
FrustumPlane[TOP].a = ComboMatrix._14 - ComboMatrix._12;
FrustumPlane[TOP].b = ComboMatrix._24 - ComboMatrix._22;
FrustumPlane[TOP].c = ComboMatrix._34 - ComboMatrix._32;
FrustumPlane[TOP].d = ComboMatrix._44 - ComboMatrix._42;
D3DXPlaneNormalize( &FrustumPlane[TOP], &FrustumPlane[TOP] );
FrustumPlane[FRONT].a = ComboMatrix._14 + ComboMatrix._13;
FrustumPlane[FRONT].b = ComboMatrix._24 + ComboMatrix._23;
FrustumPlane[FRONT].c = ComboMatrix._34 + ComboMatrix._33;
FrustumPlane[FRONT].d = ComboMatrix._44 + ComboMatrix._43;
D3DXPlaneNormalize( &FrustumPlane[FRONT], &FrustumPlane[FRONT] );
FrustumPlane[BACK].a = ComboMatrix._14 - ComboMatrix._13;
FrustumPlane[BACK].b = ComboMatrix._24 - ComboMatrix._23;
FrustumPlane[BACK].c = ComboMatrix._34 - ComboMatrix._33;
FrustumPlane[BACK].d = ComboMatrix._44 - ComboMatrix._43;
D3DXPlaneNormalize( &FrustumPlane[BACK], &FrustumPlane[BACK] );
}
/ POINT IN FRUSTUM \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
/
/ This determines if a point is inside of the frustum
/
/ POINT IN FRUSTUM \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*
{
for( int i = 0; i < 6; i++ )
{
float x = D3DXPlaneDotCoord( &FrustumPlane[i], & Point );
if( x < 0 )
return false;
}
// The point was inside of the frustum (In front of ALL the sides of the frustum)
return true;
}
转载于:https://blog.51cto.com/xiaoxiang/26928
DirectX下 Viewing Frustum 的详细实现相关推荐
- linux系统退出当前计算节点命令,Linux下60个系统命令详细解.doc
Linux下60个系统命令详细解 嵌入式学习指引--Linux下60个系统命令详细解 Linux为用户提供了大量的命令,利用它可以有效地完成大量的工作,如磁盘操作.文件存取.目录操作.进程管理.文件权 ...
- Win10 Anaconda下TensorFlow-GPU环境搭建详细教程(包含CUDA+cuDNN安装过程)(转载)...
win7(win10也适用)系统安装GPU/CPU版tensorflow Win10 Anaconda下TensorFlow-GPU环境搭建详细教程(包含CUDA+cuDNN安装过程) 目录 2.配置 ...
- linux下安装DB2的详细步骤
我也是才学习,在网上找了一个在linux下安装DB2 的步骤,共享给大家看看了. linux下安装DB2的详细步骤! 第一步:检查程序包及其版本 在软件包管理中查看下列软件包是否安装,如没有安装,先安 ...
- svn安装教程 mysql_CentOS6.4 下安装SVN的详细教程(超详细)
1.检查系统是否已经安装如果安装就卸载 rpm -qa subversion yum remove subversion 2.安装 yum install subversion 3.建立SVN库 mk ...
- iis服务器部署项目,IIS环境下部署项目的详细教程
分享IIS环境下部署项目的详细教程 1.环境部署 1.1安装IIS7 进入控制面板,选择"程序和功能",进入如下页面后 找到World Wide Web Services,确保选中 ...
- mysql8.018安装教程_mysql8.0.18下安装winx64的详细教程(图文详解)
到网站 下载mysql数据库 解压后进入目录 d:\program files\mysql-8.0.18 创建my.ini文件 [mysql] # 设置mysql客户端默认字符集 default-ch ...
- linux操作系统adsl 上网设置,Linux操作系统下ADSL拨号上网详细步骤 -电脑资料
本指南将帮助你在Ubuntu 6.06 LTS (Dapper Drake)下用PPPoE以太网modem建立ADSL网络连接, 1. 简介 虽然用路由器联网很常见,我们有时也需要用PPPoE直接连接 ...
- 【Linux】CentOS7下安装Ngnix代理服务器详细过程 附Linux 64位 Ngnix压缩包百度云盘分享
[Linux]CentOS7下安装Ngnix代理服务器详细过程 附Linux 64位 Ngnix压缩包百度云盘分享 Ngnix基本概况 Nginx (读作"engine X") 由 ...
- Linux下卸载nginx的详细步骤,亲测有效
1.检查nginx服务是否运行,如果正在运行则关闭服务. ps -ef|grep nginx /usr/local/nginx/sbin/nginx -s stop 2.查找并删除nginx相关文件. ...
最新文章
- Linux驱动程序编写
- 最短路径问题-Dijkstra算法的python实现
- 组合测试法是什么 软件测试,组合测试法中的全对偶测试法
- JDK源码分析-TreeMap(1)
- 在新的固态硬盘只装ubuntu16.04系统,重启后无启动项解决方案
- C++:51---继承中的构造函数、析构函数、拷贝控制一系列规则
- 敏捷开发中asp.net MVC的开发次序感受(先开发View?先开发Model?先开发Controller!)...
- Redis - 在电商购物车场景下的实战分析
- Mac小技巧:在mac上怎么把png转换成jpg
- 链表例题2:链表的倒数第k个节点是多少
- 如何使用FireBug插件查询元素的xPath属性
- 风物长宜放眼量,人间正道是沧桑 - 一位北美 IT 技术人破局
- cat 常用的日志分析架构方案_深度剖析|数据库生产常用架构方案
- 鸿蒙无锡有什么特产,无锡太湖鼋头渚十大特产
- 测试相机的软件叫什么,测年龄的app叫什么(测年龄的相机软件app)
- 8个精挑细选的适用App,全是黑科技,用起来超爽
- Spring Boot 注解原理
- 一个强化学习 Q-learning 算法的简明教程
- 为listview、或者recyclerView的item增加进场动画
- AWS S3 and Glacier
热门文章
- 动态调用有关的方法?
- 从AppStore提取ipa
- tinyxml 内存泄露_有关TinyXML使用的简单总结
- numa节点_漫步云端NUMA调度
- EEGNet: 神经网络应用于脑电信号
- 想体验从活火山上滑下来的刺激感?VR来成全你
- AI创业公司最佳「开发工具」指南火了,还发现了个可挑战Jupyter的「杀手」
- 让电影动漫统统变丝滑,480帧也毫无卡顿,交大博士生开源插帧软件DAIN
- 姚班学霸蝉联第一,清华再霸榜,湘潭大学表现亮眼,第四届 CCF CCSP落下帷幕...
- 官方资源帖!手把手教你在TensorFlow 2.0中实现CycleGAN,推特上百赞