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

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

0 Members and 1 Guest are viewing this topic.

Carlitox

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: Thor 2.0
« Reply #270 on: December 25, 2013, 04:40:52 pm »
Now I avoid the unnecesary copies.

std::mt19937 mt;
std::uniform_real_distribution<float> distr(1.f, 3.f);

auto randomizer_lambda = [&distr, &mt]
{
        return sf::seconds(distr(mt));
};

thor::UniversalEmitter emitter;
emitter.setParticleLifetime(randomizer_lambda);

 

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
[Thor] Arrow style, fewer shapes
« Reply #271 on: December 28, 2013, 05:11:48 pm »
The class thor::Arrow has been extended with a style attribute. It can not only be used as an arrow, but also as a line. I will probably add support for bidirectional arrows in the future. To clarify the graphical differences:
line       -----
arrow      ---->
bd. arrow  <--->

The function thor::Shapes::pie() has been removed because I considered the pie shape too specific. I wanted to remove thor::Shapes::line() as well, because lines can now be expressed as arrows, but I think it may be useful for those who only need a sf::ConvexShape and not a whole arrow object.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

iride

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Thor 2.0
« Reply #272 on: January 03, 2014, 03:35:02 am »
I want particles to have random color. How can I do that using UniversalEmitter::setParticleColor?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #273 on: January 03, 2014, 02:25:25 pm »
It's very simple, you can pass a function pointer to setParticleColor(). It is then converted to a thor::Distribution<sf::Color>.
// Your function that creates a random color
sf::Color randomColor();

thor::UniversalEmitter emitter;
emitter.setParticleColor(&randomColor);
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Raincode

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Thor 2.0
« Reply #274 on: January 05, 2014, 01:49:01 pm »
Hi,
I ran cmake and then tried building Thor with mingw32-make install, and got errors. I seriously don't know what they mean, maybe someone can decypher them for me and tell me what the problem is, please?#

D:\Thor\Thor-master\src\Particle.cpp: In function 'float thor::getElapsedRatio(const thor::Particle&)':
D:\Thor\Thor-master\src\Particle.cpp:62:38: error: no match for 'operator/' (operand types are 'sf::Time' and 'sf::Time')
  return getElapsedLifetime(particle) / getTotalLifetime(particle);
                                      ^
D:\Thor\Thor-master\src\Particle.cpp:62:38: note: candidates are:
In file included from D:/SFML-2.1/include/SFML/System/Vector2.hpp:250:0,
                 from D:/Thor/Thor-master/include/Thor/Particles/Particle.hpp:35,
                 from D:\Thor\Thor-master\src\Particle.cpp:26:
D:/SFML-2.1/include/SFML/System/Vector2.inl:131:19: note: template<class T> sf::Vector2<T> sf::operator/(const sf::Vector2<T>&, T)

 inline Vector2<T> operator /(const Vector2<T>& left, T right)
                   ^
D:/SFML-2.1/include/SFML/System/Vector2.inl:131:19: note:   template argument deduction/substitution failed:
D:\Thor\Thor-master\src\Particle.cpp:62:65: note:   'sf::Time' is not derived from 'const sf::Vector2<T>'
  return getElapsedLifetime(particle) / getTotalLifetime(particle);
                                                                 ^
In file included from D:/Thor/Thor-master/include/Thor/Particles/Particle.hpp:34:0,
                 from D:\Thor\Thor-master\src\Particle.cpp:26:
D:/SFML-2.1/include/SFML/System/Time.hpp:376:22: note: sf::Time sf::operator/(sf::Time, sf::Int64)
 SFML_SYSTEM_API Time operator /(Time left, Int64 right);
                      ^
D:/SFML-2.1/include/SFML/System/Time.hpp:376:22: note:   no known conversion for argument 2 from 'sf::Time' to 'sf::Int64 {aka lon
g long int}'
D:/SFML-2.1/include/SFML/System/Time.hpp:364:22: note: sf::Time sf::operator/(sf::Time, float)
 SFML_SYSTEM_API Time operator /(Time left, float right);
                      ^
D:/SFML-2.1/include/SFML/System/Time.hpp:364:22: note:   no known conversion for argument 2 from 'sf::Time' to 'float'
D:\Thor\Thor-master\src\Particle.cpp: In function 'float thor::getRemainingRatio(const thor::Particle&)':
D:\Thor\Thor-master\src\Particle.cpp:67:40: error: no match for 'operator/' (operand types are 'sf::Time' and 'sf::Time')
  return getRemainingLifetime(particle) / getTotalLifetime(particle);
                                        ^
D:\Thor\Thor-master\src\Particle.cpp:67:40: note: candidates are:
In file included from D:/SFML-2.1/include/SFML/System/Vector2.hpp:250:0,
                 from D:/Thor/Thor-master/include/Thor/Particles/Particle.hpp:35,
                 from D:\Thor\Thor-master\src\Particle.cpp:26:
