Right, so i have a class called "model" that is used for storing all the model information for an incomming model (brought in from .ase), anyway, at the beginning of the .ase file there is the name of the model, an example would be "cube", or "torus". Anyway, i have that name stored in a char name[255]; what i want is, a separate model variable for each, so have it define each name as a model. In essence, doing the same thing as
model cube;
model torus;
except, having them dynamically named... so somehow
model (name[255]); and be able to later access it by like
cube->verts = xxxxxx
the problem is, it keeps saying im redefining "name".. any ideas on how to do this? (perhaps some code examples to help me through?)

starman

04-25-2003, 09:50 AM

Learn the C++ standard library, in particular string and vector:

#include <vector>
#include <string>

using namespace std;

vector<string> models;

for all model names in file {
string name = model_name;
models.push_back(name);
}

You can access these like you would the elements of an array, or use an iterator if you want to just sequentially process them:

vector<string>::iterator i;

for (i = models.begin(); i != models.end(); ++i) {
string name = *i;
// do something with name
}

If you want to access them *by* their names, look at the standard library 'map' container.

Originally posted by ImpactDNI:
Right, so i have a class called "model" that is used for storing all the model information for an incomming model (brought in from .ase), anyway, at the beginning of the .ase file there is the name of the model, an example would be "cube", or "torus". Anyway, i have that name stored in a char name[255]; what i want is, a separate model variable for each, so have it define each name as a model. In essence, doing the same thing as
model cube;
model torus;
except, having them dynamically named... so somehow
model (name[255]); and be able to later access it by like
cube->verts = xxxxxx
the problem is, it keeps saying im redefining "name".. any ideas on how to do this? (perhaps some code examples to help me through?)

ImpactDNI

04-25-2003, 10:08 AM

Sorry guys, im learning C++/OGL as i go =P just as a side project to school... not quite used to the string/vector libraries... whats the push.back func do?