Public Member Functions | |
Graphical objects assignation to the 2d entity | |
| void | SetSurface (IND_Surface *pNewSurface) |
| void | SetAnimation (IND_Animation *pNewAnimation) |
| void | SetPrimitive2d (IND_Primitive2d pPri2d) |
| void | SetFont (IND_Font *pFont) |
Animations | |
| void | SetSequence (int pSequence) |
| void | SetNumReplays (int pNumReplays) |
Primitives | |
| void | SetLine (int pX1, int pY1, int pX2, int pY2) |
| void | SetRectangle (int pX1, int pY1, int pX2, int pY2) |
| void | SetRadius (int pRadius) |
| void | SetNumSides (int pNumSides) |
| void | SetPolyAngle (float pPolyAngle) |
| void | SetPolyPoints (IND_Point *pPolyPoints) |
| void | SetNumLines (int pNumLines) |
Fonts | |
| void | SetAlign (IND_Align pAlign) |
| void | SetCharSpacing (int pCharSpacing) |
| void | SetLineSpacing (int pLineSpacing) |
| void | SetText (char *pText) |
Space transformations (Some of these methods doesn't affect the fonts or the primitives) | |
| void | SetPosition (float pX, float pY, int pZ) |
| void | SetAngleXYZ (float pAnX, float pAnY, float pAnZ) |
| void | SetScale (float pSx, float pSy) |
| void | SetMirrorX (bool pMx) |
| void | SetMirrorY (bool pMy) |
| void | SetFilter (IND_Filter pF) |
| bool | SetHotSpot (float pX, float pY) |
| bool | SetRegion (int pOffX, int pOffY, int pRegionWidth, int pRegionHeight) |
| bool | ToggleWrap (bool pWrap) |
| void | SetWrapDisplacement (float pUDisplace, float pVDisplace) |
Color transformations, blending and back face culling (Some of these methods doesn't affect the fonts or the primitives) | |
| void | SetBackCull (bool pCull) |
| void | SetTint (byte pR, byte pG, byte pB) |
| void | SetTransparency (byte pA) |
| void | SetFade (byte pR, byte pG, byte pB, byte pA) |
| void | SetBlendSource (IND_BlendingType pSo) |
| void | SetBlendDest (IND_BlendingType pDs) |
Collisions | |
| bool | SetBoundingAreas (char *pFile) |
| bool | SetBoundingTriangle (char *pId, int pAx, int pAy, int pBx, int pBy, int pCx, int pCy) |
| bool | SetBoundingCircle (char *pId, int pOffsetX, int pOffsetY, int pRadius) |
| bool | SetBoundingRectangle (char *pId, int pOffsetX, int pOffsetY, int pWidth, int pHeight) |
| bool | DeleteBoundingAreas (char *pId) |
| void | ShowCollisionAreas (bool pShowCollisionAreas) |
| void | ShowGridAreas (bool pShowGridAreas) |
Gets | |
| IND_Surface * | GetSurface () |
| If the entity has a surface assigned, it returns a pointer to this surface. | |
| IND_Animation * | GetAnimation () |
| If the entity has a animation assigned, it returns a pointer to this animation. | |
| int | GetSequence () |
| Returns the sequence number that has been assigned to the animation. | |
| int | GetNumReplays () |
| Returns the number of repetitions the animation has to do. If this value is equal or less than zero, it indicates that the amination is looping. | |
| float | GetPosX () |
| Returns X position of the entity. | |
| float | GetPosY () |
| Returns Y position of the entity. | |
| int | GetPozZ () |
| Returns Z position of the entity. | |
| float | GetAngleX () |
| Returns the angle in the X axis of the entity. | |
| float | GetAngleY () |
| Returns the angle in the Y axis of the entity. | |
| float | GetAngleZ () |
| Returns the angle in the Z axis of the entity. | |
| float | GetScaleX () |
| Returns the X scale of the entity. | |
| float | GetScaleY () |
| Returns the Y scale of the entity. | |
| bool | GetBackCull () |
| Indicate if the entity is making backface culling 0 = No, 1 = Yes. | |
| bool | GetMirrorX () |
| Indicate if the entity makes horizontal mirror. 0 = No, 1 = Yes. | |
| bool | GetMirrorY () |
| Indicate if the entity makes vertical mirror. 0 = No, 1 = Yes. | |
| IND_Filter | GetFilter () |
| Returns the type of filter IND_Filter which uses the graphical object assignated to the entity. | |
| IND_Type | GetType () |
| Returns the type IND_Type which uses the graphical object assignated to the entity. | |
| byte | GetTintR () |
| Returns the tinted level in the R (red) channel of the entity. | |
| byte | GetTintG () |
| Returns the tTinted level in the G (green) channel of the entity. | |
| byte | GetTintB () |
| Returns the tinted level in the B (blue) channel of the entity. | |
| byte | GetTransparency () |
| Returns the transparency level of the entity. | |
| byte | GetFadeR () |
| Returns the fade level in R (red) channel of the entity. | |
| byte | GetFadeG () |
| Returns the fade level in G (green) channel of the entity. | |
| byte | GetFadeB () |
| Returns the fade level in B (blue) channel of the entity. | |
| byte | GetFadeA () |
| Returns the fade level of the entity. | |
| IND_BlendingType | GetBlendSource () |
| Returns the blending type IND_BlendingType for the source. | |
| IND_BlendingType | GetDestSource () |
| Returns the blending type IND_BlendingType for the destination. | |
| float | GetHotSpotX () |
| Returns the X HotSpot of the entity. | |
| float | GetHotSpotY () |
| Returns the Y HotSpot of the entity. | |
| int | GetRegionX () |
| Returns the X position of the upper left corner of the region assignated to the entity by IND_Entity2d::SetRegion(). | |
| int | GetRegionY () |
| Returns the Y position of the upper left corner of the region assignated to the entity by IND_Entity2d::SetRegion(). | |
| int | GetRegionWidth () |
| Returns the width of the region assignated to the entity by IND_Entity2d::SetRegion(). | |
| int | GetRegionHeight () |
| Returns the height of the region assignated to the entity by IND_Entity2d::SetRegion(). | |
| bool | IfWrap () |
| Returns the position 1 (true) if the image is being repeated in the X,Y axis. | |
| int | GetLineX1 () |
| Returns the position in x from the first point of a primitive line. | |
| int | GetLineY1 () |
| Returns the position in y from the first point of a primitive line. | |
| int | GetLineX2 () |
| Returns the position in x from the second point of a primitive line. | |
| int | GetLineY2 () |
| Returns the position in y from the second point of a primitive line. | |
| int | GetRadius () |
| Returns the radius of the primitives IND_REGULAR_POLY. | |
| int | GetNumSides () |
| Returns the numbers of sides of the primitive IND_REGULAR_POLY. | |
| float | GetPolyAngle () |
| Returns the primitive angle IND_REGULAR_POLY. | |
| IND_Point * | GetPolyPoints () |
| Returns the points array which draw the primitive IND_POLY2D. | |
| int | GetNumLines () |
| Returns the number of lines which draw the primitive IND_POLY2D. | |
| IND_Align | GetAlign () |
| Returns the align IND_Align of the text. | |
| int | GetCharSpacing () |
| Returns the additional space between characters when using IND_Font. | |
| int | GetLineSpacing () |
| Returns the line spacing between lines when using IND_Font. | |
| char * | GetText () |
| Returns the text string of the entity. | |
| bool | IsShowCollisionAreas () |
| Returs true if the collision areas are being shown. | |
| bool | IsShowGridAreas () |
| Returs true if the grid areas are being shown. | |
Friends | |
| class | IND_Entity2dManager |
An entity is an object that can have a graphical object associated to it. Using the methods of this class you will be able to change the attributes of the graphical object that it contains.
For example, in a game, a bullet can be a IND_Entity2d that has a IND_Surface associated to it. You can have as many bullets (IND_Entity2d objects) in the screen as you want, all of them sharing the same IND_Surface (the sprite). In system memory you will have only one 3d mesh loaded, the rest will be instances. The cool thing is that you can change the attributes of each of these different IND_Entity2d objects. For example, you can change the size, rotation, color or transparency of the bullets. So, having only one sprite, you can have lot of different bullets in the screen, with different sizes, colors, positions, etc.
IND_Entity2d can have so many different graphical objects associated to it:
| void IND_Entity2d::SetSurface | ( | IND_Surface * | pNewSurface | ) |
Parameters:
This function inserts a surface in the entity. If that entity has another graphical object allocated it will be replaced (but not freed) by de present surface. In the next call to IND_Entity2dManager::RenderEntities2d() the surface will be drawn.
In addition, all the attributes of the entity will be restarted.
| void IND_Entity2d::SetAnimation | ( | IND_Animation * | pNewAnimation | ) |
Parameters:
This function inserts an animation in the entity. If that entity has another graphical object allocated it will be replaced (but not freed) by de present animation. In the next call to IND_Entity2dManager::RenderEntities2d() this animation will be drawn.
In addition, all the attributes of the entity will be restarted.
| void IND_Entity2d::SetPrimitive2d | ( | IND_Primitive2d | pPri2d | ) |
Parameters:
This function inserts a primitive in the entity. If that entity has another graphical object allocated, it will be replaced (but not freeed) by de present primitive. In the next call to IND_Entity2dManager::RenderEntities2d() this primitive will be drawn.
In addition, all the parameters of the entity will be restarted.
| void IND_Entity2d::SetFont | ( | IND_Font * | pFont | ) |
Parameters:
This function inserts a font into the entity. If that entity has another graphical object allocated, it will be replaced (but not freed) by de present font. In the next call to IND_Entity2dManager::RenderEntities2d() the font will be drawn.
In addition, all the parameters of the entity will be restarted.
Important: Fonts can't be sized and can't be rotated.
| void IND_Entity2d::SetSequence | ( | int | pSequence | ) |
Parameters:
This function sets the number of sequence that will be drawn.
Default: 0.
| void IND_Entity2d::SetNumReplays | ( | int | pNumReplays | ) |
Parameters:
This function sets the number of times that the animation will be drawn on the screen.
When the parameter takes values less or equals 0 the animation repeats forever. When the parameter takes values bigger or equals 1, this number shows the number of times that the animation will be repeated.
Default: -1 (repeat forever),
| void IND_Entity2d::SetLine | ( | int | pX1, | |
| int | pY1, | |||
| int | pX2, | |||
| int | pY2 | |||
| ) |
Parameters:
This function sets the coordinates of the IND_LINE primitive that will be drawn on screen.
Default: (0, 0, 0, 0).
| void IND_Entity2d::SetRectangle | ( | int | pX1, | |
| int | pY1, | |||
| int | pX2, | |||
| int | pY2 | |||
| ) |
Parameters:
This function sets the coordinates of the IND_RECTANGLE primitive that will be drawn on screen.
Default: (0, 0, 0, 0).
| void IND_Entity2d::SetRadius | ( | int | pRadius | ) |
Parameters:
This function sets the length of the radius of the primitive IND_REGULAR_POLY that will be drawn on screen.
Default: 0.
| void IND_Entity2d::SetNumSides | ( | int | pNumSides | ) |
Parameters:
This function sets the number of sides of the regular polygon IND_REGULAR_POLY.
Default: 0.
| void IND_Entity2d::SetPolyAngle | ( | float | pPolyAngle | ) |
Parameters:
This function sets the angle of the regular polygon IND_REGULAR_POLY. With incremental values it is possible to rotate the polygon.
Default: 0.
| void IND_Entity2d::SetPolyPoints | ( | IND_Point * | pPolyPoints | ) |
Parameters:
This function sets the array of points that will be used to draw the primitive IND_POLY2D. Every point consists of two coordinates (x, y). This function must be used together with SetNumLines() that is used to indicate the number of edges to draw between the specified points.
Default: 0.
| void IND_Entity2d::SetNumLines | ( | int | pNumLines | ) |
Parameters:
This function sets the number of edges to draw by the primitive IND_POLY2D. This function must used together with SetPolyPoints() that is used to indicate the array of points.
Default: 0.
| void IND_Entity2d::SetAlign | ( | IND_Align | pAlign | ) |
| void IND_Entity2d::SetCharSpacing | ( | int | pCharSpacing | ) |
Parameters:
This function sets an additional space between characters when using a IND_Font in the 2d entity.
Debault: 0.
| void IND_Entity2d::SetLineSpacing | ( | int | pLineSpacing | ) |
Parameters:
This function sets the line spacing between lines when using a IND_Font in the 2d entity.
Debault: 0.
| void IND_Entity2d::SetText | ( | char * | pText | ) |
Parameters:
This function sets the text that is going to be shown on screen.
Default: "" (Without text).
| void IND_Entity2d::SetPosition | ( | float | pX, | |
| float | pY, | |||
| int | pZ | |||
| ) |
Parameters:
This function sets the position where the entity will be drawn. The parameter Z controls the depth. This way it is possible to choose that certain entities are drawn over others. An entity with Z = 1 will be drawn over other one with Z = 0.
Default: (0, 0, 0).
| void IND_Entity2d::SetAngleXYZ | ( | float | pAnX, | |
| float | pAnY, | |||
| float | pAnZ | |||
| ) |
Parameters:
This function sets the rotation of the entity in each of the axis.
Default: (0, 0, 0).
| void IND_Entity2d::SetScale | ( | float | pSx, | |
| float | pSy | |||
| ) |
Parameters:
This function sets the scaling of the entity in the x and y axis. With this method it is possible to get bigger or smaller entities.
Default: (1.0f, 1.0f).
| void IND_Entity2d::SetMirrorX | ( | bool | pMx | ) |
Parameters:
This function activates or deactivates the horizontal flip.
Deactivated by default (0).
| void IND_Entity2d::SetMirrorY | ( | bool | pMy | ) |
Parameters:
This function activates or deactivates the vertical flip.
Deactivated by default (0).
| void IND_Entity2d::SetFilter | ( | IND_Filter | pF | ) |
Parameters:
This function sets the filter that will affect the graphical object when drawing.
Default: IND_FILTER_LINEAR
| bool IND_Entity2d::SetHotSpot | ( | float | pX, | |
| float | pY | |||
| ) |
Parameters:
This function sets the hotspot of the graphical object (only works if the entity has an IND_Surface or IND_Animation assigned). When we talk about hotspot we are refering to an imaginary point from which the transformations are applied (trasnlation, rotation and scaling). So, we can choose that certain surface rotates on his center, on one of his vertex, or on any another intermediate position.
To establish the hotspot we use pX and pY in a range from 0 to 1 (a point inside the surface area) or higher (a point outside the surface area). Refering respectively to the horizontal and vertical position of the surface. Thus (0.5f, 0.5f) would be the center of the image, (1.0f, 0.0f) would be the top right corner, etc.
You can also set a hotspot out of the image, for example using (2.0f, 4.0f) values. This way you can make the entity rotate around a point.
Default value (0, 0) = Upper left corner.
| bool IND_Entity2d::SetRegion | ( | int | pOffX, | |
| int | pOffY, | |||
| int | pRegionWidth, | |||
| int | pRegionHeight | |||
| ) |
Parameters:
This function has two use uses:
1) First, it can be used to indicate the rectangular region which is going to be drawn from the surface or animation assigned to the entity. So, instead of drawing all the surface, it can be chosen which rectangular area is going to be rendered in the screen. This method doesn't affect primitives or fonts. If the requested region stays partly or totally out of the surface, the region will not be applied.
2) Second, if IND_Entity2d::ToggleWrap() has been used on the entity, the image will be repeated (tiling) in the region specified.
The 1st method is useful for example to draw the classic loading bar, which is showing itself from left side to right progressively changing the width of the region.
The 2nd method is useful for multiple things. For example a background made by repeating a tile.
Special remark: this function only works with IND_Surface objects that only have ONE texture assigned (you can check this using::IND_Surface::GetNumTextures() method). So, it will work only with images that are power of two and lower than the maximum texture size allowed by your card (you can check this parameter using IND_Render::GetMaxTextureSize()). The method will return 0 otherwise.
Default: (0, 0, 0, 0) (Indicates that there is no region, the whole surface will be drawn)
| bool IND_Entity2d::ToggleWrap | ( | bool | pWrap | ) |
Parameters:
This function causes the repetition of the image in the x and y axis in the specified region by IND_Entity2d::SetRegion().
| void IND_Entity2d::SetWrapDisplacement | ( | float | pUDisplace, | |
| float | pVDisplace | |||
| ) |
Parameters:
This function sets the horizontal and vertical displacement of the an image that is being tiled to the screen using the IND_Entity2d::SetRegion() and IND_Entity2d::ToggleWrap() methods.
Using this method you can, for example, create and effect of an animated tiled background.
| void IND_Entity2d::SetBackCull | ( | bool | pCull | ) |
Parameters:
This function activates or deactivates the backface culling. (true / false) = (activated / deactivated).
This feature can be deactivated when we are going to rotate the graphical object in the x or y coordinates. This way it is possible to draw for example the leaf of a tree that falls down rotating and showing both faces. In any other case this parameter must be activated for faster rendering times preventing the hardware from drawing the back faces of the polygons zones.
Activated by default (true).
| void IND_Entity2d::SetTint | ( | byte | pR, | |
| byte | pG, | |||
| byte | pB | |||
| ) |
Parameters:
This function sets the bytes pR, pG, pB for "tinting" the image to a certain color. For example, if we use RGB = (255, 0, 0), the image will be tinted of red color. Note: It is not the same the fade that the tint. The tint produces an effect like seeing through a cellophane, whereas the fade changes the image to the color selected completely.
It is not possible to use IND_Entity2d::SetTint() and IND_Entity2d::SetFade() at the same time, the fade will prevail upon the tinting.
Default RGBA = (0, 0, 0) (Without tint)
| void IND_Entity2d::SetTransparency | ( | byte | pA | ) |
Parameters:
This function sets the level of transparency of the entity.
The A byte indicates the level of transparency. If a value 0 is used, the following graphical object will be completely transparent, opposite to the value 255 that will be drawn completely opaque. It is possible to use all the intermediate values for different levels of transparency.
Default A = (255) (Without transparency)
| void IND_Entity2d::SetFade | ( | byte | pR, | |
| byte | pG, | |||
| byte | pB, | |||
| byte | pA | |||
| ) |
Parameters:
This function sets the bytes FadeR, FadeG, FadeB for making a fade of the image to a certain color. When we speak of fade we refer to the progressive change of an image to certain color. For example, if we use RGB = (255, 0, 0), the image will be faded to red color. Note: It is not the same the fade that the tint. The tint produces an effect like seeing trough a cellophane, whereas the fade changes the image to the color selected completely.
The byte A indicates the level of fade. If a value 0 is used, the following graphical object will show itself completely of the color chosen like fade, opposite to the value 255 that it would draw completely normally. It is possible to use all the intermediate values for different levels of fade.
It is not possible to use IND_Entity2d::SetTint() and IND_Entity2d::SetFade() at the same time, the fade will prevail upon the tinting.
Default RGBA = (0, 0, 0, 255) (Without fade)
| void IND_Entity2d::SetBlendSource | ( | IND_BlendingType | pSo | ) |
Parameters:
This function sets the blending source.
Default: 0. (Blending source is not in use).
| void IND_Entity2d::SetBlendDest | ( | IND_BlendingType | pDs | ) |
Parameters:
This function sets the blending destiny.
Default 0. (Blending destiny is not in use).
| bool IND_Entity2d::SetBoundingAreas | ( | char * | pFile | ) |
Parameters:
This function return 1 (true) if an xml file that has the definitions of several bounding areas for checking collisions is parsed correctly. This method will return 0 (false) if the entity dosen't have a surface assigned (check SetSurface(). For animations in which you want that each frame has different collision areas don't use this method, define the .xml script directly in the </frame> section.
You can define in the xml file all the triangular, rectangular and circular areas that you want. It is possible to "group" the bounding areas of the 2d entity using the "id" parameter. For example you can add 3 triangles and 2 circles using the same id="head". An having at the same time 4 rectangles with the id="foot". Later, you can use this id parameter in the IND_Entity2dManager::IsCollision() method for checking collision only in that areas.
Use ShowCollisionAreas() method in order to show or hide the collision areas of this entity. In order to render all the collision areas you should use the IND_Entity2dManager::RenderCollisionAreas() method.
Default: no bounding areas assigned.
| bool IND_Entity2d::SetBoundingTriangle | ( | char * | pId, | |
| int | pAx, | |||
| int | pAy, | |||
| int | pBx, | |||
| int | pBy, | |||
| int | pCx, | |||
| int | pCy | |||
| ) |
Parameters:
This function return 1 (true) if a bounding triangle for checking collisions is defined. This method will return 0 (false) if the entity dosen't have a surface assigned (check SetSurface().
You can assign all the triangle areas (and also circular and rectangular areas, using SetBoundingCircle() and SetBoundingRectangle()) that you want. It is possible to "group" the bounding areas of the 2d entity using the "id" parameter. For example you can add 3 triangles and 2 circles using the same id="head". An having at the same time 4 rectangles with the id="foot". Later, you can use this id parameter in the IND_Entity2dManager::IsCollision() method for checking collision only in that areas.
You can also use the SetBoundingAreas() method in order to load all the bounding areas directly from an xml file.
Use ShowCollisionAreas() method in order to show or hide the collision areas of this entity. In order to render all the collision areas you should use the IND_Entity2dManager::RenderCollisionAreas() method.
Default: no bounding triangle assigned.
| bool IND_Entity2d::SetBoundingCircle | ( | char * | pId, | |
| int | pOffsetX, | |||
| int | pOffsetY, | |||
| int | pRadius | |||
| ) |
Parameters:
This function return 1 (true) if a bounding circle for checking collisions is defined. This method will return 0 (false) if the entity dosen't have a surface assigned (check SetSurface().
You can assign all the circular areas (and also triangle and rectangular areas, using SetBoundingTriangle() and SetBoundingRectangle()) that you want. It is possible to "group" the bounding areas of the 2d entity using the "id" parameter. For example you can add 3 triangles and 2 circles using the same id="head". An having at the same time 4 rectangles with the id="foot". Later, you can use this id parameter in the IND_Entity2dManager::IsCollision() method for checking collision only in that areas.
You can also use the SetBoundingAreas() method in order to load all the bounding areas directly from an xml file.
Use ShowCollisionAreas() method in order to show or hide the collision areas of this entity. In order to render all the collision areas you should use the IND_Entity2dManager::RenderCollisionAreas() method.
Default: no bounding circle assigned.
| bool IND_Entity2d::SetBoundingRectangle | ( | char * | pId, | |
| int | pOffsetX, | |||
| int | pOffsetY, | |||
| int | pWidth, | |||
| int | pHeight | |||
| ) |
Parameters:
This function return 1 (true) if a bounding rectangle for checking collisions is defined. This method will return 0 (false) if the entity dosen't have a surface assigned (check SetSurface().
You can assign all the rectangular areas (and also triangle and circular areas, using SetBoundingTriangle() and SetBoundingCircle()) that you want. It is possible to "group" the bounding areas of the 2d entity using the "id" parameter. For example you can add 3 triangles and 2 circles using the same id="head". An having at the same time 4 rectangles with the id="foot". Later, you can use this id parameter in the IND_Entity2dManager::IsCollision() method for checking collision only in that areas.
You can also use the SetBoundingAreas() method in order to load all the bounding areas directly from an xml file.
Use ShowCollisionAreas() method in order to show or hide the collision areas of this entity. In order to render all the collision areas you should use the IND_Entity2dManager::RenderCollisionAreas() method.
Default: no bounding rectangle assigned.
| bool IND_Entity2d::DeleteBoundingAreas | ( | char * | pId | ) |
Parameters:
This function return 1 (true) if a bounding rectangle for checking collisions is deleted. This method will return 0 (false) if the entity dosen't have a surface assigned (check SetSurface().
Use the pId parameter in order to define the group you want to delete. User "*" for delete all the groups.
Default: no bounding rectangle assigned.
| void IND_Entity2d::ShowCollisionAreas | ( | bool | pShowCollisionAreas | ) |
Parameters:
This function turn on / off the visualization of collision areas. This can be useful for checking that your collisions are accuarte.
In order to render all the collision areas you should use the Entity2dManager::RenderCollisionAreas() method.
Default: true.
| void IND_Entity2d::ShowGridAreas | ( | bool | pShowGridAreas | ) |
Parameters:
This function turn on / off the visualization of grid areas.
In order to render all the collision areas you should use the Entity2dManager::RenderGridAreas() method.
Default: true.
1.5.4