DirectX9 平面
来源:互联网 发布:网络虚拟物品交易平台 编辑:程序博客网 时间:2024/04/27 18:23
D3DXPLANE
The D3DX library uses the followingstructure for a plane:
typedef struct D3DXPLANE
{
#ifdef __cplusplus
public:
D3DXPLANE() {}
D3DXPLANE( CONST FLOAT* );
D3DXPLANE( CONST D3DXFLOAT16* );
D3DXPLANE( FLOAT a, FLOAT b, FLOAT c,FLOAT d );
// casting
operator FLOAT* ();
operator CONST FLOAT* () const;
// unary operators
D3DXPLANE operator + () const;
D3DXPLANE operator - () const;
// binary operators
BOOL operator == ( CONST D3DXPLANE& )const;
BOOL operator != ( CONST D3DXPLANE& )const;
#endif //__cplusplus
FLOAT a, b, c, d;
} D3DXPLANE, *LPD3DXPLANE;
This next D3DX functionevaluatesn n·p+dfor a particularplane and point:
FLOAT D3DXPlaneDotCoord(
CONST D3DXPLANE *pP, // plane.
CONST D3DXVECTOR3 *pV // point.
);
// Test the locality of a point relativeto a plane.
D3DXPLANE p(0.0f, 1.0f, 0.0f, 0.0f);
D3DXVECTOR3 v(3.0f, 5.0f, 2.0f);
float x = D3DXPlaneDotCoord( &p,&v );
if( x approximately equals 0.0f ) // v iscoplanar to the plane.
if(x>0) //visinpositive half-space.
if(x<0) //visinnegative half-space.
The D3DX library provides the followingfunction to perform thisD3DXPlaneFromPointNormalcalculation:
D3DXPLANE *D3DXPlaneFromPointNormal(
D3DXPLANE* pOut, // Result.
CONST D3DXVECTOR3* pPoint, // Point onthe plane.
CONST D3DXVECTOR3* pNormal // The normalof the plane.
);
The D3DX library provides the followingfunction to compute a plane, giventhree points on the plane:
D3DXPLANE *D3DXPlaneFromPoints(
D3DXPLANE* pOut, // Result.
CONST D3DXVECTOR3* pV1, // Point 1 on theplane.
CONST D3DXVECTOR3* pV2, // Point 2 on theplane.
CONST D3DXVECTOR3* pV3 // Point 3 on theplane.
);
We can use the following D3DX functionto normalize a plane’s normal vector:
D3DXPLANE *D3DXPlaneNormalize(
D3DXPLANE *pOut, // Resulting normalizedplane.
CONST D3DXPLANE *pP // Input plane.
);
we can transform a plane(n,d) by treating it as a 4D vector and multiplying it bythe inverse-transpose ofthe desired transformation matrix. Note that the plane’s normal vector must benormalized
first.We use the followingD3DX function to do this:
D3DXPLANE *D3DXPlaneTransform(
D3DXPLANE *pOut, // Result
CONST D3DXPLANE *pP, // Input plane.
CONST D3DXMATRIX *pM // Transformationmatrix.
);
Sample code:
D3DXMATRIX T(...); // Init. T to adesired transformation.
D3DXMATRIX inverseOfT;
D3DXMATRIX inverseTransposeOfT;
D3DXMatrixInverse( &inverseOfT, 0,&T );
D3DXMatrixTranspose(&inverseTransposeOfT, &inverseOfT );
D3DXPLANE p(...); // Init. Plane.
D3DXPlaneNormalize( &p, &p ); //make sure normal is normalized.
D3DXPlaneTransform( &p, &p,&inverseTransposeOfT );
- DirectX9 平面
- DirectX9.0常用平面函数
- 平面
- DirectX9 例程
- DirectX9 数学知识
- cegui + directX9
- DirectX9初步
- DirectX9 向量
- DirectX9 矩阵
- DirectX9 表面
- DirectX9 索引
- DirectX9 投影
- DirectX9带来的麻烦
- 代码的对比directx9
- 深入Managed DirectX9(一)
- DirectX9.0 入门手册
- DirectX9.0 入门手册
- 配置Directx9开发环境
- DirectX9 矩阵
- windows文件搜索软件之everything
- Nginx负载均衡
- 驱动的两种编译方法
- 【读书笔记】机器学习实战-决策树(2)
- DirectX9 平面
- 解决ScrollView嵌套ViewPager,导致ViewPager不能滑动的问题
- java bean
- Spring框架 Controller传递二维数组 到jsp的 js中
- Oracle的几个概念:数据库名,全局数据库名,SID,实例,命名空间,schema
- leetcode 日经贴,Cpp code -Longest Substring Without Repeating Characters
- 黑蚂蚁怎么吃补肾
- android开发之ToggleButton控件
- CSU 1513 Kick the ball!