iPhone Next Step

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

iPhone Next Step

Post by ibly31 »

Hi Guys.

So I've been working on iPhone stuff for a while. Mostly 2D... well entirely 2D. I've made a few demo apps in 3D, but those don't really count. I've recently been doing some cool generation stuff like fractal terrain (skyline style 2D, not 3D) and I feel like I'm ready to take the next step and do some 3D. I do not have the iPhone 4 yet, but when I do I plan to start full speed ahead with 3D games. But, in the mean time I'd like to get started with the basics.

I know what (most) of the popular 3D techniques are, and I've been studying up on shaders. I just don't really know how to go about it... if someone could give me a list of the essential skills in the order I should learn them, I would be very appreciative.

Also, if you've done 3D stuff extensively, I'd be very interested to hear your approach/method/history/funny things that happened to you while learning.

Thanks!
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
EccentricDuck
Chaos Rift Junior
Chaos Rift Junior
Posts: 305
Joined: Sun Feb 21, 2010 11:18 pm
Current Project: Isometric "2.5D" Airship Game
Favorite Gaming Platforms: PS2, SNES, GBA, PC
Programming Language of Choice: C#, Python, JScript
Location: Edmonton, Alberta

Re: iPhone Next Step

Post by EccentricDuck »

Understand matrix transforms and how they relate to rendering objects in 3D. In particular, understand the idea of creating matrices for scaling, rotation, and translation; how those can be multiplied together to create a world matrix; and how view and projection matrices manipulate that to transform all the vertices in your model to their appropriate location on a flat viewport (what shows up on your monitor). Understand the idea that multiplying matrices in different orders gives you different results (this is actually quite intuitive once you understand what the matrices represent), then learn how to create/manipulate them using whatever 3D framework you are using. If you have a decent grasp of matrices/linear algebra then you could write your own operations - though I'm not sure why you'd want to.

Read the very beginning of this (and maybe follow the code examples, though they're in C# using XNA):
http://rbwhitaker.wikidot.com/basic-matrices

As an example, say you have an unscaled character facing the direction that it was loaded in and it is at the point (0,0,0). You could create the instructions to render your character by translating those things into matrices. There should be defined operations to do this for you. With default scale, rotation, and position, I believe all your matrices would be "identity" matrices. You could multiply these three matrices together to construct a world matrix which holds information about it's orientation in the world relative to the point (0,0,0) (which would also be an "identity" matrix - it's the equivalent of multiplying 1 by 1 by 1 with ordinary numbers).

If you were scaled to be twice as big, rotated 45 degree, and in the position (2,0,0), you would do exactly the same thing. You would use your framework to construct those matrices (scale, rotation, and translation), then multiply them together in that order (scale * rotation * translation) to give you your character's world matrix. To think about why you do it in that order, imagine your character was an action figure whom you physically manipulated into place (maybe make him a full-sized Antonio Banderas blow up doll (see SouthPark for reference ;) )). Starting unrotated and at whatever starting point you define as (0,0,0), blow the doll up to twice it's current size (moving its "vertices" twice as far from the origin). Think of blowing it up as increasing whatever changes have been made to it. Now, rotate it 45 degrees about the vertical axis running perpendicular to its spine. Now, move it over "2 units". Fine, right? It's now where you want it.

By contrast, try implementing those in a different order. Let's do translation, scale, rotation. You move it over "2 units", fine. Now, when you blow it up, it has the effect of moving all vertices twice as far away from the origin, thus doubling the translation (to "4 units"). Next, you rotate it about the vertical axis, only this time, rotating by 45 degrees rotates it in a big arc from its current position "4 units" from (0,0,0) to another point "4 units" from (0,0,0) that's rotated 45 degrees as if going around a big circle.

Learn to work with vectors if you haven't. Learning about basic vector addition/subtraction, multiplication, and dot/cross products will make working in 3D far easier.

Sorry if you already knew all about matrix transformations - I realize I probably should have waited to see your response first.
User avatar
EccentricDuck
Chaos Rift Junior
Chaos Rift Junior
Posts: 305
Joined: Sun Feb 21, 2010 11:18 pm
Current Project: Isometric "2.5D" Airship Game
Favorite Gaming Platforms: PS2, SNES, GBA, PC
Programming Language of Choice: C#, Python, JScript
Location: Edmonton, Alberta

Re: iPhone Next Step

Post by EccentricDuck »

Sorry if I piled that stuff on too hard. I know I mostly focused on the mathematics of 3d and I may have been a bit blunt. You can pick up a lot of that stuff as you go. As for matrices, it's more important to understand the basic concepts of what they mean and how to work with whatever library uses them. You don't necessarily need to know the details of how they work (it'll help over the long term, but baby steps, if you just want to get something cool working in 3d then you're fine just to learn the library). Vectors are pretty straight-forward before you get into things like dot/cross products. Those things are useful, but once again, not entirely necessary (not for just rendering something to the screen or even creating something simple in 3d). You can pick those up and learn them as you go.

Maybe the best thing I can say is, if you want to go for it, "You can do it!"
Post Reply