¸Þ¸ðÀå_¹°¸®
@ 2004-11-23 @
°ÔÀÓ¿¡¼ÀÇ ¹°¸®ÇÐ (±è¼º¿Ï »ù °¨»ç^^)
|
- 1 Çϵå¿þ¾î °¡¼Ó
- 2 °ÔÀÓ¿¡¼ÀÇ ¹°¸®ÇÐ
- 2.1 Euler's Method
- 2.2 Hook's law
- 2.3 Verlet Intergrator
- 3 Chaos
- 4 Jump ±âº»·ÎÁ÷
|
* Ãæµ¹Âü°í
1 Çϵå¿þ¾î °¡¼Ó #
#.PPU(¹°¸®¿¬»ê ÇÁ·Î¼¼½º À¯´Ö) ; CPU°¡ ´ã´çÇÏ´Â À̹ÌÁö Àç»ý°ú °ü·ÃµÈ ¹°¸® ¿¬»êÀ» Àü´ãÇÏ´Â ÁÖº¯±â±â
/ ÄÜ¼Ö °ÔÀÓÇÁ·Î¼¼½Ì ó¸® °³³ä = CPU + GPU + PPU
#.GPU (Graphics Processing Unit)´Â
Áß¾Óó¸®ÀåÄ¡ÀÎ CPU¸¸À¸·Î °íÁ¤¹ÐµµÀÇ ±×·¡ÇÈÀ» ´Üµ¶À¸·Î ó¸®Çϱ⿡ ¹«¸®°¡ Àֱ⠶§¹®¿¡, À̸¦ º¸Á¶Çϱâ À§ÇÏ¿© 3D±×·¡ÇÈ ¿¬»ê Àü¿ëÀÇ ÇÁ·Î¼¼¼ GPU°¡ °³¹ß µÇ¾ú½À´Ï´Ù.
GPU¶ó´Â ¿ë¾î´Â ¿£ºñµð¾Æ(NVIDIA)»ç¿¡¼ 1999³â¿¡ ¡®ÁöÆ÷½º(
GeForce)¡¯¶ó´Â À̸§ÀÇ »õ·Î¿î ±×·¡ÇÈ ÄÁÆ®·Ñ·¯(Graphics Controller: ±×·¡ÇÈÄ«µå¿ë Ĩ)À» ³»³õÀ¸¸ç óÀ½ Á¦Ã¢ÇÑ °ÍÀÌ´Ù. ÁöÆ÷½º´Â CPUÀÇ µµ¿ò ¾øÀÌ ÀÚüÀûÀ¸·Î Æú¸®°ï(Polygon: 3D ±×·¡ÇÈÀ» ±¸¼ºÇÏ´Â µµÇü)ÀÇ º¯Çü(Transform) ¹× ±¤¿ø(Lighting)È¿°ú¸¦ ±¸»çÇÏ´Â ±â´É, À̸¥¹Ù ¡®Çϵå¿þ¾î(Hardware) T&L¡¯À» °®Ãß°í ÀÖ¾ú´Ù. ÀÌ´Â ÀÌÀü±îÁö »ç¿ëÇß´ø ±×·¡ÇÈ ÄÁÆ®·Ñ·¯¿Í´Â È®¿¬È÷ ´Ù¸¥ °³³äÀ̾ú±â ¶§¹®¿¡ À̸¦ ±¸ºÐÇÏ°íÀÚ GPU¶ó´Â À̸§ÀÌ ºÙ°Ô µÇ¾ú´Ù. ±×¸®°í ÁöÆ÷½ºÀÇ Ãâ½Ã ÈÄ 1³âÀÌ Áö³ 2000³â,
ATi(ÇöÀçÀÇ AMD)»ç¿¡¼ ¡®¶óµ¥¿Â(Radeon)¡¯À̶ó´Â GPU¸¦ Ãâ½ÃÇÏ°Ô µÇ¸é¼ ¾ç»çÀÇ °æÀïÀÌ º»°ÝÈ µÈ´Ù.
#.ÀÎÅÚ > Havok - ¹°¸® °è»êÀ» CPU¿¡¼ º¸Á¶ ¿ªÇÒÀ» ´ã´ç
-. Çï°ÔÀÌÆ®´Â Á¤»óÀûÀÎ °æ¿ì, ½Ì±Û ÇÁ·Î¼¼½º·Î ÀÛµ¿À» ÇÏÁö¸¸
¹è°æ ¼³Á¤À̳ª ÀÌÆåÆ® µî¿¡ ¹°¸®(ÇϺ¹) ¿¬»êÀÌ ÁøÇàµÉ ¶§, ´Ù¸¥ ÇÁ·Î¼¼½º°¡ ÀÛµ¿
--> ½ÉÇÒ °æ¿ì, ¹°¸® °è»êÀÌ ³¡³¯ ¶§±îÁö ȸéÀÌ ¸ØÃß´Â Çö»ó ¹ß»ý
#.NVIDIA > (AGEIA)
PhysX - ¹°¸® °è»êÀ» ±×·¡ÇÈÄ«µå¿¡¼ º¸Á¶ ¿ªÇÒÀ» ´ã´ç
2 °ÔÀÓ¿¡¼ÀÇ ¹°¸®ÇÐ #
- F = ma¿¡¼ °¡¼Óµµ(a)¡êÀ§Ä¡¿Í ½Ã°£ÀÇ °³³ä
- Â÷¿ø¿¡ ¿µÇâÀ» ¹ÞÁö ¾Ê´Â´Ù.(´ÜÀ§ ¹«½Ã)
- Áú·® °³³äÀÌ ¾ø´Ù.(ÀÓÀÇÀûÀÎ settingÀÌ °¡´É)
- ½Ç½Ã°£À¸·Î ó¸®ÇØ¾ß ÇÑ´Ù.
- Âü°í »çÀÌÆ®
2.1 Euler's Method #
2.2 Hook's law #
- ½ºÇÁ¸µ°è¼ö(ks); ÆÄƼŬ °£ÀÇ ÀÀÁý·Â ¿îµ¿À» À¯¹ß½ÃÅ´
-1) °è¼ö°¡ Ŭ¼ö·Ï ¸ð¾çÀ» ±×´ë·Î À¯ÁöÇÒ·Á´Â ÈûÀ¸·Î ÀÛ¿ë
--> ÀÓÀÇÀÇ ÇÑ°èÄ¡¸¦ ³ÑÀ» °æ¿ì´Â ¾ðÁ¦µçÁ¦ Æø¹ßÀÇ À§Ç輺À» °¡Áö°í ÀÖ´Ù.
-2) ½ºÇÁ¸µÀº »ó´ëÀûÀÎ À§Ä¡ÀÇ (°Å¸®¿¡ µû¸¥)º¯È¿¡ ÀÇÇØ Åº¼ºÀÌ ¹ß»ý
- °¨¼è°è¼ö(kd); ÀúÇ×À̳ª ¹°¼ºÄ¡¿¡ ÀÇÇÑ º¯È¸¦ °¨¼Ò½ÃÅ°´Â ¿ä¼Ò
-1) °¨¼è°è¼ö°¡ Å©¸é ¹Ý¹ßÇÏ´Â ÇÏ´Â ÈûÀÇ ÀÛ¾ÆÁø´Ù. -> µüµüÇÑ ¹°Ã¼ Ç¥Çö
°¨¼è°è¼ö°¡ ÀÛÀ¸¸é À¯µ¿¼ºÀÌ Å« Á©¸®¿Í °°Àº ¹°ÁúÀ» Ç¥Çö ÇÒ ¼ö ÀÖ´Ù.
- ÇÑÂÊÀÌ °íÁ¤µÇ¾î ÀÖ´Â ½ºÇÁ¸µ¿¡ Áú·® mÀÎ ¹°Ã¼°¡ ´Ù¸¥ÂÊ ³¡¿¡ ÀÖÀ» ¶§,
¡ÅFs = -ks(l - lo)
( ks´Â ½ºÇÁ¸µ»ó¼ö, lÀº ½ºÇÁ¸µÀÌ ´Ã¾î³ ±æÀÌ, loÀº ½ºÇÁ¸µÀÇ ¿ø·¡±æÀÌ )
¡ÅFd = kd(v1 - v2)
( kd´Â °¨¼è°è¼ö, v1Àº Ãʱ⠼ӵµ, v2´Â ³ªÁß¼Óµµ, (v1 - v2)´Â »ó´ë¼Óµµ )
¡ÅF = Fs + Fd
Euler's Method Àû¿ëÇؼ À§Ä¡°ªRnew¸¦ ±¸ÇÑ´Ù.
¡Ø ±¸¼Ó Á¶°Ç¿¡¼ ½ºÇÁ¸µ »ó¼ö°¡ Å« µüµüÇÑ ¹°Ã¼¿¡ ½ÉÇÑ Áøµ¿À» °¡ÇÒ °æ¿ì Æø¹ßÀÇ À§Ç輺Àº ¾ðÁ¦³ª ÀÖ´Ù.
2.3 Verlet Intergrator #
- °³º°ÀûÀÎ ÆÄƼŬÀÇ ¿òÁ÷ÀÓÀ» °Ã¼ ¿îµ¿À¸·Î Ç¥ÇöÇÒ ¼ö ÀÖ°í, ¿¡³ÊÁö°¡ º¸Á¸ µÊÀ¸·Î½á ¾ÈÁ¤ÀûÀÌ´Ù.
¡Å R( t+¥Ät ) = 2R(t) - R(t-¥Ät) + A*¥Ät©÷
-1) ¿ÀÀÏ·¯ ÇعýÀÇ V(¼Óµµ)¿Í R(À§Ä¡)ÀÇ Ç׸ñÀÌ 2°³ÀÇ R(À§Ä¡)·Î ´ëü
-2) ÃʱâÄ¡ R(t-¥Ät) = R(t) - V(t)*¥Ät ·Î °è»ê
-3) ¿¹»óÇØ´ø °á°ú°¡ ³ª¿À¸é 2~3¹ø ·çÇÁ¸¦ µ¹·Á¼ ÇØ´ç ÇÁ·¹ÀÓ¿¡¼ °íÁ¤½Ãų ¼ö ÀÖ´Ù.
3 Chaos #
- Ä«¿À½º¶ó´Â ¸»Àº ±×¸®½º¾î khaos¿¡¼ ³ª¿Â °ÍÀÌÁö¸¸ ÇöÀç´Â ÀϹÝÀûÀ¸·Î Chaos(Ä«¿À½º, È¥µ·À̶ó´Â ÀǹÌ)·Î Ç¥±âÇÑ´Ù.
- ¾î¶² ½Ã½ºÅÛÀÇ ¾î´À ½ÃÁ¡¿¡¼ÀÇ »óÅÂ(=ÃʱⰪ)°¡ Á¤ÇØÁö¸é ±× ÈÄÀÇ »óÅ´ ¿ø¸®ÀûÀ¸·Î ¸ðµÎ °áÁ¤µÈ´Ù°í ÇÏ´Â °áÁ¤·ÐÀû ¹ýÄ¢À» µû¸£°í ÀÖÀ½¿¡µµ ºÒ±¸ÇÏ°í, ¾ÆÁÖ º¹ÀâÇؼ ºÒ±ÔÄ¢ÇÏ°í ºÒ¾ÈÁ¤ÇÑ ¸Õ Àå·¡ÀÇ »óŸ¦ ¿¹ÃøÇÏ´Â °ÍÀÌ ºÒ°¡´ÉÇÑ Çö»ó
- ÀοëµÇ´Â ½ÄÀÇ ¿¹;
y = ax(1-x) a´Â »ó¼ö, xÀÇ ÃʱâÄ¡¸¦ 0.1À̶ó°í °¡Á¤ÇÒ ¶§,
´ÙÀ½¿¡ ½Ä¿¡ Àû¿ëÇÒ xÀÇ °ªÀº ÇöÀç °è»êµÈ yÀÇ °ªÀ» »ç¿ëÇÑ´Ù.(0°ú 1»çÀÌ °ª)
4 Jump ±âº»·ÎÁ÷ #
const float JumpGHIGHTRAVITY 1800.0f
const float SAFEHEIGHT = 2.0f;
const float STARTJUMP = 100.0f;
static float fUp = 0.0f;
// Á¡ÇÁ ¿©ºÎ
if( !Á¡ÇÁÁß && ÇöÀç ¾Ö´Ï¸ÞÀ̼ÇÀÌ Á¡ÇÁÀΰ¡? )
{
m_bJumpstart = true;
m_bJump = true;
fUp = STARTJUMP;
m_fGravity = 0.0f;
}
if( m_bJump ) // »ó½Â ºÎºÐ
{
m_fGravity += (JumpGHIGHTRAVITY * (fDelta*fDelta)*0.5f );
fUp -= m_fGravity;
if( fUp < 0.0f )
{
m_fGravity = 0.0f;
m_bJump = false;
}
else
{
oldTrans.z += fUp;
}
}
else // ³«ÇÏ ¿©ºÎ
{
if( (oldTrans.z - kNewTrans.z) > SAFEHEIGHT )
{
m_fGravity += (JumpGHIGHTRAVITY * (fDelta*fDelta)*0.5f );
oldTrans.z -= m_fGravity;
}
else
{
oldTrans = kNewTrans;
m_fGravity = 0.0f;
m_bJumpstart = false;
}
}
- À§ÀÇ Äڵ忡¼ Á¡ÇÁ¸¦ °ËÃâÇÏ´Â ºÎºÐÀÌ ·ÎÁ÷ ¾È¿¡ Àֱ⠶§¹®¿¡ ÇÁ·¹ÀÓ¸¶´Ù ÆǺ°ÇÏ´Â ¹®Á¦°¡ ÀÖ¾î¼
¿ÜºÎ¿¡¼ Å° ÀÔ·ÂÀÌ µÇ´Â ºÎºÐ¿¡¼ jump start¸¦ ÇÔ¼ö·Î È£ÃâÇϵµ·Ï ¼öÁ¤
-.±ËÀûÀ» ÀÏÁ¤Çϱâ À¯Áö Çϱâ À§ÇØ Sin°î¼±À» µû¶ó¼ »ó½Â ÈÄ Á¤Á¡¿¡¼ ÇÔ¼ö »ç¿ëÇؼ ³«ÇÏ
-.Á¡ÇÁ À̺¥Æ® ¹ß»ý½Ã ÇöÀç À§Ä¡(m_pSavePosition)¸¦ ÀúÀå ÈÄ »ó½Â±¸¿ª¿¡¼ ±âÁØÀ¸·Î »ç¿ë
-.Á¤»óºÎºÐ¿¡¼ m_bJump02 = false, m_bJumpstart = false¿¡¼ ´Ù½Ã Á¡ÇÁ°¡´É
class className
{
public:
void StartJump();
private:
Point3 m_vSavePosition;
bool m_bJump02; // Á¡ÇÁ À̺¥Æ®¸¦ ¹Þ¾Æ¼ ij¸¯ÅÍ°¡ ÇöÀç »ó½Â ÁßÀÎÁö¸¦ Ç¥½Ã
bool m_bJumpstart; // Á¡ÇÁ¸¦ ÇÒ ¼ö ÀÖ´Â »óÅ ÀÎÁö¸¦ Ç¥½Ã
float m_fGravity;
float m_fHightPos;
float m_fJumpStartTime;
float m_fJumpTime;
float m_fJumpTimeMAX;
}
-----------------------------------------------------------------------------------
const float DEF_JumpGHIGHTRAVITY = 1600.0f;
const float DEF_JumpRAD = PI * 0.5; // 90µµ
const float DEF_JumpMAX = 12.0f; // jump½Ã ÃÖ°í Á¤Á¡ÀÇ ³ôÀÌ
void className::StartJump()
{
if( m_bJumpstart == true )
return;
CPlayer * pkPlayer = GetPlayer();
_TKASSERT( pkPlayer );
m_pSavePosition = pkPlayer->GetWorldTranslate();
ControllerSequence* pkSequence = pkPlayer->GetSequence(Animation_jump);
m_fJumpTimeMAX = pkSequence->GetLength() * 1.1f;
m_fJumpTime = m_fJumpTimeMAX * 0.5f;
m_fJumpStartTime = GetCurTime();
m_bJumpstart = true;
m_bJump02 = true;
}
bool className::UpDate()
{
...
// Á¡ÇÁ ¹× ³«ÇÏ ºÎºÐ - Sin°î¼±À» µû¶ó¼ »ó½Â ÈÄ Á¤Á¡¿¡¼ ÇÔ¼ö »ç¿ëÇؼ ³«ÇÏ
//=========================================================================================
float fjumptime = GetCurTime() - m_fJumpStartTime;
if( m_bJump02 ) // Á¡ÇÁ½Ã »ó½Â ±¸°£
{
float fjumpRAD = (fjumptime/m_fJumpTime) * DEF_JumpRAD;
if( fjumptime < m_fJumpTime ) // »ó½Â Áß
{
m_fHightPos = Sin(fjumpRAD) * DEF_JumpMAX;
m_fHightPos += m_vSavePosition.z;
}
else // ÃÖ°í Á¤Á¡ºÎºÐ
{
m_fHightPos = m_vSavePosition.z + DEF_JumpMAX;
m_bJump02 = false;
}
}
else //Á¡ÇÁ°¡ ¾Æ´Ò¶§ ³«ÇÏ
{
if((oldTrans.z - kNewTrans.z) < 2.0f)
{
m_fHightPos = kNewTrans.z;
oldTrans = kNewTrans;
}
if(m_fHightPos > kNewTrans.z)
{
m_fGravity += (DEF_JumpGHIGHTRAVITY * ((fDelta*fDelta)*0.5));
m_fHightPos -= m_fGravity;
}
else // if(m_fHightPos <= kNewTrans.z)
{
m_fHightPos = kNewTrans.z;
m_fGravity = 0.0f;
m_bJumpstart = false;
m_bJump02 = false;
}
}
oldTrans.z = m_fHightPos;
}