views:

5219

answers:

6

I would like to find an iPhone OpenGL ES Example that responds to touch. Ideally it would meet these requirements:

  • Displays a 3D object in the center of the screen like a cube
  • Maps a texture to the cube surfaces
  • Should move the camera around the cube as you drag your finger
  • Should zoom the camera in and out on the cube by pinching
  • Optionally has a background behind the cube that wraps around the back of the camera.(for example this could create the effect of the cube being in space)

Has anyone seen one or more examples that can do these or at least render the cube with the texture?

+1  A: 

I haven't found example code for this exact task, but here's a tutorial about the iPhone touch API. Using the code from there, you should be able to react on touch events. For the graphics, look at this site that contains various OpenGL ES examples.

schnaader
+5  A: 

For sample OpenGL ES code that responds to touch events take a look at the GLPaint sample code from Apple.

Mark Thalman
+12  A: 

My iPhone application Molecules has its source code available via a BSD license. It uses OpenGL ES to render a molecular structure, using single touches to rotate the structure, a pinch gesture for zooming, and simultaneous movement of two fingers for panning across the molecule. Unfortunately, it does not yet use textures for any of the rendering it does.

I document some of the things I've learned about OpenGL ES from it here and here.

Brad Larson
I will have to keep trying but currently I cannot get the molecules download to compile. I was hoping to get it to work in 3.0 but I cannot get 3.0 or 2.0 to compile. Thanks,
Jamey McElveen
What errors are you getting? In any case, here is a link to a preliminary version that will compile using the 3.0 SDK: http://www.sunsetlakesoftware.com/sites/default/files/Molecules-07012009.zip
Brad Larson
Thanks will try that
Jamey McElveen
+7  A: 

Sounds like you're looking for more than one example:

  1. The XCode template "OpenGL ES Application" does this.
  2. This NeHe for iPhone tutorial texture maps a cube.
  3. For this you need the arcball algorithm. Thanks, NeHe.
  4. Here is a pinch tutorial.
  5. Why not place your scene inside a texture mapped cylinder?
    Once again, NeHe to the rescue. Does that guy ever sleep!?!

You're welcome!

Rhythmic Fistman
Good stuff I about have the example working.
Jamey McElveen
Excellent. I graciously accept the bounty.
Rhythmic Fistman
A: 

Hi,

I can recommend this link: http://andreicostin.com/index.php/brain/2009/09/21/iphone_opengl_demo_3d_cube_with_texture_

HTH.

Regards, Andrei

zveriu
A: 

Hi please, may I ask if there is a way I can develop a model in blender and then export it to the xcode or iphone? if there is I will like to know what the processes and procedures are

BUNBA