-/*\r
-Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
-For a list of contributors, see the accompanying CONTRIBUTORS file.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\r
-*/\r
-\r
-/*\r
-Camera plugin for GtkRadiant\r
-Copyright (C) 2002 Splash Damage Ltd.\r
-*/\r
-\r
-#include "camera.h"\r
-\r
-// Render view\r
-CRenderer *Renderer = NULL;\r
-\r
-// Interaction\r
-CListener *Listener = NULL;\r
-\r
-// plugin name\r
-static const char *PLUGIN_NAME = "Camera";\r
-\r
-// commands in the menu\r
-static const char *PLUGIN_COMMANDS = "About...,-,Load Camera...,-,Preview Camera,-,Camera Inspector...,-,New Spline Camera,New Interpolated Camera,New Fixed Camera";\r
-\r
-// globals\r
-GtkWidget *g_pRadiantWnd = NULL;\r
-GtkWidget *g_pCameraInspectorWnd = NULL;\r
-CCamera *firstCam = NULL; // double linked list\r
-CCamera *firstFreeCam = NULL; // single linked list\r
-CCamera *currentCam = NULL; // single item\r
-bool g_bEditOn = false;\r
-int g_iEditMode = 0; // 0: editting points 1: adding points\r
-int g_iActiveTarget = -1;\r
-int g_iPreviewRunning = 0; // 0: no preview 1: start preview 2: preview in progress\r
-\r
-static const char *PLUGIN_ABOUT = "Camera v1.0 for GtkRadiant\n"\r
- "by Arnout van Meer (rr2do2@splashdamage.com)\n\n"\r
- "This product contains software technology\n"\r
- "from id Software, Inc. ('id Technology').\n"\r
- "id Technology (c) 2001, 2002 id Software, Inc.";\r
-\r
-\r
-#include "iplugin.h"\r
-\r
-const char* QERPlug_Init(void* hApp, void* pMainWidget)\r
-{\r
- g_pRadiantWnd = (GtkWidget*)pMainWidget;\r
-\r
- // initialize cams\r
- for( int i = 0; i < MAX_CAMERAS; i++ ) {\r
- if( i == 0 ) { \r
- firstFreeCam = new CCamera( i );\r
- firstCam = firstFreeCam;\r
- } else {\r
- firstCam->SetNext( new CCamera( i ) );\r
- firstCam = firstCam->GetNext();\r
- }\r
- }\r
- firstCam = NULL;\r
-\r
- if( !Renderer )\r
- {\r
- Renderer = new CRenderer;\r
- }\r
-\r
- if( g_pCameraInspectorWnd == NULL )\r
- g_pCameraInspectorWnd = CreateCameraInspectorDialog();\r
-\r
- InitIglToQgl(&g_QglTable);\r
-\r
- GetFileTypeRegistry()->addType("camera", filetype_t("Camera file", "*.camera"));\r
-\r
- return "Camera for GtkRadiant";\r
-}\r
-\r
-const char* QERPlug_GetName()\r
-{\r
- return PLUGIN_NAME;\r
-}\r
-\r
-const char* QERPlug_GetCommandList()\r
-{\r
- return PLUGIN_COMMANDS;\r
-}\r
-\r
-void QERPlug_Dispatch (const char* p, float* vMin, float* vMax, bool bSingleBrush)\r
-{\r
- if( !strcmp( p, "New Fixed Camera" ) )\r
- DoNewFixedCamera();\r
- else if( !strcmp( p, "New Interpolated Camera" ) )\r
- DoNewInterpolatedCamera();\r
- else if( !strcmp( p, "New Spline Camera" ) )\r
- DoNewSplineCamera();\r
- else if( !strcmp( p, "Camera Inspector..." ) )\r
- DoCameraInspector();\r
- else if( !strcmp( p, "Preview Camera" ) )\r
- DoPreviewCamera();\r
- else if( !strcmp( p, "Load Camera..." ) )\r
- DoLoadCamera();\r
- else if( !strcmp( p, "About..." ) )\r
- g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, PLUGIN_ABOUT, "About", MB_OK, NULL );\r
-}\r
-\r
-\r
-// toolbar\r
-\r
-#include "itoolbar.h"\r
-\r
-unsigned int ToolbarButtonCount()\r
-{\r
- return 1;\r
-}\r
-\r
-class CameraInspectorButton : public IToolbarButton\r
-{\r
-public:\r
- virtual const char* getImage() const\r
- {\r
- return "camera_insp.bmp";\r
- }\r
- virtual const char* getText() const\r
- {\r
- return "Inspector";\r
- }\r
- virtual const char* getTooltip() const\r
- {\r
- return "Camera Inspector";\r
- }\r
- virtual void activate() const\r
- {\r
- DoCameraInspector();\r
- }\r
- virtual EType getType() const\r
- {\r
- return eButton;\r
- }\r
-};\r
-\r
-CameraInspectorButton g_camerainspectorbutton;\r
-\r
-const IToolbarButton* GetToolbarButton(unsigned int index)\r
-{\r
- return &g_camerainspectorbutton;\r
-}\r
-\r
-\r
-_QERFuncTable_1 g_FuncTable;\r
-_QERQglTable g_QglTable;\r
-_QERUITable g_UITable;\r
-_QERCameraTable g_CameraTable;\r
-\r
-// =============================================================================\r
-// SYNAPSE\r
-\r
-#include "synapse.h"\r
-\r
-class CameraSynapseClient : public CSynapseClient\r
-{\r
-public:\r
- // CSynapseClient API\r
- bool RequestAPI(APIDescriptor_t *pAPI);\r
- const char* GetInfo();\r
- \r
- CameraSynapseClient() { }\r
- virtual ~CameraSynapseClient() { }\r
-};\r
-\r
-CSynapseServer* g_pSynapseServer = NULL;\r
-CameraSynapseClient g_SynapseClient;\r
-\r
-extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)\r
-{\r
- if (strcmp(version, SYNAPSE_VERSION))\r
- {\r
- Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);\r
- return NULL;\r
- }\r
- g_pSynapseServer = pServer;\r
- g_pSynapseServer->IncRef();\r
- Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());\r
-\r
- g_SynapseClient.AddAPI(TOOLBAR_MAJOR, "camera", sizeof(_QERPlugToolbarTable));\r
- g_SynapseClient.AddAPI(PLUGIN_MAJOR, "camera", sizeof(_QERPluginTable));\r
-\r
- g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);\r
- g_SynapseClient.AddAPI(UI_MAJOR, NULL, sizeof(_QERUITable), SYN_REQUIRE, &g_UITable);\r
- g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(_QERQglTable), SYN_REQUIRE, &g_QglTable);\r
- g_SynapseClient.AddAPI(CAMERA_MAJOR, NULL, sizeof(_QERCameraTable), SYN_REQUIRE, &g_CameraTable);\r
-\r
- return &g_SynapseClient;\r
-}\r
-\r
-bool CameraSynapseClient::RequestAPI(APIDescriptor_t *pAPI)\r
-{\r
- if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR))\r
- {\r
- _QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);\r
-\r
- pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;\r
- pTable->m_pfnGetToolbarButton = &GetToolbarButton;\r
- return true;\r
- }\r
- else if (!strcmp(pAPI->major_name, PLUGIN_MAJOR))\r
- {\r
- _QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);\r
-\r
- pTable->m_pfnQERPlug_Init = QERPlug_Init;\r
- pTable->m_pfnQERPlug_GetName = QERPlug_GetName;\r
- pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;\r
- pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;\r
- return true;\r
- }\r
-\r
- Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());\r
- return false;\r
-}\r
-\r
-#include "version.h"\r
-\r
-const char* CameraSynapseClient::GetInfo()\r
-{\r
- return "Camera plugin v1.0 - Arnout van Meer - built " __DATE__ " " RADIANT_VERSION;\r
-}\r
-\r
-\r
-\r
-//\r
-// CCamera\r
-//\r
-CCamera *AllocCam() {\r
- if( !firstFreeCam )\r
- return( NULL );\r
-\r
- CCamera *cam = firstFreeCam;\r
- firstFreeCam = firstFreeCam->GetNext();\r
- cam->Init();\r
- if( firstCam ) {\r
- cam->SetNext( firstCam );\r
- firstCam->SetPrev( cam );\r
- }\r
- firstCam = cam;\r
-\r
- return( cam );\r
-}\r
-\r
-void FreeCam( CCamera *cam ) {\r
- if( cam->GetPrev() ) {\r
- if( cam->GetNext() ) {\r
- cam->GetPrev()->SetNext( cam->GetNext() );\r
- cam->GetNext()->SetPrev( cam->GetPrev() );\r
- } else {\r
- cam->GetPrev()->SetNext( NULL );\r
- }\r
- } else if( cam->GetNext() ) {\r
- cam->GetNext()->SetPrev( NULL );\r
- firstCam = cam->GetNext();\r
- } else {\r
- firstCam = NULL;\r
- }\r
-\r
- cam->GetCam()->clear();\r
- cam->Init();\r
-\r
- if( firstFreeCam ) {\r
- cam->SetNext( firstFreeCam );\r
- }\r
- firstFreeCam = cam;\r
-}\r
-\r
-void SetCurrentCam( CCamera *cam ) {\r
- currentCam = cam;\r
-}\r
-\r
-CCamera *GetCurrentCam() {\r
- return( currentCam );\r
-}\r
+/*
+Copyright (C) 1999-2007 id Software, Inc. and contributors.
+For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+This file is part of GtkRadiant.
+
+GtkRadiant is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+GtkRadiant is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GtkRadiant; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+/*
+Camera plugin for GtkRadiant
+Copyright (C) 2002 Splash Damage Ltd.
+*/
+
+#include "camera.h"
+
+// Render view
+CRenderer *Renderer = NULL;
+
+// Interaction
+CListener *Listener = NULL;
+
+// plugin name
+static const char *PLUGIN_NAME = "Camera";
+
+// commands in the menu
+static const char *PLUGIN_COMMANDS = "About...,-,Load Camera...,-,Preview Camera,-,Camera Inspector...,-,New Spline Camera,New Interpolated Camera,New Fixed Camera";
+
+// globals
+GtkWidget *g_pRadiantWnd = NULL;
+GtkWidget *g_pCameraInspectorWnd = NULL;
+CCamera *firstCam = NULL; // double linked list
+CCamera *firstFreeCam = NULL; // single linked list
+CCamera *currentCam = NULL; // single item
+bool g_bEditOn = false;
+int g_iEditMode = 0; // 0: editting points 1: adding points
+int g_iActiveTarget = -1;
+int g_iPreviewRunning = 0; // 0: no preview 1: start preview 2: preview in progress
+
+static const char *PLUGIN_ABOUT = "Camera v1.0 for GtkRadiant\n"
+ "by Arnout van Meer (rr2do2@splashdamage.com)\n\n"
+ "This product contains software technology\n"
+ "from id Software, Inc. ('id Technology').\n"
+ "id Technology (c) 2001, 2002 id Software, Inc.";
+
+
+#include "iplugin.h"
+
+const char* QERPlug_Init(void* hApp, void* pMainWidget)
+{
+ g_pRadiantWnd = (GtkWidget*)pMainWidget;
+
+ // initialize cams
+ for( int i = 0; i < MAX_CAMERAS; i++ ) {
+ if( i == 0 ) {
+ firstFreeCam = new CCamera( i );
+ firstCam = firstFreeCam;
+ } else {
+ firstCam->SetNext( new CCamera( i ) );
+ firstCam = firstCam->GetNext();
+ }
+ }
+ firstCam = NULL;
+
+ if( !Renderer )
+ {
+ Renderer = new CRenderer;
+ }
+
+ if( g_pCameraInspectorWnd == NULL )
+ g_pCameraInspectorWnd = CreateCameraInspectorDialog();
+
+ InitIglToQgl(&g_QglTable);
+
+ GetFileTypeRegistry()->addType("camera", filetype_t("Camera file", "*.camera"));
+
+ return "Camera for GtkRadiant";
+}
+
+const char* QERPlug_GetName()
+{
+ return PLUGIN_NAME;
+}
+
+const char* QERPlug_GetCommandList()
+{
+ return PLUGIN_COMMANDS;
+}
+
+void QERPlug_Dispatch (const char* p, float* vMin, float* vMax, bool bSingleBrush)
+{
+ if( !strcmp( p, "New Fixed Camera" ) )
+ DoNewFixedCamera();
+ else if( !strcmp( p, "New Interpolated Camera" ) )
+ DoNewInterpolatedCamera();
+ else if( !strcmp( p, "New Spline Camera" ) )
+ DoNewSplineCamera();
+ else if( !strcmp( p, "Camera Inspector..." ) )
+ DoCameraInspector();
+ else if( !strcmp( p, "Preview Camera" ) )
+ DoPreviewCamera();
+ else if( !strcmp( p, "Load Camera..." ) )
+ DoLoadCamera();
+ else if( !strcmp( p, "About..." ) )
+ g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, PLUGIN_ABOUT, "About", MB_OK, NULL );
+}
+
+
+// toolbar
+
+#include "itoolbar.h"
+
+unsigned int ToolbarButtonCount()
+{
+ return 1;
+}
+
+class CameraInspectorButton : public IToolbarButton
+{
+public:
+ virtual const char* getImage() const
+ {
+ return "camera_insp.bmp";
+ }
+ virtual const char* getText() const
+ {
+ return "Inspector";
+ }
+ virtual const char* getTooltip() const
+ {
+ return "Camera Inspector";
+ }
+ virtual void activate() const
+ {
+ DoCameraInspector();
+ }
+ virtual EType getType() const
+ {
+ return eButton;
+ }
+};
+
+CameraInspectorButton g_camerainspectorbutton;
+
+const IToolbarButton* GetToolbarButton(unsigned int index)
+{
+ return &g_camerainspectorbutton;
+}
+
+
+_QERFuncTable_1 g_FuncTable;
+_QERQglTable g_QglTable;
+_QERUITable g_UITable;
+_QERCameraTable g_CameraTable;
+
+// =============================================================================
+// SYNAPSE
+
+#include "synapse.h"
+
+class CameraSynapseClient : public CSynapseClient
+{
+public:
+ // CSynapseClient API
+ bool RequestAPI(APIDescriptor_t *pAPI);
+ const char* GetInfo();
+
+ CameraSynapseClient() { }
+ virtual ~CameraSynapseClient() { }
+};
+
+CSynapseServer* g_pSynapseServer = NULL;
+CameraSynapseClient g_SynapseClient;
+
+#if __GNUC__ >= 4
+#pragma GCC visibility push(default)
+#endif
+extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
+#if __GNUC__ >= 4
+#pragma GCC visibility pop
+#endif
+ if (strcmp(version, SYNAPSE_VERSION))
+ {
+ Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version);
+ return NULL;
+ }
+ g_pSynapseServer = pServer;
+ g_pSynapseServer->IncRef();
+ Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf());
+
+ g_SynapseClient.AddAPI(TOOLBAR_MAJOR, "camera", sizeof(_QERPlugToolbarTable));
+ g_SynapseClient.AddAPI(PLUGIN_MAJOR, "camera", sizeof(_QERPluginTable));
+
+ g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(_QERFuncTable_1), SYN_REQUIRE, &g_FuncTable);
+ g_SynapseClient.AddAPI(UI_MAJOR, NULL, sizeof(_QERUITable), SYN_REQUIRE, &g_UITable);
+ g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(_QERQglTable), SYN_REQUIRE, &g_QglTable);
+ g_SynapseClient.AddAPI(CAMERA_MAJOR, NULL, sizeof(_QERCameraTable), SYN_REQUIRE, &g_CameraTable);
+
+ return &g_SynapseClient;
+}
+
+bool CameraSynapseClient::RequestAPI(APIDescriptor_t *pAPI)
+{
+ if (!strcmp(pAPI->major_name, TOOLBAR_MAJOR))
+ {
+ _QERPlugToolbarTable* pTable= static_cast<_QERPlugToolbarTable*>(pAPI->mpTable);
+
+ pTable->m_pfnToolbarButtonCount = &ToolbarButtonCount;
+ pTable->m_pfnGetToolbarButton = &GetToolbarButton;
+ return true;
+ }
+ else if (!strcmp(pAPI->major_name, PLUGIN_MAJOR))
+ {
+ _QERPluginTable* pTable= static_cast<_QERPluginTable*>(pAPI->mpTable);
+
+ pTable->m_pfnQERPlug_Init = QERPlug_Init;
+ pTable->m_pfnQERPlug_GetName = QERPlug_GetName;
+ pTable->m_pfnQERPlug_GetCommandList = QERPlug_GetCommandList;
+ pTable->m_pfnQERPlug_Dispatch = QERPlug_Dispatch;
+ return true;
+ }
+
+ Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo());
+ return false;
+}
+
+#include "version.h"
+
+const char* CameraSynapseClient::GetInfo()
+{
+ return "Camera plugin v1.0 - Arnout van Meer - built " __DATE__ " " RADIANT_VERSION;
+}
+
+
+
+//
+// CCamera
+//
+CCamera *AllocCam() {
+ if( !firstFreeCam )
+ return( NULL );
+
+ CCamera *cam = firstFreeCam;
+ firstFreeCam = firstFreeCam->GetNext();
+ cam->Init();
+ if( firstCam ) {
+ cam->SetNext( firstCam );
+ firstCam->SetPrev( cam );
+ }
+ firstCam = cam;
+
+ return( cam );
+}
+
+void FreeCam( CCamera *cam ) {
+ if( cam->GetPrev() ) {
+ if( cam->GetNext() ) {
+ cam->GetPrev()->SetNext( cam->GetNext() );
+ cam->GetNext()->SetPrev( cam->GetPrev() );
+ } else {
+ cam->GetPrev()->SetNext( NULL );
+ }
+ } else if( cam->GetNext() ) {
+ cam->GetNext()->SetPrev( NULL );
+ firstCam = cam->GetNext();
+ } else {
+ firstCam = NULL;
+ }
+
+ cam->GetCam()->clear();
+ cam->Init();
+
+ if( firstFreeCam ) {
+ cam->SetNext( firstFreeCam );
+ }
+ firstFreeCam = cam;
+}
+
+void SetCurrentCam( CCamera *cam ) {
+ currentCam = cam;
+}
+
+CCamera *GetCurrentCam() {
+ return( currentCam );
+}