Domanda

I need to make a Google SketchUp plugin that has to generate textures from external data and add them on a object. I know that SketchUp can use external images as texures. But does it possible to generate textures dynamically?

È stato utile?

Soluzione

Yes, it should be possible, but there is no libraries for that which ships with SketchUp. I think there even are some plugins out there that does something similar to what your describe. (http://sketchucation.com/forums/viewtopic.php?t=21077#p176910)

If you generate bitmaps in Ruby it'll most likely be terribly slow so I would recommend you write a Ruby C extension, then you can use the many C libraries out there to manipulate bitmaps.

You also cannot apply an in-memory bitmap as a texture, you will have to write it out to a temp file and then load it as you would normally: material.texture = path_to_image_file.

Also beware that compiling Ruby C Extensions to run within SketchUp might need some different compiler flags than what you'd normally use - otherwise you'll get a BugSplat and crash SketchUp. For a bare bone example of compiling a C Extension for Ruby SketchUp have a look at this repository: https://bitbucket.org/thomthom/sketchup-ruby-c-extension

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top