4 posts • Page 1 of 1
I'd like to output my model into 4 quad images(each a 256x256 png) , and then combine them into a big one (512x512). I wrote a plugin that sort of worked, but the 4 quads don't EXACTLY align (please see the attachment, esp. the bottom 2 pngs). Could someone please help?
Here are my steps:
1. I resize the SU window so make sure the view's client area is 512x512 pixels (used Spy++ to verify it).
2. In SU, I set the camera to be paraline.
3. In my plug in, I have a fucntion restore_camera, used to reset the camera each time before I output the quad image:
new_eye = [vx,vy,vz]
new_target = [tx,ty,tz]
new_up = [ux,uy,uz]
new_camera = Sketchup::Camera.new(new_eye,new_target,new_up,false)
model = Sketchup.active_model
view = model.active_view
view.camera = new_camera
4. For each quad, the outputting image part looks like the following. I'm adding each quad with 4 lines, selecting them, and zoom to selection. These quads are visible in the attached png.
# x, y below is the column/row index of the 4 quads, the 4 quads will be (0,0),(1,0),(0,1),(1,1) respectively
z = 1
tileWH = 256
ip0 = view.inputpoint (x*tileWH, y*tileWH)
ip1 = view.inputpoint ((x+1)*tileWH, y*tileWH)
ip2 = view.inputpoint ((x+1)*tileWH, (y+1)*tileWH)
ip3 = view.inputpoint (x*tileWH, (y+1)*tileWH)
pt3d_0 = ip0.position
pt3d_1 = ip1.position
pt3d_2 = ip2.position
pt3d_3 = ip3.position
theEdges = Sketchup.active_model.entities.add_line pt3d_0, pt3d_1
theEdges = Sketchup.active_model.entities.add_line pt3d_1, pt3d_2
theEdges = Sketchup.active_model.entities.add_line pt3d_2, pt3d_3
theEdges = Sketchup.active_model.entities.add_line pt3d_3, pt3d_0
write_current_view("c:/temp/su_output/" + z.to_s() + "_" + x.to_s() + "_" + y.to_s() + ".png")
Please, register (free) to access all the attachments on the forums.
I think you need to set the camera to Parallel Projection:
I would think it may be less hassle.. to write out the large 512x512 image, then use another utility such as ImageMagic? to cut up the image into quads.
Or you could bring the image back into Sketchup, explode it, and draw 2 lines from the midpoints of each opposite edge, cutting the image into quads.
Thanks, I was already doing paraline projection in the camera constructor.
I was only using quads as an example. In the plugin I'm writing, it could be as many as 1024x1024 tiles (each 256x256 pixels), over the single file size/memory limit.
Could someone please let me know what I did wrong in the code, or point me to a right direction?
4 posts • Page 1 of 1