DirectX
jjuiddong
- 문자열 출력
- DirectX sample의 Text3D 프로젝트를 참조하자.
- ID3DXSprite, ID3DXFont 를 잘 사용하는게 관건이다.
- <3D 공간상에 폰트 출력하기> 참조
- 3D좌표를 투영된 2D좌표로 변환하기
- D3DXVec3Project() 함수를 이용하자.
PxTransform viewTM = m_Sample.getApplication().getCamera().getViewMatrix(); PxTransform tm = m_pRenderNode->getTransform(); tm.p.x = -tm.p.x; // change left hand axis D3DXMATRIX m; convertD3D9(m, tm); D3DXMATRIX mProj; D3DXMatrixPerspectiveFovLH(&mProj, 55.f * PxPi / 180.0f, 800.f/600.f, 0.1f, 10000.f); D3DXMATRIX mView; { D3DXVECTOR3 pos(-viewTM.p.x, viewTM.p.y, viewTM.p.z); PxVec3 lookAt = viewTM.p + (m_Sample.getApplication().getCamera().getViewDir() * 10.f); D3DXVECTOR3 target(-lookAt.x, lookAt.y, lookAt.z); D3DXMatrixLookAtLH(&mView, &pos, &target, &D3DXVECTOR3(0.0f, 1.0f, 0.0f)); } D3DVIEWPORT9 viewport; viewport.X = 0; viewport.Y = 0; viewport.Width = 800; viewport.Height = 600; viewport.MaxZ = 1; viewport.MinZ = 0; D3DXVECTOR3 v; D3DXVec3Project(&v, &D3DXVECTOR3(0,0,0), &viewport, &mProj, &mView, &m); if ((v.x < 0) || (v.y < 0) || (v.x > 800) || (v.y > 600)) return; m_Sample.getRenderer()->print(v.x, v.y, m_Name.c_str() );
- 라인출력
LPD3DXLINE m_line; D3DXCreateLine(device, &m_line); PxTransform viewTM = m_Sample.getApplication().getCamera().getViewMatrix(); D3DXMATRIX mProj; D3DXMatrixPerspectiveFovLH(&mProj, 55.f * PxPi / 180.0f, 800.f/600.f, 0.1f, 10000.f); D3DXMATRIX mView; { D3DXVECTOR3 pos(-viewTM.p.x, viewTM.p.y, viewTM.p.z); PxVec3 lookAt = viewTM.p + (m_Sample.getApplication().getCamera().getViewDir() * 10.f); D3DXVECTOR3 target(-lookAt.x, lookAt.y, lookAt.z); D3DXMatrixLookAtLH(&mView, &pos, &target, &D3DXVECTOR3(0.0f, 1.0f, 0.0f)); } m_line->Begin(); D3DXMATRIX mat = mView * mProj; m_line->DrawTransform( &m_lineList.front(), m_lineList.size(), &mat, D3DCOLOR_XRGB(255, 0, 0)); m_line->End();
- 벡터와 면의 충돌 판정 함수
- D3DXIntersectTri() 함수를 이용하자.
- http://blog.naver.com/PostView.nhn?blogId=zeowing&logNo=90082927644
- 직접 짠 코드, IntersectTri() 함수를 참조하자.