April 23, 2024, 12:10:41 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


"Template" type x files and cBasic

Started by 3Dpdk, February 02, 2008, 04:17:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

3Dpdk

February 02, 2008, 04:17:05 AM Last Edit: February 02, 2008, 05:52:15 PM by 3Dpdk
Quick re-intro:
I was an iBasic user 2005, wrote an icon editor (unfinished but usable), went out to sea, lost contact for a while, found out iBasic had gone away, found Ionic Wind/ cBasic and eBasic just this past week ... I'm back!

I'm writing a file/model manager utility for a specific 3D program and need to include a model viewer window in the UI. I've done that and it works fine allowing the user to see the model from the file they are about to manipulate.

Here's the problem: The parent program uses X files of both 0303 and 0302 versions and several template styles. The only models I can get to display in my viewer window is X file version 0302 with the "Header" style template.

Does anyone know if the other forms of X file can be displayed in cBasic?



[EDIT] Incase this might be a "gray area" for some:
X files can have several template styles and there is more than one version of these files. Using a simple text editor like Word Pad you can check this out. On the first line of every X file you will see something like
Xof 0303txt 0032
or
Xof 0302txt 0064

The Xof tells DirectX this is an X file. (sort of like the first two bytes of a bitmap image is ASC("BM"))
03 indicates the major version - 02 indicates the minor version
txt indicates the type of data, eg. text, binary, etc, but you will be looking at "txt" because it's difficult to make sense of binary data.
0032 or 0064 indicates the floating point precision of the numbers in the data

You may find several combinations of this information but the two listed above seem to be the most common.

Next you will find one to several "templates". These are definitions of data format DX can expect to find in the data fields of the same name further down in the file.

A special type template is called a Header and looks like this

Header{
1; (these numbers can vary and I THINK indicate)  
0; (what data will be found and where in each data group)
1;
}

This is the type that I have been sucessfull in loading into the viewer window. It doesn't seem to matter if its 0032 or 0064, 0303 or 0302; but if the file has any other template it just doesn't seem to show up.

So is this a DX command I'm missing or is cBasic only capable of loading the Header style template?
One last point, building these models "manually" by reading the file is pretty much out of the question. we're talking complex x file models, 2,3,4 Mb long - and asking the other content artists to convert some 1200+ X files to suit the needs of the file manager is just silly!

3Dpdk

I guess I stumped everyone on this.  ???

Mr Turly can correct me if I'm wrong but apparently the cBasic Xfile load command can only interpret or pass on an X file with the "Header {n;n;n}" type template, however the version and floating point precision don't seem to matter to cBasic. Notice that this is the template style that is written when a model is saved from cBasic.

Left to my own experimentation I finally solved the issue with a work around.

My solution was; instead of loading the X file directly, the program writes a temporary X file by reading each line in the file as a string and writing that string to the temporary file. It writes everything in the original - starting with the mesh data and leaving out all the templates and transformation matrix data (also note that version 0302 writes material data and texture paths immediately after template and transform matrix data. These need to be included in the temporary X file) . It also writes the file ID and version and Header {1;0;1;} template in the proper place in the document. Then it loads this temporary X file into the viewer.

This method as it stands won't work for animated models because the keyframe data will crash the loader, but a few more checks as each string is read should solve that problem.

I only posted this in case others have had or are having similar problems getting cBasic to load X files. Seems no one here knew the answers to this, so this is a way to get around the problem.

Ionic Wind Support Team

Creative uses DX7 and uses the built in X loading functions of that interface, so its limitations are whatever Microsoft put in that loader.   In other words I had nothing to do with it ;)

Paul.
Ionic Wind Support Team

3Dpdk

Understood!

My work around works just fine, but a funny quirk I could mention.

In order for the "fudged" Header type format to work I have to initialize DX by loading an unchanged X file containing open templates first. From what I'm reading this loads the templates into DX to be used for following X files with the Header type template.

?

I don't know ... but it works so that's what matters.

Thanks for the comment, Paul. I figured I must be a bit obscure down here at the bottom of the forum.