// NeL - MMORPG Framework
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
#ifndef NL_RETRIEVABLE_SURFACE_H
#define NL_RETRIEVABLE_SURFACE_H
#include
#include "nel/misc/types_nl.h"
#include "nel/misc/vector.h"
#include "nel/misc/file.h"
#include "nel/misc/aabbox.h"
#include "surface_quad.h"
namespace NLPACS
{
/**
* The various features of the models (precisely, the indexes to the table of features).
*/
enum
{
NumMaxCreatureModels = 4,
NumCreatureModels = 2,
ModelRadius = 0,
ModelHeight = 1,
ModelInclineThreshold = 2,
NumModelCharacteristics = 3
};
/**
* The features of the models, as floats
*/
extern float Models[NumMaxCreatureModels][NumModelCharacteristics];
/**
* A retrievable surface (inside a local surface retriever). It is composed of
* the Ids of the chains composing the border of the surface.
* \author Benjamin Legros
* \author Nevrax France
* \date 2001
*/
class CRetrievableSurface
{
public:
/**
* A link from the current surface to a neighbor surface through a chain.
* \author Benjamin Legros
* \author Nevrax France
* \date 2001
*/
class CSurfaceLink
{
public:
/// The id of the chain between the 2 neighbors.
sint32 Chain;
/// The id of the neighbor.
sint32 Surface;
public:
/// Constructor.
CSurfaceLink(sint32 chain=0, sint32 surface=0) : Chain(chain), Surface(surface) {}
/// Serialises this CSurfaceLink.
void serial(NLMISC::IStream &f) { f.serial(Chain, Surface); }
};
enum
{
IsFloorBit = 24,
IsSlantBit = 25,
IsCeilingBit = 26,
IsUnderWaterBit = 27,
ClusterHintBit = 28,
NormalQuantasStartBit = 0,
NormalQuantasStopBit = 3,
NormalQuantasBitMask = 0x0000000f,
CharacterQuantasStartBit = 8,
CharacterQuantasStopBit = 11,
CharacterQuantasBitMask = 0x00000f00,
MaterialQuantasStartBit = 16,
MaterialQuantasStopBit = 23,
MaterialQuantasBitMask = 0x00ff0000
};
/**
* A list of chain
* WARNING: a loop is a list of index in the surface link list _Chains !!
* This is not directly the ChainId
* ChainId is _Chains[loop[i]].Chain !!!
*/
struct TLoop : std::vector
{
float Length;
void serial(NLMISC::IStream &f);
};
protected:
friend class CLocalRetriever;
/// @name Surface features.
//@{
uint8 _NormalQuanta;
uint8 _OrientationQuanta;
uint8 _Material;
uint8 _Character;
uint8 _Level;
sint8 _QuantHeight;
bool _IsFloor;
bool _IsCeiling;
//@}
/// Various flags.
uint32 _Flags;
float _WaterHeight;
/// The links to the neighbor surfaces.
std::vector _Chains;
/// The loops of chains
std::vector _Loops;
/// A Height QuadTree that allows to easily find the height out for a given 2D point. -- deprecated
CSurfaceQuadTree _Quad;
/// The topologies associated with the surface, for each type of model.
sint32 _Topologies[NumMaxCreatureModels];
/// The center of the surface.
NLMISC::CVector _Center;
public:
CRetrievableSurface()
{
uint i;
for (i=0; i &getChains() const { return _Chains; }
/// Gets nth link form this surface to its neighbor.
CSurfaceLink getChain(uint n) const { return _Chains[n]; }
/// Get nth loop
const TLoop &getLoop(uint n) const { return _Loops[n]; }
/// Get loops
const std::vector &getLoops() const { return _Loops; }
const NLMISC::CVector &getCenter() const { return _Center; }
/// Translates the surface by the translation vector.
void translate(const NLMISC::CVector &translation)
{
_Center += translation;
_Quad.translate(translation);
}
/// Serialises the CRetrievableSurface.
void serial(NLMISC::IStream &f);
};
}; // NLPACS
#endif // NL_RETRIEVABLE_SURFACE_H
/* End of retrievable_surface.h */