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


C++ D3DXMatrixInverse函数代码示例

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


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

示例1: D3DXMatrixIdentity

bool CFrustum::setFrustum(const D3DXMATRIXA16& pmatViewProj )
{
	D3DXMATRIXA16	matInv;
	D3DXMatrixIdentity( &matInv );
	// 투영행렬까지 거치면 모든 3차원 월드좌표의 점은 (-1,-1,0) ~ (1,1,1)사이의 값으로 바뀐다.
	// m_vtx에 이 동차공간의 경계값을 넣어둔다.
	m_vtx[0].x = -1.0f;	m_vtx[0].y = -1.0f;	m_vtx[0].z = 0.0f;
	m_vtx[1].x =  1.0f;	m_vtx[1].y = -1.0f;	m_vtx[1].z = 0.0f;
	m_vtx[2].x =  1.0f;	m_vtx[2].y = -1.0f;	m_vtx[2].z = 1.0f;
	m_vtx[3].x = -1.0f;	m_vtx[3].y = -1.0f;	m_vtx[3].z = 1.0f;
	m_vtx[4].x = -1.0f;	m_vtx[4].y =  1.0f;	m_vtx[4].z = 0.0f;
	m_vtx[5].x =  1.0f;	m_vtx[5].y =  1.0f;	m_vtx[5].z = 0.0f;
	m_vtx[6].x =  1.0f;	m_vtx[6].y =  1.0f;	m_vtx[6].z = 1.0f;
	m_vtx[7].x = -1.0f;	m_vtx[7].y =  1.0f;	m_vtx[7].z = 1.0f;

	// view * proj의 역행렬을 구한다.
	D3DXMatrixInverse(&matInv, NULL, &pmatViewProj );

	// Vertex_최종 = Vertex_local * Matrix_world * Matrix_view * Matrix_Proj 인데,
	// Vertex_world = Vertex_local * Matrix_world이므로,
	// Vertex_최종 = Vertex_world * Matrix_view * Matrix_Proj 이다.
	// Vertex_최종 = Vertex_world * ( Matrix_view * Matrix_Proj ) 에서
	// 역행렬( Matrix_view * Matrix_Proj )^-1를 양변에 곱하면
	// Vertex_최종 * 역행렬( Matrix_view * Matrix_Proj )^-1 = Vertex_World 가 된다.
	// 그러므로, m_vtx * matInv = Vertex_world가 되어, 월드좌표계의 프러스텀 좌표를 얻을 수 있다.
	for( int i = 0; i < 8; i++ )
		D3DXVec3TransformCoord( &m_vtx[i], &m_vtx[i], &matInv );

	// 0번과 5번은 프러스텀중 near평면의 좌측상단과 우측하단이므로, 둘의 좌표를 더해서 2로 나누면
	// 카메라의 좌표를 얻을 수 있다.(정확히 일치하는 것은 아니다.)
	m_vPos = ( m_vtx[0] + m_vtx[5] ) / 2.0f;
	
	// 얻어진 월드좌표로 프러스텀 평면을 만든다
	// 벡터가 프러스텀 안쪽에서 바깥쪽으로 나가는 평면들이다.
	D3DXPlaneFromPoints(&m_plane[0], m_vtx+4, m_vtx+7, m_vtx+6);	// 상 평면(top)
	D3DXPlaneFromPoints(&m_plane[1], m_vtx  , m_vtx+1, m_vtx+2);	// 하 평면(bottom)
	D3DXPlaneFromPoints(&m_plane[2], m_vtx  , m_vtx+4, m_vtx+5);	// 근 평면(near)
	D3DXPlaneFromPoints(&m_plane[3], m_vtx+2, m_vtx+6, m_vtx+7);	// 원 평면(far)
	D3DXPlaneFromPoints(&m_plane[4], m_vtx  , m_vtx+3, m_vtx+7);	// 좌 평면(left)
	D3DXPlaneFromPoints(&m_plane[5], m_vtx+1, m_vtx+5, m_vtx+6);	// 우 평면(right)

	return TRUE;
}
开发者ID:qiomoip,项目名称:space-express,代码行数:43,代码来源:Frustum.cpp

