Contents
Games Demystified: Super Mario Galaxy
 
 
Printer-Friendly VersionPrinter-Friendly Version
 
Latest News
spacer View All spacer
 
November 22, 2009
 
Video Game Watchdog National Institute On Media And The Family Shutting Down [11]
 
Modern Warfare 2 Infinity Ward's 'Most Successful PC Version' Yet [12]
 
New Tech, Design Details Of Project Natal To Emerge At Gamefest In February
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
November 22, 2009
 
Sucker Punch Productions
Character Artist
 
Sucker Punch Productions
3D Environment Artist
 
Sucker Punch Productions
Network Programmer
 
Sucker Punch Productions
Texture Artist
 
Sony Online Entertainment
Brand Manager
 
Monolith Productions
Sr. Software Engineer, Engine - Monolith Productions - #113767
 
Crystal Dynamics
Sr. Level Designer
 
Gargantuan Studios
Lead World Designer
spacer
Latest Features
spacer View All spacer
 
November 22, 2009
 
arrow Upping The Craft: Susan O'Connor On Games Writing [6]
 
arrow Small Developers: Minimizing Risks in Large Productions - Part II [6]
 
arrow iPhone Piracy: The Inside Story [48]
 
arrow And Yet It Grows: Analyzing the Size and Growth of the European Game Market [5]
 
arrow NPD: Behind the Numbers, October 2009 [13]
 
arrow Reflecting On Uncharted 2: How They Did It [5]
 
arrow Sponsored Feature: Rasterization on Larrabee -- Adaptive Rasterization Helps Boost Efficiency
 
arrow Postmortem: Wadjet Eye's The Blackwell Convergence [2]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
November 22, 2009
 
Accepting the Inherent Value of Games
 
Planckogenesis, Part II: Song Structure & Gravy Train [1]
 
Designing Games Is About Matching Personalities [1]
spacer
About
spacer News Director:
Leigh Alexander
Features Director:
Christian Nutt
Editor At Large:
Chris Remo
Advertising:
John 'Malik' Watson
Recruitment/Education:
Gina Gross
 
Features
  Games Demystified: Super Mario Galaxy
by Jeremy Alessi
10 comments
Share RSS
 
 
March 27, 2008 Article Start Previous Page 2 of 4 Next
 

 

As stated above the shapes in the game are often strange and in real life the effects of gravity would probably cause Mario to fall all over himself. In the game however, he always comes out a hero by landing on his feet and in general looking really slick as he traverses the strange surfaces, such as the one below.

Advertisement

Calculating real gravity on a surface like this would be a task best left to Stephen Hawking. However, for the game to play correctly, the developers merely had to cast a ray relatively down from Mario's local center and grab the nearest surface normal.

Inside any 3D game engine worth its salt, there is a list of all polygons being rendered on screen and we can retrieve the first polygon that our ray cast intersects.

That polygon in this case represents our plane and the inverse of its surface normal represents the direction of gravity that will pull Mario smoothly back to the planetoids surface. That polygon's surface normal is also used to align Mario to the curvature of the planetoid.

In the illustration above we can see that the character is aligned to the surface normal of the previously jumped on polygon but the ray cast (dotted line) now intersects another polygon as the player crosses the border from one polygon to the next. In Galaxy, Mario's orientation is adjusted extremely smoothly due to a combination of factors.

First and easiest to understand is that each planetoid in the game is fairly high polygon so the change from one surface normal to another isn't too steep. Additionally, interpolation can be used to smoothly transition from one orientation to the next. So, the surface normals in a Galaxy planetoid are analogous to the key frames of an animation in that regard.

To demonstrate these concepts we'll be looking at some high-level source code we've created - written in Blitz3D, which is an excellent tool for prototyping concepts just like this. You'll need to download a demo or full version of Blitz3D to edit and re-compile the code.

Here's the specially created executable/source code package for Gamasutra readers to try that demonstrates a lot of the concepts used in Galaxy. The source code does a number of things including setup, camera tethering, and rendering.

 
Article Start Previous Page 2 of 4 Next
 
Comments

Soren Andersen
profile image
Funny to see this article now. Three weeks ago we gave up on getting this to work in a HL2 Source mod. We ended up making a flat world instead (se my website link for the mod profile page on moddb.com)

Dan Mitchell
profile image
Excellent article. I cannot wait till the next on Very informative, and educational. I love seeing articles like this, since it helps cut down time on dev time/ research thus allowing others sections of the dev project more time, allowing for even more innovation.

Giuseppe Navarria
profile image
Nice article so far, maybe the tecnique you explained is a bit rought, for example movement will be smoother with normals interpolation, also a simple raycast will lead you in a sea of gameplay glitches...
PS Next time, set your example NOT at 640x480 fullscreen, or it will crash for users without a prehistoric monitor supporting that low resolution, I had to download the source and recompile it running on a window to see your stuff!

Marty Plumbo
profile image
I used a technique very similar to this in Shockwave3D a couple of years back to create my freeware game Microbop (http://gigaplay.com/microbop).

If it can work in Shockwave3D, it can work anywhere! ;-)


Robert Dowling
profile image
This was a great little read. I'm no engineer myself, but it may cut a little research time off my coding partner's schedule.

Andrew Williams
profile image
Great article, this looks like its going to be a great series. On a side note, If anyone is familiar with Sonic Adventure 2 battle, or just Sonic Adventure 2, the space levels in that game seemed to use a very similar technique to what we see in galaxy, however I do believe that to jump from planet to planet required a cannon of sorts. Anyway, great article, hope to see another soon.

paul grenfell
profile image
Good article. Looking forwards to more in the series :)

Now check out Serious Sam's gravity handling. They did it using zones (defined in the level editor) and it works very well. It is also easier to implement well since you don't need to worry about any smoothing. I suspect that SMG may well have used a hybrid of these two approaches.

Jose Eduardo Teran
profile image
Great article; a nice approach for understanding the world of physics in games.

This will help us to acquire some more basic knowledge about gravity and it's use on games, which are very demanding right now.

Keep up the good work, and I want to read the next ones.

Marc Melvin
profile image
I am a little annoyed that I'm just coming across this article today, but I'm also relieved that my method for doing similar logic in a game I was building for Dream.Build.Play using XNA is right on target with the logic used by a previously successful game title.

The only problem I ran into using this method was that snapping an object instantly to a new surface normal sometimes caused its ray to hit the polygon that it was previously using to calculate its up vector (when moving slowly along a "downward" slope, that is). I ended up scrapping this method because of the jittery back and forth effect that it was causing, eventually spiraling the object out of control into oblivion... maybe if I had LERPed the rotation slowly as mentioned in this article, I wouldn't have had the problems that I did.

Oh well... live and learn. Good article! :)

Tom nguyent
profile image

I love mario brother, I used to play all day when i was a kid...missed them :)


none
 
Comment:
 


Submit Comment