mogre
Download
Skip this Video
Download Presentation
MOGRE

Loading in 2 Seconds...

play fullscreen
1 / 31

MOGRE - PowerPoint PPT Presentation


  • 106 Views
  • Uploaded on

MOGRE. Introduction. At the end of this lecture you will be able to: Understand ways of using OGRE in languages other than C++ Understand what MOGRE is Understand the advantages and disadvantages of using MOGRE Understand the process of how to install and setup MOGRE

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' MOGRE' - skip


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
introduction
Introduction
  • At the end of this lecture you will be able to:
    • Understand ways of using OGRE in languages other than C++
    • Understand what MOGRE is
    • Understand the advantages and disadvantages of using MOGRE
    • Understand the process of how to install and setup MOGRE
    • Learn how to embed MOGRE into a Windows Form
    • Learn how to perform basic input processing in MOGRE
references
References
  • http://www.ogre3d.org/wiki/index.php/MOGRE
using ogre in toolset dev
Using OGRE in Toolset Dev
  • Under Windows, OGRE and it’s plugins are written and built as a set of C++ static import and dynamic linked libraries
  • To use it natively, the client code needs to be also written in C++
  • This is optimal for games programming where the power and speed of C++ is essential
using ogre in toolset dev1
Using OGRE in Toolset Dev
  • For toolset development, performance is not so much a high priority compared to fast development time
  • Development in C++ usually incurs longer development times (due to memory management, debugging, syntactical issues, etc.)
  • What would be ideal would be a means of using OGRE and accessing all it’s the functionality within another programming language which may better support RAD for the programming team
  • Reflective of industry game/graphics engines
ogre for other languages
OGRE for Other Languages
  • Axiom
    • C# port of OGRE
  • MOGRE
    • .NET wrapper for OGRE, with porting of some elements
  • OgreDotNet
    • Another .NET wrapper, though support and maintenance has lapsed since OGRE release 1.2
  • PyOgre
    • Binding for Python
  • Ogre4j
    • Bindings for Java
what is mogre
What is MOGRE?
  • Stands for Managed OGRE
    • .NET 2.0 wrapper for the OGRE
  • Allows the OGRE rendering engine to be used by .NET programming languages
    • C#, VB.NET, Managed C++ etc.
  • Also wraps the Newton physics library with MogreNewt.
  • Currently supports OGRE Eihort 1.4.0 (Final)
benefits of mogre
Benefits of MOGRE
  • Application code can be developed in .NET languages
    • Can make use of all the in-built windows GUI forms and controls provided as part of the .NET framework
    • Garbage collection
    • Generally faster to time develop – aligned with Rapid Applications Development paradigm
benefits of mogre1
Benefits of MOGRE
  • OGRE use with .NET languages, getting all associated benefits of the .NET framework.
  • Mogre releases are very responsive to OGRE code updates ( compared to a full .NET port of OGRE – like AXIOM ), as the majority of the Mogre wrapper classes can be auto-generated from the OGRE source
  • To date, most proven responsiveness to changes in OGRE
benefits of mogre2
Benefits of MOGRE
  • Clients know that, under the hood, they are still mainly getting OGRE, rather than a rewrite ( with possible new bugs introduced, etc )
  • Benefit and tradeoff profile is perfectly suited to game toolset development – where performance speed can be sacrificed for faster time to develop and responsiveness to change
  • .NET attractive to future direction of games industry
disadvantages of mogre
Disadvantages of MOGRE
  • Performance will not be optimal compared to developing in purely unmanaged languages like C/C++
  • The wrapper objects introduces an extra layer of processing to delegate calls to OGRE – a performance hit
  • The OGRE source is modified, meaning that the OGRE code cannot be used as-is and all Mogre updates will also have it’s own special OGRE release ( with the appropriate source modifications ) coupled with it
disadvantages of mogre1
Disadvantages of MOGRE
  • The original creator and maintainer will be leaving the project May 2007 ( however, other people have offered to step up and take over the role )
how mogre works
How MOGRE Works
  • Set of managed C++.NET wrapper classes
  • Wrapper classes are created for every underlying C++ OGRE class types
  • These wrapper classes attempt to expose the same C++ interface supported by the underlying classes, to encourage consistency
  • Additional .NET features are supported:
    • E.g. properties are used instead of get/set accessors
  • Under the hood, these wrapper objects delegate all calls to an internal, unmanaged OGRE C++ object
how mogre works1
How MOGRE Works
  • MOGRE is built into a single .dll assembly which is included as a reference in all client .NET projects
  • All classes and types are contained within the MOGRE namespace
  • From a programming clients point of view, calls are simply made using a .NET interface.
  • The author of MOGRE uses a custom in-house tool to auto-generate the wrapper code from original OGRE source
how mogre works2
How MOGRE Works
  • MOGRE actually modifies the OGRE source code, so it is not a pure “layered” wrapper as such
  • These code modifications efficiently deal with the management of the internal OGRE object, promoting faster access
  • External OGRE plugins will need to be recompiled with the modified Mogre interfaces in order to be used successfully within Mogre
  • For speed benefits, some elements of OGRE are totally rewritten in C++.NET rather than wrapped, mainly many of the maths classes