示例2: switch

//
// WndProc
//
LRESULT CALLBACK d3d::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch( msg )
	{
	case WM_DESTROY:
		::PostQuitMessage(0);
		break;
		
	case WM_KEYDOWN:
		if( wParam == VK_ESCAPE )
			::DestroyWindow(hwnd);

		break;
	case WM_LBUTTONDOWN:

		// compute the ray in view space given the clicked screen point
		d3d::Ray ray = CalcPickingRay(LOWORD(lParam), HIWORD(lParam));

		// transform the ray to world space
		D3DXMATRIX view ;
		static D3DXMATRIX lastView;
		Device->GetTransform(D3DTS_VIEW, &view);
		if (view!= lastView)
		{
			OutputDebugString("!=\n");
		}


		lastView = view;

		D3DXMATRIX viewInverse;
		D3DXMatrixInverse(&viewInverse,	0, &view);

		TransformRay(&ray, &viewInverse);

		// test for a hit
		if( RaySphereIntTest(&ray, &BSphere) )
			::MessageBox(0, "Hit!", "HIT", 0);

		break;
	}
	return ::DefWindowProc(hwnd, msg, wParam, lParam);
}
开发者ID:as2120,项目名称:ZNginx,代码行数:46,代码来源:pickSample.cpp

示例3: D3DXMatrixInverse

	Ray PickVisitor::PickInvMatrix(
		Ray ray, 
		D3DXMATRIX a_Matrix)
	{
		// Get the inverse view matrix

		D3DXMATRIX matrix;
		D3DXMatrixInverse( &matrix, NULL, &a_Matrix );

		Ray result;
		// Transform the pick ray (normaly WorldView) into object space
		D3DXVec4Transform(&result.orig, &ray.orig, &matrix);
		D3DXVec4Transform(&result.dir, &ray.dir, &matrix);

		//TODO: test ray with and without normalize
		D3DXVec3Normalize((D3DXVECTOR3*)&result.dir, (D3DXVECTOR3*)&result.dir);
		result.dir.w=0.0;
		return result;
	}
开发者ID:TheWhiteAmbit,项目名称:TheWhiteAmbit,代码行数:19,代码来源:PickVisitor.cpp

示例4: D3DXMatrixInverse

	void mouseUtil::calcRayVectorOrthoRH(D3DXMATRIX matView, D3DXMATRIX matProj)
	{
		D3DXMATRIX matInvView;
		D3DVECTOR v;

		D3DXMatrixInverse( &matInvView, NULL, &matView );

		v.x =  (  ( ( ( 2.0f * ( m_nMouseX ) ) / m_nScreenWidth  ) - 1 ) - matProj._31 ) / matProj._11;
		v.y =  ( -( ( ( 2.0f * ( m_nMouseY ) ) / m_nScreenHeight ) - 1 ) - matProj._32 ) / matProj._22;
		v.z =  -1.0f;

		m_vRayPos.x	= v.x * matInvView._11 + v.y * matInvView._21 + v.z * matInvView._31;
		m_vRayPos.y	= v.x * matInvView._12 + v.y * matInvView._22 + v.z * matInvView._32;
		m_vRayPos.z	= matInvView._43;

		m_vRayDir.x = matInvView._41;
		m_vRayDir.y = matInvView._42;
		m_vRayDir.z = v.x * matInvView._13 + v.y * matInvView._23 + v.z * matInvView._33;
	}
开发者ID:dfghj44444,项目名称:XmGui,代码行数:19,代码来源:MouseUtil.cpp

示例5: assert

