¸¶¿ì½º¿òÁ÷À϶§¸¶´Ù ŸÀÏÀ§¿¡ Ç¥½Ã¸¦ ÇÏ°í ½Í¾î¿ä. 3d-2d°£ ÁÂÇ¥º¯È¯ÀÌ ÇÊ¿äÇÑ°Í °°Àºµ¥¿ä. ¾î¶»°Ô ÇÏ¸é µÇ³ª¿ä. °¨»çÇÕ´Ï´Ù.
#188-1. ¾È¿µ±â |
2006/01/22 (Sun) |
¿ÀºêÁ§Æ® ÇÇÅ·¿¡ ´ëÇÑ °ÍÀº..
http://www.gamza.net/ ÀÇ Algorithm & Math ¿¡ µé¾î °¡½Ã¸é 'PickµÈ °÷ÀÇ 3Â÷¿øÁÂÇ¥ °è»ê¹ý'À̶ó´Â °Á°¡ Àִµ¥ ÀÌ°ÍÀ» º¸½Ã¸é µË´Ï´Ù.
|
#188-2. ¼øµ¹ÀÌ |
2006/01/24 (Tue) |
±×°÷¿¡ ÀÖ´Â ¸îÁÙ
g_pD3DDevice.GetViewport(vp); g_pD3DDevice.GetTransform( D3DTS_PROJECTION, matProj ); GetCursorPos( ptCursor ); ScreenToClient( hWindow, ptCursor );
v.x := (( (((ptCursor.x-vp.X)*2.0/vp.Width ) - 1.0)) - matProj._31 ) / matProj._11; v.y := ((- (((ptCursor.y-vp.Y)*2.0/vp.Height) - 1.0)) - matProj._32 ) / matProj._22; v.z := 1.0;
g_pD3DDevice.GetTransform( D3DTS_VIEW, matView ); D3DXMatrixInverse( m, nil, matView ); vPickRayDir.x := v.x*m._11 + v.y*m._21 + v.z*m._31; vPickRayDir.y := v.x*m._12 + v.y*m._22 + v.z*m._32; vPickRayDir.z := v.x*m._13 + v.y*m._23 + v.z*m._33; vPickRayOrig.x := m._41; vPickRayOrig.y := m._42; vPickRayOrig.z := m._43; t := 1.0 / D3DXVec3Length( vPickRayDir ) ; //vPickRayDir,vPickRayOrig:TD3DVector; ppp.x:=vPickRayOrig.x + vPickRayDir.x * t ; ppp.y:=vPickRayOrig.y + vPickRayDir.y * t ; ppp.z:=vPickRayOrig.z + vPickRayDir.z * t ;
ÀÌ·±½ÄÀ¸·Î Çϴϱî ppp°ªÀÌ -4,3,0À¸·Î¸¸ ³ª¿À³×¿ä. ¸¶¿ì½º°¡ ¿òÁ÷À̸é ÇØ´çŸÀÏÀ» Å׵θ®°¡ ÃÄÁø ŸÀÏ·Î ¹Ù²Ù·Á°í Çϰŵç¿ä. ¾î¶»°Ô ÇØ¾ß ÇÏ´ÂÁö¿ä.
|
#188-3. ¾È¿µ±â |
2006/01/27 (Fri) |
¼Ò½º°¡ ÀÌ»óÇѵ¥¿ä.
t := 1.0 / D3DXVec3Length( vPickRayDir ); °¡ ¿©±â¿¡ µé¾î°¡¸é ¾ÈµË´Ï´Ù.
Á¦ÀÏ ¸¶Áö¸·ÀÇ °ø½Ä¿¡¼º¸¸é t´Â °Å¸®¸¦ ³ªÅ¸³»´Â factor·Î º¸À̴µ¥, ÀÌ °ªÀº Ãâ·ÂµÇ°í ÀÖ´Â ¸ðµç Æú¸®°ïÁß¿¡ ±¤¼±ÀÇ ¹æÇâ°ú ±³Â÷ÇÏ´Â °Í¿¡ ´ëÇØ °Å¸®¸¦ Á¶»çÇÑ ÈÄ t °ªÀÌ Ä«¸Þ¶ó¿¡ °¡Àå °¡±î¿î Çϳª(triangle)¸¦ °ñ¶ó³»´Â °úÁ¤ÀÌ ÀÖ¾î¾ß ÇÕ´Ï´Ù. ±×·± °úÁ¤ÀÌ ¾øÀÌ À§Ã³·³ ¾²¸é Ç×»ó °ªÀº °ªÀÌ ³ª¿À´Â °ÍÀÌ ´ç¿¬ÇÏÁö¿ä.
|
|