Skip to content

[Merged by Bors] - add a 3d lines example #5319

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

Closed
wants to merge 7 commits into from

Conversation

IceSentry
Copy link
Contributor

@IceSentry IceSentry commented Jul 14, 2022

Objective

  • Showcase how to use a Material and Mesh to spawn 3d lines

image

Solution

  • Add an example using a simple Material and Mesh definition to draw a 3d line
    • Shows how to use LineList and LineStrip in combination with a specialized Material

Notes

This isn't just a primitive shape because it needs a special Material, but I think it's a good showcase of the power of the Material and AsBindGroup abstractions. All of this is easy to figure out when you know these options are a thing, but I think they are hard to discover which is why I think this should be an example and not shipped with bevy.

@IceSentry IceSentry added C-Examples An addition or correction to our examples A-Rendering Drawing game state to the screen labels Jul 14, 2022
@alice-i-cecile
Copy link
Member

I really like this as a learning example! I still think we should consider shipping a first class tool for this, but we can cross that bridge when we get there 😄

IceSentry and others added 2 commits July 14, 2022 13:08
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
@IceSentry
Copy link
Contributor Author

IceSentry commented Jul 14, 2022

Yeah, I agree we should have an api for that at some point, but this uses a different Material it can't just use the normal primitive shape. Or it could, but it would require some warning to only use it with a Material made to draw lines.

@tim-blackbird
Copy link
Contributor

I agree that these lines can't be shapes.
How about adding static methods to Mesh instead, like Mesh::from_lines() and Mesh::from_line_strip()?

@IceSentry
Copy link
Contributor Author

I think I'd prefer creating a module mesh/line with both From impls from this example to make it more in line with the other ways to create Meshes. I'm still not sure I like it until we add more line drawing features like the LineMaterial because without the Material creating a line mesh is pretty much useless.

I guess I should write a line drawing RFC 👀

@nicopap
Copy link
Contributor

nicopap commented Jul 15, 2022

Regarding the API for a debug lines module, I'd be more than happy to provide input. I've a vision™, to say the least. Based on this code, I'd use a mix of my

To create something very ergonomic, accepting lines, line strips, shapes and does not require modifying any system param to draw (only local changes) that is easy to disable with a cargo flag.

Copy link
Contributor

@nicopap nicopap left a comment

Choose a reason for hiding this comment

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

LGTM. I remember migrating bevy_debug_lines to 0.6 and adding about 300 lines of code. This is so much better.

This is also a pretty decent introduction to the AsBindGroup derive macro. We definitively need this.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Very nice. Should be useful both as learning material and as a snippet to steal! No complaints about the example; you know how this works.

@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 Jul 15, 2022
@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Jul 15, 2022
# Objective

- Showcase how to use a `Material` and `Mesh` to spawn 3d lines

![image](https://user-images.githubusercontent.com/8348954/179034236-ebc07f90-3eb5-46cc-8fc1-be7e6bf983fb.png)

## Solution

- Add an example using a simple `Material` and `Mesh` definition to draw a 3d line
	- Shows how to use `LineList` and `LineStrip` in combination with a specialized `Material`

## Notes

This isn't just a primitive shape because it needs a special Material, but I think it's a good showcase of the power of the `Material` and `AsBindGroup` abstractions. All of this is easy to figure out when you know these options are a thing, but I think they are hard to discover which is why I think this should be an example and not shipped with bevy.

Co-authored-by: Charles <IceSentry@users.noreply.github.com>
@bors bors bot changed the title add a 3d lines example [Merged by Bors] - add a 3d lines example Jul 15, 2022
@bors bors bot closed this Jul 15, 2022
inodentry pushed a commit to IyesGames/bevy that referenced this pull request Aug 8, 2022
# Objective

- Showcase how to use a `Material` and `Mesh` to spawn 3d lines

![image](https://user-images.githubusercontent.com/8348954/179034236-ebc07f90-3eb5-46cc-8fc1-be7e6bf983fb.png)

## Solution

- Add an example using a simple `Material` and `Mesh` definition to draw a 3d line
	- Shows how to use `LineList` and `LineStrip` in combination with a specialized `Material`

## Notes

This isn't just a primitive shape because it needs a special Material, but I think it's a good showcase of the power of the `Material` and `AsBindGroup` abstractions. All of this is easy to figure out when you know these options are a thing, but I think they are hard to discover which is why I think this should be an example and not shipped with bevy.

Co-authored-by: Charles <IceSentry@users.noreply.github.com>
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
# Objective

- Showcase how to use a `Material` and `Mesh` to spawn 3d lines

![image](https://user-images.githubusercontent.com/8348954/179034236-ebc07f90-3eb5-46cc-8fc1-be7e6bf983fb.png)

## Solution

- Add an example using a simple `Material` and `Mesh` definition to draw a 3d line
	- Shows how to use `LineList` and `LineStrip` in combination with a specialized `Material`

## Notes

This isn't just a primitive shape because it needs a special Material, but I think it's a good showcase of the power of the `Material` and `AsBindGroup` abstractions. All of this is easy to figure out when you know these options are a thing, but I think they are hard to discover which is why I think this should be an example and not shipped with bevy.

Co-authored-by: Charles <IceSentry@users.noreply.github.com>
@IceSentry IceSentry deleted the lines-example branch January 21, 2023 06:59
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- Showcase how to use a `Material` and `Mesh` to spawn 3d lines

![image](https://user-images.githubusercontent.com/8348954/179034236-ebc07f90-3eb5-46cc-8fc1-be7e6bf983fb.png)

## Solution

- Add an example using a simple `Material` and `Mesh` definition to draw a 3d line
	- Shows how to use `LineList` and `LineStrip` in combination with a specialized `Material`

## Notes

This isn't just a primitive shape because it needs a special Material, but I think it's a good showcase of the power of the `Material` and `AsBindGroup` abstractions. All of this is easy to figure out when you know these options are a thing, but I think they are hard to discover which is why I think this should be an example and not shipped with bevy.

Co-authored-by: Charles <IceSentry@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen 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.

4 participants