Isotropix Forums

get translation and rotation from houdini ptc cloud

General Discussion about Isotropix and CG related topics

get translation and rotation from houdini ptc cloud

Unread postby sfarci » Thu Feb 13, 2020 1:12 pm

Hey guys

Here is a stupid question. I'm trying, through script, to get the transformation and rotation of each particles coming from an houdini generated ptc cloud.
At the moment I managed to get all the transformations (point positions) but not the rotation/normals attribute written in it.
For the position I used

Code: Select all
sel = ix.selection[0]
ptc = sel.get_module().get_geometry().get_point_cloud()
ptc_count = ptc.get_point_count()

#I know, this bit here is nasty, but does the trick
ptc= ix.get_item(str(sel)).get_module().get_geometry().get_point_cloud()
global_matrix = sel.get_module().get_global_matrix()
pos = ix.api.GMathVec3fArray()

for i in range(ptc_count):
    ptc.get_positions(pos)


For the rotations I tried to use the get_normals(). Usually it crashes, so I've checked if I they were in there

Code: Select all
if ptc.has_normals():
        print 'yes'
    else:
        print 'no'


of course it had no normals (even though they have been written inside each particle in every way possible: N, normals, Normals, orient etc etc).

The question is...
Is there a better way to return position, rotation (possibly scale as well) attributes written onto particles, query them and return it into values that can be used later on to either replace it with a geo/light/locator etc etc?

Thank you very much for any tips and tricks.

Sorry for the stupid question.

S.
sfarci
 
Posts: 9
Joined: Wed Oct 05, 2016 12:11 pm

Re: get translation and rotation from houdini ptc cloud

Unread postby dboude » Thu Feb 13, 2020 3:14 pm

Hi,

To get values of exported properties you can use this snippet :

Code: Select all
sel = ix.selection[0]
ptc = sel.get_module()
count = ptc.get_point_count()

propCount = 0
properties = ptc.get_properties()

propName = "orient"

for i in range(int(count)):
    index = properties.get_property_index(propName)
    propValue = properties.get_property(index).get_values_property(0).get_float(i)
    print propValue[0], propValue[1], propValue[2], propValue[3]


In this example, the point cloud is selected and I get the values of a property called "orient" (quaternion)

Hope it helps

Cheers !
Démian
Isotropix
Technical Artist - Clarisse Specialist
User avatar
dboude
 
Posts: 1289
Joined: Mon Jul 03, 2017 10:51 am

Re: get translation and rotation from houdini ptc cloud

Unread postby sfarci » Thu Feb 13, 2020 3:38 pm

Demian you are a hero!!!
Thank you very much!!!!!
sfarci
 
Posts: 9
Joined: Wed Oct 05, 2016 12:11 pm


Return to General Discussion
cron