jeske's picture

SimpleScene: 3d scene manager in C# and OpenTK

SimpleScene is an scene manager for C# and OpenTK, released into the public domain. It's primarily intended for educational purposes, and as a starter-kit for those who want to get their hands dirty learning OpenGL and GLSL.

There is a GLSL120 shader which supports per-pixel light from a single GL-light, as well as single-pass wireframes. It has code to render using legacy GL calls, or vertex-buffers (which are much faster), and it's own wavefrontOBJ loader. There's also an attempt at bump mapping, but it's not fully working. It currently doesn't have any space partitioning (such as octrees or bsp), nor does it have heightmap terrain. Perhaps I'll add them in the future. The bonus of it *not* having those things and many more, is that it's dirt simple and mostly easy to read the code. I try to keep it as direct as possible with few abstractions.

The Scene manager comes with a sample program, WavefrontOBJLoader, which loads a skybox, a spaceship 3d model, and paints some stars into the skybox for fun.

To get started, you can read a CodeProject article about SimpleScene, and download the code from the SimpleScene github.

Images

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
migueltk's picture

Great, very cool ... thanks for your work.

However for different cultures of "en-US" one exception is generated and the program does not work, you need to add the following code:

using System.Collections.Generic;
using System.Globalization;
 
public SSScene ()  { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;  }

regards

jeske's picture

Thanks for pointing out this bug!

This is happening because I'm using float.Parse() in my obj loader, and the CurrentCulture setting changes the float format parsing. The better fix is for me to replace those float.Parse occurances with:

float.Parse(data, CultureInfo.InvariantCulture);

Then It's not necessary to force the CurrentCulture. I've made the change and checked it in. Let me know if that fixes your issue!

migueltk's picture

I tried it on Linux Ubuntu 14.04, apart from the usual problems with uppercase and lowercase letters in filenames, I found this error:

GL Version = 4.4.12874 Compatibility Profile Context 14.10.1006
GL Shader Version = 4.30
-- bumpVertex --

-- bumpFragment --
Fragment shader failed to compile with the following errors:
ERROR: 0:141: error(#132) Syntax error: "f" parse error
> float edgeIntensity = exp2((-1f / edgeWidth)*nearD*nearD * 2);
ERROR: error(#273) 1 compilation errors. No code generated

** Shader Compile Failed **

The problem is solved with the following modification:

float edgeIntensity = exp2((-1.0f / edgeWidth)*nearD*nearD * 2);

replace -1f by -1.0f , Mystery??

I have also had to replace this code (comment only part):

public WavefrontOBJViewer()
			: base(
				800, 600), 
				GraphicsMode.Default, // color format
				"WavefrontOBJLoader",
				GameWindowFlags.Default,  // windowed mode 
				DisplayDevice.Default,    // primary monitor
				2, 2,  // opengl version
				GraphicsContextFlags.Debug
				)
		{
			VSync = VSyncMode.On;
 
		}

by

public WavefrontOBJViewer()
			: base(
				800, 600)/*, 
				GraphicsMode.Default, // color format
				"WavefrontOBJLoader",
				GameWindowFlags.Default,  // windowed mode 
				DisplayDevice.Default,    // primary monitor
				2, 2,  // opengl version
				GraphicsContextFlags.Debug
				)*/
		{
			VSync = VSyncMode.On;
 
		}

for the window displays, linux stuff!

If it works on Linux should run on Windows

flopoloco's picture

Nice work Jeske. Works great.

ravi.joshi53's picture

Just tried to run on my laptop (in which there is no graphic card). I got the following error-

I am using Windows 7 32bit.

Gameengineer's picture

Great framework. Lots of time and effort was put into this code and the codeproject article.