?
Solved

parsing milkshape files

Posted on 2009-12-29
2
Medium Priority
?
661 Views
Last Modified: 2013-12-14
hi

i was wondering if anyone could tell me how to parse milkshape files. I do not how to read the chunks like }ÄHÀ³Q±½"VD@½7 · ðÀ7`PEAto make them usefull. I want to do this using fstream.h and ifstreams.  have attached an example file
Model.txt
0
Comment
Question by:sassek
2 Comments
 
LVL 7

Expert Comment

by:johnnash1180
ID: 26137934
The milkshape files should be in binary format. Go through the following urls to get the details of that file format.

http://en.wikipedia.org/wiki/MilkShape_3D#MilkShape_3D_file_format
http://local.wasp.uwa.edu.au/~pbourke/dataformats/ms3d/

You can use the http://local.wasp.uwa.edu.au/~pbourke/dataformats/ms3d/ms3dspec.h header file to get structure of that ms3d file format details.

John Nash
0
 
LVL 7

Accepted Solution

by:
js-profi earned 860 total points
ID: 26158623
It is ms3d file format specified at http://chumbalum.swissquake.ch/ms3d/ms3dspec.txt

Use #include  and not fstream.h which is deprecated.

Goto project settings C++ code generation and switch alignment to 1-byte packed.

Open file with

    std::ifstream ms("model.dat", ios_base::binary | ios_base::in);

Then read first header

   ms3d_header_t msh;
   ms.read((char*)&msh, sizeof(msh));
 
Then number of vertices

  unsigned short numV;
  ms.read((char*)&numV, 2);

For each vertex read into vertext struct
    std::vector v;  
   for (unsigned short n = 0; n < numV; ++n)
   {
       v.push_back(ms3d_vertex_t);
       ms.read((char*)&v.back(), sizeof(ms3d_vertex_t));
   }

Then do similar with triangles, groups, joints, materials, ...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question