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

Feature/634/sprite rendering and animation #638

Merged
merged 4 commits into from Apr 23, 2018

Conversation

Projects
None yet
3 participants
@azriel91
Contributor

azriel91 commented Apr 12, 2018

Attempt at sprite animation: #634. This is branched off #641.

example


This change is Reviewable

@azriel91 azriel91 changed the title from WIP: Feature/634/sprite rendering and animation to Feature/634/sprite rendering and animation Apr 13, 2018

@azriel91

This comment has been minimized.

Show comment
Hide comment
@azriel91

azriel91 Apr 13, 2018

Contributor

woo it works 🎉

Contributor

azriel91 commented Apr 13, 2018

woo it works 🎉

@Xaeroxe Xaeroxe self-requested a review Apr 13, 2018

@azriel91 azriel91 changed the title from Feature/634/sprite rendering and animation to [WIP] Feature/634/sprite rendering and animation Apr 14, 2018

@azriel91

This comment has been minimized.

Show comment
Hide comment
@azriel91

azriel91 Apr 14, 2018

Contributor

WIP: rebasing over Rhuagh's animation implementation.

Contributor

azriel91 commented Apr 14, 2018

WIP: rebasing over Rhuagh's animation implementation.

@azriel91 azriel91 changed the title from [WIP] Feature/634/sprite rendering and animation to Feature/634/sprite rendering and animation Apr 15, 2018

@azriel91

This comment has been minimized.

Show comment
Hide comment
@azriel91

azriel91 Apr 15, 2018

Contributor

Updated to work with the new animation types, had to edit the Flat passes, I'm not sure if I should've used the function or just added the AlbedoOffset buffer. Screenshot is on the first comment.

Appveyor build failure is due to something wrong with the window installer download

Contributor

azriel91 commented Apr 15, 2018

Updated to work with the new animation types, had to edit the Flat passes, I'm not sure if I should've used the function or just added the AlbedoOffset buffer. Screenshot is on the first comment.

Appveyor build failure is due to something wrong with the window installer download

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
@Xaeroxe

Xaeroxe Apr 17, 2018

Member

So we're to merge #641, followed by #644, followed by this?

Ping @Rhuagh to confirm, I haven't been following gitter as well as I should.

Member

Xaeroxe commented Apr 17, 2018

So we're to merge #641, followed by #644, followed by this?

Ping @Rhuagh to confirm, I haven't been following gitter as well as I should.

@azriel91

This comment has been minimized.

Show comment
Hide comment
@azriel91

azriel91 Apr 17, 2018

Contributor

Yeaps 😄

  • #641 adds the material animation (texture, and texture coordinates)
  • #644 adds delayed start over animations
  • This adds sprites, and takes advantage of the material animation to pick a texture and shift the texture coordinates.

I had this idea, though not sure if I'll do it soon -- I have a self-imposed deadline for something in 1.5 weeks:

  • Split the bat sprite sheet into two
  • Make the grey bat evolve into the brown bat by swapping the texture id in the animation
Contributor

azriel91 commented Apr 17, 2018

Yeaps 😄

  • #641 adds the material animation (texture, and texture coordinates)
  • #644 adds delayed start over animations
  • This adds sprites, and takes advantage of the material animation to pick a texture and shift the texture coordinates.

I had this idea, though not sure if I'll do it soon -- I have a self-imposed deadline for something in 1.5 weeks:

  • Split the bat sprite sheet into two
  • Make the grey bat evolve into the brown bat by swapping the texture id in the animation
@azriel91

This comment has been minimized.

Show comment
Hide comment
@azriel91

azriel91 Apr 22, 2018

Contributor

Ready for review

Contributor

azriel91 commented Apr 22, 2018

Ready for review

@jojolepro

This looks pretty good, nice job!
A much needed feature. 👍

@@ -59,6 +59,7 @@ thread_profiler = { version = "0.1", optional = true }
amethyst_gltf = { path = "amethyst_gltf", version = "0.1" }
genmesh = "0.5"
amethyst_animation = { path = "amethyst_animation", version = "0.1.0" }
+ron = "0.1"

This comment has been minimized.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

ron version is 0.2, any reason to use 0.1?

@jojolepro

jojolepro Apr 23, 2018

Collaborator

ron version is 0.2, any reason to use 0.1?

This comment has been minimized.

@azriel91

azriel91 Apr 23, 2018

Contributor

To keep it consistent with amethyst_assets and amethyst_config. Generally within a repo I try to keep the same dependency versions

@azriel91

azriel91 Apr 23, 2018

Contributor

To keep it consistent with amethyst_assets and amethyst_config. Generally within a repo I try to keep the same dependency versions

This comment has been minimized.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

okay, then we might want to update it in a future PR. For this one you can keep 0.1

@jojolepro

jojolepro Apr 23, 2018

Collaborator

okay, then we might want to update it in a future PR. For this one you can keep 0.1

amethyst_renderer/src/sprite.rs
+/// These should be in normalized coordinates:
+///
+/// * X axis: 0.0 is the left side and 1.0 is the right side.
+/// * Y axis: 0.0 is the top and 1.0 is the botoom.

This comment has been minimized.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

