Sign in to follow this  

Problem with loading .x file with custom templates

This topic is 2549 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi.
I'm trying to use DirectX .x files as files for describing game levels.
The contents of the file I'm trying to parse are:
[code]xof 0303txt 0032

template Environment { <8EC36C32-91E6-40df-BD10-6333F3843950>
[...]
}

template Position { <1002A8C1-9890-4cdd-AC11-E2168DDEAA8D>
DOUBLE x;
DOUBLE y;
DOUBLE z;
}

template Velocity { <21F50CE8-25F2-49df-AAB7-86D71F1DF076>
DOUBLE vx;
DOUBLE vy;
DOUBLE vz;
}

template Angles { <91780636-4836-4b9b-9C99-5E176A3D7FFC>
FLOAT a;
FLOAT b;
FLOAT c;
}

template AngularVelocity { <C755E2E3-1DEF-42a4-9CD2-0B8699965636>
FLOAT avx;
FLOAT avy;
FLOAT avz;
}

template RGBAColor { <74EAC0A1-EDF3-4f61-938C-997C5DE9E87C>
FLOAT r;
FLOAT g;
FLOAT b;
FLOAT a;
}

template Color { <99B22A47-616F-46d1-AFC6-BDF4C222A06D>
RGBAColor diffuse;
RGBAColor ambient;
RGBAColor specular;
RGBAColor emissive;
FLOAT power;
}

template LOD { <8B4D0388-435E-4440-ADFC-CB79998AFFA0>
DWORD lod;
}

template Inertia { <092A5136-7B9E-478a-88E9-7EB2BCBA56F9>
DOUBLE mass;
}

template State { <F6A1C24C-1807-42ae-831F-16AF6887BD67>
Position pos;
Velocity vel;
Angles angs;
AngularVelocity av;
}

template Dimensions { <59946D5B-45A9-4226-AF56-D05162ADFCC3>
DWORD dimnum;
array DOUBLE dimensions[dimnum];
}

template Sphere { <A00196B0-F630-4c3e-83D3-B765C6370F1A>
[State, Inertia, Color, LOD, Dimensions]
}

template Plane { <75274942-95B8-4f52-A826-63687A91CA0D>
[State, Inertia, Color, LOD, Dimensions]
}

Environment {
Plane {
80: Dimensions {
81: 2;
82: 20.0, 20.0;
83: }
84:
85: Inertia {
86: 0.0;
87: }
88:
LOD {
10;
}

State {
0.0; 0.0; 0.0;;
0.0; 0.0; 0.0;;
3.1415926536; 0.0; 0.0;;
0.0; 0.0; 0.0;;
}

Color {
1.0; 1.0; 1.0; 1.0;;
0.0; 0.0; 0.0; 0.0;;
0.0; 0.0; 0.0; 0.0;;
0.0; 0.0; 0.0; 0.0;;
0.0;
}
}
}[/code]
The templates are registered fine. But the function ID3DXFile::CreateEnumObject returns D3DXFERR_PARSEERROR. Also the Output window contains the following:

[quote]D3DX: ModulateData: out of data trying to read dimensions
D3DX: Bad data list for (unnamed) object.
D3DX: 83: parser: failed to create data part object near "20.0"

D3DX: 83: syntax error near "20.0"

D3DX: Parse error.[/quote]
I fail to see where there is error in my .x file. Interestingly, if I change the type of dimensions array from DOUBLE to FLOAT the error moves to line 87. If I then change the type of mass to FLOAT the error disappears & the data is loaded fine. So if anyone can point out where the error might be I'd appreciate it.
Also if anyone can advise me some other format (with ready libraries) for storing game levels I'd appreciate it too.

Share this post


Link to post
Share on other sites

This topic is 2549 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this