access data from customAttributes
#1
hi tyson,
it would be nice if we have ability to access data from customAttributes.
i want to be able birth particles from object custom attributes which storing array of matrix3 .
i know its possible just by using to "birthobject" which take transform from it.
but if i have to get 10k+ objects to be used in birthObject it will make the scene too slow...
and also picking 10k objects took forever to update the list inside tflow.

it will be much efficient by just storing the matrix3 array into attributes...then let flow access those data to generate particles. 
even better if we can access all kind data not just matrix3
this feature will also make things very procedural....and i think a lot of TDs will happy  Big Grin
thanks...
  Reply
#2
I don't really see the benefit of this. Why are you storing transforms in custom attributes to begin with? Why not just use a Script operator or something?
  Reply
#3
(03-14-2020, 03:23 AM)tyFlow Wrote: I don't really see the benefit of this. Why are you storing transforms in custom attributes to begin with? Why not just use a Script operator or something?
hi tyson i got tree generator script... it generate thousands leafs.
i can convert it to particle using birth object using element option. but offcourse i lost precise transform and pivot.
so it will be benefit if i can just reuse the precalculated transform matrix from the script when the leafs generated. 
another case is when i created cloner modifier and some procedural object... like this:  https://youtu.be/TcHRAwlN0vs  (just jump at 3:14 if too long).
if i can make tflow talk to those it would be awesome... just some idea though... 
  Reply
#4
Well for leaves another option is to just procedurally generate a fairly accurate pivot. You can use the Move Pivots operator to move the leaves pivots to the closest point on the nearest branch, and the Rotation operator (with affect shapes turned off) to orient the pivot to the nearest point on the branch, so the z-axis of the pivot matches the surface normal.

Certainly using the Custom Attributes of your leaves somehow would give you perfect accuracy, but adding some kind of "Birth from Custom Attributes" operator would be so esoteric you might be the only one who ever actually utilizes it Smile
  Reply
#5
(03-14-2020, 04:37 PM)tyFlow Wrote: Well for leaves another option is to just procedurally generate a fairly accurate pivot. You can use the Move Pivots operator to move the leaves pivots to the closest point on the nearest branch, and the Rotation operator (with affect shapes turned off) to orient the pivot to the nearest point on the branch, so the z-axis of the pivot matches the surface normal.

Certainly using the Custom Attributes of your leaves somehow would give you perfect accuracy, but adding some kind of "Birth from Custom Attributes" operator would be so esoteric you might be the only one who ever actually utilizes it Smile

yes using move pivot is my current closest solution...
regarding "i am the only one who ever actually utilizes it " not really sure about that.
the idea is we want to drive value with another value that we prepared beforehand. its the same concept as data operator in PFLOW.
there is "object parameter" which does the same (see attached image). i can acces bend angle value to be use for anything. the value doesn't have to be matrix...it can be float,vector,boolean,etc. 
and it doesn't have to be implemented in "birth" operator. as along it can acquire data doesn't matter where you gonna implement it. just plug it to be used in other operator. for example set position from attribute/parameter. or any other use case. its quite flexible actually (just my opinion).  Smile


Attached Files Thumbnail(s)
   
  Reply
#6
The issue is not driving values with other values, the issue is the method. Storing values in custom attributes is as arbitrary as storing them in strings in the user property buffer, or in a text file on disk, etc. I'm not going to add a "Birth From Custom Attributes" operator any more than I would add a "Add Force from values stored in text file" operator, because it's too niche.

A generic "get value from parameter block" operator would be less niche, but then it wouldn't be specific enough for your purposes anyways. Maybe a single property could be read from an arbitrary parameter block, but being able to read arrays of matrices, and then use those values to birth particles...is its own beast that would require handling in non-intuitive ways.

That's why the script operator exists...so that you can basically do whatever handling is required and I don't have to make a million operators for every very-specific-and-unique scenario Smile By the way it's worth noting: the Script operator is linked up to max's own .NET implementation...so it's conceivable that you could use it to retrieve an IINode of your input object (by name or handle), then read custom attributes from it, then do your birthing. I haven't tested that specifically, but I don't think there's anything preventing it from working in the current implementation.
  Reply
#7
For fun, here is an example of reading custom attributes from a node using the Script operator. In this case, I added 6 custom attribute float values to a point helper in the scene, and read them in using a script. I birth a number of particles equal to the number of available attributes, and assign the attribute float value to the new particle's position.x value.

If you click the point helper in the scene, you can see the attributes in the modifier panel and change them (refresh the sim after changing them in order to import the changes into the flow).

The only real trick to accessing Max C# structures (IINode, IParamBlock, etc) is figuring out what their class names and function/property names are. They mostly correspond to equivalent C++ SDK structures, and you can figure out the exact syntax required by examining the .NET dlls in the [maxroot]\bin\assemblies folder with a tool like DotPeek.


Attached Files
.max   custAttrib.max (Size: 744 KB / Downloads: 322)
  Reply
#8
(03-14-2020, 07:39 PM)tyFlow Wrote: For fun, here is an example of reading custom attributes from a node using the Script operator. In this case, I added 6 custom attribute float values to a point helper in the scene, and read them in using a script. I birth a number of particles equal to the number of available attributes, and assign the attribute float value to the new particle's position.x value.

If you click the point helper in the scene, you can see the attributes in the modifier panel and change them (refresh the sim after changing them in order to import the changes into the flow).

The only real trick to accessing Max C# structures (IINode, IParamBlock, etc) is figuring out what their class names and function/property names are. They mostly correspond to equivalent C++ SDK structures, and you can figure out the exact syntax required by examining the .NET dlls in the [maxroot]\bin\assemblies folder with a tool like DotPeek.

whoa this is great...
i can dive deeper about this script operator.
yeah in fact i wouldn't ask complicated operator if i knew this can be done before...
hmmm perhaps you could update the doc or example for this capabilities...
thanks tyson!!!
  Reply


Forum Jump: