The GtkRadiant sources as originally released under the GPL license.

This commit is contained in:
Travis Bradshaw
2012-01-31 15:20:35 -06:00
commit 0991a5ce8b
1590 changed files with 431941 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

290
contrib/camera/camera.cpp Normal file
View File

@@ -0,0 +1,290 @@
/*
Copyright (C) 1999-2006 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();
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", eMB_OK );
}
// 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;
extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer)
{
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 );
}

View File

@@ -0,0 +1,8 @@
; camera.def : Declares the module parameters for the DLL.
LIBRARY "CAMERA"
DESCRIPTION 'CAMERA Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here
Synapse_EnumerateInterfaces @1

174
contrib/camera/camera.dsp Normal file
View File

@@ -0,0 +1,174 @@
# Microsoft Developer Studio Project File - Name="camera" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=camera - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "camera.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "camera.mak" CFG="camera - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "camera - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "camera - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "camera"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "camera - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAMERA_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I "..\..\libs" /I "..\..\..\gtk2-win32\include\glib-2.0" /I "..\..\..\gtk2-win32\lib\glib-2.0\include" /I "..\..\..\gtk2-win32\lib\gtk-2.0\include" /I "..\..\..\gtk2-win32\include\gtk-2.0" /I "..\..\..\gtk2-win32\include\gtk-2.0\gdk" /I "..\..\..\gtk2-win32\include\pango-1.0" /I "..\..\..\gtk2-win32\include\atk-1.0" /I "..\..\..\stlport\stlport" /I "..\..\..\libxml2\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAMERA_EXPORTS" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 user32.lib synapse.lib glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib /nologo /dll /machine:I386 /def:".\camera.def" /libpath:"../../libs/synapse/release" /libpath:"..\..\..\gtk2-win32\lib"
# SUBTRACT LINK32 /pdb:none
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=Copy to dir...
PostBuild_Cmds=copy Release\camera.dll "../../install/plugins"
# End Special Build Tool
!ELSEIF "$(CFG)" == "camera - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAMERA_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "..\..\libs" /I "..\..\..\gtk2-win32\include\glib-2.0" /I "..\..\..\gtk2-win32\lib\glib-2.0\include" /I "..\..\..\gtk2-win32\lib\gtk-2.0\include" /I "..\..\..\gtk2-win32\include\gtk-2.0" /I "..\..\..\gtk2-win32\include\gtk-2.0\gdk" /I "..\..\..\gtk2-win32\include\pango-1.0" /I "..\..\..\gtk2-win32\include\atk-1.0" /I "..\..\..\stlport\stlport" /I "..\..\..\libxml2\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CAMERA_EXPORTS" /YX /FD /I /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 user32.lib synapse.lib glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib /nologo /dll /debug /machine:I386 /def:".\camera.def" /pdbtype:sept /libpath:"../../libs/synapse/debug" /libpath:"..\..\..\gtk2-win32\lib"
# SUBTRACT LINK32 /pdb:none
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=Copy to dir...
PostBuild_Cmds=copy Debug\camera.dll "../../install/plugins"
# End Special Build Tool
!ENDIF
# Begin Target
# Name "camera - Win32 Release"
# Name "camera - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\camera.cpp
# End Source File
# Begin Source File
SOURCE=.\camera.def
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\dialogs.cpp
# End Source File
# Begin Source File
SOURCE=.\dialogs_common.cpp
# End Source File
# Begin Source File
SOURCE=.\funchandlers.cpp
# End Source File
# Begin Source File
SOURCE=.\listener.cpp
# End Source File
# Begin Source File
SOURCE=.\misc.cpp
# End Source File
# Begin Source File
SOURCE=.\renderer.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\camera.h
# End Source File
# Begin Source File
SOURCE=.\dialogs.h
# End Source File
# Begin Source File
SOURCE=.\funchandlers.h
# End Source File
# Begin Source File
SOURCE=.\listener.h
# End Source File
# Begin Source File
SOURCE=.\misc.h
# End Source File
# Begin Source File
SOURCE=.\renderer.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

165
contrib/camera/camera.h Normal file
View File

@@ -0,0 +1,165 @@
/*
Copyright (C) 1999-2006 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.
*/
#ifndef _CAMERA_H_
#define _CAMERA_H_
typedef unsigned char byte;
#include "mathlib.h"
#include <string.h>
#include "qertypes.h"
#include <stdio.h>
#define USE_QERTABLE_DEFINE
#include "iscenegraph.h"
#include "qerplugin.h"
#define USE_QGLTABLE_DEFINE
#include "igl.h"
extern _QERQglTable __QGLTABLENAME;
#include "iui.h"
#include "icamera.h"
#include "bytebool.h"
class CCamera;
#include <gtk/gtk.h>
#include "str.h"
#include "misc.h"
#include "dialogs.h"
#include "funchandlers.h"
#include "renderer.h"
#include "listener.h"
extern _QERFuncTable_1 g_FuncTable;
extern _QERQglTable g_QglTable;
extern _QERUITable g_UITable;
extern _QERCameraTable g_CameraTable;
extern CRenderer *Renderer;
extern CListener *Listener;
// splinelib
#define CAMERA_PLUGIN
#define DotProduct(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
#include "splines/splines.h"
// this needs to match splines.cpp
#define MAX_CAMERAS 64
extern idCameraDef camera[MAX_CAMERAS];
extern "C" qboolean loadCamera(int camNum, const char *name);
#define PATH_MAX 260
//
// CCamera
//
class CCamera {
public:
CCamera( int i ) {
cam = &camera[i];
camnum = i;
Init();
}
~CCamera();
void Init() {
next = prev = NULL;
fileName[0] = '\0';
hasbeensaved = 0;
}
idCameraDef *GetCam() {
return( cam );
}
int GetCamNum() {
return( camnum );
}
char *GetFileName() {
return( fileName );
}
void SetFileName( const char *name, bool save ) {
strcpy( fileName, name );
if( save )
hasbeensaved = 1;
}
CCamera *GetNext() {
return( next );
}
CCamera *GetPrev() {
return( prev );
}
void SetNext( CCamera *camera ) {
next = camera;
}
void SetPrev( CCamera *camera ) {
prev = camera;
}
int HasBeenSaved() {
return( hasbeensaved );
}
void HasBeenModified() {
if( hasbeensaved )
hasbeensaved = 2;
}
protected:
idCameraDef *cam;
int camnum;
CCamera *next, *prev;
char fileName[PATH_MAX];
int hasbeensaved; // 0:never saved 1:saved 2:saved, but modified
};
CCamera *AllocCam();
void FreeCam( CCamera *cam );
void SetCurrentCam( CCamera *cam );
CCamera *GetCurrentCam();
// globals
extern GtkWidget *g_pRadiantWnd;
extern GtkWidget *g_pCameraInspectorWnd;
extern CCamera *firstCam;
extern bool g_bEditOn;
extern int g_iEditMode;
extern int g_iActiveTarget;
extern int g_iPreviewRunning;
extern CCamera *g_pCurrentEditCam;
#endif // _CAMERA_H_

