// 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_SHADOW_POLY_RECEIVER_H
#define NL_SHADOW_POLY_RECEIVER_H
#include "nel/misc/types_nl.h"
#include "nel/misc/triangle.h"
#include "nel/misc/vector_h.h"
#include "nel/3d/quad_grid.h"
#include "nel/3d/vertex_buffer.h"
#include "nel/3d/index_buffer.h"
namespace NL3D {
class IDriver;
class CMaterial;
class CShadowMap;
// ***************************************************************************
#define NL3D_SPR_NUM_CLIP_PLANE 7
#define NL3D_SPR_NUM_CLIP_PLANE_SHIFT (1< &destTris, bool colorUpfacingVertices);
/** Use the triangles added for camera 3rd person collision
* return a [0,1] value. 0 => collision at start. 1 => no collision.
* \param testType is the type of intersection: simple ray, cylinder or cone
* \param radius is the radius of the 'cylinder' or 'cone' (not used for simpleRay test, radius goes to end for cone)
*/
float getCameraCollision(const CVector &start, const CVector &end, TCameraColTest testType, float radius);
// ************
private:
// Vertices.
class CVectorId : public CVector
{
public:
uint8 RefCount;
uint8 Flags;
sint16 VBIdx;
CVectorId() {RefCount=0;}
CVectorId(const CVector &v) {(*(CVector*)this)= v; RefCount=0;}
};
std::vector _Vertices;
std::vector _FreeVertices;
typedef std::map TVertexMap;
TVertexMap _VertexMap;
// Triangles
struct CTriangleId
{
uint Vertex[3];
};
typedef CQuadGrid TTriangleGrid;
TTriangleGrid _TriangleGrid;
std::vector _Triangles;
std::vector _FreeTriangles;
// Render
// TODO_SHADOW: optim: VBHard.
CVertexBuffer _VB;
CIndexBuffer _RenderTriangles;
// Vertex Mgt.
// Allocate a vertex. RefCount init to 0. _VertexMap modified.
uint allocateVertex(const CVector &v);
// Release a vertex, freeing him if no more unused => _VertexMap modified.
void releaseVertex(uint id);
// increment the Count of the ith vertex;
void incVertexRefCount(uint id);
// render, using current selection in the quad grid
void renderSelection(IDriver *drv, CMaterial &shadowMat, const CShadowMap *shadowMap, const CVector &casterPos, const CVector &vertDelta);
// select a polygon in the triangle grid
void selectPolygon(const NLMISC::CPolygon2D &poly);
};
} // NL3D
#endif // NL_SHADOW_POLY_RECEIVER_H
/* End of shadow_poly_receiver.h */