From 959831f4ef5a3e797f576c3de08cd65032c997ad Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 13 Jan 2013 18:54:10 +1000 Subject: Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard. --- .../examples/16.Quake3MapShader/Makefile | 76 +- .../16.Quake3MapShader/Quake3MapShader.dev | 118 ++-- .../16.Quake3MapShader/Quake3MapShader.vcproj | 266 +++---- .../Quake3MapShader_vc10.vcxproj | 378 +++++----- .../Quake3MapShader_vc11.vcxproj | 386 +++++----- .../16.Quake3MapShader/Quake3MapShader_vc8.vcproj | 380 +++++----- .../16.Quake3MapShader/Quake3MapShader_vc9.vcproj | 376 +++++----- .../examples/16.Quake3MapShader/main.cpp | 776 ++++++++++----------- 8 files changed, 1378 insertions(+), 1378 deletions(-) (limited to 'libraries/irrlicht-1.8/examples/16.Quake3MapShader') diff --git a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Makefile b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Makefile index 952b309..cfe3b45 100644 --- a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Makefile +++ b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Makefile @@ -1,38 +1,38 @@ -# Makefile for Irrlicht Examples -# It's usually sufficient to change just the target name and source file list -# and be sure that CXX is set to a valid compiler -Target = 16.Quake3MapShader -Sources = main.cpp - -# general compiler settings -CPPFLAGS = -I../../include -I/usr/X11R6/include -CXXFLAGS = -O3 -ffast-math -#CXXFLAGS = -g -Wall - -#default target is Linux -all: all_linux - -ifeq ($(HOSTTYPE), x86_64) -LIBSELECT=64 -endif - -# target specific settings -all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../../lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -lXcursor -all_linux clean_linux: SYSTEM=Linux -all_win32: LDFLAGS = -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lm -all_win32 clean_win32: SYSTEM=Win32-gcc -all_win32 clean_win32: SUF=.exe -# name of the binary - only valid for targets which set SYSTEM -DESTPATH = ../../bin/$(SYSTEM)/$(Target)$(SUF) - -all_linux all_win32: - $(warning Building...) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS) - -clean: clean_linux clean_win32 - $(warning Cleaning...) - -clean_linux clean_win32: - @$(RM) $(DESTPATH) - -.PHONY: all all_win32 clean clean_linux clean_win32 +# Makefile for Irrlicht Examples +# It's usually sufficient to change just the target name and source file list +# and be sure that CXX is set to a valid compiler +Target = 16.Quake3MapShader +Sources = main.cpp + +# general compiler settings +CPPFLAGS = -I../../include -I/usr/X11R6/include +CXXFLAGS = -O3 -ffast-math +#CXXFLAGS = -g -Wall + +#default target is Linux +all: all_linux + +ifeq ($(HOSTTYPE), x86_64) +LIBSELECT=64 +endif + +# target specific settings +all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../../lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -lXcursor +all_linux clean_linux: SYSTEM=Linux +all_win32: LDFLAGS = -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lm +all_win32 clean_win32: SYSTEM=Win32-gcc +all_win32 clean_win32: SUF=.exe +# name of the binary - only valid for targets which set SYSTEM +DESTPATH = ../../bin/$(SYSTEM)/$(Target)$(SUF) + +all_linux all_win32: + $(warning Building...) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS) + +clean: clean_linux clean_win32 + $(warning Cleaning...) + +clean_linux clean_win32: + @$(RM) $(DESTPATH) + +.PHONY: all all_win32 clean clean_linux clean_win32 diff --git a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader.dev b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader.dev index 14ebb42..44c58db 100644 --- a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader.dev +++ b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader.dev @@ -1,59 +1,59 @@ -[Project] -FileName=example.dev -Name=Irrlicht Example 16 Quake3 Map Shader -UnitCount=1 -Type=1 -Ver=1 -ObjFiles= -Includes=..\..\include -Libs= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Compiler= -CppCompiler= -Linker=../../lib/Win32-gcc/libIrrlicht.a_@@_ -IsCpp=1 -Icon= -ExeOutput=../../bin/Win32-gcc -ObjectOutput=obj -OverrideOutput=1 -OverrideOutputName=16.Quake3MapShader.exe -HostApplication= -Folders= -CommandLine= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=0000000000000000000000 -UseCustomMakefile=0 -CustomMakefile= - -[Unit1] -FileName=main.cpp -CompileCpp=1 -Folder=Projekt1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion= -FileDescription=Irrlicht Engine example compiled using DevCpp and gcc -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= -AutoIncBuildNr=0 - +[Project] +FileName=example.dev +Name=Irrlicht Example 16 Quake3 Map Shader +UnitCount=1 +Type=1 +Ver=1 +ObjFiles= +Includes=..\..\include +Libs= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Compiler= +CppCompiler= +Linker=../../lib/Win32-gcc/libIrrlicht.a_@@_ +IsCpp=1 +Icon= +ExeOutput=../../bin/Win32-gcc +ObjectOutput=obj +OverrideOutput=1 +OverrideOutputName=16.Quake3MapShader.exe +HostApplication= +Folders= +CommandLine= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000000000000000 +UseCustomMakefile=0 +CustomMakefile= + +[Unit1] +FileName=main.cpp +CompileCpp=1 +Folder=Projekt1 +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Irrlicht Engine example compiled using DevCpp and gcc +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 + diff --git a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader.vcproj b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader.vcproj index de658b3..8592c84 100644 --- a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader.vcproj +++ b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader.vcproj @@ -1,133 +1,133 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc10.vcxproj b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc10.vcxproj index ea09774..c47fc52 100644 --- a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc10.vcxproj +++ b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc10.vcxproj @@ -1,190 +1,190 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - 16.Quake3MapShader - {EB3B38EA-5CE7-4983-845B-880661E69D09} - 16.Quake3MapShader - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\bin\Win32-VisualStudio\ - ..\..\bin\Win64-VisualStudio\ - true - true - ..\..\bin\Win32-VisualStudio\ - ..\..\bin\Win64-VisualStudio\ - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - Disabled - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - Cdecl - - - ..\..\bin\Win32-VisualStudio\16.Quake3MapShader.exe - ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) - true - Console - - - - - - - Disabled - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - Level3 - ProgramDatabase - Cdecl - - - ..\..\bin\Win64-VisualStudio\16.Quake3MapShader.exe - ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) - true - Console - - - - - - - true - Speed - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreaded - false - - - Level3 - - - Cdecl - - - ..\..\bin\Win32-VisualStudio\16.Quake3MapShader.exe - ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) - false - Console - true - true - - - - - - - true - Speed - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreaded - false - - - Level3 - - - Cdecl - - - ..\..\bin\Win64-VisualStudio\16.Quake3MapShader.exe - ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) - false - Console - true - true - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 16.Quake3MapShader + {EB3B38EA-5CE7-4983-845B-880661E69D09} + 16.Quake3MapShader + Win32Proj + + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + true + true + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + Cdecl + + + ..\..\bin\Win32-VisualStudio\16.Quake3MapShader.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + Cdecl + + + ..\..\bin\Win64-VisualStudio\16.Quake3MapShader.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + true + Speed + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + + + Cdecl + + + ..\..\bin\Win32-VisualStudio\16.Quake3MapShader.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + false + Console + true + true + + + + + + + true + Speed + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + + + Cdecl + + + ..\..\bin\Win64-VisualStudio\16.Quake3MapShader.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + false + Console + true + true + + + + + + + + + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc11.vcxproj b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc11.vcxproj index 1bd3735..8b1f1f8 100644 --- a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc11.vcxproj +++ b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc11.vcxproj @@ -1,194 +1,194 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - 16.Quake3MapShader - {EB3B38EA-5CE7-4983-845B-880661E69D09} - 16.Quake3MapShader - Win32Proj - - - - Application - MultiByte - v110 - - - Application - MultiByte - v110 - - - Application - MultiByte - v110 - - - Application - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\bin\Win32-VisualStudio\ - ..\..\bin\Win64-VisualStudio\ - true - true - ..\..\bin\Win32-VisualStudio\ - ..\..\bin\Win64-VisualStudio\ - - - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - Disabled - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - Cdecl - - - ..\..\bin\Win32-VisualStudio\16.Quake3MapShader.exe - ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) - true - Console - - - - - - - Disabled - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - Level3 - ProgramDatabase - Cdecl - - - ..\..\bin\Win64-VisualStudio\16.Quake3MapShader.exe - ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) - true - Console - - - - - - - true - Speed - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreaded - false - - - Level3 - - - Cdecl - - - ..\..\bin\Win32-VisualStudio\16.Quake3MapShader.exe - ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) - false - Console - true - true - - - - - - - true - Speed - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreaded - false - - - Level3 - - - Cdecl - - - ..\..\bin\Win64-VisualStudio\16.Quake3MapShader.exe - ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) - false - Console - true - true - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 16.Quake3MapShader + {EB3B38EA-5CE7-4983-845B-880661E69D09} + 16.Quake3MapShader + Win32Proj + + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + true + true + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + Cdecl + + + ..\..\bin\Win32-VisualStudio\16.Quake3MapShader.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + Cdecl + + + ..\..\bin\Win64-VisualStudio\16.Quake3MapShader.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + true + Speed + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + + + Cdecl + + + ..\..\bin\Win32-VisualStudio\16.Quake3MapShader.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + false + Console + true + true + + + + + + + true + Speed + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + + + Cdecl + + + ..\..\bin\Win64-VisualStudio\16.Quake3MapShader.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + false + Console + true + true + + + + + + + + + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc8.vcproj b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc8.vcproj index 65fc83c..bcde8dc 100644 --- a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc8.vcproj +++ b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc8.vcproj @@ -1,190 +1,190 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc9.vcproj b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc9.vcproj index a533ce0..4728032 100644 --- a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc9.vcproj +++ b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/Quake3MapShader_vc9.vcproj @@ -1,188 +1,188 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/main.cpp b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/main.cpp index 1e5d55e..bd11c95 100644 --- a/libraries/irrlicht-1.8/examples/16.Quake3MapShader/main.cpp +++ b/libraries/irrlicht-1.8/examples/16.Quake3MapShader/main.cpp @@ -1,388 +1,388 @@ -/** Example 016 Quake3 Map Shader Support - -This Tutorial shows how to load a Quake 3 map into the -engine, create a SceneNode for optimizing the speed of -rendering and how to create a user controlled camera. - -Lets start like the HelloWorld example: We include -the irrlicht header files and an additional file to be able -to ask the user for a driver type using the console. -*/ -#include -#include "driverChoice.h" - -/* - define which Quake3 Level should be loaded -*/ -#define IRRLICHT_QUAKE3_ARENA -//#define ORIGINAL_QUAKE3_ARENA -//#define CUSTOM_QUAKE3_ARENA -//#define SHOW_SHADER_NAME - -#ifdef ORIGINAL_QUAKE3_ARENA - #define QUAKE3_STORAGE_FORMAT addFolderFileArchive - #define QUAKE3_STORAGE_1 "/baseq3/" - #ifdef CUSTOM_QUAKE3_ARENA - #define QUAKE3_STORAGE_2 "/cf/" - #define QUAKE3_MAP_NAME "maps/cf.bsp" - #else - #define QUAKE3_MAP_NAME "maps/q3dm8.bsp" - #endif -#endif - -#ifdef IRRLICHT_QUAKE3_ARENA - #define QUAKE3_STORAGE_FORMAT addFileArchive - #define QUAKE3_STORAGE_1 "../../media/map-20kdm2.pk3" - #define QUAKE3_MAP_NAME "maps/20kdm2.bsp" -#endif - -using namespace irr; -using namespace scene; - -/* -Again, to be able to use the Irrlicht.DLL file, we need to link with the -Irrlicht.lib. We could set this option in the project settings, but -to make it easy, we use a pragma comment lib: -*/ -#ifdef _MSC_VER -#pragma comment(lib, "Irrlicht.lib") -#endif - - -/* -A class to produce a series of screenshots -*/ -class CScreenShotFactory : public IEventReceiver -{ -public: - - CScreenShotFactory( IrrlichtDevice *device, const c8 * templateName, ISceneNode* node ) - : Device(device), Number(0), FilenameTemplate(templateName), Node(node) - { - FilenameTemplate.replace ( '/', '_' ); - FilenameTemplate.replace ( '\\', '_' ); - } - - bool OnEvent(const SEvent& event) - { - // check if user presses the key F9 - if ((event.EventType == EET_KEY_INPUT_EVENT) && - event.KeyInput.PressedDown) - { - if (event.KeyInput.Key == KEY_F9) - { - video::IImage* image = Device->getVideoDriver()->createScreenShot(); - if (image) - { - c8 buf[256]; - snprintf(buf, 256, "%s_shot%04d.jpg", - FilenameTemplate.c_str(), - ++Number); - Device->getVideoDriver()->writeImageToFile(image, buf, 85 ); - image->drop(); - } - } - else - if (event.KeyInput.Key == KEY_F8) - { - if (Node->isDebugDataVisible()) - Node->setDebugDataVisible(scene::EDS_OFF); - else - Node->setDebugDataVisible(scene::EDS_BBOX_ALL); - } - } - return false; - } - -private: - IrrlichtDevice *Device; - u32 Number; - core::stringc FilenameTemplate; - ISceneNode* Node; -}; - - -/* -Ok, lets start. -*/ - -int IRRCALLCONV main(int argc, char* argv[]) -{ - /* - Like in the HelloWorld example, we create an IrrlichtDevice with - createDevice(). The difference now is that we ask the user to select - which hardware accelerated driver to use. The Software device would be - too slow to draw a huge Quake 3 map, but just for the fun of it, we make - this decision possible too. - */ - - // ask user for driver - video::E_DRIVER_TYPE driverType=driverChoiceConsole(); - if (driverType==video::EDT_COUNT) - return 1; - - // create device and exit if creation failed - const core::dimension2du videoDim(800,600); - - IrrlichtDevice *device = createDevice(driverType, videoDim, 32, false ); - - if (device == 0) - return 1; // could not create selected driver. - - const char* mapname=0; - if (argc>2) - mapname = argv[2]; - else - mapname = QUAKE3_MAP_NAME; - - /* - Get a pointer to the video driver and the SceneManager so that - we do not always have to write device->getVideoDriver() and - device->getSceneManager(). - */ - video::IVideoDriver* driver = device->getVideoDriver(); - scene::ISceneManager* smgr = device->getSceneManager(); - gui::IGUIEnvironment* gui = device->getGUIEnvironment(); - - //! add our private media directory to the file system - device->getFileSystem()->addFileArchive("../../media/"); - - /* - To display the Quake 3 map, we first need to load it. Quake 3 maps - are packed into .pk3 files, which are nothing other than .zip files. - So we add the .pk3 file to our FileSystem. After it was added, - we are able to read from the files in that archive as they would - directly be stored on disk. - */ - if (argc>2) - device->getFileSystem()->QUAKE3_STORAGE_FORMAT(argv[1]); - else - device->getFileSystem()->QUAKE3_STORAGE_FORMAT(QUAKE3_STORAGE_1); -#ifdef QUAKE3_STORAGE_2 - device->getFileSystem()->QUAKE3_STORAGE_FORMAT(QUAKE3_STORAGE_2); -#endif - - // Quake3 Shader controls Z-Writing - smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); - - /* - Now we can load the mesh by calling getMesh(). We get a pointer returned - to a IAnimatedMesh. As you know, Quake 3 maps are not really animated, - they are only a huge chunk of static geometry with some materials - attached. Hence the IAnimated mesh consists of only one frame, - so we get the "first frame" of the "animation", which is our quake level - and create an Octree scene node with it, using addOctreeSceneNode(). - The Octree optimizes the scene a little bit, trying to draw only geometry - which is currently visible. An alternative to the Octree would be a - AnimatedMeshSceneNode, which would draw always the complete geometry of - the mesh, without optimization. Try it out: Write addAnimatedMeshSceneNode - instead of addOctreeSceneNode and compare the primitives drawn by the - video driver. (There is a getPrimitiveCountDrawed() method in the - IVideoDriver class). Note that this optimization with the Octree is only - useful when drawing huge meshes consisting of lots of geometry. - */ - scene::IQ3LevelMesh* const mesh = - (scene::IQ3LevelMesh*) smgr->getMesh(mapname); - - /* - add the geometry mesh to the Scene ( polygon & patches ) - The Geometry mesh is optimised for faster drawing - */ - scene::ISceneNode* node = 0; - if (mesh) - { - scene::IMesh * const geometry = mesh->getMesh(quake3::E_Q3_MESH_GEOMETRY); - node = smgr->addOctreeSceneNode(geometry, 0, -1, 4096); - } - - // create an event receiver for making screenshots - CScreenShotFactory screenshotFactory(device, mapname, node); - device->setEventReceiver(&screenshotFactory); - - /* - now construct SceneNodes for each Shader - The Objects are stored in the quake mesh scene::E_Q3_MESH_ITEMS - and the Shader ID is stored in the MaterialParameters - mostly dark looking skulls and moving lava.. or green flashing tubes? - */ - if ( mesh ) - { - // the additional mesh can be quite huge and is unoptimized - const scene::IMesh * const additional_mesh = mesh->getMesh(quake3::E_Q3_MESH_ITEMS); - -#ifdef SHOW_SHADER_NAME - gui::IGUIFont *font = device->getGUIEnvironment()->getFont("../../media/fontlucida.png"); - u32 count = 0; -#endif - - for ( u32 i = 0; i!= additional_mesh->getMeshBufferCount(); ++i ) - { - const IMeshBuffer* meshBuffer = additional_mesh->getMeshBuffer(i); - const video::SMaterial& material = meshBuffer->getMaterial(); - - // The ShaderIndex is stored in the material parameter - const s32 shaderIndex = (s32) material.MaterialTypeParam2; - - // the meshbuffer can be rendered without additional support, or it has no shader - const quake3::IShader *shader = mesh->getShader(shaderIndex); - if (0 == shader) - { - continue; - } - - // we can dump the shader to the console in its - // original but already parsed layout in a pretty - // printers way.. commented out, because the console - // would be full... - // quake3::dumpShader ( Shader ); - - node = smgr->addQuake3SceneNode(meshBuffer, shader); - -#ifdef SHOW_SHADER_NAME - count += 1; - core::stringw name( node->getName() ); - node = smgr->addBillboardTextSceneNode( - font, name.c_str(), node, - core::dimension2d(80.0f, 8.0f), - core::vector3df(0, 10, 0)); -#endif - } - } - - /* - Now we only need a Camera to look at the Quake 3 map. And we want to - create a user controlled camera. There are some different cameras - available in the Irrlicht engine. For example the Maya Camera which can - be controlled comparable to the camera in Maya: Rotate with left mouse - button pressed, Zoom with both buttons pressed, translate with right - mouse button pressed. This could be created with - addCameraSceneNodeMaya(). But for this example, we want to create a - camera which behaves like the ones in first person shooter games (FPS). - */ - - scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(); - - /* - so we need a good starting Position in the level. - we can ask the Quake3 Loader for all entities with class_name - "info_player_deathmatch" - we choose a random launch - */ - if ( mesh ) - { - quake3::tQ3EntityList &entityList = mesh->getEntityList(); - - quake3::IEntity search; - search.name = "info_player_deathmatch"; - - s32 index = entityList.binary_search(search); - if (index >= 0) - { - s32 notEndList; - do - { - const quake3::SVarGroup *group = entityList[index].getGroup(1); - - u32 parsepos = 0; - const core::vector3df pos = - quake3::getAsVector3df(group->get("origin"), parsepos); - - parsepos = 0; - const f32 angle = quake3::getAsFloat(group->get("angle"), parsepos); - - core::vector3df target(0.f, 0.f, 1.f); - target.rotateXZBy(angle); - - camera->setPosition(pos); - camera->setTarget(pos + target); - - ++index; -/* - notEndList = ( index < (s32) entityList.size () && - entityList[index].name == search.name && - (device->getTimer()->getRealTime() >> 3 ) & 1 - ); -*/ - notEndList = index == 2; - } while ( notEndList ); - } - } - - /* - The mouse cursor needs not to be visible, so we make it invisible. - */ - - device->getCursorControl()->setVisible(false); - - // load the engine logo - gui->addImage(driver->getTexture("irrlichtlogo2.png"), - core::position2d(10, 10)); - - // show the driver logo - const core::position2di pos(videoDim.Width - 128, videoDim.Height - 64); - - switch ( driverType ) - { - case video::EDT_BURNINGSVIDEO: - gui->addImage(driver->getTexture("burninglogo.png"), pos); - break; - case video::EDT_OPENGL: - gui->addImage(driver->getTexture("opengllogo.png"), pos); - break; - case video::EDT_DIRECT3D8: - case video::EDT_DIRECT3D9: - gui->addImage(driver->getTexture("directxlogo.png"), pos); - break; - } - - /* - We have done everything, so lets draw it. We also write the current - frames per second and the drawn primitives to the caption of the - window. The 'if (device->isWindowActive())' line is optional, but - prevents the engine render to set the position of the mouse cursor - after task switching when other program are active. - */ - int lastFPS = -1; - - while(device->run()) - if (device->isWindowActive()) - { - driver->beginScene(true, true, video::SColor(255,20,20,40)); - smgr->drawAll(); - gui->drawAll(); - driver->endScene(); - - int fps = driver->getFPS(); - //if (lastFPS != fps) - { - io::IAttributes * const attr = smgr->getParameters(); - core::stringw str = L"Q3 ["; - str += driver->getName(); - str += "] FPS:"; - str += fps; - str += " Cull:"; - str += attr->getAttributeAsInt("calls"); - str += "/"; - str += attr->getAttributeAsInt("culled"); - str += " Draw: "; - str += attr->getAttributeAsInt("drawn_solid"); - str += "/"; - str += attr->getAttributeAsInt("drawn_transparent"); - str += "/"; - str += attr->getAttributeAsInt("drawn_transparent_effect"); - - device->setWindowCaption(str.c_str()); - lastFPS = fps; - } - } - - /* - In the end, delete the Irrlicht device. - */ - device->drop(); - - return 0; -} - -/* -**/ +/** Example 016 Quake3 Map Shader Support + +This Tutorial shows how to load a Quake 3 map into the +engine, create a SceneNode for optimizing the speed of +rendering and how to create a user controlled camera. + +Lets start like the HelloWorld example: We include +the irrlicht header files and an additional file to be able +to ask the user for a driver type using the console. +*/ +#include +#include "driverChoice.h" + +/* + define which Quake3 Level should be loaded +*/ +#define IRRLICHT_QUAKE3_ARENA +//#define ORIGINAL_QUAKE3_ARENA +//#define CUSTOM_QUAKE3_ARENA +//#define SHOW_SHADER_NAME + +#ifdef ORIGINAL_QUAKE3_ARENA + #define QUAKE3_STORAGE_FORMAT addFolderFileArchive + #define QUAKE3_STORAGE_1 "/baseq3/" + #ifdef CUSTOM_QUAKE3_ARENA + #define QUAKE3_STORAGE_2 "/cf/" + #define QUAKE3_MAP_NAME "maps/cf.bsp" + #else + #define QUAKE3_MAP_NAME "maps/q3dm8.bsp" + #endif +#endif + +#ifdef IRRLICHT_QUAKE3_ARENA + #define QUAKE3_STORAGE_FORMAT addFileArchive + #define QUAKE3_STORAGE_1 "../../media/map-20kdm2.pk3" + #define QUAKE3_MAP_NAME "maps/20kdm2.bsp" +#endif + +using namespace irr; +using namespace scene; + +/* +Again, to be able to use the Irrlicht.DLL file, we need to link with the +Irrlicht.lib. We could set this option in the project settings, but +to make it easy, we use a pragma comment lib: +*/ +#ifdef _MSC_VER +#pragma comment(lib, "Irrlicht.lib") +#endif + + +/* +A class to produce a series of screenshots +*/ +class CScreenShotFactory : public IEventReceiver +{ +public: + + CScreenShotFactory( IrrlichtDevice *device, const c8 * templateName, ISceneNode* node ) + : Device(device), Number(0), FilenameTemplate(templateName), Node(node) + { + FilenameTemplate.replace ( '/', '_' ); + FilenameTemplate.replace ( '\\', '_' ); + } + + bool OnEvent(const SEvent& event) + { + // check if user presses the key F9 + if ((event.EventType == EET_KEY_INPUT_EVENT) && + event.KeyInput.PressedDown) + { + if (event.KeyInput.Key == KEY_F9) + { + video::IImage* image = Device->getVideoDriver()->createScreenShot(); + if (image) + { + c8 buf[256]; + snprintf(buf, 256, "%s_shot%04d.jpg", + FilenameTemplate.c_str(), + ++Number); + Device->getVideoDriver()->writeImageToFile(image, buf, 85 ); + image->drop(); + } + } + else + if (event.KeyInput.Key == KEY_F8) + { + if (Node->isDebugDataVisible()) + Node->setDebugDataVisible(scene::EDS_OFF); + else + Node->setDebugDataVisible(scene::EDS_BBOX_ALL); + } + } + return false; + } + +private: + IrrlichtDevice *Device; + u32 Number; + core::stringc FilenameTemplate; + ISceneNode* Node; +}; + + +/* +Ok, lets start. +*/ + +int IRRCALLCONV main(int argc, char* argv[]) +{ + /* + Like in the HelloWorld example, we create an IrrlichtDevice with + createDevice(). The difference now is that we ask the user to select + which hardware accelerated driver to use. The Software device would be + too slow to draw a huge Quake 3 map, but just for the fun of it, we make + this decision possible too. + */ + + // ask user for driver + video::E_DRIVER_TYPE driverType=driverChoiceConsole(); + if (driverType==video::EDT_COUNT) + return 1; + + // create device and exit if creation failed + const core::dimension2du videoDim(800,600); + + IrrlichtDevice *device = createDevice(driverType, videoDim, 32, false ); + + if (device == 0) + return 1; // could not create selected driver. + + const char* mapname=0; + if (argc>2) + mapname = argv[2]; + else + mapname = QUAKE3_MAP_NAME; + + /* + Get a pointer to the video driver and the SceneManager so that + we do not always have to write device->getVideoDriver() and + device->getSceneManager(). + */ + video::IVideoDriver* driver = device->getVideoDriver(); + scene::ISceneManager* smgr = device->getSceneManager(); + gui::IGUIEnvironment* gui = device->getGUIEnvironment(); + + //! add our private media directory to the file system + device->getFileSystem()->addFileArchive("../../media/"); + + /* + To display the Quake 3 map, we first need to load it. Quake 3 maps + are packed into .pk3 files, which are nothing other than .zip files. + So we add the .pk3 file to our FileSystem. After it was added, + we are able to read from the files in that archive as they would + directly be stored on disk. + */ + if (argc>2) + device->getFileSystem()->QUAKE3_STORAGE_FORMAT(argv[1]); + else + device->getFileSystem()->QUAKE3_STORAGE_FORMAT(QUAKE3_STORAGE_1); +#ifdef QUAKE3_STORAGE_2 + device->getFileSystem()->QUAKE3_STORAGE_FORMAT(QUAKE3_STORAGE_2); +#endif + + // Quake3 Shader controls Z-Writing + smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); + + /* + Now we can load the mesh by calling getMesh(). We get a pointer returned + to a IAnimatedMesh. As you know, Quake 3 maps are not really animated, + they are only a huge chunk of static geometry with some materials + attached. Hence the IAnimated mesh consists of only one frame, + so we get the "first frame" of the "animation", which is our quake level + and create an Octree scene node with it, using addOctreeSceneNode(). + The Octree optimizes the scene a little bit, trying to draw only geometry + which is currently visible. An alternative to the Octree would be a + AnimatedMeshSceneNode, which would draw always the complete geometry of + the mesh, without optimization. Try it out: Write addAnimatedMeshSceneNode + instead of addOctreeSceneNode and compare the primitives drawn by the + video driver. (There is a getPrimitiveCountDrawed() method in the + IVideoDriver class). Note that this optimization with the Octree is only + useful when drawing huge meshes consisting of lots of geometry. + */ + scene::IQ3LevelMesh* const mesh = + (scene::IQ3LevelMesh*) smgr->getMesh(mapname); + + /* + add the geometry mesh to the Scene ( polygon & patches ) + The Geometry mesh is optimised for faster drawing + */ + scene::ISceneNode* node = 0; + if (mesh) + { + scene::IMesh * const geometry = mesh->getMesh(quake3::E_Q3_MESH_GEOMETRY); + node = smgr->addOctreeSceneNode(geometry, 0, -1, 4096); + } + + // create an event receiver for making screenshots + CScreenShotFactory screenshotFactory(device, mapname, node); + device->setEventReceiver(&screenshotFactory); + + /* + now construct SceneNodes for each Shader + The Objects are stored in the quake mesh scene::E_Q3_MESH_ITEMS + and the Shader ID is stored in the MaterialParameters + mostly dark looking skulls and moving lava.. or green flashing tubes? + */ + if ( mesh ) + { + // the additional mesh can be quite huge and is unoptimized + const scene::IMesh * const additional_mesh = mesh->getMesh(quake3::E_Q3_MESH_ITEMS); + +#ifdef SHOW_SHADER_NAME + gui::IGUIFont *font = device->getGUIEnvironment()->getFont("../../media/fontlucida.png"); + u32 count = 0; +#endif + + for ( u32 i = 0; i!= additional_mesh->getMeshBufferCount(); ++i ) + { + const IMeshBuffer* meshBuffer = additional_mesh->getMeshBuffer(i); + const video::SMaterial& material = meshBuffer->getMaterial(); + + // The ShaderIndex is stored in the material parameter + const s32 shaderIndex = (s32) material.MaterialTypeParam2; + + // the meshbuffer can be rendered without additional support, or it has no shader + const quake3::IShader *shader = mesh->getShader(shaderIndex); + if (0 == shader) + { + continue; + } + + // we can dump the shader to the console in its + // original but already parsed layout in a pretty + // printers way.. commented out, because the console + // would be full... + // quake3::dumpShader ( Shader ); + + node = smgr->addQuake3SceneNode(meshBuffer, shader); + +#ifdef SHOW_SHADER_NAME + count += 1; + core::stringw name( node->getName() ); + node = smgr->addBillboardTextSceneNode( + font, name.c_str(), node, + core::dimension2d(80.0f, 8.0f), + core::vector3df(0, 10, 0)); +#endif + } + } + + /* + Now we only need a Camera to look at the Quake 3 map. And we want to + create a user controlled camera. There are some different cameras + available in the Irrlicht engine. For example the Maya Camera which can + be controlled comparable to the camera in Maya: Rotate with left mouse + button pressed, Zoom with both buttons pressed, translate with right + mouse button pressed. This could be created with + addCameraSceneNodeMaya(). But for this example, we want to create a + camera which behaves like the ones in first person shooter games (FPS). + */ + + scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(); + + /* + so we need a good starting Position in the level. + we can ask the Quake3 Loader for all entities with class_name + "info_player_deathmatch" + we choose a random launch + */ + if ( mesh ) + { + quake3::tQ3EntityList &entityList = mesh->getEntityList(); + + quake3::IEntity search; + search.name = "info_player_deathmatch"; + + s32 index = entityList.binary_search(search); + if (index >= 0) + { + s32 notEndList; + do + { + const quake3::SVarGroup *group = entityList[index].getGroup(1); + + u32 parsepos = 0; + const core::vector3df pos = + quake3::getAsVector3df(group->get("origin"), parsepos); + + parsepos = 0; + const f32 angle = quake3::getAsFloat(group->get("angle"), parsepos); + + core::vector3df target(0.f, 0.f, 1.f); + target.rotateXZBy(angle); + + camera->setPosition(pos); + camera->setTarget(pos + target); + + ++index; +/* + notEndList = ( index < (s32) entityList.size () && + entityList[index].name == search.name && + (device->getTimer()->getRealTime() >> 3 ) & 1 + ); +*/ + notEndList = index == 2; + } while ( notEndList ); + } + } + + /* + The mouse cursor needs not to be visible, so we make it invisible. + */ + + device->getCursorControl()->setVisible(false); + + // load the engine logo + gui->addImage(driver->getTexture("irrlichtlogo2.png"), + core::position2d(10, 10)); + + // show the driver logo + const core::position2di pos(videoDim.Width - 128, videoDim.Height - 64); + + switch ( driverType ) + { + case video::EDT_BURNINGSVIDEO: + gui->addImage(driver->getTexture("burninglogo.png"), pos); + break; + case video::EDT_OPENGL: + gui->addImage(driver->getTexture("opengllogo.png"), pos); + break; + case video::EDT_DIRECT3D8: + case video::EDT_DIRECT3D9: + gui->addImage(driver->getTexture("directxlogo.png"), pos); + break; + } + + /* + We have done everything, so lets draw it. We also write the current + frames per second and the drawn primitives to the caption of the + window. The 'if (device->isWindowActive())' line is optional, but + prevents the engine render to set the position of the mouse cursor + after task switching when other program are active. + */ + int lastFPS = -1; + + while(device->run()) + if (device->isWindowActive()) + { + driver->beginScene(true, true, video::SColor(255,20,20,40)); + smgr->drawAll(); + gui->drawAll(); + driver->endScene(); + + int fps = driver->getFPS(); + //if (lastFPS != fps) + { + io::IAttributes * const attr = smgr->getParameters(); + core::stringw str = L"Q3 ["; + str += driver->getName(); + str += "] FPS:"; + str += fps; + str += " Cull:"; + str += attr->getAttributeAsInt("calls"); + str += "/"; + str += attr->getAttributeAsInt("culled"); + str += " Draw: "; + str += attr->getAttributeAsInt("drawn_solid"); + str += "/"; + str += attr->getAttributeAsInt("drawn_transparent"); + str += "/"; + str += attr->getAttributeAsInt("drawn_transparent_effect"); + + device->setWindowCaption(str.c_str()); + lastFPS = fps; + } + } + + /* + In the end, delete the Irrlicht device. + */ + device->drop(); + + return 0; +} + +/* +**/ -- cgit v1.1