Hi,
Is there any project/solutions (open/close source) which is able to render VTK files natively in Mantra (preferably without having to convert the files to bgeo)?
Cheers
Rendering VTK files with Mantra ?
3885 5 2- nicholas_yue
- Member
- 301 posts
- Joined: July 2005
- Online
- dulo
- Member
- 383 posts
- Joined: June 2010
- Offline
- dulo
- Member
- 383 posts
- Joined: June 2010
- Offline
import numpy
# This code is called when instances of this SOP cook.
node = hou.pwd()
geo = node.geometry()
# Add code to modify the contents of geo.
filePath = hou.Node.evalParm(hou.pwd(), “parmFilePath”)
infile = file(filePath,'r')
data = numpy.load(infile)
infile.close()
data = data.astype(numpy.float64)
dimensions = data.shape
xres = dimensions
yres = dimensions
zres = dimensions
volume_bbox = hou.BoundingBox(0, 0, 0,xres , yres, zres)
volume = geo.createVolume( xres, yres, zres, volume_bbox)
volume.setAllVoxels (data.flatten(order='F'))
This is the code to convert from numpy to houdini volume .. just insert before this the code to load the vtk file and copy it into a numpy array ..
I have the code to do that too somewhere, but I didnt find it just now ..
# This code is called when instances of this SOP cook.
node = hou.pwd()
geo = node.geometry()
# Add code to modify the contents of geo.
filePath = hou.Node.evalParm(hou.pwd(), “parmFilePath”)
infile = file(filePath,'r')
data = numpy.load(infile)
infile.close()
data = data.astype(numpy.float64)
dimensions = data.shape
xres = dimensions
yres = dimensions
zres = dimensions
volume_bbox = hou.BoundingBox(0, 0, 0,xres , yres, zres)
volume = geo.createVolume( xres, yres, zres, volume_bbox)
volume.setAllVoxels (data.flatten(order='F'))
This is the code to convert from numpy to houdini volume .. just insert before this the code to load the vtk file and copy it into a numpy array ..
I have the code to do that too somewhere, but I didnt find it just now ..
- ashcic
- Member
- 17 posts
- Joined: July 2018
- Offline
Hi Dulo,
Thanks for sharing that code! That has been massively helpful for me. In the end I reduced it slightly, do let me know if I'm missing something by cutting out some of the extra sections:
(The hou.evalParm… is a file field that I added to the python node)
Ash
Thanks for sharing that code! That has been massively helpful for me. In the end I reduced it slightly, do let me know if I'm missing something by cutting out some of the extra sections:
import numpy node = hou.pwd() geo = node.geometry() data = numpy.load(hou.evalParm('/obj/geo1/numpy_to_volume/numpyfile')) xres, yres, zres = data.shape volume_bbox = hou.BoundingBox(0, 0, 0, xres , yres, zres) volume = geo.createVolume( xres, yres, zres, volume_bbox) volume.setAllVoxels (data.flatten(order='F'))
(The hou.evalParm… is a file field that I added to the python node)
Ash
- tamte
- Member
- 8597 posts
- Joined: July 2007
- Offline
- ashcic
- Member
- 17 posts
- Joined: July 2018
- Offline
-
- Quick Links