Page 1 of 4

BallZ

Posted: Tue Jun 22, 2010 6:51 pm
by Rado1
My experiments with 3D surfaces ended up in a small framework for dynamic visualization of surfaces in the form of small spheres; I call it BallZ. The intention was to create a generic and extensible code enabling simple specification of new shapes. Because BallZ seems to be not only useful, but also nice, it can be used as a screensaver.

I provide the source code for your fun. You can extend it by new surfaces easily: just add new update* (and maybe also init*) function(s) to the OnLoaded/ZLibrary, update the States/SceneState/OnState+OnUpdate code by adding calls of your function(s), and update the SCENES constant.

For ZGE gurus (Ville, jph, Kjell, y offs et, ...): I would really appreciate if you commented my code.

Posted: Wed Jun 23, 2010 4:08 am
by y offs et
It's a beautiful piece of work, and a substantial contribution to the code repository.

I'm flattered to be included in a group of real gurus. I'm more the resident noob / translator.

Nevertheless, I did find a 5% FPS improvement by substituting MeshSphere into your SphereMesh / Mesh and removing your two components.

Considering I tried a multitude of other techniques without any appreciable difference, I think that little bit is significant.

Posted: Wed Jun 23, 2010 7:06 am
by VilleK
I really like it too. The transitions between shape and color are mesmerizing to watch.

Thanks for sharing the code. It looks well structured and reusable with a good understanding of when to use components and when to use scripting. In my opinion you can now call yourself a ZGE guru too :) ;)

Posted: Wed Jun 23, 2010 1:47 pm
by Kjell
:)

Excellent work Rado1 ~ Somehow I get the feeling you've watched some of the video tutorials :wink: The only thing I would have done different is using a single 3D array for the colors instead of three 2D arrays.

@y_offs_et - Did you set the MeshSphere to 8x7 Samples like his MeshBox? Since in that case it makes sense .. it's one of those ( slightly annoying ) inconsistencies of ZGE. A 8x7 MeshBox ( 2D ) generates 9x8 ( triangulated ) quads, while a 8x7 MeshSphere generates 7x7, hence the difference in performance.

K

Posted: Wed Jun 23, 2010 5:03 pm
by Rado1
y offs et wrote:Nevertheless, I did find a 5% FPS improvement by substituting MeshSphere into your SphereMesh / Mesh and removing your two components.
I tried MeshSphere with the identical number of triangles (144) and FPS was the same on my machine (60 in average). The used SphereMesh (originally provided by Kjell) looks better in larger scales of models.
Kjell wrote:The only thing I would have done different is using a single 3D array for the colors instead of three 2D arrays.
You're right, 3-dimensional arrays would reduce amount of variables... I used more "didactic" approach.

Posted: Wed Jun 23, 2010 5:17 pm
by y offs et
Actually I used a 10x10 meshSphere which looked the same to me. I based my measurement on the fourth scene only, which is the most drain on resources. At one point my FPS would drop to 7.3 as compared to 7.6 or so ( 1680x1050 ) , which seemed about 5%. I mused the increase might be due to an optimized component vs. working thru code.

Posted: Wed Jun 23, 2010 6:28 pm
by Kjell
:?

Sounds very strange .. the Producer components are only executed once ( upon creation of the mesh ), after that it doesn't matter anymore whether the mesh has been created using a Expression or a MeshPrimitive.

Perhaps the difference is solely caused by the fact that Rado1 accidentally enabled HasTexCoords on his SphereMesh ( unnecessary since he's not using any textures ) while a MeshSphere doesn't have any texture coordinates.

K

Posted: Wed Jun 23, 2010 7:00 pm
by y offs et
Since you can't take a screenshot of a screensaver, I put the zproj in a 1280x800 window for both. I waited thru three cycles on each run and grabbed the lowest num I could. The results were consistent with the shots. I'm satisfied this is fact.

Posted: Fri Jun 25, 2010 12:13 pm
by jph_wacheski
That is a nice display,. I really like the smooth transitions between the set animations. Your code is very well done as well,. I always get new ideas, for ways of doing stuff, when I look at other peoples code. Thanks for posting it.

Posted: Mon Jun 28, 2010 11:27 am
by Rado1
Thank you all for encouraging feedback. I updated the code according to your comments. Based on additional comments of my friends, I added clock, new fractal shape, and also the possibility to configure execution. If you put the Ballz.cfg file in the same directory as executable, you can configure switching the clock on/of and also rotating of all shapes vs. displaying just one selected. The description of config file format is contained in the attached example.

Posted: Mon Jun 28, 2010 3:28 pm
by VilleK
I love the new shape, the morphing effect looks great for that one! And the clock is very neatly made too. Good improvements.

Posted: Thu Jul 01, 2010 12:37 am
by Deozaan
I like your screen saver. It was pointed out to me on DonationCoder.com.

I'd like to suggest an improvement:

Screen savers shouldn't have the same image in the same location the entire time the screen saver is running. That defeats the purpose of running a screen saver in the first place.

Could you do something about the copyright and the clock always being in the same location? (The problem with the clock is the colons, which are always on and always in the same place.) I'm not sure what would be best, as others have stated (in the DonationCoder thread) that they didn't like the copyright moving around with the balls.

Maybe the copyright could just move to another corner of the screen after 5 minutes or so? And the clock could move from bottom to top and vice versa.

Posted: Thu Jul 01, 2010 12:53 am
by jph_wacheski
I would suggest fading it in and out and moving it around,. clock color could change as well.

Posted: Wed Jul 14, 2010 8:55 pm
by Rado1
Update of BallZ is here. The clock is slowly moving and changing its color. Also a new shape was added. Copyright was moved to the config file.

Posted: Wed Jul 14, 2010 9:15 pm
by Deozaan
Thanks for incorporating my suggestions. I like your method of sliding the clock across the bottom rather than just having it jump to another location every few minutes.

I really like the new shape, too. It reminds me of something from the Cthulhu mythos.