Renaming Variables?

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?)

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.

How about a structure?

typedefine MODEL
{
char name[255];
int size;
int origin_x, origin_y, origin_z;
GLFloat *vertex_data;
};

MODEL model_store[10]; // Create storage for 10 models.

create_model_object(char *name, GLfloat *data)
{
model_store[?].name = name; // store name of model which could be torus, cube, etc.

model_store[?].data = data; // store data of model
}

So when processing or finding object.

for(x=0; x < objects_max; x++)
{
if ( strcmp( model_store.name, search_name) return x; // if name match return number of object.
}

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?)

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?

I think you need some RTFM