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

Author Topic: NetEXT - SFML.NET Extension Library based on Thor  (Read 38357 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
Re: NetEXT - .NET Extension Library based on Thor
« Reply #15 on: December 01, 2013, 11:56:49 pm »
Quote from: Nexus
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++. 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.

I have already been considering most of these points. The biggest point is the way the CLR handles objects, the automatic garbage collection will only collect objects when no references remain to them, this is essentially already the shared ownership model. The only reason to implement the resource module in C# would be to avoid duplicate loading of resources.

Quote from: krzat
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).

Good to know, my main goal at the moment is to only port Thor and keep a generic interface. But I will keep your library in mind in case I ever need anything  ;)
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: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: NetEXT - .NET Extension Library based on Thor
« Reply #16 on: December 08, 2013, 04:09:47 pm »
Something important I forgot to mention: thor::ConcaveShape is based on a Constrained Delaunay Triangulation implemented in Thor.Math. It took me quite some time to implement and test this algorithm. It will be a huge effort to port the algorithm to C#, I do not recommend it.

I suggest that -- if you even want to provide ConcaveShape in NetEXT (I have the feeling it's not used very often in Thor) -- you should look for simpler triangulation algorithms, see here. Maybe the .NET framework can also help you, I don't know about its geometric capabilities.
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
NetEXT: Resource && Networking Module Release
« Reply #17 on: January 14, 2014, 01:44:15 am »
Alright, I have now added a resource module to NetEXT. It is a much more simplified version of Thor's resource module that is more tailored to C#/CLI. The main point to this module is to avoid duplicate loading of resources.

Here is a sample of how to utilize this module.

// Create a ResourceCache<Texture> with predefined Texture constructors
// Note: If you create a resource cache without the factory function you must provide constructors
//     that match the parameters that are passed in the Aquire(Key, Parameters) function

var texturecache = CacheFactory.CreateTextureCache();


// Gets a couple handle to a texture with "My Texture" string as the key
// If the key doesn't exist then it will be loaded from ".\\image.jpg"

var texturehandle = texturecache.Aquire("My Texture", ".\\image.jpg"); // Will load the texture
//     since it hasn't been loaded/cached yet
var secondhandle = texturecache.Aquire("My Texture", ".\\image.jpg"); // Will NOT load the
//     texture since we already cached it


// Now create a sprite with the texture we just acquired
// Note: All resource handles must be kept alive as long as the resource is being used

Sprite sprite = new Sprite(texturehandle); // Implicit conversion from
//     ResourceHandle<Texture> to Texture


// Now do whatever you want, maybe draw the sprite to the screen


On a side note, I have also added a networking module that is based on SFNUL. Please note the networking module is a WIP and still has several issues, but I would be glad if anyone would like to try it out and report any issues they have.

Here is a sample of the networking module.

public class Coordinate : SyncedObject
{
        public SyncedInt X = null;
        public SyncedInt Y = null;
        public Coordinate()
        {
                // Initialization order *must* remain the same
                X = new SyncedInt(200, this, SynchronizationType.Dynamic);
                Y = new SyncedInt(300, this, SynchronizationType.Dynamic);
        }
}

// Server
SynchronizerServer synchronizer = new SynchronizerServer();
var coord = synchronizer.CreateObject<Coordinate>();

// Client
SynchronizerClient synchronizer = new SynchronizerClient();

// Assuming everything is already setup and created

// Server
coord.X.Value = 45; // Yea still working on implicit conversion so the *.Value will not be needed
coord.Y.Value = 6;

// On the client we do nothing and the values are automatically updated
« Last Edit: February 21, 2014, 05:44:22 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
NetEXT 1.8 Released
« Reply #18 on: February 21, 2014, 04:53:15 am »
NetEXT 1.8 Released


This is a big update including documentation for all modules. Oh and about the huge version number jump [there wasn't any before so technically I can start wherever 8)]. I am working on getting NetEXT version numbering synchronized with Thor, so considering Thor currently has 2.0 as the development version I am aiming to hit the same number when Thor 2.x is finally released.  :)

  • Particle system now includes support for multiple texture rects
  • Refactored the input module, support has now been added for custom actions and joystick axis actions
  • Refactored input module, it is no longer required to implement a proxy class for animations
  • And lots of other minor tweaks to improve consistency/generic support

The biggest thing left to do at the moment is to finish the shape module and get the official site up with tutorials and documentation.

Documentation is not yet available online, but for now just plug an updated version of NetEXT into the object browser to read the documentation.  Also any feedback from anyone is welcome on the documentation, even if you don't plan on using NetEXT I want to hear your opinions :D
« Last Edit: February 21, 2014, 03:09:23 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Nbxy

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #19 on: March 26, 2014, 07:04:22 pm »
Just a silly question. How do I use it? I have SFML.net installed and fully working but for this one I couldn't find any installation guides. Do I just throw it in there with the SFML-files - and what next? The readme-file was just about the licensing. How about making a step-by-step guide for the newbies :)

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #20 on: March 31, 2014, 02:19:13 pm »
Sorry for the late reply, I was out of the country. Yes I am working on getting some tutorials created. Right now there is a tutorial for building NetEXT only. After you build NetEXT the only thing left to do is add the NetEXT dll as a reference to your project (same as adding the SFML dlls as references).  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #21 on: April 01, 2014, 05:00:22 am »
hmm this should be useful.  Going to be working on a space shooter with a huge range to move about so can't have the player getting bored with my programmer art. :P Keep up the good work too. :)
I have many ideas but need the help of others to find way to make use of them.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #22 on: April 13, 2014, 09:34:12 pm »
Just curious did you compile for VS 2013 or 2012?  Since I'm using 2012. ???
I have many ideas but need the help of others to find way to make use of them.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #23 on: April 13, 2014, 10:01:21 pm »
Compiler version makes no difference when it comes to managed assemblies (unlike when dealing with C++ libraries). Instead you should pay attention to which version of the .NET framework that it builds with. NetEXT will work with .NET Framework 4 Client Profile or greater (4.5 and 4.5.1).  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #24 on: April 13, 2014, 10:08:48 pm »
OK just checking. :) 
I have many ideas but need the help of others to find way to make use of them.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #25 on: April 16, 2014, 04:16:16 am »
You're missing two vector math equations that could be useful.

One for changing a vector into an angle and another for changing an angle into a vector.

Chances are I missed something in these two equations so make any changes you have to. :)

