Aleksandr Kirichenko

Faitel

Expertise
Generalist
Location
Not Specified
Website

Recent Forum Posts

Could someone please explain this code to me?June 16, 2022, 11:53 a.m.

gimletful
Hello, i am newbie to Houdini, i am watching the applied Houdini tutorial particle 3 as well, and i encountered this code. but i cannot get my head around.

@N = point (1, "P", @ptnum)- @P;

what does this code even mean.
i simply don't understand what is point (1, "P", @ptnum), it doesn't make sense. point is definitely not @P, it looks like a local variable, and what is the stuff in the bracket.
usually P would get followed by (x, y, z) but here 1 is not value 1 but the input.

can somebody point me to the right direction please.

Letters predefined by @ are attributes, you can find their values in Geometry Spreadsheet tab. In some cases, you may want to read attributes from another geometry, like here, from geometry connected to second input of attribute wrangle (All inputs have numbers starting from 0). @ can't read attributes from inputs other than 0, so you need special VEX function to read the attribute. You want to read Position attribute of current point from second input, so you need:
Point function, (there are also vertex(), prim(), detail() for attributes stored on vertices, primitives, details geometry components)
(
1, - input number (to read attribute from second input of attribute wrangle node)
"P", - attribute's name you want to read (N(normals),P(positon),"v"(velocity),"Cd"(color) etc.)
@ptnum - special type of attributes, contains number of current point(there are also @primnum(current primitive), @vtxnum( cur.vertex)
)
Attribute wrangle will pass over every point and calculate the code
@N = point (1, "P", @ptnum)- @P;
Mathematically the code means:
Attribute wrangle(repeat calculations for every point from first(0) input):
Normal vector (x,y,z) = Second geometry's point position vector (x,y,z) - First geometry's point position vector (x,y,z)

PS:
Theoretically you can replace it with:
vector Normal = point(1, "P", @ptnum) - point(0, "P", @ptnum); //Vector variable Normal equal to vector position of point from first input minus vector position of point from second input)
setpointattrib(0, "N", @ptnum, N); //replace normal attribute with Normal variable.
But there is no need to make it so complicated, @ allows you read and write attributes freely but only for components from first(0) input.

Simple tutorials about geometry components and math operations in 3d space [www.sidefx.com]

Geometry attributes documentation [www.sidefx.com]
VEX functions reference list [www.sidefx.com]

VirtuCamera plugin: Virtual camera for Houdini (Py3) and iOSJune 14, 2022, 2:47 a.m.

fabriciochamon
This is super cool , great job! thanks for sharing.

does it stream translation as well, like getting xforms from some AR type of camera ?

btw, regarding your question (1), use parm.setKeyframes() instead, and pass in a Keyframe() array, you'll get faster times than adding keyframes at every loop iteration, according to the docs. (see screenshot attached)
So maybe you could find a way to store all transforms during stream and set keyframes at a later stage ? (you'l need to have a frame range defined of course, as to know when its time to gather xforms and bake)

Thank you for the tip, Fabricio! I'll test it. I'm also thinking of shifting from recording in device to recording in chops as alternative mode because I see that there are a lot of other ways to utilize device xforms and maybe it isn't smart to lock everything just on python and camera. So, I am actively discovering CHOPs at the moment.