Views
From SVN to RenderWindow
From Axiom
Contents |
Abstract
- This tutorial will explain how you get a new own project working as soon as possible
- It starts with installing required packages and ends with a rendering window displaying a rotating cube
- As it doesn't explain any code it's best suited for persons who want to change from Ogre3D to Axiom3D
- I've tested it with Ubuntu 10.04 LTS with a clean svn checkout so it should work easily as a step-by-step instruction
- Please add informations if there are any mistakes/problems in/with this tutorial
Installing required packages
Use apt-get, Synaptic Package Manager, or any other method to install the following packages
- subversion
- mono, monodevelop (mono-debugger, monodevelop-debugger-mdb may be useful)
- libtaoframework-* (you probably don't need every package but I just installed everything to be on the safe side)
- libdevil1c2
- nvidia-cg-toolkit
Download the sources
svn co https://axiomengine.svn.sourceforge.net/svnroot/axiomengine/trunk
Step-by-step instruction for the rest :-)
- open "...bla.../trunk/Projects/Axiom.2008.sln" with MonoDevelop
- you may get some error about missing stuff ("Axiom.Tests.Integration.csproj") -- just ignore it
- In the Solution window right-click on "Solution Axiom.2008"
- choose -> Add -> Add New Project ...
- choose -> "Console Project" and give it a name of your choice (I chose "Test")
- Press -> "Forward" and than -> "OK" without checking any checkboxes
- copy the code in section "Code" below in this tutorial into your automatic created "Main.cs"
- double-click on -> Test/References to edit the references (or right-click on Test/References -> Edit References...)
- add the following references: (go to the "Projects" tab)
- Axiom
- Axiom.Platforms.OpenTK
- Axiom.RenderSystems.OpenGL.OpenTK
- You should now be able to successfully compile your "Test" project
- starting the created Test.exe, however, could give you an "System.DllNotFoundException: opengl32.dll" -- That's because you need to tell Tao the naming of your libraries. After compiling you will get a file named "OpenTK.dll.config" which should contain the nescessary dll overrides. Unfortunatelly the program looks at "Tao.OpenGl.dll.config" so the easiest (TODO: or is it "the most easiest?") way to solve this problem is to create a link: "ln -s OpenTK.dll.config Tao.OpenGl.dll.config"
- All right, you can now start your project ("mono Test.exe"). If everything works you'll see a blue rotating cube on a yellow background. -- congratulations, you've got your new own project and can start porting all of your projects from Ogre3D/Mogre to Axiom3D ;-)
Problems/Hints
I've got some problems getting things work so here're my hints
- I always get some Exception about missing a "opengl32.dll" but I'm very sure I've installed OpenGL, at least I can start glxinfo/glxgears!
- You need to add some dll-overrides for Linux. This problem is mentioned in the step-by-step instruction above.
- I've called root.CreateRenderWindow(...) but I don't see any window. Is there a Show/Open method I have to call?
- This bugged me at least an hour, searching the internet without any help. The window isn't displayed befor you render anything so you need to call root.RenderOneFrame or root.StartRendering() to get a window.
- Ok, I finally got a window and see a rotating cube but there's heavy flickering on the image. Shouldn't there be something called double buffering?
- I've searched for this some hours, too and the internet couldn't help here either. I assume, you write something to your console in your render loop and the console window is below of your render window? That's what causes the flickering. Disable the console output or move the console window so the render window isn't longer above it.
- I extended the code with loading some resources but when I call InitializeAllResourceGroups() I always get an exception.
- One of many reasons can be that you didn't created a render window yet. Be sure to call CreateRenderWindow() before InitializeAllResourceGroups().
If you have problems that can't be solved, try posting in this thread: http://www.axiom3d.net/forums/viewtopic.php?f=1&t=1014
Problems with Crickhollow
As the time of writing this, you can also use this example with the crickhollow svn checkout. There are, however, some minor problems to solve
- return type of OnFrameStarted must be bool instead of void (I assume you can solve this problem by yourself by editing Main.cs)
- root.CreateSceneManager() now takes at least two arguments, so change line "sceneManager = root.CreateSceneManager(SceneType.Generic);" to "sceneManager = root.CreateSceneManager(SceneType.Generic, "TestSceneManager");"
- you may get a segfault after calling root.Initialize(false), look at http://www.axiom3d.net/forums/viewtopic.php?f=14&t=957 for a solution.
Code
using System;
using Axiom;
using Axiom.Core;
using Axiom.Math;
using Axiom.Graphics;
namespace Test
{
class MainClass
{
Root root;
RenderWindow window;
SceneManager sceneManager;
Camera camera;
Viewport viewport;
Light light;
SceneNode sceneNode;
Entity entity;
long timeLast, timeNow, timeDelta;
public void init()
{
root = new Root("test.log");
root.RenderSystem = root.RenderSystems["OpenGL"];
root.FrameStarted += OnFrameStarted;
window = root.Initialize(false);
window = root.CreateRenderWindow( "TestRenderWindow", 800, 600, false);
sceneManager = root.CreateSceneManager(SceneType.Generic);
camera = sceneManager.CreateCamera("TestCamera");
camera.Position = new Vector3(0, 0, 500);
camera.LookAt(new Vector3(0, 0, -300));
camera.Near = 5;
camera.AutoAspectRatio = true;
viewport = window.AddViewport(camera);
viewport.BackgroundColor = ColorEx.Yellow;
light = sceneManager.CreateLight("light1");
light.Type = LightType.Point;
light.Position = new Vector3(0, 150, 300);
light.Diffuse = ColorEx.Blue;
light.Specular = ColorEx.Blue;
sceneManager.AmbientLight = new ColorEx(0.2f, 0.2f, 0.2f);
}
public void createScene()
{
entity = sceneManager.CreateEntity("TestEntity", PrefabEntity.Cube);
sceneNode = sceneManager.RootSceneNode.CreateChildSceneNode();
sceneNode.AttachObject(entity);
sceneNode.Yaw(45);
}
protected virtual void OnFrameStarted( object source, FrameEventArgs evt )
{
timeLast = timeNow;
timeNow = root.Timer.Milliseconds;
timeDelta = timeNow - timeLast;
sceneNode.Roll(timeDelta * 0.020f);
}
public static void Main (string[] args)
{
MainClass main = new MainClass();
main.init();
main.createScene();
Console.WriteLine("start rendering...");
main.root.StartRendering();
}
}
}



