Access to Attributes inside Unity C# script

   888   6   0
User Avatar
Member
158 posts
Joined: April 2014
Offline
How does one go about getting attributes in C# from an hda inside Unity?

So far we're trying to get a list of nodes and we need ID's (which aren't really exposed in Houdini). See attached.

We couldn't even find a way to get nodes by name.

There has to be a simpler and more elegant way.

Thank you.

Attachments:
h.JPG (65.3 KB)

Winter is coming!
User Avatar
Staff
571 posts
Joined: May 2017
Offline
I have a comprehensive example of this in the works. Plan to have it uploaded here tomorrow.
User Avatar
Staff
571 posts
Joined: May 2017
Offline
Attached is an example script showing how to load, cook, query and change parms, and attributes. I'll be integrating this into the plugin as part of the shipped example scripts.

Let me know if you have any questions, or if you have suggestions for more API support.

Attachments:
HEU_ExampleEvergreenQuery.cs (16.7 KB)

User Avatar
Member
158 posts
Joined: April 2014
Offline
Hello Seelan,

Okay, so we're making some progress but it seems to come to a dead end when we try to get them from a PDG link instance.

We've tried to put a “unity_script” attribute in the Top network as well as the hda's, but nothing works.

What's the proper way of doing this when you are running a PDG link?

I think the issue here is that we're trying on query on something that doesn't exist yet.

Thank you.
Winter is coming!
User Avatar
Staff
571 posts
Joined: May 2017
Offline
Please elaborate what you're trying to accomplish, and what you tried (HDA network screenshot).

If you just want a unity script to run or do some work after cooking, you can probably use the cook events. I should have better documentation on these, but alas, it slipped through the cracks. For now, on the Inspector UI on your HDA in Unity, you can open up the EVENTS section. This section allows callbacks to be attached to each of the Generate and Bake functions after they have been invoked. This is useful for executing custom code and setup after generating, cooking, or baking. For example, after baking a new platform from an HDA, a custom script can setup the platform for the navigation system. See HoudiniEngineUnity/Scripts/Tests/HEU_AssetEventReceiverTest.cs for examples of callback functions.
User Avatar
Member
158 posts
Joined: April 2014
Offline
Sorry for not being clear.

So we're setting up an environment similar to what Kenny Lammers did in his PDG tuts.

However, we need to get some points & attributes (from an HDA) at runtime to process them.

More specifically we have a Heightfield Scatter sop generating some points with a tag. So we query inside Unity for those points and attributes and we can get the points and attributes directly from an HDA.

But when we incorporate a TOP network and use the PDG link we don't get any HDA nodes returned. We don't know how to get access to those HDA's and their data (attributes, points etc) anymore.

We are using the same code and in the method PotpulateTOPNetworks() in HEU_PDGAssetLink.cs.

So how do we get access to the HDA's and their information (points attributes) used by the PDG link?

Or does the fact we're using a PDG link asset mean that we can't get access to the HDA's that the HDA Processors are processing?

I hope this makes sense.
Edited by firefly9000 - July 8, 2019 14:21:17

Attachments:
h.JPG (57.6 KB)

Winter is coming!
User Avatar
Staff
571 posts
Joined: May 2017
Offline
Ah ok. I think the confusion on your part can be clarified by thinking of not loading HDAs directly (as you would in Unity in the non-PDG workflow), but rather think of it as working with cook outputs of your TOP nodes and loading the generated .bgeo files. When an HDAProcessor is used in TOPs, it's only active when it's being cooked, but you can't really access that HDA from Unity because its running in another process somewhere. Rather, you'd wait for its output file(s) and get the attributes by loading that file, which is usually a .bgeo file (for Kenny's tutorial we used bgeo files).

PDGAssetLink does this automatically using HEU_GeoSync.cs. Take a look at HEU_PDGAssetLink.cs::LoadResults where the HEU_GeoSync.cs is attached to a gameobject, and StartSync is then called. You can then follow the rabbit hole, and you'll eventually end up in
HEU_ThreadedTaskLoadGeo.cs::DoWork
which does the loading of all geometry. You can attach your attribute querying code in there somewhere to get the data from your generated bgeo files.
Edited by seelan - July 8, 2019 14:57:21
  • Quick Links