   Problem with code from "Focus on 3D Models"
  I can say that the book is excellent and exactly what I needed. These days I''m trying to load an ms3d file using book''s code. In fact I''m rewriting the code in order to focus on the format. But I have problems. I am trying to make a class for static models so I have used the code to load the vertices,the faces,the meshes and the materials.I use the same procedure with book''s in order to read the file till the joints section and then I stop. There is no problem with reading the vertices. The number which I read from the file (using the "thug jump.ms3d" file) is indeed 502 which is the number MilkShape shows for the file(in model statistics). But the number of triangles isn''t right. I read from the file a number of 32000 and something and MilkShape shows 982 triangles for the model. So if I try to use memcpy() to copy the triangles in memory which I have allocated before, using that number of triangles, the program crashes!I can''t find what''s wrong since the code seems absolutely right ( after all it''s exactly like book''s, I "parse" the file exactly the same way) , so if anyone has an idea what''s wrong,please help me.And something else:Where can I find the MS3D specification?Thanks in advance  
  By exactly do you mean copy and paste or you typed it out yourself? If you typed it you migh have made a small slip somewhere so it might be worth you posting your code. For whats is worth I recently used the file format described from the book and it works okay so its most likely your code somewhere, the file format spec given is spot on.Ofcourse the model couldve become corrupted if you accidently wrote to it, so you could try copying from the cd to replace it. ;  Thanks for the answer Drazgal.I typed the code by myself and there''s no lip in it(I checked it out many times!!).But I found what''s wrong. Function sizeof() doesn''t return the right amount of bytes for the structures(SMs3DVertex,SMs3DTriangle and others).I know it''s weird but sizeof(SMs3dVertex) returns 20 bytes and sizeof(SMs3DTriangle) returns 72 bytes which are not right for these two structures(the first has 15 bytes size and the second 70 bytes). I did some changes and  till know I have no problem  in loading the file. Some problems in rendering occured but I''ll check them out too.At least for the "thug jump.ms3d" I take 502 vertices,982 triangles,14 faces and 2 materials which are ok. So has anyone any idea why sizeof() returns wrong number of bytes? I''ll search general programming forum and post a topic there, but if anyone can help at this , an answer would be very helpful. Thanks;  Actually just remembered what your problem maybe, I had the same problem myself. Visual Studio (and most compilers) will pad your structure so it is of a certian multiple, so it is faster for memory retrival. So your structure isnt the right size and stuff. Turn this off and you should be fine, to do this in Visual Studio C++ (atleast version 6.0 dont know about others), go to Project, Project Settings,C++, change category to code generation then change the struct memory alignment to 1 byte. This might fix your problem (if it doesnt turn it back as its normally a good thing). There is a way (some #pragma or something) to only select the alignment option for those structures only so you still get the speed on others in your project but I cant for thelife of me remember what (only ever seen it used once), should be easy to search for.  ;  Exactly that! I have already done it and at least it gives me a size of 15 for the structure which is right! I''ll rewrite the code and see how it''s going. However in project from the book''s cd, the structure allignment is 8 bytes and it compiles just fine. I''ll keep it 1 byte in my project which works well. Thanks Drazgal! 