mogre vs ogre
MOGRE vs OGRE
  • MOGRE methods use PascalCase rather than camelCase
  • OGRE’s get…(), set…(), and is…() methods are converted to properties under MOGRE
  • Properties with the first letter being in lower case indicates not an accessor, but a public exposure of the underlying class member
mogre vs ogre1
MOGRE vs OGRE
  • In place of OGRE’s listener functions, MOGRE uses .NET events and delegate functions

mRoot.FrameStarted += new FrameListener.FrameStartedHandler(Skeletal_FrameStarted);

    • FrameStarted: the event
    • FrameListener.FrameStartedHandler: the delegate( for naming clarification )
    • Skeletal_FrameStarted: the function
mogre installation
MOGRE Installation
  • Download the MOGRE 0.2.0 + OGRE 1.4.0 SDK installer from the MOGRE Wiki page
    • http://www.ogre3d.org/wiki/index.php/MOGRE
  • Run the Installer
  • Can specify a different install directory if desired (OGRE_HOME environment variable will be appropriately set)
  • Ensure the we have Visual Studio 8 SP1 installed
  • New Dlls for MOGRE:
    • Mogre.dll
    • MogreNewt.dll
  • These need to be copied to the project’s output/working directory where all the existing OGRE dlls are
setting up mogre project
Setting Up MOGRE Project
  • Add Reference to Mogre.dll
  • Two alternatives for setting the output location
    • Use the Mogre SDKs output path
      • Add the following to Properties->Build Events->post build event:

copy "$(TargetPath)" "%OGRE_HOME%\bin\$(ConfigurationName)“

    • Create our own output directory:
      • Ensure that all the required .dll files are copied
      • Ensure all the paths in the .cfg files are correct
executing mogre projects
Executing MOGRE Projects
  • Two alternatives for how to execute MOGRE Projects:
    • Directly navigate to the output directory and run the compiled .exe file
    • To run ( and debug) within Visual Studio’s IDE:
      • Point Properties->Debug->Start external programto the output .exe ( where the assocated .dlls and .cfg files are )
      • Point Properties->Debug- >Working directoryto the path where the output .exe and .dlls and .cfg files are located
mogreframework
MogreFramework
  • Similar to the ExampleApplication framework provided and used for the OGRE samples
  • Written in C# and supports MOGRE
  • Usage is very similar
  • Creates its own window so not suitable out-of-the box for Win Forms integration
mogre and win forms
MOGRE and Win Forms
  • Create a C# Windows Form in Visual Studio
  • During Form intialisation, perform the usual OGRE setup sequence, up to the creation of the render window, i.e.
    • Create root
    • Load config file
    • Add resource locations
    • Set render system
mogre and win forms1
MOGRE and Win Forms
  • We need to create a render window manually to get MOGRE to embed itself into the form rather than create it’s own separate window – as in the MogreFramework

mRoot.Initialise(false, "Main Ogre Window");

NameValuePairList misc = new NameValuePairList();

misc["externalWindowHandle"] = Handle.ToString();

RenderWindow window = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);

mogre and win forms2
MOGRE and Win Forms
  • MOGRE can be embedded to controls as well as forms
  • Multiple render windows can be created and attached to independent controls / forms
  • The rest of the setup process can then proceed, ie:
    • Initialise resource groups
    • Create scenemanager
    • Create camera
    • Create viewport
    • Create scene
    • Position camera
    • Etc…
mogre and win forms3
MOGRE and Win Forms
  • Other considerations:
    • Disposing of the MOGRE root object when the form disposes
      • Create an event handler and attach to .Disposed event of the form
      • Call m_Root.Dispose();
    • Resizing MOGRE window when the form is resized
      • Create an event handler and attach to .Resize event of form
      • Call m_Window.WindowMovedOrResized();
mogre and win forms4
MOGRE and Win Forms
  • The render loop:

Show();

while (mRoot != null && mRoot.RenderOneFrame())

{

Application.DoEvents();

}

mogre and win froms
MOGRE and Win Froms
  • Refer to:

http://www.ogre3d.org/tikiwiki/Mogre+Basic+Tutorial+6

for full code listing

keyboard and mouse input
Keyboard and Mouse Input
  • For basic, buffered keyboard and mouse input, the .NET Framework’s input system can be used
  • Use the appropriate Key and Mouse events and attach corresponding Key and Mouse Input Handlers

this.KeyDown += new KeyEventHandler(KeyDownHandler);

void KeyDownHandler(object sender, KeyEventArgs e)

{

switch (e.KeyCode)

{

case Keys.I:

etc..

keyboard and mouse input1
Keyboard and Mouse Input

this.MouseDown += new MouseEventHandler(MouseDownHandler);

void MouseDownHandler(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Middle)

etc..

keyboard and mouse input2
Keyboard and Mouse Input
  • Another advantage of using MOGRE and .NET is that individual forms and controls can be given individual input handlers
  • This allows easier implementation of the multiple viewport type presentation typical of scene editors
  • e.g. when the mouse is dragged whilst in the perspective viewport, only the scene in that viewport is rotated, panned, zoomed etc.
lecture review
Lecture Review
  • Understand ways of using OGRE in languages other than C++
  • Understand what MOGRE is
  • Understand the advantages and disadvantages of using MOGRE
  • Understand the process of how to install and setup MOGRE
  • Learn how to embed MOGRE into a Windows Form
  • Learn how to perform basic input processing in MOGRE
ad