void SkinnedMeshNode::LinkToBone(Entity* pEntity)
{
	assert(!m_vecBoneRef.empty());
	D3DXMATRIX tmBoneWorldReferenceInv;
		
	size_t iBoneRef=0,nBoneRefSize =m_vecBoneRef.size() ;	

	for (iBoneRef=0;iBoneRef<nBoneRefSize;iBoneRef++)
	{
		BONEREFINFO& refItem=m_vecBoneRef[iBoneRef];

		refItem.pNode = pEntity->FindNode(refItem.strNodeName);	
		assert(refItem.pNode!=NULL);	
		// 찾지 못하는경우가 있어서는 안됨 블렌트 버택스에 boneIndex가 들어가있으므로		
		D3DXMatrixInverse(&tmBoneWorldReferenceInv,NULL,&refItem.pNode->GetNodeTM());
		refItem.SkinOffset = GetNodeTM() * tmBoneWorldReferenceInv;	// LocalTM = WorldTM * Parent.WorldTM.Inverse		
	}

}
开发者ID:ldw9981,项目名称:Rendering,代码行数:19,代码来源:SkinnedMeshNode.cpp

示例6: p

	//	地面との当たり判定
	bool	Collision::CheckDown( iexMesh*	org, const Vector3& pos, float& outHeight )
	{
		Vector3 p( pos.x, pos.y + 2.0f, pos.z );
		Vector3 vec( 0, -1.0f, 0 );
		Vector3 out;
		outHeight = pos.y;
		float dist = 100.0f;

		// オブジェクトの逆行列を算出
		org->Update();
		Matrix mat = org->TransMatrix;
		Matrix invMat;	// 逆行列
		D3DXMatrixInverse( &invMat, null, &mat );

		// 逆行列でレイをローカル化
		Vector3 invVec;
		invVec.x = invMat._11 * vec.x + invMat._21 * vec.y + invMat._31 * vec.z;
		invVec.y = invMat._12 * vec.x + invMat._22 * vec.y + invMat._32 * vec.z;
		invVec.z = invMat._13 * vec.x + invMat._23 * vec.y + invMat._33 * vec.z;

		Vector3 invPos;
		invPos.x = invMat._11 * p.x + invMat._21 * p.y + invMat._31 * p.z + invMat._41;
		invPos.y = invMat._12 * p.x + invMat._22 * p.y + invMat._32 * p.z + invMat._42;
		invPos.z = invMat._13 * p.x + invMat._23 * p.y + invMat._33 * p.z + invMat._43;

		if ( org->RayPick( &out, &invPos, &invVec, &dist ) >= 0 )
		{

			Vector3 resultPos;
			resultPos.x = mat._11 * out.x + mat._21 * out.y + mat._31 * out.z + mat._41;
			resultPos.y = mat._12 * out.x + mat._22 * out.y + mat._32 * out.z + mat._42;
			resultPos.z = mat._13 * out.x + mat._23 * out.y + mat._33 * out.z + mat._43;

			outHeight = resultPos.y;

			if ( pos.y < resultPos.y )
			{
				return true;
			}
		}

		return false;
	}
开发者ID:NyamLand,项目名称:WonderToyBox,代码行数:44,代码来源:Collision.cpp

示例7: HR

