Outerra forum

Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => JavaScript development => Topic started by: Uriah on January 26, 2015, 12:17:22 am

Title: Display real-time data on any screen, HUD or MFD
Post by: Uriah on January 26, 2015, 12:17:22 am
It works!!!   :D 8) :)) ^-^

After weeks of slow progress I developed the optimal script to display any data on a screen updated in real time.

Without render to texture, I had to make multiple meshes per number/letter to be displayed. Each mesh has a different material/texture applied to it and all the meshes are hidden by the script except the one matching the current alphanumeric value of the variable. If you just need to display numbers, each digit requires ten meshes, with materials for numbers 0 through 9. If you need to display just letters, each requires 26 meshes, A through Z. If you need it to display numbers and letters, 36 meshes, 0-9, A-Z, and symbols, etc. This method can be used for more advanced display elements, such as a Heading Indicator (horizontal compass), or Attitude Indicator. The complexity is greater because the hide/show logic needs to account for X, Y, Z rotation/translation coordinates, and hide elements as they move "off screen". I already have a working Heading Indicator, but it has a few bugs that needs to be fixed.

I am helping a few people implement this feature into their project. Contact me if you need help setting up a custom solution. In the screenshots below there are 53 meshes in total, 50 used to display five digits (0-9) and 3 for A, S, L, with 13 materials (26 maps). All meshes except the active value are hidden at each update call. I use five digits to display values up to 99,999. Plenty for display ASL for an aircraft.

The code and files attached should provide all the information needed to implement this functionality in the cockpit of any aircraft or the dash of any vehicle. I included comments in the script to explain the algorithm. Let me know if there are any questions.

Best regards,
Uriah George

