game programming 02 - ogre3d 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

47
Game Programming 02 - OGRE3D 엔엔 엔엔 2010 엔 2 엔엔 엔엔엔엔엔엔엔엔

Upload: loreen-porter

Post on 13-Jan-2016

242 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Game Programming 02- OGRE3D 엔진 소개

2010 년 2 학기디지털콘텐츠전공

Page 2: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

OGRE3D 엔진의 소개

• 역사• 라이센싱• 개발 환경의 설치• 데모 프로그램 컴파일 및 실행

Page 3: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

3D 엔진의 종류• 3D 엔진 데이타베이스 (

http://www.devmaster.net/engines/)– 등록된 엔진은 모두 242 개 .– 엔진별 성능 , 특징 , 및 사용자들의 리뷰가 가득 .– 주로 공개 엔진에 대한 정보가 주류 .

Page 4: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

OGRE : 공개 엔진 중 1 위

Page 5: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

오우거 (OGRE) ?• 유럽 판타지문학에 자주

등장하는 흉악한 종족 . 사람을 잡아먹는 흉측한 몬스터 .

• 사람보다 몸집이 약간 크며 거인과 달리 머리에 뿔이 나 있다 .

• 무기와 방어도구를 비교적 익숙하게 사용하지만 그렇다고 머리가 좋은 것은 아니다 . 무기도 기껏해야 곤봉정도 . 오크를 부하로 거느리는 경우가 많다 .

Page 6: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

OGRE 3D 엔진 소개• OGRE 소개

– Object-oriented Graphics Rendering Engine 의 약자– 2001 년 영국의 Steve 'sinbad' Streeting 라는

소프트웨어 엔지니어가 개발을 시작

– 현재 v1.7.1 까지 진행됨 (2010 년 4 월 release)– 객체지향인터페이스 방식의 설계를 통한 깔끔하고 간결한

엔진 클래스 및 인터페이스– Direct3D 와 OpenGL 의 동시 지원– 확장용이한 프레임웍 구조를 통한 쉽고 빠른 애플리케이션

제작– 다양한 플랫폼 지원 : 윈도우 , 리눅스 , 맥 OS, iPhone

Page 7: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

OGRE 3D 엔진 소개• OGRE 는 그래픽스 렌더링 및 애니메이션 엔진

– 인공지능 엔진 , 물리 엔진 등을 포함하는 full 3D game engine 은 아님

– 같이 사용될 수 있는 다양한 물리 엔진 , AI 엔진 , 사운드 엔진 등이 존재함 .

– YAKE(www.yake.org): OGRE 를 기반으로 하는 공개 소스 3D 게임 엔진

Page 8: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

OGRE 3D 엔진 소개• OGRE 의 라이센싱 모델

– GNU LGPL (Lesser General Public License)– 상용 개발에 사용이 가능– 상용 프로그램과 동적 링킹이 가능함 .

Page 9: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

www.ogre3d.org : 공식 홈페이지

Page 10: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Screenshot

Page 11: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Screenshot

Page 12: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Screenshot

Page 13: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

OGRE 3D 구조

Page 14: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

OGRE 개발 환경• 컴파일러– Visual Studio 2005/2008/2010– 2005/2008 needs to have service pack 1

installed

• OGRE 엔진 – OGRE SDK ver. 1.7.1– 위치 : http://www.ogre3d.org/download/sdk

• 데모 및 툴– OGRE 엔진 데모 -

http://www.ogre3d.org/download/demos

Page 15: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

How to install the OGRE SDK

• After download the file, extract it onto c:\OgreSDK\

• Set an environment variable ‘OGRE_HOME’ :

Page 16: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Setting up an application

• http://www.ogre3d.org/tikiwiki/Setting+Up+An+Application+-+Visual+Studio

Page 17: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Setting up an application

• Win32 Application with an empty project

Page 18: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Setting up an application

• Download TutorialFramework.zip

• Insert those files into the project

Page 19: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Project Configuration

• Download TutorialFramework.zip

• Insert those files into the project

Page 20: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Setting up properties

Page 21: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Setting up properties

• Set Multi-Byte Character Set

Page 22: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Setting up properties

• Debugging Configuration Properties– Command: $(OGRE_HOME)\Bin\$(Configuration)\$

(ProjectName).exe

– Working Directory: $(OGRE_HOME)\Bin\$(Configuration)

Page 23: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Setting up properties

• Configuration Properties - C/C++ - General– Additional Include Directories

$(OGRE_HOME)\include\OIS $(OGRE_HOME)\include\OGRE $(OGRE_HOME)\Samples\Common\include $(OGRE_HOME)\boost_1_42

Page 24: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Setting up properties

• Configuration Properties - Linker – General– Additional Library Directories

$(OGRE_HOME)\lib\$(Configuration) $(OGRE_HOME)\boost_1_42\lib

Page 25: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Setting up properties

• Configuration Properties - Build Events - Post-Build Event– Command Line

copy "$(OutDir)\$(TargetFileName)" "$(OGRE_HOME)\Bin\$(Configuration)"

Page 26: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Setting up properties

• Configuration Properties - Linker - Input – – Additional Dependencies

• DEBUG: OgreMain_d.lib OIS_d.lib• RELEASE: OgreMain.lib OIS.lib

Page 27: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

And Run it!

NOTHING!

Page 28: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Edit the code a little bit

void TutorialApplication::createScene(void){ // create your scene here :)

Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh"); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); headNode->attachObject(ogreHead); // Set ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5)); // Create a light Ogre::Light* l = mSceneMgr->createLight("MainLight"); l->setPosition(20,80,50);}

void TutorialApplication::createScene(void){ // create your scene here :)

Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh"); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); headNode->attachObject(ogreHead); // Set ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5)); // Create a light Ogre::Light* l = mSceneMgr->createLight("MainLight"); l->setPosition(20,80,50);}

Page 29: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

And then Run it again!

Page 30: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Or Alternatively

• Download Ogre AppWizard At: http://code.google.com/p/ogreappwizards/

Page 31: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Using the Ogre AppWizard

• Like an ordinary Win32/MFC Project selecting an Ogre Application at a New Project:

Page 32: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Using the Ogre AppWizard

• Application Setting:

Page 33: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Using the Ogre AppWizard

• Run it!

Page 34: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

How to learn to use OGRE?

• http://www.ogre3d.org/tikiwiki/Tutorials

Page 35: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Want to enjoy OGRE?

• Download the demos:

Page 36: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Want to enjoy OGRE?

• Play it!

Page 37: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

숙제• OGRE 3D 를 인스톨하고 , 실행 한 뒤

Screenshot 을 찍어서 제출

• OGRE 3D Demo 중 흥미 있는 데모 5 개를 선택하여 Screenshot 을 찍은 뒤 선택한 이유 및 그 데모에 사용된 기술에 대해 조사

• 제출 방법 : 문서 하나로 만든 뒤 moodle 에 제출 (doc, hwp, pdf)

• 제출 시한 : 4 월 16 일 목요일 23 시 59 분까지

Page 38: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Basic of OGRE• Scene Manager:

– Managing everything appearing in the scene– Cameras, Objects, Planes, billboards, lights...and so

on

• 3 kinds of Scene Managers– Octree(8 진 트리 ) Scene Manager

• 기본 장면 관리자• 대부분의 장면에 사용 가능

– BSP(Binary Surface Partition) Scene Manager• 건물 내부와 같이 벽과 복도 등으로 구성된 장면에 최적화된

성능 .

– Terrain Scene Manager• 정적 지형을 가지는 비교적 소규모의 장면에 적합• 고해상도의 지형에 적합 mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);

Page 39: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Basic of OGRE

• Entity:– Objects to be rendered on the scene – 3D meshes: Character, robot, fish, terrain and

so on. – Cameras, lights, billboards are not entities.

3D Mesh

Page 40: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Basic of OGRE

• Scene Node:– Representing translation, rotation and scale

(transformation)– Not an actual object– An(or multiple) entity can be attached to.

NodeNode

Entity1

Entity1

Entity2

Entity2

Page 41: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Scene Manager, node and entity

rootroot

Node1Node1 Node2Node2

Entity1

Entity1

Entity2

Entity2

Entity3

Entity3

Node3Node3

Entity4

Entity4

Entity5

Entity5

Node4Node4

Entity6

Entity6

Page 42: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Hierarchical Modeling

• A hierarchical model is created by nesting the descriptions of subparts into one another to form a tree organization

Page 43: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Revisiting the code

void TutorialApplication::createScene(void){ // create your scene here :)

Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh"); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); headNode->attachObject(ogreHead); // Set ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5)); // Create a light Ogre::Light* l = mSceneMgr->createLight("MainLight"); l->setPosition(20,80,50);}

void TutorialApplication::createScene(void){ // create your scene here :)

Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh"); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); headNode->attachObject(ogreHead); // Set ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5)); // Create a light Ogre::Light* l = mSceneMgr->createLight("MainLight"); l->setPosition(20,80,50);}

Page 44: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Adding One More Node

void TutorialApplication::createScene(void){ // create your scene here :)

Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh"); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); headNode->attachObject(ogreHead); Ogre::Entity* ogreHead2 = mSceneMgr->createEntity( "Head2", "ogrehead.mesh" ); Ogre::SceneNode* headNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode ( "HeadNode2", Ogre::Vector3( 100, 0, 0 ) ); headNode2->attachObject( ogreHead2 );

// Set ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5)); // Create a light Ogre::Light* l = mSceneMgr->createLight("MainLight"); l->setPosition(20,80,50);}

void TutorialApplication::createScene(void){ // create your scene here :)

Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh"); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); headNode->attachObject(ogreHead); Ogre::Entity* ogreHead2 = mSceneMgr->createEntity( "Head2", "ogrehead.mesh" ); Ogre::SceneNode* headNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode ( "HeadNode2", Ogre::Vector3( 100, 0, 0 ) ); headNode2->attachObject( ogreHead2 );

// Set ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5)); // Create a light Ogre::Light* l = mSceneMgr->createLight("MainLight"); l->setPosition(20,80,50);}

Page 45: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Node Transformation

• Translate:– SceneNode::translate ( Ogre::Vector3(..) );

• Rotate:– SceneNode::yaw(Degree(..));– SceneNode::pitch ( );– SceneNode::roll ( );

• Scale– SceneNode::scale ( x, y, z );

Page 46: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

Cool ninja without hassle

• Replace the CreateScene function with the one in our homepage!

Page 47: Game Programming 02 - OGRE3D 엔진 소개 2010 년 2 학기 디지털콘텐츠전공

정리• OGRE 3D 의 rendering process:– 시스템 초기화

• Root 개체 생성• 컨피규레이션 설정• 렌더 윈도우 생성• 리소스 위치 설정• 프레임 리스너 생성

– 씬 생성• 씬 매니저 생성• 카메라 및 뷰포트 생성• 광원 생성• 엔터티 생성• 씬 노드 생성

– 렌더링