• Create Account

### #Actual___

Posted 12 October 2012 - 01:00 PM

well if you want to save vertices only just do sth like this
struct THeader{
int vertlen; //amount of vertices you want to save
};

struct t3dpoint {
float x;
float y;
float z;
};
FILE* f = fopen(filename,"wb+");

now you can save them
//through all vertices in array
for (j=0; j < header.vertlen ; j++)  fwrite(&verts[j],sizeof(verts[j]),1,f); //or sizeof t3dpoint (whatever)
fclose(f);


and you want to load them



int length;
int j;
FILE* f = fopen(filename,"rb");

memset(&header,0,sizeof(THeader)); //do this if header consist more than one var if not ther is no need even to make a struct from header

int j;

set the length of verts - array in excample it can be simple pointer (t3dpoint * verts;)
for (j=0; j < header.vertlen ; j++) {
t3dpoint imo;
verts[j] = imo; //something like this i use static arrays so i just assign it like thus  if this does not work you will need to write (*verts[i]) = imo; but have no idea if it will work anyway <img src='http://public.gamedev.net//public/style_emoticons/default/tongue.png' class='bbc_emoticon' alt=':P' />
}

fclose(f);
}

Congrats! you have your own file type

### #4___

Posted 12 October 2012 - 11:33 AM

well if you want to save vertices only just do sth like this
struct THeader{
int vertlen; //amount of vertices you want to save
};

struct t3dpoint {
float x;
float y;
float z;
};
FILE* f = fopen(filename,"wb+");

now you can save them
//through all vertices in array
for (j=0; j < header.vertlen ; j++)  fwrite(&verts[j],sizeof(verts[j]),1,f); //or sizeof t3dpoint (whatever)
fclose(f);


and you want to load them



int length;
int j;
FILE* f = fopen(filename,"rb");

memset(&header,0,sizeof(THeader)); //do this if header consist more than one var if not ther is no need even to make a struct from header

int j;

set the length of verts - array in excample it can be simple pointer (t3dpoint * verts;)
for (j=0; j < header.vertlen ; j++) {
t3dpoint imo;
verts[j] = imo; //something like this i use static arrays so i just assign it like thus  if this does not work you will need to write (*verts[i]) = imo; but have no idea if it will work anyway <img src='http://public.gamedev.net//public/style_emoticons/default/tongue.png' class='bbc_emoticon' alt=':P' />
}

fclose(f);
}

Congrats! you have your own file type

### #3___

Posted 12 October 2012 - 11:27 AM

well if you want to save vertices only just do sth like this
struct THeader{
int vertlen; //amount of vertices you want to save
};

struct t3dpoint {
float x;
float y;
float z;
}

FILE* f = fopen(filename,"wb+");

now you can save them
//through all vertices in array
for (j=0; j < header.vertlen ; j++)  fwrite(&verts[j],sizeof(verts[j]),1,f); //or sizeof t3dpoint (whatever)
fclose(f);


and you want to load them



int length;
int j;
FILE* f = fopen(filename,"rb");

memset(&header,0,sizeof(THeader)); //do this if header consist more than one var if not ther is no need even to make a struct from header

int j;

set the length of verts - array in excample it can be simple pointer (t3dpoint * verts;)
for (j=0; j < header.vertlen ; j++) {
t3dpoint imo;
verts[j] = imo; //something like this i use static arrays so i just assign it like thus  if this does not work you will need to write (*verts[i]) = imo; but have no idea if it will work anyway <img src='http://public.gamedev.net//public/style_emoticons/default/tongue.png' class='bbc_emoticon' alt=':P' />
}

fclose(f);
}

Congrats! you have your own file type

### #2___

Posted 12 October 2012 - 11:27 AM

well if you want to save vertices only just do sth like this
struct THeader{
int vertlen; //amount of vertices you want to save
};

struct t3dpoint {
float x;
float y;
float z;
}

FILE* f = fopen(filename,"wb+");

now you can save them
//through all vertices in array
for (j=0; j < header.vertlen ; j++)  fwrite(&verts[j],sizeof(verts[j]),1,f); //or sizeof t3dpoint (whatever)
fclose(f);


and you want to load them



int length;
int j;
FILE* f = fopen(filename,"rb");

memset(&header,0,sizeof(THeader)); //do this if header consist more than one var if not ther is no need even to make a struct from header

int j;

set the length of verts - array in excample it can be simple pointer (t3dpoint * verts;)
for (j=0; j < header.vertlen ; j++) {
t3dpoint imo;
verts[j] = imo; //something like this i use static arrays so i just assign it like thus  if this does not work you will need to write (*verts[i]) = imo; but have no idea if it will work anyway <img src='http://public.gamedev.net//public/style_emoticons/default/tongue.png' class='bbc_emoticon' alt=':P' />
}

fclose(f);
}

Congrats! ou have your own file type

### #1___

Posted 12 October 2012 - 11:27 AM

well if you want to save vertices only just do sth like this
struct THeader{
int vertlen; //amount of vertices you want to save
};

struct t3dpoint {
float x;
float y;
float z;
}

FILE* f = fopen(filename,"wb+");

now you can save them
//through all vertices in array
for (j=0; j < header.vertlen ; j++)  fwrite(&verts[j],sizeof(verts[j]),1,f); //or sizeof t3dpoint (whatever)
fclose(f);


and you want to load them



int length;
int j;
FILE* f = fopen(filename,"rb");

memset(&header,0,sizeof(THeader)); //do this if header consist more than one var if not ther is no need even to make a struct from header

int j;

set the length of verts - array in excample it can be simple pointer (t3dpoint * verts;)
}