240 likes | 255 Views
Useful Tools for Making Video Games. Part I An overview of Ogre. Sample Games. Thunder Wheels Kong Masterplan Pacific Storm Trampoline. Features. Graphics API independent 3D implementation Platform independence Material & Shader support
E N D
Useful Tools for Making Video Games Part I An overview of Ogre
Sample Games • Thunder Wheels • Kong • Masterplan • Pacific Storm • Trampoline
Features • Graphics API independent 3D implementation • Platform independence • Material & Shader support • Well known texture formats: png, jpeg, tga, bmp, dds, dxt • Mesh support: Milkshape3D, 3D Studio Max, Maya, Blender • Scene features • BSP, Octree plugins, hierarchical scene graph • Special effects • Particle systems, skyboxes, billboarding, HUD, cube mapping, bump mapping, post-processing effects • Easy integration with physics libraries • ODE, Tokamak, Newton, OPCODE • Open source!
Startup Sequence • ExampleApplication • Go() • Setup() • Configure() • setupResources() • chooseSceneManager() • createCamera() • createViewport() • createResourceListener() • loadResources() • createScene() • frameStarted/Ended() • createFrameListener() • destroyScene()
Basic Scene • Entity, SceneNode • Camera, lights, shadows • BSP map • Integrated ODE physics • BSP map • Frame listeners
CEGUI • Window, panel, scrollbar, listbox, button, static text • Media/gui/ogregui.layout CEGUI::Window* sheet = CEGUI::WindowManager::getSingleton().loadWindowLayout((CEGUI::utf8*)"ogregui.layout"); mGUISystem->setGUISheet(sheet);
Animation • Node animation (camera, light sources) • Skeletal Animation AnimationState *mAnimationState; mAnimationState = ent->getAnimationState("Idle"); mAnimationState->setLoop(true); mAnimationState->setEnabled(true); mAnimationState->addTime(evt.timeSinceLastFrame); mNode->rotate(quat);
Animation • Crowd (instancing vs single entity) InstancedGeometry* batch = new InstancedGeometry(mCamera->getSceneManager(), "robots" ); batch->addEntity(ent, Vector3::ZERO); batch->build(); • Facial animation VertexPoseKeyFrame* manualKeyFrame; manualKeyFrame->addPoseReference(); manualKeyFrame->updatePoseReference ( ushortposeIndex, Realinfluence)
Picking CEGUI::Point mousePos = CEGUI::MouseCursor::getSingleton().getPosition(); Ray mouseRay = mCamera->getCameraToViewportRay(mousePos.d_x/float(arg.state.width), mousePos.d_y/float(arg.state.height)); mRaySceneQuery->setRay(mouseRay); mRaySceneQuery->setSortByDistance(false); RaySceneQueryResult &result = mRaySceneQuery->execute(); RaySceneQueryResult::iterator mouseRayItr; Vector3 nodePos; for (mouseRayItr = result.begin(); mouseRayItr != result.end(); mouseRayItr++) { if (mouseRayItr->worldFragment) { nodePos = mouseRayItr->worldFragment->singleIntersection; break; } // if }
Particle Effects mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject( mSceneMgr->createParticleSystem("sil", "Examples/sil")); Examples/sil { material Examples/Flare2 particle_width 75 particle_height 100 cull_each false quota 1000 billboard_type oriented_self // Area emitter emitter Point { angle 30 emission_rate 75 time_to_live 2 direction 0 1 0 velocity_min 250 velocity_max 300 colour_range_start 0 0 0 colour_range_end 1 1 1 } // Gravity affector LinearForce { force_vector 0 -100 0 force_application add } // Fader affector ColourFader { red -0.5 green -0.5 blue -0.5 } }
Fire and Smoke affector Rotator { rotation_range_start 0 rotation_range_end 360 rotation_speed_range_start -60 rotation_speed_range_end 200 }
Cel Shading vertex_program Ogre/CelShadingVP cg { source Example_CelShading.cg entry_point main_vp … default_params { … } } material Examples/CelShading { … vertex_program_ref Ogre/CelShadingVP {} fragment_program_ref Ogre/CelShadingFP {} }
Cube Mapping • With Perlin noise to distort vertices void morningcubemap_fp ( float3 uv : TEXCOORD0, out float4 colour : COLOR, uniform samplerCUBE tex : register(s0) ) { colour = texCUBE(tex, uv); // blow out the light a bit colour *= 1.7; }
Bump Mapping + =
Reflections & Refractions // Noise texture_unit { // Perlin noise volume texture waves2.dds // min / mag filtering, no mip filtering linear linear none } // Reflection texture_unit { // Will be filled in at runtime texture Reflection tex_address_mode clamp // needed by ps.1.4 tex_coord_set 1 } // Refraction texture_unit { // Will be filled in at runtime texture Refraction tex_address_mode clamp // needed by ps.1.4 tex_coord_set 2 }
Grass Each grass section is 3 planes at 60 degrees to each other Normals point straight up to simulate correct lighting
Supporting tools (add-ons) • Blender, Autodesk 3DS, Milkshape3D, Softimage XSI importers/exporters • Particle editors, mesh viewers • GUI editors • Physics bindings • Scene exporters and lots more Add-on site
References • http://www.ogre3d.org/