Hi guys,
i was wondering if you guys could answer my questions!
i wanna wrtie a tool that in some cases it needs to store Onject data such as Animation controllers and …
now how can i save those infos as and XML file?
now i can save it as a text file but i wanna how to save them as XML file!! and also can you tell me what’re advantage of saving infos in txt file and XML file?(in fact i donno the diffrences between them as a info container).
I’d suggest looking into an established XML-based format like Collada, or even FBX. In my experience there’s rarely a good reason to roll your own format.
and if you have not seen, the source code for FBX now ships with the new plugins so you can integrate it even more tightly in to your pipeline.
to answer your question though also…
text files as a way to store data… they are just data dump, all the formating is up to you, but you will have to make your own format writer and also reader to parse the .txt file, searching for strings and then figure out what to do with them…
vs.
xml, where it has a built in structure for how data is written and read, but it can be anything you want for the most part like a text file… you won’t have to start from scratch on creating scripts to read and write the data, just scripts to process and get what you want to save and load.
…
with that said, max stores animation all ready as an xml file the .anm files that it writes out for its animation merge tool , load and save animation is creating its version of an .xml format and so you could start with looking at that, as it is just a max script (in the max install directory) for doing the animation export and you can see what they are doing in there.
[QUOTE=Adam Pletcher;1158]I’d suggest looking into an established XML-based format like Collada, or even FBX. In my experience there’s rarely a good reason to roll your own format.[/QUOTE]
I’ll second that. I would only write my own format for a specific reason for something simple (like a very simple model format for swapping between programs- but this should probably use a more popular format and the bugs should be worked out in the pipeline, rather than writing your own).
If you have a reason to write your own format: For very simple model data, you may want to go with text files, but for more complex stuff, go with XML. Just compare an XML file to something like BVH and look which makes more sense.
The only reason to write your own format would probably be if you have a special rig setup or controllers (something like [w]PuppetShop[/w] is well served by its own XML-based format for animation saving and loading). If you are trying to impress potential employers (as I know you are), I personally think it says more to get a standardized format working, rather than creating your own for everything. It shows you can work with existing codebases and other coders, and use things already done for you rather than redo them yourself (the exception would be learning excersizes).
that’s a very perfect answer,in fact the reason i wanted to save the save/load data as XML was to have a better acceceable data,i meant getting date better,as you know storing in a text file would be a pain to read it as well as XML.
so i have to think about learning XML too!
thanks for your good answers.