Varying multiple objects output / Making fences

   2960   8   1
User Avatar
Member
52 posts
Joined: Nov. 2016
Offline
Hey there.
So I am making fences with Houdini.
Should be a fairly straight forward process, but I have run into a rather specific problem with how Houdini and HEU seems to function.

So putting down a row of poles on a flat surface and instantiating something between them is all fine and good, because it will be a square, even space between the poles. But putting them on a terrain becomes troublesome, if you need to fit wires, planks or fences between them. Since this space between poles with slightly different rotations won't be square, I'd have to deform or uniquely generate each “filling” between the poles.

I can this in a geometry node with a for-loop, but then I will end up with just one big object in Unity, which is really bad for something that is running across a good 3-400m in-game. Culling will be problematic.

Any suggestions on how I could get a dynamic number of outputs? They obviously don't need to be instances of geometry or anything, just not one big piece of geo.
Edited by MartinBaadsgaard - Nov. 15, 2018 18:18:00
User Avatar
Member
571 posts
Joined: May 2017
Offline
Using instancing is probably the way to go if you don't want to write custom code. You can use a Resample on your curve or whatever is defining the path, which can break up your geometry into sections, then assign each section as an instance to a point. You might even be able to reuse sections if they are similar, maybe.

Another way using custom code in Unity is to dynamically create an object merge node for each section, then get the output from it. You can take a look at the example code in Plugins/HoudiniEngineUnity/Scripts/Examples/HEU_ScriptMeshInputUVLayoutExample.cs to see how to dynamically create nodes and get outputs. This path will be more trickier though.
User Avatar
Member
52 posts
Joined: Nov. 2016
Offline
So the first thing you are talking about was what I was first thinking I'd do.
But I am not sure how to go about it in practice.
(Sorry, still rather new to Houdini..)

An Instance Obj node only takes 1 object input and everything defined within its network will define the points to instance on. There is an instancepoint() function to use, but it will not let you make variations in the SOP per copy, only object-level variation.

So not sure how to do it the way you are mentioning.


The other way sounds very extensive. I'm gonna go have a good long look at that example just for the educational value of it, but of course, simpler is better
Edited by MartinBaadsgaard - Nov. 16, 2018 11:58:13
User Avatar
Member
571 posts
Joined: May 2017
Offline
MartinBaadsgaard
So the first thing you are talking about was what I was first thinking I'd do.
But I am not sure how to go about it in practice.
(Sorry, still rather new to Houdini..)

An Instance Obj node only takes 1 object input and everything defined within its network will define the points to instance on. There is an instancepoint() function to use, but it will not let you make variations in the SOP per copy, only object-level variation.

So not sure how to do it the way you are mentioning.

You can use the instance attribute to define the object to use per point. So for each point, create a string-type attribute named instance with value of the path to the object you want to use at that point. These objects would then be the sections.
Edited by seelan - Nov. 16, 2018 14:02:19
User Avatar
Member
52 posts
Joined: Nov. 2016
Offline
Oh, yea so I can use prefabs at each point. But I also wanted to generate these objects in the HDA.
So it would generate a deformed mesh to fit perfectly between each set of fence poles. You can imagine that the four corners could be either offset in a parallelogram or skewed if the poles have randomized orientation of pick it up from the normal of the terrain.

So I would generate potentially a hundred sections, which should all, preferably, be individual objects.
User Avatar
Member
571 posts
Joined: May 2017
Offline
The instance attribute allows to point to internal objects within an HDA.
The unity_instance attribute allows to point to prefabs or meshes in Unity.

Also, regardless of either one you use, there will be a UI field to override the instance object in Unity.
User Avatar
Member
52 posts
Joined: Nov. 2016
Offline
I was very confused for a bit. Haven't been able to find anything about the instance Obj node letting you define a path in the attribute.
So first I thought you meant the instance SOP node and “instancepath”.
Which interestingly enough, ended being my solution.

So my mind was a bit blown when defining that “instance” point attribute just “magically worked”. What the hell!
Where in the docs is this??

But since I will have a variable number of outputs, I couldn't just have them predefined in the SOP network.
So what i ended up doing was actually create a loop, where i vary the “instances” and then just use the Instance SOP node to create in individual object in Unity.

I attached a little example with bot the Instance Attribute for the OBJ Instance node and an example of a foreach with the SOP Instance node to create randomly jiggled varying outputs of the input.

Just if someone else comes by this and need a solution or if what I am doing is horribly bad practice and needs correction

Attachments:
Obj Inst Test.hda (24.4 KB)

User Avatar
Member
571 posts
Joined: May 2017
Offline
The instance attribute wasn't documented in the plugin documentation, but I've just updated it (online version should be updated tomorrow).

Sounds like you got something that can get you dynamic outputs though.
User Avatar
Member
52 posts
Joined: Nov. 2016
Offline
Thanks, yea it is a very useful detail.
Small note; I didn't manage to find it in the Houdini docs either (not HEU or Engine docs, but main program),
which was why I was surprised, as it clearly does its thing right in Houdini..
Maybe I missed something, maybe there are holes in the docs.

I did find tutorials on it later, though.
  • Quick Links