Archived

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

PmanC

struct problems

Recommended Posts

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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,...

Share this post


Link to post
Share on other sites
and: (unless you simplified 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

Share this post


Link to post
Share on other sites