Mario Galaxy game-like

Get answers to all your basic programming questions. No Ogre questions, please!

Mario Galaxy game-like

Postby dudeabot » Thu Mar 12, 2009 3:24 am

hello, on "normal" games the gravity usually is (0,-1,0), but how would one work to get a gameplay like Mario Galaxy? Considering it would be possible to use any mesh shape (mostly spheric). I was trying to get a general algorithm idea, but i think my physics are bad :P first, i though about it would be possible to stick with the (0,-1,0), like a localized physics, but how would it be to move the character through the surface?

any input is appreciated!
dudeabot
Gnome
 
Posts: 334
Kudos: 6
Joined: 28 Jun 2007
Location: Brazil

Re: Mario Galaxy game-like

Postby Pyritie » Thu Mar 12, 2009 1:30 pm

Could you post a video or something? I don't think all of us have played mario galaxy. (I know I haven't :P)
I use Mogre, BulletSharp, LuaNetInterface, irrKlang, and Miyagi! | Ponykart (Showcase)
Image
User avatar
Pyritie
Gnome
 
Posts: 363
Kudos: 8
Joined: 25 Feb 2009
Location: UK

Re: Mario Galaxy game-like

Postby Kojack » Thu Mar 12, 2009 3:41 pm

If you find the closest vertex on the mesh to your current position and use the reverse of it's normal as the gravity. This should let you run over uneven terrain (as you run up the side of a mountain gravity shifts so it's like you are on flat ground), and even orbit it if you move fast enough and jump. :)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
 
Posts: 7126
Kudos: 516
Joined: 25 Jan 2004
Location: Brisbane, Australia

Re: Mario Galaxy game-like

Postby dudeabot » Thu Mar 12, 2009 4:34 pm

Pyritie wrote:Could you post a video or something? I don't think all of us have played mario galaxy. (I know I haven't :P)


i havent either :P http://www.youtube.com/watch?v=eqOSSr23i6w

If you find the closest vertex on the mesh to your current position and use the reverse of it's normal as the gravity. This should let you run over uneven terrain (as you run up the side of a mountain gravity shifts so it's like you are on flat ground), and even orbit it if you move fast enough and jump.


thanks, ill try this!
dudeabot
Gnome
 
Posts: 334
Kudos: 6
Joined: 28 Jun 2007
Location: Brazil

Re: Mario Galaxy game-like

Postby dudeabot » Thu Mar 12, 2009 5:46 pm

hmm how would i go to get the nearet vertex, do a raycasting? if so where to shoot the raycast from (i assume somewhere near the player, but the terrani isnt flat)
dudeabot
Gnome
 
Posts: 334
Kudos: 6
Joined: 28 Jun 2007
Location: Brazil

Re: Mario Galaxy game-like

Postby KungFooMasta » Thu Mar 12, 2009 7:31 pm

You could try keeping track of the current 'body' the character is associated with, and pull the characters towards the body at all times. Every time the character touches a body, it updates the body associated with the character. I think this would only work well for spherical bodies, you would need other rules for non-spherical ones.
Creator of QuickGUI!
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
 
Posts: 2087
Kudos: 16
Joined: 03 Mar 2005
Location: WA, USA

Re: Mario Galaxy game-like

Postby KungFooMasta » Thu Mar 12, 2009 7:42 pm

ok I watched the video. I think you can just assume the character is always upright, and pull him down according to his local NEGATIVE_UNIT_Y direction. If he is not always upright, you can track the last upright position and pull him in the previous local NEGATIVE_UNIT_Y direction.
Creator of QuickGUI!
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
 
Posts: 2087
Kudos: 16
Joined: 03 Mar 2005
Location: WA, USA

Re: Mario Galaxy game-like

Postby Kojack » Thu Mar 12, 2009 9:33 pm

hmm how would i go to get the nearet vertex, do a raycasting? if so where to shoot the raycast from (i assume somewhere near the player, but the terrani isnt flat)

Get access to the terrain's vertex buffer (you can do that from an entity, various places on the wiki and forum talk about it). Loop through each vertex and test it's distance to your position (simple vector magnitude) to find the closest. Now set your gravity to be the negative of that vertex's normal and rotate your model (and camera) to be upright relative to the normal.
Of course for a detailed landscape that could become slow, and every free moving physics body will need to do the same thing to get their own local gravities, so it might be wise to create an octree of the terrain so you can quickly look up a small number of vertices around your current position instead of testing all of them.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
 
Posts: 7126
Kudos: 516
Joined: 25 Jan 2004
Location: Brisbane, Australia

Re: Mario Galaxy game-like

Postby KungFooMasta » Fri Mar 13, 2009 12:21 am

Was my method not feasible/possible, or were you just answering his question? :P
Creator of QuickGUI!
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
 
Posts: 2087
Kudos: 16
Joined: 03 Mar 2005
Location: WA, USA

Re: Mario Galaxy game-like

Postby dudeabot » Fri Mar 13, 2009 1:30 am

Kojack wrote:
hmm how would i go to get the nearet vertex, do a raycasting? if so where to shoot the raycast from (i assume somewhere near the player, but the terrani isnt flat)

Get access to the terrain's vertex buffer (you can do that from an entity, various places on the wiki and forum talk about it). Loop through each vertex and test it's distance to your position (simple vector magnitude) to find the closest. Now set your gravity to be the negative of that vertex's normal and rotate your model (and camera) to be upright relative to the normal.
Of course for a detailed landscape that could become slow, and every free moving physics body will need to do the same thing to get their own local gravities, so it might be wise to create an octree of the terrain so you can quickly look up a small number of vertices around your current position instead of testing all of them.


thanks!
though i was thinking it will find some possible solutions, and it has to be decided accordingto movement direction (have to do some math here :|)

ok I watched the video. I think you can just assume the character is always upright, and pull him down according to his local NEGATIVE_UNIT_Y direction. If he is not always upright, you can track the last upright position and pull him in the previous local NEGATIVE_UNIT_Y direction.


i think the problem with this, is to know which direction
dudeabot
Gnome
 
Posts: 334
Kudos: 6
Joined: 28 Jun 2007
Location: Brazil

Re: Mario Galaxy game-like

Postby Kojack » Fri Mar 13, 2009 6:32 pm

Was my method not feasible/possible, or were you just answering his question? :P

I was answering the question I quoted. :)
Not saying your method won't work too, that's just my guess at how it could be done (having never played the game either, although my students did modify their Mawashi Madness game to turn into Mario Galaxy using multiple spherical gravities in Bullet.

Another game with cool gravity effects is Psychonauts.
www.youtube.com/watch?v=IRgMyLCiRpo
User avatar
Kojack
OGRE Moderator
OGRE Moderator
 
Posts: 7126
Kudos: 516
Joined: 25 Jan 2004
Location: Brisbane, Australia

Re: Mario Galaxy game-like

Postby _tommo_ » Fri Mar 13, 2009 7:52 pm

I think that Mario Galaxy doesn't use exactly the algorithm described by Kojack as it couldn't work in the actual game... or at least iw would be much more slow and limited.
a small example, using that you could climb any wall, and you couldn't have at all slopes!
Instead in Mario galaxy you are often on slopes, even if the gravity is "curved".

I think instead that they use "Point", "plane" and "mesh" gravity types:

-plane is the gravity we know, used in some portions of the game world;

-point attracts everything to a single point, suited for spheres; often planets like this have some slopes and vertical steps on them, bent on the surface of a sphere; note that this way they are vertical relative to the surface of the planet, and mario slows down to walk on them, or can't at all.
Example: the small bumps and houses on the tutorial planet. Mario's normal IS NOT always the surface normal there.

-mesh is a gravity that uses the algorithm described by kojack on a special Gravity mesh; the mesh is not a simple low poly version of the planet, instead it models the direction of the gravity at each point of the "planet", so that it lacks vertical step or slopes, so that mario can't climb everything like a spider.

At least this is the idea i had after collecting 242 stars :lol:
OverMindGames Blog
IndieVault.it: Il nuovo portale italiano su Game Dev & Indie Games
User avatar
_tommo_
Gnoll
 
Posts: 677
Kudos: 3
Joined: 19 Sep 2006

Re: Mario Galaxy game-like

Postby dudeabot » Mon Mar 16, 2009 12:26 am

ok

here is what i came so far:

considering the game will have perfect spheres i have the movement like this:

Code: Select all
      
                x= rho * cos(Degree(theta).valueDegrees()) * sin(Degree(phi).valueDegrees());
      y= rho * sin(Degree(theta).valueDegrees()) * sin(Degree(phi).valueDegrees());
      z= rho * cos(Degree(phi).valueDegrees());


rho is the radius of the sphere, Theta (The angle of rotation around the Z axis, where 0 degrees means parallel to the x axis) and Phi (the angle of declination from the Z axis ).

however theres still some issues
the movement doesnt take in account the character orientation, and talking about orientation, how would i align the upvector of the charcater,

for example, i have "currentNormal", and rotate a bit around the sphere, will have a "newnormal" i have to rotate the character to match that normal and align his upvector

im not sure how to do this, i though of getting the perpendicular vector of the normal vector(crossproduct), but there are infinite solutions

i hope it sounded clear :)
dudeabot
Gnome
 
