Jump to content
  • Advertisement

Archived

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

shadow12345

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.

If you intended to correct an error in the post then please contact us.

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,
				and then updates the velocity 
			*/
			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.UpdateSound();

			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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!