View File

@@ -0,0 +1,190 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="camera">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\include,..\..\libs,..\..\..\gtk2-win32\include\glib-2.0,..\..\..\gtk2-win32\lib\glib-2.0\include,..\..\..\gtk2-win32\lib\gtk-2.0\include,..\..\..\gtk2-win32\include\gtk-2.0,..\..\..\gtk2-win32\include\gtk-2.0\gdk,..\..\..\gtk2-win32\include\pango-1.0,..\..\..\gtk2-win32\include\atk-1.0,..\..\..\stlport\stlport,..\..\..\libxml2\include"
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;CAMERA_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/camera.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib"
OutputFile=".\Debug/camera.dll"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="../../libs/synapse/debug,..\..\..\gtk2-win32\lib"
ModuleDefinitionFile=".\camera.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/camera.pdb"
ImportLibrary=".\Debug/camera.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/camera.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\include,..\..\libs,..\..\..\gtk2-win32\include\glib-2.0,..\..\..\gtk2-win32\lib\glib-2.0\include,..\..\..\gtk2-win32\lib\gtk-2.0\include,..\..\..\gtk2-win32\include\gtk-2.0,..\..\..\gtk2-win32\include\gtk-2.0\gdk,..\..\..\gtk2-win32\include\pango-1.0,..\..\..\gtk2-win32\include\atk-1.0,..\..\..\stlport\stlport,..\..\..\libxml2\include"
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;CAMERA_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/camera.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="glib-2.0.lib gobject-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib"
OutputFile=".\Release/camera.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="../../libs/synapse/release,..\..\..\gtk2-win32\lib"
ModuleDefinitionFile=".\camera.def"
ProgramDatabaseFile=".\Release/camera.pdb"
ImportLibrary=".\Release/camera.lib"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/camera.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath=".\camera.cpp">
</File>
<File
RelativePath=".\camera.def">
</File>
<File
RelativePath=".\dialogs.cpp">
</File>
<File
RelativePath=".\dialogs_common.cpp">
</File>
<File
RelativePath=".\funchandlers.cpp">
</File>
<File
RelativePath=".\listener.cpp">
</File>
<File
RelativePath=".\misc.cpp">
</File>
<File
RelativePath=".\renderer.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath=".\camera.h">
</File>
<File
RelativePath=".\dialogs.h">
</File>
<File
RelativePath=".\funchandlers.h">
</File>
<File
RelativePath=".\listener.h">
</File>
<File
RelativePath=".\misc.h">
</File>
<File
RelativePath=".\renderer.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

1356
contrib/camera/dialogs.cpp Normal file

File diff suppressed because it is too large Load Diff

37
contrib/camera/dialogs.h Normal file
View File

@@ -0,0 +1,37 @@
/*
Copyright (C) 1999-2006 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.
*/
struct TwinWidget {
GtkWidget* one;
GtkWidget* two;
};
void dialog_button_callback (GtkWidget *widget, gpointer data);
gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data);
//void dialog_button_callback_settex (GtkWidget *widget, gpointer data);
void RefreshCamListCombo( void );
GtkWidget *CreateCameraInspectorDialog( void );

View File

@@ -0,0 +1,51 @@
/*
Copyright (C) 1999-2006 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"
void dialog_button_callback (GtkWidget *widget, gpointer data)
{
GtkWidget *parent;
int *loop, *ret;
parent = gtk_widget_get_toplevel (widget);
loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");
*loop = 0;
*ret = (int)data;
}
gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
{
int *loop;
gtk_widget_hide (widget);
loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");
*loop = 0;
return TRUE;
}

View File

@@ -0,0 +1,269 @@
/*
Copyright (C) 1999-2006 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"
extern GtkWidget *g_pEditModeAddRadioButton;
char* Q_realpath(const char *path, char *resolved_path, size_t size)
{
#if defined (__linux__) || defined (__APPLE__)
return realpath(path, resolved_path);
#else
return _fullpath(resolved_path, path, size);
#endif
}
static void DoNewCamera( idCameraPosition::positionType type )
{
CCamera *cam = AllocCam();
if( cam ) {
char buf[128];
sprintf( buf, "camera%i", cam->GetCamNum() );
cam->GetCam()->startNewCamera( type );
cam->GetCam()->setName( buf );
cam->GetCam()->buildCamera();
sprintf( buf, "Unsaved Camera %i", cam->GetCamNum() );
cam->SetFileName( buf, false );
SetCurrentCam( cam );
RefreshCamListCombo();
// Go to editmode Add
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(g_pEditModeAddRadioButton), TRUE );
// Show the camera inspector
DoCameraInspector();
// Start edit mode (if not initiated by DoCameraInspector)
if( !g_bEditOn )
DoStartEdit( GetCurrentCam() );
} else {
g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, "No free cameras available.", "Create Camera Error", eMB_OK );
}
}
void DoNewFixedCamera()
{
DoNewCamera( idCameraPosition::FIXED );
}
void DoNewInterpolatedCamera()
{
DoNewCamera( idCameraPosition::INTERPOLATED );
}
void DoNewSplineCamera()
{
DoNewCamera( idCameraPosition::SPLINE );
}
void DoCameraInspector()
{
gtk_widget_show( g_pCameraInspectorWnd );
}
void DoPreviewCamera()
{
if( GetCurrentCam() ) {
g_iPreviewRunning = 1;
g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
}
}
void DoLoadCamera()
{
char basepath[PATH_MAX];
if( firstCam && firstCam->HasBeenSaved() )
ExtractFilePath( firstCam->GetFileName(), basepath );
else
strcpy( basepath, g_FuncTable.m_pfnGetGamePath() );
const gchar *filename = g_FuncTable.m_pfnFileDialog( (GtkWidget *)g_pRadiantWnd, TRUE, "Open Camera File", basepath, "camera");
if( filename )
{
CCamera *cam = AllocCam();
char fullpathtofile[PATH_MAX];
if( cam ) {
Q_realpath(filename, fullpathtofile, PATH_MAX);
// see if this camera file was already loaded
CCamera *checkCam = firstCam->GetNext(); // not the first one as we just allocated it
while( checkCam ) {
if( !strcmp( fullpathtofile, checkCam->GetFileName() ) ) {
char error[PATH_MAX+64];
FreeCam( cam );
sprintf( error, "Camera file \'%s\' is already loaded", fullpathtofile );
g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Load error", eMB_OK );
//g_free( filename );
return;
}
checkCam = checkCam->GetNext();
}
if( loadCamera( cam->GetCamNum(), fullpathtofile ) ) {
cam->GetCam()->buildCamera();
cam->SetFileName( filename, true );
SetCurrentCam( cam );
RefreshCamListCombo();
g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
} else {
char error[PATH_MAX+64];
FreeCam( cam );
sprintf( error, "An error occured during the loading of \'%s\'", fullpathtofile );
g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Load error", eMB_OK );
}
//g_free( filename );
} else {
g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, "No free camera slots available", "Load error", eMB_OK );
}
}
}
void DoSaveCamera() {
char basepath[PATH_MAX];
if( !GetCurrentCam() )
return;
if( GetCurrentCam()->GetFileName()[0] )
ExtractFilePath( GetCurrentCam()->GetFileName(), basepath );
else
strcpy( basepath, g_FuncTable.m_pfnGetGamePath() );
const gchar *filename = g_FuncTable.m_pfnFileDialog( g_pRadiantWnd, FALSE, "Save Camera File", basepath, "camera");
if( filename ) {
char fullpathtofile[PATH_MAX + 8];
Q_realpath(filename, fullpathtofile, PATH_MAX);
// File dialog from windows (and maybe the gtk one from radiant) doesn't handle default extensions properly.
// Add extension and check again if file exists
if( strcmp( fullpathtofile + (strlen(fullpathtofile) - 7), ".camera" ) ) {
strcat( fullpathtofile, ".camera" );
if( FileExists( fullpathtofile ) ) {
if( g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, "File already exists.\nOverwrite?", "Save Camera File", eMB_YESNO ) == eIDNO )
return;
}
}
// see if this camera file was already loaded
CCamera *checkCam = firstCam;
while( checkCam ) {
if( checkCam == GetCurrentCam() ) {
checkCam = checkCam->GetNext();
if( !checkCam ) // we only have one camera file opened so no need to check further
break;
} else if( !strcmp( fullpathtofile, checkCam->GetFileName() ) ) {
char error[PATH_MAX+64];
sprintf( error, "Camera file \'%s\' is currently loaded by GtkRadiant.\nPlease select a different filename.", fullpathtofile );
g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Save error", eMB_OK );
return;
}
checkCam = checkCam->GetNext();
}
// FIXME: check for existing directory
GetCurrentCam()->GetCam()->save( fullpathtofile );
GetCurrentCam()->SetFileName( fullpathtofile, true );
RefreshCamListCombo();
}
}
void DoUnloadCamera() {
if( !GetCurrentCam() )
return;
if( !GetCurrentCam()->HasBeenSaved() ) {
char buf[PATH_MAX+64];
sprintf( buf, "Do you want to save the changes for camera '%s'?", GetCurrentCam()->GetCam()->getName() );
if( g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, buf, "Warning", eMB_YESNO ) == eIDYES )
DoSaveCamera();
} else if( GetCurrentCam()->HasBeenSaved() == 2 ) {
char buf[PATH_MAX+64];
sprintf( buf, "Do you want to save the changes made to camera file '%s'?", GetCurrentCam()->GetFileName() );
if( g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, buf, "Warning", eMB_YESNO ) == eIDYES )
DoSaveCamera();
}
if( g_pCurrentEditCam ) {
DoStopEdit();
g_pCurrentEditCam = NULL;
}
FreeCam( GetCurrentCam() );
SetCurrentCam( NULL );
RefreshCamListCombo();
}
CCamera *g_pCurrentEditCam = NULL;
void DoStartEdit( CCamera *cam ) {
if( g_pCurrentEditCam ) {
DoStopEdit();
g_pCurrentEditCam = NULL;
}
if( cam ) {
g_bEditOn = true;
if( !Listener )
Listener = new CListener;
cam->GetCam()->startEdit( g_iActiveTarget < 0 ? true : false );
g_pCurrentEditCam = cam;
g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
}
}
void DoStopEdit( void ) {
g_bEditOn = false;
if( Listener ) {
delete Listener;
Listener = NULL;
}
if( g_pCurrentEditCam ) {
// stop editing on the current cam
g_pCurrentEditCam->GetCam()->stopEdit();
g_pCurrentEditCam = NULL;
g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
}
}

View File

@@ -0,0 +1,37 @@
/*
Copyright (C) 1999-2006 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.
*/
void DoNewFixedCamera();
void DoNewInterpolatedCamera();
void DoNewSplineCamera();
void DoCameraInspector();
void DoPreviewCamera();
void DoLoadCamera();
void DoSaveCamera();
void DoUnloadCamera();
void DoStartEdit( CCamera *cam );
void DoStopEdit( void );

234
contrib/camera/listener.cpp Normal file
View File

@@ -0,0 +1,234 @@
/*
Copyright (C) 1999-2006 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"
CListener::CListener()
{
refCount = 1;
m_bHooked = FALSE;
m_bLeftMBPressed = m_bRightMBPressed = m_bMiddleMBPressed = false;
oldValid = false;
Register();
}
CListener::~CListener()
{
UnRegister();
}
void CListener::Register()
{
g_UITable.m_pfnHookWindow( this );
g_pXYWndWrapper = g_UITable.m_pfnGetXYWndWrapper();
m_bHooked = TRUE;
}
void CListener::UnRegister()
{
if(m_bHooked)
{
g_UITable.m_pfnUnHookWindow( this );
g_pXYWndWrapper= NULL;
m_bHooked = FALSE;
}
}
bool CListener::OnMouseMove( unsigned int nFlags, double x, double y )
{
SetViewType( g_pXYWndWrapper->GetViewType() );
if( m_bLeftMBPressed && oldValid && g_iEditMode == 0 ) {
vec3_t click, delta;
g_pXYWndWrapper->SnapToGrid( (int)x, (int)y, click );
switch( m_vt ) {
case XY:
VectorSet( delta, click[0] - old_x, click[1] - old_y, 0 );
old_x = click[0]; old_y = click[1];
break;
case XZ:
VectorSet( delta, click[0] - old_x, 0, click[2] - old_y );
old_x = click[0]; old_y = click[2];
break;
case YZ:
VectorSet( delta, 0, click[1] - old_x, click[2] - old_y );
old_x = click[1]; old_y = click[2];
break;
}
if( g_iActiveTarget < 0 )
GetCurrentCam()->GetCam()->getPositionObj()->updateSelection( delta[0], delta[1], delta[2] );
else
GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->updateSelection( delta[0], delta[1], delta[2] );
GetCurrentCam()->HasBeenModified();
g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
return true;
}
return false;
}
bool CListener::OnLButtonDown( unsigned int nFlags, double x, double y )
{
SetViewType( g_pXYWndWrapper->GetViewType() );
m_bLeftMBPressed = true;
oldValid = true;
vec3_t org, delta;
g_pXYWndWrapper->SnapToGrid( (int)x, (int)y, org );
switch( m_vt ) {
case XY:
old_x = org[0]; old_y = org[1]; org[2] = 64*1024;
VectorSet( delta, 0, 0, -1 );
break;
case XZ:
old_x = org[0]; old_y = org[2]; org[1] = 64*1024;
VectorSet( delta, 0, -1, 0 );
break;
case YZ:
old_x = org[1]; old_y = org[2]; org[0] = 64*1024;
VectorSet( delta, -1, 0, 0 );
break;
}
if( g_iEditMode == 0 ) {
if( g_iActiveTarget < 0 )
GetCurrentCam()->GetCam()->getPositionObj()->selectPointByRay( org[0], org[1], org[2], delta[0], delta[1], delta[2], true );
else
GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->selectPointByRay( org[0], org[1], org[2], delta[0], delta[1], delta[2], true );
} else if( g_iEditMode == 1 ) {
idVec3 *lastcoord;
idCameraPosition *camera;
if( g_iActiveTarget < 0 ) {
camera = GetCurrentCam()->GetCam()->getPositionObj();
} else {
camera = GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget);
}
if( camera->numPoints() ) {
lastcoord = camera->getPoint( camera->numPoints() -1 );
switch( m_vt ) {
case XY:
camera->addPoint( org[0], org[1], lastcoord->z );
break;
case XZ:
camera->addPoint( org[0], lastcoord->y, org[2] );
break;
case YZ:
camera->addPoint( lastcoord->x, org[1], org[2] );
break;
}
} else {
switch( m_vt ) {
case XY:
camera->addPoint( org[0], org[1], 0 );
break;
case XZ:
camera->addPoint( org[0], 0, org[2] );
break;
case YZ:
camera->addPoint( 0, org[1], org[2] );
break;
}
}
GetCurrentCam()->HasBeenModified();
}
g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
return true;
//return false;
}
bool CListener::OnLButtonUp( unsigned int nFlags, double x, double y )
{
SetViewType( g_pXYWndWrapper->GetViewType() );
m_bLeftMBPressed = false;
oldValid = false;
if( g_iEditMode == 0 ) {
if( g_iActiveTarget < 0 )
GetCurrentCam()->GetCam()->getPositionObj()->deselectAll();
else
GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->deselectAll();
g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
}
return false;
}
bool CListener::OnRButtonDown( unsigned int nFlags, double x, double y )
{
SetViewType( g_pXYWndWrapper->GetViewType() );
m_bRightMBPressed = true;
return false;
}
bool CListener::OnRButtonUp( unsigned int nFlags, double x, double y )
{
SetViewType( g_pXYWndWrapper->GetViewType() );
m_bRightMBPressed = false;
return false;
}
bool CListener::OnMButtonDown( unsigned int nFlags, double x, double y )
{
SetViewType( g_pXYWndWrapper->GetViewType() );
m_bMiddleMBPressed = true;
return false;
}
bool CListener::OnMButtonUp( unsigned int nFlags, double x, double y )
{
SetViewType( g_pXYWndWrapper->GetViewType() );
m_bMiddleMBPressed = false;
return false;
}

64
contrib/camera/listener.h Normal file
View File

@@ -0,0 +1,64 @@
/*
Copyright (C) 1999-2006 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.
*/
class CListener : public IWindowListener
{
public:
bool OnMouseMove(guint32 nFlags, gdouble x, gdouble y);
bool OnLButtonDown(guint32 nFlags, gdouble x, gdouble y);
bool OnMButtonDown(guint32 nFlags, gdouble x, gdouble y);
bool OnRButtonDown(guint32 nFlags, gdouble x, gdouble y);
bool OnLButtonUp(guint32 nFlags, gdouble x, gdouble y);
bool OnMButtonUp(guint32 nFlags, gdouble x, gdouble y);
bool OnRButtonUp(guint32 nFlags, gdouble x, gdouble y);
bool OnKeyPressed(char *s) { return false; }
bool Paint() { return true; }
void Close() { }
void UnRegister();
void Register();
CListener();
virtual ~CListener();
void IncRef() { refCount++; }
void DecRef() { refCount--; if (refCount <= 0) delete this; }
void SetViewType( VIEWTYPE vt ) { if( m_vt != vt ) oldValid = false; m_vt = vt; }
private:
IXYWndWrapper *g_pXYWndWrapper;
bool m_bHooked;
int refCount;
VIEWTYPE m_vt;
// mouse button status
bool m_bLeftMBPressed, m_bRightMBPressed, m_bMiddleMBPressed;
// old mouse coordinates
bool oldValid;
gdouble old_x, old_y;
};

243
contrib/camera/misc.cpp Normal file
View File

@@ -0,0 +1,243 @@
/*
Copyright (C) 1999-2006 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"
void Sys_ERROR( char* text, ... )
{
va_list argptr;
char buf[32768];
va_start (argptr,text);
vsprintf (buf, text,argptr);
va_end (argptr);
Sys_Printf("Camera::ERROR->%s", buf);
}
char* UnixToDosPath( char* path )
{
#ifndef WIN32
return path;
#else
for(char* p = path; *p; p++)
{
if(*p == '/')
*p = '\\';
}
return path;
#endif
}
void ExtractFilePath( const char *path, char *dest )
{
const char *src;
src = path + strlen(path) - 1;
//
// back up until a \ or the start
//
while (src != path && *(src-1) != '/' && *(src-1) != '\\')
src--;
memcpy (dest, path, src-path);
dest[src-path] = 0;
}
const char* ExtractFilename( const char* path )
{
char* p = strrchr(path, '/');
if(!p)
{
p = strrchr(path, '\\');
if(!p)
return path;
}
return ++p;
}
int Q_stricmp (const char *s1, const char *s2) {
return stricmp( s1, s2 );
}
/*
==============
FileExists
==============
*/
bool FileExists (const char *filename)
{
FILE *f;
f = fopen( filename, "r" );
if( !f )
return false;
fclose( f );
return true;
}
//
// command buffer
// empty wrappers, don't really use them here
//
void Cbuf_AddText( const char *text ) {};
void Cbuf_Execute (void) {};
//
// Common
//
void CDECL Com_Error( int level, const char *error, ... )
{
va_list argptr;
char buf[32768];
va_start (argptr,error);
vsprintf (buf, error,argptr);
va_end (argptr);
Sys_Printf("Camera::ERROR->%s", buf);
}
void CDECL Com_Printf( const char* msg, ... )
{
va_list argptr;
char buf[32768];
va_start (argptr,msg);
vsprintf (buf, msg,argptr);
va_end (argptr);
Sys_Printf("Camera::%s", buf);
}
void CDECL Com_DPrintf( const char* msg, ... )
{
#ifdef _DEBUG
va_list argptr;
char buf[32768];
va_start (argptr,msg);
vsprintf (buf, msg,argptr);
va_end (argptr);
Sys_Printf("Camera::%s", buf);
#endif
}
void *Com_Allocate( int bytes ) {
return( malloc( bytes ) );
}
void Com_Dealloc( void *ptr ) {
free( ptr );
}
//
// Filesystem
//
#ifdef WIN32
#pragma warning(disable : 4311)
#pragma warning(disable : 4312)
#endif
int FS_Read( void *buffer, int len, fileHandle_t f ) {
return fread( buffer, len, 1, (FILE *)f );
}
int FS_Write( const void *buffer, int len, fileHandle_t h ) {
return fwrite( buffer, len, 1, (FILE *)h );
}
int FS_ReadFile( const char *qpath, void **buffer ) {
fileHandle_t h;
byte* buf;
int len;
buf = NULL;
len = FS_FOpenFileRead( qpath, &h, qfalse );
if( h == 0 ) {
if ( buffer ) {
*buffer = NULL;
}
return -1;
}
buf = (byte *)Com_Allocate( len + 1 );
*buffer = buf;
FS_Read (buf, len, h);
buf[len] = 0;
FS_FCloseFile( h );
return len;
}
void FS_FreeFile( void *buffer ) {
Com_Dealloc( buffer );
}
int FS_FOpenFileRead( const char *filename, fileHandle_t *file, bool uniqueFILE ) {
FILE *fh;
long len;
fh = fopen( filename, "rb" );
*file = *(fileHandle_t *)&fh;
if( file )
{
fseek (fh, 0, SEEK_END);
len = ftell (fh);
rewind (fh);
return len;
}
else
return -1;
}
fileHandle_t FS_FOpenFileWrite( const char *filename ) {
FILE *fh;
fileHandle_t f;
memset( &f, 0, sizeof(f) );
fh = fopen( filename, "wb" );
f = (fileHandle_t)fh;
return f;
}
void FS_FCloseFile( fileHandle_t f ) {
fclose( (FILE *)f );
}

76
contrib/camera/misc.h Normal file
View File

@@ -0,0 +1,76 @@
/*
Copyright (C) 1999-2006 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.
*/
void Sys_ERROR( char* text, ... );
char* UnixToDosPath( char* path );
void ExtractFilePath( const char *path, char *dest );
const char* ExtractFilename( const char* path );
bool FileExists (const char *filename);
int Q_stricmp (const char *s1, const char *s2);
typedef int fileHandle_t;
extern "C" {
// command buffer
void Cbuf_AddText( const char *text );
void Cbuf_Execute (void);
// common
#ifndef CDECL
#ifdef WIN32
#define CDECL __cdecl
#else
#define CDECL
#endif
#endif
void CDECL Com_Error( int level, const char *error, ... );
void CDECL Com_Printf( const char *msg, ... );
void CDECL Com_DPrintf( const char *msg, ... );
void *Com_Allocate( int bytes );
void Com_Dealloc( void *ptr );
// filesystem
int FS_Read( void *buffer, int len, fileHandle_t f );
int FS_Write( const void *buffer, int len, fileHandle_t h );
int FS_ReadFile( const char *qpath, void **buffer );
void FS_FreeFile( void *buffer );
int FS_FOpenFileRead( const char *filename, fileHandle_t *file, bool uniqueFILE );
fileHandle_t FS_FOpenFileWrite( const char *filename );
void FS_FCloseFile( fileHandle_t f );
}
// vectors
#define DotProduct4(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])
#define VectorSubtract4(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3])
#define VectorAdd4(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3])
#define VectorCopy4(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
#define VectorScale4(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s))
#define VectorMA4(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s),(o)[3]=(v)[3]+(b)[3]*(s))
#define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
#define SnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}

