Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    FieldList Modifiers

    Cinema 4D SDK
    r20 sdk c++
    3
    6
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      JohnTerenece
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • F
        Fritz
        last edited by

        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.html

        Regards
        Fritz

        1 Reply Last reply Reply Quote 0
        • J
          JohnTerenece
          last edited by JohnTerenece

          @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

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            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

            MAXON SDK Specialist

            MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • J
              JohnTerenece
              last edited by

              Thanks for the response Manuel, I got it working.

              John Terenece

              1 Reply Last reply Reply Quote 0
              • ManuelM
                Manuel
                last edited by

                hi,

                Would be nice to share the solution.

                Cheers,
                Manuel

                MAXON SDK Specialist

                MAXON Registered Developer

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post