LightFire#
LightFire# is a fast and small Engine to create platform independent Games and Graphic Applications for Linux and Windows Operating Systems.
It provides Graphic, Sound and Network support.
Supported Operating System
All Operating Systems with .NET Runtime (or mono).
Linux, *BSD, MacOSX, Windows
Sourceforge Project Page
![]() |
(01.07.2006) Quake 3 Bsp Scene Node. Map Test: AEon's Desert. |
![]() |
(01.07.2006) Quake 3 Bsp Scene Node. Map Test: AEon's Desert. |
![]() |
(01.07.2006) Quake 3 Bsp Scene Node. Light Test. |
![]() |
(18.04.2006) You can paint directly onto the Terrain. |
![]() |
(01.02.2006) The GUI with Progress Bar, Button and TextBox. |
![]() |
(01.02.2006) Quake3 Bsp Scene Node with Light. (Alpha Version) |
![]() |
(16.09.2005) Quake3 Bsp Scene Node without Light. (Alpha Version) |
| (16.09.2005) Quake3 Bsp Scene Node with Vertex Color. (Alpha Version) |
| The GUI can have different skins. |
| Picking (select objects) can be done per Bounding Box andor per Vertex. |
| Octrees split the world into sectors. |
| Terrains can be formed, coloured and modified in many ways. |
Get the latest Code
Using CVS
The latest code is available using CVS.
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/lightfire3d co LightFireCS
This will create a directory called "LightFireCS".
Using SourceForge Download
Download the latest Release candidate from the SourceForge.net Project page if there is a release available.
Setting up a project
Introduction
Create a new empty project in your favorite IDE. We recommend #Develop (Windows) or MonoDevelop (Linux).
References
Add references for
- System
- Tao.Sdl.dll
- Tao.Devil.dll
- Tao.OpenGL.dll
- LightFireCS.dll
Sample Class
Introduction
The following Code shows how to create a window, handle input (without using the Event System) and prepare rendering.
Sample.cs
First we have to include our namespaces.
using LightFireCS;
using LightFireCS.Graphics;
Then we need to create our class and the Main entry point.
We create gDevice and iDevice to store the handles for later use.
{
private LightFireCS.Graphics.Device gDevice;
private LightFireCS.Input.Device iDevice;
[STAThread]
static void Main()
{
Sample smpl = new Sample();
smpl.Loop();
}
Now we assign our handles and create a 640x480 window with 32 bit color depth.
{
gDevice = LightFireCS.Graphics.Device.Get(); // or Device.Get() because of "using LightFireCS.Graphics"
iDevice = LightFireCS.Input.Device.Get();
gDevice.Init(640, 480, 32, false);
gDevice.SetWindowText("Sample");
}
The Main Loop handles Input and allow us to render 3D (Models, Terrains, ...) and 2D (GUI, HUD, ...) things.
{
while(gDevice.IsRunning)
{
iDevice.UpdateInput();
if(iDevice.GetKeyState(Tao.Sdl.Sdl.SDLK_ESCAPE))
gDevice.Quit();
gDevice.BeginRender();
gDevice.SetPerspectiveView();
// 3D Rendering
gDevice.SetOrthoView();
// 2D Rendering
gDevice.EndRender();
}
}
}
Input handling using Events
LightFire# supports the .NET Event System. Instead of using the GetKeyState function we could add an EventHandler for Key Down messages.
public void OnKeyDown(Object o, KeyEventArgs e)
{
if(e.keyIndex == Tao.Sdl.Sdl.SDLK_ESCAPE)
gDevice.Quit();
}
Gui
The LightFire# Gui allows you to create a complete User Interface with only a few lines of code.
Every Window and Control can have it`s own theme by using different style sets.
The Theme sets are easy to use xml files.
Scene mangagment
Models, Terrain, Shadows and Octrees are managed in a hierarchy of nodes. Every Node can have multiple child nodes.
Supported formats
TexturesTGA, JPG, GIF, PNG, BMP and many other file formats are supported by using the powerful DevIL Image Library.
Meshes
LightFire# supports the 3DS (3D Studio) file format.
The LightFire#.GUI provides you with a simple interface to create every GUI you can imagine.
Styles
The LightFire#.GUI uses XML style files to customize the layout of the controls.
Each GUI element has a default key. (Window = window, Progess Bar = progressBar, ...). You can
use your own keys for every control.
<style name="window">
<background img="res/gui/test_*.tga" color="255 255 255 196" />
<backgroundHover img="res/gui/test_*.tga" color="255 255 255 196" />
<backgroundDisabled img="res/gui/test_*.tga" color="255 255 255 196" />
<font file="res/morpheus.ttf" size="16" />
</style>
</styles>
A * is replaced with: b, bl, br, t, tl, tr, l, m ,r.
Where each is a corner of an image and m is the center image.
The example would use nine tga files for the background. (test_b.tga, test_bl.tga, test_br.tga, ...)
The color is given as RGB[A]. Where A is the optional alpha value used for transparency (255 no transparency, 0 total transparent).
We use the font "morpheus" for the window.
The window
Window windowTest;
//Load the style and create a window
style = new StyleFactory("res/testgui.xml");
windowTest = new Window(new Rect(300, 120, 520, 400), "Test Window", style);
WindowManager.Get().RegisterWindow(windowText);
//Render the window in the Main Loop
GDevice gDevice = GDevice.Get();
MessageHandler.Get().ProcessEvents();
gDevice.BeginRender();
gDevice.SetOrthoView();
WindowManager.Get().Render();
gDevice.EndRender();
windowTest = new Window(new Rect(300, 120, 520, 400), "Test Window", style);
is equal to
windowTest = new Window(new Rect(300, 120, 520, 400), "Test Window", style, "window");
Buttons and Events
Creating a button and catching the Click Event is very simple.
First we need a style entry. Just add:
<background img="res/gui/button.tga" />
<backgroundHover img="res/gui/button.tga" color="0 0 255" />
<backgroundDisabled img="res/gui/button.tga" color="0 0 255" />
<font file="res/arial.ttf" size="18" />
</style>
And the Code:
//Create the button and add an Event Handler
quitButton = new Button(windowTest, new Rect(12, 32, 268, 64), "Quit", style);
quitButton.LeftDown += new EventHandler(OnButtonWindowQuitQuit);
//The Event Handler
public void OnButtonWindowQuitQuit(object o, EventArgs e)
{
GDevice.Get().Quit();
}
Scripting Language
The LightFire#.Script Language provides a simple interface to use C# as a Script Language.
This Tutorial shows a application which invokes a function in a script.
Application
First we include our namespaces to keep this as simple as possible.
using LightFireCS.Script;
Then we create a basic main class.
{
public static void Main()
{
Now this is where the magic starts.
The ScriptObject provides everything we need to compile and run our script.
We have to compile our Script using the CompileFromFile function.
The function returns the amount of errors during compilation.
ScriptObject.errors contains all Error Messages
int errors = scr.CompileFromFile("script.cs");
Console.WriteLine("Done");
Console.WriteLine("Errors: {0}", errors);
if(errors != 0)
{
foreach(string errstr in scr.errors)
Console.WriteLine(errstr);
return;
}
If everything went right we can Execute functions.
The first argument is the path to the function we want to call.
The second is the function itself and the last argument takes arguments for the function such as object[] {55.4, "hello", "max"}.
Object o = scr.ExecuteFunction("Script", "ScriptMain", null);
Console.WriteLine("Done");
}
}
Script
The Script only Writes a string.
System.dll is always referenced, further assemblies have to be added to the ScriptObject.
class Script
{
public static void ScriptMain()
{
Console.WriteLine("Script Main Function!");
}
}
Status
| Item | Status | Description |
|---|---|---|
| AI | ||
| Graphics | ||
| Device | Complete | Create render target. Init OpenGL and enumerate render device settings. |
| SceneNode Interface | Complete | Provides nodes to create a scene graph. |
| Octree Node | Complete | Octree SceneNode. |
| Quake3 Bsp Node | WiP | Load and render Quake3 Bsp Maps. |
| Shadow Node | WiP | Alle Child nodes cast shadows. |
| Model Manager | Complete | Load and manage models. |
| Terrain Manager | WiP | Load and manage Terrains. |
| Texture Manager | Complete | Load and manage Textures. |
| Camera | Complete | First Person and Object Oriented camera. |
| GUI | ||
| Skinning | Complete | Skinnable GUI using XML. |
| Fonts | Complete | Load TTF (True Type Font) files and render fonts. |
| Window | Complete | Contains GUI controls. |
| Button | Complete | Button control. |
| TextCtrl | WiP | Text control. |
| ListCtrl | Planning | Listbox control. |
| ImgCtrl | Planning | Image control. |
| ScrollbarCtrl | Planning | Scrollbar control. |
| CheckBoxCtrl | Planning | CheckBox control. |
| ProgessBar | Complete | Progess Bar control. |
| Menu | Planning | Menu and Context Menu control. |
| Input | ||
| Input | Complete | Handle Mouse and Keyboard access. |
| Events | WiP | C# Event System for Input Events. |
| IO | ||
| VFS Reader | WiP | Virtual File System reader |
| Log | ||
| Text File Log | Complete | Create structured txt Log File. |
| HTML File Log | Complete | Write html Log File. |
| Math | ||
| Bounding Box | Complete | AABB Axis Aligned Bounding Boxes. |
| Vector3 | Complete | 3D Vector. |
| Matrix4 | Complete | 4x4 Matrix. |
| Intersection | Complete | RayAABB - RayVertex Intersection. Picking. |
| Net | ||
| Script | ||
| Script Object | Complete | Compile and execute scripts. |
| Sound | ||
WiP = Work in Progress
License
LightFire# is licensed under the terms and conditions of the GNU Lesser General Public License (LGPL).
LightFire# Game Engine
Copyright (C) 2005-2009 Sebastian Pech
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Anmelden oder Registrieren um Kommentare zu schreiben











