72 lines
1.5 KiB
C#
72 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using OpenTK;
|
|
|
|
using org.budnhead.graphics;
|
|
|
|
namespace org.budnhead.core
|
|
{
|
|
public abstract class WorldObject
|
|
{
|
|
private List<WorldObject> children;
|
|
|
|
public WorldObject()
|
|
{
|
|
children = new List<WorldObject>();
|
|
}
|
|
|
|
public virtual Model3D getModel3D(){
|
|
return null;
|
|
}
|
|
|
|
public readonly BufferedValueInstance<Vector3> Position = new BufferedValueInstance<Vector3>(new Vector3());
|
|
public readonly BufferedValueInstance<Matrix4> Rotation = new BufferedValueInstance<Matrix4>(Matrix4.Identity);
|
|
public readonly BufferedValueInstance<Matrix4> Scale = new BufferedValueInstance<Matrix4>(Matrix4.Identity);
|
|
|
|
public Matrix4 Transformation {
|
|
get { return (Scale.Value * Rotation.Value) * Matrix4.CreateTranslation( Position.Value ) ; }
|
|
}
|
|
public Matrix4 BufferedTransformation {
|
|
get { return (Scale.BufferedValue * Rotation.BufferedValue) * Matrix4.CreateTranslation( Position.BufferedValue ) ; }
|
|
}
|
|
|
|
public void addChild(WorldObject wo){
|
|
if (!children.Contains(wo)){
|
|
children.Add(wo);
|
|
}
|
|
}
|
|
|
|
public void removeChild(WorldObject wo){
|
|
if (children.Contains(wo)){
|
|
children.Remove(wo);
|
|
}
|
|
}
|
|
|
|
public WorldObject[] Children{
|
|
get { return this.children.ToArray(); }
|
|
}
|
|
}
|
|
|
|
public class ObjectGroup : WorldObject {
|
|
|
|
}
|
|
|
|
public class DumpObject : WorldObject {
|
|
|
|
Model3D model3d;
|
|
|
|
public Model3D Model3D {
|
|
get { return this.model3d; }
|
|
set { this.model3d = value; }
|
|
}
|
|
|
|
public override Model3D getModel3D()
|
|
{
|
|
return model3d;
|
|
}
|
|
|
|
}
|
|
|
|
}
|