1 / 28

3D Game Engine

3D Game Engine. Agung Toto Wibowo http://gameprogramming.blog.ittelkom.ac.id/blog/ Materi tutorial diambil dari wiki Ogre : http://www.ogre3d.org/wiki/index.php/Ogre_Tutorials. Game Engine. game engine is a software system designed for the creation and development of video games .

aminia
Télécharger la présentation

3D Game Engine

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3D Game Engine Agung Toto Wibowo http://gameprogramming.blog.ittelkom.ac.id/blog/ Materi tutorial diambil dari wiki Ogre : http://www.ogre3d.org/wiki/index.php/Ogre_Tutorials

  2. Game Engine • game engine is a software system designed for the creation and development of video games. • core functionality : • rendering engine (“renderer”) for 2D or 3D graphics, • a physics engine or collision detection (and collision response), • sound, scripting, & animation, • artificial intelligence, • networking, streaming, • memory management, threading, and a scene graph

  3. Game Engine • sometimes called "game middleware" • provide a flexible and reusable software platform • provides all the core functionality needed, • reducing costs, complexities, and time-to-market • Some game engines only provide real-time 3D rendering capabilities • "graphics engine," "rendering engine," or "3D engine“ • RealmForge, Truevision3D, OGRE, Crystal Space, Genesis3D, Irrlicht and JMonkey Engine.

  4. Ogre 3DEngine • OGRE (Object-oriented Graphics Rendering Engine) adalah open source rendering engine grafik yang ditulisdandimaintainolehtimintikecil, • http://www.ogre3d.org/about/team • Telahberkembangluasmenjadikomunitas • http://www.ogre3d.org/ • Well documented and tutorial • http://www.ogre3d.org/wiki/index.php/Ogre_Tutorials

  5. Fiturpada Ogre • Fitur Ogre meliputi : productivity, platform & 3D API, material / shader, mesh, scene feature, special Effect, danfitur-fiturpentinglainnya. • Productivity : • Desain interface OO sederhanadanmudahdipergunakan • Independent terhadapimplementasi 3D (Direct 3D, OpenGL, Glide dansebagainya • Frame work yang extensible • Desain yang baik, teratur, dandokumentasipenuhterhadapsemua class engine • platform & 3D API, • Direct3D (mensupport DirectX 7 dan 9) dan OpenGL; • Support terhadap Windows (semuaversiutama), Linux dan Mac OSX; • Dapatdibangunpada Visual C++ 6, Visual C++ .NET, Visual C++ .NET 2003 dan Visual C++ 2005 pada Windows (STLportdibutuhkanuntukversi Visual C++ sebelum 2003); • Dapatdibangunpadagcc 3+ di Linux dan Mac OSX .

  6. Fiturpada Ogre • material / shader, • Pengelolaan asset material bisadiluarkode • Mendukungfungsioperasi multi texture, danmultipass blending, pembangunandanpengubahankoordinattekstur, operasiwarnadan alpha blend • Mendukung texture file-file PNG, JPEG TGA, BMP, DDS danbeberapa format yang tidakstandarlainnya • mesh, • Menerima format data mesh, memisahkankonsepdari vertex buffers, index buffers, vertex declarations dan buffer mappings • Dapatmengeksportdaribeberapamodelling tools (Milkshape3D, 3D Studio Max, Maya, Blenderdan Wings3D) • Patch Biquadric Bezier padapermukaanlengkung; • Progressive meshes (LOD) ; • scene feature, dan special Effect,

  7. Instalasi Ogre • File SDK adadihttp://www.ogre3d.org/download/sdk

  8. Instalasi Ogre • Berbagaitambahanplugindisediakanoleh Ogre, termasuk Ogre SDK Wizzard. • http://sourceforge.net/projects/ogreconglo/files/

  9. Memulai Ogre • Buataplikasidengannama “TutorialApplication” melalui Ogre SDK Wizzard • Kita akanberkonsentrasipadakodeberikut : class TutorialApplication : public ExampleApplication { protected: public: TutorialApplication() { }   ~TutorialApplication() { } protected: void createScene(void) { } };

  10. Pembangun Ogre • SceneManager • Memanagesemua yang munculpadalayar • Objek, plane, billboards, light, dansebagainya • type ScneneManager : Octree, Terrain, Nature, Paging, BSP, DotSceneOctree, Portal Connected Zone, Myrddins Paging Landscape, Editable Terrain, dan Planet Rendering Engine • Entitas • Object (mesh 3D) yang direnderpadasebuah scene. • Contoh : Sebuah robot, ikan, terrain • Object direndermelihataspeklokasi, danorientasi • Tidaklangsungmenempatkansebuah entity pada scene, melainkanharusditempelkanpadasebuah object SceneNode

  11. Pembangun Ogre • SceneNode • mentracklokasidanorientasisemuaobjek yang ditempelkanpadanya • SceneNodedapatmemilikibeberapa object yang ditempelkankepadanya • PosisiSceneNodeselalu relative terhadapparentSceneNode, dansetiapSceneManagermemiliki root node (lokasisemuaSceneNodediletakkan)

  12. MeletakkanObjek • TambahkankodeberikutpadaTutorialApplication::createScene() // mensetpencahayaan mSceneMgr->setAmbientLight( ColourValue( 1, 1, 1 ) ); // menambahkanobjekke scene. Entity *ent1 = mSceneMgr->createEntity( "Robot", "robot.mesh" ); SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode" ); node1->attachObject( ent1 ); • Kompile, danjalankanaplikasi

  13. KoordinatdanVektor • Sumbu x dan z sebagaibidanghorisontal, dansumbu y adalahsumbuvertikal. • Sumbu x akanberjalandarikirikekanan monitor • Sumbu y sejajardenganbawahkeatas monitor, • Sumbu z adalaharahmenujudanmenjauhdari monitor, • class Vector untukmerepresentasikanposisidanarah • 2 (Vector2), 3 (Vector3), dan 4 (Vector4)

  14. MenambahkanObjek • TambahkankodeberikutpadaTutorialApplication::createScene() yang telahkitaubahtadi. // menambahkan robot keduadenganlokasibergeser 50 unit dari robot pertama. Entity *ent2 = mSceneMgr->createEntity( "Robot2", "robot.mesh" ); SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode2", Vector3( 50, 0, 0 ) ); node2->attachObject( ent2 ); • Kompile, danjalankan program

  15. Beberapa Method Penting • Entity • Entity::setVisible, • Entity::isVisible, • Entity::getName, • Entity::getParentSceneNode • SceneNode • SceneNode::getPosition, • SceneNode::setPosition, • SceneNode:: translate, • SceneNode:: scale, • SceneNode::yaw, • SceneNode::pitch, • SceneNode::roll, • SceneNode::resetOrientation, • SceneNode::setOrientation, • SceneNode::getOrientation, • SceneNode::rotate

  16. Translasi • UbahkodepadaTutorialApplication::createScene() menjadisepertidibawahini Entity *ent1 = mSceneMgr->createEntity( "Robot", "robot.mesh" ); SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode" ); node1->attachObject( ent1 ); Entity *ent2 = mSceneMgr->createEntity( "Robot2", "robot.mesh" ); SceneNode *node2 = node1->createChildSceneNode( "RobotNode2", Vector3(0, 0, 0 ) ); node2->attachObject( ent2 ); node2->translate( Vector3( 50, 0, 10 ) ); // ubah-ubahnilaidisini, makakedua robot masihberjaraksama. Kenapa??? node1->translate( Vector3( 10, 0, 10 ) ); • Kompile, danjalankan program

  17. Penskalaan • UbahkodepadaTutorialApplication::createScene() menjadisepertidibawahini Entity *ent1 = mSceneMgr->createEntity( "Robot", "robot.mesh" ); SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode" ); node1->attachObject( ent1 );  node1->scale( .5, 1, 2 ); Entity *ent2 = mSceneMgr->createEntity( "Robot2", "robot.mesh" ); SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode2", Vector3( 50, 0, 0 ) ); node2->attachObject( ent2 );  node2->scale( 1, 2, 1 ); • Kompile, danjalankan program

  18. Rotasi • Kita dapatmerotasikanobjekdenganmempergunakan method yaw, pitch, dan roll baikdalam degree ataudalam radian. Entity *ent1 = mSceneMgr->createEntity( "Robot", "robot.mesh" ); SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode" ); node1->attachObject( ent1 );  node1->yaw( Degree( -90 ) ); Entity *ent2 = mSceneMgr->createEntity( "Robot2", "robot.mesh" ); SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode2", Vector3( 50, 0, 0 ) ); node2->attachObject( ent2 );  node2->pitch( Degree( -90 ) ); • Kompile, danjalankan program

  19. Kamera, BayangandanCahaya • Sebelumlebihlanjutmencobakamera, bayangandancahayapadaogre, kitaakanubahterlebihdahulukodepada class TutorialApplicationdenganmenambahkan method berikut virtual void createCamera(void) { }   virtual void createViewports(void) { }   void createScene(void) { Entity *ent; Light *light; }

  20. Kameradan Viewport • Kamera • objek special yang berkerjasepertiSceneNode • dipergunakanuntukmelihat scene • memilikifungsisetPosition, yaw, roll, dan pitch, danbisakita attach padaSceneNode • Viewport • menentukan scene manapadakamera yang akankita render

  21. MembuatKamera • TambahkankodeberikutpadaTutorialApplication::createCamera() // create the camera mCamera = mSceneMgr->createCamera("PlayerCam"); // set its position, direction mCamera->setPosition(Vector3(0,10,500)); mCamera->lookAt(Vector3(0,0,0)); mCamera->setNearClipDistance(5); • Perintahpertamamembuatkameradengannama “PlayerCam” • Perintahkeduamensetposisidarikamera, sedangperintahberikutnyamensetarahpandangkamera • Perintahterakhirmenentukanjarakterdekat yang terlihatkamera. • UntukmensetjarakterjauhgunakansetFarClipDistance.

  22. Membuat Viewport • TambahkankodeberikutpadaTutorialApplication::createViewport() // Create one viewport, entire window Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour(ColourValue(0,0,0)); // mengubah aspect ratio camera mCamera->setAspectRatio( Real(vp->getActualWidth()) / Real(vp->getActualHeight()) ); • Perintahmembuat viewport denganmenempelkansebuahkamerapada viewport. • Perintahkeduamenset background dari viewport. • Menset aspect ratio dari viewport.

  23. Bayangan (shadow) • SceneManagermemilikifungsisetShadowTechniqueuntukmenset type bayangan yang kitainginkan • Untukmencoba shadow pada Ogre, tambahkankodeberikutpadaTutorialApplication::createScene(); mSceneMgr->setAmbientLight(ColourValue(0, 0, 0)); mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE); // menambahkanobjek ent = mSceneMgr->createEntity("Ninja", "ninja.mesh"); ent->setCastShadows(true); mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent); // membuat ground tempat shadow diproyeksikan. Plane plane(Vector3::UNIT_Y, 0); MeshManager::getSingleton().createPlane("ground", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 1500,1500,20,20,true,1,5,5,Vector3::UNIT_Z); ent = mSceneMgr->createEntity("GroundEntity", "ground"); mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);

  24. Cahaya (Light) • Point (LT_POINT) • cahaya point memancarkancahayadarititikkesemuaarah • Spotlight (LT_SPOTLIGHT) • Cahayaakankeluarmelaluisuatuarahtertentu • Bisaditentukanbesarsudutlingkarandalamdanlingkaranluar • terangpada center, danlebihreduppadabagianluar • Directional (LT_DIRECTIONAL) • mensimulasikancahayajarakjauh yang menabrakapapunpada scene darisatuarah • menset directional light

  25. MembuatCahayapada Ogre[1] • TambahkankodeberikutpadaTutorialApplication::createScene light = mSceneMgr->createLight("Light1"); light->setType(Light::LT_POINT); light->setPosition(Vector3(0, 150, 250)); light->setDiffuseColour(1.0, 0.0, 0.0); light->setSpecularColour(1.0, 0.0, 0.0); • Kompiledanjalankanaplikasi. • Kita dapatkan ninja danbayangannya. • Lihatjuga ninja daridepan, makaakanterlihatada silhouette

  26. MembuatCahayapada Ogre[2] • TambahkankodeberikutpadaTutorialApplication::createScene() light = mSceneMgr->createLight("Light2"); light->setType(Light::LT_SPOTLIGHT); light->setDiffuseColour(0, 0, 1.0); light->setSpecularColour(0, 0, 1.0); light->setDirection(-1, -1, 0); light->setPosition(Vector3(300, 300, 0)); light->setSpotlightRange(Degree(35), Degree(50)); • Kompiledanjalankanaplikasi.

  27. MembuatCahayapada Ogre[3] • TambahkankodeberikutpadaTutorialApplication::createScene() light = mSceneMgr->createLight("Light3"); light->setType(Light::LT_DIRECTIONAL); light->setDiffuseColour(ColourValue(.25, .25, 0)); light->setSpecularColour(ColourValue(.25, .25, 0)); light->setDirection(Vector3( 0, -1, 1 )); • Kompiledanjalankanaplikasi.

  28. Selamatbersenang-senang

More Related