Jump to content

Calculate "from" "to" using Matrix?


Atom

Recommended Posts

Hi All,

 

I am trying to calculate the "from" "to" parameters for a Renderman light shader using the Houdini matrix information.

 

The "from" is easy, it is simply the location extracted from the matrix.

n = hou.node(light_name)
if n != None:
    mtx = n.worldTransform()
    # from
    pos=mtx.extractTranslates() 

It is the "to" value that I am having trouble with. I realize I need to use the rotation information projected along a vector to produce a new location but I am not quite sure how to do that using Houdini Python.

 

Here is an example I found in some Blender python code accomplishing the same task. How would I translate that to Houdini based Python?

    m = ob.matrix_world
    loc = m.to_translation()
    lvec = loc - (m.to_quaternion() * mathutils.Vector((0,0,1)))
Edited by Atom
Link to comment
Share on other sites

I tried rotating it right but it did not work.

 

Does anyone know how to  calculate the "from" "to" parameters for a Renderman light shader using the Houdini matrix information?

Link to comment
Share on other sites

n = hou.node(light_name)
if n != None:
    mtx = n.worldTransform()
    # from
    pos=mtx.extractTranslates()
    # to
    direction = hou.Vector3((0, 0, -1)) * mtx
    # and depending on your needs evantually:
    lookat  = pos + direction

I'm not sure if vector should be pointed backwards though but this is easy fix anyway.

Link to comment
Share on other sites

  • 3 weeks later...

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...