botoom x)

@jojolepro

jojolepro Apr 23, 2018

Collaborator

botoom x)

This comment has been minimized.

@azriel91

azriel91 Apr 23, 2018

Contributor

fixed! 😅

@azriel91

azriel91 Apr 23, 2018

Contributor

fixed! 😅

amethyst_renderer/src/sprite.rs
+/// * X axis: 0.0 is the left side and 1.0 is the right side.
+/// * Y axis: 0.0 is the top and 1.0 is the botoom.
+#[derive(Clone, Debug)]
+pub struct Sprite {

This comment has been minimized.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

An implement of the From trait for ((f32,f32),(f32,f32)) and [f32,4] could be useful I think.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

An implement of the From trait for ((f32,f32),(f32,f32)) and [f32,4] could be useful I think.

This comment has been minimized.

@azriel91

azriel91 Apr 23, 2018

Contributor

done

@azriel91

azriel91 Apr 23, 2018

Contributor

done

examples/sprites/main.rs
+use amethyst_animation::{get_animation_set, AnimationBundle, AnimationCommand, EndControl,
+ MaterialTextureSet};
+
+const BACKGROUND_COLOUR: [f32; 4] = [0.0, 0.0, 0.0, 0.0]; // black

This comment has been minimized.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

Actually that's transparent ;)

@jojolepro

jojolepro Apr 23, 2018

Collaborator

Actually that's transparent ;)

This comment has been minimized.

@azriel91

azriel91 Apr 23, 2018

Contributor

fixed!

@azriel91

azriel91 Apr 23, 2018

Contributor

fixed!

+ let entity = world
+ .create_entity()
+ // The default `Material`, whose textures will be swapped based on the animation.
+ .with(sprite_sheet_material.clone())

This comment has been minimized.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

Is this clone necessary?

@jojolepro

jojolepro Apr 23, 2018

Collaborator

Is this clone necessary?

This comment has been minimized.

@azriel91

azriel91 Apr 23, 2018

Contributor

Yeap, because the loop creates multiple entities, and each of them have their own material component

@azriel91

azriel91 Apr 23, 2018

Contributor

Yeap, because the loop creates multiple entities, and each of them have their own material component

This comment has been minimized.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

I didn't realized it was a loop

@jojolepro

jojolepro Apr 23, 2018

Collaborator

I didn't realized it was a loop

+///
+/// * `index`: Index of the sprite sheet's texture in the `MaterialTextureSet`.
+/// * `definition`: Definition of the sprite layout on the sprite sheet.
+pub fn load(index: usize, definition: &sprite::SpriteSheetDefinition) -> SpriteSheet {

This comment has been minimized.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

Shouldn't that be directly into the engine? It seems pretty inconvenient to code this each time you make a new project.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

Shouldn't that be directly into the engine? It seems pretty inconvenient to code this each time you make a new project.

This comment has been minimized.

@azriel91

azriel91 Apr 23, 2018

Contributor

the SpriteSheetDefinition is user defined, based on #634 (comment), so it has to be outside

@azriel91

azriel91 Apr 23, 2018

Contributor

the SpriteSheetDefinition is user defined, based on #634 (comment), so it has to be outside

This comment has been minimized.

@jojolepro

jojolepro Apr 23, 2018

Collaborator

okay, I'll make myself a predefined one then ;)

@jojolepro

jojolepro Apr 23, 2018

Collaborator

okay, I'll make myself a predefined one then ;)

@Xaeroxe

I have nothing more to add, @jojolepro already said everything I saw.

azriel91 added some commits Apr 11, 2018

Re-export types from `gfx_core` and `gfx`.
This allows consumers to not have to link to those crates when using
transparent sprites.
Implement `From<Sprite> for MaterialPrimitive`.
This makes it easier for users to construct Material animations.
@jojolepro

Thanks you!

@Xaeroxe

This comment has been minimized.

Show comment
Hide comment
Member

Xaeroxe commented Apr 23, 2018

bors bot added a commit that referenced this pull request Apr 23, 2018

Merge #638
638: Feature/634/sprite rendering and animation r=jojolepro,Xaeroxe a=azriel91

Attempt at sprite animation: #634. This is branched off #641.

![example](https://user-images.githubusercontent.com/2993230/39100375-798d6d82-46dd-11e8-8869-550fcb0fe887.gif)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/amethyst/amethyst/638)
<!-- Reviewable:end -->


Co-authored-by: Azriel Hoh <azriel91@gmail.com>
@bors

This comment has been minimized.

Show comment
Hide comment

@bors bors bot merged commit d8bf0e0 into amethyst:develop Apr 23, 2018

3 checks passed

bors Build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@azriel91 azriel91 deleted the azriel91:feature/634/sprite-rendering-and-animation branch Apr 24, 2018

@jojolepro

This comment has been minimized.

Show comment
Hide comment
@jojolepro

jojolepro Apr 24, 2018

Collaborator

Congratz!

Collaborator

jojolepro commented Apr 24, 2018

Congratz!

@azriel91 azriel91 referenced this pull request Apr 25, 2018

Closed

[RFC] Support for 2D Sprite Rendering and Animation #634

4 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment