DSOL::Sprites::AffineMatrix Class Reference

a class that holds data about rotating and scaling a sprite. More...

#include <AffineMatrix.hpp>

Inherits DSOL::IUpdate.

List of all members.

Public Member Functions

 AffineMatrix (const uint index, const bool useMainOam=true)
 the constructor that creates an AffineMatrix object.
AffineMatrixflipHorizontal ()
 flips the matrix horizontally.
AffineMatrixflipVertical ()
 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 AffineMatrixoperator= (const AffineMatrix &source)
 the asignment operator, will copy everything exept the index.
AffineMatrixsetAffineTransformation (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.
AffineMatrixsetAngleScale (const int angle=0, const int scaleX=FIX_VALUE_1, const int scaleY=FIX_VALUE_1)
 sets the angle and scale of the object.
AffineMatrixsetConvertAffineTransformation (const int hdx, const int vdx, const int hdy, const int vdy)
 Allows you to set a normal affine transformation matrix.
AffineMatrixsetIdentityMatrix ()
 (re)sets the matrix to the identity matrix.
AffineMatrixsetIndex (const uint index)
 sets the rotation index of the object.
AffineMatrixsetMainEngine (const bool useMainOam=true)
 sets the AffineMatrix's engine.
virtual AffineMatrixupdate ()
 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


Detailed Description

a class that holds data about rotating and scaling a sprite.

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.


Constructor & Destructor Documentation

DSOL::Sprites::AffineMatrix::AffineMatrix ( const uint  index,
const bool  useMainOam = true 
) [inline]

the constructor that creates an AffineMatrix object.

Parameters:
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.


Member Function Documentation

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.

Returns:
a reference to the object, so you can chain multiple commands.

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.

Returns:
a reference to the object, so you can chain multiple commands.

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.

Parameters:
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.

See also:
setConvertAffineTransformation()
Returns:
the 1st value of the affine matrix, in .8 fixed point format.

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).

See also:
setConvertAffineTransformation()
Returns:
the 3th value of the affine matrix, in .8 fixed point format.

const int DSOL::Sprites::AffineMatrix::getConvertedScaleX (  )  const

returns the x scale.

Returns:
the x scale of the object, in .8 fixed point format.

const int DSOL::Sprites::AffineMatrix::getConvertedScaleY (  )  const

returns the y scale.

Returns:
the y scale of the object, in .8 fixed point format.

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).

See also:
setConvertAffineTransformation()
Returns:
the 2nd value of the affine matrix, in .8 fixed point format.

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.

See also:
setConvertAffineTransformation()
Returns:
the 4th value of the affine matrix, in .8 fixed point format.

const int DSOL::Sprites::AffineMatrix::getHdx (  )  const [inline]

returns the 1st value of the affine matrix.

Returns:
the 1st value of the affine matrix, in .8 fixed point format.

const int DSOL::Sprites::AffineMatrix::getHdy (  )  const [inline]

returns the 3th value of the affine matrix.

Returns:
the 3th value of the affine matrix, in .8 fixed point format.

const uint DSOL::Sprites::AffineMatrix::getIndex (  )  const [inline]

returns the rotation index of the object.

Returns:
the rotation index.

bool DSOL::Sprites::AffineMatrix::getMainEngine (  )  const [inline]

returns if the sprite uses the main oam or not.

Returns:
true if it uses the main oam, false otherwise.

const int DSOL::Sprites::AffineMatrix::getScaleX (  )  const [inline]

returns the x scale.

Returns:
the x scale of the object, in .8 fixed point format.

const int DSOL::Sprites::AffineMatrix::getScaleY (  )  const [inline]

returns the y scale.

Returns:
the y scale of the object, in .8 fixed point format.

const int DSOL::Sprites::AffineMatrix::getVdx (  )  const [inline]

returns the 2nd value of the affine matrix.

Returns:
the 2nd value of the affine matrix, in .8 fixed point format.

const int DSOL::Sprites::AffineMatrix::getVdy (  )  const [inline]

returns the 4th value of the affine matrix.

Returns:
the 4th value of the affine matrix, in .8 fixed point format.

const AffineMatrix& DSOL::Sprites::AffineMatrix::operator= ( const AffineMatrix source  ) 

the asignment operator, will copy everything exept the index.

Parameters:
source the affine matrix to copy from.
Returns:
a reference to the object, so you can chain multiple commands.

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.

Parameters:
mainOAM true if the Affine Matrix is for the main oam, false otherwise
Returns:
the index of an unreserved AffineMatrix index (which has been reserved for you) or NUMBER_OF_AFFINE_MATRIXES if there are no AffineMatrix indexes left (will display an error in debug mode)

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.

Parameters:
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.
Returns:
a reference to the object, so you can chain multiple commands.

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.

Parameters:
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.
Returns:
a reference to the object, so you can chain multiple commands.

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.

Parameters:
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.
Note:
the convertion method doesn't really invert the matrix, but use an other method to get the right hardware values.
Returns:
a reference to the object, so you can chain multiple commands.

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.

Returns:
a reference to the object, so you can chain multiple commands.

AffineMatrix& DSOL::Sprites::AffineMatrix::setIndex ( const uint  index  )  [inline]

sets the rotation index of the object.

Parameters:
index the new index of the object.
Returns:
a reference to the object, so you can chain multiple commands.

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.

Parameters:
useMainOam true if the sprite should be on the main engine, false for the sub engine. default is true.
Returns:
a reference to the object, so you can chain multiple commands.

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.

Returns:
a reference to the object, so you can chain multiple commands.


Member Data Documentation

const int DSOL::Sprites::AffineMatrix::FIX_SCALE = (1<<8) [static]

a constant for scaling the .8 fixed point values with division.

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.

a constant for the number of affine matrixes available per sprite engine


The documentation for this class was generated from the following file:

Generated on Thu Sep 10 19:09:47 2009 for DSOL by  doxygen 1.5.8