View Full Version : Showing model (MDL file) with AC textures?
garfield_x
06 Mar 2007, 07:56
Hi
Is someone familiar or knows where to find some information to show an image of the aircraft model with the texture in a screen/window as is done by FSRepaint?
I want to include such a viewer in one of my programs (if possible )
Any help is welcome.
Hi Peter,
For my MDL Tweaker tool I have build a parser that can read the MDL files and show a preview of them in a window. But this code only works for Fs2004 scenery MDL files at the moment.
For FsX there is no different between aircraft and scenery anymore, but my MDL reading code is certainly not finished yet :).
garfield_x
06 Mar 2007, 14:37
Thx for the reply.
Where did you got the information about these things?
I did a lot of search with google on MDL files etc. I found out that it actually are RIFF files, but i could not find any information on how to process these files for displaying.
I've looked at the DirectX SDK, but also no information.
Hi Peter,
Basically I figured it out myself what the MDL file contains. I have made an article (http://www.fsdeveloper.com/wiki/index.php?title=Fs2004_scenery_MDL_format) about this on the Wiki. For the FsX format we are now working on a similar article (http://www.fsdeveloper.com/wiki/index.php?title=FsX_MDL_format), but it is certianly not complete yet.
theisomizer
09 Mar 2007, 17:01
Hi Peter,
Basically I figured it out myself what the MDL file contains. I have made an article (http://www.fsdeveloper.com/wiki/index.php?title=Fs2004_scenery_MDL_format) about this on the Wiki. For the FsX format we are now working on a similar article (http://www.fsdeveloper.com/wiki/index.php?title=FsX_MDL_format), but it is certianly not complete yet.
Yes, and I have a lot more I have figured out myself (FSX format) that I need to add. It's hard to find time to update the wiki but I will be releasing an API soon that can read the FSX MDL (with extensive documentation and some C++ source code). So hopefully once that happens I can update some of the wiki stuff.
Sean
garfield_x
10 Mar 2007, 02:41
That would be nice.
To me it si just a small addon to my ACA program, so it must not take a lot of time for me.
theisomizer
11 Mar 2007, 23:21
That would be nice.
To me it si just a small addon to my ACA program, so it must not take a lot of time for me.
Yes, it should be fairly straightforward. In your program you will just need to make an external call to my API dll, and my program will then decode all of the sections of the file into memory for your application to use.
I'll have an interim (Bug free yet incomplete) build ready in a week or so, and I'll make an announcement here when its ready.
Cheers,
Sean
Hello fellow MDL freaks!
Arno I've been reading your wiki format description on MDLX datatyped RIFF files and for once something like this might even make sense to me. Not a programmer just a hardcore FS mesh junkie. Well I've been lovin' the poking you've done to it so I started coding my own little gem in DELPHI to parse the fsx MDL files. got a few different methods to parse the file and I even brute forced a little GL viewer to render the whole chaos as a 'single' mesh. ALL vertices from VERT all indices from INDE arrayed all up in sequence. NO PART info from the LOD tables yet(in progress). I don't even have to start listing the questionable practices in the least with that approach....but it renders at least one part ok, which is a rather big leap for me.
Well You coding in C languages is not as clear but the info is awesome! I'll read up on C syntax to make sense of it.
I sure could enjoy some detailed discussions an the fundamentals of the different VertexBuffers and why all the Different VERT(chunks) sections why not just one like INDE, and how they all get a PART defined.
thanx
Peter
Hi Peter,
It is certainly very interesting to understand why things have been implemented like they are. I don't understand all this myself yet, but while playing with the new MDL format that is certainly something to learn. If we can have some good discussions about that on the forum, that would be great of course.
I got the parsing for the partslist in the bag. Last LOD only for high res mesh.
Eagerly waiting for anyone to share thoughts on this parts issue....lots of 'em.
From FSX 747 I loaded 303 chunks not including the other LODE chunks or anything from ANIB. might expand options to pick LODE chunk to read and send to GL renderer later, but must sort out the meshes first. So before I fill my arrays with silly stuff I hope someone sheds a little more light on it.....
Peter
http://img455.imageshack.us/img455/1766/mdlxez8.jpg
Well not a lot of discussion in past days:confused:
Tested my theory with the mesh rendering and it looks ok for now.
but with NO parts splitting the following triangles seem to be bound within the first mesh, so must get dirty with the offsets and counts. Prying at it with a crowbar seems to be getting me forward slower than perhaps a scalpel would.
Maybe some more ellaborate discussions?
zip
theisomizer
06 Apr 2007, 18:07
Zip/Peter,
Welcome to the forums, and sorry for any lack of discussion. I think I speak for all of us when I say that it isn't a lack of interest that keeps us from posting, only a lack of time.
Anyways, I read both of your posts but don't quite understand what your question is. What are the problems are you having with the PART sections?
Personally I am pretty familiar with the MDL format, and I know several others here on the forum are as well. I hope we can help answer your question.
Yours,
Sean
Greets Sean,
Having said I'm not a programmer probably means different things to people, but it's just that. So I was asking for more of this intense research to surface. Aircraft Engineering background fuels most of my interests, and Arno's description was enough for me to get interested. I model Aircraft for personal pleasures but the more you learn the more you want. I managed to get a few methods workin on converting my MDL (FS9), back to source with tex but no anim. So FSX is out now the format description is out so I guess I wanted to make a newbie thread out of this discussion. like a live tutorial for others interested including myself.
My question was about the Vertexbuffers and the reason for multiple VERT sections, having compared it to INDE. and the PART reference offsets into which of those. TANS???? TRAN-transform matrices? Do I need them for anything in static mesh only? Or just for animation data?
Anything You guys got I'll take so I can curl up and READ and try.....
Zip
theisomizer
07 Apr 2007, 00:47
Zip,
Ok, I see what you are saying. Believe it or not I come from a similar background you do, and you remind me of myself a few years ago. I am an aerospace engineer myself and so are several others of us, including arno. Although I wouldn't say I am a beginner at programming, I am certainly far from being an expert and still have a lot to learn. We all do. So I can relate.
Anyways, the documentation publicly available on the MDL format is very sparse. I have been meaning to update it with some of my knowledge for a long time, but never got around to it. I guess now I have a reason to.
I have the next four days off for the easter holidays, and I will write a nice MDL tutorial during this time. I owe it to the FS community for all the help they've given me. Think of it as a "MDL for Dummies". I think it should help answer most of your questions and should give you a jump start on your MDL Reading tool.
I am working on the following MDL resources, in chronological order:
1. Updated Wiki page with more MDL information
2. Above mentioned beginner's MDL tutorial
3. Eventually a pdf file with the complete MDL specification
4. Some more tutorials
5. Some source code <C++ at first, but might port it to other languages> to assist in reading/rendering/converting the MDL format
6. An open source app that actually will read/render/convert the MDL format
Eventually I hope to have a complete system that can convert the MDL back to gmax source code. It would probably consist of an app that would dump the MDL back to a .X file (or possibly the intermediate XML format). Then a maxscript that would load the file back into gmax. But I am still far from this.
Anyways, until I have this tutorial together, here is what I recommend you do:
1. Read up on the C-based language syntax. Delphi certainly is not a bad language, and I am not telling you to switch to C. Trust me, I had been writing Pascal many years before I started C. But most of us FS guys work in C-based stuff, so it will help you to understand the syntax. I'd say C++ is a good place to start as it is a nice mix between lower level C & higher level C#.
2. Download the DirectX SDK. I know you are using OGL, but the DXSDK has some great info on 3D graphics in general. And FS stores much of its information in a DX like format, since it has to send it straight to the DX engine.
3. Download .net Reflector or some equivalent program and explore some of the MDL tools. I suggest taking a look at xtomdl.exe and mdlscan.exe.
4. Explore the XML intermediate format of the MDL file. Try compiling a model with the /KEEP option and explore the generated XML file. It is the closest representation of the MDL file there is, and contains all of the same info the MDL does only in a human readable format. It is an invaluable resource.
I'll answer some of your more specific MDL questions in the tutorial. Have fun and good luck until then,
Sean
....mmmmm.....
This is what I was Prying at! This will start a new era. The knowledge base provided on the net, enables people llike myself to do the things that were black voodoo done by guru coders back just a few years. eg gauges programming. XML now allows me to do complete custom panel from the ground up with (not sure), almost as much functionality if not as good. And the code to it is done in the same household. Trying to keep away from C as long as feasible, so I can get Delphi under my belt. Also I parctice my hand in disassembly, reversing and assembly coding as well. All in my 'spare' time, so rather slow. Info that You and Arno made available is what feeds the mind of people like me who need a little more than the will itself. I know I'm in way over my head but this makes me wanna learn more all the time!
Thanx fellows for holding the light for us
Zip
got all excited so I enumerated all the mesh chunks ready to read in memorystreams. It seems ready to go. I'm readying a new loop to make my model class contain all the sub-meshes for the Draw proc. I have the mescount so I might have another go at it to draw more than 1 object.
http://img478.imageshack.us/img478/4678/clip11vw3.jpg
zip
Greets simmers...
Still pounding away at my keyboard.(Eagerly awaiting the tuts for dummies) Made some changes in UI (must say GLScene makes it very easy), to piggyback a Renderer onto my parser instead of a separate loader app. Gonna try and size the box to BBOX dimensions and take it from there step by step.
HAPPY EASTER !
zip
...and the blind bat is still flyin'...
I shoved 3 textured boxes into max8 and built mdl. still using the same code that I used to visualize the cessna and it shows all 3. Scene root has 3 children (are these not parts?). But if I attach 2 together it'll optimize it and I get messed up mesh. Not even really sure of its importance but I'd like to be for the hell of it. Anyone who finds my 'comic relief' worthy is welcome to add to my 'in'sanity.
PS: @theisomizer: Reflector is a crafty little gadget, sure I'll invest some time there. Also would love to know the purpose of MdlScan....
zip
http://img236.imageshack.us/img236/2084/clip13yo1.jpg
by the look of it just call me the 'thread killa' ...
http://img469.imageshack.us/img469/1034/maulegd8.jpg
compliments of Reflector
public RIFF_KEY_TYPE = (DICT_SIGNATURE=$54434944, FS9_ANIMATION_COMMANDS_SIGNATURE=$43494e41, FS9_ANIMATION_PARAMETERS_SIGNATURE=$50494e41, FS9_ANIMATIONS_SIGNATURE=$4d494e41, FS9_ATTACH_POINT_SIGNATURE=$41545441, FS9_ATTACHED_OBJECT_DATA=$4f545441, FS9_BGL_ENTRY_SIGNATURE=$204c4742, FS9_BOUNDING_BOX_SIGNATURE=$584f4242, FS9_CRASH_SIGNATURE=$53415243, FS9_CREATOR_SIGNATURE=$54465349, FS9_DICTIONARY_SIGNATURE=$54434944, FS9_EXTERIOR_MODEL=$45545845, FS9_INTERIOR_MODEL=$45544e49, FS9_LOD_SIGNATURE=$20444f4c, FS9_MATERIALS_SIGNATURE=$4554414d, FS9_MODEL_HEADER=$20394d48, FS9_MOUSE_RECT_SIGNATURE=$53554f4d, FS9_PLATFORMS_SIGNATURE=$54414c50, FS9_SCENE_GRAPH_SIGNATURE=$4e454353, FS9_SHADOW_MODEL=$44414853, FS9_STATIC_TRANSFORM_SIGNATURE=$4e415254, FS9_TEXTURES_SIGNATURE=$54584554, FS9_VERTICES_SIGNATURE=$54524556, FSX_ANIM_BLOCK_SIGNATURE=$42494e41, FSX_ANIM_LINK_SIGNATURE=$4c414753, FSX_ANIM_TRANSFORM_SIGNATURE=$54494e41, FSX_ANIMATION_MAP_SIGNATURE=$50414d41, FSX_ANIMATION_PARAMETERS_SIGNATURE=$50494e41, FSX_ATTACHED_OBJECT_DATA=$4f545441, FSX_AUTOGEN_AUTOGEN_2=$324e4741, FSX_AUTOGEN_FILE_KEY=$584e4741, FSX_AUTOGEN_GENERIC_BUILDING_DEFINITIONS=$44444247 , FSX_AUTOGEN_GENERIC_BUILDING_PLACEMENTS=$444c4247, FSX_AUTOGEN_GENERIC_BUILDING_TEXTURE=$45544247, FSX_AUTOGEN_POLYGON_REGION_DATA=$47455250, FSX_AUTOGEN_POLYLINE_BUILDING_DATA=$444c4250, FSX_AUTOGEN_POLYLINE_VECTOR_DATA=$43455650, FSX_AUTOGEN_ROW_HOUSE=$48574f52, FSX_AUTOGEN_VEGETATION_FS9_RECTANGLE_DATA=$4f52475 6, FSX_AUTOGEN_VEGETATION_FS9_RECTANGLE_DEFINITION=$4 4524756, FSX_AUTOGEN_VEGETATION_GUID_RECTANGLE_DATA=$475247 56, FSX_AUTOGEN_VERSION=$53524556, FSX_BONE_MAP_SIGNATURE=$50414d42, FSX_BOUNDING_BOX_SIGNATURE=$584f4242, FSX_HEADER_SIGNATURE=$484c444d, FSX_IK_CHAIN_LIST=$4c434b49, FSX_IK_JOINT_CONSTRAINT=$434a4b49, FSX_IK_JOINT_CONSTRAINT_REF=$434a4753, FSX_INDEX_BUFFER_SIGNATURE=$45444e49, FSX_LOD_ENTRY_SIGNATURE=$45444f4c, FSX_LOD_TABLE_SIGNATURE=$54444f4c, FSX_MATERIALS_SIGNATURE=$4554414d, FSX_MODEL_DATA=$444c444d, FSX_MODEL_FRIENDLY_NAME_SIGNATURE=$4e4c444d, FSX_MODEL_GUID_SIGNATURE=$474c444d, FSX_NOVISIBILITY_SIM=$534e4956, FSX_NOVISIBILITY_SIMCODE=$434e4956, FSX_PART_LIST_SIGNATURE=$4c524150, FSX_PART_MODEL_VERT_INDEX=$4d495650, FSX_PART_SHADOW_VERT_INDEX=$53495650, FSX_PART_SIGNATURE=$54524150, FSX_PLATFORM_LIST_SIGNATURE=$4c414c50, FSX_PLATFORM_SIGNATURE=$54414c50, FSX_RADIUS_SIGNATURE=$49444152, FSX_REFERENCE_POINT_LIST_SIGNATURE=$4c464552, FSX_REFERENCE_POINT_SIGNATURE=$50464552, FSX_SCENE_GRAPH_BONE_REF=$52424753, FSX_SCENE_GRAPH_SIGNATURE=$4e454353, FSX_SHADOW_MESH=$4d414853, FSX_SKIN_SIGNATURE=$4e494b53, FSX_STATIC_TRANSFORM_SIGNATURE=$4e415254, FSX_TANSPACE_SIGNATURE=$534e4154, FSX_TEXTURES_SIGNATURE=$54584554, FSX_VERTEX_BUFFER_SIGNATURE=$42524556, FSX_VERTICES_SIGNATURE=$54524556, FSX_VISIBILITY_LINK_SIGNATURE=$4c564753, FSX_VISIBILITY_LIST_SIGNATURE=$4c534956, FSX_VISIBILITY_SIM=$53534956, FSX_VISIBILITY_SIMCODE=$43534956, HEAD_SIGNATURE=$484c444d, MDL8_SIGNATURE=$384c444d, MDL9_SIGNATURE=$394c444d, MDLX_SIGNATURE=$584c444d, RIFF_SIGNATURE=$46464952, UNKNOWN_SIGNATURE=0, VIEW_SIGNATURE=$204c4742);
almost there...:stirthepo
theisomizer
12 Apr 2007, 21:01
Hey zip,
Glad to see you are coming along. On the Cessna model it looks like you have come pretty far. Now if we can just fix the rest we'll be in good shape!:wizard:
Anyways, I went through and de-hexed the stuff from reflector. Here's what I got: (Sorry it's in C++ but it's the comments that count)
namespace Microsoft
{
namespace FlightSimulator
{
public __value enum RIFF_KEY_TYPE
{
// Fields
DICT_SIGNATURE = 0x54434944,//--------------------------------- DICT
FS9_ANIMATION_COMMANDS_SIGNATURE = 0x43494e41,//=============== ANIC
FS9_ANIMATION_PARAMETERS_SIGNATURE = 0x50494e41,//------------- ANIP
FS9_ANIMATIONS_SIGNATURE = 0x4d494e41,//======================= ANIM
FS9_ATTACH_POINT_SIGNATURE = 0x41545441,//--------------------- ATTA
FS9_ATTACHED_OBJECT_DATA = 0x4f545441,//======================= ATTO
FS9_BGL_ENTRY_SIGNATURE = 0x204c4742,//------------------------ BGL
FS9_BOUNDING_BOX_SIGNATURE = 0x584f4242,//===================== BBOX
FS9_CRASH_SIGNATURE = 0x53415243,//---------------------------- CRAS
FS9_CREATOR_SIGNATURE = 0x54465349,//========================== ISFT
FS9_DICTIONARY_SIGNATURE = 0x54434944,//----------------------- DICT
FS9_EXTERIOR_MODEL = 0x45545845,//============================= EXTE
FS9_INTERIOR_MODEL = 0x45544e49,//----------------------------- INTE
FS9_LOD_SIGNATURE = 0x20444f4c,//============================== LOD
FS9_MATERIALS_SIGNATURE = 0x4554414d,//------------------------ MATE
FS9_MODEL_HEADER = 0x20394d48,//=============================== HM9
FS9_MOUSE_RECT_SIGNATURE = 0x53554f4d,//----------------------- MOUS
FS9_PLATFORMS_SIGNATURE = 0x54414c50,//======================== PLAT
FS9_SCENE_GRAPH_SIGNATURE = 0x4e454353,//---------------------- SCEN
FS9_SHADOW_MODEL = 0x44414853,//=============================== SHAD
FS9_STATIC_TRANSFORM_SIGNATURE = 0x4e415254,//----------------- TRAN
FS9_TEXTURES_SIGNATURE = 0x54584554,//========================= TEXT
FS9_VERTICES_SIGNATURE = 0x54524556,//------------------------- VERT
FSX_ANIM_BLOCK_SIGNATURE = 0x42494e41,//======================= ANIB
FSX_ANIM_LINK_SIGNATURE = 0x4c414753,//------------------------ SGAL
FSX_ANIM_TRANSFORM_SIGNATURE = 0x54494e41,//=================== ANIT
FSX_ANIMATION_MAP_SIGNATURE = 0x50414d41,//-------------------- AMAP
FSX_ANIMATION_PARAMETERS_SIGNATURE = 0x50494e41,//============= ANIP
FSX_ATTACHED_OBJECT_DATA = 0x4f545441,//----------------------- ATTO
FSX_AUTOGEN_AUTOGEN_2 = 0x324e4741,//========================== AGN2
FSX_AUTOGEN_FILE_KEY = 0x584e4741,//--------------------------- AGNX
FSX_AUTOGEN_GENERIC_BUILDING_DEFINITIONS = 0x44444247,//======= GBDD
FSX_AUTOGEN_GENERIC_BUILDING_PLACEMENTS = 0x444c4247,//-------- GBLD
FSX_AUTOGEN_GENERIC_BUILDING_TEXTURE = 0x45544247,//=========== GBTE
FSX_AUTOGEN_POLYGON_REGION_DATA = 0x47455250,//---------------- PREG
FSX_AUTOGEN_POLYLINE_BUILDING_DATA = 0x444c4250,//============= PBLD
FSX_AUTOGEN_POLYLINE_VECTOR_DATA = 0x43455650,//--------------- PVEC
FSX_AUTOGEN_ROW_HOUSE = 0x48574f52,//========================== ROWH
FSX_AUTOGEN_VEGETATION_FS9_RECTANGLE_DATA = 0x4f524756,//------ VGRO
FSX_AUTOGEN_VEGETATION_FS9_RECTANGLE_DEFINITION = 0x44524756,// VGRD
FSX_AUTOGEN_VEGETATION_GUID_RECTANGLE_DATA = 0x47524756,//----- VGRG
FSX_AUTOGEN_VERSION = 0x53524556,//============================ VERS
FSX_BONE_MAP_SIGNATURE = 0x50414d42,//------------------------- BMAP
FSX_BOUNDING_BOX_SIGNATURE = 0x584f4242,//===================== BBOX
FSX_HEADER_SIGNATURE = 0x484c444d,//--------------------------- MDLH
FSX_IK_CHAIN_LIST = 0x4c434b49,//============================== IKCL
FSX_IK_JOINT_CONSTRAINT = 0x434a4b49,//------------------------ IKJC
FSX_IK_JOINT_CONSTRAINT_REF = 0x434a4753,//==================== SGJC
FSX_INDEX_BUFFER_SIGNATURE = 0x45444e49,//--------------------- INDE
FSX_LOD_ENTRY_SIGNATURE = 0x45444f4c,//======================== LODE
FSX_LOD_TABLE_SIGNATURE = 0x54444f4c,//------------------------ LODT
FSX_MATERIALS_SIGNATURE = 0x4554414d,//======================== MATE
FSX_MODEL_DATA = 0x444c444d,//--------------------------------- MDLD
FSX_MODEL_FRIENDLY_NAME_SIGNATURE = 0x4e4c444d,//============== MDLN
FSX_MODEL_GUID_SIGNATURE = 0x474c444d,//----------------------- MDLG
FSX_NOVISIBILITY_SIM = 0x534e4956,//=========================== VINS
FSX_NOVISIBILITY_SIMCODE = 0x434e4956,//----------------------- VINC
FSX_PART_LIST_SIGNATURE = 0x4c524150,//======================== PARL
FSX_PART_MODEL_VERT_INDEX = 0x4d495650,//---------------------- PVIM
FSX_PART_SHADOW_VERT_INDEX = 0x53495650,//===================== PVIS
FSX_PART_SIGNATURE = 0x54524150,//----------------------------- PART
FSX_PLATFORM_LIST_SIGNATURE = 0x4c414c50,//==================== PLAL
FSX_PLATFORM_SIGNATURE = 0x54414c50,//------------------------- PLAT
FSX_RADIUS_SIGNATURE = 0x49444152,//=========================== RADI
FSX_REFERENCE_POINT_LIST_SIGNATURE = 0x4c464552,//------------- REFL
FSX_REFERENCE_POINT_SIGNATURE = 0x50464552,//================== REFP
FSX_SCENE_GRAPH_BONE_REF = 0x52424753,//----------------------- SGBR
FSX_SCENE_GRAPH_SIGNATURE = 0x4e454353,//====================== SCEN
FSX_SHADOW_MESH = 0x4d414853,//-------------------------------- SHAM
FSX_SKIN_SIGNATURE = 0x4e494b53,//============================= SKIN
FSX_STATIC_TRANSFORM_SIGNATURE = 0x4e415254,//----------------- TRAN
FSX_TANSPACE_SIGNATURE = 0x534e4154,//========================= TANS
FSX_TEXTURES_SIGNATURE = 0x54584554,//------------------------- TEXT
FSX_VERTEX_BUFFER_SIGNATURE = 0x42524556,//==================== VERB
FSX_VERTICES_SIGNATURE = 0x54524556,//------------------------- VERT
FSX_VISIBILITY_LINK_SIGNATURE = 0x4c564753,//================== SGVL
FSX_VISIBILITY_LIST_SIGNATURE = 0x4c534956,//------------------ VISL
FSX_VISIBILITY_SIM = 0x53534956,//============================= VISS
FSX_VISIBILITY_SIMCODE = 0x43534956,//------------------------- VISC
HEAD_SIGNATURE = 0x484c444d,//================================= MDLH
MDL8_SIGNATURE = 0x384c444d,//--------------------------------- MDL8
MDL9_SIGNATURE = 0x394c444d,//================================= MDL9
MDLX_SIGNATURE = 0x584c444d,//--------------------------------- MDLX
RIFF_SIGNATURE = 0x46464952,//================================= RIFF
UNKNOWN_SIGNATURE = 0,//---------------------------------------
VIEW_SIGNATURE = 0x204c4742//================================== BGL
};
}
}
I'm still working on the tutorial but it's coming slower than I thought. It should really be worth the time, though, as it getting to be really informative. This info should make a great addition to the tut.
I wish you continued success, and I'll try to post on the forums more in the next few days. :D
Sean
Hello there...
@theisomizer: Thank you for the encouragement and the good words
Didn't check XtoMDL in reflector yet but prying at it with somthin' else yielded these ....
Could these be the 2 int values starting PART records?(first 2 UNKNOWN int's in Arno's description?
.class nested public auto sealed ansi PartType extends [mscorlib]System.Enum
{
.field public specialname rtspecialname int32 value__
.field public static literal value class PartType UNKNOWN = int32(-1515870811)
.field public static literal value class PartType REFERENCE_POINT = int32(-1515870811)
.field public static literal value class PartType PLATFORM = int32(-1515870811)
.field public static literal value class PartType FLATTENING_POLY = int32(-1515870811)
.field public static literal value class PartType VISIBLE_MESH_WITH_CRASH = int32(-1515870811)
.field public static literal value class PartType VISIBLE_MESH_WITHOUT_CRASH = int32(-1515870811)
}
.method private hidebysig void WritePart(class Microsoft.FlightSimulator.XmlToMdlLib.Part P)
{
.locals init (class Microsoft.FlightSimulator.XmlToMdlLib.IndexGroup V0)
ldarg.0
ldfld class Microsoft.FlightSimulator.XmlToMdlLib.IndexList Microsoft.FlightSimulator.XmlToMdlLib.MDLProcessin gContext::m_IndexList
ldarg.1
callvirt class System.String Microsoft.FlightSimulator.XmlToMdlLib.Part::get_In dexGroupName()
callvirt class Microsoft.FlightSimulator.XmlToMdlLib.IndexGroup Microsoft.FlightSimulator.XmlToMdlLib.IndexList::F indGroup(class System.String szName)
stloc.0
ldloc.0
brfalse loc_11698
ldarg.0
ldfld class Microsoft.FlightSimulator.XmlToMdlLib.FileExporter Microsoft.FlightSimulator.XmlToMdlLib.MDLProcessin gContext::m_Exporter
ldstr "PART"
ldarg.1
callvirt class System.String Microsoft.FlightSimulator.XmlToMdlLib.Part::get_Na me()
callvirt void Microsoft.FlightSimulator.XmlToMdlLib.FileExporter ::StartRIFF(class System.String Name, class System.String Suffix)
ldarg.0
ldfld class Microsoft.FlightSimulator.XmlToMdlLib.FileExporter Microsoft.FlightSimulator.XmlToMdlLib.MDLProcessin gContext::m_Exporter
ldarg.1
callvirt value class PART_TYPE Microsoft.FlightSimulator.XmlToMdlLib.Part::get_Ty pe()
callvirt void [mscorlib]System.IO.BinaryWriter::Write(int32)
ldarg.0
ldfld class Microsoft.FlightSimulator.XmlToMdlLib.FileExporter Microsoft.FlightSimulator.XmlToMdlLib.MDLProcessin gContext::m_Exporter
ldarg.1
callvirt class SceneGraphNode Microsoft.FlightSimulator.XmlToMdlLib.Part::get_Sc eneGraphReference()
callvirt int32 SceneGraphNode::get_ID()
callvirt void [mscorlib]System.IO.BinaryWriter::Write(int32)
stfld int32 SceneGraphNode::m_iID
edit...:
further poking {PART struct}
get_Type()
get_SceneGraphReference()
GetMaterialIndex(class System.String szName)
get_VBIdx()
get_BaseVertexOffset()
get_VertexCount()
get_BaseIndexOffset()
get_IndexCount()
get_MouseRectHandlerID()
the call to WritePart in xtomdl writes these little critters in a neat little riff chunk to mdl file
from intermediate XML
theisomizer
14 Apr 2007, 00:52
Regarding the PART record,
This is the function that actually writes the part (Sorry more C#)
private void WritePart(Part P)
{
IndexGroup group = this.m_IndexList.FindGroup(P.IndexGroupName);
if (group != null)
{
this.m_Exporter.StartRIFF("PART", P.Name);
this.m_Exporter.Write((int) P.Type);
this.m_Exporter.Write(P.SceneGraphReference.ID);
this.m_Exporter.Write(this.GetMaterialIndex(P.Mesh Material.FriendlyName));
this.m_Exporter.Write(group.VBIdx);
this.m_Exporter.Write(group.BaseVertexOffset);
this.m_Exporter.Write(group.VertexCount);
this.m_Exporter.Write(group.BaseIndexOffset);
this.m_Exporter.Write(group.IndexCount);
this.m_Exporter.Write(P.MouseRectHandlerID);
this.m_Exporter.EndRIFF(P.Name);
}
}
Which means the actual structure of a PART definition (still 36 bytes) is:
sint32 Type;
sint32 SceneGraphReference;
sint32 MaterialIndex;
uint32 VBIdx;
uint32 BaseVertexOffset;
uint32 VertexCount;
uint32 BaseIndexOffset;
uint32 IndexCount;
sint32 MouseRectHandlerID;
Where type is one from the following enum:
public enum PartType
{
UNKNOWN, // 0
REFERENCE_POINT, // 1
PLATFORM, // 2
FLATTENING_POLY, // 3
VISIBLE_MESH_WITH_CRASH, // 4
VISIBLE_MESH_WITHOUT_CRASH // 5
}
SceneGraphReference and MaterialIndex are the corresponding IDs for the scenegraph node and material definition used by the part. I'm guessing VBIdx stands for Vertex Buffer index (from the VERB node). BaseVertexOffset is in the VERB node too. VertexCount is self explanatory.
Same thing goes for BaseIndexOffset and IndexCount, these are from the INDE section.
MouseRectHandlerID is an advanced thing that I haven't quite got figured out yet. The mouse rectangle system has to do with advanced event driven animations, so we can safely ignore it for now. Small steps, my friend. :teacher:
BTW expect the first part of my MDL tutorial tommorow or Sunday. I'll post it here on the forums.
Sean
Hey Sean!
Thanx for clearing it up...it seems I was lookin in the right place.
(Totally irrelevant that I haven't a clue what SceneGraph or its Node is.)
Anyhow I adjusted my code to finally read it too
http://img399.imageshack.us/img399/2234/clip14ec2.jpg
The IDE debugger is my best friend and worst enemy but this time it shows me the right data:D
Jugglin' ~1200 lines of code now in 4 units, but getting the right data out of memory will eliminate parsing a separate filestream and the GLViewer stuff which will simplify it a lot.
Can't wait for the tuts (C is inevitable). Little Steps in big leaps:)
Little less 'bog down' in drawing it after only using LOD100. Must be still lost somewhere in the indexing the vertices to the triangles but hey, it's better then it was. Glad they don't look like this in the Sim.
http://img441.imageshack.us/img441/5939/clip15wt4.jpg
http://img217.imageshack.us/img217/2866/clip16wn2.jpg
http://img412.imageshack.us/img412/7357/clip17jw1.jpg
:mischievo zip
Carefully avoiding the overwhelming urge to smash my rig, I had a deeper look into what I was doing so far. The results in previous pics were yielded by code that was not indexing the VERTs to the triangles because......I (for some unknown reason) decided not to include the base vertex offset. :banghead: :censored: Hope to get it sorted soon.
edit: Also all but the first vertex buffer's data were ignored(kinda feel stupid 'bout that), cuz I only parsed for first VERTchunk.
looks like I did a little extra grooming of important code. With all this it's a miracle I managed to draw anything at all.
zip
vBulletin® v3.8.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.