Jump to content

How to get the position of an object to supply to the dot expression?


Recommended Posts

I am trying to use the dot expression which requires 2 vector values. I want to use the position of 2 different objects. I can access tx, ty, tx, but not t.

What's the right way to do this? Because I know ch expression references basic component values, like x, y, z, r, g, b but not the compound data itself.

Thanks :)

Link to comment
Share on other sites

In hscript that would be something along the line:

dot(vtorigin("/obj/geo1", ""), vtorigin("/obj/geo2",""))

note it takes parenting into account thanks to vtorigin(), which computes actual world position, not just t?. Python though predictably is more verbatim:

t1 = hou.node("/obj/geo1").worldTransform().extractTranslates()
t2 = hou.node("/obj/geo2").worldTransform().extractTranslates()
t1.dot(t2)

Edited by SYmek
  • Like 1
Link to comment
Share on other sites

Thanks Symek, owe you again :)

Btw also thought this when looking at the available expressions:

There is a vector3 expression. Can you use this to create a vector3 from 3 channel references (tx, ty, tz) for each object and then use it? I.e.:

dot(vector3(x1,y1,z1), vector3(x2,y2,z2))

I imagine this wouldn't take parenting into account like your vtorigin example?

Link to comment
Share on other sites

There is a vector3 expression. Can you use this to create a vector3 from 3 channel references (tx, ty, tz) for each object and then use it? I.e.:

dot(vector3(x1,y1,z1), vector3(x2,y2,z2))

I imagine this wouldn't take parenting into account like your vtorigin example?

Sure you can, but as you say, this takes solely channel values, which is often not perfect, since your objects can live in subnets, or be parented.

exhelp -k keyword

is your friend and great evening companion :lol:

/-> exhelp -k vector
angvel         dopfieldtype   matrix         stripmatrix    volumegradient 
clamptosphere  dopoptions     mlookat        vangle         vorigin        
cross          dot            mlookatup      vector         vrorigin       
dihedral       explodematrix  mobjlookat     vector3        vscale         
distance       explodematrixp normalize      vector4        vset           
dopallfields   iprquery       objlookat      vlength        vsize          
dopfield       length         rotaxis        vlength2       vtorigin       
dopfields 

Edited by SYmek
  • Like 1
Link to comment
Share on other sites

Thanks Symek, you are my companion though :)

I will use exhelp. I didn't know it provided more options like that.

Lastly in your first reply, you also showed the Python version. Do you use python expressions yourself? I see most people's examples have hscript and thought maybe it's because it's shorter and most people are used to it more.

Reason I ask this is because, I don't wanna use say all python expressions and alienate the majority who use hscript when sharing scenes, etc :)

Link to comment
Share on other sites

Lastly in your first reply, you also showed the Python version. Do you use python expressions yourself? I see most people's examples have hscript and thought maybe it's because it's shorter and most people are used to it more.

It depends on complexity. I would compute a dot() with hscript, but say cancelling rotation in matrix is Python thing. As long as you don't feel like you're fighting with the code, hscript is fine :). I specially like custom expression functions read with exread from disk, tasty! :)

edit:

surely I meant exread :)

Edited by SYmek
  • Like 1
Link to comment
Share on other sites

Thanks for clearing that out. I never used mread, but is exread not better to read a custom expression from disk? A quick look at mread, I saw it's for loading a hip file, but not really sure.

If you are doing it though, there must be a reason :)

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