matrix to variable

   3704   4   2
User Avatar
Member
1390 posts
Joined: July 2005
Offline
I'm repeating my question from odforce thread here to emphasize my curious:
Am I wrong or hscript can not save matrix to variable?
Code like this:
set lookat = normalize(vector3(0,0,-1) * (rotate($RX, “x”) * rotate($RY, “y”) * rotate($RZ, “z”)))
doesn't work divided into sections… only in one expression.
Something like: $myvector * $mymatrix * $mymatrix is not allowed?
Thanks for enlightenment!

sy.
User Avatar
Staff
2540 posts
Joined: July 2005
Offline
I belive hscript only supports floats, int's and strings.

Expressions on the other hand can support all the data types in Houdini. Check out the expression language help in the docs.

All parameters can take expression functions directly as well. As long as you return the data type supported by the parm that you are in. In this special case, simply omit the expression function declaration and simply write the expression inside the curly braces.
There's at least one school like the old school!
User Avatar
Member
1390 posts
Joined: July 2005
Offline
jeff
I belive hscript only supports floats, int's and strings.

I believe this is a reason it didn't work. This is a part of hscript file so I need to use like this. (Of course I missed here `` but I got it in source.)

thanks jeff,
sy.
User Avatar
Member
4262 posts
Joined: July 2005
Offline
There are two different things here, the expression language and hscript.

The expression language supports a matrix type.


{

vector p = vector3(0,5,0);
matrix m = identity(4);
matrix trans = translate(0,5,0);

p = p * m * trans;

return p;
## Returns 10
}


Unlike the expression language hscript doesn't have any types at all. It works just like the csh where you assign some string to a variable. Since everything is just a string you have to specify your variable type every time you use it.


set p = `vector3(0,5,0)`
set m = `identity(4)`
set trans = `translate(0,5,0)`

set p = `vector($p) * matrix($m) * matrix($trans)`

echo `vector($p)`

## Returns 10



The moral of the story is to keep everything in the expression language as much as possible, but if you do have to use hscript it should be doable.
if(coffees<2,round(float),float)
User Avatar
Member
1390 posts
Joined: July 2005
Offline
Thank you Wolfwood! Now I got it.

So maybe you can explain me also why above stated expression doesn't express my camera target? It miss it in millimeters…

if I rotate vector(0, 0, -1) with rotate(cameraRot) matrix should I get lookat vector. right?
  • Quick Links