林
林枫
Unregistered / Unconfirmed
GUEST, unregistred user!
我想在3D人物的头顶上显示它的名字,不管人物在屏幕的什么位置(或远或近),就好象时下流行的游戏中那样。
用了些代码,但好象不对:
( * iMesh )->GetPosition( &WordP );
DXUTGetD3DDevice()->GetViewport(&vp);
// 取得视口
View = *g_Camera.GetViewMatrix();
Proj = *g_Camera.GetProjMatrix();
Word = *g_Camera.GetWorldMatrix();
D3DXVec3Project(&ScreenP, &WordP, &vp, &Proj, &View, &Word);
int zx = int(ScreenP.x);
int zy = int(ScreenP.y);
CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 );
txtHelper.begin
();
txtHelper.SetInsertionPos( zx , zy );
txtHelper.DrawFormattedTextLine( L"
man %d", i );
txtHelper.End();
好象ScreenP并不是屏幕坐标啊?
用了些代码,但好象不对:
( * iMesh )->GetPosition( &WordP );
DXUTGetD3DDevice()->GetViewport(&vp);
// 取得视口
View = *g_Camera.GetViewMatrix();
Proj = *g_Camera.GetProjMatrix();
Word = *g_Camera.GetWorldMatrix();
D3DXVec3Project(&ScreenP, &WordP, &vp, &Proj, &View, &Word);
int zx = int(ScreenP.x);
int zy = int(ScreenP.y);
CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 );
txtHelper.begin
();
txtHelper.SetInsertionPos( zx , zy );
txtHelper.DrawFormattedTextLine( L"
man %d", i );
txtHelper.End();
好象ScreenP并不是屏幕坐标啊?