This site requires JavaScript, please enable it in your browser!
Greenfoot back

Comments for Realistic Balls

Return to Realistic Balls

A new version of this scenario was uploaded on Wed Apr 25 07:58:15 UTC 2012 Scrapped the really slow filter that I'd found. It wasn't optimised and didn't add too much to the effect (in my opinion). I'll add shadows in next etc. However, for now, things should just move for you. Source provided.
sp33dysp33dy

2012/4/25

This is the article I found. Do have a read for the theory. http://www.emanueleferonato.com/2007/06/10/creation-of-realistic-spheres-in-flash-with-textures-and-masking/
A new version of this scenario was uploaded on Wed Apr 25 08:20:06 UTC 2012 Couldn't help but add an Earth! Balls also have random starting positions now.
sp33dysp33dy

2012/4/25

I'm going to add a shadow next (with a simple casting effect from light actor) and will also look at writing a fast displacement map filter. The filter I obtained isn't quick. A dirty approximation is all that is required and gives me a new challenge!
sp33dysp33dy

2012/4/25

I'm going to add a shadow next (with a simple casting effect from light actor) and will also look at writing a fast displacement map filter. The filter I obtained isn't quick. A dirty approximation is all that is required and gives me a new challenge!
SPowerSPower

2012/4/25

I would also be nice if you would add that shine effect you see in the last program of that article you found.
sp33dysp33dy

2012/4/25

Hi SPower, that shine effect is the displacement map filter I mentioned.. :) There is a filter available on the net, but it isn't tuned.. I would like that shiny look ASAP.
sp33dysp33dy

2012/4/27

See my 2d bump map and light demo: http://www.greenfoot.org/scenarios/4933 I found an article and source for how to do this. I just need time now to mash the two together!
SPowerSPower

2012/4/27

I understand, and it's a great effect! I will wait for the light effects.
A new version of this scenario was uploaded on Sat Apr 28 12:25:22 UTC 2012 Updated with light and bump filtering. A little disappointing, given the size of the balls. I need to increase them and the effect will look better. Space toggles on/off filtering.
A new version of this scenario was uploaded on Sun Apr 29 10:15:33 UTC 2012 A little happier with this effect. Although it's still a little slow (there is some optimisation to do). I've also got to deal with blacks; which don't 'shine' yet.
A new version of this scenario was uploaded on Sun Apr 29 23:37:34 UTC 2012 Discovered that i'd artificially shrunk the balls. They are now the correct size. I thought of another technique to speed up the lighting. Those with black boxes are new variety. Anyone like to comment on the look in terms of realism??
SPowerSPower

2012/5/1

The movement is really realistic right now! What would make it even more realistic, is let the balls touch each other and than, let the other ball move in the direction the other ball hit him. To explain it a little bit better: Let's say there are 2 balls, ball 1 and ball 2. Ball 1 is moving, ball 2 is doing nothing. If ball 1 touches ball 2, ball 2 will move.
sp33dysp33dy

2012/5/1

Yep, SPower. That's where I'm going to go with it. However, work has taken over my life again. Might be a while before I get back to this; given a nice trip to europe at the end of the week.
A new version of this scenario was uploaded on Sat May 12 10:45:51 UTC 2012 Ok, spent a few hours this morning learning about elastic collisions. Now implemented. I've refactored the code an awful lot and will publish when I've added light effects. Yep, I've run out of time as I'm heading to a weekend away with family. Thought I'd upload a taster.
A new version of this scenario was uploaded on Sat May 12 10:49:02 UTC 2012 Earth was missing.. Lol
sp33dysp33dy

2012/5/12

you can also drag the balls.. The left/right to turn off/on lighting isn't operating right now. Will try to update tomorrow night or Monday.
SPowerSPower

2012/5/12

Great! But one question: why do you have the 'with-source' tag, while you didn't post the source code?
A new version of this scenario was uploaded on Sun May 13 19:54:19 UTC 2012 Ok, not had a chance to put light source in yet; therefore I'll post up the rough and ready code.
A new version of this scenario was uploaded on Sun May 13 21:41:09 UTC 2012 Added the alpha mask code. Do you see the difference between the two sets?
A new version of this scenario was uploaded on Mon May 14 18:55:33 UTC 2012 Added code to ensure balls are added into space and are shown on load (rather than start). There is a known problem in which balls collide and pin against each other. This is when three collisions or more occur at the same time. I will look and fix this soon. Time for tea.
SpilliSpilli

2012/5/15

This is cool, I'd recommend adding some type of intersection depth code which will push the balls back when intersection occurs because sometimes the balls fuse together.
SpilliSpilli

2012/5/15

This is cool, I'd recommend adding some type of intersection depth code which will push the balls back when intersection occurs because sometimes the balls fuse together.
sp33dysp33dy

2012/5/15

Thanks Spilli, thats what I plan today. Add code to move balls back to when they actually hit and prioritize the collision order. This should then ensure the balls never cling to each other. I'm also just putting a movable light source in and considering how to put ball reflections into a ball!
A new version of this scenario was uploaded on Tue May 15 19:01:02 UTC 2012 I've cleaned up some of the method overrides in the AlphaMasked & Skinned classes. I've also hardwired a rotate to the balls for now. This is in preperation of spin. F1 - Show boundarys F2 - Hide Boundarys F5 - Stop movement F6 - Start movement
A new version of this scenario was uploaded on Wed May 16 14:42:22 UTC 2012 Clingy ball syndrome fixed. Light actor added. Next is to add light spot and shadow to each ball based on distance and direction from light.
A new version of this scenario was uploaded on Wed May 23 22:26:11 UTC 2012 Had 5 mins to mess around with circular gradient fills tonight. Looks like the lighting is simple to perform. Drag the light source around (the yellow star).
MorranMorran

2012/11/20

As the ball rolls, the ball images act like they were in 3D and not 2D. How did you get the Ball images to look 3D?