Hello
I am actual making a space game where the player is on a little planet. Because the Planet is round and the the player should go all over the planet, the planet must pull the player at it. So it must have a own gravity.
At this moment I dont have implemanted any Physic Engine. (Iam thinking about Newton or Bullet)
Do anyone now a physic engine which can handle this sort of gravity? Or can I easiely implement it in irrlicht itself?
Thanks for help
Feuerstern
Physic for Space Game (walk at planets)
-
- Posts: 105
- Joined: Mon Jun 02, 2014 2:32 am
- Location: Washington, D.C.
- Contact:
Re: Physic for Space Game (walk at planets)
Hi, Feuerstern.
There should be several tutorials on physics integration at:
http://irrlicht.sourceforge.net/tutorials/
Look towards the bottom of the page, and you should find several options available (I believe Newton is included as well).
There should be several tutorials on physics integration at:
http://irrlicht.sourceforge.net/tutorials/
Look towards the bottom of the page, and you should find several options available (I believe Newton is included as well).
My blog: http://fsgdp.wordpress.com "The Free Software Game Development Pipeline"
Re: Physic for Space Game (walk at planets)
All larger physics engines (Bullet, PhysX) implement "force fields" which are ideal for gravity.
Just be aware to not add to many objects with "gravity" because you'll soon turn this into an N-Body problem which is a task for supercomputers.
Just be aware to not add to many objects with "gravity" because you'll soon turn this into an N-Body problem which is a task for supercomputers.
Re: Physic for Space Game (walk at planets)
Hi Feuerstern.
If you just need to keep your characters walking around the planet and not shoot boxes or drop objects, may be you can use this approach I used in my little simulation of a planet.
I'm using this code for moving my characters around the planet:
I hope it can be usefull
If you just need to keep your characters walking around the planet and not shoot boxes or drop objects, may be you can use this approach I used in my little simulation of a planet.
I'm using this code for moving my characters around the planet:
Code: Select all
void update()
{
//set the character position on the planet, without rotations
CharacterNode->setPosition(AIEntity->getAbsolutePosition());
//get the actual position
irr::core::vector3df curPoint = CharacterNode->getPosition();
//get the destination position (this is using irrAI but it can be ported to another navigation system)
irr::core::vector3df nextPoint = ((INPC*)AIEntity)->getCurrentWaypoint()->getPosition();
//set the Z direction
irr::core::vector3df worldDirection(0,0,-1);
//and the Y direction
irr::core::vector3df inverseUp(0,-1,0);
irr::core::vector3df masterUp = curPoint - inverseUp;
masterUp.normalize();
//this is the direction vector, with this, we calculate the others rotations
irr::core::vector3df masterDirection = nextPoint - curPoint;
irr::core::vector3df realDirection = masterUp.crossProduct(masterDirection).normalize();
realDirection = realDirection.crossProduct(masterUp);
irr::core::quaternion quatDirection;
quatDirection.rotationFromTo(worldDirection, realDirection);
irr::core::vector3df worldUp(0,1,0);
irr::core::matrix4 mat;
quatDirection.getMatrix(mat);
mat.rotateVect(worldUp);
irr::core::quaternion quatUp;
quatUp.rotationFromTo(worldUp,masterUp);
//merge the rotations in one
irr::core::quaternion quatAll = quatDirection * quatUp;
irr::core::vector3df eulers;
quatAll.toEuler(eulers);
//convert the quaternions in eulers
eulers *= irr::core::RADTODEG;
CharacterNode->setRotation(eulers);
}