(http://i.imgur.com/uVQK8io.jpg)

(http://i.imgur.com/lOVJ2wd.jpg)

(http://i.imgur.com/ZKUPphQ.jpg)

(http://i.imgur.com/JCArYCW.jpg)

Script:

Code: [Select]
var geom, jsb, timedt, val;
function initialize(reload){geom = this.get_geomob(0);jsb = this.jsb();snd = this.sound();
this.set_fps_camera_pos({x:0.0,y:4.10,z:1.5});

//GNU
//Real time data show/hide mesh update script v0.1, by Uriah George (1/25/15)

//Display meshes
A_00_mesh = geom.get_mesh_id('A-00');
A_01_mesh = geom.get_mesh_id('A-01');
A_02_mesh = geom.get_mesh_id('A-02');
A_03_mesh = geom.get_mesh_id('A-03');
A_04_mesh = geom.get_mesh_id('A-04');
A_05_mesh = geom.get_mesh_id('A-05');
A_06_mesh = geom.get_mesh_id('A-06');
A_07_mesh = geom.get_mesh_id('A-07');
A_08_mesh = geom.get_mesh_id('A-08');
A_09_mesh = geom.get_mesh_id('A-09');

B_00_mesh = geom.get_mesh_id('B-00');
B_01_mesh = geom.get_mesh_id('B-01');
B_02_mesh = geom.get_mesh_id('B-02');
B_03_mesh = geom.get_mesh_id('B-03');
B_04_mesh = geom.get_mesh_id('B-04');
B_05_mesh = geom.get_mesh_id('B-05');
B_06_mesh = geom.get_mesh_id('B-06');
B_07_mesh = geom.get_mesh_id('B-07');
B_08_mesh = geom.get_mesh_id('B-08');
B_09_mesh = geom.get_mesh_id('B-09');

C_00_mesh = geom.get_mesh_id('C-00');
C_01_mesh = geom.get_mesh_id('C-01');
C_02_mesh = geom.get_mesh_id('C-02');
C_03_mesh = geom.get_mesh_id('C-03');
C_04_mesh = geom.get_mesh_id('C-04');
C_05_mesh = geom.get_mesh_id('C-05');
C_06_mesh = geom.get_mesh_id('C-06');
C_07_mesh = geom.get_mesh_id('C-07');
C_08_mesh = geom.get_mesh_id('C-08');
C_09_mesh = geom.get_mesh_id('C-09');

D_00_mesh = geom.get_mesh_id('D-00');
D_01_mesh = geom.get_mesh_id('D-01');
D_02_mesh = geom.get_mesh_id('D-02');
D_03_mesh = geom.get_mesh_id('D-03');
D_04_mesh = geom.get_mesh_id('D-04');
D_05_mesh = geom.get_mesh_id('D-05');
D_06_mesh = geom.get_mesh_id('D-06');
D_07_mesh = geom.get_mesh_id('D-07');
D_08_mesh = geom.get_mesh_id('D-08');
D_09_mesh = geom.get_mesh_id('D-09');

E_00_mesh = geom.get_mesh_id('E-00');
E_01_mesh = geom.get_mesh_id('E-01');
E_02_mesh = geom.get_mesh_id('E-02');
E_03_mesh = geom.get_mesh_id('E-03');
E_04_mesh = geom.get_mesh_id('E-04');
E_05_mesh = geom.get_mesh_id('E-05');
E_06_mesh = geom.get_mesh_id('E-06');
E_07_mesh = geom.get_mesh_id('E-07');
E_08_mesh = geom.get_mesh_id('E-08');
E_09_mesh = geom.get_mesh_id('E-09');

}
function update_frame(dt){

//GNU
//Real time data show/hide mesh update script v0.1, by Uriah George (1/25/15)

//Hide all display meshes at first update call

geom.set_mesh_visible_id(A_00_mesh, false); //Hide
geom.set_mesh_visible_id(A_01_mesh, false); //Hide
geom.set_mesh_visible_id(A_02_mesh, false); //Hide
geom.set_mesh_visible_id(A_03_mesh, false); //Hide
geom.set_mesh_visible_id(A_04_mesh, false); //Hide
geom.set_mesh_visible_id(A_05_mesh, false); //Hide
geom.set_mesh_visible_id(A_06_mesh, false); //Hide
geom.set_mesh_visible_id(A_07_mesh, false); //Hide
geom.set_mesh_visible_id(A_08_mesh, false); //Hide
geom.set_mesh_visible_id(A_09_mesh, false); //Hide

geom.set_mesh_visible_id(B_00_mesh, false); //Hide
geom.set_mesh_visible_id(B_01_mesh, false); //Hide
geom.set_mesh_visible_id(B_02_mesh, false); //Hide
geom.set_mesh_visible_id(B_03_mesh, false); //Hide
geom.set_mesh_visible_id(B_04_mesh, false); //Hide
geom.set_mesh_visible_id(B_05_mesh, false); //Hide
geom.set_mesh_visible_id(B_06_mesh, false); //Hide
geom.set_mesh_visible_id(B_07_mesh, false); //Hide
geom.set_mesh_visible_id(B_08_mesh, false); //Hide
geom.set_mesh_visible_id(B_09_mesh, false); //Hide

geom.set_mesh_visible_id(C_00_mesh, false); //Hide
geom.set_mesh_visible_id(C_01_mesh, false); //Hide
geom.set_mesh_visible_id(C_02_mesh, false); //Hide
geom.set_mesh_visible_id(C_03_mesh, false); //Hide
geom.set_mesh_visible_id(C_04_mesh, false); //Hide
geom.set_mesh_visible_id(C_05_mesh, false); //Hide
geom.set_mesh_visible_id(C_06_mesh, false); //Hide
geom.set_mesh_visible_id(C_07_mesh, false); //Hide
geom.set_mesh_visible_id(C_08_mesh, false); //Hide
geom.set_mesh_visible_id(C_09_mesh, false); //Hide

geom.set_mesh_visible_id(D_00_mesh, false); //Hide
geom.set_mesh_visible_id(D_01_mesh, false); //Hide
geom.set_mesh_visible_id(D_02_mesh, false); //Hide
geom.set_mesh_visible_id(D_03_mesh, false); //Hide
geom.set_mesh_visible_id(D_04_mesh, false); //Hide
geom.set_mesh_visible_id(D_05_mesh, false); //Hide
geom.set_mesh_visible_id(D_06_mesh, false); //Hide
geom.set_mesh_visible_id(D_07_mesh, false); //Hide
geom.set_mesh_visible_id(D_08_mesh, false); //Hide
geom.set_mesh_visible_id(D_09_mesh, false); //Hide

geom.set_mesh_visible_id(E_00_mesh, false); //Hide
geom.set_mesh_visible_id(E_01_mesh, false); //Hide
geom.set_mesh_visible_id(E_02_mesh, false); //Hide
geom.set_mesh_visible_id(E_03_mesh, false); //Hide
geom.set_mesh_visible_id(E_04_mesh, false); //Hide
geom.set_mesh_visible_id(E_05_mesh, false); //Hide
geom.set_mesh_visible_id(E_06_mesh, false); //Hide
geom.set_mesh_visible_id(E_07_mesh, false); //Hide
geom.set_mesh_visible_id(E_08_mesh, false); //Hide
geom.set_mesh_visible_id(E_09_mesh, false); //Hide

//GNU
//Real time data show/hide mesh update script v0.1, by Uriah George (1/25/15)

var ASL = (Math.round(jsb['position/h-sl-ft']*1)/1); //Rounds decimal to whole number
var ASL_string = ASL.toString(); //Converts variable to string, e.g. 19
var ASL_str_length = ASL_string.length; //Returns length of string, e.g. 2
var ASL_zero_pad_length = 5 - ASL_str_length
var ASL_pad_string = ("00000" + ASL_string).slice(-5) //Zero pads the string with up to five zeros e.g. 00019 or 00000

var A_digit_value = ASL_pad_string.charAt(0); //Returns 1st number in string
var B_digit_value = ASL_pad_string.charAt(1); //Returns 2nd number in string
var C_digit_value = ASL_pad_string.charAt(2); //Returns 3rd number in string
var D_digit_value = ASL_pad_string.charAt(3); //Returns 4th number in string
var E_digit_value = ASL_pad_string.charAt(4); //Returns 5th number in string

//Hide/Show Meshes
// if A equals 0, show mesh 00
// if A does not equal 0, hide mesh 00

//Digit A
if (A_digit_value == 0){
geom.set_mesh_visible_id(A_00_mesh, true); //Show
}
if (A_digit_value != 0){
geom.set_mesh_visible_id(A_00_mesh, false); //Hide
}

if (A_digit_value == 1){
geom.set_mesh_visible_id(A_01_mesh, true); //Show
}
if (A_digit_value != 1){
geom.set_mesh_visible_id(A_01_mesh, false); //Hide
}

if (A_digit_value == 2){
geom.set_mesh_visible_id(A_02_mesh, true); //Show
}
if (A_digit_value != 2){
geom.set_mesh_visible_id(A_02_mesh, false); //Hide
}

if (A_digit_value == 3){
geom.set_mesh_visible_id(A_03_mesh, true); //Show
}
if (A_digit_value != 3){
geom.set_mesh_visible_id(A_03_mesh, false); //Hide
}

if (A_digit_value == 4){
geom.set_mesh_visible_id(A_04_mesh, true); //Show
}
if (A_digit_value != 4){
geom.set_mesh_visible_id(A_04_mesh, false); //Hide
}

if (A_digit_value == 5){
geom.set_mesh_visible_id(A_05_mesh, true); //Show
}
if (A_digit_value != 5){
geom.set_mesh_visible_id(A_05_mesh, false); //Hide
}

if (A_digit_value == 6){
geom.set_mesh_visible_id(A_06_mesh, true); //Show
}
if (A_digit_value != 6){
geom.set_mesh_visible_id(A_06_mesh, false); //Hide
}

if (A_digit_value == 7){
geom.set_mesh_visible_id(A_07_mesh, true); //Show
}
if (A_digit_value != 7){
geom.set_mesh_visible_id(A_07_mesh, false); //Hide
}

if (A_digit_value == 8){
geom.set_mesh_visible_id(A_08_mesh, true); //Show
}
if (A_digit_value != 8){
geom.set_mesh_visible_id(A_08_mesh, false); //Hide
}

if (A_digit_value == 9){
geom.set_mesh_visible_id(A_09_mesh, true); //Show
}
if (A_digit_value != 9){
geom.set_mesh_visible_id(A_09_mesh, false); //Hide
}

//
//
//Digit B
if (B_digit_value == 0){
geom.set_mesh_visible_id(B_00_mesh, true); //Show
}
if (B_digit_value != 0){
geom.set_mesh_visible_id(B_00_mesh, false); //Hide
}

if (B_digit_value == 1){
geom.set_mesh_visible_id(B_01_mesh, true); //Show
}
if (B_digit_value != 1){
geom.set_mesh_visible_id(B_01_mesh, false); //Hide
}

if (B_digit_value == 2){
geom.set_mesh_visible_id(B_02_mesh, true); //Show
}
if (B_digit_value != 2){
geom.set_mesh_visible_id(B_02_mesh, false); //Hide
}

if (B_digit_value == 3){
geom.set_mesh_visible_id(B_03_mesh, true); //Show
}
if (B_digit_value != 3){
geom.set_mesh_visible_id(B_03_mesh, false); //Hide
}

if (B_digit_value == 4){
geom.set_mesh_visible_id(B_04_mesh, true); //Show
}
if (B_digit_value != 4){
geom.set_mesh_visible_id(B_04_mesh, false); //Hide
}

if (B_digit_value == 5){
geom.set_mesh_visible_id(B_05_mesh, true); //Show
}
if (B_digit_value != 5){
geom.set_mesh_visible_id(B_05_mesh, false); //Hide
}

if (B_digit_value == 6){
geom.set_mesh_visible_id(B_06_mesh, true); //Show
}
if (B_digit_value != 6){
geom.set_mesh_visible_id(B_06_mesh, false); //Hide
}

if (B_digit_value == 7){
geom.set_mesh_visible_id(B_07_mesh, true); //Show
}
if (B_digit_value != 7){
geom.set_mesh_visible_id(B_07_mesh, false); //Hide
}

if (B_digit_value == 8){
geom.set_mesh_visible_id(B_08_mesh, true); //Show
}
if (B_digit_value != 8){
geom.set_mesh_visible_id(B_08_mesh, false); //Hide
}

if (B_digit_value == 9){
geom.set_mesh_visible_id(B_09_mesh, true); //Show
}
if (B_digit_value != 9){
geom.set_mesh_visible_id(B_09_mesh, false); //Hide
}

//
//
//Digit C
if (C_digit_value == 0){
geom.set_mesh_visible_id(C_00_mesh, true); //Show
}
if (C_digit_value != 0){
geom.set_mesh_visible_id(C_00_mesh, false); //Hide
}

if (C_digit_value == 1){
geom.set_mesh_visible_id(C_01_mesh, true); //Show
}
if (C_digit_value != 1){
geom.set_mesh_visible_id(C_01_mesh, false); //Hide
}

if (C_digit_value == 2){
geom.set_mesh_visible_id(C_02_mesh, true); //Show
}
if (C_digit_value != 2){
geom.set_mesh_visible_id(C_02_mesh, false); //Hide
}

if (C_digit_value == 3){
geom.set_mesh_visible_id(C_03_mesh, true); //Show
}
if (C_digit_value != 3){
geom.set_mesh_visible_id(C_03_mesh, false); //Hide
}

if (C_digit_value == 4){
geom.set_mesh_visible_id(C_04_mesh, true); //Show
}
if (C_digit_value != 4){
geom.set_mesh_visible_id(C_04_mesh, false); //Hide
}

if (C_digit_value == 5){
geom.set_mesh_visible_id(C_05_mesh, true); //Show
}
if (C_digit_value != 5){
geom.set_mesh_visible_id(C_05_mesh, false); //Hide
}

if (C_digit_value == 6){
geom.set_mesh_visible_id(C_06_mesh, true); //Show
}
if (C_digit_value != 6){
geom.set_mesh_visible_id(C_06_mesh, false); //Hide
}

if (C_digit_value == 7){
geom.set_mesh_visible_id(C_07_mesh, true); //Show
}
if (C_digit_value != 7){
geom.set_mesh_visible_id(C_07_mesh, false); //Hide
}

if (C_digit_value == 8){
geom.set_mesh_visible_id(C_08_mesh, true); //Show
}
if (C_digit_value != 8){
geom.set_mesh_visible_id(C_08_mesh, false); //Hide
}

if (C_digit_value == 9){
geom.set_mesh_visible_id(C_09_mesh, true); //Show
}
if (C_digit_value != 9){
geom.set_mesh_visible_id(C_09_mesh, false); //Hide
}

//
//
//Digit D
if (D_digit_value == 0){
geom.set_mesh_visible_id(D_00_mesh, true); //Show
}
if (D_digit_value != 0){
geom.set_mesh_visible_id(D_00_mesh, false); //Hide
}

if (D_digit_value == 1){
geom.set_mesh_visible_id(D_01_mesh, true); //Show
}
if (D_digit_value != 1){
geom.set_mesh_visible_id(D_01_mesh, false); //Hide
}

if (D_digit_value == 2){
geom.set_mesh_visible_id(D_02_mesh, true); //Show
}
if (D_digit_value != 2){
geom.set_mesh_visible_id(D_02_mesh, false); //Hide
}

if (D_digit_value == 3){
geom.set_mesh_visible_id(D_03_mesh, true); //Show
}
if (D_digit_value != 3){
geom.set_mesh_visible_id(D_03_mesh, false); //Hide
}

if (D_digit_value == 4){
geom.set_mesh_visible_id(D_04_mesh, true); //Show
}
if (D_digit_value != 4){
geom.set_mesh_visible_id(D_04_mesh, false); //Hide
}

if (D_digit_value == 5){
geom.set_mesh_visible_id(D_05_mesh, true); //Show
}
if (D_digit_value != 5){
geom.set_mesh_visible_id(D_05_mesh, false); //Hide
}

if (D_digit_value == 6){
geom.set_mesh_visible_id(D_06_mesh, true); //Show
}
if (D_digit_value != 6){
geom.set_mesh_visible_id(D_06_mesh, false); //Hide
}

if (D_digit_value == 7){
geom.set_mesh_visible_id(D_07_mesh, true); //Show
}
if (D_digit_value != 7){
geom.set_mesh_visible_id(D_07_mesh, false); //Hide
}

if (D_digit_value == 8){
geom.set_mesh_visible_id(D_08_mesh, true); //Show
}
if (D_digit_value != 8){
geom.set_mesh_visible_id(D_08_mesh, false); //Hide
}

if (D_digit_value == 9){
geom.set_mesh_visible_id(D_09_mesh, true); //Show
}
if (D_digit_value != 9){
geom.set_mesh_visible_id(D_09_mesh, false); //Hide
}

//
//
//Digit E
if (E_digit_value == 0){
geom.set_mesh_visible_id(E_00_mesh, true); //Show
}
if (E_digit_value != 0){
geom.set_mesh_visible_id(E_00_mesh, false); //Hide
}

if (E_digit_value == 1){
geom.set_mesh_visible_id(E_01_mesh, true); //Show
}
if (E_digit_value != 1){
geom.set_mesh_visible_id(E_01_mesh, false); //Hide
}

if (E_digit_value == 2){
geom.set_mesh_visible_id(E_02_mesh, true); //Show
}
if (E_digit_value != 2){
geom.set_mesh_visible_id(E_02_mesh, false); //Hide
}

if (E_digit_value == 3){
geom.set_mesh_visible_id(E_03_mesh, true); //Show
}
if (E_digit_value != 3){
geom.set_mesh_visible_id(E_03_mesh, false); //Hide
}

if (E_digit_value == 4){
geom.set_mesh_visible_id(E_04_mesh, true); //Show
}
if (E_digit_value != 4){
geom.set_mesh_visible_id(E_04_mesh, false); //Hide
}

if (E_digit_value == 5){
geom.set_mesh_visible_id(E_05_mesh, true); //Show
}
if (E_digit_value != 5){
geom.set_mesh_visible_id(E_05_mesh, false); //Hide
}

if (E_digit_value == 6){
geom.set_mesh_visible_id(E_06_mesh, true); //Show
}
if (E_digit_value != 6){
geom.set_mesh_visible_id(E_06_mesh, false); //Hide
}

if (E_digit_value == 7){
geom.set_mesh_visible_id(E_07_mesh, true); //Show
}
if (E_digit_value != 7){
geom.set_mesh_visible_id(E_07_mesh, false); //Hide
}

if (E_digit_value == 8){
geom.set_mesh_visible_id(E_08_mesh, true); //Show
}
if (E_digit_value != 8){
geom.set_mesh_visible_id(E_08_mesh, false); //Hide
}

if (E_digit_value == 9){
geom.set_mesh_visible_id(E_09_mesh, true); //Show
}
if (E_digit_value != 9){
geom.set_mesh_visible_id(E_09_mesh, false); //Hide
}


//Hide Zero Padding A
if (ASL_str_length <= 4){
geom.set_mesh_visible_id(A_00_mesh, false); //Hide A-00
}

//Hide Zero Padding B
if (ASL_str_length <= 3){
geom.set_mesh_visible_id(B_00_mesh, false); //Hide B-00
}

//Hide Zero Padding C
if (ASL_str_length <= 2){
geom.set_mesh_visible_id(C_00_mesh, false); //Hide C-00
}

//Hide Zero Padding D
if (ASL_str_length <= 1){
geom.set_mesh_visible_id(D_00_mesh, false); //Hide D-00
}

//Print AGL, ASL, ASL string values A, B, C, D, and E
this.log_inf("AGL = " + (Math.round(jsb['position/h-agl-ft']*1)/1));
this.log_inf("ASL = " + (Math.round(jsb['position/h-sl-ft']*1)/1));
this.log_inf("A = " + (ASL_string.charAt(0)));
this.log_inf("B = " + (ASL_string.charAt(1)));
this.log_inf("C = " + (ASL_string.charAt(2)));
this.log_inf("D = " + (ASL_string.charAt(3)));
this.log_inf("E = " + (ASL_string.charAt(4)));
this.log_inf("Length = " + ASL_string.length);
this.log_inf(("0000" + 1).slice(-4));

}

Example text, diffuse and opacity map. (Opacity maps are compressed to ATI1N format using Compressonator)

http://www.mediafire.com/download/tjc9tdv8a9lzg2u/Digital_A.dds
http://www.mediafire.com/download/hjj8n9ctsc44c5t/Digital_A_OPACITY.DDS
http://www.mediafire.com/download/9atvdbi6hjiec7d/Digital_0.dds
http://www.mediafire.com/download/491dy0hk0gliqe9/Digital_0_OPACITY.DDS

Materials (excerpt):

Code: [Select]
{
"name" : "Digital_0",
"color" : "1.0,1.0,1.0,0.2",
"f0" : "1.0",
"roughness" : "0.0",
"no_light" : true,
"alpha_masked" : false,
"tex_albedo" : "Digital_0.dds",
"tex_normal" : "",
"tex_roughness" : "",
"tex_opacity" : "Digital_0_OPACITY.dds",
"tex_reflectance" : "",
"tex_environment" : ""
},
{
"name" : "Digital_1",
"color" : "1.0,1.0,1.0,0.2",
"f0" : "1.0",
"roughness" : "0.0",
"no_light" : true,
"alpha_masked" : false,
"tex_albedo" : "Digital_1.dds",
"tex_normal" : "",
"tex_roughness" : "",
"tex_opacity" : "Digital_1_OPACITY.dds",
"tex_reflectance" : "",
"tex_environment" : ""
},
{
"name" : "Digital_2",
"color" : "1.0,1.0,1.0,0.2",
"f0" : "1.0",
"roughness" : "0.0",
"no_light" : true,
"alpha_masked" : false,
"tex_albedo" : "Digital_2.dds",
"tex_normal" : "",
"tex_roughness" : "",
"tex_opacity" : "Digital_2_OPACITY.dds",
"tex_reflectance" : "",
"tex_environment" : ""
},
{
"name" : "Digital_3",
"color" : "1.0,1.0,1.0,0.2",
"f0" : "1.0",
"roughness" : "0.0",
"no_light" : true,
"alpha_masked" : false,
"tex_albedo" : "Digital_3.dds",
"tex_normal" : "",
"tex_roughness" : "",
"tex_opacity" : "Digital_3_OPACITY.dds",
"tex_reflectance" : "",
"tex_environment" : ""
},
{
"name" : "Digital_4",
"color" : "1.0,1.0,1.0,0.2",
"f0" : "1.0",
"roughness" : "0.0",
"no_light" : true,
"alpha_masked" : false,
"tex_albedo" : "Digital_4.dds",
"tex_normal" : "",
"tex_roughness" : "",
"tex_opacity" : "Digital_4_OPACITY.dds",
"tex_reflectance" : "",
"tex_environment" : ""
},
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: ZeosPantera on January 26, 2015, 12:34:07 am
That is pretty bad-ass. I would just fill that baby up with info.
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: PytonPago on January 26, 2015, 01:44:01 am
Partly kida what ive dode for the urals odometer (but turning the number wheels). Its a lot of meshes if ya need some alphabet in there this "single letter texture" way, but the outcome is worth the effort !

 Is that the F-117s HUD ?
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Uriah on January 26, 2015, 01:58:05 am
Thanks ZeosPantera!

It is totally worth the effort. Actually getting data to update in real time using this method isn't that much effort once you have the font set of textures made and logic architecture to hide/show elements. Once that is in place just use Sublime text editor to mass copy, paste and edit (Ctrl+D) to make 10 or 20 such variables displayed. The most frustrating part is getting the syntax of all of the IF arguments correct, so the active 'show' statement isn't over ruled by another conflicting statement. Last statement to call the method wins, is the rule. So if you have different MFD modes, you have your mode selection script at the bottom, which hides sets of screens, and shows the active displays elements. I am working on a fully interactive MFD, keyboard controlled, until a 3d interactive UI is implemented.

Regards,
Uriah

(http://i.imgur.com/LJNuVuM.jpg)
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: PytonPago on January 26, 2015, 02:27:53 am
Sweet !
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Acetone on January 26, 2015, 03:13:38 am
MAPaUEL level skyrocketting these days, incredibly well done Uriah!  :D

(for reference: http://forum.outerra.com/index.php?topic=3004.msg31901#msg31901 (http://forum.outerra.com/index.php?topic=3004.msg31901#msg31901))
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: M7 on January 26, 2015, 05:24:35 pm
That looks awesome!!!
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Uriah on January 27, 2015, 01:09:02 am
Thanks!
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Acetone on January 27, 2015, 03:14:38 am
BTW, managing to display simple informations on screen seems to be already quite complex but...


You seriously aim to make the full MFD of your last screenshot dynamic Uriah? :-X
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Uriah on January 27, 2015, 03:29:15 am
Yes much of it, some already done, eventually all of it with a new OT display system. It really isn't as complex or difficult as it seems. Just need to map all the meshes names and in the script develop a better hide/display architecture.

It is a temporary solution. I fixed the transparency issue for the HUD as well.

Regards,
Uriah
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Acetone on January 27, 2015, 03:32:15 am
Yes much of it, some already done, eventually all of it with a new OT display system. It really isn't as complex or difficult as it seems. Just need to map all the meshes names and in the script develop a better hide/display architecture.

It is a temporary solution. I fixed the transparency issue for the HUD as well.

Regards,
Uriah

Wow! I'm looking forward to see this in action!  :D
(and folks in the Avsim forum are going to turn crazy when interactive MFD will show up)
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Uriah on January 27, 2015, 03:33:55 am
Oh I know! That's the point.  :))
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: PytonPago on January 27, 2015, 06:56:42 am
Oh I know! That's the point.  :))

What are your sources for the MDFs screens ?
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Uriah on January 27, 2015, 07:25:20 am
What are your sources for the MDFs screens ?

NASA reference images and video, and a lot of measurements and fine tuning.

Regards,
Uriah
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: HiFlyer on January 27, 2015, 08:27:25 am
I wonder how progress is going om the permanent solution to these issues........
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: MVJB on January 28, 2015, 06:20:26 am
I don't have the SDK yet (I should get into it and play around with it a bit) but do the meshes allow for UV texture coordinate settings? If so, you could put all your textures on a single texture/material and have your mesh sprites change the UV coordinates depending on what you want to display. I use this method in my DX11 gauge tech in FSX. Also, when I don't need to render text but rather some other simple primitive shape, I use actual meshes pre-programmed into my shaders which is a little lighter on the GPU in that they aren't as pixel shader bound.

Eg for rendering a unfilled circle, the only pixels calculated would be the ones covered by the triangles, rather than in a sprite case, a whole square section of pixels of the dimensions of the circle.

Ultimately, being able to render 2D meshes and sprites to texture with predefined scripts by the Outerra team would be what I would like to see.
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Uriah on January 28, 2015, 12:45:43 pm
Hi MVJB,

I am really not sure either way if that is possible. I can look into it.

My next version of the HUD will use one texture, with all the characters for a font set on on map, and each mesh will have a different UV position on that map, but it still uses multiple meshes. It would be optimal if you could have a script which can change the UVs, this way you just have one mesh, and one map. I will definetly be looking for a better solution to this problem.

From what I understand there is a long-term permanent OT solution under development, that is all I know. I think there is a thread discussing it somewhere.

Regards,
Uriah
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Levi on March 09, 2015, 07:47:53 am
Here's my version of your script Uriah.
As you can see, the overall length have been considerably reduced.
This is the script used on the F-117 to display the heading digits on the left screen, but now you don't need to call the meshes within the initialize function anymore, making the script even shorter.

Code: [Select]
var geom, jsb;
function rad2deg(angle_rad){return angle_rad*180/PI;}

function digits(input, lenght_string, lenght){
var string = (Math.round(input*1)/1).toString();
this.str_length = string.length;
this.value = (lenght_string + string).slice(lenght);
}
function update_frame(dt){
//Digits Heading
var digits_hdg = new digits(rad2deg(jsb['attitude/heading-true-rad']), "000", -3);

geom.set_mesh_visible('MFD9_hdg_A_00', digits_hdg.value.charAt(0) == 0);
geom.set_mesh_visible('MFD9_hdg_A_01', digits_hdg.value.charAt(0) == 1);
geom.set_mesh_visible('MFD9_hdg_A_02', digits_hdg.value.charAt(0) == 2);
geom.set_mesh_visible('MFD9_hdg_A_03', digits_hdg.value.charAt(0) == 3);
geom.set_mesh_visible('MFD9_hdg_A_04', digits_hdg.value.charAt(0) == 4);
geom.set_mesh_visible('MFD9_hdg_A_05', digits_hdg.value.charAt(0) == 5);
geom.set_mesh_visible('MFD9_hdg_A_06', digits_hdg.value.charAt(0) == 6);
geom.set_mesh_visible('MFD9_hdg_A_07', digits_hdg.value.charAt(0) == 7);
geom.set_mesh_visible('MFD9_hdg_A_08', digits_hdg.value.charAt(0) == 8);
geom.set_mesh_visible('MFD9_hdg_A_09', digits_hdg.value.charAt(0) == 9);

geom.set_mesh_visible('MFD9_hdg_B_00', digits_hdg.value.charAt(1) == 0);
geom.set_mesh_visible('MFD9_hdg_B_01', digits_hdg.value.charAt(1) == 1);
geom.set_mesh_visible('MFD9_hdg_B_02', digits_hdg.value.charAt(1) == 2);
geom.set_mesh_visible('MFD9_hdg_B_03', digits_hdg.value.charAt(1) == 3);
geom.set_mesh_visible('MFD9_hdg_B_04', digits_hdg.value.charAt(1) == 4);
geom.set_mesh_visible('MFD9_hdg_B_05', digits_hdg.value.charAt(1) == 5);
geom.set_mesh_visible('MFD9_hdg_B_06', digits_hdg.value.charAt(1) == 6);
geom.set_mesh_visible('MFD9_hdg_B_07', digits_hdg.value.charAt(1) == 7);
geom.set_mesh_visible('MFD9_hdg_B_08', digits_hdg.value.charAt(1) == 8);
geom.set_mesh_visible('MFD9_hdg_B_09', digits_hdg.value.charAt(1) == 9);

geom.set_mesh_visible('MFD9_hdg_C_00', digits_hdg.value.charAt(2) == 0);
geom.set_mesh_visible('MFD9_hdg_C_01', digits_hdg.value.charAt(2) == 1);
geom.set_mesh_visible('MFD9_hdg_C_02', digits_hdg.value.charAt(2) == 2);
geom.set_mesh_visible('MFD9_hdg_C_03', digits_hdg.value.charAt(2) == 3);
geom.set_mesh_visible('MFD9_hdg_C_04', digits_hdg.value.charAt(2) == 4);
geom.set_mesh_visible('MFD9_hdg_C_05', digits_hdg.value.charAt(2) == 5);
geom.set_mesh_visible('MFD9_hdg_C_06', digits_hdg.value.charAt(2) == 6);
geom.set_mesh_visible('MFD9_hdg_C_07', digits_hdg.value.charAt(2) == 7);
geom.set_mesh_visible('MFD9_hdg_C_08', digits_hdg.value.charAt(2) == 8);
geom.set_mesh_visible('MFD9_hdg_C_09', digits_hdg.value.charAt(2) == 9);

if (digits_hdg.str_length <= 2)geom.set_mesh_visible('MFD9_hdg_A_00', false);
if (digits_hdg.str_length <= 1)geom.set_mesh_visible('MFD9_hdg_B_00', false);
}
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Uriah on March 09, 2015, 08:00:18 am
Nice, condensed all that into the function and called the geoms from update. Very nice.

Hopefully it won't be much longer we'll have to use such a hack. With render to texture API and the 3d cockpit manipulators, extended controls, lights and emissive textures, MFDs, HUDs, will be functionally complete. Then we just have to figure out how to slip the .js scipt into multiple files, so we can have MFD_display.js and include that in aircraft.js so the MFD script can be plugged into any mod easily.

Does anyone know how to include a second javascript, called from the first? I know it should be possible, no different than web pages including multiple javascript files to control the css style sheet containing the html content. When the computer executes the script, the include should just extend the original script, like it is inserted at the include line. It might be an OT side limitation. We can include many .xml files in the FDM as Systems. I need to be able to do that with the script.

Thanks for posting that Levi!

Best regards,
Uriah
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Levi on March 09, 2015, 08:46:07 am
Yes, hopefully render to texture API will be ready sooner than later, so that this kind of hacks are no longer needed.
I like the idea of modularity. And reusing pieces of code is always a good thing.

I think it's not possible to include a second javascript at this moment without official implementation, but I hope I'm wrong.
For very long scripts, splitting them into several parts would be very useful, so all can be more clean and organized. Just as you already can do with the FDM.
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: SteelRat on March 31, 2015, 09:38:24 am
Yes, hopefully render to texture API will be ready sooner than later, so that this kind of hacks are no longer needed.
I like the idea of modularity. And reusing pieces of code is always a good thing.

I think it's not possible to include a second javascript at this moment without official implementation, but I hope I'm wrong.
For very long scripts, splitting them into several parts would be very useful, so all can be more clean and organized. Just as you already can do with the FDM.

Code: [Select]
$include("path/script.js");
The only problem for the folder "Outerra/TerrainData" you must specify a full path "E:/Outerra/TerrainData".
I want to hear from the developers about the magical way) to get the path to the custom folder.
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: cameni on March 31, 2015, 02:25:56 pm
We actually want to avoid dependency and version hell that would be introduced by allowing includes outside of the package file. I'll rather optimize loading of scripts (if they have the same content), but you should not expect the $include to work with stuff outside the package.

Does anyone know how to include a second javascript, called from the first? I know it should be possible, no different than web pages including multiple javascript files to control the css style sheet containing the html content. When the computer executes the script, the include should just extend the original script, like it is inserted at the include line. It might be an OT side limitation. We can include many .xml files in the FDM as Systems. I need to be able to do that with the script.

I haven't tested it, I assumed that $include would work from nested includes as well. Beware it's not exactly the same thing as a C-style include - Javascript must parse the file first, and only when it then executes the $include statement, it will add the content of the included file, parse and execute it. I'm now not entirely sure what's the actual order of all parse-execute operations during a nested include.
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: SteelRat on March 31, 2015, 03:19:14 pm
We actually want to avoid dependency and version hell that would be introduced by allowing includes outside of the package file. I'll rather optimize loading of scripts (if they have the same content), but you should not expect the $include to work with stuff outside the package.

Does anyone know how to include a second javascript, called from the first? I know it should be possible, no different than web pages including multiple javascript files to control the css style sheet containing the html content. When the computer executes the script, the include should just extend the original script, like it is inserted at the include line. It might be an OT side limitation. We can include many .xml files in the FDM as Systems. I need to be able to do that with the script.

I haven't tested it, I assumed that $include would work from nested includes as well. Beware it's not exactly the same thing as a C-style include - Javascript must parse the file first, and only when it then executes the $include statement, it will add the content of the included file, parse and execute it. I'm now not entirely sure what's the actual order of all parse-execute operations during a nested include.

I have a big request, not remove it. I plan to actively use it. I'll let you know about the problems, if they will.
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: cameni on March 31, 2015, 04:19:28 pm
Problems will follow soon on their own :)

Any dependency on other packages or modules is asking for trouble in the future. Packages should contain everything they need, and not be dependent on other data that may be updated or removed independently. Includes are for better structuring of the code within the package.
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: SteelRat on March 31, 2015, 04:30:26 pm
Problems will follow soon on their own :)

Any dependency on other packages or modules is asking for trouble in the future. Packages should contain everything they need, and not be dependent on other data that may be updated or removed independently. Includes are for better structuring of the code within the package.

OK, you here the God creator!)
Title: Re: Display real-time data on any screen, HUD or MFD
Post by: Uriah on March 31, 2015, 05:09:50 pm
Works for me! Thanks for the info Cameni.

Regards,
Uriah