public override void Init() { this.SetModel(Resource.GetMesh("radio.obj")); this.Material = Resource.GetMaterial("engine/white"); Song = Audio.LoadSong("Resources/Audio/radio.mp3", true, true, this); //Song.Play(true); }
public override void Init() { this.Material = Resource.GetMaterial("models/props/speaker"); this.Material.Properties.SpecularPower = 32.0f; this.Material.Properties.SpecularIntensity = 1.0f; this.drawMode = OpenTK.Graphics.OpenGL.BeginMode.Triangles; this.Model = Resource.GetMesh("speaker.obj"); //this.Model = ObjLoader.LoadFile("Resources/Models/cow.obj"); song = Audio.LoadSong("Resources/Audio/Brodyquest.mp3", true, true, this ); startTime = (float)Utilities.Time + 1.0f; //this.DisableLighting = true; }
private static void LoadCuePoints(Audio audio, string filename) { AudioCueLoader.CueStruct[] cues = AudioCueLoader.LoadCues(filename); if (cues != null) { audio.StartLoopPosition = cues[0].SamplePosition * 2; audio.EndLoopPosition = cues[1].SamplePosition * 2; audio.EndLoopPosition = (int)Utilities.Clamp(audio.EndLoopPosition, Bass.BASS_ChannelGetLength(audio.Handle, BASSMode.BASS_POS_BYTES) - 200, 0L); } }
/// <summary> /// Load a song from the hard disk and create a new Audio instance. /// </summary> /// <param name="filename">The filename on the hard disk</param> /// <param name="Loop">Should the sound loop?</param> /// <param name="Positional">Should the sound play at a specific position? (else global)</param> /// <param name="ent">If it is positional, what entity should this be attached to?</param> /// <returns>A new Audio class</returns> public static Audio LoadSong(string filename, bool Loop = false, bool Positional = false, Entity.BaseEntity ent = null) { int handle = 0; BASSFlag flags = BASSFlag.BASS_MUSIC_PRESCAN; if (Loop) flags = flags | BASSFlag.BASS_SAMPLE_LOOP; if (Positional || ent != null) flags = flags | BASSFlag.BASS_SAMPLE_3D | BASSFlag.BASS_SAMPLE_MONO; handle = Bass.BASS_StreamCreateFile(filename, 0, 0, flags); if (handle != 0) { Audio audio = new Audio(handle, filename); audio.Positional = (Positional || ent != null); audio.AttachedEntity = ent; audio.Looped = Loop; //Try to load the loop positions from wav files if (audio.Looped) LoadCuePoints(audio, filename); //Add the audio object to our list to keep track of it _lsAudio.Add(audio); //Set its volume so it's in line with our global volume audio.SetVolume(audio.Volume); //Create a callback so we can control playback looping and stuff Bass.BASS_ChannelSetSync(audio.Handle, BASSSync.BASS_SYNC_END, 0, _SyncDel, IntPtr.Zero); return audio; } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed to create music stream '" + filename + "'!"); Console.WriteLine(Bass.BASS_ErrorGetCode()); Console.ResetColor(); if (Bass.BASS_ErrorGetCode() == BASSError.BASS_ERROR_NO3D) Console.WriteLine("Are you sure the audio file is mono?"); } return new Audio(-1, "rude"); }
public override void Init() { this.drawMode = OpenTK.Graphics.OpenGL.BeginMode.Triangles; this.Scale = new Vector3(physScale, physScale, physScale); offsets[0] *= physScale; offsets[1] *= physScale; wheelsize *= physScale; //Load models this.Model = Resource.GetMesh("vehicles/van.obj"); this.Material = Resource.GetMaterial("models/vehicles/van"); wheel = Resource.GetMesh("wheel.obj"); wheel.mat = this.Material; //Create the physics /* Body bod = FarseerPhysics.Factories.BodyFactory.CreateRectangle(Utilities.PhysicsWorld, 14f * physScale, 4.7f * physScale, 0.7f); bod.BodyType = BodyType.Dynamic; this.Physics = bod.FixtureList[0]; this.Physics.Body.Restitution = 0.2f; this.Physics.Body.Friction = 2.0f; this.Physics.UserData = (object)this.GetType().Name; //Create da weelz wheels = new Fixture[2]; Body wheelbod = FarseerPhysics.Factories.BodyFactory.CreateCircle(Utilities.PhysicsWorld, wheelsize, 0.7f); wheelbod.BodyType = BodyType.Dynamic; wheelbod.Friction = 20.0f; wheelbod.Position = new Microsoft.Xna.Framework.Vector2(offsets[0].X, offsets[0].Y ); wheelbod.Restitution = 1.0f; FarseerPhysics.Factories.JointFactory.CreateRevoluteJoint(Utilities.PhysicsWorld, wheelbod, this.Physics.Body, wheelbod.Position); //Microsoft.Xna.Framework.Vector2.Zero wheels[0] = wheelbod.FixtureList[0]; wheelbod = FarseerPhysics.Factories.BodyFactory.CreateCircle(Utilities.PhysicsWorld, wheelsize, 0.7f); wheelbod.BodyType = BodyType.Dynamic; wheelbod.Position = new Microsoft.Xna.Framework.Vector2(offsets[1].X, offsets[1].Y); wheelbod.Restitution = 1.0f; FarseerPhysics.Factories.JointFactory.CreateRevoluteJoint(Utilities.PhysicsWorld, wheelbod, this.Physics.Body, wheelbod.Position); wheels[1] = wheelbod.FixtureList[0]; //Set their positions this.Physics.Body.Position = new Microsoft.Xna.Framework.Vector2(this.Position.X, this.Position.Y); wheels[0].Body.Position = new Microsoft.Xna.Framework.Vector2(offsets[0].X, offsets[0].Y) + this.Physics.Body.Position; wheels[1].Body.Position = new Microsoft.Xna.Framework.Vector2(offsets[1].X, offsets[1].Y) + this.Physics.Body.Position; */ //Setup overriding the camera and stuff Zoom = 15.0f; Utilities.engine.Keyboard.KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown); View.CalcView += new Action(ply_CalcView); horn = Audio.LoadSong("Resources/Audio/horn.mp3", false, true, this); }
public override void Init() { //Create the model //Utilities.VertexP3N3T2[] vertss = Utilities.CalculateVertices(radius, radius, 90, 90); //int[] elements = Utilities.CalculateElements(90, 90); ; this.Model = Resource.GetMesh("cow.obj"); //Utilities.LoadOBJ("Resources/Models/cow.obj", out verts, out elements, out normals, out lsUV); //this.Mat = Resource.GetMaterial("Resources/Materials/cow.jpg"); //, "Resources/Shaders/default.vert", "Resources/Shaders/default.frag" //this.Mat = Resource.GetMaterial("Resources/Materials/cow.jpg", "Resources/Shaders/default.vert", "Resources/Shaders/default.frag"); this.drawMode = OpenTK.Graphics.OpenGL.BeginMode.Triangles; this.SetPos(new Vector3(0, 3.0f, -3.0f)); Zoom = 10.0f; Normal = new Vector2(0, 1); //Create the sound effect for the physics of our ball phys_hit = Audio.LoadSong("Resources/Audio/Physics/rock_hit_hard.wav", false); Utilities.engine.Keyboard.KeyDown += new EventHandler<KeyboardKeyEventArgs>(Keyboard_KeyDown); this.SetMode(PlayerMode.NOCLIP); }