ePlaice / For the Best Software on the Net

Mainly Free and Open Source Software

Graphics Navigation

Axiom Game Engine | Irrlicht Engine | OpenGL Tao Framework | Bezier Curves | Bifurcation Diagram | Lorenz Attractor |

Valid XHTML 1.1

Latest news

01 Apr 2008: Inkscape 0.46 has been released with major functional improvements.

07 Jun 2007: GLEE version 1.2 has been released with new Aspect ratio feature and some bug fixes.

17 Jan 2008: Stellarium version 0.91 has been released with improved startup and stability. Now runs very smoothly under Windows XP

26 Jan 2008: Horde3D SDK [0.14.0] released

Links:

DirectX and Axiom Game Engine

Axiom Sample 2

I was looking for a Games Engine that would take out some of the hard work involved in starting with either OpenGL or DirectX. I have found the Nehe tutorials to be an excellent place to start if you are new to computer Games. Whilst some may dismiss playing computer games as a bit of a waste of time there is also a very serious side to these developments; they make very heavy use of graphics and lead the way in requirements for computing power which drive the computer technology forward. These techniques then spin over into mainstream computing so that we all benefit from advances made in gaming with I guess the ultimate aim of having a desktop that simulates as closely as possible what happens in the real physical world. Examples of this can be seen where pages in books are made to turn just like real book pages as opposed to scrolling down the computer screen. If you are running on a Microsoft Platform and have an interest in Graphics then it is natural to see what DirectX has to offer and compare it with say OpenGL. I had already decided that I wanted to stay with C# as the programming language of choice. By now I have seen the advantages in coding productivity using C#, and prefer to use managed code over C++ and C. At first sight there does seem to be a bit of a contradiction since with graphics we all want code that will run the fastest which invariably is produced by C++. However, the preformance disadvantage of C# can be mitigated by optimization and I suspect is likely to be a major concern only to the Commercial developers.

When I started looking at DirectX I was immediately struck by how few tutorials and examples were available using C# and DirectX. Many of the examples just didn't work properly and it almost seemed like a combination that had attracted some interest a few years ago and then died out. Maybe it's because Microsoft have released XNA, but at the moment I am not going to even look at this option. So, already with DirectX I feel quite confused as to whether I should worry about DirectX because of XNA, also I understand DirectX 10 is only available on Vista and not XP. This is one of the reasons I suspect that there is so much concern about going with Microsoft and being locked into dead-end technologies. For the moment I will see what can be achieved with C# and DirectX 9 on my humble XP machine.

Installing Axiom

One of the first problems you are faced with when installing Axiom is which version to choose, because there are actually three versions available each given a code word, so you can choose from Crickhollow (alpha and potentially bleeding edge), Woodhall (Release Candidate available) and Hobbiton (released in January 2007). In the end I went for Woodhall because this was the one that seemed to be being worked on - version 0.7.5 RC released 29 May 2009. I downloaded the full code and was pleased to see this installed without any problems, running on Windows XP and DirectX9.

First Impressions

When you start off using a project for the first time, the initial impressions are all important particularly when you don't have much time. I have to confess I was quite put off initially because the whole setup had a rather outdated look about it with no flashy website showing some of the examples. This is a bit of a shame because the terrain picture that is displayed on Sourceforge is rather drab. I have since found out that Axiom is also available on the CodePlex site and I personally found this a more interesting showcase for the product. Some of the sample applications look rather good and whilst some are lacking some of the detail of the Ogre demos, provide quite a comprehensive overview of the capabilities (Get the Crickhollow version running under Windows Forms). In fact when I get a moment I will display some here.

Using SharpDevelop3

All of the development was achieved using the SharpDevelop 3 IDE using the template Create a new Windows Console Application.

Samples

