It works!!! 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
Script: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.ddshttp://www.mediafire.com/download/hjj8n9ctsc44c5t/Digital_A_OPACITY.DDShttp://www.mediafire.com/download/9atvdbi6hjiec7d/Digital_0.ddshttp://www.mediafire.com/download/491dy0hk0gliqe9/Digital_0_OPACITY.DDSMaterials (excerpt):{
"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" : ""
},