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 an example for sprites with a custom shape #2973

Closed
wants to merge 1 commit into from

Conversation

mockersf
Copy link
Member

It has come to my attention in #2957 that it may not be common knowledge that this is relatively easy to do.

This shows 4 lines of sprites with custom shapes:

  • one line of shapes based on the formula for a star with a plain color
  • one line of shapes based on the formula for a star with an image
  • one line of shapes based on the formula for a disc with a plain color
  • one line of shapes based on the formula for a disc with an image

Screenshot 2021-10-15 at 20 41 15

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Oct 15, 2021
@mockersf mockersf added A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples and removed S-Needs-Triage This issue needs to be labelled labels Oct 15, 2021
@DJMcNab
Copy link
Member

DJMcNab commented Oct 15, 2021

Could we have a method on Mesh which abstracts creating them based on 2d points? I assume doing UVs properly would be hairy?

This code is not exactly trivial to read.

@Davier
Copy link
Contributor

Davier commented Oct 15, 2021

I believe this is currently not supported on the new renderer. Should it be?

@Nilirad
Copy link
Contributor

Nilirad commented Oct 15, 2021

Could we have a method on Mesh which abstracts creating them based on 2d points?

I think for regular polygons it's ok, but for stars it's a bit odd, since they're used more rarely. Alternatively, we can make a parametrized primitive shape, just like it has been done for Capsule.

I believe this is currently not supported on the new renderer. Should it be?

Sorry if I didn't understand your question, but this example is not presenting any fancy new feature. It just shows how to customize the Mesh and Handle<ColorMaterial> components already present in SpriteBundle to make custom shapes. This should naturally be supported by the new renderer as a direct consequence of it reaching feature parity with the current one (unless the new renderer gets rid of Mesh from SpriteBundle, which I know it was considered in the past, but I don't know if it has been done for the new renderer).

Copy link
Contributor

@Nilirad Nilirad left a comment

Choose a reason for hiding this comment

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

Visually, it is quite appealing, but the code is kinda complicated.
The code for direct creation of a single shape would look much more appealing, even if (maybe) less eye catching. In that way, it would even be similar to the mesh example.

I would also prefer using a very simple shape (e.g. a triangle), to focus the attention on the topic of the example rather than the shape.

@mockersf
Copy link
Member Author

Visually, it is quite appealing, but the code is kinda complicated.

Yeah I wanted it to be fun to view and not go over shapes that will be added someday in bevyengine/rfcs#12... but all the loops makes it hard to read.

I believe this is currently not supported on the new renderer. Should it be?

Oh the mesh component has been removed from the new sprite bundle so it won't be as easy to do 😞

pub struct PipelinedSpriteBundle {
pub sprite: Sprite,
pub transform: Transform,
pub global_transform: GlobalTransform,
pub texture: Handle<Image>,
}

So I guess that example won't be useful anyway after the new renderer is merged

@Nilirad
Copy link
Contributor

Nilirad commented May 3, 2022

Sprites no longer have custom meshes, and now we have Mesh2D doing this job. I think this can be closed.

@IceSentry
Copy link
Contributor

This is covered by the mesh2d_manual example

@IceSentry IceSentry closed this Oct 1, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants