Created
August 3, 2013 13:44
-
-
Save handsomematt/6146491 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _LND_H_ | |
#define _LND_H_ | |
// Includes | |
#include <mvmath.h> // This include file includes the math functions | |
#include <ddraw.h> // for DXT3 | |
// | |
// Structures | |
// | |
// | |
// Header of .lnd files | |
// | |
struct LND_Header | |
{ | |
int mnBlocks; | |
byte mBlocks[32*32]; | |
int mnMaterials; | |
int mnCountries; | |
int mSizeofBlock; | |
int mSizeofMaterial; | |
int mSizeofCountry; | |
DWORD mnLoResTex; | |
}; | |
// | |
// LoRes Compressed Texture | |
// | |
struct LND_LoResCompressedTexture | |
{ | |
int mSize; | |
DDSURFACEDESC2 mDDSD; | |
}; | |
// | |
// LoRes Texture Structure | |
// | |
struct LND_LoResTexture | |
{ | |
void *mpTexture; // pointer, ignore when loaded from file | |
void *mpMaterial; // pointer, ignore when loaded from file | |
int mnSubTextures; | |
int mId; | |
LND_LoResCompressedTexture mCompressedTexture; | |
// here comes the data, actually sizeof(LND_LoResCompressedTexture) - mSize | |
}; | |
// | |
// The size of a LoResTexture | |
// | |
const int LND_LoResTextureSize = 256*256 + sizeof(LND_LoResTexture); | |
const int LND_LoResTextureExportSize = 256*256 + sizeof(DDSURFACEDESC2)-4; | |
// | |
// A Land Cell | |
// | |
struct LND_LandCell | |
{ | |
union | |
{ | |
DWORD mLight; | |
struct | |
{ | |
byte mBlue; | |
byte mGreen; | |
byte mRed; | |
byte mColor; | |
}; | |
}; | |
byte mAltitude; | |
byte mSaveColor; | |
unsigned short mFlags; | |
// | |
// the flags is a bitfield with these values: | |
// nb split is used to say if the cell's quad is split into triangles this way: / or this way: \ | |
// | |
enum | |
{ | |
MASK_COUNTRY = 0xF, | |
MASK_WATER = (1<<4), | |
MASK_COAST = (1<<5), | |
MASK_TYPE = (MASK_WATER|MASK_COAST), | |
MASK_SPLIT = (1<<7), | |
MASK_INVISIBLE = (1<<8), // TODO | |
MASK_FULLWATER = (1<<9), | |
SOUND_LAND = 0, | |
SOUND_SEA = 1, | |
SOUND_FRESH_WATER = 2, | |
SOUND_COASTAL = 3, | |
SOUND_BIT0 = (1<<10), | |
SOUND_BIT1 = (1<<11), | |
SOUND_BIT2 = (1<<12), | |
SOUND_BIT3 = (1<<13), | |
ROL_SOUND = 10, | |
MASK_SOUND = SOUND_BIT0|SOUND_BIT1|SOUND_BIT2|SOUND_BIT3, | |
}; | |
enum TSplit | |
{ | |
TSPLIT_NORMAL = 0, | |
TSPLIT_INVERSE = 1, | |
TSPLIT_MAX = 0xFFFFFFFF, | |
}; | |
}; | |
// | |
// LandBlock | |
// | |
struct LND_Block | |
{ | |
// | |
// enums used by this structure | |
// | |
enum LandMeshLOD | |
{ | |
LOD_0 = 0, | |
LOD_1 = 1, | |
LOD_2 = 2, | |
LOD_UNDEF , | |
}; | |
enum MeshBlendingMod | |
{ | |
FULL_0 = 0, | |
BLEND_0_AND_1 = 1, | |
FULL_1 = 2, | |
BLEND_1_AND_2 = 3, | |
FULL_2 = 4, | |
}; | |
enum TextureBlend | |
{ | |
HIGH_DETAIL = 0, | |
LOW_DETAIL = 1, | |
MIXTE_DETAIL = 2, | |
}; | |
// | |
// substructures | |
// | |
typedef struct | |
{ | |
BOOL mbClipped; | |
ULONG mFrameVisibility; | |
ULONG mbUnused; | |
BOOL mbUseSmallBump; | |
BOOL mForceLowres; | |
LandMeshLOD mMeshLod; | |
MeshBlendingMod mMeshBlending; | |
TextureBlend mTextureBlend; | |
//MeshLodType mMeshLodType; | |
int mMeshLodType; | |
//TFog mFog; | |
int mFog; | |
} Info; | |
// | |
// Structure variables | |
// | |
LND_LandCell mCells[(17*17 + 4) & ~0x4]; // 293 | |
int mIndex; // unique id of block | |
float mOffsetX; // position of block in 512x512 world | |
float mOffsetZ; // position of block in 512x512 world | |
int mLine32; // position of block in 32x32 block array | |
int mColumn32; // position of block in 32x32 block array | |
Info mInfo; // rendering info | |
//LH3DTexture* mpTexture; | |
//LH3DMaterial* mpMaterial; | |
int* mpTexture; | |
int* mpMaterial; | |
int mbDrawSomething; | |
//LH3DMaterial *mpSpecialMaterialBefore; | |
//LH3DMaterial *mpSpecialMaterialAfter; | |
int *mpSpecialMaterialBefore; | |
int *mpSpecialMaterialAfter; | |
float mTransformUVBefore[12]; | |
float mTransformUVAfter[12]; | |
LND_Block* mNextSorting; | |
float mValueSorting; | |
int mLowRestexture; | |
float m_fu_lrs; // 0.0f <-> 1.0f | |
float m_fv_lrs; | |
int m_iu_lrs; // 0 <-> 256 | |
int m_iv_lrs; | |
BOOL mbSmallTextureUpdated; | |
}; | |
// | |
// Next Comes the Country structure | |
// it defines the surface theme (desert, forest, grass plain, montain...) | |
// | |
struct LND_Country | |
{ | |
typedef struct | |
{ | |
ULONG mIndex1; | |
ULONG mIndex2; | |
ULONG mCoef; // scaling factor | |
} TMapMaterial; | |
DWORD mTerrainType; // i'm not sure about this value :) | |
TMapMaterial mMapMaterials[256]; | |
}; | |
// | |
// a Material is a 256x256 textures which is blended together with other materials | |
// at run-time to create | |
// the landscape textures for each block, depending on country settings, altitude, etc | |
// each material covers one block exactly. of course a block may blend several materials | |
// together (eg sand material and grass material) to make its texture. | |
// | |
struct LND_Material | |
{ | |
unsigned short mTerrainType; | |
unsigned short mImage[256*256]; | |
}; | |
// | |
// Finally a Bump and a Noise grayscale Map | |
// | |
struct LND_BumpMap | |
{ | |
byte data[256*256]; | |
}; | |
struct LND_NoiseMap | |
{ | |
byte data[256*256]; | |
}; | |
// | |
// the gradient used for material composing | |
// | |
byte blend_gradient[16*16]; | |
#endif // _LND_H_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment