force (lx_force.hpp)

From The Foundry MODO SDK wiki
Jump to: navigation, search
There are security restrictions on this page


Force

Forces describe how elements in a dynamic simulation are affected by outside influences. A force item derives from a common item type, and writes a force object to one of its channels. Simulations can then access the force interface and use it to compute the forces on its elements.

Item Type

Force items all derive from a common type, a type of locator. Being a locator type means all forces have a location, which seems fairly reasonable. All forces implicitly support enable/disable, strength and inversion.

(1) SDK: Declarations
 #define LXsITYPE_FORCE                  "force.root"
 
 #define LXsICHAN_FORCE_FORCE            "forceObj"
 #define LXsICHAN_FORCE_FILTER           "filterObj"
 #define LXsICHAN_FORCE_ENABLE           "enable"
 #define LXsICHAN_FORCE_STRENGTH         "strength"
 #define LXsICHAN_FORCE_TORQUE           "torque"
 #define LXsICHAN_FORCE_INVERT           "invert"

An item inheriting from this type writes a basic force object to the 'forceObj' channel. This is then overridden by the core implementation for the default behaviors. This includes a falloff on the force effect which can be set with a graph link.

(2) SDK: Declarations
 #define LXsGRAPH_FORCEFALLOFF   "forceFalloff"

Interface

The force interface allows clients to compute forces from positions and other element features.

(3) SDK: Declarations
 #define LXu_FORCE               "A712DF74-0DD4-4D8C-87B7-CDF66D4E6848"

Get flag bits describing the force. A force can require velocity or mass as an input, and can optionally generate angular forces.

(4) SDK: ILxForce interface
         LXxMETHOD(  unsigned,
 Flags) (
         LXtObjectID              self);

(5) SDK: Declarations
 #define LXfFORCE_VELOCITY        0x01
 #define LXfFORCE_MASS            0x02
 #define LXfFORCE_ANGULAR         0x04

These single point methods are optimized for computing a force for a single element. Any given force only needs to implement one of these based on the flags above. The client is required to call the right API.

(6) SDK: ILxForce interface
         LXxMETHOD(  LxResult,
 Force) (
         LXtObjectID              self,
         const LXtFVector         pos,
         LXtFVector               force);
 
         LXxMETHOD(  LxResult,
 ForceV) (
         LXtObjectID              self,
         const LXtFVector         pos,
         const LXtFVector         velocity,
         LXtFVector               force);
 
         LXxMETHOD(  LxResult,
 ForceM) (
         LXtObjectID              self,
         const LXtFVector         pos,
         float                    mass,
         LXtFVector               force);
 
         LXxMETHOD(  LxResult,
 ForceVM) (
         LXtObjectID              self,
         const LXtFVector         pos,
         const LXtFVector         velocity,
         float                    mass,
         LXtFVector               force);

Computing forces over multiple elements is more efficiently done using runs which are arrays of floats. Anything not requested by the flags will be unset. Angular forces can only be computed in runs.

(7) SDK: ILxForce interface
         LXxMETHOD(  LxResult,
 ForceRun) (
         LXtObjectID              self,
         const float            **pos,
         const float            **velocity,
         const float             *mass,
         float                  **force,
         unsigned                 num);
 
         LXxMETHOD(  LxResult,
 ForceRunAng) (
         LXtObjectID              self,
         const float            **pos,
         const float            **velocity,
         const float            **angVel,
         const float             *mass,
         float                  **force,
         float                  **torque,
         unsigned                 num);

(8) User Class: Force method

Empty Force Python user class.

(9) PY: Force method
 pass