I had a school project that I need to build a visualization application to plot some scientific dataset in 3D on my snow leopard. While I had some experience in terms of plotting in Windows, building a 3D application in Macintosh environment is fairly new to me. So I kinda spent couple of weeks researching and experimenting couple of components that are needed to proceed .
Canvas
Basically, you need to setup a screen canvas to draw 3D objects, which can be achieved by using OpenGL API . The library takes care of setting up the graphic hardware, creation of objects, and projection them to 2D screen pixel on the canvas, all sorts of basic functionalities in 3D world. Normally this process is fixed, but a shader language (normally comes with OpenGL) can let you adjust how you represent object and how to draw them into pixels at run time through some scripts. This really adds the overall flexibility, and effects can achieved very easily by writing some shader and plug into the pipeline.
To see how apple supports OpenGL and shader, you can check out GLSLShowpiece application from apple reference library ( it comes with a executable file). You can test your shader easily using OpenGL shader builder (in XCode folder) where you can test all sorts of functionality of shader without writing any code.
Engine
To make 3D rendering job a bit easier, I’d also like to have a backbone engine that deals with scene loading, objects/material management, camera handling in a black box, so I can concentrate on the application logic. Here’s a list of engines/libraries that I came across, some are more favoring game, and some are to the visualization (the difference between game and visualization lies in where their interests first originates, IMO). To name a few,
1) NSOpenGLView control in Mac XCode
2) Ogre 3D, game engine, open source
3) Unity 3D, game engine, commercial
4) OpenScenGraph, open source, visualization
5) VTK, open source, scientific visualization
First of all, NSOpenGLView is a native control developed by Apple to have openGL embedded in a native view, which is very nice, and you can find couple of ready to built demos from Online Reference Library, OpenGL section.
While NSOpenGLView is a good place to start, the design is pretty basic at this moment. So I checked some game engine, ex. Ogre 3D. It got very decent resource management, scene construction and utilities that you’ll find handy in 3D space. To be able to use it as a native view in XCode, you need to direct the rendering output to NSView as described in this post and more examples can be found here here, ex. mouse control, etc.
![]()
I mentioned Unity 3D here because I’ve used it for another of my project before. It’s a commercial game engine, very robust, cross platformed, and objects can be controlled through script language. Personally I like it a lot except the fact that it lacks the native GUI controls on OSX. And for this project, it could be very time consuming.
OpenSceneGraph and VTK are two visualization packages that are available to the open source community. Though I didn’t get chance to test them, from what I read from introduction, they contains lot of visualization processing libraries that will come handy if your data needs to be manipulated before plotting.
All in all, for this project, I chose Ogre. And this post will be keep updated as the project unfolds.
Fang
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=4ed55529-ea29-41f2-9f39-da794ba61980)










