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

750 lines
32 KiB
C++

//ROMTEAM WorldEditor
////////////////////////////////////////////////////////////////////////////////////////
// File : Box3D.cpp: implementation of the Box3D class.
// Author : Cristi Petrescu
// 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 "DlgBox3D.hpp"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Box3D::Box3D
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : constructors to create a new object
// make one for each Geometry3D one. No general constructor :-(
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
Box3D::Box3D (BOOL bModifiable, CPA_EditorBase *_p_oEditor, /*ACP_tdxIndex xNbPoints, ACP_tdxIndex xNbElements,*/ const CString _csName , tdeSaveStatus _eStatus )
: Shape3D (bModifiable, _p_oEditor, 2, 1, _csName , _eStatus)
{
CommonBox3D ();
}
Box3D::Box3D (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, 2, 1, _p_oOwnerFile, _csName, _p_cRefPath, _eStatus)
{
CommonBox3D ();
}
/****????*****///rezolvat ?? ionut
Box3D::Box3D (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)
{
// this seems to be used at load time.
// so do not alter the data!
// CommonBox3D ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Box3D::CommonBox3D( )
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : common implementation for the constructors
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Box3D::CommonBox3D( )
{
// initialise with dummy data
MTH3D_tdstVector stMinMaxPoints [2] = {{ (float) -0.1 , (float) -0.1 , (float) -0.1 } ,
{ (float) 0.1 , (float) 0.1 , (float) 0.1 }};
fn_vSetListOfPoints (2 , stMinMaxPoints);
m_hElement = fn_hCreateElementAlignedBox (1);
fn_eSetAlignedBox (m_hElement, 0 , 0 , 1);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Box3D::~Box3D()
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : destructor, do nothing
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
Box3D::~Box3D()
{
}
/*
//-----------------------------------------------------------------------------
// Class Box3D - _OnKeyDown
// Default: we do not use the message
//-----------------------------------------------------------------------------
BOOL Box3D::_OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
return FALSE;
}
//-----------------------------------------------------------------------------
// Class Box3D - _OnKeyUp
// Default: we do not use the message
//-----------------------------------------------------------------------------
BOOL Box3D::_OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
return FALSE;
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Box3D::_OnMouseMove
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : adjust the box size according to the mouse input
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::_OnMouseMove(UINT nFlags, tdstMousePos * p_stPos, MTH3D_tdstVector * pDeplacement)
{
if (Shape3D::_OnMouseMove (nFlags, p_stPos, pDeplacement))
{
// we make the movement
MTH3D_tdstVector OldSize;
MTH3D_M_vSetVectorElements (& OldSize , GetLength () ,
GetWidth () ,
GetHeight ());
// Calculate the deplacement in the local repere
MTH3D_tdstVector LocalDeplacement;
ConvertVectorGlobalToLocal (& LocalDeplacement ,
HIE_fn_hGetSuperObjectGlobalMatrix (m_pSuperObject -> GetStruct ()) ,
pDeplacement);
MTH3D_tdstVector Point = m_stLocalSelectedPoint;
// Set the new dimensions of the ZDx box object by moving one vertex
if (Point . xX > 0) IncMaxPointX (& LocalDeplacement . xX);
else IncMinPointX (& LocalDeplacement . xX);
if (Point . xY > 0) IncMaxPointY (& LocalDeplacement . xY);
else IncMinPointY (& LocalDeplacement . xY);
if (Point . xZ > 0) IncMaxPointZ (& LocalDeplacement . xZ);
else IncMinPointZ (& LocalDeplacement . xZ);
// Calculate the real move and return it in pDeplacement
MTH3D_tdstVector NewSize;
MTH3D_M_vSetVectorElements (& NewSize , GetLength () ,
GetWidth () ,
GetHeight ());
MTH3D_tdstVector DeltaSize;
MTH3D_M_vSubVector (& DeltaSize , & NewSize , & OldSize);
if (Point . xX < 0) DeltaSize . xX = - DeltaSize.xX;
if (Point . xY < 0) DeltaSize . xY = - DeltaSize.xY;
if (Point . xZ < 0) DeltaSize . xZ = - DeltaSize.xZ;
ConvertVectorLocalToGlobal (pDeplacement ,
HIE_fn_hGetSuperObjectGlobalMatrix (m_pSuperObject -> GetStruct ()) ,
& DeltaSize);
return TRUE;
}
else
return FALSE;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : BBox3D::_OnLButtonDown
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : initialise the resizing
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::_OnLButtonDown(UINT nFlags, tdstMousePos * p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo * p_stObject)
{
if (Shape3D::_OnLButtonDown(nFlags, p_stPos, xIndex, p_stObject))
{
// resizing is allowed
ConvertPointGlobalToLocal (& m_stLocalSelectedPoint ,
HIE_fn_hGetSuperObjectGlobalMatrix (m_pSuperObject -> GetStruct ()) ,
& m_stGlobalSelectedPoint);
MTH3D_M_vSubVector (& m_stLocalSelectedPoint , & m_stLocalSelectedPoint ,
& GetCenter ());
m_stLocalSelectedPoint . xX /= GetLength ();
m_stLocalSelectedPoint . xY /= GetWidth ();
m_stLocalSelectedPoint . xZ /= GetHeight ();
return TRUE;
}
else
return FALSE;
}
/*
//-----------------------------------------------------------------------------
// Class Box3D - _OnLButtonUp
// Default: we do not use the message
//-----------------------------------------------------------------------------
BOOL Box3D::_OnLButtonUp(UINT nFlags, tdstMousePos * p_stPos)
{
return FALSE;
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method : Box3D::_OnLButtonDblClk
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : launch the modal dialog for keyboard editing
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::_OnLButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)
{
int iDlgResult;
HINSTANCE hOldInst = AfxGetResourceHandle();
AfxSetResourceHandle ( ((CPA_DLLBase*)(GetEditor()))->GetDLLIdentity()->hModule );
CDlgBox3D dlgBox3D(this);
iDlgResult = dlgBox3D.DoModal();
AfxSetResourceHandle(hOldInst);
if (iDlgResult == IDOK)
return TRUE;
else
return FALSE;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : GetMinPoint
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : return the 3D coordinates of the point with the min coordinates of the box
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
MTH3D_tdstVector Box3D::GetMinPoint ()
{
MTH3D_tdstVector stMinPoint;
fn_eGetMinPoint (& stMinPoint , m_hElement);
return stMinPoint;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetMinPoint
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the 3D coordinates of the point with the min coordinates of the box
// if the given value is not correct, return FALSE
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetMinPoint (MTH3D_tdstVector * _MinPoint)
{
return fn_eSetMinPoint (_MinPoint , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetMinPointX
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the X coordinate of the point with the min coordinates of the box
// if the given value is not correct, return FALSE
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetMinPointX (GLI_tdxValue * _MinPointX)
{
return fn_eSetMinPointX (_MinPointX , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetMinPointY
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the Y coordinate of the point with the min coordinates of the box
// if the given value is not correct, return FALSE
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetMinPointY (GLI_tdxValue * _MinPointY)
{
return fn_eSetMinPointY (_MinPointY , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetMinPointZ
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the Z coordinate of the point with the min coordinates of the box
// if the given value is not correct, return FALSE
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetMinPointZ (GLI_tdxValue * _MinPointZ)
{
return fn_eSetMinPointZ (_MinPointZ , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : IncMinPointX
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : incremente the X coordinate of the point with the min coordinates of the box
// with a given value
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::IncMinPointX (GLI_tdxValue * _IncX)
{
return fn_eIncMinPointX (_IncX , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : IncMinPointY
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : incremente the Y coordinate of the point with the min coordinates of the box
// with a given value
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::IncMinPointY (GLI_tdxValue * _IncY)
{
return fn_eIncMinPointY (_IncY , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : IncMinPointZ
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : incremente the Z coordinate of the point with the min coordinates of the box
// with a given value
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::IncMinPointZ (GLI_tdxValue * _IncZ)
{
return fn_eIncMinPointZ (_IncZ , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : GetMaxPoint
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : return the 3D coordinates of the point with the max coordinates of the box
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
MTH3D_tdstVector Box3D::GetMaxPoint ()
{
MTH3D_tdstVector stMaxPoint;
fn_eGetMaxPoint (& stMaxPoint , m_hElement);
return stMaxPoint;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetMaxPoint
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the 3D coordinates of the point with the max coordinates of the box
// if the given value is not correct, return FALSE
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetMaxPoint (MTH3D_tdstVector * _MaxPoint)
{
return fn_eSetMaxPoint (_MaxPoint , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetMaxPointX
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the X coordinate of the point with the max coordinates of the box
// if the given value is not correct, return FALSE
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetMaxPointX (GLI_tdxValue * _MaxPointX)
{
return fn_eSetMaxPointX (_MaxPointX , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetMaxPointY
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the Y coordinate of the point with the max coordinates of the box
// if the given value is not correct, return FALSE
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetMaxPointY (GLI_tdxValue * _MaxPointY)
{
return fn_eSetMaxPointY (_MaxPointY , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetMaxPointZ
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the Z coordinate of the point with the max coordinates of the box
// if the given value is not correct, return FALSE
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetMaxPointZ (GLI_tdxValue * _MaxPointZ)
{
return fn_eSetMaxPointZ (_MaxPointZ , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : IncMaxPointX
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : incremente the X coordinate of the point with the Max coordinates of the box
// with a given value
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::IncMaxPointX (GLI_tdxValue * _IncX)
{
return fn_eIncMaxPointX (_IncX , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : IncMaxPointY
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : incremente the Y coordinate of the point with the Max coordinates of the box
// with a given value
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::IncMaxPointY (GLI_tdxValue * _IncY)
{
return fn_eIncMaxPointY (_IncY , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : IncMaxPointZ
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : incremente the Z coordinate of the point with the Max coordinates of the box
// with a given value
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::IncMaxPointZ (GLI_tdxValue * _IncZ)
{
return fn_eIncMaxPointZ (_IncZ , m_hElement) == C_Ok;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : GetCenter
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : return the 3D coordinates of the center of the box
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
MTH3D_tdstVector Box3D::GetCenter ()
{
MTH3D_tdstVector stMinPoint = GetMinPoint ();
MTH3D_tdstVector stMaxPoint = GetMaxPoint ();
MTH3D_tdstVector stCenter;
MTH3D_M_vAddVector (& stCenter , & stMinPoint , & stMaxPoint);
MTH3D_M_vMulScalarVector (& stCenter , MTH_M_xFloatToReal ((float) 0.5) , & stCenter);
return stCenter;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetCenter
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the center of the box (in fact, the middle of the min point and the max point)
// dimensions are unchanged
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Box3D::SetCenter (MTH3D_tdstVector * _Vertex)
{
SetCenterX (MTH3D_M_xGetXofVector (_Vertex));
SetCenterY (MTH3D_M_xGetYofVector (_Vertex));
SetCenterZ (MTH3D_M_xGetZofVector (_Vertex));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetCenterX
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the X coordinate of the center of the box (in fact, the middle of the min point and the max point)
// dimensions are unchanged
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Box3D::SetCenterX (GLI_tdxValue _X)
{
GLI_tdxValue MinPointX = _X - GetLength () / 2;
GLI_tdxValue MaxPointX = _X + GetLength () / 2;
fn_eSetMinPointX (& MinPointX , m_hElement);
fn_eSetMaxPointX (& MaxPointX , m_hElement);
fn_eSetMinPointX (& MinPointX , m_hElement); // To be sure (because we must have Min <= Max)
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetCenterY
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the Y coordinate of the center of the box (in fact, the middle of the min point and the max point)
// dimensions are unchanged
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Box3D::SetCenterY (GLI_tdxValue _Y)
{
GLI_tdxValue MinPointY = _Y - GetWidth () / 2;
GLI_tdxValue MaxPointY = _Y + GetWidth () / 2;
fn_eSetMinPointY (& MinPointY , m_hElement);
fn_eSetMaxPointY (& MaxPointY , m_hElement);
fn_eSetMinPointY (& MinPointY , m_hElement); // To be sure (because we must have Min <= Max)
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetCenterZ
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the Z coordinate of the center of the box (in fact, the middle of the min point and the max point)
// dimensions are unchanged
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
void Box3D::SetCenterZ (GLI_tdxValue _Z)
{
GLI_tdxValue MinPointZ = _Z - GetHeight () / 2;
GLI_tdxValue MaxPointZ = _Z + GetHeight () / 2;
fn_eSetMinPointZ (& MinPointZ , m_hElement);
fn_eSetMaxPointZ (& MaxPointZ , m_hElement);
fn_eSetMinPointZ (& MinPointZ , m_hElement); // To be sure (because we must have Min <= Max)
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : GetLength
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : return the length of the box
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
GLI_tdxValue Box3D::GetLength ()
{
return MTH3D_M_xGetXofVector (& GetMaxPoint ()) - MTH3D_M_xGetXofVector (& GetMinPoint ());
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : GetWidth
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : return the width of the box
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
GLI_tdxValue Box3D::GetWidth ()
{
return MTH3D_M_xGetYofVector (& GetMaxPoint ()) - MTH3D_M_xGetYofVector (& GetMinPoint ());
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : GetHeight
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : return the height of the box
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
GLI_tdxValue Box3D::GetHeight ()
{
return MTH3D_M_xGetZofVector (& GetMaxPoint ()) - MTH3D_M_xGetZofVector (& GetMinPoint ());
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetLength
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the length of the box
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetLength (GLI_tdxValue * _Length)
{
BOOL Correct;
if (! (Correct = (* _Length >= 0.))) * _Length = 0.;
GLI_tdxValue MinPointX = MTH3D_M_xGetXofVector (& GetCenter ()) - * _Length / 2;
GLI_tdxValue MaxPointX = MTH3D_M_xGetXofVector (& GetCenter ()) + * _Length / 2;
SetMinPointX (& MinPointX);
SetMaxPointX (& MaxPointX);
return Correct;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetWidth
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the width of the box
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetWidth (GLI_tdxValue * _Width)
{
BOOL Correct;
if (! (Correct = (* _Width >= 0.))) * _Width = 0.;
GLI_tdxValue MinPointY = MTH3D_M_xGetYofVector (& GetCenter ()) - * _Width / 2;
GLI_tdxValue MaxPointY = MTH3D_M_xGetYofVector (& GetCenter ()) + * _Width / 2;
SetMinPointY (& MinPointY);
SetMaxPointY (& MaxPointY);
return Correct;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method :Box3D : SetHeight
// Date : 97.11
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description : set the height of the box
// Author : Cristi Petrescu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification :
// Date :
// By :
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL Box3D::SetHeight (GLI_tdxValue * _Height)
{
BOOL Correct;
if (! (Correct = (* _Height >= 0.))) * _Height = 0.;
GLI_tdxValue MinPointZ = MTH3D_M_xGetZofVector (& GetCenter ()) - * _Height / 2;
GLI_tdxValue MaxPointZ = MTH3D_M_xGetZofVector (& GetCenter ()) + * _Height / 2;
SetMinPointZ (& MinPointZ);
SetMaxPointZ (& MaxPointZ);
return Correct;
}