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

229 lines
7.8 KiB
C++

//ROMTEAM WorldEditor
////////////////////////////////////////////////////////////////////////////////////////
// File : ITObject.cpp: implementation of the ITObject class.
// Author : Ionut Grozea
// 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
#include "3dinterf.hpp"
#include "DlgObject.h"
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : ITObject3D::ITObject3D
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : constructor to create a new object
// Author : Ionut Grozea
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification : add _csName in constructor
// Date : 97.12
// By : Cristian Stegaru
//////////////////////////////////////////////////////////////////////////////////////////////////////
ITObject3D::ITObject3D (CPA_EditorBase *_p_oEditor ,int vi_x ,int vi_y , float(* vf_Ver )[3] , WORD (*vf_IT)[3] , const CString _csName, tdeSaveStatus _eStatus)
: Shape3D (TRUE , _p_oEditor, vi_x*vi_y ,1 , _csName, _eStatus)
{
m_vi_x = vi_x ;
m_vi_y = vi_y;
CommonITObject3D ( vi_x , vi_y, vf_Ver , vf_IT);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : ITObject3D::CreateITObject3D
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set vertices of ITObject3D
// Author : Ionut Grozea
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void ITObject3D::CreateITObject3D(int vi_x ,int vi_y, float(* vf_Ver )[3] , WORD (*vf_IT)[3])
{
int i;
MTH3D_tdstVector *pa13_stPoint = new MTH3D_tdstVector[vi_x*vi_y];
for (i = 0 ; i<vi_x*vi_y; i++)
MTH3D_M_vSetVectorElements ( pa13_stPoint+i, vf_Ver[i][0]*10, vf_Ver[i][2]*10, vf_Ver[i][1]*10);
fn_vSetListOfPoints(vi_y*vi_x , pa13_stPoint);
delete[] pa13_stPoint;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : ITObject3D::CommonITObject3D
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set texture vertices of ITObject3D
// Author : Ionut Grozea
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void ITObject3D::CommonITObject3D(int vi_x ,int vi_y, float(* vf_Ver )[3] , WORD (*vf_IT)[3] )
{
int i,k,j;
CreateITObject3D( vi_x , vi_y, vf_Ver , vf_IT);
ACP_tdxHandleOfElement hElement = fn_hCreateElementIndexedTriangle((vi_x-1)*(vi_y-1)*2 , vi_x*vi_y);
for(i=k=0; i<vi_x; i++)
{
for(j=0; j<vi_y; j++ , k++)
{
ACP_tdst2DUVValues q = { (float)i/(vi_x-1),(float)j/(vi_y-1) };
GEO_vSetUVOfIndexedTriangles(GetStruct(), hElement, k, &q);
}
}
for (i = 0 ; i<(vi_x-1)*(vi_y-1)*2 ; i++)
{
fn_eSetIndexedTriangle ( hElement, i, vf_IT[i][0], vf_IT[i][1], vf_IT[i][2]);
GEO_vSetIndexedUVOfFaceOfIndexedTriangles( GetStruct(), hElement , i, vf_IT[i][0], vf_IT[i][1], vf_IT[i][2]);
}
fn_vInitElementSection( m_hElement );
GEO_vEndCreateObject ( GetStruct() );
GEO_vCreateObjectListOfPointsMaterial(GetStruct());
GEO_xCreateObjectListOfEdges(GetStruct());
}
ITObject3D::~ITObject3D()
{
}
ACP_tdxHandleOfElement ITObject3D::GetHElement()
{
return m_hElement;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :ITObject3D::_OnLButtonDblClk
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : launch the modal dialog
// Author : Ionut Grozea
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ITObject3D::_OnLButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)
{
HINSTANCE hOldInst = AfxGetResourceHandle();
AfxSetResourceHandle ( ((CPA_DLLBase*)(GetEditor()))->GetDLLIdentity()->hModule );
//problems
// CDlgObject dlg(this) ;
// if ( dlg.DoModal()==IDOK)
// {
// SetRadius(dlg.m_fRadius);
// SetSamplingRate(dlg.m_Nx, dlg.m_Ny);
// }
AfxSetResourceHandle(hOldInst);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :ITObject3D::SetScaleX
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set scale x of ITObject3D
// Author : Ionut Grozea
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void ITObject3D::SetScaleX(float fScale)
{
int i;
MTH3D_tdstVector* p_stPoint = new MTH3D_tdstVector;
for ( i=0 ; i<m_vi_x*m_vi_y ; i++)
{
fn_vGetPoint( i, p_stPoint);
p_stPoint->xX = (p_stPoint->xX)*fScale;
fn_vSetPoint (i , p_stPoint);
}
delete[] p_stPoint;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :ITObject3D::SetScaleY
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set scale y of ITObject3D
// Author : Ionut Grozea
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void ITObject3D::SetScaleY(float fScale)
{
int i;
MTH3D_tdstVector* p_stPoint = new MTH3D_tdstVector;
for ( i=0 ; i<m_vi_x*m_vi_y ; i++)
{
fn_vGetPoint( i, p_stPoint);
p_stPoint->xY = (p_stPoint->xY)*fScale;
fn_vSetPoint (i , p_stPoint);
}
delete[] p_stPoint;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :ITObject3D::SetScaleY
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set scale y of ITObject3D
// Author : Ionut Grozea
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void ITObject3D::SetScaleZ(float fScale)
{
int i;
MTH3D_tdstVector* p_stPoint = new MTH3D_tdstVector;
for ( i=0 ; i<m_vi_x*m_vi_y ; i++)
{
MTH3D_tdstVector* p_stPoint = new MTH3D_tdstVector;
fn_vGetPoint( i, p_stPoint);
p_stPoint->xZ = (p_stPoint->xZ)*fScale;
fn_vSetPoint (i , p_stPoint);
}
delete[] p_stPoint;
}