Hello, a simple question from a new Houdini user
I am placing instances along a spline in Unreal, and I am having trouble on getting the resample length to adapt to the bounding box of the instance used inside Unreal. Ideally when I change to an instance with a different size, the resample length of the spline should change as well. Any ideas on how to do this?
Instance size affecting spline resample length
5026 5 0- Sc
- Member
- 3 posts
- Joined: 3月 2014
- Offline
- DASD
- Member
- 453 posts
- Joined: 2月 2013
- Offline
You can use http://www.sidefx.com/docs/houdini15.5/expressions/bbox [sidefx.com] to find out about the size of the thing you want to instance, and then it's a matter of dividing the length of the spline by th result to find out how many points you want on the spline. Also probably need to truncate that number (round off) and make sure the last point of the spline is removed, or something like that. Depends on what behaviour you actually want.
You will probably also want to look into the polyframe SOP to allign the normals of the points on the spline along the spline, so you can orient the instances along the spline…
You will probably also want to look into the polyframe SOP to allign the normals of the points on the spline along the spline, so you can orient the instances along the spline…
Edited by DASD - 2016年11月28日 14:03:53
- Sc
- Member
- 3 posts
- Joined: 3月 2014
- Offline
- DASD
- Member
- 453 posts
- Joined: 2月 2013
- Offline
- Sc
- Member
- 3 posts
- Joined: 3月 2014
- Offline
- DASD
- Member
- 453 posts
- Joined: 2月 2013
- Offline
As far as I understand, you assign a new mesh (instead of the default box) to the HDA in Unreal. What this does is, it puts the new mesh onto the instance points, instead of the old mesh. Now here's the problem. You scale your box to make it fit along the spline segments, but you are not scaling the mesh you assign in Unreal. To do this, you need to analyze the size of the input mesh. You can get the input mesh from Unreal into the HDA with an object merge node with the “Object 1” parameter promoted to the UI of your HDA. You make a check in switchnode, to see if there is anything coming in from this merge node. If not, you just use your default box. Then you analyze the size of this thing and then calculate a scale factor. Basically: size of box along the axis that aligns with the curve edge times scale factor equals curve segment lenght.
Then you create a point vector attribute “scale” with each of the three value slots equal your scale factor. That needs to happen on your instance points, so basically you can do it in the same node where you create the instance attribute.
You will also want to put a polyframe node after that. Untick “Normal Name”, replace “tangentu” with “N” (no quotation marks) and set Entity to “First Edge”. That way you get normals along the spline. These normals and the scale attribute are both interpreted by the instance node to do specific things with the instanced mesh. The normals will rotate it and the scale will scale it.
In unreal this then gets translated into a Instance static mesh node in Blueprints (when you bake to blueprints) and that blueprint node does the exact same thing as Houdini's instance node. Note that in Unreal negative scale on instances will lead to undesirable results, so don't do it.
Then you create a point vector attribute “scale” with each of the three value slots equal your scale factor. That needs to happen on your instance points, so basically you can do it in the same node where you create the instance attribute.
You will also want to put a polyframe node after that. Untick “Normal Name”, replace “tangentu” with “N” (no quotation marks) and set Entity to “First Edge”. That way you get normals along the spline. These normals and the scale attribute are both interpreted by the instance node to do specific things with the instanced mesh. The normals will rotate it and the scale will scale it.
In unreal this then gets translated into a Instance static mesh node in Blueprints (when you bake to blueprints) and that blueprint node does the exact same thing as Houdini's instance node. Note that in Unreal negative scale on instances will lead to undesirable results, so don't do it.
Edited by DASD - 2016年11月30日 14:25:03
-
- Quick Links