How to create wolf 3D kind of basic 3D walls in openGL - iphone

I was trying to figure out how I can create simple 3D walls like this in openGL. I dont want to create any fancy stuff just a basic 3D wall where i can move fwd and backwards imagine it as Wolf 3D game with only map no killing etc.
Is there any framework which I can use to do this?? I want to do it in openGL so that I can create/render this thing on my iphone.
Thanks
Pranay
If any body can point me to some sample source code it will be helpful.

As a non-OpenGL alternative, you can construct such a maze and move through it using only Core Animation. The textured wall segments would be CALayers containing images that had been transformed in 3-D to face the appropriate directions. The maze could be translated relative to the camera to cause the user to move through the area. The code for this would be significantly simpler than an equivalent OpenGL ES implementation written from scratch.
An example of this is presented by John Blackburn in his article here.

If you want to use OpenGL, then you have to create everything yourself. But there are several nice 3D engines.
Free:
oolongengine,
Ogre iPhone
Payed (but very powerful):
Shiva3D,
Unity3D

Creating a walk-throug in a 3D space from scratch, isn't basic stuff. It's actually a lot of math.
You will start with the 3D model of the world and in order to put yourself in the perspective of the viewer you have to transform this 3D model with a series of transformations:
The World transformation - Moves the world map
The View transformation - Transforms vertices into camera space
Perspective transformation - Maps 3D space into 2D
Each of those transformations will be defined as a 4x4 matrix. Hope this helps you for a start.

Related

Feasibilty/efficieny of using 3D models for a 2D game

I've been using Unity3D for a while now and I've also had experience coding 2D games using LibGdx.
In the past, I used to get my sprites off the net or make my own however that wasn't really the best way to do things since I'm more of a programmer and would sometimes need very specific things and so I've started to learn blender and I'm actually enjoying it atm.
What I want to know is how much of an overhead is it if you're using 3D models for a 2D game? Especially if you want to port it to mobile?
The overhead is significant for rendering since with a basic sprite, you have 6 vertices (2 tris to make a quad) while a 3d model can have hundreds of thousands of vertices.
The advantage on the other hand is that animations are made of sprites, so your texture amount and size may increase. In 3D, an animation is a text file so fairly light.
The physics is simplified in 2D since you can do surface collision while 3D requires volume collision and obviously checking an extra dimension is more expensive.
There are probably other considerations but those are the first coming in mind.
Now, the choice of 3D over 2D should be simply based on what you are trying to achieve. Side scrolling games like Angry Birds do not need 3D. Games like Taichi Panda are better with 3D despite being a 2D game (only x and z camera movement I think).
A FPS game should only be done in 3D or it will look like Duke Nukem.

How can I smooth texture objects in OpenGL ES 1.1 (iPhone)

