reman3/Rayman_X/cpa/tempgrp/OGD/src/Alt3D.cpp

663 lines
26 KiB
C++

////////////////////////////////////////////////////////////////////////////////////////
// File : Altimap3D.cpp: implementation of the Altimap3D class.
// Author : Cristi Petrescu
// Date : 98.02.05
// 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
#include "3dinterf.hpp"
#include "DlgAlt3D.hpp"
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::Altimap3D
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : constructor to create a new object
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
Altimap3D::Altimap3D (CPA_EditorBase *_p_oEditor, const CString _csName , tdeSaveStatus _eStatus )
:Shape3D (TRUE, _p_oEditor, 121, 1, _csName , _eStatus)
{
CommonAltimap3D (10, 10);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::Altimap3D
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : constructor to create a new object
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
Altimap3D::Altimap3D (CPA_EditorBase *_p_oEditor, ACP_tdxIndex xWidth, ACP_tdxIndex xDepth, MTH_tdxReal xSquareDimX, MTH_tdxReal xSquareDimY, const CString _csName , tdeSaveStatus _eStatus )
:Shape3D(TRUE, _p_oEditor, (xWidth + 1) * (xDepth + 1), 1, _csName , _eStatus)
{
CommonAltimap3D (xWidth, xDepth, xSquareDimX, xSquareDimY);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::CommonAltimap3D
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : construct of Altimap3D
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Altimap3D::CommonAltimap3D (ACP_tdxIndex xWidth /*= 10*/, ACP_tdxIndex xDepth /*= 10*/, MTH_tdxReal xSquareDimX /*= 1*/, MTH_tdxReal xSquareDimY /*= 1*/)
{
ACP_tdxIndex xNbVertices = (xWidth + 1) * (xDepth + 1);
ACP_tdxIndex xNbSquares = xWidth * xDepth;
m_hElement = fn_hCreateElementAltimap(xNbVertices, xNbSquares, xNbSquares * 2, 4, 1);
// set the origin
MTH3D_tdstVector stCenter = {0.0, 0.0, -1.0};
SetOrigin (stCenter);
// set the heights
ACP_tdxIndex xCount;
for (xCount = 0; xCount < xNbVertices; xCount ++)
{
GEO_vSetAltimapVertexHeight (GetStruct (), m_hElement, xCount, 0.1f * (xCount - xNbVertices / 2));
}
// set the square parameters
GEO_vSetAltimapSquarePattern (GetStruct (), m_hElement, xWidth, xSquareDimX, xDepth, xSquareDimY);
// build the rest of it
ACP_tdxIndex xWidthCount, xDepthCount;
GEO_vSetAltimapNbFaces (GetStruct (), m_hElement, xWidth * xDepth * 2);
for (xWidthCount = 0; xWidthCount < xWidth; xWidthCount ++)
{
for (xDepthCount = 0; xDepthCount < xDepth; xDepthCount ++)
{
ACP_tdxIndex xNumSquare = xWidthCount + xDepthCount * xWidth;
// set the squares
GEO_vSetAltimapSquare (GetStruct (), m_hElement, xNumSquare, GEO_C_xAltiSquareBothTRBL, xNumSquare * 2);
// set the faces
// uvs
GEO_vSetAltimapFaceUVIndex (GetStruct (), m_hElement, xNumSquare * 2, 0, 1, 3);
GEO_vSetAltimapFaceUVIndex (GetStruct (), m_hElement, xNumSquare * 2 + 1, 0, 2, 3);
// materials
GEO_vSetAltimapFaceMaterialIndex (GetStruct (), m_hElement, xNumSquare * 2, 0);
GEO_vSetAltimapFaceMaterialIndex (GetStruct (), m_hElement, xNumSquare * 2 + 1, 0);
// and a normals ?!
}
}
// set the uv values
GEO_vSetAltimapNbUVValues (GetStruct (), m_hElement, 4);
ACP_tdst2DUVValues stUV0 = {0.0, 0.0};
GEO_vSetAltimapUVValue (GetStruct (), m_hElement, 0, stUV0);
ACP_tdst2DUVValues stUV1 = {1.0, 0.0};
GEO_vSetAltimapUVValue (GetStruct (), m_hElement, 1, stUV1);
ACP_tdst2DUVValues stUV2 = {0.0, 1.0};
GEO_vSetAltimapUVValue (GetStruct (), m_hElement, 2, stUV2);
ACP_tdst2DUVValues stUV3 = {1.0, 1.0};
GEO_vSetAltimapUVValue (GetStruct (), m_hElement, 3, stUV3);
// set the material
GEO_vSetAltimapNbMaterials (GetStruct (), m_hElement, 1);
GEO_tdstElementAltimap *p_stAltimap = (GEO_tdstElementAltimap *) GetStruct () -> d_stListOfElements [m_hElement];
p_stAltimap -> d_hMaterial [0] = fn_hGetDefaultGameMaterial ();
// set the normals
if(GetStruct()->d_stListOfPointsNormals)
GEO_M_CPAFree(GetStruct()->d_stListOfPointsNormals);
if(GetStruct()->d_hListOfPointsMaterial)
GEO_M_CPAFree(GetStruct()->d_hListOfPointsMaterial);
if(GetStruct()->d_stListOfEdges)
GEO_M_CPAFree(GetStruct()->d_stListOfEdges);
if(GetStruct()->d_stListOfPointsReceivedLightIntensity)
GEO_M_CPAFree(GetStruct()->d_stListOfPointsReceivedLightIntensity);
GEO_xCreateObjectPointNormals (GetStruct());
GEO_vCreateObjectListOfPointsMaterial(GetStruct());
GEO_xCreateObjectListOfEdges(GetStruct());
GEO_xComputeObjectNormals (GetStruct());
GEO_vComputeObjectListOfPointsMaterial(GetStruct());
GEO_xComputeObjectListOfEdges(GetStruct());
// I will use the vertexes for the altimap for selection
GEO_tdstGeometricObject *p_stObject = (GEO_tdstGeometricObject *) GetStruct ();
MTH3D_tdstVector *d_stPoints, stOriginNoZ;
ACP_tdxIndex xI, xJ, xK;
GEO_M_CPAMalloc( d_stPoints,
MTH3D_tdstVector *,
( p_stAltimap->xWidth+1 ) * ( p_stAltimap->xDepth+1 ) * sizeof( MTH3D_tdstVector ),
E_uwGEONotEnoughtMemory );
p_stObject -> d_stListOfPoints = d_stPoints;
//--- xI : Width
//--- xJ : Height
//--- xK : xJ * (Width+1) + xI
MTH3D_M_vSetVectorElements( &stOriginNoZ, p_stAltimap->stOrigin.xX, p_stAltimap->stOrigin.xY, MTH_C_ZERO );
for(xJ = 0, xK = 0; xJ < p_stAltimap->xDepth+1; xJ++)
for(xI = 0 ; xI< p_stAltimap->xWidth+1; xI++, xK ++)
{
//--- For each Vertex, sets the coordinates in its super object axis system
(d_stPoints + xK) -> xX = MTH_M_xRealToLong(xI) * p_stAltimap->xDeltaX;
(d_stPoints + xK) -> xY = MTH_M_xRealToLong(xJ) * p_stAltimap->xDeltaY;
(d_stPoints + xK) -> xZ = p_stAltimap->d_xHeight[xK];
MTH3D_M_vAddVector(d_stPoints + xK, d_stPoints + xK, &stOriginNoZ);
}
// EndCreate ();
m_pAltimapUndo = NULL;
}
Altimap3D::~Altimap3D()
{
}
/*
keep them a little more, maybe may prove useful...
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::SetNbX
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : change the x sampling rate
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Altimap3D::SetNbX(int iNbX)
{
// remind the old values...
m_iOldNbX = m_iNbX;
m_iOldNbY = m_iNbY;
m_iNbX = iNbX >= 2 ? iNbX : 2;
if (m_iOldNbX != m_iNbX)
{
// keep the z's
GEO_tdstGeometricObject *pObj = GetStruct ();
MTH3D_tdstVector *aPoint = pObj -> d_stListOfPoints;
m_aZ = (GLI_tdxValue *) malloc (m_iOldNbX * m_iOldNbY * sizeof (GLI_tdxValue));
for (int i = 0; i < m_iOldNbX; i ++)
for (int j = 0; j < m_iOldNbY; j ++)
m_aZ [i * m_iOldNbY + j] = aPoint [i * m_iOldNbY + j] . xZ;
m_bNewAltimap = FALSE;
m_hElement = NewElement (0, m_iNbX, m_iNbY);
free (m_aZ);
m_aZ = NULL;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::SetNbY
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : change the Y sampling rate
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Altimap3D::SetNbY(int iNbY)
{
// remind the old values...
m_iOldNbX = m_iNbX;
m_iOldNbY = m_iNbY;
m_iNbY = iNbY >= 2 ? iNbY : 2;
if (m_iOldNbY != m_iNbY)
{
// keep the z's
GEO_tdstGeometricObject *pObj = GetStruct ();
MTH3D_tdstVector *aPoint = pObj -> d_stListOfPoints;
m_aZ = (GLI_tdxValue *) malloc (m_iOldNbX * m_iOldNbY * sizeof (GLI_tdxValue));
for (int i = 0; i < m_iOldNbX; i ++)
for (int j = 0; j < m_iOldNbY; j ++)
m_aZ [i * m_iOldNbY + j] = aPoint [i * m_iOldNbY + j] . xZ;
m_bNewAltimap = FALSE;
m_hElement = NewElement (0, m_iNbX, m_iNbY);
free (m_aZ);
m_aZ = NULL;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::SetSizeX
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : change the x size of the Altimap
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Altimap3D::SetSizeX(GLI_tdxValue SizeX)
{
if (SizeX >= 0)
{
GEO_tdstGeometricObject *pObj = GetStruct ();
MTH3D_tdstVector *aPoint = pObj -> d_stListOfPoints;
GLI_tdxValue ScaleX = SizeX / (m_iNbX - 1);
for (int i = 0; i < m_iNbX; i ++)
for (int j = 0; j < m_iNbY; j ++)
aPoint [i * m_iNbY + j] . xX = i * ScaleX;
m_SizeX = SizeX;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::SetSizeY
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : change the Y size of the Altimap
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Altimap3D::SetSizeY(GLI_tdxValue SizeY)
{
if (SizeY >= 0)
{
GEO_tdstGeometricObject *pObj = GetStruct ();
MTH3D_tdstVector *aPoint = pObj -> d_stListOfPoints;
GLI_tdxValue ScaleY = SizeY / (m_iNbY - 1);
for (int i = 0; i < m_iNbX; i ++)
for (int j = 0; j < m_iNbY; j ++)
aPoint [i * m_iNbY + j] . xY = j * ScaleY;
m_SizeY = SizeY;
}
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::SetOrigin
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the altimap origin
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Altimap3D::SetOrigin (MTH3D_tdstVector st3DPoint)
{
GEO_vSetAltimapOrigin (GetStruct (), m_hElement, st3DPoint);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::SetWidth
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the width of the altimap
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Altimap3D::SetWidth (ACP_tdxIndex xWidth)
{
ACP_tdxIndex xOldWidth;
ACP_tdxIndex xOldDepth;
MTH_tdxReal xOldSquareDimX;
MTH_tdxReal xOldSquareDimY;
GEO_vGetAltimapSquarePattern (GetStruct (), m_hElement, &xOldWidth, &xOldSquareDimX, &xOldDepth, &xOldSquareDimY);
GEO_vSetAltimapSquarePattern (GetStruct (), m_hElement, xWidth, xOldSquareDimX, xOldDepth, xOldSquareDimY);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::SetDepth
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the depth of the altimap
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Altimap3D::SetDepth (ACP_tdxIndex xDepth)
{
ACP_tdxIndex xOldWidth;
ACP_tdxIndex xOldDepth;
MTH_tdxReal xOldSquareDimX;
MTH_tdxReal xOldSquareDimY;
GEO_vGetAltimapSquarePattern (GetStruct (), m_hElement, &xOldWidth, &xOldSquareDimX, &xOldDepth, &xOldSquareDimY);
GEO_vSetAltimapSquarePattern (GetStruct (), m_hElement, xOldWidth, xOldSquareDimX, xDepth, xOldSquareDimY);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::SetSquareDimX
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : sets the x square size
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Altimap3D::SetSquareDimX (MTH_tdxReal xSquareDimX)
{
ACP_tdxIndex xOldWidth;
ACP_tdxIndex xOldDepth;
MTH_tdxReal xOldSquareDimX;
MTH_tdxReal xOldSquareDimY;
GEO_vGetAltimapSquarePattern (GetStruct (), m_hElement, &xOldWidth, &xOldSquareDimX, &xOldDepth, &xOldSquareDimY);
GEO_vSetAltimapSquarePattern (GetStruct (), m_hElement, xOldWidth, xSquareDimX, xOldDepth, xOldSquareDimY);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::SetSquareDimY
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : sets the y square size
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Altimap3D::SetSquareDimY (MTH_tdxReal xSquareDimY)
{
ACP_tdxIndex xOldWidth;
ACP_tdxIndex xOldDepth;
MTH_tdxReal xOldSquareDimX;
MTH_tdxReal xOldSquareDimY;
GEO_vGetAltimapSquarePattern (GetStruct (), m_hElement, &xOldWidth, &xOldSquareDimX, &xOldDepth, &xOldSquareDimY);
GEO_vSetAltimapSquarePattern (GetStruct (), m_hElement, xOldWidth, xOldSquareDimX, xOldDepth, xSquareDimY);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::GetOrigin
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : get the altimap origin
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
MTH3D_tdstVector Altimap3D::GetOrigin (void)
{
MTH3D_tdstVector stOrigin;
GEO_vGetAltimapOrigin (GetStruct (), m_hElement, &stOrigin);
return stOrigin;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::GetWidth
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : get the altimap width
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
ACP_tdxIndex Altimap3D::GetWidth (void)
{
ACP_tdxIndex xWidth;
ACP_tdxIndex xDepth;
MTH_tdxReal xSquareDimX;
MTH_tdxReal xSquareDimY;
GEO_vGetAltimapSquarePattern (GetStruct (), m_hElement, &xWidth, &xSquareDimX, &xDepth, &xSquareDimY);
return xWidth;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::GetDepth
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : get the altimap depth
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
ACP_tdxIndex Altimap3D::GetDepth (void)
{
ACP_tdxIndex xWidth;
ACP_tdxIndex xDepth;
MTH_tdxReal xSquareDimX;
MTH_tdxReal xSquareDimY;
GEO_vGetAltimapSquarePattern (GetStruct (), m_hElement, &xWidth, &xSquareDimX, &xDepth, &xSquareDimY);
return xDepth;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::GetSquareDimX
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : get the altimap square x size
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
MTH_tdxReal Altimap3D::GetSquareDimX (void)
{
ACP_tdxIndex xWidth;
ACP_tdxIndex xDepth;
MTH_tdxReal xSquareDimX;
MTH_tdxReal xSquareDimY;
GEO_vGetAltimapSquarePattern (GetStruct (), m_hElement, &xWidth, &xSquareDimX, &xDepth, &xSquareDimY);
return xSquareDimX;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Altimap3D::GetSquareDimY
// Date : 98.03
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : get the altimap square y size
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
MTH_tdxReal Altimap3D::GetSquareDimY (void)
{
ACP_tdxIndex xWidth;
ACP_tdxIndex xDepth;
MTH_tdxReal xSquareDimX;
MTH_tdxReal xSquareDimY;
GEO_vGetAltimapSquarePattern (GetStruct (), m_hElement, &xWidth, &xSquareDimX, &xDepth, &xSquareDimY);
return xSquareDimY;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Altimap3D::_OnLButtonDblClk
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : launch the modal dialog
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Altimap3D::_OnLButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)
{
int iDlgResult;
HINSTANCE hOldInst = AfxGetResourceHandle();
AfxSetResourceHandle ( ((CPA_DLLBase*)(GetEditor()))->GetDLLIdentity()->hModule );
CDlgAltimap3D dlgAltimap3D(this);
iDlgResult = dlgAltimap3D.DoModal();
AfxSetResourceHandle(hOldInst);
if (iDlgResult == IDOK)
{
// ... because the edit manager redoes them
m_pAltimapUndo -> Undo ();
// and the real AskFor is done by the calling editor
// m_pGeometry3DDLL -> GetInterface () -> GetMultiDevice () -> GetEditManager () -> AskFor (pAltimapUndo);
return TRUE;
}
else
{
m_pAltimapUndo -> Undo ();
m_pAltimapUndo = NULL;
return FALSE;
}
}
//------------------------------------------ AltimapUndo ---------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :AltimapUndo::AltimapUndo
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : Init the undo data
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
AltimapUndo::AltimapUndo(Altimap3D *pAltimap3D) : CPA_Modif(0, "Set Altimap Parameters", FALSE)
{
m_pAltimap3D = pAltimap3D;
GEO_tdstElementAltimap *p_stAltimap = (GEO_tdstElementAltimap *) m_pAltimap3D -> GetStruct () -> d_stListOfElements [m_pAltimap3D -> m_hElement];
ACP_tdxIndex xNbVertices = (p_stAltimap -> xWidth + 1) * (p_stAltimap -> xDepth + 1);
ACP_tdxIndex xNbSquares = p_stAltimap -> xWidth * p_stAltimap -> xDepth;
GEO_M_CPAMalloc( m_p_stAltimapUndo,
GEO_tdstElementAltimap *,
sizeof( GEO_tdstElementAltimap ),
E_uwGEONotEnoughtMemory );
memcpy (m_p_stAltimapUndo, p_stAltimap, sizeof (GEO_tdstElementAltimap));
//--- Array of Heights ---
GEO_M_CPAMalloc( m_p_stAltimapUndo -> d_xHeight,
MTH_tdxReal *,
xNbVertices * sizeof( MTH_tdxReal ),
E_uwGEONotEnoughtMemory );
memcpy (m_p_stAltimapUndo -> d_xHeight, p_stAltimap -> d_xHeight, xNbVertices * sizeof (MTH_tdxReal));
/*
// no way
//--- Array of Point Normals ---
*/
//--- Array of Square Descriptors ---
GEO_M_CPAMalloc( m_p_stAltimapUndo->d_stSquare,
GEO_tdstAltimapSquare *,
xNbSquares* sizeof( GEO_tdstAltimapSquare ),
E_uwGEONotEnoughtMemory );
memcpy (m_p_stAltimapUndo -> d_stSquare, p_stAltimap -> d_stSquare, xNbSquares * sizeof (GEO_tdstAltimapSquare));
//--- Array of Face descriptors ---
GEO_M_CPAMalloc( m_p_stAltimapUndo->d_stFaces,
GEO_tdstAltimapFace *,
p_stAltimap -> xNbFaces * sizeof( GEO_tdstAltimapFace ),
E_uwGEONotEnoughtMemory );
memcpy (m_p_stAltimapUndo -> d_stFaces, p_stAltimap -> d_stFaces, p_stAltimap -> xNbFaces * sizeof (GEO_tdstAltimapFace));
//--- Array of UV Values ---
GEO_M_CPAMalloc( m_p_stAltimapUndo->d_stUVValues,
ACP_tdst2DUVValues *,
p_stAltimap -> xNbUVValues * sizeof( ACP_tdst2DUVValues ),
E_uwGEONotEnoughtMemory );
memcpy (m_p_stAltimapUndo -> d_stUVValues, p_stAltimap -> d_stUVValues, p_stAltimap -> xNbUVValues * sizeof (ACP_tdst2DUVValues));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :AltimapUndo::Undo
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : undo sphere parameters
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL AltimapUndo::Undo (void)
{
GEO_tdstElementAltimap stAltimapSwap;
GEO_tdstElementAltimap *p_stAltimap = (GEO_tdstElementAltimap *) m_pAltimap3D -> GetStruct () -> d_stListOfElements [m_pAltimap3D -> m_hElement];
memcpy (& stAltimapSwap, p_stAltimap, sizeof (GEO_tdstElementAltimap));
memcpy (p_stAltimap, m_p_stAltimapUndo, sizeof (GEO_tdstElementAltimap));
memcpy (m_p_stAltimapUndo, & stAltimapSwap, sizeof (GEO_tdstElementAltimap));
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :AltimapUndo::~AltimapUndo
// Date : 98.02
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : destroy the undo structure
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
AltimapUndo::~AltimapUndo (void)
{
// delete the altimap infos
GEO_M_CPAFree (m_p_stAltimapUndo -> d_xHeight);
//GEO_M_CPAFree (m_p_stAltimapElement -> d_stPointNormals); // never alloc it
GEO_M_CPAFree (m_p_stAltimapUndo -> d_stSquare);
GEO_M_CPAFree (m_p_stAltimapUndo -> d_stFaces);
GEO_M_CPAFree (m_p_stAltimapUndo -> d_stUVValues);
GEO_M_CPAFree (m_p_stAltimapUndo);
}