> My app is an interactive particle swarm optimization ( > http://en.wikipedia.org/wiki/Particle_swarm_optimization for the curious) > that generates N-dimensional coordinates representing individuals in a very > compelling, organic way. For visualization, of course, I'm mainly concerned > with two- and three-dimensional instances of these swarms. > > My trouble is in deciding which graphics framework to pursue for the > visualization. Since all I need are representations of points, the path of > least resistance for 2-D visualization seems to be using a simple loop with > calls to [NSBezierPath fillrect:]. However, I suspect this pattern would not > extend well to rendering a scene with 3-D instances of the swarms. > > Beyond the use of Bezier paths, my knowledge falls short pretty quickly. I > often hear people sing the praises of Core Animation, but the emphasis on > layering in the documentation makes me doubt its capability to draw such a > 3-D scene. > > I also see Quartz mentioned as a friendlier wrapper for OpenGL, but again I > get the impression that it's more geared toward 2-D rendering than anything > else. Is a straight dive into full OpenGL the way to go here? I realize that > these frameworks have similarities, and that picking the "wrong" one won't > at all be a waste of my time, but I'd be thrilled to hear thoughts on their > comparative virtues before I take the plunge either way. >
So I think a quick simple distinction between Quartz, Cocoa, Core Animation, and OpenGL would be useful. Simplistically, Quartz is the 2D drawing framework on the Mac. It does a lot of in software though which has its strength and weaknesses. Strengths are that drawing looks consistent on all different Macs and it provides some nice features like anti-aliasing, rounded caps, etc, for things it draws. Cocoa is the highest level framework which provides the easiest APIs to use. It's drawing functionality uses Quartz underneath the hood. Core Animation focuses less on how to actually draw underlying primitives, but how to move them in space. You can think of Core Animation as a rectangle engine. You draw things in rectangles and move them around. To actually draw stuff in the rectangles, you would generally use one of the other frameworks. Core Animation leverages OpenGL to cache your rectangles on the video card so if the underlying view content doesn't change, drawing can be very fast and unload the burden off the CPU. Core Animation also leverages OpenGL to transform these rectangles in space (position, rotation, scale). Core Animation also provides animation functionality that lets you describe where and how you want to animate an object, and Core Animation will animate it for you without you having to worry about interpolating it over time or poll the event loop. OpenGL is your direct access to the video card. You don't get a lot of stuff for free, but it is very fast. And it also does 3D. Unlike Quartz, you are not guaranteed to see exactly the same thing on different video cards. Concerning 2D, I don't have a sense of what you plan to actually draw and how much stuff you intend to draw. If you are planning to draw so much that you expect to push the graphics system, OpenGL will be your best bet. However, if you don't think you will be in this situation, Quartz/Core Animation/Cocoa may be easier and draw things prettier with less effort. Scott Stevenson has a nice Core Animation based demo called NanoLife which may be of interest to you. http://theocacao.com/document.page/555 For 3D, Core Animation has some 3D capabilities, but it really isn't intended for it. (In the above NanoLife link, I think somebody posted a link to a modification that makes the spores align in a spherical layout.) If you are serious about 3D, I would recommend OpenGL. If you go the OpenGL route, GL_POINT_SPRITE might be one of the primitives you want to consider to represent your object. One last thing, you might also look into Quartz Composer. It basically draws OpenGL, but let's you express things with wires and boxes instead of code. -Eric _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com