Closed harry-cpp closed 8 years ago
I've used https://bitbucket.org/C3/2d-xna-primitives/wiki/Home which was written by @jcpmcdonald who (at least used to be) an active member of the GDSE community. He might be down for allowing the inclusion of it.
I've pinged him about this issue in the GDSE chat room, hopefully he'll respond. His account was last active about 5 days ago, so hopefully he'll log in and see my message sometime soon.
Interesting. The library a friend and I wrote a long while back adds extension methods to the SpriteBatch that allows for easy drawing of primitive shapes. Here's the library: https://bitbucket.org/C3/2d-xna-primitives/wiki/Home And here's a simplified list of extensions it adds:
DrawArc DrawCircle DrawLine DrawRectangle FillRectangle PutPixel
It is published under the zlib licence, and I think drawing primitive shapes is a useful tool to have in an extension to MonoGame. Note that I have not personally tested my project with MonoGame, but it doesn't do anything out of the ordinary.
Thanks @jcpmcdonald. With your permission I think this would be a great addition to MonoGame.Extended. The API looks very clean. I really like the simple nature of sprite batch extension methods.
[Farseer Physics](https://farseerphysics.codeplex.com/SourceControl/latest#DebugViews/DebugView MonoGame/PrimitiveBatch.cs) also has some good ideas in their debug renderer related to this.
Along with the LibGDX API I think we should take a look at how each of these libraries work and consider what suits and what doesn't.
MonoGame.Extended.Primitives
might be a suitable namespace.
My blessing is given.
I could have really used a debug renderer last night when I was working on bounding rectangles for Sprites :)
I think we should get this into the 0.3 release.
@craftworkgames I was thinking on working on this tomorrow(it's midnight at my timezone), also I wanted to setup an API that looks like libGDX one, since I liked using it...
If it's ok with you I think I could get this ready for 0.2 release.
@cra0zy Yeah, go ahead and work on this. If you finish it by the 0.2 release we can include it, if not we can include it in the next release for sure.
@cra0zy By all means start working on it. I'd like to keep the releases short and regular (weeks not months) so it doesn't really matter if it makes it into 0.2 or 0.3. I'd rather a small amount of polished code over a large amount of buggy code so take your time.
I wanted to setup an API that looks like libGDX one
I like LibGDX too. I use it as a reference a lot, but be aware that the Java paradigm doesn't always fit C# so we shouldn't mimic it exactly.
I quite like @jcpmcdonald's implementation but I'll leave the API in your hands and see what you come up with. Post back here once you've had some time to consider what the API might look like.
Thanks.
So in the end I didn't have a lot of time to work on anything last few days....
Anyway today I started working on this, and for now I have implemented DrawLine and DrawRectangle: https://gist.github.com/cra0zy/4681d5b782e214fa266c
Post any bonus methods or any modifications you want me to add to them, in the meantime I'll add DrawPolygon and DrawCircle methods in the similar way.
@cra0zy How's it going?
I just ran into this old Microsoft PrimitiveBatch sample from 2007 in my travels. I don't know how useful it will be for the library, it uses the BasicEffect instead of a SpriteBatch internally. I just thought I'd link it here for another reference point.
This happened: http://blogs.unity3d.com/2015/08/26/unity-comes-to-linux-experimental-build-now-available/ , and I just had to stress test it... couldn't resist... can't resist... must stress test....
Anyway my current problems are:
and I just had to stress test it... couldn't resist... can't resist... must stress test....
Lol. Fair enough. You should write a blog post about the results of the stress test. I'm sure others would find it interesting.
- drawing circles fast and efficient
- filling non rectangle shapes... especially polygons.... those can be so confusing
The [Farseer Physics Debug Renderer](http://farseerphysics.codeplex.com/SourceControl/latest#DebugViews/DebugView MonoGame/DebugViewXNA.cs) has pretty good implementations of these things.
I don't plan on writing a blog post, but here is a list of bugs I found:
That's quite a few. I guess that's what they mean by "experimental build".
Under what licence is Farseer Physics?
Looks like Ms-PL
I think the safest thing to do is to ask the maintainers if it's okay to use some of the code from the debug renderer. I'd be very surprised if they had a problem with it.
@GenBox @JeffWeber Would it be okay if we used some of the implementation of the Farseer Debug Renderer in our library? We are mostly interested in the algorithms for drawing shapes in a non-physics specific scenario.
Feel free to use the DebugView and related code from Farseer Physics Engine.
Thanks @Genbox. Much appreciated :smile:
@cra0zy Are you still working on this? Shall we leave it until the 0.4 release?
Leave it for 0.4 release.
Found another reference for this: https://msdn.microsoft.com/en-us/library/bb196414.aspx#ID2EEF
I might get started on this one shortly.
It really bugs me that we don't have this yet. I started working on something this morning. It shouldn't take too long :smile:
What are you using for drawing lines?
What are you using for drawing lines?
Currently it's just a quick and dirty approach using a single pixel texture and a SpriteBatch
from this library.
However, I'm perfectly aware that it's probably not the most efficient way. I just wanted to get something going.
Did you take a look at the PrimitiveBatch
class in MonoGame samples? It can be easily extended to draw polygons including circles and rectangles. I can provide a code snippet here for doing just that if you want.
Did you take a look at the PrimitiveBatch class in MonoGame samples?
So I got the SpriteBatch
extensions way working pretty well. There's still some issues with DrawPolygon
at this stage. It doesn't seem like a particularly efficient way to draw shapes, but if you're just using them for debugging or prototyping it's really handy to have something like this.
I also really like the PrimitiveBatch
approach in the MonoGame samples. The [Farseer Physics DebugViewXNA
class](http://farseerphysics.codeplex.com/SourceControl/latest#DebugViews/DebugView MonoGame/DebugViewXNA.cs) has a pretty good implementation that uses a [PrimitiveBatch
](http://farseerphysics.codeplex.com/SourceControl/latest#DebugViews/DebugView MonoGame/PrimitiveBatch.cs) class too.
So the only question remaining is, should we include both the SpriteBatch
extensions and the PrimitiveBatch
approach in MonoGame.Extended? What are the pro's and con's?
One thing that always bugged me about XNA is that it doesn't have a way of drawing basic shapes very easily.
libgdx for example has ShapeRenderer for that: https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html