D:/SFML-2.1/include/SFML/System/Vector2.inl:131:19: note: template<class T> sf::Vector2<T> sf::operator/(const sf::Vector2<T>&, T)

 inline Vector2<T> operator /(const Vector2<T>& left, T right)
                   ^
D:/SFML-2.1/include/SFML/System/Vector2.inl:131:19: note:   template argument deduction/substitution failed:
D:\Thor\Thor-master\src\Particle.cpp:67:67: note:   'sf::Time' is not derived from 'const sf::Vector2<T>'
  return getRemainingLifetime(particle) / getTotalLifetime(particle);
                                                                   ^
In file included from D:/Thor/Thor-master/include/Thor/Particles/Particle.hpp:34:0,
                 from D:\Thor\Thor-master\src\Particle.cpp:26:
D:/SFML-2.1/include/SFML/System/Time.hpp:376:22: note: sf::Time sf::operator/(sf::Time, sf::Int64)
 SFML_SYSTEM_API Time operator /(Time left, Int64 right);
                      ^
D:/SFML-2.1/include/SFML/System/Time.hpp:376:22: note:   no known conversion for argument 2 from 'sf::Time' to 'sf::Int64 {aka lon
g long int}'
D:/SFML-2.1/include/SFML/System/Time.hpp:364:22: note: sf::Time sf::operator/(sf::Time, float)
 SFML_SYSTEM_API Time operator /(Time left, float right);
                      ^
D:/SFML-2.1/include/SFML/System/Time.hpp:364:22: note:   no known conversion for argument 2 from 'sf::Time' to 'float'
src\CMakeFiles\thor.dir\build.make:465: recipe for target 'src/CMakeFiles/thor.dir/Particle.cpp.obj' failed
mingw32-make[2]: *** [src/CMakeFiles/thor.dir/Particle.cpp.obj] Error 1
CMakeFiles\Makefile2:77: recipe for target 'src/CMakeFiles/thor.dir/all' failed
mingw32-make[1]: *** [src/CMakeFiles/thor.dir/all] Error 2
Makefile:115: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
 

Kind Regards

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #275 on: January 05, 2014, 01:56:13 pm »
You must use the latest SFML revision from GitHub. operator/ for sf::Time was a relatively recent addition.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Raincode

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Thor 2.0
« Reply #276 on: January 05, 2014, 02:38:55 pm »
Ah ok, thanks. Know I at least understand what's going on

Know it gives me "Unsupported architecture" when trying to use cmake on sfml,  guess I'll still habe to try a bit or use a slightly older version of thor




zachprinz

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Thor 2.0
« Reply #277 on: January 07, 2014, 03:39:38 am »
Hey, I'm not sure how much this has to do with Thor but I'm having a wierd problem with the library.

I've build and installed the latest GitHub versions of both SFML and Thor for VS11 using Cmake, but get this error when trying to run your example "particle.cpp" after linking the created libs for the aforementioned libraries.



I know this usually happens when there's a mismatch between what was linked to and the dll, or a mismatch in the IDE the libraries libs were compiled for but both SFML and Thor were compiled for VS11.

Anyways, I figured I'd post and see if anyone would know whats happening.

Thanks.

