DirectX SDK |
This topic pertains only to applications developed in C++.
Setting up the direction for a single-axis effect is extremely simple because there is really nothing to specify. Put the DIEFF_CARTESIAN flag in the dwFlags member of the DIEFFECT structure, and set rglDirection to point to a single LONG containing the value 0.
The following code example sets up the direction and axis parameters for an x-axis effect:
DIEFFECT eff; LONG lZero = 0; // No direction DWORD dwAxis = DIJOFS_X; // X-axis effect ZeroMemory(&eff, sizeof(DIEFFECT)); eff.cAxes = 1; // One axis eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; // Flags eff.rglDirection = &lZero; // Direction eff.rgdwAxes = &dwAxis; // Axis for effect
Setting up the direction for a polar two-axis effect is only a little more complicated. Set the DIEFF_POLAR flag in dwFlags, and set rglDirection to point to an array of two LONGs. The first element in this array is the direction from which you want the effect to come. The second element in the array must be 0.
The following code example sets up the direction and axis parameters for a two-axis effect coming from the east:
DIEFFECT eff; LONG rglDirection = { 90 * DI_DEGREES, 0 }; // 90 degrees from // north, that is, east DWORD rgdwAxes[2] = { DIJOFS_X, DIJOFS_Y }; // X- and y-axis ZeroMemory(&eff, sizeof(DIEFFECT)); eff.cAxes = 2; // Two axes eff.dwFlags = DIEFF_POLAR | DIEFF_OBJECTOFFSETS; // Flags eff.rglDirection = rglDirection; // Direction eff.rgdwAxes = rgdwAxes; // Axis for effect
Setting up the direction for a Cartesian two-axis effect is a little more complicated. Set the DIEFF_CARTESIAN flag in dwFlags, and again set rglDirection to point to an array of two LONGs. This time the first element in the array is the x-coordinate of the direction vector, and the second is the y-coordinate.
The following code example sets up the direction and axis parameters for a two-axis effect coming from the east:
DIEFFECT eff; LONG rglDirection = { 1, 0 }; // Positive x = east DWORD rgdwAxes[2] = { DIJOFS_X, DIJOFS_Y }; // X- and y-axis ZeroMemory(&eff, sizeof(DIEFFECT)); eff.cAxes = 2; // Two axes eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; // Flags eff.rglDirection = rglDirection; // Direction eff.rgdwAxes = rgdwAxes; // Axis for effect