当前位置: 首页>>代码示例>>C++>>正文


C++ D3DXMatrixLookAtLH函数代码示例

本文整理汇总了C++中D3DXMatrixLookAtLH函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DXMatrixLookAtLH函数的具体用法?C++ D3DXMatrixLookAtLH怎么用?C++ D3DXMatrixLookAtLH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了D3DXMatrixLookAtLH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: D3DXMatrixRotationX

void Camera::Update()
{
	D3DXMATRIXA16 matRotationX, matRotationY;
	D3DXMATRIXA16 matRotation;
	D3DXMatrixRotationX(&matRotationX, camRotX);
	D3DXMatrixRotationY(&matRotationY, camRotY);
	matRotation = matRotationX * matRotationY;

	eyePosition = D3DXVECTOR3(0, 0, -camDistance);
	D3DXVec3TransformCoord(&eyePosition, &eyePosition, &matRotation);
	if ( lookTarget )
	{
		lookAt = (*lookTarget);
		eyePosition = (*lookTarget) + eyePosition;
	}
	
	D3DXMatrixLookAtLH(&matView, &eyePosition, &lookAt, &upVector);
	GameManager::GetDevice()->SetTransform(D3DTS_VIEW, &matView);

}
开发者ID:SGA160108305C,项目名称:20160212_1_FVF_TEXTURE,代码行数:20,代码来源:Camera.cpp

示例2: InitMatrix

/**-----------------------------------------------------------------------------
 * 행렬 설정
 *------------------------------------------------------------------------------
 */
void InitMatrix()
{
	/// 월드 행렬 설정
	D3DXMatrixIdentity( &g_matWorld );
    g_pd3dDevice->SetTransform( D3DTS_WORLD, &g_matWorld );

    /// 뷰 행렬을 설정
    D3DXVECTOR3 vEyePt( 100.0f, 100.0f, -130.0f );
    D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
    D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
    D3DXMatrixLookAtLH( &g_matView, &vEyePt, &vLookatPt, &vUpVec );
    g_pd3dDevice->SetTransform( D3DTS_VIEW, &g_matView );

    /// 프로젝션 행렬 설정
    D3DXMatrixPerspectiveFovLH( &g_matProj, D3DX_PI/4, 1.0f, 1.0f, 1000.0f );
    g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &g_matProj );

	/// 카메라 초기화
	g_pCamera->SetView( &vEyePt, &vLookatPt, &vUpVec );
}
开发者ID:blastingzone,项目名称:ComputerGraphicsAdvenced,代码行数:24,代码来源:main.cpp

示例3: assert

// Sets up the view of the scene based on passed in eye and target
void CD3DObj::setViewMatrix(const CPos &eye, const CPos &lookAt)
{
	assert(mEffect != NULL);

	D3DXMATRIXA16 matrix;
	D3DXVECTOR3 up(0.0f, 1.0f, 0.0f); // World's up vector

	// Create the view matrix
	// **NOTE** We can cast to (D3DXVECTOR3*) because our CPos has it's data members (x,y,z)
	// declared the same way a D3DXVECTOR3 does
	D3DXMatrixLookAtLH(&matrix, (D3DXVECTOR3*)(&eye), (D3DXVECTOR3*)(&lookAt), &up);
	
	// Set the view matrix for fixed function pipeline
	mResult = mDevice->SetTransform(D3DTS_VIEW, &matrix);
	assert(mResult == D3D_OK);
	
	// Set the view matrix for shader
	mResult = mEffect->SetMatrix("gViewMat", &matrix);
	assert(mResult == D3D_OK);
}
开发者ID:88er,项目名称:tutorials,代码行数:21,代码来源:d3d_obj.cpp

示例4: Render

void Render()
{
	float angle = timeGetTime() % 10000 * 1.f / 10000 * 2 * D3DX_PI ;
	int r = 3;
	D3DXVECTOR3 pos(cos(angle) * r, 0.f, sin(angle) * r);
	D3DXVECTOR3 target(0.f, 0.f, 0.f);
	D3DXVECTOR3 up(0.f, 1.f, 0.f);
	D3DXMATRIX matrixView;
	D3DXMatrixLookAtLH(&matrixView, &pos, &target, &up);
	pDevice->SetTransform(D3DTS_VIEW, &matrixView);

	pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 220, 0, 255), 1.0f, 0);
	pDevice->SetStreamSource(0, VB, 0, sizeof(Vertex));	//4 将顶点缓存与数据流进行链接,
	pDevice->SetFVF(Vertex::FVF);						//5 设置顶点格式
			
	pDevice->BeginScene();
	pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);	//6 绘制
	pDevice->EndScene();
	pDevice->Present(NULL, NULL, NULL, NULL);
}
开发者ID:daodaodaorenjiandao,项目名称:Graphics,代码行数:20,代码来源:main.cpp

示例5: SetupMatrix

VOID SetupMatrix()
{
	// Translate so the center of the box is the coordinate system origin.
	D3DXMATRIXA16 matWorld ;
	D3DXMatrixTranslation( &matWorld, -0.5f, -0.5f, 0.5f) ;
	g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

	// Set up view matrix
	D3DXVECTOR3 vEyePt( 0.0f, 3.0f, -5.0f );		
	D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );	
	D3DXVECTOR3 vUpVec( 0.0f, 3.0f, 0.0f );	
	D3DXMATRIXA16 matView;
	D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
	g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

	// Set up perspective matrix
	D3DXMATRIXA16 matProj;
	D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 1000.0f );
	g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
}
开发者ID:Clearlove1992,项目名称:GraphicsDemos,代码行数:20,代码来源:VertexAlpha.cpp

示例6: D3DXMatrixLookAtLH

//------------------------------------------------------------------
// Storm3D_Camera::ApplyMirrored
//------------------------------------------------------------------
void Storm3D_Camera::ApplyMirrored()
{
	// Create View matrix
    D3DXMatrixLookAtLH(&mv,(D3DXVECTOR3*)&position,
		(D3DXVECTOR3*)&target,(D3DXVECTOR3*)&upvec);    
	Storm3D2->GetD3DDevice()->SetTransform(D3DTS_VIEW,&mv);

	// Calc aspect!
	Storm3D_SurfaceInfo ss=Storm3D2->GetScreenSize();
	float aspect=(float)ss.width/(float)ss.height;

	// Create Projection matrix
    D3DXMATRIX matProj;
    //D3DXMatrixPerspectiveFovLH(&matProj,fov,-aspect,1.0f,vis_range);
    D3DXMatrixPerspectiveFovLH(&matProj,fov,-aspect,znear,vis_range);
	Storm3D2->GetD3DDevice()->SetTransform(D3DTS_PROJECTION,&matProj);

	// Multiply matrices to get VP (view-projection) matrix
	vp=mv*matProj;
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:23,代码来源:Storm3D_Camera.cpp

示例7: SetMatrices

//-----------------------------------------------------------------------------
// Desc: 设置变换矩阵
//-----------------------------------------------------------------------------
VOID SetMatrices()
{
	//建立并设置世界矩阵
	D3DXMATRIX matWorld;
	D3DXMatrixIdentity( &matWorld );
	g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

	//建立并设置观察矩阵
	D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f );
	D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
	D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
	D3DXMATRIX matView;
	D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
	g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

	//建立并设置投影矩阵
	D3DXMATRIX matProj;
	D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
	g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:23,代码来源:Multilights.cpp

示例8: D3DXMatrixIdentity

void DXCamera::Init()
{
	// world
	D3DXMatrixIdentity( &_world );

	// view
	_eyeVec = D3DXVECTOR3( 0.0f, 50, -70 ); // camera position
	_lookVec = D3DXVECTOR3( 0.0f, 30.0f, 0.0f ); // look at point
	_upVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );

	D3DXMatrixLookAtLH( &_view, &_eyeVec, &_lookVec, &_upVec );

	// projection
	D3DXMatrixPerspectiveFovLH( &_proj, FOV, 1.0f, NEAR_PLANE, FAR_PLANE );

	// transform camera
	D3D9_DEVICE->SetTransform( D3DTS_WORLD, &_world );
	D3D9_DEVICE->SetTransform( D3DTS_VIEW, &_view );
	D3D9_DEVICE->SetTransform( D3DTS_PROJECTION, &_proj );
}
开发者ID:popoory67,项目名称:NinetailEngine,代码行数:20,代码来源:DXCamera.cpp

