SOLVED Force fields for dynamics simulations


I am working on a C++ plugin that does particle dynamics simulations. It is not using C4D particles; the simulation engine is different. I am looking for a way to create scene objects that can act as Wind/Gravity/etc. forces for the particles in the simulation; i.e. objects that allow obtaining vector forces for given particle positions/velocities (and possibly masses).

For C4D particles (which, again, I am not using) it seems this can be done with Particle Attractor/Deflector/Gravity/Wind etc. from the Simulate->Particles menu. However I can't find the C++ API to obtain the forces from these objects. I am looking for an analogue to 3ds Max's class ForceField or Maya's MFnField function set. Or maybe there's a different way to do that in C4D?



Hi Nikolay, thanks for reaching out us.

With regard to your question, if your scope is to retrieve the values of the parameters bound to such particle "operators" BaseContainers and Parameters are the relevant words.

With regard to parameters, being these entities derived from the C4DAtom class I warmly recommend to look at the Parameter and Parameter Properties section in the C4D Atom Manual where accessing the value belonging to a parameter is presented.

With regard to BaseContainer, I instead recommend you to have a look at the BaseContainer Manual.

Finally, but consider it more like a rough thought, you might think about having a twin "representation" of your particles so that a ghost "C4D particle" representation can interact with the Cinema 4D particle operators and give you the chance to derive the behavior that your particles will have to undergo when interacting with such operators.

Best, Riccardo

Hi Riccardo,

Thanks a lot for your reply. Unfortunately, I couldn't find anything helpful in the documentation.

Let me explain in more detail.

In abstract terms, I need an object that can can represent a vector field, with the appropriate API allowing to obtain vector values at any point (or set of points) in space.

In practical terms, I need to get the force exerted by, e.g. a Wind object, on a particle at a given world position. This is the wind force that a C4D particle at that position would "feel" when simulated. Is there a public API to get that force? I stress again that the force is normally position-dependent, hence the "parameters" of the Wind are not what I'm looking for. For some force fields (e.g. drag), the force depends on the velocity (again, that of each specific particle); for others (such as gravity) the force would be constant.

The only thing I could find in the documentation that resembles what I am looking for are the functions for sampling a field: FieldObject::Sample() and related. These functions allow getting field values at a set of points in space, which is exactly what I need. However, C4D fields seem to be geometric objects, not directly related to dynamics, and seem designed to represent falloffs rather than vector fields. I will end up using C4D fields if there's nothing else available, but I'd rather let clients use the appropriate C4D tools for particle dynamics. On the other hand, maybe I'm wrong about C4D fields - can they be used to directly influence particle motion?


Hi Nikolay, thanks for following up and for further detailing you request.

With regard to the FieldObject class you've pin-pointed, it has, unfortunately, nothing to do with vector fields but rather with MoGraph Fields as you've already spotted. Just for the sake of completeness this manual describes it.

Going back to the root, I'm sorry to confirm that there's no public API fitting with the precise scope you mentioned above to retrieve for a given point in space the force applied by a particle operator in that specific position.

Best, Riccardo

Hi Ricardo, thanks a lot for the prompt and detailed replies!

It looks like we'll have to abandon this functionality in the C4D version of the plugin for now. Too bad, since it adds a great deal of flexibility to the simulation.

Any chance you would consider extending the API to allow native C4D objects to act as forces in external dynamics simulations? I don't think this is unreasonable, as I said this is available in both 3ds Max and Maya. Any plugin that does dynamics would absolutely want to have these available.



Hi Nikolay, thanks for following up.

I've forwarded the idea request to the development department responsible for. After evaluating they'll decide if and when to schedule this API addition in our release cycle.

Best, Riccardo