Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Thor 2.0 released!  (Read 368587 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 released!
« Reply #450 on: October 26, 2015, 12:36:24 am »
I added Thor 2.0 binaries for Visual Studio 2015.
-> Download page
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

bjadams

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: Thor 2.0 released!
« Reply #451 on: October 27, 2015, 11:35:41 pm »
just in time for me to start using sfml + thor!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
[Thor] New Animator API
« Reply #452 on: December 29, 2015, 10:54:26 am »
It has been a while since the last update. As I mentioned already a few times, I wasn't exactly happy with some limitations of the Animations module, for example the need to copy animations for every animator or to manually track progress, e.g. to know when an animation has finished. In the meantime, I have addressed many of those issues. That's why I'm now announcing a major improvement of the thor::Animator API.


Animation maps

The Thor 2.0 Animator stores all the animations and tracks a progress. Since different animated objects (e.g. sprites) have different animation progress, one needs to duplicate the Animator instance, and with it all the stored animations. Thor 2.1 changes this by splitting the functionality in two classes: Animator that tracks progress and animates an object, and AnimationMap which stores the animations. The former references the latter. Animation maps are resource-style classes, this separation is comparable to sf::Sprite and sf::Texture.
thor::AnimationMap<sf::Sprite, std::string> animations;
animations.addAnimation("anim1", ...);

thor::Animator<sf::Sprite, std::string> animator(animations);


Queued animations

It is now finally possible to queue multiple animations. Thus, one need no longer keep track of an animation, and code like if (finished) startNewAnimation() is history. The API is very simple and expressive, thanks to operator overloading. The play() function plays some animations and resets the queue, the queue() function appends to the end.
thor::Animator<sf::Sprite, std::string> animator;

// Play anim1, then anim2
animator.play() << "anim1" << "anim2";

// Append further animations to the queue
animator.queue() << "anim3";


Playback schemes and notifications

Another new feature are playback schemes. They give more control over the playback of animations. So far, I have implemented repeat() to repeat an animation a finite number of times and loop() to repeat it indefinitely. They're very easy-to-use with the queue syntax (which was not straightforward to implement, there's some heavy metaprogramming behind the scenes):
// Play one animation, then 3 times another, then loop a third one
animator.play()
   << "anim1"
   << thor::Playback::repeat("anim2", 3)
   << thor::Playback::loop("anim3");

Furthermore, you can be notified when an animation starts or finishes. You can register a callback that does virtually anything. The SDK example uses it to output the playing animation. On the other hand, explicit polling functions like isPlayingAnimation() and getPlayingAnimation() have been removed.
animator.play()
   << "anim1"
   << thor::Playback::notify([] () { std::cout << "Finished!\n"; });


Keep in mind that this entire API is generic. You don't have to use it to animate SFML objects, you can do anything it permits. It needn't even be an animation, you can also use it for other logic that is updated based on a progress.

You can get an overview over the new functionality on my homepage. You can directly use it by checking out the latest revision on GitHub. Have fun! :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re: Thor 2.0 released!
« Reply #453 on: December 29, 2015, 10:31:41 pm »
Nice update!

I was thinking about the issue of copying animation data not long ago and it's nice to see that you thought about the same stuff as well. :D

Playback shemes / queueing has very nice design that I may try to implement for my engine somewhere in the future. Looks very clean and makes it so much easier than constantly checking which animation is playing at the moment. This design might be useful for doing cutscenes and music playlists too! :)

Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

AlexxanderX

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • AlexanderX
Re: Thor 2.0 released!
« Reply #454 on: December 30, 2015, 10:14:33 am »
It would be nice if you could separate in modules the library, like SFML. For my game I want just to use the ResourceManager. Anyway, nice ResourceManager implementation.  :D
Here you can find my blog and tutorials about SFML - http://alexanderx.net/ (died...) - http://web.archive.org/web/20160110002847/http://alexanderx.net/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 released!
« Reply #455 on: December 30, 2015, 10:20:21 am »
Playback shemes / queueing has very nice design that I may try to implement for my engine somewhere in the future.
You can also just use it instead of re-implementing the same design ;)

In fact, that would help me much more, because then I see how Thor is used in the real world. If people want to achieve something, they try to exploit the available API to its limits, and don't just write their own workarounds. If something isn't possible, such feedback is very valuable for me -- I can use it to improve the API, and other users can benefit as well. If everybody just copies the code or writes his own variation, Thor won't progress.


This design might be useful for doing cutscenes and music playlists too! :)
Yes. Reusable design was a core criterion when writing this, it's very likely that I'm going to use some parts when I write the music players in Thor.


It would be nice if you could separate in modules the library, like SFML. For my game I want just to use the ResourceManager.
I thought about this, but the modules are too small and there are already 9 (and this number will grow in the future). It would add a lot of complexity to link everyone of them separately and get the dependencies right, for little benefit. There should not be a big issue with using only the resource managers -- it's not as if you carry Thor's entire weight in your application. Linkers are smart enough to exclude the parts that are not used.

Concerning thor::ResourceHolder in particular, a lot of it should be header-only, if I remember correctly. So you may not even have to link Thor.


Anyway, nice ResourceManager implementation.  :D
Thanks :)
« Last Edit: December 30, 2015, 10:21:54 am by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

AlexxanderX

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • AlexanderX
Re: Thor 2.0 released!
« Reply #456 on: December 30, 2015, 02:03:55 pm »
I get this warning when using the Aurora that come with Thor:
Quote
In file included from E:/Work/Programare/Libs/Thor/include/Thor/Resources/OwnershipModels.hpp:34:0,
                 from E:/Work/Programare/Libs/Thor/include/Thor/Resources.hpp:32,
                 from E:/Work/Programare/Apps/CPP/Katan/Client/include/States/StateMachine.hpp:9,
                 from E:\Work\Programare\Apps\CPP\Katan\Client\src\States\StateMachine.cpp:1:
