Skip to main content

History: Snippets

Source of version: 11

Copy to clipboard
            {DIV()}{IMG(src="img/wiki_up/Codesnippets.jpg",imalign="left")}{IMG}
-=HOWTO's and Code Snippets=-
This is a cookbook of code recipies for implementing a wide variety of tasks. The mini articles below on this page are for articles of a significant size. See ((OogstsHowTo|The Big HOWTO)) and ((OogstsHowTo2|The Big HOWTO (II))) for a large collection of miscellaneous, smaller samples. Samples from external sites go on the ((Articles And Sources|External Resources)) page.{DIV}
%clear%
{toc}

!!HOWTO
((OogstsHowTo|HOWTO)) - Collection of miscellaneous, smaller samples

((OogstsHowTo2|HOWTO (II))) - Part 2

!!Geometry
!!!Vertex and Index Buffers
* ((Sharing buffers)) - Sharing vertex and index buffers across multiple meshes
* ((Generating A Mesh|Generating a Mesh)) - Example of creating a mesh in memory using a index and vertex buffer
* ((RetrieveVertexData|Retrieving vertex data from a mesh))
* ((DynamicGrowingBuffers|Dynamically growing vertex buffers))
* ((ManualSphereMeshes|Creating a sphere mesh manually with nice texture coordinates and normals))
* ((SuperEllipsoid|Using super ellipsoid for creating simple 3d primitives))
* ((GeometricMesh|Creating various geometric/geodesic shapes))
* ((A Series Of Tubes|Creates a set of tubes along a path))
* ((Changing Coordinate Handedness)) - One way of using DirectX data

!!!Manual Object
* ((ManualObject)) - A minimal example
* ((ManualObject 2D)) - A minimal example (Eihort only)
* ((ManualObject AxisObject)) - A simple Axis using box's.
* ((EditorGridSystem)) - A dynamically changing grid system for editors and such
* ((Create Tetrahedron with MOGRE)) (easy to port for Ogre)
* ((Loading from VRML 2.0 / X3D|Loading from VRML)) - Load/create an entity from a VRML 2.0 / X3D format (using CyberX3D)

!!!General
* ((Setting a vector's length))
* ((Nearest point on a line)) - Find the nearest point on a line between two points
* ((2D line intersection)) - do 2 lines described by 4 vertices in a plane intersect?
* ((Find Spline index)) - from global interpolation value
* ((Raycasting to the polygon level)) - how to see if a line intersects with a mesh's geometry
* ((GetScreenspaceCoords|Get Screenspace Coordinates)) - Get the screenspace (2D) coordinates of a MovableObject.
* ((Projecting 3D position and size to 2D))
* ((Equal Length Spline)) - Generating new spline (based on SimpleSpline) which has equal distance between points.
* ((Nearest point on a Spline)) - From "Robust and Efficient Computation of the Closest Point on a Spline Curve"
* ((Get XZ coordinates|Get XZ coordinates)) - Retrieve XZ coordinates by a mouse ray

!!Rendering
* ((SpriteManager2d|2D Sprite Manager)): A class for rendering 2D sprites, ie: the ((DirectDraw)) way.

{DL()}
((MOGRE SpriteManager2d))
{DL}

* ((Line 3D|Drawing Lines in 3D))
* ((DynamicLineDrawing|Drawing lines in 3D revisited)): Example of ((DynamicGrowingBuffers|dynamic buffers code)).
* ((Circle3D|Drawing Circles in 3D))
* ((Displaying 2D Backgrounds))
* ((Displaying LensFlare|Displaying a Lens Flare Effect))
* ((Faking HDR|HDR Effects Without Using Full Floating Point Textures))
* ((MovableText|Billboard-style Text in 3D)): MovableText

{DL()}
((MOGRE MovableText))
{DL}

* ((OgreSprites|A More In-Depth Version of the 2D Sprite Manager))
* ((Oriented Bounding Box))

!!Non-Photorealistic Rendering
* ((Non-Photorealistic Rendering))

!!Materials & Textures
* ((URLArchive|Loading resources from a URL)) - an Archive class for external resources.
* ((ProxyArchive|Merging and transforming archives)) - an Archive implementations that provide various transforms (resource overrides, file name prefixes).
* ((Creating dynamic textures)) - and materials using them.
* ((Saving dynamic textures))
* ((Per renderable transparency)) - Utility classes to allow single renderables (Entities and SubEntities so far) to change their transparency without changing others that use the same material through a MaterialInstance utility class. See [http://www.ogre3d.org/phpBB2/viewtopic.php?t=10767|this forum thread]
* ((Exporting3DTextures|Exporting 3D Textures)) - The (programmatic) generation of .dds and .raw 3D textures for use in Ogre.
* ((MaterialExamples|Material script examples)) - some example materials
* ((RotatingATextureUsingGetYaw|Rotating a texture using the ~np~getYaw()~/np~ function)) - How to rotate a texture 360 degrees with the quaternion.getYaw() function
* ((ObjectTextDisplay|Displaying 3D Object Text in 2D Without Using Billboards)) -- How to use the view transform to obtain 2D screen-space coordinates to draw overlay text above or near an object in the 3D scene.
* ((MovableTextOverlay|Displaying non-overlapping Text Overlays above Ogre MovableObjects)) -- Some enhancements to the ((ObjectTextDisplay|Xavier's ObjectTextDisplay)) class resulted in 3 classes that do all the work for you. Enjoy!
* ((ObjectTitle)) - Display a title (text overlay) above a MovableObject
* ((PGF|Loading PGF Images)) -- Source code for loading PGF images using libPGF in Ogre
* ((TerrainMeshDecal|Terrain Selection using a Mesh Decal)) -- using a mesh decal to show a marker on the terrain for terrain selection
* ((Light mapping)) -- A class used to do lightmapping in ogre.
* ((Reloading materials and parsing material scripts)) -- Ogre helper methods to reload all the materials found in a material script.
* ((Extending the Ogre GUI demo to reload textures on the fly)) -- A small extension to add a reload button to the Ogre GUI demo that makes customizing TaharezLook.tga faster.
* ((ColoredTextAreaOverlayElement)) -- A class to allow Quake 3 style color codes to be inserted into text overlay elements.
* ((FadeEffectOverlay|Fade In/Out Effect Overlay)) -- Create an overlay that lets you create fade in/out effects in your scene.
* ((CropImage|Crop Image)) -- Crop an Image into a smaller image.
* ((Creating transparency based on a key colour in code))
* ((Merge exe with a media zip)) -- Embed a zip file of media within an ogre application executable.

!!Particles
* ((ParticleExampleSun|Sun Effect)) - An Example Particle Script
* ((Moving Space Dust Effect)) - A Space Dust Effect
* ((InterpolationAffector|Interpolation Affector)) - A particle affector to vary size, rotation and velocity of particles.
* ((IteratedFractal|Iterated Fractals)) - Using ((ManualObject))s as Point Sprites to create a Pickover attractor (updates in real-time with a ''million or more'' points!)
* ((ParticleExampleSun)) - particle code + how to use
* ((MeshEmitter)) - an emitter class + example
!!Shaders
* ((ShaderIntroduction|Introduction)) - How to submit a shader
* ((Getting Started With Ogre CG Materials))
* ((How To Compile CG Files|How to compile CG code)) - How to check for errors in .cg code
* ((Orange Shader)) - A simple shader
* ((Fading Object Shader)) - A fade-to-dark effect
* ((Holographe Shader)) - An hologram effect
* ((PerPixel Lighting)) - Basic per-pixel, rather slow, texturing included
* ((PerPixel Lighting II))
* ((The Monster)) - Tuneable parameters, feature-full, 1-pass, max 3 lights
* ((Normal AO Specular Mapping Shader)) - normal/diffuse/AO/specular mapping
* ((Shadows)) - How to start on Shadows
* ((Depth Shadow Mapping)) - How to implement depth shadow mapping in your own project as seen in the Shadows demo
* ((Custom Shadow Mapping)) - How to implement a custom shadow technique
* ((Parallel Split Shadow Mapping)) (PSSM) - A method for high-detail shadows
* ((Offset Bump Ambient Lightmap)) - Offset/Bump with added ambient and optional lightmap
* ((OceanFog|Ocean Fog)) - Basic underwater "depth" effect using the Ocean Shader
* ((Normal Mapping with Hardware Skinning and Specular)) - Combined normal mapping and hardware skinning
* ((Smoke Trails)) - Adding some turbulence to your ribbon trails
* ((Terrain Alpha Splatting)) - Basic terrain shader with up to 8 splat textures.

!!Animation & Movement
* ((RotateYawOnly|Rotating yaw while ignoring pitch and roll))
* ((ManuallyControllingBones|Manually Controlling Bones))
* ((3rd person camera system tutorial)) - How to create a basic, flexible camera system
* [http://ox.slug.louisville.edu/~o0lozi01/wiki/index.php/RGF:_Physics_Loader|Integrating Physics and OGRE from XML] - Creating and loading physical structures from XML and automatically linking them to Ogre models.
* ((How to limit the pitch of a camera))
* ((Creating a simple first-person camera system))
* ((Generic Manual Pose Loading))
* ((Make A Character Look At The Camera|Make a character look at the camera)) Using quaternions and SLERP to make a character look at a camera(or any other object for that matter) naturally, with constraints on head movement
* ((Euler Angle Class)) - An Ogre compatible class for euler angles.
* ((How to drive a car)) - You have a car, you have a point (i.e. waypoint), but you don't know how to determine side car should turn to drive to point(left or right).
* ((Controlling car on twisted track)) - Controlling car on crazy, twisted tracks using physics engine.
* [http://ogre-ccs.sourceforge.net|Creating a camera sontrol system] - A plugin for managing and creating custom camera modes. 

!!Input
* ((Head Tracking using the WiiMote))
* ((ThreeDeeObjectPicking|3D Object Picking)) - cTh (bad camel screen to 3D coord translation)
* ((KeyboardTranslator|Translate from english keyboard layout to any other, for instance german))
* ((GII|Using OGRE with GII)) Using OGRE with the GII input library
* ((Using OIS)) Using the Object-orientated Input System Library with OGRE
* ((Pick Drag Drop)) - How to make drag&drop objects
* ((Simple keyboard string editing)) - A small class to take key presses and edit a string.
* ((Auto Repeat Key Input)) - A small class to take key presses and auto repeat keyboard input for GUI.

!!GUI
* ((UOgreBrowser)) - Embedding uBrowser in an Ogre application
* ((Using Ogre with FLTK FLUID)) - Tutorial

!!!CEGUI
* ((CEGUICommonFileDialog|CEGUI Common File Dialog)) - CEGUI Common file dialog
* ((Initial Mouse Position With OIS and CEGUI)) - How to initialize the mouse cursor to a starting position
* ((CEGUIBuildDialog|CEGUI Build Dialog)) - CEGUI dialog which displays rotating 3D meshes on multiple buttons
* ((How To Show The Mouse Cursor)) - Showing the mouse using CEGUI
* ((Creating a good looking Confirm Dialog with CEGUI))
* ((Update Ogre source code with latest Cegui source code))

!!!Other GUI Systems
* ((Comparison of GUIs)) - This page contains a comparison of the various GUI systems available
* ((Integrating OpenGUI)) - How to integrate OpenGUI in Ogre projects
* ((MyGUI quickstart)) - How to add a GUI with button

!!!General
* ((Creating Overlays via Code))
* ((PieSliceOverlay|PieSlice Overlay)) - Useful for pie charts, sniper scopes, rev counters and other such circular GUI elements.
* ((How to show the Mouse Cursor W/O CEGUI))
* ((Simple Text Output)) - Simple text output using overlays.
* ((Scrolling Message)) - Scrolling messages which is based on the Simple Text Output above.
* ((OgreFontHelper)) utils for rendering text if Ogre::TextAreaOverlayElement is not enough
* ((Reading a Unicode Multi Language Translation Table)) - A How To with code for creating, reading, and using a Unicode translation table
* ((ColoredTextAreaOverlayElement)) - Extension for the ''TextAreaOverlayElement''

!!!Embedding OGRE in mainstream GUI libraries
* ((Using Ogre with FLTK)) - Here presented a way to embed Ogre into FLTK gui toolkit window
* ((wxOgre)) - A simple rendering widget for wxWindows (OGRE V1.0.1)
* ((wxOgre for OGRE v1.2)) - A simple rendering widget for wxWindows (OGRE V1.2)
* ((wxOgre for OGRE v1.4)) - A simple rendering widget for wxWindows 2.8 <- Most Recent.
* ((wxOgreView)) - A minimalistic C++ class providing Ogre render windows within wxWidgets
* ((GtkOgre)) - A GtkWidget for embedding Ogre render windows in GTK.
* ((GtkmmOgre)) - A GtkmmOgreWidget for embedding Ogre render windows in Gtkmm.
* ((qtOgre)) - Embedding Ogre into a qt application.

!!Sound & multimedia
* ((FMOD SoundManager)) - SoundManager using FMOD
* ((OpenAL|OpenAL SoundManager)) - SoundManager using OpenAl
* ((DirectShow video in ogre texture|DirectShow video on a texture)) - how to play video with Direct Show in Ogre textures

!!Physics
* ((BulletMeshStrider|Mesh strider for bullet)) - Subclass from btStridingMeshInterface for sharing graphics and collision meshes

* ((BulletDebugDrawer|Debug drawer for bullet)) - Subclass from btIDebugDraw that allows you to visualize collision shapes, contact points and more.

* ((NxOgreTerrainHeightfield|Build a Manual TerrainHeightField with NxOgre)) - A simple function to get a Heightfield in NxOgre similar to an Ogre Terrain

!!System
!!!Minimal Ogre projects
* ((Basic Ogre Framework)) A fully featured, yet clean base application.
* ((Project base)) - A blank project to use as the base of your own. Get all the messy initial details out of the way with this 1000+ line boilerplate.
* ((MinimalApplication|Minimal Application)) a minimal app __without__ using exampleApplication.h
* ((Hello World with minimal Ogre init)): Hello World without using ExampleApplication.h or resource scripts
* ((MinimalPracticalApplication|Minimal Practical Application)) a minimal application using it's own main loop and plugin loading
* ((One Function Ogre)): Exploring how to start Ogre without using ExampleApplication.h or the built in Config Dialog

!!!Timer
* ((TimerManager)) - Wrapping Ogre::Timer to issue callbacks
* ((Assaf Muller's Timer Manager)) - A timer manager to help you access timers from anywhere

!!!Logging
* ((DumpingNodeTree|Dumping a node tree to the log))
* [http://www.opengameengine.org/wiki/index.php?title=LogManager|Easy Logging Manager]
* [http://ox.slug.louisville.edu/~o0lozi01/wiki/index.php/Rumble_Game_Framework:_Step_Log|Logging Frequently Changing Variables]

!!!Console
* ((ConsoleCode|Creating a Scalable Console))
* ((OgreConsole|OgreConsole - A simple graphical console))
* ((LuaConsole|A Lua in game console, loosely based on the above "Creating a Scalable Console"))

!!!OS tricks
* ((Change of a icon and caption of the Application)) Simple way.
* ((Custom Icon and Cursor)) Even Simpler Way.
* ((GetExecutablePath|Find path to executable to locate data files))
* ((ProjectPaths|How to make your project paths cross platform))
* ((LinuxDrivers|Installing Video Drivers On Linux))
* ((Linux Material Scripts Parsing|Solve ''*.material'' scripts parsing problems on Linux))
* ((DetectAC|Detect AC power status on Windows))

!!!Scene manager
* ((ChangeSceneManagerRunTime|Change the scenemanager at runtime))

!!!Render system
* ((SafelyLoadingRenderSystems|How to safely load rendersystems without a crash)) (as in, fail gracefully on systems that lack DirectX or GL)
* ((FlushGPUBuffer|How to flush the GPU command buffer regularly))

!!!Script compilers (Shoggoth)
* ((NewScriptFeatures|New Scripting Features))
* ((ExtendingScriptCompilers|Extending compiler with new scripting systems))

!!!Misc
* [http://ox.slug.louisville.edu/~o0lozi01/wiki/index.php/Rumble_Game_Framework:_OGRE_Particle_Manager|Controlling Particle Systems]
* ((LoadingMeshesWithoutOgre|How to load a mesh without initialising the Ogre renderer))
* ((Loading Animations without a RenderSystem|How to load and play animations without initialising the Ogre renderer))
* [http://ox.slug.louisville.edu/~o0lozi01/wiki/index.php/RGF:_XML_Tools|Parsing XML Files]
* ((Camcorder|A simple camcorder class for recording & playing back camera paths))
* ((Creating A Plugin DLL|A short example on how to create a plugin DLL that is loaded by Ogre at startup.))
* ((Loading Meshes From Any Path|How to load a mesh not under the predefined resource path.))

!!Miscellaneous
* ((Easy debug text)) - uses the default ogre debug overlay text on the OgreDebugPanel ((overlay))
* ((High resolution screenshots)) - how to make screenshots of unlimited size
* ((Printf with ogre)) - a simple class that lets you use printf with ogre.
* ((DotScene Loader with User Data)) - code for loading .scene files
* ((DotScene Loader with User Data Class)) - code for loading .scene files too
* ((Frustum Culling In Object Space)) - frustum culling using a custom SimpleFrustum class.
* ((HowTo: Write text on texture|Writing text on texture)) - how to write text onto a texture.
* ((All-purpose script parser)) - allows you to load your own custom data from Ogre-style scripts
* ((Query Ogre Version)) - a shell extension which allows to know the version of Ogre I'm working on
* ((MovableTextOverlay)) - display a text above an object (((HUD)) / heads up display)
* ((Ogre Compatible HeightMap)) - get height of terrain at (x,z) positions
* ((Set icon of Window (Mogre)))
* ((TinyXMLResource)) - use TinyXML documents via Ogres resource system
* ((AI Agent Control)) - AI Agent control code snippets

!!Useful Code Articles (w/code)
* [http://www.gamedev.net/reference/programming/features/coretree1/|std::map<> versus core::tree<>] - Gamedev.net
* [http://www.gamedev.net/columns/hardcore/softedgeshadow/|Soft Edge Shadows] - Gamedev.net
* [http://www.codeguru.com/Cpp/Cpp/cpp_mfc/callbacks/article.php/c10557/#more|Callbacks] - CodeGuru
* [http://www.newty.de/fpt/fpt.html|Function Pointers] - Newty.DE
* [http://www.eskimo.com/~scs/cclass/int/sx10a.html|Function Pointers] - Eskimo.com
* [http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.10|Pointers to Member Functions] - Parashift
* [http://www.codeproject.com/useritems/fd.asp|Fast Delegates] - The Code Project

---
Alias: (alias(CodeSnippets))
        

History

Information Version
Thu 29 of Mar, 2012 12:35 GMT-0000 icaro56 [rollback version 64] 66
Mon 17 of Dec, 2012 17:22 GMT-0000 drwbns 65
Thu 29 of Mar, 2012 12:32 GMT-0000 icaro56 63
Tue 15 of Nov, 2011 10:13 GMT-0000 spacegaier added alias 62
Sun 31 of Jul, 2011 23:09 GMT-0000 jacmoe 61
Sat 08 of May, 2010 17:35 GMT-0000 jacmoe 60
Thu 07 of Jan, 2010 22:56 GMT-0000 jacmoe 59
Thu 07 of Jan, 2010 22:56 GMT-0000 jacmoe 58
Mon 04 of Jan, 2010 01:52 GMT-0000 jacmoe 57
Sun 03 of Jan, 2010 04:39 GMT-0000 jacmoe 56
Sun 03 of Jan, 2010 04:38 GMT-0000 jacmoe 55
Sun 03 of Jan, 2010 03:30 GMT-0000 jacmoe 54
Sun 03 of Jan, 2010 03:27 GMT-0000 jacmoe 53
Sun 03 of Jan, 2010 03:26 GMT-0000 jacmoe 52
Sun 03 of Jan, 2010 03:18 GMT-0000 jacmoe 51
Sun 03 of Jan, 2010 03:18 GMT-0000 jacmoe 50
Sun 03 of Jan, 2010 03:16 GMT-0000 jacmoe 49
Sun 03 of Jan, 2010 03:05 GMT-0000 jacmoe 48
Sun 03 of Jan, 2010 02:46 GMT-0000 jacmoe 47
Sun 03 of Jan, 2010 02:35 GMT-0000 jacmoe 46
Sun 03 of Jan, 2010 02:31 GMT-0000 jacmoe 45
Sun 03 of Jan, 2010 02:25 GMT-0000 jacmoe 44
Sun 03 of Jan, 2010 02:19 GMT-0000 jacmoe 43
Sun 03 of Jan, 2010 02:17 GMT-0000 jacmoe 42
Sun 03 of Jan, 2010 01:42 GMT-0000 jacmoe 41