internal PlayerModel( int playerIndex, int asioChannel, HolofunkModel holofunkModel) { m_playerIndex = playerIndex; m_asioChannel = asioChannel; m_parent = holofunkModel; // TODO: EVIL INIT ORDER DEPENDENCY: hand models contain state machines, which update scene graphs on initialization! m_playerSceneGraph = new PlayerSceneGraph(holofunkModel.SceneGraph, playerIndex, asioChannel); m_leftHandModel = new PlayerHandModel(this, false); m_rightHandModel = new PlayerHandModel(this, true); // the microphone has only per-loop parameters m_microphoneParameters = AllEffects.CreateParameterMap(); }
/// <summary>Update the scene's background based on the current beat, and the positions of /// the two hands based on the latest data polled from Kinect.</summary> /// <remarks>We pass in the current value of "now" to ensure consistent /// timing between the PlayerState update and the scene graph udpate.</remarks> internal void Update( HolofunkModel holofunkModel, HolofunKinect kinect, Moment now, float frameRateMsec) { // should do this once a second or so, to reduce garbage... if (++m_frameCount == MagicNumbers.StatusTextUpdateInterval) { m_frameCount = 0; m_statusText.Text.Clear(); long usedAudioMB = Audio.AudioAllocator.TotalReservedSpace / 1024 / 1024; long freeAudioMB = Audio.AudioAllocator.TotalFreeListSpace / 1024 / 1024; long usedVideoMB = holofunkModel.VideoAllocator.TotalReservedSpace / 1024 / 1024; long freeVideoMB = holofunkModel.VideoAllocator.TotalFreeListSpace / 1024 / 1024; m_statusText.Text.AppendFormat( "Time: {10}:{11:D2} | BPM: {0} | Update FPS: {1} | Kinect FPS: {2} | CPU: {3}%\nAudio: {4}/{5}MB | Video: {6}/{7}MB | Free streams: {8}\n{9}\n", Clock.BPM, frameRateMsec == 0 ? 0 : Math.Floor((1000f / frameRateMsec) * 10) / 10, kinect.m_totalFrames / Clock.Now.Seconds, Math.Floor(Audio.CpuUsage * 10) / 10, usedAudioMB - freeAudioMB, usedAudioMB, usedVideoMB - freeVideoMB, usedVideoMB, Audio.StreamPoolFreeCount, (Spam.TopLine1 == null ? "" : Spam.TopLine1) + "\n" + (Spam.TopLine2 == null ? "" : Spam.TopLine2), DateTime.Now.Hour, DateTime.Now.Minute); } // Scale to byte and use for all RGBA components (premultiplied alpha, don't you know) Color backgroundColor = FloatScaleToRGBAColor(1 - (now.FractionalBeat / 1.2f)); m_background.Color = backgroundColor; m_background.SecondaryColor = backgroundColor; m_beatNode.Update(now); Texture2D currentSlide = Content.Slides[holofunkModel.SlideIndex]; m_slide.Texture = currentSlide; m_slide.LocalTransform = new Transform(new Vector2( m_canvasSize.X - (int)(currentSlide.Width), currentSlide.Height / 8)); m_slide.Color = holofunkModel.SlideVisible ? Color.White : new Color(0, 0, 0, 0); Spam.Graphics.WriteLine("EndUpdate"); }
protected override void LoadContent() { base.LoadContent(); float scale = GraphicsDevice.PresentationParameters.BackBufferHeight / m_viewportSize.Y; float scaledViewportWidth = m_viewportSize.X * scale; float scaledViewportOffset = (GraphicsDevice.PresentationParameters.BackBufferWidth - scaledViewportWidth) / 2; Transform transform = new Transform(new Vector2(scaledViewportOffset, 0), new Vector2(scale)); m_spriteBatch = new SpriteBatchWrapper(new SpriteBatch(GraphicsDevice), ViewportSize, transform); var holofunkContent = new HolofunkTextureContent(Content, GraphicsDevice); m_model = new HolofunkModel( GraphicsDevice, m_clock, m_holofunkBass, m_kinect, holofunkContent, m_viewportSize, m_clock.BPM, m_audioAllocator, m_videoAllocator); }