Jump to content

Understanding Ray VEX


logix1390

Recommended Posts

Hello,

I am in the middle of doing a procedural modeling tutorial:
http://lesterbanks.com/2017/03/procedural-modeling-houdini/

 

He creates a curve and manually rays it to the terrain using vex .

The code is as follows:  (the curve is in the first input and the terrain mesh is in the second input)

 

vector rayD = {0,-100,0};

vector hittP, hitUVW;

i@hitPrim = intersect(1, @P, rayD, hittP, hitUVW);

@P = hittP;

This works perfectly

Now I am trying to understand what is going on here exactly and how Houdini is solving this .

I searched for the intersect function in the help and found this:

int intersect(int input, vector orig, vector dir, vector p&, vector uvw&)

I guess what is confusing me is the "vector p&", and "vector uvw&" above and how that related to the vectors he created "vector hittP, hitUVW" .

 

I am still a beginner in VEX ... If anyone can help me understand this, I would really appreciate it.

I will also attach my scene file for anyone that wants to take a look.

 

Thank you!

 

 

 

 

Ray_VEX.hip

Link to comment
Share on other sites

for the intersect function, the last 2 parameters are output parameter ;)

you initialize them beforehand and the intersect function will overwrite them, in this case with the position, for "vector &p", where the ray hit (or the "orig" position if it did not hit anything)
"vector uvw&" returns the intrinisic uv of the position on the primitive (i@hitPrim) you could use this together with the primuv() function 

basically whenever there is a & in a function param, thats a way the docs try to tell you its an output parameter.

Hope that helps! :)
 

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