Add rayman2 source files
This commit is contained in:
764
Rayman_X/cpa/tempgrp/T3D/src/CPA_Grid.cpp
Normal file
764
Rayman_X/cpa/tempgrp/T3D/src/CPA_Grid.cpp
Normal file
@@ -0,0 +1,764 @@
|
||||
/*=========================================================================
|
||||
*
|
||||
* CPA_Grid.cpp : Implementation file.
|
||||
*
|
||||
*
|
||||
* Version 1.0
|
||||
* Creation date
|
||||
* Revision date
|
||||
*
|
||||
* MT
|
||||
*=======================================================================*/
|
||||
|
||||
#ifdef ACTIVE_EDITOR
|
||||
|
||||
#include "stdafx.h"
|
||||
#define HieFriend
|
||||
#include "ACP_Base.h"
|
||||
|
||||
#include "incvig.h"
|
||||
#include "incGam.h"
|
||||
|
||||
#include "Itf.h"
|
||||
|
||||
|
||||
#include "CPA_Grid.hpp"
|
||||
|
||||
/*****************************************************************************
|
||||
MACROS
|
||||
*****************************************************************************/
|
||||
#define M_GetLSTWorld() (((DEV_MultiDevice3D*)GetDevice())->GetWorld())
|
||||
#define M_GetLSTViewPort() ((DEV_ViewPort3D*)((DEV_MultiDevice3D*)GetDevice())->GetFocusDevice()->GetViewPort())
|
||||
// ALX
|
||||
#define M_GetLSTCameraInterface() (M_GetLSTViewPort()->GetCameraInterface())
|
||||
#define M_GetLSTCamera() (M_GetLSTViewPort()->GetCamera())
|
||||
// End ALX
|
||||
#define M_GetLSTEvtEditor() (m_p_oDevice->GetInterface())
|
||||
#define M_GetFocusDevice() (GetDevice()->GetFocusDevice())
|
||||
#define M_RedrawAll() (M_GetLSTEvtEditor()->fn_vUpdateAll(E_mc_JustDraw))
|
||||
#define MAKE_RGB(r,g,b) (((r&0xff)<<16)+((g&0xff)<<8)+(b&0xff))
|
||||
|
||||
/*****************************************************************************
|
||||
CONSTANTS
|
||||
*****************************************************************************/
|
||||
static long C_lGridColor = MAKE_RGB(255,255,255); // Color of grid
|
||||
static long C_lSelColor = MAKE_RGB(0,128,0); // Color of box selection
|
||||
|
||||
#define C_xNbLines 5
|
||||
#define C_xLineWidth MTH_M_xFloatToReal(1000)
|
||||
|
||||
#define C_xDefaultSphereRadius MTH_M_xFloatToReal(0.1)
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------------------------------------------------
|
||||
CPA_Grid::CPA_Grid(CPA_KeyActionConfiguration *p_oKeyboard, DEV_MultiDevice3D *p_oDevice /*=NULL*/) : CPA_Contact(p_oDevice)
|
||||
{
|
||||
m_p_oMultiDevice = NULL;
|
||||
m_wNbOfColumns = 0;
|
||||
m_wNbOfRows = 0;
|
||||
m_xMaxSphereBoxRadius = 0;
|
||||
m_xGridSquareSize = 0;
|
||||
m_xFirstCenterX = 0;
|
||||
m_xFirstCenterZ = 0;
|
||||
m_xLastCenterX = 0;
|
||||
m_xLastCenterZ = 0;
|
||||
m_bShowSelection = TRUE;
|
||||
m_bShowGrid = TRUE;
|
||||
|
||||
// Keys
|
||||
m_p_oKeyboard = p_oKeyboard;
|
||||
m_bNavigationMode = FALSE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Create grid for receiving current World
|
||||
// ----------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vPositionWorldOnGrid(void)
|
||||
{
|
||||
if(M_GetLSTWorld() == NULL)
|
||||
return;
|
||||
|
||||
m_fn_vComputeRowColumn();
|
||||
if(!m_wNbOfRows || !m_wNbOfColumns)
|
||||
return;
|
||||
|
||||
m_fn_vComputeMaxSphereBoxRadius();
|
||||
m_fn_vComputeFirstAndLastCenters();
|
||||
m_fn_vComputeObjectsPosition();
|
||||
m_fn_vCenterOnGrid();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Compute the position of each objects, and move them.
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vComputeObjectsPosition(void)
|
||||
{
|
||||
CPA_SuperObject *p_oEdList = M_GetLSTWorld() -> GetRoot();
|
||||
POSITION stPos = p_oEdList -> GetHeadPosition();
|
||||
CPA_SuperObject *p_oEdChild = p_oEdList -> GetSuperObjectFirstChild();
|
||||
short wRow = 0;
|
||||
short wColumn = 0;
|
||||
|
||||
while(p_oEdChild)
|
||||
{
|
||||
POS_tdxHandleToPosition _hMatrix;
|
||||
GLI_tdstSphere *p_stSphere = NULL;
|
||||
MTH3D_tdstVector st3DCenter,st3DPosition;
|
||||
MTH3D_tdstVector stTranslation;
|
||||
|
||||
m_fn_vConvertRowColumnTo3D(wRow, wColumn, &st3DPosition);
|
||||
_hMatrix = HIE_fn_hGetSuperObjectMatrix(p_oEdChild->GetStruct());
|
||||
POS_fn_vSetIdentityMatrix(_hMatrix);
|
||||
|
||||
POS_fn_vGetTranslationVector(_hMatrix, &stTranslation);
|
||||
// First, centred with sphere box center
|
||||
//p_stSphere = HIE_fn_hGetSuperObjectSphere(p_oEdChild->GetStruct());
|
||||
if( m_fn_bGetSphereBoxCenter( p_oEdChild, &st3DCenter ) )
|
||||
{
|
||||
MTH3D_M_vSubVector(&stTranslation, &stTranslation, &st3DCenter);
|
||||
}
|
||||
// Second, place the object
|
||||
MTH3D_M_vAddVector(&stTranslation, &stTranslation, &st3DPosition);
|
||||
|
||||
POS_fn_vSetTranslationVector(_hMatrix, &stTranslation);
|
||||
|
||||
// Force the absolute matrix to be recalculated
|
||||
POS_fn_vNormalizeMatrix(_hMatrix);
|
||||
|
||||
wColumn = (wColumn + 1) % m_wNbOfColumns;
|
||||
if(wColumn == 0)
|
||||
wRow++;
|
||||
|
||||
p_oEdChild = p_oEdList->GetSuperObjectNextChild( p_oEdChild );
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================================================
|
||||
//
|
||||
// SPECIAL METHODS
|
||||
//
|
||||
//======================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Reset content
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vResetContent(void)
|
||||
{
|
||||
// No grid
|
||||
m_wNbOfRows = 0; // No rows
|
||||
m_wNbOfColumns = 0; // No columns
|
||||
m_bShowSelection = FALSE; // No current selection
|
||||
m_xMaxSphereBoxRadius = 0; // No object, so no max sphere box radius
|
||||
}
|
||||
|
||||
//======================================================================================
|
||||
//
|
||||
// GRID
|
||||
//
|
||||
//======================================================================================
|
||||
|
||||
//======================================================================================
|
||||
// COMPUTING
|
||||
//======================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Convert a row and column to a 3D position. (square center)
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vConvertRowColumnTo3D(short _wRow, short _wColumn, MTH3D_tdstVector *_p_stVxCenter)
|
||||
{
|
||||
MTH3D_M_vSetVectorElements(_p_stVxCenter, - m_xFirstCenterX + MTH_M_xMul(m_xGridSquareSize,_wColumn)
|
||||
, 0
|
||||
, m_xFirstCenterZ - MTH_M_xMul(m_xGridSquareSize,_wRow));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// compute center of square of given SuperObject
|
||||
// ----------------------------------------------------------------------------
|
||||
/*
|
||||
void CPA_Grid::m_fn_vComputeCenterOfSuperObject(CPA_SuperObject *_p_SprObj, MTH3D_tdstVector *_p_stVxCenter)
|
||||
{
|
||||
short wRow, wColumn;
|
||||
|
||||
// Compute row and column of selection
|
||||
m_fn_vComputeGridPosOfSuperObject(_p_SprObj, &wRow, &wColumn);
|
||||
m_fn_vConvertRowColumnTo3D(wRow, wColumn, _p_stVxCenter);
|
||||
}
|
||||
*/
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Compute the m_xMaxSphereBoxRadius that is the maximum sphere box radius of all
|
||||
// the displayed objects. It is used to compute the size of a rectangle of the grid.
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vComputeMaxSphereBoxRadius(void)
|
||||
{
|
||||
CPA_SuperObject *p_oEdList = M_GetLSTWorld()->GetRoot();
|
||||
|
||||
m_xMaxSphereBoxRadius = 0;
|
||||
CPA_SuperObject *p_oEdChild = p_oEdList->GetSuperObjectFirstChild();
|
||||
while(p_oEdChild)
|
||||
{
|
||||
MTH_tdxReal xRadius = m_fn_xGetSphereBoxRadius(p_oEdChild);
|
||||
m_xMaxSphereBoxRadius = MTH_M_xMax( m_xMaxSphereBoxRadius, xRadius);
|
||||
p_oEdChild = p_oEdList->GetSuperObjectNextChild( p_oEdChild );
|
||||
}
|
||||
m_xGridSquareSize = MTH_M_xAdd(m_xMaxSphereBoxRadius,m_xMaxSphereBoxRadius);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Compute the sphere box radius of an object
|
||||
//--------------------------------------------------------------------------------------
|
||||
MTH_tdxReal CPA_Grid::m_fn_xGetSphereBoxRadius(CPA_SuperObject *_p_oSprObj)
|
||||
{
|
||||
MTH_tdxReal xResult = 0;
|
||||
CPA_BaseObject *p_oObject = _p_oSprObj -> GetObject();
|
||||
|
||||
if( p_oObject )
|
||||
{
|
||||
MTH3D_tdstVector stCenter;
|
||||
|
||||
ACP_tdxHandleOfObject hObj = ((CPA_ObjectDLLBase*)p_oObject -> GetEditor()) -> fn_hGetBoundingVolume( p_oObject );
|
||||
if( hObj )
|
||||
//ANNECY TQ 22/06/98{
|
||||
GEO_fn_vGetInfoFromGeometricSphere( &stCenter, &xResult, hObj );
|
||||
//ENDANNECY TQ}
|
||||
|
||||
}
|
||||
return xResult;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Compute the sphere box center of an object
|
||||
//--------------------------------------------------------------------------------------
|
||||
BOOL CPA_Grid::m_fn_bGetSphereBoxCenter(CPA_SuperObject *_p_oSprObj, MTH3D_tdstVector *_p_stCenter)
|
||||
{
|
||||
CPA_BaseObject *p_oObject = _p_oSprObj -> GetObject();
|
||||
|
||||
if( p_oObject )
|
||||
{
|
||||
MTH_tdxReal xResult;
|
||||
|
||||
ACP_tdxHandleOfObject hObj = ((CPA_ObjectDLLBase*)p_oObject -> GetEditor()) -> fn_hGetBoundingVolume( p_oObject );
|
||||
if( hObj )
|
||||
{
|
||||
//ANNECY TQ 22/06/98{
|
||||
GEO_fn_vGetInfoFromGeometricSphere( _p_stCenter, &xResult, hObj );
|
||||
//ENDANNECY TQ}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Compute distances between center of grid and first and last object in grid.
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vComputeFirstAndLastCenters(void)
|
||||
{
|
||||
// First center
|
||||
m_xFirstCenterX = MTH_M_xSub(MTH_M_xDiv(MTH_M_xMul(m_wNbOfColumns, m_xGridSquareSize), 2), m_xMaxSphereBoxRadius);
|
||||
m_xFirstCenterZ = MTH_M_xSub(MTH_M_xDiv(MTH_M_xMul(m_wNbOfRows, m_xGridSquareSize), 2), m_xMaxSphereBoxRadius);
|
||||
|
||||
// Last center
|
||||
m_xLastCenterX = - m_xFirstCenterX + (MTH_M_xMul(m_xGridSquareSize, (m_wNbOfColumns - 1)));
|
||||
m_xLastCenterZ = m_xFirstCenterZ - (MTH_M_xMul(m_xGridSquareSize, (m_wNbOfRows - 1)));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Compute number of row and columns
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vComputeRowColumn(void)
|
||||
{
|
||||
int iCount = M_GetLSTWorld() -> GetRoot() -> GetCount();
|
||||
/*
|
||||
m_wNbOfRows = m_wNbOfColumns = 0;
|
||||
if(iCount)
|
||||
{
|
||||
m_wNbOfRows = ((short) sqrt((double) iCount)) + 1;
|
||||
m_wNbOfColumns = m_wNbOfRows;
|
||||
}
|
||||
*/
|
||||
if( iCount > 0 )
|
||||
{
|
||||
m_wNbOfRows = (short)floor(sqrt((double)iCount));
|
||||
m_wNbOfColumns = iCount / m_wNbOfRows ;
|
||||
|
||||
while( m_wNbOfColumns * m_wNbOfRows < iCount )
|
||||
{
|
||||
if( m_wNbOfRows < m_wNbOfColumns )
|
||||
m_wNbOfRows++;
|
||||
else
|
||||
m_wNbOfColumns++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_wNbOfRows = m_wNbOfColumns = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Reset the selection
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vCompute3DPosOfSuperObject(CPA_SuperObject *_p_SprObj,MTH_tdxReal *_p_xLeftX, MTH_tdxReal *_p_xTopZ,
|
||||
MTH_tdxReal *_p_xRightX, MTH_tdxReal *_p_xBottomZ,
|
||||
MTH_tdxReal *_p_xXL, MTH_tdxReal *_p_xZL)
|
||||
{
|
||||
MTH_tdxReal xLeftX = - m_xFirstCenterX - m_xMaxSphereBoxRadius;
|
||||
MTH_tdxReal xTopZ = m_xFirstCenterZ + m_xMaxSphereBoxRadius;
|
||||
MTH_tdxReal xRightX = m_xLastCenterX + m_xMaxSphereBoxRadius;
|
||||
MTH_tdxReal xBottomZ = m_xLastCenterZ - m_xMaxSphereBoxRadius;
|
||||
short wSelRow, wSelColumn;
|
||||
|
||||
// Compute row and column of selection
|
||||
m_fn_vComputeGridPosOfSuperObject(_p_SprObj, &wSelRow, &wSelColumn);
|
||||
// Compute coordinates of selection box
|
||||
*_p_xLeftX = MTH_M_xAdd(xLeftX, MTH_M_xMul(wSelColumn, m_xGridSquareSize));
|
||||
*_p_xTopZ = MTH_M_xSub(xTopZ, MTH_M_xMul(wSelRow, m_xGridSquareSize));
|
||||
*_p_xRightX = MTH_M_xAdd(*_p_xLeftX, m_xGridSquareSize);
|
||||
*_p_xBottomZ = MTH_M_xSub(*_p_xTopZ, m_xGridSquareSize);
|
||||
|
||||
*_p_xZL = MTH_M_xDiv(m_xGridSquareSize,C_xLineWidth);
|
||||
*_p_xXL = MTH_M_xDiv(m_xGridSquareSize,C_xLineWidth);
|
||||
|
||||
*_p_xLeftX += MTH_M_xMul(*_p_xXL,C_xNbLines);
|
||||
*_p_xTopZ -= MTH_M_xMul(*_p_xZL,C_xNbLines);
|
||||
*_p_xRightX -= MTH_M_xMul(*_p_xXL,C_xNbLines);
|
||||
*_p_xBottomZ += MTH_M_xMul(*_p_xZL,C_xNbLines);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// search column and row of given SuperObject
|
||||
// ----------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vComputeGridPosOfSuperObject(CPA_SuperObject *_p_SprObj,short *_p_wRow,short *_p_wColumn)
|
||||
{
|
||||
CPA_SuperObject *p_oEdList = M_GetLSTWorld()->GetRoot();
|
||||
CPA_SuperObject *p_oChild = p_oEdList->GetSuperObjectFirstChild();
|
||||
BOOL bFound = FALSE;
|
||||
|
||||
*_p_wRow = 0;
|
||||
*_p_wColumn = 0;
|
||||
while(p_oChild && !bFound)
|
||||
{
|
||||
if(p_oChild == _p_SprObj)
|
||||
bFound = TRUE;
|
||||
else
|
||||
{
|
||||
*_p_wColumn = (*_p_wColumn + 1) % m_wNbOfColumns;
|
||||
if(*_p_wColumn == 0)
|
||||
(*_p_wRow)++;
|
||||
}
|
||||
p_oChild = p_oEdList->GetSuperObjectNextChild(p_oChild);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// To see all the grid in the window.
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vCenterOnGrid(void)
|
||||
{
|
||||
CPA_CameraDLLBase *p_oCameraInterface = M_GetLSTCameraInterface();
|
||||
CPA_BaseObject *p_oCamera = M_GetLSTCamera();
|
||||
MTH_tdxReal xRadius = MTH_M_xMul(m_wNbOfColumns, m_xMaxSphereBoxRadius);
|
||||
MTH_tdxReal xAlphaX,xRatio;
|
||||
CPA_CameraCoords CameraCoords;
|
||||
|
||||
GLI_xGetCameraAspectAndRatio((GLI_tdxHandleToCamera)p_oCamera->GetData(),&xAlphaX,&xRatio);
|
||||
|
||||
/*
|
||||
float fD1 = MTH_M_xRealToFloat(MTH_M_xDiv(xRadius, MTH_M_xTan(MTH_M_xDiv(xAlphaX,2))));
|
||||
float fD2 = MTH_M_xRealToFloat(MTH_M_xDiv(xRadius, MTH_M_xTan(MTH_M_xDiv(MTH_M_xMul(xAlphaX,xRatio),2))));
|
||||
|
||||
xRadius = ((fD1 > fD2)? fD1 : fD2);
|
||||
*/
|
||||
// target camera
|
||||
CameraCoords . SetXYZ( 0, 0, 0 );
|
||||
CameraCoords . SetAxisSystem( WorldCoordinates );
|
||||
p_oCameraInterface -> SetTargetPoint( p_oCamera , &CameraCoords );
|
||||
p_oCameraInterface -> SetTargetType (p_oCamera , tPoint );
|
||||
// position camera
|
||||
CameraCoords . SetXYZ( 0, -xRadius, 0 );
|
||||
CameraCoords . SetAxisSystem( WorldCoordinates );
|
||||
p_oCameraInterface -> SetPosition( p_oCamera , &CameraCoords );
|
||||
|
||||
// Free camera
|
||||
p_oCameraInterface -> SetTargetType( p_oCamera , tNone );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Center on current selected object.
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vCenterOnSuperObject(CPA_SuperObject *_p_SprObj)
|
||||
{
|
||||
/*
|
||||
MTH3D_tdstVector stVertex;
|
||||
|
||||
CPA_Camera *p_oCamera = M_GetLSTCamera();
|
||||
MTH_tdxReal xAlphaX,xRatio;
|
||||
|
||||
GLI_xGetCameraAspectAndRatio(p_oCamera->GetEngineCamera(),&xAlphaX,&xRatio);
|
||||
GLI_tdstSphere *p_stSphere = HIE_fn_hGetSuperObjectSphere(_p_SprObj->GetStruct());
|
||||
MTH_tdxReal xRadius = (p_stSphere ? p_stSphere->xRadius : C_xDefaultSphereRadius );
|
||||
float fD1 = MTH_M_xRealToFloat(MTH_M_xDiv(xRadius, MTH_M_xTan(MTH_M_xDiv(xAlphaX,2))));
|
||||
float fD2 = MTH_M_xRealToFloat(MTH_M_xDiv(xRadius, MTH_M_xTan(MTH_M_xDiv(MTH_M_xMul(xAlphaX,xRatio),2))));
|
||||
|
||||
xRadius = ((fD1 > fD2)? fD1 : fD2);
|
||||
|
||||
POS_fn_vGetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(_p_SprObj->GetStruct()), &stVertex);
|
||||
MTH3D_M_vGetVectorElements(&p_oCamera->m_fPosX, &p_oCamera->m_fPosY, &p_oCamera->m_fPosZ, &stVertex);
|
||||
p_oCamera->m_fPosY = -xRadius;
|
||||
p_oCamera->SetMode(p_oCamera->Free);
|
||||
p_oCamera->UpdateAbsolute();
|
||||
*/
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// search square picked
|
||||
// ----------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vComputePickedSquare(GLI_tdst2DVertex *_p_st2DMousePos, short *_p_wRow, short *_p_wColumn)
|
||||
{
|
||||
MTH3D_tdstVector st3DMouse ;
|
||||
MTH_tdxReal xLeftX = - m_xFirstCenterX - m_xMaxSphereBoxRadius;
|
||||
MTH_tdxReal xTopZ = m_xFirstCenterZ + m_xMaxSphereBoxRadius;
|
||||
|
||||
// compute clipping point on grid plane
|
||||
m_fn_vGetPosOnGridPlane(M_GetLSTViewPort()->m_hDisplayDevice,M_GetLSTViewPort()->m_hDisplayViewport,_p_st2DMousePos,&st3DMouse);
|
||||
|
||||
*_p_wRow = 0;
|
||||
*_p_wColumn = 0;
|
||||
|
||||
// compute column
|
||||
while( st3DMouse.xX > xLeftX )
|
||||
{
|
||||
(*_p_wColumn)++;
|
||||
xLeftX += m_xGridSquareSize;
|
||||
}
|
||||
|
||||
(*_p_wColumn)--;
|
||||
|
||||
// compute row
|
||||
while( st3DMouse.xZ < xTopZ )
|
||||
{
|
||||
(*_p_wRow)++;
|
||||
xTopZ -= m_xGridSquareSize;
|
||||
}
|
||||
|
||||
(*_p_wRow)--;
|
||||
|
||||
if( (*_p_wRow <0) || (*_p_wRow>=m_wNbOfRows) || (*_p_wColumn<0) || (*_p_wColumn>=m_wNbOfColumns))
|
||||
// out of grid
|
||||
*_p_wRow = *_p_wColumn = -1;
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// search point picked on grid plane
|
||||
// ----------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vGetPosOnGridPlane(GLD_tdhDevice hDev, GLD_tdhViewport hVp,
|
||||
GLI_tdst2DVertex *_p_st2DMousePos,
|
||||
MTH3D_tdstVector *p_stDstVertex)
|
||||
{
|
||||
GLD_tdstViewportAttributes stViewAttrib;
|
||||
|
||||
if(GLD_bGetViewportAttributes( hDev, hVp, &stViewAttrib ))
|
||||
{
|
||||
GLI_tdstSpecificAttributesFor3D *p_stSpecAttrib3D = (GLI_tdstSpecificAttributesFor3D *)stViewAttrib.p_vSpecificToXD;
|
||||
POS_tdstCompletePosition stMatrix, stInvMatrix ;
|
||||
MTH3D_tdstVector stPosCam,stPosClip;
|
||||
GLI_tdstEqPlan stPlan;
|
||||
|
||||
POS_fn_vSetIdentityMatrix(&stInvMatrix);
|
||||
POS_fn_vSetIdentityMatrix(&stMatrix);
|
||||
// get picked position
|
||||
PIC_vMouse3DScreen(hDev, hVp, _p_st2DMousePos, &stPosClip);
|
||||
|
||||
// get camera position
|
||||
GLI_xGetCameraMatrix ( p_stSpecAttrib3D->p_stCam , &stMatrix );
|
||||
POS_fn_vInvertMatrix( &stInvMatrix , &stMatrix );
|
||||
POS_fn_vGetTranslationVector( &stInvMatrix, &stPosCam );
|
||||
// get grid plane equation
|
||||
GLI_vDefinePlanEquation( &stPlan , MTH_M_xFloatToReal(0.0) ,
|
||||
MTH_M_xFloatToReal(1.0) ,
|
||||
MTH_M_xFloatToReal(0.0) ,
|
||||
MTH_M_xFloatToReal(0.0) );
|
||||
// compute intersection
|
||||
GLI_bIntersectionPlanDroite( &stPlan , &stPosCam, &stPosClip, p_stDstVertex) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//======================================================================================
|
||||
// DISPLAY
|
||||
//======================================================================================
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Display grid and selection
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vDisplay(GLD_tdstViewportAttributes *_p_stViewAttrib)
|
||||
{
|
||||
// There's not gris yet
|
||||
if (!m_wNbOfRows || !m_wNbOfColumns || (!m_bShowGrid && !m_bShowSelection))
|
||||
return;
|
||||
|
||||
// Load camera matrix
|
||||
POS_tdstCompletePosition stMatrix;
|
||||
POS_fn_vSetIdentityMatrix(&stMatrix);
|
||||
|
||||
GLI_xGetCameraMatrix(((GLI_tdstSpecificAttributesFor3D*)(_p_stViewAttrib->p_vSpecificToXD))->p_stCam,&stMatrix);
|
||||
GLI_xLoadMatrix(&stMatrix);
|
||||
|
||||
if(m_bShowGrid)
|
||||
m_fn_vDisplayGrid(_p_stViewAttrib);
|
||||
if(m_bShowSelection)
|
||||
m_fn_vDisplaySelection(_p_stViewAttrib);
|
||||
GLI_xPopMatrix();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Display grid
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vDisplayGrid(GLD_tdstViewportAttributes *_p_stViewAttrib)
|
||||
{
|
||||
MTH_tdxReal xLeftX = - m_xFirstCenterX - m_xMaxSphereBoxRadius;
|
||||
MTH_tdxReal xTopZ = m_xFirstCenterZ + m_xMaxSphereBoxRadius;
|
||||
MTH_tdxReal xRightX = m_xLastCenterX + m_xMaxSphereBoxRadius;
|
||||
MTH_tdxReal xBottomZ = m_xLastCenterZ - m_xMaxSphereBoxRadius;
|
||||
MTH_tdxReal xXL = MTH_M_xDiv(m_xGridSquareSize,C_xLineWidth);
|
||||
MTH_tdxReal xZL = MTH_M_xDiv(m_xGridSquareSize,C_xLineWidth);
|
||||
MTH_tdxReal xTopZE = MTH_M_xSub(xTopZ,MTH_M_xMul(xXL,C_xNbLines));
|
||||
MTH_tdxReal xBottomZE = MTH_M_xAdd(xBottomZ,MTH_M_xMul(xXL,C_xNbLines));
|
||||
MTH_tdxReal xLeftXE = MTH_M_xSub(xLeftX,MTH_M_xMul(xZL,C_xNbLines));
|
||||
MTH_tdxReal xRightXE = MTH_M_xAdd(xRightX,MTH_M_xMul(xZL,C_xNbLines));
|
||||
MTH_tdxReal xX, xZ;
|
||||
MTH3D_tdstVector stVxA, stVxB;
|
||||
MTH3D_tdstVector stDepl;
|
||||
WORD wLine;
|
||||
|
||||
// Vertical lines
|
||||
xX = xLeftXE;
|
||||
MTH3D_M_vNullVector(&stDepl);
|
||||
MTH3D_M_vSetXofVector(&stDepl,xXL);
|
||||
for (wLine = 0; wLine < (m_wNbOfColumns + 1); wLine++)
|
||||
{
|
||||
MTH3D_M_vSetVectorElements(&stVxA, xX, 0.0, xTopZE);
|
||||
MTH3D_M_vSetVectorElements(&stVxB, xX, 0.0, xBottomZE);
|
||||
m_fn_vDrawOneLine(_p_stViewAttrib,C_lGridColor,&stVxA,&stVxB,&stDepl,C_xNbLines<<1);
|
||||
xX += m_xGridSquareSize;
|
||||
}
|
||||
|
||||
// Horizontal lines
|
||||
xZ = xTopZE;
|
||||
MTH3D_M_vNullVector(&stDepl);
|
||||
MTH3D_M_vSetZofVector(&stDepl,xZL);
|
||||
for (wLine = 0; wLine < (m_wNbOfRows + 1); wLine++)
|
||||
{
|
||||
MTH3D_M_vSetVectorElements(&stVxA, xLeftXE, 0.0, xZ);
|
||||
MTH3D_M_vSetVectorElements(&stVxB, xRightXE, 0.0, xZ);
|
||||
m_fn_vDrawOneLine(_p_stViewAttrib,C_lGridColor,&stVxA,&stVxB,&stDepl,C_xNbLines<<1);
|
||||
xZ -= m_xGridSquareSize;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Display selection
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vDisplaySelection(GLD_tdstViewportAttributes *_p_stViewAttrib)
|
||||
{
|
||||
if(M_GetLSTEvtEditor())
|
||||
{
|
||||
CPA_List<CPA_SuperObject> *p_List = M_GetLSTWorld()->GetListSelected();
|
||||
POSITION pos = p_List->GetHeadPosition();
|
||||
while(pos)
|
||||
{
|
||||
CPA_SuperObject *p_Obj = p_List->GetNext(pos);
|
||||
|
||||
MTH3D_tdstVector stVxA, stVxB, stDepl;
|
||||
MTH_tdxReal xLeftX,xTopZ,xRightX,xBottomZ;
|
||||
MTH_tdxReal xXL,xZL;
|
||||
MTH_tdxReal xFront;
|
||||
|
||||
m_fn_vCompute3DPosOfSuperObject(p_Obj,&xLeftX,&xTopZ,&xRightX,&xBottomZ,&xXL,&xZL);
|
||||
xFront = -MTH_M_xMul(xXL,50);
|
||||
// horizontal lines
|
||||
MTH3D_M_vNullVector(&stDepl);
|
||||
MTH3D_M_vSetZofVector(&stDepl,-xZL);
|
||||
MTH3D_M_vSetVectorElements(&stVxA, xLeftX, xFront, xTopZ);
|
||||
MTH3D_M_vSetVectorElements(&stVxB, xRightX, xFront, xTopZ);
|
||||
m_fn_vDrawOneLine(_p_stViewAttrib,C_lSelColor,&stVxA,&stVxB,&stDepl,C_xNbLines);
|
||||
MTH3D_M_vSetZofVector(&stDepl,xZL);
|
||||
MTH3D_M_vSetVectorElements(&stVxA, xLeftX, xFront, xBottomZ);
|
||||
MTH3D_M_vSetVectorElements(&stVxB, xRightX, xFront, xBottomZ);
|
||||
m_fn_vDrawOneLine(_p_stViewAttrib,C_lSelColor,&stVxA,&stVxB,&stDepl,C_xNbLines);
|
||||
|
||||
// vertical lines
|
||||
MTH3D_M_vNullVector(&stDepl);
|
||||
MTH3D_M_vSetXofVector(&stDepl,xXL);
|
||||
MTH3D_M_vSetVectorElements(&stVxA, xLeftX, xFront, xTopZ);
|
||||
MTH3D_M_vSetVectorElements(&stVxB, xLeftX, xFront, xBottomZ);
|
||||
m_fn_vDrawOneLine(_p_stViewAttrib,C_lSelColor,&stVxA,&stVxB,&stDepl,C_xNbLines);
|
||||
MTH3D_M_vSetXofVector(&stDepl,-xXL);
|
||||
MTH3D_M_vSetVectorElements(&stVxA, xRightX, xFront, xBottomZ);
|
||||
MTH3D_M_vSetVectorElements(&stVxB, xRightX, xFront, xTopZ);
|
||||
m_fn_vDrawOneLine(_p_stViewAttrib,C_lSelColor,&stVxA,&stVxB,&stDepl,C_xNbLines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// draw one line
|
||||
// ----------------------------------------------------------------------------
|
||||
void CPA_Grid::m_fn_vDrawOneLine(GLD_tdstViewportAttributes *_p_stViewAttrib, long lColor,
|
||||
MTH3D_tdstVector *_p_stVxA, MTH3D_tdstVector *_p_stVxB,
|
||||
MTH3D_tdstVector *_p_stDepl, ACP_tdxIndex _xNbLines)
|
||||
{
|
||||
for ( ACP_tdxIndex xLarg=0 ; xLarg<_xNbLines ; xLarg++ )
|
||||
{
|
||||
GLI_xDraw3DLine16((GLD_tdstViewportAttributes_*)_p_stViewAttrib, _p_stVxA, _p_stVxB, lColor);
|
||||
MTH3D_M_vAddVector(_p_stVxA, _p_stVxA, _p_stDepl);
|
||||
MTH3D_M_vAddVector(_p_stVxB, _p_stVxB, _p_stDepl);
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================================================
|
||||
//
|
||||
// MESSAGES FROM THE DEVICE
|
||||
//
|
||||
//======================================================================================
|
||||
|
||||
/*===========================================================================
|
||||
KeyDown
|
||||
=========================================================================*/
|
||||
BOOL CPA_Grid::_OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
||||
{
|
||||
unsigned short uwAction = m_p_oKeyboard->mfn_uwKeyToAction(nChar);
|
||||
|
||||
// change mode
|
||||
if (uwAction == KA_ID_NAVMODE)
|
||||
{
|
||||
m_bNavigationMode = !m_bNavigationMode;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// navigation mode
|
||||
if (m_bNavigationMode && (M_GetLSTWorld()->GetCountSelected() == 1))
|
||||
{
|
||||
CPA_SuperObject *pEdList = M_GetLSTWorld()->GetRoot();
|
||||
CPA_SuperObject *pSelected = M_GetLSTWorld()->GetSingleSelection();
|
||||
CPA_SuperObject *pNewSelection;
|
||||
int iColumn;
|
||||
|
||||
switch (uwAction)
|
||||
{
|
||||
case KA_ID_LEFT:
|
||||
pNewSelection = pEdList->GetSuperObjectPrevChild(pSelected);
|
||||
if (pNewSelection)
|
||||
m_p_oDevice->GetInterface()->fn_bSelectObject(pNewSelection, FALSE, FALSE);
|
||||
return TRUE;
|
||||
|
||||
case KA_ID_RIGHT:
|
||||
pNewSelection = pEdList->GetSuperObjectNextChild(pSelected);
|
||||
if (pNewSelection)
|
||||
m_p_oDevice->GetInterface()->fn_bSelectObject(pNewSelection, FALSE, FALSE);
|
||||
return TRUE;
|
||||
|
||||
case KA_ID_UP:
|
||||
iColumn = 0;
|
||||
pNewSelection = pSelected;
|
||||
while (iColumn < m_wNbOfColumns && pNewSelection)
|
||||
{
|
||||
pNewSelection = pEdList->GetSuperObjectPrevChild(pNewSelection);
|
||||
iColumn++;
|
||||
}
|
||||
if (pNewSelection && (pNewSelection != pSelected))
|
||||
m_p_oDevice->GetInterface()->fn_bSelectObject(pNewSelection, FALSE, FALSE);
|
||||
return TRUE;
|
||||
|
||||
case KA_ID_DOWN:
|
||||
iColumn = 0;
|
||||
pNewSelection = pSelected;
|
||||
while (iColumn < m_wNbOfColumns && pNewSelection)
|
||||
{
|
||||
pNewSelection = pEdList->GetSuperObjectNextChild(pNewSelection);
|
||||
iColumn++;
|
||||
}
|
||||
if (pNewSelection && (pNewSelection != pSelected))
|
||||
m_p_oDevice->GetInterface()->fn_bSelectObject(pNewSelection, FALSE, FALSE);
|
||||
return TRUE;
|
||||
|
||||
default :
|
||||
return CPA_Contact::_OnKeyDown(nChar, nRepCnt, nFlags);
|
||||
}
|
||||
}
|
||||
|
||||
//key not processed
|
||||
return CPA_Contact::_OnKeyDown(nChar, nRepCnt, nFlags);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// if no object is picked, search if a square is picked
|
||||
//--------------------------------------------------------------------------------------
|
||||
BOOL CPA_Grid::_OnLButtonDown(UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stObject)
|
||||
{
|
||||
BOOL bResult = CPA_Contact::_OnLButtonDown(nFlags, p_stPos, xIndex, p_stObject);
|
||||
|
||||
// if no picking
|
||||
if(!xIndex && m_bShowGrid)
|
||||
{
|
||||
// search object on grid
|
||||
CPA_SuperObject *p_oEdChild = m_fn_p_oGetSuperObjectFromPos( p_stPos );
|
||||
// select object
|
||||
if(p_oEdChild)
|
||||
m_p_oDevice->GetInterface()->fn_vAddSelectedObject(p_oEdChild);
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : return SO on square under pos
|
||||
// ----------------------------------------------------------------------------
|
||||
CPA_SuperObject *CPA_Grid::m_fn_p_oGetSuperObjectFromPos(tdstMousePos *p_stPos)
|
||||
{
|
||||
CPA_SuperObject *p_oEdChild = NULL;
|
||||
short wRow = 0;
|
||||
short wColumn = 0;
|
||||
short wRowPicked,wColumnPicked;
|
||||
|
||||
m_fn_vComputePickedSquare(&(p_stPos->stPos2D),&wRowPicked,&wColumnPicked);
|
||||
// if picking on a square
|
||||
if( (wRowPicked != -1) && (wColumnPicked != -1) )
|
||||
{
|
||||
CPA_SuperObject *p_oEdList = M_GetLSTWorld()->GetRoot();
|
||||
p_oEdChild = p_oEdList->GetSuperObjectFirstChild();
|
||||
// search object piched
|
||||
while( (p_oEdChild) && !((wColumn == wColumnPicked) && (wRow == wRowPicked)) )
|
||||
{
|
||||
wColumn = (wColumn + 1) % m_wNbOfColumns;
|
||||
if(wColumn == 0)
|
||||
wRow = wRow + 1;
|
||||
p_oEdChild = p_oEdList->GetSuperObjectNextChild(p_oEdChild);
|
||||
}
|
||||
}
|
||||
return p_oEdChild;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Call to draw something in the viewport.
|
||||
//--------------------------------------------------------------------------------------
|
||||
void CPA_Grid::fn_vAddObjectsToDraw( GLD_tdstViewportAttributes *_p_stViewAttrib, GLI_tdxHandleToLight _p_stLight,DEV_ViewPort *p3)
|
||||
{
|
||||
/*
|
||||
MTH_tdxReal xMaxSphereBoxRadiusBackup = m_xMaxSphereBoxRadius;
|
||||
|
||||
// if object size has changed, must compute new size of grid
|
||||
m_fn_vComputeMaxSphereBoxRadius();
|
||||
if(xMaxSphereBoxRadiusBackup != m_xMaxSphereBoxRadius)
|
||||
{
|
||||
m_fn_vComputeFirstAndLastCenters();
|
||||
m_fn_vComputeObjectsPosition();
|
||||
m_fn_vCenterOnGrid();
|
||||
}
|
||||
*/
|
||||
if(_p_stViewAttrib)
|
||||
m_fn_vDisplay(_p_stViewAttrib);
|
||||
CPA_Contact::fn_vAddObjectsToDraw(_p_stViewAttrib,_p_stLight,p3);
|
||||
}
|
||||
|
||||
#endif //ACTIVE_EDITOR
|
627
Rayman_X/cpa/tempgrp/T3D/src/DlgVwCt.cpp
Normal file
627
Rayman_X/cpa/tempgrp/T3D/src/DlgVwCt.cpp
Normal file
@@ -0,0 +1,627 @@
|
||||
// DlgVwCt.h : implementation file
|
||||
//
|
||||
|
||||
//#undef _DEBUG
|
||||
#include "stdafx.h"
|
||||
//#define _DEBUG
|
||||
|
||||
// ALX
|
||||
#include "ACP_Base.h"
|
||||
#define HieFriend
|
||||
#include "incGam.h"
|
||||
#include "Itf.h"
|
||||
/*
|
||||
#include "ACP_Base.h"
|
||||
#include "CPALib.h"
|
||||
*/
|
||||
// End ALX
|
||||
#include "DlgVwCt.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// MACROS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#define M_LBContent() ((CListBox*) GetDlgItem(IDC_LIST_CONTENT) )
|
||||
#define M_LBChoice() ((CListBox*) GetDlgItem(IDC_LIST_CHOICE) )
|
||||
#define M_CBType() ((CComboBox*) GetDlgItem(IDC_COMBO_TYPE) )
|
||||
#define M_CTChoice() ((CTreeCtrl*) GetDlgItem(IDC_TREE_HIERARCHY) )
|
||||
|
||||
#define M_ClientRect( pWnd, poRect ) \
|
||||
(pWnd) -> GetWindowRect( poRect ); \
|
||||
ScreenToClient( poRect );
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// MACROS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#define C_iBorderSize 10
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgViewerContent dialog
|
||||
|
||||
|
||||
CDlgViewerContent::CDlgViewerContent(CPA_MainWorld *_p_oMainWorld, CPA_List<tdst_VW_ObjInfo> *_p_oListOfInitialObjects,CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDlgViewerContent::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CDlgViewerContent)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_p_oMainWorld = _p_oMainWorld;
|
||||
m_p_oListOfInitialObjects = _p_oListOfInitialObjects;
|
||||
m_ocstTreeName = "";
|
||||
m_bTreeUsed = FALSE;
|
||||
//
|
||||
m_oBmpEdNoObject.LoadBitmap( IDB_EDIT_NOOBJECT );
|
||||
m_oBmpEdSupObj.LoadBitmap( IDB_EDIT_SUPOBJ );
|
||||
m_oBmpNoEdNoObject.LoadBitmap( IDB_NOEDIT_NOOBJECT );
|
||||
m_oBmpNoEdSupObj.LoadBitmap( IDB_NOEDIT_SUPOBJ );
|
||||
m_oBmpPEdNoObject.LoadBitmap( IDB_PEDIT_NOOBJECT );
|
||||
m_oBmpPEdSupObj.LoadBitmap( IDB_PEDIT_SUPOBJ );
|
||||
m_oBmpPNoEdNoObject.LoadBitmap( IDB_PNOEDIT_NOOBJECT );
|
||||
m_oBmpPNoEdSupObj.LoadBitmap( IDB_PNOEDIT_SUPOBJ );
|
||||
}
|
||||
|
||||
CDlgViewerContent::~CDlgViewerContent()
|
||||
{
|
||||
m_oBmpEdNoObject.DeleteObject();
|
||||
m_oBmpEdSupObj.DeleteObject();
|
||||
m_oBmpNoEdNoObject.DeleteObject();
|
||||
m_oBmpNoEdSupObj.DeleteObject();
|
||||
m_oBmpPEdNoObject.DeleteObject();
|
||||
m_oBmpPEdSupObj.DeleteObject();
|
||||
m_oBmpPNoEdNoObject.DeleteObject();
|
||||
m_oBmpPNoEdSupObj.DeleteObject();
|
||||
}
|
||||
|
||||
void CDlgViewerContent::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CDlgViewerContent)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDlgViewerContent, CDialog)
|
||||
//{{AFX_MSG_MAP(CDlgViewerContent)
|
||||
ON_WM_SIZE()
|
||||
ON_WM_GETMINMAXINFO()
|
||||
ON_BN_CLICKED(ID_BT_DELETE, OnBtdelete)
|
||||
ON_BN_CLICKED(ID_BT_ADD, OnBtadd)
|
||||
ON_CBN_SELCHANGE(IDC_COMBO_TYPE, OnSelchangeComboType)
|
||||
ON_LBN_DBLCLK(IDC_LIST_CHOICE, OnDblClkListObjects)
|
||||
ON_LBN_DBLCLK(IDC_LIST_CONTENT, OnDblclkListContent)
|
||||
ON_BN_CLICKED(ID_BT_OPEN, OnBtOpen)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgViewerContent message handlers
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description :
|
||||
//--------------------------------------------------------------------------------
|
||||
BOOL CDlgViewerContent::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
CListBox *pLB = M_LBContent();
|
||||
|
||||
pLB -> ResetContent();
|
||||
// fill Content ListBox
|
||||
POSITION stPos = m_p_oListOfInitialObjects -> GetHeadPosition();
|
||||
while ( stPos )
|
||||
{
|
||||
tdst_VW_ObjInfo *p_stVWOI = m_p_oListOfInitialObjects -> GetNext ( stPos );
|
||||
CPA_SuperObject *p_oSprObj = p_stVWOI -> m_p_oSuperObject;
|
||||
CPA_BaseObject *p_oObject = p_oSprObj -> GetObject();
|
||||
|
||||
int iIndex = pLB -> AddString ( p_oObject -> GetName() ) ; // Object Name
|
||||
if( iIndex != LB_ERR )
|
||||
pLB -> SetItemData ( iIndex, (DWORD) p_oSprObj ) ; // Super_Object pointer
|
||||
}
|
||||
GetDlgItem( ID_BT_OPEN ) -> EnableWindow( pLB -> GetCount() );
|
||||
|
||||
// fill Type ComboBox & Choice ListBox
|
||||
M_CBType() -> ResetContent();
|
||||
// add Actor Type
|
||||
mfn_vAddListOfType( "Actor", "Actors" );
|
||||
// add Geometric type
|
||||
mfn_vAddListOfType( "Geometric", "Geometric Objects" );
|
||||
// add Hierarchy Tree
|
||||
mfn_vAddHierarchyTree( "Hierarchy" );
|
||||
|
||||
// select hierarchy
|
||||
if( M_CBType() -> SelectString( -1, "Hierarchy" ) != LB_ERR )
|
||||
mfn_vShowHierarchyTree();
|
||||
else
|
||||
M_CBType() -> SetCurSel( -1 );
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description :
|
||||
// ----------------------------------------------------------------------------
|
||||
BOOL CDlgViewerContent::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
if( pMsg->message == WM_KEYDOWN )
|
||||
{
|
||||
CListBox *pLBChoice = M_LBChoice();
|
||||
CListBox *pLBContent = M_LBContent();
|
||||
CTreeCtrl *pTree = M_CTChoice();
|
||||
HTREEITEM hCurItem = pTree -> GetSelectedItem();
|
||||
|
||||
if( ( ( (int)pMsg -> wParam) == VK_INSERT ) &&
|
||||
( ( ( pLBChoice -> GetSelCount() > 0 ) && ( pMsg->hwnd == pLBChoice -> m_hWnd ) ) ||
|
||||
( ( pTree -> GetSelectedItem() ) && ( pMsg->hwnd == pTree -> m_hWnd ) )
|
||||
)
|
||||
)
|
||||
{
|
||||
OnBtadd();
|
||||
}
|
||||
else if ( ( ((int)pMsg -> wParam) == VK_DELETE ) && ( pLBContent -> GetSelCount() > 0 ) && ( pMsg->hwnd == pLBContent -> m_hWnd ) )
|
||||
{
|
||||
OnBtdelete();
|
||||
}
|
||||
}
|
||||
return CDialog::PreTranslateMessage(pMsg);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : handle function for msg WM_SIZE
|
||||
// ----------------------------------------------------------------------------
|
||||
void CDlgViewerContent::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
CDialog::OnSize(nType, cx, cy);
|
||||
|
||||
if(GetDlgItem(IDC_LIST_CHOICE))
|
||||
{
|
||||
CRect oRectDlg, oRectLBContent, oRectLBChoice, oRectCT, oRectCB;
|
||||
CRect oRectBTAdd, oRectBTOK, oRectBTDel, oRectBTCancel, oRectBTOpen;
|
||||
CSize oSize;
|
||||
|
||||
// get size and position
|
||||
GetClientRect( &oRectDlg );
|
||||
|
||||
M_ClientRect( M_LBChoice(), &oRectLBChoice );
|
||||
M_ClientRect( M_CTChoice(), &oRectCT );
|
||||
M_ClientRect( M_LBContent(), &oRectLBContent );
|
||||
M_ClientRect( M_CBType(), &oRectCB );
|
||||
M_ClientRect( GetDlgItem( ID_BT_ADD ), &oRectBTAdd );
|
||||
M_ClientRect( GetDlgItem( ID_BT_DELETE ), &oRectBTDel );
|
||||
M_ClientRect( GetDlgItem( IDOK ), &oRectBTOK );
|
||||
M_ClientRect( GetDlgItem( IDCANCEL ), &oRectBTCancel );
|
||||
M_ClientRect( GetDlgItem( ID_BT_OPEN ), &oRectBTOpen );
|
||||
|
||||
// resize
|
||||
// place BT 'Cancel' 'Delete' & 'OK'
|
||||
oSize = oRectBTCancel . Size();
|
||||
oRectBTCancel . bottom = oRectDlg . bottom - C_iBorderSize;
|
||||
oRectBTCancel . top = oRectBTCancel . bottom - oSize . cy;
|
||||
oRectBTOK . bottom = oRectBTOpen . bottom = oRectBTCancel . bottom;
|
||||
oRectBTOK . top = oRectBTOpen . top = oRectBTCancel . top;
|
||||
oSize = oRectBTCancel . Size();
|
||||
oRectBTCancel . right = oRectDlg . right - C_iBorderSize;
|
||||
oRectBTCancel . left = oRectBTCancel . right - oSize.cx;
|
||||
oSize = oRectBTOpen . Size();
|
||||
oRectBTOpen . left = ( oRectBTCancel . left + oRectBTOK . left ) >> 1;
|
||||
oRectBTOpen . right = oRectBTOpen . left + oSize.cx;
|
||||
// translate LBContent
|
||||
oSize = oRectLBContent . Size();
|
||||
oRectLBContent . right = oRectDlg . right - C_iBorderSize;
|
||||
oRectLBContent . left = oRectLBContent . right - oSize.cx;
|
||||
oRectLBContent . bottom = oRectDlg . bottom - oRectBTOK . Height() - (C_iBorderSize << 1);
|
||||
// place BTAdd
|
||||
oSize = oRectBTAdd . Size();
|
||||
int iHeight = oRectLBContent . Height();
|
||||
oRectBTDel . right = oRectBTAdd . right = oRectLBContent . left - C_iBorderSize;
|
||||
oRectBTDel . left = oRectBTAdd . left = oRectBTAdd . right - oSize.cx;
|
||||
oRectBTAdd . top = oRectLBContent . top + (iHeight>>1) - oSize.cy - C_iBorderSize;
|
||||
oRectBTAdd . bottom = oRectBTAdd . top + oSize.cy;
|
||||
oRectBTDel . top = oRectBTAdd . bottom + (C_iBorderSize>>1);
|
||||
oRectBTDel . bottom = oRectBTDel . top + oSize.cy;
|
||||
// resize LBChoice & CTree
|
||||
oRectLBChoice . right = oRectBTAdd . left - C_iBorderSize;
|
||||
oRectLBChoice . bottom = oRectLBContent . bottom;
|
||||
oRectCT . right = oRectLBChoice . right;
|
||||
oRectCT . bottom = oRectLBChoice . bottom;
|
||||
// resize CB
|
||||
oRectCB . right = oRectCT . right;
|
||||
|
||||
// move windows
|
||||
M_LBChoice() -> MoveWindow ( &oRectLBChoice ) ;
|
||||
M_CTChoice() -> MoveWindow ( &oRectCT ) ;
|
||||
M_LBContent() -> MoveWindow ( &oRectLBContent ) ;
|
||||
M_CBType() -> MoveWindow ( &oRectCB ) ;
|
||||
GetDlgItem( ID_BT_ADD ) -> MoveWindow ( &oRectBTAdd ) ;
|
||||
GetDlgItem( ID_BT_DELETE ) -> MoveWindow ( &oRectBTDel ) ;
|
||||
GetDlgItem( IDOK ) -> MoveWindow ( &oRectBTOK ) ;
|
||||
GetDlgItem( IDCANCEL ) -> MoveWindow ( &oRectBTCancel ) ;
|
||||
GetDlgItem( ID_BT_OPEN ) -> MoveWindow ( &oRectBTOpen ) ;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : handle function for msg WM_GETMINMAXINFO
|
||||
// ----------------------------------------------------------------------------
|
||||
void CDlgViewerContent::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
|
||||
{
|
||||
// limit min size
|
||||
lpMMI -> ptMinTrackSize . x = 412;
|
||||
lpMMI -> ptMinTrackSize . y = 257;
|
||||
|
||||
CDialog::OnGetMinMaxInfo( lpMMI );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : handle function for msg BN_CLICKED on button OK
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::OnOK()
|
||||
{
|
||||
mfn_vUpdateList();
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : handle function for msg BN_CLICKED on button OPEN
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::OnBtOpen()
|
||||
{
|
||||
mfn_vUpdateList();
|
||||
CDialog::EndDialog(C_OPENVIEWER);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : handle function for msg BN_CLICKER on button Delete
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::OnBtdelete()
|
||||
{
|
||||
// multiple selection list
|
||||
CListBox *pLB = M_LBContent();
|
||||
int iNbSel = pLB -> GetSelCount();
|
||||
|
||||
if ( iNbSel > 0 )
|
||||
{
|
||||
int *pa_iIndexes = (int*)malloc( iNbSel * sizeof(int));
|
||||
|
||||
pLB -> GetSelItems( iNbSel, pa_iIndexes );
|
||||
|
||||
for ( int iIdx=iNbSel-1 ; iIdx>=0 ; iIdx-- )
|
||||
{
|
||||
pLB -> DeleteString ( pa_iIndexes[iIdx] ) ;
|
||||
}
|
||||
free(pa_iIndexes);
|
||||
}
|
||||
GetDlgItem( ID_BT_OPEN ) -> EnableWindow( pLB -> GetCount() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : handle function for msg BN_CLICKER on button Add
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::OnBtadd()
|
||||
{
|
||||
CComboBox *pCB = M_CBType();
|
||||
int iIndex = pCB -> GetCurSel();
|
||||
|
||||
if( iIndex != CB_ERR )
|
||||
{
|
||||
CString ocstChoiceName;
|
||||
|
||||
pCB -> GetLBText( iIndex , ocstChoiceName );
|
||||
if ( ocstChoiceName == m_ocstTreeName )
|
||||
mfn_vAddSelectionFromTree();
|
||||
else
|
||||
mfn_vAddSelectionFromList();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : handle function for msg CBN_SELCHANGE on combo type
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::OnSelchangeComboType()
|
||||
{
|
||||
CComboBox *pCB = M_CBType();
|
||||
int iIndex = pCB -> GetCurSel();
|
||||
|
||||
if( iIndex != CB_ERR )
|
||||
{
|
||||
CString ocstChoiceName;
|
||||
|
||||
pCB -> GetLBText( iIndex , ocstChoiceName );
|
||||
if ( ocstChoiceName == m_ocstTreeName )
|
||||
mfn_vShowHierarchyTree();
|
||||
else
|
||||
mfn_vFillChoiceList( (CPA_List<CPA_SuperObject>*) pCB -> GetItemData( iIndex ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : handle function for msg LBN_DBLCLK on choice list
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::OnDblclkListContent()
|
||||
{
|
||||
CListBox *pLBContent = M_LBContent();
|
||||
int iIndex = pLBContent -> GetCurSel();
|
||||
|
||||
if( iIndex != LB_ERR )
|
||||
{
|
||||
pLBContent -> DeleteString( iIndex );
|
||||
}
|
||||
GetDlgItem( ID_BT_OPEN ) -> EnableWindow( pLBContent -> GetCount() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : handle function for msg LBN_DBLCLK on choice list
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::OnDblClkListObjects()
|
||||
{
|
||||
CListBox *pLBChoice = M_LBChoice();
|
||||
CListBox *pLBContent = M_LBContent();
|
||||
int iIndex = pLBChoice -> GetCurSel();
|
||||
|
||||
if( iIndex != LB_ERR && (pLBContent -> GetCount() < (MAX_DEVICE-1)) )
|
||||
{
|
||||
CPA_SuperObject *p_oSprObj = (CPA_SuperObject*)pLBChoice -> GetItemData( iIndex );
|
||||
CPA_BaseObject *p_oObject = p_oSprObj -> GetObject();
|
||||
|
||||
int iIdx = pLBContent -> AddString( p_oObject -> GetName() ); // object name
|
||||
if( iIdx != LB_ERR )
|
||||
pLBContent -> SetItemData ( iIdx , (DWORD) p_oSprObj ); // super object pointer
|
||||
}
|
||||
GetDlgItem( ID_BT_OPEN ) -> EnableWindow( pLBContent -> GetCount() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : fill Choice list with selected list on Type Combo
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::mfn_vFillChoiceList(CPA_List<CPA_SuperObject> *_p_oList)
|
||||
{
|
||||
CListBox *pLB = M_LBChoice();
|
||||
CTreeCtrl *pTree = M_CTChoice();
|
||||
|
||||
pTree -> EnableWindow( FALSE );
|
||||
pTree -> ShowWindow( SW_HIDE );
|
||||
|
||||
pLB -> EnableWindow( TRUE );
|
||||
pLB -> ShowWindow( SW_SHOW );
|
||||
pLB -> ResetContent();
|
||||
|
||||
if( _p_oList )
|
||||
{
|
||||
// fill list
|
||||
POSITION stPos = _p_oList -> GetHeadPosition();
|
||||
|
||||
while ( stPos )
|
||||
{
|
||||
CPA_SuperObject *p_oSprObj = _p_oList -> GetNext( stPos );
|
||||
CPA_BaseObject *p_oObj = p_oSprObj -> GetObject() ;
|
||||
|
||||
int iIdx = pLB -> AddString ( p_oObj -> GetName() ); // object name
|
||||
if( iIdx != LB_ERR )
|
||||
pLB -> SetItemData ( iIdx, (DWORD)p_oSprObj ); // super object pointer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : show heirarchy tree
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::mfn_vShowHierarchyTree()
|
||||
{
|
||||
CListBox *pLB = M_LBChoice();
|
||||
CTreeCtrl *pTree = M_CTChoice();
|
||||
|
||||
pLB -> EnableWindow( FALSE );
|
||||
pLB -> ShowWindow( SW_HIDE );
|
||||
|
||||
pTree -> EnableWindow( TRUE );
|
||||
pTree -> ShowWindow( SW_SHOW );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : add a list on Type Combo
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::mfn_vAddListOfType(CString _csTypeName, CString _csListName)
|
||||
{
|
||||
CComboBox *pCB = M_CBType();
|
||||
CPA_List<CPA_SuperObject> *p_oList = m_p_oMainWorld -> GetInterface() -> GetObjectListByType (_csTypeName);
|
||||
|
||||
if( p_oList )
|
||||
{
|
||||
int iIndex = pCB -> AddString ( _csListName ) ;
|
||||
if ( iIndex != CB_ERR )
|
||||
pCB -> SetItemData( iIndex , (DWORD) p_oList ) ;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : add hierarchy on Tree
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::mfn_vAddHierarchyTree(CString _csListName)
|
||||
{
|
||||
CComboBox *pCB = M_CBType();
|
||||
|
||||
// only one tree
|
||||
if( m_bTreeUsed )
|
||||
return ;
|
||||
|
||||
m_ocstTreeName = _csListName ;
|
||||
m_bTreeUsed = TRUE;
|
||||
pCB -> AddString ( _csListName ) ;
|
||||
|
||||
// init icons for hierarchy tree
|
||||
m_stImageList.Create(16, 16, FALSE, 0, 9);
|
||||
/*
|
||||
m_stImageList.Add(M_GetMainApp()->LoadIcon(EDT_IDI_EDIT_NOOBJECT));
|
||||
m_stImageList.Add(M_GetMainApp()->LoadIcon(EDT_IDI_EDIT_SUPOBJ));
|
||||
m_stImageList.Add(M_GetMainApp()->LoadIcon(EDT_IDI_NOEDIT_NOOBJECT));
|
||||
m_stImageList.Add(M_GetMainApp()->LoadIcon(EDT_IDI_NOEDIT_SUPOBJ));
|
||||
m_stImageList.Add(M_GetMainApp()->LoadIcon(EDT_IDI_PEDIT_NOOBJECT));
|
||||
m_stImageList.Add(M_GetMainApp()->LoadIcon(EDT_IDI_PEDIT_SUPOBJ));
|
||||
m_stImageList.Add(M_GetMainApp()->LoadIcon(EDT_IDI_PNOEDIT_NOOBJECT));
|
||||
m_stImageList.Add(M_GetMainApp()->LoadIcon(EDT_IDI_PNOEDIT_SUPOBJ));
|
||||
*/
|
||||
m_stImageList.Add(&m_oBmpEdNoObject,(CBitmap*)NULL);
|
||||
m_stImageList.Add(&m_oBmpEdSupObj,(CBitmap*)NULL);
|
||||
m_stImageList.Add(&m_oBmpNoEdNoObject,(CBitmap*)NULL);
|
||||
m_stImageList.Add(&m_oBmpNoEdSupObj,(CBitmap*)NULL);
|
||||
m_stImageList.Add(&m_oBmpPEdNoObject,(CBitmap*)NULL);
|
||||
m_stImageList.Add(&m_oBmpPEdSupObj,(CBitmap*)NULL);
|
||||
m_stImageList.Add(&m_oBmpPNoEdNoObject,(CBitmap*)NULL);
|
||||
m_stImageList.Add(&m_oBmpPNoEdSupObj,(CBitmap*)NULL);
|
||||
|
||||
M_CTChoice() -> SetImageList(&m_stImageList, TVSIL_NORMAL);
|
||||
|
||||
// fill tree
|
||||
mfn_vFillHierarchyTree( m_p_oMainWorld -> GetWorld() -> GetRoot() , TVI_ROOT);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : add a list on Type Combo
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::mfn_vFillHierarchyTree (CPA_SuperObject *pEdParent, HTREEITEM hTreeParent)
|
||||
{
|
||||
CTreeCtrl *pTree = M_CTChoice();
|
||||
CPA_SuperObject *pEdChild;
|
||||
HTREEITEM hTreeChild;
|
||||
int iNumImage;
|
||||
|
||||
if (!pEdParent)
|
||||
return;
|
||||
|
||||
for (pEdChild = pEdParent->GetSuperObjectFirstChild(); pEdChild;
|
||||
pEdChild = pEdParent->GetSuperObjectNextChild(pEdChild))
|
||||
{
|
||||
// find good icon
|
||||
iNumImage = 0;
|
||||
if (pEdChild->GetSuperObjectOwner())
|
||||
iNumImage += 4;
|
||||
if (pEdChild->fn_bIsEditProtected())
|
||||
iNumImage += 2;
|
||||
if (pEdChild->GetObjectType() != HIE_C_ulSuperObject)
|
||||
iNumImage += 1;
|
||||
// create item
|
||||
if( pEdChild->GetObject() )
|
||||
hTreeChild = pTree -> InsertItem( pEdChild->GetObject()->GetName(), iNumImage, iNumImage, hTreeParent, TVI_LAST ); // object name
|
||||
else
|
||||
hTreeChild = pTree -> InsertItem( pEdChild->GetName(), iNumImage, iNumImage, hTreeParent, TVI_LAST ); // object name
|
||||
pTree -> SetItemData( hTreeChild, (DWORD) pEdChild ); // super object pointer
|
||||
// next level
|
||||
mfn_vFillHierarchyTree( pEdChild, hTreeChild );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : add selection from list
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::mfn_vAddSelectionFromList()
|
||||
{
|
||||
// multiple selection
|
||||
CListBox *pLBChoice = M_LBChoice();
|
||||
CListBox *pLBContent = M_LBContent();
|
||||
int iNbSel = pLBChoice -> GetSelCount();
|
||||
|
||||
if ( iNbSel != LB_ERR )
|
||||
{
|
||||
int *pa_iIndexes = (int*)malloc( iNbSel * sizeof(int));
|
||||
pLBChoice -> GetSelItems( iNbSel, pa_iIndexes );
|
||||
for ( int iIndex=0 ; (iIndex<iNbSel && (pLBContent -> GetCount() < (MAX_DEVICE-1)) ) ; iIndex++ )
|
||||
{
|
||||
CPA_SuperObject *p_oSprObj = (CPA_SuperObject*)pLBChoice -> GetItemData( pa_iIndexes[iIndex] );
|
||||
CPA_BaseObject *p_oObject = p_oSprObj -> GetObject();
|
||||
|
||||
int iIdxCnt = pLBContent -> FindStringExact( -1, p_oObject -> GetName() );
|
||||
if( iIdxCnt == LB_ERR )
|
||||
{
|
||||
// new object
|
||||
int iIdx = pLBContent -> AddString( p_oObject -> GetName() ); // object name
|
||||
if( iIdx != LB_ERR )
|
||||
pLBContent -> SetItemData ( iIdx , (DWORD) p_oSprObj ); // super object pointer
|
||||
}
|
||||
}
|
||||
free(pa_iIndexes);
|
||||
}
|
||||
GetDlgItem( ID_BT_OPEN ) -> EnableWindow( pLBContent -> GetCount() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : add selection from tree
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::mfn_vAddSelectionFromTree()
|
||||
{
|
||||
CTreeCtrl *pTree = M_CTChoice();
|
||||
HTREEITEM hCurItem = pTree -> GetSelectedItem();
|
||||
|
||||
if( hCurItem )
|
||||
{
|
||||
CPA_SuperObject *p_oSprObj = (CPA_SuperObject *) pTree -> GetItemData(hCurItem);
|
||||
CPA_BaseObject *p_oObject = p_oSprObj -> GetObject();
|
||||
|
||||
CListBox *pLBContent = M_LBContent();
|
||||
if(p_oObject && (pLBContent -> GetCount() < (MAX_DEVICE-1)) )
|
||||
{
|
||||
int iIdxCnt = pLBContent -> FindStringExact( -1, p_oObject -> GetName() );
|
||||
if( iIdxCnt == LB_ERR )
|
||||
{
|
||||
// new object
|
||||
int iIdx = pLBContent -> AddString( p_oObject -> GetName() ); // object name
|
||||
if( iIdx != LB_ERR )
|
||||
pLBContent -> SetItemData ( iIdx , (DWORD) p_oSprObj ); // super object pointer
|
||||
}
|
||||
}
|
||||
GetDlgItem( ID_BT_OPEN ) -> EnableWindow( pLBContent -> GetCount() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : update global list with selected objects
|
||||
//--------------------------------------------------------------------------------
|
||||
void CDlgViewerContent::mfn_vUpdateList()
|
||||
{
|
||||
CListBox *pLB = M_LBContent();
|
||||
|
||||
CList<DWORD,DWORD> m_oListOfWord;
|
||||
for( int iIndex = 0 ; iIndex < pLB -> GetCount() ; iIndex++ )
|
||||
{
|
||||
DWORD dwValue = pLB->GetItemData( iIndex );
|
||||
if ( dwValue != LB_ERR )
|
||||
{
|
||||
m_oListOfWord . AddTail ( dwValue );
|
||||
}
|
||||
}
|
||||
//
|
||||
POSITION stPos = m_p_oListOfInitialObjects -> GetHeadPosition();
|
||||
while( stPos )
|
||||
{
|
||||
POSITION stCurPos = stPos;
|
||||
tdst_VW_ObjInfo *p_stObjInfo = m_p_oListOfInitialObjects -> GetNext( stPos );
|
||||
|
||||
DWORD dwValue = (DWORD) p_stObjInfo -> m_p_oSuperObject;
|
||||
|
||||
POSITION stP = m_oListOfWord . Find( dwValue );
|
||||
|
||||
if( stP )
|
||||
m_oListOfWord . RemoveAt( stP );
|
||||
else
|
||||
{
|
||||
free( p_stObjInfo );
|
||||
m_p_oListOfInitialObjects -> RemoveAt( stCurPos );
|
||||
}
|
||||
}
|
||||
//
|
||||
stPos = m_oListOfWord . GetHeadPosition();
|
||||
while( stPos )
|
||||
{
|
||||
tdst_VW_ObjInfo *p_stObjInfo = (tdst_VW_ObjInfo*) malloc( sizeof (tdst_VW_ObjInfo ) );
|
||||
p_stObjInfo -> m_p_oSuperObject = (CPA_SuperObject*) m_oListOfWord . GetNext( stPos );
|
||||
p_stObjInfo -> m_bUsePos = FALSE;
|
||||
POS_fn_vSetIdentityMatrix(&p_stObjInfo -> stMatrix);
|
||||
m_p_oListOfInitialObjects -> AddTail( p_stObjInfo );
|
||||
}
|
||||
}
|
6
Rayman_X/cpa/tempgrp/T3D/src/StdAfx.cpp
Normal file
6
Rayman_X/cpa/tempgrp/T3D/src/StdAfx.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// ACPProject.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
104
Rayman_X/cpa/tempgrp/T3D/src/T3DFRMBs.cpp
Normal file
104
Rayman_X/cpa/tempgrp/T3D/src/T3DFRMBs.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef ACTIVE_EDITOR
|
||||
|
||||
#include "stdafx.h"
|
||||
// ALX
|
||||
#include "ACP_Base.h"
|
||||
#define HieFriend
|
||||
#include "incGam.h"
|
||||
#include "Itf.h"
|
||||
|
||||
#include "T3DFRMBs.hpp"
|
||||
#include "T3DInterf.hpp"
|
||||
|
||||
#define M_PosMenuOption 4
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Tool3D_FRMBaseMenu
|
||||
|
||||
IMPLEMENT_DYNCREATE(Tool3D_FRMBaseMenu, FRMBaseMenu)
|
||||
|
||||
BEGIN_MESSAGE_MAP(Tool3D_FRMBaseMenu, FRMBaseMenu)
|
||||
//{{AFX_MSG_MAP(Tool3D_FRMBaseMenu)
|
||||
ON_WM_INITMENUPOPUP()
|
||||
ON_WM_SYSCOMMAND()
|
||||
ON_WM_SIZE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Tool3D_FRMBaseMenu construction/destruction
|
||||
|
||||
Tool3D_FRMBaseMenu::Tool3D_FRMBaseMenu()
|
||||
{
|
||||
//statement
|
||||
m_p_oTool3D = NULL;
|
||||
}
|
||||
|
||||
Tool3D_FRMBaseMenu::~Tool3D_FRMBaseMenu()
|
||||
{
|
||||
//statement
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Tool3D_FRMBaseMenu Message
|
||||
|
||||
////
|
||||
void Tool3D_FRMBaseMenu::OnSysCommand( UINT nID, LPARAM lParam )
|
||||
{
|
||||
switch (nID)
|
||||
{
|
||||
case SC_CLOSE:
|
||||
case SC_MINIMIZE:
|
||||
M_GetMainWnd()->SendMessage(WM_SYSCOMMAND,(WORD)nID,MAKELPARAM(0,-1));
|
||||
break;
|
||||
default:
|
||||
FRMBaseMenu::OnSysCommand(nID, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
////
|
||||
void Tool3D_FRMBaseMenu::OnSize( UINT nType, int cx, int cy )
|
||||
{
|
||||
FRMBaseMenu::OnSize(nType,cx,cy);
|
||||
}
|
||||
|
||||
void Tool3D_FRMBaseMenu::fn_vInitGeneralMenuWithContext(void)
|
||||
{
|
||||
FRMBaseMenu::fn_vInitGeneralMenuWithContext();
|
||||
|
||||
m_oGeneralMenu.GetSubMenu(M_PosMenuOption)->EnableMenuItem(CPA_IDCB_DISPLAYWORLD, MF_BYCOMMAND|MF_GRAYED);
|
||||
m_oGeneralMenu.GetSubMenu(M_PosMenuOption)->EnableMenuItem(CPA_IDCB_DISPLAYVISIBLE, MF_BYCOMMAND|MF_GRAYED);
|
||||
m_oGeneralMenu.GetSubMenu(M_PosMenuOption)->EnableMenuItem(CPA_IDCB_DISPLAYSECTOR, MF_BYCOMMAND|MF_GRAYED);
|
||||
|
||||
m_oGeneralMenu.GetSubMenu(M_PosMenuOption)->EnableMenuItem(CPA_IDCB_VIEWBOUND, MF_BYCOMMAND|MF_GRAYED);
|
||||
m_oGeneralMenu.GetSubMenu(M_PosMenuOption)->EnableMenuItem(CPA_IDCB_WORLDTEXTURED, MF_BYCOMMAND|MF_GRAYED);
|
||||
m_oGeneralMenu.GetSubMenu(M_PosMenuOption)->EnableMenuItem(CPA_IDCB_WORLDGRID, MF_BYCOMMAND|MF_GRAYED);
|
||||
m_oGeneralMenu.GetSubMenu(M_PosMenuOption)->EnableMenuItem(CPA_IDCB_WORLDWIRED, MF_BYCOMMAND|MF_GRAYED);
|
||||
}
|
||||
|
||||
void Tool3D_FRMBaseMenu::mfn_vUpdateDeviceToolBar(void)
|
||||
{
|
||||
//FRMBaseMenu::mfn_vUpdateDeviceToolBar();
|
||||
//m_oGeneralDialogBar.m_oDeviceToolbar.ShowWindow( SW_HIDE );
|
||||
m_oGeneralDialogBar.m_oDisplayToolbar.ShowWindow( SW_HIDE );
|
||||
m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_CURRENTSECTOR) -> EnableWindow( FALSE );
|
||||
m_oGeneralDialogBar.GetDlgItem(CPA_IDCB_SELECTMODE) -> EnableWindow( FALSE );
|
||||
}
|
||||
|
||||
void Tool3D_FRMBaseMenu::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
|
||||
{
|
||||
FRMBaseMenu::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu) ;
|
||||
|
||||
// grayed Reinit the map !!
|
||||
if ( nIndex == 0 )
|
||||
pPopupMenu->EnableMenuItem (0, MF_BYPOSITION | MF_GRAYED ) ;
|
||||
// grayed the other
|
||||
m_p_oToolSubMenu->fn_cGrayedItem (pPopupMenu, "Recompute all bounding volumes" ) ;
|
||||
m_p_o3DViewSubMenu->fn_cGrayedItem (pPopupMenu, "Display" ) ;
|
||||
m_p_o3DViewSubMenu->fn_cGrayedItem (pPopupMenu, "Bounding Volume" ) ;
|
||||
m_p_o3DViewSubMenu->fn_cGrayedItem (pPopupMenu, "Axis" ) ;
|
||||
}
|
||||
|
||||
#endif //ACTIVE_EDITOR
|
58
Rayman_X/cpa/tempgrp/T3D/src/T3DFrame.cpp
Normal file
58
Rayman_X/cpa/tempgrp/T3D/src/T3DFrame.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
// T3DFrame.cpp: implementation of the Tool3D_Frame class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "stdafx.h"
|
||||
#include "ACP_Base.h"
|
||||
|
||||
#include "Itf.h"
|
||||
#include "animview.h"
|
||||
#include "T3DFrame.hpp"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
extern "C" CPA_DLLBase *fn_p_oGetDLL(long lKey);
|
||||
extern tdstDLLIdentity g_stTool3DIdentity;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Tool3D_Frame::Tool3D_Frame()
|
||||
{
|
||||
m_p_clBaseObjectList = new CPA_BaseObjectList();
|
||||
m_p_clDialogList = new CPA_DialogList();
|
||||
m_bDisplayAllFam = TRUE;
|
||||
}
|
||||
|
||||
Tool3D_Frame::~Tool3D_Frame()
|
||||
{
|
||||
delete m_p_clBaseObjectList;
|
||||
delete m_p_clDialogList;
|
||||
}
|
||||
|
||||
BOOL Tool3D_Frame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext * pContext)
|
||||
{
|
||||
|
||||
if (!(CreateSplitter(C_cHorizontalSplitter,2)))
|
||||
return FALSE;
|
||||
|
||||
//Creates Dialog List View
|
||||
|
||||
m_p_clDialogList->fn_vInitDialog( fn_p_oGetDLL(0), this );
|
||||
SetPaneView( 0, m_p_clDialogList,"Selection", 200);
|
||||
|
||||
HINSTANCE hOldInst = AfxGetResourceHandle();
|
||||
AfxSetResourceHandle( g_stTool3DIdentity.hModule );
|
||||
|
||||
//Creates other views
|
||||
if ( !CreateView( 1,RUNTIME_CLASS(CAnimationView),"Animation control", 800 ) )
|
||||
return FALSE;
|
||||
AfxSetResourceHandle( hOldInst );
|
||||
|
||||
return TRUE;
|
||||
}
|
830
Rayman_X/cpa/tempgrp/T3D/src/T3DWorld.cpp
Normal file
830
Rayman_X/cpa/tempgrp/T3D/src/T3DWorld.cpp
Normal file
@@ -0,0 +1,830 @@
|
||||
// implementation of special world class for the 3DTool Dll
|
||||
|
||||
|
||||
//// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
//// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
//// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
//// WARNING WARNING
|
||||
//// WARNING WARNING
|
||||
//// WARNING SuperObjects are not destroyed !!!!! WARNING
|
||||
//// WARNING WARNING
|
||||
//// WARNING WARNING
|
||||
//// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
//// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
//// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
|
||||
#ifdef ACTIVE_EDITOR
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#define D_State_Define
|
||||
#define HieFriend
|
||||
|
||||
#include "ACP_Base.h"
|
||||
#include "incGam.h"
|
||||
#include "Itf.h"
|
||||
//#include "HIE.h"
|
||||
|
||||
#include "T3DWorld.hpp"
|
||||
|
||||
inline POS_tdxHandleToPosition M_AllocMatrix()
|
||||
{
|
||||
POS_tdxHandleToPosition hPos = (POS_tdxHandleToPosition) malloc (sizeof (POS_tdstCompletePosition) );
|
||||
POS_fn_vSetIdentityMatrix(hPos);
|
||||
|
||||
return hPos;
|
||||
}
|
||||
|
||||
//#define M_AllocMatrix() ((POS_tdxHandleToPosition) malloc (sizeof (POS_tdstCompletePosition)))
|
||||
|
||||
//#define M_AllocMatrix() POS_fn_hCreateMatrix(POS_C_xCompletePosition);
|
||||
|
||||
#define M_GetCopyOfSuperObject(p_oSprObj) (p_oSprObj) -> GetMainWorld() -> GetInterface() -> GetCopyOfSuperObject(p_oSprObj)
|
||||
|
||||
#define M_ForEachSuperObjectChild( p_oSprObjFather, p_oSprObjChild ) \
|
||||
for( p_oSprObjChild = p_oSprObjFather -> GetSuperObjectFirstChild() ; \
|
||||
p_oSprObjChild ; \
|
||||
p_oSprObjChild = p_oSprObjFather -> GetSuperObjectNextChild( p_oSprObjChild ) )
|
||||
|
||||
#define M_T3DDeleteSuperObject( p_oSO, bWithEngine )\
|
||||
{ \
|
||||
if( p_oSO ) \
|
||||
{ \
|
||||
if( p_oSO -> GetStruct() ) \
|
||||
p_oSO -> SetObject( NULL ); \
|
||||
if( ! bWithEngine ) \
|
||||
p_oSO -> SetSuperObjectStruct( NULL ); \
|
||||
p_oSO -> fn_bUnValidate(); \
|
||||
/*delete p_oSO;*/ \
|
||||
} \
|
||||
}
|
||||
|
||||
#define M_T3DStepSize 10
|
||||
#define M_T3DInitSize 50
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// constructor :
|
||||
//--------------------------------------------------------------------------------
|
||||
Tool3D_World::Tool3D_World(CPA_MainWorld *_p_oMainWorld)
|
||||
:CPA_World(_p_oMainWorld, TRUE)
|
||||
|
||||
{
|
||||
CPA_SuperObject *p_Root = _p_oMainWorld -> GetInterface() -> GetCopyOfSuperObject( _p_oMainWorld -> GetWorld() -> GetRoot() );
|
||||
POS_tdxHandleToPosition hMatrix;
|
||||
// fbolefeysot - 01/07/98{
|
||||
// CHN_tdxHandleToChannelArray hChannelArray;
|
||||
//END fbolefeysot}
|
||||
//CHN_tdxHandleToCASList hCAList;
|
||||
//CHN_tdxHandleToUCCList hUCCList;
|
||||
|
||||
p_Root -> SetObject(_p_oMainWorld -> GetWorld() -> GetRoot() -> GetObject());
|
||||
hMatrix = HIE_fn_hGetSuperObjectMatrix(p_Root -> GetStruct());
|
||||
POS_fn_vSetIdentityMatrix(hMatrix);
|
||||
|
||||
p_Root -> SetEditProtected( TRUE );
|
||||
fn_vSetRoot(p_Root);
|
||||
|
||||
// init values
|
||||
m_eWorldType = C_eNone;
|
||||
m_p_oRootFromAnim = NULL;
|
||||
//
|
||||
m_oListOfSO . RemoveAll();
|
||||
m_xLastSOUsedPosition = NULL;
|
||||
|
||||
m_p_oBaseFromAnim = NULL;
|
||||
m_p_oDLLPO = NULL;
|
||||
m_p_oInterface = NULL;
|
||||
|
||||
m_p_stEngineObject = (tdstEngineObject *) malloc( sizeof( struct tdstEngineObject_ ) );
|
||||
memset( m_p_stEngineObject, 0, sizeof(struct tdstEngineObject_) );
|
||||
fn_v3dDataAlloc( m_p_stEngineObject );
|
||||
//
|
||||
// fbolefeysot - 01/07/98{
|
||||
// fn_vInitCSOList( & hCSOList, );
|
||||
//END fbolefeysot}
|
||||
// fn_vInitCASList( & hCAList );
|
||||
//fn_vInitUCCList( & hUCCList );
|
||||
//
|
||||
// fbolefeysot - 01/07/98{
|
||||
fn_v3dDataSetChannelSOList( m_p_stEngineObject -> h_3dData, NULL );
|
||||
fn_v3dDataSetFirstActiveChannel(m_p_stEngineObject -> h_3dData, NULL );
|
||||
m_stState.p_stAnim = NULL;
|
||||
//END fbolefeysot}
|
||||
// fn_v3dDataSetChannelActivationList( m_p_stEngineObject -> h_3dData, hCAList );
|
||||
//fn_v3dDataSetChannelUnderControlList( m_p_stEngineObject -> h_3dData, hUCCList );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Destructor :
|
||||
//--------------------------------------------------------------------------------
|
||||
Tool3D_World::~Tool3D_World()
|
||||
{
|
||||
CPA_SuperObject *p_oSO;
|
||||
|
||||
M_T3DDeleteSuperObject( GetRoot(), TRUE );
|
||||
|
||||
fn_vSetRoot( NULL );
|
||||
while( ! m_oListOfSO . IsEmpty() )
|
||||
{
|
||||
p_oSO = m_oListOfSO . RemoveHead();
|
||||
if( p_oSO )
|
||||
M_T3DDeleteSuperObject( p_oSO, FALSE );
|
||||
}
|
||||
|
||||
free(m_p_stEngineObject);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description :
|
||||
//--------------------------------------------------------------------------------
|
||||
BOOL Tool3D_World::mfn_bAcceptModif(CPA_ObjectDLLBase *pDLLBase)
|
||||
{
|
||||
if( (m_eWorldType == C_eGridActor) || (m_eWorldType == C_eGridList) )
|
||||
return ( pDLLBase && ( ( pDLLBase -> GetName() == C_szDLLZDxName ) ||
|
||||
( pDLLBase -> GetName() == C_szDLLGeometryName )
|
||||
)
|
||||
);
|
||||
else
|
||||
return ( pDLLBase && pDLLBase -> GetName() == C_szDLLZDxName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : create a new hierarchy from an actor
|
||||
//--------------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vCreateHierarchyFromActor(CPA_SuperObject *_p_oSprObj)
|
||||
{
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : create a new hierarchy from a superobject
|
||||
//--------------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vCreateHierarchyFromSuperObject(CPA_SuperObject *_p_oSprObj)
|
||||
{
|
||||
mfn_vCreateHierarchyFromObject( _p_oSprObj -> GetObject() );
|
||||
//
|
||||
m_eWorldType = C_eSuperObject;
|
||||
m_p_oRootFromAnim = NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : create a new hierarchy from an object
|
||||
//--------------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vCreateHierarchyFromObject(CPA_BaseObject *_p_oObject)
|
||||
{
|
||||
POS_tdxHandleToPosition hMatrix;
|
||||
MTH3D_tdstVector stCenter;
|
||||
|
||||
m_eWorldType = C_eObject;
|
||||
m_p_oRootFromAnim = NULL;
|
||||
// create new SuperObject
|
||||
CPA_SuperObject *p_oNewSprObj = M_GetCopyOfSuperObject( GetRoot() );
|
||||
// set object of new SuperObject
|
||||
p_oNewSprObj -> SetObject( _p_oObject );
|
||||
//
|
||||
p_oNewSprObj -> SetEditProtected( FALSE );
|
||||
// add new SuperObject to Hierarchy
|
||||
fn_vInsertSuperObjectInNewWorld( p_oNewSprObj, GetRoot(), FALSE );
|
||||
// center object
|
||||
hMatrix = HIE_fn_hGetSuperObjectMatrix(p_oNewSprObj -> GetStruct());
|
||||
POS_fn_vSetIdentityMatrix(hMatrix);
|
||||
if( mfn_bComputeCenterAndRadiusBoundingBox( p_oNewSprObj, &stCenter ) )
|
||||
{
|
||||
MTH3D_tdstVector stTranslation;
|
||||
|
||||
POS_fn_vGetTranslationVector( hMatrix, &stTranslation );
|
||||
MTH3D_M_vSubVector(&stTranslation, &stTranslation, &stCenter);
|
||||
POS_fn_vSetTranslationVector( hMatrix, &stTranslation );
|
||||
}
|
||||
POS_fn_vNormalizeMatrix(hMatrix);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : create a new hierarchy from an actor to a grid view
|
||||
//--------------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vCreateGridHierarchyFromActor(CPA_SuperObject *_p_oSprObj)
|
||||
{
|
||||
m_eWorldType = C_eGridActor;
|
||||
m_p_oRootFromAnim = NULL;
|
||||
// create new hierarchy
|
||||
mfn_vLinearizeHierarchy( GetRoot(), _p_oSprObj);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : create a new hierarchy from a list of objects to a grid view
|
||||
//--------------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vCreateGridHierarchyFromList(CPA_List<CPA_BaseObject> *_p_oList, CPA_MainWorld *_p_oMainWorld)
|
||||
{
|
||||
m_eWorldType = C_eGridList;
|
||||
m_p_oRootFromAnim = NULL;
|
||||
// create new hierarchy
|
||||
POSITION stPos = _p_oList -> GetHeadPosition();
|
||||
while(stPos)
|
||||
{
|
||||
CPA_BaseObject *p_Object = _p_oList -> GetNext( stPos );
|
||||
//??? CPA_SuperObject *pLastSprObj = p_Object -> GetSuperObject();
|
||||
CPA_SuperObject *pSuper_Object = _p_oMainWorld -> GetInterface() -> GetNewSuperObject(E_ss_NoSave);
|
||||
// save link
|
||||
// create the matrix of the super object
|
||||
POS_tdstCompletePosition *p_stPos;
|
||||
|
||||
p_stPos = M_AllocMatrix();
|
||||
POS_fn_vSetIdentityMatrix(p_stPos);
|
||||
HIE_fn_vSetSuperObjectMatrix(pSuper_Object -> GetStruct () , p_stPos);
|
||||
|
||||
p_stPos = M_AllocMatrix();
|
||||
POS_fn_vSetIdentityMatrix(p_stPos);
|
||||
pSuper_Object -> GetStruct () -> hGlobalMatrix = p_stPos;
|
||||
|
||||
POS_fn_vSetIdentityMatrix(HIE_fn_hGetSuperObjectMatrix (pSuper_Object -> GetStruct ()));
|
||||
POS_fn_vSetIdentityMatrix(HIE_fn_hGetSuperObjectGlobalMatrix (pSuper_Object -> GetStruct ()));
|
||||
//
|
||||
pSuper_Object->SetObject(p_Object);
|
||||
// add superobject to new world
|
||||
fn_vInsertSuperObjectInNewWorld( pSuper_Object, GetRoot(), FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Description : create a new hierarchy from an objects Table
|
||||
//--------------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vCreateGridHierarchyFromTable(CPA_BaseObject *_p_oTable, CPA_MainWorld *_p_oMainWorld)
|
||||
{
|
||||
CPA_List<CPA_BaseObject> oList;
|
||||
long lNbObjects;
|
||||
|
||||
lNbObjects = _p_oMainWorld -> fn_lFindObjects( &oList, "", C_szPhysicalObjectTypeName, _p_oTable );
|
||||
if( lNbObjects )
|
||||
mfn_vCreateGridHierarchyFromList( &oList, _p_oMainWorld );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Fill world with VWOI (NEW)
|
||||
// ----------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vCreateViewerHierarchyFromVWOIList(CPA_List<tdst_VW_ObjInfo> *_p_oListOfVWOI, CPA_MainWorld *_p_oMainWorld)
|
||||
{
|
||||
m_p_oRootFromAnim = NULL;
|
||||
m_eWorldType = C_eViewer;
|
||||
// create new hierarchy
|
||||
POSITION stPos = _p_oListOfVWOI -> GetHeadPosition();
|
||||
while(stPos)
|
||||
{
|
||||
CPA_SuperObject *p_oLastFather = _p_oListOfVWOI -> GetNext(stPos) -> m_p_oSuperObject;
|
||||
CPA_BaseObject *p_oObject = p_oLastFather -> GetObject();
|
||||
CPA_SuperObject *p_oNewFather = _p_oMainWorld -> GetInterface() -> GetNewSuperObject(E_ss_NoSave);
|
||||
// add super object
|
||||
// create the matrix of the super object
|
||||
|
||||
POS_tdstCompletePosition *p_stPos;
|
||||
|
||||
p_stPos = M_AllocMatrix();
|
||||
POS_fn_vSetIdentityMatrix(p_stPos);
|
||||
HIE_fn_vSetSuperObjectMatrix(p_oNewFather -> GetStruct () , p_stPos);
|
||||
|
||||
p_stPos = M_AllocMatrix();
|
||||
POS_fn_vSetIdentityMatrix(p_stPos);
|
||||
p_oNewFather -> GetStruct () -> hGlobalMatrix = p_stPos;
|
||||
|
||||
POS_fn_vSetIdentityMatrix(HIE_fn_hGetSuperObjectMatrix (p_oNewFather -> GetStruct ()));
|
||||
POS_fn_vSetIdentityMatrix(HIE_fn_hGetSuperObjectGlobalMatrix (p_oNewFather -> GetStruct ()));
|
||||
p_oNewFather -> SetObject(p_oObject);
|
||||
// add SuperObject to new hierarchy
|
||||
fn_vInsertSuperObjectInNewWorld( p_oNewFather, GetRoot(), FALSE );
|
||||
// duplicate child hierarchy
|
||||
mfn_vDuplicateHierarchy( p_oNewFather, p_oLastFather);
|
||||
}
|
||||
// compute position of objects
|
||||
mfn_vComputeSuperObjectPosFromViewer();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Description : create hierarchy (SO+O) using anim, frame and objects table
|
||||
*---------------------------------------------------------------------------*/
|
||||
CPA_SuperObject *Tool3D_World::mfn_p_oCreateHierarchyFromAnim(CPA_SuperObject *_p_oSprObjActor)
|
||||
{
|
||||
HIE_tdxHandleToSuperObject hSO = _p_oSprObjActor -> GetStruct();
|
||||
MS_tdxHandleTo3dData h3dData = M_GetMSHandle( hSO, 3dData );
|
||||
MS_tdxHandleTo3dData h3dDataCopy = m_p_stEngineObject -> h_3dData;
|
||||
tdxHandleToState hState = fn_h3dDataGetCurrentState( h3dData ) ? fn_h3dDataGetCurrentState( h3dData )
|
||||
: fn_h3dDataGetInitialState( h3dData );
|
||||
struct tdstAnim3d_ *p_stAnim = hState ? fn_p_stGetAnimInState( hState ) : NULL;
|
||||
unsigned short uwFrame = fn_uw3dDataGetCurrentFrame( h3dData );
|
||||
POS_tdxHandleToPosition hMatrix;
|
||||
MTH3D_tdstVector stCenter;
|
||||
// fbolefeysot - 01/07/98{
|
||||
CHN_tdxHandleToChannelArray hChannelArray;
|
||||
//END fbolefeysot}
|
||||
//CHN_tdxHandleToCASList hCAList;
|
||||
//CHN_tdxHandleToUCCList hUCCList;
|
||||
|
||||
//Stefan Dumitrean 1-06-98
|
||||
if( !p_stAnim )
|
||||
return NULL;
|
||||
//End Stefan Dumitrean 1-06-98
|
||||
|
||||
m_eWorldType = C_eAnimOK;
|
||||
|
||||
// create new SuperObject that will be put in T3D world
|
||||
CPA_SuperObject *p_oNewSprObj = M_GetCopyOfSuperObject( _p_oSprObjActor );
|
||||
// T3D world actor object is the same as the main world actor object
|
||||
p_oNewSprObj -> SetObject( _p_oSprObjActor -> GetObject() );
|
||||
// duplicate 3dData structure in a safe variable
|
||||
memcpy(h3dDataCopy,h3dData,fn_ul3dDataSizeOf());
|
||||
// fn_v3dDataCopyClone( m_p_stEngineObject, (tdstEngineObject *)HIE_fn_hGetSuperObjectObject( hSO ) );
|
||||
|
||||
// clear channel array
|
||||
// fn_vInitCSOList(&hChannelArray,fn_ul3dDataGetNumberOfChannels(h3dData));
|
||||
// copy the original channel array and first active channel in the safe structure
|
||||
// fn_v3dDataSetChannelSOList( h3dDataCopy, fn_h3dDataGetChannelSOList(h3dData) );
|
||||
// fn_v3dDataSetFirstActiveChannel(h3dDataCopy,fn_h3dDataGetFirstActiveChannel(h3dData));
|
||||
// fn_p_st3dDataGetCurrentFrame(h3dDataCopy)->p_stArrayOfElts3d = fn_p_st3dDataGetCurrentFrame(h3dData)->p_stArrayOfElts3d;
|
||||
|
||||
// reset dynamic datas
|
||||
fn_v3dDataSetChannelSOList(h3dData,NULL);
|
||||
fn_v3dDataSetFirstActiveChannel(h3dData,NULL);
|
||||
fn_p_st3dDataGetCurrentFrame(h3dData)->p_stArrayOfElts3d = NULL;
|
||||
fn_p_st3dDataGetCurrentFrame(h3dData)->stHierarchy.ulNbOfCouples = 0;
|
||||
fn_p_st3dDataGetCurrentFrame(h3dData)->stHierarchy.d_stCouples= NULL;
|
||||
fn_v3dDataSetSizeOfArrayOfElts3d(h3dData,0);
|
||||
fn_v3dDataSetCurrentState(h3dData,&m_stState);
|
||||
|
||||
// put the new SuperObject into T3D world
|
||||
fn_vInsertSuperObjectInNewWorld( p_oNewSprObj, GetRoot(), FALSE );
|
||||
|
||||
// save SO tht is in the T3D world
|
||||
m_p_oRootFromAnim = p_oNewSprObj;
|
||||
// save SO that is in the real world
|
||||
m_p_oBaseFromAnim = _p_oSprObjActor;
|
||||
// init used values
|
||||
m_p_oDLLPO = GetRoot() -> GetMainWorld() -> GetObjectDLLWithName( C_szDLLPhysicalObjectName );
|
||||
m_p_oInterface = GetRoot() -> GetMainWorld() -> GetInterface();
|
||||
|
||||
// center object
|
||||
hMatrix = HIE_fn_hGetSuperObjectMatrix(p_oNewSprObj -> GetStruct());
|
||||
POS_fn_vSetIdentityMatrix(hMatrix);
|
||||
if( mfn_bComputeCenterAndRadiusBoundingBox( p_oNewSprObj, &stCenter ) )
|
||||
{
|
||||
MTH3D_tdstVector stTranslation;
|
||||
|
||||
POS_fn_vGetTranslationVector( hMatrix, &stTranslation );
|
||||
MTH3D_M_vSubVector(&stTranslation, &stTranslation, &stCenter);
|
||||
POS_fn_vSetTranslationVector( hMatrix, &stTranslation );
|
||||
}
|
||||
POS_fn_vNormalizeMatrix(hMatrix);
|
||||
|
||||
// uwFrame %= p_stAnim -> uwNumberOfFrames;
|
||||
// fn_v3dDataSetCurrentFrame( h3dData, uwFrame );
|
||||
|
||||
mfn_vUpdateHierarchyFromAnim(p_stAnim,fn_uw3dDataGetCurrentFrame(M_GetMSHandle(hSO,3dData)));
|
||||
|
||||
return p_oNewSprObj;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Description : update hierarchy (SO+O) using anim, frame and objects table
|
||||
*---------------------------------------------------------------------------*/
|
||||
void Tool3D_World::mfn_vUpdateHierarchyFromAnim(struct tdstAnim3d_* _p_stAnim, unsigned short _uwFrame)
|
||||
{
|
||||
//
|
||||
HIE_tdxHandleToSuperObject hSO = m_p_oRootFromAnim -> GetStruct();
|
||||
|
||||
m_eWorldType = C_eAnimTemp;
|
||||
// clear editor hierarchy
|
||||
mfn_vClearHierarchy( m_p_oRootFromAnim );
|
||||
// construct engine hierarchy
|
||||
fn_v3dDataSetCurrentFrame( M_GetMSHandle( hSO, 3dData ), _uwFrame );
|
||||
fn_p_st3dDataGetCurrentFrame(M_GetMSHandle(hSO,3dData))->p_stAnim = NULL;
|
||||
fn_v3dDataSetFlagModifState(M_GetMSHandle(hSO,3dData),TRUE);
|
||||
if (fn_h3dDataGetCurrentState(M_GetMSHandle(hSO,3dData))->p_stAnim == NULL)
|
||||
fn_h3dDataGetCurrentState(M_GetMSHandle(hSO,3dData))->p_stAnim = _p_stAnim;
|
||||
PLA_fn_bDoFirstInitOfAnimPlayerForCharacter(hSO, _p_stAnim);
|
||||
// encapsulate with editor object
|
||||
mfn_vFillHierarchyWithEngineAnim( m_p_oRootFromAnim, TRUE );
|
||||
//
|
||||
m_p_oInterface -> fn_vChangeWorld();
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Description : update hierarchy (SO) using anim, frame and objects table
|
||||
*---------------------------------------------------------------------------*/
|
||||
void Tool3D_World::mfn_vPlayAnim(struct tdstAnim3d_* _p_stAnim, unsigned short _uwFrame)
|
||||
{
|
||||
HIE_tdxHandleToSuperObject hSO = m_p_oRootFromAnim -> GetStruct();
|
||||
//
|
||||
m_eWorldType = C_eAnimTemp;
|
||||
// clear editor hierarchy
|
||||
mfn_vClearHierarchy( m_p_oRootFromAnim );
|
||||
// construct engine hierarchy
|
||||
fn_v3dDataSetCurrentFrame( M_GetMSHandle( hSO, 3dData ), _uwFrame );
|
||||
fn_p_st3dDataGetCurrentFrame(M_GetMSHandle(hSO,3dData))->p_stAnim = NULL;
|
||||
PLA_fn_vInitAllChildInHeapNewAnim( hSO, _p_stAnim, _uwFrame );
|
||||
PLA_fn_vDoFrame( _p_stAnim, _uwFrame, hSO );
|
||||
// encapsulate with editor object
|
||||
mfn_vFillHierarchyWithEngineAnim( m_p_oRootFromAnim, FALSE );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Remove world and delete all SuperObjects created
|
||||
// ----------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vResetWorld(void)
|
||||
{
|
||||
if( (m_eWorldType == C_eAnimTemp) || (m_eWorldType == C_eAnimOK) )
|
||||
{
|
||||
//
|
||||
HIE_tdxHandleToSuperObject hSO = m_p_oRootFromAnim -> GetStruct();
|
||||
MS_tdxHandleTo3dData h3dData = M_GetMSHandle( hSO, 3dData );
|
||||
MS_tdxHandleTo3dData h3dDataCopy = m_p_stEngineObject -> h_3dData;
|
||||
// fbolefeysot - 01/07/98{
|
||||
CHN_tdxHandleToChannelArray hChannelArray;
|
||||
//END fbolefeysot}
|
||||
//CHN_tdxHandleToCASList hCAList;
|
||||
//CHN_tdxHandleToUCCList hUCCList;
|
||||
// PLA_fn_vDesInitAllChildOfCharacter(hSO,(struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(hSO));
|
||||
|
||||
// hChannelArray = fn_h3dDataGetChannelSOList( h3dData );
|
||||
// fn_vFreeCSOList( & hChannelArray/*, fn_ul3dDataGetNumberOfChannels(h3dData)*/);
|
||||
|
||||
// fn_v3dDataSetChannelSOList( h3dData, NULL );
|
||||
// fn_v3dDataSetFirstActiveChannel( h3dData, NULL );
|
||||
|
||||
fn_v3dDataCopyClone( (tdstEngineObject *)HIE_fn_hGetSuperObjectObject( hSO ), m_p_stEngineObject );
|
||||
memcpy(h3dData,h3dDataCopy,fn_ul3dDataSizeOf());
|
||||
|
||||
// fbolefeysot - 01/07/98{
|
||||
//END fbolefeysot}
|
||||
// hCAList = fn_h3dDataGetChannelActivationList(h3dData);
|
||||
//hUCCList = fn_h3dDataGetChannelUnderControlList(h3dData);
|
||||
// restore list on Real Actor
|
||||
// fn_v3dDataSetChannelSOList( h3dData, fn_h3dDataGetChannelSOList(h3dDataCopy) );
|
||||
// fn_v3dDataSetFirstActiveChannel(h3dData,fn_h3dDataGetFirstActiveChannel(h3dDataCopy ));
|
||||
// fn_p_st3dDataGetCurrentFrame(h3dData)->p_stArrayOfElts3d = fn_p_st3dDataGetCurrentFrame(h3dDataCopy)->p_stArrayOfElts3d;
|
||||
//fn_v3dDataSetChannelActivationList( h3dData, fn_h3dDataGetChannelActivationList(h3dDataCopy) );
|
||||
//fn_v3dDataSetChannelUnderControlList( h3dData, fn_h3dDataGetChannelUnderControlList(h3dDataCopy) );
|
||||
// reinit list on local backup structure
|
||||
// fbolefeysot - 01/07/98{
|
||||
//END fbolefeysot}
|
||||
// fn_vFreeCASList( & hCAList );
|
||||
//fn_vFreeUCCList( & hUCCList );
|
||||
//
|
||||
// fbolefeysot - 01/07/98{
|
||||
// fn_vInitCSOList( & hCSOList );
|
||||
//END fbolefeysot}
|
||||
// fn_vInitCASList( & hCAList );
|
||||
//fn_vInitUCCList( & hUCCList );
|
||||
//
|
||||
// fbolefeysot - 01/07/98{
|
||||
// fn_v3dDataSetChannelSOList( h3dDataCopy, NULL );
|
||||
// fn_v3dDataSetFirstActiveChannel( h3dDataCopy, NULL );
|
||||
// fn_p_st3dDataGetCurrentFrame(h3dDataCopy)->p_stArrayOfElts3d = NULL;
|
||||
//END fbolefeysot}
|
||||
// fn_v3dDataSetChannelActivationList( h3dDataCopy, hCAList );
|
||||
//fn_v3dDataSetChannelUnderControlList( h3dDataCopy, hUCCList );
|
||||
//
|
||||
|
||||
mfn_vClearHierarchy( m_p_oRootFromAnim, TRUE );
|
||||
m_p_oRootFromAnim -> Isolate( FALSE );
|
||||
fn_vUpdateListObjects(m_p_oRootFromAnim, E_lum_Delete, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// delete New Hierarchy
|
||||
mfn_vResetHierarchy( GetRoot() );
|
||||
}
|
||||
m_p_oRootFromAnim = NULL;
|
||||
m_eWorldType = C_eNone;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// protected functions
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Duplicate Hierarchy from _p_oPreviousFather to _p_oNewFather
|
||||
// ----------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vDuplicateHierarchy(CPA_SuperObject *_p_oNewFather, CPA_SuperObject *_p_oPreviousFather)
|
||||
{
|
||||
CPA_SuperObject *p_oEdChild;
|
||||
|
||||
M_ForEachSuperObjectChild( _p_oPreviousFather, p_oEdChild )
|
||||
{
|
||||
// create new SuperObject
|
||||
CPA_SuperObject *p_oNewSprObj = M_GetCopyOfSuperObject(p_oEdChild);
|
||||
// set object of new SuperObject
|
||||
p_oNewSprObj -> SetObject( p_oEdChild -> GetObject() );
|
||||
// add new SuperObject to Hierarchy
|
||||
fn_vInsertSuperObjectInNewWorld( p_oNewSprObj, _p_oNewFather, FALSE );
|
||||
// Duplicate child Hierarchy
|
||||
mfn_vDuplicateHierarchy( p_oNewSprObj, p_oEdChild );
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Duplicate Hierarchy from _p_oPreviousFather to _p_oNewFather
|
||||
// ----------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vLinearizeHierarchy(CPA_SuperObject *_p_oNewFather, CPA_SuperObject *_p_oPreviousFather)
|
||||
{
|
||||
CPA_SuperObject *p_oEdChild;
|
||||
|
||||
M_ForEachSuperObjectChild( _p_oPreviousFather, p_oEdChild )
|
||||
{
|
||||
|
||||
// jt 19/8/97
|
||||
// Pour <20>viter de traiter les super-objets correspondant <20> des canaux
|
||||
// J'ai un cas ou les matrices du super objet ne sont pas correctement allou<6F>es -> plantage
|
||||
// Il y a surement mieux <20> faire.
|
||||
if (p_oEdChild->GetObject())
|
||||
{
|
||||
// end jt 19/8/97
|
||||
|
||||
// create new SuperObject
|
||||
CPA_SuperObject *p_oNewSprObj = M_GetCopyOfSuperObject(p_oEdChild);
|
||||
// unprotect SuperObject
|
||||
p_oNewSprObj -> SetEditProtected( FALSE );
|
||||
// set object of new SuperObject
|
||||
p_oNewSprObj -> SetObject( p_oEdChild -> GetObject() );
|
||||
// add new SuperObject to Hierarchy
|
||||
fn_vInsertSuperObjectInNewWorld( p_oNewSprObj, _p_oNewFather, FALSE );
|
||||
// Duplicate child Hierarchy
|
||||
mfn_vLinearizeHierarchy( _p_oNewFather, p_oEdChild );
|
||||
|
||||
|
||||
// jt 19/8/97
|
||||
}
|
||||
// end jt 19/8/97
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : Delete all SuperObjects from hierarchy
|
||||
// ----------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vDeleteHierarchy( CPA_SuperObject *_p_oFather )
|
||||
{
|
||||
// delete child
|
||||
CPA_SuperObject *p_oEdChild = _p_oFather -> GetSuperObjectFirstChild();
|
||||
while ( p_oEdChild )
|
||||
{
|
||||
CPA_SuperObject *p_oChild = p_oEdChild;
|
||||
// next child
|
||||
p_oEdChild = _p_oFather -> GetSuperObjectNextChild( p_oEdChild );
|
||||
// delete
|
||||
mfn_vDeleteHierarchy( p_oChild );
|
||||
}
|
||||
// remove from hierarchy
|
||||
fn_vDeleteSuperObjectInNewWorld( _p_oFather, FALSE ) ;
|
||||
// delete father
|
||||
M_T3DDeleteSuperObject( _p_oFather, TRUE );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : compute max sphere box
|
||||
// ----------------------------------------------------------------------------
|
||||
MTH_tdxReal Tool3D_World::m_fn_vComputeMaxSphereBoxRadius(void)
|
||||
{
|
||||
MTH_tdxReal xMaxSphereBoxRadius = 0;
|
||||
|
||||
CPA_SuperObject *p_oEdChild;
|
||||
M_ForEachSuperObjectChild( GetRoot(), p_oEdChild )
|
||||
{
|
||||
MTH_tdxReal xRadius = m_fn_xGetSphereBoxRadius( p_oEdChild );
|
||||
xMaxSphereBoxRadius = MTH_M_xMax( xMaxSphereBoxRadius, xRadius );
|
||||
}
|
||||
|
||||
return xMaxSphereBoxRadius;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Description : compute radius of object sphere box (with his child)
|
||||
// ----------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vComputeSuperObjectPosFromViewer(void)
|
||||
{
|
||||
// compute max sphere box radius
|
||||
MTH_tdxReal xRadius = MTH_M_xMul(m_fn_vComputeMaxSphereBoxRadius() , 100 );
|
||||
short wIndex = 0;
|
||||
|
||||
CPA_SuperObject *p_oEdChild;
|
||||
M_ForEachSuperObjectChild( GetRoot(), p_oEdChild )
|
||||
{
|
||||
POS_tdxHandleToPosition hMatrix;
|
||||
MTH3D_tdstVector st3DCenter,st3DPosition;
|
||||
MTH3D_tdstVector stTranslation;
|
||||
|
||||
MTH3D_M_vSetVectorElements(&st3DPosition, MTH_M_xMul(xRadius,wIndex) , 0 , 0 );
|
||||
hMatrix = HIE_fn_hGetSuperObjectMatrix(p_oEdChild->GetStruct());
|
||||
POS_fn_vSetIdentityMatrix(hMatrix);
|
||||
|
||||
// get translation vector
|
||||
POS_fn_vGetTranslationVector( hMatrix, &stTranslation );
|
||||
|
||||
// First, centred with sphere box center
|
||||
if( m_fn_bGetSphereBoxCenter( p_oEdChild, &st3DCenter ) )
|
||||
{
|
||||
MTH3D_M_vSubVector(&stTranslation, &stTranslation, &st3DCenter);
|
||||
}
|
||||
// Second, place the object
|
||||
MTH3D_M_vAddVector(&stTranslation, &stTranslation, &st3DPosition);
|
||||
|
||||
// set translation vector
|
||||
POS_fn_vSetTranslationVector( hMatrix, &stTranslation );
|
||||
|
||||
// Force the absolute matrix to be recalculated
|
||||
POS_fn_vNormalizeMatrix(hMatrix);
|
||||
|
||||
wIndex++;
|
||||
}
|
||||
HIE_fn_vInvalidateAllGlobalMatrices();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Compute the sphere box radius of an object
|
||||
//--------------------------------------------------------------------------------------
|
||||
MTH_tdxReal Tool3D_World::m_fn_xGetSphereBoxRadius(CPA_SuperObject *_p_oSprObj)
|
||||
{
|
||||
MTH_tdxReal xResult;
|
||||
|
||||
if( mfn_bComputeCenterAndRadiusBoundingBox( _p_oSprObj, NULL, &xResult ) )
|
||||
return xResult;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Compute the sphere box center of an object
|
||||
//--------------------------------------------------------------------------------------
|
||||
BOOL Tool3D_World::m_fn_bGetSphereBoxCenter(CPA_SuperObject *_p_oSprObj, MTH3D_tdstVector *_p_stCenter)
|
||||
{
|
||||
CPA_BaseObject *p_oObject = _p_oSprObj -> GetObject();
|
||||
|
||||
if( p_oObject )
|
||||
{
|
||||
MTH_tdxReal xResult;
|
||||
|
||||
ACP_tdxHandleOfObject hObj = ((CPA_ObjectDLLBase*)p_oObject -> GetEditor()) -> fn_hGetBoundingVolume( p_oObject );
|
||||
if( hObj )
|
||||
{
|
||||
GEO_fn_vGetInfoFromGeometricSphere( _p_stCenter, &xResult, hObj );
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Compute center of Bounding Box from geometric object
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
BOOL Tool3D_World::mfn_bComputeCenterAndRadiusBoundingBox(CPA_SuperObject *_p_oSprObj, MTH3D_tdstVector *_p_stCenter /*=NULL*/, MTH_tdxReal *_xRadius /*=NULL*/)
|
||||
{
|
||||
CPA_BaseObject *p_oObject = (_p_oSprObj) ? _p_oSprObj -> GetObject() : NULL;
|
||||
|
||||
|
||||
|
||||
if( p_oObject )
|
||||
{
|
||||
MTH_tdxReal xResult;
|
||||
MTH3D_tdstVector stCenter;
|
||||
|
||||
ACP_tdxHandleOfObject hObj = ((CPA_ObjectDLLBase*)p_oObject -> GetEditor()) -> fn_hGetBoundingVolume( p_oObject );
|
||||
if( hObj )
|
||||
{
|
||||
GEO_fn_vGetInfoFromGeometricSphere( &stCenter, &xResult, hObj );
|
||||
|
||||
if( _p_stCenter )
|
||||
{
|
||||
POS_tdxHandleToPosition hMatrix;
|
||||
MTH3D_M_vNullVector( _p_stCenter );
|
||||
hMatrix = HIE_fn_hGetSuperObjectMatrix(_p_oSprObj->GetStruct());
|
||||
POS_fn_vMulMatrixVertex( _p_stCenter, hMatrix, &stCenter );
|
||||
}
|
||||
if( _xRadius )
|
||||
*_xRadius = xResult;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Author : MT
|
||||
// Creation : 20/08/97
|
||||
//
|
||||
// Description : reset hierarchy from given root
|
||||
// ----------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vResetHierarchy(CPA_SuperObject *_p_oRootSO)
|
||||
{
|
||||
// delete New Hierarchy
|
||||
CPA_SuperObject *p_oEdChild = _p_oRootSO -> GetSuperObjectFirstChild();
|
||||
while ( p_oEdChild )
|
||||
{
|
||||
CPA_SuperObject *_p_oChild = p_oEdChild;
|
||||
p_oEdChild = _p_oRootSO -> GetSuperObjectNextChild( p_oEdChild );
|
||||
// delete child hierarchy
|
||||
mfn_vDeleteHierarchy( _p_oChild );
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Author : MT
|
||||
// Creation : 20/08/97
|
||||
//
|
||||
// Description :
|
||||
// ----------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vFillHierarchyWithEngineAnim( CPA_SuperObject *_p_oRootSO, BOOL _bWithObject /*=TRUE*/ )
|
||||
{
|
||||
m_xLastSOUsedPosition = m_oListOfSO . GetHeadPosition();
|
||||
//
|
||||
if( _p_oRootSO && _p_oRootSO -> GetStruct() )
|
||||
mfn_vFillHierarchy( _p_oRootSO, _bWithObject );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Author : MT
|
||||
// Creation : 20/08/97
|
||||
//
|
||||
// Description :
|
||||
// ----------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vFillHierarchy( CPA_SuperObject *_p_oRootSO, BOOL _bWithObject /*=TRUE*/ )
|
||||
{
|
||||
HIE_tdxHandleToSuperObject hSO;
|
||||
HIE_tdxHandleToSuperObject hSOChild;
|
||||
long lIndex;
|
||||
tdxHandleToVoid hObject;
|
||||
CPA_BaseObject *p_oObject;
|
||||
CPA_SuperObject *p_oSO;
|
||||
|
||||
ASSERT( _p_oRootSO && _p_oRootSO -> GetStruct() );
|
||||
|
||||
hSO = _p_oRootSO -> GetStruct();
|
||||
lIndex = 0;
|
||||
HIE_M_ForEachChildOf( hSO, hSOChild, lIndex )
|
||||
{
|
||||
// SO
|
||||
if( m_xLastSOUsedPosition )
|
||||
{
|
||||
p_oSO = m_oListOfSO . GetNext( m_xLastSOUsedPosition );
|
||||
p_oSO -> SetSuperObjectStruct( hSOChild );
|
||||
}
|
||||
else
|
||||
{
|
||||
p_oSO = m_p_oInterface -> GetNewSuperObject( hSOChild, E_ss_NoSave );
|
||||
m_oListOfSO . AddTail( p_oSO );
|
||||
}
|
||||
ASSERT( p_oSO );
|
||||
_p_oRootSO -> AddANewChild( p_oSO, FALSE );
|
||||
fn_vUpdateListObjects( p_oSO, E_lum_Insert, FALSE);
|
||||
// Object
|
||||
if ( _bWithObject )
|
||||
{
|
||||
if( HIE_fn_ulGetSuperObjectType( hSOChild ) == HIE_C_ulPO )
|
||||
{
|
||||
hObject = HIE_fn_hGetSuperObjectObject( hSOChild );
|
||||
p_oObject = hObject ? m_p_oDLLPO -> GetBaseObject( hObject, C_szPhysicalObjectTypeName ) : NULL;
|
||||
p_oSO -> SetObject( p_oObject );
|
||||
}
|
||||
}
|
||||
// hierarchy
|
||||
if( p_oSO && p_oSO -> GetStruct() )
|
||||
mfn_vFillHierarchy( p_oSO, _bWithObject );
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Author : MT
|
||||
// Creation : 21/08/97
|
||||
//
|
||||
// Description :
|
||||
// ----------------------------------------------------------------------------
|
||||
void Tool3D_World::mfn_vClearHierarchy( CPA_SuperObject *_p_oRootSO, BOOL _bDelete /*=FALSE*/ )
|
||||
{
|
||||
CPA_SuperObject *p_oSO;
|
||||
POSITION xPos;
|
||||
|
||||
xPos = m_oListOfSO . GetHeadPosition();
|
||||
while( xPos )
|
||||
{
|
||||
p_oSO = m_oListOfSO . GetNext( xPos );
|
||||
p_oSO -> Isolate( FALSE );
|
||||
fn_vUpdateListObjects( p_oSO, E_lum_Delete, FALSE);
|
||||
if( _bDelete )
|
||||
{
|
||||
M_T3DDeleteSuperObject( p_oSO , FALSE );
|
||||
}
|
||||
}
|
||||
m_xLastSOUsedPosition = m_oListOfSO . GetHeadPosition();
|
||||
}
|
||||
|
||||
#endif //ACTIVE_EDITOR
|
1698
Rayman_X/cpa/tempgrp/T3D/src/T3Dinterf.cpp
Normal file
1698
Rayman_X/cpa/tempgrp/T3D/src/T3Dinterf.cpp
Normal file
File diff suppressed because it is too large
Load Diff
10
Rayman_X/cpa/tempgrp/T3D/src/_T3d.def
Normal file
10
Rayman_X/cpa/tempgrp/T3D/src/_T3d.def
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
LIBRARY
|
||||
EXPORTS
|
||||
fn_p_szGetCPAVersion
|
||||
fn_p_stGetDLLIdentity
|
||||
fn_p_oGetDLL
|
||||
fn_vInitDll
|
||||
SECTIONS
|
||||
.data READ WRITE
|
1324
Rayman_X/cpa/tempgrp/T3D/src/animview.cpp
Normal file
1324
Rayman_X/cpa/tempgrp/T3D/src/animview.cpp
Normal file
File diff suppressed because it is too large
Load Diff
116
Rayman_X/cpa/tempgrp/T3D/src/dllcom.cpp
Normal file
116
Rayman_X/cpa/tempgrp/T3D/src/dllcom.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// Common functions for Object DLL capabilities
|
||||
// C. Beaudet
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "ACP_Base.h"
|
||||
#define HieFriend
|
||||
#include "incGam.h"
|
||||
#include "Itf.h"
|
||||
|
||||
#include "T3Dinterf.hpp"
|
||||
#include "X:\Cpa\Main\inc\_EditID.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Global vars
|
||||
static char *gs_p_szCPAVersion = C_szCPAVersion;
|
||||
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
|
||||
|
||||
#ifdef DLL_ONLY_ONE_INSTANCE
|
||||
static Tool3D_Interface *gs_p_oTool3DInterface = NULL;
|
||||
#endif
|
||||
|
||||
static CList<CPA_DLLBase*,CPA_DLLBase*> g_oListOfInstances; //private internal
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// functions that are present in all DLL :
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
//========================================================================
|
||||
// Get current CPA version
|
||||
//========================================================================
|
||||
extern "C" char __declspec(dllexport) *fn_p_szGetCPAVersion(void)
|
||||
{
|
||||
return gs_p_szCPAVersion;
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
// Get type of this DLL
|
||||
//========================================================================
|
||||
extern "C" tdstDLLIdentity __declspec(dllexport) *fn_p_stGetDLLIdentity(void)
|
||||
{
|
||||
g_stTool3DIdentity . eType = TOOL_DLL;
|
||||
g_stTool3DIdentity . csName = C_szDLLTool3DName;
|
||||
g_stTool3DIdentity . hModule = NULL;
|
||||
g_stTool3DIdentity . p_oListOfInstances = &g_oListOfInstances;
|
||||
|
||||
return &g_stTool3DIdentity;
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
// DLL int function
|
||||
//========================================================================
|
||||
extern "C" void __declspec(dllexport) fn_vInitDll(void)
|
||||
{
|
||||
new CDynLinkLibrary(extensionDLL);
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
// DLL entry point
|
||||
//========================================================================
|
||||
extern "C" int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
if (!AfxInitExtensionModule(extensionDLL, hInstance))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
// Get the DLL
|
||||
//========================================================================
|
||||
extern "C" CPA_DLLBase __declspec(dllexport) *fn_p_oGetDLL(long lKey)
|
||||
{
|
||||
#ifdef DLL_ONLY_ONE_INSTANCE
|
||||
|
||||
switch(lKey)
|
||||
{
|
||||
case 0: // the game world
|
||||
if (gs_p_oTool3DInterface == NULL)
|
||||
{
|
||||
gs_p_oTool3DInterface = new Tool3D_Interface();
|
||||
ASSERT(gs_p_oTool3DInterface != NULL);
|
||||
}
|
||||
return gs_p_oTool3DInterface;
|
||||
break;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#else //DLL_ONLY_ONE_INSTANCE
|
||||
|
||||
switch(lKey)
|
||||
{
|
||||
case 0: // the game world
|
||||
return new Tool3D_Interface();
|
||||
break;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif //DLL_ONLY_ONE_INSTANCE
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// functions that are present in this type of DLL only :
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#undef DLL_ONLY_ONE_INSTANCE
|
Reference in New Issue
Block a user