using System; using System.Collections.Generic; using OpenTK; using org.budnhead.audio; using org.budnhead.graphics; namespace org.budnhead.core { public class Actor : WorldObject { internal static List activeActors = new List(); private static List finishedActors = new List(); internal static void updateActors(float elapsed){ // Update all active Actors... foreach (Actor a in activeActors.ToArray()){ a.update(elapsed); } // Remove finished Actors foreach (Actor a in finishedActors.ToArray()){ 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); //_player = new nhPlayer(); //activePlayers.Add(_player); } public void destroy(){ finishedActors.Add(this); //_player.deletePlayer(); } public readonly BufferedValueInstance Heading = new BufferedValueInstance(new Vector3(0,0,1)); public readonly BufferedValueInstance Velocity = new BufferedValueInstance(new Vector3()); public readonly BufferedValueInstance Weight = new BufferedValueInstance(0); public bool IsActive { get { return activeActors.Contains(this); } } public virtual void update(float timespan){ /* if (soundPlaying()){ syncSoundPosition(); } */ } 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.Value = Matrix4.CreateRotationX(MathHelper.PiOver2) * mRotation; } public Model3D Model3D { get; set; } public override Model3D getModel3D() { return Model3D; } //>>>>>>>>AUDIO private static List activePlayers = new List(); private static Dictionary aBuffers = new Dictionary(); private nhPlayer _player; public bool isPlaying = false; public void setDistanceAttenuation(float rollOf = 2.0f, float refDistance = 1.0f, float maxDistance = 100.0f) { // _player.setDistanceAttenuation(rollOf, refDistance, maxDistance); } public void setBuffers(params string[] buffers) { /* foreach (string i in buffers) { if(!aBuffers.ContainsKey(i)) aBuffers.Add(i, nhBuffers.buffers[i]); }*/ } public void playSound(string sound, float gain = 1.0f, bool loop = false) { // _player.position = this.Position.Value; // _player.velocity = this.Velocity.Value; // _player.play(aBuffers[sound], gain, loop); } private void syncSoundPosition() { // _player.setPosition(this.Position.Value); // _player.setVelocity(this.Velocity.Value); } public Boolean soundPlaying(){ return false; //_player.state(); } } }