ì œ 물리 ì—”ì§„ì„ ì™„ì„±í• ë•Œê¹Œì§€ ì´ íŽ˜ì´ì§€ëŠ” ì •ë¦¬ê°€ 불가능한 아수ë¼ìž¥ì¼ 것입니다... -.- Ian Millingtonì˜ ì±… [http://www.kangcom.com/sub/view.asp?sku=200611020031 Game Physics Engine Development]를 ë³´ê³ ë§Œë“œëŠ” 3D 게임 물리 엔진. 게임 물리 엔진ì´ê¸° ë•Œë¬¸ì— '''실시간 ê°•ì²´ ì‹œë®¬ë ˆì´ì…˜'''ì„ ì¤‘ì ì 으로 다룬다. ì´ ì±…ì˜ ì˜¨ë¼ì¸ 사ì´íŠ¸: http://procyclone.com/ 게임 물리 ì—”ì§„ì€ í¬ê²Œ 세 개로 나눈다. 1. ìž…ìž ì—”ì§„(particle engine) 2. 질량 집합체 엔진(mass aggregate engine) 3. ê°•ì²´ 엔진(rigid body engine) == ìž…ìž ì—”ì§„ == ìž…ìž ì—”ì§„ì€ ëª¨ë“ ë¬¼ì²´ë¥¼ í¬ê¸° 없는 ìž…ìž(particle)ë¡œ 표현한다. ìž…ìžì— 힘(force)ì„ ìž‘ìš©í•˜ë©´ ìž…ìžê°€ 움ì§ì¸ë‹¤. ê³ ë“±í•™êµ ë¬¼ë¦¬ ì‹œê°„ì— ë‹¨ì¼ ë¬¼ì²´ì˜ ê°€ì† ìš´ë™ì´ë‹ˆ íž˜ì˜ ìž‘ìš© 따위를 ë°°ì› ì„ í…ë° ë‹¨ìˆœížˆ 그런 물체를 ë™ì‹œì— 수천 ê°œ 움ì§ì¼ 수 ìžˆë‹¤ê³ ë³´ë©´ ëœë‹¤. 사실 ì¶©ëŒ ì²˜ë¦¬ë„ ì—†ì–´ì„œ 물리 엔진ì´ë¼ê³ 부르기ì—는 조금 ê·¸ë ‡ë‹¤. ìµœì‹ ê²Œìž„ì„ ë³´ë©´ 화면 ìƒì— ë¶ˆë¹›ì´ ë‚ ì•„ë‹¤ë‹ˆê±°ë‚˜ 피가 튀기는 ë“±ì˜ íš¨ê³¼ë¥¼ ìžì£¼ ë³¼ 수 ìžˆëŠ”ë° ì´ëŠ” 주로 ìž…ìž ì—”ì§„ìœ¼ë¡œ 구현한 것ì´ë‹¤. attachment:particle_engine_sample_00.png attachment:particle_engine_sample_01.png * ì˜ˆì œ * FLiNT 엔진: [http://flintparticles.org/examples] * Stardust 엔진: [https://code.google.com/p/stardust-particle-engine/] ---- == 질량 집합체 엔진 == 질량 집합체 ì—”ì§„ì€ ìž…ìžë“¤ì„ ìš©ìˆ˜ì² (spring) ë˜ëŠ” 막대(rod) ê°™ì€ êµ¬ì†(constraint)으로 묶어 í•˜ë‚˜ì˜ ë¬¼ì²´ì²˜ëŸ¼ ì‹œë®¬ë ˆì´ì…˜í• 수 있다. 예를 들어 í•˜ë‚˜ì˜ ìƒìž 집합체는 ì 4개와 막대 6개로 구성ëœë‹¤. 현실ì—ì„œ 물체는 ìˆ˜ë§Žì€ ìž…ìžë“¤ë¡œ 구성ë˜ëŠ”ë°, 질량 집합체 ì—”ì§„ì€ ë¬¼ì²´ì˜ í•µì‹¬ ìž…ìžë“¤ë§Œ ê°€ì§€ê³ ê·¸ 물체를 ê¸°ìˆ í•˜ë ¤ëŠ” ì ‘ê·¼ë²•ìœ¼ë¡œ ì´í•´í• 수 있다. 질량 집합체 엔진ì—서는 ë¬¼ì²´ì˜ íšŒì „ì„ ë”°ë¡œ êµ¬í˜„í• í•„ìš”ê°€ ì—†ëŠ”ë° ê°€ë ¹ ëª¨ì„œë¦¬ì˜ í•œ ìž…ìžë¥¼ ìž¡ê³ ëŒë©´ 나머지 ì ë“¤ì´ ë”°ë¼ì˜¤ë©´ì„œ ìžë™ìœ¼ë¡œ íšŒì „ë˜ê¸° 때문ì´ë‹¤. ì´í•´í•˜ê¸°ë„ êµ¬í˜„í•˜ê¸°ë„ ë§¤ìš° 쉬우나 ë¬¼ì²´ì˜ ê³¨ê²©ë§Œìœ¼ë¡œ 어설프게 ì‹œë®¬ë ˆì´ì…˜í•˜ê¸° ë•Œë¬¸ì— ë³µìž¡í•œ 물체를 질량 집합체로 만들면 물체가 ì°Œê·¸ëŸ¬ì§„ë‹¤ë“ ì§€ 움푹 패ì¸ë‹¤ë“ 지 조금씩 ë³€í˜•ì´ ì¼ì–´ë‚œë‹¤. Locorocoë¼ë©´ 모를까 ì˜ìžë¥¼ ë°”ë‹¥ì— ì§‘ì–´ ë˜ì¡ŒëŠ”ë° ì˜ìžê°€ ê³ ë¬´ê³µì²˜ëŸ¼ 출ë ì´ëŠ” ê²ƒì„ ë°”ë¼ì§€ëŠ” ì•Šì„ ê²ƒì´ë‹¤. 형태가 간단한 물체는 질량 집합체로 ë§Œë“¤ì–´ë„ ë§¤ìš° 튼튼하기 ë•Œë¬¸ì— ê°„ë‹¨í•œ ì‹œë®¬ë ˆì´ì…˜ì„ 하기ì—는 매우 ì 합하다. 단 복잡한 물체를 질량 집합체로 ë§Œë“¤ë ¤ê³ í–ˆë‹¤ê°€ëŠ” 구ì†ì˜ 수가 íë°œì 으로 ì¦ê°€í•˜ê¸° ë•Œë¬¸ì— ì‹¤ì‹œê°„ ì‹¤í–‰ì´ ë¶ˆê°€ëŠ¥í•´ì§ˆ 수 있다. attachment:mass_aggregate_engine_sample_00.png ìž…ìž 20개를 ìƒì„±í•˜ê³ ëª¨ë“ ìŒì„ ìš©ìˆ˜ì² ë¡œ 연결하면 ìžì—°ìŠ¤ë ˆ ê· í˜•ì„ ì´ë£¨ì–´ ì•ˆì •ëœ êµ¬ì¡°ë¡œ ìˆ˜ë ´í•œë‹¤. attachment:mass_aggregate_engine_sample_01.png 사ê°í˜•ì€ ìž…ìž 4개와 막대 6ê°œ, 삼ê°í˜•ì€ ìž…ìž 3개와 막대 3개로 구성ëœë‹¤. attachment:mass_aggregate_engine_sample_02.png ëª¸ì˜ ê´€ì ˆë“¤ì„ ìž…ìžë¡œ ë³´ê³ ë§‰ëŒ€ë¡œ 연결하면 플래시 게임 [http://www.kongregate.com/games/eric_gurt/dead-drunk-1-9 DeadDrunk]ì˜ ê·¸ 졸ë¼ë§¨ì„ 만들 수 있다. 지 í˜¼ìž ì¶¤ì‚¬ìœ„ * ì˜ˆì œ * 옷ê°(cloth) ì‹œë®¬ë ˆì´ì…˜: http://www.youtube.com/watch?v=8bAQbJzqa-0 * ë¨¸ë¦¬ì¹´ë½ ì‹œë®¬ë ˆì´ì…˜: http://wonderfl.net/c/dLlx ---- == ê°•ì²´ 엔진 == ê°•ì²´ ì—”ì§„ì€ ë¬¼ì²´ë“¤ì„ ë³€í˜•ë˜ì§€ 않는 기하학ì ë„형으로 간주한다. ë¬¼ì²´ì˜ ë°€ë„는 ê· ì¼í•˜ë‹¤ê³ ê°€ì •í•˜ëŠ” 경우가 대부분ì´ë©° ê·¸ì— ë”°ë¼ ì§ˆëŸ‰ ì¤‘ì‹¬ì€ ê¸°í•˜í•™ì 중심과 같다. * ê°•ì²´ ì—”ì§„ì„ ì´ë£¨ëŠ” ê¸°ìˆ ë“¤ * 3D 변환: 4x4 í–‰ë ¬ê³¼ 사ì›ìˆ˜ * íšŒì „ ìš´ë™: ëŒë¦¼íž˜(torque), 관성 모멘트 * ì¶©ëŒ ê²€ì¶œ(걸러내기): 경계 볼륨 계층ë„, 공간 ë¶„í• íŠ¸ë¦¬, ê²©ìž * ì¶©ëŒ ê²€ì¶œ(ì •ë°€ê²€ì‚¬): 분리축 ì •ë¦¬(Separating Axis Theorem), ì ‘ì´‰(contact) ì •ë³´ ìƒì„± * ì¶©ëŒ í•´ê²°: 여기 배우는 중... ---- 13장 ''ì ‘ì´‰ ìƒì„±'' 요약 ì˜ì–´ ì±…ì„ ì½ìœ¼ë©´ í•„ê¸°ë„ ì˜ì–´ë¡œ 하게 ë˜ëŠ” ë§ˆìˆ -.- Coherence: a technique to extend algorithms that only generate one contact * Generating Contact Data with SATs * SAT generates only one contact... not enough * '''But''' we don't need to alter the algorithm. what? * The idea is COHERENCE. 1. In each frame, generate single contact with SAT. 2. Solve it in the normal way. 3. It is ''likely that'' the objects will interpenetrate again. 4. Run SAT again. Now we will get a new contact near the previous contact. Let's say them ContA and ContB. 5. Keep track of ContA and ContB, resolve them together! This process relies on the fact that - objects don't move too far from frame to frame. This is called coherence. A contact in one frame is likely to be still almost a contact in the next frame. ---- 14장. ì¶©ëŒ í•´ê²°(Collision Resolution) * Collision Detector : generates contact data. * integrator : Rigid body equations of motion including torques and forces. * => Combine them, make rotating objects respond to contacts! * Impulse and Impulsive Torque * In real world, when two objects collide each other, their materials compress. * As they compress, they exert a force to try to return to their original shapes. * '''impulse''' : an instant change of velocity * Now we are dealing with rotating object bodies, have to consider not only '''linear''' velocity, but also '''angular''' velocity. * How collisions affect both linear and angular velocities? * D'Alembert's principle * Linear component : linearAccel = force * inverse(mass) * Angular component : torque = point X force ; angularAccel = inverse(InertiaTensor) X torque * Impulsive torque : Instant angular change in velocity * '''u''' = I X angularVel = point X impulse * compare it with linear version : impulse = mass * point * Strictly, impulse is "impulsive force" or "linear impulse" * Similarly, '''u''' is "impulsive torque" or "angular impulse" * Accordingly, Δ(dΘ/dt) = inverse(I) X '''u''' * Handling rotating collisions * Just as for particle collisions, we need two steps. * First, resolve the relative motoin of the two objects by applying impulse and impulsive torque. * Second, resolve any penetration that has occurred. * Collision Impulses * To calculate the impulse and impulsive torque on each object, * 1. Change to contact coordinates * 2. Work out velocity change by impulse * 3. Work out impulse change by velocity * 4. Work out desired velocity change * 5. Work out the impulse * 6. Apply the impulse! impulsive torqueì˜ ì •ì²´ì— ëŒ€í•´ 갈피를 못 잡았었는ë°, 충격량(impulse)ì€ ë¬¼ì²´ì˜ ì„ ìš´ë™ëŸ‰(m'''v''')ì„ ë³€í™”ì‹œí‚¤ëŠ” ì–‘ì´ë‹¤. 그럼 impulsive torque는 ê°ìš´ë™ëŸ‰('''L''' = '''r''' X m'''v''')ì„ ë³€í™”ì‹œí‚¤ëŠ” ì–‘ì¸ê°€? 맞는 것 같다. impulsive torque와 ê°ìš´ë™ëŸ‰ì˜ ì°¨ì›ì€ m^2 * kg / së¡œ 같다! ê·¸ë¦¬ê³ ê°ìš´ë™ëŸ‰ì„ ì‹œê°„ì— ëŒ€í•´ 미분하면 í† í¬ê°€ ë‚˜ì˜¤ê³ ... 충ëŒì‹œ 반발계수를 kë¼ í•˜ë©´ ì¶©ëŒ ì „ 분리ì†ë„ v_sì— ëŒ€í•´ ì¶©ëŒ í›„ 분리ì†ë„는 -k * v_s ë‘ ë¬¼ì²´ì˜ ì„ ì†ë„ v1, v2는 ì´ì „ê³¼ ê°™ì€ ë°©ë²•ìœ¼ë¡œ 구한다 ê°ì†ë„는 그냥 v1ì´ëž‘ v2ì— ìœ„ì¹˜ 벡터 곱해주면 ë˜ëŠ”ê±°??? 멘붕