/// <summary> /// Updates this object for the given view. /// </summary> /// <param name="updateState">Current state of the update pass.</param> /// <param name="layerViewSubset">The layer view subset wich called this update method.</param> protected override void UpdateForViewInternal(SceneRelatedUpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset) { if (base.CountRenderPassSubscriptions(layerViewSubset) == 0) { base.SubscribeToPass(RenderPassInfo.PASS_LINE_RENDER, layerViewSubset, RenderLines); } }
/// <summary> /// Updates this object for the given view. /// </summary> /// <param name="updateState">Current state of the update pass.</param> /// <param name="layerViewSubset">The layer view subset which called this update method.</param> protected override void UpdateForViewInternal(SceneRelatedUpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset) { if (this.CountRenderPassSubscriptions(layerViewSubset) <= 0) { this.SubscribeToPass(RenderPassInfo.PASS_PLAIN_RENDER, layerViewSubset, this.Render); } }
/// <summary> /// Updates this object for the given view. /// </summary> /// <param name="updateState">Current state of the update pass.</param> /// <param name="layerViewSubset">The layer view subset wich called this update method.</param> protected override void UpdateForViewInternal(SceneRelatedUpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset) { //Subscribe to render passes if ((m_passRelevantValuesChanged) || (base.CountRenderPassSubscriptions(layerViewSubset) == 0)) { //Unsubscribe from all passes first base.UnsubsribeFromAllPasses(layerViewSubset); //Now subscribe to needed pass if (base.Opacity < 1f) { base.SubscribeToPass( RenderPassInfo.PASS_TRANSPARENT_RENDER, layerViewSubset, OnRenderTransparent); } else { base.SubscribeToPass( RenderPassInfo.PASS_PLAIN_RENDER, layerViewSubset, OnRenderPlain); } //Update local flag m_passRelevantValuesChanged = false; } }
/// <summary> /// This update method gets called on each update pass for each scenes /// this component is attached to. /// </summary> /// <param name="updateState">Current update state.</param> /// <param name="correspondingView">The view which attached this component (may be null).</param> protected override void Update(SceneRelatedUpdateState updateState, ViewInformation?correspondingView) { var actCamera = correspondingView?.Camera; if (actCamera == null) { return; } foreach (var actInputFrame in updateState.InputFrames) { var isControlKeyDown = false; foreach (var actInputState in actInputFrame.GetInputStates(correspondingView !)) { switch (actInputState) { // Handle keyboard case KeyboardState actKeyboardState: UpdateForKeyboard(actCamera, actKeyboardState, out isControlKeyDown); continue; // Handle mouse (or pointer) case MouseOrPointerState mouseState: UpdateForMouse(actCamera, isControlKeyDown, mouseState); continue; } } } }
/// <summary> /// This update method gets called on each update pass for each scenes /// this component is attached to. /// </summary> /// <param name="updateState">Current update state.</param> /// <param name="correspondingView">The view which attached this component (may be null).</param> protected override void Update(SceneRelatedUpdateState updateState, ViewInformation correspondingView) { Camera3DBase actCamera = correspondingView.Camera; if (actCamera == null) { return; } foreach (InputFrame actInputFrame in updateState.InputFrames) { foreach (var actInputState in actInputFrame.GetInputStates(correspondingView)) { // Handle keyboard KeyboardState actKeyboardState = actInputState as KeyboardState; bool isControlKeyDown = false; if (actKeyboardState != null) { UpdateForKeyboard(actCamera, actKeyboardState, out isControlKeyDown); continue; } // Handle mouse (or pointer) MouseOrPointerState mouseState = actInputState as MouseOrPointerState; if (mouseState != null) { UpdateForMouse(actCamera, isControlKeyDown, mouseState); } } } }
/// <summary> /// Updates the object. /// </summary> /// <param name="updateState">Current update state.</param> protected override void UpdateInternal(SceneRelatedUpdateState updateState) { // Handle line data reloading flag if (m_forceReloadLineData) { m_localResources.ForEachInEnumeration((actItem) => actItem.LineDataLoaded = false); m_forceReloadLineData = false; } }
/// <summary> /// Updates this object for the given view. /// </summary> /// <param name="updateState">Current state of the update pass.</param> /// <param name="layerViewSubset">The layer view subset wich called this update method.</param> /// <exception cref="System.NotImplementedException"></exception> protected override void UpdateForViewInternal(SceneRelatedUpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset) { if (base.CountRenderPassSubscriptions(layerViewSubset) == 0) { this.SubscribeToPass( RenderPassInfo.PASS_2D_OVERLAY, layerViewSubset, OnRenderOverlay2D); } }
protected override void UpdateInternal(SceneRelatedUpdateState updateState) { foreach (InputFrame actInputFrame in updateState.InputFrames) { GamepadState gamepadState = actInputFrame.DefaultGamepad; if (gamepadState == GamepadState.Dummy) { continue; } Vector3 moveVector = Vector3.Zero; // Handle left/right movement Vector3 moveX = new Vector3(0.1f, 0f, 0f); if (gamepadState.IsButtonDown(GamepadButton.DPadLeft)) { moveVector += -moveX; } else if (gamepadState.IsButtonDown(GamepadButton.DPadRight)) { moveVector += moveX; } else if (Math.Abs(gamepadState.LeftThumbX) > 0.5f) { moveVector += gamepadState.LeftThumbX * moveX; } else if (Math.Abs(gamepadState.RightThumbX) > 0.5f) { moveVector += gamepadState.RightThumbX * moveX; } // Handle up/down movement Vector3 moveZ = new Vector3(0f, 0f, 0.1f); if (gamepadState.IsButtonDown(GamepadButton.DPadDown)) { moveVector += -moveZ; } else if (gamepadState.IsButtonDown(GamepadButton.DPadUp)) { moveVector += moveZ; } else if (Math.Abs(gamepadState.LeftThumbY) > 0.5f) { moveVector += gamepadState.LeftThumbY * moveZ; } else if (Math.Abs(gamepadState.RightThumbY) > 0.5f) { moveVector += gamepadState.RightThumbY * moveZ; } this.Position = this.Position + moveVector; } base.UpdateInternal(updateState); }
/// <summary> /// Updates this object for the given view. /// </summary> /// <param name="updateState">Current state of the update pass.</param> /// <param name="layerViewSubset">The layer view subset wich called this update method.</param> protected override void UpdateForViewInternal(SceneRelatedUpdateState updateState, ViewRelatedSceneLayerSubset layerViewSubset) { //Subscribe to render passes if (base.CountRenderPassSubscriptions(layerViewSubset) == 0) { base.SubscribeToPass( RenderPassInfo.PASS_PLAIN_RENDER, layerViewSubset, OnRenderPlain); base.SubscribeToPass( RenderPassInfo.PASS_TRANSPARENT_RENDER, layerViewSubset, OnRenderTransparent); } }
protected override void Update(SceneRelatedUpdateState updateState, ViewInformation correspondingView) { base.Update(updateState, correspondingView); foreach (var actInputFrame in updateState.InputFrames) { if (actInputFrame.DefaultKeyboard.IsKeyDown(WinVirtualKey.Escape)) { s_renderTarget.UISynchronizationContext.PostAlsoIfNull(() => { Application.Exit(); }); } } }
/// <summary> /// Updates the object. /// </summary> /// <param name="updateState">Current update state.</param> protected override void UpdateInternal(SceneRelatedUpdateState updateState) { }
/// <summary> /// Triggers internal update within the resource (e. g. Render to Texture). /// </summary> /// <param name="updateState">Current state of update process.</param> public void Update(SceneRelatedUpdateState updateState) { }
protected override void Update(SceneRelatedUpdateState updateState, ViewInformation correspondingView, PerSceneContext componentContext) { Camera3DBase actCamera = correspondingView.Camera; if (actCamera == null) { return; } foreach (InputFrame actInputFrame in updateState.InputFrames) { foreach (var actInputState in actInputFrame.GetInputStates(correspondingView)) { // Handle keyboard KeyboardState actKeyboardState = actInputState as KeyboardState; if (actKeyboardState != null) { UpdateForKeyboard(componentContext, actCamera, actKeyboardState); continue; } // Handle mouse (or pointer) MouseOrPointerState mouseState = actInputState as MouseOrPointerState; if (mouseState != null) { UpdateForMouse(componentContext, actCamera, mouseState); } } } // Ensure that our values are in allowed ranges float maxRad = EngineMath.RAD_90DEG * 0.99f; float minRad = EngineMath.RAD_90DEG * -0.99f; componentContext.CameraHVRotation.X = componentContext.CameraHVRotation.X % EngineMath.RAD_360DEG; if (componentContext.CameraDistance < this.CameraDistanceMin) { componentContext.CameraDistance = this.CameraDistanceMin; } if (componentContext.CameraDistance > this.CameraDistanceMax) { componentContext.CameraDistance = this.CameraDistanceMax; } if (componentContext.CameraHVRotation.Y <= minRad) { componentContext.CameraHVRotation.Y = minRad; } if (componentContext.CameraHVRotation.Y >= maxRad) { componentContext.CameraHVRotation.Y = maxRad; } // Update camera position and rotation Vector3 cameraOffset = Vector3.UnitX; cameraOffset = Vector3.TransformNormal( cameraOffset, Matrix4x4.CreateRotationY(componentContext.CameraHVRotation.X)); cameraOffset = Vector3.TransformNormal( cameraOffset, Matrix4x4.CreateFromAxisAngle(Vector3.Cross(cameraOffset, Vector3.UnitY), componentContext.CameraHVRotation.Y)); Vector3 focusedLocation = this.GetFocusedLocation(); actCamera.Position = focusedLocation + cameraOffset * componentContext.CameraDistance; actCamera.Target = focusedLocation; }
internal abstract void UpdateInternal(SceneRelatedUpdateState updateState, ViewInformation?correspondingView, object?componentContext);