5

For my new app, I want to have a native iOS or Android UI, plus a 3d view that shows some graphs. While my initial plan to use CSS transforms in a WebView to achieve the desired 3d effect has failed because the performance was not anywhere near usable, I'm looking for another solution. Here are what I think are my options:

1. Recreate the scene in OpenGL ES
I'd recreate our graphing engine completely in OpenGL. This would certainly be possible, but probably be very hard to do for people like me who actually never did 3d programming before. Would it be possible to port OpenGL code written for iOS to Android? Or would I have to create the engine twice?

2. Use readymade 3d engine like Unity3d
I stumbled over Unity3d, Marmalade and similar tools that would probably help me create the 3d scenes more easily. However, it seems at a first glance like I would have to create the entire application in the respective authoring system. I'd to use native controls for anything except the 3d view. Is that possible in those tools? If yes, is it possible to port the 3d from iOS to Android or vice versa?

Did I ask the right questions; did I make the correct assumptions? Does anything sound wrong to you? What did I miss?

Are these all the options I have? Or is there maybe something else, a hybrid solution of some sorts?

Which option should I choose?

Edit: To clarify, I don't want to show iOS or android controls inside the 3d view, but rather around it: The user interface would be native and the 3d part would be contained inside one view.

winsmith
  • 20,791
  • 9
  • 39
  • 49

1 Answers1

2

Pretty complex one ;-)

(1) OpenGL vs. engine:

I think it would be possible to write the major part of the OpenGL code in a way that it is portable for example in C++ using Objective-C++ on iOS and NDK on Android (just an idea, never used NDK). Now it depends on the graphical part where to go. If you say graphs, do you mean you "only" need function graphs to plot on the screen? Or do you have more objects like in games or architectural apps to display in OpenGL?

If the latter is the case, the bigger problem appears to be the seamless integration of models. Every scene containing more than some cubes is designed in a modelling tool and can be exported into several formats (obj, dae, fbx, ...). But then you need to import it into your app. That's where game engines come to play regardless whether Unity, SIO2, Bork, Unreal, Oolong, ...

If you need to plot graphs, the manual OpenGL solution might be worth to consider. Although even then some research on existing engine maybe useful because OpenGL isn't that intuitive and you will need some time to make friends. I did plotting multiple graphs with zooming, coloring, ... in an iPhone app using OpenGL directly but it was a pure research project and portability was less important.

(2) Mixing OpenGL with GUI elements

Basically it's not possible to display a standard UIButton within an OpenGL view. But you can have OpenGL views and regular UI views and switch between them. I don't know of any tool that allows you doing both OpenGL based stuff and regular GUI programming and further on platform independent.

So on one hand you need to create your 3D stuff in the tool of your choice and then integrate native UI code. For Unity and iOS there some resources how to do it How to access Unity assets natively on Android or iPhone? or Mixing Unity generated code with Objective-C in iOS?

On the other hand you will need a platform independent framework to get regular GUI programming done so that you can run it on both Android and iOS. I am not familiar with this topic but I've heard from Mono based frameworks.

Community
  • 1
  • 1
Kay
  • 12,918
  • 4
  • 55
  • 77
  • To clarify, I don't want to show iOS or android controls inside the 3d view, but rather around it: The user interface would be native and the 3d part would be contained inside one view. Would that make integrating a 3d engine easier? – winsmith Dec 13 '11 at 12:55
  • 1
    Complex 3D world: Yes because of model integration. Function graph plotting only: Depends, because even 3D engine has a learning curve and they fit best for modelled scenes i.e. they are not specialised in the plotting area, although it should be possible (s. http://forum.unity3d.com/threads/40787-Can-we-draw-graph-in-unity). Note that I've only experience with Unity3D and a tiny bit of SIO2 – Kay Dec 13 '11 at 13:13
  • Would it be possible to share the code for the app you created? I wouldn't use it directly, but maybe it could give me an idea which way would be better suited. The 3d content consists of nothing but cylinders for bar charts plus some line graphs. – winsmith Dec 13 '11 at 13:41
  • It was research bound to NDA regarding the contents. But I am going to have a look at the pure grahics part maybe I can extract some classes (native Obj-C). There is a sample http://developer.apple.com/library/ios/#samplecode/AccelerometerGraph/Introduction/Intro.html . It doesn't use OpenGL but Quartz2D – Kay Dec 13 '11 at 13:56
  • 1
    I think it's almost useless for you http://dl.dropbox.com/u/658954/GLGraphClasses.zip But the correct sequence of steps in method render might be interesting. Note that I had continuous input of sensor data and a strong need for performance, that's why I used this rolling array approach. – Kay Dec 13 '11 at 14:07