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


C++ D3DXMatrixPerspectiveFovLH函数代码示例

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


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

示例1: D3DXVECTOR3

Camera::Camera(HWND g_hWnd, GraphicsEngineParams params)
{
	this->forceBoundries = false;
	this->g_hWnd = g_hWnd;
	this->params = params;
	this->pos = D3DXVECTOR3(0, 0, 0);
	this->terrain = NULL;
	this->followTarget = NULL;
	this->moveOnlyInXZ = false;
	this->angleX = 0;
	this->angleY = 0;
	
	this->speed = 1.0f;
	this->sensitivity = 1.0f;

	this->updateCamera = true;
	this->activeWindowDisabling = true;

	D3DXMatrixPerspectiveFovLH(&this->projection, (float)D3DX_PI * this->params.FOV, this->params.windowWidth / (float)this->params.windowHeight, this->params.NearClip, this->params.FarClip);
}
开发者ID:Edaenge,项目名称:NDYGFX,代码行数:20,代码来源:Camera.cpp

示例2: 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

示例3: 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

示例4: 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

示例5: D3DXMatrixPerspectiveFovLH

BOOL jcd3d::jcd3d_setProjectionPerspectiveTransform(LPDIRECT3DDEVICE9 lpd3dd, INT windowWidth, INT windowHeight)
{
	if(lpd3dd == NULL)
	{
		return NULL;
	}
	else
	{
		D3DXMATRIX out;
		D3DXMatrixPerspectiveFovLH(&out, D3DX_PI * 0.5f, (FLOAT)windowWidth / (FLOAT)windowHeight, 1.0f, 1000.0f);
		if(FAILED(lpd3dd->SetTransform(D3DTS_PROJECTION, &out)))
		{
			return FALSE;
		}
		else
		{
			return TRUE;
		}
	}
}
开发者ID:chengkehan,项目名称:lab,代码行数:20,代码来源:jcd3d.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: 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

示例8: SetupProjectiveTransform

void SetupProjectiveTransform(D3DXVECTOR3 &From, D3DXVECTOR3 &To, float HotSpotA)
{
 D3DXMATRIX V, InvV;
 D3DXMATRIX matTexScale;
 D3DXMATRIX m_matTex2;
 D3DXMATRIX m_matLightProj, m_matLightView;

 D3DXVECTOR3 vUp;
 vUp.x = 0;
 vUp.y = 1;
 vUp.z = 0;

 // Set the light projection matrix.

 D3DXMatrixPerspectiveFovLH( &m_matLightProj, R3D_DEG2RAD(HotSpotA), 1.33f, r3dRenderer->NearClip, r3dRenderer->FarClip ); //1.0f, 20000.0f);

    
 // Set the light view matrix.
 D3DXMatrixLookAtLH( &m_matLightView, &From, &To, &vUp);

 // This will scale and offset -1 to 1 range of x, y
 // coords output by projection matrix to 0-1 texture
 // coord range.
    ZeroMemory( &matTexScale, sizeof( D3DMATRIX ) );
    matTexScale._11 = 0.5f;
    matTexScale._22 = 0.5f;
    matTexScale._33 = 0.0f; 
    matTexScale._41 = 0.5f; 
    matTexScale._42 = 0.5f;
    matTexScale._43 = 0.5f; 
    matTexScale._44 = 1.0f;


    D3DXMATRIX mat, mat2;
    D3DXMatrixMultiply( &mat, &m_matLightProj, &matTexScale );
    D3DXMatrixMultiply( &mat2, &m_matLightView, &mat ); 

  D3DXMatrixTranspose( &mat2, &mat2 );

  r3dRenderer->pd3ddev->SetVertexShaderConstantF(  20, (float *)&mat2,  4 );
}
开发者ID:Mateuus,项目名称:warbrasil,代码行数:41,代码来源:r3dLight.cpp

示例9: D3DXVECTOR3

//-----------------------------------------------------------------------------
// Name: RestoreDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::RestoreDeviceObjects()
{
    m_pFont->RestoreDeviceObjects();

    // Setup render state
    m_pd3dDevice->SetRenderState( D3DRS_LIGHTING,     TRUE );
    m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
    m_pd3dDevice->SetRenderState( D3DRS_ZENABLE,      TRUE );
    m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
    m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );

    // Setup the light
    D3DLIGHT8 light;
    light.Type         = D3DLIGHT_DIRECTIONAL;
    light.Diffuse.r    = light.Diffuse.g  = light.Diffuse.b  = 1.0f;
    light.Specular.r   = light.Specular.g = light.Specular.b = 0.0f;
    light.Ambient.r    = light.Ambient.g  = light.Ambient.b  = 0.3f;
    light.Position     = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
    D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &D3DXVECTOR3( 0.3f, -1.0f, 1.0f ) );
    light.Attenuation0 = light.Attenuation1 = light.Attenuation2 = 0.0f;
    light.Range        = sqrtf(FLT_MAX);
    m_pd3dDevice->SetLight(0, &light );
    m_pd3dDevice->LightEnable(0, TRUE );

    m_ArcBall.SetWindow( m_d3dsdBackBuffer.Width, m_d3dsdBackBuffer.Height, 0.85f );
    m_ArcBall.SetRadius( m_fObjectRadius );

    FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;

    D3DXMATRIX matProj;
    D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, m_fObjectRadius/64.0f,
                                m_fObjectRadius*200.0f);
    m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );

    // update the local copies of the meshes
    UpdateLocalMeshes(&m_MeshAttrSorted);
    UpdateLocalMeshes(&m_MeshStripReordered);
    UpdateLocalMeshes(&m_MeshVertexCacheOptimized);

    return S_OK;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:45,代码来源:optimizedmesh.cpp

