I know, I’ve posted quite similar thread to the 2D section, but after a week or so of trying to solve the problem myself, I found out, that the easiest way to achieve the wanted result is using meshes… So I’m really sorry for double-posting, but I would really appreciate your generous help. I’m no programmer so… This is, what I wrote about my problem:
I need to deformate a sprite of random shape with a mouse grab. I want to grab an edge of a sprite, drag it around and let the sprite “bend”, for example like a paper… I think I can find the line of a bend quite easily, but I do not know, how to actually deform the sprite…
I’m sorry for my chaotic description, this might help you to understand:
So, as I’ve already said, I’m a weak coder, so I was experimenting and looking for any help, but with no result. Anyway, probably the easiest way to achieve my point is using meshes, right? But I do not know, how to generate a msh from a sprite and how to shift the final vertices correctly. Do you think you could help me somehow, or am I too brash? Any tiny hint is appreciated! Thanks for any feedback!
For origami you’re going to have to slice and reconstruct the mesh each time otherwise it will never deform how you’re expecting. So the main problem for you is splitting any kind of mesh into 2 separate meshes along a plane.
You will need to slice many meshes by the end of it, so you’ll be building up a list of sliced meshes, each with their own collision.
Far from a trivial task and it’s one I wouldn’t take on board without 3 months spare time personally so I don’t think you’re going to be in any luck at all unless you pay someone or make it simpler.
Well, orriginally, I thought, It could be possible to shift mesh’s vertices and change its z-coordinate with every new bend. That mesh could have minimal z-scale. Then, it would have a texture with the sprite. That’s probably impossible, right?
I wanted t use it fo 2D game, but that probably does not change anything… Also, one guy from czech forum showed me this: http://www.west-racing.com/mf/?page_id=2 I thought it could help somehow. I will keep looking for any solution. Unfortunately, I’ve got no idea, how to make this simpler…
You mean create a new mesh for each “fold”, instead of adding vertices to the original one? I think that’s what hippocoder is talking about, actually. If this is strictly 2D folding and not 3D that makes things simpler, but it’s still something that will be difficult if you haven’t done mesh modification before.
MegaFiers seems to be a general-purpose deformation system. It looks powerful enough for this - possibly a bit overkill, actually. I’m not sure if any of the existing modifiers are exactly what you want - maybe a modified Bend?
In any case, you’ll also need to figure out how the UI for this works, in terms of determining a fold angle from the mouse position / movement.
Well, I ment adding vertices to original one. And yes, I know, that it’s gonna be difficult, but I think I can sacrifice a lot time to learning…
Yeah, that Bend modifier caught my eye and I think it could be usefull, but I woul have to simplfy it a lot…
I think finding the angle should not be so hard. I would compare the current mouse position with the original position (when player “grabs” the paper with LMB clicking). Then, the fold would be the line perpendicular to this line crossing in in the half… The other things like unfolding and creating a new fold I have theoretically prepared, but irst, I need to handle just this…
Naturally, doing it this way means that you can’t have more than one fold, but it was fairly simple to set up (compared to changing vertices and triangle indices)
Wow, thanks, mr. hpjohn! Looks fantastic! I’m gonna sit down and learn, how to code this, it’s still kind of “higher league” for me…
But really, thank you showing this point of view… The limitation of one fold could be a problem in my case, but I think I could make the concept of my game simpler… I would probably have to change few details, for example changing “grabbing areas” or making one side kind of “solid”… But that should not be a problem, right?
By the way, is this somehow possible with sprites in 4.3?
OK, so now, I need to close myself in the cellar and just learn and learn and learn. Thank you very much for the feedback!
Still, feel free to write some tips or advices. I would be grateful for them!