Skip to content
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

Add a cylinder mesh to bevy_render #2282

Closed
allsey87 opened this issue May 30, 2021 · 9 comments
Closed

Add a cylinder mesh to bevy_render #2282

allsey87 opened this issue May 30, 2021 · 9 comments
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@allsey87
Copy link
Contributor

What problem does this solve or what need does it fill?

Cylinders are a fundamental shape and we should have a means of generating cylinder meshes in Bevy. Currently the closest option to this is a capsule shape.

What solution would you like?

The addition of a Cylinder shape and implementation of From<Cylinder> for Mesh.

What alternative(s) have you considered?

  • Modify the capsule so that the ends could have zero radius?
  • Import a GLTF

Additional context

PR #305 implemented this feature but was closed before merge. I would like to bring this PR back to life and get it merged, however, meshes, normals, UVs etc are not my area of expertise and I am having some problems with the UVs/normals I think (see below). Perhaps I can open a new PR for this? Some more commits will be necessary to get the rendering working.

cylinder

@allsey87 allsey87 added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels May 30, 2021
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels May 30, 2021
@alice-i-cecile
Copy link
Member

Have you seen the geometric primitives RFC? :)
bevyengine/rfcs#12

It's ready for community comment, so your input on this topic would be valuable.

@Rust-Ninja-Sabi
Copy link

Is it now possible to make cylinder from the standard shapes?

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Jul 11, 2022

This should be constructable via the Capsule type.

However we should at the least add a helper method for this.

@alice-i-cecile alice-i-cecile added the D-Trivial Nice and easy! A great choice to get started with Bevy label Jul 11, 2022
@JayPavlina
Copy link
Contributor

JayPavlina commented Nov 30, 2022

I attempted this, but I don't think it's possible to create a cylinder from a capsule.

  • radius controls both the radius of the capsule section and the radius of the spheres on the ends. Setting radius to 0 makes it invisible.
  • rings does not have any noticeable effect
  • depth changes the distance between the spheres.
  • latitudes and longitudes just change the resolution.

Also I experimented with RegularPolygon, and it could be used to create the caps, but not sure how to create the column connecting them.

I think a cylinder needs to be a separate shape.

@alice-i-cecile
Copy link
Member

Sounds good, I'd be happy to have this implemented as a seperate shape.

@JayPavlina
Copy link
Contributor

I'll take a look at #305 and see if I can revive it, but I'll probably have the same problems that @allsey87 had with UVs/normals. But I'll see how it goes.

@rparrett
Copy link
Contributor

rparrett commented Nov 30, 2022

I'd be happy to donate the cylinder code here: https://github.com/rparrett/typey_birb/blob/main/src/cylinder.rs

I had intended to PR it at some point but I'd be happy if someone else did that work.

@JayPavlina
Copy link
Contributor

JayPavlina commented Nov 30, 2022

@rparrett Feel free to do the PR then. I don't know how to fix the lighting on the other one, but I put yours in the 3d_shapes example and it looks perfect.

Edit: Oh I just saw that you said you'd be happy for someone else to do it. I can do it then.

Screenshot 2022-11-30 at 5 14 36 PM

@rparrett
Copy link
Contributor

rparrett commented Nov 30, 2022

Yeah, feel free to PR that code if you want. Maybe add the author of #305 and me as co-authors if you want. IIRC, my code was very loosely based on that one (docs still seem pretty similar) but I abandoned most of it when the UVs weren't behaving and referenced... some old textbook somewhere.

I don't need another PR on my plate at this moment though.

@bors bors bot closed this as completed in 2e7925d Dec 11, 2022
alradish pushed a commit to alradish/bevy that referenced this issue Jan 22, 2023
# Objective

Adds a cylinder shape. Fixes bevyengine#2282.

## Solution

- I added a custom cylinder shape, taken from [here](https://github.com/rparrett/typey_birb/blob/main/src/cylinder.rs) with permission from @rparrett.
- I also added the cylinder shape to the `3d_shapes` example scene.

---

## Changelog

- Added cylinder shape

Co-Authored-By: Rob Parrett <robparrett@gmail.com>
Co-Authored-By: davidhof <7483215+davidhof@users.noreply.github.com>
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

Adds a cylinder shape. Fixes bevyengine#2282.

## Solution

- I added a custom cylinder shape, taken from [here](https://github.com/rparrett/typey_birb/blob/main/src/cylinder.rs) with permission from @rparrett.
- I also added the cylinder shape to the `3d_shapes` example scene.

---

## Changelog

- Added cylinder shape

Co-Authored-By: Rob Parrett <robparrett@gmail.com>
Co-Authored-By: davidhof <7483215+davidhof@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-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants