Keeping desired image size

General discussion about the R.U.B.E editor
Post Reply
vanush
Posts: 4
Joined: Wed Apr 11, 2018 2:09 pm

Keeping desired image size

Post 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.
vanush
Posts: 4
Joined: Wed Apr 11, 2018 2:09 pm

Re: Keeping desired image size

Post 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));
}
Post Reply