I compiled all the samples but for some reason to do with missing XNA I could not run them. So I then ran the binaries supplied and this time everything ran OK. I swapped in my compiled dlls and still everything ran OK, so I could only conclude that it was something strange in the setup. I was impressed by the examples which I think have mainly been ported across from the Ogre C++ Engine - bump mapping worked a treat in DirectX, but strangely enough there was a problem using OpenGL.

Using Windows Forms

I then tried to run using Windows Forms (without the annoying Dos box), but quickly came unstuck when I realised this tutorial only applied to Crickhollow version. I looked at modifying the program but found the changes required were a bit intimidating, so moved on as sometimes I am a little bit impatient. Once I installed Version 0.8 I came back to this and got this working in a few minutes. Unfortunately, the tutorial is a little bit out of date and you need to change :-


_SceneManager = _Root.CreateSceneManager(Axiom.Core.SceneType.Generic, "MainSceneManager");
To
_SceneManager = _Root.SceneManagers.GetSceneManager(Axiom.Core.SceneType.Generic);

It should at least compile and then all you need to do is remember to add the assembly references to the project as specified and also add DevIL.dll (which is not specified in the Tutorial) to the output folder, otherwise you will get meaningless error messagas telling you that jpg's and png's are not loading because of missing codecs.

Tutorial 1

I then tried compiling the Tutorial 1 example which was interesting! I eventually managed it after about 2 hours which was disappointing. Use the view source tab on the page to obtain a listing without line numbers which can be copied and pasted directly into your application. This saves time having to strip out the line numbers manually. The first thing I did was point the EngineConfig xml file to my downloaded folder. This worked fine - the alternative method of detailing which meshes and images are actually being used (including those for the Axiom logo and fps box) proved to be a little tedious by trial and error by looking at the EngineLog.

Libraries / dlls Required

The next problem was trying to work out which libraries are actually required; I just wanted to run on Windows XP with DirectX9. This was largely a matter of trial and error because I did not want to use the scatter gun approach suggested in the tutorial of using every library. In some places using SharpDevelop, I had to add the dll references to the project, and in other cases I had to copy the dll to the output folder. All rather confusing, here is the list of Project dll references I needed for Tutorial 1 :-

  • Axiom
  • Axiom.Platform.Windows
  • Axiom.Plugins.ParticleFX
  • Axiom.RenderSystems.DirectX9
  • Axiom.SceneManagers.Octree
  • Tao.DevIL.dll - Tao Developers Image Library
  • ICSharpCode.SharpZipLib.dll - Advanced Zip and Streaming Compression
  • Axiom.Plugins.DevILCodecs - from version 0.8 onwards

You might also need :-

  • Axiom.SceneManagers.BSP
  • Axiom.Plugins.CgProgramManager

Here is a list of the dll's I needed to have in the output folder - I tried adding these as project assembly references, but obtained an error message from SharpDevelop 3, saying Mono.Cecil.Binary.ImageFormatException: The image is not a managed assembly. I then placed the dll in the output folder resulting in a successful compile. :-

  • DevIL.dll - Cross platform Developers Image Library
  • ILU.dll - Only required when scaling re-sizing images (e.g. Render to Texture Demo)
  • cg.dll - Allows high level shading language to be used from NVidia (Microsoft has HLSL) - Only required for Shading (e.g. Grass Demo)

Summary

Once it had compiled it was very straightforward to carry on through the tutorial and add the mesh to the Scene. In summary, I did not have to make any changes for 0.7.5 (the Tutorial said it had been modified for 0.7.2). I was a bit baffled for the need to have reference to Axiom.Plugins.ParticleFX and I don't know why both Tao.DevIL.dll and DevIL.dll are required to be present. I am baffled by the fact that there are two concurrent versions under development neither of which have been fully released - this, added to the requirement to support multi platforms plus support for OpenGL, DirectX and XNA must make for a very complex project to manage. I will need a lot of convincing to move from 0.7.5 to 0.8 (the alpha version) even if it does have more advanced features, so far I feel this is the right choice for me - just starting out. It would have been nice if the tutorial template code could have been made part of the release. For my part I am not too interested in the inner workings of Axiom - I just want to use the Graphics, which is why I started looking at a Graphics Engine in the first place.

Running Tutorials

There are some excellent tutorials referenced on the Axiom main page - so the first task was to get as many as possible running under the Woodhall version

Intermediate Tutorial 1

Making this run was no problem at all using an almost identical setup for the Tutorial 1 described above. One minor change I had to make was to change 'Scale' to 'ScaleBy' in three places.

Tutorial 2

I managed to get this tutorial to run quite readily using the same basic configuration as for Tutorial 1. The problem I have with this tutorial is that the second shadow does not show up with Light1 and Light3 set as suggested. The second shadow does show up if you include the Light2 in the scene. I also bumped up the lighting from 0.25 to 0.5 to make the overall scene a bit brighter. Otherwise no changes had to be made and it worked first time.

Tutorial 3

The terrain file worked first time, but then I ran into problems with the SkyBox. From the log I gathered I needed 6 jpg files for the faces of the cube, which I eventually found tucked away in a zip file called SkyBoxes.zip. I wasn't sure if I should unzip manually or put it in the archives directory - in the end I just unzipped directly into the Textures folder and the SkyBox worked in a very similar manner to the SkyBox in the samples.

Move to Crickhollow version 0.8 Alpha 3

Here is my justification for moving to an alpha version. It did not take long to realize that version 0.7.5 even in its released form was only a small part of the future planned. There are many new features in the 0.8 version including those that I needed to compile some of the Axiom Tutorials and more importantly those that are required to convert the Ogre C++ tutorials and examples. I am by no means an accomplished coder but I found it relatively easy to port the Ogre Intermediate 5 Tutorial which relies on Manual Objects (only in version 0.8) to run under Axiom. I include a code sample below. However, moving directly to version 0.8 would have been a mistake for me. With version 0.7.5 you get project files which enable you to build the application reasonably effortlessly - only BAT files come with version 0.8. Also there is quite a large learning curve getting to grips with the various libraries and Media locations. Also, even though the AxiomEngine.log (called AxiomExample.log in version 0.7.5) file is very useful for debugging there are a great number of idiosynchrisies such as which error messages can be ignored and those that do not show up at all. Trying to work these out with an alpha version would have been a step too far for me. Also, I read in the forum that the Project Manager has a great plan for merging the two versions and rapidly bringing out a Beta 1 and Beta 2 version of 0.8. So without more ado here is my first bash with Axiom 0.8 using the Ogre C++ file.

Running the Demo

There were no Visual Studio project files waiting to be run. So, I found the quickest way forward was to copy the project files and solution files that I created for 0.7.5 and copy these across. There were a few things I had to do :-

  • Change all the assembly references to point at the 0.8 versions
  • Edit the EngineConfig.xml to point at the correct Media folder
  • Add the Axiom.Plugin.devILCodecs.dll
  • I compiled the Demos.dll, including the new sample files

I managed to run the demo using a version of 0.8 and got 29 demos instead of the original 25 with 0.7.5. There was source for a CommandLine and a WinForms implementation, but I only managed to get the CommandLine implementation working. Note the order of the applications on the browser screen is in alphabetic order which is the same as SharpDevelop holds the .cs files in the IDE. Not much success with OpenGL but DirectX is looking quite good. I could not find an easy way to to make DirectX the first option in the browser, so in the end I resorted to a dirty fix by knocking out the reference to OpenGL in the project file. This left me with just one choice i.e. DirectX for the render system. In fact there are some stunning demos available already working for the most part in version 0.8 as long as you stick to DirectX - I noticed a problem with Example 18 failing. When I looked at the log file it was requesting ILU.dll to be present. I copied this to to the folder for the Browser, as SharpDevelop complained this was not a Managed assembly, re-ran and this time it worked to spec. I liked the waving grass demo particularly - a lot better than the Tutorial example at the bottom of the page :-

