Jump to content
Sign in to follow this  

Raycast points to align objects

Recommended Posts

I have this nice setup. What I'm going for is a surface that I can model freely, and then apply all kinds of different objects onto it by using points that are raycast onto the surface. This way the applied objects are independent from the original object and their placement won't be messed up by changing numbers of e.g. prims on the base model. This is mostly going to be used to construct buildings with various windows, doors, etc. This is how it looks like currently:


The objects are placed by a raycast from the point onto the surface. I have checkboxes for aligning the object to the center of the primitive or moving them freely. I can also scale the objects corresponding to the primitive size.

However, I'm still having the following problem:

Scaling only works on vertically aligned primitives, as the calculation of the height and width of the primitive is very simplistic. Can anyone help me with this calculation, so it also works on angled / non-vertically aligned primitives? I know that "height / width" will mean something different, depending on which side the primitive is on. I was looking into adding in a direction that's coming from the center of the base object or even add a checkbox that allows to 'flip' the height and width (which would require to place some objects individually depending on where they are supposed to go ,which would be fine).


Any help on this is greatly appreciated, the .hip is attached: excercise_11_ray.hiplc


Share this post

Link to post
Share on other sites

Thank you very much julian. If there are simpler ways, can you point me towards a reference? I'm still learning and probably do many thing much more complicated than necessary.

The intention of this system is to have a tool that helps me build house facades much quicker. The boxes I am aligning in this example stand in for facade details such as windows, doors, ventilation objects, support beams, etc. In some instances I not only need to orient these objects towards the surface (which I already did with my first version), but also know the boundaries of the primitive they are projected on. For example a window that is always aligned at the bottom of a primitive, or a support beam that will be scaled to match the primitive size. To give some context, this is a shot of a building created with my current version of the tool:


Share this post

Link to post
Share on other sites

I was thinking the for loops in both the main tree and the subnet were unnecessary, probably, as the copy function is effectively a for loop by itself. Anyway, take a look at the attached scene - it removes both for loops but this time it does take liberties with your original scene!



Edited by julian johnson
improved alignment of boxes.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account


Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this