void XFileDemo::drawScene()
{
	HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffeeeeee, 1.0f, 0));
	HR(gd3dDevice->BeginScene());

	HR(mFX->SetValue(mhLight, &mLight, sizeof(DirLight)));
	HR(mFX->SetMatrix(mhWVP, &(mWorld*mView*mProj)));

	D3DXMATRIX worldInvTrans;
	D3DXMatrixInverse(&worldInvTrans, 0, &mWorld);
	D3DXMatrixTranspose(&worldInvTrans, &worldInvTrans);
	HR(mFX->SetMatrix(mhWorldInvTrans, &worldInvTrans));
	HR(mFX->SetMatrix(mhWorld, &mWorld));

	HR(mFX->SetTechnique(mhTech));
	UINT numPasses = 0;
	HR(mFX->Begin(&numPasses, 0));
	HR(mFX->BeginPass(0));

	for (int j = 0; j < mMtrl.size(); ++j)
	{
		HR(mFX->SetValue(mhMtrl, &mMtrl[j], sizeof(Material)));

		if (mTex[j] != 0)
		{
			HR(mFX->SetTexture(mhTex, mTex[j]));
		}
		else
		{
			HR(mFX->SetTexture(mhTex, mWhiteTex));
		}

		HR(mFX->CommitChanges());
		HR(mMesh->DrawSubset(j));
	}
	HR(mFX->EndPass());
	HR(mFX->End());

	mGfxStats->display(D3DCOLOR_XRGB(0,0,0));
	HR(gd3dDevice->EndScene());
	HR(gd3dDevice->Present(0, 0, 0, 0));
}
开发者ID:kasicass,项目名称:introdx9,代码行数:42,代码来源:XFileDemo.cpp

示例8: D3DXMatrixInverse

// 输入摄像机投影矩阵,得到6个平面
bool ZFrustum::Make(D3DXMATRIX* pmatViewProj,float fEpsilon)
{
	m_fEpsilon = fEpsilon;
	int i;
	D3DXMATRIX matInv;

	m_vtx[0].x = -1.0f; m_vtx[0].y = -1.0f; m_vtx[0].z = 0.0f;
	m_vtx[1].x =  1.0f; m_vtx[1].y = -1.0f; m_vtx[1].z = 0.0f;
	m_vtx[2].x =  1.0f; m_vtx[2].y = -1.0f; m_vtx[2].z = 1.0f;
	m_vtx[3].x = -1.0f; m_vtx[3].y = -1.0f; m_vtx[3].z = 1.0f;
	m_vtx[4].x = -1.0f; m_vtx[4].y =  1.0f; m_vtx[4].z = 0.0f;
	m_vtx[5].x =  1.0f; m_vtx[5].y =  1.0f; m_vtx[5].z = 0.0f;
	m_vtx[6].x =  1.0f; m_vtx[6].y =  1.0f; m_vtx[6].z = 1.0f;
	m_vtx[7].x = -1.0f; m_vtx[7].y =  1.0f; m_vtx[7].z = 1.0f;

	// 求得view*proj的逆矩阵
	D3DXMatrixInverse(&matInv,NULL,pmatViewProj);
	// 将8个顶点转换到世界空间
	for (i = 0;i < 8;i++)
	{
		D3DXVec3TransformCoord(&m_vtx[i],&m_vtx[i],&matInv);
		D3DXVECTOR3 v = m_vtx[i];
	}
	// 求出摄像机的大致坐标(近裁截面中心,非准确摄像机位置)
	m_vPos = (m_vtx[0] + m_vtx[5]) / 2.0f;

	// 通过8个顶点的世界坐标,制作平截台体平面,法线方向向外
	// top
	D3DXPlaneFromPoints(&m_plane[0],m_vtx + 4,m_vtx + 7,m_vtx + 6);
	// bottom
	D3DXPlaneFromPoints(&m_plane[1],m_vtx,m_vtx + 1,m_vtx + 2);
	// near
	D3DXPlaneFromPoints(&m_plane[2],m_vtx,m_vtx + 4,m_vtx + 5);
	// far
	D3DXPlaneFromPoints(&m_plane[3],m_vtx + 2,m_vtx + 6,m_vtx + 7);
	// left
	D3DXPlaneFromPoints(&m_plane[4],m_vtx,m_vtx + 3,m_vtx + 7);
	// right
	D3DXPlaneFromPoints(&m_plane[5],m_vtx + 1,m_vtx + 5,m_vtx + 6);

	return true;
}
开发者ID:ly772696417,项目名称:XianXiaLegend,代码行数:43,代码来源:ZFrustum.cpp

