Getting Started With MonoDevelop - Axiom : A 3D Rendering Engine in C#

Getting Started With MonoDevelop

From Axiom

Jump to: navigation, search

Show code samples in

Contents

Getting Axiom

Downloading the Binaries

  • Go to Axiom's Codeplex page
  • Click on the Download button on the right hand side of the screen.
  • Save the zip file somewhere on your harddrive.
  • Whilst you're waiting for the download to complete, create a folder called Axiom on your C:// drive. (Or another place of your choosing)
  • After the download completes, you'll need to unblock the zip file by Right-Clicking the Zip file and selecting Properties.
    • On the General Tab there's a button label 'Unblock' click it to unblock the zip file.
  • Now, extract the contents into the folder you created in the above step.

Obtaining source from SVN

If you want to be able to make changes to the Engine itself, you'll need to edit the source code. Note that part of the license requires that any changes that you make to improve the engine must be shared with the community. This does not mean that you need to share your the source code of your game (although that would be really nice), it simply means if you alter Axiom itself, your version of Axiom must be given back to the community. This enables us all to have a consistently better Rendering Engine.

Obtaining The Source

Compiling the Source

Now that TortoiseSVN has completed checking out Axiom, it's time to build it.

  • Browse to C:\Axiom\Projects and double-click either Axiom.2008, or Axiom.2010 depending on your version of Visual Studio.

You'll notice other solutions such as Axiom.Xbox and Axiom.Droid are present, but this is a tutorial for Windows, so they will not be mentioned further.

  • Now that the solution has been opened, right-click the solution in the Solution Explorer and select Build Solution

For a list of Dependencies see Source Dependencies

On Windows

Creating a new Project

  1. Open MonoDevelop
  2. From the Menu Select File->New->Solution
  3. In the New Solution Dialog Window, select Console project, and fill in the Project Name and Location, for the purposes of this tutorial we will be using AxiomOpenGLGame for the Project Name, then click Forward.
Link=
  1. At the Project Features dialog click Ok.

Add Axiom References

  1. Right Click the References node in your new Project, and select "Edit References..."
  2. Click the ".Net Assembly" Tab to b rowse for the Axiom Assemblies.
  3. Browse to where your Axiom Assemblies are located and add references to the following assemblies :
  • Axiom.dll
  • Axiom.Platform.Win32.dll
  • Axiom.RenderSystems.OpenGL.dll
  • Axiom.Plugins.FreeImageCodecs.dll
Link=
  1. Use the "Edit References..." Dialog again to add a reference to :
  • System.xml
Link=

The Game Class

Add a new Class file to your Project and name it Game.cs use the code below to populate your Game class.


using System;

using Axiom.Core;
using Axiom.Math;
using Axiom.Graphics;

namespace Axiom.Tutorials
{
	public sealed class Game
	{
		private readonly Root _root;
		private readonly RenderWindow _window;
		private SceneManager _scene;
		private Camera _camera;
		
		public Game( Root root, RenderWindow window )
		{
			_root = root;
			_window = window;
		}

		public void OnLoad()
		{
 			ResourceGroupManager.Instance.AddResourceLocation( "media", "Folder", true );

			_scene = _root.CreateSceneManager( "DefaultSceneManager", "DefaultSM" );
			_scene.ClearScene();

			_camera = _scene.CreateCamera( "MainCamera" );

			_camera.Position = new Vector3( 0, 10, 200 );
			_camera.LookAt( Vector3.Zero );
			_camera.Near = 5;
			_camera.AutoAspectRatio = true;

			var vp = _window.AddViewport( _camera, 0, 0, 1.0f, 1.0f, 100 );
			vp.BackgroundColor = ColorEx.CornflowerBlue;

			ResourceGroupManager.Instance.InitializeAllResourceGroups();

		}

		public void CreateScene()
		{

		}

		public void OnUnload()
		{
		}

		public void OnRenderFrame( object s, FrameEventArgs e )
		{
		}

	}
}

Imports Axiom.Core
Imports Axiom.Math
Imports Axiom.Graphics

Namespace Axiom.Tutorials
	Public Class Game

                Public Sub OnLoad()
                End Sub
		Public Sub CreateScene()
		End Sub
                Public Sub OnUnLoad()
                End Sub
		Protected Sub OnFrameStarted(source As Object, evt As FrameEventArgs)
		End Sub

	End Class
End Namespace

import clr
clr.AddReferenceToFile("Axiom.dll")
clr.AddReferenceToFile("Axiom.Demos.dll")
from Axiom.Core import *
from Axiom.Math import *
from Axiom.Demos import TechDemo
from Axiom.Demos.Configuration import EngineConfig
class BasicTutorial1(TechDemo):
    def CreateScene(self):
        pass
    def OnFrameStarted(self, obj, evt):
       TechDemo.OnFrameStarted(self, obj, evt)
        
if __name__ == '__main__':
    root = Root('AxiomTutorial.log')
    root.RenderSystem = root.RenderSystems['OpenGL'] #or DirectX9
    config = EngineConfig()
    config.ReadXml('EngineConfig.xml')
        
    for row in config.FilePath:
        ResourceGroupManager.Instance.AddResourceLocation( row.src, row.type, row.group, False, True );

    ta = BasicTutorial1()
    ta.Start()

Wiring it all Up

If you're not using Python, browse to your Main.cs file and paste the following code:

using Axiom.Core;
using Axiom.Graphics;

namespace Axiom.Tutorials
{
	internal static class Program
	{
		private static void Main()
		{
			using ( var engine = new Root() )
			{
				engine.RenderSystem = engine.RenderSystems[ 0 ];
				using ( var renderWindow = engine.Initialize( true ) )
				{
					var game = new Game( engine, renderWindow );
					game.OnLoad();
					game.CreateScene();
					engine.FrameRenderingQueued += game.OnRenderFrame;
					engine.StartRendering();
					game.OnUnload();
				}
			}
		}
	}
}
Namespace AxiomTutorials
    Module Program
        Public Sub Main(ByVal args As String())
            Dim root as New Root("AxiomTutorial.log");
            root.RenderSystem = root.RenderSystems["DirectX9"] 'Or "OpenGL"
            Dim config as EngineConfig = New EngineConfig()

            ' load the config file
            ' relative from the location of debug and releases executables
            config.ReadXml("EngineConfig.xml")

' interrogate the available resource paths
For Each row As EngineConfig.FilePathRow In config.FilePath
	ResourceGroupManager.Instance.AddResourceLocation(row.src, row.type, row.group, False, True)
Next

            Dim app As New BasicTutorial1
            app.Run()
        End Sub
    End Module

Press F5 to compile and run.
Link=
Once your satisfied with the neat blue screen, head on over to the tutorials to continue learning how to build games with Axiom.

On MacOS

Coming Soon!

On Linux

Coming Soon!

Views
Powered by MediaWiki GNU Free Documentation License 1.2