Jump to content

Projecting mesh from single point to geometry


nkyms

Recommended Posts

Hello,

Houdini beginner here, I am looking for a solution to project geometry from a given single point (labelled as the green dot in the diagram, just above the mid point of the sphere) to y=0 to make a semisphere.

The point is to have a flat ground without deformations and changes to the UV projection while a camera is positioned at the given point. So say you had a panoramamic image/video applied to the semisphere, it would look undistorted when viewing from this given point.
 
Thanks in advance!

Untitled-1.jpg

Edited by nkyms
Link to comment
Share on other sites

Thanks for the reply.

No, the shape is close to what is intended but what I'd like to do is bring the points in towards the middle.

In theory I need each point below y=0 to move towards 0,0,0 (or a given point) until it hits the y axis.

14 minutes ago, animatrix said:

Hi,

You mean like this?

image.thumb.png.4017daebd1136fa5c213a966f4869375.png

Then you can just use this inside a Point Wrangle SOP:

if ( @P.y < 0 )
    @P.y = 0;


if ( @P.y < 0 )
    @P.y = 0;

 

 

Link to comment
Share on other sites

No, let me reword this. 

I'd like to move each point below the y-axis towards the middle until it reaches the y axis.

Meaning the points will not come to a single point. And when viewing from the middle point, each point will still be at the same angle.

I'd use the ray node, but this only allows for a vector direction.

Edited by nkyms
Link to comment
Share on other sites

27 minutes ago, animatrix said:

image.thumb.png.1872d30ca16613b45767b950c486d833.png

Thanks for the help so far.

By bringing the points towards the middle of the initial sphere they should hit the bottom of the semisphere along the x,z plane, sorry I think I confused you by saying y-axis. 

The first image you sent is the closest, but the angles of each point viewed from the center are changed. I need each point to be the same angle and projected to the lower base of the semi-circle.

Link to comment
Share on other sites

Same result along with greetings from stack overflow:

string cam = chs('camera');

matrix xform_cam = optransform(cam);
vector pos_cam = cracktransform(0,0,0,0,0, xform_cam);
vector pos_plane = {0,0,0};
vector nml_plane = {0,1,0};

vector dir_line = normalize(v@P - pos_cam);
float scale = dot(nml_plane, pos_plane) - dot(nml_plane, pos_cam) / dot(nml_plane, dir_line);

v@P = pos_cam + dir_line * scale;

 

hemisphere_calc.hipnc

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

14 hours ago, konstantin magnus said:

Same result along with greetings from stack overflow:


string cam = chs('camera');

matrix xform_cam = optransform(cam);
vector pos_cam = cracktransform(0,0,0,0,0, xform_cam);
vector pos_plane = {0,0,0};
vector nml_plane = {0,1,0};

vector dir_line = normalize(v@P - pos_cam);
float scale = dot(nml_plane, pos_plane) - dot(nml_plane, pos_cam) / dot(nml_plane, dir_line);

v@P = pos_cam + dir_line * scale;

 

hemisphere_calc.hipnc

Thanks for the solution.

This did the trick. I still don't really understand what is happening fully in the expression, but I'll have a shot.

Link to comment
Share on other sites

You can also use something like this which is similar to Konstantin's approach:

vector linePlaneIntersection ( vector raypos, raydir, planepos, planedir )
{
    vector diff = raypos - planepos;
    vector d = dot ( diff, planedir ) / dot ( raydir, planedir );
    return raypos - raydir * d;
}

if ( @P.y < 0 )
{
    vector n = normalize ( chv("p") - @P );
    vector p = linePlaneIntersection ( @P, n, 0, { 0, 1, 0 } );
    @P = p;
}

Depending on the P parameter, the result will change, so make sure to set it to non 0, 0, 0. Otherwise all bottom points will intersect at 0, 0, 0. Here I use 0, 0.3, 0:

image.thumb.png.83c17457a5e745657bcb79d2848269e9.png

Edited by animatrix
  • Thanks 2
Link to comment
Share on other sites

10 hours ago, animatrix said:

You can also use something like this which is similar to Konstantin's approach:


vector linePlaneIntersection ( vector raypos, raydir, planepos, planedir )
{
    vector diff = raypos - planepos;
    vector d = dot ( diff, planedir ) / dot ( raydir, planedir );
    return raypos - raydir * d;
}

if ( @P.y < 0 )
{
    vector n = normalize ( chv("p") - @P );
    vector p = linePlaneIntersection ( @P, n, 0, { 0, 1, 0 } );
    @P = p;
}

Depending on the P parameter, the result will change, so make sure to set it to non 0, 0, 0. Otherwise all bottom points will intersect at 0, 0, 0. Here I use 0, 0.3, 0:

image.thumb.png.83c17457a5e745657bcb79d2848269e9.png

Thanks, this works well. I'll have a look at your solution too.

Edited by nkyms
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...