- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# include/ps2_ps2icon.hpp

Go to the documentation of this file.

    00001
    00010 #ifndef __PS2_ICON_LOADER_HPP_INCLUDE_GUARD__
    00011 #define __PS2_ICON_LOADER_HPP_INCLUDE_GUARD__
    00012
    00013 #include <fstream>
    00014 #include "../gbLib/include/gbException.hpp"
    00015 #include "obj_loader.hpp"
    00016
    00021 class PS2Icon {
    00022 public:
    00025     typedef struct Icon_Header_t {
    00026         unsigned int file_id;
    00027         unsigned int animation_shapes;
    00028         unsigned int texture_type;
    00029         unsigned int reserved;
    00030         unsigned int n_vertices;
    00031     } Icon_Header;
    00035     typedef struct Vertex_Coord_t {
    00036         short f16_x;
    00037         short f16_y;
    00038         short f16_z;
    00039         short f16_unknown;
    00040     } Vertex_Coord;
    00044     typedef struct Texture_Data_t {
    00045         short        f16_u;
    00046         short        f16_v;
    00047         unsigned int color;
    00048     } Texture_Data;
    00051     typedef struct Animation_Header_t {
    00052         unsigned int id_tag;
    00053         unsigned int frame_length;
    00054         float        anim_speed;
    00055         unsigned int play_offset;
    00056         unsigned int n_frames;
    00057     } Animation_Header;
    00060     typedef struct Frame_Data_t {
    00061         unsigned int shape_id;
    00062         unsigned int n_keys;
    00063     } Frame_Data;
    00066     typedef struct Frame_Key_t {
    00067         float time;
    00068         float value;
    00069     } Frame_Key;
    00070 private:
    00071     Icon_Header header;
    00072     Vertex_Coord* vertices;
    00073     Vertex_Coord* normals;
    00074     Texture_Data* vert_texture;
    00075     float* fvertices;
    00076     float* fnormals;
    00077     Animation_Header anim_header;
    00078     Frame_Data* animation;
    00079     Frame_Key** anim_keys;
    00080     unsigned int texture[16384];
    00081 public:
    00086     PS2Icon();
    00092     PS2Icon(char const * fname);
    00095     ~PS2Icon();
    00100     int GetNVertices() const;
    00105     int GetNShapes() const;
    00110     int GetNFrames() const;
    00117     int GetFrameShape(int frame) const;
    00124     int GetNFrameKeys(int frame) const;
    00131     float GetFrameKeyTime(int frame, int key) const;
    00138     float GetFrameKeyValue(int frame, int key) const;
    00143     int GetTextureType() const;
    00149     void GetVertexData(float* data, int shape) const;
    00153     void GetVertexColorData(unsigned int* data) const;
    00157     void GetNormalData(float* data) const;
    00161     void GetVertexTextureData(float* data) const;
    00165     void GetTextureData(unsigned int* data) const;
    00171     void GetTextureData(unsigned int* data, int pitch) const;
    00178     unsigned int GetTextureData(int x, int y) const;
    00183     void WriteFile(char const * fname) const;
    00188     void SetGeometry(OBJ_Mesh const& mesh);
    00194     void SetGeometry(OBJ_Mesh const& mesh, float scale_factor);
    00201     void SetGeometry(float const* pverts, float const* pnormals, float const* ptexture, int n_vertices);
    00205     void SetTextureData(unsigned int const* data);
    00209     void BuildMesh(OBJ_Mesh* mesh);
    00210 private:
    00214     void AllocateVertexMemory();
    00219     void ReadFile(std::ifstream & fin);
    00222     static bool CheckValidity(Icon_Header const&);
    00223 };
    00224 typedef PS2Icon *LPPS2ICON;
    00225
    00226 //EXTENSIVE DOCUMENTATION:
    00294 #endif