Jump to content
COMBATSIM Forum
Krycztij

TAW terrain format

Recommended Posts

Having trouble with the LODs, but found out some things:

1. There is always at least one LOD, ie the second word of the .3 file is always non-zero.

2. The maximum number of LODs is four.

3. What we call type '0020' and '00a3' only ever have one LOD.

4. For type '0000', the start of the bytecode for each LOD can be found by the following logic:

        if self.type=='0000' or self.type=='0020':

            code_start=int(data[17],16)/2+18

            if self.lod2dist!=0:

                code_start2=int(data[18],16)/2+19

            if self.lod3dist!=0:

                code_start3=int(data[19],16)/2+20 

            if self.lod4dist!=0:

                code_start4=int(data[20],16)/2+21             

That leaves types '0083' and '0087'. While quite a few of them follow similar rules to the '0000' type using the value of the 18th,19th and 20th words, I haven't been able to find a general rule. :(

Hmmn, haven't forgotten about this and I've been staring at the '0087' types for the last hour, but just can't make anything add up. After the '0087', there are some numbers which look like offsets similar to the '0000' case but....

Think I'll give up on this for a while. :angry:

Share this post


Link to post
Share on other sites

Hmmn, haven't forgotten about this and I've been staring at the '0087' types for the last hour, but just can't make anything add up. After the '0087', there are some numbers which look like offsets similar to the '0000' case but....

Think I'll give up on this for a while. :angry:

Would it be possible that LOD information is not encoded in the .3 file at all but in the SSD? (I haven't looked at any SSD's yet.)

In related news, many buildings render now that 009D/009E/009F are implemented:

skys.png

But many LOD's and damage levels are still left blank. I have, however, yet to implement other 009F types than 0301 and 0401.

Share this post


Link to post
Share on other sites

Would it be possible that LOD information is not encoded in the .3 file at all but in the SSD? (I haven't looked at any SSD's yet.)

I guess it's possible, but I thought this would be unlikely as the .3 models can be swapped around without causing the game to crash.

I could supply a text file with all the starting points of the LODs to be used as a lookup table until we sort out how to do it properly.

Share this post


Link to post
Share on other sites

I guess it's possible, but I thought this would be unlikely as the .3 models can be swapped around without causing the game to crash.

I could supply a text file with all the starting points of the LODs to be used as a lookup table until we sort out how to do it properly.

Would be great and I could implement it quickly. Could you also provide the total file size? To prevent the mechanism from loading invalid LOD offsets when someone has modded the file.

Share this post


Link to post
Share on other sites

I agree the 009f is two instructions. Here are some old notes (be kind critically) regarding 009f/009e/009d:

As I recall, the 009f opcode used for textured building surface polygons, but if the texture is not used, then the operand also contains the colors to be used at the specified vertices.

The TAW Options GUI menu presents the 'Building Texture' option which controls the 009f decision for texture vs color, effectively selecting either 0 or 1 for 'BUILD_TEXTURE=' in game.cfg.

The 009f/009X pairs come in three (0401/0301/0103) variations, which I have categorized based on the 4th word:

C/9D

009F000C0004030100C900CA00CC

009D001A00030002

E/9E

009F000E0001040100CF00CF00CC00CC

009E000200010019001A

8/9D

009F0008004F010300B

0009D001400130012

8/9E

009F0008004B010300B6

009E0012001300180019

It seems that the 4th byte gives the number of bytes to the operand. The 7th byte is consistent with the number of colors to be used. 009e/009d define the palette index colors to be used if BUILD_TEXTURE=0.

If 0401 is for a gouroud shaded quad, 0301 for a gouroud shaded triangle and 0103 for flat shaded polygons,

I believe the following executable code section may be related:

DGROUP:0064C318 unicode 0, <?>,0

DGROUP:0064C31C aTxtr db 'txtr',0 ; DATA XREF: DGROUP:off_6DB864o

DGROUP:0064C321 align 4

DGROUP:0064C324 aColr db 'colr',0 ; DATA XREF: DGROUP:006DB868o

DGROUP:0064C329 align 4

DGROUP:0064C32C aGour db 'gour',0 ; DATA XREF: DGROUP:006DB86Co

