Archived

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

f8k8

Synchronising data between manager classes

Recommended Posts

This is more of a design question than a programming one, but I just wanted some opinions. I''ve got a manager class for my physics meshes, which will be used for collision etc, and another one for my graphics meshes, so the objects can be rendered. Basically, I''m creating a 3D solar system program, and seeing as how all the meshes will be basically spheres, I''m going to generate them inside the program, instead of loading mesh files. The thing is, I''m not sure where to actually generate the meshes. If I create them in the physics manager, I''d have to either generate them seperately in the graphics manager, or copy across the triangle data from the physics manager. Both would work OK for just plain spheres, although I''d need duplicate code if I were to generate a seperate mesh in the graphics manager. One of the problems is if I want to generate randomly irregular spheres, for things like asteroids etc. I''d need to copy the data from the physics manager, so that the same mesh would be used for rendering as collision. What I want to do though is to have the graphics and physics systems as independant as possible. Sorry if this made absolutely no sense. --------------------------------------- Let''s struggle for our dream of Game! http://andrewporritt.4t.com

Share this post


Link to post
Share on other sites
do u really need mesh in the physics manager? wouldn''t a position, radious and mass be enough to simulate a solar system? and if u need collision detection, just use sphere collision

Share this post


Link to post
Share on other sites
You can also have a separate MeshFactory-class that creates a mesh if it doesn't exist and returns a handle to it (if it exists it only returns the handle). This is of course easier if you read mesh-data from disk as you can use the (path and) filename to check if it has already been loaded. Otherwise you need to have some unique id for each mesh that both the physics and the renderer knows (like "earth", "sun", etc).

[edited by - amag on January 5, 2004 10:30:49 AM]

Share this post


Link to post
Share on other sites