資源簡介
設計了一種基于GPU編程實現的大規模地形場景的實時繪制與漫游算法。利用GPU端完成地形網格更新、地形塊的自動選取、高度圖和紋理圖采樣等大部分計算工作,大大減輕了CPU端的計算負載。
代碼片段和文件信息
#include?“camera.h“
Camera::Camera()
{
_cameraType?=?AIRCRAFT;
_pos???=?XMVectorSet(0.0f?0.0f?0.0f0.0f);
_right?=?XMVectorSet(1.0f?0.0f?0.0f0.0f);
_up????=?XMVectorSet(0.0f?1.0f?0.0f0.0f);
_look??=?XMVectorSet(0.0f?0.0f?1.0f0.0f);
}
Camera::Camera(CameraType?cameraType)
{
_cameraType?=?cameraType;
_pos???=?XMVectorSet(0.0f?1.0f?-5.0f?0.0f);
_right?=?XMVectorSet(1.0f?0.0f?0.0f0.0f);
_up????=?XMVectorSet(0.0f?1.0f?0.0f0.0f);
_look??=?XMVectorSet(1.0f?0.0f?1.0f0.0f);
}
Camera::~Camera()
{
}
void?Camera::getPosition(XMVECTOR*?pos)
{
*pos?=?_pos;
}
void?Camera::setPosition(XMVECTOR*?pos)
{
_pos?=?*pos;
}
void?Camera::getRight(XMVECTOR*?right)
{
*right?=?_right;
}
void?Camera::getUp(XMVECTOR*?up)
{
*up?=?_up;
}
void?Camera::getLook(XMVECTOR*?look)
{
*look?=?_look;
}
void?Camera::walk(float?units)
{
//?move?only?on?xz?plane?for?land?object
if(?_cameraType?==?LANDobject?)
{
//_pos?+=?XMVECTOR(_look.x?0.0f?_look.z)?*?units;
float?newX?=XMVectorGetX(_pos)?+?XMVectorGetX(_look)*units;
float?newY?=XMVectorGetY(_pos);
float?newZ?=XMVectorGetZ(_pos)?+?XMVectorGetZ(_look)*units;
float?newW?=XMVectorGetW(_pos);
_pos?=?XMVectorSet(newXnewYnewZnewW);
}
//if(?_cameraType?==?AIRCRAFT?)
// _pos?+=?_look?*?units;
}
void?Camera::strafe(float?units)
{
//?move?only?on?xz?plane?for?land?object
if(?_cameraType?==?LANDobject?)
{
//_pos?+=?XMVECTOR(_right.x?0.0f?_right.z)?*?units;
float?newX?=XMVectorGetX(_pos)?+?XMVectorGetX(_right)*units;
float?newY?=XMVectorGetY(_pos);
float?newZ?=XMVectorGetZ(_pos)?+?XMVectorGetZ(_right)*units;
float?newW?=XMVectorGetW(_pos);
_pos?=?XMVectorSet(newXnewYnewZnewW);
}
//if(?_cameraType?==?AIRCRAFT?)
// _pos?+=?_right?*?units;
}
void?Camera::fly(float?units)
{
//?move?only?on?y-axis?for?land?object
if(?_cameraType?==?LANDobject?)
{
//_pos.y?+=?units;
float?newX?=XMVectorGetX(_pos);
float?newY?=XMVectorGetY(_pos)?+?units;
float?newZ?=XMVectorGetZ(_pos);
float?newW?=XMVectorGetW(_pos);
_pos?=?XMVectorSet(newXnewYnewZnewW);
}
//if(?_cameraType?==?AIRCRAFT?)
// _pos?+=?_up?*?units;
}
void?Camera::pitch(float?angle)
{
//D3DXMATRIX?T;
//D3DXMatrixRotationAxis(&T?&_right angle);
XMMATRIX?T;
T?=?XMMatrixRotationAxis(_right?angle);
//?rotate?_up?and?_look?around?_right?vector
//D3DXVec3TransformCoord(&_up&_up?&T);
//D3DXVec3TransformCoord(&_look&_look?&T);
_up?=?XMVector3TransformCoord(_upT);
_look?=?XMVector3TransformCoord(_lookT);
}
void?Camera::yaw(float?angle)
{
XMMATRIX?T;
//?rotate?around?world?y?(0?1?0)?always?for?land?object
if(?_cameraType?==?LANDobject?)
//D3DXMatrixRotationY(&T?angle);
T?=?XMMatrixRotationY(angle);
//?rotate?around?own?up?vector?for?aircraft
//if(?_cameraType?==?AIRCRAFT?)
// D3DXMatrixRotationAxis(&T?&_up?angle);
//?rotate?_righ
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????4889??2011-01-13?23:04??Large?scale?terrain?rendering?using?D3D11\camera.cpp
?????文件?????????914??2010-12-15?21:32??Large?scale?terrain?rendering?using?D3D11\camera.h
?????文件????????5648??2010-12-23?16:02??Large?scale?terrain?rendering?using?D3D11\createMesh.cpp
?????文件?????????457??2010-12-23?16:01??Large?scale?terrain?rendering?using?D3D11\createMesh.h
?????目錄???????????0??2012-05-06?22:01??Large?scale?terrain?rendering?using?D3D11\DXUT\
?????目錄???????????0??2012-05-06?22:01??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\
?????文件?????????335??2010-05-14?08:48??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\dpiaware.manifest
?????文件??????267270??2010-05-25?05:05??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUT.cpp
?????文件???????18629??2010-05-25?05:05??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUT.h
?????文件????????1605??2010-06-02?19:32??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUT_2008.sln
?????文件???????11011??2010-06-02?19:32??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUT_2008.vcproj
?????文件????????1606??2010-06-02?19:32??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUT_2010.sln
?????文件???????17695??2010-06-02?19:32??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUT_2010.vcxproj
?????文件?????????877??2010-06-02?19:32??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUT_2010.vcxproj.filters
?????文件???????45123??2010-05-25?05:05??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUTDevice11.cpp
?????文件????????8723??2010-05-14?08:48??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUTDevice11.h
?????文件???????44136??2010-05-14?08:48??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUTDevice9.cpp
?????文件????????9375??2010-05-14?08:48??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUTDevice9.h
?????文件???????68571??2010-05-25?05:05??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUTmisc.cpp
?????文件???????25349??2010-05-25?05:05??Large?scale?terrain?rendering?using?D3D11\DXUT\Core\DXUTmisc.h
?????目錄???????????0??2012-05-06?22:01??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\
?????文件???????25214??2010-05-14?08:48??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\directx.ico
?????文件???????57189??2010-05-25?05:05??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\DXUTcamera.cpp
?????文件???????20173??2010-05-14?08:48??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\DXUTcamera.h
?????文件??????242618??2010-05-27?15:59??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\DXUTgui.cpp
?????文件???????47295??2010-05-14?08:48??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\DXUTgui.h
?????文件???????37245??2010-05-14?08:48??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\DXUTguiIME.cpp
?????文件????????5886??2010-05-19?01:52??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\DXUTguiIME.h
?????文件????????9763??2010-05-14?08:48??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\DXUTLockFreePipe.h
?????文件????????1611??2010-06-02?19:32??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\DXUTOpt_2008.sln
?????文件???????11645??2010-06-02?19:32??Large?scale?terrain?rendering?using?D3D11\DXUT\Optional\DXUTOpt_2008.vcproj
............此處省略83個文件信息
評論
共有 條評論