public void Update(EngineTime engineTime) { if (!IsEnabled || !IsAnimating || Animation == null || Math.Abs(PlaybackSpeed) <= float.Epsilon) { return; } _IsDirty = true; _CurrentPlaybackPosition += engineTime.ElapsedTime.TotalSeconds * PlaybackSpeed; if (IsLooping) { while (_CurrentPlaybackPosition < 0) { _CurrentPlaybackPosition += Animation.Duration; } while (_CurrentPlaybackPosition > Animation.Duration) { _CurrentPlaybackPosition -= Animation.Duration; } } else if (_CurrentPlaybackPosition <= 0 || _CurrentPlaybackPosition > Animation.Duration) { _IsAnimating = false; } }
public override void Draw(EngineTime time, ref Matrix world, ref Matrix view, ref Matrix projection) { base.Draw(time, ref world, ref view, ref projection); if (AnimationPlayer.Animation != null) { if (DisplayAnimationJoints) { foreach (var i in _BoneMap) { var m = _AnimationPose[i]; var w = Matrix.Scaling(0.025f) * m * world; Engine.Cube.Draw(time, ref w, ref view, ref projection); } } } if (DisplayReferenceJoints) { foreach (var i in _BoneMap) { var m = Skeleton.ReferencePose[i]; var w = Matrix.Scaling(0.025f) * m * world; Engine.Cube.Draw(time, ref w, ref view, ref projection); } } }
public override void Update(EngineTime engineTime) { if (AnimationPlayer.Animation != null) { AnimationPlayer.Update(engineTime); _AnimationPose = _AnimationPlayer.GetPose(); for (var i = 0; i < JointMatrixArray.Length; ++i) { var skeletonBoneIndex = _BoneMap[i]; var invRef = _InvertedReferencePose[skeletonBoneIndex]; var pose = _AnimationPose[skeletonBoneIndex]; JointMatrixArray[i] = invRef * pose; } } else { for (var i = 0; i < JointMatrixArray.Length; ++i) { JointMatrixArray[i] = Matrix.Identity; } } base.Update(engineTime); }
public override void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection) { if (Material == null) { return; } var transformedWorld = Transformation * world; var ia = Engine.Device.ImmediateContext.InputAssembler; EffectTechnique tech = Material.CurrentTechnique; Material.Effect.Apply(ref world, ref view, ref projection); Material.Apply(Model.Parameters); var skinnedEffect = Material.Effect as Effects.SkinnedEffect; if (skinnedEffect != null) { var boneList = Model.Definition.BoneLists[Primitive.BaseMesh.Header.BoneListIndex]; Matrix[] jointMatrix = new Matrix[boneList.ActualCount]; for (var i = 0; i < boneList.ActualCount; ++i) { jointMatrix[i] = Model.JointMatrixArray[boneList.Bones[i]]; } skinnedEffect.JointMatrixArray = jointMatrix; } ia.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList; ia.SetVertexBuffers(0, Primitive.VertexBufferBinding); ia.SetIndexBuffer(Primitive.IndexBuffer, SharpDX.DXGI.Format.R16_UInt, 0); InputLayout inputLayout = Material.Effect.GetInputLayout(tech.GetPassByIndex(0)); ia.InputLayout = inputLayout; for (var i = 0; i < tech.Description.PassCount; ++i) { var pass = tech.GetPassByIndex(i); pass.Apply(Engine.Device.ImmediateContext); if (Parts.Length == 0) { Engine.Device.ImmediateContext.DrawIndexed(Primitive.BaseMesh.Header.IndexCount, 0, 0); } else { foreach (var part in Parts) { part.Draw(Engine.Device); } } } }
public override void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection) { if (!IsLoaded) { return; } var transformedWorld = Transformation * world; _MeshContainer.Draw(time, ref transformedWorld, ref view, ref projection); }
//Update for the controller public void Update(SceneNode node, EngineTime time, InputState inputs) { //Get the actual position of the camera Vector3 position = node.WorldTranslation; //Get the actual rotation of the camera Matrix matrix = Matrix.CreateFromQuaternion(node.WorldRotation); //Set the corrected translmation to the camera with a smooth effect node.WorldTranslation = (float)(1 - K * time.ElapsedTime.TotalSeconds) * position + K * (float)time.ElapsedTime.TotalSeconds * TargetPosition; //Set the rotation of the camera for always looking at the NanoBot node.WorldRotation = LookAt(node); }
private void OnUpdate(EngineTime time) { foreach (var rectangle in layer.Elements.Where(l => l.GetType() == typeof(Rectangle))) { var transform = rectangle.Transform; transform.rotation -= 0.001f; var bounds = rectangle.LocalBounds; rectangle.LocalBounds = bounds; rectangle.Transform = transform; } foreach (var triangle in layer.Elements.Where(l => l.GetType() == typeof(Triangle))) { var transform = triangle.Transform; transform.rotation += 0.001f; var bounds = triangle.LocalBounds; triangle.LocalBounds = bounds; triangle.Transform = transform; } var ctransform = c.Transform; ctransform.rotation += 0.001f * (float)time.FrameTime.TotalMilliseconds; if (Keyboard.IsKeyDown(Keyboard.Key.W)) { ctransform.position.y -= 1.0f; } if (Keyboard.IsKeyDown(Keyboard.Key.A)) { ctransform.position.x -= 1.0f; } if (Keyboard.IsKeyDown(Keyboard.Key.S)) { ctransform.position.y += 1.0f; } if (Keyboard.IsKeyDown(Keyboard.Key.D)) { ctransform.position.x += 1.0f; } c.Transform = ctransform; }
public override void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection) { var ia = Engine.Device.ImmediateContext.InputAssembler; var vs = Engine.Device.ImmediateContext.VertexShader; var ps = Engine.Device.ImmediateContext.PixelShader; var worldViewProj = world * view * projection; worldViewProj.Transpose(); Engine.Device.ImmediateContext.UpdateSubresource(ref worldViewProj, ConstantBuffer); ia.InputLayout = InputLayout; ia.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList; ia.SetVertexBuffers(0, VertexBufferBinding); vs.SetConstantBuffer(0, ConstantBuffer); vs.Set(VertexShader); ps.Set(PixelShader); Engine.Device.ImmediateContext.Draw(36, 0); }
/// <summary> /// Scene Drawing and Updating. /// </summary> public void UpdateAndDraw() { this.ThrottleIfInactive(); App.BeginProfiling(); try { float elapsedSecs = this.mStopWatch.GetElapsedMilliSecs() / 1000f; float deltaRealTime = elapsedSecs - this.mTimeAtLastFrame; float deltaGameTime = 0f; if (!this.mPauseGameTime) { deltaGameTime = deltaRealTime * this.mGameTimeMultiplier; } this.mTotalRealTime += deltaRealTime; this.mTotalGameTime += deltaGameTime; EngineTime engineTime = new EngineTime(deltaRealTime, deltaGameTime, this.mTotalRealTime, this.mTotalGameTime); this.mTimeAtLastFrame = elapsedSecs; App.PauseGameClock(this.mPauseGameTime); App.SetGameTimeScale(this.mGameTimeMultiplier); App.Update(deltaRealTime, deltaGameTime); Sims3.CSHost.Animation.Manager.UpdateRenderer(deltaGameTime); this.UpdateExtra(engineTime); if (GfxDevice.BeginScene()) { this.mScene.BeginFrame(); this.mScene.DrawScene(); this.DrawExtra(engineTime); if (!this.mHideUI) { GfxDevice.RectInt viewport = GfxDevice.GetViewport(); App.RenderUI(viewport.left, viewport.top, viewport.right, viewport.bottom); } GfxDevice.EndScene(); } GfxDevice.Present(); } finally { App.EndProfiling(); } }
public override void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection) { if (Material == null) return; var transformedWorld = Transformation * world; var ia = Engine.Device.ImmediateContext.InputAssembler; EffectTechnique tech = Material.CurrentTechnique; Material.Effect.Apply(ref world, ref view, ref projection); Material.Apply(Model.Parameters); var skinnedEffect = Material.Effect as Effects.SkinnedEffect; if (skinnedEffect != null) { var boneList = Model.Definition.BoneLists[Primitive.BaseMesh.Header.BoneListIndex]; Matrix[] jointMatrix = new Matrix[boneList.ActualCount]; for (var i = 0; i < boneList.ActualCount; ++i) jointMatrix[i] = Model.JointMatrixArray[boneList.Bones[i]]; skinnedEffect.JointMatrixArray = jointMatrix; } ia.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList; ia.SetVertexBuffers(0, Primitive.VertexBufferBinding); ia.SetIndexBuffer(Primitive.IndexBuffer, SharpDX.DXGI.Format.R16_UInt, 0); InputLayout inputLayout = Material.Effect.GetInputLayout(tech.GetPassByIndex(0)); ia.InputLayout = inputLayout; for (var i = 0; i < tech.Description.PassCount; ++i) { var pass = tech.GetPassByIndex(i); pass.Apply(Engine.Device.ImmediateContext); if (Parts.Length == 0) { Engine.Device.ImmediateContext.DrawIndexed(Primitive.BaseMesh.Header.IndexCount, 0, 0); } else { foreach (var part in Parts) part.Draw(Engine.Device); } } }
public void Update(EngineTime engineTime) { if (!string.IsNullOrWhiteSpace(SetTitle)) { _Engine.Form.Text = SetTitle; SetTitle = null; } if (Replacement != null) { lock (AddQueue) AddQueue.Clear(); _InnerContainer.Clear(); var l = Replacement(_Engine); foreach (var c in l) { if (c != null) { _InnerContainer.Add(c); } } Replacement = null; } EngineHelper.MultiComponentFunction[] toAdd; lock (AddQueue) { toAdd = AddQueue.ToArray(); AddQueue.Clear(); } foreach (var f in toAdd) { var l = f(_Engine); foreach (var c in l) { if (c != null) { _InnerContainer.Add(c); } } } _InnerContainer.Update(engineTime); }
protected override void DrawExtra(EngineTime engineTime) { if (this.mDebugCircleVisible) { GraphicsUtil.DrawCircle(ref sDrawTransform, 1f, this.mDrawColor, false); } if (this.mEffectsStatsVisible) { EffectsManager.DrawStats(this.mEffectStatsX, this.mEffectStatsY, this.mEffectStatsIncr); } if (this.mGeneralStatsVisible) { StatsManager.DrawStats(this.mGeneralStatsX, this.mGeneralStatsY); } if (this.mGameSpeedVisible) { float textY = this.renderPanelEx1.Height - 14f; App.DrawText(string.Concat("Game Speed: ", this.PauseGameTime ? "Paused" : this.GameTimeMultiplier.ToString()), 2f, textY); } }
private void OnUpdate(EngineTime time) { if (Keyboard.IsKeyDown(Keyboard.Key.ESC)) { SaNiEngine.Exit(); return; } // Windowed/fullscreen changes. //if (Keyboard.IsKeyDown(Keyboard.Key.Y)) GraphicsDevice.Fullscreen(); //if (Keyboard.IsKeyDown(Keyboard.Key.U)) GraphicsDevice.Windowed(); foreach (var brick in bricks) { brick.Fill = new Color((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble()); } player.Update(time); ball.Update(time, player.Rect.GlobalBounds); // Best collision check algorithm EU (bricks <-> ball) for (var i = 0; i < bricks.Count; i++) { var brick = bricks[i]; if (brick.GlobalBounds.Intersects(ball.Circle.GlobalBounds)) { brick.Destroy(); bricks.Remove(brick); } } }
public override void Update(EngineTime engineTime) { _TerrainContainer.Update(engineTime); _LgbPartsContainer.Update(engineTime); base.Update(engineTime); }
public override void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection) { _TerrainContainer.Draw(time, ref world, ref view, ref projection); _LgbPartsContainer.Draw(time, ref world, ref view, ref projection); }
public override void Update(SceneNode node, EngineTime time) { base.Update(node, time); _lastWorld = node.WorldPose; }
public override void Update(EngineTime engineTime) { _MeshContainer.Update(engineTime); base.Update(engineTime); }
/// <summary> /// Place to put code that is executed before drawing is performed /// in the current game time frame. /// </summary> /// <param name="engineTime">The time values for the current updating frame.</param> protected virtual void UpdateExtra(EngineTime engineTime) { }
public void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection) { _InnerContainer.Draw(time, ref world, ref view, ref projection); }
public override void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection) { if (!IsLoaded) return; var transformedWorld = Transformation * world; _MeshContainer.Draw(time, ref transformedWorld, ref view, ref projection); }
public override void Update(EngineTime engineTime) { _Content.Update(engineTime); base.Update(engineTime); }
public void Update(EngineTime time) { var direction = GetDirectionFromInput(); Move(direction, (float)time.FrameTime.TotalMilliseconds); }
public override void Update(EngineTime engineTime) { if (AnimationPlayer.Animation != null) { AnimationPlayer.Update(engineTime); _AnimationPose = _AnimationPlayer.GetPose(); for(var i = 0; i < JointMatrixArray.Length; ++i) { var skeletonBoneIndex = _BoneMap[i]; var invRef = _InvertedReferencePose[skeletonBoneIndex]; var pose = _AnimationPose[skeletonBoneIndex]; JointMatrixArray[i] = invRef * pose; } } else { for (var i = 0; i < JointMatrixArray.Length; ++i) JointMatrixArray[i] = Matrix.Identity; } base.Update(engineTime); }
public void Update(EngineTime time, Rectf playerRect) { var delta = (float)time.FrameTime.TotalMilliseconds; Move(delta, playerRect); }
public override void Draw(EngineTime time, ref SharpDX.Matrix world, ref SharpDX.Matrix view, ref SharpDX.Matrix projection) { var adjustedWorld = Transformation * world; _Content.Draw(time, ref adjustedWorld, ref view, ref projection); }
public void Update(EngineTime engineTime) { if (!IsEnabled || !IsAnimating || Animation == null || Math.Abs(PlaybackSpeed) <= float.Epsilon) return; _IsDirty = true; _CurrentPlaybackPosition += engineTime.ElapsedTime.TotalSeconds * PlaybackSpeed; if (IsLooping) { while (_CurrentPlaybackPosition < 0) _CurrentPlaybackPosition += Animation.Duration; while (_CurrentPlaybackPosition > Animation.Duration) _CurrentPlaybackPosition -= Animation.Duration; } else if (_CurrentPlaybackPosition <= 0 || _CurrentPlaybackPosition > Animation.Duration) _IsAnimating = false; }
/// <summary> /// Place to put code that is executed between /// GfxDevice.BeginScene() and GfxDevice.EndScene(), /// after the Scene Manager is rendered and before the UI is rendered. /// </summary> /// <param name="engineTime">The time values for the current drawing frame.</param> protected virtual void DrawExtra(EngineTime engineTime) { }