Show kmap.h syntax highlighted
/*
Copyright (C) 2003, 2004, 2005 by Luca Cappa
Written by Luca Cappa groton@users.sourceforge.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __KMAP_H__
#define __KMAP_H__
#include "csutil\flags.h"
#include "ikxmlwriter.h"
#include "ikxmlreader.h"
#include "korientation.h"
struct iEngine;
struct iSector;
struct iGraphics3D;
struct iMaterialWrapper;
struct iMeshWrapper;
class csTransform;
struct iPolygon3D;
struct iDocumentNode;
class csVector3;
class KBlockId;
class KBlock;
class KOrientation;
class KLightList;
class KLight;
class KMap;
//
//Useful local class.
//
class Cell
{
friend class KMap;
bool mInvalidFlag;
static const Cell mInvalid;
Cell (bool pInvalidFlag)
{
mInvalidFlag = pInvalidFlag;
m_block = 0;
};
public:
KBlock* m_block;
KOrientation m_orientation;
Cell() : m_block (0)
{
};
~Cell ()
{
Reset ();
}
void Reset ();
void Set (KBlock* pBlock, KOrientation const& pOr)
{
Reset ();
m_block = pBlock;
m_orientation = pOr;
}
bool IsBlock ()
{
return (m_block != 0);
}
bool IsInvalid ()
{
return mInvalidFlag;
}
};
class KMap : public iKXMLWriter, public iKXMLReader
{
public:
enum
{
KMAP_NEED_RELIGHTING = 1
};
protected:
char* m_name;
csRef<iMaterialWrapper> m_wallMaterial;
csRef<iMaterialWrapper> m_floorMaterial;
csRef<iSector> m_sector;
csRef<iEngine> m_engine;
csRef<iGraphics3D> m_g3d;
csRef<iLoader> m_loader;
csArray<csArray<Cell> > m_map;
size_t m_Xsize;
size_t m_Zsize;
//The lights!
csRef<KLightList> m_lightList;
csFlags m_flags;
Cell& KMap::FindBlockByName (const char* p_name);
void DestroyCells ();
csRef<iCollideSystem> m_collideSystem;
public:
SCF_DECLARE_IBASE;
KMap (iSector*);
virtual ~KMap ();
csFlags& GetFlags ();
KBlock* KMap::CreateBlock (const KBlockId& p_bId, const KOrientation& p_o);
bool PutBlock (const KBlockId&, size_t, size_t, const KOrientation&,
bool p_autoRotateEnaled = true);
void RotateBlockY (KBlock& p_b, const KOrientation&);
bool RemoveBlock (size_t, size_t);
void RemoveBlock (char*);
void RemoveNotVisiblePolygons ();
void AttachColliders ();
void DetachColliders ();
void SetSize (csVector2 const& p_size);
csVector2 GetSize () const;
void Resize (csVector2 const& p_size);
//
//Lights handling.
void HideLights (bool p_b);
void AddLight (KLight* p_light);
void RemoveLight (KLight* p_light);
KLight* FindLightByName (const char* p_lightName);
KLightList const* KMap::GetLightList ();
bool SetMaterial (iMaterialWrapper* p_wallMat,
iMaterialWrapper* p_floorMat);
void GetAt (size_t, size_t, KBlock*&, KOrientation&) const;
void SetName (const char* p_name);
const char* GetName () const;
//iKXMLWriter interface and
//iKXMLReader interface.
bool Write (iDocumentNode*) const;
bool Read (iDocumentNode*);
};
#endif // __KMAP_H__
See more files for this project here