//ROMTEAM WorldEditor
////////////////////////////////////////////////////////////////////////////////////////
// File        : Plane3D.cpp: implementation of the Plane3D class.
// Author      : Viorel Preoteasa
// Date        : 97.11
// Description :
////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ACP_Base.h"

#include "ITF.h"
#include "incGAM.h"
#include "GLI.h"
#include "DPT.h"

#undef CPA_WANTS_IMPORT
#undef CPA_EXPORT
#define CPA_WANTS_EXPORT
    #include "OGD.h"
#undef CPA_WANTS_EXPORT
#ifndef CPA_WANTS_IMPORT
#define CPA_WANTS_IMPORT
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Construction/Destruction of Plane3D
// Date   : 97-11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : 
// Author      : Viorel Preoteasa - CPA2
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date         :
// By           :
//////////////////////////////////////////////////////////////////////////////////////////////////////
Plane3D::Plane3D (BOOL bModifiable, CPA_EditorBase *_p_oEditor, /*ACP_tdxIndex xNbPoints, ACP_tdxIndex xNbElements,*/ const CString _csName , tdeSaveStatus _eStatus )
	: Shape3D (bModifiable, _p_oEditor, 24, 3, _csName , _eStatus)
{
	CommonPlane3D ();
}

Plane3D::Plane3D (BOOL bModifiable, CPA_EditorBase *_p_oEditor, /*ACP_tdxIndex xNbPoints, ACP_tdxIndex xNbElements,*/ CPA_BaseObject *_p_oOwnerFile, const CString _csName /*= ""*/, char *_p_cRefPath /*= NULL*/, tdeSaveStatus _eStatus /*= E_ss_Responsible*/)
	: Shape3D (bModifiable, _p_oEditor, 24, 3, _p_oOwnerFile, _csName, _p_cRefPath, _eStatus)
{
	CommonPlane3D ();
}

Plane3D::Plane3D (BOOL bModifiable, CPA_EditorBase *_p_oEditor, CPA_BaseObject *_p_oOwnerFile, ACP_tdxHandleOfObject _hObject, const CString _csName /*= ""*/, char *_p_cRefPath /*= NULL*/, tdeSaveStatus _eStatus /*= E_ss_Modify*/)
	: Shape3D (bModifiable, _p_oEditor, _p_oOwnerFile, _hObject, _csName, _p_cRefPath, _eStatus)
{
	CommonPlane3D ();
}

Plane3D::~Plane3D()
{

}

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Plane3D
// Date   : 97-11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : Common initialisation
// Author      : Viorel Preoteasa - CPA2
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date         :
// By           :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Plane3D::CommonPlane3D()
{
	MTH3D_tdstVector a8_stPoint [24];
	for ( int iCounter=0; iCounter<24; iCounter++ )
		MTH3D_M_vSetVectorElements ( a8_stPoint+iCounter, 0.0, 0.0, 0.0 );

	fn_vSetListOfPoints(24, a8_stPoint);
	
	m_hElement[0] = fn_hCreateElementIndexedTriangle(4,0);
	fn_eSetIndexedTriangle ( m_hElement[0], 0, 0, 1, 3 );
	fn_eSetIndexedTriangle ( m_hElement[0], 1, 1, 2, 3 );
	fn_eSetIndexedTriangle ( m_hElement[0], 2, 4, 7, 5 );
	fn_eSetIndexedTriangle ( m_hElement[0], 3, 6, 5, 7 );

	m_hElement[1] = fn_hCreateElementIndexedTriangle(12,0);
	fn_eSetIndexedTriangle ( m_hElement[1], 0, 0, 4, 11 );
	fn_eSetIndexedTriangle ( m_hElement[1], 1, 4, 15, 11 );
	fn_eSetIndexedTriangle ( m_hElement[1], 2, 14, 5, 1 );
	fn_eSetIndexedTriangle ( m_hElement[1], 3, 10, 14, 1 );
	fn_eSetIndexedTriangle ( m_hElement[1], 4, 1, 5, 6 );
	fn_eSetIndexedTriangle ( m_hElement[1], 5, 1, 6, 2 );
	fn_eSetIndexedTriangle ( m_hElement[1], 6, 3, 20, 7 );
	fn_eSetIndexedTriangle ( m_hElement[1], 7, 3, 16, 20 );
	fn_eSetIndexedTriangle ( m_hElement[1], 8, 17, 6, 21 );
	fn_eSetIndexedTriangle ( m_hElement[1], 9, 17, 2, 6 );
	fn_eSetIndexedTriangle ( m_hElement[1], 10, 0, 3, 7 );
	fn_eSetIndexedTriangle ( m_hElement[1], 11, 7, 4, 0 );
	
	m_hElement[2] = fn_hCreateElementIndexedTriangle(20,0);
	fn_eSetIndexedTriangle ( m_hElement[2], 0, 8, 9, 11 );
	fn_eSetIndexedTriangle ( m_hElement[2], 1, 9, 10, 11 );
	fn_eSetIndexedTriangle ( m_hElement[2], 2, 12, 13, 9 );
	fn_eSetIndexedTriangle ( m_hElement[2], 3, 9, 8, 12 );
	fn_eSetIndexedTriangle ( m_hElement[2], 4, 9, 13, 14 );
	fn_eSetIndexedTriangle ( m_hElement[2], 5, 9, 14, 10 );
	fn_eSetIndexedTriangle ( m_hElement[2], 6, 13, 12, 15 );
	fn_eSetIndexedTriangle ( m_hElement[2], 7, 13, 15, 14 );
	fn_eSetIndexedTriangle ( m_hElement[2], 8, 8, 11, 15 );
	fn_eSetIndexedTriangle ( m_hElement[2], 9, 15, 12, 8 );
	fn_eSetIndexedTriangle ( m_hElement[2], 10, 16, 17, 19 );
	fn_eSetIndexedTriangle ( m_hElement[2], 11, 17, 18, 19 );
	fn_eSetIndexedTriangle ( m_hElement[2], 12, 20, 23, 21 );
	fn_eSetIndexedTriangle ( m_hElement[2], 13, 21, 23, 22 );
	fn_eSetIndexedTriangle ( m_hElement[2], 14, 17, 22, 18 );
	fn_eSetIndexedTriangle ( m_hElement[2], 15, 17, 21, 22 );
	fn_eSetIndexedTriangle ( m_hElement[2], 16, 16, 19, 23 );
	fn_eSetIndexedTriangle ( m_hElement[2], 17, 16, 23, 20 );
	fn_eSetIndexedTriangle ( m_hElement[2], 18, 19, 18, 23 );
	fn_eSetIndexedTriangle ( m_hElement[2], 19, 18, 22, 23 );
	EndCreate();
}
