I am starting to learn about python viewer states and I am trying to use the hou.GeometryDrawable in a OBJ context but with no success. Is it possible that it is not supported in that context? I do have success with hou.SimpleDrawable, but I would like to use more advanced possibilities of hou.GeometryDrawable.
Here is the simple example that I am trying (the SimpleDrawable will display, but not the GeometryDrawable):
import hou import viewerstate.utils as su class State(object): def __init__(self, state_name, scene_viewer): self.state_name = state_name self.scene_viewer = scene_viewer # Drawable for drawing the polygon under the cursor. self.geo_drawable = hou.GeometryDrawable(self.scene_viewer, hou.drawableGeometryType.Face, "geo_drawable", params = { "style": hou.drawableGeometryFaceStyle.Plain, "color1": (0.0,1.0,0.0,1.0) } ) self.simple_drawable = hou.SimpleDrawable(self.scene_viewer, hou.Geometry(), "simple_drawable") def show(self, visible): self.geo_drawable.show(visible) self.simple_drawable.show(visible) def onEnter(self, kwargs): sops = hou.sopNodeTypeCategory() box = sops.nodeVerb("box") box.setParms({"scale": 0.25}) geo = hou.Geometry() temp = hou.Geometry() for x in (-0.5, 0.5): for y in (-0.5, 0.5): for z in (-0.5, 0.5): box.setParms({ "t": hou.Vector3(x, y, z) }) box.execute(temp, []) geo.merge(temp) # update the drawable self.geo_drawable.setGeometry(geo) self.simple_drawable.setGeometry(geo) self.simple_drawable.enable(True) self.show(True) def onResume(self, kwargs): self.show(True) def onInterrupt(self,kwargs): self.show(False) def onDraw( self, kwargs ): """ This callback is used for rendering the drawables """ handle = kwargs["draw_handle"] self.geo_drawable.draw(handle) def createViewerStateTemplate(): """ Mandatory entry point to create and return the viewer state template to register. """ state_typename = "obj_geo_drawable" state_label = "obj_geo_drawable" state_cat = hou.objNodeTypeCategory() template = hou.ViewerStateTemplate(state_typename, state_label, state_cat) template.bindFactory(State) template.bindIcon("MISC_python") return template
Any help or info would be greatly appreciated
Thanks in advance!