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

Author Topic: Thor C++ Library – An SFML extension  (Read 138520 times)

0 Members and 3 Guests are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #120 on: July 14, 2011, 09:28:17 pm »
Okay, I changed the animations to take a [0,1] progress instead of an absolute value. I believe, in the end things get simpler and more flexible (especially when it comes to playing parallel or serial animations). The drawback is that the absolute duration has to be specified at every animator, but since thor::Animator is a copyable class, it can be initialized once and copied for different sf::Sprite instances.

Stuff I am planning to implement next:
  • Allow thor::FrameAnimation to change the image, not only the subrect of a sprite
  • Create other thor::Animation derivates (probably the mentioned parallel and serial animations)
  • Maybe transform thor::Animator into a template to allow other IDs than std::string. However I actually hate to transform such simple classes into templates, already because the whole implementation is required in the header :D
It should already be possible to implement the discussed interpolation/tweener feature relatively easy on user side:
Code: [Select]
class MyAnimation : public thor::Animation
{
public:
MyAnimation(thor::Animation::Ptr wrappedAnimation, std::function<float(float)> intervalTransformer)
: mAnimation(wrappedAnimation)
, mTransformer(intervalTransformer)
{
}

virtual void Apply(sf::Sprite& target, float progress) const
{
mAnimation->Apply(target, mTransformer(progress));
}

private:
thor::Animation::Ptr            mAnimation;
std::function<float(float)>     mTransformer;
};

Perhaps I can even take something like this into the public API. It would allow many things, such as reversing an animation, distorting the process, playing an animation multiple times, etc.

In fact, a std::tr1::function<void(sf::Sprite&, float)> might have been an interesting alternative to the whole thor::Animation class hierarchy... But probably the current approach is easier, especially for people not used to high-order functions and binders. In the end, it might require slightly more code because people cannot use super-compact std::tr1::bind() calls ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
Thor C++ Library – An SFML extension
« Reply #121 on: July 18, 2011, 01:43:22 pm »
Will you change the methods Update to take a Uint in milliseconds soon?
Pluma - Plug-in Management Framework

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #122 on: July 18, 2011, 03:04:27 pm »
No, I don't plan to change them, unsigned int milliseconds complicate the handling of delta-times a lot. In fact, they make time handling more complicated in general. For the Time module classes, I nearly must provide sf::Uint32 because floats get unprecise after some time, and because the underlying sf::Clock uses Uint32, too (so there would always be rounding errors at conversions).

We have already discussed that here, I'm not really satisfied with this inconsistency. The only thing I can imagine is a thor::Time class, but there are several issues with it, too (see link). For the delta-time parameters, I think the easiest solution is to keep them as float seconds. So, thor::Time would be used by thor::StopWatch, thor::Timer and thor::TriggeringTimer.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

spiritofforcefield

  • Newbie
  • *
  • Posts: 5
    • View Profile
Thor C++ Library – An SFML extension
« Reply #123 on: July 18, 2011, 03:36:09 pm »
Wow, I should have visited this forum earlier!

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
Thor C++ Library – An SFML extension
« Reply #124 on: July 18, 2011, 07:24:35 pm »
Ok, seems a reasonable solution. Plus it's all about visual stuff, for applications that must be very precise there isn't a real problem if one keep logics and visualization separated :P
Pluma - Plug-in Management Framework

MorleyDev

  • Full Member
  • ***
  • Posts: 219
  • "It is not enough for code to work."
    • View Profile
    • http://www.morleydev.co.uk/
Thor C++ Library – An SFML extension
« Reply #125 on: August 09, 2011, 02:41:54 pm »
Out of curiosity, in the tutorials you list unique_ptr as unique ownership and then auto_ptr as moved ownership. But from what I can tell, unique_ptr is also moveable via the use of r-value references (unique_ptr&&) and was intended to replace auto_ptr which is deprecated due to it's usage of hacks to simulate r-value references?
UnitTest11 - A unit testing library in C++ written to take advantage of C++11.