Waving Grass demo

Ogre Intermediate Tutorial 5

The first thing when using 0.8 (assuming you want to use a Dos box) is to copy the ExampleApplicationCrickhollow.cs to your project. I use SharpDevelop 3 for all my C# developments, but I expect the arrangement is fairly similar if you use Microsoft Visual Studio. I then quickly converted the C++ code to C# - this was fairly straightforward but would have been quicker if I could have laid my hands on some good documentation for Crickhollow.

Converted Code

Here is my sample code, which is an almost line for line conversion of the Ogre Intermediate Tutorial that is quite fully explained on the Ogre Website :-

/*
 * Created by SharpDevelop.
 * User: David Herring
 * Date: 11/06/2009
 * Time: 12:55
 *
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using 
System.Collections;
using 
System.Collections.Generic;
using 
Axiom;
using 
Axiom.Core;
using 
Axiom.Math;
using 
Axiom.Graphics;
using 
Axiom.Animating;
using 
ExampleApplicationCrickhollow;

namespace 
AxiomInt5 {
    
class Program {
        
public static void Main(string[] args) {
            StaticGeometryApplication app 
= new StaticGeometryApplication();
            
app.Run();
        
}
    }
    
class StaticGeometryApplication : ExampleApplicationCrickhollow.ExampleApplication {

        
void createGrassMesh() {

            
const float width 25;
            const float 
height 30;

            
ManualObject mo = new ManualObject("GrassObject");

            
// Vector3 vec(width/2, 0, 0);
            
Vector3 vec = new Vector3(width/200);
            
Quaternion rot Quaternion.FromAngleAxis(Utility.DegreesToRadians(60), Vector3.UnitY);

            
mo.Begin("Examples/GrassBlades", OperationType.TriangleList);
            for 
(int 0i < 3++i) {
                mo.Position(-vec.x, height, -vec.z)
;
                
mo.TextureCoord(00);

                
mo.Position(vec.x, height, vec.z);
                
mo.TextureCoord(10);

                
mo.Position(-vec.x, 0, -vec.z);
                
mo.TextureCoord(01);

                
mo.Position(vec.x, 0, vec.z);
                
mo.TextureCoord(11);
                int 
offset i * 4;
                
mo.Triangle((ushort)offset, (ushort)(offset+3), (ushort)(offset+1));
                
mo.Triangle((ushort)offset, (ushort)(offset+2), (ushort)(offset+3));
                
vec rot * vec;
            
}
            mo.End()
;
            
mo.ConvertToMesh("GrassBladesMesh""grass");
        
}

        
protected override void CreateScene() {

            Entity entity
;

            
createGrassMesh();
            
SceneManager.AmbientLight = new ColorEx(111);

            
Entity ent SceneManager.CreateEntity("Robot""robot.mesh");
            
SceneNode node SceneManager.RootSceneNode.CreateChildSceneNode("RobotNode");
            
node.AttachObject(ent);

            
Plane plane = new Plane(Vector3.UnitY, 0.0f);

            
MeshManager.Instance.CreatePlane("floor","grass", plane, 450.0f, 450.0f,
                                             
1010true1, 50f, 50f, Vector3.UnitZ);

            
entity SceneManager.CreateEntity("FloorEntity""floor");

            
SceneManager.RootSceneNode.CreateChildSceneNode().AttachObject(entity);

            
entity.MaterialName "Examples/GrassFloor";
            
entity.CastShadows = false;

            
Entity grass SceneManager.CreateEntity("grass""GrassBladesMesh");
            
StaticGeometry sg SceneManager.CreateStaticGeometry("GrassArea"1);

            const int 
size 375;
            const int 
amount 20;

            
sg.RegionDimensions = new Vector3(size, size, size);
            
sg.Origin = new Vector3(-size/20, -size/2);

            for 
(int -size/2x < size/2x +(size/amount))
                
for (int -size/2z < size/2z +(size/amount)) {
                    
float size / (float)amount / 2;
                    
Vector3 pos =  new Vector3(x + Utility.RangeRandom(-r, r), 0, z + Utility.RangeRandom(-r, r));
                    
Vector3 scale = new Vector3(1, Utility.RangeRandom(0.9f, 1.1f), 1);
    
                    
Quaternion orientation Quaternion.FromAngleAxis(Utility.DegreesToRadians(Utility.RangeRandom(0359)), Vector3.UnitY);

                    
sg.AddEntity(grass, pos, orientation, scale);
                
}
            
            sg.Build()
;

        
}

        
protected override void CreateCamera() {
            Camera 
SceneManager.CreateCamera("PlayerCam");
            
Camera.Position = new Vector3(150.0f, 150.0f, 150.0f);
            
Camera.LookAt(new Vector3(0.0f, 0.0f, 0.0f));
            
Camera.Near 5.0f;
        
}

    }
}

Problems Encountered

Not too many problems as follows :-

  • First set up the Assembly references to point at the 0.8 version of Axiom
  • Then add in AxionDevILCodecs.dll (an extra dll required for version 0.8 - without it png's don't seem to work)
  • Grab some resources from the Ogre download and place them in your Media folder - you will need Materials Examples/GrassFloor and Examples/GrassBlades plus Texture gras_02.png
  • I got a warning from the AxiomEngine.log telling me to upgrade the Robot.mesh as soon as possible using the Ogre MeshUpdater. I tried this but unfortunately all the animations were lost - so a bit of a waste of time. It's not surprising that the Axiom Media file supplied comes with out of date meshes.

Results

You should end up with a nice scene as follows :- Ogre Int 5

Ogre Intermediate Tutorial 7 - Render To Texture

This proved to be a little bit more troublesome and some of the code did not translate well, such as BoundingBox for the MiniScreen. I did get this to work as per instructions using Axiom 0.8; some of the conversions are not too obvious, but I was helped by the Render To Texture example in the Demos folder. If any one is interested in the code just let me know using my eplaice email address.

Move to Crickhollow Beta 1 version

After successfully trying the Alpha version I thought moving to a Beta version should be a breeze. How wrong can you be! From the very start I found I could not obtain a straight compile using SharpDevelop. I also found that DirectX had been sidelined and something called SlimDX substituted. Now SlimDX might be the best thing since sliced bread but I was surprised to see this part of the Beta 1 release. Time is limited so I decided not to persevere any further with Axiom until it finds a stable development ethos. So this is why I started looking at Irrlicht.

Creating Meshes

One big problem I found with Axiom (and also Ogre) was the lack of professional utlities for importing/exporting 3D meshes using the Ogre Mesh format. This was a bit of a turnoff, particularly when I could not even find a half decent Mesh viewer. Of course I may just not have looked hard enough, but the constant theme I found was a a project had been started, not quite finished, rarely an executable to run (compile it yourself!). There is clearly a need, just from the number of occasions I saw a new project was just starting to either import or export or view objects. It was then I stumbled across the DeleD engine. This comes with quite a few import/export tools and from the number of times I have used it, seems to work quite well. I like it because it is fairly simplistic to use and you don't have to get acquainted with Blender, Truespace or other heavyweights if all you want to do is take in a 3D object, tweak it a bit and export it out to Ogre Mesh format. Most of the important formats are catered for including 3DS, .X, Collada and OBJ files. Of course there is a Pro version which is not free, but this does seem to be rather good value. I have not tried the Pro version, and I would state I have no affiliation to DeleD, but it seems to me it must be worthwhile to use something that works rather than keep on reinventing the wheel.I tried several samples moving from .X mesh to Ogre Mesh and had very good results with Dragon.X, the only problem being that Axiom version 0.8 has had some problems reading .BMP textures, so I had to test using 0.7.5. Currently exporting animations is not supported, but according to the forums, this is coming with the .X mesh being first in the queue.