E:/Work/Programare/Libs/Thor/include/Thor/Resources/OwnershipModels.hpp: In member function 'void thor::detail::TrackingDeleter<R, Map>::operator()(R*)':
E:/Work/Programare/Libs/Thor/extlibs/aurora/include/Aurora/Meta/Templates.hpp:188:57: warning: typedef 'auroraRequireCompleteType' locally defined but not used [-Wunused-local-typedefs]
 #define AURORA_REQUIRE_COMPLETE_TYPE(Type) typedef char auroraRequireCompleteType[(sizeof(Type))]
                                                         ^
E:/Work/Programare/Libs/Thor/include/Thor/Resources/OwnershipModels.hpp:105:4: note: in expansion of macro 'AURORA_REQUIRE_COMPLETE_TYPE'
    AURORA_REQUIRE_COMPLETE_TYPE(R);
Here you can find my blog and tutorials about SFML - http://alexanderx.net/ (died...) - http://web.archive.org/web/20160110002847/http://alexanderx.net/

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Thor 2.0 released!
« Reply #457 on: December 30, 2015, 02:16:47 pm »
Great news Nexus. I look forward to playing with the new Thor - expecting it to be excellent as always ;)

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re: Thor 2.0 released!
« Reply #458 on: December 30, 2015, 03:18:22 pm »
Playback shemes / queueing has very nice design that I may try to implement for my engine somewhere in the future.
You can also just use it instead of re-implementing the same design ;)

In fact, that would help me much more, because then I see how Thor is used in the real world. If people want to achieve something, they try to exploit the available API to its limits, and don't just write their own workarounds. If something isn't possible, such feedback is very valuable for me -- I can use it to improve the API, and other users can benefit as well. If everybody just copies the code or writes his own variation, Thor won't progress.
Yeah, seeing such cool changes is making me think about using your library. You see, I'm just learning a lot more when I implement my own stuff but now I think that I can use some help with your lib. :D
I'm thinking about doing a smaller project some time soon and I'll use Thor for it for different stuff and if I'm comfortable enough with it, I'll use it in Re:creation.
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
[Thor] New Animator API
« Reply #459 on: December 30, 2015, 04:55:33 pm »
@AlexxanderX: I fixed the warning in Aurora (but it's not merged to Thor yet). If you need to get rid of it now, copy the Aurora include files to Thor's extlib directory, overwriting the existing ones.

@Jesper Juhl: Thanks for the confidence :)

@Elias Dialer: Alright, let me know in case you have questions!
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Thor 2.0 released!
« Reply #460 on: January 03, 2016, 02:31:47 pm »
I've noticed when browsing that two dates on http://www.bromeon.ch/index.html say 2016 instead of 2015 (or Thor is literally the software of the future).
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11007
    • View Profile
    • development blog
    • Email
Thor 2.0 released!
« Reply #461 on: January 03, 2016, 04:27:18 pm »
Guess the search + replace backfired. :P
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 released!
« Reply #462 on: January 03, 2016, 04:57:08 pm »
Indeed, thanks! That went really fast :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Kojay

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Thor 2.0 released!
« Reply #463 on: January 19, 2016, 01:15:03 am »
Hello,

I am looking to implement ctrl+tab and shift+tab shortcuts in an application, with the help of Thor.Input. However, only the former works. This is a minimal example that reproduces the behavior:

#include <Thor/Input.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <iostream>

enum class Action{
    Close,
    ShiftTab,
    CtrlTab
};

int main()
{
    sf::RenderWindow window(sf::VideoMode(800,600),"SFML with Thor");
    window.setFramerateLimit(60);

    thor::ActionMap<Action> actionMap;
    thor::ActionMap<Action>::CallbackSystem system;

    actionMap[Action::Close] = thor::Action(sf::Event::Closed);
    system.connect(Action::Close, std::bind(&sf::RenderWindow::close, &window));

    thor::Action lctrl(sf::Keyboard::LControl, thor::Action::Hold),
                 rctrl(sf::Keyboard::RControl, thor::Action::Hold),
                 lshift(sf::Keyboard::LShift, thor::Action::Hold),
                 rshift(sf::Keyboard::RShift, thor::Action::Hold),
                 tab(sf::Keyboard::Tab, thor::Action::PressOnce);

    auto ctrl = lctrl || rctrl;
    auto shift = lshift || rshift;

    actionMap[Action::CtrlTab] = ctrl && tab;
    system.connect0(Action::CtrlTab, [](){
        std::cout << "CtrlTab" << std::endl;
    });

    actionMap[Action::ShiftTab] = shift && tab;
    system.connect0(Action::ShiftTab, [](){
        std::cout << "ShiftTab" << std::endl;
    });

    while (window.isOpen()){
        actionMap.update(window);
        actionMap.invokeCallbacks(system, &window);

        window.clear();
        window.display();
    }
}
 

CtrlTab appears on stdout everytime Ctrl+Tab is pressed; Shift+Tab does not. Instead, shift key by itself works.
Any clues would be appreciated.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 released!
« Reply #464 on: January 19, 2016, 10:55:11 pm »
Hm... I can't imagine how this could be related to Thor, as I don't treat the keys differently. Can you reproduce the same behavior with SFML alone (with sf::Keyboard for Shift and sf::Event for Tab)?

Might Shift+Tab be a special combination of your OS or a running application, similar to Alt+Tab?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything