using System; using System.Collections.Generic; using OpenTK; using org.niclasundharald.engine.graphics; namespace org.niclasundharald.engine { public class Actor : WorldObject { public static List activeActors = new List(); public static List finishedActors = new List(); public static void updateAll(float timespan){ foreach (Actor a in activeActors){ a.update(timespan); } foreach (Actor a in finishedActors){ activeActors.Remove(a); } finishedActors.Clear(); } private int id; public Actor(int id) { Console.WriteLine("New Actor: {0} / {1}",id,this); this.id = id; activeActors.Add(this); } public void destroy(){ finishedActors.Add(this); } public Vector3 Heading { get; set; } public Vector3 Velocity { get; set; } public float Weight { get; set; } public virtual void update(float timespan){ } public void setHeading(Vector3 heading,Vector3 top){ Vector3 x,y,z; z = heading.Normalized(); x = Vector3.Cross( top.Normalized(), z ).Normalized(); y = Vector3.Cross( x, z ); Matrix4 mRotation = new Matrix4( new Vector4(x,0), new Vector4(y,0), new Vector4(z,0), new Vector4(0,0,0,1) ); Rotation = Matrix4.CreateRotationX(MathHelper.PiOver2) * mRotation; } public Model3D Model3D { get; set; } public override Model3D getModel3D() { return Model3D; } } }