//ROMTEAM WorldEditor //////////////////////////////////////////////////////////////////////////////////////// // File : ParamSurface3D.cpp: implementation of the ParamSurface3Dclass. // 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 ParamSurface3D // Date : 97-11 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : // Author : Viorel Preoteasa - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// ParamSurface3D::ParamSurface3D (BOOL bModifiable, CPA_EditorBase *_p_oEditor, ACP_tdxIndex xNbPoints, ACP_tdxIndex xNbElements, const CString _csName, tdeSaveStatus _eStatus) : Shape3D (bModifiable, _p_oEditor, xNbPoints, xNbElements, _csName, _eStatus) { CommonParamSurface3D(); } ParamSurface3D::ParamSurface3D (BOOL bModifiable, CPA_EditorBase *_p_oEditor, ACP_tdxIndex xNbPoints, ACP_tdxIndex xNbElements, CPA_BaseObject *_p_oOwnerFile, const CString _csName, char *_p_cRefPath, tdeSaveStatus _eStatus) : Shape3D(bModifiable, _p_oEditor, xNbPoints, xNbElements, _p_oOwnerFile, _csName, _p_cRefPath, _eStatus) { CommonParamSurface3D(); } ParamSurface3D::ParamSurface3D (BOOL bModifiable, CPA_EditorBase *_p_oEditor, CPA_BaseObject *_p_oOwnerFile, ACP_tdxHandleOfObject _hObject, const CString _csName, char *_p_cRefPath, tdeSaveStatus _eStatus) : Shape3D (bModifiable, _p_oEditor, _p_oOwnerFile, _hObject, _csName, _p_cRefPath, _eStatus) { CommonParamSurface3D(); } ParamSurface3D::~ParamSurface3D() { if(GetStruct()->d_stListOfPoints) free(GetStruct()->d_stListOfPoints); if(GetStruct()->d_stListOfPointsNormals) free(GetStruct()->d_stListOfPointsNormals); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : ParamSurface3D // Date : 97-11 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : Common initialisation // Author : Viorel Preoteasa - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// void ParamSurface3D::CommonParamSurface3D() { m_IndexTriangleNb = 0; GetStruct()->xNbPoints = 0; GetStruct()->d_stListOfPoints = NULL; GetStruct()->d_stListOfPointsNormals = NULL; //ROMTEAM WorldEditor (Cristian Stegaru 12/97) m_bFirstInit = TRUE; //ENDROMTEAM WorldEditor (Cristian Stegaru) } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : Dist // Date : 97-11 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : the distance between two points. // Author : Viorel Preoteasa - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// float ParamSurface3D::Dist(MTH3D_tdstVector &a, MTH3D_tdstVector &b) { return (float)(fabs(a.xX-b.xX)+fabs(a.xY-b.xY)+fabs(a.xZ-b.xZ)); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // Method : NewElement // Date : 97-11 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Description : calculation of object points and triangles from parametrisation. // Author : Viorel Preoteasa - CPA2 ////////////////////////////////////////////////////////////////////////////////////////////////////// // Modification : // Date : // By : ////////////////////////////////////////////////////////////////////////////////////////////////////// ACP_tdxHandleOfElement ParamSurface3D::NewElement(ACP_tdxHandleOfElement hElement, int ns, int nt) { int i,j,k,l,m, Nb_T; float t, s, ds, dt; float s0=0, s1=1, t0=0, t1=1; GEO_tdstGeometricObject *U = GetStruct(); GMT_tdxHandleToGameMaterial hMaterial=NULL; MTH3D_tdstVector *stPoint = (MTH3D_tdstVector *)malloc(ns*nt*sizeof(MTH3D_tdstVector)); int *Pos = (int *)malloc(ns*nt*sizeof(int)); int *New_Point = (int *)malloc(ns*nt*sizeof(int)); ds = (s1-s0)/(ns-1); dt = (t1-t0)/(nt-1); s = s0; for(i=0, k=0, m=0; i0.00001; l++); if(l==k) { New_Point[m] = k; Pos[k] = m; m++; } else Pos[k] = Pos[l]; t += dt; k++; } s += ds; } for(i=0, k=0, Nb_T=0; ixNbPoints) { if(U->d_stListOfPoints) free(U->d_stListOfPoints); U->d_stListOfPoints = (MTH3D_tdstVector *)malloc(m*sizeof(MTH3D_tdstVector)); memset(U->d_stListOfPoints, 0, m*sizeof(MTH3D_tdstVector)); } if(U->d_xListOfElementsTypes[0]) GEO_vGetGameMaterialOfIndexedTriangles (GetStruct(), hElement , &hMaterial); if((m != U->xNbPoints) || (m_IndexTriangleNb!=Nb_T)) { U->d_stListOfElements[0] = NULL; U->d_xListOfElementsTypes[0] = NULL; //ROMTEAM WorldEditor (Cristian Stegaru 12/97) if (m_bFirstInit) { m_bFirstInit = FALSE; hElement = fn_hCreateElementIndexedTriangle(Nb_T, m); } else { GEO_vCreateElementIndexedTriangles (GetStruct(), &hElement, Nb_T, m); // default matérial fn_vSetEngineGameMaterial(hElement,0, fn_hGetDefaultGameMaterial() ); } //ENDROMTEAM WorldEditor (Cristian Stegaru) U->xNbPoints = m; m_IndexTriangleNb = Nb_T; } for(i=0; i