useful tools for making video games - ogre (2008)
TRANSCRIPT
Useful Tools for Making Video Games
Part IAn overview of Ogre
Sample Games
Thunder WheelsKongMasterplanPacific StormTrampoline
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!
Core Objects
Startup Sequence
ExampleApplicationGo() Setup()Configure()setupResources()chooseSceneManager()createCamera()createViewport()createResourceListener()loadResources()createScene()frameStarted/Ended()createFrameListener()destroyScene()
Basic Scene
Entity, SceneNodeCamera, lights, shadowsBSP mapIntegrated ODE physicsBSP mapFrame listeners
Terrain, sky, fog
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);
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);
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)
Picking
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 }
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
}}
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
Fire and Smoke
affector Rotator{
rotation_range_start 0rotation_range_end 360rotation_speed_range_start
60rotation_speed_range_end200
}
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 {}
}
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;
}
Bump Mapping
+ =
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
}
Reflections & Refractions
Grass
Each grass section is 3 planes at 60 degrees to each otherNormals point straight up to simulate correct lighting
Post-Processing Effects
Supporting tools (add-ons)
Blender, Autodesk 3DS, Milkshape3D, Softimage XSI importers/exportersParticle editors, mesh viewersGUI editorsPhysics bindingsScene exporters and lots more
Add-on site
References
http://www.ogre3d.org/