Every GeomObject that supports the IGeometry protocol can be exported as RIB. If the geometry does not support the protocol it will be ignored.
The IGeometry protocol only specifies the presence of one method:
| matid) |
Here is an example of an adapter class that implements the IGeometry protocol for the SphereGeom (which knows nothing about RenderMan):
import protocols
from ri import *
# Adapter class that implements the IGeometry protocol on behalf of the SphereGeom class
class SphereAdapter:
protocols.advise(instancesProvide=[IGeometry], asAdapterForTypes=[SphereGeom])
def __init__(self, spheregeom, proto):
self.geom = spheregeom
def render(self, matid):
# A sphere can only have one single material
if matid==0:
r = self.geom.radius
RiSphere(r, -r, r, 360)