///////////////////////////////////////////////////////////////////////////////
/// @file dePortal_priv.hpp
///
/// @brief Portal culling routines, private header
///
/// @author Assassin
///
/// This file is the intellectual property of Novus Delta, LLC.. Usage of the
/// contents of this file is subject to the Destiny3D Member License which
/// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
///
/// This file is distributed "AS IS" without warranty of any kind.  Novus
/// Delta, LLC. does not guarantee the fitness of the contents of this file
/// for any particular purpose.
///
/// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
///
/// <hr>
///                                 Change History
/// <hr>
///
/// @date Jan 2002
/// @author Assassin
/// @remarks Creation
///
///////////////////////////////////////////////////////////////////////////////

#ifndef DEPORTAL_PRIV_HPP
#define DEPORTAL_PRIV_HPP

#include "deGlobalTypes.hpp"
#include "dePortal.hpp"
#include "deArray.hpp"
#include "deMath.hpp"

#pragma todo(fix the orthographic border case intersection and clipping stuff)

class dePortal : public IdePortal
{
protected:
	~dePortal();
public:
	dePortal();
	dePortal(deVec3d Vertices[], int Num);
	int Release();
	
	IdeVertexBuffer * GetVBuffer();
	deBoolean IsTPortal() const;
	void SetTPortal(deBoolean TPortal);
	
//	void ClipFrustum(deTransformInfo * CamPos, const deFrustum &in, deFrustum &out);
	deBoolean ClipFrustum(const deTransformInfo & CamPos, const IdePlaneFrustum* in, IdePlaneFrustum* out);
	deBoolean IntersectsFrustum(const deTransformInfo & CamPos, const IdePlaneFrustum* f) const;
	
	void SetVertices(deVec3d Vertices[], long Num);
	deVec3d* GetVertices(long &Num) const;
	
	deWorldID	GetLinkWorldID() const;
	deObjectID	GetLinkObjectID() const;
	void		SetLinkWorldID(deWorldID WorldID);
	void		SetLinkObjectID(deObjectID ObjectID);
	deBoolean	LinkTo(IdeSceneRoom* SceneRoom);
	
	deBoolean IsPlanar();
	
	void SetNormal(const deVec3d & v);
	void GetNormal(deVec3d & v) const;

	void SetPosition(const deTransformInfo & M);
	void GetPosition(deTransformInfo & M) const;
	void SetTransform(const deTransformInfo & M);
	void GetTransform(deTransformInfo & M) const;
	void ConcatTransform(deTransformInfo & M);
	
private:
	deWorldID			m_LinkWorldID;
	deObjectID			m_LinkObjectID;
	deTransform			m_Transform, m_Position;
	deTArray <deVec3d>	m_Vertices;
	IdeVertexBuffer *	m_VBuffer;
	deBoolean			m_VertsChanged;
	deBoolean			m_DoesTransformation;
	deBoolean			m_IsPlanar;
	deVec3d				m_Normal;
};

#endif