Jump to content

Load ASCII PTX data into Houdini


Recommended Posts

Hi all.

Can anyone tell me what the best method for bringing in ASCII data into Houdini would be. I have PTX point clouds that I would like to mesh in Houdini, but I can't load them. Here's an example of the first 20 lines from one of the PTX files:

3680
2463
7115.197796 14574.203673 51.118767
0.737771 -0.675051 0
0.675051 0.737771 0
0 0 1
0.737771 -0.675051 0 0
0.675051 0.737771 0 0
0 0 1 0
7115.197796 14574.203673 51.118767 1
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0

Thanks!

Link to comment
Share on other sites

I have never deal with PTX, but I think Python is a way to go.

If there are point coordinates in this file and you need to create the same points in Houdini, you can read them with Python, then create points (either with Python or with VEX). Should not be that hard to create a script which does this, more tricky would be to update point cloud in Houdini if PTX file was changed.

Edited by kiryha
Link to comment
Share on other sites

With a single point cloud you could only create points for lines in your file that contain exactly 7 values (standing for Px, Py, Pz, I, Cr, Cg, Cb):

import csv

node = hou.pwd()
geo = node.geometry()
path = node.evalParm('path')

geo.addAttrib(hou.attribType.Point, 'Cd', (-1.0,-1.0,-1.0))
geo.addAttrib(hou.attribType.Point, 'intensity', -1.0)

def add_point(position, color, intensity):
    pt = geo.createPoint()
    pt.setPosition(hou.Vector3(position))
    pt.setAttribValue('Cd', color)
    pt.setAttribValue('intensity', intensity)

with open(path) as f:
    reader = csv.reader(f)
    for row in reader:
        values = row[0].split()
        if len(values) == 7:
            pos = tuple([float(i) for i in values[0:3]])
            ins = float(values[3])
            clr = tuple([float(i)/255.0 for i in values[4:7]])
            add_point(pos, clr, ins)

And perhaps filter out 'missing points' by removing any point that was set to 0,0,0:

if(length(v@P) < 0.001){
    removepoint(0, @ptnum);
}

 

import_point_cloud.png

py_import_ptx_02.hiplc

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...