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