Opt File Format

Want to edit the game, build your own craft and missions? Here you'll find help, tools, guides and people to discuss with.
Post Reply

Opt File Format

Gringlas
XWAU Member
Posts: 1289
Joined: Mon Oct 30, 2000 12:01 am
Contact:

Post by Gringlas » Thu Feb 05, 2015 10:38 am

Hi everybodey! It's been a very long time since my last post here, but the gog release of XWA made me come back here and my interest on the game awoke once more :)

The last few days I've been meddling around with the OPT file format, out of interest in a personal project. I'm new to this stuff and used the only source I found on the format, which is Stealth Jedi's document: http://www.oocities.org/v_d_d/Xwing_Uno ... Specs.html

I was able to understand everything to up to block 22 I guess, but from there I'm puzzled and don't understand the Main Mesh Header. I'm using the original Containerbrick,opt, as I thought this model to be rather easy.

For example I tried to find the vertices, but I don't really understand how to find the jump offset, from the information given in the document:
offset to 03 // vertices

I would be grateful if someone would be able to point me to more information or would be able to explain it to me a bit more detailed. :) Thank you!

User avatar
JeremyaFr
XWAU Member
Posts: 3987
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Thu Feb 05, 2015 8:04 pm

Hi,

If this can help, here is the structure of ContainerBrick.opt:
ContainerBrick-Structure.png
Add 8 to the indicated offset to find the block in the file.
You do not have the required permissions to view the files attached to this post.

Gringlas
XWAU Member
Posts: 1289
Joined: Mon Oct 30, 2000 12:01 am
Contact:

Post by Gringlas » Fri Feb 06, 2015 9:05 am

Hi JeremyaFr, thank you for the strucutre, but I'm still not sure if I get it right.

According to Stealth Jedis documentation,
I located the 02 Header at bock 12 and 13 (0200) after that I should locate the NumOfOffsets, which in my understanding indicates the mesh count, right? This would be a longint 010000 (starting at block 14) and this would be 1, which is correct for the containerbrick model, right? The next instruction is the Jump to the first offset. I don't know how this offset ist stored (longint, byte, word).
Even though I don't seem to understand that part correctly according to StealthJedi I should find the first jump offset at block 22, which would be 66, as you pointed out in your image of the OPT Structure. So I would start at block 66+8 reading the vertices, right? If i'd do so I'd calculate a vertex as 3 float values, which would be 216bytes of data for the vertices.
So I would get the following points:

Block Float
74 0.0
78 0.0
82 0.0

86 0.0
90 0.0
94 0.0

98 435.5
102 2.015751
106 -2.019767

(...)

Am I'm correct here?

User avatar
JeremyaFr
XWAU Member
Posts: 3987
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon Feb 09, 2015 12:36 am

Hi Gringlas,
Gringlas wrote:I located the 02 Header at bock 12 and 13 (0200) after that I should locate the NumOfOffsets, which in my understanding indicates the mesh count, right?
mostly right. The first offset may point to a texture. In that case, NumOfOffsets = mesh count, otherwise NumOfOffsets = mesh count + 1.
Gringlas wrote:This would be a longint 010000 (starting at block 14) and this would be 1, which is correct for the containerbrick model, right?
right
Gringlas wrote:I don't know how this offset ist stored (longint, byte, word).
All offsets are longint.
Gringlas wrote:I should find the first jump offset at block 22, which would be 66, as you pointed out in your image of the OPT Structure. So I would start at block 66+8 reading the vertices, right?
The first jump offset at block 22 is 26 (Main Mesh Header). In this node, the first jump is 66.
At block 66+8, it's the node (Mesh Vertex Header ) that contains the vertices, not the vertices themselves.

Gringlas
XWAU Member
Posts: 1289
Joined: Mon Oct 30, 2000 12:01 am
Contact:

Post by Gringlas » Mon Feb 09, 2015 8:56 pm

Thanks for the detailed answer. :) i'm in skiing holidays right now, so i think i'll be able to try it next monday :)

Gringlas
XWAU Member
Posts: 1289
Joined: Mon Oct 30, 2000 12:01 am
Contact:

Post by Gringlas » Sat Feb 14, 2015 6:20 pm

And its me again :)
I was able to find most of the values in your screenshot.
No the vertex header puzzles me. I find it at node 74 as 00 03 00 00. It seems to me, that the number of 00 in the headers pointed out in Stealth Jedis document are 1...n, right? Because The count of vertices is 12 00 00 00 found at offset 87, followed directly by 8A 08 A9 00 which would be the jumpf offset to the first vertex in this case 90 + 8, but at that location I would find 0.0/0.0/0.0 for the vertex x/y/z coords.
Also I'd assume to find jump offsets to 18 vertices and not just one, but the other bytes won't give me reasonable jump offsets. What I'm doing wrong here?

Gringlas
XWAU Member
Posts: 1289
Joined: Mon Oct 30, 2000 12:01 am
Contact:

Post by Gringlas » Sun Feb 22, 2015 3:23 pm

any hints or ideas, or is my question not clear enough? Help would be greatly appreciated. :) thanks!

