Point Instance procedural and orient attibute

   1020   2   1
User Avatar
Member
34 posts
Joined: 9月 2014
Offline
Hello,

I having a ton of trouble getting my head around this, I have a python sop, that is creating my point cloud.
Im giving is a postition & scale, those work correctly, but the orient is not.

In the attribute spread sheet, i can see the 3 params for the orient, all have values.

I simplified the code to include some transforms, originally they are coming from some worldspace maya transforms, but to confirm i wasnt going crazy i took a few from the moana island data set.

C:/leaf.obj , is a leaf geometry, but i have tried with a grid that is scales to be a rectangle.

node = hou.pwd()
geo = node.geometry()


pivot = {0,0,0}
v3 = hou.Vector3 (1,0,0)
m = hou.Matrix4()

geo.addAttrib(hou.attribType.Point, "orient",v3)
geo.addAttrib(hou.attribType.Point, "pscale",1.0)
geo.addAttrib(hou.attribType.Point, "instancefile", "")
# some test ws xforms
transforms = [
        [
            0.9476891756057739, 
            -0.3092913031578064, 
            0.07889299094676971, 
            0.0, 
            -0.06873862445354462, 
            0.043607283383607864, 
            0.9966812133789062, 
            0.0, 
            -0.3117051422595978, 
            -0.9499669671058655, 
            0.02006589248776436, 
            0.0, 
            50.91556930541992, 
            113.11812591552734, 
            -17.59348487854004, 
            1.0
        ],
        [
            0.011039327830076218, 
            -0.2005908042192459, 
            0.7990818023681641, 
            0.0, 
            -0.4085596799850464, 
            0.6926376819610596, 
            0.17951379716396332, 
            0.0, 
            -0.7154367566108704, 
            -0.39863455295562744, 
            -0.09018410742282867, 
            0.0, 
            95.37860107421875, 
            94.6856689453125, 
            -21.098573684692383, 
            1.0
        ], 
        [
            -0.7893863320350647, 
            0.09577027708292007, 
            -0.10461504757404327, 
            0.0, 
            0.11940404027700424, 
            0.7679983973503113, 
            -0.1979062259197235, 
            0.0, 
            0.07654441148042679, 
            -0.2103620171546936, 
            -0.7701525092124939, 
            0.0, 
            178.22116088867188, 
            64.501220703125, 
            24.868995666503906, 
            1.0
        ], 
        [
            -0.16089898347854614, 
            0.0215655155479908, 
            -0.6914180517196655, 
            0.0, 
            0.16879704594612122, 
            0.6896406412124634, 
            -0.017770059406757355, 
            0.0, 
            0.6708438992500305, 
            -0.16835418343544006, 
            -0.16136221587657928, 
            0.0, 
            134.9632568359375, 
            138.3452911376953, 
            109.56019592285156, 
            1.0
        ], 
        [
            0.12487196922302246, 
            -0.0351731963455677, 
            -0.7897642850875854, 
            0.0, 
            0.36846989393234253, 
            0.709984540939331, 
            0.026640724390745163, 
            0.0, 
            0.6994245052337646, 
            -0.3677535653114319, 
            0.1269664615392685, 
            0.0, 
            82.2651596069336, 
            77.03775787353516, 
            112.33985137939453, 
            1.0
        ], 
        ]

for world_space in transforms:

    m4 = hou.Matrix4(world_space)
    
    point = geo.createPoint()
    if point != None:
        # get the point location
        point.setPosition(m4.extractTranslates('srt'))
        
        # get its orient
        point.setAttribValue("orient", m4.extractRotates('srt'))
        #print m4.extractRotates('srt') i can see that this is different
        
        # get the uniform scale
        point.setAttribValue("pscale", (sum(m4.extractScales('srt')))/3.0)
        # set the leaf file
        point.setAttribValue("instancefile", "C:/leaf.obj")
        


Once this executes, i can see my leaves, positioned and scaled in the scene view, but they have no rotation


If someone can point me in the right direction would be fantastic.

Cheers
Kym
User Avatar
Member
7850 posts
Joined: 9月 2011
Offline
The orient attribute as created is one dimension short of a quaternion (vector4).
The values being passed are from extract rotates are three dimensional euler rotations (xyz) not four dimensional quaternion rotations (wxyz).
User Avatar
Member
34 posts
Joined: 9月 2014
Offline
Hi jsmack,

So the changes i made to the above, based on your information look like:

geo.addAttrib(hou.attribType.Point, "orient",hou.Quaternion())

#per point

qu = hou.Quaternion()
qu.setToRotationMatrix(m4.extractRotationMatrix3())

point.setAttribValue("orient", qu)

This give me some rotations, which is good, ill have to go back to my larger data set to see if matches what is coming from maya.

**edit, confirmed this gives me the correct rotations im after, thanks for your help.

Cheers
kym
Edited by Kym Watts - 2020年6月11日 17:01:14
  • Quick Links