Line-drawing / "carving" mechanic

Hi everyone.

I’ve been rolling an idea around in my brain for the last few days, and I’m kind of stuck with how to approach it.
I was wondering if anyone knows of any assets, or has any ideas, that may help me.

Here’s what I’m trying to achieve:
In my app, the player will be able to carve letters / drawings / whatever they like into a “wooden” surface.
I’ve thought of doing this by joining points (recorded as the player drags their finger around the screen), and then somehow filling the drawn line with a “carved” texture of some sort.
Perhaps I can do this with Line Renderer…

Does anyone have any ideas of how to approach the line-drawing bit, and then especially the texture-filling bit?
I’m especially interested in figuring out a way to have a seamless carved texture, that doesn’t look like a bunch of quads joined together with ugly texture seams.

I’ve been searching around for info, and I can’t tell for sure if Vectrosity would let me do this. I know it can do the line drawing stuff, of course, but it’s the seamless texturing of that line that I’m most unsure of.

Thanks for any help.

I have not looked into this at all, but I would think you can place an instance of an object, every so often, on a drag. If true, why not have your background, say wood, then drag finger, on drag, place a semi transparent object, perhaps shaded heavily on the edges to make it look like a groove. And simply use a cap sprite at touch begin and touch end.

Thanks renman3000.

I’ve thought of doing something vaguely similar, but I couldn’t figure out how to make multiple instances of a “carve” object blend together nicely, in order to look like a continuous carving.

Hm. Not sure, but I think, if that were the method to go, I would consider sprite size and distance traveled. Match them up. Only trick is to insure the sprite is always rotated correctly.

Yeah, I’ll have to carefully tweak the distance moved (from the previous point) that will trigger the creation of a new point.
I guess if I control that carefully, I can control the sprite size and therefore the rotation.
It’s gonna be tricky!

Sure thing. I think placement is no big deal, but placement and rotation is where it gets funky for me. I imagine shape of the sprite may come into play?

Very likely, yes.
It doesn’t matter if I have to limit the shape or size of the sprite, and therefore limit the distance at which they are placed from each other - rotation will indeed be the killer.

At least with this method. Perhaps if you look at “draw line unity3d” it might be of service. Of course if this was the method, you could perhaps measure delta x and delta y and base the rotation off of that vector.

I’ll have a serious think about that.
It sounds pretty reasonable.

Thanks for your help and suggestions.

Looks like vectrosity may indeed be the solution!

I just saw this in the most recent release notes:
• VectorLine.continuousTexture, for making a texture tile once, evenly, over the length of a line regardless of how many points the line might have. e.g., myLine.continuousTexture = true;

Off to the asset store!

Well…while I definitely appreciate sales, I’m not 100% sure Vectrosity is appropriate for this. Although I’m not quite clear on what you’re planning on doing. A mockup would help.

–Eric

Hi Eric.

My app will (assuming I can get it working!) have a screen in it where the user is expected to carve something (a shape, a letter, a random scribble - doesn’t matter) into a “wooden” surface.

It is to be one continous line, and the idea is that it will look like it has been carved in actual wood (except virtually, of course).
I need to be able to have the drawn line simulate a carved notch, or scratch. I’d use a texture with a “notch” graphic, which I can hopefully repeat seamlessly along the length of the line, smoothly through any curves.

By the way, I really appreciate you popping into this thread - your customer service is legendary, and I’m not even a customer just yet!

I get the general idea, however a mockup as to what you want it to look like would be really helpful. :slight_smile:

–Eric

If I were you I’d take a look at the linerender and/or the trailrenderer code on the unity wiki. The wiki version gives you more control (i.e. you could simply remove the code that removes vertices from the trail as you go. You would have to manage it though as obviously there are finite limits to the size of a Unity mesh, but it’s a good place to start.

http://wiki.unity3d.com/index.php/OptimizedTrailRenderer

Mike
@Runonthesopt

If the carving is to remain where the user left it, then the trail renderer is the wrong choice. It sounds as though you want vectrosity splines but with texture for grooves.

Yep, that’s precisely what I’m after.
Just gotta figure out how to do it!
:slight_smile:

Maybe you want to use the SetTextureScale function in Vectrosity, though again I’m not 100% sure if that’s the look you’re after…

–Eric

Something like this:

  • though I don’t think I’ll worry about having accurate shadowing!
  • it will be a continuous line, without the variations in line thickness and carving depth present in this image (it’s from a photoshop tutorial)
  • it won’t need to have the ability to join the end point to the start point gracefully
  • the groove does not need to respect the texture of the wooden surface (i.e. no wood grain needs to be visible in the groove)

[EDIT] really it can just be a texture with a dark section through the middle, and lighter tones along the edges.

[EDIT 2] actually i’ve thought about the app mechanic a bit more… it might actually make sense to use a glowing line to represent the notch. If i use a glowing white line as default, is it easy in vectrosity to change the colour, if i allow the player to “rate” some event in the app by changing colour?

Yes, just plain dark in the middle and light on the edges, and use something like 75% transparency so the wood shows through. Just a regular Vectrosity line would work for that, no need for continuousTexture or SetTextureScale.

Actually you could even get correct shading by using a normal map. The only catch is that the line would need tangents, and currently there isn’t a function to do this. (There’s an AddNormals function, which would also be necessary for this, since normals are used for lighting, but an AddTangents function would be needed too.) However, the source code is included, and you can find code for generating tangents on the forum, so it wouldn’t be much trouble to add that.

–Eric

Ah, that sounds very doable - and it’s a great idea!
Thanks Eric!

I actually bought vectrosity last night, so I’m looking forward to experimenting with it.

One more quick question (sorry about all of this!) - is it easy to change the colour of the vectrosity line if I let the player have some choices for line colour, after the line has already been drawn?