Sign in to follow this  
thedodgeruk

creating a class for rockets, should i use a static for the models mesh?

Recommended Posts

building a game , which has rockets in it , this will be a class , that has life time , vectors and stuff.
but all instances of this class will have the same mesh.

so i was thinking would it be bes to declare it as static, other wise it will load in meshes which it does not have to .

or is there a better way

Share this post


Link to post
Share on other sites
You are talking about a generic problem ("reuse certain resources") and one specific approach for solving it ("make them static"). In my opinion, there's nothing wrong with the static approach, as long as you can pull it off without getting into order of initialization troubles. However, you should be aware that this problem can be solved in a variety of different ways. For example, you could introduce a resource manager class that makes sure resources are only loaded once. You can find plenty of information (articles, forum discussions...) about resource management on this site.

Share this post


Link to post
Share on other sites
You don't have to declare your rockets static just to use a single mesh.
There are many ways to avoid this, but one would be your class having a reference of some sort, maybe a number or a real reference or pointer, to a mesh.
Why not create a simple mesh manager class, which you can index your meshes in?

Edit: ^ too slow! -although a resource manager is more general. Probably a better idea to start off with that, you can always inherit to more specific loaders and managers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this