Search Tips Advanced Search |
| Delphi Graphics and Game Programming Exposed with DirectX 7.0 by John Ayres Wordware Publishing, Inc. ISBN: 1556226373 Pub Date: 12/01/99
Search this book:
Previous | Table of Contents | Next
Conditions As we’ve discussed, conditions are force feedback effects that respond to the position or motion of an axis. Condition effects are divided into four subtypes: spring, friction, damper, and inertia, all of which produce similar but subtly different tactile feedback sensations. All condition effects use a TDICondition structure for their type-specific parameters. The TDICondition structure is defined as:
    TDICondition = packed record

      lOffset : longint;                    // effect offset

      lPositiveCoefficient : longint;       // positive offset coefficient

      lNegativeCoefficient : longint;       // negative offset coefficient

      dwPositiveSaturation : DWORD;         // positive offset max force output

      dwNegativeSaturation : DWORD;         // negative offset max force output

      lDeadBand : longint;                  // inactive region

    end;
Each condition subtype makes use of specific members of this structure, as we’ll examine below. Unlike other effects, conditions can accept an array of TDICondition structures in the lpvTypeSpecificParams member of the TDIEffect structure. Each TDICondition structure defines condition parameters for each axis, with each TDICondition structure in the array matching up to the axis specified in the rgdwAxes member at the same index. When using an array of TDICondition structures in this manner, the cbTypeSpecificParams member of the TDIEffect structure must be set to SizeOf(TDICondition) multiplied by the number of members in the array. We’ll see an example of this later in the chapter. Spring A spring condition causes the device to exert a force on an axis when it is moved away from a central location. This central location is defined by the lOffset member. A value of 0 puts this point at the center of the axis. The lOffset member can be set to values ranging from 10,000 to 10,000 (or you can use the DI_FFNOMINALMAX constant again), with negative values to the left and positive values to the right, relative to the axis. The lPositiveCoefficient indicates the strength of the force exerted on the axis when it is moved to the farthest position from the defined central location. This force is increased from 0 to lPositiveCoefficient as the axis is moved, giving a sensation of increased resistance as the axis is moved farther and farther away from the neutral point. Again, the lPositiveCoefficient can be set to values in the range 10,000 to 10,000, with positive values pushing the axis toward the central location and negative values pulling the axis away from the central location. If the driver supports negative coefficients, the lNegativeCoefficient member can be set to values within this range, which can be used to indicate a different amount of force to be applied when the axis is moved to the negative side of the central location. If negative coefficients are not supported, the positive coefficient is used. The lDeadBand member defines an area around the central location in which the axis can move before any amount of force is applied. The saturation values define a similar area at the farthest distance of the axis, with the negative saturation value indicating an area on the negative side of the central location. As with coefficients, if negative saturation values are not supported, the positive saturation value is used. dwPositiveSaturation, dwNegativeSatura- tion, and lDeadBand members can be set in the range of 0 to 10,000, indicating a percentage of the range of travel in hundredths of a percent.
| Note: The lDeadBand member may not be supported by some drivers.
Friction The friction condition causes the device to exert a constant force on an axis as the axis is moved, regardless of its position. The lPositiveCoefficient member indicates the strength of this force, with values ranging from 10,000 to 10,000. Positive values indicate a push on the axis in the opposite direction of its movement, giving a resistant sensation, and negative values indicate a pull on the axis in the direction of its movement, giving an accelerating sensation. The lOffset, lNegativeCoefficient, dwPositiveSaturation, dwNegativeSaturation, and lDeadBand members are ignored. Damper The damper condition causes the device to exert a force on an axis in proportion to its velocity of movement. In other words, the faster the axis is moving, the more force is exerted. The lPositiveCoefficient member indicates the maximum force applied, with values in the range of 10,000 to 10,000. Like friction, positive values indicate a push on the axis in the opposite direction of its movement, and negative values indicate a pull on the axis in the direction of its movement. The lOffset member is used to define a central point very similar to the spring condition. However, this central point is in relation to the axis’ velocity, with a value of 0 indicating no velocity. A value other than 0 will cause a force to be applied to the axis even when it is not moving. The saturation and deadband parameters act in a similar manner in relation to velocity, and can be used to indicate a minimum and maximum velocity range in which force would be exerted on the axis. Inertia The inertia condition is very similar to the damper condition, except that force is exerted in proportion to the acceleration of an axis. In other words, no force will be applied if the axis is moving at a steady velocity. Like the damper condition, the lPositiveCoefficient member is used to indicate the maximum force, with positive values causing resistance and negative values causing acceleration. Also like the damper condition, the lOffset can be used to define a central point relative to the acceleration of the axis, with non-zero values generating acceleration. Saturation and deadband work in a similar manner. Constant Forces A constant force is simply a push on an axis at a given magnitude. It is the simplest of all force feedback effects, and as such, it has a very simple type-specific data structure. Constant forces use a TDIConstantForce structure for their type-specific parameters, which is defined as:
    TDIConstantForce = packed record

      lMagnitude : longint;                // the strength of the force

    end;
The only member of this structure, lMagnitude, indicates the strength of the force in the range 10,000 to 10,000. Positive values push the axis in the direction indicated by the rglDirection member of the TDIEffect structure; negative values push the axis in the opposite direction.
Previous | Table of Contents | Next

Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.