Archived

This topic is now archived and is closed to further replies.

representing physics is driving me mad

This topic is 5240 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I''ve got an elaborate entity system. Right now entities can collide with each other, and I''ve got perfect collision detection. I''m trying to setup a physics loop that takes into account: -Time Base movement (already implemented) -Inter-object forces (so that when objects hit each other you calculate the forces, and modify their velocities) -Linear and rotational physics (which is calculted in the inter object collisions) I''m trying something like this in my GameCycle function (which is run each frame by the engine):
//The module that must be used when interacting with the engine: updates all of the entities,

//collects and handles all messages/commands

void	MainGameCycle()
{
unsigned	int	time	=	timeGetTime();
if((float)(time - Export.mFPS.LastTimeBufferSwapped) >= (float)(1000/151))
{

Export.mKeys	=	Export.CheckKeyBoard();
Export.mFPS.UpdateFPS();
Export.mFPS.LastTimeBufferSwapped = time;

/*
-Gather input, run AI
*/
Export.UpdateEntities();

/*
-Ideally BeginPhysics sums all of the forces on an object,
*/
Export.BeginPhysics();

/*
-Ideally ActOnPhysics should actually try moving the object, BUT
once you hit another object the velocity changes, and this must be taken into account
somewhere
*/
Export.ActOnPhysics();

Export.pRenderScene();

//FIXME: shouldn''t pRenderScene swap the buffers?

SwapBuffers(Export.hDC);
Export.HandleCommands();	//Check for map changes, killing entities and removing

//them from the world (and cleaning up memory)

}
}

What I''ve got right now is, each entity is Updated, then I''ve got two functions which start and end the physics queue. However, this idea isn''t great, because BeginPhysics would check the keyboard and calculated the ideal velocity, then ActOnPhysics would try to move each object, but then if the object collides with another both of their velocities must be modified taking into account their masses and linear and rotational displacements. This is driving me mad how to represent this in code. The ironic part is it isn''t hte math that''s giving me trouble.

Share on other sites
Can someone point me to some physics sources? Im trying to read http://www.physicsengine.com/, but it doesn''t work. I''ve downloaded oliii''s code, and I see how his physics works, but it''s very specific applications. I''ve also downloaded physics code from a digipen student, but again it''s too specific. I.e it''s the source on how to topple sticks (stacked as dominos) based on rotational torques. Does anybody have any sources of very generalized physics stuff?

Share on other sites
Try here http://examples.oreilly.com/physicsgame/

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 18
• Forum Statistics

• Total Topics
632161
• Total Posts
3004505

×