by default when creating a point instancer in houdini solaris, the prototypes are left underneath it, even when instanced, which creates lots of descendants which in turn slow down considerably the loading and viewing of the data for very complex shots.
Is there an easy way to go around this issue other than python scripting from scratch a custom point instancer ?
usd point instancer reading external prototypes
1503 5 3- drhein
- Member
- 3 posts
- Joined: Nov. 2019
- Offline
- drhein
- Member
- 3 posts
- Joined: Nov. 2019
- Offline
- npetit
- Staff
- 360 posts
- Joined: Feb. 2008
- Offline
Here's an example:
Create a sphere, a cube and a torus, plug a python LOP and set it to use this code:
Create a sphere, a cube and a torus, plug a python LOP and set it to use this code:
from random import random, randint import hou from hou import hmath from pxr import UsdGeom, Gf node = hou.pwd() stage = node.editableStage() numinstances = 20 prim = stage.DefinePrim("/pointinstancer", 'PointInstancer') pi = UsdGeom.PointInstancer(prim) rel = pi.GetPrototypesRel() rel.AddTarget("/cube1") rel.AddTarget("/sphere1") rel.AddTarget("/torus1") protoindices = pi.GetProtoIndicesAttr() protoindices.Set([randint(0,2) for x in range(numinstances)]) pos = pi.GetPositionsAttr() pos.Set([[float(x * 5), 3.0, 0.0] for x in range(numinstances)]) rot = pi.GetOrientationsAttr() rot.Set([Gf.Quath(*list(hou.Quaternion(hmath.buildRotate(random()*180, random()*360, random()*270)))) for x in range(numinstances)]) scl = pi.GetScalesAttr() scl.Set([[random()*2+0.2]*3 for x in range(numinstances)])
- drhein
- Member
- 3 posts
- Joined: Nov. 2019
- Offline
- NMVHS
- Member
- 21 posts
- Joined: May 2015
- Offline
npetitIs there a way to do this with variants? For example, to have instancer randomly choose variants of a sphere.
Here's an example:
Create a sphere, a cube and a torus, plug a python LOP and set it to use this code:from random import random, randint import hou from hou import hmath from pxr import UsdGeom, Gf node = hou.pwd() stage = node.editableStage() numinstances = 20 prim = stage.DefinePrim("/pointinstancer", 'PointInstancer') pi = UsdGeom.PointInstancer(prim) rel = pi.GetPrototypesRel() rel.AddTarget("/cube1") rel.AddTarget("/sphere1") rel.AddTarget("/torus1") protoindices = pi.GetProtoIndicesAttr() protoindices.Set([randint(0,2) for x in range(numinstances)]) pos = pi.GetPositionsAttr() pos.Set([[float(x * 5), 3.0, 0.0] for x in range(numinstances)]) rot = pi.GetOrientationsAttr() rot.Set([Gf.Quath(*list(hou.Quaternion(hmath.buildRotate(random()*180, random()*360, random()*270)))) for x in range(numinstances)]) scl = pi.GetScalesAttr() scl.Set([[random()*2+0.2]*3 for x in range(numinstances)])
- mtucker
- Staff
- 4441 posts
- Joined: July 2005
- Offline
-
- Quick Links