FieldList Modifiers
-
Hello,
I am working on a plugin that utilize Fields to affect the position of points in a spline. With the code listed below that I took from the FieldList Manual I am able to retrieve the falloff value from the positions I feed into the Fields.
However, the returned value does no give the effects of the Delay/Smooth/Spring/Decay Modifiers within the Field. How can I get the modified value?
Here is a video for clarity of
.GeData data; Matrix opMat = op->GetMg(); const DescID fieldParameterID(idFieldList); if (!op->GetParameter(fieldParameterID, data, DESCFLAGS_GET::NONE)) return returnArray; CustomDataType* const customData = data.GetCustomDataType(CUSTOMDATATYPE_FIELDLIST); FieldList* const fieldList = static_cast<FieldList*>(customData); if (!fieldList) return returnArray; Int32 fieldListCount = 0; if (fieldList) fieldListCount = fieldList->GetCount(); if (fieldListCount > 0) { maxon::BaseArray<maxon::Vector> positions; maxon::BaseArray<maxon::Vector> uvws; maxon::BaseArray<maxon::Vector> directions; resultVoid = positions.Resize(vectorArray.GetCount()); resultVoid = uvws.Resize(vectorArray.GetCount()); resultVoid = directions.Resize(vectorArray.GetCount()); Int32 pointIndex = 0; for (maxon::Vector& pos : positions) { pos = opMat * vectorArray[pointIndex]; pointIndex++; } FieldInput points(positions.GetFirst(), directions.GetFirst(), uvws.GetFirst(), pointIndex, Matrix()); FieldOutput results = fieldList->SampleListSimple(*op, points) iferr_return; Bool valid = FALSE; for (Int32 index = 0; index < positions.GetCount(); index++) { // Retreive falloff value to use results._value[index]; } }
Any help would be greatly appreciated.
John Terenece
-
Hi John,
important for field "memory" effects that depend of previous frames is the correct "caller" in the FieldInfo. This is important for the list to know whom to store the previous frame data for, as many sources can sample the same field list. The SampleListSimple you are using does not require passing a FieldInfo and I would assume that should still work as you are passing the caller (*op) to the Sample call, but maybe maybe something is broken :D. It might be worth trying the longer route by creating a FieldInfo and calling the general Sample function.:
maxon::Result< void > SampleList (const FieldInfo &info, const FieldInput &inputs, FieldOutput &outputs)
https://developers.maxon.net/docs/cpp/2023_2/struct_field_info.htmlRegards
Fritz -
@fritz
Thank you for the response Fritz.I tried swapping my code from using SampleListSimple to SampleList and I am still getting the same results as before. My code for sampling now looks like this.
FieldInput points(positions.GetFirst(), directions.GetFirst(), uvws.GetFirst(), pointIndex, Matrix()); const FieldInfo info = FieldInfo::Create(op, points, FIELDSAMPLE_FLAG::VALUE) iferr_return; FieldOutput results; results.Resize(vectorArray.GetCount(), FIELDSAMPLE_FLAG::VALUE) iferr_return; fieldList->SampleList(info, points, results);
John Terenece
-
Hi,
Our DropEffector have a falloff and it seems to work nicely with the Time and Delay you could maybe have a look at it. I don't see the use of CalcFields in your code that could be something to check.
Cheers,
Manuel -
Thanks for the response Manuel, I got it working.
John Terenece
-
hi,
Would be nice to share the solution.
Cheers,
Manuel