User avatar
JeremyaFr
XWAU Member
Posts: 3987
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sun Feb 22, 2015 7:16 pm

Hello,
Here is the list of jump offsets in ContainerBrick.opt:

CONTAINERBRICK.OPT
0x00000000: File Header
File Size: 72929
Global Offset: 11077680
Jumps Count: 1, Offset: 0x00000016
Jump 0: 0x0000001A

0x0000001A: Node Type: NodeGroup
Jumps Count: 6, Offset: 0x00000032
Jump 0: 0x0000004A
Jump 1: 0x0000013A
Jump 2: 0x000001E2
Jump 3: 0x000002BA
Jump 4: 0x0000031A
Jump 5: 0x00000362

0x0000004A: Node Type: MeshVertices
Data Offset: 0x00000062
Count: 18

0x0000013A: Node Type: TextureCoordinates
Data Offset: 0x00000152
Count: 18

0x000001E2: Node Type: VertexNormals
Data Offset: 0x000001FA
Count: 16

0x000002BA: Node Type: MeshDescriptor
Data Offset: 0x000002D2

0x0000031A: Node Type: RotationScale
Data Offset: 0x00000332

0x00000362: Node Type: NodeGroup
Jumps Count: 4, Offset: 0x0000037A
Jump 0: 0x00000000
Jump 1: 0x00000000
Jump 2: 0x00000000
Jump 3: 0x0000038A

0x0000038A: Node Type: FaceGrouping
Jumps Count: 1, Offset: 0x000003A2
Jump 0: 0x000003AA
Data Offset: 0x000003A6
Count: 1

0x000003AA: Node Type: NodeGroup
Jumps Count: 8, Offset: 0x000003C2
Jump 0: 0x000003E2
Jump 1: 0x00004EC5
Jump 2: 0x00004FA9
Jump 3: 0x00007A8C
Jump 4: 0x00007B0C
Jump 5: 0x0000A5EF
Jump 6: 0x0000A66F
Jump 7: 0x00011BFD

0x000003E2: Node Type: Texture
Data Offset: 0x00000403

0x00004EC5: Node Type: FaceData
Data Offset: 0x00004EDD
Count: 2

0x00004FA9: Node Type: Texture
Data Offset: 0x00004FCA

0x00007A8C: Node Type: FaceData
Data Offset: 0x00007AA4
Count: 1

0x00007B0C: Node Type: Texture
Data Offset: 0x00007B2D

0x0000A5EF: Node Type: FaceData
Data Offset: 0x0000A607
Count: 1

0x0000A66F: Node Type: Texture
Data Offset: 0x0000A690

0x00011BFD: Node Type: FaceData
Data Offset: 0x00011C15
Count: 2

Notes:
  • The offset next to Jumps Count is the offset of the jump table. Each jump is a int. Remove the global offset and add 8 to obtain the node offset.
  • A node doesn't directly contains data, but contains a jump offset to its data.

mynt57
Recruit
Posts: 2
Joined: Thu Feb 26, 2015 5:04 am

Post by mynt57 » Thu Feb 26, 2015 5:16 am

Is there documentation for the xvt/bop format the same way you found for the xwa format? I know there are differences between bop and xwa, and this document seems to describe the OPT format in terms of xwa entities.

mynt57
Recruit
Posts: 2
Joined: Thu Feb 26, 2015 5:04 am

Post by mynt57 » Sun Mar 01, 2015 7:02 pm

I decided to just use the available documentation and parse the xwa opts, and it turns out they are significantly better. See xwa's imperialstardestroyer2 opt vs bop's ISD. Now that I can successfully parse higher quality opts, I'm not really sure I need to parse the xvt bop ones anymore.

I found OP's documentation page ambiguous but correct. If I update my code to also parse xvt/bop models I may put out an updated HTML.

Loading/rendering/editing in java/opengl

Gringlas
XWAU Member
Posts: 1289
Joined: Mon Oct 30, 2000 12:01 am
Contact:

Post by Gringlas » Thu Mar 19, 2015 1:15 pm

It's been some time since my last post, but I was busy and only able to have a look at this topic every now and then. I finally have found the Vertices and compared them to those displayed in your superb XWAOptEditor, JeremyaFr. The Containerbrick.opt contains 10 vertices, but Iat block 90 I find 12 00 00 00 which should be the NumVertices (Longint) according to StealthJedi. The next block 94 (8A 08 A9 00) is Jump to Floats, which contains the jump offset to the vertices of the Mesh, which start in block 98 up to 314, which are 18 vertices with 3 floats each. What is the meaning of those 8 overmuch vertices?

User avatar
JeremyaFr
XWAU Member
Posts: 3987
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Mon Mar 23, 2015 12:19 am

The extra vertices at the end of the vertices block replicate the hitzone.

User avatar
JeremyaFr
XWAU Member
Posts: 3987
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Tue Sep 29, 2015 12:50 pm

Hello,

I have uploaded the source code of my opt dll to GitHub:
https://github.com/JeremyAnsel/JeremyAnsel.Xwa.Opt

The binaries are consumable through a NuGet package:
http://www.nuget.org/packages/JeremyAnsel.Xwa.Opt

Post Reply