Anteworld - Outerra Game > Modding: Importer, Tools & Utilities

showing images on canvas ?

(1/2) > >>

fly77:
I am trying to show some images on the canvas using script found in some of outerra default models. It works to show the airspeed.dds image. I tried to edit this file in gimp or subtsitute it with another one made by me in gimp (.dds   DXT1 format generate mipmaps) and add also the corresponding .tga as I have seen there is also a airspeed.tga in the Anteworld/ui folder  but neither works. Nothing shows up. I only can get to show up the airspeed.dds or the set of images basic.dds with all of the images of the set showing together. How to create and show my own images on the canvas ?



--- Code: ---var display_canvas,$sketch;

function init_vehicle()
{
...
 $sketch = this.sketch = this.$query_interface("ot::js::sketch.get");
}


function update_frame(dt, engine, brake, steering)
{

this.img = $sketch.load_image("ui/airspeed.dds");
   
$sketch.make_canvas_active(display_canvas);
var screen_size = world.screen_size();
$sketch.set_canvas_2d_offset({ x: screen_size.x*0, y: 0 });
$sketch.clear_canvas();
$sketch.draw_image(this.img, {x:300,y:300}, 0xffffffff);
}
--- End code ---

cameni:
airspeed.dds is in uncompressed ARGB format, did you try that one?

fly77:
Thanks cameni ! Now that I exported it form gimp as uncompressed RBGA8 (no mipmap) it works !  Great !

fly77:
I have a HUD for a plane that I made using the  this.sketch.draw_text  command  as it gives the text clearly visible in different colors and allways in same place whatever the cameraview.
As I spawn a second instance of the same plane I'd like to show a fresh canvas..but it seems that this.sketch.clear_canvas() only clears the canvas of instance that created it. So the result after spawning a second instance of the plane is as bad as in the image below. No better result if I leave away the "this." How to completely remove the canvas when exiting the plane or when entering the new one so that a new plane (or other vehicle) finds a clear screen on which to display its canvas ?



--- Code: ---function initialize(reload){
...
this.sketch = this.$query_interface("ot::js::sketch.get");
this.display_canvas = this.sketch.create_canvas(-1, { x: 0, y: 0 }, {x: 0, y: 0 });

}

function update_frame(dt){
...
this.sketch.make_canvas_active(this.display_canvas);
    screen_size = ot_world.screen_size();
    this.sketch.set_canvas_font('ui/xolonium_50_bold.fnt');
    this.sketch.clear_canvas();
     
    var sentence = "dynamic object hit: "+ hitscore;
    this.sketch.draw_text({ x:screen_size.x-sentence.length * (45), y: screen_size.y*(1-1/25)-50 }, 0xddff0000, sentence);
   
}
--- End code ---

cameni:
Well, that's a disadvantage when scripts access global objects, you then need to manage it too. I think we already decided there will have to be canvas given to the active vehicle via vehicle api, that will be shared and managed (cleared).

Navigation

[0] Message Index

[#] Next page

Go to full version