ms3dmodel.h

00001  /*
00002 * "PS2" Application Framework
00003 *
00004 * University of Abertay Dundee
00005 * May be used for educational purposed only
00006 *
00007 * Author - Dr Henry S Fortuna
00008 *
00009 * $Revision: 1.2 $
00010 * $Date: 2007/08/19 12:45:10 $
00011 *
00012 */
00013 
00014 #ifndef __MS3DMODEL_H__
00015 #define __MS3DMODEL_H__
00016 
00017 #include <stdio.h>
00018 #include "pipeline.h"
00019 #include "ps2matrix4x4.h"
00020 
00021 // Internal structure used by the Loading code
00022 struct MSVertex
00023 {
00024         // flags, x, y, z, u, v, bone index
00025         int flags;
00026         float x, y, z, u, v;
00027         int bone;
00028         int _pad; // 16 byte align
00029 };
00030 
00031 // Internal structure used by the Loading code
00032 struct MSTriangle
00033 {
00034         // triangle: flags, vertex index1, vertex index2, vertex index3, 
00035         // normal index1, normal index 2, normal index 3, smoothing group
00036         int flags, vert1, vert2, vert3,
00037                            norm1, norm2, norm3, smoothinggroup;
00038 };
00039 
00040 // Internal structure used by the Loading code
00041 struct Vector3
00042 {
00043         float x, y, z;
00044 };
00045 
00046 // Internal structure used by the Loading code
00047 struct MSMesh
00048 {
00049         // mesh: name, flags, material index
00050         char strName[256];
00051         int flags, matindex;
00052 
00053         int nTriangles,
00054                 nNormals,
00055                 nVerts;
00056 
00057         MSVertex   * pVertices;
00058         Vector3    * pNormals;
00059         MSTriangle * pTriangles;
00060 };
00061 
00062 class CMs3dModel
00063 {
00064 public:
00065         CMs3dModel(void);
00066         ~CMs3dModel(void);
00067         
00068         void SetWorldMatrix(const Matrix4x4 & matWorld);
00069         
00070         void SetWVPMatrix(const Matrix4x4 & matWVP);
00071 
00072         bool LoadModelData(const char * strFilename, bool bTransparent = false);
00073         
00074         void Render(void);
00075 
00076         char * GetTextureName( )
00077         { return m_strTexname; }
00078 
00079 protected:
00080         void GetNextLOC(char *pStr1024);
00081         void InitialiseDMA(bool bTransparent);
00082 
00083         MSMesh * m_pMeshes;
00084 
00085         char m_strTexname[256];
00086 
00087         int m_iStaticAddr;
00088         int m_nFrames, m_nCurrentFrame, m_nMeshes;
00089         FILE * m_fp;
00090         
00091         // The world and WorldViewProjection Matrices
00092         Matrix4x4 m_World, m_WVP;
00093         
00094         bool m_bWorldLoaded;
00095 };
00096 
00097 #endif

Generated on Sun May 18 21:45:08 2008 for PS2X by  doxygen 1.5.4