| 1 | /* |
| 2 | Copyright (C) 1999-2006 Id Software, Inc. and contributors. |
| 3 | For a list of contributors, see the accompanying CONTRIBUTORS file. |
| 4 | |
| 5 | This file is part of GtkRadiant. |
| 6 | |
| 7 | GtkRadiant is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | GtkRadiant is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with GtkRadiant; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #include "pluginapi.h" |
| 23 | |
| 24 | #include "modulesystem.h" |
| 25 | #include "qerplugin.h" |
| 26 | |
| 27 | #include "generic/callback.h" |
| 28 | #include "math/vector.h" |
| 29 | |
| 30 | #include "gtkmisc.h" |
| 31 | |
| 32 | #include "camwindow.h" |
| 33 | |
| 34 | #include "mainframe.h" |
| 35 | |
| 36 | |
| 37 | // camera API |
| 38 | void QERApp_GetCamera( Vector3& origin, Vector3& angles ){ |
| 39 | CamWnd& camwnd = *g_pParentWnd->GetCamWnd(); |
| 40 | origin = Camera_getOrigin( camwnd ); |
| 41 | angles = Camera_getAngles( camwnd ); |
| 42 | } |
| 43 | |
| 44 | void QERApp_SetCamera( const Vector3& origin, const Vector3& angles ){ |
| 45 | CamWnd& camwnd = *g_pParentWnd->GetCamWnd(); |
| 46 | Camera_setOrigin( camwnd, origin ); |
| 47 | Camera_setAngles( camwnd, angles ); |
| 48 | } |
| 49 | |
| 50 | void QERApp_GetCamWindowExtents( int *x, int *y, int *width, int *height ){ |
| 51 | #if 0 |
| 52 | CamWnd* camwnd = g_pParentWnd->GetCamWnd(); |
| 53 | |
| 54 | gtk_window_get_position( camwnd->m_window, x, y ); |
| 55 | |
| 56 | *width = camwnd->Camera()->width; |
| 57 | *height = camwnd->Camera()->height; |
| 58 | #endif |
| 59 | } |
| 60 | |
| 61 | #include "icamera.h" |
| 62 | |
| 63 | class CameraAPI |
| 64 | { |
| 65 | _QERCameraTable m_camera; |
| 66 | public: |
| 67 | typedef _QERCameraTable Type; |
| 68 | STRING_CONSTANT( Name, "*" ); |
| 69 | |
| 70 | CameraAPI(){ |
| 71 | m_camera.m_pfnGetCamera = &QERApp_GetCamera; |
| 72 | m_camera.m_pfnSetCamera = &QERApp_SetCamera; |
| 73 | m_camera.m_pfnGetCamWindowExtents = &QERApp_GetCamWindowExtents; |
| 74 | } |
| 75 | _QERCameraTable* getTable(){ |
| 76 | return &m_camera; |
| 77 | } |
| 78 | }; |
| 79 | |
| 80 | #include "modulesystem/singletonmodule.h" |
| 81 | #include "modulesystem/moduleregistry.h" |
| 82 | |
| 83 | typedef SingletonModule<CameraAPI> CameraModule; |
| 84 | typedef Static<CameraModule> StaticCameraModule; |
| 85 | StaticRegisterModule staticRegisterCamera( StaticCameraModule::instance() ); |