All code is guilty until proven innocent, unworthy until tested, and pointless without singular and well-defined purpose.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #126 on: August 09, 2011, 07:58:15 pm »
You are perfectly right, but unique_ptr is not implicitly movable.  You need to invoke std::move() to transfer ownership from a named object – in contrast to auto_ptr. Maybe I should make that clearer, putting it on the same level as scoped_ptr without further notes might indeed be confusing.

By the way, good to know that some people actually read the tutorials :D
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

WitchD0ctor

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.teleforce-blogspot.com
Thor C++ Library – An SFML extension
« Reply #127 on: August 11, 2011, 11:56:03 am »
Im just curious but, with the new changes in SFML regarding the new texture class, is it possible yet to texture a shape? That together with your Concave shape class would allow neat dynamic terrain
John Carmack can Divide by zer0.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #128 on: August 11, 2011, 02:10:01 pm »
I don't think it is possible yet. But as far as I remember, Laurent once planned to implement something similar, I don't know if that is still up-to-date however. Maybe with the new rendering system...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Thor C++ Library – An SFML extension
« Reply #129 on: August 11, 2011, 03:09:40 pm »
Quote
Maybe with the new rendering system...

Indeed.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #130 on: August 13, 2011, 01:34:09 am »
Now that I have had some time again, I could implement a lot of things, especially in the Resources module:
  • I improved thor::ResourcePtr. The smart pointer has now true strong-reference semantics, i.e. resources in use cannot be released at all. Apart from that, it is possible to store own objects in ResourcePtrs (not only those returned by thor::ResourceManager), and to specify custom deleters (for objects not allocated with new).
  • Thor has been adapted to SFML's recent division from sf::Image into sf::Image and sf::Texture, in order to be compatible with the newest Git revision.
  • I added the class thor::Resources::TextureKey to load sf::Texture resources via the resource manager.
  • I added a function FromStream() to all resource keys. These can now load resources from the recently introduced sf::InputStream.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Thor C++ Library – An SFML extension
« Reply #131 on: September 20, 2011, 06:07:18 pm »
I seem to be getting some problems with CMake, Im sure there problems on my end but I dont know what it could be.

this is configuring NMake
Quote
The C compiler identification is MSVC
The CXX compiler identification is MSVC
Check for CL compiler version
Check for CL compiler version - 1600
Check if this is a free VC compiler
Check if this is a free VC compiler - yes
Check for working C compiler: C:/Program Files/Microsoft Visual Studio 10.0/VC/bin/cl.exe
CMake Error: Remove failed on file: C:/Documents and Settings/Richy/My Documents/thor/make/CMakeFiles/CMakeTmp/cmTryCompileExec.exe: System Error: Permission denied
CMake Error: Remove failed on file: C:/Documents and Settings/Richy/My Documents/thor/make/CMakeFiles/CMakeTmp/Debug/cmTryCompileExec.exe: System Error: Permission denied
Check for working C compiler: C:/Program Files/Microsoft Visual Studio 10.0/VC/bin/cl.exe -- broken
CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
  The C compiler "C:/Program Files/Microsoft Visual Studio
  10.0/VC/bin/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/Documents and Settings/Richy/My Documents/thor/make/CMakeFiles/CMakeTmp

 

  Run Build Command:nmake /NOLOGO "cmTryCompileExec\fast"

     "C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe" -f
  CMakeFiles\cmTryCompileExec.dir\build.make /nologo -L
  CMakeFiles\cmTryCompileExec.dir\build

     "C:\Program Files\CMake 2.8\bin\cmake.exe" -E cmake_progress_report
  "C:\Documents and Settings\Richy\My
  Documents\thor\make\CMakeFiles\CMakeTmp\CMakeFiles" 1

  Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj

     C:\PROGRA~1\MICROS~2.0\VC\bin\cl.exe
  @C:\DOCUME~1\Richy\LOCALS~1\Temp\nm17F.tmp

  testCCompiler.c

  Linking C executable cmTryCompileExec.exe

     "C:\Program Files\CMake 2.8\bin\cmake.exe" -E vs_link_exe
  C:\PROGRA~1\MICROS~2.0\VC\bin\cl.exe /nologo
  @CMakeFiles\cmTryCompileExec.dir\objects1.rsp
  @C:\DOCUME~1\Richy\LOCALS~1\Temp\nm180.tmp

  LINK : fatal error LNK1104: cannot open file 'cmTryCompileExec.exe'


  LINK Pass 1 failed.  with 2

  NMAKE : fatal error U1077: '"C:\Program Files\CMake 2.8\bin\cmake.exe"' :
  return code '0xffffffff'

  Stop.

  NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio
  10.0\VC\BIN\nmake.exe"' : return code '0x2'

  Stop.

 

 

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:42 (project)


