#include <AffineMatrix.hpp>
Inherits DSOL::IUpdate.
Public Member Functions | |
AffineMatrix (const uint index, const bool useMainOam=true) | |
the constructor that creates an AffineMatrix object. | |
AffineMatrix & | flipHorizontal () |
flips the matrix horizontally. | |
AffineMatrix & | flipVertical () |
flips the matrix vertically. | |
const int | getConvertedHdx () const |
returns the 1st value of the affine matrix, converted. | |
const int | getConvertedHdy () const |
returns the 3th value of the affine matrix, converted. | |
const int | getConvertedScaleX () const |
returns the x scale. | |
const int | getConvertedScaleY () const |
returns the y scale. | |
const int | getConvertedVdx () const |
returns the 2nd value of the affine matrix, converted. | |
const int | getConvertedVdy () const |
returns the 4th value of the affine matrix, converted. | |
const int | getHdx () const |
returns the 1st value of the affine matrix. | |
const int | getHdy () const |
returns the 3th value of the affine matrix. | |
const uint | getIndex () const |
returns the rotation index of the object. | |
bool | getMainEngine () const |
returns if the sprite uses the main oam or not. | |
const int | getScaleX () const |
returns the x scale. | |
const int | getScaleY () const |
returns the y scale. | |
const int | getVdx () const |
returns the 2nd value of the affine matrix. | |
const int | getVdy () const |
returns the 4th value of the affine matrix. | |
const AffineMatrix & | operator= (const AffineMatrix &source) |
the asignment operator, will copy everything exept the index. | |
AffineMatrix & | setAffineTransformation (const int hdx, const int vdx, const int hdy, const int vdy) |
Allows you to directly sets the affine transformation matrix used by the hardware. | |
AffineMatrix & | setAngleScale (const int angle=0, const int scaleX=FIX_VALUE_1, const int scaleY=FIX_VALUE_1) |
sets the angle and scale of the object. | |
AffineMatrix & | setConvertAffineTransformation (const int hdx, const int vdx, const int hdy, const int vdy) |
Allows you to set a normal affine transformation matrix. | |
AffineMatrix & | setIdentityMatrix () |
(re)sets the matrix to the identity matrix. | |
AffineMatrix & | setIndex (const uint index) |
sets the rotation index of the object. | |
AffineMatrix & | setMainEngine (const bool useMainOam=true) |
sets the AffineMatrix's engine. | |
virtual AffineMatrix & | update () |
this will update the AffineMatrix object. | |
Static Public Member Functions | |
static void | freeAffineMatrix (const uint AffineMatrixIndex, const bool mainOAM=true) |
frees a AffineMatrix index so other sprites can use it. | |
static uint | reserveEmptyAffineMatrix (const bool mainOAM=true) |
reserves an empty AffineMatrix index to use. | |
Static Public Attributes | |
static const int | FIX_SCALE = (1<<8) |
a constant for scaling the .8 fixed point values with division. | |
static const int | FIX_SHIFT = 8 |
a constant for shifting the .8 fixed point values. | |
static const int | FIX_VALUE_1 = (1<<8) |
a constant for the value 1 in .8 fixed point. | |
static const uint | NUMBER_OF_AFFINE_MATRIXES = 32 |
a constant for the number of affine matrixes available per sprite engine |
sprite(s) can use objects of this class to manage information about scaling and rotating sprites. there can be at most 32 objects (index 0-31) (the hardware wont allow more), but multiple sprites can use the same AffineMatrix object.
DSOL::Sprites::AffineMatrix::AffineMatrix | ( | const uint | index, | |
const bool | useMainOam = true | |||
) | [inline] |
the constructor that creates an AffineMatrix object.
index | the index of the AffineMatrix in oam, must be (0-31). | |
useMainOam | true if this AffineMatrix object is for sprites of the main engine, false for the sub engine. default is true. |
AffineMatrix& DSOL::Sprites::AffineMatrix::flipHorizontal | ( | ) |
flips the matrix horizontally.
flips the matrix so that any image that uses it will be flipped over a horizontal line in the middle of the image.
AffineMatrix& DSOL::Sprites::AffineMatrix::flipVertical | ( | ) |
flips the matrix vertically.
flips the matrix so that any image that uses it will be flipped over a vertical line in the middle of the image.
static void DSOL::Sprites::AffineMatrix::freeAffineMatrix | ( | const uint | AffineMatrixIndex, | |
const bool | mainOAM = true | |||
) | [inline, static] |
frees a AffineMatrix index so other sprites can use it.
this will free a AffineMatrix index that has been reserved with reserveEmptyAffineMatrix() so that other sprites can use it.
mainOAM | true if the AffineMatrix index is for the main oam, false otherwise | |
AffineMatrixIndex | the index to be freed, should be an index gotten with reserveEmptyAffineMatrix() |
const int DSOL::Sprites::AffineMatrix::getConvertedHdx | ( | ) | const |
returns the 1st value of the affine matrix, converted.
the value is converted to a more easier format for humans, (a normal affine matrix, with an up-right ax system). the value may differ a few points because of precision loss.
const int DSOL::Sprites::AffineMatrix::getConvertedHdy | ( | ) | const |
returns the 3th value of the affine matrix, converted.
the value is converted to a more easier format for humans, (a normal affine matrix, with an up-right ax system).
const int DSOL::Sprites::AffineMatrix::getConvertedScaleX | ( | ) | const |
returns the x scale.
const int DSOL::Sprites::AffineMatrix::getConvertedScaleY | ( | ) | const |
returns the y scale.
const int DSOL::Sprites::AffineMatrix::getConvertedVdx | ( | ) | const |
returns the 2nd value of the affine matrix, converted.
the value is converted to a more easier format for humans, (a normal affine matrix, with an up-right ax system).
const int DSOL::Sprites::AffineMatrix::getConvertedVdy | ( | ) | const |
returns the 4th value of the affine matrix, converted.
the value is converted to a more easier format for humans, (a normal affine matrix, with an up-right ax system). the value may differ a few points because of precision loss.
const int DSOL::Sprites::AffineMatrix::getHdx | ( | ) | const [inline] |
returns the 1st value of the affine matrix.
const int DSOL::Sprites::AffineMatrix::getHdy | ( | ) | const [inline] |
returns the 3th value of the affine matrix.
const uint DSOL::Sprites::AffineMatrix::getIndex | ( | ) | const [inline] |
returns the rotation index of the object.
bool DSOL::Sprites::AffineMatrix::getMainEngine | ( | ) | const [inline] |
returns if the sprite uses the main oam or not.
const int DSOL::Sprites::AffineMatrix::getScaleX | ( | ) | const [inline] |
returns the x scale.
const int DSOL::Sprites::AffineMatrix::getScaleY | ( | ) | const [inline] |
returns the y scale.
const int DSOL::Sprites::AffineMatrix::getVdx | ( | ) | const [inline] |
returns the 2nd value of the affine matrix.
const int DSOL::Sprites::AffineMatrix::getVdy | ( | ) | const [inline] |
returns the 4th value of the affine matrix.
const AffineMatrix& DSOL::Sprites::AffineMatrix::operator= | ( | const AffineMatrix & | source | ) |
the asignment operator, will copy everything exept the index.
source | the affine matrix to copy from. |
static uint DSOL::Sprites::AffineMatrix::reserveEmptyAffineMatrix | ( | const bool | mainOAM = true |
) | [static] |
reserves an empty AffineMatrix index to use.
this will check if there are AffineMatrix indexes that hasn't been reserved yet, and reserves and returns it if there are onreserved AffineMatrix. there are 32 AffineMatrix for main oam and 32 for sub engine.
mainOAM | true if the Affine Matrix is for the main oam, false otherwise |
AffineMatrix& DSOL::Sprites::AffineMatrix::setAffineTransformation | ( | const int | hdx, | |
const int | vdx, | |||
const int | hdy, | |||
const int | vdy | |||
) | [inline] |
Allows you to directly sets the affine transformation matrix used by the hardware.
with this, you have more freedom to set the matrix, but it might be more difficult to use if you're not used to affine transformation matrix. make sure to inverse the matrix before passing it to this function, cause the hardware needs an inverse matrix. or use setConvertAffineTransformation(), which convert the values for you.
hdx | the 1st matrix value, in .8 fixed point format. | |
vdx | the 2th matrix value, in .8 fixed point format. | |
hdy | the 3nd matrix value, in .8 fixed point format. | |
vdy | the 4th matrix value, in .8 fixed point format. |
AffineMatrix& DSOL::Sprites::AffineMatrix::setAngleScale | ( | const int | angle = 0 , |
|
const int | scaleX = FIX_VALUE_1 , |
|||
const int | scaleY = FIX_VALUE_1 | |||
) |
sets the angle and scale of the object.
the angle can be one of the spriteAngle enum values, a 360 degree value converted with libnds's degreesToAngle() macro function, or an 32 bits int if you need precision. the scale values are in .8 fixed point format.
angle | the new angle of the object, in the format that libnds uses (32768 degrees), default is 0 (no angle). | |
scaleX | the value to scale the x ax with, in .8 fixed point format. | |
scaleY | the value to scale the y ax with, in .8 fixed point format. |
AffineMatrix& DSOL::Sprites::AffineMatrix::setConvertAffineTransformation | ( | const int | hdx, | |
const int | vdx, | |||
const int | hdy, | |||
const int | vdy | |||
) |
Allows you to set a normal affine transformation matrix.
with this, you have more freedom to set the matrix, but it might be more difficult to use if you're not used to affine transformation matrix. this function will convert the matrix so you can enter a normal matrix, and it will work correctly with the hardware. it assumes the values are in an up-right ax system.
hdx | the 1st matrix value, in .8 fixed point format. | |
vdx | the 2nd matrix value, in .8 fixed point format. | |
hdy | the 3th matrix value, in .8 fixed point format. | |
vdy | the 4th matrix value, in .8 fixed point format. |
AffineMatrix& DSOL::Sprites::AffineMatrix::setIdentityMatrix | ( | ) |
(re)sets the matrix to the identity matrix.
sets the matrix to the identity matrix, which means any sprite using it won't be rotated, scaled ect.
AffineMatrix& DSOL::Sprites::AffineMatrix::setIndex | ( | const uint | index | ) | [inline] |
sets the rotation index of the object.
index | the new index of the object. |
AffineMatrix& DSOL::Sprites::AffineMatrix::setMainEngine | ( | const bool | useMainOam = true |
) | [inline] |
sets the AffineMatrix's engine.
puts the sprite on the main or the sub engine.
useMainOam | true if the sprite should be on the main engine, false for the sub engine. default is true. |
virtual AffineMatrix& DSOL::Sprites::AffineMatrix::update | ( | ) | [inline, virtual] |
this will update the AffineMatrix object.
this will copy the data to oam so sprites can use it.
const int DSOL::Sprites::AffineMatrix::FIX_SCALE = (1<<8) [static] |
a constant for scaling the .8 fixed point values with division.
const int DSOL::Sprites::AffineMatrix::FIX_SHIFT = 8 [static] |
a constant for shifting the .8 fixed point values.
const int DSOL::Sprites::AffineMatrix::FIX_VALUE_1 = (1<<8) [static] |
a constant for the value 1 in .8 fixed point.
const uint DSOL::Sprites::AffineMatrix::NUMBER_OF_AFFINE_MATRIXES = 32 [static] |
a constant for the number of affine matrixes available per sprite engine