struct problems
hey...
i have 3 structs that represent an object:
typedef struct {
float x,y,z;
}vertex;
typedef struct {
vertex v1,v2,v3,v4;
}quad;
typedef struct {
int numverts;
int numnorms;
int numfaces;
vertex *verts;
vertex *norms;
quad *faceverts;
quad *facenorms;
vertex *coords;
}mesh;
i am reading in an .obj file, so in the loading function i read in the mesh struct i want the values assigned to, set up the sub structer arrays, and begin to assign values:
void loadObj(mesh mesh1,char *path){
... some other code not having to do with the problem ...
mesh1.numverts=numpoints;
mesh1.verts=new vertex[numpoints];
for (int temp=0;temp<numpoints;temp++){
readstr(file,line);
sscanf(line,"v %f %f %f",&x1,&y1,&z1);
mesh1.verts[temp].x=x1;
mesh1.verts[temp].y=y1;
mesh1.verts[temp].z=z1;
}
i do that for normals, and fave values.
i call the functions in my init function like this:
loadObj(mesh1,"pumpkin.obj");
where mesh1 is a mesh structure:
mesh mesh1;
for some reasom, the values arn''t being assigned to mesh1 in the loadObj function. how come this is happening?
I hope any of that made sence. -PmanC
In your mesh struct, you''re trying to read in values into pointer variables. Using pointers for use in reading and writing files never works.
Come up with another method
Come up with another method

November 03, 2002 10:50 PM
try:
void loadObj(mesh *mesh1,char *path){
and replace all your mesh1. by mesh1-> in your function.
when calling the function you''ll also need to give it
a pointer to mesh1 loadObj (&mesh1,...
void loadObj(mesh *mesh1,char *path){
and replace all your mesh1. by mesh1-> in your function.
when calling the function you''ll also need to give it
a pointer to mesh1 loadObj (&mesh1,...
and: (unless you simplified this)
is quite badly broken... but then again, it shouldn''t have compiled like this
quote:
for (int temp=0;temp readstr(file,line);
sscanf(line,"v %f %f %f",&x1,&y1,&z1);
mesh1.verts[temp].x=x1;
mesh1.verts[temp].y=y1;
mesh1.verts[temp].z=z1;
is quite badly broken... but then again, it shouldn''t have compiled like this
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement