(Microsoft PowerPoint - \301\24615\260\255 - \303\346\265\271\303\263\270\256)

Similar documents
(Microsoft PowerPoint - \301\24613\260\255 - oFusion \276\300 \261\270\274\272)

슬라이드 1

<4D F736F F F696E74202D20C1A63034B0AD202D20C7C1B7B9C0D3B8AEBDBAB3CABFCD20B9ABB9F6C6DBC0D4B7C2>

<4D F736F F F696E74202D20C1A63137B0AD202D20C1F6C7FCC3E6B5B9C3B3B8AE>

슬라이드 1

(Microsoft PowerPoint - \301\24611\260\255 - \276\326\264\317\270\336\300\314\274\307)

슬라이드 1

<4D F736F F F696E74202D20C1A63037B0AD202D20B1A4BFF8B0FA20B1D7B8B2C0DA>

슬라이드 1

(Microsoft PowerPoint - \301\24608\260\255 - \261\244\277\370\260\372 \300\347\301\372)

슬라이드 1

<4D F736F F F696E74202D20C1A63134B0AD202D20BBE7BFF8BCF6BFCD20C8B8C0FC>

<4D F736F F F696E74202D20C1A63130B0AD202D20C1F6C7FCB0FA20C7CFB4C3C0C720B7BBB4F5B8B5>

<4D F736F F F696E74202D B3E22032C7D0B1E220C0A9B5B5BFECB0D4C0D3C7C1B7CEB1D7B7A1B9D620C1A638B0AD202D20C7C1B7B9C0D320BCD3B5B5C0C720C1B6C0FD>

슬라이드 1

슬라이드 1

C++ Programming

표준프레임워크 Nexus 및 CI 환경구축가이드 Version 3.8 Page 1

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

Microsoft PowerPoint - [2009] 02.pptx

슬라이드 1

(Microsoft Word - \301\337\260\243\260\355\273\347.docx)

C++ Programming

슬라이드 1

Microsoft PowerPoint - additional01.ppt [호환 모드]

Microsoft PowerPoint - 11주차_Android_GoogleMap.ppt [호환 모드]

C++ Programming

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - Chapter 6.ppt

C++ Programming

C프로-3장c03逞풚

슬라이드 1

Microsoft PowerPoint - additional07.ppt [호환 모드]

Microsoft PowerPoint - es-arduino-lecture-03

PowerPoint Template

Microsoft PowerPoint - Class10_LOD와자료구조.pptx

설계란 무엇인가?

1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout << " 양수입력 : "; cin >> *p; if (*p <= 0) cout << " 양수를입력해야합니다 " << endl; return; 동적할

Microsoft PowerPoint - chap01-C언어개요.pptx

PowerPoint 프레젠테이션

Open GL

목차 제 1 장개요 제 2 장소프트웨어구조 제 3 장공통요소 I

유니티 변수-함수.key

ALTIBASE 사용자가이드 Templete

학습목차 2.1 다차원배열이란 차원배열의주소와값의참조

2002 Game White paper 2002 Game White paper

JAVA PROGRAMMING 실습 08.다형성

Microsoft PowerPoint - 8ÀÏ°_Æ÷ÀÎÅÍ.ppt

Microsoft PowerPoint - Java7.pptx

Google Maps Android API v2

Microsoft PowerPoint - C++ 5 .pptx

PowerPoint Presentation

Microsoft PowerPoint - 14주차 강의자료

Microsoft PowerPoint - 05geometry.ppt

안드로이드기본 11 차시어댑터뷰 1 학습목표 어댑터뷰가무엇인지알수있다. 리스트뷰와스피너를사용하여데이터를출력할수있다. 2 확인해볼까? 3 어댑터뷰 1) 학습하기 어댑터뷰 - 1 -

슬라이드 1

슬라이드 1

설계란 무엇인가?

PowerPoint Template

Microsoft PowerPoint - Chapter 1-rev

Java Programing Environment

PowerPoint Presentation

Microsoft PowerPoint - Chapter 10.ppt

Microsoft PowerPoint - 6-PythonGUI-sprite

윈도우시스템프로그래밍

PowerPoint Template

