Original Post
Hello everyone,
I am not entirely sure this is the correct board to post this to, since it is more a design question than an actual physics question. If so, please move my ramblings to where-ever they should be
For the past month I've been working on a simple 2D Engine using XNA 4.0 and Irrklang for audio. It's more or less finished, apart from the physics. Because of the simplicity of the first few games I have in mind for which I will use this engine I do not require more than the very basics of Physics such as collision detection between rectangles and spheres. (that's basically it) I've been working on it quite a bit and slowly but surely it's taking shape. My main question really is, what are some "good" ways to bring all the theory and all the classes together in a solid physics framework. What I mean is, I have a class Body, a class Shape and a class World.
World contains information such as the Gravity, etc, and also all the Physics Bodies currently in the scene. Bodies have properties such as acceleration, velocity and position and Shape is the shape of the object. (for now limited to circular and rectangular) I've created game engines in the past but I've never had to work with a Physics Engine from scratch and to my dismay I didn't get the opportunity to properly work with them at my internship either. As such I am not sure that my approach is the correct one.
So far I have a single Physics World which is updated (it's an XNA game component) and which in turn updates Bodies who apply their velocities. I am mostly stuck on where and when to check for collisions. Do I check if objects colide right after translating one? Or do I simply translate everything and THEN check for possible collisions. (the latter, I think, would give problems when two fast moving objects just pass one another by) Also, what is a good way to handle these collisions? Do I use events to which objects using the PhysicsBody subscribe? Or are there "better" ways of doing this?
I hope I am making sense with this, because as you can probably see, creating an easy-to-use, fluent Physics Engine isn't exactly something I have done before. I am not really having any problems with the maths aspect of it, but simply plugging it all into my engine properly is causing hiccups on my part.
If anyone knows of any good tutorials pertaining to this quite specific problem I would be very grateful for being pointed in the right direction. I'm also well aware that "good" and "better" are all matters of perspective, but I think everyone would agree that while there are no perfect ways of handling certain problems, there are plenty of wrong ways, and mine could be one of them.
Thank you in advance ^^
I am not entirely sure this is the correct board to post this to, since it is more a design question than an actual physics question. If so, please move my ramblings to where-ever they should be
For the past month I've been working on a simple 2D Engine using XNA 4.0 and Irrklang for audio. It's more or less finished, apart from the physics. Because of the simplicity of the first few games I have in mind for which I will use this engine I do not require more than the very basics of Physics such as collision detection between rectangles and spheres. (that's basically it) I've been working on it quite a bit and slowly but surely it's taking shape. My main question really is, what are some "good" ways to bring all the theory and all the classes together in a solid physics framework. What I mean is, I have a class Body, a class Shape and a class World.
World contains information such as the Gravity, etc, and also all the Physics Bodies currently in the scene. Bodies have properties such as acceleration, velocity and position and Shape is the shape of the object. (for now limited to circular and rectangular) I've created game engines in the past but I've never had to work with a Physics Engine from scratch and to my dismay I didn't get the opportunity to properly work with them at my internship either. As such I am not sure that my approach is the correct one.
So far I have a single Physics World which is updated (it's an XNA game component) and which in turn updates Bodies who apply their velocities. I am mostly stuck on where and when to check for collisions. Do I check if objects colide right after translating one? Or do I simply translate everything and THEN check for possible collisions. (the latter, I think, would give problems when two fast moving objects just pass one another by) Also, what is a good way to handle these collisions? Do I use events to which objects using the PhysicsBody subscribe? Or are there "better" ways of doing this?
I hope I am making sense with this, because as you can probably see, creating an easy-to-use, fluent Physics Engine isn't exactly something I have done before. I am not really having any problems with the maths aspect of it, but simply plugging it all into my engine properly is causing hiccups on my part.
If anyone knows of any good tutorials pertaining to this quite specific problem I would be very grateful for being pointed in the right direction. I'm also well aware that "good" and "better" are all matters of perspective, but I think everyone would agree that while there are no perfect ways of handling certain problems, there are plenty of wrong ways, and mine could be one of them.
Thank you in advance ^^