I initially implemented skyboxes in pure Ruby in SU.
# skybox functionality
class MyViewObserver < Sketchup;;ViewObserver
def initialize(stub)
.. build a definition using 'stub' as filepath
skybox = Sketchup.active_model.definitions[dname]
@skybox = Sketchup.active_model.entities.add_instance skybox, Geom;;Transformation.new
@skybox.locked= true
end
def onViewChanged (view)
@skybox.locked= false
@skybox.move! view.camera.eye
@skybox.locked= true
end
def remove
@skybox.locked= false
Sketchup.active_model.entities.erase_entities @skybox
end
end
def add_skybox
$skybox = MyViewObserver.new("~projects/Ruby/skybox/space1")
Sketchup.active_model.active_view.add_observer($skybox)
end
ie Sketchup will move the skybox along with your camera. Works OK - only let down by SU crazily aggressive bounds on Z when it draws.
Adam
@alan fraser said:
Texture Maker will generate a cgi landscape and sky and export it in a variety of formats...including a skybox. Screenshot and result attached below.
Sky boxes are used extensively in games and work very well. They can be used well in SU, as Adam says, but only really from a very fixed viewpoint....that being the centre of the cube.
Games get around this by locking the skybox to the viewer. As you move through a first person perspective shoot-em-up the skybox moves with you, so always appears in the correct perspective and always infinitely distant. This obviously isn't the case in SU.
I realise this thread has drifted slightly away from Ruby, but there's a challenge for somebody.
Skyboxes can work well in SU, but generally only if you move a few feet...or catch a glimpse out of a window, not up and down streets. Of course you can make them really huge, so that any novement by the viewer is very slight in comparison...but then you get clipping problems.
The simplest solution is simply to map a panoramic image around a cylinder. Here is a very old thread from the old forum, now transferred to Google Groups. So old, in fact, that it predates SU's ability to map around cylinders, so I had to do it by slicing the image into sections...but the resulting skps still work ok for most situations.