Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

RageSpline - Create smooth 2D graphics inside Unity Editor - RELEASED

Discussion in 'Assets and Asset Store' started by keely, Apr 23, 2011.

  1. LeshaVH

    LeshaVH

    Joined:
    Mar 22, 2010
    Posts:
    84
    Keely, could you tell me please - does your example Car game run on 60 fps and smoothly on iPhone4?

    What do you think about 2d physics integration (written on pure c#) instead of 3d?
     
    Last edited: May 20, 2011
  2. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    I can only say with 99% certainty, because I don't have iPhone4, but it easily runs 60fps on iPhone 3GS so I'm willing to bet it's the same with iPhone4.

    Can someone else confirm RageCar 60fps @ iPhone4?

    If you mean that will I roll my own 2D physics integration on top of RageSpline, then the answer is "not likely going to happen".

    Rolling my own physics engine - even in 2D - isn't a trivial task and physics in general is a deep topic with lot's of little quirks and problems.

    Someone else might port Box2D or chipmunk to Unity and I've heard rumors that ppl have already done this. Definitely doable.
     
    Last edited: May 20, 2011
  3. LeshaVH

    LeshaVH

    Joined:
    Mar 22, 2010
    Posts:
    84
    iPhone 3gs is faster than iPhone4 in games, because 4 times less pixels (fill rate is battle neck) and only +200mHz CPU, and, as I remember, the same PowerVR chip...

    Well, I propose to use farseerphysics.codeplex.com as 2d engine, its port of Box2d plus some features... Actually I have assembly for .net 2.0 of farseer..
     
  4. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I've read some postmortems for mobile titles where they had compared Box2D and others against Unity's PhysX. Their expectation was that Box2D, being 2D-only would be faster than PhysX's all-3D approach (with appropriate motion constraints to achieve 2D-only motion). However, they actually found that PhysX was at least as fast as Box2D, and perhaps faster. Probably partly due to greater resources nVidia has to optimize PhysX. And I can pretty much guarantee a hand-rolled physics system in C# is going to be MUCH slower than PhysX.

    Regarding 3GS versus iPhone 4, as you pointed out, fillrate is the only advantage 3GS has since it has fewer pixels to draw. Given that RageSpline can get away with using non-blended shaders for the interior of the pieces, fillrate isn't the issue on RageSpline. If anything, it would be the vertex count, which the 3GS has a disadvantage in. So if it's 60fps on 3GS, it's going to be 60fps on iPhone 4. And I can confirm experimentally that it does, in fact, run at 60fps on iPhone 4.
     
  5. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @keely, so, I got tired of waiting for the update so I'm making my own update. Apparently we don't pay you enough :) So, I just dove into the code and there isn't a single comment so I may be a little off base with this (and I expect that you will let me know how wrong I am). If you set the AAWidth to 0 it appears that you still generate the extra verts even though they are on top of the existing verts. A pretty simple optimization to reduce fill verts by half would be to just change the GenerateFillVerts() to just check for zero AAWidth:

    and GenerateFillVerts change both:

    Code (csharp):
    1. if (outline == Outline.None) to if (outline == Outline.None  AntiAliasingWidth > 0)
    The only issue then is that your triangulator forgets to make one triangle.
     
  6. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Yeah I wasn't really supporting anything without the anti-aliasing because it looked so cool and the performance was good. It makes sense to support the non-AA too. Seems like you can get pretty nice looking stuff that goes under 300 verts and gets batched too. And if you have outline texture with alphas on the border, you don't need the AA.

    Atleast my current version doesn't miss a triangle after removing the anti-aliasing so I guess I have done something that fixes that. There's so many little changes that I've lost track already.
     
  7. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    There's a good change I'll stop adding new stuff and try to ship alpha after the weekend. You can still send me more money if you feel like it ;)
     
  8. hxx2010

    hxx2010

    Joined:
    Aug 31, 2009
    Posts:
    155
    Visually, my wheels did not fall to the ground, how to solve the height difference
     

    Attached Files:

  9. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    There's currently only two options to solve it and they are both difficult.

    One way is described here

    The second way is to make everything much bigger in world space. This helps because collider depth is currently static and your problem will become 10x smaller if you make the wheels (and everything else) 10x bigger.

    The third way is to wait for the v1.1 update where this is fixed. I can't give you the exact date, but the beta-testing starts any day now.
     
  10. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    160
    @Keely
    Will you raise the prize in next version? And what is new features in v1.1? Do you have any roadmap?

    I've seen your tool in popular section of asset store so I tried to check it. And Wow! I really like what I saw. It's a very valuable tool for 2D game development. IMO
     
  11. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Not sure. Originally I was planning to bring more new stuff with v1.1 and announced that prize will go up.

    Now that there's some new stuff, but not as much as planned, I might keep the prize the same with v1.1.

    It's very likely that I'm raising the prize eventually. I don't know if it's with v1.1, v1.2 or later. It all depends on demand and features etc.

    To be honest I rather see many ppl using it cheaply than few people paying premium. I'm dumb like that.

    Yes it's pretty cool and I'm working hard to make it even better. My biggest hope is that other people will start extending it too. The potential is huge.
     
    Last edited: May 21, 2011
  12. Alienchild

    Alienchild

    Joined:
    Oct 14, 2010
    Posts:
    364
    I wanted to use this with a hobby project of mine, and planned to purchase this "some time in the future" (like I often do, but forget). Because of the support you have shown on your product, how humble you seem in your posts and simply the time you take to answer posts here, I decided to buy it. Haven't tried it out yet but I'm sure it will fit right in with my cartoony game. Thank you.
     
  13. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Posts like this are worth way more than 50$. Thank you, sir!
     
  14. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    I'm thinking about dropping the BoxCollider support altogether. I don't think anyone will miss them, since MeshColliders seem to work perfectly and it's more simple. Anyone against this?
     
  15. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @keely, You may want to hold off on killing box collider support until you get a version with both in everyones hands so we can test.


    I have found what looks like a minor bug with the tri creation algorithm. First, some data. Below is actual tri indices from the created mesh. The mesh has an outline and fill vertex count of 3 for simplicity:

    without outline: 1-2-0-0-4-3-0-1-4-1-5-4-1-2-5-2-3-5-2-0-3
    with outline: 1-2-0-3-7-6-3-4-7-6-10-9-6-7-10-9-13-12-9-10-13-4-8-7-4-5-8-7-11-10-7-8-11-10-14-13-10-11-14-5-6-8-5-3-6-8-9-11-8-6-9-11-12-14-11-9-12-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0

    Lots and lots of 0,0,0 tris get added.


    Onto more interesting stuff. Here is the beginning of RageExtruder. You can pick an extrusion depth and if you want to extrude from the AA ring or first one before AA. This first pic is with no outline:




    This one has a Zwrite bug in the shader. That face that is displayed in the back is actually in the front. Speaking of which, any ideas how to modify the shader s the outline doesn't appear above the face? Zwrite On does the trick but it has artifacts.




    With Zwrite On but had to remove AA and Emboss:




    What would be really nice for modding/adding to RageSpline would be an API to get at things. Currently, almost everything is private so subclassing doesn't help. It's always a pity when you have to modify the third part source because then you have to reapply every time the source changes. RageExtruder currently only needed to change 3 "private" to "public" which isn't terrible but it took a lot of self control to not just hack on the source.
     
    Last edited: May 21, 2011
  16. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    Just some thoughts on the subject...

    Will the mesh collider volume consist of the entirety of the shape, or will it just follow the outline like the box colliders do? My main concern is just that there be adjustable thickness as this greatly affects collision accuracy.

    As to the volume versus rim issue, I guess people who are using the interiors of their RageSplines might need it to be a rim.

    Also, I'm not a PhysX guru, but I wasn't sure if mesh colliders are slower or if there are any accuracy differences between mesh colliders and primitives. I do know the docs say "Primitive Colliders are less costly for objects under physics control."

    I do know there are things you can do with objects which have compound primitives that can't be done with mesh colliders. For example, only convex mesh colliders can collider with other mesh colliders, and those are limited to 255 triangles.

    On the plus side, mesh colliders are the only type that will properly deform with non-uniform scaling of an object. And I also expect that a RageSpline that is being dynamically deformed via manipulation of the control points at runtime (ragdoll spline, anyone?) would be faster to just be able to use the mesh as the collider rather than re-calculating collider primitives. But a collide-able deforming RageSpline might not be a good idea in the first place...
     
  17. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Looks like that I'm calculating bigger int[] for triangles than is needed in some scenario and then the rest of the array is all zero. I wonder if Unity discards those before they get sent to the GPU.

    The part where I calculated total trianglecount was pretty awful and complex. I have now cleaned up the code a bit so I'm hoping what you describe is already fixed. Atleast I don't see any extra zeros appearing with my current test object.

    Very nice! I hope my beta doesn't cause you any heart-attacks.

    I guess the Z-fighting comes from the fact that the outline, fill and emboss all have same Z (zero) locally. You could try to hack different values in.

    I could change methods to public, but I have to admit I'm quite the noob when it comes to exposing source code to extensions. I have no experience in building extendable libraries or classes.

    So far when I've been talking about API, I've been talking about pretty simple functions like adding points and Get/Set wrappers to stuff like colors. I haven't been thinking about people inheriting RageSpline-class and fiddling with the actual mesh generation code.

    I thought that really skilled people could use RageSpline as a gizmo and build their own meshes from zero around it, but now that you mentioned it, there's a middle ground too, where you just override some of the mesh building stuff and let others be. Just like you're extruder.

    This made me crap my pants a little to be honest :). The way I constructed all the methods makes sense to me and my approach, but I haven't really thought about it from the stand-point of inheritance. My personal paradigm, in which I have grown into by doing a lot of mistakes at my dayjob, is to avoid making code too fancy and generic.

    Is making methods public enough or is there something else that's seems a bit ugly now in terms of extending?
     
  18. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @keely, I would take publicifying for now. In some cases the whole idea of encapsulation drives me nuts (though it has it's place). I would just suggest putting a little comment note on the methods/properties that could do some damage so that folks understand they are getting their hands dirty if they touch them. Stuff like this makes me miss Objective-C. It has no real notion of public vs private so you can really get at the inner workings of everything.

    I imagine your beta mesh collider is awfully similar to the extruder I wrote. Looks like I may get to toss it in the trash. I'm hoping that your methods and algorithms didn't change too much cause I finally have a baseline understanding of all your code :)
     
  19. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    I don't quite grasp what you mean by rim and volume. I think it's a language barrier thing for me.

    I'm building the MeshColliders around the borders of a shape. It's like open-ended cylinder along the Z-axis. Like you said this rules out physics inside the RageSpline-shape. It could also make doing collidable lines worse if you wan't stuff to collide from both sides of the line.

    I'm letting the user to set an offset for the meshcollider mesh. This means that you can have it a little more further than the actual border or maybe you wan't it to be 5 units inside it. You can also adjust the depth of the "cylinder" in Z-axis.

    Can you rephrase what you meant by "My main concern is just that there be adjustable thickness as this greatly affects collision accuracy". I don't understand this in the context of MeshCollider.

    I'm no PhysX guru either, but if I'd had to guess, the last sentence is directed to someone who is thinking about whether to use a single box collider vs. 100 vertex mesh collider. I'm sure it's not that simple with RageSpline scenario.

    Good point. I think the accuracy with 255 triangles would cover very complex shape, but who knows what ppl want to do.
     
  20. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    I kinda hate OOP altogether but that's a different story. I make em all public. I can't remember why I made them private in the first place. I guess it was out of habit.

    Well. Extruding graphics and physics in RageSpline are two very different things. You need to cover many grounds with graphical side like supporting all the AA,outline,gradient,texturing,Z-fighting,yaddayadda. That's why didn't jump right at it, but at the moment I'm optimistic that I'll do it eventually.

    That's cool, because I usually don't ;)
     
  21. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    What I mean is if the collider is generated, as you described, around the border of the shape, as opposed to it "filling" the entire shape. Meaning if it was only around the border, you could put stuff inside the shape as well as outside, and have both collide with the borders of the shape. Whereas if the collider "fills" the shape, then, for example, a rigidbody could not be placed inside any more than you could put one inside a box collider.

    As long as the mesh collider is non-convex, I would think actually this would be possible. Of course, if you're doing it as an open-ended cylinder as you described, then that would rule out a convex mesh collider (though I suppose you could still tick the "convex" box in the collider inspector if you wanted).

    I mean basically if it is an open-ended cylinder (or tube), then this refers to the thickness of the walls of that tube. Just like right now, you have very thin box colliders arranged around the edges of the shape, and if they are too thin and an object is moving too fast, the object can embed itself in the collider, or pass through it entirely. But if the box colliders are thicker, this is much less likely to happen. So I was thinking about the same issue as it applies to a mesh collider.

    Maybe, maybe not. It could be addressed to someone using a compound collider that uses 5 primitives, versus a 100 vertex mesh collider. In RageSpline's case, if a rigidbody were attached, then all those box colliders would be considered to compose a "compound collider". Whereas a mesh collider would be a single collider. But I don't know if having 32 box primitives would be faster or not compared to a single mesh collider.

    Right, some people may make an entire huge level out of a single shape (though I think that would be a Bad Idea). But not that the 255 triangle limitation only applies to convex mesh colliders, not mesh colliders in general. I think the convex mesh thing would be most useful if you were using RageSplines for things like tumbling rocks with rigidbodies, etc. But again, I don't know PhysX well enough to know if a tumbling boulder with 32 box colliders is faster or not than the same boulder with a single convex mesh collider of some complexity. I mean, it might seem straight-forward at first, but when you consider the optimizations PhysX has when calculating primitive-to-primitive collisions versus mesh-to-mesh collisions, then we might be surprised. Suppose you have a complex, concave shape with a mesh collider, and then your boulder also has a mesh collider. For the boulder to tumble across the surface of the concave mesh, the boulder MUST be convex, or else PhysX won't let it collide with the other mesh collider. Sticking with primitives (box colliders) for both would allow both to be concave shapes.

    But I guess only some actual benchmark test would show which approach is more practical and performant...
     
  22. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    MeshColliders don't have a thickness property unfortunately. There have been many times I wish they did. If dealing with fast moving objects and MeshColliders you usually need a little script to shoot out a ray every frame to check for when you get your object embedded into the mesh and give it a nudge if it did.

    There could definitely be an option to flip the mesh normals inside out as well for those people using the inside of the RageSpline for collisions. Or even a way to generate both if you want to stick a hamster inside a RageSpline and roll it down a RageSpline hill.
     
  23. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Thanks to Brady for explaining it out for me. I finally got what you tried to say.

    Considering all the arguments, I think I would be a fool to remove BoxCollider support, since it seems that it's not very clear cut which of the methods is better after all.

    Viva la feedback.
     
  24. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,474
    I guess what I meant was if the mesh collider were in the shape of a thick tube, for example. Or perhaps think of a torus. I was thinking the thickness of the torus could be controllable. But now that you mention it, I'm not sure such a "thickness" would make any difference to PhysX since it may not contemplate the "volume" of the interior of the collider so as to dis-embed an object the same way it does with, say, a box primitive, which I believe is what causes a thicker box to prevent embedding as compared to a thinner box. PhysX may, instead, only contemplate the surface of the mesh itself. Good thoughts, Prime31!
     
  25. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    Thx for the links iByte, I was researching other free libraries so these are nice pointers to have. We're definitely starting with custom-written SVG to get the simplest possible files working first (just a couple points). InkScape is definitely the tool of choice to export SVGs if you want to use public libraries, it's free and can import Illustrator and Corel Draw files easily too so I'm sure as long as we get full InkScape compatibility we don't need anything else.

    For the record I'm also working on a text-from-font generator which works with regular 3D objects and RageSpline objects, yesterday I got it working for the first time using a custom 3D-characters font, very cool :) My plans for it is having a simple output-GUI generator and type animator to give us nice vector-text output in our games. Lots of ground to cover yet before that happens, but I'm excited already!

    My partner coder (the one who actually knows something about physics and math) told me the best performance you can get is with sphere colliders. He gave me a pretty comprehensible reason for that - there's only one parameter to make calculations and compare against, radius. Following that logic box colliders are actually more computationally intensive than capsule colliders. Interesting, huh? As for mesh colliders, it depends on how many faces are there, a single plane would be cheaper than a box collider for instance.

    I agree, yet VS+Resharper help a lot in making it resonably safe for the coder's sanity. Now, inheritance is what really drives me nutz. All those classes that you don't even know are there, and you can/should overwrite them to "extend" their functionality - which you also don't know WTF is supposed to be? Ouch, my head hurts.. :) Sure, if you're doing stuff all for yourself fine, but for collaborative coding (essential for today's large scope of most tools) it's mayhem, we need better helper tools for that, at least in C# as it stands.
     
  26. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    I put out very first alpha to some of the people I reckon wants it.

    I don't have any official list of beta-testers and I might have forgotten few people I sent betas earlier.

    The version is really quite unfinished and most likely buggy. It doesn't include every asset that the official update will. There isn't any documentation yet. If you still wan't to play with it, and didn't receive it yet, send me a pm.

    Take backups before you use it!
     
  27. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    At the moment it seems like that current features for the update are:

    - RageSpline API
    - New inspector GUI
    - RageSplineStyle feature
    - Outline and multi-texturing in general
    - Meshcolliders
    - More adjustable physics
    - Support for non-AA shapes
    - Various small fixes

    It's a lot smaller update than I was originally planning, but I haven't forgot all the other features that didn't make it this time.
     
  28. wesllg

    wesllg

    Joined:
    Jan 8, 2011
    Posts:
    18
    Quick question - please excuse me if this has been covered - but I am looking for a tool that will allow one to quickly generate smooth/curved collision data in-editor. Optimally, I could use my own custom graphics (say, tilemap) and use RageSpline for collision, allowing smooth rolling movement.

    Also, as per Brady's post, RageSpline actually uses BoxColliders for collision? So does this actually allow for one to place rigid bodies within a spline area and still have effective/working collision detection/response?
     
  29. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @weslig, RageSpline isn't really designed to just be a physics mesh collider creator though with the next update and some hacking you could pull it off. The next update will have the option for box or mesh colliders. Box colliders as the name implies are just box shaped colliders so they will work from all sides and you can have an object inside the spline.
     
  30. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Does it really need hacking with the v1.1 ? Does it even need hacking with v1.0?

    I can't test it right now (at job), but doesn't RageSpline work exactly like "tool that will allow one to quickly generate smooth/curved collision data in-editor", when you just set everything else than physics to "none" from the inspector?

    btw. I'm feeling kind of retarded, when I'm asking how features in my own product work :D
     
  31. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @keely, from the sounds of his requirements the current version cannot pull it off out of the box. It only has a box collider option. What it sounds like wesllg wants is the ability to create a shape in the editor and save out just the collision mesh which could then be applied to his tilemap setup which I totally doable with the next update and minor hacking (a call to the asset database to store the collision mesh).
     
  32. LeshaVH

    LeshaVH

    Joined:
    Mar 22, 2010
    Posts:
    84
    Keely, I got one question about tesselation of spline.

    As I see, spline control vertices are not taken into tesselation - and there some bad behaiour on the corners...

    As I undestand spine vertices must be taken as vertices for polygon creation...
    And the number of vertices does not fix this.
    BTW, I think tesselation should be adaptive - on the straght line less vertices, on the smooth corners - more...

    What do you think?

    Thanx!
     

    Attached Files:

    Last edited: May 23, 2011
  33. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    Thanks Keely, very comprehensive update and I'm enjoying the API so far. One little question. I personally don't like the "verbose" standard way of getting a component as you've written:

    I rather the short form:
    Nevertheless, I do recall that there were problems with using both these "shortcuts" in previous Unity iPhone versions, but as far as I know this was addressed after Unity 3's release with a newer Mono and some smart compiler optimizations. Can anyone confirm that? I don't want to write a lot of code and later have to rewrite it to verbose format.

    Now, specifically about the beta release and my SVG import research. Beta seems stable so far, at least I didn't manage to crash it after some pulls and pushes. With the API parsing a bunch of points from SVG is quite trivial in fact, there are a couple oddities like the fact that Illustrator coordinates make the (0,0) coordinate the top-left corner, instead of the bottom-left one, which will require some fiddling in the parsing. Parsing actual bezier paths (which's what we all want, right?) will be a bit more tricky, but it's fine. I foresee some slight precision/accuracy problems depending on the size of the original document, the SVG exporting process rounds up the values in inches to the first decimal place. Nothing that scaling the document 10 or 100 times before exporting to SVG doesn't solve, of course :)

    All in all good research progress made today, I'm eager to get it all sorted out and start getting my feet wet on the actual code! BTW, I won't use any custom open library/project available out there, they're way too complex, having to support a ton of SVG commands that we won't need anyways. It's better to start over with minimal path support (black and white, no path width etc) then slowly implement most used features.
     
  34. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    If you have 3 spline vertices (like it seems you do), the vertex count variable should be multiplication of 3. For example 3,6,9,12,15,18... This way the poly split will hit exactly where the sharp corner is.

    In the v1.1 update, I'm forcing this behind the scenes, so you don't have to worry about it anymore.

    I actually had this feature in the very first versions, but I removed it because it caused some problems. It's good thinking.

    I might go back to it, but it seems that vertex count isn't that big of a problem performance-wise and algorithm like that would only save a few verts, not a huge percentage.
     
  35. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Good to hear. Wasn't sure what kind of stuff is needed. Surely there will be more features added to API too later on.

    Yeah I think the short version didn't work back in the days. I'm kind of a noob in c# so I'm not even 100% confident that I understand what the actual difference is between them. As said, I'm really not in the position to guess if the shorter version has any risks.

    btw. You can use the IRageSpline-interface too. It's easier to use with Intellisense/autocomplete when there are no methods outside the "official" API around.

    Very good news! None of the other testers hasn't answered anything yet. I took the radio silence as a good sign.

    The tiny amount of research I did, before dropping the SVG support from the immediate todo-list, gave me the impression that it's going to be a bit messy. I hope you guys can make it happen.
     
  36. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Coudn't you just make RageSpline the child gameobject and use the run-time generated physics as is? Why store the collision mesh?
     
  37. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    To be honest so far I found the hardest part to parse the XML (I know there are system functions and classes out there to do it, just never did it), actually parsing the "D" command to RageSpline is pretty straightforward. You even use the same cubic bezier format that most SVG exports use, the parameters you've exposed to the API are the very same SVG uses, both for smooth and corner point types.

    I'll let you know if I stumble upon any actual roadblocks, so far it seems just raw work tbh. And thanks for the hint on IRageSpline-interface, I'll keep it in mind if I miss something in the API.
     
  38. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @keely, you could go dynamic for the collision meshes but I am assuming the OP is planning on using the collision objects with a tilemap (something like the excellent Unitile for instance http://forum.unity3d.com/threads/72934-UniTile-2d-Tile-based-Map-Editor-within-Unity). For a tilemap instance it probably wouldn't be the best idea to generate every tile's collision mesh at runtime. There could potentially be a ton of them. Having a single, shared collision mesh that you can assign to a tile seems to be what the OP is looking for but who really knows...

    As for the GetComponent discussion: the rule of thumb should always be if there is a generic version of the method available use it. At the very least it will save you a cast and provide cleaner code. In this case, GetComponent<T> is the weapon of choice.

    The beta seems solid to me so far. I haven't had enough time to say for 100% sure but porting over the extruder was trivial and everything seems solid so far. Much nicer inspector also! Well done! I'll be giving it a better run-through starting tomorrow now that I have a few minutes to myself again. I like @LeshaVH's idea a lot. That was on my initial list when I started making something similar to RS. The idea isn't that it would reduce the number of verts but it uses the verts that it does have much more efficiently for both collisions and looks.
     
  39. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
  40. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    Maddox
    Actually that first link i pointed you too has the parsing classes that were very easily adapted for the purpose your talking about. After I got that code imported, I started with the simple SVG types, square, circle, line, rectangle and was still working on the path as it was more complex and that particular library it doesn't have any code for breaking down the path units "d"

    One other issue to keep in mind with a straight SVG import is that svg objects (based on the sample I happen to be using below) can be layered to achieve certain effects. So in order to maintain the object it will/(maybe) necessary to create multiple RageSpline objects per complete svg object. This is going to drive up the vertex/material counts as there no opportunity to flatten the graphic.

    iByte

    Edit this is as far as I got before I had to put it aside, due to other commitments.

    Sample of original artwork
    $svg_animals.jpg

    My attempt so far

    $svg_import_test.png

    You can see i have some issues still to fix.

    My circles are not being size correctly all the time. I was using all sharp points and some (based on "S" and "s") need to be smooth points I think. Also having some troubles with the last control point that I hadn't quite figured out yet.
     
    Last edited: May 24, 2011
  41. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    Yeah, actually that coordinate layout is part of the SVG spec, so you have to flip the "Y" coordinates to play nice with Unity... gets to be fun when they put both absolute and relative coords in the mix.

    It's also interesting to note that Inkscape uses a bottom left system so I found that handy to compare my results with the same graphic imported into Inkscape.

    iByte
     
    Last edited: May 24, 2011
  42. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    Actually I've found the UnitySVG project to be too inheritance-spaghetti for my tastes, and the proper SVG part (at least from what I've gahtered) is too tied to the 2D-rendering process. I've also found some other libraries (easier to grasp than the one by MrJoy) which have D-command attributes breaking as well, but tbh this is so simple to do that I rather do it myself. As you've properly noticed already, I have some aversion to try and understand other people's code - I do use APIs, but that's generally as far as I'd go :)

    As for the circles/etc, commands, for now I'll be satisfied with simply converting everything to paths/outlines before exporting. Btw, thanks for the tip on InkScape using the bottom-left=0,0 convention, should make things easy for starters, although I do intend to check the origin application and flip the Y automatically, it's fairly trivial anyways.
     
  43. Alienchild

    Alienchild

    Joined:
    Oct 14, 2010
    Posts:
    364
    I have a newbie question about RageSpline; when I scale the Prefabs that comes with RageSpline (Egg, for example) to the correct scale relative to my other game object then the background color of the spline becomes blurry, the outline becomes a mess and it looks off. What am I doing wrong? I simply scaled it by using the scale tool, and I can't find any options in the inspector to correct the settings.

    Edit: I just noticed that everything looks OK after I scale it until I actually run the game.

     
    Last edited: May 24, 2011
  44. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Nice screenshots :)

    You can also press the refresh-button to fix the problem in-editor without running the game.

    It has to do with RageSpline object not noticing that you have scaled the object and the RefreshMesh() isn't getting called.

    The blurry part you see is the anti-aliasing and outline width not getting scaled down with the rest of the object. If the refresh-button doesn't help, you could try to adjust those.
     
    Last edited: May 24, 2011
  45. iisjreg

    iisjreg

    Joined:
    Mar 25, 2011
    Posts:
    101
    I like it, but you definitely need your eye-block-man (he needs a name =] )

    P.S. I keep hovering over the purchase button, but am waiting for next update (plus I have no exact need right now for it).
    Is the next update going to be a big enough change to break current set-ups at all?
    Thanks.
     
  46. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    I'm calling him mr.Cube :). The layout is not final, just a draft. I will bring him along.

    None of the testers who currently have v1.1 (alpha) have complained that anything broke. The example game included certainly worked 100% after updating.

    I can give you the link to the update right away if it helps. I might add one more feature, but it's pretty much final v1.1 feature-wise.
     
    Last edited: May 24, 2011
  47. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    You had mentioned earlier about parsing the xml and I was referring to that first link in my earlier note "http://www.codeproject.com/KB/cs/svgpad.aspx" which pretty much just parses the xml and presents it in a windows form. But I can understand if you would prefer to roll your own :)

    This raises another point in that what may be imported in as a mix of svg objects, most likely will only go out as svg paths

    The SVG file format coordinate data will always be in top left 0,0 coordinates http://www.w3.org/TR/SVG/coords.html - how the application choose's to present it, is "well" up the the application. :D

    From your previous comments I get the feeling you initially seem to be more focused with export? (where as I was more interested in import).

    All the best

    iByte
     
    Last edited: May 24, 2011
  48. Alienchild

    Alienchild

    Joined:
    Oct 14, 2010
    Posts:
    364
    Thank you, now it works fine, I was just missing the outline/AA adjustment settings :D
     
  49. Acumen

    Acumen

    Joined:
    Nov 20, 2010
    Posts:
    1,041
    Hey Alienchild could you elaborate what exactly on your screen is made with pure ragesplinesplines and what is using more or less textured methods ?
    Maybe even a bigger screen could fall out of your hand ?
    Looks mighty handsome and looks much more like an actual game product. So yeah, sharing a bit more information on this, would be cool.
     
  50. Alienchild

    Alienchild

    Joined:
    Oct 14, 2010
    Posts:
    364
    I just bought RageSpline a couple of days ago and just got around to test it out today. This means that all of the artwork you see there are textures. Nothing fancy really, some scrolling skies and a ground texture. In the foreground though I have made a simple animation system that utilizes iTween, that makes the leaves/grass/whateveritis wave back and forth (no bending) while at the same time scale a bit in and out, making it come more alive. Please note that this is currently really crude graphics where I haven't spent much time on the details, but rather gotten a feel for the general style and color palette. RageSpline will be used to add better geometry for my setpieces (platforms that the game pieces will stand on), and is really a match made in heaven for this type of cartoony style.

    I've attached a screenshot from an earlier build. Notice that once everything is bigger it doesn't look as cool ;) The green tile is not used anymore btw, it was a placeholder graphics. The black tiles is more or less how it will look, with eyes that animate with a simple animation system I wrote.