EDIT: I just build static libs for sfml and thor and that works fine.
« Last Edit: January 07, 2014, 06:16:03 am by zachprinz »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
AW: Thor 2.0
« Reply #278 on: January 07, 2014, 07:29:26 am »
The error means that you have a library mismatch, i.e. you used different libraries to build your application, than the dlls you have providee.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Thor 2.0
« Reply #279 on: January 07, 2014, 05:36:02 pm »
In your resource system you should use a variable who accepts any kind of function type to load the resources. (It's what I was trying to say earlier)

And, you should use a simplified system for your callback system, and get rid of the context, to do something lie this :
//Store a function pointer to a member function and pass an objet to call the function later.
Function <void(MyAppli&, Vector2f)> (&function, &object);
//Create and store the signal and the slot.
System::connect<Function<void(MyAppli&, Vector2f)>>("IsMouseInsideRect",  func);
//Call the
 

The interest is that the second parameter of the connect method can be any kind of function objects who call a pointer to a function.

I had juste to write a class who store a pointer to a non member function  wich call a pointer to any king a function. (I had to do this because we can't store the adress of object members functions.)
This class can also store the value of the arguments if it's necessary.

To call the signal, you just have to write the kind of the function pointer in <> :
System::emit<Function<void(MyAppli&, Vector2f)>>("IsMouseInsideRect",  mousePos);
 

The class system use the type erasure to store a generic pointer to the slot, and to cast the generic pointer into the slot type at the execution when we need to call it.

The same mecanism can be applied for actions, you can create an action, passing them a slot, and, link the slot to one or more sf::event throw the action, I've event set a map who link to sf::even, one event to trigger the action, and another event to terminate the action, but, I need to still improve the code, the template syntax is a bit barabare, and I need to redefine the operator || and && like you do in your class action map :

moveAction = new Action<Slot<void, Function<void(MyAppli&, sf::Keyboard::Key, sf::Time)>>> (slot2, false);
        sf::Event endEvent1, endEvent2, endEvent3, endEvent4;
        sf::Event event1, event2, event3, event4;
        event1.type = sf::Event::KeyPressed;
        event1.key.code = sf::Keyboard::Key::Z;
        event2.type = sf::Event::KeyPressed;
        event2.key.code = sf::Keyboard::Key::Q;
        event3.type = sf::Event::KeyPressed;
        event3.key.code = sf::Keyboard::Key::S;
        event4.type = sf::Event::KeyPressed;
        event4.key.code = sf::Keyboard::Key::D;

        endEvent1.type = sf::Event::KeyReleased;
        endEvent1.key.code = sf::Keyboard::Key::Z;
        endEvent2.type = sf::Event::KeyReleased;
        endEvent2.key.code = sf::Keyboard::Key::Q;
        endEvent3.type = sf::Event::KeyReleased;
        endEvent3.key.code = sf::Keyboard::Key::S;
        endEvent4.type = sf::Event::KeyReleased;
        endEvent4.key.code = sf::Keyboard::Key::D;
        moveAction->linkEvents(event1, endEvent1);
        moveAction->linkEvents(event2, endEvent2);
        moveAction->linkEvents(event3, endEvent3);
        moveAction->linkEvents(event4, endEvent4);
 

To call the slot you just need to call the process method of the action class (and you can pass some params if it's necessary) :

 if (event.type == sf::Event::KeyPressed || event.type == sf::Event::KeyReleased) {
                moveAction->pushEvent(event);
                View view = getWindow().getView();
                moveAction->process(event.key.code,realTime.restart());
 


But except that 2 defaults that I've still to improve (the template writting and the redefinition of the operator && and ||) I find that this code is perfect.

A macro should do the trick.  :)

But I think you can easely simplify the action mecanism and the resource loading mecanism of the thor library by this way, because, if we can pass any kind of fonction pointer to the resource system, you don't have to redefine the key for loading the resource, and, you don't need to pass by class such contexts to access to the window. (It's often the cause of many crashes and environnement problems, then I prefer pass the render windw to a function)

To finish my discution, I think I'll even do a placeholder system, to replace some arguments before calling the slot. (and not always the whole argument list)
If I an find a way to pass references into a tuple, it would be nice too. (But I think that the lvalues and std::forwad should solve the problem)

PS : The new c++11 functionnalities seems to be powerfull!  :D


« Last Edit: January 07, 2014, 05:42:42 pm by Lolilolight »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #280 on: January 07, 2014, 08:17:59 pm »
Lolilolight, there is connect0() for exactly that.

But we discussed resource managers and callbacks almost to death in the French thread. Please don't start again, especially not in this thread. Furthermore, I already stated several times that I will reflect about a different (simpler) design for resource management in Thor, so please just be patient...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: Thor 2.0
« Reply #281 on: January 08, 2014, 10:23:52 am »
Ok.  :)

I think I'll rewritte the SFML event with a flag system for my class action. (Because I cannot store the Actions because they are on different types)
I can get rid of the ActionMap so. (I find that it's very unplaisant to recreate an action, for each SFML events)

But I didn't want to discuss again about that in this thread anymore.






kingcools

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Thor 2.0
« Reply #282 on: January 11, 2014, 01:56:18 am »
Hi, im trying to download and install the thor framework yet my winrar always tells me the archives are damaged.
This happens everytime i try to download the thor 1.1 sdk for example (tried other links as well)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #283 on: January 11, 2014, 08:52:08 am »
I reuploaded all the archives, should be fine now.

Anyway, I recommend using the latest Thor revision from GitHub rather than Thor 1.1, see also this post.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

kingcools

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Thor 2.0
« Reply #284 on: January 11, 2014, 05:52:33 pm »
Hi,

thank you for the reupload, even though i used the github version as a substitute in the meantime :P

One critique:
When building the (thor-)project it would be better or at least more convenient if cmake would create a makefile that in return would build all of the project in the same folder.
After the build process i still had the include/cpp files in the download folder, though it would be nice if those were in the chosen buildfolder (thats how it is with sfml for example).

edit:
Good job by the way, your lib looks very useful!
one question: are you the same nexus that is on the c++-forum? if so, thanks for your help there haha

 

anything