Справочник Пользователя для Conitec 3d gamestudio-source development

Скачать
Страница из 21
3D Gamestudio Programmer's Manual
                        
© Conitec July 2002
                       21
  word skin1[skinwidth/2*skinheight/2];
// the 1st mipmap (if any)
  word skin2[skinwidth/4*skinheight/4];
// the 2nd mipmap (if any)
  word skin3[skinwidth/8*skinheight/8];
// the 3rd mipmap (if any)
} mdl5_skin_t;
The 565 and 4444 pixel formats are described in the mdl format description.
HMP height values
A terrain contains a set of animation frames, which each is a set of height values. Normally
only the first frame is used, because terrain does not animate. Each mesh vertex is defined by a
height value and a normal. 
typedef byte unsigned char;
typedef struct { 
  word  z;   // height value, packed on 0..65536
  byte  lightnormalindex; // index of the vertex normal
  byte  unused;       // not used
} hmp_trivertx_t;
To get the real Z coordinate from the packed coordinates, multiply it by the Z scaling factor,
and add the Z offset. Both the scaling factor and the offset can be found in the
mdl_header
struct.
Thus the formula for calculating the real height positions is: 
float height = (scale_z * z) + offset_z;
The X and Y position of the vertes results of the number of the vertex in the mesh, and thus
must not be stored. The lightnormalindex field is an index to the actual vertex normal vector,
just like in the MDL format description. A whole frame has the following structure: 
typedef struct {
  long type;      // always 2
  mdl_trivertx_t bboxmin,bboxmax;   // bounding box of the frame – see mdl description 
  char name[16];  // name of the frame, used for animation
  hmp_trivertx_t height[numverts];  // array of height values
} hmp_frame_t;