#include <ps2_ps2icon.hpp>
Public Types | |
typedef struct PS2Icon::Icon_Header_t | Icon_Header |
typedef struct PS2Icon::Vertex_Coord_t | Vertex_Coord |
typedef struct PS2Icon::Texture_Data_t | Texture_Data |
typedef struct PS2Icon::Animation_Header_t | Animation_Header |
typedef struct PS2Icon::Frame_Data_t | Frame_Data |
typedef struct PS2Icon::Frame_Key_t | Frame_Key |
Public Member Functions | |
PS2Icon () | |
Constructor. | |
PS2Icon (char const *fname) | |
Constructor. | |
~PS2Icon () | |
Destructor. | |
int | GetNVertices () const |
Get the number of vertices of the icon. | |
int | GetNShapes () const |
Get the number of shapes per vertex. | |
int | GetNFrames () const |
Get the number of frames in the animation. | |
int | GetFrameShape (int frame) const |
Get the number of the shape used in a specific frame. | |
int | GetNFrameKeys (int frame) const |
Get the number of keys used in a specific frame. | |
float | GetFrameKeyTime (int frame, int key) const |
Get the time key for a specific frame and key. | |
float | GetFrameKeyValue (int frame, int key) const |
Get the value key for a specific frame and key. | |
int | GetTextureType () const |
Get the texture type. | |
void | GetVertexData (float *data, int shape) const |
Get the vertex data used in a specific shape. | |
void | GetVertexColorData (unsigned int *data) const |
Get the per-vertex color data. | |
void | GetNormalData (float *data) const |
Get the per-vertex normal data. | |
void | GetVertexTextureData (float *data) const |
Get the per-vertex texture coordinates. | |
void | GetTextureData (unsigned int *data) const |
Get the complete texture data block. | |
void | GetTextureData (unsigned int *data, int pitch) const |
Copy the complete texture block to a pitched field. | |
unsigned int | GetTextureData (int x, int y) const |
Get the color value of a specific pixel in the texture. | |
void | WriteFile (char const *fname) const |
Save the current data to a new icon file. | |
void | SetGeometry (OBJ_Mesh const &mesh) |
Set the geometry data of the icon. | |
void | SetGeometry (OBJ_Mesh const &mesh, float scale_factor) |
Set the geometry data of the icon. | |
void | SetGeometry (float const *pverts, float const *pnormals, float const *ptexture, int n_vertices) |
Set the geometry data of the icon. | |
void | SetTextureData (unsigned int const *data) |
Set the texture data of the icon. | |
void | BuildMesh (OBJ_Mesh *mesh) |
Build a mesh from current data. | |
Classes | |
struct | Animation_Header_t |
Animation header. More... | |
struct | Frame_Data_t |
Per-frame animation data. More... | |
struct | Frame_Key_t |
Per-key animation data. More... | |
struct | Icon_Header_t |
File header. More... | |
struct | Texture_Data_t |
Set of texture coordinates. More... | |
struct | Vertex_Coord_t |
Set of vertex coordinates. More... |
This class can be used to read and write icon files.
This class keeps two representations of most of its data. Aside from the representation also used in the file, there is also a representation that fits the standards of modern graphic APIs for visualization.
ABBBBBGGGGGRRRRR
where the exact purpose of the alpha bit is yet to be discovered. If the texture_type value in the header has a value of 0x07 or higher the texture data is encoded with a simple RLE algorithm, which was documented in detail by Martin Akesson.
PS2Icon::PS2Icon | ( | ) |
Constructor.
PS2Icon::PS2Icon | ( | char const * | fname | ) |
Constructor.
[in] | fname | Complete path to a valid icon file |
Ghulbus::gbException | GB_FAILED indicates a file access error; | |
std::bad_alloc |
int PS2Icon::GetNVertices | ( | ) | const |
Get the number of vertices of the icon.
Ghulbus::gbException | GB_FAILED uint overflow; |
int PS2Icon::GetNShapes | ( | ) | const |
Get the number of shapes per vertex.
Ghulbus::gbException | GB_FAILED uint overflow; |
int PS2Icon::GetNFrames | ( | ) | const |
Get the number of frames in the animation.
Ghulbus::gbException | GB_FAILED uint overflow; |
int PS2Icon::GetFrameShape | ( | int | frame | ) | const |
Get the number of the shape used in a specific frame.
[in] | frame | Number of the frame [0..(n_frames-1)] |
Ghulbus::gbException | GB_FAILED uint overflow; GB_ILLEGALPARAMETER; |
int PS2Icon::GetNFrameKeys | ( | int | frame | ) | const |
Get the number of keys used in a specific frame.
[in] | frame | Number of the frame [0..(n_frames-1)] |
Ghulbus::gbException | GB_FAILED uint overflow; GB_ILLEGALPARAMETER; |
float PS2Icon::GetFrameKeyTime | ( | int | frame, | |
int | key | |||
) | const |
Get the time key for a specific frame and key.
[in] | frame | Number of the frame [0..(n_frames-1)] |
[in] | key | Number of the key [0..(animation[frame].n_keys-1)] |
Ghulbus::gbException | GB_ILLEGALPARAMETER; |
float PS2Icon::GetFrameKeyValue | ( | int | frame, | |
int | key | |||
) | const |
Get the value key for a specific frame and key.
[in] | frame | Number of the frame [0..(n_frames-1)] |
[in] | key | Number of the key [0..(animation[frame].n_keys-1)] |
Ghulbus::gbException | GB_ILLEGALPARAMETER; |
int PS2Icon::GetTextureType | ( | ) | const |
Get the texture type.
Ghulbus::gbException | GB_FAILED uint overflow; |
void PS2Icon::GetVertexData | ( | float * | data, | |
int | shape | |||
) | const |
Get the vertex data used in a specific shape.
[out] | data | A field of at least size (n_vertices * 3), resp. (n_vertices * n_shapes * 3) |
[in] | shape | A positive integer specifies the shape; A negative integer causes all shapes to be copied to data sequentially |
Ghulbus::gbException | GB_ILLEGALPARAMETER; |
void PS2Icon::GetVertexColorData | ( | unsigned int * | data | ) | const |
Get the per-vertex color data.
[out] | data | A field of at least size (n_vertices) |
void PS2Icon::GetNormalData | ( | float * | data | ) | const |
Get the per-vertex normal data.
[out] | data | A field of at least size (n_vertices * 3) |
void PS2Icon::GetVertexTextureData | ( | float * | data | ) | const |
Get the per-vertex texture coordinates.
[out] | data | A field of at least size (n_vertices * 2) |
void PS2Icon::GetTextureData | ( | unsigned int * | data | ) | const |
Get the complete texture data block.
[out] | data | A field of at least size 16384 |
void PS2Icon::GetTextureData | ( | unsigned int * | data, | |
int | pitch | |||
) | const |
Copy the complete texture block to a pitched field.
[out] | data | A field of at least size (16384 * sizeof(unsigned int)) |
[in] | pitch | The size of each row in data in bytes |
Ghulbus::gbException | GB_ILLEGALPARAMETER; |
unsigned int PS2Icon::GetTextureData | ( | int | x, | |
int | y | |||
) | const |
Get the color value of a specific pixel in the texture.
[in] | x | X-coordinate [0..127] |
[in] | y | Y-coordinate [0..127] |
Ghulbus::gbException | GB_ILLEGALPARAMETER; |
void PS2Icon::WriteFile | ( | char const * | fname | ) | const |
Save the current data to a new icon file.
[in] | fname | The full path of the destination file |
Ghulbus::gbException | GB_FAILED file access error; |
void PS2Icon::SetGeometry | ( | OBJ_Mesh const & | mesh | ) |
Set the geometry data of the icon.
[in] | mesh | A valid OBJ_Mesh object holding new geometry data |
std::bad_alloc |
void PS2Icon::SetGeometry | ( | OBJ_Mesh const & | mesh, | |
float | scale_factor | |||
) |
Set the geometry data of the icon.
[in] | mesh | A valid OBJ_Mesh object holding new geometry data |
[in] | scale_factor | A factor that is multiplied onto each vertex for scaling |
std::bad_alloc |
void PS2Icon::SetGeometry | ( | float const * | pverts, | |
float const * | pnormals, | |||
float const * | ptexture, | |||
int | n_vertices | |||
) |
Set the geometry data of the icon.
[in] | pverts | A field of at least size n_vertices*3 holding vertex data |
[in] | pnormals | A field of at least size n_vertices*3 holding normal data |
[in] | ptexture | A field of at least size n_vertices*2 holding 2D texture coordinate data |
[in] | n_vertices | Number of vertices |
void PS2Icon::SetTextureData | ( | unsigned int const * | data | ) |
Set the texture data of the icon.
[in] | data | A field of at least size 16384 containing 32 bit image data |
void PS2Icon::BuildMesh | ( | OBJ_Mesh * | mesh | ) |
Build a mesh from current data.
[in,out] | mesh | A mesh object that will be filled with the icon geometry |