Controlling the view
-
Hello,
I'm a total beginner with sketchup and ruby so forgive me if this is a silly question. By way of background, I'm trying to use sketchup to make tiles for a simple 2d isometric game. Basically I make all of my models within a certain bounding cube, then I set the view/camera to a specific position and rotate the model to the eight compass directions, stopping to write a 2d image at each step. This way I can make tiles of my characters, and buildings at every orientation.
What I'd like to do is make a plug-in to make this process completely repeatable. Ideally once I have a model that's within the appropriate bounding cube the script would set the view/camera to the standard position, set the standard rendering options, rotate the model 8 times and write an image at each step.
So far I can set the rendering options (background color, axis display off, no perspective, etc) and the camera position and write out images, so that's great. The thing I'm currently stuck on is setting the view itself. I don't want the images to be the wrong size because the window has the wrong aspect ratio. Also, setting the camera position doesn't control the zoom level as I had hopped, and sometimes there seems to be some foreground clipping (like stuff that is too close to the camera is cut off), I don't understand why that happens. I would like to set the window so that it's always the same size and shape and my bounding cube fills it completely.
If anyone knows of another plug-in that does what I want (or something similar) or can give me some tips I'd really appreciate it!
Thanks,
Matt -
Hi Matt,
It might be easier to set up scenes for each image you want to export. You can traverse the scenes and export the images using Ruby.
-
Hi,
I remember looooooong time ago I have coded a basic VR objet exporter that might help you.
It's here:
http://www.crai.archi.fr/RubyLibraryDepot/Ruby/em_ren_page.htm
The camera moves on a virtual hemisphere, rotates around the model and exports numbered snapshots a any desired angle. -
Hey,
Thanks for your suggestions, unfortunately they don't quite meet my needs. Basically I'm building a bunch of different models for different tiles. What's important is that they are all exactly the same size (to the pixel). I need to precisely set the view zoom and camera angles to make sure the sizes always match up. I looked at the ado code, here you rely on "zoom extents" which doesn't work for me. Some of the models fill the whole tile, others are smaller than a tile, if I do zoom extents some things will be too big and others too small.
I'm pretty surprised that you can't get precise control over the exact camera view from a script, surely there must be a way? For example I want to set up a camera such that the image represents exactly the rectangle [0,0,0], [0,5,0], [5,5,0], [5,0,0], with a fixed aspect ratio, say w/h = 2. I actually can set the aspect ratio, but I can't find a way to control the zoom (I should mention that I'm using parallel projection, maybe that's related).
Thanks again for your help!
Matt
Advertisement