Saving object materials (textures AND text) for maps

I have a mapping system on my server and maps are saved in raw data in this format:

model x y z rx ry rz group

But I'd like to implement saving for material textures and text. I need help working out the best way to do this.

Obviously only material indexes that HAVE materials changed need to be saved - no need to waste space. The thing is the format will be different for textures and text - textures have this data to be saved:

materialindex, &modelid, txdname[], texturename[], &materialcolor

while text has:
materialindex, text[], &materialsize, fontface[], &fontsize, &bold, &fontcolor, &backcolor, &textalignment

So obviously I would need to identify in the data what type of material is applied - texture or text.

I have a rough idea how to do this, just not sure how to implement it with sscanf. Also a problem is spaces - there may be spaces in the material text and the material text font. Would there be a better option than sscanf or what? Would I have to use a different delimiter? I don't want to edit the format of the model x y z rx ry rz group part because then players lose their old maps. It seems very complicated to me (not sscanf - trying to save all this data on one line).

Thoughts please.

Here is one of my theories:

Write the line like so, for text at least, material textures are easier:

model x y z rx ry rz group materialindex materialtype text[?] materialsize fontface[?] fontsize, bold, fontcolor backcolor textalignment

By changing the delimiter in sscanf you could find the end of the text/fontface. Ugh. I'm really confused about this for some reason. Another thing I need to stress is that materials can either be textures or text - so sscanf would need to be used twice - one to read the 'material type' then again to get the data for that ONE material index, and do the same for them all on that line.

Theory #2
Perhaps materials should go down on to the next line?

Use an integer for every object which defines the material. 0 for default texture, 1 for different material, 2 for text written on it. Simply check the value of this integer and relating this value process the data of the object.

You didn't read my entire post though. Objects can have many material indexes - some may be textures some may be text. I'm also not sure how to 'process' this data. Writing it isn't really a problem, apart from the spaces issue.

Forum Jump:

Users browsing this thread: 1 Guest(s)