Zulko / vapory

Photo-realistic 3D rendering with Python and POV-Ray
Other
485 stars 70 forks source link

How to add new povray elements to vapory? #22

Open tanuva opened 9 years ago

tanuva commented 9 years ago

tl;dr: How does the syntax used in the class documentation comments that specify a POVRayElement's content work?

I'm trying to make heightfields available in vapory. From the existing POVRayElements, I deduce the syntax should be something like """ 'parameter_name', default_value_implying_type, 'parameter2_name', another_default """.

This is vapory 0.1.1 from pip on Python 2.7.

Zulko commented 9 years ago

please provide the whole code (in particular the implementation of imagemap)

tanuva commented 9 years ago

I'm sorry, should've added that right away. The whole implementation is this (actual code wasn't changed):

class ImageMap(POVRayElement):
    """ ImageMap('image', 'my_image.png') """
    povray_name= 'image_map'
    url = wikiref+'Image_Map'

The code using it is this (excerpt):

sphere1 = Sphere([-4, 2, 2], 2.0,
        ImageMap(image = "map.png"))

(Not sure if that would even result in correct pov syntax, but I'd expect vapory to write at least a pov file I can check manually.)

I actually only changed the class comment but don't really understand how it is parsed. Reading vapory's readme again (RTFM, future self!), I understand that those comments are not parsed by some magic but simple usage instructions. I see now how POVRayElement works, but I don't get how ImageMap breaks here as the default implementation of POVRayElement works the same way f.e. for Camera.