HW5 Exercise 1 (60pts) M interpreter with a simple type system M. M. M.., M (simple type system). M, M. M., M.

<BABBB9AE2DC7D5C3BC2E687770>

제11장 프로세스와 쓰레드

Microsoft PowerPoint Application Resources[Part1](2.0h).pptx

K&R2 Reference Manual 번역본

C++ Programming

Microsoft PowerPoint - Week04_DirectX9 프로그래밍의 기초2.pptx

슬라이드 1

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++,

PowerPoint Template

Microsoft PowerPoint - additional-11_13l.ppt [호환 모드]

PowerPoint 프레젠테이션

tut_modelsim(student).hwp

(Microsoft PowerPoint - 11\300\345.ppt [\310\243\310\257 \270\360\265\345])



Microsoft PowerPoint - additional08.ppt [호환 모드]

PowerPoint Presentation

슬라이드 1

Chapter_02-3_NativeApp

untitled

1. 자바프로그램기초 및개발환경 2 장 & 3 장. 자바개발도구 충남대학교 컴퓨터공학과

표준프레임워크로 구성된 컨텐츠를 솔루션에 적용하는 것에 문제가 없는지 확인

Microsoft PowerPoint - 9ÀÏ°_ÂüÁ¶ÀÚ.ppt

2

chap10.PDF


Microsoft PowerPoint - chap10-함수의활용.pptx

Microsoft PowerPoint - Chap12-OOP.ppt

설계란 무엇인가?

Slide 1

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밊

기본자료형만으로이루어진인자를받아서함수를결과값으로반환하는고차함수 기본자료형과함수를인자와결과값에모두이용하는고차함수 다음절에서는여러가지예를통해서고차함수가어떤경우에유용한지를설명한다. 2 고차함수의 예??장에서대상체만바뀌고중간과정은동일한계산이반복될때함수를이용하면전체연산식을간 단

Transcription:

게임엔진 제 15 강충돌처리 이대현교수 한국산업기술대학교게임공학과

학습목차 엔터티본구조의이해 콘솔입출력방법 본의위치좌표의획득 충돌오브젝트를이용한충돌처리기법 OgreOPCODE 를이용한충돌처리실습

본 (Bone) 뼈대애니메이션 (skeletal animation) 의기본구조. 위치와방향정보를가지고있는조인트. 본이여러개모여서 ( 트리구조 ) 하나의뼈대를이루게됨.

실습 ShowBones 닌자본구조의출력

콘솔입출력을위한설정 : cout, cin 을이용한입출력가능

PlayState.cpp bool PlayState::enter(void) { 중략 실습 Bone *bone; Skeleton::BoneIterator bi = ninjaentity->getskeleton()->getboneiterator(); while(bi.hasmoreelements()) { bone = bi.getnext(); std::cout << bone->getname() << ":" << bone->getposition(); if (bone->getparent()) { Bone* pb = static_cast <Bone*>(bone->getParent()); std::cout << "--->" << pb->getname() << std::endl; } else { std::cout << std::endl; } } 후략 }

실행결과

본구조의트리형태 머리 칼끝

본구조의출력 Bone *bone; Skeleton::BoneIterator bi = mninjaentity->getskeleton()->getboneiterator(); while(bi.hasmoreelements()) { bone = bi.getnext(); std::cout << bone->getname() << ":" << bone->getposition(); if (bone->getparent()) { Bone* pb = static_cast <Bone*>(bone->getParent()); std::cout << "--->" << pb->getname() << std::endl; } else { std::cout << std::endl; } }

실습 TipFish 칼끝의물고기

PlayState.cpp bool PlayState::enter(void) { 중략 실습 mfishentity = mscenemgr->createentity("fish#1", "fish.mesh"); mfishnode = mninjanode->createchildscenenode("fishnode"); mfishnode->attachobject(fishentity); mfishnode->scale(4,4,4); mswordtipbone = mninjaentity->getskeleton()->getbone("joint29"); 후략 } bool PlayState::frameStarted(GameManager* game, const FrameEvent& evt) { 중략 Vector3 pos = mswordtipbone->_getderivedposition(); mfishnode->setposition(pos); 후략 }

실행결과