示例9: setCameraMatrix

void setCameraMatrix(IDirect3DDevice9 * device)
{
	D3DXMATRIX cameraMatrix;
	D3DXMatrixRotationYawPitchRoll(&cameraMatrix, cameraYaw, 0, 0);
	D3DXVECTOR3 transTemp;
	D3DXVec3TransformCoord(&transTemp, &move, &cameraMatrix);
	cameraPos += transTemp;

	D3DXMatrixRotationYawPitchRoll(&cameraMatrix, cameraYaw, cameraPitch, cameraRoll);

	D3DXVec3TransformCoord(&cameraTarget, &D3DXVECTOR3(0, 0, -1), &cameraMatrix);
	D3DXVec3TransformCoord(&cameraUpVector, &D3DXVECTOR3(0, 1, 0), &cameraMatrix);

	D3DXVECTOR3 targetTemp = cameraTarget + cameraPos;

	D3DXMatrixLookAtLH(&cameraMatrix, &cameraPos, &targetTemp, &cameraUpVector);
	device->SetTransform(D3DTS_VIEW, &cameraMatrix);

	move = D3DXVECTOR3(0, 0, 0);
}
开发者ID:GROWrepo,项目名称:GameTeam_Study_Direct3D9,代码行数:20,代码来源:Main.cpp

示例10: D3DXVec3Cross

    void Camera::lookAt(const D3DXVECTOR3& eye, const D3DXVECTOR3& at, const D3DXVECTOR3& up)
    {
        D3DXVECTOR3 axisUp = up;
        D3DXVECTOR3 axisTo = (at-eye);
        //check if up and  at - eye is perpendicular. If not, make them.
        if( D3DXVec3Dot(&axisUp,&axisTo) != 0)
        {
            D3DXVECTOR3 temp;
            D3DXVec3Cross(&temp, &axisUp, &axisTo);
            D3DXVec3Cross(&axisUp, &axisTo, &temp);
        }
        D3DXVec3Normalize(&axisUp, &axisUp);
        D3DXVec3Normalize(&axisTo, &axisTo);

        D3DXMatrixIdentity(&m_viewMatrix);
        D3DXMatrixLookAtLH(&m_viewMatrix,&eye,&at,&axisUp);

        //calculate transforms
        m_translation = -eye;
        D3DXVECTOR3 ref = D3DXVECTOR3(0,0,1);
        D3DXVECTOR3 rotAxis;
        D3DXVec3Cross(&rotAxis,&axisTo,&ref);
        D3DXVec3Normalize(&rotAxis, &rotAxis);
        float angle;
        

        angle = acos(D3DXVec3Dot( &ref, &axisTo ))*0.5f;

        m_orientation = D3DXQUATERNION(sin(angle)*rotAxis.x, sin(angle)*rotAxis.y, sin(angle)*rotAxis.z, cos(angle));

        //check if up vector is still "up"
        
        D3DXVECTOR3 rotatedUp = MathUtil::rotateVec3ByQuat(&axisUp, &m_orientation);
        if(D3DXVec3Dot(&rotatedUp,&up)<0)
        {
            m_orientation = D3DXQUATERNION(axisTo.x*sin(MathUtil::PI*0.5f),axisTo.y*sin(MathUtil::PI*0.5f), axisTo.z*sin(MathUtil::PI*0.5f), cos(MathUtil::PI*0.5f)) * m_orientation;
        }


        m_viewCacheValid = true;
    }
开发者ID:Manaluusua,项目名称:Dx11Sandbox,代码行数:41,代码来源:Camera.cpp

示例11: D3DXMatrixRotationYawPitchRoll

//////////////////////////////////////////////////////////////////////////////////////////
//			Mise a jour																	//
//////////////////////////////////////////////////////////////////////////////////////////
void CCamera::Update()
{
	D3DXVECTOR3 up, position, lookAt;
	float yaw, pitch, roll;
	D3DXMATRIX rotationMatrix;

	// Defini l'axe qui symbolise la verticalite, Y
	up.x = 0.0f;
	up.y = 1.0f;
	up.z = 0.0f;

	// Position de la cam
	position.x = m_positionX;
	position.y = m_positionY;
	position.z = m_positionZ;

	// Endroit ou la cam regarde
	lookAt.x = 0.0f;
	lookAt.y = 0.0f;
	lookAt.z = 1.0f;

	// Yaw (Y axis), pitch (X axis), et roll (Z axis) en radians
	pitch = m_rotationX * 0.0174532925f;
	yaw   = m_rotationY * 0.0174532925f;
	roll  = m_rotationZ * 0.0174532925f;

	// Cree la matrice de rotation pour les yaw/pitch/roll
	D3DXMatrixRotationYawPitchRoll(&rotationMatrix, yaw, pitch, roll);

	// Transferme les vecteurs lookAt et Up via la matrice de rotation pour que l'angle de vue soit correcte
	D3DXVec3TransformCoord(&lookAt, &lookAt, &rotationMatrix);
	D3DXVec3TransformCoord(&up, &up, &rotationMatrix);

	// Relativise la direction de vue par rapport a la position de la cam
	lookAt = position + lookAt;

	// Cree la matrice a partir des trois vecteurs
	D3DXMatrixLookAtLH(&m_viewMatrix, &position, &lookAt, &up);

	return;
}
开发者ID:SeraphXIV,项目名称:Engine,代码行数:44,代码来源:Camera.cpp

示例12: D3DXMatrixRotationYawPitchRoll

void CameraClass::Render()
{
	D3DXVECTOR3 up, position, lookAt;
	float yaw, pitch, roll;
	D3DXMATRIX rotationMatrix;

	// Setup the vector that points upwards.
	up.x = 0.0f;
	up.y = 1.0f;
	up.z = 0.0f;

	// Setup the position of the camera in the world.
	position.x = m_positionX;
	position.y = m_positionY;
	position.z = m_positionZ;

	// Setup where the camera is looking by default.
	lookAt.x = 0.0f;
	lookAt.y = 0.0f;
	lookAt.z = 1.0f;

	// Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians.
	pitch = m_rotationX * 0.0174532925f;
	yaw   = m_rotationY * 0.0174532925f;
	roll  = m_rotationZ * 0.0174532925f;

	// Create the rotation matrix from the yaw, pitch, and roll values.
	D3DXMatrixRotationYawPitchRoll(&rotationMatrix, yaw, pitch, roll);

	// Transform the lookAt and up vector by the rotation matrix so the view is correctly rotated at the origin.
	D3DXVec3TransformCoord(&lookAt, &lookAt, &rotationMatrix);
	D3DXVec3TransformCoord(&up, &up, &rotationMatrix);

	// Translate the rotated camera position to the location of the viewer.
	lookAt = position + lookAt;

	// Finally create the view matrix from the three updated vectors.
	D3DXMatrixLookAtLH(&m_viewMatrix, &position, &lookAt, &up);

	return;
}
开发者ID:tesla21,项目名称:CUDA2DFluid,代码行数:41,代码来源:cameraclass.cpp

示例13: D3DM_INIT

void c_Camera::UpdateCameraNormal(void)
{
	//位置情報マトリックス生成
	D3DXMATRIX matrix;
	D3DM_INIT(matrix);
	D3DXMatrixTranslation(&matrix,m_vRecPos.x,m_vRecPos.y,m_vRecPos.z);
	
	//現在マトリックスからのズレを計算
	D3DXVec3TransformCoord(&m_vCameraIdentity,&m_vRangeFromRecPos,&matrix);
	
	//目標までのVec3生成
	D3DXVECTOR3 vLook;
	if(m_pmTargetMatrix)
	D3DXVec3TransformCoord(&vLook,&m_vRangeFromTarget,m_pmTargetMatrix);
	else
	D3DXVec3TransformCoord(&vLook,&m_vRangeFromTarget,&matrix);
	//vUp生成
	D3DXVECTOR3 vUP;
	D3DXVec3TransformCoord(&vUP,&D3DXVECTOR3(0.0f,1.0f,0.0f),&matrix);

	//最終合算
	D3DXMatrixLookAtLH(&m_matView,&m_vCameraIdentity,&vLook,&vUP);
	//D3DXVec3TransformCoord(&m_vRecPos,
	//	&D3DXVECTOR3(0.0f,150.0f,-300.0f),
	//	&GetModelMatrix());

	//D3DXVECTOR3 vLook;
	//D3DXVec3TransformCoord(&vLook,
	//	&D3DXVECTOR3(0.0f,100.0f,0.0f),
	//	&GetModelMatrix());

	//D3DXVECTOR3 vUP;
	//D3DXVec3TransformNormal(&vUP,
	//	&D3DXVECTOR3(0.0f,1.0f,0.0f),
	//	&GetModelMatrix());

	//D3DXMatrixLookAtLH(&m_matView,
	//	&m_vRecPos,&vLook,&vUP);
	//D3DM_INIT(m_matView);
	//D3DXMatrixTranslation(&m_matView,m_vRecPos.x,m_vRecPos.y,m_vRecPos.z);
}
开发者ID:lovelyapple,项目名称:DirectX_3D_Project,代码行数:41,代码来源:Sys_C_Camera.cpp

示例14: SetupMatrix

VOID SetupMatrix()
{
	// Translate so the center of the box is the coordinate system origin.
	D3DXMATRIXA16 matTrans ;
	D3DXMatrixTranslation( &matTrans, -0.5f, -0.5f, 0.5f) ;

	// rotation by time elapsed
	D3DXMATRIXA16 matRol ;
	UINT  iTime  = timeGetTime() % 1000;
	FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 1000.0f;


	if( g_rotAxis == 4 )	// rotate by x-axis.
		D3DXMatrixRotationX( &matRol, fAngle );

	else if( g_rotAxis == 2 ) // rotate by y-axis.
		D3DXMatrixRotationY( &matRol, fAngle );

	else if( g_rotAxis == 1 ) // rotate by z-axis.
		D3DXMatrixRotationZ( &matRol, fAngle );

	else
		D3DXMatrixIdentity( &matRol ) ; // hold on

	D3DXMATRIXA16 matWorld = matTrans * matRol ;
	g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

	// Set up view matrix
	D3DXVECTOR3 vEyePt( 0.0f, 3.0f, -5.0f );		
	D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );	
	D3DXVECTOR3 vUpVec( 0.0f, 3.0f, 0.0f );	
	D3DXMATRIXA16 matView;
	D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
	g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

	// Set up perspective matrix
	D3DXMATRIXA16 matProj;
	D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 1000.0f );
	g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );

}
开发者ID:BillyKim,项目名称:directxcode,代码行数:41,代码来源:Vertex_alpha_Texture_color.cpp

示例15: D3DCOLOR_XRGB

void DX9Renderer::Draw()
{
	m_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0);
	
	m_pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
	
	if (SUCCEEDED(m_pD3DDevice->BeginScene()))
	{
		D3DXMATRIX matWorld, matView, matProj;
		
		D3DXMatrixIdentity(&matWorld);
		
		D3DXVECTOR3 vEyePt( 0.0f, 0.0f, -5.0f );
		D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
		D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
		D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );

		float aspectRatio = ((float)800) / ((float)600);
		D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, aspectRatio, 1.0f, 100.0f );

		m_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld);
		m_pD3DDevice->SetTransform(D3DTS_VIEW, &matView);
		m_pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj);

		RenderableObjectListPtr list = this->GetRenderableObjectList();
		for (unsigned int i = 0; i < list->RenderableObjectNum(); i++)
		{
			DX9RenderableObject* obj = reinterpret_cast<DX9RenderableObject*>(list->GetRenderableObject(i).get());
			m_pD3DDevice->SetFVF(obj->GetFVF());

			m_pD3DDevice->SetStreamSource(0, (DX9::VertexBuffer)obj->GetVertexBuffer(), 0, obj->GetVertexSize());
			m_pD3DDevice->SetIndices((DX9::IndexBuffer)obj->GetIndexBuffer());
			m_pD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, obj->GetVertexNum(), 0, obj->GetIndexNum());
		}

		m_pD3DDevice->EndScene();
	}

	m_pD3DDevice->Present(NULL, NULL, NULL, NULL);
}
开发者ID:JianchengZh,项目名称:kasicass,代码行数:41,代码来源:K1RDX9Renderer.cpp


注:本文中的D3DXMatrixLookAtLH函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。