Vector graphics
by Anton Chernov · in Torque 2D Beginner · 03/07/2013 (2:39 pm) · 6 replies
Hi!
I recently came around the T2D engine and taking a look at the code inside gave me a wow effect! You guys are awesome! I'll develop my game with it, although I need vetor graphics for assets.
So basically I started to look into the engine to understand how I could extend it to support vector graphics. I found that drawing primitives is already supported and ShapeVector could hold the needed data.
So I want to create a class PathAsset : AssetBase that could parse for the beginning a simple path from a source. Than an path asset would look like
path.asset.taml:
<PathAsset
Data="0 1 2 3 4 5"
Fill="Red" />
Could you give me a hint if this is the right direction I'm going?
I'm also confused than everyone knows about some editor for assets and maybe levels but did not get it where to get it. :)
I recently came around the T2D engine and taking a look at the code inside gave me a wow effect! You guys are awesome! I'll develop my game with it, although I need vetor graphics for assets.
So basically I started to look into the engine to understand how I could extend it to support vector graphics. I found that drawing primitives is already supported and ShapeVector could hold the needed data.
So I want to create a class PathAsset : AssetBase that could parse for the beginning a simple path from a source. Than an path asset would look like
path.asset.taml:
<PathAsset
Data="0 1 2 3 4 5"
Fill="Red" />
Could you give me a hint if this is the right direction I'm going?
I'm also confused than everyone knows about some editor for assets and maybe levels but did not get it where to get it. :)
#2
In any case, it is definitely great that you are willing to help contribute!
03/08/2013 (3:38 am)
Good question. Right now there are discussions and investigations within the steering committee regarding the framework for future editors but there hasn't been an open discussion within the community on this yet.In any case, it is definitely great that you are willing to help contribute!
#3
@Anton - I don't think I would go about creating an asset that replicates an object, unless you do not want to use the ShapeVector at all. I think the best route is to use the ShapeVector, but to create utility functions to create them to spec.
03/08/2013 (7:15 am)
We will be talking about the editors publicly on Monday. Hope everyone will contribute to that discussion, since it is the hot topic right now.@Anton - I don't think I would go about creating an asset that replicates an object, unless you do not want to use the ShapeVector at all. I think the best route is to use the ShapeVector, but to create utility functions to create them to spec.
#4
If you're up for it, I'd go for creating a new type entirely, maybe based upon paths like you seem to be indicating then go ahead and have it consume an asset. The main thing to consider would be if you want all your vector stuff shared or if you want it to be persisted inline when the scene object itself is saved.
Several approaches come to mind, one is to have a base type that persists its geometry (path) using custom TAML. Then you could derive from that and have one that can consume a geometry asset and it essentially constructs the geometry from the asset using the API on the base type. It can then flag to the base type to NOT persist the geometry and so you'd then just have an asset reference.
That might give you a base type of (say) "GeometryObject" and a derived type of "VectorObject" with an associated "VectorAsset".
That might not all make sense but it'd work for sure.
One thing I wanted to find time for was to use something like Anti-Grain to render to a bitmap and render that. You can even get basic SWF support.
03/08/2013 (7:24 am)
It does depend on what you're doing for sure. The ShapeVector wasn't my creation but I believe it was only designed for basic stuff, it should probably have been called "BasicVector" or something. ;)If you're up for it, I'd go for creating a new type entirely, maybe based upon paths like you seem to be indicating then go ahead and have it consume an asset. The main thing to consider would be if you want all your vector stuff shared or if you want it to be persisted inline when the scene object itself is saved.
Several approaches come to mind, one is to have a base type that persists its geometry (path) using custom TAML. Then you could derive from that and have one that can consume a geometry asset and it essentially constructs the geometry from the asset using the API on the base type. It can then flag to the base type to NOT persist the geometry and so you'd then just have an asset reference.
That might give you a base type of (say) "GeometryObject" and a derived type of "VectorObject" with an associated "VectorAsset".
That might not all make sense but it'd work for sure.
One thing I wanted to find time for was to use something like Anti-Grain to render to a bitmap and render that. You can even get basic SWF support.
#5
The actual idea is the following: I have the whole scene drawn in flash. Flash exports to fxg, which is a vector format similar to svg, thus xml. With xslt filters I convert to taml for which the engine has already read/import support. So I need a way to read paths from taml, maybe than extend shapevector? hm... i'll try that.
@ Melv: Yes, that sounds exactly how I was thinking of it. I'll make sure the shapevector isn't enough for my needs.
About anti-grain - this sounds fine and also looks awesome, but requires an intermediate render target for the texture I suppose, to render it with the rest of the engine work.
And where and what will be the discussion about the editor? irc?
03/10/2013 (7:04 am)
@ Michael: Sure, but then is the problem how to specify the paths that should be imported.The actual idea is the following: I have the whole scene drawn in flash. Flash exports to fxg, which is a vector format similar to svg, thus xml. With xslt filters I convert to taml for which the engine has already read/import support. So I need a way to read paths from taml, maybe than extend shapevector? hm... i'll try that.
@ Melv: Yes, that sounds exactly how I was thinking of it. I'll make sure the shapevector isn't enough for my needs.
About anti-grain - this sounds fine and also looks awesome, but requires an intermediate render target for the texture I suppose, to render it with the rest of the engine work.
And where and what will be the discussion about the editor? irc?
#6
03/10/2013 (7:33 am)
I'll likely be posting a blog early this week (Monday or Tuesday), to discuss editors. I'll spam the link to all the blogs and threads I can find where people have asked about them.
Anton Chernov