65 lines
1.2 KiB
C#
65 lines
1.2 KiB
C#
using System;
|
|
|
|
using OpenTK;
|
|
|
|
namespace org.niclasundharald.engine.graphics
|
|
{
|
|
public class GLScene
|
|
{
|
|
GLSceneOrientation sceneOrientation;
|
|
ShaderProgram shader;
|
|
WorldObject root;
|
|
|
|
public GLScene()
|
|
{
|
|
sceneOrientation = GlobalDefaults.instance().ActiveScene;
|
|
shader = GlobalDefaults.instance().DefaultShaderProgram;
|
|
root = new ObjectGroup();
|
|
}
|
|
|
|
public GLScene(GLSceneOrientation sceneOrientation)
|
|
{
|
|
this.sceneOrientation = sceneOrientation;
|
|
shader = GlobalDefaults.instance().DefaultShaderProgram;
|
|
root = new ObjectGroup();
|
|
}
|
|
|
|
|
|
|
|
public WorldObject RootObject {
|
|
get { return this.root; }
|
|
set { this.root = value; }
|
|
}
|
|
|
|
public void draw(){
|
|
Matrix4 objectMatrix = Matrix4.Identity;
|
|
|
|
shader.use();
|
|
|
|
if (root != null){
|
|
draw( objectMatrix, root );
|
|
}
|
|
}
|
|
|
|
public void draw(Matrix4 baseMatrix,WorldObject wo){
|
|
Matrix4 objectMatrix = baseMatrix * wo.Transformation;
|
|
|
|
//Console.WriteLine("draw(): o={0}\noM=\n{1}",wo,objectMatrix);
|
|
shader.setup(objectMatrix, sceneOrientation);
|
|
|
|
Model3D m3d = wo.getModel3D();
|
|
if (m3d != null){
|
|
m3d.draw();
|
|
}
|
|
|
|
foreach (WorldObject child in wo.Children){
|
|
draw( objectMatrix, child );
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|