Jump to content
  • Advertisement

Archived

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

PmanC

struct problems

This topic is 5765 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

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
ok... i''ll try what the Anonymous Poster said. by the way, the code is extremely simplified, so if somthing doesn''t make sence it probably would in the full code.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!