Page 1 of 1

Keeping desired image size

Posted: Wed Apr 11, 2018 2:20 pm
by vanush
Currently when I drop an image into the RUBE scene, it's height is set to 1meter/point and the width based on aspect ratio. Is there a way to change this behavior? For example it would be good to have a pixel to meter ratio property in the settings so that when one adds an image its size is corrected based on that.
Is it possible to get such a behavior using scripts or other facility? Otherwise now when I add an image, I must do the calculation manually.

Re: Keeping desired image size

Posted: Fri Apr 13, 2018 3:47 pm
by vanush
Got it with image drop hook script and having a pixel to meter(ptm) ratio set in world's custom properties:

Code: Select all

print("Adjusting image size");
image[] images = getDroppedImages();
for (uint i = 0; i < images.length; i++) {
  image img = images[i];
  img.setHeight(img.getPixelHeight() * getWorld().getCustomFloat("ptm", 1));
}