Hi. I’d to have a way to deform arbitrarily a sprite (e.g., suppose I have a road texture and I want to deform the sprite to follow a spline). I have the suspicion that I can use CCGrid3D for this objective, because I’ve seen it in action for the effects (Waves, Ripples, etc.)
I’m observing that the CCGrid, however, tries to use the window coordinates, and as such is oriented to be used only for window effects.
I’ve tried to google for this to no avail, can anyone point me in the right direction to have this effect in my sprites?
This is going to be a bit tricky. You need to deform your vertices for the sprite, either in vertex shader or on CPU. Now, a sprite only has 4 vertices, which limits the ways you can deform it. You need to create your own mesh for this object with sufficient resolution of vertices for your effect. I’m not aware of any built-in way in cocos2d-x for this.
I’d like to share the class, but I have not tested it throughly, I have to test in case the texture comes from an atlas non rotated, and see how it would interact with CCSpriteBatchNode (as this is a terrain it will be repeated many times and I’d like to have just one OpenGL call to draw them all.
SpriteBatchNode assumes a quad to be rendered, i doubt it will work for you. Have you considered trying out Sprite3D for this? Cocos2d-x probably also batches those meshes for you.