示例9: D3DXMatrixInverse

void PTGScene::onObjRender(HwSceneObject *sender)
{
	HwMaterial *mat = sender->getMaterial();
	HwShader *shd = mat->getPass(0)->getShader();
	HwCamera *cam = pEng->getScene()->getCamera();
	if (shd == NULL)
		return;

	if (mat->getCurrTechn() == 0)
	{
		D3DXMATRIX wvm = sender->worldMatrix() * cam->viewM();
		shd->getPass(0)->vp()->setConst("g_mWorldView", wvm);
		shd->getPass(0)->vp()->setConst("g_mProj", cam->projM());
	}
	else
	{
		D3DXMATRIX mLightView = pLCam->viewM();

		D3DXMATRIXA16 mViewToLightProj = cam->viewM();
		D3DXMatrixInverse( &mViewToLightProj, NULL, &mViewToLightProj );
		mViewToLightProj = mViewToLightProj *  mLightView * pLCam->projM();

		shd->getPass(0)->vp()->setConst("g_mViewToLightProj", mViewToLightProj);
		D3DXMATRIX wvm = sender->worldMatrix() * cam->viewM();
		shd->getPass(0)->vp()->setConst("g_mWorldView", wvm);
		shd->getPass(0)->vp()->setConst("g_mProj", cam->projM());
	
		shd->getPass(0)->pp()->setConst("g_fCosTheta", cosf(D3DX_PI / 4));
		shd->getPass(0)->pp()->setConst( "g_vLightDiffuse", D3DXVECTOR4(1, 1, 1, 1.0));
		shd->getPass(0)->pp()->setConst( "g_vMaterial", D3DXVECTOR4(1, 1, 1, 1.0));
		shd->getPass(0)->pp()->setConst( "g_vLightAmbient", D3DXVECTOR4(0.3, 0.3, 0.3, 1.0));

		D3DXVECTOR3 v = pLCam->getEye();
		D3DXVECTOR4 v4;
		D3DXVec3Transform( &v4, &v, &cam->viewM());
		shd->getPass(0)->pp()->setConst( "g_vLightPos", v4);
		v4 = D3DXVECTOR4(pLCam->getDirection(), 0);
		D3DXVec4Transform( &v4, &v4, &cam->viewM() );  // Direction in view space
		D3DXVec3Normalize( ( D3DXVECTOR3* )&v4, ( D3DXVECTOR3* )&v4 );
		shd->getPass(0)->pp()->setConst( "g_vLightDir", v4);	
	}
}
开发者ID:MrKuznetsov,项目名称:PandaTheBest,代码行数:42,代码来源:pandaTheGame.cpp

示例10: D3DXMatrixRotationX

//-----------------------------------------------------------------------------
// Name: OneTimeSceneInit
// Desc:
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::OneTimeSceneInit()
{
    HRESULT hr;

    // Initialize Water
    if(FAILED(hr = m_Water.Initialize(64.0f, WATER_DEPTH)))
        return hr;

    // Initialize Environment
    if(FAILED(hr = m_Environment.Initialize(1000.0f)))
        return hr;

    // Misc stuff
    D3DXMatrixRotationX(&m_matPosition, D3DX_PI * -0.3f);
    m_matPosition._42 = 15.0f;
    m_matPosition._43 = 15.0f;

    D3DXMatrixInverse(&m_matView, NULL, &m_matPosition);
    return S_OK;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:24,代码来源:CWaterApp.cpp

示例11: D3DXMatrixInverse

INT CLcXSkinIns::FrameMove()
{
	LPDIRECT3DDEVICE9 pDev = (LPDIRECT3DDEVICE9)LcDev_GetD3Device();

	m_dTimeCur += m_fElapse;

	// For Sort...(optional)
	D3DXMATRIX	mtViwI;

	pDev->GetTransform( D3DTS_VIEW,  &mtViwI );
	D3DXMatrixInverse(&mtViwI, NULL, &mtViwI);
	
	D3DXVECTOR3	vcCam	= D3DXVECTOR3(mtViwI._41, mtViwI._42, mtViwI._43);
	D3DXVECTOR3	vcZ		= D3DXVECTOR3(mtViwI._31, mtViwI._32, mtViwI._33);
	D3DXVECTOR3	vcTmp	= m_vcTrn - vcCam;

	m_fStlSrtR = D3DXVec3Dot(&vcZ, &vcTmp);

	return 0;
}
开发者ID:GALICSOFT,项目名称:glc220_src,代码行数:20,代码来源:LnXSkinIns.cpp

示例12: Vec2

	Vec2 Graphics::ScreenToWorldSpace(Vec2 screenPosition)
	{
		//Convert to normalized screen space 0 to 1
		screenPosition.x /= SurfaceSize.x;
		screenPosition.y /= SurfaceSize.y;

		//Convert to projected space -1 to 1
		screenPosition *= 2.0f;
		screenPosition -= Vec2(1,1);
		screenPosition.y *= -1;

		//Unproject the point by applying the inverse
		//of the ViewProjection matrix
		Mat4 inverseViewProjection;
		float det;
		D3DXMatrixInverse(&inverseViewProjection,&det,&ViewProjMatrix);
		Vec4 worldSpacePosition;
		D3DXVec2Transform(&worldSpacePosition,&screenPosition,&inverseViewProjection);
		return Vec2(worldSpacePosition.x,worldSpacePosition.y);
	}
开发者ID:WestleyArgentum,项目名称:cs260-last2,代码行数:20,代码来源:Graphics.cpp

示例13: AddTranslation

//-----------------------------------------------------------------------------
// Updates the object.
//-----------------------------------------------------------------------------
void SceneObject::Update( float elapsed, bool addVelocity )
{
	// Calculate the friction for this update.
	float friction = 1.0f - m_friction * elapsed;

	// Move the object.
	m_velocity *= friction;
	if( addVelocity == true )
	{
		D3DXVECTOR3 velocity = m_velocity * elapsed;
		AddTranslation( velocity.x, velocity.y, velocity.z );
	}

	// Spin the object.
	m_spin *= friction;
	D3DXVECTOR3 spin = m_spin * elapsed;
	AddRotation( spin.x, spin.y, spin.z );

	// Update the object's world matrix.
	D3DXMatrixMultiply( &m_worldMatrix, &m_rotationMatrix, &m_translationMatrix );

	// Create a view matrix for the object.
	D3DXMatrixInverse( &m_viewMatrix, NULL, &m_worldMatrix );

	// Update the object's forward vector.
	m_forward.x = (float)sin( m_rotation.y );
	m_forward.y = (float)-tan( m_rotation.x );
	m_forward.z = (float)cos( m_rotation.y );
	D3DXVec3Normalize( &m_forward, &m_forward );

	// Update the object's right vector.
	m_right.x = (float)cos( m_rotation.y );
	m_right.y = (float)tan( m_rotation.z );
	m_right.z = (float)-sin( m_rotation.y );
	D3DXVec3Normalize( &m_right, &m_right );

	// Update the object's bounding volume using the translation matrix only.
	// This will maintain an axis aligned bounding box around the object in
	// world space rather than the object's local space.
	RepositionBoundingVolume( &m_translationMatrix );
}
开发者ID:asutermo,项目名称:Wolf-Operatives,代码行数:44,代码来源:SceneObject.cpp

示例14: D3DXMatrixInverse

bool CGameProc::Pick(POINT ptMouse)
{
	LPMONINFO oldMonInfo=g_pPlayer->m_pTargetInfo;
	D3DXMATRIX pmatProj = g_pCamera->GetProjMatrix(&pmatProj);
	D3DXVECTOR3 v;
	v.x = ( ( ( 2.0f * m_pt.x ) / m_clientWidth) - 1 ) / pmatProj._11;
	v.y = -( ( ( 2.0f * m_pt.y ) / m_clientHeight) - 1 ) / pmatProj._22;
	v.z = 1.0f;
	
	D3DXMATRIX matView=g_pCamera->GetViewMatrix(&matView);
	D3DXMATRIX m;
	D3DXVECTOR3 vDir,vPos;
	D3DXMatrixInverse(&m,NULL,&matView);
    vDir.x = v.x * m._11 + v.y * m._21 + v.z * m._31;
    vDir.y = v.x * m._12 + v.y * m._22 + v.z * m._32;
	vDir.z = v.x * m._13 + v.y * m._23 + v.z * m._33;
	vPos.x = m._41;
    vPos.y = m._42;
    vPos.z = m._43;
	m_xMonsterList.MoveCurrentToTop();
	for (int nCnt=0;nCnt<m_xMonsterList.GetCounter();nCnt++)
	{
		CMonster *pMonster;
		pMonster=m_xMonsterList.GetCurrentData();
		
		if(pMonster->m_pMonsterMesh->GetBoundBox()->CheckIntersectByRay(&vPos,&vDir))
		{
			//	pMonster->m_pMonsterMesh->m_bFoucs=true;
			g_pPlayer->m_pTargetInfo=&pMonster->m_xMonsterInfo;
			return true;
		}
// 		else
// 		{
// 			//	pMonster->m_pMonsterMesh->m_bFoucs=false;
// 			g_pPlayer->m_pTargetInfo=NULL;
// 		}
		m_xMonsterList.MoveNextNode();
	}
	return false;

}
开发者ID:wang35666,项目名称:3dgame,代码行数:41,代码来源:GameProc.cpp

示例15: D3DXIntersectTri

/*************************************************************************
 * D3DXIntersectTri
 */
BOOL WINAPI D3DXIntersectTri(CONST D3DXVECTOR3 *p0, CONST D3DXVECTOR3 *p1, CONST D3DXVECTOR3 *p2, CONST D3DXVECTOR3 *praypos, CONST D3DXVECTOR3 *praydir, FLOAT *pu, FLOAT *pv, FLOAT *pdist)
{
    D3DXMATRIX m;
    D3DXVECTOR4 vec;

    m.u.m[0][0] = p1->x - p0->x;
    m.u.m[1][0] = p2->x - p0->x;
    m.u.m[2][0] = -praydir->x;
    m.u.m[3][0] = 0.0f;
    m.u.m[0][1] = p1->y - p0->z;
    m.u.m[1][1] = p2->y - p0->z;
    m.u.m[2][1] = -praydir->y;
    m.u.m[3][1] = 0.0f;
    m.u.m[0][2] = p1->z - p0->z;
    m.u.m[1][2] = p2->z - p0->z;
    m.u.m[2][2] = -praydir->z;
    m.u.m[3][2] = 0.0f;
    m.u.m[0][3] = 0.0f;
    m.u.m[1][3] = 0.0f;
    m.u.m[2][3] = 0.0f;
    m.u.m[3][3] = 1.0f;

    vec.x = praypos->x - p0->x;
    vec.y = praypos->y - p0->y;
    vec.z = praypos->z - p0->z;
    vec.w = 0.0f;

    if ( D3DXMatrixInverse(&m, NULL, &m) )
    {
        D3DXVec4Transform(&vec, &vec, &m);
        if ( (vec.x >= 0.0f) && (vec.y >= 0.0f) && (vec.x + vec.y <= 1.0f) && (vec.z >= 0.0f) )
        {
            *pu = vec.x;
            *pv = vec.y;
            *pdist = fabs( vec.z );
            return TRUE;
        }
    }

    return FALSE;
}
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:44,代码来源:mesh.c


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