78 lines
1.4 KiB
C#
78 lines
1.4 KiB
C#
using System;
|
|
|
|
using OpenTK;
|
|
using org.budnhead.core;
|
|
using org.budnhead.tools;
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
namespace org.budnhead.graphics
|
|
{
|
|
public class Scene
|
|
{
|
|
ShaderProgram shader;
|
|
WorldObject root;
|
|
|
|
public Scene()
|
|
{
|
|
shader = ResourceLibrary.getResource<ShaderProgram>("default");
|
|
root = new ObjectGroup();
|
|
}
|
|
|
|
public Scene(GLSceneOrientation sceneOrientation)
|
|
{
|
|
shader = ResourceLibrary.getResource<ShaderProgram>("default");
|
|
root = new ObjectGroup();
|
|
}
|
|
|
|
public Scene(Scene source){
|
|
this.shader = source.shader;
|
|
this.root = source.root;
|
|
}
|
|
|
|
|
|
public WorldObject RootObject {
|
|
get { return this.root; }
|
|
set { this.root = value; }
|
|
}
|
|
|
|
public void draw(Viewport viewport){
|
|
Matrix4 objectMatrix = Matrix4.Identity;
|
|
|
|
shader.use();
|
|
|
|
if (root != null){
|
|
draw( viewport, objectMatrix, root );
|
|
}
|
|
|
|
foreach (WorldObject child in Actor.activeActors.ToArray()){
|
|
draw( viewport, objectMatrix, child );
|
|
}
|
|
|
|
}
|
|
|
|
public void draw(Viewport viewport,Matrix4 baseMatrix,WorldObject wo){
|
|
Matrix4 objectMatrix = wo.Transformation * baseMatrix;
|
|
|
|
//Console.WriteLine("draw(,{0}",wo);
|
|
|
|
//Console.WriteLine("draw(): o={0}\noM=\n{1}",wo,objectMatrix);
|
|
shader.setup(objectMatrix, viewport.SceneOrientation);
|
|
|
|
Model3D m3d = wo.getModel3D();
|
|
if (m3d != null){
|
|
m3d.draw();
|
|
}
|
|
|
|
foreach (WorldObject child in wo.Children){
|
|
draw( viewport, objectMatrix, child );
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|