SUBSIM Radio Room Forums

SUBSIM Radio Room Forums (https://www.subsim.com/radioroom/index.php)
-   SH4 Mods Workshop (https://www.subsim.com/radioroom/forumdisplay.php?f=219)
-   -   [TEC] SweetScape 010 Editor (https://www.subsim.com/radioroom/showthread.php?t=239565)

Jeff-Groves 01-26-19 08:23 PM

Once upon a time..............
(Yeah things start with that to this day!)
The only way to work with the files was in Hex.
Most of the early tools did that even if one did not know it was hex work.
Some of the (Actually all the best) Modders worked the files in Hex.
Those were the days before S3D which one person called a "Dumb down tool"
On that I have 2 opinions.
1. Yes.
It did open the door to just being ignorant of the TRUE file structure and hoping it would do EVERYTHING you wanted to do.

2. No.
Blended with a GOOD Hex editor? One can do things in less time than S3D alone can never do.

In Modding SH series of Games always look for the best Tools and ways of doing it. Years of modding with subpar tools have lost a lot of good modders.

Jeff-Groves 01-27-19 11:59 AM

Been expanding the script to read (False) RAW terrain files in SH5 to now export the information to the Object file format.
That will allow us to SEE the (False) RAW terrain files in a 3D program.
:up:

SH3/4 use a different (True) RAW format then SH5. However. It should be possible to do the same thing for SH3/4 IF the height values
are the same based on info We have.

Jeff-Groves 01-27-19 01:57 PM

Testing has proven the RAW files are inverted in SH5.
Not surprising in a way. Just have to adjust the scripts now.

Tycho 01-28-19 08:21 AM

Quote:

Originally Posted by Jeff-Groves (Post 2588664)
It should be possible to do the same thing for SH3/4 IF the height values are the same based on info We have.

I have sh3 elevations table, extracted from sh3.exe!
Most part look the same like the one posted in "The SH5 EcoMod" thread, but have some differences.
Underwater is different near the shore, and 0-64 band is different. The rest look the same.
When go home tonight, I'll post it if you need it.
I did some experiments there, but now will be interested to change sh3 elevation table with this one from sh5, and to see the result.

Jeff-Groves 01-28-19 01:12 PM

That information would be useful. We could then create a 3D model of the SH3/4 terrain one could work with in any 3D program.

Tycho 01-28-19 03:40 PM

SH3 Terrain elevations table
 

//SH3 Terrain elevations table
//0x530ac0
//0-47 = Underwater
//48-255 = Above-water

// Underwater
0 - 0xc4bb8000 = -1500.0
1 - 0xc3e00000 = -448.0
2 - 0xc3d00000 = -416.0
3 - 0xc3c00000 = -384.0
4 - 0xc3b00000 = -352.0
5 - 0xc3a00000 = -320.0
6 - 0xc3900000 = -288.0
7 - 0xc3800000 = -256.0
8 - 0xc36a0000 = -234.0
9 - 0xc35c0000 = -220.0
10 - 0xc3530000 = -211.0
11 - 0xc34a0000 = -202.0
12 - 0xc3410000 = -193.0
13 - 0xc3380000 = -184.0
14 - 0xc32f0000 = -175.0
15 - 0xc3260000 = -166.0
16 - 0xc31d0000 = -157.0
17 - 0xc3140000 = -148.0
18 - 0xc3090000 = -137.0
19 - 0xc3000000 = -128.0
20 - 0xc2f00000 = -120.0
21 - 0xc2de0000 = -111.0
22 - 0xc2d00000 = -104.0
23 - 0xc2c20000 = -97.0
24 - 0xc2b40000 = -90.0
25 - 0xc2aa0000 = -85.0
26 - 0xc2a00000 = -80.0
27 - 0xc2980000 = -76.0
28 - 0xc2900000 = -72.0
29 - 0xc2880000 = -68.0
30 - 0xc2800000 = -64.0
31 - 0xc2700000 = -60.0
32 - 0xc2600000 = -56.0
33 - 0xc2500000 = -52.0
34 - 0xc2400000 = -48.0
35 - 0xc2300000 = -44.0
36 - 0xc2200000 = -40.0
37 - 0xc2140000 = -37.0
38 - 0xc2080000 = -34.0
39 - 0xc1f80000 = -31.0
40 - 0xc1e00000 = -28.0
41 - 0xc1d00000 = -26.0
42 - 0xc1c00000 = -24.0
43 - 0xc1b00000 = -22.0
44 - 0xc1a00000 = -20.0
45 - 0xc1900000 = -18.0
46 - 0xc1880000 = -17.0
47 - 0xc1800000 = -16.0

// Above-water
48 - 0x40800000 = 4.0
49 - 0x40a00000 = 5.0
50 - 0x40c00000 = 6.0
51 - 0x41000000 = 8.0
52 - 0x41200000 = 10.0
53 - 0x41400000 = 12.0
54 - 0x41600000 = 14.0
55 - 0x41700000 = 15.0
56 - 0x41800000 = 16.0
57 - 0x41900000 = 18.0
58 - 0x41a00000 = 20.0
59 - 0x41b00000 = 22.0
60 - 0x41c00000 = 24.0
61 - 0x41d00000 = 26.0
62 - 0x41e00000 = 28.0
63 - 0x41f00000 = 30.0
64 - 0x42000000 = 32.0
65 - 0x42080000 = 34.0
66 - 0x42100000 = 36.0
67 - 0x42180000 = 38.0
68 - 0x42200000 = 40.0
69 - 0x42280000 = 42.0
70 - 0x42300000 = 44.0
71 - 0x42380000 = 46.0
72 - 0x42400000 = 48.0
73 - 0x42480000 = 50.0
74 - 0x42500000 = 52.0
75 - 0x42580000 = 54.0
76 - 0x42600000 = 56.0
77 - 0x42680000 = 58.0
78 - 0x42700000 = 60.0
79 - 0x42780000 = 62.0
80 - 0x42800000 = 64.0
81 - 0x42880000 = 68.0
82 - 0x42900000 = 72.0
83 - 0x42980000 = 76.0
84 - 0x42a00000 = 80.0
85 - 0x42a80000 = 84.0
86 - 0x42b00000 = 88.0
87 - 0x42b80000 = 92.0
88 - 0x42c00000 = 96.0
89 - 0x42c80000 = 100.0
90 - 0x42d00000 = 104.0
91 - 0x42d80000 = 108.0
92 - 0x42e00000 = 112.0
93 - 0x42e80000 = 116.0
94 - 0x42f00000 = 120.0
95 - 0x42f80000 = 124.0
96 - 0x43000000 = 128.0
97 - 0x43040000 = 132.0
98 - 0x43080000 = 136.0
99 - 0x430c0000 = 140.0
100 - 0x43100000 = 144.0
101 - 0x43140000 = 148.0
102 - 0x43180000 = 152.0
103 - 0x431c0000 = 156.0
104 - 0x43200000 = 160.0
105 - 0x43240000 = 164.0
106 - 0x43280000 = 168.0
107 - 0x432c0000 = 172.0
108 - 0x43300000 = 176.0
109 - 0x43340000 = 180.0
110 - 0x43380000 = 184.0
111 - 0x433c0000 = 188.0
112 - 0x43400000 = 192.0
113 - 0x43480000 = 200.0
114 - 0x43500000 = 208.0
115 - 0x43580000 = 216.0
116 - 0x43600000 = 224.0
117 - 0x43680000 = 232.0
118 - 0x43700000 = 240.0
119 - 0x43780000 = 248.0
120 - 0x43800000 = 256.0
121 - 0x43840000 = 264.0
122 - 0x43880000 = 272.0
123 - 0x438c0000 = 280.0
124 - 0x43900000 = 288.0
125 - 0x43940000 = 296.0
126 - 0x43980000 = 304.0
127 - 0x439c0000 = 312.0
128 - 0x43a00000 = 320.0
129 - 0x43a40000 = 328.0
130 - 0x43a80000 = 336.0
131 - 0x43ac0000 = 344.0
132 - 0x43b00000 = 352.0
133 - 0x43b40000 = 360.0
134 - 0x43b80000 = 368.0
135 - 0x43bc0000 = 376.0
136 - 0x43c00000 = 384.0
137 - 0x43c40000 = 392.0
138 - 0x43c80000 = 400.0
139 - 0x43cc0000 = 408.0
140 - 0x43d00000 = 416.0
141 - 0x43d40000 = 424.0
142 - 0x43d80000 = 432.0
143 - 0x43dc0000 = 440.0
144 - 0x43e00000 = 448.0
145 - 0x43e80000 = 464.0
146 - 0x43f00000 = 480.0
147 - 0x43f80000 = 496.0
148 - 0x44000000 = 512.0
149 - 0x44040000 = 528.0
150 - 0x44080000 = 544.0
151 - 0x440c0000 = 560.0
152 - 0x44100000 = 576.0
153 - 0x44140000 = 592.0
154 - 0x44180000 = 608.0
155 - 0x441c0000 = 624.0
156 - 0x44200000 = 640.0
157 - 0x44240000 = 656.0
158 - 0x44280000 = 672.0
159 - 0x442c0000 = 688.0
160 - 0x44300000 = 704.0
161 - 0x44340000 = 720.0
162 - 0x44380000 = 736.0
163 - 0x443c0000 = 752.0
164 - 0x44400000 = 768.0
165 - 0x44440000 = 784.0
166 - 0x44480000 = 800.0
167 - 0x444c0000 = 816.0
168 - 0x44500000 = 832.0
169 - 0x44540000 = 848.0
170 - 0x44580000 = 864.0
171 - 0x445c0000 = 880.0
172 - 0x44600000 = 896.0
173 - 0x44640000 = 912.0
174 - 0x44680000 = 928.0
175 - 0x446c0000 = 944.0
176 - 0x44700000 = 960.0
177 - 0x44780000 = 992.0
178 - 0x44800000 = 1024.0
179 - 0x44840000 = 1056.0
180 - 0x44880000 = 1088.0
181 - 0x448c0000 = 1120.0
182 - 0x44900000 = 1152.0
183 - 0x44940000 = 1184.0
184 - 0x44980000 = 1216.0
185 - 0x449c0000 = 1248.0
186 - 0x44a00000 = 1280.0
187 - 0x44a40000 = 1312.0
188 - 0x44a80000 = 1344.0
189 - 0x44ac0000 = 1376.0
190 - 0x44b00000 = 1408.0
191 - 0x44b40000 = 1440.0
192 - 0x44b80000 = 1472.0
193 - 0x44bc0000 = 1504.0
194 - 0x44c00000 = 1536.0
195 - 0x44c40000 = 1568.0
196 - 0x44c80000 = 1600.0
197 - 0x44cc0000 = 1632.0
198 - 0x44d00000 = 1664.0
199 - 0x44d40000 = 1696.0
200 - 0x44d80000 = 1728.0
201 - 0x44dc0000 = 1760.0
202 - 0x44e00000 = 1792.0
203 - 0x44e40000 = 1824.0
204 - 0x44e80000 = 1856.0
205 - 0x44ec0000 = 1888.0
206 - 0x44f00000 = 1920.0
207 - 0x44f40000 = 1952.0
208 - 0x44f80000 = 1984.0
209 - 0x45000000 = 2048.0
210 - 0x45040000 = 2112.0
211 - 0x45080000 = 2176.0
212 - 0x450c0000 = 2240.0
213 - 0x45100000 = 2304.0
214 - 0x45140000 = 2368.0
215 - 0x45180000 = 2432.0
216 - 0x451c0000 = 2496.0
217 - 0x45200000 = 2560.0
218 - 0x45240000 = 2624.0
219 - 0x45280000 = 2688.0
220 - 0x452c0000 = 2752.0
221 - 0x45300000 = 2816.0
222 - 0x45340000 = 2880.0
223 - 0x45380000 = 2944.0
224 - 0x453c0000 = 3008.0
225 - 0x45400000 = 3072.0
226 - 0x45440000 = 3136.0
227 - 0x45480000 = 3200.0
228 - 0x454c0000 = 3264.0
229 - 0x45540000 = 3392.0
230 - 0x45600000 = 3584.0
231 - 0x45680000 = 3712.0
232 - 0x45700000 = 3840.0
233 - 0x45780000 = 3968.0
234 - 0x457c0000 = 4032.0
235 - 0x45820000 = 4160.0
236 - 0x45860000 = 4288.0
237 - 0x458a0000 = 4416.0
238 - 0x458e0000 = 4544.0
239 - 0x4594d000 = 4762.0
240 - 0x45960000 = 4800.0
241 - 0x45a20000 = 5184.0
242 - 0x45a92000 = 5412.0
243 - 0x45b12000 = 5668.0
244 - 0x45b6b000 = 5846.0
245 - 0x45be0000 = 6080.0
246 - 0x45c20000 = 6208.0
247 - 0x45c92000 = 6436.0
248 - 0x45d04000 = 6664.0
249 - 0x45d76000 = 6892.0
250 - 0x45db6000 = 7020.0
251 - 0x45e36000 = 7276.0
252 - 0x45e76000 = 7404.0
253 - 0x45ee8000 = 7632.0
254 - 0x45f68000 = 7888.0
255 - 0x45fa0000 = 8000.0

Jeff-Groves 01-28-19 04:06 PM

Thanks Tycho.
I saved that information for future testing.
Now. The SH3/4 RAW files are 601 x 601 pixels and do use the 0 to 255 colors for height data. Viewing in a 3D program would greatly assist even SH3/4! Testing on the SH5 RAW files is going better then I expected so far.
RAW files from SH5 will read as a 201 x 201 if imported to Photoshop.
THAT IS A FALSE READING!!!
SH5 RAW files are 101 x 101 pixels (Not a very accurate definition).
They are 101 x 101 floats that give the height values of the given area.
MUCH more accurate the SH3/4.

@Tycho
Given you can tell me where to find that data in the SH3.exe? It may be possible to edit for a sharper shore line and maybe shoals effect!

propbeanie 01-28-19 08:33 PM

This is getting ~really~ good... High hopes! :salute:

Tycho 01-30-19 07:26 AM

Quote:

Originally Posted by Jeff-Groves (Post 2588852)
@Tycho
Given you can tell me where to find that data in the SH3.exe? It may be possible to edit for a sharper shore line and maybe shoals effect!

I don't know, probably it is matter of experiment with the elevation values and tests.

This year I decided to take a break from SH3.
Everything related is archived, and will rest for year or two.
So, I will not spend big amount of time and brain power for Silent Hunter.

Here, about terrain I can change this elevations table with sh5 one. Just for experiment, to see the result, and because will be quick and easy.
In fact, in sh3.exe have two such tables, the two are identical.
First one is at: 0x530ac0 /or: 00130ac0
And I saw where is used in the code.
Second one, at: 0x5314f0 /or: 001314f0
I don't saw where is used. Maybe is not used.
It is matter of experiment, are it also need to be changed, if I change the first one.

By address of the first one you can search where is used in the code section.
In this function, for example:
 

Code:

0x506FCE: 53                    PUSH        EBX                ; <==0x00506FC7(*-0x7)
0x506FCF: 33DB                  XOR        EBX,EBX           
0x506FD1: 85ED                  TEST        EBP,EBP           
0x506FD3: 0F8EA8000000          JLE        0x507081          ; (*+0xAE) 
0x506FD9: 56                    PUSH        ESI               
0x506FDA: 57                    PUSH        EDI               
0x506FDB: EB03                  JMP        0x506FE0          ; (*+0x5) 
0x506FDD: 8D4900                LEA        ECX,[ECX]         
0x506FE0: 8B44241C              MOV        EAX,DWORD PTR [ESP+0x1C]; <==0x00506FDB(*-0x5), 0x00507079(*+0x99)
0x506FE4: D90498                FLD        DWORD PTR [EAX+EBX*4]
0x506FE7: D9542410              FST        DWORD PTR [ESP+0x10]
0x506FEB: D81DC00E5300          FCOMP      DWORD PTR [0x530EC0]; .rdata:0x00 0x80 0xBB 0xC4
0x506FF1: DFE0                  FNSTSW      AX               
0x506FF3: F6C441                TEST        AH,0x41           
0x506FF6: 7A04                  JPE        0x506FFC          ; (*+0x6) 
0x506FF8: 32C0                  XOR        AL,AL             
0x506FFA: EB77                  JMP        0x507073          ; (*+0x79) 
0x506FFC: D9442410              FLD        DWORD PTR [ESP+0x10]; <==0x00506FF6(*-0x6)
0x507000: D81DA8AA5200          FCOMP      DWORD PTR [0x52AAA8]; .rdata:0x00 0x00 0xFA 0x45
0x507006: DFE0                  FNSTSW      AX               
0x507008: F6C401                TEST        AH,0x1           
0x50700B: 7504                  JNZ        0x507011          ; (*+0x6) 
0x50700D: 0CFF                  OR          AL,0xFF           
0x50700F: EB62                  JMP        0x507073          ; (*+0x64) 
0x507011: D9442410              FLD        DWORD PTR [ESP+0x10]; <==0x0050700B(*-0x6)
0x507015: D81DACDA5100          FCOMP      DWORD PTR [0x51DAAC]
0x50701B: DFE0                  FNSTSW      AX               
0x50701D: F6C441                TEST        AH,0x41           
0x507020: 7A0C                  JPE        0x50702E          ; (*+0xE) 
0x507022: BFC00A5300            MOV        EDI,0x530AC0      ; .rdata:0x00 0x80 0xBB 0xC4
0x507027: BE2F000000            MOV        ESI,0x2F         
0x50702C: EB0A                  JMP        0x507038          ; (*+0xC) 
0x50702E: BF800B5300            MOV        EDI,0x530B80      ; .rdata:0x00 0x00 0x80 0x40 ; <==0x00507020(*-0xE)
0x507033: BECF000000            MOV        ESI,0xCF         
0x507038: D9442410              FLD        DWORD PTR [ESP+0x10]; <==0x0050702C(*-0xC), 0x00507063(*+0x2B)
0x50703C: 8D46FF                LEA        EAX,[ESI-0x1]     
0x50703F: 99                    CDQ                           
0x507040: 2BC2                  SUB        EAX,EDX           
0x507042: 8BC8                  MOV        ECX,EAX           
0x507044: D1F9                  SAR        ECX,1             
0x507046: D81C8F                FCOMP      DWORD PTR [EDI+ECX*4]
0x507049: DFE0                  FNSTSW      AX               
0x50704E: 7A05                  JPE        0x507055          ; (*+0x7) 
0x507050: 8D7101                LEA        ESI,[ECX+0x1]     
0x507053: EB0B                  JMP        0x507060          ; (*+0xD) 
0x507055: 83CAFF                OR          EDX,0xFF          ; <==0x0050704E(*-0x7)
0x507058: 2BD1                  SUB        EDX,ECX           
0x50705A: 8D7C8F04              LEA        EDI,[EDI+ECX*4+0x4]
0x50705E: 03F2                  ADD        ESI,EDX           
0x507060: 83FE01                CMP        ESI,0x1            ; <==0x00507053(*-0xD)
0x507063: 7FD3                  JG          0x507038          ; (*-0x2B) 
0x507065: 8B4C2414              MOV        ECX,DWORD PTR [ESP+0x14]
0x507069: 8BC7                  MOV        EAX,EDI           
0x50706B: 2DC00A5300            SUB        EAX,0x530AC0      ; .rdata:0x00 0x80 0xBB 0xC4
0x507070: C1F802                SAR        EAX,0x2           
0x507073: 88040B                MOV        BYTE PTR [EBX+ECX],AL; <==0x00506FFA(*-0x79), 0x0050700F(*-0x64)
0x507076: 43                    INC        EBX               
0x507077: 3BDD                  CMP        EBX,EBP           
0x507079: 0F8C61FFFFFF          JL          0x506FE0          ; (*-0x99) 
0x50707F: 5F                    POP        EDI               
0x507080: 5E                    POP        ESI               
0x507081: 5B                    POP        EBX                ; <==0x00506FD3(*-0xAE)
0x507082: 8BC1                  MOV        EAX,ECX           
0x507084: 5D                    POP        EBP               
0x507085: 83C408                ADD        ESP,0x8           
0x507088: C3                    RET


Maybe is possible, let's say, to prioritise the underwater and to simplify the above water terrain. If give it more indexes.
Of course, this will require completely new map and elevations table, if now give 208 to the underwater and 48 to the ground:
The most of the world will go underwater (Sci-Fi mod: Waterworld :hmmm:).
To better understand it, I need to run it through debugger, but I will not.
Maybe is possible, this 601x601 also to be changed, I think, I once saw this somewhere there.

So, probably many things are possible if someone have desire to do it.

Jeff-Groves 01-30-19 10:55 AM

Tycho,

Thanks Mate!
:salute:

On taking a break? I myself do so from time to time. gap got me interested in the current 010 script to extract the information in the SH5 RAW files.
So far it will extract the heights and create an obj file that one can edit in any 3D program that imports the obj format.

A second script will convert the obj back to a RAW file.

Once the scripts are working as planned? A stand alone program will be done.

Jeff-Groves 01-30-19 12:50 PM

The start script to export SH5 terrain RAW files to the obj format.
This does all the x y z stuff but does not include the VT or faces code.
Nice looping example thought!
_____________________________________

//------------------------------------------------
//--- 010 Editor Script File
// RAW to object file .003
// Reads the DetailMask RAW files in SH5 and outputs an Object file
//
//------------------------------------------------
int i, l, t, s=101;
char W[40];


float x, y, z;
x=-2550;

for( i = 0; i < s; i++)
{
x=(x+50);
z=-2550;
l=101;

{
for( t = 0; t < l; t++)
{
y = ReadFloat();
z=(z+50);
Printf( "v %f %f %f\n", z, y, x );
FSkip(4);

}
}
}
Printf("Test");// all the code for textures and faces will follow
W = InputString("Save File", "Name your save file", "c:\\temp\\");// You can change the path when saving.
OutputPaneSave( W );

Jeff-Groves 01-31-19 01:24 PM

Had to send a possible bug report to SweetScape today!
:doh:

Run this script and you'll see the problem at line 84 or so.
This does not interfere with the stand alone C++ version I'm working on.
It only interferes with rapid prototype coding.
Given this error? It may show up as I finalize coding the faces stuff.


//------------------------------------------------
//--- 010 Editor Script File
// RAW to object file add in
// Adds the Textures
//
//------------------------------------------------
// all the code for textures coords below
int j, m, q=101, p;
float vt1=-0.00100000000003808065, vt2;






for( j = 0; j < q; j++)
{

vt1=(vt1+0.001);
vt2=-0.01;
m=101;

{
for( p = 0; p < m; p++)
{
vt2=(vt2+0.01);
Printf( "vt %f %f\n", vt1, vt2);

}
}
}
Printf("texture Testing. Error at texture coord 84");

Jeff-Groves 02-01-19 09:21 AM

Fixed script above by replacing float with double.

float vt1=-0.00100000000003808065, vt2;
to
double vt1=-0.00100000000003808065, vt2;

and changed the Printf function

Printf( "vt %f %f\n", vt1, vt2);
to
Printf( "vt %lf %lf\n", vt1, vt2);


Will triple check the output then move on to the faces scripting.

propbeanie 02-01-19 09:43 AM

Ah-HAA! So I'm not the only one with data type issues... shneaky little data bits... Glad you got that. Looking at the documentation, a Double is a "64-Bit Floating Point Number ", while a Float is a "32-Bit Floating Point Number", which with the files of the game, it would seem to make more sense to use a 32-bit data type, but... I suppose it has to do with the OS maybe?? :hmmm: - there are only the 3 types of 64-bit data types, the other two being "int". Does your earlier issue have to do with the rounding factor maybe?? Truncating the data maybe?? :hmmm: Thanks :salute:

Jeff-Groves 02-01-19 09:54 AM

It's a problem with floats.
From Graeme at SweetScape............

"The error you are seeing is caused because 'float' is not very accurate for doing a lot of computations. We tried your function in C++ and it gives the same issue. 'float' is just not very accurate and if you switch to 'double' it will be better, although double has accuracy issues as well for lots of computations."

Then next section (Faces) uses all ints so shouldn't have a problem.
:)

One thing I am doing is writing separate scripts for each part.
Verts, Vertical Textures, Faces are all separate scripts.
Makes catching errors easier.
The 1st script calls the next 2 in order just as if it was all one script.


All times are GMT -5. The time now is 05:41 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.