Configuring incomplete, errors occurred!


And this is VS2010 solutions
Quote
Check for working C compiler using: Visual Studio 10
CMake Error: Remove failed on file: C:/Documents and Settings/Richy/My Documents/thor/make/CMakeFiles/CMakeTmp/cmTryCompileExec.exe: System Error: Permission denied
CMake Error: Remove failed on file: C:/Documents and Settings/Richy/My Documents/thor/make/CMakeFiles/CMakeTmp/Debug/cmTryCompileExec.exe: System Error: Permission denied
Check for working C compiler using: Visual Studio 10 -- broken
CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
  The C compiler "C:/Program Files/Microsoft Visual Studio
  10.0/VC/bin/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/Documents and Settings/Richy/My Documents/thor/make/CMakeFiles/CMakeTmp

 

  Run Build Command:C:\PROGRA~1\MICROS~2.0\Common7\IDE\devenv.com
  CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec

 

  Microsoft (R) Visual Studio Version 10.0.30319.1.

  Copyright (C) Microsoft Corp.  All rights reserved.

  1>------ Build started: Project: cmTryCompileExec, Configuration: Debug
  Win32 ------

  1> testCCompiler.c

  1>LINK : fatal error LNK1104: cannot open file 'C:\Documents and
  Settings\Richy\My
  Documents\thor\make\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec.exe'

  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
  ==========

 

 

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:42 (project)


Configuring incomplete, errors occurred!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #132 on: September 20, 2011, 08:36:59 pm »
"Permission denied" may indicate that you don't have enough rights to delete the file or that it is currently in use. Make sure this is not the case. Try to start the Visual Studio command prompt as administrator.

What did you enter to the VS command prompt? It should be something like this:
Code: [Select]
cmake -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=Release -D THOR_SHARED_LIBS=FALSE -D THOR_STATIC_STD_LIBS=FALSE -D SFMLDIR="C:/Program Files/C++ Libraries/SFML" -D CMAKE_INSTALL_PREFIX="../install" ../../trunk

nmake install

And does it work when you generate a Visual Studio Solution instead of a NMake Makefile?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
Thor C++ Library – An SFML extension
« Reply #133 on: September 20, 2011, 09:04:32 pm »
Hi, yea you are right.
Im on XP so i thought i was admin right away but turns out im not.
Running as admin fixed it

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Thor C++ Library – An SFML extension
« Reply #134 on: September 30, 2011, 08:05:03 pm »
Because it may be very useful for user-defined controls, I implemented string conversion functions for sf::Keyboard::Key and sf::Mouse::Button enumerators. Both directions (from and to string) are provided.

Example:
Code: [Select]
#include <Thor/Events/InputNames.hpp>

int main()
{
    std::string str = thor::ToString(sf::Key::A);
    // str == "A"
}


And I still think about an extension of the animation functionality (with the above-mentioned points, maybe classes for serial/parallel animations). But I only get few feedback concerning the Animation module, I don't even know if there are people that actually use it... So if you have some ideas, express them ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything