-
Notifications
You must be signed in to change notification settings - Fork 5
Add basic window control for interactive simulation #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| Interactive Simulation | ||
| ====================== | ||
|
|
||
| The Interactive Simulation module provides tools and interfaces for interacting with the simulation environment, including window management, input handling, and real-time control of simulated assets. | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 2 | ||
|
|
||
| Window interaction <window.md> | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Window interaction | ||
|
|
||
| This section describes the default window interaction controls available in the simulation. These controls allow users to interact with the simulation environment using keyboard, mouse, and customizable input events. | ||
|
|
||
| ## Default Window Events | ||
|
|
||
| The simulation window comes with a set of default controls that enable users to perform various actions, such as selecting objects, manipulating the camera view, and triggering specific events. These controls are implemented using the `ObjectManipulator` class (provided by `dexsim`). | ||
|
|
||
| | Events | Description | | ||
| |---------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| | **Raycast Information Display** | Press the right mouse button to select a point and the 'C' key to print the raycast distance and hit position of a surface (world coordinates) to the console. Useful for debugging and checking the position of objects in the simulation. | | ||
|
|
||
| > **Note:** We will add more interaction features in future releases. Stay tuned for updates! | ||
|
|
||
| ## Customizing Window Events | ||
|
|
||
| Users can create their own custom window interaction controls by subclassing the `ObjectManipulator` class. This allows for the implementation of specific behaviors and responses to user inputs. | ||
|
|
||
| Here's an example of how to create a custom window event that responds to key presses: | ||
|
|
||
| ```python | ||
| from dexsim.engine import ObjectManipulator | ||
| from dexsim.types import InputKey | ||
|
|
||
| class CustomWindowEvent(ObjectManipulator): | ||
| def on_key_down(self, key): | ||
| if key == InputKey.SPACE.value: | ||
| print("Space key pressed!") | ||
|
|
||
|
|
||
| # Assuming you already have a SimulationManager instance called `sim_manager` | ||
| # (for example, created elsewhere in your code): | ||
| # sim_manager = SimulationManager(...) | ||
|
|
||
| # Register the custom window event handler with the simulation: | ||
| sim_manager.add_custom_window_control(CustomWindowEvent()) | ||
| ``` | ||
|
|
||
| The functions table below summarizes the key methods available in the `ObjectManipulator` class for customizing window events: | ||
| | Method | Description | | ||
| |----------------------|---------------------------------------------------------------------------------------------------| | ||
| | `on_key_down(key)` | Triggered when a key is pressed down. The `key` parameter indicates which key was pressed. | | ||
| | `on_key_up(key)` | Triggered when a key is released. The `key` parameter indicates which key was released. | | ||
| | `on_mouse_moved(x, y)`| Triggered when the mouse is moved. The `x` and `y` parameters indicate the new mouse position. | | ||
| | `on_mouse_down(button, x, y)` | Triggered when a mouse button is pressed. The `button` parameter indicates which button was pressed, and `x`, `y` indicate the mouse position. | | ||
| | `on_mouse_up(button, x, y)` | Triggered when a mouse button is released. The `button` parameter indicates which button was released, and `x`, `y` indicate the mouse position. | | ||
| | `on_mouse_wheel(delta)` | Triggered when the mouse wheel is scrolled. The `delta` parameter indicates the amount of scroll. | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.