[SOLVED]Crowd Detect End Of Clip?

   2452   3   0
User Avatar
Member
2556 posts
Joined: June 2008
Offline
Hi All,

How can I reliably detect if my clip has played all it's frames?
There is @stateduration but that only tells me how long I have been in my current state. It is not accurate when retiming is turned on. Or there is no way to determine what amount of retiming is actually occurring? There is @clipretimes and @cliptimes but those numbers area always fluctuating.

I need some kind percentage through clip attribute. Is this part of the crowd system or can it be generated with VEX code based upon existing attributes?

Entertaining any suggestions…

Thanks
Edited by - Sept. 16, 2015 09:45:13
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
2556 posts
Joined: June 2008
Offline
In continuing effort to try to make use of the built-in agent inspection functions I offer this test scene.

I am trying to get the length of myself, in seconds.

I place a Crowd Trigger node into Custom VEXpression mode and run the following code every frame.

string handle_path = “opobj/crowd_sim:crowdobject/Geometry”; //geoself() I also tried 0
float my_clip_length = agentcliplength(handle_path, i@id, “walk”);
printf("My state is and my clip length is %f\n", s@state, my_clip_length);

Even though I can detect my state, I can no detect my length.

The attached example file is the default mocapbiped01 and a default crowd simulation.

Has anyone had any success with the VEX functions to fetch the agent clip length?

Attachments:
ap_clip_length_crowd_issue.hipnc (553.7 KB)
Untitled-1.jpg (156.7 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
7737 posts
Joined: July 2005
Online
I don't think you're passing in the right clipname. To double check, look in the geometry spreadsheet and under Primitive Intrinsics, examine agentclipnames.
User Avatar
Member
2556 posts
Joined: June 2008
Offline
Thank you Edward, that was it.

If I actually fetch the agentclipcatalog and then subtract the string length of my current clip state name I can detect myself in the list and pass the full clip name from the catalog instead of the post-fix state string found under the @state attribute.

string handle_path = “opobj/crowd_sim:crowdobject/Geometry”;
string clipname = “”; // Our result starts off empty.
string clipname_to_find = @state; // Searching for our state name.
int lcn = len(clipname_to_find); // Get the length of our state.
string agentcatalog = agentclipcatalog(handle_path, i@id); // Get the list of all possible states.
foreach (int i; string clip_candidate; agentcatalog) {
int l = len(clip_candidate); // Get the length of the list entry.
string candidate_state = clip_candidate; // Subtract our state length from entry length.
if (candidate_state == @state) {clipname = clip_candidate;} // Populate our result if a match.
}
if (len(clipname) > 0) {
float my_clip_length = agentcliplength(handle_path, i@id, clipname);
printf("My state is and my clip length is %f\n“, s@state, my_clip_length);
} else {
printf(”Unable to detect state in current clipcatalog.\n", s@state);
}


I suppose this is the same with other clip based VEX functions as well that require a clipname.

And here is the same thing with the main logic turned into a VEX function, clipname_from_state.


string clipname_from_state (string handle; int id; string state) {
string result = “”;
int l_state = len(state); // Get the length of our state.
string agentcatalog = agentclipcatalog(handle, id); // Get the list of all possible states.
foreach (int i; string clip_candidate; agentcatalog) { // Loop through list.
int l = len(clip_candidate); // Get the length of the list entry.
string candidate_state = clip_candidate; // Subtract our state length from entry length.
if (candidate_state == state) {result = clip_candidate;} // Populate our result if a match.
}
return result;
}

string handle_path = “opobj/crowd_sim:crowdobject/Geometry”;
string clipname = clipname_from_state(handle_path, i@id, @state);
if (len(clipname) > 0) {
float my_clip_length = agentcliplength(handle_path, i@id, clipname);
printf("My state is and my clip length is %f\n“, s@state, my_clip_length);
} else {
printf(”Unable to detect state in current clipcatalog.\n", @state);
}
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
  • Quick Links