Skip to content

Example for axes gizmos #12299

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 5 commits into from
Mar 4, 2024
Merged

Conversation

mweatherley
Copy link
Contributor

@mweatherley mweatherley commented Mar 4, 2024

Objective

  • Follow-up to Add coordinate axes gizmo #12211
  • Introduces an example project that demonstrates the implementation and behavior of Gizmos::axes for an entity with a Transform component.

Solution

In order to demonstrate how Gizmo::axes can be used and behaves in practice, we introduce an example of a simple scene containing a pair of cuboids locked in a grotesque, inscrutable dance: the two are repeatedly given random Transforms which they interpolate to, showing how the axes move with objects as they translate, rotate, and scale.

Screenshot 2024-03-04 at 1 16 33 PM

On the implementation side, we demonstrate how to draw axes for entities, automatically sizing them according to their bounding boxes (so that the axes will be visible):

fn draw_axes(mut gizmos: Gizmos, query: Query<(&Transform, &Aabb), With<ShowAxes>>) {
    for (&transform, &aabb) in &query {
        let length = aabb.half_extents.length();
        gizmos.axes(transform, length);
    }
}

Changelog

  • Created examples/gizmos/axes.rs.
  • Added 'axes' example to Cargo.toml.

@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples A-Gizmos Visual editor and debug gizmos labels Mar 4, 2024
@alice-i-cecile
Copy link
Member

It might be nicer to show how to create automatically scaled axes in this example, rather than customizing the length, but I don't feel strongly.

@pablo-lua
Copy link
Contributor

How about adding another box with other set of axes? Then we could have both

@mweatherley
Copy link
Contributor Author

It might be nicer to show how to create automatically scaled axes in this example, rather than customizing the length, but I don't feel strongly.

Good idea! I'll size the axes based on the Aabb component like I mentioned in the first PR.

@mweatherley
Copy link
Contributor Author

How about adding another box with other set of axes? Then we could have both

I tried this out, but I felt that playing with the axis sizing detracted from the demonstration of the tool's main utility (drawing axes on objects for debugging) so I tried to do a good job of just demonstrating automatically sized axes instead.

Copy link
Contributor

@pablo-lua pablo-lua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good example, showing the user that they can go very far with this feature!

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Mar 4, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 4, 2024
Merged via the queue into bevyengine:main with commit 4673fb3 Mar 4, 2024
@mweatherley mweatherley deleted the axes-example branch March 4, 2024 21:03
github-merge-queue bot pushed a commit that referenced this pull request Mar 8, 2024
# Objective

- Improve example from #12299 
- Make it frame rate independent
- Make it not randomly random

## Solution

- Transitions between transforms will take 2 seconds instead of 100
frames
- Random is seeded
spectria-limina pushed a commit to spectria-limina/bevy that referenced this pull request Mar 9, 2024
# Objective

- Follow-up to bevyengine#12211 
- Introduces an example project that demonstrates the implementation and
behavior of `Gizmos::axes` for an entity with a `Transform` component.

## Solution

In order to demonstrate how `Gizmo::axes` can be used and behaves in
practice, we introduce an example of a simple scene containing a pair of
cuboids locked in a grotesque, inscrutable dance: the two are repeatedly
given random `Transform`s which they interpolate to, showing how the
axes move with objects as they translate, rotate, and scale.

<img width="1023" alt="Screenshot 2024-03-04 at 1 16 33 PM"
src="https://github.com/bevyengine/bevy/assets/2975848/c1ff4794-6722-491c-8522-f59801645139">



On the implementation side, we demonstrate how to draw axes for
entities, automatically sizing them according to their bounding boxes
(so that the axes will be visible):
````rust
fn draw_axes(mut gizmos: Gizmos, query: Query<(&Transform, &Aabb), With<ShowAxes>>) {
    for (&transform, &aabb) in &query {
        let length = aabb.half_extents.length();
        gizmos.axes(transform, length);
    }
}
````

---

## Changelog

- Created examples/gizmos/axes.rs.
- Added 'axes' example to Cargo.toml.
spectria-limina pushed a commit to spectria-limina/bevy that referenced this pull request Mar 9, 2024
# Objective

- Improve example from bevyengine#12299 
- Make it frame rate independent
- Make it not randomly random

## Solution

- Transitions between transforms will take 2 seconds instead of 100
frames
- Random is seeded
mtsr pushed a commit to mtsr/bevy that referenced this pull request Mar 15, 2024
# Objective

- Follow-up to bevyengine#12211 
- Introduces an example project that demonstrates the implementation and
behavior of `Gizmos::axes` for an entity with a `Transform` component.

## Solution

In order to demonstrate how `Gizmo::axes` can be used and behaves in
practice, we introduce an example of a simple scene containing a pair of
cuboids locked in a grotesque, inscrutable dance: the two are repeatedly
given random `Transform`s which they interpolate to, showing how the
axes move with objects as they translate, rotate, and scale.

<img width="1023" alt="Screenshot 2024-03-04 at 1 16 33 PM"
src="https://github.com/bevyengine/bevy/assets/2975848/c1ff4794-6722-491c-8522-f59801645139">



On the implementation side, we demonstrate how to draw axes for
entities, automatically sizing them according to their bounding boxes
(so that the axes will be visible):
````rust
fn draw_axes(mut gizmos: Gizmos, query: Query<(&Transform, &Aabb), With<ShowAxes>>) {
    for (&transform, &aabb) in &query {
        let length = aabb.half_extents.length();
        gizmos.axes(transform, length);
    }
}
````

---

## Changelog

- Created examples/gizmos/axes.rs.
- Added 'axes' example to Cargo.toml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Gizmos Visual editor and debug gizmos C-Examples An addition or correction to our examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants