2d Graphical Trickery!

Hi all,

seeking a bit of advice for something that has kinda get me scratching my head for a day or two.

We all know that any graphics we create within Codea are 2d, no denying it, they are. We can add depth, shading, whatever to simulate a 3rd dimension, but ultimately, bottom line, they’re 2d.

Now, if I was to draw a circle in Codea, it would appear as a circle, again, simple to visualise.

I could then add some shading to that circle to give the simulated appearance of depth, that sad little circle now turns into what our mind thinks is more than likely a sphere.

So far so good, but here’s the problem.

WITHOUT using spherical texture mapping, is there any possible way to give that ‘circle’ / ‘sphere’ the appearance of it moving so the mind thinks it’s a ball in motion?

The only thing I’ve managed to achieve which looks ‘ok’ but far from ‘good’ is a slight wobble (by no more than 3 pixels) in the opposite axis of motion. ie. if the ball is moving up the screen, there’s a slight wobble between left and right - it gives the appearance of a ‘ball’ but certainly not a perfectly rounded sphere.

Can anyone think of any graphic ‘tricks’ that could emulate movement a bit more realistically?

Is there a reason you don’t want to use a mesh and so have a “proper” sphere?

More than anything, trying to avoid using meshes as I’m trying to adhere to a pure ‘graphical effect’ method of doing something.

Hi JMH,

There is a simple technique of colour cycling. I have generated a bouncing ball in a box, when I first started with Codea. To simulate a ‘3D’ sphere I textured it with sequential ellipses of different widths (I’ll try to dig out the link). I was trying to use rotate on it, but sadly at the time didn’t know what I was doing. You could simply use that, but you could enhance it by using a colour rotation cycle for the ellipses to give the impression of curvature and movement.

try : http://gist.github.com/2897503

Remember this is early days crude code for me - but I’m not doing much better now!!!

Bri_G

:slight_smile:

Hi JMH,

For a slightly better sphere you could take the code I did in the following link:

http://twolivesleft.com/Codea/Talk/profile/419/Bri_G

Then, just using the points, triangulate() the vertices matrix and make each triangle a shaded mesh. You could shade from bottom up and produce quite a nice sphere - I thought about doing it but thought it would take me ages.

The best way to do this would be to cycle through the vertice list applying a programmed color() value so you get a gradual shading change.

I hope that helps - maybe a longer term target.

Bri_G

:slight_smile:

Hey Bri_G thanks for the code.

Very close to what I’m after and has given me a slight lightbulb effect in my brain with an idea using those lines that you’ve shown n the sphere!

Many thanks, much much appreciated, J

Hi JMH,

No problem - please keep us posted, I’d like to see what you are doing.

Bri_G

:slight_smile: