3D 图形转换(3D Transformation)
来源:互联网 发布:音乐消原唱软件 编辑:程序博客网 时间:2024/04/26 10:28
1. 移动
图形学中,有以下几种空间概念: object space, world space, view space, projection space, 和 screen space
通常物品显示出来,需要经如下变换
旋转: 如下分别表示沿X,Y,Z 旋转
缩放变换:sx, sy, sz分别表示沿X,Y,Z的缩放因子
切换变换 Shearing
D3D 实现 思路
1.定义世界矩阵(world transformation):
D3DXMATRIX matWorld;D3DXMatrixRotationY( &matWorld, timeGetTime()/150.0f );g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
2.定义视图矩阵(View Transformation):
D3DXVECTOR3 vEyePt ( 0.0f, 3.0f,-5.0f ); // 定义 eye pointD3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f ); // look-at pointD3DXVECTOR3 vUpVec ( 0.0f, 1.0f, 0.0f ); // “up” directionD3DXMATRIXA16 matView; D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec ); // 计算view Matrixg_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
3. 定义投影矩阵(Projection Transformation): 把3D 物品投影到2D 屏幕
D3DXMATRIX matProj;D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f ); // 建立 projection Matrix, 1/4 pi 定义视野角度,后面的1,100 定义视锥远近g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
在D3D 中可以使用 XMMatrixRotationY(t) 表示绕自身Y轴旋转
以原点为中心,4 为半径,圆周运动
// 2nd Cube: Rotate around originXMMATRIX mSpin = XMMatrixRotationZ( -t );XMMATRIX mOrbit = XMMatrixRotationY( -t * 2.0f );XMMATRIX mTranslate = XMMatrixTranslation( -4.0f, 0.0f, 0.0f );XMMATRIX mScale = XMMatrixScaling( 0.3f, 0.3f, 0.3f );matWorld2 = mScale * mSpin * mTranslate * mOrbit;
// Update variables for the second cube //ConstantBuffer cb2;cb2.mWorld = XMMatrixTranspose(matWorld2 );cb2.mView = XMMatrixTranspose( matView );cb2.mProjection = XMMatrixTranspose( matProj );g_pImmediateContext->UpdateSubresource( g_pConstantBuffer, 0, NULL, &cb2, 0, 0 );//// Render the second cube//g_pImmediateContext->DrawIndexed( 36, 0, 0 );
0 0
- 3D 图形转换(3D Transformation)
- 3D Transformation 3D物体位移函数
- 3D图形基本知识
- 3D图形接口
- 3D图形
- DirectX 3D图形
- 3D图形
- Triangulation求解3D坐标-直接线性转换(Direct Linear Transformation-DLT)算法
- 安卓中绘制2D、3D图形
- CSS3 2D转换&3D转换
- CSS3 2D转换 3D转换
- SVG表现3D图形
- Java 3D图形API
- 3D图形渲染管线
- 优化3D图形流水线
- 真正的3D图形
- 3d图形转xaml
- 3D图形渲染管线
- android控件之Menu
- [LeetCode-205] Isomorphic Strings(同构字符串)
- 小案例:取成绩的前三名1
- dom4J的使用事例
- 【大话GSM】MS计算寻呼信道、寻呼子信道以及确定在何时监听
- 3D 图形转换(3D Transformation)
- Android系统常用隐藏命令大全
- 对视图的认识
- 关于初学网页制作的心得
- 四件在我步入职业软件开发生涯那天起就该知道的事情
- Python特殊语法:filter、map、reduce、lambda
- jquery ajax参数详解
- NoClassDefFoundError 集合
- Android 语音合成(使用科大讯飞sdk)