1410 lines
56 KiB
C++
1410 lines
56 KiB
C++
//#################################################################################
|
|
//
|
|
// BASE CLASS OF YOUR DLL interface
|
|
//
|
|
//#################################################################################
|
|
|
|
#include <direct.h>
|
|
|
|
#include "stdafx.h"
|
|
#include "acp_base.h"
|
|
#include "geo.h"
|
|
#include "gli.h"
|
|
#include "ITF.h"
|
|
#include "caminter.hpp"
|
|
#include "ogd.h"
|
|
#include "X:\Cpa\Main\inc\_EditID.h"
|
|
//CPA 2 Corneliu Babiuc 04-05-98
|
|
//include files for level path & name
|
|
#include "incGAM.h"
|
|
#include "DPT.h"
|
|
//END CPA2 Corneliu Babiuc 04-05-98
|
|
|
|
// infos
|
|
static CString g_csOCAName = "Camera";
|
|
static CString g_csOCAAuthor = "Fabien Bole-Feysot & Chantal Oury";
|
|
static CString g_csOCAVersion = "V 3.0.1 18/03/98";
|
|
static CString g_csOCAFrenchHelpFile = "Camera.hlp";
|
|
static CString g_csOCAEnglishHelpFile = "";
|
|
|
|
|
|
// the DLL global definition
|
|
tdstDLLIdentity g_stCameraIdentity;
|
|
|
|
|
|
|
|
|
|
#define C_PI 3.14159265
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
Camera_Interface::Camera_Interface(void)
|
|
{
|
|
|
|
// CPA_Ed_1 MP BEGIN
|
|
|
|
//mouse handler
|
|
m_bRotateOn=FALSE;
|
|
m_bIsMoving=FALSE;
|
|
|
|
hcursorR=AfxGetApp()->LoadCursor(MAKEINTRESOURCE(CPA_IDC_ROTATECAMERA));
|
|
hcursorM=AfxGetApp()->LoadCursor(MAKEINTRESOURCE(CPA_IDC_MOVECAMERA));
|
|
|
|
// CPA_Ed_1 MP END
|
|
|
|
m_p_stDLLIdentity = &g_stCameraIdentity;
|
|
|
|
// Does your DLL can output in main game view ?
|
|
m_stBaseDLLDefinition.bCanOutputIn3DView = FALSE;
|
|
|
|
m_fTranslationStep = 1;
|
|
m_fRotationStep = (float) (C_PI/32);
|
|
|
|
// TODO : Add your own code here
|
|
|
|
SetCurrent(FALSE);
|
|
SetEditorInfo(g_csOCAName, g_csOCAAuthor, g_csOCAVersion, g_csOCAFrenchHelpFile, g_csOCAEnglishHelpFile);
|
|
|
|
m_p_oKeyConfiguration = NULL;
|
|
m_p_oInertCameraGeomObject = NULL;
|
|
m_hLastEngineCamera = NULL;
|
|
|
|
m_bFirstTime = TRUE;
|
|
m_lSlotForEngineCamera = -1;
|
|
m_lSlotForLastEditorCamera = -1;
|
|
|
|
m_bCameraTargetMode = FALSE;
|
|
|
|
// ANNECY MT NewInterface 26/03/98 {
|
|
m_eReferentialDisplayMode = DisplayDownLeft;
|
|
// ENDANNECY MT NewInterface }
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::fn_vJustAfterRegistered()
|
|
{
|
|
CString types[] = {C_szCameraObjectTypeName};
|
|
|
|
fn_vRegisterObjectsType(types,1);
|
|
Camera::StaticInit();
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::fn_vConstruct()
|
|
{
|
|
// Keyboard
|
|
InitKeyboard();
|
|
// Display
|
|
SetReferentialDisplayMode( m_eReferentialDisplayMode ); // update ToolBar
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::fn_vInitListByType (CPA_World *pWorld)
|
|
{
|
|
pWorld->fn_vAddANewListByType ("Camera", this);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::fn_vBeforeEditor(void)
|
|
{
|
|
DEV_ViewPort3D *p_oMainvp;
|
|
GLI_tdxHandleToCamera hEngineCamera, hCopyOfEngineCamera;
|
|
ACP_tdxHandleOfObject hObject;
|
|
CPA_CameraSlots *p_oSlotCamera;
|
|
CPA_EditorBase *pGeomDLL;
|
|
Camera *p_oEngineCamera;
|
|
CPA_SuperObject *p_oCameraSO;
|
|
CPA_BaseObject *p_oOwnerFile;
|
|
CString csCameraName = "Inert_Camera_Picture";
|
|
|
|
p_oSlotCamera = GetMainWorld()->GetWorld()->GetCameraSlots();
|
|
p_oMainvp = (DEV_ViewPort3D*)(M_GetMainDeviceNum(0)->GetViewPort());
|
|
|
|
// get the game engine camera
|
|
hEngineCamera = p_oMainvp->GetEngineCamera();
|
|
ASSERT(hEngineCamera != NULL); // there's no game camera!!!
|
|
|
|
// save the real game engine camera in the specific variable
|
|
m_hLastEngineCamera = hEngineCamera;
|
|
|
|
if (m_p_oInertCameraGeomObject == NULL)
|
|
{
|
|
// load the camera geometric representation
|
|
hObject = GLI_pLoadGeometricInFile("edt_data\\objects\\camera\\camera.mod^Geometric:camera");
|
|
//create the corresponding editor geometric object
|
|
pGeomDLL = GetMainWorld () -> GetObjectDLLWithName (C_szDLLGeometryName);
|
|
p_oOwnerFile = (CPA_BaseObject*) pGeomDLL -> OnQueryAction( this, C_uiGetOwnerByFileName, (LPARAM)"edt_data\\objects\\camera\\camera.mod");
|
|
m_p_oInertCameraGeomObject = new Geometry3D(pGeomDLL, p_oOwnerFile, (ACP_tdxHandleOfObject)hObject, csCameraName);
|
|
}
|
|
|
|
if (m_bFirstTime)
|
|
{
|
|
// this part is executed only once, the first time
|
|
//CPA2 Corneliu Babiuc 30-04-98
|
|
// m_bFirstTime = FALSE;
|
|
//END CPA2 Corneliu Babiuc 30-04-98
|
|
// init the main world camera slots
|
|
m_lSlotForEngineCamera = p_oSlotCamera->ReserveASlot("Copy Of Engine Camera");
|
|
m_lSlotForLastEditorCamera = p_oSlotCamera->ReserveASlot("Last Editor Camera");
|
|
//Stefan Dumitrean 24-06-98 ( slots )
|
|
p_oSlotCamera->ActivatePrevCamTip();
|
|
p_oSlotCamera->SetCurrentSlot(p_oSlotCamera->SetSpecialSlotNr(p_oSlotCamera->ReserveASlot("Default Slot")));
|
|
//End Stefan Dumitrean 24-06-98 ( slots )
|
|
}
|
|
|
|
// make a copy of the engine camera
|
|
GLI_xCreateCamera(&hCopyOfEngineCamera, GLI_C_lPersCamWithoutDistorsion);
|
|
GLI_vCopyCamera(hCopyOfEngineCamera,hEngineCamera);
|
|
|
|
// make a new Camera from the copy of the engine structure
|
|
p_oEngineCamera = new Camera(InertCamera,this,GetMainWorld(),hCopyOfEngineCamera);
|
|
|
|
// and put this new camera in the slot 0
|
|
p_oSlotCamera->SaveCameraInSlot(m_lSlotForEngineCamera,"Copy Of Engine Camera",p_oEngineCamera,MakeACopy);
|
|
//Stefan Dumitrean 26-06-98 ( slots )
|
|
p_oSlotCamera->SaveCameraInSlot(p_oSlotCamera->GetSpecialSlotNr(),"Default Slot",p_oEngineCamera,MakeACopy);
|
|
//End Stefan Dumitrean 26-06-98 (slots)
|
|
|
|
// associate a camera superobject and a geometric superobject and a geometric object to the camera
|
|
//Stefan Dumitrean 24-06-98 ( slots )
|
|
//if the current slot is the "mode change slot" initialize with engine camera
|
|
if( !m_bFirstTime && p_oSlotCamera->GetCurrentSlot() >= 0 )
|
|
p_oCameraSO = AssociateSuperObject( (Camera*)p_oSlotCamera->GetCameraFromSlot( p_oSlotCamera->GetCurrentSlot(), MakeACopy ) );
|
|
else
|
|
p_oCameraSO = AssociateSuperObject(p_oEngineCamera);
|
|
//End Stefan Dumitrean 24-06-98 ( slots )
|
|
|
|
// put this camera in the main viewport
|
|
p_oMainvp->ChangeCamera(p_oCameraSO);
|
|
|
|
// and put this camera in the hierarchy
|
|
InsertCameraInHierarchy(p_oCameraSO);
|
|
|
|
// move the camera ahead a bit to avoid auto-selection of stdcam
|
|
CPA_CameraCoords oCoords(CameraCoordinates,0,0,(float)0.3);
|
|
p_oEngineCamera->Translate(&oCoords);
|
|
|
|
//CPA2 Corneliu Babiuc 30-04-98
|
|
//read the saved slots
|
|
if (m_bFirstTime)
|
|
{
|
|
m_bFirstTime = FALSE;
|
|
LoadSlotsPositions(p_oEngineCamera);
|
|
}
|
|
//END CPA2 Corneliu Babiuc 30-04-98
|
|
|
|
// get the active camera
|
|
p_oEngineCamera = (Camera*) GetMainWorld()->GetFRMBase()->m_oGeneralDialogBar.m_p_oCamera;
|
|
|
|
// and show its dialogbar
|
|
if (p_oEngineCamera != NULL)
|
|
p_oEngineCamera->ShowDialogBar();
|
|
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::fn_vBeforeEngine(void)
|
|
{
|
|
DEV_ViewPort3D *p_oMainvp;
|
|
CPA_SuperObject *p_oCameraSO;
|
|
Camera *p_oCamera;
|
|
CPA_CameraSlots *p_oCameraslots;
|
|
|
|
// get the main world slots
|
|
p_oCameraslots = GetMainWorld()->GetWorld()->GetCameraSlots();
|
|
|
|
// get the game viewport
|
|
p_oMainvp = (DEV_ViewPort3D*)(M_GetMainDeviceNum(0)->GetViewPort());
|
|
// put a NULL camera in the game viewport, and get the game viewport last camera
|
|
// don't remember the previous camera
|
|
p_oCameraSO = p_oMainvp->ChangeCamera(NULL,FALSE);
|
|
p_oCamera = (Camera*)p_oCameraSO->GetObject();
|
|
// save this camera in the reserved slot
|
|
p_oCameraslots->SaveCameraInSlot(m_lSlotForLastEditorCamera,"Last Editor Camera",p_oCamera,MakeACopy);
|
|
//Stefan Dumitrean 24-06-98 ( slots )
|
|
//saves the current slot
|
|
//when we go back to the editor this slot will be restored
|
|
if( p_oCameraslots->GetCurrentSlot() >= 0 )
|
|
p_oCameraslots->SaveCameraInSlot(p_oCameraslots->GetCurrentSlot(),"",p_oCamera,MakeACopy);
|
|
SaveSlotsPositions();
|
|
//End Stefan Dumitrean 24-06-98 ( slots )
|
|
|
|
// put back the engine camera in the game viewport
|
|
GLI_xSetViewportCamera(p_oMainvp->m_hDisplayDevice,p_oMainvp->m_hDisplayViewport,m_hLastEngineCamera);
|
|
GLI_xAdjustCameraToViewport (p_oMainvp->m_hDisplayDevice,p_oMainvp->m_hDisplayViewport,m_hLastEngineCamera);
|
|
|
|
// get the active camera
|
|
p_oCamera = (Camera*) GetMainWorld()->GetFRMBase()->m_oGeneralDialogBar.m_p_oCamera;
|
|
// and hide its dialogbar
|
|
if (p_oCamera != NULL)
|
|
p_oCamera->HideDialogBar();
|
|
|
|
// destroy the old game viewport editor camera
|
|
DestroyCamera(p_oCameraSO);
|
|
|
|
}
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::fn_vAddObjectsToDraw(GLD_tdstViewportAttributes *p1 , GLI_tdstLight *p2, DEV_ViewPort* p3)
|
|
{
|
|
MTH3D_tdstVector stOrigin,stP1,stP2,stP3;
|
|
POS_tdstCompletePosition stMatrix,stMatrix2;
|
|
DEV_ViewPort3D *p_oViewPort;
|
|
Camera *p_oCamera;
|
|
GEO_tdstColor ColBidon;
|
|
long lLineColor;
|
|
|
|
POS_fn_vSetIdentityMatrix(&stMatrix);
|
|
POS_fn_vSetIdentityMatrix(&stMatrix2);
|
|
// ANNECY MT NewInterface 26/03/98 {
|
|
if (m_eReferentialDisplayMode ==DisplayNone)
|
|
return;
|
|
// ENDANNECY MT NewInterface }
|
|
|
|
// get the current camera
|
|
p_oViewPort = (DEV_ViewPort3D*)p3;
|
|
p_oCamera = (Camera*)p_oViewPort->GetCamera();
|
|
|
|
if (p_oCamera == NULL)
|
|
return;
|
|
|
|
ColBidon.xR=0.5;
|
|
ColBidon.xG=0.5;
|
|
ColBidon.xB=0.5;
|
|
ColBidon.xA=0.5;
|
|
GLI_xGetCameraMatrix(((GLI_tdstSpecificAttributesFor3D*)(p1->p_vSpecificToXD))->p_stCam,&stMatrix);
|
|
// init for drawing
|
|
GLI_xLoadMatrix(&stMatrix);
|
|
GLI_vSetFog(100,100,200,&ColBidon);
|
|
|
|
#define C_Grid_Offset 0.008
|
|
#define C_Grid_NbLines 9
|
|
|
|
// prepare the Origin Point
|
|
// get the camera matrix
|
|
p_oCamera->GetMatrix(&stMatrix2);
|
|
// get the camera position
|
|
POS_fn_vGetTranslationVector(&stMatrix2,&stOrigin);
|
|
// buil the offset vector, in camera coordinates, from camera to origin
|
|
// ANNECY MT NewInterface 26/03/98 {
|
|
if( m_eReferentialDisplayMode == DisplayDownLeft )
|
|
{
|
|
MTH3D_M_vSetVectorElements(&stP1,0.22 - C_Grid_Offset*(C_Grid_NbLines-1)/2,
|
|
-0.17 + C_Grid_Offset*(C_Grid_NbLines-1)/2,
|
|
0.35);
|
|
}
|
|
else if( m_eReferentialDisplayMode == DisplayDownRight )
|
|
{
|
|
MTH3D_M_vSetVectorElements(&stP1,-0.21 + C_Grid_Offset*(C_Grid_NbLines-1)/2,
|
|
-0.17 + C_Grid_Offset*(C_Grid_NbLines-1)/2,
|
|
0.35);
|
|
}
|
|
// ENDANNECY MT NewInterface }
|
|
|
|
// translate it in world coordinates
|
|
p_oCamera->CameraToWorldCoordinates_Vector(stP1);
|
|
// add it to camera position --> origin
|
|
MTH3D_M_vAddVector(&stOrigin,&stP1,&stOrigin);
|
|
|
|
// put the origin at the beginning of the grid
|
|
MTH3D_M_vSetVectorElements(&stP1,- C_Grid_Offset * (C_Grid_NbLines-1)/2,
|
|
- C_Grid_Offset * (C_Grid_NbLines-1)/2,
|
|
(float)0.00);
|
|
MTH3D_M_vAddVector(&stOrigin,&stOrigin,&stP1);
|
|
|
|
// draw the grid X lines
|
|
// p3 = origin
|
|
// p2 = offset
|
|
// p1 = extremite
|
|
MTH3D_M_vSetVectorElements(&stP2,(float)0.0,(float)C_Grid_Offset,(float)0.00);
|
|
MTH3D_M_vCopyVector(&stP3,&stOrigin);
|
|
MTH3D_M_vCopyVector(&stP1,&stOrigin);
|
|
MTH3D_M_vSetXofVector(&stP1,MTH3D_M_xGetXofVector(&stP3) + C_Grid_Offset * (C_Grid_NbLines-1));
|
|
lLineColor = 0xf0f0f0;
|
|
for (int i=0;i<C_Grid_NbLines;i++)
|
|
{
|
|
GLI_xDraw3DLine16 (p1,&stP3,&stP1,lLineColor);
|
|
MTH3D_M_vAddVector(&stP1,&stP1,&stP2);
|
|
MTH3D_M_vAddVector(&stP3,&stP3,&stP2);
|
|
lLineColor ^= 0xf0f0f0;
|
|
}
|
|
|
|
// draw the grid Y lines
|
|
// p3 = origin
|
|
// p2 = extremite
|
|
// p1 = offset
|
|
MTH3D_M_vSetVectorElements(&stP1,(float)C_Grid_Offset,(float)0.0,(float)0.00);
|
|
MTH3D_M_vCopyVector(&stP3,&stOrigin);
|
|
MTH3D_M_vCopyVector(&stP2,&stOrigin);
|
|
MTH3D_M_vSetYofVector(&stP2,MTH3D_M_xGetYofVector(&stP3) + C_Grid_Offset * (C_Grid_NbLines-1));
|
|
|
|
lLineColor = 0xf0f0f0;
|
|
for (i=0;i<C_Grid_NbLines;i++)
|
|
{
|
|
GLI_xDraw3DLine16 (p1,&stP3,&stP2,lLineColor);
|
|
MTH3D_M_vAddVector(&stP2,&stP2,&stP1);
|
|
MTH3D_M_vAddVector(&stP3,&stP3,&stP1);
|
|
lLineColor ^= 0xf0f0f0;
|
|
}
|
|
|
|
// put the origin in the center of the grid
|
|
MTH3D_M_vSetVectorElements(&stP1,C_Grid_Offset * (C_Grid_NbLines-1)/2,
|
|
C_Grid_Offset * (C_Grid_NbLines-1)/2,
|
|
(float)0.00);
|
|
MTH3D_M_vAddVector(&stOrigin,&stOrigin,&stP1);
|
|
|
|
// CPA2 ASilvescu 98-04-13
|
|
#define CYLINDER 0.0015f
|
|
if(GetInterface()->fn_bConsX())
|
|
for(int i=0; i<20; i++)
|
|
{
|
|
MTH3D_M_vSetVectorElements(&stP1, 0.0f, (float)CYLINDER*sin(i*6.28/20), (float)CYLINDER*cos(i*6.28/20));
|
|
MTH3D_M_vAddVector(&stP2, &stP1, &stOrigin);
|
|
stP1.xX = 0.02f;
|
|
MTH3D_M_vAddVector(&stP1, &stP1, &stOrigin);
|
|
GLI_xDraw3DLine16 (p1, &stP1, &stP2, 0x00FF00);
|
|
}
|
|
|
|
if(GetInterface()->fn_bConsY())
|
|
for(int i=0; i<20; i++)
|
|
{
|
|
MTH3D_M_vSetVectorElements(&stP1, (float)CYLINDER*sin(i*6.28/20), 0.0f, (float)CYLINDER*cos(i*6.28/20));
|
|
MTH3D_M_vAddVector(&stP2, &stP1, &stOrigin);
|
|
stP1.xY = 0.02f;
|
|
MTH3D_M_vAddVector(&stP1, &stP1, &stOrigin);
|
|
GLI_xDraw3DLine16 (p1, &stP1, &stP2, 0xFF00FF);
|
|
}
|
|
|
|
if(GetInterface()->fn_bConsZ())
|
|
for(int i=0; i<20; i++)
|
|
{
|
|
MTH3D_M_vSetVectorElements(&stP1, (float)CYLINDER*sin(i*6.28/20), (float)CYLINDER*cos(i*6.28/20), 0.0f);
|
|
MTH3D_M_vAddVector(&stP2, &stP1, &stOrigin);
|
|
stP1.xZ = 0.03f;
|
|
MTH3D_M_vAddVector(&stP1, &stP1, &stOrigin);
|
|
GLI_xDraw3DLine16 (p1, &stP1, &stP2, 0x00FFFF);
|
|
}
|
|
// End CPA2 ASilvescu 98-04-13
|
|
|
|
// draw the X axis
|
|
MTH3D_M_vSetVectorElements(&stP1,(float)0.02,(float)0,(float)0);
|
|
MTH3D_M_vAddVector(&stP1,&stP1,&stOrigin);
|
|
GLI_xDraw3DLine16 (p1,&stOrigin,&stP1,0x00FF00);
|
|
|
|
// draw the X letter
|
|
MTH3D_M_vSetVectorElements(&stP1,(float)0.022,(float)0,(float)-0.002);
|
|
MTH3D_M_vSetVectorElements(&stP2,(float)0.026,(float)0,(float)0.002);
|
|
MTH3D_M_vAddVector(&stP1,&stP1,&stOrigin);
|
|
MTH3D_M_vAddVector(&stP2,&stP2,&stOrigin);
|
|
GLI_xDraw3DLine16 (p1,&stP1,&stP2,0x00FF00);
|
|
MTH3D_M_vSetVectorElements(&stP1,(float)0.022,(float)0,(float)0.002);
|
|
MTH3D_M_vSetVectorElements(&stP2,(float)0.026,(float)0,(float)-0.002);
|
|
MTH3D_M_vAddVector(&stP1,&stP1,&stOrigin);
|
|
MTH3D_M_vAddVector(&stP2,&stP2,&stOrigin);
|
|
GLI_xDraw3DLine16 (p1,&stP1,&stP2,0x00FF00);
|
|
|
|
// draw the Y axis
|
|
MTH3D_M_vSetVectorElements(&stP2,(float)0,(float)0.02,(float)0);
|
|
MTH3D_M_vAddVector(&stP2,&stP2,&stOrigin);
|
|
GLI_xDraw3DLine16 (p1,&stOrigin,&stP2,0xFF00FF);
|
|
|
|
// draw the Y letter
|
|
MTH3D_M_vSetVectorElements(&stP1,(float)0,(float)0.022,(float)0.002);
|
|
MTH3D_M_vSetVectorElements(&stP2,(float)0,(float)0.024,(float)0);
|
|
MTH3D_M_vAddVector(&stP1,&stP1,&stOrigin);
|
|
MTH3D_M_vAddVector(&stP2,&stP2,&stOrigin);
|
|
GLI_xDraw3DLine16 (p1,&stP1,&stP2,0xFF00FF);
|
|
MTH3D_M_vSetVectorElements(&stP1,(float)0,(float)0.026,(float)0.002);
|
|
MTH3D_M_vSetVectorElements(&stP2,(float)0,(float)0.022,(float)-0.002);
|
|
MTH3D_M_vAddVector(&stP1,&stP1,&stOrigin);
|
|
MTH3D_M_vAddVector(&stP2,&stP2,&stOrigin);
|
|
GLI_xDraw3DLine16 (p1,&stP1,&stP2,0xFF00FF);
|
|
|
|
// draw the Z axis
|
|
MTH3D_M_vSetVectorElements(&stP3,(float)0,(float)0,(float)0.03);
|
|
MTH3D_M_vAddVector(&stP3,&stP3,&stOrigin);
|
|
GLI_xDraw3DLine16 (p1,&stOrigin,&stP3,0x00FFFF);
|
|
// draw the Z letter
|
|
MTH3D_M_vSetVectorElements(&stP1,(float)-0.002,(float)0,(float)0.036);
|
|
MTH3D_M_vSetVectorElements(&stP2,(float)0.002,(float)0,(float)0.036);
|
|
MTH3D_M_vAddVector(&stP1,&stP1,&stOrigin);
|
|
MTH3D_M_vAddVector(&stP2,&stP2,&stOrigin);
|
|
GLI_xDraw3DLine16 (p1,&stP1,&stP2,0x00FFFF);
|
|
MTH3D_M_vSetVectorElements(&stP1,(float)-0.002,(float)0,(float)0.032);
|
|
MTH3D_M_vAddVector(&stP1,&stP1,&stOrigin);
|
|
GLI_xDraw3DLine16 (p1,&stP1,&stP2,0x00FFFF);
|
|
MTH3D_M_vSetVectorElements(&stP2,(float)0.002,(float)0,(float)0.032);
|
|
MTH3D_M_vAddVector(&stP2,&stP2,&stOrigin);
|
|
GLI_xDraw3DLine16 (p1,&stP1,&stP2,0x00FFFF);
|
|
|
|
GLI_xPopMatrix();
|
|
}
|
|
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
ACP_tdxHandleOfObject Camera_Interface::fn_hGetBoundingVolume(CPA_BaseObject *_p_oCamera)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
if (p_oCamera->GetCameraType() == InertCamera)
|
|
{
|
|
ASSERT(m_p_oInertCameraGeomObject != NULL);
|
|
return ((CPA_ObjectDLLBase*)m_p_oInertCameraGeomObject->GetEditor())->fn_hGetBoundingVolume(m_p_oInertCameraGeomObject);
|
|
}
|
|
else
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
}
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::fn_vComputeBoundingVolume(CPA_BaseObject *_p_oCamera)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
if (p_oCamera->GetCameraType() == InertCamera)
|
|
{
|
|
ASSERT(m_p_oInertCameraGeomObject != NULL);
|
|
((CPA_ObjectDLLBase*)m_p_oInertCameraGeomObject->GetEditor())->fn_vComputeBoundingVolume(m_p_oInertCameraGeomObject);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
// communication with viewport
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::DestroyCamera(CPA_SuperObject *_p_oCameraSO)
|
|
{
|
|
Camera *p_oCamera = (Camera *) _p_oCameraSO->GetObject();
|
|
|
|
ASSERT(p_oCamera != NULL);
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
// disactivate camera
|
|
p_oCamera->Disactivate();
|
|
|
|
// if the old camera was in the hierarchy,
|
|
if (_p_oCameraSO->fn_bIsUnderObject(M_GetWorld()->GetRoot()))
|
|
{
|
|
// remove camera SO from hierarchy and delete SO
|
|
GetInterface()->fn_bDeleteObjectInHierarchy(_p_oCameraSO,FALSE,FALSE,TRUE);
|
|
// and delete camera
|
|
delete p_oCamera;
|
|
}
|
|
else
|
|
{
|
|
// delete SuperObject and camera
|
|
delete _p_oCameraSO;
|
|
delete p_oCamera;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=========================================================================================
|
|
//=========================================================================================
|
|
//=========================================================================================
|
|
//=========================================================================================
|
|
//=========================================================================================
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::Activate(CPA_BaseObject *_p_oCamera, DEV_ViewPort3D *p_oViewPort, CPA_DialogBar *p_oPopUpParent, CPoint oPos)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->Activate(p_oViewPort,p_oPopUpParent,oPos);
|
|
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::Disactivate(CPA_BaseObject *_p_oCamera)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->Disactivate();
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::SetRotationAxisSystem(CPA_BaseObject *_p_oCamera, tdeAxisSystem eSystem)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->SetRotationAxisSystem(eSystem);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::SetTranslationAxisSystem(CPA_BaseObject *_p_oCamera, tdeAxisSystem eSystem)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->SetTranslationAxisSystem(eSystem);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
tdeAxisSystem Camera_Interface::GetRotationAxisSystem(CPA_BaseObject *_p_oCamera)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->GetRotationAxisSystem();
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::GetMatrix(CPA_BaseObject *_p_oCamera, POS_tdstCompletePosition *p_oMatrix)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->GetMatrix(p_oMatrix);
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::SetMatrix(CPA_BaseObject *_p_oCamera, POS_tdstCompletePosition *p_oMatrix)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->SetMatrix(p_oMatrix);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
tdeAxisSystem Camera_Interface::GetTranslationAxisSystem(CPA_BaseObject *_p_oCamera)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->GetTranslationAxisSystem();
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
BOOL Camera_Interface::SetRotationCenterType(CPA_BaseObject *_p_oCamera, tdeRotationCenterType eRotCenterType)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->SetRotationCenterType(eRotCenterType);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
tdeRotationCenterType Camera_Interface::GetRotationCenterType(CPA_BaseObject *_p_oCamera)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->GetRotationCenterType();
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
tdeRotationCenterType Camera_Interface::GetEffectiveRotationCenterType(CPA_BaseObject *_p_oCamera)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->GetEffectiveRotationCenterType();
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
BOOL Camera_Interface::SetTargetType(CPA_BaseObject *_p_oCamera, tdeTargetType eTargetType)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->SetTargetType(eTargetType);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
tdeTargetType Camera_Interface::GetTargetType(CPA_BaseObject *_p_oCamera)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->GetTargetType();
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
BOOL Camera_Interface::ZoomOnTarget(CPA_BaseObject *_p_oCamera, CPA_SuperObject *pTarget)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->ZoomOnTarget(pTarget);
|
|
return TRUE;
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::SetRotationCenterPoint(CPA_BaseObject *_p_oCamera, CPA_CameraCoords *p_oRotationCenter, tdeCoordsType eType)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->SetRotationCenterPoint(p_oRotationCenter,eType);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
BOOL Camera_Interface::SetRotationCenterSuperObject(CPA_BaseObject *_p_oCamera, CPA_SuperObject *p_oSuperObject)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->SetRotationCenterSuperObject(p_oSuperObject);
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
BOOL Camera_Interface::GetRotationCenter(CPA_BaseObject *_p_oCamera, MTH3D_tdstVector &r_stCenter)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->GetRotationCenter(r_stCenter);
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::SetTargetPoint(CPA_BaseObject *_p_oCamera, CPA_CameraCoords *p_oRotationCenter)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->SetTargetPoint(p_oRotationCenter);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
BOOL Camera_Interface::SetTargetSuperObject(CPA_BaseObject *_p_oCamera, CPA_SuperObject *p_oSuperObject)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->SetTargetSuperObject(p_oSuperObject);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
BOOL Camera_Interface::GetTarget(CPA_BaseObject *_p_oCamera, MTH3D_tdstVector &r_stTarget)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return p_oCamera->GetTarget(r_stTarget);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::Translate(CPA_BaseObject *_p_oCamera, CPA_CameraCoords *p_oOffset, BOOL bUserDefinedAxis)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->Translate(p_oOffset,bUserDefinedAxis);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::SetPosition(CPA_BaseObject *_p_oCamera, CPA_CameraCoords *p_oPos)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->SetPosition(p_oPos);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::Rotate(CPA_BaseObject *_p_oCamera, tdeAxis eAxis, double dAngle)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->Rotate(eAxis,dAngle);
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::SetRotation(CPA_BaseObject *_p_oCamera, double dAngleX, double dAngleY, double dAngleZ)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->SetRotation(dAngleX,dAngleY,dAngleZ);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::Update(CPA_BaseObject *_p_oCamera)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->Update();
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::CameraToWorldCoordinates_Point(CPA_BaseObject *_p_oCamera, MTH3D_tdstVector &r_stVector)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->CameraToWorldCoordinates_Point(r_stVector);
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::CameraToWorldCoordinates_Vector(CPA_BaseObject *_p_oCamera, MTH3D_tdstVector &r_stVector)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->CameraToWorldCoordinates_Vector(r_stVector);
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::WorldToCameraCoordinates_Point(CPA_BaseObject *_p_oCamera, MTH3D_tdstVector &r_stVector)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->WorldToCameraCoordinates_Point(r_stVector);
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::WorldToCameraCoordinates_Vector(CPA_BaseObject *_p_oCamera, MTH3D_tdstVector &r_stVector)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
p_oCamera->WorldToCameraCoordinates_Vector(r_stVector);
|
|
}
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
CPA_SuperObject *Camera_Interface::CreateDefaultCamera()
|
|
{
|
|
|
|
// make a new inert camera
|
|
return CreateInertCamera(NULL,"default_camera");
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::InsertCameraInHierarchy(CPA_SuperObject *p_oCameraSO)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(p_oCameraSO != NULL);
|
|
p_oCamera = (Camera*)p_oCameraSO->GetObject();
|
|
ASSERT(p_oCamera != NULL);
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
GetInterface()->fn_bInsertObjectInHierarchy(p_oCameraSO,GetInterface()->GetSpecificInterface()->GetDynamicRoot(),
|
|
FALSE,FALSE,FALSE);
|
|
// must pass FALSE else crash when a new device is created because the redraw
|
|
// occurs before the new camera is ready !
|
|
//ANNECY Shaitan Correction 20/02/98
|
|
// GetInterface()->fn_vCancelCurrentSelection(FALSE);
|
|
//ENDANNECY Shaitan Correction
|
|
}
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
CPA_BaseObject *Camera_Interface::CopySlotCamera(CPA_BaseObject* _p_oCamera)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oCamera = (Camera*)_p_oCamera;
|
|
ASSERT(p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
return new Camera(*p_oCamera);
|
|
}
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::PutCameraInViewPort(CPA_BaseObject *_p_oCamera,DEV_ViewPort3D *p_oViewPort, BOOL bWithPrevCam)
|
|
{
|
|
Camera *p_oNewCamera,*p_oOldCamera;
|
|
CPA_SuperObject *p_oSO,*p_oSOGeom;
|
|
GEO_tdxHandleToMatrix hCameraMatrix,hSOMatrix;
|
|
long lSlotNum = -1;
|
|
|
|
|
|
ASSERT(_p_oCamera != NULL);
|
|
p_oNewCamera = (Camera*)_p_oCamera;
|
|
ASSERT(_p_oCamera->fn_bIsOfType(C_szCameraObjectTypeName));
|
|
|
|
// get actual viewport camera
|
|
p_oSO = p_oViewPort->GetCameraSO();
|
|
p_oOldCamera = (Camera *)p_oSO->GetObject();
|
|
ASSERT(p_oOldCamera != NULL);
|
|
|
|
// Get the name of the old camera
|
|
CString csOldCameraName = p_oOldCamera->GetName ();
|
|
|
|
// Delete the old camera so that the new camera can have the same name
|
|
// delete p_oOldCamera;
|
|
|
|
// rename new camera with name of old camera
|
|
if (p_oNewCamera->fn_eRename(csOldCameraName))
|
|
p_oNewCamera->SetDefaultUniqueName();
|
|
|
|
// attach the new camera to the old camera superobject
|
|
p_oSO->SetObject(p_oNewCamera);
|
|
|
|
// sets the SO at the same place that the camera
|
|
// ( ==> copy the camera matrix in the SO matrix)
|
|
hCameraMatrix = p_oNewCamera->GetCameraMatrix();
|
|
hSOMatrix = HIE_fn_hGetSuperObjectMatrix((HIE_tdxHandleToSuperObject) p_oSO->GetData());
|
|
GEO_M_vCopyMatrix(hSOMatrix,hCameraMatrix);
|
|
|
|
// change the camera geometric representation according to the camera type
|
|
p_oSOGeom = p_oSO->GetSuperObjectFirstChild();
|
|
|
|
switch (p_oNewCamera->GetCameraType())
|
|
{
|
|
case InertCamera:
|
|
p_oSOGeom->SetObject(GetInertCameraGeomObject());
|
|
break;
|
|
|
|
case ActorCamera:
|
|
break;
|
|
}
|
|
|
|
// change the camera in the viewport
|
|
p_oViewPort->ChangeCamera(p_oSO,bWithPrevCam);
|
|
}
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
// accept delete if the camera is not active
|
|
BOOL Camera_Interface::fn_bAcceptModifDelete(CPA_List<CPA_SuperObject> *p_oListObjects, tdeStatus eStatus)
|
|
{
|
|
POSITION stPos;
|
|
BOOL bResult;
|
|
CPA_SuperObject *p_oSO;
|
|
Camera *p_oCamera;
|
|
|
|
bResult = TRUE;
|
|
stPos = p_oListObjects->GetHeadPosition();
|
|
while (stPos)
|
|
{
|
|
p_oSO = p_oListObjects->GetNext(stPos);
|
|
if (p_oSO->GetObject()->fn_bIsOfType(C_szCameraObjectTypeName))
|
|
{
|
|
p_oCamera = (Camera*)p_oSO->GetObject();
|
|
if (p_oCamera->IsActive())
|
|
return FALSE;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
// ANNECY MT NewInterface 26/03/98 {
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
void Camera_Interface::SetReferentialDisplayMode(tdeDisplayReferential eDisplayMode)
|
|
{
|
|
m_eReferentialDisplayMode = eDisplayMode;
|
|
GetInterface() -> GetFrameBase() -> m_oGeneralDialogBar . fn_vUpdateAxisMode( (int) m_eReferentialDisplayMode );
|
|
}
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
tdeDisplayReferential Camera_Interface::GetReferentialDisplayMode()
|
|
{
|
|
return m_eReferentialDisplayMode;
|
|
}
|
|
|
|
// ENDANNECY MT NewInterface }
|
|
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
//================ P R I V A T E ===================================================================
|
|
//==================================================================================================
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
// create an inert camera with its SuperObject and graphic object
|
|
CPA_SuperObject *Camera_Interface::CreateInertCamera(GLI_tdxHandleToCamera hEngineCamera,CString csName,CString csFileName,CString csSectionName)
|
|
{
|
|
Camera *p_oCamera;
|
|
|
|
// create the camera
|
|
if (hEngineCamera == NULL)
|
|
p_oCamera = new Camera(InertCamera,this,GetMainWorld(),csName,csFileName,csSectionName);
|
|
else
|
|
p_oCamera = new Camera(InertCamera,this,GetMainWorld(),hEngineCamera,csName,csFileName,csSectionName);
|
|
|
|
// create SuperObject associated
|
|
return AssociateSuperObject(p_oCamera);
|
|
}
|
|
|
|
|
|
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
//********************************************************************************************************
|
|
// create a superObject, a Geometric superobject and a geometric object for this camera
|
|
CPA_SuperObject *Camera_Interface::AssociateSuperObject(Camera *p_oCamera)
|
|
{
|
|
CPA_SuperObject *p_oCameraSO,*p_oCameraGeom;
|
|
GEO_tdxHandleToMatrix hCameraMatrix,hSOGeomMatrix;
|
|
MTH3D_tdstVector stRelativePos;
|
|
|
|
// create the superobject
|
|
p_oCameraSO = GetInterface()->GetNewSuperObject(E_ss_NoSave,C_Dynamic);
|
|
|
|
// link camera and object
|
|
p_oCameraSO->SetObject(p_oCamera);
|
|
|
|
// sets the SO at the same place that the camera
|
|
// (replace the SO matrix by the camera matrix so that camera and SO have the same matrix)
|
|
hCameraMatrix = p_oCamera->GetCameraMatrix();
|
|
HIE_fn_vSetSuperObjectMatrix ((HIE_tdxHandleToSuperObject) p_oCameraSO->GetData() , hCameraMatrix);
|
|
|
|
// create the camera geometric SuperObject
|
|
p_oCameraGeom = GetInterface()->GetNewSuperObject(E_ss_NoSave,C_Protected);
|
|
p_oCameraGeom->SetEditProtected(TRUE);
|
|
p_oCameraGeom->SetSuperObjectOwner(p_oCameraSO);
|
|
|
|
//move the camera geometric representation back a little bit to avoid auto-selection
|
|
MTH3D_M_vSetVectorElements(&stRelativePos,0,0,(float)-0.05);
|
|
hSOGeomMatrix = HIE_fn_hGetSuperObjectMatrix(p_oCameraGeom->GetStruct());
|
|
POS_fn_vSetTranslationVector(hSOGeomMatrix,&stRelativePos);
|
|
|
|
// link the SO with the geometric object
|
|
p_oCameraGeom->SetObject(m_p_oInertCameraGeomObject);
|
|
|
|
// the geom SO is the son of the camera SO
|
|
p_oCameraSO->AddTail(p_oCameraGeom);
|
|
|
|
return p_oCameraSO;
|
|
}
|
|
//CPA 2 Corneliu Babiuc 30-04-98
|
|
//***********************************************************************************************
|
|
// Method : void Camera_Interface::LoadSlotsPositions(CPA_BaseObject * p_oCamera)
|
|
// Date : 24-03-98
|
|
//***********************************************************************************************
|
|
// Description :
|
|
// Load from .ECA file, camera position and name
|
|
// Parameters:
|
|
// p_oCamera: - pointer to current camera
|
|
// Author : Laurentiu Barza
|
|
// Modification: Corneliu Babiuc 05-05-98
|
|
//***********************************************************************************************
|
|
|
|
//BEGIN CPA2 Laurentiu Barza 24-03-98
|
|
void Camera_Interface::LoadSlotsPositions(CPA_BaseObject * p_oCamera)
|
|
{
|
|
|
|
FILE * fInitialPositionsFile;
|
|
char szName[250];
|
|
char readData[80];
|
|
char readChar;
|
|
|
|
//Stefan Dumitrean 2-07-98 ( slots )
|
|
char szNameEditor[250], szNameSelection[250];
|
|
//End Stefan Dumitrean 2-07-98 ( slots )
|
|
//get the camera slots
|
|
CPA_CameraSlots * p_oSlotCamera = GetMainWorld()->GetWorld()->GetCameraSlots();
|
|
ASSERT(p_oSlotCamera);
|
|
|
|
POS_tdstCompletePosition stSlotMatrix;
|
|
|
|
//construct the ECA file name
|
|
strcpy(szName, fn_szGetLevelsDataPath());
|
|
strcat(szName,"\\");
|
|
strcat(szName,fn_p_szGetLevelName());
|
|
strcat(szName,"\\");
|
|
strcat(szName,fn_p_szGetLevelName());
|
|
strcat(szName,".eca");
|
|
|
|
if((fInitialPositionsFile = fopen(szName, "r")) != NULL)
|
|
{
|
|
while (!feof(fInitialPositionsFile))
|
|
{
|
|
POS_fn_vSetIdentityMatrix(&stSlotMatrix);
|
|
//read camera's description
|
|
if( fscanf(fInitialPositionsFile,"%s %c %[^\"] %c", readData, &readChar, szName, &readChar) <4)
|
|
{ //wrong format
|
|
break;
|
|
}
|
|
// STM - camera's never have scale, so transform mat == rotation matrix
|
|
fscanf(fInitialPositionsFile,"%s %c %f %f %f %c", readData,&readChar,&stSlotMatrix.stTranslationVector.xX,&stSlotMatrix.stTranslationVector.xY,&stSlotMatrix.stTranslationVector.xZ,&readChar );
|
|
fscanf(fInitialPositionsFile,"%s %c %f %f %f %c", readData,&readChar,&stSlotMatrix.stTransformMatrix.stCol_0.xX,&stSlotMatrix.stTransformMatrix.stCol_0.xY,&stSlotMatrix.stTransformMatrix.stCol_0.xZ,&readChar );
|
|
fscanf(fInitialPositionsFile,"%s %f %f %f %c", readData,&stSlotMatrix.stTransformMatrix.stCol_1.xX,&stSlotMatrix.stTransformMatrix.stCol_1.xY,&stSlotMatrix.stTransformMatrix.stCol_1.xZ,&readChar );
|
|
fscanf(fInitialPositionsFile,"%s %f %f %f %c", readData,&stSlotMatrix.stTransformMatrix.stCol_2.xX,&stSlotMatrix.stTransformMatrix.stCol_2.xY,&stSlotMatrix.stTransformMatrix.stCol_2.xZ,&readChar );
|
|
fscanf(fInitialPositionsFile,"%s %c %f %f %f %c", readData,&readChar,&stSlotMatrix.stTransformMatrix.stCol_0.xX,&stSlotMatrix.stTransformMatrix.stCol_0.xY,&stSlotMatrix.stTransformMatrix.stCol_0.xZ,&readChar );
|
|
fscanf(fInitialPositionsFile,"%s %f %f %f %c", readData,&stSlotMatrix.stTransformMatrix.stCol_1.xX,&stSlotMatrix.stTransformMatrix.stCol_1.xY,&stSlotMatrix.stTransformMatrix.stCol_1.xZ,&readChar );
|
|
fscanf(fInitialPositionsFile,"%s %f %f %f %c", readData,&stSlotMatrix.stTransformMatrix.stCol_2.xX,&stSlotMatrix.stTransformMatrix.stCol_2.xY,&stSlotMatrix.stTransformMatrix.stCol_2.xZ,&readChar );
|
|
//Stefan Dumitrean 2-07-98 ( slots )
|
|
fscanf(fInitialPositionsFile,"%s %c %[^\"] %c", readData, &readChar, szNameEditor, &readChar );
|
|
fscanf(fInitialPositionsFile,"%s %c %[^\"] %c", readData, &readChar, szNameSelection, &readChar );
|
|
//End Stefan Dumitrean 2-07-98 ( slots )
|
|
fscanf(fInitialPositionsFile,"%s", readData);
|
|
|
|
//make a copy of camera
|
|
CPA_BaseObject * p_oTempCamera = CopySlotCamera(p_oCamera);
|
|
|
|
//set new camera matrix
|
|
SetMatrix(p_oTempCamera, &stSlotMatrix);
|
|
|
|
//save camera in slot without copy it
|
|
CString csName = szName;
|
|
long lSlotNum = p_oSlotCamera->SaveCameraInSlot(p_oSlotCamera->GetSlotNumber(szName), csName, p_oTempCamera, DontMakeACopy);
|
|
//Stefan Dumitrean 2-07-98 ( slots )
|
|
p_oSlotCamera->SetEditorNameForSlotNr( lSlotNum, szNameEditor );
|
|
p_oSlotCamera->SetSelectionNameForSlotNr( lSlotNum, szNameSelection );
|
|
//End Stefan Dumitrean 2-07-98 ( slots )
|
|
}
|
|
fclose(fInitialPositionsFile);
|
|
}
|
|
else
|
|
{
|
|
// wsprintf(szName, "Error: could not open %s file !", szName);
|
|
// AfxMessageBox( szName, MB_ICONWARNING|MB_OK);
|
|
}
|
|
}
|
|
|
|
//***********************************************************************************************
|
|
// Method : void Camera_Interface::SaveSlotsPositions()
|
|
// Date : 24-03-98
|
|
//***********************************************************************************************
|
|
// Description :
|
|
// Save all non empty slots in an .ECA file
|
|
// Parameters:
|
|
// Author : Laurentiu Barza
|
|
// Modification: Corneliu Babiuc 05-05-98
|
|
//***********************************************************************************************
|
|
void Camera_Interface::SaveSlotsPositions()
|
|
{
|
|
|
|
FILE * fInitialPositionsFile;
|
|
POS_tdstCompletePosition stSlotMatrix;
|
|
CPA_CameraSlots * p_oSlotCamera = GetMainWorld()->GetWorld()->GetCameraSlots();
|
|
ASSERT(p_oSlotCamera);
|
|
|
|
char szName[250];
|
|
char szBuf[250];
|
|
|
|
//construct the ECA file name
|
|
strcpy(szName, fn_szGetLevelsDataPath());
|
|
strcat(szName,"\\");
|
|
strcat(szName,fn_p_szGetLevelName());
|
|
strcat(szName,"\\");
|
|
strcat(szName,fn_p_szGetLevelName());
|
|
strcat(szName,".eca");
|
|
|
|
if((fInitialPositionsFile = fopen(szName, "w")) == NULL)
|
|
{
|
|
wsprintf(szBuf, "Error: could not open the file %s!", szName);
|
|
AfxMessageBox(szBuf, MB_ICONWARNING|MB_OK);
|
|
return;
|
|
}
|
|
|
|
for (long lSlotNum = 0; lSlotNum<p_oSlotCamera->GetTotalSlotsNumber(); lSlotNum++)
|
|
{
|
|
//if slot is empty do nothing
|
|
if (p_oSlotCamera->IsEmpty(lSlotNum)) continue;
|
|
//Stefan Dumitrean 2-07-98 ( slots )
|
|
// do not save reserved slots
|
|
if (p_oSlotCamera->IsSlotReserved(lSlotNum)) continue;
|
|
/*
|
|
//do not save "Copy Of Engine Camera" slot and "Engine Camera Mode"
|
|
if ( p_oSlotCamera->GetSlotName(lSlotNum) == "Copy Of Engine Camera" ||
|
|
p_oSlotCamera->GetSlotName(lSlotNum) == "Engine Camera Mode")
|
|
continue;
|
|
*/
|
|
//End Stefan Dumitrean 2-07-98 ( slots )
|
|
|
|
//try to get camera
|
|
CPA_BaseObject * p_oCamera = p_oSlotCamera->GetCameraFromSlot(lSlotNum, DontMakeACopy);
|
|
if (p_oCamera == NULL) continue;
|
|
|
|
//get the matrix
|
|
POS_fn_vSetIdentityMatrix(&stSlotMatrix);
|
|
GetMatrix(p_oCamera, &stSlotMatrix);
|
|
//save camera's position
|
|
// STM- cameras never have scale, no rotation matrix == transform matrix
|
|
fprintf(fInitialPositionsFile,"\n{NameOfCameraSlot: \"%s\"\n", p_oSlotCamera->GetSlotName(lSlotNum));
|
|
fprintf(fInitialPositionsFile,"TranslationVector: ( %f %f %f )\n\n",stSlotMatrix.stTranslationVector.xX,stSlotMatrix.stTranslationVector.xY,stSlotMatrix.stTranslationVector.xZ);
|
|
fprintf(fInitialPositionsFile,"RotationMatrix: ( %f %f %f )\n",stSlotMatrix.stTransformMatrix.stCol_0.xX,stSlotMatrix.stTransformMatrix.stCol_0.xY,stSlotMatrix.stTransformMatrix.stCol_0.xZ);
|
|
fprintf(fInitialPositionsFile," ( %f %f %f )\n",stSlotMatrix.stTransformMatrix.stCol_1.xX,stSlotMatrix.stTransformMatrix.stCol_1.xY,stSlotMatrix.stTransformMatrix.stCol_1.xZ);
|
|
fprintf(fInitialPositionsFile," ( %f %f %f )\n\n",stSlotMatrix.stTransformMatrix.stCol_2.xX,stSlotMatrix.stTransformMatrix.stCol_2.xY,stSlotMatrix.stTransformMatrix.stCol_2.xZ);
|
|
fprintf(fInitialPositionsFile,"TransformMatrix: ( %f %f %f )\n",stSlotMatrix.stTransformMatrix.stCol_0.xX,stSlotMatrix.stTransformMatrix.stCol_0.xY,stSlotMatrix.stTransformMatrix.stCol_0.xZ);
|
|
fprintf(fInitialPositionsFile," ( %f %f %f )\n",stSlotMatrix.stTransformMatrix.stCol_1.xX,stSlotMatrix.stTransformMatrix.stCol_1.xY,stSlotMatrix.stTransformMatrix.stCol_1.xZ);
|
|
fprintf(fInitialPositionsFile," ( %f %f %f )\n\n",stSlotMatrix.stTransformMatrix.stCol_2.xX,stSlotMatrix.stTransformMatrix.stCol_2.xY,stSlotMatrix.stTransformMatrix.stCol_2.xZ);
|
|
//Stefan Dumitrean 2-07-98 ( slots )
|
|
fprintf(fInitialPositionsFile,"EditorName: \"%s\"\n", p_oSlotCamera->GetEditorNameForSlotNr( lSlotNum ) );
|
|
fprintf(fInitialPositionsFile,"SelectionName: \"%s\"\n", p_oSlotCamera->GetSelectionNameForSlotNr( lSlotNum ) );
|
|
//End Stefan Dumitrean 2-07-98 ( slots )
|
|
fprintf(fInitialPositionsFile,"}\n");
|
|
}
|
|
fclose(fInitialPositionsFile);
|
|
}
|
|
//END CPA2 Laurentiu Barza 24-03-98
|
|
//END CPA2 Corneliu Babiuc 05-05-98
|
|
|
|
/*=========================================================================*/
|
|
/*=========================================================================*/
|
|
void Camera_Interface::ChangeCameraTarget()
|
|
{
|
|
POS_tdstCompletePosition stCameraMatrix;
|
|
MTH3D_tdstVector point;
|
|
CPA_CameraCoords oCoords;
|
|
Camera *p_oCamera;
|
|
|
|
|
|
p_oCamera = (Camera*) GetMainWorld()->GetFRMBase()->m_oGeneralDialogBar.m_p_oCamera;
|
|
|
|
GetMatrix(p_oCamera, &stCameraMatrix);
|
|
point.xX = 0;
|
|
point.xY = 0;
|
|
point.xZ = GetInterface()->GetCameraTargetDepth();
|
|
POS_fn_vMulMatrixVertex(&point, &stCameraMatrix, &point);
|
|
|
|
oCoords.SetXYZ(point.xX, point.xY, point.xZ);
|
|
SetTargetPoint(p_oCamera, &oCoords);
|
|
SetTargetType(p_oCamera,tPoint);
|
|
Update(p_oCamera);
|
|
}
|