I have uploaded the demo project in 2 parts. (Sorry :-( OGRE is quite large and I couldn't upload 1 file.)
Extract both of the zip files into the same place before running the demo.
e.g. in winzip click "extract" -> "c:\temp" (same process for both)
Your directory structure should look like this once completed doing so:
..\OgreInWpf\DemoApps
..\OgreInWpf\Libraries
..\OgreInWpf\Media (MUST EXIST)
..\OgreInWpf\Release (goto this folder to run the demos)
With This You Can... the 10 second overview
- Blend a First Class Gaming Graphics Engine into a First Class Presentation System.
- Spill your coffee over your keyboard as you see just how cool your UI look and feel can be.
References
Requirements
- Visual Studio 2008
- .Net framework 3.5 (Service Pack 1)
- A reasonable graphics card. This project might not run on all computers. I have only tested it on NVidia cards.
Introduction
The Viewport3D control in the WPF is pretty useful, but it lacks the cool tweakiness of a proper graphics engine, e.g:
- performance critical features like scene paging and "level of detail" meshes allowing large meshes to be displayed using different configurations; a hi-polygon version when near to the camera for when high definition is important, and with a low-polygon version when far away from the camera.
- GPU (Graphics Processor) scripts for DirectX Pixel Shaders to achieve scene blurring, or to simulate night vision goggles. Now, I'm not talking about the GPU code itself, because the new 3.5 SP1 framework has got GPU Bitmap effects, I'm talking about making it easy and maintainable to apply these kinky features by having a scripting resource mechanism so you don't even have to write a line of code to include fancy first rate materials features in your scene. (Well one line ;-) This allows you to change the object's materials easily and without any re-compiling. No mess, no fuss.
- Proper package resource management for your textures, scripts, GPU Shaders, animations etc.
- Plenty of other stuff which you'll need, even before you get to the physics, sound, AI and actual gaming side...
As you can see there really is a lot of technology that goes into a modern game and animation effects. Now, graphics aside what about all this behaving itself on your desktop, reading office documents, allowing a user to work in an interface that's funky, themable, supports data binding, web services, swanky smoke effects, etc...
Missing the good old days of Pac-man and DOS ?. It all seemed so much simpler back then. I know I sometimes do.... um, miss DOS, not seem simple. Though I know people that might argue that point.
Not convinced...ok, ok, say your boss comes to you and says, "Frank", cause that's your name...you know, or Bob.
"Frank" he says, "we need to write an application for the 'Smokey Cheese Company', that has, ok, get this, a swift little smoke effect on the main screen, see, bellowing smoke into the air -", (I can do this you say to yourself, you know, graphics isn't too hard) ...", the boss continues, " - over their scrolling logo and displays a list of stuff from a web service where the user can click - "
Ok now it's getting a bit harder all of a sudden because graphics engines don't have very good UI controls (the boss still hasn't stopped talking by the way)
- "..blah blah, by Friday!", the boss finishes.
Unfortunately Bob is out for tea.
The Fluffy Bunny Of Doom syndrome.
Each a do-able task in their own right?. Integration people, that's what I'm talking about.
Enter Stage (left): The OgreImage Class
Ogre loading
Sweet particle effects
Realtime TV compositor effect
The OgreImage class is just like any of the other WPF ImageSource classes. An image source can be used as a brush for a background, for text, or displayed in an Image control and the OgreImage is no different, except that it has all the functionality of a First Class Graphics Engine. It has been based on the new D3DImage (system.windows.interop.d3dimage.aspx) class which is part of the Framework 3.5 SP 1 update.
I have, in the simplest way implemented the process of hosting the OGRE engine in the DirectX context of the D3DImage class. That is to say, you will still need to interact with the OGRE library via the MOGRE library as any other .NET OGRE application, but won't have to deal with screen re-sizing and DirectX device loss/management issues. One thing I have implemented is asynchronous loading of the OGRE resources and have included a progress event system to allow for the a progress indicator implementation (see example). I've done this because OGRE Engine can take a while to start-up.
There is currently no implementation of a control similar to the Viewport3D, but I'm hoping to expand on this project and to xaml-fy it more to allow for the entire scene to be constructed in xaml.
How To Use It
Exactly like you might have displayed a bitmap in the Image control you could do the following:
The ImageSource
<Image x:Name="RenterTargetControl"
Stretch="Fill"
SizeChanged="RenterTargetControl_SizeChanged"
MouseDown="RenterTargetControl_MouseDown"
<Image.Source>
<OgreLib:OgreImage x:Name="_ogreImage"
Initialised="_image_InitScene"
PreRender="_image_PreRender"
ResourceLoadItemProgress=
"OgreImage_ResourceLoadItemProgress"/>
</Image.Source>
</Image>
This would include the OgreImage class in your page displayed via the Image control. The events of interest are:
-
The ResourceLoadItemProgress event which is called for every resource loaded. Here you can get the name of the resource and a scalar (0 -> 1) indicating the progress of the entire loading process.
private void OgreImage_ResourceLoadItemProgress
(object sender, ResourceLoadEventArgs e)
{
_progressName.Text = e.Name;
_progressScale.ScaleX = e.Progress;
}
-
The Initialised event. This event is called just after all the resources have been loaded (and before the first frame is rendered). In this event the scene can be constructed.
Please refer to the Ogre wiki on how to use Ogre SceneManager itself.
void _image_InitScene(object sender, RoutedEventArgs e)
{
var sb = (Storyboard)this.Resources["StartEngine"];
sb.Begin(this);
SceneManager sceneMgr = _ogreImage.SceneManager;
Light l = sceneMgr.CreateLight("MainLight");
l.Position = new Vector3(20F, 80F, 50F);
_ogreMesh = sceneMgr.CreateEntity
("ogre", "ogrehead.mesh");
_ogreNode = sceneMgr.RootSceneNode.CreateChildSceneNode
("ogreNode");
_ogreNode.AttachObject(_ogreMesh);
_fountainNode = sceneMgr.RootSceneNode.CreateChildSceneNode();
ParticleSystem.DefaultNonVisibleUpdateTimeout = 5;
_cb_Click(null, null);
}
-
The PreRender event. This event is called before the frame is rendered. Here you can update or change any of the scene nodes.
void _image_PreRender(object sender, System.EventArgs e)
{
if (_ogreImage.Camera.Viewport != _viewport)
{
_viewport = _ogreImage.Camera.Viewport;
_cbCompositor_Click(_cbBloom, null);
_cbCompositor_Click(_cbGlass, null);
_cbCompositor_Click(_cbOldTV, null);
}
_ogreNode.Rotate(new Vector3(0, 1, 0), new Degree(0.1f));
}
Resizing the Ogre Viewport
Also, to get the Ogre viewport to resize itself when the Image size changes you need to manually resize the OgreImage image on the size event of the Image.
private void RenterTargetControl_SizeChanged
(object sender, SizeChangedEventArgs e)
{
if (_ogreImage == null) return;
_ogreImage.ViewportSize = e.NewSize;
}
To keep the app responsive during a window drag exercise I've made the OgreImage class delay its processing of the resize. This will make the image wait for a couple of milliseconds (200 by default) until the size has stabilized. Have a look at the ResizeRenderTargetDelay property.
Starting it all. "Graphics, you haz dem."
One more thing to do is to start the engine. Currently this is done manually by calling the InitOgreAsync method. The reason why the engine can't start automatically is because it requires a valid windows handle to initialize itself and this isn't available while the page xaml is busy loading. I'm sure it won't be too difficult to come up with a clever solution, but I'll let you guys do that. ;-)
The control can be initialized on the window's Loaded event.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
_ogreImage = (OgreImage)RenterTargetControl.Source;
_ogreImage.InitOgreAsync();
}
Binding to the OGRE Library and Media
The OGRE library is quite a monster to get setup for a project. I have only included the essential DLLs and media in this article's download because the full MOGRE setup is quite large. If you would like to develop using MOGRE you will need to download the full SDK which is a hefty 40 meg.
The executables in this project have been compiled into the "Release" folder of the article's download where all the OGRE/MOGRE "Release" DLLs and resource config files are. They are quite large so there's only one instance of them. That is to say, all the VS projects have been configured to have their build output go directly into the Release folder.
If you'd like to re-compile the MogreWpf.Interop.dll (a c++ project) you'll need to set the MOGRE_HOME environment variable in windows to include the "<..>\MogreSDK" path....once you've downloaded the MOGRE SDK. Also compile it in "Release" mode to match the Ogre and Mogre DLLs for this project's download.
Points of Interest
- The WPF now supports GPU Bitmap effects (a-series-on-gpu-based-effects-for-wpf)
This article doesn't use them, it just might interest you to know that it's now possible to do funky stuff in the WPF.
- Ogre is a pretty good object oriented graphics library. If you like graphics programming you should have a look at it. It is mature library, is fun to use and has a good Texture Material and Particle Effects scripting language.
Conclusion
And there you have it. A 3D graphics engine blended into your WPF window. Ooooooh,....shiny!
Ok, this wouldn't be the best way to create a 2000 "frames per second" game. It would be best to leave the OGRE Engine to use its native windowing system, but it will keep your boss loving you at your day job. ;-)
Note: Before you make all kinds of promises to 'said' boss, read the OGRE and MOGRE licenses first, and also I'm not sure the implementation of the OgreImage is 100% reliable at all times. I have had some funny crashes, though it seems pretty stable at the moment after my last code tweak'ins (fluffy bunnies aside). However it should give you a good place to start your "next level" graphics journey.
History
- 2008-09-09 - Initial publication
|
|
 |
 | WPF TusharCool | 21:28 10 Jan '10 |
|
 |
Hi Good Morning
I get below Exception
An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in Mogre.dll Additional information: External component has thrown an exception.
please help me.......... Have nice time Advance Thanks
|
|
|
|
 |
 | Update to latest Mogre version. OverlordCW | 9:19 5 Dec '09 |
|
 |
Hi,
could you update your lib to the latest mogre version (v1.6.4), please?
|
|
|
|
 |
 | OPENGL/OPENSG and WPF njss | 7:18 22 Jun '09 |
|
 |
It's possible to use this same technique to make a OpenGL application render inside a WPF application? How?
Thanks!
|
|
|
|
 |
|
 |
Sorry but no. WPF is very much DirectX only. The WPF allows you access to it's DirectX surface object. (Which is how I get the Orge scene into the Image.) There might be some kind of library allowing you to copy a OpenGL surface to the DirectX surface, which would then make it possible, but I don't know of any such lovely little trinket. I remember a library which transformed OpenGL calls to DirectX (long time ago in a galaxy far away), ...humf...
|
|
|
|
 |
 | You async loading bar isn't a good idea... jmix90 | 6:29 26 Mar '09 |
|
 |
Hello,
I tell this, because when you load the D3D device in another thread, you cannot reset it (update methode) in another thread. So if you lost the device (press Ctrl+Alt+Del), the app crash...
Maybe someone know how to perform a better way ?
Thx for you code bythe way 
|
|
|
|
 |
 | Can't compile solution... John Pursey | 13:05 14 Feb '09 |
|
 |
I am new to all this (C#, WPF, OGRE / MOGRE), so I expect I am just not doing an obvious step. However, when I attempt to compile the DemoApps solution, I get:
C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not locate the assembly "MogreWpf.Interop". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
and then it fails to compile on the "using mogre;" line. How do I point it at the precompiled assembly?
|
|
|
|
 |
|
 |
I have just tried this on a totally different machine and it worked first time. (I tested using the "OgreInWpf\DemoApps\DemoApps.sln" Solutiuon)
Humpf....lets check a couple if things:
1. I re-downloaded the goodies from the web site and extracted both zip files into the same dir. (c:\temp\ogre) (Half the files are in the one zip, half in the other.) Remeber, you need both for this to work. (I'm guessing your problem might be that, or in the way you extracted the files). Just open each in WinZip, select "Extract To" and for both use the exatct same path". Almost like you're about to overwrite the contents of the first zip with the second.
This is a dump of what your directory structure should look like: Here is where the dll should reside -> (c:\temp\Ogre\OgreInWpf\Release\MogreWpf.Interop.dll)
c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\App.xaml c:\temp\Ogre\OgreInWpf c:\temp\Ogre\OgreInWpf\clean.bat c:\temp\Ogre\OgreInWpf\DemoApps c:\temp\Ogre\OgreInWpf\DemoApps\DemoApps.sln c:\temp\Ogre\OgreInWpf\DemoApps\DemoApps.suo c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\App.xaml.cs c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\OgreHead.csproj c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\OgreHead.csproj.user c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\Properties c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\Properties\AssemblyInfo.cs c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\Properties\Resources.Designer.cs c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\Properties\Resources.resx c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\Properties\Settings.Designer.cs c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\Properties\Settings.settings c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\Release c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\Release\OgreHead.vshost.exe.manifest c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\Window1.xaml c:\temp\Ogre\OgreInWpf\DemoApps\OrgreHead\Window1.xaml.cs c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\App.xaml c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\App.xaml.cs c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\bin c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\bin\Release c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\Properties c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\Properties\AssemblyInfo.cs c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\Properties\Resources.Designer.cs c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\Properties\Resources.resx c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\Properties\Settings.Designer.cs c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\Properties\Settings.settings c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\SmokeyCheeseCompany.csproj c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\Window1.xaml c:\temp\Ogre\OgreInWpf\DemoApps\SmokeyCheeseCompany\Window1.xaml.cs c:\temp\Ogre\OgreInWpf\Libraries c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\app.ico c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\app.rc c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\AssemblyInfo.cpp c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\MogreWpf.Interop.D3D9RenderSystem.cpp c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\MogreWpf.Interop.D3D9RenderSystem.h c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\MogreWpf.Interop.sln c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\MogreWpf.Interop.suo c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\MogreWpf.Interop.vcproj c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\MogreWpf.Interop.vcproj.FRED-COMPUTER.Fred.user c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\MogreWpf.Interop.vcproj.LESLIEG.Fred.user c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\ReadMe.txt c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\resource.h c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\Stdafx.cpp c:\temp\Ogre\OgreInWpf\Libraries\MogreWpf.Interop\Stdafx.h c:\temp\Ogre\OgreInWpf\Libraries\OgreLib c:\temp\Ogre\OgreInWpf\Libraries\OgreLib\Designer.cs c:\temp\Ogre\OgreInWpf\Libraries\OgreLib\OgreImage.cs c:\temp\Ogre\OgreInWpf\Libraries\OgreLib\OgreImage.Properties.cs c:\temp\Ogre\OgreInWpf\Libraries\OgreLib\OgreImage.Resources.cs c:\temp\Ogre\OgreInWpf\Libraries\OgreLib\OgreLib.csproj c:\temp\Ogre\OgreInWpf\Libraries\OgreLib\Properties c:\temp\Ogre\OgreInWpf\Libraries\OgreLib\Properties\AssemblyInfo.cs c:\temp\Ogre\OgreInWpf\Libraries\OgreLib\TextureHelper.cs c:\temp\Ogre\OgreInWpf\Libraries\Release c:\temp\Ogre\OgreInWpf\Media c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\COPYING c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred.glsl.program c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred.hlsl.program c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred.material c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferreddemo.material c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\glsl\nm_notex_ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\glsl\nm_ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\glsl\nm_vs.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\glsl\notex_ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\glsl\ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\glsl\vs.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\hlsl\nm_notex_ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\hlsl\nm_ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\hlsl\nm_vs.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\hlsl\notex_ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\hlsl\ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\material\hlsl\vs.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\glsl\Ambient_ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\glsl\GlobalLight_ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\glsl\LightMaterial_ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\glsl\LightMaterial_vs.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\glsl\ShowColour_ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\glsl\ShowDS_ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\glsl\ShowNormal_ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\glsl\SinglePass_ps.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\glsl\vs.glsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\hlsl\Ambient_ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\hlsl\GlobalLight_ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\hlsl\LightMaterial_ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\hlsl\LightMaterial_vs.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\hlsl\ShowColour_ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\hlsl\ShowDS_ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\hlsl\ShowNormal_ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\hlsl\SinglePass_ps.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\DeferredShading\post\hlsl\vs.hlsl c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_debug.glsl.program c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_debug.hlsl.program c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_debug.material c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_minilight.glsl.program c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_minilight.hlsl.program c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_minilight.material c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_multipass.glsl.program c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_multipass.hlsl.program c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_multipass.material c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_onepass.glsl.program c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_onepass.hlsl.program c:\temp\Ogre\OgreInWpf\Media\DeferredShadingMedia\deferred_post_onepass.material c:\temp\Ogre\OgreInWpf\Media\fonts c:\temp\Ogre\OgreInWpf\Media\fonts\bluebold.ttf c:\temp\Ogre\OgreInWpf\Media\fonts\bluecond.ttf c:\temp\Ogre\OgreInWpf\Media\fonts\bluehigh.ttf c:\temp\Ogre\OgreInWpf\Media\fonts\read_me.html c:\temp\Ogre\OgreInWpf\Media\fonts\sample.fontdef c:\temp\Ogre\OgreInWpf\Media\fonts\solo5.ttf c:\temp\Ogre\OgreInWpf\Media\gui c:\temp\Ogre\OgreInWpf\Media\gui\ogregui.layout c:\temp\Ogre\OgreInWpf\Media\materials c:\temp\Ogre\OgreInWpf\Media\materials\programs c:\temp\Ogre\OgreInWpf\Media\materials\programs\AmbientOneTexture.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Bloom_ps20.hlsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Bloom_vs11.hlsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Blur0_ps20.hlsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Blur0_vs.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Blur0_vs11.hlsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Blur1_ps20.hlsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Blur1_vs.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Blur1_vs11.hlsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Blur_ps.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Combine_fp.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\crowdVp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\DepthShadowmap.hlsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\DepthShadowmapCasterFp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\DepthShadowmapCasterVp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\DepthShadowmapNormalMapReceiverFp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\DepthShadowmapNormalMapReceiverVp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\DepthShadowmapReceiverFp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\DepthShadowmapReceiverVp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\DOF_ps.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\Example_Basic.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\Example_Basic.hlsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\Example_BumpMapping.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\Example_CelShading.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\Example_Fresnel.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\Example_FresnelPS.asm c:\temp\Ogre\OgreInWpf\Media\materials\programs\Example_Projection.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\GlassFP.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\Grass.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\GrayScale.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\hdr.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\hdr.hlsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\hdr_bloom.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\hdr_downscale2x2luminence.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\hdr_downscale3x3.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\hdr_downscale3x3brightpass.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\hdr_finalToneMapping.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\hdr_tonemap_util.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\HeatVision.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\instancing.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\instancingVp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\InvertFP.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\LaplaceFP.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\Ocean2GLSL.frag c:\temp\Ogre\OgreInWpf\Media\materials\programs\Ocean2GLSL.vert c:\temp\Ogre\OgreInWpf\Media\materials\programs\Ocean2HLSL_Cg.frag c:\temp\Ogre\OgreInWpf\Media\materials\programs\Ocean2HLSL_Cg.vert c:\temp\Ogre\OgreInWpf\Media\materials\programs\oceanGLSL.frag c:\temp\Ogre\OgreInWpf\Media\materials\programs\oceanGLSL.vert c:\temp\Ogre\OgreInWpf\Media\materials\programs\oceanHLSL_Cg.frag c:\temp\Ogre\OgreInWpf\Media\materials\programs\oceanHLSL_Cg.vert c:\temp\Ogre\OgreInWpf\Media\materials\programs\OffsetMapping.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\OffsetMapping.hlsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\OffsetMappingFp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\OffsetMappingVp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\OffsetMapping_specular.asm c:\temp\Ogre\OgreInWpf\Media\materials\programs\OldMovieFP.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\OldTV.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\PosterizeFP.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\SharpenEdgesFP.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\skinningTwoWeightsVp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\StdQuad_vp.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\StdQuad_vp.glsl c:\temp\Ogre\OgreInWpf\Media\materials\programs\TilingFP.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\varianceshadowcasterfp.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\varianceshadowcastervp.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\varianceshadowreceiverfp.cg c:\temp\Ogre\OgreInWpf\Media\materials\programs\varianceshadowreceivervp.cg c:\temp\Ogre\OgreInWpf\Media\materials\scripts c:\temp\Ogre\OgreInWpf\Media\materials\scripts\Bloom.material c:\temp\Ogre\OgreInWpf\Media\materials\scripts\Example-DynTex.material c:\temp\Ogre\OgreInWpf\Media\materials\scripts\Example.material c:\temp\Ogre\OgreInWpf\Media\materials\scripts\Examples-Advanced.material c:\temp\Ogre\OgreInWpf\Media\materials\scripts\Examples.compositor c:\temp\Ogre\OgreInWpf\Media\materials\scripts\Examples.program c:\temp\Ogre\OgreInWpf\Media\materials\scripts\Glass.material c:\temp\Ogre\OgreInWpf\Media\materials\scripts\Ogre.material c:\temp\Ogre\OgreInWpf\Media\materials\scripts\OldMovie.material c:\temp\Ogre\OgreInWpf\Media\materials\scripts\OldTV.material c:\temp\Ogre\OgreInWpf\Media\materials\scripts\smoke.material c:\temp\Ogre\OgreInWpf\Media\materials\scripts\StdQuad_vp.program c:\temp\Ogre\OgreInWpf\Media\materials\textures c:\temp\Ogre\OgreInWpf\Media\materials\textures\aureola.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\basic_droplet.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\cel_shading_diffuse.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\cel_shading_edge.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\cel_shading_specular.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\Dirt.jpg c:\temp\Ogre\OgreInWpf\Media\materials\textures\dirt01.jpg c:\temp\Ogre\OgreInWpf\Media\materials\textures\droplet.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\flare.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\flaretrail.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\GreenSkin.jpg c:\temp\Ogre\OgreInWpf\Media\materials\textures\NoiseVolume.dds c:\temp\Ogre\OgreInWpf\Media\materials\textures\Random3D.dds c:\temp\Ogre\OgreInWpf\Media\materials\textures\smoke.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\smokecolors.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\spheremap.png c:\temp\Ogre\OgreInWpf\Media\materials\textures\WaterNormal1.tga c:\temp\Ogre\OgreInWpf\Media\materials\textures\WeirdEye.png c:\temp\Ogre\OgreInWpf\Media\models c:\temp\Ogre\OgreInWpf\Media\models\ogrehead.mesh c:\temp\Ogre\OgreInWpf\Media\overlays c:\temp\Ogre\OgreInWpf\Media\overlays\BasicOgreGuiTemplates.inc c:\temp\Ogre\OgreInWpf\Media\overlays\Compositor.overlay c:\temp\Ogre\OgreInWpf\Media\overlays\DP3.overlay c:\temp\Ogre\OgreInWpf\Media\overlays\Example-CubeMapping.overlay c:\temp\Ogre\OgreInWpf\Media\overlays\Example-DynTex.overlay c:\temp\Ogre\OgreInWpf\Media\overlays\Example-Water.overlay c:\temp\Ogre\OgreInWpf\Media\overlays\Shadows.overlay c:\temp\Ogre\OgreInWpf\Media\packs c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\axes.mesh c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\axes.png c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\New_Ogre_Border.png c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\New_Ogre_Border_Break.png c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\New_Ogre_Border_Center.png c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\Ogre.fontdef c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\OgreCore.material c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\OgreDebugPanel.overlay c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\OgreProfiler.material c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\ProfileAvgBar.png c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\ProfileCurrentBar.png c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\ProfileMaxBar.png c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\ProfileMinBar.png c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\OgreLoadingPanel.overlay c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\ogretext.png c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\bluebold.ttf c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\bluecond.ttf c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\bluehigh.ttf c:\temp\Ogre\OgreInWpf\Media\packs\OgreCore.zip\read_me.html c:\temp\Ogre\OgreInWpf\Media\particle c:\temp\Ogre\OgreInWpf\Media\particle\emitted_emitter.particle c:\temp\Ogre\OgreInWpf\Media\particle\Example-Water.particle c:\temp\Ogre\OgreInWpf\Media\particle\Example.particle c:\temp\Ogre\OgreInWpf\Media\particle\smoke.particle c:\temp\Ogre\OgreInWpf\Release c:\temp\Ogre\OgreInWpf\Release\cg.dll c:\temp\Ogre\OgreInWpf\Release\D3DX9_37.dll c:\temp\Ogre\OgreInWpf\Release\Mogre.dll c:\temp\Ogre\OgreInWpf\Release\MogreWpf.Interop.dll c:\temp\Ogre\OgreInWpf\Release\ogre.cfg c:\temp\Ogre\OgreInWpf\Release\OgreHead.exe c:\temp\Ogre\OgreInWpf\Release\OgreHead.vshost.exe c:\temp\Ogre\OgreInWpf\Release\OgreHead.vshost.exe.manifest c:\temp\Ogre\OgreInWpf\Release\OgreLib.dll c:\temp\Ogre\OgreInWpf\Release\OgreMain.dll c:\temp\Ogre\OgreInWpf\Release\plugins.cfg c:\temp\Ogre\OgreInWpf\Release\Plugin_BSPSceneManager.dll c:\temp\Ogre\OgreInWpf\Release\Plugin_CgProgramManager.dll c:\temp\Ogre\OgreInWpf\Release\Plugin_OctreeSceneManager.dll c:\temp\Ogre\OgreInWpf\Release\Plugin_ParticleFX.dll c:\temp\Ogre\OgreInWpf\Release\RenderSystem_Direct3D9.dll c:\temp\Ogre\OgreInWpf\Release\resources.cfg c:\temp\Ogre\OgreInWpf\Release\SmokeyCheeseCompany.exe
2. I'm using Visual Studio 2008 SP1 + WPF 3.5 SP1 (WPF SP1 is a must).
3. (Try removing and re-adding the dll reference) If you are sure all is sane in your solution folder try remove and re-add the dll reference. To do this find "OrgeLib" project's "References" folder (in Visual Studio), remove "MogreWpf.Interop" by right+clicking and selecing remove. Then right+click on the "References" folder and selected "Add Reference", locate the dll and add back to the solution. (You should see a yellow warning next to any references where there is a problem"
Good luck. I hope it works. Ogre and WPF can be serious fun.
|
|
|
|
 |
|
 |
Ok, I tried on a fresh computer and indeed I think I must have not extracted properly -- because there definately is everything in the "Release" folder which there wasn't before. The OgreHead.exe in the release directory works out of the box, so that's a win! The SmokeyCheeseCompany.exe runs, but doesn't actually display any 3D and when I close it the window goes black and it just hangs requiring it to be shut down manually. I will check on the service packs for WPF and VS 2008, as I suspect that is the current problem.
|
|
|
|
 |
|
 |
So I have all the service packs up, but the SmokeyCheeseCompany app is still not working. However, I did manage to rebuild, run and debug the OgreHead app so I think I am good to go. Thanks!
|
|
|
|
 |
|
 |
If the OgreHead is working then at least you can play. WoooHoooo!!!!!!!!
What is happening with the smokey cheese app? What error are you getting? Is it too smokey? Or maybe a Ogre resource file issue?
|
|
|
|
 |
 | I did some benchmarks. Also, do you have any updates on your progress? JaredThirsk | 5:23 10 Jan '09 |
|
 |
I attempted some benchmarks. You can see my results on the thread you started at the OGRE forum: http://www.ogre3d.org/forums/viewtopic.php?f=11&t=44263&p=323210#p323210[^]
Have you made any progress on the game you were making? I'd like to figure out if I can use this with my own OGRE-based game (even if I took a reasonable framerate hit). If you want me to do any more benchmarks, let me know.
Cheers
|
|
|
|
 |
|
 |
Thanks for the posting. It's frikken awsome. )
It does show that the WPF and Vista both do some funny DirectX magic. I guess it isn't intended for the best of both world API interaction, but I think it's still VERY usable.
Also, Jared has some good suggestions for making Ogre run better under Vista and WPF, go check out the thread.
Thanks again man.
|
|
|
|
 |
 | Fullscreen mode ? codedjinn | 9:12 28 Dec '08 |
|
 |
Hi,
Any idea how to do a fullscreen integration like this ?
Thanks
|
|
|
|
 |
|
 |
This is the best approach I know of, for any WPF app. It still doesn't seem to get the WPF app into the realm of high-performance that you get with a Ogre3D app in fullscreen mode
this.WindowState = WindowState.Normal; this.WindowStyle = WindowStyle.None; this.ResizeMode = ResizeMode.NoResize; this.WindowState = WindowState.Maximized; this.Topmost = true;
|
|
|
|
 |
|
 |
Sorry for the late reply. Me busy. It sucky. I stil have soooo much to publish.
Hum...genuine full screen WPF. I've had a quick look to see how you create a D3D app in fullscreen mode and I see you have to Create the Direct3DDevice in fullscreen mode (Windowed = false), however you don't have control of the WPF DirectX device.
I've tried to Reset() the D3D device without any excess......yet.
If anyone has messed with the WPF D3D device and can share some in-site into the hacky-ness involded I'd love to know.
|
|
|
|
 |
 | Wow ! Thanks ! Roland Tomczak | 8:00 24 Nov '08 |
|
 |
Hi,
I was looking for a while for a good 3D Engine being integrated with WPF using D3D Engine... Your work is amazing and seems very stable !
Well done, and thank you 
|
|
|
|
 |
|
 |
My pleasure.
I still need to publish by version of the 80's classic Missile Commander game demonstrating game and WPF UI. + sound cool sounds. Just need to find the time.
|
|
|
|
 |
|
 |
Double sulk. My laptop is still in the workshop. For 7 weeks now. APPLE S.A SUCKS BIGTIME!
So...still waiting for safe return of Macbook. Once safe and sturdy, will post long overdue Missile Command game. Then saving of the planet can commence.
|
|
|
|
 |
 | Can this be a replacement to CEGUI ? Jiaozi | 23:03 10 Sep '08 |
|
 |
Hello,
Do you think WPF can be a real replacement of CEGUI in term of gain of productivity with no performance penalties ? I mean displaying the main menu with WPF (Play, Options, Exit, Load Games, ...) while loading the Ogre engine.
|
|
|
|
 |
|
 |
Oh yes. Defiantly. You'll need to see if there are any DirectX slowness when placing a WPF over the Ogre image. There might be a performance penalty. (Maybe only on some of the older video cards)
I haven't done any Ogre Native vs. WPF embedded tests yet.
I'm currently writing a 'Missile Commander' type game (which I'll publish soon) which uses the WPF for the UI. It's MUCH better the CEGUI! 
One thing to take note of though, is Ogre steals the keyboard and mouse if you use the Ogre input system. You'll need to release it first before the WPF controls could respond to the user input. I'm only using the WPF controls for their visual effects, and still use Ogre to process the input events. I then keep the WPF controls up-to-date with my Game State. (You know, for power bars and such, WPF power bars and labels look sweet, can be databound to their game objects, templated, and take minutes to get working.)
It seems to be working great for me.
|
|
|
|
 |
|
 |
I was just wondering how I was going to do a OGRE-WPF integration and thanks to you I don't need to anymore!!!
Really great article. Have you done any benchmarking since you did this article ?
|
|
|
|
 |
|
 |
Thanks. 
No. No benchmarking yet sorry. Should be easy enough to do though. Take note of controls with opacity < 1. They might force software mode. Also check if there's any difference if you place controls over the Ogre image.
I have a full Missile Commander game I've written using the Ogre Image Source control I still need to publish. It demonstrates Orge and WPF UI working well together....fabulously in fact. Just been veeeery busy at work.
|
|
|
|
 |
|
 |
Yes I can probably do my own benchmarks...but I am a really lazy person and my work takes TOO much of my own time 
But thanks again for doing this. I am really looking forward to build UI for my game in WPF 
|
|
|
|
 |
|
 |
I hope you publish your game when it's done.
Having said that....I still need to publish mine. I have the work problem too.
|
|
|
|
 |
 | Fixed the DirectX dependency problem (fixes DirectX SDK dependencies) [modified] Leslie Godwin | 10:55 9 Sep '08 |
|
 |
People where getting an exception caused by a missing DirectX dll.
You'll need to re-download the files.
I've converted the project to use the "Release" versions of the OGRE/MOGRE (DirectX) dlls. You can now compile the OgreLib and DempApps as debug or release now.
I've been able to test this on 2 machines and everything looks good.
modified on Wednesday, September 10, 2008 2:29 AM
|
|
|
|
 |
|
|