Useful Tools for Making Video Games - Ogre (2008)

24
Useful Tools for Making Video Games Part I An overview of Ogre

Transcript of Useful Tools for Making Video Games - Ogre (2008)

Page 1: Useful Tools for Making Video Games - Ogre (2008)

Useful Tools for Making Video Games

Part IAn overview of Ogre

Page 2: Useful Tools for Making Video Games - Ogre (2008)

Sample Games

Thunder WheelsKongMasterplanPacific StormTrampoline

Page 3: Useful Tools for Making Video Games - Ogre (2008)

Features

Graphics API independent 3D implementationPlatform independenceMaterial & Shader support

Well known texture formats: png, jpeg, tga, bmp, dds, dxt

Mesh support: Milkshape3D, 3D Studio Max, Maya, BlenderScene features

BSP, Octree plugins, hierarchical scene graphSpecial effects

Particle systems, skyboxes, billboarding, HUD, cube mapping, bump mapping, post-processing effects

Easy integration with physics librariesODE, Tokamak, Newton, OPCODE

Open source!

Page 4: Useful Tools for Making Video Games - Ogre (2008)

Core Objects

Page 5: Useful Tools for Making Video Games - Ogre (2008)

Startup Sequence

ExampleApplicationGo() Setup()Configure()setupResources()chooseSceneManager()createCamera()createViewport()createResourceListener()loadResources()createScene()frameStarted/Ended()createFrameListener()destroyScene()

Page 6: Useful Tools for Making Video Games - Ogre (2008)

Basic Scene

Entity, SceneNodeCamera, lights, shadowsBSP mapIntegrated ODE physicsBSP mapFrame listeners

Page 7: Useful Tools for Making Video Games - Ogre (2008)

Terrain, sky, fog

Page 8: Useful Tools for Making Video Games - Ogre (2008)

CEGUIWindow, panel, scrollbar, listbox, button, static textMedia/gui/ogregui.layout

CEGUI::Window* sheet =CEGUI::WindowManager::getSingleton().load

WindowLayout((CEGUI::utf8*)"ogregui.layout");mGUISystem->setGUISheet(sheet);

Page 9: Useful Tools for Making Video Games - Ogre (2008)

Animation

Node animation (camera, light sources)Skeletal AnimationAnimationState *mAnimationState; mAnimationState = ent-

>getAnimationState("Idle");mAnimationState->setLoop(true);mAnimationState->setEnabled(true); mAnimationState-

>addTime(evt.timeSinceLastFrame); mNode->rotate(quat);

Page 10: Useful Tools for Making Video Games - Ogre (2008)

Animation

Crowd (instancing vs single entity)InstancedGeometry* batch =

new InstancedGeometry(mCamera->getSceneManager(), "robots" );

batch->addEntity(ent, Vector3::ZERO);batch->build();

Facial animationVertexPoseKeyFrame* manualKeyFrame;manualKeyFrame->addPoseReference();manualKeyFrame->updatePoseReference

( ushort poseIndex, Real influence)

Page 11: Useful Tools for Making Video Games - Ogre (2008)

Picking

Page 12: Useful Tools for Making Video Games - Ogre (2008)

PickingCEGUI::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 }

Page 13: Useful Tools for Making Video Games - Ogre (2008)

Particle EffectsmSceneMgr->getRootSceneNode()-

>createChildSceneNode()->attachObject(

mSceneMgr->createParticleSystem("sil","Examples/sil"));

Examples/sil{

material Examples/Flare2particle_width 75particle_height 100cull_each falsequota 1000billboard_type oriented_self

// Area emitteremitter Point{

angle 30emission_rate 75time_to_live 2direction 0 1 0velocity_min 250velocity_max 300colour_range_start 0 0 0colour_range_end 1 1 1

}

// Gravityaffector LinearForce{

force_vector 0 -100 0force_application add

}

// Faderaffector ColourFader{

red -0.5green -0.5blue -0.5

}}

Page 14: Useful Tools for Making Video Games - Ogre (2008)

Particle Effects

Affectors (LinearForce, ColorFader)Linear Force AffectorColourFader AffectorColourFader2 AffectorScaler AffectorRotator AffectorColourInterpolator AffectorColourImage AffectorDeflectorPlane AffectorDirectionRandomiser Affector

Emitter attributes(point, box, clyinder, ellipsoid, hollow ellipsoid, ring)anglecolourcolour_range_startcolour_range_enddirectionemission_ratepositionvelocityvelocity_minvelocity_maxtime_to_livetime_to_live_mintime_to_live_maxdurationduration_minduration_maxrepeat_delayrepeat_delay_minrepeat_delay_max

Particle system attributesquotamaterialparticle_widthparticle_heightcull_eachbillboard_typebillboard_originbillboard_rotation_typecommon_directioncommon_up_vectorrenderersortedlocal_spacepoint_renderingaccurate_facingiteration_interval

nonvisible_update_timeout

Page 15: Useful Tools for Making Video Games - Ogre (2008)

Fire and Smoke

affector Rotator{

rotation_range_start 0rotation_range_end 360rotation_speed_range_start

60rotation_speed_range_end200

}

Page 16: Useful Tools for Making Video Games - Ogre (2008)

Cel Shadingvertex_program Ogre/CelShadingVP cg{

source Example_CelShading.cgentry_point main_vp…

default_params{…}

}

material Examples/CelShading{…

vertex_program_ref Ogre/CelShadingVP {}fragment_program_ref Ogre/CelShadingFP {}

}

Page 17: Useful Tools for Making Video Games - Ogre (2008)

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 bitcolour *= 1.7;

}

Page 18: Useful Tools for Making Video Games - Ogre (2008)

Bump Mapping

+ =

Page 19: Useful Tools for Making Video Games - Ogre (2008)

Reflections & Refractions// Noisetexture_unit{

// Perlin noise volumetexture waves2.dds// min / mag filtering, no mipfiltering linear linear none

}// Reflectiontexture_unit{

// Will be filled in at runtimetexture Reflectiontex_address_mode clamp// needed by ps.1.4tex_coord_set 1

}// Refractiontexture_unit{

// Will be filled in at runtimetexture Refractiontex_address_mode clamp// needed by ps.1.4tex_coord_set 2

}

Page 20: Useful Tools for Making Video Games - Ogre (2008)

Reflections & Refractions

Page 21: Useful Tools for Making Video Games - Ogre (2008)

Grass

Each grass section is 3 planes at 60 degrees to each otherNormals point straight up to simulate correct lighting

Page 22: Useful Tools for Making Video Games - Ogre (2008)

Post-Processing Effects

Page 23: Useful Tools for Making Video Games - Ogre (2008)

Supporting tools (add-ons)

Blender, Autodesk 3DS, Milkshape3D, Softimage XSI importers/exportersParticle editors, mesh viewersGUI editorsPhysics bindingsScene exporters and lots more

Add-on site

Page 24: Useful Tools for Making Video Games - Ogre (2008)

References

http://www.ogre3d.org/