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

Author Topic: NetEXT - SFML.NET Extension Library based on Thor  (Read 41162 times)

0 Members and 1 Guest are viewing this topic.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
NetEXT - SFML.NET Extension Library based on Thor
« on: August 30, 2013, 08:46:03 pm »
What is it?

NetEXT is a SFML.NET extension library that is designed to provide extension modules to SFML for CLI/CLR languages. It currently covers areas in graphics, particles and more (see the feature list below), but more is planned. The API is very close if not exactly the same as Thor so most examples can be ported directly from Thor to NetEXT.


Special Thanks

I want to thank Nexus for his Thor Library. NetEXT is a native C# port of Thor. And of course thanks to Laurent for SFML.


Licensing

NetEXT is licensed with the ZLIP/PNG, the license same as SFML and Thor. Go to town on it and write patches and other features and then make pull requests.


Current Features
  • Large Texture/Sprite/RenderTexture classes
  • Particle System complete with the ability to build custom Emitters/Affectors
  • Animation Module that supports custom Animation classes
  • Vector Math Module
  • Time module providing different wrappers around the Clock class such as a Stopwatch
  • Complete Input Module with customizable actions and callbacks
  • Resource Manager Module
  • Networking module [WIP] [BETA]


Planned Features
  • Shape Module
  • More math functions


Where do I get it?

You can get the full source code over on Bitbucket. There is also a precompiled version available here and here.


Documentation

Documentation has now been written for NetEXT, at the moment there is no online version of it [coming soon], but for now just drop NetEXT into your object browser to read the documentation.
« Last Edit: March 13, 2015, 07:39:55 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: NetEXT - .NET Extension Library
« Reply #1 on: August 31, 2013, 12:59:41 am »
Very interesting project. Thank you for bringing the functionality to C# :)

I can add a link to your BitBucket site on the Thor download page, in order to consider NetEXT an official port (even if it doesn't cover all/exactly the same features). If you keep the API similar, you can also link to the Thor documentation in your project, to avoid the massive duplication and maintenance.

In case you ever need help to understand the implementation or design decisions behind Thor, don't hesitate to contact me ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - .NET Extension Library
« Reply #2 on: August 31, 2013, 07:00:16 pm »
Update

I have now ported and pushed Thor's animation module to NetEXT. The animation example is also ported so try it out.  :)


Very interesting project. Thank you for bringing the functionality to C# :)

No problem :D I finally decided that since the SFML.NET community was growing it was time to do a port.


Quote
I can add a link to your BitBucket site on the Thor download page, in order to consider NetEXT an official port (even if it doesn't cover all/exactly the same features). If you keep the API similar, you can also link to the Thor documentation in your project, to avoid the massive duplication and maintenance.

That would be great if you would consider NetEXT an official port  :) Currently the API is very similar except for a little variable renaming, the API signatures just about match exactly though (except in a few places where C# can't do what C++ can). As for the documentation, I will add a link to your documentation since I do not feel like writing my own  ;)


Quote
In case you ever need help to understand the implementation or design decisions behind Thor, don't hesitate to contact me ;)

Of course, can't forget that particle system bug :D
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: NetEXT - .NET Extension Library based on Thor
« Reply #3 on: September 23, 2013, 11:34:35 am »
Hello zsbzsb,

first, thank you for the c# port!  :D

I may be wrong, but I have possible found a bug in the particlesystem AddAffector.
If I add more than one affector without parameter TimeTo Live (using only the constructor AddAffector(AffectorBase NewAffector) ), only the first affector is added because
_affector.Contains(affector) returns allways true.

     public void AddAffector(AffectorBase NewAffector, long TimeToLive)
        {
            TimeLink<ExpiringTime, AffectorBase> affector = new TimeLink<ExpiringTime, AffectorBase>(new ExpiringTime(TimeToLive), NewAffector);
            if (!_affectors.Contains(affector))
                _affectors.Add(affector);
        }


I have also two questions:
- the math distributions is not implemented, right? So, I can not write something like
emitter.setParticlePosition( thor::Distributions::circle(center, radius) );   // Emit particles in given circle
- any plans to add the AnimationAffector ? :-)
best regards,

Mad

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - .NET Extension Library based on Thor
« Reply #4 on: September 23, 2013, 01:41:56 pm »
I may be wrong, but I have possible found a bug in the particlesystem AddAffector.
If I add more than one affector without parameter TimeTo Live (using only the constructor AddAffector(AffectorBase NewAffector) ), only the first affector is added because
_affector.Contains(affector) returns allways true.

You are right, there was a bug. In the comparison check I was comparing the time value and the affector/emitter and returning true if either was the same.


Quote
I have also two questions:
- the math distributions is not implemented, right? So, I can not write something like
emitter.setParticlePosition( thor::Distributions::circle(center, radius) );   // Emit particles in given circle

Predefined distributions are not implemented yet, but it is planned. The distribution class however is implemented so it is possible for you to write your own circle functions. You can write that now  ;)

UniversalEmitter emitter;
emitter.ParticlePosition = Distributions.Circle(center, radius);


Quote
- any plans to add the AnimationAffector ? :-)

Yes

Edit

I decided to go ahead and implement the predefined distributions and the AnimationAffector. It is all on Bitbucket so go download the latest :D
« Last Edit: September 24, 2013, 04:46:05 am by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: NetEXT - .NET Extension Library based on Thor
« Reply #5 on: September 23, 2013, 09:01:56 pm »
Man, you are quick.  :D Thanks!
One question: didn't the constructors in class Distribution<ValueType> have to be public?
best regards,

Mad

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - .NET Extension Library based on Thor
« Reply #6 on: September 24, 2013, 04:11:37 am »
Man, you are quick.  :D Thanks!

