(C#) #Develop2 Irrlicht Project Template

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
Nachtwind
Posts: 8
Joined: Tue Feb 07, 2006 11:37 am

(C#) #Develop2 Irrlicht Project Template

Post by Nachtwind »

Put the follwing code in a file called "Irrlicht.xpt" and put it into: "[SDroot]/2.0/data/templates/project/csharp"

Code: Select all

<?xml version="1.0"?>
<Template originator   = "Nachtwind"
          created      = "06/10/2006"
          lastModified = "06/10/2006">
	
	<!-- Template Header -->
	<TemplateConfiguration>
		<Name>Irrlicht.Net Project</Name>
		<Category>C#</Category>
		<Icon>C#.Project.DOSProject</Icon>
		<LanguageName>C#</LanguageName>
		<Description>This will setup a simple example like skeleton. Dont forget to make a reference to the Irrlicht DLL.</Description>
	</TemplateConfiguration>
	
	<!-- Actions -->
	<Actions>
		<Open filename = "Main.cs"/>
	</Actions>
	
	<!-- Template Content -->
	<Combine name = "${ProjectName}" directory = ".">
		<Options>
			<StartupProject>${ProjectName}</StartupProject>
		</Options>
		
		<Project name = "${ProjectName}" directory = ".">
			<Options/>

			<ProjectItems>
				<Reference Include="System" />
				<Reference Include="System.Data" />
				<Reference Include="System.Xml" />
			</ProjectItems>
			<Files>
				<File name="Main.cs"><![CDATA[${StandardHeader.C#}
using System;
using System.Text;
using System.IO;
using Irrlicht;
using Irrlicht.Video;
using Irrlicht.GUI;
using Irrlicht.Core;
using Irrlicht.Scene;
namespace Irrlicht
{
	class Program
	{
		IrrlichtDevice device;
		/// <summary>
		/// Main entry point for the program.
		/// </summary>
		/// <param name="args">Arguments to pass the software.</param>
		[STAThread]
		static void Main(string[] args)
		{
			Program prog = new Program();
			prog.run();
		}
		public void run()
		{
			// ask user for driver
			DriverType driverType;
			// Ask user to select driver:
			StringBuilder sb = new StringBuilder();
			sb.Append("Please select the driver you want for this example:\n");
			sb.Append("\n(a) Direct3D 9.0c\n(b) Direct3D 8.1\n(c) OpenGL 1.5");
			sb.Append("\n(d) Software Renderer\n(e) Apfelbaum Software Renderer");
			sb.Append("\n(f) Null Device\n(otherKey) exit\n\n");
			// Get the user's input:
			TextReader tIn = Console.In;
			TextWriter tOut = Console.Out;
			tOut.Write(sb.ToString());
			string input = tIn.ReadLine();
			// Select device based on user's input:
			switch (input) 
			{
				case "a":
					driverType = DriverType.DIRECT3D9;
					break;
				case "b":
					driverType = DriverType.DIRECT3D8;
					break;
				case "c":
					driverType = DriverType.OPENGL;
					break;
				case "d":
					driverType = DriverType.SOFTWARE;
					break;
				case "e":
					driverType = DriverType.SOFTWARE2;
					break;
				case "f":
					driverType = DriverType.NULL_DRIVER;
					break;
				default:
					return;
			}
			// Create device and exit if creation fails:
			device = new IrrlichtDevice(driverType, new Dimension2D(1024, 768), 32, true, true, true);
			if (device == null) 
			{
				tOut.Write("Device creation failed.");
				return;
			}
			/*
			Get a pointer to the video driver and the SceneManager so that
			we do not always have to write device.VideoDriver()
			*/
			IVideoDriver driver = device.VideoDriver;

			/*Setup your scene here*/

			while (device.Run() && driver != null) 
			{
				if (device.WindowActive) 
				{

					driver.BeginScene(true, true, new Color(0, 120, 102, 136));
					driver.EndScene();
				}
			}
			GC.Collect();
		}
	}
}



]]></File>
			<File name="AssemblyInfo.cs"><![CDATA[using System.Reflection;
using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.

[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):

[assembly: AssemblyVersion("1.0.*")]

]]></File>
			</Files>
		</Project>
	</Combine>
</Template>

Its nothing great, but its always something good to start with.
Have fun
Quite obviously, our problems do not come from what we invent, but from how we use our sophisticated toys. The difficulties stem not from our hardware or software, but from ourselves.
Post Reply