ROOT logo
// $Id: MD2Object.h 2088 2008-11-23 20:26:46Z matevz $

// Copyright (C) 1999-2008, Matevz Tadel. All rights reserved.
// This file is part of GLED, released under GNU General Public License version 2.
// For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/.

#ifndef Geom1_MD2Object_H
#define Geom1_MD2Object_H

#include <Glasses/ZNode.h>
#include <Stones/ZColor.h>

class MD2Object : public ZNode
{
  MAC_RNR_FRIENDS(MD2Object);

public:
  struct MD2Header
  {
    int iMagic;
    int iVersion;
    int iSkinWidth;
    int iSkinHeight;
    int iFrameSize;
    int iNumSkins;
    int iNumVertices;
    int iNumTexCoords;
    int iNumTriangles;
    int iNumGlCommands;
    int iNumFrames;
    int iOffsetSkins;
    int iOffsetTexCoords;
    int iOffsetTriangles;
    int iOffsetFrames;
    int iOffsetGlCommands;
    int iOffsetEnd;
  };

  struct MD2Triangle
  {
    short iVertexIndex[3];
    short iTextureIndex[3];
  };

  struct MD2Vertex
  {
    unsigned char abVertex[3];
    unsigned char abLightNormalIndex;
  };

  struct MD2TextureCoord
  {
    short sU,sV;
  };

  struct MD2CommandVertex
  {
    float fU;
    float fV;
    int iVertexIndex;
  };

  struct MD2Frame
  {
    float afScale[3];
    float afTranslate[3];
    char  acName[16];
    MD2Vertex akVertices[1];
  };

  struct Vector3 {
    float x,y,z;
  };

private:
  void _init();
  void _clear_data();

protected:
  TString	mFile;		// X{GS}   7 Filor()
  Float_t       mFrameTime;     // X{GS}   7 Value(-range=>[0,1000,1,100], -join=>1)
  Int_t         mMaxFrame;      // X{G}    7 ValOut()
  Float_t       mNormFac;       // X{GS}   7 Value(-range=>[-10,10,1,100], -join=>1)
  ZColor	mColor;		// X{PGS}  7 ColorButt()

public:
  MD2Object(const Text_t* n="MD2Object", const Text_t* t=0) :
    ZNode(n,t) { _init(); }
  virtual ~MD2Object() {}

  void Load(); // X{E} 7 MCWButt()

  const Vector3*          Vertices()      const { return m_akVertex; }
  const Int_t*            Normals()       const { return m_akNormal; }
  const MD2Header&        Header()        const { return m_kHeader; }
  const MD2Triangle*      Triangles()     const { return m_akTriangle; }
  const MD2TextureCoord*  TextureCoords() const { return m_akTextureCoords; }

  char      *m_akFrames; //!
  MD2Header  m_kHeader;  //!

  //indices

  Vector3*           m_akVertex;         //!
  Int_t*             m_akNormal;         //!
  MD2Triangle*       m_akTriangle;       //!
  MD2TextureCoord*   m_akTextureCoords;  //!
  MD2CommandVertex** m_akTriangleFans;   //!
  MD2CommandVertex** m_akTriangleStrips; //!

  UInt_t m_uiNumFans;   //!
  UInt_t m_uiNumStrips; //!

#include "MD2Object.h7"
  ClassDef(MD2Object, 1);
}; // endclass MD2Object


#endif
 MD2Object.h:1
 MD2Object.h:2
 MD2Object.h:3
 MD2Object.h:4
 MD2Object.h:5
 MD2Object.h:6
 MD2Object.h:7
 MD2Object.h:8
 MD2Object.h:9
 MD2Object.h:10
 MD2Object.h:11
 MD2Object.h:12
 MD2Object.h:13
 MD2Object.h:14
 MD2Object.h:15
 MD2Object.h:16
 MD2Object.h:17
 MD2Object.h:18
 MD2Object.h:19
 MD2Object.h:20
 MD2Object.h:21
 MD2Object.h:22
 MD2Object.h:23
 MD2Object.h:24
 MD2Object.h:25
 MD2Object.h:26
 MD2Object.h:27
 MD2Object.h:28
 MD2Object.h:29
 MD2Object.h:30
 MD2Object.h:31
 MD2Object.h:32
 MD2Object.h:33
 MD2Object.h:34
 MD2Object.h:35
 MD2Object.h:36
 MD2Object.h:37
 MD2Object.h:38
 MD2Object.h:39
 MD2Object.h:40
 MD2Object.h:41
 MD2Object.h:42
 MD2Object.h:43
 MD2Object.h:44
 MD2Object.h:45
 MD2Object.h:46
 MD2Object.h:47
 MD2Object.h:48
 MD2Object.h:49
 MD2Object.h:50
 MD2Object.h:51
 MD2Object.h:52
 MD2Object.h:53
 MD2Object.h:54
 MD2Object.h:55
 MD2Object.h:56
 MD2Object.h:57
 MD2Object.h:58
 MD2Object.h:59
 MD2Object.h:60
 MD2Object.h:61
 MD2Object.h:62
 MD2Object.h:63
 MD2Object.h:64
 MD2Object.h:65
 MD2Object.h:66
 MD2Object.h:67
 MD2Object.h:68
 MD2Object.h:69
 MD2Object.h:70
 MD2Object.h:71
 MD2Object.h:72
 MD2Object.h:73
 MD2Object.h:74
 MD2Object.h:75
 MD2Object.h:76
 MD2Object.h:77
 MD2Object.h:78
 MD2Object.h:79
 MD2Object.h:80
 MD2Object.h:81
 MD2Object.h:82
 MD2Object.h:83
 MD2Object.h:84
 MD2Object.h:85
 MD2Object.h:86
 MD2Object.h:87
 MD2Object.h:88
 MD2Object.h:89
 MD2Object.h:90
 MD2Object.h:91
 MD2Object.h:92
 MD2Object.h:93
 MD2Object.h:94
 MD2Object.h:95
 MD2Object.h:96
 MD2Object.h:97
 MD2Object.h:98
 MD2Object.h:99
 MD2Object.h:100
 MD2Object.h:101
 MD2Object.h:102
 MD2Object.h:103
 MD2Object.h:104
 MD2Object.h:105
 MD2Object.h:106
 MD2Object.h:107
 MD2Object.h:108
 MD2Object.h:109
 MD2Object.h:110
 MD2Object.h:111
 MD2Object.h:112
 MD2Object.h:113
 MD2Object.h:114
 MD2Object.h:115
 MD2Object.h:116
 MD2Object.h:117
 MD2Object.h:118
 MD2Object.h:119