要建立起视图空间,我们需要一个视图矩阵,产生视图矩阵的一个函数是:
D3DXMATRIX *D3DXMatrixLookAtLH(
    D3DXMATRIX* pOut,
    CONST D3DXVECTOR3* pEye, 
    CONST D3DXVECTOR3* pAt,
    CONST D3DXVECTOR3* pUp 
);
pOut:返回的视图矩阵指针
pEye:设置摄像机的位置
pAt:设置摄像机的观察点
pUp:设置方向“上”
请问摄像机的位置和摄像机的观察点有什么区别?
还有pUp这个方向有什么作用?
我是初学者

解决方案 »

  1.   

    请问摄像机的位置和摄像机的观察点有什么区别?
    还有pUp这个方向有什么作用?
    我是初学者摄像机位置是相机在世界坐标系中的坐标,观察点是你观察的物体在世界坐标系中的坐标。这两点连线成为视角坐标系中的一个轴,再指定一个pUp,它是视角坐标系的另一个轴,这样用左手定则就可以确定第三个轴,整个视角坐标系就建立起来了。如果没有pUp,光有一个轴是无法确定视角坐标系的。
      

  2.   

    应该是Z轴,pUp或它的一个分量是Y轴,用左手定则导出的第三个轴是X轴
      

  3.   

    m_fCamXPos = f;//相机坐标
    m_fCamYPos = f;
    m_fCamZPos = f;
    m_fXCenter = 0.0f;//物体坐标
    m_fYCenter = 0.0f;
    m_fZCenter = 0.0f;    // Set the transform matrices
        D3DXVECTOR3 vEyePt    = D3DXVECTOR3( m_fCamXPos, m_fCamYPos, m_fCamZPos );
        D3DXVECTOR3 vLookatPt = D3DXVECTOR3( m_fXCenter, m_fYCenter, m_fZCenter );
        D3DXVECTOR3 vUpVec    = D3DXVECTOR3( 0.0f, 1.0f,  0.0f );//默认以Y轴为"向上"
            D3DXMatrixIdentity( &m_matWorld );
        D3DXMatrixLookAtLH( &m_matView, &vEyePt, &vLookatPt, &vUpVec );
        FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
        D3DXMatrixPerspectiveFovLH( &m_matProj, D3DX_PI/2, fAspect, 1.0f, 1000.0f );
    谁能帮我改下上面代码.我想在显示器上垂直从上往下看到我的物体(物体建立在世界坐标系的原点)
      

  4.   

    m_fCamXPos = f;//相机坐标
    m_fCamYPos = f;
    m_fCamZPos = f;
    m_fXCenter = 0.0f;//物体坐标
    m_fYCenter = 0.0f;
    m_fZCenter = 0.0f;    // Set the transform matrices
        D3DXVECTOR3 vEyePt    = D3DXVECTOR3( 0.0f, 5.0f,0.0f);
        D3DXVECTOR3 vLookatPt = D3DXVECTOR3( m_fXCenter, m_fYCenter, m_fZCenter );
        D3DXVECTOR3 vUpVec    = D3DXVECTOR3( 0.0f, 0.0f,  1.0f );//默认以Y轴为"向上"    D3DXMatrixIdentity( &m_matWorld );
        D3DXMatrixLookAtLH( &m_matView, &vEyePt, &vLookatPt, &vUpVec );
        FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
        D3DXMatrixPerspectiveFovLH( &m_matProj, D3DX_PI/2, fAspect, 1.0f, 1000.0f );
      

  5.   

    The view transformation locates the viewer in world space, transforming vertices into camera space. In camera space, the camera, or viewer, is at the origin, looking in the positive z-direction. Recall that Direct3D uses a left-handed coordinate system, so z is positive into a scene. The view matrix relocates the objects in the world around a camera's position—the origin of camera space—and orientation.
      

  6.   

    The view matrix relocates the objects in the world around a camera's position—the origin of camera space—and orientation.请问 The view matrix 是如何relocates the objects in the world around a camera's position.我想清楚地知道如何建 camera space的坐标系.