bool PlayState::enter(void) { 중략 mfishentity = mscenemgr->createentity("fish#1", "fish.mesh"); mfishnode = mninjanode->createchildscenenode("fishnode"); mfishnode->attachobject(fishentity); mfishnode->scale(4,4,4); mswordtipbone = mninjaentity->getskeleton()->getbone("joint29"); 후략 } bool PlayState::frameStarted(GameManager* game, const FrameEvent& evt) { 중략 Vector3 pos = mswordtipbone->_getderivedposition(); mfishnode->setposition(pos); 후략 }

충돌오브젝트기반의충돌처리기법 충돌오브젝트 충돌을확인할부분을구, 또는육면체등으로표시한것. 충돌메쉬 (Collision Mesh), 바운딩박스 (bounding box) 충돌처리 충돌오브젝트간의충돌이일어나는지를확인 정확도는떨어지지만, 훨씬빠른시간내에충돌검사를할수있음. 격투대전게임에서가격에사용되는손또는발부분, 가격이가해지는머리, 복부, 배부분만을바운딩박스로적용.

OgreOPCODE OPCODE 공개물리엔진인 ODE 에포함된충돌검사라이브러리 OgreOPCODE OPCODE 라이브러리를 OGRE 용으로 wrapping 한라이브러리

OgreOpcode 설치 설치 OgreOpcodeSDK_vc80.zip 을 OgreSDK 폴더에압축풀기 bin/debug/ogreopcode_d.dll bin/debug/ogreopcode.dll include/ogreopcode/*.* lib/ogreopcode.lib, OgreOpcode_d.lib 프로젝트속성 : C++ 추가포함디렉토리및링커입력추가종속성설정

실습 CollisionTest 닌자의킥공격충돌처리

PlayState.cpp bool PlayState::enter(void) { 중략 실습 mtipnode = mninjanode->createchildscenenode("tipnode"); mheadnode = mninjanode2->createchildscenenode("headnode"); mswordtipbone = mninjaentity->getskeleton()->getbone("joint27"); mheadbone = mninjaentity2->getskeleton()->getbone("joint8"); new CollisionManager(mSceneMgr); CollisionManager::getSingletonPtr()->addCollClass("ninja"); CollisionManager::getSingletonPtr()->addCollType("ninja", "ninja", COLLTYPE_CONTACT); mcollidecontext = CollisionManager::getSingletonPtr()->getDefaultContext();

PlayState.cpp 실습 mtipcollshape = CollisionManager::getSingletonPtr()->createBoxCollisionShape("tip"); mtipcollshape->load(mtipnode, 5.0f, 5.0f, 5.0f); mtipcollobj = mcollidecontext->createobject("tip"); mtipcollobj->setcollclass("ninja"); mtipcollobj->setshape(mtipcollshape); mcollidecontext->addobject(mtipcollobj); mheadcollshape = CollisionManager::getSingletonPtr()->createBoxCollisionShape("head"); mheadcollshape->load(mheadnode, 25.0f, 25.0f, 25.0f); mheadcollobj = mcollidecontext->createobject("head"); mheadcollobj->setcollclass("ninja"); mheadcollobj->setshape(mheadcollshape); mcollidecontext->addobject(mheadcollobj); mcollidecontext->reset(); 후략

PlayState.cpp bool PlayState::frameStarted(GameManager* game, const FrameEvent& evt) { 중략 Vector3 pos = mswordtipbone->_getderivedposition(); mtipnode->setposition(pos); pos = mheadbone->_getderivedposition(); mheadnode->setposition(pos); 실습 CollisionManager::getSingletonPtr()->getDefaultContext()->collide(evt.timeSinceLastFrame); CollisionPair **collisionsreport; int numcollisions = mcollidecontext->getcollisions(mtipcollobj, collisionsreport); static int ccnt = 0; if (numcollisions) { CollisionObject *obj1 = collisionsreport[0]->this_object; CollisionObject *obj2 = collisionsreport[0]->other_object; std::cout << "Collision #" << ++ccnt << " between" << obj1->getname() << " and " << obj2->getname() << std::endl; mninjaentity2->getanimationstate("idle1")->setenabled(false); mninjaentity2->getanimationstate("death1")->settimeposition(0.0f); mninjaentity2->getanimationstate("death1")->setloop(false); mninjaentity2->getanimationstate("death1")->setenabled(true); } 후략

실행결과

OgreOPCODE 설정 // 충돌오브젝트위치를찾기위함. mswordtipbone = ninjaentity->getskeleton()->getbone("joint27"); mheadbone = ninjaentity2->getskeleton()->getbone("joint8"); // 충돌매니저의생성 new CollisionManager(mSceneMgr); // 충돌클래스의설정 CollisionManager::getSingletonPtr()->addCollClass("ninja"); // 충돌체크타입의설정 CollisionManager::getSingletonPtr()->addCollType("ninja", "ninja", COLLTYPE_CONTACT); // 충돌체크컨텍스트설정 충돌체크할오브젝트들의그룹 mcollidecontext = CollisionManager::getSingletonPtr()->getDefaultContext(); COLLTYPE_IGNORE: 충돌체크를하지않음. COLLTYPE_QUICK: 고속 sphere 대 sphere 체크를수행. COLLTYPE_CONTACT: 첫번째충돌체크만 report COLLTYPE_EXACT: 모든 contact을 report

충돌메쉬의생성및등록 // 충돌오브젝트의형태생성 mtipcollshape = CollisionManager::getSingletonPtr()->createBoxCollisionShape("tip"); mtipcollshape->load(mtipnode, 10.0f, 10.0f, 10.0f); // 충돌오브젝트의생성및등록 mtipcollobj = mcollidecontext->createobject("tip"); mtipcollobj->setcollclass("ninja"); mtipcollobj->setshape(mtipcollshape); mcollidecontext->addobject(mtipcollobj); // 상대편닌자의머리위치에충돌오브젝트생성 mheadcollshape = CollisionManager::getSingletonPtr()->createBoxCollisionShape("head"); mheadcollshape->load(mheadnode, 30.0f, 30.0f, 30.0f); mheadcollobj = mcollidecontext->createobject("head"); mheadcollobj->setcollclass("ninja"); mheadcollobj->setshape(mheadcollshape); mcollidecontext->addobject(mheadcollobj); // 충돌컨텍스트초기화 mcollidecontext->reset();

// 충돌오브젝트의위치계산 Vector3 pos = mswordtipbone->_getderivedposition(); mtipnode->setposition(pos); pos = mheadbone->_getderivedposition(); mheadnode->setposition(pos); // 충돌체크 CollisionManager::getSingletonPtr()->getDefaultContext()->collide(evt.timeSinceLastFrame); // 충돌체크결과해석 CollisionPair **collisionsreport; int numcollisions = mcollidecontext->getcollisions(mtipcollobj, collisionsreport); static int ccnt = 0; if (numcollisions) { CollisionObject *obj1 = collisionsreport[0]->this_object; CollisionObject *obj2 = collisionsreport[0]->other_object; ninjaentity2->getanimationstate("idle1")->setenabled(false); ninjaentity2->getanimationstate("death1")->settimeposition(0.0f); ninjaentity2->getanimationstate("death1")->setloop(false); ninjaentity2->getanimationstate("death1")->setenabled(true); }

COLLTYPE_CONTACT 의이해 직전프레임의충돌결과를이용함. 1번프레임 충돌! 2번프레임 실제로충돌검사를하기전에, 1번프레임의결과이용 충돌! 3번프레임 실제의충돌검사시행. 따라서, 현재의구조에서는한번공격에두번이상의충돌이검출될수있음.

정리 엔터티본구조 뼈대애니메이션 (skeletal animation) 의기본구조. 위치와방향정보를가지고있는조인트. 본의위치좌표의획득 _getderivedposition() OPCODE의충돌오브젝트를이용한충돌처리기법 충돌클래스설정 충돌오브젝트컨텍스트 ( 그룹 ) 설정 충돌오브젝트정의및충돌오브젝트그룹에등록 collide() 로충돌검사 getcollisions() 으로충돌결과획득

실습과제 #9 충돌처리추가 닌자의하단공격 ( M 키이 ) 이상대닌자의발부분에가해질때닌자가쓰러지도록구현.