Mario Galaxy game-like
-
- Gnome
- Posts: 334
- Joined: Thu Jun 28, 2007 2:12 pm
- Location: Brazil
- x 5
- Contact:
Mario Galaxy game-like
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 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!
any input is appreciated!
- Pyritie
- Gnome
- Posts: 363
- Joined: Wed Feb 25, 2009 6:15 pm
- Location: UK
- x 8
- Contact:
Re: Mario Galaxy game-like
Could you post a video or something? I don't think all of us have played mario galaxy. (I know I haven't :P)
- Kojack
- OGRE Moderator
- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 534
Re: Mario Galaxy game-like
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.
-
- Gnome
- Posts: 334
- Joined: Thu Jun 28, 2007 2:12 pm
- Location: Brazil
- x 5
- Contact:
Re: Mario Galaxy game-like
i havent either http://www.youtube.com/watch?v=eqOSSr23i6wPyritie 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)
thanks, ill try this!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.
-
- Gnome
- Posts: 334
- Joined: Thu Jun 28, 2007 2:12 pm
- Location: Brazil
- x 5
- Contact:
Re: Mario Galaxy game-like
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)
- KungFooMasta
- OGRE Contributor
- Posts: 2087
- Joined: Thu Mar 03, 2005 7:11 am
- Location: WA, USA
- x 16
- Contact:
Re: Mario Galaxy game-like
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!
- KungFooMasta
- OGRE Contributor
- Posts: 2087
- Joined: Thu Mar 03, 2005 7:11 am
- Location: WA, USA
- x 16
- Contact:
Re: Mario Galaxy game-like
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!
- Kojack
- OGRE Moderator
- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 534
Re: Mario Galaxy game-like
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.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)
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.
- KungFooMasta
- OGRE Contributor
- Posts: 2087
- Joined: Thu Mar 03, 2005 7:11 am
- Location: WA, USA
- x 16
- Contact:
Re: Mario Galaxy game-like
Was my method not feasible/possible, or were you just answering his question?
Creator of QuickGUI!
-
- Gnome
- Posts: 334
- Joined: Thu Jun 28, 2007 2:12 pm
- Location: Brazil
- x 5
- Contact:
Re: Mario Galaxy game-like
thanks!Kojack wrote: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.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)
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.
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 )
i think the problem with this, is to know which directionok 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.
- Kojack
- OGRE Moderator
- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 534
Re: Mario Galaxy game-like
I was answering the question I quoted.Was my method not feasible/possible, or were you just answering his question?
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
- _tommo_
- Gnoll
- Posts: 677
- Joined: Tue Sep 19, 2006 6:09 pm
- x 5
- Contact:
Re: Mario Galaxy game-like
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
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
-
- Gnome
- Posts: 334
- Joined: Thu Jun 28, 2007 2:12 pm
- Location: Brazil
- x 5
- Contact:
Re: Mario Galaxy game-like
ok
here is what i came so far:
considering the game will have perfect spheres i have the movement like this:
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
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());
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
- _tommo_
- Gnoll
- Posts: 677
- Joined: Tue Sep 19, 2006 6:09 pm
- x 5
- Contact:
Re: Mario Galaxy game-like
so the player moves the angle values, that get translated into the linear ones, right?
(if I understood well )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 ).
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
PS: Sorry for the never-ending math post
(if I understood well )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 ).
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
PS: Sorry for the never-ending math post
- volca
- Gnome
- Posts: 393
- Joined: Thu Dec 08, 2005 9:57 pm
- x 1
- Contact:
Re: Mario Galaxy game-like
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)
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)
- Kojack
- OGRE Moderator
- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 534
Re: Mario Galaxy game-like
I posted the same youtube video of psychonauts just 4 posts above yours.
The milkman level of psychonauts rocked.
- volca
- Gnome
- Posts: 393
- Joined: Thu Dec 08, 2005 9:57 pm
- x 1
- Contact:
Re: Mario Galaxy game-like
Damn, I should pay more attention!
The whole psychonauts game was a quality refreshment!
The whole psychonauts game was a quality refreshment!
- test84
- Gremlin
- Posts: 159
- Joined: Fri Nov 14, 2008 8:23 pm
Re: Mario Galaxy game-like
I think this is helpful: http://www.gamasutra.com/view/feature/3 ... mario_.php
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
Re: Mario Galaxy game-like
Hmm... They're just doing a raycast downward from the Player. So you can't really 'jump straight up to a roof'.test84 wrote:I think this is helpful: http://www.gamasutra.com/view/feature/3 ... mario_.php