Jump to content
  • Advertisement


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


Turespace Model Loading...

This topic is 6329 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

Not really sure if this is where to post but... I''m working on a Truespace model loader. I downloaded th *only* file format document on the *.cob (Truespace object file) from Whotsit that i found. I can read in the header values, but after that, when I try to start to read in chunks, the program won''t work. The header is in plain text in the files, but the data is in binary. I''m using:
FILE* fp;
if ((fp = fopen(filename, "rb")) == NULL)
  return false;

// read in header....

// read in chunks - get run-time errors

I''m new to loading binary files, so I wonder if I''m doing something wrong. Anyways, if someone could point me to a site that has another *.cob format specification (the on I have is for version 2!) or maybe some example source code or tutorials on binary files or Truespace model loading. I appreciate any help given. Thanks.

Share this post

Link to post
Share on other sites
Here''s some code I wrote a while ago, but it will only load file which have a single object (a single polygonal data chunk), it the file has materials or groups it''ll crash, but I think it might not be that hard to update it. Anyway hopefully this will help you out. The code also does not deal with the current position and axis matrices.

cob_header COB_Header;
cob_local_vertex_list *COB_Vertex_List;
cob_UV_List UV_List;
cob_Faces *Faces;

cob_polygonal_data_chunk_header COB_PolyChunk_Header;
cob_chunk_name COB_Chunk_Name;
cob_local_axis COB_Local_Axis;
cob_current_pos COB_Current_Pos;

FILE *fileptr = fopen(filename,"rb");





COB_Vertex_List = new cob_local_vertex_list[num_verticies];

for(int i=0; i<num_verticies; i++)


UV_List.u = new float[num_uv];
UV_List.v = new float[num_uv];

for(i=0; i<num_uv; i++)


Faces = new cob_Faces[num_faces];

for(i=0; i<num_faces; i++)

you should also make sure you''ve set up your structures correctly (sorry about the bad naming)...

typedef struct
char id[9];
char version[6];
char binary;
char endian[2];
char blanks[13];
char newline;

typedef struct
char type[4];
short major_version;
short minor_version;
long chunk_id;
long parent_id;
long num_bytes;

typedef struct
short dupecount;
short str_len;
char *name;

typedef struct
float center[3];
float dir_x[3];
float dir_y[3];
float dir_z[3];

typedef struct
float MatrixRow1[4];
float MatrixRow2[4];
float MatrixRow3[4];

typedef struct
float Vertex_Coordinates[3];

typedef struct
float *u;
float *v;

typedef struct
BYTE flags_byte;
short num_verticies;
short mat_index;
long vertex_index[3];
long uv_index[3];


typedef struct
long num_verticies;
long num_faces;
long num_uv;
point_3d *VertexList;
cob_UV_List UV_List;
cob_Faces *Faces;


Digital Radiation

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!