示例10: 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

示例11: 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

示例12: SetViewAndProjMatrix

void SetViewAndProjMatrix()
{
	D3DXVECTOR3 vEyePt(0.0f,10.0f,-10.0f);
	D3DXVECTOR3 vLookatPt(0.0f,0.0f,0.0f);
	D3DXVECTOR3 vUpVec(0.0f,1.0f,0.0f);
	D3DXMATRIXA16 matView;
	D3DXMatrixLookAtLH(&matView,&vEyePt,&vLookatPt,&vUpVec);
	d3d.GetD3DDevice()->SetTransform(D3DTS_VIEW,&matView);

	D3DXMATRIXA16 matProj;
	D3DXMatrixPerspectiveFovLH(&matProj,D3DX_PI/4,1.0f,1.0f,100.0f);
	d3d.GetD3DDevice()->SetTransform(D3DTS_PROJECTION,&matProj);

	//设置纹理过虑
	//d3d.GetD3DDevice()->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);
	//d3d.GetD3DDevice()->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
	//各项异性
	//d3d.GetD3DDevice()->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_ANISOTROPIC);
	//d3d.GetD3DDevice()->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_ANISOTROPIC);
	//d3d.GetD3DDevice()->SetSamplerState(0,D3DSAMP_MAXANISOTROPY,8);
}
开发者ID:virtualhu,项目名称:MMEngine,代码行数:21,代码来源:MMEngine.cpp

示例13: D3DXMatrixLookAtLH

void DrawScence::SetViewProjectionMatrix()
{
	D3DXMATRIX matView;
	D3DXMatrixLookAtLH(&matView,
					   &m_Camera.g_vPos,
					   &m_Camera.g_vViewAt,
					   &m_Camera.g_vUp);
	m_pD3DDevice->SetTransform(D3DTS_VIEW,&matView);

	CRect rect;
	GetWindowRect(m_hWnd,&rect);

	D3DXMATRIX matProj;
	D3DXMatrixPerspectiveFovLH(&matProj,
							   D3DX_PI * 0.5,
							   1.0f * rect.Width() / rect.Height(),
							   1.0f,
							   10000.0f);
	m_pD3DDevice->SetTransform(D3DTS_PROJECTION,&matProj);

}
开发者ID:ly772696417,项目名称:UIDesigner,代码行数:21,代码来源:DrawScence.cpp

示例14: SetupMatrix

void SetupMatrix()
{
	// translate model to origin
	D3DXMATRIX world ;
	D3DXMatrixTranslation(&world, 0.0f, 0.0f, 0.0f) ;
	g_pd3dDevice->SetTransform(D3DTS_WORLD, &world) ;

	// set view
	D3DXVECTOR3 upVec(0.0f, 1.0f, 0.0f) ;
	D3DXVECTOR3 lookCenter(0.0f, 0.0f, 0.0f) ;
	D3DXVECTOR3 eyePt(0.0f, 0.0f, -20.0f) ;

	D3DXMATRIX view ;
	D3DXMatrixLookAtLH(&view, &eyePt, &lookCenter, &upVec) ;
	g_pd3dDevice->SetTransform(D3DTS_VIEW, &view) ;

	// set projection
	D3DXMATRIX proj ;
	D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 4, 1.0f, 1.0f, 1000.0f) ;
	g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &proj) ;
}
开发者ID:BillyKim,项目名称:directxcode,代码行数:21,代码来源:PointSprites.cpp

示例15: SetupMatrices

//-----------------------------------------------------------------------------
// Desc: 设置变换矩阵
//-----------------------------------------------------------------------------
VOID SetupMatrices()
{
	//创建并设置世界矩阵
	D3DXMATRIXA16 matWorld;
	D3DXMatrixIdentity(&matWorld);
	D3DXMatrixRotationY(&matWorld, timeGetTime() / 2000.0f);
	g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld);

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

	//创建并设置投影矩阵
	D3DXMATRIXA16 matProj;
	D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI / 2, 1.0f, 0.0f, 100.0f);
	g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj);
}
开发者ID:kristyfuwa,项目名称:TwiLight,代码行数:24,代码来源:D3D9_RenderToTexture.cpp


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