Posts: 334
Kudos: 6
Joined: 28 Jun 2007
Location: Brazil

Re: Mario Galaxy game-like

Postby _tommo_ » Mon Mar 16, 2009 3:23 pm

so the player moves the angle values, that get translated into the linear ones, right?

(if I understood well :roll: )I think that this is bad for several reasons...
the first is that you should get heavy gimbal lock problems;
the second is that on the "equator" of the sphere your character moves faster than at other latitudes: this because given the same angle, the lenght of its arc of sphere surface increases with the distance from the poles.
So your character moves differently on different regions of your spheres.

For me you should tackle the problem at its origin, and with ogre (and its scene nodes) it should be easy:
in fact the complication is that the "parent node" of the player, in normal games, is directly the Root Node, and because of that you can reason in absolute values.
Instead, here the coordinate system of the player moves according to the surface of the sphere the player stands on.

So, you should create a "system" scenenode wich is the coordinate system of the player, that is placed exactly on the surface where the player is, and which up-vector is the surface normal (it's difficult to explain without an image :roll: ).
Then you have a "player" scene node attached to this one, so that you can translate and rotate the player just like in a normal game (except that to walk you need to move the parent node).

To place the "parent" you need only to rotate via quaternions the radius vector, similar to what you are doing now. Then you set its upvector to the normalized radius.
To orientate or make jump the player you can yaw pitch, roll or traslate the "player" node just as usual.

This way is Ogre that handles your math... so you should avoid many nasty glitches :wink:

PS: Sorry for the never-ending math post :lol:
OverMindGames Blog
IndieVault.it: Il nuovo portale italiano su Game Dev & Indie Games
User avatar
_tommo_
Gnoll
 
Posts: 677
Kudos: 3
Joined: 19 Sep 2006

Re: Mario Galaxy game-like

Postby volca » Tue Mar 17, 2009 12:19 pm

Why won't you define gravitational shapes of the small "planets" - the gravitational force can be then calculated using a method of the given shape (given the position of an object). The upvector for character is inverse normalized version of gravitational force no matter what happens - just make the physics so the character will have the tendency to rotate feet down. Movement of the character will then be relative to it's upvector.

Or just use the normal, but that could cause some problems with bad tesselation or other than sphere shapes (like cube or torus) - especially when jumping.

This reminds me of Psychonauts - especially Milkman conspiracy level (http://www.youtube.com/watch?v=IRgMyLCiRpo)
Image
User avatar
volca
Gnome
 
Posts: 393
Kudos: 1
Joined: 08 Dec 2005

Re: Mario Galaxy game-like

Postby Kojack » Tue Mar 17, 2009 3:12 pm

:)
I posted the same youtube video of psychonauts just 4 posts above yours. :)

The milkman level of psychonauts rocked.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
 
Posts: 7126
Kudos: 516
Joined: 25 Jan 2004
Location: Brisbane, Australia

Re: Mario Galaxy game-like

Postby volca » Tue Mar 17, 2009 3:14 pm

Damn, I should pay more attention!

The whole psychonauts game was a quality refreshment! :)
Image
User avatar
volca
Gnome
 
Posts: 393
Kudos: 1
Joined: 08 Dec 2005

Re: Mario Galaxy game-like

Postby test84 » Fri Mar 20, 2009 12:46 am

User avatar
test84
Gremlin
 
Posts: 159
Kudos: 0
Joined: 14 Nov 2008

Re: Mario Galaxy game-like

Postby nikki » Sat Mar 21, 2009 2:45 pm

test84 wrote:I think this is helpful: http://www.gamasutra.com/view/feature/3 ... mario_.php

Hmm... They're just doing a raycast downward from the Player. So you can't really 'jump straight up to a roof'. :)
User avatar
nikki
Old One
 
Posts: 2730
Kudos: 13
Joined: 17 Sep 2005
Location: Princeton, New Jersey, USA


Return to Back to Basics

Who is online

Users browsing this forum: No registered users and 2 guests