Advertisement

.x files into OGL applications...

Started by July 26, 2004 03:51 PM
2 comments, last by GamerSg 20 years, 4 months ago
i'm using VC++ 6.0, and 3dsmax 6, and I've downloaded the Panda Directx exporter from: http://www.andytather.co.uk/Panda/directxmax.htm i'm pretty new to OpenGL programing, so bare with me on this... i've followed NeHe's tutorials up to number 10 (the walk around/gamelevel one)... but i don't even know how to create a text file with the world co-ords like the ones sent with the sample codes at the end of the tutorial... So i've created a simple cube (6 sided w/uvs, and map) and exported the .x file, which looks like this, when opened in notepad... ---------------------------------------------------------- xof 0303txt 0032 template FVFData { <b6e70a0e-8ef9-4e83-94ad-ecc8b0c04897> DWORD dwFVF; DWORD nDWords; array DWORD data[nDWords]; } template EffectInstance { <e331f7e4-0559-4cc2-8e99-1cec1657928f> STRING EffectFilename; [...] } template EffectParamFloats { <3014b9a0-62f5-478c-9b86-e4ac9f4e418b> STRING ParamName; DWORD nFloats; array FLOAT Floats[nFloats]; } template EffectParamString { <1dbc4c88-94c1-46ee-9076-2c28818c9481> STRING ParamName; STRING Value; } template EffectParamDWord { <e13963bc-ae51-4c5d-b00f-cfa3a9d97ce5> STRING ParamName; DWORD Value; } Material PDX01_-_Default { 0.588235;0.588235;0.588235;1.000000;; 3.200000; 0.000000;0.000000;0.000000;; 0.000000;0.000000;0.000000;; } Mesh Box01 { 14; -20.765272;0.000000;-20.765272;, 20.765272;0.000000;-20.765272;, -20.765272;0.000000;20.765272;, 20.765272;0.000000;20.765272;, -20.765272;41.530544;-20.765272;, 20.765272;41.530544;-20.765272;, -20.765272;41.530544;20.765272;, 20.765272;41.530544;20.765272;, 20.765272;41.530544;-20.765272;, -20.765272;41.530544;-20.765272;, 20.765272;41.530544;20.765272;, 20.765272;41.530544;-20.765272;, -20.765272;41.530544;20.765272;, 20.765272;41.530544;20.765272;; 12; 3;0,3,2;, 3;3,0,1;, 3;4,7,5;, 3;7,4,6;, 3;0,8,1;, 3;8,0,9;, 3;1,10,3;, 3;10,1,11;, 3;3,12,2;, 3;12,3,13;, 3;2,4,0;, 3;4,2,6;; MeshMaterialList { 1; 12; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; { PDX01_-_Default } } MeshTextureCoords { 14; 0.624999;0.624999;, 0.625001;0.874999;, 0.374999;0.625002;, 0.375001;0.875002;, 0.624996;0.374999;, 0.624993;0.124999;, 0.374996;0.375002;, 0.374993;0.125002;, 0.875001;0.874996;, 0.874999;0.624996;, 0.375004;1.125002;, 0.625004;1.124999;, 0.124999;0.625005;, 0.125001;0.875005;; } } --------------------------------------------------------------- i'm going to assume most of the data exported with the plugin is useless data to OGL, and i'm sure the data in this simple file, would be pretty much the same, as if i were to create a biped figure and exported it. except it would be more data.... with that said... i've 2 questions... 1) Would anyone happen to know of a tutorial, or article that would explain how to use this data in my OGL programs? and/or... 2)could someone explaing to me how i would translate this into my OpenGL program?
"I am nobody,Nobody is perfect...I guess this means,that i am perfect."~Evulness 2004
You can find information on the .x file format here. That should be a start..
Advertisement
hmm...

got a good idea of what to do, but i just wanna make sure i'm thinking straight...

i looked over the word doccument:
(Microsoft DirectX File Format Specification file from the link you gave me. http://www.wotsit.org/download.asp?f=x);
and i also closely reread over lesson10., and looked over the world.txt file from the code sample...

if i'm understanding this correctly, which i'm probably not...

i can crop out nearly all the data from that .x file i exported, and crop it down to just this:

Mesh Box01 {
14;
-20.765272;0.000000;-20.765272;,
20.765272;0.000000;-20.765272;,
-20.765272;0.000000;20.765272;,
20.765272;0.000000;20.765272;,
-20.765272;41.530544;-20.765272;,
20.765272;41.530544;-20.765272;,
-20.765272;41.530544;20.765272;,
20.765272;41.530544;20.765272;,
20.765272;41.530544;-20.765272;,
-20.765272;41.530544;-20.765272;,
20.765272;41.530544;20.765272;,
20.765272;41.530544;-20.765272;,
-20.765272;41.530544;20.765272;,
20.765272;41.530544;20.765272;;
12;
3;0,3,2;,
3;3,0,1;,
3;4,7,5;,
3;7,4,6;,
3;0,8,1;,
3;8,0,9;,
3;1,10,3;,
3;10,1,11;,
3;3,12,2;,
3;12,3,13;,
3;2,4,0;,
3;4,2,6;;
:according to the word doccument, 14; is the number of verticies, with their location(s) listed below... and 12; is the number of poly's (triagles) with their co-ords listed below....
with that said... couldn't i just crop all but that data out, format the remaining code, like in the world.txt file and use the same code from lesson10, to load my cube into my OpenGL program?

heres a small piece of the world.txt:
// Floor 1
-3.0 0.0 -3.0 0.0 6.0
-3.0 0.0 3.0 0.0 0.0
3.0 0.0 3.0 6.0 0.0

-3.0 0.0 -3.0 0.0 6.0
3.0 0.0 -3.0 6.0 6.0
3.0 0.0 3.0 6.0 0.0

:what i'm wondering is how i can convert the .x format of the mesh data, into the same format he has for the world.txt file?
cause the .x file only has 4 spaces...
(example:12;
3;0,3,2;, //face 0 has 3 verticies, in position 0,3,2
"I am nobody,Nobody is perfect...I guess this means,that i am perfect."~Evulness 2004
You could write a loader for loading x files or you could write a convertor program to convert the data to the way u want it. For reading in data, you would want to use
#include <fstream>

Try searching on google for more information on how to use fstream.

This topic is closed to new replies.

Advertisement