The implementation of those two things was fairly easy and straightforward.  8)

Quote
One question: didn't the constructors in class Distribution<ValueType> have to be public?

They are not public because there are implicit operators to create the Distribution<ValueType> object. After all it feels weird and makes code more unreadable to write something like this

Distribution<string> stringvalue = new Distribution<string>("Hello There");

verses

Distribution<string> stringvalue = "Hello There";

I guess they could be public, but as I see it there is no need for them to be public. However, I will look into this and see how Thor handles it.
« Last Edit: September 24, 2013, 04:44:27 am by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: NetEXT - .NET Extension Library based on Thor
« Reply #7 on: September 24, 2013, 07:18:18 am »
However, I will look into this and see how Thor handles it.
The constructors are public, but in C++ you can implicitly convert from other objects if a constructor is not explicit and can be called with one argument.

The implementation is a bit more complicated: To allow indirect conversions, such as const char[5] to std::string as in
thor::Distribution<std::string> s = "text";
, the constructor parameter is a template parameter.

In addition, I use SFINAE (through AURORA_ENABLE_IF) to find out whether a functor or a constant is passed ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - .NET Extension Library based on Thor
« Reply #8 on: September 26, 2013, 02:15:11 am »
The constructors are public, but in C++ you can implicitly convert from other objects if a constructor is not explicit and can be called with one argument.

Well in that case I will change the constructors of NetEXT's Distribution to public.

Quote
In addition, I use SFINAE (through AURORA_ENABLE_IF) to find out whether a functor or a constant is passed ;)

Well in my case whether it be a blessing or a curse, C# does not have the ability to pass by constants  ::)

Also you should all download the latest version, measuring of time has been greatly improved and there have been several other bug fixes.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: NetEXT - .NET Extension Library based on Thor
« Reply #9 on: September 27, 2013, 03:39:32 pm »
Hello!

Can someone give me a small example how to use AnimatedText ?
I can not find examples, neither at Thor nor NetExt  :(

Thanks!
best regards,

Mad

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - .NET Extension Library based on Thor
« Reply #10 on: September 27, 2013, 04:33:57 pm »
Hello!

Can someone give me a small example how to use AnimatedText ?
I can not find examples, neither at Thor nor NetExt  :(

Thanks!

If you are talking about making text animations such as text flying in off the screen, showing letters one at a time, and so on your out of luck. You would need to design those animations yourself, the reason AnimatedText exists is to only allow Text objects to be applied to the animation module.

In Thor you don't need separate objects to apply animations to templates (C++ templates are compiled directly into the user code using the type provided). But in C# it is a bit different because I can't just call on functions/properties in C# with templates unless the generic type has been constrained to a base type. So in the end I wrote an abstract class that then takes care of calling the animated object's functions/properties. That is the reason there is an AnimatedBase, AnimatedText, AnimatedSprite, and so on.

This way you can apply animations to whatever object type you want by simply inheriting AnimatedBase and then calling the appropriate functions/properties on the type you want to animate.
« Last Edit: September 27, 2013, 04:40:52 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Mad

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: NetEXT - .NET Extension Library based on Thor
« Reply #11 on: September 27, 2013, 04:39:49 pm »
Hello!

Can someone give me a small example how to use AnimatedText ?
I can not find examples, neither at Thor nor NetExt  :(

Thanks!

If you are talking about making text animations such as text flying in off the screen, showing letters one at a time, and so on your out of luck. You would need to design those animations yourself, the reason AnimatedText exists is to only allow Text objects to be applied to the animation module.


Well, that was my intension.  8) ok, out of luck...and I went back to coding  ::)
best regards,

Mad

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - .NET Extension Library based on Thor
« Reply #12 on: December 01, 2013, 06:25:53 pm »
Alright, lots of stuff has been improved and finished since the initial release  ;D

Mainly what has been completed is...

  • Vector Module
  • Input Module
  • Time Module (includes Time and Clock classes that implement sf::Time and sf::Clock for easy handling of time)

Currently the Resources and Shapes modules are in progress  :)

For anyone that is using it I highly recommend you upgrade to the latest edition  ;)
« Last Edit: December 01, 2013, 11:37:54 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: NetEXT - .NET Extension Library based on Thor
« Reply #13 on: December 01, 2013, 07:25:13 pm »
You seem to be really fast, it looks like a large part of Thor has already been ported :)

Concerning resources, keep in mind that thor::ResourceCache is not meant to be a general-purpose resource management system, it is rather specific to the cases where 1. shared ownership is required and 2. duplicates shall be resolved automatically. Often, neither is necesssary, that's why I am going to implement a more lightweight alternative in the future. I don't know if it even makes sense to port thor::ResourceCache directly to C#, as the lifetime and object ownership model is completely different from C++ -- however, the latter was an important point when I designed the resource caches. You should ask yourself whether a C# implementation would relieve the user and allow resources to be handled in a generic way (e.g. thor::ResourceKey<R> can also be used independently), or if it would just make everything more abstract and complicated.

Concerning shapes, the classes thor::Arrow and thor::ConcaveShape can be considered more or less stable. Some functions in the thor::Shapes namespace however might be removed -- shapes like pies are nice to show shapes in action, but they're not particularly useful as a reusable component of the Thor library. I might put them directly into an example.

Just to keep that in mind, not that you have to perform useless refactoring later. In general, the progress list gives a rough idea on what may still change in Thor ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

krzat

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: NetEXT - .NET Extension Library based on Thor
« Reply #14 on: December 01, 2013, 08:40:10 pm »
Seems like you are developing something similiar to mine library: https://bitbucket.org/krzat/sfml.utils .
Feel free to pull some classes (unless the goal is only to port Thor).
SFML.Utils - useful extensions for SFML.Net

 

anything