reman3/Rayman_X/cpa/tempgrp/AI/AIGame/Procedu1.cxx

5948 lines
214 KiB
C++

/************************************************************************************************
* Name: Procedu1.c *
* Use : Procedures for AI of Rayman II and Egypte *
* Author: Benoit Germain, Christophe Giraud, Jacques Thénoz *
* (c) UBI Simulations Annecy *
************************************************************************************************/
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
extern AI_tdstMind *p_stCurrentMind; /*declared in Intell.c*/
#endif
/*VLTEMPORARY*/
/* Oliv' - Portage v14 & v15*/
#ifndef U64
#include "x:\cpa\tempgrp\gliglou\multidrv\inc\dispmode.h"
#else
#include "Gli\Specif\InitRast.h"
#endif /* U64 */
/* EndOfOliv'*/
/*EVL*/
#ifdef U64
/* For resolution switching...*/
#include "u_boot.h"
#include "u_cfb.h"
#include "U_zbuf.h"
#include "GLD/Specif/u_vpt.h"
extern short g_wWhichFrameBuffer;
extern void GAM_fn_vSwitchToLores();
extern void GAM_fn_vSwitchToHires();
/* For language switching...*/
#include "LDR/Specif/GetVal.h"
void FON_fn_vLoadTextStringInOneLanguage(unsigned short _uwLanguageId);
#endif /*U64*/
/*************** FabPerez Cheat Code *******/
#if defined (WIN32) && defined (_DEBUG)
#ifndef CHEAT_CODE_DELTA_TIME
#define CHEAT_CODE_DELTA_TIME 1
#endif
#ifndef PRF_C_lMaxNbCheatCodeVariable
#define PRF_C_lMaxNbCheatCodeVariable 3
#endif
#ifndef CHEAT_CODE_INVERT_PAD
#define CHEAT_CODE_INVERT_PAD 2
#endif
#ifndef CHEAT_CODE_RANDOM_PAD
#define CHEAT_CODE_RANDOM_PAD 3
#endif
#ifdef __cplusplus
extern "C"
{
#endif // cplusplus
extern BOOL g_CheatCodeActivate;
extern unsigned long g_ulCurrentCheatCode;
extern BOOL (*a_p_fnCheatCodeFonction[PRF_C_lMaxNbCheatCodeVariable] )(BOOL);
extern BOOL a_lCheatCodeVariable[PRF_C_lMaxNbCheatCodeVariable];
#ifdef __cplusplus
}
#endif // cplusplus
#ifdef __cplusplus
extern "C"
{
#endif // cplusplus
int g_iXValueCheat, g_iYValueCheat;
#ifdef __cplusplus
}
#endif // cplusplus
BOOL (*p_fn)(BOOL);
#endif //(WIN32) & (DEBUG)
/************ Fin FabPerez Cheat Code **********/
#ifdef __cplusplus
extern "C"
{
#endif
extern void GAM_fn_vWriteStringInUbiIniFile( char *_szKey, char *_szID, char *_szBuffer ) ;
extern MTH_tdxReal MEC_g_xBaseCoeff;
extern MTH_tdxReal MEC_g_xWalkCoeff;
#ifdef __cplusplus
}
#endif
/*ANNECY BBB 16/10/97 {*/
tdstNodeInterpret *fn_p_stCustomBitsProc(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
unsigned long ulCurrentBits;
MS_tdxHandleToStandardGame hStdGame;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
hStdGame = M_GetMSHandle(hNewSuperObjPerso,StandardGame);
/*get the current value of the custom bits*/
ulCurrentBits = fn_ulStandardGameGetCustomBits(hStdGame);
M_EvalNextParameter(&stParam);
switch ( eProcedureId )
{
case eProc_ChangeOneCustomBit:
{
unsigned long ulMask = (1 << (M_GetSetParam_lValue(&stParam) - 1));
SAF_M_AssertWithMsg((ulMask & C_ulUnchangableCustomBits) == 0, "Tentative de modification d'un CustomBit en lecture seule");
/*read the boolean that tells to set/clear the bit*/
M_EvalNextParameter(&stParam);
if ( M_GetSetParam_lValue(&stParam) ) /*if true*/
ulCurrentBits |= ulMask; /*set the bit*/
else
ulCurrentBits &= ~ulMask; /*else clear it*/
/*store the bits back into the ministructure*/
fn_vStandardGameSetCustomBits(hStdGame, ulCurrentBits);
}
break;
case eProc_ChangeManyCustomBits:
{
unsigned long ulBitMask, ulNewBits;
/*read the boolean that tells which bits are affected by the next mask*/
ulBitMask = M_GetSetParam_lValue(&stParam);
SAF_M_AssertWithMsg((ulBitMask & C_ulUnchangableCustomBits) == 0, "Tentative de modification d'un CustomBit en lecture seule");
/*read the values that are to be affected to the bits*/
M_EvalNextParameter(&stParam);
ulNewBits = M_GetSetParam_lValue(&stParam);
/*clear the bits to be affected in the current value*/
ulCurrentBits &= ~ulBitMask;
/*clear the unused bits of the new value*/
ulNewBits &= ulBitMask;
/*copy the bits that are set from the new to the current value*/
ulCurrentBits |= ulNewBits;
/*store the bits back into the ministructure*/
fn_vStandardGameSetCustomBits(hStdGame, ulCurrentBits);
}
break;
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
break;
}
return p_stTree;
}
/* -----------------01/12/97 10:18-------------------
string manipulation routines
--------------------------------------------------*/
tdstNodeInterpret *fn_p_stStringProc(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
char *pszString = NULL;
short wAffectedPos, wNewCharacter, wStringLength = 0;
/*start by reading all the parameters*/
M_EvalNextParameter(&stParam);
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
if ( eProcedureId != eProc_ChangeLanguage )
{
pszString = (char *)fn_szGetStringFromTextOrStringParam(&stParam);
/*HP*/
if(pszString)
wStringLength = strlen(pszString);
M_EvalNextParameter(&stParam);
}
#else /* FQ 24/08/99 : When AI_EXCLUDE... eProc_StringAddChar is still available !! */
if ( eProcedureId == eProc_StringAddChar )
{
pszString = (char *)fn_szGetStringFromTextOrStringParam(&stParam);
/*HP*/
if(pszString)
wStringLength = strlen(pszString);
M_EvalNextParameter(&stParam);
}
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
wAffectedPos = M_GetSetParam_lValue(&stParam);
switch ( eProcedureId )
{
case eProc_ChangeLanguage:
/*we use wAffectedPos as the language identifier*/
SAF_M_AssertWithMsg(wAffectedPos >= 0 && wAffectedPos < FON_fn_uwGetNumberOfAvailableLanguages(), "Langue non disponible");
g_stEngineStructure.ucCurrentLanguage = (unsigned char) wAffectedPos;
#ifdef U64
//FB170399
fn_vStartLoad();
fn_vLoadFat(-1);
FON_fn_vLoadTextStringInOneLanguage(g_stEngineStructure.ucCurrentLanguage);
fn_vEndLoad();
#else
{ /* in PC, update the ubi.ini file with the selected language */
GAM_fn_vWriteStringInUbiIniFile( "RAYMAN2" , "Language" , g_stEngineStructure . p_stLanguageTable [ g_stEngineStructure.ucCurrentLanguage ] . szLanguageCode ) ;
}
#endif
break;
case eProc_StringAddChar:
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
case eProc_StringReplaceChar:
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
if ( wAffectedPos >= 0 && wAffectedPos < wStringLength )
{
M_EvalNextParameter(&stParam);
wNewCharacter = M_GetSetParam_lValue(&stParam);
pszString += wAffectedPos;
/*make room for the new character if we insert it*/
if ( eProcedureId == eProc_StringAddChar )
{
/*mve the terminating zero as well*/
#ifdef U64
/* Here, we move the size too */
memmove(pszString + 1, pszString, wStringLength - wAffectedPos + 2);
#else
memmove(pszString + 1, pszString, wStringLength - wAffectedPos + 1);
#endif
}
/*change the character as specified*/
*pszString = (char) wNewCharacter;
}
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_StringRemoveChar:
if ( wAffectedPos >= 0 && wAffectedPos < wStringLength )
{
pszString += wAffectedPos;
/*this moves the terminating zero as well*/
memmove(pszString, pszString + 1, wStringLength - wAffectedPos);
}
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
break;
}
return p_stTree;
}
/***********************************************************************
* Function : TEXT_EntierEnTexte ( TEXTE, entier )
************************************************************************/
tdstNodeInterpret *fn_p_stIntToText(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
char* pszString;
int iValue;
#ifdef U64
long lSize;
#endif
/* Get String */
M_EvalNextParameter(&stParam);
pszString = (char *)fn_szGetStringFromTextOrStringParam(&stParam);
#ifdef U64
lSize = (long)(unsigned char)*((unsigned char *)pszString + (strlen(pszString)+1));
#endif
/* Get value*/
M_EvalNextParameter(&stParam);
iValue = M_ReturnParam_lValue (&stParam);
itoa ( iValue, pszString, 10 );
#ifdef U64
*((unsigned char *)pszString + strlen(pszString)+1) = (unsigned char) lSize;
#endif
return(p_stTree);
}
/* --------------------------------------------------
parameters for a given action code are:
eProc_SetColliderType
-> collider priority
-> type
eProc_SetColliderVector
-> collider priority
-> vector index
-> vector
eProc_SetColliderReal
-> collider priority
-> real index
-> real
if the priority is higher or equal to the current one, the action can take place, else the information is not replaced
-------------------------------------------------- */
tdstNodeInterpret *fn_p_stCollideCommunicationProc(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
HIE_tdxHandleToSuperObject hNewSuperObjPerso = p_SuperObjPerso;
MS_tdxHandleToCollSet hCollSet;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
unsigned char ucPriority;
short wIndex = -1;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
hCollSet = M_GetMSHandle(hNewSuperObjPerso,CollSet);
/*SAF_M_AssertWithMsg(hCollSet, "hCollSet est nulle!")*/
M_EvalNextParameter(&stParam);
ucPriority = M_GetSetParam_lValue(&stParam);
/*make sure we read all the arguments to keep the tree interpreter on the road*/
M_EvalNextParameter(&stParam);
switch ( eProcedureId )
{
case eProc_SetColliderType:
/*there is no additionnal argument*/
break;
case eProc_SetColliderVector:
case eProc_SetColliderReal:
/*read the index and go to the next argument*/
wIndex = M_GetSetParam_wValue(&stParam);
M_EvalNextParameter(&stParam);
break;
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
return p_stTree;
break; /* anti-bug GCC N64*/
}
/* we do the deed only if no collider of higher priority came before*/
if ( hCollSet && ucPriority >= fn_ucCollSetGetColliderPriority(hCollSet) )
{
/* this is the new priority, so that no one of lower priority can do it before I handled the collision*/
fn_vCollSetSetColliderPriority(hCollSet, ucPriority);
switch ( eProcedureId )
{
case eProc_SetColliderType:
fn_vCollSetSetColliderType(hCollSet, M_GetSetParam_cValue(&stParam));
break;
case eProc_SetColliderVector:
SAF_M_AssertWithMsg((wIndex >= 0) && (wIndex < C_wCollsetNbCollisionVectors), "L'index du vecteur spécifié n'existe pas!");
fn_vCollSetSetColliderVector(hCollSet, wIndex, &M_GetSetParam_stVertexValue(&stParam));
break;
case eProc_SetColliderReal:
SAF_M_AssertWithMsg((wIndex >= 0) && (wIndex < C_wCollsetNbCollisionReals), "L'index du réel spécifié n'existe pas!");
//fn_vCollSetSetColliderReal(hCollSet, wIndex, M_GetSetParam_xValue(&stParam));
fn_vCollSetSetColliderReal(hCollSet, wIndex, M_ReturnParam_xValue(&stParam));
break;
default:
break;
}
}
return p_stTree;
}
/* -----------------19/11/97 10:51-------------------
parameters for a given action code are:
eProc_SetFullModuleOrientation
-> channel
-> boolean TRUE: world axis, FALSE: perso axis
-> imposed axis
-> proposed axis
-> constant = 0-5
eProc_SetFullModuleOrientationWithOffset
-> channel
-> boolean TRUE: world axis, FALSE: perso axis
-> imposed axis
-> proposed axis
-> constant = 0-5
-> offset vector
eProc_SetFullPersoOrientation
-> imposed axis
-> proposed axis
-> constant = 0-5
eProc_SetFullPersoOrientationWithOffset
-> imposed axis
-> proposed axis
-> constant = 0-5
-> offset vector
--------------------------------------------------*/
void fn_vUpdateSuperObjectAfter3DChanges
(
HIE_tdxHandleToSuperObject _p_SuperObj, /* actor or channel superobject*/
POS_tdstCompletePosition *_hGLobalMovedMatrix, /* if non null, matrix must be imposed in mechanics (for actors)*/
MTH3D_tdstVector *_p_stNewPosition, /* if non null, sector and mechanics must be updated*/
ACP_tdxBool _bIsAnActor /* for actors only!*/
)
{
/*compute the associated relative matrix*/
HIE_fn_vComputeNewRelativeMatrix(_p_SuperObj);
/* for actors only: update the relevant information*/
if ( _bIsAnActor )
{
/*compute the destination sector*/
/*ATTENTION: VIRE CAR SEMBLE INUTILE (FAIT A LA FIN DE LE TRAME), MAIS ON NE SAIT JAMAIS*/
/*if ( _p_stNewPosition )
{
MS_tdxHandleToSectInfo hSectInfo = M_GetMSHandle(_p_SuperObj, SectInfo); // preserve previous sector
HIE_tdxHandleToSuperObject hTmpSector = fn_h_SectInfoGetCurrentSector(hSectInfo);
fn_vSectInfoInitForSingleCharacter(_p_SuperObj, _p_stNewPosition); // recompute sector information
fn_vSectInfoSetCurrentSector(hSectInfo, hTmpSector); // restore previous sector
}*/
/*tell the dynamics about it if relevant (we know we are an actor, but with a brain ?)*/
if ( _hGLobalMovedMatrix && M_GetMSHandle(_p_SuperObj, Dynam) )
{
MEC_vImposeRotationMatrix(
fn_p_stDynamGetDynamics(M_GetMSHandle(_p_SuperObj, Dynam)),
_hGLobalMovedMatrix
);
}
}
}
tdstNodeInterpret *fn_p_st3DProc_ForReorientation(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
HIE_tdxHandleToSuperObject hNewSuperObjPerso = p_SuperObjPerso, hChannelSuperObject = NULL, hCharSO = p_SuperObjPerso;
POS_tdstCompletePosition *hGLobalMovedMatrix;
unsigned char uwChannel = C_ucUnknownChannel, uwSecondaryMode = 0;
MTH3D_tdstVector stImposedAxis, stProposedAxis, stGlobalTranslation, stInducedTranslation;
ACP_tdxBool bTranslationChanged = 0, bGlobalVectors = 1;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
hCharSO = hNewSuperObjPerso;
switch ( eProcedureId )
{
case eProc_SetFullModuleOrientation:
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_SetFullModuleOrientationWithOffset:
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
/*read the channel identifier and get the superobject in it*/
M_EvalNextParameter(&stParam);
uwChannel = M_GetSetParam_lModuleValue(&stParam);
if ( uwChannel == C_ucUnknownChannel )
{
/*an invalid argument renders the procedure inoperant*/
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
hChannelSuperObject = fn_hGetSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(hNewSuperObjPerso,3dData)), uwChannel);
/*get the boolean that says whether the vectors are relative to the actor or not*/
M_EvalNextParameter(&stParam);
bGlobalVectors = M_GetSetParam_lValue(&stParam);
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
/*remember whether an offset is to be retrieved or not*/
bTranslationChanged |= (eProcedureId == eProc_SetFullModuleOrientationWithOffset);
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
/*fall through*/
case eProc_SetFullPersoOrientation:
case eProc_SetFullPersoOrientationWithOffset:
/*read the two vectors (imposed and proposed*/
M_EvalNextParameter(&stParam);
stImposedAxis = M_GetSetParam_stVectorValue(&stParam);
M_EvalNextParameter(&stParam);
stProposedAxis = M_GetSetParam_stVectorValue(&stParam);
/*read the interpretation mode*/
M_EvalNextParameter(&stParam);
uwSecondaryMode = M_GetSetParam_uwValue(&stParam);
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
if ( uwSecondaryMode > 5 ) /* not a valid value: go back to editor mode*/
{
char MyMsg[150];
sprintf(MyMsg,"(reorientation procedure) invalid arg in IA of '%s'", p_stCurrentMind->szPersoName);
Erm_fn_iMessageBox (MyMsg,"STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
#endif
#endif /* (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)*/
/*read the offset vector (which is always local to the rotated superobject*/
bTranslationChanged |= (eProcedureId == eProc_SetFullPersoOrientationWithOffset);
if ( bTranslationChanged )
{
M_EvalNextParameter(&stParam);
stGlobalTranslation = M_GetSetParam_stVectorValue(&stParam);
}
break;
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
return p_stTree;
break; /* anti-bug GCC N64*/
}
/*for modules, the provided vectors can be expressed relatively to the owning actor:*/
/*so convert them back into world coordinates if the next argument says so*/
if ( uwChannel != C_ucUnknownChannel )
{
if ( !bGlobalVectors )
{
/*get the global matrix of the actor's superobject*/
POS_tdstCompletePosition *hPersoGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(hNewSuperObjPerso);
/* rotate the vectors to convert them*/
POS_fn_vMulMatrixVector(&stImposedAxis, hPersoGlobalMatrix, &stImposedAxis);
POS_fn_vMulMatrixVector(&stProposedAxis, hPersoGlobalMatrix, &stProposedAxis);
}
/* when we work on a channel that contains an object, do it as if it were an actor (almost - mechanics is not implied)*/
if ( hChannelSuperObject )
{
/*
#if defined ( __DEBUG_AI__ )
// make sure it is controlled
POS_tdstCompletePosition *hOldLocalMatrix, *hNewLocalMatrix;
//retrieve the local matrix of the moved channel
hOldLocalMatrix = HIE_fn_hGetSuperObjectMatrix(hChannelSuperObject);
//force the channel to be controlled, but only in debug mode
fn_vTakeControlOfChannel((tdstEngineObject *)HIE_fn_hGetSuperObjectObject(hNewSuperObjPerso), uwChannel);
//force the allocated matrix to replace the channel matrix immediately for all controled modules
fn_vUpdateMatrixOfControledChannels((tdstEngineObject *)HIE_fn_hGetSuperObjectObject(hNewSuperObjPerso));
//get the local matrix again
hNewLocalMatrix = HIE_fn_hGetSuperObjectMatrix(hChannelSuperObject);
// if it changed, it means that the channel was not controlled, which is BAD!!!
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
if ( hNewLocalMatrix != hOldLocalMatrix )
{
char MyMsg[150];
sprintf(MyMsg,"%s's channel %d is not controlled", p_stCurrentMind->szPersoName, uwChannel);
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningChannelNotControlled, C_ucErmNoOpenInfoWindow, MyMsg)
}
#endif //(defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#endif
*/
/* FBF blindage acces modules {*/
SAF_M_AssertWithMsg( (fn_ulStandardGameGetCustomBitsSO(hNewSuperObjPerso) & GAM_C_CustBitNeedModuleMatrices) &&
HIE_fn_bIsGlobalMatrixValid(hNewSuperObjPerso)
,"Use of Module Global Matrix without the custom bit 2 (need module matrice)\n"
"You must set this CustomBit to TRUE if you want to use this function");
/* } fin blindage acces modules*/
/* work with the channel as with an actor (both are superobjets and are handled the same way*/
hNewSuperObjPerso = hChannelSuperObject;
}
/* else keep the actor to work with*/
}
/*retrieve the global matrix of the moved superobject*/
hGLobalMovedMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(hNewSuperObjPerso);
/*a rotation axis offset is proposed: compute its position in world coordinates*/
if ( bTranslationChanged )
{
/*convert the offset vector in world coordinates*/
POS_fn_vMulMatrixVector(&stInducedTranslation, hGLobalMovedMatrix, &stGlobalTranslation);
}
/*now that we are ready, compute the new rotation matrix of the superobject's position*/
{
MTH3D_tdstVector stI, stJ, stK, stTmp;
/*if the vector we got is null, use the current one instead*/
POS_fn_vGetRotationMatrix(hGLobalMovedMatrix, &stI, &stJ, &stK);
if ( MTH3D_M_bIsNullVector(&stImposedAxis) )
{
switch ( uwSecondaryMode )
{
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
break;
case 0: /*impose Y, propose Z*/
case 1: /*impose Y, propose X*/
stImposedAxis = stJ;
break;
case 2: /*impose Z, propose Y*/
case 3: /*impose Z, propose X*/
stImposedAxis = stK;
break;
case 4: /*impose X, propose Z*/
case 5: /*impose X, propose Y*/
stImposedAxis = stI;
break;
}
}
else
{
MTH3D_M_vNormalizeVector(&stImposedAxis, &stImposedAxis);
if ( (uwSecondaryMode == 0) || (uwSecondaryMode == 1) ) /* impose Y*/
{
/*we received -Y, so invert it, and normalize it as well while we are at it*/
MTH3D_M_vNegVector(&stImposedAxis, &stImposedAxis);
}
}
if ( MTH3D_M_bIsNullVector(&stProposedAxis) )
{
switch ( uwSecondaryMode )
{
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
break;
case 0: /*impose Y, propose Z*/
case 4: /*impose X, propose Z*/
stProposedAxis = stK;
break;
case 1: /*impose Y, propose X*/
case 3: /*impose Z, propose X*/
stProposedAxis = stI;
break;
case 2: /*impose Z, propose Y*/
case 5: /*impose X, propose Y*/
stProposedAxis = stJ;
break;
}
}
else
{
MTH3D_M_vNormalizeVector(&stProposedAxis, &stProposedAxis);
if ( (uwSecondaryMode == 2) || (uwSecondaryMode == 5) ) /* propose Y*/
{
/*we received -Y, so invert it, and normalize it as well while we are at it*/
MTH3D_M_vNegVector(&stProposedAxis, &stProposedAxis);
}
}
/*now that we are sure all our vectors are suitable for the following, let's proceed*/
switch ( uwSecondaryMode )
{
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
break;
case 5: /*impose X, propose Y*/
/*build a new Z from X and Y*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stTmp, &stImposedAxis, &stProposedAxis);
if ( !MTH3D_M_bIsNullVector(&stTmp) )
{
MTH3D_M_vNormalizeVector(&stK, &stTmp);
}
/*build the final Y from Z and X*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stJ, &stK, &stImposedAxis);
/*MTH3D_M_vNormalizeVector(&stJ, &stJ); inutile aux imprécisions de calculs près...*/
break;
case 4: /*impose X, propose Z*/
/*build a new Y from Z and X*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stTmp, &stProposedAxis, &stImposedAxis);
if ( !MTH3D_M_bIsNullVector(&stTmp) )
{
MTH3D_M_vNormalizeVector(&stJ, &stTmp);
}
/*build the final Z from X and Y*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stK, &stImposedAxis, &stJ);
/*MTH3D_M_vNormalizeVector(&stK, &stK); inutile aux imprécisions de calculs près...*/
break;
case 3: /*impose Z, propose X*/
/*build a new Y from Z and X*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stTmp, &stImposedAxis, &stProposedAxis);
if ( !MTH3D_M_bIsNullVector(&stTmp) )
{
MTH3D_M_vNormalizeVector(&stJ, &stTmp);
}
/*build the final X from Y and Z*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stI, &stJ, &stImposedAxis);
/*MTH3D_M_vNormalizeVector(&stI, &stI); inutile aux imprécisions de calculs près...*/
break;
case 2: /*impose Z, propose Y*/
/*build a new X from Y and Z*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stTmp, &stProposedAxis, &stImposedAxis);
if ( !MTH3D_M_bIsNullVector(&stTmp) )
{
MTH3D_M_vNormalizeVector(&stI, &stTmp);
}
/*build the final Y from Z and X*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stJ, &stImposedAxis, &stI);
/*MTH3D_M_vNormalizeVector(&stJ, &stJ); inutile aux imprécisions de calculs près...*/
break;
case 1: /*impose Y, propose X*/
/*build a new Z from X and Y*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stTmp, &stProposedAxis, &stImposedAxis);
if ( !MTH3D_M_bIsNullVector(&stTmp) )
{
MTH3D_M_vNormalizeVector(&stK, &stTmp);
}
/*build the final X from Y and Z*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stI, &stImposedAxis, &stK);
/*MTH3D_M_vNormalizeVector(&stI, &stI); inutile aux imprécisions de calculs près...*/
break;
case 0: /*impose Y, propose Z*/
/*build a new X from Z and Y*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stTmp, &stImposedAxis, &stProposedAxis);
if ( !MTH3D_M_bIsNullVector(&stTmp) )
{
MTH3D_M_vNormalizeVector(&stI, &stTmp);
}
/*build the final Z from Y and X*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stK, &stI, &stImposedAxis);
/*MTH3D_M_vNormalizeVector(&stK, &stK); inutile aux imprécisions de calculs près...*/
break;
}
/*we have the rotation matrix: set it directly*/
if ( uwSecondaryMode < 2 ) /* impose Y*/
{
POS_fn_vSetRotationMatrix(hGLobalMovedMatrix, &stI, &stImposedAxis, &stK);
}
else if ( uwSecondaryMode < 4 )/* impose Z*/
{
POS_fn_vSetRotationMatrix(hGLobalMovedMatrix, &stI, &stJ, &stImposedAxis);
}
else /* impose X*/
{
POS_fn_vSetRotationMatrix(hGLobalMovedMatrix, &stImposedAxis, &stJ, &stK);
}
if ( bTranslationChanged ) /*if the rotation center is offseted*/
{
/*compute the new global version of the offset vector*/
POS_fn_vMulMatrixVector(&stTmp, hGLobalMovedMatrix, &stGlobalTranslation);
/*substract it from the old one (before the rotation of the matrix)*/
MTH3D_M_vSubVector(&stInducedTranslation, &stInducedTranslation, &stTmp);
/*this is a world-expressed translation that must be added to the rotated matrix' position*/
POS_fn_vGetTranslationVector(hGLobalMovedMatrix, &stGlobalTranslation);
MTH3D_M_vAddVector(&stGlobalTranslation, &stGlobalTranslation, &stInducedTranslation);
POS_fn_vSetTranslationVector(hGLobalMovedMatrix, &stGlobalTranslation);
}
}
fn_vUpdateSuperObjectAfter3DChanges(
hNewSuperObjPerso, /* actor or channel superobject*/
hGLobalMovedMatrix, /* modified rotation ?*/
bTranslationChanged ? &stGlobalTranslation : NULL, /* modified translation ?*/
(ACP_tdxBool) (uwChannel == C_ucUnknownChannel) /* in an actor ?*/
);
/* fbolefeysot - 28/07/98{*/
if (uwChannel != C_ucUnknownChannel)
{
/* not an actor, so signal that an animation matrix has changed*/
fn_v3dDataSetAnimMatrixHasChanged(M_GetMSHandle(hCharSO,3dData));
}
/*END fbolefeysot}*/
return p_stTree;
}
/* ============================================================
function: ChangePersoHorizSighting
Use : ULTRA.ACT_ChangeViseePerso()
author: Yann Le tensorer october 6, 1998
==============================================================*/
tdstNodeInterpret *fn_p_stChangePersoHorizSighting(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
MTH3D_tdstVector stSightVector; /* sight of the perso*/
MTH3D_tdstVector stXvect,stZvect; /* temporary vectors */
MTH3D_tdstVector *p_stTmpV0,*p_stTmpV1,*p_stTmpV2; /* temporary vector pointers*/
POS_tdxHandleToPosition hGlobalMatrix,hLocalMatrix;
MS_tdxHandleToDynam hDynam;
/*/ enum tdeFuncId_ eFuncId = M_eFuncIdInterpret(p_stTree-1);*/
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
unsigned long ulCustomBits ;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/* read input parameter (sight vector)*/
M_EvalNextParameter(&stParam);
stSightVector = M_GetSetParam_stVectorValue(&stParam);
/* get the global,local matrix and the dynamic of the actor*/
hGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(hNewSuperObjPerso);
hLocalMatrix = HIE_fn_hGetSuperObjectMatrix(hNewSuperObjPerso);
hDynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
/* horizontalize the sight vector */
stSightVector . xZ = MTH_C_ZERO ;
/* is the input parameter a null vector ?*/
if ( MTH3D_M_bIsNullVector ( & stSightVector ) )
{
/*=========== we get the old sight vector of the character, and set its z coordinate to 0*/
POS_fn_vGetRotationVector ( HIE_fn_hGetSuperObjectGlobalMatrix ( hNewSuperObjPerso ) , & p_stTmpV0 , & p_stTmpV1 , & p_stTmpV2 ) ;
MTH3D_M_vNegVector ( & stSightVector , p_stTmpV1 ) ; /* objects watch in -Y, so we negate the vector*/
stSightVector . xZ = MTH_C_ZERO ;
/* if the current sight is vertical too, use K as the new sighting */
if ( MTH3D_M_bIsNullVector ( & stSightVector ) )
{
stSightVector = * p_stTmpV2 ;
}
}
/* CALCULATE THE NEW ROTATION MATRIX*/
MTH3D_M_vQuickNormalizeVector ( & stSightVector , & stSightVector ) ;
stXvect . xZ = MTH_C_ZERO ;
MTH3D_M_vSetBaseKVector ( & stZvect ) ;
/* if sightvector is (a,b), we negate the sight vector(-a,-b) and put (-b,a) in the X vector of the new rotation matrix*/
stXvect . xY = stSightVector . xX ;
stSightVector . xX = MTH_M_xNeg ( stSightVector . xX ) ;
stSightVector . xY = MTH_M_xNeg ( stSightVector . xY ) ;
stXvect . xX = stSightVector . xY ;
/* UPDATE EVERYTHING WITH THE NEW MATRIX...*/
/* we set the new rotation matrix*/
POS_fn_vSetRotationMatrix ( hGlobalMatrix , & stXvect , & stSightVector , & stZvect ) ;
/* we need this so that the global matrix will not be recalculated...*/
HIE_fn_vValidateGlobalMatrix ( hNewSuperObjPerso ) ;
/* is the father an actor ?*/
if ( HIE_M_xGetSuperObjectMember ( HIE_M_hGetSuperObjectFather ( hNewSuperObjPerso ) , ulTypeOfLinkedObject ) & HIE_C_ulActor )
{
/* yes, so the actor is on a platform, we recalculate its local matrix... (longer...)*/
HIE_fn_vComputeNewRelativeMatrix ( hNewSuperObjPerso ) ;
}
else
/*no, no need to recalculate the local matrix, we just copy the global rotation matrix into the local...*/
POS_fn_vSetRotationMatrix ( hLocalMatrix , & stXvect , & stSightVector , & stZvect ) ;
if
(
((ulCustomBits = fn_ulStandardGameGetCustomBitsSO(hNewSuperObjPerso)) & GAM_C_CustBitNeedModuleMatrices)
&&
(!hDynam || (ulCustomBits & GAM_C_CustBitNoMechanic))
)
{
/* If we refresh the hierarchy now, when the meca is performed and moves the actor,*/
/* it would refresh the hierarchy too because of the GAM_C_CustBitNeedModuleMatrices custombit.*/
/* Problem: This is effective only if the children are believed invalid, which would not be the case*/
/* because the validity test is the frame counter. The hierarchy refresh here would validate all the*/
/* children with the current frame counter, then when the meca arrives, the father's matrix may change,*/
/* but the frame counter does not, because the meca is done during the same engine frame. hence, a second*/
/* hierarchy refresh would believe that the children matrixes are already correct!*/
HIE_fn_vRefreshHierarchy ( hNewSuperObjPerso ) ;
}
if ( hDynam )
{
MEC_vImposeRotationVector ( fn_p_stDynamGetDynamics ( hDynam ) ,& stXvect , & stSightVector , & stZvect ) ;
}
/*force the matrix of all children to be recomputed (we want all matrixes to be up-to-date), which*/
/*was the case when the AI engine started for the handled actor*/
/*HIE_fn_vRefreshHierarchy(hNewSuperObjPerso);*/
return p_stTree;
}
/* -----------------19/11/97 10:51-------------------
parameters for a given action code are:
eProc_RotateModuleAroundVectorWithOffset
-> channel
-> global axis
-> angle
-> offset vector
eProc_RotatePersoAroundVectorWithOffset
-> global axis
-> angle
-> offset vector
eProc_RotateModuleAroundVector
-> channel
-> global axis
-> angle
eProc_RotatePersoAroundVector
-> global axis
-> angle
eProc_SetPersoAtModulePosition
-> perso owning the module
-> channel
eProc_AcceptPersoZoom
-> boolean that enables or disables perso zooming
eProc_ZoomPerso
-> zoom coeffs for X, Y and Z in a vector
eProc_ZoomModule
-> animation channel
-> zoom coeffs for X, Y and Z in a vector
eProc_RotatePersoAroundXwithOffset
eProc_RotatePersoAroundYwithOffset
eProc_RotatePersoAroundZwithOffset
-> angle in degrees
-> translation offset local vector
eProc_RotateModuleAroundXwithOffset
eProc_RotateModuleAroundYwithOffset
eProc_RotateModuleAroundZwithOffset
-> animation channel
-> angle in degrees
-> translation offset local vector
eProc_RotatePersoAroundX
eProc_RotatePersoAroundY
eProc_RotatePersoAroundZ
-> angle in degrees
eProc_RotateModuleAroundX
eProc_RotateModuleAroundY
eProc_RotateModuleAroundZ
-> animation channel
-> angle in degrees
eProc_SetPersoAbsolutePosition
-> displacement vector
eProc_ChangePersoSighting
-> orientation vector
eProc_ChangePersoSightingwithOffset
-> orientation vector
-> relative position of rotation axis
eProc_RelativeMovePerso
-> displacement vector
-> boolean TRUE: world axis, FALSE: perso axis
eProc_ChangeModuleSighting
-> orientation vector
-> channel
-> boolean TRUE: world axis, FALSE: perso axis
eProc_ChangeModuleSightingWithOffset
-> orientation vector
-> channel
-> boolean TRUE: world axis, FALSE: perso axis
-> relative position of rotation axis
eProc_SetModuleAbsolutePosition
-> displacement vector
-> channel
-> boolean TRUE: world axis, FALSE: perso axis
eProc_RelativeMoveModule
-> displacement vector
-> channel
-> boolean TRUE: world axis, FALSE: perso axis
--------------------------------------------------*/
tdstNodeInterpret *fn_p_st3DProc(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
HIE_tdxHandleToSuperObject hNewSuperObjPerso = p_SuperObjPerso, hChannelSuperObject = NULL, hCharSO = p_SuperObjPerso;
/*POS_tdstCompletePosition stDestinationMatrix;*/
POS_tdstCompletePosition stPersoToWorldMatrix, *hGLobalMovedMatrix, *hPersoGlobalMatrix = NULL;
MTH3D_tdstVector stPositionToReach, stTempVector, stGlobalTranslation;
ACP_tdxBool bGlobalAxis = 0, bTranslationChanged = 0, bRotationChanged = 0, bScaleChanged = 0;
unsigned char ucChannel = C_ucUnknownChannel;
MTH_tdxReal xAngle = MTH_C_ZERO;
MS_tdxHandleToDynam hDynam;
/* Oliv' - 02/03/1999 - we need a better test on CustomBits */
unsigned long ulCustomBits;
/* EndOfOliv' */
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
hCharSO = hNewSuperObjPerso;
/*get the global matrix of the actor's superobject*/
hPersoGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(hNewSuperObjPerso);
hDynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
/*start by reading all the parameters*/
M_EvalNextParameter(&stParam);
/*read additional parameters*/
switch ( eProcedureId )
{
// #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ //KOU 10/05/2006 11:37
case eProc_RotateModuleAroundVectorWithOffset:
ucChannel = M_GetSetParam_lModuleValue(&stParam);
if ( ucChannel == C_ucUnknownChannel )
{
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
hChannelSuperObject = fn_hGetSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(hNewSuperObjPerso,3dData)), ucChannel);
/*prepare to read the next parameter*/
M_EvalNextParameter(&stParam);
/*and fall through*/
//#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_RotatePersoAroundVectorWithOffset:
/*read the rotation axis*/
stPositionToReach = M_GetSetParam_stVectorValue(&stParam);
/*and the rotation angle*/
M_EvalNextParameter(&stParam);
xAngle = M_ReturnParam_xValue(&stParam);
xAngle = MTH_M_xNeg(MTH_M_xDegToRad(xAngle));
/*read the translation offset (the rotation center, in fact)*/
M_EvalNextParameter(&stParam);
stGlobalTranslation = M_GetSetParam_stVectorValue(&stParam);
/* the rotation matrix will be changed by the operation, and the position too*/
bRotationChanged = 1;
bGlobalAxis = 1;
bTranslationChanged = 1;
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_RotateModuleAroundVector:
ucChannel = M_GetSetParam_lModuleValue(&stParam);
if ( ucChannel == C_ucUnknownChannel )
{
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
hChannelSuperObject = fn_hGetSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(hNewSuperObjPerso,3dData)), ucChannel);
/*prepare to read the next parameter*/
M_EvalNextParameter(&stParam);
/*and fall through*/
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_RotatePersoAroundVector:
/*read the rotation axis*/
stPositionToReach = M_GetSetParam_stVectorValue(&stParam);
/*and the rotation angle*/
M_EvalNextParameter(&stParam);
xAngle = M_ReturnParam_xValue(&stParam);
xAngle = -MTH_M_xDegToRad(xAngle);
/* the rotation matrix will be changed by the operation, but not the position*/
bRotationChanged = 1;
bGlobalAxis = 1;
break;
case eProc_SetPersoAtModulePosition:
{
/*get the perso that owns the target channel (the moved perso is given by the ultra operator*/
p_SuperObjPerso = M_GetSetParam_p_stSupObjValue(&stParam);
SAF_M_AssertWithMsg(p_SuperObjPerso, "l'acteur spécifié est nul");
/* if the passed actor is the same as the ultra actor, we do nothing (an actor cnnot move to the*/
/* position defined by its own modules)*/
if ( p_SuperObjPerso == hNewSuperObjPerso )
{
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
/*get the superobject for the channel of the actor*/
M_EvalNextParameter(&stParam);
ucChannel = M_GetSetParam_lModuleValue(&stParam);
if ( ucChannel == C_ucUnknownChannel )
{
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
/*get the super-object in the channel of its owner, not of the moved actor!!*/
hChannelSuperObject = fn_hGetSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(p_SuperObjPerso,3dData)), ucChannel);
/* if there is none, do nothing*/
if ( !hChannelSuperObject )
{
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
/* clear the channel identifier, because we modify an actor's position, not a module's*/
ucChannel = C_ucUnknownChannel;
/*the rotation ,translation are changed by values given in world coordinates*/
bTranslationChanged = 1;
bRotationChanged = 1;
bGlobalAxis = 1;
}
break;
case eProc_ZoomModule:
/*read the channel*/
ucChannel = M_GetSetParam_lModuleValue(&stParam);
if ( ucChannel == C_ucUnknownChannel )
{
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
/*replace the affected superobject, since the action is the same*/
hChannelSuperObject = fn_hGetSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(hNewSuperObjPerso,3dData)), ucChannel);
/*get ready to read the next argument*/
M_EvalNextParameter(&stParam);
/* fall through*/
case eProc_ZoomPerso:
/*read the zoom factors*/
stPositionToReach = M_GetSetParam_stVectorValue(&stParam);
/* no need to convert anything*/
bGlobalAxis = 1;
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_RotateModuleAroundXwithOffset:
case eProc_RotateModuleAroundYwithOffset:
case eProc_RotateModuleAroundZwithOffset:
/*read the channel*/
ucChannel = M_GetSetParam_lModuleValue(&stParam);
if ( ucChannel == C_ucUnknownChannel )
{
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
/*replace the affected superobject, since the action is the same*/
hChannelSuperObject = fn_hGetSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(hNewSuperObjPerso,3dData)), ucChannel);
/*get ready to read the next argument*/
M_EvalNextParameter(&stParam);
/*then fall through*/
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_RotatePersoAroundXwithOffset:
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_RotatePersoAroundYwithOffset:
case eProc_RotatePersoAroundZwithOffset:
/*read the angle*/
xAngle = M_ReturnParam_xValue(&stParam);
xAngle = MTH_M_xDegToRad(xAngle);
/*read the translation offset (the rotation center, in fact)*/
M_EvalNextParameter(&stParam);
stPositionToReach = M_GetSetParam_stVectorValue(&stParam);
/*since the rotation may induce a displacement, the translation matrix is assumed to change as well*/
bTranslationChanged = 1;
bRotationChanged = 1;
/* no need to convert anything*/
bGlobalAxis = 1;
break;
case eProc_RotateModuleAroundX:
case eProc_RotateModuleAroundY:
case eProc_RotateModuleAroundZ:
/*read the channel*/
ucChannel = M_GetSetParam_lModuleValue(&stParam);
if ( ucChannel == C_ucUnknownChannel )
{
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
/*replace the affected superobject, since the action is the same*/
hChannelSuperObject = fn_hGetSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(hNewSuperObjPerso,3dData)), ucChannel);
/*get ready to read the next argument*/
M_EvalNextParameter(&stParam);
/*then fall through*/
case eProc_RotatePersoAroundX:
case eProc_RotatePersoAroundY:
case eProc_RotatePersoAroundZ:
/*read the angle*/
xAngle = M_ReturnParam_xValue(&stParam);
xAngle = MTH_M_xDegToRad(xAngle);
/*this variable is used to know if the rotation axis is the origin or not of the rotated object*/
bRotationChanged = 1;
/* no need to convert anything*/
bGlobalAxis = 1;
break;
case eProc_SetPersoAbsolutePosition:
stPositionToReach = M_GetSetParam_stVectorValue(&stParam);
bTranslationChanged = 1;
bGlobalAxis = 1;
break;
case eProc_ChangePersoSightingWithOffset:
case eProc_ChangePersoAnySighting:
stPositionToReach = M_GetSetParam_stVectorValue(&stParam);
if ( eProcedureId == eProc_ChangePersoSightingWithOffset )
{
M_EvalNextParameter(&stParam);
stGlobalTranslation = M_GetSetParam_stVectorValue(&stParam);
bTranslationChanged = 1;
}
bGlobalAxis = 1;
bRotationChanged = 1;
break;
case eProc_RelativeMovePerso:
stPositionToReach = M_GetSetParam_stVectorValue(&stParam);
/*read the flag*/
M_EvalNextParameter(&stParam);
bGlobalAxis = M_GetSetParam_lValue(&stParam);
bTranslationChanged = 1;
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_ChangeModuleSightingWithOffset:
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_ChangeModuleSighting:
case eProc_RelativeMoveModule:
case eProc_SetModuleAbsolutePosition:
{
/*get the position to reach*/
stPositionToReach = M_GetSetParam_stVectorValue(&stParam);
/*get the affected module*/
M_EvalNextParameter(&stParam);
ucChannel = M_GetSetParam_lModuleValue(&stParam);
if ( ucChannel == C_ucUnknownChannel )
{
return fn_p_stSwapNextParameter(p_stTree);
break; /* anti-bug GCC N64*/
}
/*replace the affected superobject, since the action is the same*/
hChannelSuperObject = fn_hGetSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(hNewSuperObjPerso,3dData)), ucChannel);
/*read the flag that says if the passed vector is relative to the owning actor or to the world*/
M_EvalNextParameter(&stParam);
bGlobalAxis = M_GetSetParam_lValue(&stParam);
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
if ( eProcedureId == eProc_ChangeModuleSightingWithOffset )
{
M_EvalNextParameter(&stParam);
stGlobalTranslation = M_GetSetParam_stVectorValue(&stParam);
bTranslationChanged = 1;
}
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
}
break;
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
return p_stTree;
break; /* anti-bug GCC N64*/
}
/*if the anim frame did not change since the previous engine frame, the controled modules' matrixes are*/
/*not reinitialized with the value from the anim, but keep the alteration done right here the previous frame*/
/*so we dont do anything if we handle a module and the anim frame did not change (when that works, that is...)*/
/*
if
(
( uwChannel != C_ucUnknownChannel )
&& fn_s3dDataGetLastFrame(M_GetMSHandle(p_SuperObjPerso,3dData))==fn_uc3dDataGetCurrentFrame(M_GetMSHandle(p_SuperObjPerso,3dData))
)
return p_stTree;
*/
/* when we work on a channel that contains an object, do it as if it were an actor (almost - mechanics is not implied)*/
if ( ucChannel != C_ucUnknownChannel )
{
/* do nothing if the channel is empty!*/
if ( !hChannelSuperObject )
return p_stTree;
/*
#if defined(__DEBUG_AI__)
// make sure it is controlled
POS_tdstCompletePosition *hOldLocalMatrix, *hNewLocalMatrix;
//retrieve the local matrix of the moved channel
hOldLocalMatrix = HIE_fn_hGetSuperObjectMatrix(hChannelSuperObject);
//force the channel to be controlled, but only in debug mode
fn_vTakeControlOfChannel((tdstEngineObject *)HIE_fn_hGetSuperObjectObject(hNewSuperObjPerso), uwChannel);
//force the allocated matrix to replace the channel matrix immediately for all controled modules
fn_vUpdateMatrixOfControledChannels((tdstEngineObject *)HIE_fn_hGetSuperObjectObject(hNewSuperObjPerso));
//get the local matrix again
hNewLocalMatrix = HIE_fn_hGetSuperObjectMatrix(hChannelSuperObject);
// if it changed, it means that the channel was not controlled, which is BAD!!!
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
if ( hNewLocalMatrix != hOldLocalMatrix )
{
char MyMsg[150];
sprintf(MyMsg,"%s's channel %d is not controlled", p_stCurrentMind->szPersoName, uwChannel);
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningChannelNotControlled, C_ucErmNoOpenInfoWindow, MyMsg)
}
#endif // (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#endif // __DEBUG_AI__
*/
/* FBF blindage acces modules {*/
#ifdef ACTIVE_EDITOR
fn_vCheckModuleAccess(hNewSuperObjPerso, TRUE, &ucChannel);
#endif
/* } fin blindage acces modules*/
hNewSuperObjPerso = hChannelSuperObject;
}
/*retrieve the global matrix of the moved superobject*/
hGLobalMovedMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(hNewSuperObjPerso);
/*some vector will need to be converted in relative coordinate, so prepare the conversion matrix for this purpose*/
if ( !bGlobalAxis )
{
/*retrieve the conversion matrix of the moved superobject, to express coordinates in the world's system*/
POS_fn_vCopyMatrix(&stPersoToWorldMatrix, hPersoGlobalMatrix);
}
/*
//we will work with a copy of the global matrix, because we want to retain the original one
//for collision tests
POS_fn_vSetType(&stDestinationMatrix, POS_C_xCompletePosition);
if ( POS_M_xAcceptScale(hGLobalMovedMatrix) )
POS_fn_vAcceptScaleOn(&stDestinationMatrix);
POS_fn_vCopyMatrix(&stDestinationMatrix, hGLobalMovedMatrix);
*/
switch ( eProcedureId )
{
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
break;
//#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ //KOU 10/05/2006 11:37
case eProc_RotateModuleAroundVectorWithOffset:
//#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_RotatePersoAroundVectorWithOffset:
/*convert the offset vector in world coordinates*/
POS_fn_vMulMatrixVector(&stTempVector, hGLobalMovedMatrix, &stGlobalTranslation);
/*and fall through*/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_RotateModuleAroundVector:
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_RotatePersoAroundVector:
SAF_M_AssertWithMsg((! MTH3D_M_bIsNullVector(&stPositionToReach)), "Vecteur NUL pour Rotation")
MTH3D_M_vNormalizeVector(&stPositionToReach, &stPositionToReach);
POS_fn_vRotatePositionAroundAxisNoTranslation(hGLobalMovedMatrix, &stPositionToReach, xAngle);
if ( bTranslationChanged ) /*if the rotation center is offseted*/
{
/*compute the new global version of the offset vector*/
POS_fn_vMulMatrixVector(&stPositionToReach, hGLobalMovedMatrix, &stGlobalTranslation);
/*substract it from the old one (before the rotation of the matrix)*/
MTH3D_M_vSubVector(&stPositionToReach, &stTempVector, &stPositionToReach);
/*this is a world cordinates expressed translation that must be added given to the rotated matrix*/
goto label_RelativeMovePerso;
}
/*now do the common stuff*/
goto label_UpdateRelativeMatrix;
case eProc_SetPersoAtModulePosition:
/*put the complete position of the channel's module in the moved actor's*/
POS_fn_vCopyMatrix(hGLobalMovedMatrix, HIE_fn_hGetSuperObjectGlobalMatrix(hChannelSuperObject));
/*now do the common stuff*/
goto label_UpdateRelativeMatrix;
case eProc_ZoomPerso:
/*we have to warn the mechanics about that, if relevant*/
bScaleChanged = 1;
/* fall through*/
case eProc_ZoomModule:
/* if the super object does not accept scale, do nothing*/
if ( HIE_fn_SO_bHasNoTransformationMatrix(hNewSuperObjPerso) )
{
return p_stTree;
break; /* anti-bug GCC N64*/
}
/*the zomm is simplified if this is true*/
if ( HIE_fn_SO_bHasZoomInsteadOfScale(hNewSuperObjPerso) )
{
/*zoom is equal in all directions*/
MTH3D_M_vSetYofVector(&stPositionToReach, MTH3D_M_xGetXofVector(&stPositionToReach));
MTH3D_M_vSetZofVector(&stPositionToReach, MTH3D_M_xGetXofVector(&stPositionToReach));
}
SAF_M_AssertWithMsg(
(MTH_M_bDifferentZero(stPositionToReach.xX) && MTH_M_bDifferentZero(stPositionToReach.xY) && MTH_M_bDifferentZero(stPositionToReach.xZ)),
"un facteur de zoom nul n'est pas autorise"
);
/* modify the superobject's matrix only if the mechanics won't do it for us*/
if ( (ucChannel != C_ucUnknownChannel) || !hDynam )
{
MTH3D_tdstVector stV1, stV2, stV3;
/*normalize the vectors*/
MTH3D_M_vSetVectorElements(&stV1, MTH3D_M_xGetXofVector(&stPositionToReach), MTH_C_ZERO, MTH_C_ZERO);
MTH3D_M_vSetVectorElements(&stV2, MTH_C_ZERO, MTH3D_M_xGetYofVector(&stPositionToReach), MTH_C_ZERO);
MTH3D_M_vSetVectorElements(&stV3, MTH_C_ZERO, MTH_C_ZERO, MTH3D_M_xGetZofVector(&stPositionToReach));
/*and set the vectors in the transform matrix*/
POS_fn_vSetScaleMatrix(hGLobalMovedMatrix, &stV1, &stV2, &stV3);
}
/*now do the common stuff*/
goto label_UpdateRelativeMatrix;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_RotateModuleAroundXwithOffset:
case eProc_RotateModuleAroundYwithOffset:
case eProc_RotateModuleAroundZwithOffset:
case eProc_RotatePersoAroundXwithOffset:
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_RotatePersoAroundYwithOffset:
case eProc_RotatePersoAroundZwithOffset:
/*convert the offset vector in world coordinates*/
POS_fn_vMulMatrixVector(&stTempVector, hGLobalMovedMatrix, &stPositionToReach);
/*and fall through*/
case eProc_RotateModuleAroundX:
case eProc_RotateModuleAroundY:
case eProc_RotateModuleAroundZ:
case eProc_RotatePersoAroundX:
case eProc_RotatePersoAroundY:
case eProc_RotatePersoAroundZ:
{
/*first compute a rotation matrix for the angle*/
MTH3D_tdstVector stV1, stV2, stV3;
MTH_tdxReal xDummy = MTH_M_xCos(xAngle);
xAngle = MTH_M_xSin(xAngle);
switch ( eProcedureId )
{
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_RotateModuleAroundXwithOffset:
case eProc_RotatePersoAroundXwithOffset:
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_RotateModuleAroundX:
case eProc_RotatePersoAroundX:
MTH3D_M_vSetVectorElements(&stV1, MTH_C_ONE, MTH_C_ZERO, MTH_C_ZERO);
MTH3D_M_vSetVectorElements(&stV2, MTH_C_ZERO, xDummy, xAngle);
MTH3D_M_vSetVectorElements(&stV3, MTH_C_ZERO, -xAngle, xDummy);
break;
case eProc_RotateModuleAroundY:
case eProc_RotatePersoAroundY:
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_RotateModuleAroundYwithOffset:
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_RotatePersoAroundYwithOffset:
MTH3D_M_vSetVectorElements(&stV1, xDummy, MTH_C_ZERO, xAngle);
MTH3D_M_vSetVectorElements(&stV2, MTH_C_ZERO, MTH_C_ONE, MTH_C_ZERO);
MTH3D_M_vSetVectorElements(&stV3, -xAngle, MTH_C_ZERO, xDummy);
break;
case eProc_RotateModuleAroundZ:
case eProc_RotatePersoAroundZ:
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_RotateModuleAroundZwithOffset:
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_RotatePersoAroundZwithOffset:
MTH3D_M_vSetVectorElements(&stV1, xDummy, xAngle, MTH_C_ZERO);
MTH3D_M_vSetVectorElements(&stV2, -xAngle, xDummy, MTH_C_ZERO);
MTH3D_M_vSetVectorElements(&stV3, MTH_C_ZERO, MTH_C_ZERO, MTH_C_ONE);
break;
default:
break;
}
/*then rotate the vectors with the rotation matrix of the perso (ie no scale is applied yet)*/
POS_fn_vRotateVector(&stV1, hGLobalMovedMatrix, &stV1);
POS_fn_vRotateVector(&stV2, hGLobalMovedMatrix, &stV2);
POS_fn_vRotateVector(&stV3, hGLobalMovedMatrix, &stV3);
/*the vectors we got are the object's rotation matrix rotated around the specified axis*/
POS_fn_vSetRotationMatrix(hGLobalMovedMatrix, &stV1, &stV2, &stV3);
/*when doing this, make sure the scale matrix dont get shrinked by calculus imprecisions*/
/*if ( POS_M_xAcceptScale(hGLobalMovedMatrix) )
{
MTH3D_tdstVector stSV1, stSV2, stSV3;
MTH_tdxReal xZX, xZY, xZZ;
//get the scale coefficients
POS_fn_vGetScaleMatrix(hGLobalMovedMatrix, &stSV1, &stSV2, &stSV3);
xZX = MTH3D_M_xNormVector(&stSV1);
xZY = MTH3D_M_xNormVector(&stSV2);
xZZ = MTH3D_M_xNormVector(&stSV3);
//compute local scaled vectors with the specified norms
MTH3D_M_vSetVectorElements(&stV1, xZX, MTH_C_ZERO, MTH_C_ZERO);
MTH3D_M_vSetVectorElements(&stV2, MTH_C_ZERO, xZY, MTH_C_ZERO);
MTH3D_M_vSetVectorElements(&stV3, MTH_C_ZERO, MTH_C_ZERO, xZZ);
//and use the result as the new transform matrix
POS_fn_vSetScaleMatrix(hGLobalMovedMatrix, &stV1, &stV2, &stV3);
}
else
POS_fn_vResetScaleMatrix(hGLobalMovedMatrix);
*/
if ( bTranslationChanged ) /*if the rotation center is offseted*/
{
/*compute the new global version of the offset vector*/
POS_fn_vMulMatrixVector(&stPositionToReach, hGLobalMovedMatrix, &stPositionToReach);
/*substract it from the old one (before the rotation of the matrix)*/
MTH3D_M_vSubVector(&stPositionToReach, &stTempVector, &stPositionToReach);
/*this is a world cordinates expressed translation that must be added given to the rotated matrix*/
goto label_RelativeMovePerso;
}
}
/*now do the common stuff*/
goto label_UpdateRelativeMatrix;
case eProc_ChangePersoSightingWithOffset:
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_ChangeModuleSightingWithOffset:
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
/*convert the offset vector in world coordinates*/
POS_fn_vMulMatrixVector(&M_GetSetParam_stVertexValue(&stParam), hGLobalMovedMatrix, &stGlobalTranslation);
/*and fall through*/
case eProc_ChangePersoAnySighting:
case eProc_ChangeModuleSighting:
{
MTH3D_tdstVector stI, stJ, stK;
unsigned char b_ucKisUp, b_ucIisLeft;
POS_fn_vGetRotationMatrix(hGLobalMovedMatrix, &stI, &stTempVector, &stK);
/* if the specified sighting is not valid, use the current one instead*/
if ( MTH3D_M_bIsNullVector(&stPositionToReach) )
stJ = stTempVector;
else
{
/*we change the sight axis, which is -J, so negate to components to change J with them*/
MTH3D_M_vNegVector(&stPositionToReach, &stPositionToReach);
/*convert the vector in world coordinates if necessary*/
if ( !bGlobalAxis )
POS_fn_vMulMatrixVector(&stPositionToReach, &stPersoToWorldMatrix, &stPositionToReach);
/*normalize it now, and this is our new sighting vector*/
MTH3D_M_vNormalizeVector(&stJ, &stPositionToReach);
}
/*now get another vector to define a vertical plane containing the new J*/
if
( /* if the new vector is vertical*/
MTH_M_bIsNullWithEpsilon(MTH3D_M_xGetXofVector(&stJ), MTH_M_xDoubleToReal(0.001))
&& MTH_M_bIsNullWithEpsilon(MTH3D_M_xGetYofVector(&stJ), MTH_M_xDoubleToReal(0.001))
)
{
/* try the old one to define the vertical plane*/
if
( /* if is is vertical too*/
MTH_M_bIsNullWithEpsilon(MTH3D_M_xGetXofVector(&stTempVector), MTH_M_xDoubleToReal(0.001))
&& MTH_M_bIsNullWithEpsilon(MTH3D_M_xGetYofVector(&stTempVector), MTH_M_xDoubleToReal(0.001))
)
/* use the old K*/
stTempVector = stK;
/* else we aleady got the old J in the destination vector*/
}
else
/*else just symmetrize X and Y, and change Z, just in case it is null (so that the vectors can never be colinear)*/
MTH3D_M_vSetVectorElements(&stTempVector, MTH_M_xNeg(MTH3D_M_xGetXofVector(&stJ)), MTH_M_xNeg(MTH3D_M_xGetYofVector(&stJ)), MTH_M_xAdd(MTH3D_M_xGetZofVector(&stJ), MTH_M_xDoubleToReal(2.0)));
/*remember the direction the old X and Z were looking*/
b_ucKisUp = MTH_M_bGreater(MTH_M_xSign(MTH3D_M_xGetZofVector(&stK)), MTH_C_ZERO);
b_ucIisLeft = MTH_M_bGreater(MTH_M_xSign(MTH3D_M_xGetXofVector(&stI)), MTH_C_ZERO);
/*now we can compute a temporary new X*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stI, &stTempVector, &stJ);
MTH3D_M_vSetZofVector(&stI, MTH_C_ZERO)
/*and extrapolate a new K from it*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stK, &stI, &stJ);
/*keep it looking the right way*/
if ( MTH_M_bGreater(MTH_M_xSign(MTH3D_M_xGetZofVector(&stK)), MTH_C_ZERO) != b_ucKisUp )
MTH3D_M_vNegVector(&stK, &stK);
/*and build the definitive proper X from it*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stI, &stJ, &stK);
MTH3D_M_vNormalizeVector(&stI, &stI);
MTH3D_M_vNormalizeVector(&stK, &stK);
/*now set back the new rotation vectors in the matrix*/
POS_fn_vSetRotationMatrix(hGLobalMovedMatrix, &stI, &stJ, &stK);
/*when doing this, make sure the scale matrix dont get shrinked by calculus imprecisions*/
/*if ( POS_M_xAcceptScale(hGLobalMovedMatrix) )
{
MTH3D_tdstVector stSV1, stSV2, stSV3;
MTH_tdxReal xZX, xZY, xZZ;
//get the scale coefficients
POS_fn_vGetScaleMatrix(hGLobalMovedMatrix, &stSV1, &stSV2, &stSV3);
xZX = MTH3D_M_xNormVector(&stSV1);
xZY = MTH3D_M_xNormVector(&stSV2);
xZZ = MTH3D_M_xNormVector(&stSV3);
//compute local scaled vectors with the specified norms
MTH3D_M_vSetVectorElements(&stI, xZX, MTH_C_ZERO, MTH_C_ZERO);
MTH3D_M_vSetVectorElements(&stJ, MTH_C_ZERO, xZY, MTH_C_ZERO);
MTH3D_M_vSetVectorElements(&stK, MTH_C_ZERO, MTH_C_ZERO, xZZ);
//and use the result as the new transform matrix
POS_fn_vSetScaleMatrix(hGLobalMovedMatrix, &stI, &stJ, &stK);
}
else
POS_fn_vResetScaleMatrix(hGLobalMovedMatrix);
*/
if ( bTranslationChanged ) /*if the rotation center is offseted*/
{
/*compute the new global version of the offset vector*/
POS_fn_vMulMatrixVector(&stGlobalTranslation, hGLobalMovedMatrix, &stGlobalTranslation);
/*substract it from the old one (before the rotation of the matrix)*/
MTH3D_M_vSubVector(&stPositionToReach, &M_GetSetParam_stVertexValue(&stParam), &stGlobalTranslation);
/*this is a world cordinates expressed translation that must be added given to the rotated matrix*/
goto label_RelativeMovePerso;
}
}
/*now update the relative matrix accordingly*/
goto label_UpdateRelativeMatrix;
case eProc_RelativeMoveModule:
case eProc_RelativeMovePerso:
label_RelativeMovePerso:
/*convert the movement in world coordinates if necessary*/
if ( !bGlobalAxis )
POS_fn_vMulMatrixVector(&stPositionToReach, &stPersoToWorldMatrix, &stPositionToReach);
/*add it to the current position, so that we get an absolute position*/
POS_fn_vGetTranslationVector(hGLobalMovedMatrix, &stTempVector);
MTH3D_M_vAddVector(&stPositionToReach, &stPositionToReach, &stTempVector);
/*go to the main handling part of the displacement (fall through, but skip the case below)*/
goto label_SetPersoAbsolutePosition;
case eProc_SetModuleAbsolutePosition:
/*if the coordinates are expressed relatively to the perso*/
if ( !bGlobalAxis )
/*convert the perso-relative position to a world-relative position*/
POS_fn_vMulMatrixVertex(&stPositionToReach, &stPersoToWorldMatrix, &stPositionToReach);
/*fall through*/
case eProc_SetPersoAbsolutePosition:
label_SetPersoAbsolutePosition:
/*modify the hierarchy only for actors, not channels...*/
/*if ( uwChannel == C_ucUnknownChannel )*/
/* fn_vReputCharacterSuperObjectAtTheWorld(hNewSuperObjPerso);*/
/*remember the old translation vector, for the dynamics*/
POS_fn_vGetTranslationVector(hGLobalMovedMatrix, &stGlobalTranslation);
/*set the absolute position in the world*/
POS_fn_vSetTranslationVector(hGLobalMovedMatrix, &stPositionToReach);
/*recompute the sector of the moved actor (if it is an actor)*/
/*ATTENTION: VIRE CAR SEMBLE INUTILE (FAIT A LA FIN DE LE TRAME), MAIS ON NE SAIT JAMAIS*/
/*if ( bTranslationChanged && (uwChannel == C_ucUnknownChannel) )
{
MS_tdxHandleToSectInfo hSectInfo = M_GetMSHandle(hNewSuperObjPerso,SectInfo);
HIE_tdxHandleToSuperObject hTmpSector = fn_h_SectInfoGetCurrentSector(hSectInfo); // preserve previous sector
fn_vSectInfoInitForSingleCharacter(hNewSuperObjPerso, &stPositionToReach); // recompute sector information
fn_vSectInfoSetCurrentSector(hSectInfo, hTmpSector); // restore previous sector
}*/
/*tell the dynamics only if it is an actor...*/
if
(
( (eProcedureId == eProc_SetPersoAbsolutePosition) || (eProcedureId == eProc_RelativeMovePerso) )
&& hDynam
)
MEC_vImposeTranslation(fn_p_stDynamGetDynamics(hDynam),&stPositionToReach);
label_UpdateRelativeMatrix:
/*give the new global matrix to the actor*/
HIE_fn_vValidateGlobalMatrix(hNewSuperObjPerso);
/*POS_fn_vCopyMatrix(hGLobalMovedMatrix, &stDestinationMatrix);*/
/*update the local matrix*/
HIE_fn_vComputeNewRelativeMatrix(hNewSuperObjPerso);
/*force the matrix of all children to be recomputed (we want all matrixes to be up-to-date), which*/
/*was the case when the AI engine started for the handled actor*/
/* ANNECY MT - 06/10/98 {*/
/* if a channel, or an actor whose dynamics will not refresh the hierarchy, refreh it ourselves*/
/* Oliv' - 02/03/1999 - we need a better test on CustomBits */
/* if no meca can be not only !hDynam, but GAM_C_CustBitNoMechanic too */
if
(
(HIE_fn_ulGetSuperObjectType(hNewSuperObjPerso) != HIE_C_ulActor)
||
(
((ulCustomBits=fn_ulStandardGameGetCustomBitsSO(hNewSuperObjPerso)) & GAM_C_CustBitNeedModuleMatrices)
&&
(!hDynam || (ulCustomBits & GAM_C_CustBitNoMechanic))
)
)
/* EndOfOliv' */
{
/* If we refresh the hierarchy now, when the meca is performed and moves the actor,*/
/* it would refresh the hierarchy too because of the GAM_C_CustBitNeedModuleMatrices custombit.*/
/* Problem: This is effective only if the children are believed invalid, which would not be the case*/
/* because the validity test is the frame counter. The hierarchy refresh here would validate all the*/
/* children with the current frame counter, then when the meca arrives, the father's matrix may change,*/
/* but the frame counter does not, because the meca is done during the same engine frame. hence, a second*/
/* hierarchy refresh would believe that the children matrixes are already correct!*/
HIE_fn_vRefreshHierarchy ( hNewSuperObjPerso ) ;
}
/* END ANNECY MT }*/
/*tell the dynamics about it if relevant (we know we are an actor, but with a brain ?)*/
if ( ( ucChannel == C_ucUnknownChannel ) && hDynam )
{
if ( bScaleChanged )
{
struct DNM_stDynamics * pstDynamic = fn_p_stDynamGetDynamics ( hDynam ) ;
if ( pstDynamic )
{
DNM_M_vDynamicsSetScale (
pstDynamic ,
MTH3D_M_xGetXofVector ( & stPositionToReach ) ,
MTH3D_M_xGetYofVector ( & stPositionToReach ) ,
MTH3D_M_xGetZofVector ( & stPositionToReach)
);
DNM_M_vDynamicsSetChangeScale ( pstDynamic , TRUE ) ;
}
}
MEC_vImposeRotationMatrix(fn_p_stDynamGetDynamics(hDynam), hGLobalMovedMatrix);
}
}
/* fbolefeysot - 28/07/98{*/
if (ucChannel != C_ucUnknownChannel)
{
/* not an actor, so signal that an animation matrix has changed*/
fn_v3dDataSetAnimMatrixHasChanged(M_GetMSHandle(hCharSO,3dData));
#ifndef U64
/* ANNECY AV DEMO {*/
#ifndef RETAIL
if (g_DEMO_KeybTest == DEMO_RECORD)
{
DEMO_fn_vSaveModuleMove (hCharSO, ucChannel , (int) eProcedureId != eProc_SetModuleAbsolutePosition);
}
#endif /* RETAIL */
/* END ANNECY AV }*/
#endif /* U64 */
}
return p_stTree;
}
// Make the perso 'vertical' by setting the Z vector to 0,0,1 (or 0,0,-1), keeping one axis and calculating the other
tdstNodeInterpret *fn_p_st3DProcVertical(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
BOOL bZUp;
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
HIE_tdxHandleToSuperObject hNewSuperObjPerso = p_SuperObjPerso;
POS_tdstCompletePosition *pPersoMatrix;
MTH3D_tdstVector vX, vY, vZ, vNewZ;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso, &hNewSuperObjPerso);
M_EvalNextParameter(&stParam);
bZUp = (M_ReturnParam_xValue(&stParam) >= 0);
if (bZUp)
{
MTH3D_M_vSetVectorElements(&vNewZ, MTH_C_ZERO, MTH_C_ZERO, MTH_C_ONE);
}
else
{
MTH3D_M_vSetVectorElements(&vNewZ, MTH_C_ZERO, MTH_C_ZERO, MTH_C_MinusONE);
}
pPersoMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(hNewSuperObjPerso);
POS_fn_vGetRotationMatrix(pPersoMatrix, &vX, &vY, &vZ);
switch (eProcedureId)
{
case eProc_ForceVerticalUsingX:
{
MTH3D_tdstVector vTempX, vTempY;
MTH3D_M_vNormalizeVector(&vTempX, &vX);
MTH3D_M_vCrossProductVectorWithoutBuffer(&vY, &vNewZ, &vTempX);
POS_fn_vSetRotationMatrix(pPersoMatrix, &vTempX, &vY, &vNewZ);
}
break;
case eProc_ForceVerticalUsingY:
{
MTH3D_tdstVector vTempX, vTempY;
MTH3D_M_vNormalizeVector(&vTempY, &vY);
MTH3D_M_vCrossProductVectorWithoutBuffer(&vX, &vTempY, &vNewZ);
POS_fn_vSetRotationMatrix(pPersoMatrix, &vX, &vTempY, &vNewZ);
}
break;
}
return p_stTree;
}
/*****************************************************************************
parameters for a given action code are:
eProc_SetUsedExitIdentifier
-> map id
-> exit id
eProc_GetUsedExitIdentifier
-> pointer on map id
-> pointer on exit id
*****************************************************************************/
tdstNodeInterpret *fn_p_stWorldMapProc(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
switch ( eProcedureId )
{
case eProc_SetGlobalCounter:
M_EvalNextParameter(&stParam);
g_stEngineStructure.ucLevelGlobalCounter = M_GetSetParam_ucValue(&stParam);
break;
case eProc_GetUsedExitIdentifier:
{
/*get the identifiers of the dsgvars that will receive the stored values*/
unsigned char ucVarId = M_ucVarIdInterpret(p_stTree);
p_stTree ++;
/*prepare the value to store in the dsgvar and do it*/
if(g_stEngineStructure.xDemoMode)
{
g_stEngineStructure.ucPreviousLevel=0;
M_Full_GetSetParam_Integer(&stParam, g_stEngineStructure.ucPreviousLevel);
}
else
/*prepare the value to store in the dsgvar and do it*/
M_Full_GetSetParam_Integer(&stParam, g_stEngineStructure.ucPreviousLevel);
ucVarId = fn_ucSetDsgVar(ucVarId, 0, AI_M_stGetMindOfSuperObj(p_SuperObjPerso), &stParam);
#if defined(__DEBUG_AI__)
if ( ucVarId == C_INVALID_SET )
{
M_AIFatalError(E_uwAIFatalInvalidAccessToField);
}
#endif
ucVarId = M_ucVarIdInterpret(p_stTree);
p_stTree ++;
if(g_stEngineStructure.xDemoMode)
{
g_stEngineStructure.ucExitIdToQuitPrevLevel=0;
M_Full_GetSetParam_Integer(&stParam, g_stEngineStructure.ucExitIdToQuitPrevLevel);
}
else
M_Full_GetSetParam_Integer(&stParam, g_stEngineStructure.ucExitIdToQuitPrevLevel);
/*prepare the value to store in the dsgvar and do it again*/
ucVarId = fn_ucSetDsgVar(ucVarId, 0, AI_M_stGetMindOfSuperObj(p_SuperObjPerso), &stParam);
#if defined(__DEBUG_AI__)
if ( ucVarId == C_INVALID_SET )
{
M_AIFatalError(E_uwAIFatalInvalidAccessToField);
}
#endif
}
break;
case eProc_SetUsedExitIdentifier:
M_EvalNextParameter(&stParam);
if(!g_stEngineStructure.xDemoMode)
g_stEngineStructure.ucPreviousLevel = M_GetSetParam_ucValue(&stParam);
M_EvalNextParameter(&stParam);
if(!g_stEngineStructure.xDemoMode)
g_stEngineStructure.ucExitIdToQuitPrevLevel = M_GetSetParam_ucValue(&stParam);
break;
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
break;
}
return p_stTree;
}
/*****************************************************************************
*****************************************************************************/
tdstNodeInterpret *fn_p_stOptionChangerProc(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
M_EvalNextParameter(&stParam);
switch ( eProcedureId )
{
case eProc_OptionConfigureKey : /*change the input value of the first action with the second action */
{
IPT_tdxHandleToEntryElement IPT_xHandleToChange , IPT_xHandle ;
IPT_xHandleToChange = ( IPT_tdxHandleToEntryElement ) M_GetSetParam_lValue ( & stParam ) ;
M_EvalNextParameter ( & stParam ) ;
IPT_xHandle = ( IPT_tdxHandleToEntryElement ) M_GetSetParam_lValue ( & stParam ) ;
if ( IPT_fn_bModifyIPTAction ( IPT_xHandleToChange , IPT_xHandle ) != IPT_C_TRUE )
{
SAF_M_AssertWithMsg(IPT_C_FALSE, "Input handle non modifiable");
}
}
break ;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_OptionChangeActionKey: /*change the input value of the specified action with the last validated basic input*/
{
/* get button handle*/
IPT_tdxHandleToEntryElement IPT_xHandle = (IPT_tdxHandleToEntryElement) M_GetSetParam_lValue(&stParam);
if (IPT_fn_bChangeIPTValue(IPT_xHandle, IPT_C_Exchange) != IPT_C_TRUE)
{
SAF_M_AssertWithMsg(IPT_C_FALSE, "Input handle non modifiable");
}
}
break;
case eProc_OptionChangeDetailsValue:
fn_vChangeDetailsValue(M_GetSetParam_lValue(&stParam));
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_OptionChangeMusicVolume:
fn_vChangeMusicVolumeValue(M_GetSetParam_lValue(&stParam));
break;
case eProc_OptionChangeSfxVolume:
fn_vChangeFxVolumeValue(M_GetSetParam_lValue(&stParam));
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
#ifdef D_USE_LIPSYNC
case eProc_OptionChangeVoiceVolume:
fn_vChangeVoiceVolumeValue(M_GetSetParam_lValue(&stParam));
break;
#endif
#endif // _AI_EXCLUDE_NEVER_USED_ }
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
break;
}
return p_stTree;
}
/*ENDANNECY BBB 16/10/97 }*/
#ifdef U64
/* FQ CINE*/
extern char g_CinemaScopeMode;
extern int g_CinemaScopeMinYClip;
extern int g_CinemaScopeMaxYClip;
/* END FQ CINE*/
#endif
/*******************************************************************************/
/*ANNECY CB*/
#ifdef U64
extern char g_ulUseAntiAliasing;
#endif /* U64 */
tdstNodeInterpret *fn_p_stChangeScreen(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
unsigned long ulMode;
long lVal1, lVal2, lVal3, lVal4;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
unsigned long ulChangeScreenPositionInPercent = 0;
M_EvalNextParameter(&stParam);
ulMode = M_GetSetParam_lValue(&stParam);
switch ( eProcedureId )
{
case eProc_ChangeScreenClip:
M_EvalNextParameter(&stParam);
lVal1 = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lVal2 = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lVal3 = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lVal4 = M_GetSetParam_lValue(&stParam);
#ifndef U64
#ifndef RETAIL
DEMO_fn_vSaveChangeViewportSize ((unsigned char)ulMode ,2 , 0 , 0 , (unsigned char)lVal1 , (unsigned char)lVal2 , (unsigned char)lVal3 , (unsigned char)lVal4 , 0 , 0);
#endif /* RETAIL */
fn_vChangeViewPortPercent(ulMode, 2, 0, 0, lVal1, lVal2, lVal3, lVal4, 0, 0);
#else
if ((lVal1==0) && (lVal2==0) && (lVal3==100) && (lVal4==100))
{
g_CinemaScopeMode=0;
g_ulUseAntiAliasing=0;
}
else
{
g_CinemaScopeMinYClip=lVal1;
g_CinemaScopeMaxYClip=lVal3;
g_CinemaScopeMode=1;
g_ulUseAntiAliasing=1;
}
#endif
break;
case eProc_ChangeScreenSize:
M_EvalNextParameter(&stParam);
lVal1 = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lVal2 = M_GetSetParam_lValue(&stParam);
if(lVal1 < 0) lVal1 = 0;
if(lVal1 > 100) lVal1 = 100;
if(lVal2 < 0) lVal2 = 0;
if(lVal2 > 100) lVal2 = 100;
#ifndef U64
#ifndef RETAIL
DEMO_fn_vSaveChangeViewportSize ((unsigned char)ulMode , 1 ,(unsigned char)lVal1 , (unsigned char)lVal2 , 0 , 0 , 0 , 0 , 0 , 0);
#endif /* RETAIL */
fn_vChangeViewPortPercent(ulMode, 1, lVal1, lVal2, 0, 0, 0, 0, 0, 0);
#else
/* M_PrintfN64(("eProc_ChangeScreenSize\n"));*/
/* M_PrintfN64(("Parametre = eProc_ChangeScreenSize %d %d\n",lVal1,lVal2));*/
/*if (lVal2==100) g_CinemaScopeMode=0;
else
{
// We copy the new Y size here
g_CinemaScopeYSize=lVal2;
g_CinemaScopeMode=2;
}*/
#endif
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
case eProc_ChangeScreenPosPercent:
ulChangeScreenPositionInPercent = 1;
/*no break : it's normal*/
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
case eProc_ChangeScreenPos:
M_EvalNextParameter(&stParam);
lVal1 = (int) M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lVal2 = (int) M_GetSetParam_lValue(&stParam);
#ifndef U64
#ifndef RETAIL
DEMO_fn_vSaveChangeViewportSize ((unsigned char)ulMode, (unsigned char) (3 + ulChangeScreenPositionInPercent), 0 , 0 , 0 , 0 , 0 , 0 , (unsigned char)lVal1 , (unsigned char)lVal2);
#endif /* RETAIL */
#endif
fn_vChangeViewPortPercent(ulMode, 3 + ulChangeScreenPositionInPercent, 0, 0, 0, 0, 0, 0, (int) lVal1, (int) lVal2);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
case eProc_ChangeScreenRatio :
M_EvalNextParameter(&stParam);
fn_vChangeViewportRatio (ulMode, M_ReturnParam_xValue(&stParam)) ;
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
default:
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
break;
}
return p_stTree;
}
/*ENDANNECY CB*/
/*ANNECY jt {*/
/*****************************************************************************
* Function: orient toward an obstacle *
* Use : PlaqueContreMur () *
* Use for : orient a perso toward normal of collide obstacle *
* Author : Jacques Thénoz *
* Date of last modification: 21/11/97 *
*****************************************************************************/
/*tdstNodeInterpret *fn_p_OrientWallNormal (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
if (eProcedureId==eProc_OrientWallNormal)
{
MTH3D_tdstVector stNormalVector;
DNM_tdstReport *p_stDynamReport;
DNM_tdstObstacle* p_stObstacle;
MS_tdxHandleToDynam h_Dynam;
tdstMACDPID *p_stMACDPID;
MTH_tdxReal xAngle;
MTH3D_tdstVector stVectorAxis;
if (fn_bGethDynamAndMACDPIDPointers(p_SuperObjPerso,&h_Dynam,&p_stMACDPID))
{
if ( (p_stDynamReport = fn_pstGetDNMReport(p_SuperObjPerso))!=NULL )
{
p_stObstacle = DNM_M_p_stReportGetWall(p_stDynamReport);
if (p_stObstacle)
{
MTH3D_M_vCopyVector ( &stNormalVector, DNM_M_p_stObstacleGetNorm (p_stObstacle) );
if ( MTH_M_bIsNull(MTH3D_M_xGetYofVector(&stNormalVector)) )
{
if (MTH_M_bIsNull(MTH3D_M_xGetXofVector(&stNormalVector))) return p_stTree;
xAngle = MTH_M_xATan( MTH3D_M_xGetYofVector(&stNormalVector)/MTH3D_M_xGetXofVector(&stNormalVector) );
}
else xAngle = MTH_M_xATan( -MTH3D_M_xGetXofVector(&stNormalVector)/MTH3D_M_xGetYofVector(&stNormalVector) );
if (MTH3D_M_xGetYofVector(&stNormalVector)<MTH_C_ZERO) xAngle = MTH_M_xAdd ( xAngle, MTH_C_Pi );
fn_vBoolAddRequestWithDynam(p_SuperObjPerso,h_Dynam,LRM_eRequest_TurnAbsolute);
MTH3D_M_vSetVectorElements(&stVectorAxis, MTH_C_ZERO, MTH_C_ZERO, MTH_C_ONE);
M_vMACDPIDSetOrientation(p_stMACDPID,xAngle,&stVectorAxis);
}
}
}
}
return p_stTree;
}*/
/*ENDANNECY jt }*/
/*ANNECY CG {*/
/*******************************************************************
* Procedure: FixePositionPerso *
* Use : FixePositionPerso( Perso, Vecteur_Nlle_Position ) *
* Author : Christophe Giraud *
* Date of last modification: 26/02/98 *
*******************************************************************/
tdstNodeInterpret *fn_p_stFixePositionPerso( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
HIE_tdxHandleToSuperObject hPerso;
MTH3D_tdstVector *p_stVector;
MS_tdxHandleToDynam h_Dynam;
DNM_tdstDynamics *p_stDynamics ;
GEO_tdxHandleToMatrix hGlobalMatrix;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/* Get first parameter that is a Perso*/
M_EvalNextParameter( &stParam );
hPerso = (HIE_tdxHandleToSuperObject) M_GetSetParam_p_stSupObjValue( &stParam );
SAF_M_AssertWithMsg(hPerso, "le perso spécifié est invalide");
#if defined(ACTIVE_EDITOR) && defined(__DEBUG_AI__)
if ( fn_bStandardGameIsAPlatform(hPerso) )
{
char szMsg[512], *pszPersoName;
int i, iNbActorChildren = 0;
HIE_tdxHandleToSuperObject hChild;
strcpy(szMsg, "il est interdit de deplacer une plateforme qui a des fils par cette méthode!\n Les fils sont:");
HIE_M_ForEachChildOf(hPerso,hChild,i)
{
if ( HIE_fn_ulGetSuperObjectType(hChild) == HIE_C_ulActor )
{
tdstEngineObject *hChildActor = (tdstEngineObject *) HIE_fn_hGetSuperObjectObject(hChild);
strcat(szMsg, "\n\t- ");
if (hChildActor->h_Brain && hChildActor->h_Brain->p_stMind)
{
pszPersoName = hChildActor->h_Brain->p_stMind->szPersoName;
}
else
{
pszPersoName = "**unknown**";
}
strcat(szMsg, pszPersoName);
iNbActorChildren ++;
}
}
SAF_M_AssertWithMsg((iNbActorChildren == 0), szMsg);
}
#endif
/* Get second parameter that is a vector*/
M_EvalNextParameter( &stParam );
p_stVector = &M_GetSetParam_stVertexValue( &stParam );
switch(eProcedureId)
{
case eProc_FixePositionPerso:
{
h_Dynam = M_GetMSHandle(hPerso,Dynam);
if ( h_Dynam )
{
p_stDynamics=fn_p_stDynamGetDynamics(h_Dynam);
MEC_vInitTranslation( p_stDynamics, hPerso, p_stVector ) ;
}
else
{
hGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix (hPerso);
POS_fn_vSetTranslationVector ( hGlobalMatrix, p_stVector );
HIE_fn_vComputeNewRelativeMatrix (hPerso);
}
return p_stTree;
break; /* anti-bug GCC N64*/
}
default:
{
/* Procedure does not exist !!*/
M_AIFatalError(E_uwAIFatalNotValidProcedure);
return(p_stTree);
break;
}
}
}
/*ENDANNECY CG }*/
/*******************************************************************
* Procedure: FixePositionZDM *
* Use : FixePositionZDM( Perso, ZDM, Vecteur_Nlle_Position ) *
* Procedure: FixePositionZDE *
* Use : FixePositionZDE( Perso, ZDE, Vecteur_Nlle_Position ) *
* Procedure: FixePositionZDD *
* Use : FixePositionZDD( Perso, ZDD, Vecteur_Nlle_Position ) *
* Author : Christophe Giraud *
* Date of last modification: 27/10/97 *
*******************************************************************/
tdstNodeInterpret *fn_p_stFixePositionZDx( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
HIE_tdxHandleToSuperObject hPerso;
MTH3D_tdstVector *p_stVector,
stVectorMin,
stVectorMax,
stTmpVector;
ACP_tdxIndex xMaxPoint,
xMinPoint;
ACP_tdxHandleOfObject hGeoObj;
long lZoneNumber;
/*XB*/
char *cName;
/*End XB*/
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/* Get first parameter that is a Perso*/
M_EvalNextParameter( &stParam );
hPerso = (HIE_tdxHandleToSuperObject) M_GetSetParam_p_stSupObjValue( &stParam );
SAF_M_AssertWithMsg(hPerso, "l'acteur spécifié est nul");
/*XB*/
cName = AI_M_szGetPersoName(AI_M_stGetMindOfSuperObj(hPerso));
/*End XB*/
/* Get second parameter that is a ZDM*/
M_EvalNextParameter( &stParam );
lZoneNumber = (long) M_GetSetParam_lZDMIdValue(&stParam);
/* Get third parameter that is a vector*/
M_EvalNextParameter( &stParam );
p_stVector = &M_GetSetParam_stVertexValue( &stParam );
switch(eProcedureId)
{
case eProc_FixePositionZDM:
hGeoObj = fn_hGetGeometricZdxOfTypeAtIndex( C_ucTypeZdm, (unsigned short)(lZoneNumber-1), hPerso );
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_FixePositionZDD:
hGeoObj = fn_hGetGeometricZdxOfTypeAtIndex( C_ucTypeZdd, (unsigned short)(lZoneNumber-1), hPerso );
break;
case eProc_FixePositionZDE:
hGeoObj = fn_hGetGeometricZdxOfTypeAtIndex( C_ucTypeZde, (unsigned short)(lZoneNumber-1), hPerso );
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
default:
{
/* Procedure does not exist !!*/
M_AIFatalError(E_uwAIFatalNotValidProcedure);
return(p_stTree);
break;
}
}
/* Move geometric object*/
if( hGeoObj )
{
switch( *hGeoObj->d_xListOfElementsTypes )
{
case GEO_C_xElementPoints: /* It's a point:*/
case GEO_C_xElementSpheres: /* It's a sphere:*/
{
/* Set new Point*/
GEO_vSetPointOfObject( hGeoObj, p_stVector, 0 );
GEO_vEndModifyObject2( hGeoObj );
}
break;
case GEO_C_xElementAlignedBoxes: /* It's a box.*/
case GEO_C_xElementCones: /* It's a cone:*/
{
/* Get MinPoint and MaxPoint of the box*/
GEO_vGetMinMaxPointOfIndexedAlignedBox ( hGeoObj, 0, 0, &xMinPoint, &xMaxPoint );
/* Get MinVector and MaxVector of the box*/
GEO_vGetPointOfObject( hGeoObj, &stVectorMin, xMinPoint );
GEO_vGetPointOfObject( hGeoObj, &stVectorMax, xMaxPoint );
/* Distance between old min point and new min point*/
MTH3D_M_vSubVector( &stTmpVector, p_stVector, &stVectorMin );
/* Compute new MaxVector*/
MTH3D_M_vAddVector( &stVectorMin, &stVectorMin, &stTmpVector );
MTH3D_M_vAddVector( &stVectorMax, &stVectorMax, &stTmpVector );
/* Set new MaxPoint*/
GEO_vSetPointOfObject( hGeoObj, &stVectorMin, xMinPoint );
GEO_vSetPointOfObject( hGeoObj, &stVectorMax, xMaxPoint );
GEO_vEndModifyObject2( hGeoObj );
}
break;
}
}
return p_stTree;
}
/*ENDANNECY CG }*/
/*****************************************************************************
* Function: Set option mechanic flags *
* Use : ActiveTruc ( vrai ou faux ) *
* Author : Jacques Thénoz *
* Date of last modification: 16/12/97 *
*****************************************************************************/
tdstNodeInterpret *fn_p_SetMechanicOption (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stValue;
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/* get button handle*/
M_EvalNextParameter(&stValue);
/* Get Dynamics structure*/
h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
if (!h_Dynam)
{
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIWarningScriptError , C_lErmNoDebugData,
C_ucErmOpenInfoWindow, C_ucNeverStopForDebug,
"You must allocate Dynamics.");
Erm_fn_iMessageBox ("You must allocate Dynamics.","STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
#endif
#endif
return(p_stTree);
}
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
switch (eProcedureId)
{
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
case eProc_SetMechanicAnimation :
DNM_M_vDynamicsSetAnimation (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
case eProc_SetMechanicCollide :
DNM_M_vDynamicsSetCollide (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
/* init collide matrix */
if (M_GetSetParam_lValue(&stValue))
DNM_M_vDynamicsSetCollisionTranslation ( pstDynamic, POS_fn_p_stGetTranslationVector(DNM_M_p_stDynamicsGetCurrentMatrix(pstDynamic)) );
break;
case eProc_SetMechanicGravity :
DNM_M_vDynamicsSetGravity (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_SetMechanicTilt :
DNM_M_vDynamicsSetTilt (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
case eProc_SetMechanicGi :
DNM_M_vDynamicsSetGi (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
case eProc_SetMechanicClimb :
DNM_M_vDynamicsSetClimb (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_SetMechanicOnGround :
DNM_M_vDynamicsSetOnGround (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_SetMechanicSpider :
DNM_M_vDynamicsSetSpider (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_SetMechanicShoot :
DNM_M_vDynamicsSetShoot (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
case eProc_SetMechanicSwim :
DNM_M_vDynamicsSetSwim (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
case eProc_SetMechanicNeverFall :
DNM_M_vDynamicsSetNeverFall (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
case eProc_SetMechanicCollisionControl :
DNM_M_vDynamicsSetCollisionControl (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_SetMechanicKeepSpeedZ :
DNM_M_vDynamicsSetKeepWallSpeedZ (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_SetMechanicSpeedLimit :
DNM_M_vDynamicsSetSpeedLimit (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
case eProc_SetMechanicInertia :
DNM_M_vDynamicsSetInertia (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
case eProc_SetMechanicStream :
DNM_M_vDynamicsSetStream (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
case eProc_SetMechanicStickOnPlatform :
DNM_M_vDynamicsSetStickOnPlatform (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
case eProc_SetMechanicScale :
DNM_M_vDynamicsSetScaleOption (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
case eProc_SetMechanicNewMechanic :
DNM_M_vDynamicsSetDontUseNewMechanic (pstDynamic,(BOOL) M_GetSetParam_lValue(&stValue)?TRUE:FALSE);
break;
default:
break;
}
return p_stTree;
}
/*ANNECY JMD {*/
/****************************************************************************************
* Procedure : ChangerIntensiteLumineuse
* Use : ChangerIntensiteLumineuse ( "Actor", R, G, B, Intensité )
* Author : Jean-Marc Drouaud
****************************************************************************************/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
tdstNodeInterpret *fn_p_stChangeLigthIntensity(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstEngineObject *hPerso;
tdstGetSetParam stParam;
MS_tdxHandleToMSLight h_MSLight = NULL;
/*GEO_tdstColor *p_tdstColor, tdstColor;*/
float xStep ;
GEO_tdxColorValue xR,xG,xB;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/* Perso*/
M_EvalNextParameter(&stParam);
hPerso = M_GetSetParam_p_stEngineObjValue(&stParam) ;
h_MSLight=hPerso->h_MSLight;
if ( h_MSLight==NULL )
return(p_stTree);
if (eProcedureId == eProc_ChangeLightIntensity ) {
M_EvalNextParameter(&stParam);
xR = M_GetSetParam_xValue(&stParam) ;
M_EvalNextParameter(&stParam);
xG = M_GetSetParam_xValue(&stParam) ;
M_EvalNextParameter(&stParam);
xB = M_GetSetParam_xValue(&stParam) ;
M_EvalNextParameter(&stParam);
xStep = M_GetSetParam_xValue(&stParam) ;
fn_vMSLightSetColorRGBA(h_MSLight,(xR*xStep),(xG*xStep),(xB*xStep),0.0);
}
return(p_stTree);
}
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
/*ENDANNECY JMD }*/
/*****************************************************************************
* Function: Set mechanic real parameter *
* Use : FixeTruc ( value ) *
* Author : Jacques Thénoz *
* Date of last modification: 16/12/97 *
*****************************************************************************/
tdstNodeInterpret *fn_p_SetMechanicRealParameter (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stValue;
MTH_tdxReal xValue;
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
M_EvalNextParameter(&stValue);
xValue = M_GetSetParam_xValue (&stValue);
/* Get Dynamic structure*/
h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
if (!h_Dynam)
{
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIWarningScriptError , C_lErmNoDebugData,
C_ucErmOpenInfoWindow, C_ucNeverStopForDebug,
"You must allocate Dynamics.");
Erm_fn_iMessageBox ("You must allocate Dynamics.","STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
#endif
#endif
return(p_stTree);
}
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
switch (eProcedureId)
{
case eProc_SetMechanicGravityFactor :
DNM_M_vDynamicsSetGravityFactor (pstDynamic,xValue);
break;
case eProc_SetMechanicSlide :
DNM_M_vDynamicsSetSlide (pstDynamic,xValue);
break;
case eProc_SetMechanicRebound :
DNM_M_vDynamicsSetRebound (pstDynamic,xValue);
break;
case eProc_SetMechanicSlopeLimit :
DNM_M_vDynamicsSetSlopeLimit ( pstDynamic, MTH_M_xTan (MTH_M_xDegToRad (xValue)) );
break;
case eProc_SetMechanicInertiaX :
DNM_M_vDynamicsSetInertiaFactorX (pstDynamic,xValue);
break;
case eProc_SetMechanicInertiaY :
DNM_M_vDynamicsSetInertiaFactorY (pstDynamic,xValue);
break;
case eProc_SetMechanicInertiaZ :
DNM_M_vDynamicsSetInertiaFactorZ (pstDynamic,xValue);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_SetMechanicTiltIntensity :
DNM_M_vDynamicsSetTiltIntensity (pstDynamic,xValue);
break;
case eProc_SetMechanicTiltInertia :
DNM_M_vDynamicsSetTiltInertia (pstDynamic,xValue);
break;
case eProc_SetMechanicTiltOrigin :
DNM_M_vDynamicsSetTiltOrigin (pstDynamic,xValue);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_SetMechanicStreamPriority :
DNM_M_vDynamicsSetStreamPriority (pstDynamic,xValue);
break;
case eProc_SetMechanicStreamFactor :
DNM_M_vDynamicsSetStreamFactor (pstDynamic,xValue);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_MecSetSlideFactorX :
DNM_M_vDynamicsSetSlideFactorX (pstDynamic,xValue);
break;
case eProc_MecSetSlideFactorY :
DNM_M_vDynamicsSetSlideFactorY (pstDynamic,xValue);
break;
case eProc_MecSetSlideFactorZ :
DNM_M_vDynamicsSetSlideFactorZ (pstDynamic,xValue);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_MecSetHangingLimit :
DNM_M_vDynamicsSetHanging (pstDynamic,TRUE);
DNM_M_vDynamicsSetCollide (pstDynamic,TRUE);
DNM_M_vDynamicsSetKeepWallSpeedZ (pstDynamic,TRUE);
DNM_M_vDynamicsSetCollisionControl (pstDynamic,TRUE);
DNM_M_vDynamicsSetSlide (pstDynamic,MTH_C_ONE);
DNM_M_vDynamicsSetRebound (pstDynamic,MTH_C_ZERO);
/* DNM_M_vDynamicsSetHangingLimit (pstDynamic,xValue); */
DNM_fn_vSetHangingLimit (pstDynamic,xValue);
break;
case eProc_MecSetBaseCoeff :
MEC_g_xBaseCoeff = xValue;
break;
case eProc_MecSetWalkCoeff :
MEC_g_xWalkCoeff = xValue;
break;
default:
break;
}
return p_stTree;
}
/*****************************************************************************
* Function: Set mechanic 3 real parameter *
* Use : FixeTruc ( value ) *
* Author : Jacques Thénoz *
* Date of last modification: 02/02/98 *
*****************************************************************************/
tdstNodeInterpret *fn_p_SetMechanic3RealParameter (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stValue;
MTH_tdxReal xValue1, xValue2, xValue3;
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
M_EvalNextParameter(&stValue);
xValue1 = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValue2 = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValue3 = M_GetSetParam_xValue (&stValue);
/* Get Dynamic structure*/
h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
if (!h_Dynam)
{
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIWarningScriptError , C_lErmNoDebugData,
C_ucErmOpenInfoWindow, C_ucNeverStopForDebug,
"You must allocate Dynamics.");
Erm_fn_iMessageBox ("You must allocate Dynamics.","STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
#endif
#endif
return(p_stTree);
}
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
switch (eProcedureId)
{
case eProc_SetMechanicInertiaXYZ :
DNM_M_vDynamicsSetInertiaFactorX (pstDynamic,xValue1);
DNM_M_vDynamicsSetInertiaFactorY (pstDynamic,xValue2);
DNM_M_vDynamicsSetInertiaFactorZ (pstDynamic,xValue3);
break;
default:
break;
}
return p_stTree;
}
/*****************************************************************************
* Function: Set mechanic vector parameter *
* Use : FixeTruc ( value ) *
* Author : Jacques Thénoz *
* Date of last modification: 29/12/97 *
*****************************************************************************/
tdstNodeInterpret *fn_p_SetMechanicVectorParameter (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stValue;
MTH3D_tdstVector *p_stVector, stVector;
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
M_EvalNextParameter(&stValue);
p_stVector = &M_GetSetParam_stVertexValue(&stValue);
/* Get Dynamic structure*/
h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
if (!h_Dynam)
{
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIWarningScriptError , C_lErmNoDebugData,
C_ucErmOpenInfoWindow, C_ucNeverStopForDebug,
"You must allocate Dynamics.");
Erm_fn_iMessageBox ("You must allocate Dynamics.","STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
#endif
#endif
return(p_stTree);
}
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
switch (eProcedureId)
{
case eProc_SetMechanicSpeedMax :
{
MTH_tdxReal xTmp;
/* read the current value*/
stVector = *DNM_M_pDynamicsGetMaxSpeed(pstDynamic);
/* replace only with the provided values that are positive or null*/
xTmp = MTH3D_M_xGetXofVector(p_stVector);
if ( MTH_M_bGreaterZero(xTmp) )
MTH3D_M_vSetXofVector(&stVector, xTmp);
xTmp = MTH3D_M_xGetYofVector(p_stVector);
if ( MTH_M_bGreaterZero(xTmp) )
MTH3D_M_vSetYofVector(&stVector, xTmp);
xTmp = MTH3D_M_xGetZofVector(p_stVector);
if ( MTH_M_bGreaterZero(xTmp) )
MTH3D_M_vSetZofVector(&stVector, xTmp);
/* and set it back into the dynamics structure*/
DNM_M_vDynamicsSetMaxSpeed (pstDynamic,&stVector);
}
break;
case eProc_SetMechanicStreamSpeed :
DNM_M_vDynamicsSetStreamSpeed (pstDynamic,p_stVector);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_AddMechanicStreamSpeed :
MTH3D_M_vAddVector ( &stVector, DNM_M_pDynamicsGetStreamSpeed (pstDynamic), p_stVector );
DNM_M_vDynamicsSetStreamSpeed (pstDynamic,&stVector);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
default:
break;
}
return p_stTree;
}
/*****************************************************************************
* Function: Set mechanic speed *
* Use : xxxVecteurVitesse ( vector ) *
* Author : Jacques Thénoz *
* Date of last modification: 23/12/97 *
*****************************************************************************/
tdstNodeInterpret *fn_p_SetMechanicSpeedVector (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stValue;
MTH3D_tdstVector *p_stVector;
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/* get button handle*/
M_EvalNextParameter(&stValue);
p_stVector = &M_GetSetParam_stVertexValue(&stValue);
/* Get Dynamics structure*/
h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
if (!h_Dynam)
{
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIWarningScriptError , C_lErmNoDebugData,
C_ucErmOpenInfoWindow, C_ucNeverStopForDebug,
"You must allocate Dynamics.");
Erm_fn_iMessageBox ("You must allocate Dynamics.","STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
#endif
#endif
return(p_stTree);
}
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
switch (eProcedureId)
{
case eProc_ProposeSpeed :
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetProposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeedZ (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeed (pstDynamic,p_stVector);
break;
case eProc_ImposeSpeed :
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetImposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeedZ (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeed (pstDynamic,p_stVector);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
case eProc_AddSpeed :
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetAddSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeedZ (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeed (pstDynamic,p_stVector);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
case eProc_ProposeAbsoluteSpeed :
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetProposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeedZ (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeed (pstDynamic,p_stVector);
break;
case eProc_ImposeAbsoluteSpeed :
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetImposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeedZ (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeed (pstDynamic,p_stVector);
break;
case eProc_AddAbsoluteSpeed :
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetAddSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeedZ (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeed (pstDynamic,p_stVector);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
case eProc_MoveLimit :
DNM_M_vDynamicsSetLimitX (pstDynamic,TRUE);
DNM_M_vDynamicsSetLimitY (pstDynamic,TRUE);
DNM_M_vDynamicsSetLimitZ (pstDynamic,TRUE);
DNM_M_vDynamicsSetLimit (pstDynamic,p_stVector);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
default:
break;
}
return p_stTree;
}
/*****************************************************************************
* Function: Set mechanic speed *
* Use : xxxVecteurVitesse ( real, real, ... ) *
* Author : Jacques Thénoz *
* Date of last modification: 12/01/98 *
*****************************************************************************/
tdstNodeInterpret *fn_p_SetMechanicSpeedReal (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stValue;
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
MTH_tdxReal xValueX, xValueY, xValueZ;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/* get button handle*/
xValueX = MTH_C_ZERO;
xValueY = MTH_C_ZERO;
xValueZ = MTH_C_ZERO;
/* Get Dynamics structure*/
h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
if (!h_Dynam)
{
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIWarningScriptError , C_lErmNoDebugData,
C_ucErmOpenInfoWindow, C_ucNeverStopForDebug,
"You must allocate Dynamics.");
Erm_fn_iMessageBox ("You must allocate Dynamics.","STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
#endif
#endif
return(p_stTree);
}
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
switch (eProcedureId)
{
case eProc_ImposeSpeedX :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsImposeSpeedY(pstDynamic)||DNM_M_bDynamicsIsImposeSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsAbsoluteImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic)) ),*/
/* "You have already impose an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetImposeSpeedX (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueX);
break;
case eProc_ImposeSpeedY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsImposeSpeedX(pstDynamic)||DNM_M_bDynamicsIsImposeSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsAbsoluteImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already impose an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetImposeSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueY);
break;
case eProc_ImposeSpeedZ :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsImposeSpeedX(pstDynamic)||DNM_M_bDynamicsIsImposeSpeedY(pstDynamic)) && DNM_M_bDynamicsIsAbsoluteImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already impose an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetImposeSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueZ);
break;
case eProc_ImposeSpeedXY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !(DNM_M_bDynamicsIsImposeSpeedZ(pstDynamic) && DNM_M_bDynamicsIsAbsoluteImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already impose an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetImposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueY);
break;
case eProc_ImposeSpeedXYZ :
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetImposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueY);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueZ);
break;
case eProc_ProposeSpeedX :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsProposeSpeedY(pstDynamic)||DNM_M_bDynamicsIsProposeSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsAbsoluteProposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already propose an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetProposeSpeedX (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueX);
break;
case eProc_ProposeSpeedY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsProposeSpeedX(pstDynamic)||DNM_M_bDynamicsIsProposeSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsAbsoluteProposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already propose an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetProposeSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueY);
break;
case eProc_ProposeSpeedZ :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsProposeSpeedX(pstDynamic)||DNM_M_bDynamicsIsProposeSpeedY(pstDynamic)) && DNM_M_bDynamicsIsAbsoluteProposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already propose an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetProposeSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueZ);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_ProposeSpeedXY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !(DNM_M_bDynamicsIsProposeSpeedZ(pstDynamic) && DNM_M_bDynamicsIsAbsoluteProposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already propose an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetProposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueY);
break;
case eProc_ProposeSpeedXYZ :
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetProposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueY);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueZ);
break;
case eProc_ImposeAbsoluteSpeedX :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsImposeSpeedY(pstDynamic)||DNM_M_bDynamicsIsImposeSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsRelativeImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already impose a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetImposeSpeedX (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueX);
break;
case eProc_ImposeAbsoluteSpeedY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsImposeSpeedX(pstDynamic)||DNM_M_bDynamicsIsImposeSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsRelativeImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already impose a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetImposeSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueY);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_ImposeAbsoluteSpeedZ :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsImposeSpeedX(pstDynamic)||DNM_M_bDynamicsIsImposeSpeedY(pstDynamic)) && DNM_M_bDynamicsIsRelativeImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already impose a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetImposeSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueZ);
break;
case eProc_ImposeAbsoluteSpeedXY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !(DNM_M_bDynamicsIsImposeSpeedZ(pstDynamic) && DNM_M_bDynamicsIsRelativeImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already impose a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetImposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueY);
break;
case eProc_ImposeAbsoluteSpeedXYZ :
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteImposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetImposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetImposeSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueY);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueZ);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_ProposeAbsoluteSpeedX :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsProposeSpeedY(pstDynamic)||DNM_M_bDynamicsIsProposeSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsRelativeImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already propose a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetProposeSpeedX (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueX);
break;
case eProc_ProposeAbsoluteSpeedY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsProposeSpeedX(pstDynamic)||DNM_M_bDynamicsIsProposeSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsRelativeImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already propose a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetProposeSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueY);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_ProposeAbsoluteSpeedZ :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsProposeSpeedX(pstDynamic)||DNM_M_bDynamicsIsProposeSpeedY(pstDynamic)) && DNM_M_bDynamicsIsRelativeImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already propose a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetProposeSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueZ);
break;
case eProc_ProposeAbsoluteSpeedXY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !(DNM_M_bDynamicsIsProposeSpeedZ(pstDynamic) && DNM_M_bDynamicsIsRelativeImposeSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already propose a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetProposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueY);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_ProposeAbsoluteSpeedXYZ :
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteProposeSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetProposeSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetProposeSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueY);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetProposeSpeed (pstDynamic),xValueZ);
break;
case eProc_AddSpeedX :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsAddSpeedY(pstDynamic)||DNM_M_bDynamicsIsAddSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsAbsoluteAddSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already add an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetAddSpeedX (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetAddSpeed (pstDynamic),xValueX);
break;
case eProc_AddSpeedY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsAddSpeedX(pstDynamic)||DNM_M_bDynamicsIsAddSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsAbsoluteAddSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already add an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetAddSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetAddSpeed (pstDynamic),xValueY);
break;
case eProc_AddSpeedZ :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsAddSpeedX(pstDynamic)||DNM_M_bDynamicsIsAddSpeedY(pstDynamic)) && DNM_M_bDynamicsIsAbsoluteAddSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already add an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetAddSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetAddSpeed (pstDynamic),xValueZ);
break;
case eProc_AddSpeedXY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !(DNM_M_bDynamicsIsAddSpeedZ(pstDynamic) && DNM_M_bDynamicsIsAbsoluteAddSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already add an absolute speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetAddSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetAddSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetAddSpeed (pstDynamic),xValueY);
break;
case eProc_AddSpeedXYZ :
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, FALSE );
DNM_M_vDynamicsSetAddSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetAddSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetAddSpeed (pstDynamic),xValueY);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetAddSpeed (pstDynamic),xValueZ);
break;
case eProc_AddAbsoluteSpeedX :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsAddSpeedY(pstDynamic)||DNM_M_bDynamicsIsAddSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsRelativeAddSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already add a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetAddSpeedX (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueX);
break;
case eProc_AddAbsoluteSpeedY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsAddSpeedX(pstDynamic)||DNM_M_bDynamicsIsAddSpeedZ(pstDynamic)) && DNM_M_bDynamicsIsRelativeAddSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already add a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetAddSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueY);
break;
case eProc_AddAbsoluteSpeedZ :
/* SAF_M_AssertWithMsg */
/* ( */
/* !((DNM_M_bDynamicsIsAddSpeedX(pstDynamic)||DNM_M_bDynamicsIsAddSpeedY(pstDynamic)) && DNM_M_bDynamicsIsRelativeAddSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already add a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetAddSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueZ);
break;
case eProc_AddAbsoluteSpeedXY :
/* SAF_M_AssertWithMsg */
/* ( */
/* !(DNM_M_bDynamicsIsAddSpeedZ(pstDynamic) && DNM_M_bDynamicsIsRelativeAddSpeed(pstDynamic) && !MTH3D_M_bIsNullVector(DNM_M_pDynamicsGetImposeSpeed (pstDynamic))),*/
/* "You have already add a relative speed."*/
/* );*/
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetAddSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeedY (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueY);
break;
case eProc_AddAbsoluteSpeedXYZ :
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_bDynamicsSetAbsoluteAddSpeed (pstDynamic, TRUE );
DNM_M_vDynamicsSetAddSpeedX (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeedY (pstDynamic,TRUE);
DNM_M_vDynamicsSetAddSpeedZ (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueY);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetImposeSpeed (pstDynamic),xValueZ);
break;
case eProc_MoveLimitX :
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
DNM_M_vDynamicsSetLimitX (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetLimit (pstDynamic),xValueX);
break;
case eProc_MoveLimitY :
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
DNM_M_vDynamicsSetLimitY (pstDynamic,TRUE);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetLimit (pstDynamic),xValueY);
break;
case eProc_MoveLimitXYZ :
M_EvalNextParameter(&stValue);
xValueX = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueY = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_vDynamicsSetLimitX (pstDynamic,TRUE);
DNM_M_vDynamicsSetLimitY (pstDynamic,TRUE);
DNM_M_vDynamicsSetLimitZ (pstDynamic,TRUE);
MTH3D_M_vSetXofVector (DNM_M_pDynamicsGetLimit (pstDynamic),xValueX);
MTH3D_M_vSetYofVector (DNM_M_pDynamicsGetLimit (pstDynamic),xValueY);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetLimit (pstDynamic),xValueZ);
break;
case eProc_MoveLimitZ :
M_EvalNextParameter(&stValue);
xValueZ = M_GetSetParam_xValue (&stValue);
DNM_M_vDynamicsSetLimitZ (pstDynamic,TRUE);
MTH3D_M_vSetZofVector (DNM_M_pDynamicsGetLimit (pstDynamic),xValueZ);
break;
case eProc_StopMoveLimitX:
DNM_M_vDynamicsSetLimitX (pstDynamic,FALSE);
break;
case eProc_StopMoveLimitY:
DNM_M_vDynamicsSetLimitY (pstDynamic,FALSE);
break;
case eProc_StopMoveLimitZ:
DNM_M_vDynamicsSetLimitZ (pstDynamic,FALSE);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_StopMoveLimitXYZ:
DNM_M_vDynamicsSetLimitX (pstDynamic,FALSE);
DNM_M_vDynamicsSetLimitY (pstDynamic,FALSE);
DNM_M_vDynamicsSetLimitZ (pstDynamic,FALSE);
break;
case eProc_MecSetHangingOff:
DNM_M_vDynamicsSetHanging (pstDynamic,FALSE);
break;
default:
break;
}
return p_stTree;
}
/*ANNECY VL SPOFLAG 23/01/98{*/
/*
----------------------------------------------------------------------------------------
Description : change flag value of a bit in SPO flag bitfield
Parameters are :
1 -> SuperObject to be changed
2 -> Constant : bit to change ( possible values are 0 : not pickable, 1 : not visible)
3 -> Constant : value to set ( possible value are 0 : unset the bit or 1 to set the bit)
----------------------------------------------------------------------------------------
*/
tdstNodeInterpret *fn_SPO_p_stChangeFlag(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstGetSetParam stValue;
HIE_tdxHandleToSuperObject hSPO;
long lFlag;
long lSet;
unsigned long ulFlags;
unsigned long ulMask;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
M_EvalNextParameter(&stValue);
hSPO = M_GetSetParam_SuperObjectValue( &stValue );
M_EvalNextParameter(&stValue);
lFlag = M_GetSetParam_lValue( &stValue );
M_EvalNextParameter(&stValue);
lSet = M_GetSetParam_lValue( &stValue );
ulFlags = HIE_fn_SO_ulGetFlags( hSPO );
ulMask = 1 << lFlag;
if (lSet)
ulFlags |= ulMask;
else
ulFlags &= ~ulMask;
HIE_fn_SO_vSetFlags( hSPO, ulFlags);
return p_stTree;
}
/*ENDANNECY VL SPOFLAG}*/
/*YLT october 7, 1997*/
/*this procedure changes the spo flags of an actor.*/
tdstNodeInterpret *fn_p_stChangeActorSpoFlag(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstGetSetParam stValue;
long lFlag;
long lSet;
unsigned long ulFlags;
unsigned long ulMask;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
M_EvalNextParameter(&stValue);
lFlag = M_GetSetParam_lValue( &stValue );
M_EvalNextParameter(&stValue);
lSet = M_GetSetParam_lValue( &stValue );
ulFlags = HIE_fn_SO_ulGetFlags( hNewSuperObjPerso );
ulMask = 1 << lFlag;
if (lSet)
ulFlags |= ulMask;
else
ulFlags &= ~ulMask;
HIE_fn_SO_vSetFlags( hNewSuperObjPerso, ulFlags);
return p_stTree;
}
/*****************************************************************************
* Function: Force/Free links between actors and platforms *
* Author : Jacques Thénoz *
* Date of last modification: 02/02/98 *
*****************************************************************************/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
tdstNodeInterpret* fn_p_PlatformLink ( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree )
{
tdstGetSetParam stValue;
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
HIE_tdxHandleToSuperObject hPlatform;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/* Get Dynamics structure*/
h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
if (!h_Dynam)
{
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIWarningScriptError , C_lErmNoDebugData,
C_ucErmOpenInfoWindow, C_ucNeverStopForDebug,
"You must allocate Dynamics.");
Erm_fn_iMessageBox ("You must allocate Dynamics.","STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
#endif
#endif
return(p_stTree);
}
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
switch (eProcedureId)
{
case eProc_SetPlatformLink :
M_EvalNextParameter( &stValue );
hPlatform = (HIE_tdxHandleToSuperObject) M_GetSetParam_p_stSupObjValue( &stValue );
SAF_M_AssertWithMsg(hPlatform, "l'acteur spécifié est nul");
MEC_fn_vForcePlatformLink (pstDynamic,hNewSuperObjPerso,hPlatform);
break;
case eProc_FreePlatformLink :
MEC_fn_vFreePlatformLink (pstDynamic,hNewSuperObjPerso);
break;
default:
break;
}
return p_stTree;
}
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
/*****************************************************************************
* Function: Force/Free links between actors and platforms *
* Author : Jacques Thénoz *
* Date of last modification: 10/02/98 *
*****************************************************************************/
tdstNodeInterpret* fn_p_HierFatherLink ( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree )
{
tdstGetSetParam stValue;
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
HIE_tdxHandleToSuperObject hChildSuperObject;
HIE_tdxHandleToSuperObject hPlatform;
tdstList* p_stList;
int i;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/* Get Dynamics structure*/
h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
if ( h_Dynam )
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
else
pstDynamic = NULL;
switch (eProcedureId)
{
case eProc_HierSetFather :
M_EvalNextParameter( &stValue );
/* if the specified new father is invalid (ie when HIER_MonPere( is the argument, and the target has no actor father)*/
/* move the target in its father hierarchy (either as first platform or last normal actor)*/
if ( !M_GetSetParam_p_stEngineObjValue(&stValue) )
{
HIE_fn_vChangeFather(hNewSuperObjPerso, HIE_M_hGetSuperObjectFather(hNewSuperObjPerso), fn_bStandardGameIsAPlatform(hNewSuperObjPerso));
}
else
{
/* a platform cannot become child of another actor!*/
SAF_M_AssertWithMsg(
!fn_bStandardGameIsAPlatform(hNewSuperObjPerso),
"Une plateforme ne peut devenir fille d'un autre acteur!"
);
hPlatform = (HIE_tdxHandleToSuperObject) M_GetSetParam_p_stSupObjValue( &stValue );
SAF_M_AssertWithMsg(hPlatform, "l'acteur spécifié est nul");
/* if there is a base mechanics, set the mechanics link*/
if ( pstDynamic && MEC_fn_bIsBaseMechanic(pstDynamic) )
{
MEC_fn_vForcePlatformLink(pstDynamic,hNewSuperObjPerso,hPlatform);
}
else
{
/* a non-platform changes its father... at least do it only if it is not already its father!!!*/
HIE_fn_vChangeFather(hNewSuperObjPerso, hPlatform, FALSE);
}
}
break;
case eProc_HierFreeFather :
if ( pstDynamic && MEC_fn_bIsBaseMechanic(pstDynamic) )
MEC_fn_vFreePlatformLink(pstDynamic, hNewSuperObjPerso);
else
fn_vReputCharacterSuperObjectAtTheWorld(hNewSuperObjPerso);
break;
case eProc_HierListOfSon :
M_EvalNextParameter(&stValue);
p_stList=(tdstList *) M_GetSetParam_Dsg_List(&stValue);
M_ClearList(p_stList);
if ( M_ucGetMaxSizeOfList(p_stList) > 0 )
{
HIE_M_ForEachChildOf (hNewSuperObjPerso,hChildSuperObject,i)
{
if (HIE_fn_bIsSuperObjectValid(hChildSuperObject))
{
if (HIE_fn_ulGetSuperObjectType(hChildSuperObject) == HIE_C_ulActor)
{
fn_vPutInList(p_stList, hChildSuperObject);
/* list full ?*/
if ( M_ucNbEltInList(p_stList)==M_ucGetMaxSizeOfList(p_stList) )
{
return p_stTree;
break;
}
}
}
}
}
break;
default:
break;
}
return p_stTree;
}
/*****************************************************************************
* Function: Set mechanic list parameter *
* Use : FixeTruc ( value ) *
* Author : Jacques Thénoz *
* Date of last modification: 03/02/98 *
*****************************************************************************/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
tdstNodeInterpret *fn_p_SetMechanicListParameter (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stValue;
tdstList* p_stList;
MTH3D_tdstVector* p_stVector;
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
unsigned long ulMaxList, ulCounter;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
M_EvalNextParameter(&stValue);
p_stList=(tdstList *) M_GetSetParam_Dsg_List(&stValue);
M_EvalNextParameter(&stValue);
p_stVector = &M_GetSetParam_stVertexValue(&stValue);
switch (eProcedureId)
{
case eProc_AddMechanicStreamSpeedList :
ulMaxList = M_ucNbEltInList (p_stList);
for (ulCounter = 0; ulCounter < ulMaxList; ulCounter ++)
{
HIE_tdxHandleToSuperObject hSuperObject;
MTH3D_tdstVector stVector;
hSuperObject = fn_p_stGetPersoInList (p_stList,(unsigned char)ulCounter);
h_Dynam = M_GetMSHandle(hSuperObject,Dynam);
if (!h_Dynam)
{
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIWarningScriptError , C_lErmNoDebugData,
C_ucErmOpenInfoWindow, C_ucNeverStopForDebug,
"You must allocate Dynamics.");
Erm_fn_iMessageBox ("You must allocate Dynamics.","STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
#endif
#endif
return(p_stTree);
break;
}
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
MTH3D_M_vAddVector ( &stVector, DNM_M_pDynamicsGetStreamSpeed (pstDynamic), p_stVector );
DNM_M_vDynamicsSetStreamSpeed (pstDynamic,&stVector);
}
break;
default:
break;
}
return p_stTree;
}
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
/*****************************************************************************
* Function: Reset the last actor collided *
* Author : YLG *
* Date of last modification: 17/02/98 *
*****************************************************************************/
tdstNodeInterpret *fn_p_stResetLastCollisionActor(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
DNM_tdstReport *p_stDynamReport;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
switch ( eProcedureId )
{
case eProc_ResetLastCollisionActor :
if (M_GetMSHandle(hNewSuperObjPerso,StandardGame))
fn_vSuperObjectSetLastCollidedCharacter(hNewSuperObjPerso,NULL);
break;
case eProc_ClearCollisionReport :
if ((p_stDynamReport = fn_pstGetDNMReport(hNewSuperObjPerso)) != NULL )
{
DNM_M_ulReportSetSurfaceState ( p_stDynamReport , C_WOT_ulNoObstacle ) ;
}
/* XB 05/05/99 */
default:
break;
/* End XB */
}
return p_stTree;
}
/*****************************************************************************
* Function: Set mechanic 3 real *
* Author : Jacques Thénoz *
* Date of last modification: 20/02/98 *
*****************************************************************************/
tdstNodeInterpret *fn_p_SetMechanic3Real (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stValue;
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
MTH_tdxReal xValue1, xValue2, xValue3;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/* Get Dynamics structure*/
h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
if (!h_Dynam)
{
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIWarningScriptError , C_lErmNoDebugData,
C_ucErmOpenInfoWindow, C_ucNeverStopForDebug,
"You must allocate Dynamics.");
Erm_fn_iMessageBox ("You must allocate Dynamics.","STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
#endif
#endif
return(p_stTree);
}
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
if (!pstDynamic) return p_stTree;
M_EvalNextParameter(&stValue);
xValue1 = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValue2 = M_GetSetParam_xValue (&stValue);
M_EvalNextParameter(&stValue);
xValue3 = M_GetSetParam_xValue (&stValue);
switch (eProcedureId)
{
case eProc_MecSetScale :
DNM_M_vDynamicsSetScale ( pstDynamic, xValue1, xValue2, xValue3 );
DNM_M_vDynamicsSetChangeScale ( pstDynamic, TRUE );
break;
case eProc_MecSetSlideFactorXYZ :
DNM_M_vDynamicsSetSlideFactorX ( pstDynamic, xValue1 );
DNM_M_vDynamicsSetSlideFactorY ( pstDynamic, xValue2 );
DNM_M_vDynamicsSetSlideFactorZ ( pstDynamic, xValue3 );
break;
default:
break;
}
return p_stTree;
}
/*****************************************************************************
* Function: Set mechanic climb speed limit *
* Author : Jacques Thénoz *
* Date of last modification: 09/04/99 *
*****************************************************************************/
tdstNodeInterpret *fn_p_SetMechanicClimbSpeedLimit (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stValue;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
MTH_tdxReal xValue;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
M_EvalNextParameter(&stValue);
xValue = M_GetSetParam_xValue (&stValue);
MEC_fn_vSetClimbSpeedLimit (xValue);
return p_stTree;
}
/*****************************************************************************
* Function: Display Shadow *
* Author : YLG *
* Date of last modification: 23/02/98 *
*****************************************************************************/
tdstNodeInterpret *fn_p_stShadow (HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stValue;
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
long lValue;
unsigned long lCustomBits;
MS_tdxHandleToStandardGame hStdGame;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
switch (eProcedureId)
{
case eProc_DisplayShadow :
{
hStdGame = M_GetMSHandle(hNewSuperObjPerso,StandardGame);
lCustomBits = fn_ulStandardGameGetCustomBits(hStdGame);
M_EvalNextParameter(&stValue);
lValue = M_GetSetParam_lValue (&stValue);
#ifndef YANNTEMP
if (lValue)
{
/* activate shadow drawing*/
lCustomBits |= GAM_C_CustBitActorHasShadow;
}
else
{
/* disactivate shadow drawing*/
lCustomBits &= ~GAM_C_CustBitActorHasShadow;
}
#endif
fn_vStandardGameSetCustomBits(hStdGame,lCustomBits);
break;
}
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
#if !defined(U64) /*MT*/
case eProc_ChangeShadowHeight :
{
MTH_tdxReal xValue;
M_EvalNextParameter(&stValue);
xValue = M_GetSetParam_xValue (&stValue);
*fn_p_x3dDataGetSHWHeightFromSO(hNewSuperObjPerso)=xValue;
break;
}
case eProc_ChangeShadowVector :
{
MTH3D_tdstVector *p_stVector;
M_EvalNextParameter(&stValue);
p_stVector = &M_GetSetParam_stVertexValue(&stValue);
MTH3D_M_vCopyVector(fn_p_st3dDataGetSHWDeformationVectorFromSO(hNewSuperObjPerso),p_stVector);
break;
}
#endif /* !U64*/
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
default :
{
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
return p_stTree;
}
break;
}
return p_stTree;
}
/***********************************************************************
* Procedure: ZON_ForceActivationZDD *
* Use : ZON_ForceActivationZDD( ZDD ) *
* Procedure: ZON_ForceActivationZDM *
* Use : ZON_ForceActivationZDM( ZDM ) *
* Procedure: ZON_ForceActivationZDE *
* Use : ZON_ForceActivationZDE( ZDE ) *
* Procedure: ZON_ForceActivationZDR *
* Use : ZON_ForceActivationZDR( ZDR ) *
* *
* Procedure: ZON_ForceDesactivationZDD *
* Use : ZON_ForceDesactivationZDD( ZDD ) *
* Procedure: ZON_ForceDesactivationZDM *
* Use : ZON_ForceDesactivationZDM( ZDM ) *
* Procedure: ZON_ForceDesactivationZDE *
* Use : ZON_ForceDesactivationZDE( ZDE ) *
* Procedure: ZON_ForceDesactivationZDR *
* Use : ZON_ForceDesactivationZDR( ZDR ) *
* *
* Procedure: ZON_LibereActivationZDD *
* Use : ZON_LibereActivationZDD( ZDD ) *
* Procedure: ZON_LibereActivationZDM *
* Use : ZON_LibereActivationZDM( ZDM ) *
* Procedure: ZON_LibereActivationZDE *
* Use : ZON_LibereActivationZDE( ZDE ) *
* Procedure: ZON_LibereActivationZDR *
* Use : ZON_LibereActivationZDR( ZDR ) *
* *
* Author : Marc Trabucato *
* Date of last modification: 12/03/98 *
***********************************************************************/
tdstNodeInterpret *fn_p_stSetPrivilegeActivationZDx( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
HIE_tdxHandleToSuperObject hPerso;
long lZoneNumber;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
MS_tdxHandleToCollSet hCollSet;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hPerso);
/********************************************************************************/
hCollSet = M_GetMSHandle(hPerso,CollSet);
SAF_M_AssertWithMsg(hCollSet, "You need a CollSet ministructure to operate on zone activations!");
/* Get first parameter that is a Zone*/
M_EvalNextParameter( &stParam );
lZoneNumber = (long) M_GetSetParam_lZDMIdValue(&stParam);
lZoneNumber--;
switch(eProcedureId)
{
/* ForceActivation */
case eProc_ForceActivationZDD:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZdd, hCollSet, (short)lZoneNumber, edmPriviligedActivated );
break;
case eProc_ForceActivationZDM:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZdm, hCollSet, (short)lZoneNumber, edmPriviligedActivated );
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_ForceActivationZDR:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZdr, hCollSet, (short)lZoneNumber, edmPriviligedActivated );
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_ForceActivationZDE:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZde, hCollSet, (short)lZoneNumber, edmPriviligedActivated );
break;
/* ForceDesactivation */
case eProc_ForceDesactivationZDE:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZde, hCollSet, (short)lZoneNumber, edmPriviligedDisactivated );
break;
case eProc_ForceDesactivationZDD:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZdd, hCollSet, (short)lZoneNumber, edmPriviligedDisactivated );
break;
case eProc_ForceDesactivationZDM:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZdm, hCollSet, (short)lZoneNumber, edmPriviligedDisactivated );
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_ForceDesactivationZDR:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZdr, hCollSet, (short)lZoneNumber, edmPriviligedDisactivated );
break;
/* LibereActivation */
case eProc_LibereActivationZDD:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZdd, hCollSet, (short)lZoneNumber, edmPriviligedDefault );
break;
case eProc_LibereActivationZDR:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZdr, hCollSet, (short)lZoneNumber, edmPriviligedDefault );
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_LibereActivationZDM:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZdm, hCollSet, (short)lZoneNumber, edmPriviligedDefault );
break;
case eProc_LibereActivationZDE:
CS_fn_vSetPrivilegedActivationZone( C_ucTypeZde, hCollSet, (short)lZoneNumber, edmPriviligedDefault );
break;
/* default */
default:
/* Procedure does not exist !!*/
M_AIFatalError(E_uwAIFatalNotValidProcedure);
return(p_stTree);
break;
}
return p_stTree;
}
/************************************************************************
* Procedure: ACT_FixePasDeCollisionAvecMap *
* Use : ACT_FixePasDeCollisionAvecMap( BOOL ) *
* Procedure: ACT_FixePasDeCollisionAvecProjectiles *
* Use : ACT_FixePasDeCollisionAvecProjectiles( BOOL ) *
* Procedure: ACT_FixePasDeCollisionAvecActeursSecondaires *
* Use : ACT_FixePasDeCollisionAvecActeursSecondaires( BOOL ) *
* Procedure: ACT_FixePasDeCollisionAvecActeurPrincipal *
* Use : ACT_FixePasDeCollisionAvecActeurPrincipal( BOOL ) *
* Procedure: ACT_FixePasDeCollisionAvecAutresSecteurs *
* Use : ACT_FixePasDeCollisionAvecAutresSecteurs( BOOL ) *
* *
* *
* Author : Marc Trabucato *
* Date of last modification: 17/03/98 *
************************************************************************/
tdstNodeInterpret *fn_p_stSetCollSetCollisionFlag( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
HIE_tdxHandleToSuperObject hPerso;
ACP_tdxBool bValue;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
MS_tdxHandleToCollSet hCollSet;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hPerso);
/********************************************************************************/
hCollSet = M_GetMSHandle(hPerso,CollSet);
/* Get first parameter that is a Zone*/
M_EvalNextParameter( &stParam );
bValue = M_GetSetParam_lValue( &stParam );
switch(eProcedureId)
{
case eProc_SetNoCollisionWithMap:
fn_vCollSetSetCharacterNoCollisionWithMap( hCollSet, bValue );
break;
case eProc_SetNoCollisionWithSecondCharact:
fn_vCollSetSetCharacterNoCollisionWithSecondaryCharacter( hCollSet, bValue );
break;
case eProc_SetNoCollisionWithMainCharact:
fn_vCollSetSetCharacterNoCollisionWithMainCharacter( hCollSet, bValue );
break;
case eProc_SetNoCollisionWithOtherSectors:
fn_vCollSetSetCharacterNoCollisionWithOtherSectors( hCollSet, bValue );
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_SetNoCollisionWithProjectile:
fn_vCollSetSetCharacterNoCollisionWithProjectile( hCollSet, bValue );
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_SetNoCollisionZdeWithProjectile:
fn_vCollSetSetCharacterNoCollisionZdeWithProjectile( hCollSet, bValue );
break;
default:
/* Procedure does not exist !!*/
M_AIFatalError(E_uwAIFatalNotValidProcedure);
return(p_stTree);
break;
}
return p_stTree;
}
/************************************************************************
* Procedure: ACT_FixeFrequenceCalculCollisions *
* : ACT_FixeFrequenceCalculIA *
* : ACT_FixeFrequenceCalculLumieres *
* Use : ACT_FixeFrequenceCalculCollisions( INT ) *
* : ACT_FixeFrequenceCalculIA( INT ) *
* : ACT_FixeFrequenceCalculLumieres( INT ) *
* *
* *
* Author : Marc Trabucato *
* Date of last modification: 12/06/98 *
************************************************************************/
tdstNodeInterpret *fn_p_stSetComputationFrequency( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
HIE_tdxHandleToSuperObject hPerso;
unsigned char ucFrequency;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hPerso);
/********************************************************************************/
/* Get first parameter that is a Zone*/
M_EvalNextParameter( &stParam );
ucFrequency = M_GetSetParam_lValue( &stParam );
switch(eProcedureId)
{
case eProc_SetBrainComputeFrequency:
fn_v3dDataSetBrainComputationFrequency( M_GetMSHandle(hPerso,3dData), ucFrequency );
break;
case eProc_SetCollComputeFrequency:
fn_vCollSetSetCollComputeFrequency( M_GetMSHandle(hPerso,CollSet), ucFrequency );
break;
case eProc_SetLightComputeFrequency:
#if !defined(U64)
fn_v3dDataSetLightComputationFrequency( M_GetMSHandle(hPerso,3dData), ucFrequency );
#endif /*U64 */
break;
default:
/* Procedure does not exist !!*/
M_AIFatalError(E_uwAIFatalNotValidProcedure);
return(p_stTree);
break;
}
return p_stTree;
}
tdstNodeInterpret *fn_p_stActivationZDR( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
HIE_tdxHandleToSuperObject hPerso;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hPerso);
/********************************************************************************/
M_EvalNextParameter( &stParam );
if (M_GetSetParam_lValue( &stParam ))
HIE_fn_SO_vSetFlags( hPerso, HIE_fn_SO_ulGetFlags(hPerso) & (~HIE_C_Flag_ulNotPickable) );
else
HIE_fn_SO_vSetFlags( hPerso, HIE_fn_SO_ulGetFlags(hPerso) | HIE_C_Flag_ulNotPickable );
return p_stTree;
}
tdstNodeInterpret *fn_p_LinkControl( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
HIE_tdxHandleToSuperObject hPerso;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
ACP_tdxBool bValue;
struct DNM_stDynamics *pstDynamic;
MS_tdxHandleToDynam h_Dynam;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hPerso);
/********************************************************************************/
M_EvalNextParameter( &stParam );
bValue = M_GetSetParam_lValue( &stParam );
/* Get Dynamics structure*/
h_Dynam = M_GetMSHandle(hPerso,Dynam);
if (!h_Dynam)
{
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIWarningScriptError , C_lErmNoDebugData,
C_ucErmOpenInfoWindow, C_ucNeverStopForDebug,
"You must allocate Dynamics.");
Erm_fn_iMessageBox ("You must allocate Dynamics.","STOP",MB_OK|MB_ICONERROR);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
fn_vSetStopAIEngineFlag();
#endif
#endif
return(p_stTree);
}
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
if (!pstDynamic)
return p_stTree;
DNM_M_bDynamicsSetLockPlatform (pstDynamic,bValue);
return p_stTree;
}
/*=====================================================================================================================================
Name: PAD_LitJoyAnalogiqueMarioMode (PAD_ReadAnalogJoystickMarioMode in english)
Author: yann le tensorer
Created: september 9,1998
Last modified:
inputs:
real a = minimal joystick value to move (joystick values < a will be set to zero) 10 is usually a good value
real b = minimal angle for rotation (angles < b will be set to zero) 0.3 is usually a good value
real c = rotation speed (the higher it is, the higher the returned angle is) 0.0001 is a normal value.
real d = inertia for joystick (between 0 and 1, 0.8 is the normal value)
long f = movement plane (0 = no reading, 1 = xOy, 2 = xOz)
bool e = xRotationAsked (set to 1 if you want the rotation to be done)
bool g = compute strafe sector id
=====================================================================================================================================*/
#ifndef FINAL_VERSION
int g_XValue;
int g_YValue;
int g_XautoValue;
int g_YautoValue;
#endif /* FINAL_VERSION */
tdstNodeInterpret *fn_p_stReadAnalogJoystickMario( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam; /* parameters...*/
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1); /* used for ultra operator*/
HIE_tdxHandleToSuperObject hCamera; /* main camera (read from ultra parameter)*/
MTH_tdxReal xAnalogForce = MTH_C_ZERO; /* norm of joystick vector (with inertia)*/
MTH_tdxReal xTrueAnalogForce; /* norm of joystick vector (without inertia)*/
MTH_tdxReal xOldAnalogForce = MTH_C_ZERO; /* old norm of joystick vector */
MTH_tdxReal xAngleRotation = MTH_C_ZERO; /* angle to rotate to be aligned with the joyvector... (in radian during the whole proc)*/
MTH_tdxReal xCenterValue; /* minimum value accepted as a wanted movement (input1.a)*/
MTH_tdxReal xMinimumAngle; /* minimum angle to rotate (input1.b)*/
MTH_tdxReal xRotationSpeed; /* rotation speed (input1.c)*/
MTH_tdxReal xTmp; /* temporary variable for calculations*/
MTH_tdxReal xJoystickInertia; /* inertia for joystick (input2.d)*/
MTH_tdxReal xDt; /* idt/100*/
MTH3D_tdstVector stJoyVector; /* vector given by the joystick (in global coordinates of the world)*/
MTH3D_tdstVector stSightVector; /* sight of the perso*/
MTH3D_tdstVector *p_stTmpV0,*p_stTmpV1,*p_stTmpV2; /* temporary vector pointers*/
int iXValue = 0, iYValue = 0; /* x & y value of joystick*/
int iDt, iDeltaFrame; /* Time to execute the engine, , equivalent deltaFrame*/
/* to rotate around z axis.*/
int iRotationAsked, iMovementPlane, iComputeStrafeSector; /* Do we have to rotate around global z axis ?*/
#ifndef U64
ACP_tdxBool bWithKeyboard = FALSE;
MTH_tdxReal xKeyboardInertia;
MTH_tdxReal xKeyXValue = MTH_C_ZERO, xKeyYValue = MTH_C_ZERO; /* x & y value of joystick*/
static MTH_tdxReal s_xPrevKeyXValue = MTH_C_ZERO, s_xPrevKeyYValue = MTH_C_ZERO;
#endif
/* check that the output dsgvars have been properly specified*/
SAF_M_AssertWithMsg(
(g_stPadOutputDsgvars.p_wAxisValueX
&& g_stPadOutputDsgvars.p_wAxisValueY
&& g_stPadOutputDsgvars.p_stPadVector
&& g_stPadOutputDsgvars.p_xAnalogForce
&& g_stPadOutputDsgvars.p_xTrueAnalogForce
&& g_stPadOutputDsgvars.p_xRotationAngle
&& g_stPadOutputDsgvars.p_wDirectionSector),
"il faut appeler PAD_FixeVariablesDeLecture() avant de lire le pad!"
);
/*======================== READ INPUT PARAMETERS =======================*/
/* get the camera (for mario mode)*/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hCamera);
M_EvalNextParameter( &stParam );
xCenterValue = M_ReturnParam_xValue(&stParam);
M_EvalNextParameter( &stParam );
xMinimumAngle = MTH_M_xDegToRad(M_ReturnParam_xValue(&stParam)); /*convert degrees into radians*/
M_EvalNextParameter( &stParam );
xRotationSpeed = M_ReturnParam_xValue(&stParam);
M_EvalNextParameter( &stParam );
xJoystickInertia = M_ReturnParam_xValue(&stParam);
M_EvalNextParameter( &stParam );
iMovementPlane = M_ReturnParam_lValue(&stParam);
M_EvalNextParameter( &stParam );
iRotationAsked = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter( &stParam );
iComputeStrafeSector = M_GetSetParam_lValue(&stParam);
/* on verifie que les valeurs fournies sont correctes*/
SAF_M_AssertWithMsg(MTH_M_bGreaterEqual(xCenterValue, MTH_C_ZERO), "la zone centrale doit etre positive ou nulle");
SAF_M_AssertWithMsg((iMovementPlane >= 0) && (iMovementPlane <= 2), "le plan de deplacement doit etre entre 0, 1 ou 2");
SAF_M_AssertWithMsg(MTH_M_bGreaterEqual(xJoystickInertia, MTH_C_ZERO) && MTH_M_bLess(xJoystickInertia, MTH_C_ONE), "l'inertie du pad doit etre entre 0 et 1 exclus")
SAF_M_AssertWithMsg(MTH_M_bGreaterEqual(xMinimumAngle, MTH_C_ZERO), "l'angle de rotation doit etre positif ou nul");
if ( iMovementPlane ) /*read something*/
{
/* read the elapsed time since the last frame*/
iDt = g_stEngineStructure.stEngineTimer.ulUsefulDeltaTime;
iDeltaFrame = MTH_M_xRealToLong(
MTH_M_xAdd(
MTH_M_xDiv(
MTH_M_xLongToReal(iDt),
MTH_M_xMul(M_xGetFrameLength(g_stEngineStructure.stEngineTimer), MTH_M_xFloatToReal(1000.0f))
),
MTH_C_Inv2
)
);
/* gestion des touches sur PC */
#ifndef U64
if ( (long) g_xKeyUp && (long) (IPT_fn_bIsValidated(g_xKeyUp)) )
{
bWithKeyboard = TRUE;
xKeyYValue = MTH_M_xAdd(xKeyYValue, MTH_M_xFloatToReal(-100.0f));
}
if ( (long) g_xKeyDown && (long) (IPT_fn_bIsValidated(g_xKeyDown)) )
{
bWithKeyboard = TRUE;
xKeyYValue = MTH_M_xAdd(xKeyYValue, MTH_M_xFloatToReal(100.0f));
}
if ( (long) g_xKeyRight && (long) (IPT_fn_bIsValidated(g_xKeyRight)) )
{
bWithKeyboard = TRUE;
xKeyXValue = MTH_M_xAdd(xKeyXValue, MTH_M_xFloatToReal(100.0f));
}
if ( (long) g_xKeyLeft && (long) (IPT_fn_bIsValidated(g_xKeyLeft)) )
{
bWithKeyboard = TRUE;
xKeyXValue = MTH_M_xAdd(xKeyXValue, MTH_M_xFloatToReal(-100.0f));
}
/* read the pad only if the keyboard was not used, else ignore it! */
if ( bWithKeyboard )
{
#define D_SpeedUpIsSpeedDown
#ifdef D_SpeedUpIsSpeedDown
/* this version reduces keyboard inertia, but also alters max speed depending on the mode */
if ( (long) g_xKeySpeedUp && (long) (IPT_fn_bIsValidated(g_xKeySpeedUp)) )
{
xKeyboardInertia = MTH_M_xFloatToReal(0.95f);
xKeyXValue = MTH_M_xMul(xKeyXValue, MTH_M_xFloatToReal(0.5f));
xKeyYValue = MTH_M_xMul(xKeyYValue, MTH_M_xFloatToReal(0.5f));
}
else
xKeyboardInertia = MTH_M_xFloatToReal(0.60f);
#else
/* this version just reduces keyboard inertia, but does not alter max speed depending on the mode */
if ( (long) g_xKeySpeedUp && (long) (IPT_fn_bIsValidated(g_xKeySpeedUp)) )
xKeyboardInertia = MTH_M_xFloatToReal(0.02f);
else
xKeyboardInertia = MTH_M_xFloatToReal(0.98f);
#endif
/* we want the diagonals to be equivalent to the main axis in intensity: scale the powers! */
if ( xKeyXValue && xKeyYValue )
{
xKeyXValue = MTH_M_xMul(MTH_C_InvSqrt2, xKeyXValue);
xKeyYValue = MTH_M_xMul(MTH_C_InvSqrt2, xKeyYValue);
}
if ( g_bCancelKeyboardInertia )
{
/* if no inertia is required, keep the instant values from the pad, but reenable inertia for the next reading */
g_bCancelKeyboardInertia = FALSE;
}
else
{
/* smooth the keyboard readings over time to simulate a progressive direction and/or intensity change */
switch ( iDeltaFrame )
{
case 1:
xTmp = xKeyboardInertia;
break;
case 2:
xTmp = MTH_M_xMul(xKeyboardInertia, xKeyboardInertia);
break;
case 3:
xTmp = MTH_M_xMul(MTH_M_xMul(xKeyboardInertia, xKeyboardInertia), xKeyboardInertia);
break;
default:
xTmp = MTH_M_xMul(xKeyboardInertia, xKeyboardInertia);
xTmp = MTH_M_xMul(xTmp, xTmp);
break;
}
xKeyXValue = MTH_M_xAdd(MTH_M_xMul(MTH_M_xSub(s_xPrevKeyXValue, xKeyXValue), xTmp), xKeyXValue);
xKeyYValue = MTH_M_xAdd(MTH_M_xMul(MTH_M_xSub(s_xPrevKeyYValue, xKeyYValue), xTmp), xKeyYValue);
}
iXValue = MTH_M_xRealToLong(xKeyXValue);
iYValue = MTH_M_xRealToLong(xKeyYValue);
}
else
#endif /* !U64 */
{
/* read analog x & y value */
#ifdef USE_IPT_DX5
iXValue = g_xJoystickAxeX ? MTH_M_xRealToLong(IPT_fn_xGetAnalogicValue(g_xJoystickAxeX)) : 0;
iYValue = g_xJoystickAxeY ? MTH_M_xRealToLong(IPT_fn_xGetAnalogicValue(g_xJoystickAxeY)) : 0;
#else /* USE_IPT_WIN */
iXValue = g_xJoystickAxeX ? IPT_fn_lGetAnalogicValue(g_xJoystickAxeX) : 0;
iYValue = g_xJoystickAxeY ? IPT_fn_lGetAnalogicValue(g_xJoystickAxeY) : 0;
#endif /* USE_IPT_WIN */
#ifndef FINAL_VERSION
g_XValue = iXValue;
g_YValue = iYValue;
#endif /* FINAL_VERSION */
}
#ifndef U64
/* even if the keyboard was not used, remember the values for the next engine frame */
s_xPrevKeyXValue = xKeyXValue;
s_xPrevKeyYValue = xKeyYValue;
#endif /* !U64 */
/* if movement plane is xOz, rotation is irrelevant, thus considered as not asked for*/
if ( iMovementPlane == 2 )
{
xRotationSpeed = MTH_C_ZERO;
iRotationAsked = 0;
}
/*=========================== JOY CALIBRATION PART ================================*/
#ifndef U64
if ( !bWithKeyboard )
#endif /* !U64 */
{
MTH_tdxReal xSquare;
/* update max values */
if ( (short) iYValue > g_cJoystickYmax )
g_cJoystickYmax = (signed char) iYValue;
else if ( (short) iYValue < g_cJoystickYmin )
g_cJoystickYmin = (signed char) iYValue;
if ( (short) iXValue > g_cJoystickXmax)
g_cJoystickXmax = (signed char) iXValue;
else if ( (short) iXValue < g_cJoystickXmin )
g_cJoystickXmin = (signed char) iXValue;
/* center values */
#ifndef U64
iXValue -= g_cJoystickXcenter;
iYValue -= g_cJoystickYcenter;
#endif /* !U64 */
/* apply calibration */
if ( iXValue > 0 )
iXValue = (iXValue * 100)
/ (
g_cJoystickXmax
#ifndef U64
- g_cJoystickXcenter
#endif /* !U64 */
);
else if (iXValue < 0)
iXValue = (iXValue * -100)
/ (
g_cJoystickXmin
#ifndef U64
- g_cJoystickXcenter
#endif /* !U64 */
);
if (iYValue > 0)
iYValue = (iYValue * 100)
/ (
g_cJoystickYmax
#ifndef U64
- g_cJoystickYcenter
#endif /* !U64 */
);
else if (iYValue < 0)
iYValue = (iYValue * -100)
/ (
g_cJoystickYmin
#ifndef U64
- g_cJoystickYcenter
#endif /* !U64 */
);
/*************** FabPerez Cheat Code *******/
#if defined (WIN32) && defined (_DEBUG)
if(g_CheatCodeActivate)
{
if(g_ulCurrentCheatCode == 0) g_CheatCodeActivate = FALSE;
else if(g_ulCurrentCheatCode == CHEAT_CODE_INVERT_PAD || g_ulCurrentCheatCode == CHEAT_CODE_RANDOM_PAD)
{
g_iXValueCheat = iXValue;
g_iYValueCheat = iYValue;
p_fn = a_p_fnCheatCodeFonction[g_ulCurrentCheatCode];
(*p_fn)(a_lCheatCodeVariable[g_ulCurrentCheatCode]);
//if(g_h_ActualEntryInput->xAnalogicValue != 0) return IPT_C_TRUE;
//else return IPT_C_FALSE;
if(g_iXValueCheat != iXValue) iXValue = g_iXValueCheat;
if(g_iYValueCheat != iYValue) iYValue = g_iYValueCheat;
}
}
#endif //(WIN32) & (DEBUG)
/************ Fin FabPerez Cheat Code **********/
/*
* force the reading inside a circle. Within a given interval, a value is considered maximal
* ie when the reading is 90% of the max, we simulate a max !
*/
xSquare = MTH_M_xLongToReal(iXValue * iXValue + iYValue * iYValue);
if ( MTH_M_bGreater(xSquare, MTH_M_xFloatToReal(8100.0f)) )
{
xSquare = MTH_M_xSqrt(xSquare);
iXValue = MTH_M_xDiv(MTH_M_xLongToReal(iXValue * 100), xSquare);
iYValue = MTH_M_xDiv(MTH_M_xLongToReal(iYValue * 100), xSquare);
}
}
#ifndef FINAL_VERSION
g_XautoValue = iXValue;
g_YautoValue = iYValue;
#endif /* FINAL_VERSION */
/*======================== CALCULATE MARIO MODE PARAMETERS =======================*/
/* put the values into a 3d vector (in the camera's xOy plane)*/
stJoyVector.xX = MTH_M_xLongToReal(-iXValue);
if ( iMovementPlane == 2 ) /* plane is xOz*/
{
stJoyVector.xY = MTH_C_ZERO;
stJoyVector.xZ = MTH_M_xLongToReal(-iYValue);
}
else /* ( iMovementPlane == 1 ) plane is xOy*/
{
stJoyVector.xY = MTH_M_xLongToReal(iYValue);
stJoyVector.xZ = MTH_C_ZERO;
}
xTrueAnalogForce = MTH3D_M_xNormVector(&stJoyVector);
/*============================= JOY INERTIA ======================================*/
/*read old AnalogForce Value (from designer variable)*/
xOldAnalogForce = *g_stPadOutputDsgvars.p_xAnalogForce;
/* the true analog force is set to zero if below the center value*/
if ( MTH_M_bLessEqual(xTrueAnalogForce, xCenterValue) )
{
xTrueAnalogForce = MTH_C_ZERO;
iRotationAsked = 0;
stJoyVector.xX = stJoyVector.xY = stJoyVector.xZ = MTH_C_ZERO;
}
/*
/ * it is set to 100 if above 90 to avoid differences in max speed depending on the direction * /
else
#ifndef U64
if ( !bWithKeyboard )
#endif / * !U64 * /
{
/ *s_stLastJoyVector = stJoyVector;* /
if ( MTH_M_bGreaterEqual(xTrueAnalogForce, MTH_M_xFloatToReal(90.0f)) )
xTrueAnalogForce = MTH_M_xFloatToReal(100.0f);
}
*/
/* if inertie is nul, do not loose time for nothing... */
if ( MTH_M_bGreaterZero(xJoystickInertia) )
{
/* give inertia to the analogvalue */
switch ( iDeltaFrame )
{
case 1:
xTmp = xJoystickInertia;
break;
case 2:
xTmp = MTH_M_xMul(xJoystickInertia, xJoystickInertia);
break;
case 3:
xTmp = MTH_M_xMul(MTH_M_xMul(xJoystickInertia, xJoystickInertia), xJoystickInertia);
break;
default:
xTmp = MTH_M_xMul(xJoystickInertia, xJoystickInertia);
xTmp = MTH_M_xMul(xTmp, xTmp);
break;
}
/* a= i*a' + (1-i)*a = i*a' + a - i*a = i * (a' - a) + a -> 1 multiply, 1 add, 1 sub */
xAnalogForce = MTH_M_xAdd(MTH_M_xMul(MTH_M_xSub(xOldAnalogForce, xTrueAnalogForce), xTmp), xTrueAnalogForce);
/* if the true analog force is too small compared to the smoothed analog force, it means we are*/
/* observing a strong deceleration, hence rotation angle might not be relevant!*/
if ( MTH_M_bGreater(MTH_M_xSub(xAnalogForce, xTrueAnalogForce), xCenterValue) )
{
iRotationAsked = 0;
stJoyVector.xX = stJoyVector.xY = stJoyVector.xZ = MTH_C_ZERO;
}
}
else
/*inertia is nul, so the analog_force is exactly the true_analog_force.*/
xAnalogForce = xTrueAnalogForce;
/* if the pad interaction is significant enough*/
if ( MTH_M_bGreaterEqual(xAnalogForce, xCenterValue) )
{
/* we calculate the norm of the joy vector (iAnalogForce)*/
/*
if ( MTH_M_bGreater(xAnalogForce,MTH_M_xFloatToReal(100.0f)) )
{
xAnalogForce = MTH_M_xFloatToReal(100.0f); / * because a vector (100,100) has a norm of 141* /
}
*/
if ( iMovementPlane == 2 ) /* plane is xOz -> rotation is irrelevant*/
{
MTH3D_tdstVector stV1 , stV2 ;
MTH_tdxReal xDotX , xDotZ ;
MTH3D_tdstVector * p_stCamV0 , * p_stCamV1 , * p_stCamV2 ; /* temporary vector pointers*/
/* =========== we give the joystick vector a norm with inertia */
if ( ! MTH3D_M_bIsNullVector ( & stJoyVector ) )
{
MTH3D_M_vNormalizeVector ( & stJoyVector , & stJoyVector ) ;
MTH3D_M_vMulScalarVector ( & stJoyVector , xAnalogForce, & stJoyVector ) ;
}
/* compute the global joyvector in the xOz vertical plane of the piloted actor */
POS_fn_vGetRotationVector ( HIE_fn_hGetSuperObjectGlobalMatrix ( p_SuperObjPerso ) , & p_stTmpV0 , & p_stTmpV1 , & p_stTmpV2 ) ;
POS_fn_vGetRotationVector ( HIE_fn_hGetSuperObjectGlobalMatrix ( hCamera ) , & p_stCamV0 , & p_stCamV1 , & p_stCamV2 ) ;
xDotX = MTH3D_M_xDotProductVector ( p_stTmpV0 , p_stCamV0 ) ;
xDotX = MTH_M_xMul (
MTH_M_xSign ( xDotX ) ,
MTH_M_xMin (
MTH_C_ONE ,
MTH_M_xMul (
MTH_M_xFloatToReal ( 1.5f ) ,
MTH_M_xDoubleToReal ( pow (
MTH_M_xRealToDouble ( MTH_M_xAbs ( xDotX ) ) ,
0.3
) )
)
)
) ;
xDotZ = MTH3D_M_xDotProductVector ( p_stTmpV2 , p_stCamV2 ) ;
xDotZ = MTH_M_xMul (
MTH_M_xSign ( xDotZ ) ,
MTH_M_xMin (
MTH_C_ONE ,
MTH_M_xMul (
MTH_M_xFloatToReal ( 1.5f ) ,
MTH_M_xDoubleToReal ( pow (
MTH_M_xRealToDouble ( MTH_M_xAbs ( xDotZ ) ) ,
0.3
) )
)
)
) ;
MTH3D_M_vMulScalarVector ( & stV1 , MTH_M_xMul ( xDotX , stJoyVector . xX ) , p_stTmpV0 ) ;
MTH3D_M_vMulScalarVector ( & stV2 , MTH_M_xMul ( xDotZ , stJoyVector . xZ ) , p_stTmpV2 ) ;
MTH3D_M_vAddVector ( & stJoyVector , & stV1 , & stV2 ) ;
/*the rotation is not usable*/
xAngleRotation = MTH_C_ZERO ;
}
else /* 1( iMovementPlane == 1 ) plane is xOy, rotation has a sense*/
{
MTH3D_tdstVector stI, stJ, stK = { MTH_C_ZERO, MTH_C_ZERO, MTH_C_ONE };
MTH3D_tdstMatrix stSystem;
ACP_tdxBool bVectorToTargetIsNull ;
/* get the positions of the camera and the caller*/
POS_fn_vGetTranslationVector ( HIE_fn_hGetSuperObjectGlobalMatrix ( hCamera ) , & stI ) ;
POS_fn_vGetTranslationVector ( HIE_fn_hGetSuperObjectGlobalMatrix ( p_SuperObjPerso ) , & stJ ) ;
/* build the horizontal vector from the caller to the camera*/
MTH3D_M_vSubVector ( & stJ , & stI , & stJ ) ;
if ( MTH3D_M_bIsNullVector ( & stJ ) )
{
bVectorToTargetIsNull = TRUE ;
}
else
{
bVectorToTargetIsNull = FALSE ;
MTH3D_M_vNormalizeVector ( & stJ , & stJ ) ;
}
/*
* if the vector is too vertical, or RM goes aways from the camera
* use the standard method instead
*/
if
(
bVectorToTargetIsNull
|| ( iYValue < 0 )
|| MTH_M_bGreater ( MTH_M_xAbs ( stJ . xZ ) , MTH_M_xDoubleToReal ( 0.8 ) )
)
{
/* get the horizontalized camera's sight as reference direction */
POS_fn_vGetRotationVector(HIE_fn_hGetSuperObjectGlobalMatrix(hCamera),&p_stTmpV0,&p_stTmpV1,&p_stTmpV2);
stJ = * p_stTmpV1 ;
stJ.xZ = MTH_C_ZERO ;
if ( MTH3D_M_bIsNullVector(&stJ) )
{
stJ = * p_stTmpV2 ;
stJ.xZ = MTH_C_ZERO ;
}
/* normalize */
MTH3D_M_vNormalizeVector(&stJ, &stJ);
/* build I third vector from J (horizontal) and K (vertical) */
MTH3D_M_vCrossProductVector(&stI, &stJ, &stK);
/* build a matrix with those base vectors */
MTH3D_M_vSetVectorsInMatrix(&stSystem, &stI, &stJ, &stK);
/* and use it to convert the pad vector from this coordinates system into global coordinates */
/* since the XY plane is horizontal and the pad vector is in this plane, it is already horizontal */
/* in global coordinates as well */
MTH3D_M_vMulMatrixVector(&stJoyVector, &stSystem, &stJoyVector);
}
else
{
stJ.xZ = MTH_C_ZERO;
/* if the camera is right above the caller, use a vector from the camera instead*/
if ( MTH3D_M_bIsNullVector(&stJ) )
{
/* since the camera looks up or down, use its Z vector as the base horizontal direction*/
POS_fn_vGetRotationVector(HIE_fn_hGetSuperObjectGlobalMatrix(hCamera),&p_stTmpV0,&p_stTmpV1,&p_stTmpV2);
stJ = *p_stTmpV2;
/* just make sure it is horizontal (even if this should not be necessaray)*/
stJ.xZ = MTH_C_ZERO;
if ( MTH3D_M_bIsNullVector(&stJ) ) /* should never occur, but we never know...*/
{
goto fin;
}
}
/* normalize*/
MTH3D_M_vNormalizeVector(&stJ, &stJ);
/* build I third vector from J (horizontal) and K (vertical)*/
MTH3D_M_vCrossProductVector(&stI, &stJ, &stK);
/* build a matrix with those base vectors */
MTH3D_M_vSetVectorsInMatrix(&stSystem, &stI, &stJ, &stK);
/* and use it to convert the pad vector from this coordinates system into global coordinates */
/* since the XY plane is horizontal and the pad vector is in this plane, it is already horizontal */
/* in global coordinates as well*/
MTH3D_M_vMulMatrixVector(&stJoyVector, &stSystem, &stJoyVector);
}
if ( MTH3D_M_bIsNullVector(&stJoyVector) ) /* the camera looks right down -> we cant get an accurate reading*/
{
/* return p_stTree;*/
goto fin;
}
MTH3D_M_vNormalizeVector(&stJoyVector,&stJoyVector); /* and normalize the Joy vector*/
/*=========== we get the sight vector of the interested character (usually the main character...)*/
POS_fn_vGetRotationVector(HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso),&p_stTmpV0,&p_stTmpV1,&p_stTmpV2);
MTH3D_M_vNegVector(&stSightVector,p_stTmpV1); /* objects watch in -Y, so we negate the vector*/
stSightVector.xZ = MTH_C_ZERO; /* we project on the z=0 plane */
if ( MTH3D_M_bIsNullVector(&stSightVector) ) /* the actor looks right down -> we cant get an accurate reading*/
{
/* return p_stTree;*/
goto fin;
}
MTH3D_M_vNormalizeVector(&stSightVector,&stSightVector); /* and normalize the sight vector*/
/*=========== we calculate the angle (in radians) between the SightVector and the JoyVector (the two vectors are normalized)*/
xTmp = MTH3D_M_xDotProductVector(&stSightVector,&stJoyVector);
if ( MTH_M_bGreater(xTmp, MTH_C_ONE) )
xTmp = MTH_C_ONE; /* sometimes, the inprecision makes this happen...*/
else if ( MTH_M_bLess(xTmp, MTH_C_MinusONE) )
xTmp = MTH_C_MinusONE;
xAngleRotation = MTH_M_xACos(xTmp);
xTmp = MTH_M_xSub(MTH_M_xMul(stSightVector.xX,stJoyVector.xY), MTH_M_xMul(stSightVector.xY,stJoyVector.xX)) ; /* we calculate the determinant (in the z=0 plane)*/
if ( MTH_M_bLessZero(xTmp) )
xAngleRotation = MTH_M_xNeg(xAngleRotation); /* if determinant is negative, the angle is negative*/
/* =========== we give back the joystick vector the original norm with inertia */
MTH3D_M_vMulScalarVector(&stJoyVector, xAnalogForce, &stJoyVector );
/*============== Calculate Angle, depending on Rotation Speed =====================*/
if
(
iRotationAsked /* rotate ONLY if explicitly asked*/
&& MTH_M_bDifferentZero(xRotationSpeed) /* and of course if the rotation speed allows it*/
)
{
MTH_tdxReal xDynamicRotation = xAngleRotation;
xDt = MTH_M_xMul(MTH_M_xLongToReal(iDt), MTH_M_xFloatToReal(0.0001f));
xTmp = xDynamicRotation;
/* change angle depending on given rotation speed...*/
xDynamicRotation = MTH_M_xMul4(xDynamicRotation,xAnalogForce,xRotationSpeed,xDt);
if ( MTH_M_bGreater(MTH_M_xAbs(xDynamicRotation),MTH_M_xAbs(xTmp)) )
xDynamicRotation = xTmp;
/*===================== set to 0 the angle if smaller than given parameter =========*/
if ( MTH_M_bLessEqual(MTH_M_xAbs(xDynamicRotation), xMinimumAngle) )
{
xDynamicRotation = MTH_C_ZERO;
}
else
{
/* xMinimumAngle is guaranteed to be >= 0*/
/* -> xAngleRotation cannot be <= 0 here!*/
if MTH_M_bDifferentZero(xTrueAnalogForce)
{
if ( iRotationAsked == 1 )
{
MS_tdxHandleToDynam hDynam = M_GetMSHandle(p_SuperObjPerso,Dynam);
/* find the meca current matrix.*/
POS_tdxHandleToPosition hGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso); /*DNM_M_p_stDynamicsGetCurrentMatrix (fn_p_stDynamGetDynamics(hDynam));*/
if ( hGlobalMatrix )
{
MTH3D_tdstMatrix stRotMatrix; /* rotation matrix*/
MTH_tdxReal xCos = MTH_M_xCos(xDynamicRotation);
MTH_tdxReal xSin = MTH_M_xSin(xDynamicRotation);
/*calculate rotation matrix*/
MTH3D_M_vSetVectorElements(&stRotMatrix.stCol_0,xCos, xSin, MTH_C_ZERO );
MTH3D_M_vSetVectorElements(&stRotMatrix.stCol_1,MTH_M_xNeg(xSin), xCos, MTH_C_ZERO );
MTH3D_M_vSetBaseKVector (&stRotMatrix.stCol_2);
/*rotate*/
MTH3D_M_vMulMatrixMatrix(&stRotMatrix,&stRotMatrix,&hGlobalMatrix->stRotationMatrix);
/*rotate the global matrix (-> update the global position)*/
POS_fn_vSetRotationMatrix ( hGlobalMatrix, &stRotMatrix.stCol_0, &stRotMatrix.stCol_1, &stRotMatrix.stCol_2 );
/*update the relative matrix (in case we are on a platform)*/
HIE_fn_vComputeNewRelativeMatrix(p_SuperObjPerso);
if ( hDynam )
{
/*the the meca the new rotation matrix*/
MEC_vImposeRotationMatrix(
fn_p_stDynamGetDynamics(hDynam),
hGlobalMatrix
);
}
}
}
}
}
}
/* we are finished with the rotation, we can convert the angle in degrees for output*/
xAngleRotation = MTH_M_xRadToDeg(xAngleRotation);
}
/* the strafe sector is defined as follows:*/
/* this sector is derived from the pad when the movement plane is vertical, else it is derived from the*/
/* angle between the global pad vector and the piloted actors sighting vector*/
/* */
/* x = -y x = y*/
/* \ 1 /*/
/* \ /*/
/* 4 X 2*/
/* / \*/
/* / 3 \*/
/**/
if ( iComputeStrafeSector )
{
if ( iMovementPlane == 2 ) /*plane is xOz: get the sector from the pad values*/
{
if ( iXValue > iYValue ) /* 1 or 2*/
{
if ( iXValue > -iYValue ) /* 2*/
iComputeStrafeSector = 2;
else
iComputeStrafeSector = 1;
}
else /* 3 or 4*/
{
if ( iXValue > -iYValue ) /* 3*/
iComputeStrafeSector = 3;
else
iComputeStrafeSector = 4;
}
}
else /* plane is xOy: get the sectors from the vector angles*/
{
MTH_tdxReal xAbsAngle = MTH_M_xAbs(xAngleRotation);
if ( MTH_M_bLessEqual(xAbsAngle, MTH_M_xFloatToReal(45.0f)) ) /* 1*/
{
iComputeStrafeSector = 1;
}
else if ( MTH_M_bGreaterEqual(xAbsAngle, MTH_M_xFloatToReal(135.0f)) ) /* 3*/
{
iComputeStrafeSector = 3;
}
else if ( MTH_M_bGreaterZero(xAngleRotation) ) /* 4*/
{
iComputeStrafeSector = 4;
}
else
{
iComputeStrafeSector = 2;
}
}
}
}
else /* analog Force is too small we don't calculate anything*/
{
iXValue = 0;
iYValue = 0;
stJoyVector.xX = stJoyVector.xY = stJoyVector.xZ = MTH_C_ZERO;
/*s_stLastJoyVector = stJoyVector;*/
/*xAnalogForce = MTH_C_ZERO;*/
/*xTrueAnalogForce = MTH_C_ZERO;*/
xAngleRotation = MTH_C_ZERO;
iComputeStrafeSector = 0;
}
}
else /* ( iMovementPlane == 0 ) no reading clear all values */
{
iXValue = 0;
iYValue = 0;
stJoyVector.xX = stJoyVector.xY = stJoyVector.xZ = MTH_C_ZERO;
/*s_stLastJoyVector = stJoyVector;*/
xAnalogForce = MTH_C_ZERO;
xTrueAnalogForce = MTH_C_ZERO;
xAngleRotation = MTH_C_ZERO;
iComputeStrafeSector = 0;
}
fin:
/* RETURN THE VALUES (iXValue,iYValue,stJoyVector,xAnalogForce,xAngleRotation)*/
/*=========================== RETURN OUTPUT PARAMETERS ===========================*/
/* Return iXValue*/
*g_stPadOutputDsgvars.p_wAxisValueX = iXValue;
/* Return iYValue*/
*g_stPadOutputDsgvars.p_wAxisValueY = iYValue;
/* Return stJoyVector*/
*g_stPadOutputDsgvars.p_stPadVector = stJoyVector;
/*Return xAnalogForce*/
*g_stPadOutputDsgvars.p_xAnalogForce = xAnalogForce;
/*Return xtrueAnalogForce*/
*g_stPadOutputDsgvars.p_xTrueAnalogForce = xTrueAnalogForce;
/*Return xAngleRotation converted in degrees*/
*g_stPadOutputDsgvars.p_xRotationAngle = xAngleRotation;
/*Return the direction sector if required*/
*g_stPadOutputDsgvars.p_wDirectionSector = iComputeStrafeSector;
/*==================================================================================*/
return p_stTree;
}
/*=====================================================================================================================================
Name: PAD_JoyAnalogiqueFixeAxes (PAD_InitAnalogJoystickAxes in english)
Author: yann le tensorer
Created: september 11,1998
Last modified:
inputs: parameter 1 = button x_axe
parameter 2 = button y_axe
Outputs: none
=====================================================================================================================================*/
tdstNodeInterpret *fn_p_stSetAnalogJoystickAxes( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1); /* used for ultra operator*/
tdstGetSetParam stParam; /* for input parameters*/
switch ( eProcedureId )
{
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
#ifndef U64
case eProc_CancelKeyboardInertia:
g_bCancelKeyboardInertia = TRUE;
break;
#endif /* !U64 */
case eProc_GetPadCalibration:
{
AI_tdstMind * p_stMind; /* Mind of perso (used to return paramaters to dsgVars)*/
unsigned char ucVarId;
unsigned short uwCenter;
unsigned long ulBounds;
M_vEvalNextVarId(p_stMind, ucVarId);
SAF_M_AssertWithMsg(M_GetDsgVarType(p_stMind, ucVarId) == eDsgVarType_0To65535, "l'argument n°1 n'est pas du bon type (entier non signé sur 2 octets)");
uwCenter =
#ifdef U64
0;
#else
g_cJoystickXcenter + (g_cJoystickYcenter << 8);
#endif /* !U64 */
M_Full_GetSetParam_Integer(&stParam, uwCenter);
ucVarId = fn_ucSetDsgVar(ucVarId, 0, p_stMind, &stParam);
M_vEvalNextVarId(p_stMind, ucVarId);
SAF_M_AssertWithMsg(M_GetDsgVarType(p_stMind, ucVarId) == eDsgVarType_PositiveInteger, "l'argument n°2 n'est pas du bon type (entier positif)");
ulBounds = g_cJoystickXmin + (g_cJoystickXmax << 8) + (g_cJoystickYmin << 16) + (g_cJoystickYmax << 24);
M_Full_GetSetParam_Integer(&stParam, ulBounds);
ucVarId = fn_ucSetDsgVar(ucVarId, 0, p_stMind, &stParam);
}
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
case eProc_SetPadCalibration:
{
#ifndef U64
unsigned short uwCenter;
#endif /* !U64 */
unsigned long ulBounds;
/* center values */
M_EvalNextParameter(&stParam);
#ifndef U64
uwCenter = M_GetSetParam_uwValue(&stParam);
g_cJoystickXcenter = uwCenter & 0xFF;
g_cJoystickYcenter = (uwCenter >> 8) & 0xFF;
#endif /* !U64 */
/* bounds values */
M_EvalNextParameter( &stParam );
ulBounds = M_GetSetParam_ulValue(&stParam);
g_cJoystickXmin = ulBounds & 0xFF;
if ( g_cJoystickXmin == 0 )
g_cJoystickXmin = C_Pad_DefaultXMinCalibration;
g_cJoystickXmax = (ulBounds >> 8) & 0xFF;
if ( g_cJoystickXmax == 0 )
g_cJoystickXmax = C_Pad_DefaultXMaxCalibration;
g_cJoystickYmin = (ulBounds >> 16) & 0xFF;
if ( g_cJoystickYmin == 0 )
g_cJoystickYmin = C_Pad_DefaultYMinCalibration;
g_cJoystickYmax = (ulBounds >> 24) & 0xFF;
if ( g_cJoystickYmax == 0 )
g_cJoystickYmax = C_Pad_DefaultYMaxCalibration;
SAF_M_AssertWithMsg(
((g_cJoystickXmax - g_cJoystickXmin) > 5) && ((g_cJoystickYmax - g_cJoystickYmin) > 5),
"les limites minimales ne peuvent être supérieures aux limites maximales!"
);
#ifndef U64
/* just to be sure that the center position is inside the limits */
if ( g_cJoystickXcenter <= g_cJoystickXmin )
g_cJoystickXcenter = g_cJoystickXmin + 1;
if ( g_cJoystickXcenter >= g_cJoystickXmax )
g_cJoystickXcenter = g_cJoystickXmax - 1;
if ( g_cJoystickYcenter <= g_cJoystickYmin )
g_cJoystickYcenter = g_cJoystickYmin + 1;
if ( g_cJoystickYcenter >= g_cJoystickYmax )
g_cJoystickYcenter = g_cJoystickYmax - 1;
#endif /* !U64 */
}
break;
case eProc_SetAnalogJoystickAxes:
/* read analog x axe button*/
M_EvalNextParameter( &stParam );
g_xJoystickAxeX =(IPT_tdxHandleToEntryElement) M_GetSetParam_lValue(&stParam );
/* read analog y axe button*/
M_EvalNextParameter( &stParam );
g_xJoystickAxeY= (IPT_tdxHandleToEntryElement) M_GetSetParam_lValue(&stParam );
break;
case eProc_SetPadReadingDsgvars: /* get destination dsgvar indexes*/
{
AI_tdstMind * p_stMind; /* Mind of perso (used to return paramaters to dsgVars)*/
unsigned char ucVarId;
/* pad global vector (vector)*/
M_vEvalNextVarId(p_stMind, ucVarId);
SAF_M_AssertWithMsg((M_GetDsgVarType(p_stMind, ucVarId) == eDsgVarType_Vector), "l'argument n°1 n'est pas du type correct");
g_stPadOutputDsgvars.p_stPadVector = (MTH3D_tdstVector *) M_GetDsgVarAddr(p_stMind,ucVarId);
/* x-value (short)*/
M_vEvalNextVarId(p_stMind, ucVarId);
SAF_M_AssertWithMsg((M_GetDsgVarType(p_stMind, ucVarId) == eDsgVarType__32768To32767), "l'argument n°2 n'est pas du type correct");
g_stPadOutputDsgvars.p_wAxisValueX = (short *) M_GetDsgVarAddr(p_stMind,ucVarId);
/* y-value (short)*/
M_vEvalNextVarId(p_stMind, ucVarId);
SAF_M_AssertWithMsg((M_GetDsgVarType(p_stMind, ucVarId) == eDsgVarType__32768To32767), "l'argument n°3 n'est pas du type correct");
g_stPadOutputDsgvars.p_wAxisValueY = (short *) M_GetDsgVarAddr(p_stMind,ucVarId);
/* analog force (real)*/
M_vEvalNextVarId(p_stMind, ucVarId);
SAF_M_AssertWithMsg((M_GetDsgVarType(p_stMind, ucVarId) == eDsgVarType_Float), "l'argument n°4 n'est pas du type correct");
g_stPadOutputDsgvars.p_xAnalogForce = (MTH_tdxReal *) M_GetDsgVarAddr(p_stMind,ucVarId);
/* true analog force (real)*/
M_vEvalNextVarId(p_stMind, ucVarId);
SAF_M_AssertWithMsg((M_GetDsgVarType(p_stMind, ucVarId) == eDsgVarType_Float), "l'argument n°5 n'est pas du type correct");
g_stPadOutputDsgvars.p_xTrueAnalogForce = (MTH_tdxReal *) M_GetDsgVarAddr(p_stMind,ucVarId);
/* rotation angle (real)*/
M_vEvalNextVarId(p_stMind, ucVarId);
SAF_M_AssertWithMsg((M_GetDsgVarType(p_stMind, ucVarId) == eDsgVarType_Float), "l'argument n°6 n'est pas du type correct");
g_stPadOutputDsgvars.p_xRotationAngle = (MTH_tdxReal *) M_GetDsgVarAddr(p_stMind,ucVarId);
/* direction sector (short)*/
M_vEvalNextVarId(p_stMind, ucVarId);
SAF_M_AssertWithMsg((M_GetDsgVarType(p_stMind, ucVarId) == eDsgVarType__32768To32767), "l'argument n°7 n'est pas du type correct");
g_stPadOutputDsgvars.p_wDirectionSector = (short *) M_GetDsgVarAddr(p_stMind,ucVarId);
break;
}
/* Oliv' - Portage v14 - To reduce number of warnings*/
default:
break;
/* EndOfOliv'*/
}
return p_stTree;
}
//=====================================================================================================================================
//HP 110299
// reinit for the demo mode
#ifdef U64
void fn_vReinitCalibrationValues()
{
g_cJoystickXmin = C_Pad_DefaultXMinCalibration;
g_cJoystickXmax = C_Pad_DefaultXMaxCalibration;
g_cJoystickYmin = C_Pad_DefaultYMinCalibration;
g_cJoystickYmax = C_Pad_DefaultYMaxCalibration;
}
#endif
#ifndef U64
/*=====================================================================================================================================
Name: PAD_InitKeyboardDirections in english and french
Author: yann le tensorer
Created: september 29,1998
Last modified:
inputs: parameter 1 = button up
parameter 2 = button down
parameter 3 = button left
parameter 4 = button right
parameter 5 = key speedup
Outputs: none
Comments: for PC version only.
=====================================================================================================================================*/
tdstNodeInterpret *fn_p_stInitKeyBoardDirections( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
/*enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1); // used for ultra operator*/
tdstGetSetParam stParam; /* for input parameters*/
/* read keyboard up key*/
M_EvalNextParameter( &stParam );
g_xKeyUp =(IPT_tdxHandleToEntryElement) M_GetSetParam_lValue(&stParam );
/* read keyboard down key*/
M_EvalNextParameter( &stParam );
g_xKeyDown= (IPT_tdxHandleToEntryElement) M_GetSetParam_lValue(&stParam );
/* read keyboard left key*/
M_EvalNextParameter( &stParam );
g_xKeyLeft= (IPT_tdxHandleToEntryElement) M_GetSetParam_lValue(&stParam );
/* read keyboard right key*/
M_EvalNextParameter( &stParam );
g_xKeyRight= (IPT_tdxHandleToEntryElement) M_GetSetParam_lValue(&stParam );
/* read keyboard speedup key*/
M_EvalNextParameter( &stParam );
g_xKeySpeedUp= (IPT_tdxHandleToEntryElement) M_GetSetParam_lValue(&stParam );
return p_stTree;
}
/*=====================================================================================================================================
Name: PAD_SetCenterPosition in english and french
Author: yann le tensorer
Created: November 12,1998
Last modified:
inputs: none
Outputs: none
Comments: for PC version only.
=====================================================================================================================================*/
tdstNodeInterpret *fn_p_stSetCenterPosition( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
int iXValue,iYValue;
/* read analog x & y value*/
#ifdef USE_IPT_DX5
iXValue = g_xJoystickAxeX ? MTH_M_xRealToLong(IPT_fn_xGetAnalogicValue(g_xJoystickAxeX)) : 0;
iYValue = g_xJoystickAxeY ? MTH_M_xRealToLong(IPT_fn_xGetAnalogicValue(g_xJoystickAxeY)) : 0;
#else /* USE_IPT_WIN */
iXValue = g_xJoystickAxeX ? IPT_fn_lGetAnalogicValue(g_xJoystickAxeX) : 0;
iYValue = g_xJoystickAxeY ? IPT_fn_lGetAnalogicValue(g_xJoystickAxeY) : 0;
#endif /* USE_IPT_WIN */
g_cJoystickXcenter = iXValue;
g_cJoystickYcenter = iYValue;
/* make sure the center the extremas dont match, else this would cause a zero divide error */
if ( g_cJoystickXcenter >= g_cJoystickXmax )
g_cJoystickXmax = g_cJoystickXcenter + 1;
if ( g_cJoystickXcenter <= g_cJoystickXmin )
g_cJoystickXmin = g_cJoystickXcenter - 1;
if ( g_cJoystickYcenter >= g_cJoystickYmax )
g_cJoystickYmax = g_cJoystickYcenter + 1;
if ( g_cJoystickYcenter <= g_cJoystickYmin )
g_cJoystickYmin = g_cJoystickYcenter - 1;
return p_stTree;
}
/*=====================================================================================================================================
Name: PAD_SetMaximalValues in english and french
Author: yann le tensorer
Created: November 12,1998
Last modified:
inputs: none
Outputs: none
Comments: for PC version only.
=====================================================================================================================================*/
tdstNodeInterpret *fn_p_stSetMaximalValues( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
int iXValue,iYValue;
/* read analog x & y value*/
#ifdef USE_IPT_DX5
iXValue = g_xJoystickAxeX ? MTH_M_xRealToLong(IPT_fn_xGetAnalogicValue(g_xJoystickAxeX)) : 0;
iYValue = g_xJoystickAxeY ? MTH_M_xRealToLong(IPT_fn_xGetAnalogicValue(g_xJoystickAxeY)) : 0;
#else /* USE_IPT_WIN */
iXValue = g_xJoystickAxeX ? IPT_fn_lGetAnalogicValue(g_xJoystickAxeX) : 0;
iYValue = g_xJoystickAxeY ? IPT_fn_lGetAnalogicValue(g_xJoystickAxeY) : 0;
#endif /* USE_IPT_WIN */
if ( (short) iYValue > g_cJoystickYmax )
g_cJoystickYmax = (signed char) iYValue;
else if ( (short) iYValue < g_cJoystickYmin )
g_cJoystickYmin = (signed char) iYValue;
if ( (short) iXValue > g_cJoystickXmax)
g_cJoystickXmax = (signed char) iXValue;
else if ( (short) iXValue < g_cJoystickXmin )
g_cJoystickXmin = (signed char) iXValue;
return p_stTree;
}
#endif /* !U64 */
/*=====================================================================================================================================
Name: ACT_FixeBooleenDansTableau (ACT_SetBooleanInArray in english)
Author: Marc Trabucato
Created: september 15,1998
Last modified:
inputs: parameter 1 = array of integer
parameter 2 = index of boolean (bit)
parameter 3 = value of boolean
Outputs: none
=====================================================================================================================================*/
tdstNodeInterpret *fn_p_stSetBooleanInArray( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
unsigned char ucArrayId;
unsigned long ulIndex;
ACP_tdxBool bState;
AI_tdstMind * p_stMind; /* Mind of perso (used to return paramaters to dsgVars)*/
/* get array index*/
M_vEvalNextVarId(p_stMind, ucArrayId);
/*ucArrayId = (unsigned char) M_ucVarIdInterpret(p_stTree);*/
/*p_stTree ++;*/
/* get index*/
M_EvalNextParameter(&stParam);
ulIndex = M_GetSetParam_lValue(&stParam);
SAF_M_AssertWithMsg(ulIndex, "L'index doit être > 0")
ulIndex--;
/* get boolean*/
M_EvalNextParameter(&stParam);
bState = (M_GetSetParam_lValue(&stParam) ? TRUE : FALSE);
switch(eProcedureId)
{
case eProc_SetBooleanInArray:
{
unsigned long ulPos = (ulIndex >> 5);
unsigned long ulBit = (ulIndex & 31);
#ifdef _DEBUG
tdeDsgVarTypeId eDsgVarType;
tdstArray *p_stArray;
unsigned long ulMyVarSize;
/* ucArrayId is an array*/
eDsgVarType = M_GetDsgVarType(p_stMind,ucArrayId);
SAF_M_AssertWithMsg((fn_GetDsgVarType(eDsgVarType)==E_vt_Array), "La variable designer n'est pas un tableau")
/* verify array size*/
p_stArray = (tdstArray*)M_GetDsgVarAddr(p_stMind,ucArrayId);
ulMyVarSize = M_ARRAY_SIZE(p_stArray);
SAF_M_AssertWithMsg((ulMyVarSize>ulPos), "Le tableau n'est pas assez grand")
#endif
/**/
if( fn_ucGetDsgVar(ucArrayId , (unsigned char)ulPos , p_stMind , &stParam) == C_VALID_GET )
{
unsigned ulValue = M_GetSetParam_lValue(&stParam);
if(bState)
{
ulValue |= (1 << ulBit);
}
else
{
ulValue &= ~(1 << ulBit);
}
M_Full_GetSetParam_Integer(&stParam , ulValue);
ucArrayId = fn_ucSetDsgVar(ucArrayId , (unsigned char)ulPos , p_stMind , &stParam);
}
break;
}
/* default */
default:
/* Procedure does not exist !!*/
M_AIFatalError(E_uwAIFatalNotValidProcedure);
break;
}
return p_stTree;
}
#if defined(WIN32) && defined(_DEBUG)
#ifdef __cplusplus
extern "C"
{
#endif
/* for drawing the raytrace segments in engine mode*/
extern unsigned char g_ucDisplayRayTraceSegments;
extern MTH3D_tdstVector g_stRayTraceSegmentOrigin[30];
extern MTH3D_tdstVector g_stRayTraceSegmentEnd[30];
extern short g_wRayTraceSegmentLife[30];
#ifdef __cplusplus
}
#endif
tdstNodeInterpret *fn_p_stDebugDrawSegment( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
#ifndef _DEBUG
/* this procedure should not be called in non-editor versions, because it is here for debug purposes only */
p_SuperObjPerso = p_SuperObjPerso;
p_stTree = fn_p_stSkipThisArgument(fn_p_stSkipThisArgument(fn_p_stSkipThisArgument(p_stTree)));
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#else /* !_DEBUG */
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
MTH3D_tdstVector stOrigin, stEnd;
long lMode;
/* get segment origin */
M_EvalNextParameter(&stParam);
stOrigin = M_GetSetParam_stVertexValue(&stParam);
/* get segment vector or end (depens on mode) */
M_EvalNextParameter(&stParam);
stEnd = M_GetSetParam_stVertexValue(&stParam);
/* get mode */
M_EvalNextParameter(&stParam);
lMode = M_GetSetParam_lValue(&stParam );
/* mode 0 : start + end */
/* mode 1 : start + vector */
if ( lMode )
{
/* compute the end's position from the vector */
MTH3D_M_vAddVector(&stEnd, &stEnd, &stOrigin);
}
if ( g_ucDisplayRayTraceSegments )
{
int i;
for ( i = 0; i < 30; i ++ )
if ( g_wRayTraceSegmentLife[i] <= 0 )
{
g_stRayTraceSegmentOrigin[i] = stOrigin;
g_stRayTraceSegmentEnd[i] = stEnd;
g_wRayTraceSegmentLife[i] = 1;
break;
}
}
#endif /* !_DEBUG */
return p_stTree;
}
#endif /* WIN32 && _DEBUG */
/*=====================================================================================================================================
Name: TEXT_SetDefaultFormatCharacter
inputs: parameter 1 = character width
parameter 2 = character height
parameter 3 = character zoom
Outputs: none
=====================================================================================================================================*/
tdstNodeInterpret *fn_p_stSetDefaultFormatCharacter( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam; /* for input parameters*/
MTH_tdxReal xCharWidth;
MTH_tdxReal xLineHeight;
MTH_tdxReal xCharZoom;
M_EvalNextParameter( &stParam );
xCharWidth = M_GetSetParam_xValue(&stParam );
M_EvalNextParameter( &stParam );
xLineHeight = M_GetSetParam_xValue(&stParam );
M_EvalNextParameter( &stParam );
xCharZoom = M_GetSetParam_xValue(&stParam );
TFMT_vSetDefaultValuesCharacter(xCharWidth, xLineHeight, xCharZoom);
return p_stTree;
}
#if (!defined U64)
/*=====================================================================================================================================
Name: VID_SelectDriver
inputs: parameter 1 = id of driver
Outputs: none
=====================================================================================================================================*/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
tdstNodeInterpret *fn_p_stSelectDriver( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam; /* for input parameters*/
long lDriver;
M_EvalNextParameter( &stParam );
lDriver = M_GetSetParam_lValue(&stParam );
return p_stTree;
}
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
#endif /* U64*/
/*=====================================================================================================================================
Name: VID_SelectResolution
inputs: parameter 1 = id of resolution
Outputs: none
=====================================================================================================================================*/
tdstNodeInterpret *fn_p_stSelectResolution( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam; /* for input parameters*/
long lResolution;
M_EvalNextParameter( &stParam );
lResolution = M_GetSetParam_lValue(&stParam );
#ifndef U64
GLI_fn_lRequestNewDisplayMode( lResolution );
#else
if(lResolution==0)
GAM_fn_vSwitchToLores();
else
GAM_fn_vSwitchToHires();
#endif
return p_stTree;
}
/*=====================================================================================================================================
Name: VID_ChangeBrightness
inputs: parameter 1 = value of brightness (real)
Outputs: none
=====================================================================================================================================*/
tdstNodeInterpret *fn_p_stChangeBrightness( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam; /* for input parameters*/
long lBrightness;
M_EvalNextParameter( &stParam );
lBrightness = M_GetSetParam_lValue(&stParam );
GLI_fn_vSetBrightness( lBrightness );
return p_stTree;
}
/***********************************************************************
* Procedures
VID_SetTextureFiltering
VID_SetAntiAliasing
* parametre:
0: OFF
1: ON
************************************************************************/
tdstNodeInterpret *fn_p_stSetVideoOptions(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
long lOnOff;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
M_EvalNextParameter( &stParam );
lOnOff = M_GetSetParam_lValue(&stParam );
#ifndef U64
return(p_stTree);
#else
/* PARTIE A REMPLIR PAR L EQUIPE U64*/
switch (eProcedureId)
{
case eProc_SetTextureFiltering:
break;
case eProc_SetAntiAliasing:
break;
default :
break;
}
return(p_stTree);
#endif
}
/***********************************************************************
* Procedures
SOUND_SetInStereoMode
* parametre:
0: OFF
1: ON
************************************************************************/
tdstNodeInterpret *fn_p_stSetInStereoMode(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
M_EvalNextParameter( &stParam );
SND_fn_vSetStereoSound((ACP_tdxBool)M_GetSetParam_lValue(&stParam ));
return(p_stTree);
}
/***********************************************************************
* Procedures
Proc_SetSaturationBackGroundDistance
* parametre:
Saturation Distance
Background Distance
************************************************************************/
tdstNodeInterpret *fn_p_stSetaturationAndBackgroundDistance(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
MS_tdxHandleToMSSound hMSSound;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
hMSSound = M_GetMSHandle(hNewSuperObjPerso,MSSound);
if (hMSSound)
{
unsigned long ulValue;
SndReal xSndValue;
// get saturation distance
M_EvalNextParameter( &stParam );
ulValue = M_GetSetParam_lValue(&stParam);
xSndValue = M_IntToRealSnd(ulValue);
fn_vMSSoundSetSaturationDistance (hMSSound , xSndValue);
// get background distance
M_EvalNextParameter( &stParam );
ulValue = M_GetSetParam_lValue(&stParam);
xSndValue = M_IntToRealSnd(ulValue);
fn_vMSSoundSetBackGroundDistance(hMSSound , xSndValue);
}
else
{
SAF_M_AssertWithMsg((hMSSound!=NULL), "La MSSound de l'acteur n'est pas allouée")
}
return(p_stTree);
}
/***********************************************************************
* Procedures
Proc_SaveCurrentRequest
Proc_RestoreRequest
* parametre:
Index du slot de sauvegarde
************************************************************************/
tdstNodeInterpret *fn_p_stSaveCurrentSoundRequest(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
unsigned long ulIndex;
SND_tdstBlockEvent *p_stBlockEvent;
//SND_tduRefEvt uRefEvt;
M_EvalNextParameter( &stParam );
ulIndex = M_GetSetParam_lValue(&stParam);
//SAF_M_AssertWithMsg((ulIndex < GAM_C_NBLOCKEVENTSLOTNUMBER),"Le numéro de slot est trop important")
switch(eProcedureId)
{
case eProc_SaveSoundEventInSlotMemory:
p_stBlockEvent = SND_fn_pstGetLastEventForObjectTypeSound(g_lSoundObjectTypeMusic);
GAM_fn_lSaveBlockEventSlotMemory (p_stBlockEvent , 0);
break;
case eProc_RestoreSoundEventInSlotMemory:
/* uRefEvt.pstPtr = GAM_p_stGetBlockEventSlotMemory(ulIndex);
if(uRefEvt.pstPtr)
{
SND_fn_lSendRequestSound((long) SND_C_OBJET_FANTOME,g_lSoundObjectTypeMusic,uRefEvt,0,NULL);
}
*/ break;
default:
M_AIFatalError(E_uwAIFatalNotValidProcedure);
break;
}
return(p_stTree);
}
#ifdef U64
/***********************************************************************
* Procedures
Proc_SelectShapnessMax
* parametre:
booléen
************************************************************************/
extern unsigned char g_bSharpnessValue;
void SetSpecialFeatures(void);
tdstNodeInterpret *Proc_SelectShapnessMax(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
/* XB 05/05/99 */
/* enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1); */
/* End XB 05/05/99 */
M_EvalNextParameter(&stParam);
/* à remplir */
if (SCREEN_WD==300)
{
if ( M_GetSetParam_lValue(&stParam) )
{
g_bSharpnessValue=1;
}
else
{
g_bSharpnessValue=0;
}
SetSpecialFeatures();
}
return p_stTree;
}
/***********************************************************************
* Procedures
Proc_CenterScreen
* parametre:
non
************************************************************************/
void Gli_vCenterScreen(void);
tdstNodeInterpret *fn_p_stCenterScreen(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
/* XB 05/05/99 */
/* enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1); */
/* End XB 05/05/99 */
Gli_vCenterScreen();
return p_stTree;
}
#endif /* U64 */
#if defined(WIN32)
/***********************************************************************
* Procedures
Proc_UpdateChecksum
* parametre:
************************************************************************/
tdstNodeInterpret *fn_p_stMiscProtectProcedure(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
DWORD dwOffset = (DWORD)PTC_GetModuleHandle(NULL);
switch(eProcedureId)
{
case eProc_UpdateChecksum:
{
unsigned char ucArrayId;
AI_tdstMind * p_stMind; /* Mind of perso (used to return paramaters to dsgVars)*/
/* get Checksum Id */
M_vEvalNextVarId(p_stMind, ucArrayId);
if( fn_ucGetDsgVar(ucArrayId , 0 , p_stMind , &stParam) == C_VALID_GET )
{
DWORD dwAddress;
MTH3D_tdstVector stVector;
DWORDLONG *p_dwlChecksum;
MTH3D_M_vCopyVector(&stVector,&M_GetSetParam_stVertexValue(&stParam));
p_dwlChecksum = (DWORDLONG *)&stVector;
M_EvalNextParameter(&stParam);
dwAddress = M_GetSetParam_ulValue(&stParam) + dwOffset;
*p_dwlChecksum += UInt32x32To64(*(DWORD*)dwAddress,*(DWORD*)dwAddress);
M_Full_GetSetParam_p_stVertex(&stParam,&stVector);
ucArrayId = fn_ucSetDsgVar(ucArrayId , 0 , p_stMind , &stParam);
}
}
break;
default:
M_AIFatalError(E_uwAIFatalNotValidProcedure);
break;
}
return(p_stTree);
}
#endif /* WIN32 */
#if defined(WIN32)
/***********************************************************************
* Procedures
Proc_ShellExecute
* parametre:
************************************************************************/
tdstNodeInterpret *fn_p_stShellExecuteProcedure ( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
switch(eProcedureId)
{
case eProc_ShellExecute :
{
char * pszString ;
M_EvalNextParameter ( & stParam ) ;
pszString = ( char * ) fn_szGetStringFromTextOrStringParam(&stParam);
(int) ShellExecute(NULL, NULL, pszString, NULL, NULL, 0) == SE_ERR_NOASSOC ;
break ;
}
default :
M_AIFatalError(E_uwAIFatalNotValidProcedure);
break;
}
return p_stTree ;
}
#endif /* WIN32 */
#include "ProcRay2.cxx"