• 大小: 54.71MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2022-05-22
  • 语言: C/C++
  • 标签: directx11  

资源简介

directx11的官方C++例程

资源截图

代码片段和文件信息

//***************************************************************************************
// Camera.h by Frank Luna (C) 2011 All Rights Reserved.
//***************************************************************************************

#include “Camera.h“

Camera::Camera()
: mPosition(0.0f 0.0f 0.0f) 
  mRight(1.0f 0.0f 0.0f)
  mUp(0.0f 1.0f 0.0f)
  mLook(0.0f 0.0f 1.0f)
{
SetLens(0.25f*MathHelper::Pi 1.0f 1.0f 1000.0f);
}

Camera::~Camera()
{
}

XMVECTOR Camera::GetPositionXM()const
{
return xmloadFloat3(&mPosition);
}

XMFLOAT3 Camera::GetPosition()const
{
return mPosition;
}

void Camera::SetPosition(float x float y float z)
{
mPosition = XMFLOAT3(x y z);
}

void Camera::SetPosition(const XMFLOAT3& v)
{
mPosition = v;
}

XMVECTOR Camera::GetRightXM()const
{
return xmloadFloat3(&mRight);
}

XMFLOAT3 Camera::GetRight()const
{
return mRight;
}

XMVECTOR Camera::GetUpXM()const
{
return xmloadFloat3(&mUp);
}

XMFLOAT3 Camera::GetUp()const
{
return mUp;
}

XMVECTOR Camera::GetLookXM()const
{
return xmloadFloat3(&mLook);
}

XMFLOAT3 Camera::GetLook()const
{
return mLook;
}

float Camera::GetNearZ()const
{
return mNearZ;
}

float Camera::GetFarZ()const
{
return mFarZ;
}

float Camera::GetAspect()const
{
return mAspect;
}

float Camera::GetFovY()const
{
return mFovY;
}

float Camera::GetFovX()const
{
float halfWidth = 0.5f*GetNearWindowWidth();
return 2.0f*atan(halfWidth / mNearZ);
}

float Camera::GetNearWindowWidth()const
{
return mAspect * mNearWindowHeight;
}

float Camera::GetNearWindowHeight()const
{
return mNearWindowHeight;
}

float Camera::GetFarWindowWidth()const
{
return mAspect * mFarWindowHeight;
}

float Camera::GetFarWindowHeight()const
{
return mFarWindowHeight;
}

void Camera::SetLens(float fovY float aspect float zn float zf)
{
// cache properties
mFovY = fovY;
mAspect = aspect;
mNearZ = zn;
mFarZ = zf;

mNearWindowHeight = 2.0f * mNearZ * tanf( 0.5f*mFovY );
mFarWindowHeight  = 2.0f * mFarZ * tanf( 0.5f*mFovY );

XMMATRIX P = XMMatrixPerspectiveFovLH(mFovY mAspect mNearZ mFarZ);
XMStoreFloat4x4(&mProj P);
}

void Camera::LookAt(FXMVECTOR pos FXMVECTOR target FXMVECTOR worldUp)
{
XMVECTOR L = XMVector3Normalize(XMVectorSubtract(target pos));
XMVECTOR R = XMVector3Normalize(XMVector3Cross(worldUp L));
XMVECTOR U = XMVector3Cross(L R);

XMStoreFloat3(&mPosition pos);
XMStoreFloat3(&mLook L);
XMStoreFloat3(&mRight R);
XMStoreFloat3(&mUp U);
}

void Camera::LookAt(const XMFLOAT3& pos const XMFLOAT3& target const XMFLOAT3& up)
{
XMVECTOR P = xmloadFloat3(&pos);
XMVECTOR T = xmloadFloat3(&target);
XMVECTOR U = xmloadFloat3(&up);

LookAt(P T U);
}

XMMATRIX Camera::View()const
{
return xmloadFloat4x4(&mView);
}

XMMATRIX Camera::Proj()const
{
return xmloadFloat4x4(&mProj);
}

XMMATRIX Camera::ViewProj()const
{
return XMMatrixMultiply(View() Proj());
}

void Camera::Strafe(float d)
{
// mPosition += d*mRight
XMVECTOR s = XMVectorReplicate(d);
XMVECTOR r

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    .......       213  2016-11-17 05:38  directx11-pratices-master\.gitignore

    .......      5058  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\Camera.cpp

    .......      2431  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\Camera.h

     文件      12999  2017-02-28 10:49  directx11-pratices-master\Common_vs2015\d3dApp.cpp

    .......      2141  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\d3dApp.h

    .......      2835  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\d3dUtil.cpp

     文件       4764  2017-02-28 10:54  directx11-pratices-master\Common_vs2015\d3dUtil.h

    .......     54214  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\d3dx11effect.h

    .......     61034  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\DDSTextureLoader.cpp

    .......      5063  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\DDSTextureLoader.h

    .......    200401  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\dxerr.cpp

    .......      3144  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\dxerr.h

    .......      3257  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\GameTimer.cpp

    .......       757  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\GameTimer.h

    .......     18097  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\GeometryGenerator.cpp

    .......      3237  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\GeometryGenerator.h

    .......       272  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\LightHelper.cpp

    .......      1847  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\LightHelper.h

    .......      2300  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\MathHelper.cpp

    .......      1779  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\MathHelper.h

     文件       1276  2017-02-28 10:47  directx11-pratices-master\Common_vs2015\TextureMgr.cpp

    .......       653  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\TextureMgr.h

    .......      4717  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\Waves.cpp

    .......      1669  2016-11-17 05:38  directx11-pratices-master\Common_vs2015\Waves.h

    .......      5384  2016-11-17 05:38  directx11-pratices-master\dx9-src\Appendix A Code\Hello World\hello.cpp

    .......     31823  2016-11-17 05:38  directx11-pratices-master\dx9-src\Part II Code\Chapter 1\D3D9 Init\chap1_0.jpg

    .......      2148  2016-11-17 05:38  directx11-pratices-master\dx9-src\Part II Code\Chapter 1\D3D9 Init\d3dInit.cpp

    .......      4197  2016-11-17 05:38  directx11-pratices-master\dx9-src\Part II Code\Chapter 1\D3D9 Init\d3dUtility.cpp

    .......      1263  2016-11-17 05:38  directx11-pratices-master\dx9-src\Part II Code\Chapter 1\D3D9 Init\d3dUtility.h

    .......        35  2016-11-17 05:38  directx11-pratices-master\dx9-src\Part II Code\Chapter 2\no samples for chap2.txt

............此处省略562个文件信息

评论

共有 条评论