183
contrib/camera/renderer.cpp Normal file
View File

@@ -0,0 +1,183 @@
/*
Copyright (C) 1999-2006 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"
CRenderer::CRenderer() {
refCount = 1;
m_bHooked = FALSE;
Register();
Initialize();
}
CRenderer::~CRenderer() {
if( m_bHooked )
UnRegister();
}
void CRenderer::Register() {
g_QglTable.m_pfnHookGL2DWindow( this );
g_QglTable.m_pfnHookGL3DWindow( this );
m_bHooked = TRUE;
}
void CRenderer::UnRegister() {
if( g_QglTable.m_nSize ) {
g_QglTable.m_pfnUnHookGL2DWindow( this );
g_QglTable.m_pfnUnHookGL3DWindow( this );
}
m_bHooked = FALSE;
}
void CRenderer::Initialize() {
}
void CRenderer::Draw2D( VIEWTYPE vt ) {
g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
g_QglTable.m_pfn_qglPushMatrix();
switch(vt)
{
case XY:
break;
case XZ:
g_QglTable.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
break;
case YZ:
g_QglTable.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
g_QglTable.m_pfn_qglRotatef(270.0f, 0.0f, 0.0f, 1.0f);
break;
}
CCamera *cam = firstCam;
while( cam ) {
cam->GetCam()->draw( ((Listener && cam == g_pCurrentEditCam) ? true : false) );
cam = cam->GetNext();
}
g_QglTable.m_pfn_qglPopMatrix();
g_QglTable.m_pfn_qglPopAttrib();
}
void CRenderer::Draw3D() {
// FIXME: really need a mainloop callback from the editor core
static long start;
static float cycle;
static long msecs;
static long current;
if( g_iPreviewRunning ) {
if( g_iPreviewRunning == 1 ) {
start = Q_QGetTickCount();
GetCurrentCam()->GetCam()->startCamera( start );
cycle = GetCurrentCam()->GetCam()->getTotalTime();
msecs = (long)(cycle * 1000);
current = start;
g_iPreviewRunning = 2;
}
if( current < start + msecs ) {
float fov;
vec3_t origin = {0.0f, 0.0f, 0.0f}, dir = {0.0f, 0.0f, 0.0f}, angles;
GetCurrentCam()->GetCam()->getCameraInfo( current, &origin[0], &dir[0], &fov );
VectorSet( angles, asin (dir[2])*180/3.14159, atan2 (dir[1], dir[0])*180/3.14159, 0 );
g_CameraTable.m_pfnSetCamera( origin, angles );
current = Q_QGetTickCount();
} else {
g_iPreviewRunning = 0;
GetCurrentCam()->GetCam()->setRunning( false );
g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
}
}
g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
CCamera *cam = firstCam;
while( cam ) {
cam->GetCam()->draw( ((Listener && cam == g_pCurrentEditCam) ? true : false) );
cam = cam->GetNext();
}
if( g_iPreviewRunning ) {
int x, y, width, height, i;
float degInRad;
g_CameraTable.m_pfnGetCamWindowExtents( &x, &y, &width, &height );
// setup orthographic projection mode
g_QglTable.m_pfn_qglMatrixMode(GL_PROJECTION);
g_QglTable.m_pfn_qglLoadIdentity();
g_QglTable.m_pfn_qglDisable( GL_DEPTH_TEST );
g_QglTable.m_pfn_qglOrtho( 0, (float)width, 0, (float)height, -100, 100 );
g_QglTable.m_pfn_qglMatrixMode( GL_MODELVIEW );
g_QglTable.m_pfn_qglLoadIdentity();
g_QglTable.m_pfn_qglColor3f( 1.f, 1.f, 1.f );
g_QglTable.m_pfn_qglBegin( GL_LINE_LOOP );
g_QglTable.m_pfn_qglVertex2f( 10, 10 );
g_QglTable.m_pfn_qglVertex2f( 40, 10 );
g_QglTable.m_pfn_qglVertex2f( 40, 25 );
g_QglTable.m_pfn_qglVertex2f( 10, 25 );
g_QglTable.m_pfn_qglEnd();
g_QglTable.m_pfn_qglBegin( GL_LINE_LOOP );
for( i = 0; i < 360; i += 60 ) {
degInRad = i * (3.14159265358979323846/180.f);
g_QglTable.m_pfn_qglVertex2f( 18 + cos(degInRad) * 5, 18 + sin(degInRad) * 5 );
}
g_QglTable.m_pfn_qglEnd();
degInRad = (360-((current - start) % 360)) * (3.14159265358979323846/180.f);
g_QglTable.m_pfn_qglBegin( GL_LINES );
g_QglTable.m_pfn_qglVertex2f( 18, 18 );
g_QglTable.m_pfn_qglVertex2f( 18 + cos(degInRad) * 5, 18 + sin(degInRad) * 5 );
g_QglTable.m_pfn_qglVertex2f( 32, 18 );
g_QglTable.m_pfn_qglVertex2f( 32 + cos(degInRad) * 5, 18 + sin(degInRad) * 5 );
g_QglTable.m_pfn_qglEnd();
g_QglTable.m_pfn_qglBegin( GL_LINE_LOOP );
for( i = 0; i < 360; i += 60 ) {
degInRad = i * (3.14159265358979323846/180.f);
g_QglTable.m_pfn_qglVertex2f( 32 + cos(degInRad) * 5, 18 + sin(degInRad) * 5 );
}
g_QglTable.m_pfn_qglEnd();
g_QglTable.m_pfn_qglBegin( GL_LINES );
g_QglTable.m_pfn_qglVertex2f( 40, 22 );
g_QglTable.m_pfn_qglVertex2f( 52, 31 );
g_QglTable.m_pfn_qglVertex2f( 40, 13 );
g_QglTable.m_pfn_qglVertex2f( 52, 4 );
g_QglTable.m_pfn_qglEnd();
}
g_QglTable.m_pfn_qglPopAttrib();
}

46
contrib/camera/renderer.h Normal file
View File

@@ -0,0 +1,46 @@
/*
Copyright (C) 1999-2006 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.
*/
class CRenderer : public IGL2DWindow, public IGL3DWindow {
public:
CRenderer();
virtual ~CRenderer();
protected:
int refCount;
public:
void Register();
void UnRegister();
void Initialize();
void Draw2D( VIEWTYPE vt );
void Draw3D();
void IncRef() { refCount++; }
void DecRef() { refCount--; if (refCount <= 0) delete this; }
bool m_bHooked;
};