DGROUP:0064C331 align 4

DGROUP:0064C334 aFlat db 'flat',0 ; DATA XREF: DGROUP:006DB870o

DGROUP:0064C339 align 4

Share this post


Link to post
Share on other sites

You are correct about the 4th byte giving the size of the operand. This is even consistent with the 009F/000C case Mike pointed out. You are also correct about the number of colors. Another two words decoded :)

009e/009d define the palette index colors to be used if BUILD_TEXTURE=0.

No, they define the vertex indices. The color palette indices are given in 009F.

Mike's source code also covers the case of the 4th word is 0900. Any idea on that? Is it just dead code from an early draft or does this actually occur?

Unrelated: I think heavenky.3 contains the stars. Anyone wants to implement real stars, e.g. from Yale Bright Star Catalogue? :)

Share this post


Link to post
Share on other sites

Would be great and I could implement it quickly. Could you also provide the total file size? To prevent the mechanism from loading invalid LOD offsets when someone has modded the file.

File on its way...

Share this post


Link to post
Share on other sites

......also covers the case of the 4th word is 0900. Any idea on that? Is it just dead code from an early draft or does this actually occur?

Here's the files where 0900 occurs, and an example line.....I have no idea what it does differently.

hut1n_90.3

hut2n_90.3

hut2n_90.3

hut_1n.3

hut_2n.3

prfb90.3

prfb_180.3

prfb_90.3

s_prefab.3


0058; 009f001800180900ffff004000b5005000b5005000bd004000bd009e000e001100120015

Share this post


Link to post
Share on other sites

File on its way...

Up and running! :thumbsup:

su27.jpg

Here's the current build:

http://www.media...1t86a22pygm

  • LOD for vanilla 0083/0087-type models implemented
  • 009E, 009D and 009F instructions implemented
  • Transparency implemented
  • 0053 error fixed
  • gamma correction fixed

It will show four LOD's for every 0083/0087-type model; I'll fix it later. Happy testing.

There's still plenty of glitches: For example, you'll have to decrement "parameter" to 0000 upon opening a SU-27-type model, otherwise, you'll see it far away because a signal light has a bogus position and interferes with auto-distance.

Edit: Sorry, I uploaded the version with the auto-distance glitch. This is the fix: http://www.mediafire.com/?x16qtfce02hct83

Share this post


Link to post
Share on other sites

Getting better all the time! :thumbsup:

..except maybe for aswan_q, which is a long way in the distance even with the last update. It was fine yesterday.

I'm amazed at the detail in some of the models, especially the ships. It's a shame there aren't any ships in the TAW campaigns.

Share this post


Link to post
Share on other sites

You are very right with aswan_q. I have tracked it down to invalid vertex indices which access out-of-bound vertices with bogus data:

Total Air War .3 File Viewer beta 2

by Pjotr Krycztij 2011

special thanks to mikew, DrKevDog and the COMBATSIM.COM community


loading 8258 words ... done

searching levels of detail ...

        found LoD #0: 0-8000

determining file type ... 00A3

trying to find beginning of bytecode ... 45 words

trying to find beginning of LOD's ...

loading LOD's ...

Direct3D 9 (SDK version (32 | 0x80000000))

auto-selected hardware vertex processing

trying to create a Direct3D 9 device (1388×767, 4× AA, windowed)

successfully created a Direct3D device on ATI Radeon HD 5700 Series

        provides 718 MiB of VRAM

        supports vs_3_0 and ps_3_0

16× anisotropic filtering selected

0093 jump 4 B if ??? (true)

0027 jump 8 B if distance is above 6000 (false)

007B jump 4 B if ??? (true)

0076 jump 4 B if ??? (true)

0008 call 140 B

0062 write XYZ #0: -1024 0 -1024

0064 write XYZ #1 with X delta: -512 0 -1024

0064 write XYZ #2 with X delta: 0 0 -1024

0064 write XYZ #3 with X delta: 512 0 -1024

0064 write XYZ #4 with X delta: 1024 0 -1024

0066 write XYZ #5 with Z delta: 1024 0 -506

0064 write XYZ #6 with X delta: -512 0 -506

0066 write XYZ #7 with Z delta: -512 0 1024

0064 write XYZ #8 with X delta: -1024 0 1024

0064 write XYZ #9 with X delta: 0 0 1024

0066 write XYZ #10 with Z delta: 0 0 0

0064 write XYZ #11 with X delta: -774 0 0

0067 write XYZ #12 with XY delta: -1024 -85 0

0064 write XYZ #13 with X delta: 512 -85 0

0067 write XYZ #14 with XY delta: 1024 -60 0

0069 write XYZ #15 with YZ delta: 1024 -85 512

0064 write XYZ #16 with X delta: -1024 -85 512

0067 write XYZ #17 with XY delta: 100 -6 512

0064 write XYZ #18 with X delta: -583 -6 512

0064 write XYZ #19 with X delta: -393 -6 512

0064 write XYZ #20 with X delta: -221 -6 512

0065 write XYZ #21 with Y delta: -221 -500 512

0067 write XYZ #22 with XY delta: 512 -49 512

0069 write XYZ #23 with YZ delta: 512 0 1024

0064 write XYZ #24 with X delta: 1024 0 1024

0064 write XYZ #25 with X delta: -768 0 1024

0068 write XYZ #26 with XZ delta: -266 0 180

0066 write XYZ #27 with Z delta: -266 0 180

0064 write XYZ #28 with X delta: -665 0 180

0064 write XYZ #29 with X delta: -512 0 180

0066 write XYZ #30 with Z delta: -512 0 32

0064 write XYZ #31 with X delta: -419 0 32

0068 write XYZ #32 with XZ delta: -244 0 117

0066 write XYZ #33 with Z delta: -244 0 117

0065 write XYZ #34 with Y delta: -244 -21 117

0068 write XYZ #35 with XZ delta: -752 -21 -512

0067 write XYZ #36 with XY delta: 400 -15 -512

0065 write XYZ #37 with Y delta: 400 -500 -512

0064 write XYZ #38 with X delta: -843 -500 -512

0065 write XYZ #39 with Y delta: -843 -17 -512

0068 write XYZ #40 with XZ delta: -281 -17 317

0068 write XYZ #41 with XZ delta: -195 -17 250

0069 write XYZ #42 with YZ delta: -195 -1 251

0068 write XYZ #43 with XZ delta: -287 -1 274

0067 write XYZ #44 with XY delta: -284 -17 274

0069 write XYZ #45 with YZ delta: -284 -3 319

0068 write XYZ #46 with XZ delta: -164 -3 353

0068 write XYZ #47 with XZ delta: -30 -3 256

0063 write XYZ #48 with XYZ delta: -105 -24 4

0065 write XYZ #49 with Y delta: -105 0 4

0068 write XYZ #50 with XZ delta: -189 0 -38

0066 write XYZ #51 with Z delta: -189 0 -38

0065 write XYZ #52 with Y delta: -189 -11 -38

0065 write XYZ #53 with Y delta: -189 -18 -38

0068 write XYZ #54 with XZ delta: -170 -18 355

0063 write XYZ #55 with XYZ delta: -900 -41 -200

0068 write XYZ #56 with XZ delta: -780 -41 -283

0064 write XYZ #57 with X delta: -90 -41 -283

0068 write XYZ #58 with XZ delta: -650 -41 -337

0064 write XYZ #59 with X delta: -221 -41 -337

0068 write XYZ #60 with XZ delta: -512 -41 -368

0064 write XYZ #61 with X delta: -358 -41 -368

0068 write XYZ #62 with XZ delta: 56 -41 -229

0068 write XYZ #63 with XZ delta: 194 -41 -176

0068 write XYZ #64 with XZ delta: -665 -41 -475

0065 write XYZ #65 with Y delta: -665 -24 -475

0068 write XYZ #66 with XZ delta: -819 -24 -421

0066 write XYZ #67 with Z delta: -819 -24 -421

0068 write XYZ #68 with XZ delta: 271 -24 -299

0066 write XYZ #69 with Z delta: 271 -24 -299

0068 write XYZ #70 with XZ delta: -512 -24 -506

0065 write XYZ #71 with Y delta: -512 -41 -506

0064 write XYZ #72 with X delta: -331 -41 -506

0065 write XYZ #73 with Y delta: -331 -24 -506

0067 write XYZ #74 with XY delta: -1024 -7 -506

0067 write XYZ #75 with XY delta: 512 -11 -506

0067 write XYZ #76 with XY delta: 0 -500 -506

0065 write XYZ #77 with Y delta: 0 -13 -506

0063 write XYZ #78 with XYZ delta: -596 0 56

0064 write XYZ #79 with X delta: -336 0 56

0068 write XYZ #80 with XZ delta: -679 0 117

0064 write XYZ #81 with X delta: -512 0 117

0064 write XYZ #82 with X delta: -407 0 117

0068 write XYZ #83 with XZ delta: -67 0 23

0065 write XYZ #84 with Y delta: -67 -15 23

0068 write XYZ #85 with XZ delta: -623 -15 -130

0067 write XYZ #86 with XY delta: -151 -23 -130

0067 write XYZ #87 with XY delta: -742 -30 -130

0064 write XYZ #88 with X delta: 7 -30 -130

0067 write XYZ #89 with XY delta: -274 -19 -130

0067 write XYZ #90 with XY delta: -512 -10 -130

0067 write XYZ #91 with XY delta: 171 -38 -130

0067 write XYZ #92 with XY delta: -389 -14 -130

0068 write XYZ #93 with XZ delta: -212 -14 357

0063 write XYZ #94 with XYZ delta: -186 -41 -467

0065 write XYZ #95 with Y delta: -186 -24 -467

0068 write XYZ #96 with XZ delta: -36 -24 -414

0065 write XYZ #97 with Y delta: -36 -41 -414

0068 write XYZ #98 with XZ delta: 118 -41 -358

0065 write XYZ #99 with Y delta: 118 -24 -358

0063 write XYZ #100 with XYZ delta: -178 -5 150

0065 write XYZ #101 with Y delta: -178 -22 150

0063 write XYZ #102 with XYZ delta: 270 -32 0

0063 write XYZ #103 with XYZ delta: 39 -15 77

0065 write XYZ #104 with Y delta: 39 0 77

0065 write XYZ #105 with Y delta: 39 -500 77

0063 write XYZ #106 with XYZ delta: -199 -2 362

0063 write XYZ #107 with XYZ delta: -263 -19 180

0063 write XYZ #108 with XYZ delta: -828 -34 187

0061 ??? (0/109)

0015 jump 12 B if triangle 16-21-22 is invisible (false)

0008 call 48 B

0015 jump 12 B if triangle 74-38-5 is invisible (false)

0008 call 186 B

0027 jump 1512 B if distance is above 6000 (false)

002E write polygon UV: texture 0; 0/96 0/120 8/119

002F draw textured polygon: 0-74-39

002E write polygon UV: texture 0; 0/96 8/119 12/119

002F draw textured polygon: 0-39-35

002E write polygon UV: texture 0; 0/96 12/119 23/120

002F draw textured polygon: 0-35-70

002E write polygon UV: texture 0; 0/96 23/120 23/96

002F draw textured polygon: 0-70-1

002E write polygon UV: texture 0; 23/96 23/120 32/120

002F draw textured polygon: 1-70-73

002E write polygon UV: texture 0; 32/120 47/96 23/96

002F draw textured polygon: 73-2-1

002E write polygon UV: texture 0; 47/96 32/120 47/120

002F draw textured polygon: 2-73-77

002E write polygon UV: texture 0; 47/120 71/96 47/96

002F draw textured polygon: 77-3-2

002E write polygon UV: texture 0; 71/96 47/120 66/119

002F draw textured polygon: 3-77-36

002E write polygon UV: texture 0; 71/96 66/119 71/120

002F draw textured polygon: 3-36-75

002E write polygon UV: texture 0; 71/120 95/96 71/96

002F draw textured polygon: 75-4-3

002E write polygon UV: texture 0; 71/120 95/120 95/96

002F draw textured polygon: 75-5-4

0000 return

0008 call 14 B

0015 jump 28 B if triangle 20-36-37 is invisible (true)

0008 call 24 B

0015 jump 12 B if triangle 19-77-76 is invisible (true)

0008 call 46 B

0015 jump 16 B if triangle 18-39-38 is invisible (false)

0008 call 2326 B

0047 write polygon UV: texture 60; 20/23 23/39 16/39

002F draw textured polygon: 18-29-28

0047 write polygon UV: texture 60; 20/23 33/23 23/39

002F draw textured polygon: 18-19-29

0047 write polygon UV: texture 60; 33/23 35/39 23/39

002F draw textured polygon: 19-27-29

0047 write polygon UV: texture 66; 49/171 77/172 95/177

002F draw textured polygon: 81-78-80

0047 write polygon UV: texture 66; 49/171 57/170 77/172

002F draw textured polygon: 81-30-78

0047 write polygon UV: texture 66; 49/177 37/170 57/170

002F draw textured polygon: 81-31-30

0047 write polygon UV: texture 66; 49/177 30/177 37/170

002F draw textured polygon: 81-82-31

0047 write polygon UV: texture 66; 30/177 18/172 37/170

002F draw textured polygon: 82-79-31

0047 write polygon UV: texture 66; 30/177 0/177 18/172

002F draw textured polygon: 82-33-79

0047 write polygon UV: texture 66; 95/191 58/191 49/178

002F draw textured polygon: 28-29-81

0047 write polygon UV: texture 66; 58/191 0/191 30/178

002F draw textured polygon: 29-27-82

0047 write polygon UV: texture 66; 58/191 30/178 49/178

002F draw textured polygon: 29-82-81

0047 write polygon UV: texture 66; 95/191 49/178 95/178

002F draw textured polygon: 28-81-80

0047 write polygon UV: texture 66; 30/178 0/191 0/178

002F draw textured polygon: 82-27-33

002E write polygon UV: texture 0; 23/120 12/119 16/121

002F draw textured polygon: 70-35-65

002E write polygon UV: texture 0; 9/123 16/121 12/119

002F draw textured polygon: 67-65-35

002E write polygon UV: texture 0; 12/119 8/119 9/123

002F draw textured polygon: 35-39-67

002E write polygon UV: texture 0; 32/120 38/121 47/120

002F draw textured polygon: 73-95-77

002E write polygon UV: texture 0; 38/121 45/124 47/120

002F draw textured polygon: 95-96-77

0047 write polygon UV: texture 66; 95/116 95/151 82/151

002F draw textured polygon: 87-80-78

0047 write polygon UV: texture 66; 95/116 82/151 82/121

002F draw textured polygon: 87-78-85

0047 write polygon UV: texture 66; 82/121 82/151 68/151

002F draw textured polygon: 85-78-30

0047 write polygon UV: texture 66; 82/121 68/151 68/124

002F draw textured polygon: 85-30-90

0047 write polygon UV: texture 66; 68/124 68/151 55/151

002F draw textured polygon: 90-30-31

0047 write polygon UV: texture 66; 68/124 55/151 55/124

002F draw textured polygon: 90-31-92

0047 write polygon UV: texture 66; 41/121 55/124 55/151

002F draw textured polygon: 89-92-31

0047 write polygon UV: texture 66; 41/121 55/151 41/151

002F draw textured polygon: 89-31-79

0047 write polygon UV: texture 66; 28/115 41/121 28/128

002F draw textured polygon: 86-89-52

0047 write polygon UV: texture 66; 41/121 41/151 28/128

002F draw textured polygon: 89-79-52

0047 write polygon UV: texture 66; 28/128 41/151 28/151

002F draw textured polygon: 52-79-33

0047 write polygon UV: texture 66; 95/96 95/114 82/121

002F draw textured polygon: 56-87-85

0047 write polygon UV: texture 66; 95/96 82/121 82/96

002F draw textured polygon: 56-85-58

0047 write polygon UV: texture 66; 82/96 82/121 68/124

002F draw textured polygon: 58-85-90

0047 write polygon UV: texture 66; 82/96 68/124 68/96

002F draw textured polygon: 58-90-60

0047 write polygon UV: texture 66; 68/96 68/124 55/124

002F draw textured polygon: 60-90-92

0047 write polygon UV: texture 66; 68/96 55/124 55/96

002F draw textured polygon: 60-92-61

0047 write polygon UV: texture 66; 41/96 55/96 55/124

002F draw textured polygon: 59-61-92

0047 write polygon UV: texture 66; 41/96 55/124 41/121

002F draw textured polygon: 59-92-89

0047 write polygon UV: texture 66; 28/96 41/96 41/121

002F draw textured polygon: 57-59-89

0047 write polygon UV: texture 66; 28/96 41/121 28/115

002F draw textured polygon: 57-89-86

0047 write polygon UV: texture 66; 0/167 0/152 13/152

002F draw textured polygon: 66-56-58

0047 write polygon UV: texture 66; 0/167 13/152 13/167

002F draw textured polygon: 66-58-64

0047 write polygon UV: texture 66; 13/167 13/152 28/152

002F draw textured polygon: 64-58-60

0047 write polygon UV: texture 66; 13/167 28/152 28/167

002F draw textured polygon: 64-60-71

0047 write polygon UV: texture 66; 28/167 28/152 41/152

002F draw textured polygon: 71-60-61

0047 write polygon UV: texture 66; 28/167 41/152 41/167

002F draw textured polygon: 71-61-72

0047 write polygon UV: texture 66; 55/167 41/167 41/152

002F draw textured polygon: 94-72-61

0047 write polygon UV: texture 66; 55/167 41/152 55/152

002F draw textured polygon: 94-61-59

0047 write polygon UV: texture 66; 68/167 55/167 55/152

002F draw textured polygon: 97-94-59

0047 write polygon UV: texture 66; 68/167 55/152 68/152

002F draw textured polygon: 97-59-57

004C fetch triangle colors

0080 draw Gouraud-shaded triangle 66-64-65 with colors 49, 49, 41

004E fetch quad colors

0081 draw Gouraud-shaded quad 64-71-70-65 with colors 49, 49, 41, 41

004E fetch quad colors

0081 draw Gouraud-shaded quad 71-72-73-70 with colors 49, 49, 41, 41

004E fetch quad colors

0081 draw Gouraud-shaded quad 72-94-95-73 with colors 49, 49, 41, 41

004E fetch quad colors

0081 draw Gouraud-shaded quad 94-97-96-95 with colors 49, 49, 41, 41

0000 return

0008 call 366 B

0027 jump 1236 B if distance is above 6000 (false)

002E write polygon UV: texture 0; 0/120 9/123 8/119

002F draw textured polygon: 74-67-39

002E write polygon UV: texture 0; 0/120 5/134 9/123

002F draw textured polygon: 74-55-67

002E write polygon UV: texture 0; 5/134 11/130 9/123

002F draw textured polygon: 55-56-67

002E write polygon UV: texture 0; 5/134 13/137 11/130

002F draw textured polygon: 55-87-56

002E write polygon UV: texture 0; 5/134 0/143 13/137

002F draw textured polygon: 55-12-87

002E write polygon UV: texture 0; 0/143 16/148 13/137

002F draw textured polygon: 12-80-87

002E write polygon UV: texture 0; 0/143 5/134 0/120

002F draw textured polygon: 12-55-74

0000 return

0008 call 842 B

0027 jump 836 B if distance is above 6000 (false)

002E write polygon UV: texture 0; 0/143 9/152 16/148

002F draw textured polygon: 12-108-80

002E write polygon UV: texture 0; 9/152 16/151 16/148

002F draw textured polygon: 108-28-80

002E write polygon UV: texture 0; 9/152 20/167 16/151

002F draw textured polygon: 108-18-28

002E write polygon UV: texture 0; 9/152 0/167 20/167

002F draw textured polygon: 108-16-18

002E write polygon UV: texture 0; 9/152 0/143 0/167

002F draw textured polygon: 108-12-16

0000 return

0000 return

0008 call 4 B

0015 jump 16 B if triangle 52-105-104 is invisible (false)

0008 call 9628 B

0047 write polygon UV: texture 60; 49/43 36/42 35/39

002F draw textured polygon: 104-33-27

0047 write polygon UV: texture 60; 49/43 43/45 36/42

002F draw textured polygon: 104-83-33

0047 write polygon UV: texture 60; 43/45 38/47 36/42

002F draw textured polygon: 83-51-33

0047 write polygon UV: texture 60; 49/43 35/39 37/23

002F draw textured polygon: 104-27-20

0047 write polygon UV: texture 60; 35/39 33/23 37/23

002F draw textured polygon: 27-19-20

0008 call 1036 B

0052 ???

0062 write XYZ #159: -115 0 112

0075 ???

002D jump 4 B if ??? (true)

0053 ???

0061 ??? (160/17)

002D jump 172 B if ??? (true)

0053 ???

0061 ??? (177/4)

0047 write polygon UV: texture 58; 1/129 63/129 63/191 1/191

0088 draw textured polygon: 177-178-179-180 <=== THIS IS THE OUT-OF-RANGE VERTEX ACCESS

There are only 109 vertices defined, but 180 accessed. It's line 1524 in your output, I guess. I don't know why this happens. Looks like it's gonna be a long night.

Edit: It has something to do with the 002D flag. If you disable, the dam is rendered normal.

Share this post


Link to post
Share on other sites

There are 195 vertices in aswan_q. The total number of vertices in any particular model is given by the word immediately before the start of the bytecode.

The later vertices are defined by 0053 opcodes which I haven't got round to investigating, although my best guess is that a sequence of vertices is defined explicitly rather than using the delta method.

These are exciting times and I don't know what to look at next. :)

Share this post


Link to post
Share on other sites

No, they define the vertex indices. The color palette indices are given in 009F.

Thanks. As I said, those were old notes and I didn't have time earlier to check it

Mike's source code also covers the case of the 4th word is 0900. Any idea on that? Is it just dead code from an early draft or does this actually occur?

Working on it.

Unrelated: I think heavenky.3 contains the stars. Anyone wants to implement real stars, e.g. from Yale Bright Star Catalogue? :)

Now those are some serious stars ;) That would certainly add a nice effect.

Share this post


Link to post
Share on other sites

The later vertices are defined by 0053 opcodes which I haven't got round to investigating, although my best guess is that a sequence of vertices is defined explicitly rather than using the delta method.

Exactly. I have just implemented 0053 as


// 0053 <number> <base index> (<x> <y> <z>)[<number>]

// Write <number> 3D positions starting at <base index>.

and it works well: The distance is okay at aswan_q, and also in all the Sukhoi-type models which had required reducing "parameter" before.

One thing I noticed: The very first frame you see at startup in aswan_q (before auto-distance reacts) looks like a cloud:

cloudsl.png

I don't know if it's a bug in the viewer, a real cloud or the dummy model for a flood. Very interesting though -- we can't see it because it is just under the surface.

Working on it.
Thanks. I'll see what those models look like, now that mikew has listed them.

Share this post


Link to post
Share on other sites

There are very interesting things everywhere I look...

I'll probably go back to simpler models that I know quite well and see what the viewer does. For instance, tent_3.3 seems to be missing its texture and shadows although the LOD selection (based on 0027) works well.

You post some sort of log a couple of posts up. It would be good to compare a single traversal through the bytecode with what we expect to happen, so is it possible for me to use this feature?

Share this post


Link to post
Share on other sites

For instance, tent_3.3 seems to be missing its texture and shadows although the LOD selection (based on 0027) works well.

I have not yet implemented red****.ini, that's why the building texture flag is hard-coded to zero. 009D/009E render vertex colors only. Of course I'll change it as soon as the INI parser works.

You post some sort of log a couple of posts up. It would be good to compare a single traversal through the bytecode with what we expect to happen, so is it possible for me to use this feature?

Currently, this is only available to me via the debugger. I am, however, currently working on implementing a debug mode: The viewer will start up without the instructions written out to the console, but if you hit the "break" key, the rendering stops and the console prints the instructions as you know it, stopping after each frame until you press a key. You have the chance to analyse and copy the whole output then.

This will also greatly improve rendering performance as the console output is the ultimate bottleneck at the moment. There is, however, one problem: If a rule violation occurs, the error window will be all the information you have. There will be no trace of instructions in the console while it is not in debug mode. I am optimistic that this won't be much of a problem because there are not many rule violations at the moment and we're steadily improving the stability. But I think it will be really uncomfortable if we actually start modding files.

I'll upload the new build in a few hours.

Share this post


Link to post
Share on other sites

Sounds good. :thumbsup:

By the way, judging by the runway end files, you have worked out what the 0030 opcode does. I had it down as a scaling function, but didn't know whether it was simply a case of multiplying xyz by the operand.

Share this post


Link to post
Share on other sites

By the way, judging by the runway end files, you have worked out what the 0030 opcode does. I had it down as a scaling function, but didn't know whether it was simply a case of multiplying xyz by the operand.

No, I haven't really. I'm just dividing by the operand (when you have 65535 discrete coordinates on each axis, and models like AIM-9X are just two meters long, then you actually want to scale up the model to have these two meters covering more discrete coordinates, i.e. to have higher precision -- so you must divide by the scale factor upon rendering to get down to your two meters again) and it seems to match somehow.

But I don't think these are final coordinates: We have the whole region covering 2000 x 2000 km in a 400 x 400 tiles map, that's 5 x 5 km per tile. Tile coordinates do actually range from -1024 to +1024, so there must be an additional scale factor somewhere. Either that or TAW uses another coordinate base, e.g. NM/1000. (I don't think so, because the Red Sea Region is really really close to 2000 km sidelength.) But I'm sure you have more knowledge on that than I have :)

Share this post


Link to post
Share on other sites

Je vous présente l'update :)

http://www.mediafire.com/?ts5t9iatzw6ws79

  • 0053 implemented (fixes distance glitches in aswan_q and various Sukhoi models)
  • Instruction dump can be enabled/disabled via F12 (copy from the console via right-click onto the console window icon on the top left, Edit -> Select All, Return key)
  • Minor stability & performance improvements
  • Minor fixes to debug output and consistency checks

If we want to find out about the translation offsets, zsu_23_4.3 should be a good starting point:

zsu.png

Share this post


Link to post
Share on other sites

I know you've probably not yet tested the old version but here's already a new one (I was bored ;) ):

http://www.mediafire.com/?ebz65gz3igecns2

  • Quicker loading time due to precompiled shaders
  • Disabled default wireframe and default damage
  • Prevented buffer overruns on invalid texture coordinate instructions

Some models like F-15 are nearly of in-game quality now. Other, like F-16UB, still won't load :/

eagleb.png

Oh and I didn't know the Eurofighter model had a breaking chute :o

Share this post


Link to post
Share on other sites

Actually, I had downloaded it 5 minutes before you posted. :)

...but got the latest one now, and aswan_q is looking good....as is a lot of other stuff.

Testing ongoing.....although 'Parameter' really needs to be split up now.

Share this post


Link to post
Share on other sites

Just wanted to chime in and tell you guys to keep up the good work.

If we cannot get a hold of the source, what you guys achieve is the second best thing and that is reverse engineering.

Share this post


Link to post
Share on other sites

Just wanted to chime in and tell you guys to keep up the good work.

If we cannot get a hold of the source, what you guys achieve is the second best thing and that is reverse engineering.

:thumbsup:

Share this post


Link to post
Share on other sites

Thank you again!

Here is a quick update with TAW-like mouse controls. Click and hold the left mouse button to rotate the model, click and hold the right mouse button to scale its distance.

http://www.mediafire.com/?d7uqps8xvsz6uwx

'Parameter' really needs to be split up now.

Okay. Let's see which conditional jumps are implemented:


// Fully implemented

0015 jump if triangle is invisible

0027 jump if distance is above


// These will require to a) find all parameters and  to implement the 0048 ("select XXXX as parameter"?) instruction

0007 jump if damage flag is set

0020 jump if parameter is below

0021 jump if parameter equals

0022 jump if parameter is above


// These are just emulated with hard-coded flags and I don't know their meaning:

0024

0025

0026

002D

003F jump if lights on?

0040

0041

0042

0043 jump if time of day equals?

0049

004B

0076

007B

007C

0087

0093[/code]

Any more flags? Are these all using distinct parameters, e.g. test 0024, 0025 and 0026 for distinct parameters or do they test the same parameter for below/equality/above? Clues on what the unknown jumps mean or do? Which parameters are just flags, which are values?

And this is to remind myself when I come home: Eventually implement the 0004 instruction!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...