59 lines
1.1 KiB
C#
59 lines
1.1 KiB
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
using OpenTK;
|
||
|
|
||
|
using org.niclasundharald.engine.graphics;
|
||
|
|
||
|
namespace org.niclasundharald.engine
|
||
|
{
|
||
|
public abstract class WorldObject
|
||
|
{
|
||
|
private Matrix4 transformation;
|
||
|
|
||
|
private List<WorldObject> children;
|
||
|
|
||
|
public WorldObject()
|
||
|
{
|
||
|
transformation = Matrix4.Identity;
|
||
|
children = new List<WorldObject>();
|
||
|
}
|
||
|
|
||
|
public virtual Model3D getModel3D(){
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
|
||
|
public Vector3 Position{
|
||
|
get { return this.transformation.ExtractTranslation(); }
|
||
|
set { this.transformation += Matrix4.CreateTranslation(value - this.transformation.ExtractTranslation()); }
|
||
|
}
|
||
|
|
||
|
public Matrix4 Transformation {
|
||
|
get { return this.transformation; }
|
||
|
set { this.transformation = value; }
|
||
|
}
|
||
|
|
||
|
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 {
|
||
|
|
||
|
}
|
||
|
}
|