Welcome to my Programming Blog...

I am currently working on a couple of projects: An original game called "Implosion" which I am porting from Flash to the iPad, and a remake of Q*bert in Python (pygame), as part of the class I am teaching. Please feel free to use the "Labels" (at right) to follow a specific project or theme. If you are one of my Python students, I recommend that you check out the Python thread.

Sunday, October 17, 2010

#VTM_iPhone notes on moving to 3d

Here are my notes on Michael Daley's presentation on moving to 3D.

A subject that scares the heck out of everybody.

Can do an awful lot without being a genius.

Http://71squared.com
Book: "learning ios game programming"

http://Particledesigner.71squared.com

Sample code is not optimized, for clarity, but still gets good performance.
Prototype project http://tiny url.com/28jp4pm

A turret game - play around with it!

One of first things you need to do to the opengl template is to ad a depth buffer. Added to createframebuffer method. (remove it in delete frame buffer method, too.)

Next must setup the perspective projection to td3dviewcontroller.mm in initOpenGLES1. Then set up the model view matrix. Setup light, fog, etc. In same method.

The math - don't need to be a math or physics genius. But you do need to have some basics, vectors, points, dot produce, cross product, normal. But the work has been done and coded in classes: SSvectorUtil.h,SSMatrixUtil.h
(found in matrix & vector folder in project, if you're curious.)

--------
State management in OpenGL

It will set a state even if the new value is the same as the old. Perhaps encapsulate the OpenGL state machine, which is what Michael has done with OGLState class.
--------
Creating 3d models

Blender. (free)
Jeff lamarche's blog has a great exporter for blender.

Blender can unwrap the shape (to a UV image) or can let you paint the vertices. Export to a png image. Then export the vertices and normals.

Each model's geometry, normal &texture data is loaded into static Vertex buffer objects.
Each model's text is created as an instance of Texture2D

Reuse models and textures where you can.

Michael has created an AssetManager class that keeps track of all these reusable assets.

(A Mipmap contains several images of the same thing that are prescaled down.)

Collisiiion detection - hard to do fast in 3d. But it has been solved. See bullet3d physics engine. (free) put out by a guy at Sony.

When we create an object, we set up it's physics object. In missile.mm class, for instance, initPhysics() method sets up the model for its physics.

Then in the viewcontroller run its initphysics() method. Also sets up a mo course collision detection shape for things - only checks the "tight" collision mesh if the course one has a collision.

Then in the view controller's game loop (update with delta) calculate the physics. Make sure that the physics update is not directly synched to the screen refresh rate.

------
Setting up the camera

To draw objects, you really are moving the world around to center the objects location and drawing it "here" then moving the world to the next object. Then you move the world to center on where the camera is and set it "here."

Ship class - found Internet code on "autonomous steering."

--------
Moving around

When set up game, set up core motion - reads the gyro 1/60 sec. Then in drawFrame method, get the attitude from the gyro and then applying that matrix to the model view.

Q&A: memory management : recommends caching the model. There is no hard/fast rule. Just kept a pool of allocated objects ahead of time and reused over and over again.

- Posted using BlogPress from my iPad

No comments:

Post a Comment