public static double VectorToAngle(double x, double y)
{
      double angle = ToDegrees(Math.Atan2(y,x));
      double realangle = (angle % 360);
      return realangle;
}

public static double VectorToAngle(Vector2f vector)
{
      return VectorToAngle(vector.X,vector.Y);
}

public static double[] AngleToVector(double degreesangle)
{
      double[] newvector = new double[2];
      newvector[0] = Math.Cos(ToRadians(angle % 360));
      newvector[1] = Math.Sin(ToRadians(angle % 360));
      return newvector;
}

public static Vector2f AngleToVectorSFML(double degreesangle)
{
      double[] newvector = AngleToVector(degreesangle);
      return new Vector2f((float)newvector[0], (float)newvector[1]);
}
 

I did see the rotate method in there but what you seem to be missing is just straight conversion between vector and angle.  Unless I'm blind and missed it. ???
« Last Edit: April 16, 2014, 04:24:03 am by StormWingDelta »
I have many ideas but need the help of others to find way to make use of them.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #26 on: April 16, 2014, 05:33:26 am »
PolarVector struct and PolarAngle functions is what you are looking for.  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #27 on: April 16, 2014, 04:17:50 pm »
lol oops.  :-[  :)
I have many ideas but need the help of others to find way to make use of them.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #28 on: April 18, 2014, 09:21:26 pm »
zsbzsb your UnitVector code has an error.  What happens when len becomes 0 or rounds to it somehow?  :)  Divide by 0 exception and the dang thing doesn't gripe either too. ???  Had the same error in my normalization code too and didn't notice it until I started dismantling it.  :(


public static Vector2f normallizedVector2(Vector2f vec)
{
    float mag = (float)VectorMagnitude(vec);
    if (Math.Abs(mag) > Math.Abs(0) || (vec.X != 0 && vec.Y != 0))
    {
        return vec / mag; //needs check for divide by 0 error or it'll return new Vector2f(NaN,NaN)
    }
    else
    {
        return vec;
    }
}
 

Hope this helps. :D
I have many ideas but need the help of others to find way to make use of them.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: NetEXT - SFML.NET Extension Library based on Thor
« Reply #29 on: April 18, 2014, 11:02:22 pm »
Alright thanks for that, I added assertions so now invalid vectors in debug configuration will throw an error.  ;)

I also pushed a few other small changes.  :)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor