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 ); |
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"); |
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. |
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:
|
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. |
How to code the faces output.
Given there are 10000 faces? Each line must follow the formula below. The loop will be slow but should work. This is NOT actual code but gives the information to code the needed loop. ---C1------ C2------ C3---- C4 f 1/101 102/100 103/201 2/202 f 2/202 103/201 104/302 3/303 C1 = +1/+101 C2 = +1/+101 C3 = +1/+101 C4 = +1/+101 |
At first look you may think we need a double loop like for the Textures.
Actually a single loop will work for our needs so speed goes up. Look close at the faces ints and the pattern. You may think 8 ints are needed. |
Quote:
|
The support from SweetScape is one big reason I pay to stay updated.
:yeah: |
Have you figured out the loop needed to output 10000 faces yet?
And the MINIMUM number of ints needed to do it? :haha: If your answer is above 3 ints? :o Your wrong! :03: |
Is there a way to do like a "Do Loop Until EOF"? :salute:
|
We only need one looping function to do everything.
I have 3 ints assigned in my loop right now. 2 only control the number of loops I do. The other is for kicking out the faces information. I take advantage of the Printf function to do the math. :03: Here's an example.............. f=(f+1); Printf("f %u", f); Printf( "/%u ", f=(f+100) ); Those lines print out 1/101 That's the first part of a face. Each line of Printf needs to be coded or numbers go real FUBAR! What I mean by that is that using f on a single line in Printf can corrupt the data. By using different lines? It preserves the true value of f for further math. BUT! We can loop the code to print out all 10000 lines easily. |
Nice. I keep confusing "program code" and "scripting"... In other words, I want to write an application in one fell swoop. You're getting the data and its structure, to be used in an app... baby steps. must take baby steps pb... :salute:
|
010 uses a C 'LIKE' code. That means it is not a fully functioning C compliant scripting language.
So it does have it's quirks. |
OK. I lied on the ints needed.
You only need 1 int. :har: I'm going to introduce you to Arrays so you understand why I only need 1 int. //------------------------------------------------ //--- 010 Editor Script File // RAW to object file add in // Adds the Faces // //------------------------------------------------ // all the code for Faces below int f[5]; f[1]=10000; for (f[2] = 0; f[2] < f[1]; f[2]++) { f[3]=(f[3]+1); Printf("f %u/%u\n ", f[3], f[4]=(f[3]+100)); } It's a cheat I'll admit. But allows a single Printf function to print the information with no corruption of data. |
Say uh, does 010 count from zero for arrays (actually, anything), like ANSI C? :salute:
|
Dat files
Hello Jeff,
Would it be possible for 010 to list all T0 / A0 / B0 nodes in each dat, within a folder, like Air or Sea ? So output could be: Unit Name T01 / T02 / A01 / B01 / B02 etc. Without having to open each dat with S3D and count them manually ? Or a template, so that we could enter our own search functions ? |
The findinfiles function will do that.
Granted you'd need to add some coding to jump past any T01 dds references. |
01000110 01110010 01100101 01100001 01101011 01101001 01101110 00100111 00100000 01010100 01100101 01100011 01101000 01101110 01101111 01101101 01100001 01100111 01100101 01110011 00100001
:D:doh::03: :arrgh!: |
Thanks Kpt. Lehmann
Us Freaking Technomages will carry on. :03: I saw a post about removing Map Contacts. In that post it was stated how much work that would be for several hundreds of ships. So...... Shall I do a script to demonstrate how that can be done? :03: |
All times are GMT -5. The time now is 03:35 PM. |
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.