I'm currently experimenting with OpenGL ES 1.1 on the iPhone and trying to get my head around some of the basics. So far I've managed to draw a grid of objects which are lit with one GL_LIGHT. Here is a screenshot of the current output (question to follow)...
So you can see that my test consists of a grid of about 140 cubes - some slightly elevated so I can see how the shaded areas work. Each cube consists of this model (from Blender) and have normals / texture coordinates...
What's puzzling me, is why I don't get a 'uniform' lighting across the entire surface. Each cube seems to be lit individually and I can kind of understand why that would be... but is it not possible to have the light transition 'normally' like it would if you arranged this model out of blocks and shone a light across it. I'd expect to not see a dark edge on each individual cube, but rather a smooth transition across the whole area.
(I'm still inwardly chuffed that I managed to get this far!)
Any help or explanations would be awesome.
Thanks,
Simon
The reason why you don't get 'uniform' lighting is because I presume you are using per vertex lighting. That is the lighting is calculated per vertex and interpolated over each triangle making up the model. Since your cube has a pretty low polygon count the transition of light across the model won't look smooth.
Using OpenGL ES 1.1 there are two solutions to this. You can use higher polygon count models or implement per-pixel (DOT3) lighting. I've not implemented this myself but have come across this problem before (my solution was to switch to OpenGL ES 2.0 and use shaders to perform per-pixel lighting).
Here is a link, which may be of use: What is DOT3 lighting?
All the best!

quartz 2d / openGl / cocos2d image distortion in iphone by moving vertices for 2.5d iphone game

We are trying to achieve the following in an iphone game:
Using 2d png files, set-up a scene that seems 3d. As the user moves the device, the individual png files would warp/distort accordingly to give the effect of depth.
example of a scene: an empty room, 5 walls and a chair in the middle. = 6 png files layered.
We have successfully accomplished this using native functions like skew and scale. By applying transformations to the various walls and the chair, as the device is tilted moved, the walls would skew/scale/translate . However, the problem is since we are using 6 png files, the edges dont meet as we move the device. We need a new solution using a real engine.
Question:
we are thinking of instead of applying skew/scale transformations, that if given the freedom to move the vertices of the rectangular images, we could precisly distort images and keep all the edges 100% aligned.
What is the best framework to do this in the LEAST amount of time? Are we going about this the correct way?
You should be able to achieve this effect (at least in regards to the perspective being applied to the walls) using Core Animation layers and appropriate 3-D transforms.
A good example of constructing a scene like this can be found in the example John Blackburn provides here. He shows how to set up layers to represent the walls in a maze by applying the appropriate rotation and translation to them, then gives the scene perspective by using the trick of altering the m34 component of the CATransform3D for the scene.
I'm not sure how well your flat chair would look using something like this, but certainly you can get your walls to have a nice perspective to them. Using layers and Core Animation would let you pull off what you want using far less code than implementing this using OpenGL ES.
Altering the camera angle is as simple as rotating the scene in response to shifts in the orientation of the device.
If you're going to the effort of warping textures as they would be warped in a 3D scene, then why not let the graphics hardware do the hard work for you by mapping the textures to 3D polygons, then changing your projection or moving polygons around?
I doubt you could do it faster by restricting yourself to 2D transformations --- the hardware is geared up to do 3x3 (well, 4x4 homogenous) matrix multiplication.

Tutorial for texture mapping a map onto an Open GL ES sphere?

I'm not looking for a library or even open source code. I want to learn how to do this on my own.
Where do I start to find an online tutorial, a book chapter, or other educational material for generating a polygonal model of a 3D sphere suitable for feeding to Open GL ES on an iPhone, and then mapping the polygons to some sort of 2D map data so I can texture map the sphere? Is there some sort of software tool (blender? maya?) with a tutorial on how to do generate this data? Where is the best place to start?
How about these articles?
Procedural Spheres in OpenGL ES
OpenGL ES From the Ground Up, Part 6: Textures and Texture Mapping
I've heard good stuff about "iPhone 3D Programming". Jeff LaMarche also recommends it here.
Hope this helps!
While not OpenGL ES, I once tried porting across the examples from this chapter in the Red Book where they show how to create an icosahedron and subdivide it to produce smooth spheres. I only got as far as using a simple icosahedron to crudely represent a sphere in the code for my Molecules application. Perhaps you could extend that.
Apple has a Mac sample application, GLSLShowpiece, that textures a sphere in a couple of places, but they use gluSphere() to generate the sphere vertices, which is unavailable in OpenGL ES.
To be honest, I'm in the process of replacing the sphere rendering code in Molecules with a 2-D billboarding approach that uses shaders to generate the sphere coloring. This should allow for far smoother spheres without having to resort to massive amounts of geometry. See this paper for the kind of results you can produce this way.

Is there an tutorial on loading an 3D model in openGL ES on the iPhone?

I've started to play around with some 3d modelers a while ago. Now I'm curious: How can I bring such an 3D model to the iPhone or iPad, so that I can see it on screen and maybe even rotate it with gestures?
1) What's the best file format for the 3D models?
2) How would I load a particular 3D model file into openGL ES and then render it?
3) How would I apply an material to the polys, i.e. to make the model appear red?
4) Does the model have some sort of center or pivot point where I can rotate it easily around? Or do I need incredible freakin' math skills to transform all the vertecies in 3D space myself? How hard is it to rotate something?
5) Can I scale models or fit them into the camera viewport? How hard is that to do? Freakin' awesome math skills needed?
5) Does openGL ES support some kind of shader tree model with gradients and effects that can be applied to the model or material?
Would be so happy if someone can point out an quick starting guide for people who know 3D, but don't know OpenGL ES. Maybe someone already made a great tutorial on this topic?
How about Using 3D Models from Blender in OpenGL ES.