From 24ac9fa75cea5b27be7ceb8498a77bfb94cd745a Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Wed, 2 Dec 2015 17:24:35 +0500 Subject: [PATCH 01/10] Fixed issues with projects for editors + deleted empty .todo file --- .../ActorEditor/ActorEditor.vcxproj.filters | 30 +++++++------- src/editors/ECore/ECore.vcxproj | 7 ++-- src/editors/LevelEditor/LevelEditor.vcxproj | 2 +- src/editors/PPEditor/PPEditor.vcxproj.filters | 34 ++++++++-------- .../ParticleEditor/ParticleEditor.todo | 3 -- .../ParticleEditor.vcxproj.filters | 39 ++++++++++--------- .../ShaderEditor/ShaderEditor.vcxproj.filters | 36 ++++++++--------- src/editors/xrEProps/xrEProps.vcxproj.filters | 32 +++++++-------- 8 files changed, 91 insertions(+), 92 deletions(-) delete mode 100644 src/editors/ParticleEditor/ParticleEditor.todo diff --git a/src/editors/ActorEditor/ActorEditor.vcxproj.filters b/src/editors/ActorEditor/ActorEditor.vcxproj.filters index cb07dab7fbc..0aa182e9d5e 100644 --- a/src/editors/ActorEditor/ActorEditor.vcxproj.filters +++ b/src/editors/ActorEditor/ActorEditor.vcxproj.filters @@ -1,7 +1,7 @@  - + {9a41bbda-99f4-484a-ba8a-63332bf95144} @@ -10,46 +10,46 @@ - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles - Sourse FIles + Source FIles diff --git a/src/editors/ECore/ECore.vcxproj b/src/editors/ECore/ECore.vcxproj index 81102d93f84..2f1d257844c 100644 --- a/src/editors/ECore/ECore.vcxproj +++ b/src/editors/ECore/ECore.vcxproj @@ -13,17 +13,18 @@ ECore {226C6807-BB48-4A07-BF13-806C38FD8FBE} - all_editors_vs + ECore + 8.1 - Application + DynamicLibrary v140 MultiByte true - Application + DynamicLibrary v140 MultiByte diff --git a/src/editors/LevelEditor/LevelEditor.vcxproj b/src/editors/LevelEditor/LevelEditor.vcxproj index 2e46eeb74ad..e0f978610db 100644 --- a/src/editors/LevelEditor/LevelEditor.vcxproj +++ b/src/editors/LevelEditor/LevelEditor.vcxproj @@ -16,7 +16,7 @@ {136857E3-D61B-4A03-A4E9-7F73ED946C41} - le + LevelEditor diff --git a/src/editors/PPEditor/PPEditor.vcxproj.filters b/src/editors/PPEditor/PPEditor.vcxproj.filters index 331c50360a4..23cf44d9439 100644 --- a/src/editors/PPEditor/PPEditor.vcxproj.filters +++ b/src/editors/PPEditor/PPEditor.vcxproj.filters @@ -1,7 +1,7 @@  - + {4b107126-daf8-4e83-8c10-927a98db0fa2} @@ -13,52 +13,52 @@ - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files diff --git a/src/editors/ParticleEditor/ParticleEditor.todo b/src/editors/ParticleEditor/ParticleEditor.todo deleted file mode 100644 index 2cbeb983387..00000000000 --- a/src/editors/ParticleEditor/ParticleEditor.todo +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/editors/ParticleEditor/ParticleEditor.vcxproj.filters b/src/editors/ParticleEditor/ParticleEditor.vcxproj.filters index 2640e606c77..b0979a0b713 100644 --- a/src/editors/ParticleEditor/ParticleEditor.vcxproj.filters +++ b/src/editors/ParticleEditor/ParticleEditor.vcxproj.filters @@ -4,7 +4,7 @@ {8da7d59b-5d35-461d-97b7-be4ed3a53514} - + {0c4f66eb-44e1-4e1e-8d6c-179a6b593c9b} @@ -55,58 +55,58 @@ - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files Other @@ -117,5 +117,6 @@ Other + \ No newline at end of file diff --git a/src/editors/ShaderEditor/ShaderEditor.vcxproj.filters b/src/editors/ShaderEditor/ShaderEditor.vcxproj.filters index 364bb0c6123..a77cd917fbf 100644 --- a/src/editors/ShaderEditor/ShaderEditor.vcxproj.filters +++ b/src/editors/ShaderEditor/ShaderEditor.vcxproj.filters @@ -1,7 +1,7 @@  - + {616336c3-6a56-4dfa-8a68-d598fa32370d} @@ -14,55 +14,55 @@ - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files diff --git a/src/editors/xrEProps/xrEProps.vcxproj.filters b/src/editors/xrEProps/xrEProps.vcxproj.filters index 81c6a89aaf1..8cc02189347 100644 --- a/src/editors/xrEProps/xrEProps.vcxproj.filters +++ b/src/editors/xrEProps/xrEProps.vcxproj.filters @@ -4,49 +4,49 @@ - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files - Sourse Files + Source Files @@ -98,7 +98,7 @@ {50486bfa-36dd-444a-97ff-3085cfb2a95d} - + {23fbccf4-abd0-49ce-b6e5-6eb563ebe033} From 7ee425c2388479a123bad7141980aeaee6996e68 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 4 Dec 2015 06:28:00 +0500 Subject: [PATCH 02/10] Some fixes for Borland project files --- src/all_editors.bpg | 6 +- src/editors/ActorEditor/ActorEditor.bpr | 256 ++++----- src/editors/ECore/xrECoreB.bpr | 506 ++++++++++-------- src/editors/LevelEditor/LevelEditor.bpr | 396 ++++++++------ src/editors/PPEditor/Postprocess.bpr | 100 ++-- src/editors/ParticleEditor/ParticleEditor.bpr | 180 ++++--- src/editors/ShaderEditor/ShaderEditor.bpr | 183 ++++--- src/editors/xrEProps/xrEPropsB.bpr | 155 +++--- src/xrCore/xrCoreB.bpr | 311 +++++------ src/xrParticles/xrParticlesB.bpr | 129 ++--- src/xrSound/xrSoundB.bpr | 102 ++-- 11 files changed, 1242 insertions(+), 1082 deletions(-) diff --git a/src/all_editors.bpg b/src/all_editors.bpg index 79a8b2348d8..ad131304349 100644 --- a/src/all_editors.bpg +++ b/src/all_editors.bpg @@ -10,7 +10,7 @@ DCC = $(ROOT)\bin\dcc32.exe $** BRCC = $(ROOT)\bin\brcc32.exe $** #------------------------------------------------------------------------------ PROJECTS = xrCoreB.dll xrSoundB.dll xrParticlesB.dll xrEPropsB.dll xrECoreB.dll \ - ActorEditor.exe ParticleEditor.exe ShaderEditor.exe LevelEditor.exe + ActorEditor.exe ParticleEditor.exe PostprocessEditor.exe ShaderEditor.exe LevelEditor.exe #------------------------------------------------------------------------------ default: $(PROJECTS) #------------------------------------------------------------------------------ @@ -43,6 +43,10 @@ ParticleEditor.exe: editors\ParticleEditor\ParticleEditor.bpr $(ROOT)\bin\bpr2mak $** $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak +PostprocessEditor.exe: editors\PPEditor\Postprocess.bpr + $(ROOT)\bin\bpr2mak $** + $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak + ShaderEditor.exe: editors\ShaderEditor\ShaderEditor.bpr $(ROOT)\bin\bpr2mak $** $(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak diff --git a/src/editors/ActorEditor/ActorEditor.bpr b/src/editors/ActorEditor/ActorEditor.bpr index 88635ac3beb..8e9b7c7b1aa 100644 --- a/src/editors/ActorEditor/ActorEditor.bpr +++ b/src/editors/ActorEditor/ActorEditor.bpr @@ -3,21 +3,28 @@ - - + + @@ -28,7 +35,7 @@ - + @@ -38,25 +45,26 @@ - - + + - + - + - + @@ -101,7 +109,7 @@ AutoIncBuild=1 MajorVer=1 MinorVer=0 Release=2 -Build=169 +Build=170 Debug=1 PreRelease=0 Special=0 @@ -113,7 +121,7 @@ CodePage=1252 [Version Info Keys] CompanyName= FileDescription= -FileVersion=1.0.2.169 +FileVersion=1.0.2.170 InternalName= LegalCopyright= LegalTrademarks= @@ -124,78 +132,79 @@ Comments= [HistoryLists\hlIncludePath] Count=30 -Item0=..\..;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrCPU_Pipe -Item1=$(VC_INCLUDE);..\..;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrCPU_Pipe -Item2=..\..;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrCPU_Pipe;..\..\xrRender -Item3=..\..\Layers\xrRender;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrCPU_Pipe;..\..\xrRender -Item4=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrCPU_Pipe;..\..\xrRender -Item5=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender -Item6=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrEngine\xrCPU_Pipe -Item7=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine\xrCPU_Pipe -Item8=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR) -Item9=$(CORE_DIR);$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source -Item10=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source -Item11=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps -Item12=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps -Item13=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\Tools\Etools -Item14=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\Tools\Etools -Item15=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\Tools\Etools -Item16=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\Tools\Etools -Item17=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps -Item18=r:\borland\components6\alexmx;R:\SDK\DirectX9.0_beta3\Include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps -Item19=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps -Item20=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals -Item21=..\ShaderEditor;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals -Item22=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;P:\Editors\EACTOREDITOR -Item23=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;editor -Item24=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals -Item25=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine -Item26=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore -Item27=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound -Item28=Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound -Item29=Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore +Item0=..\..;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine +Item1=..\..;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrCPU_Pipe +Item2=$(VC_INCLUDE);..\..;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrCPU_Pipe +Item3=..\..;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrCPU_Pipe;..\..\xrRender +Item4=..\..\Layers\xrRender;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrCPU_Pipe;..\..\xrRender +Item5=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrCPU_Pipe;..\..\xrRender +Item6=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender +Item7=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine;..\..\xrEngine\xrCPU_Pipe +Item8=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);..\..\xrEngine\xrCPU_Pipe +Item9=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR) +Item10=$(CORE_DIR);$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source +Item11=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source +Item12=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps +Item13=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps +Item14=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\Tools\Etools +Item15=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\Tools\Etools +Item16=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\Tools\Etools +Item17=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\Tools\Etools +Item18=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps +Item19=r:\borland\components6\alexmx;R:\SDK\DirectX9.0_beta3\Include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps +Item20=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps +Item21=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals +Item22=..\ShaderEditor;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals +Item23=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;P:\Editors\EACTOREDITOR +Item24=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;editor +Item25=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals +Item26=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine +Item27=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore +Item28=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound +Item29=Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound [HistoryLists\hlLibraryPath] Count=30 -Item0=..\..;..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) -Item1=..\..;..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source -Item2=..\..;..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries -Item3=..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries -Item4=..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries -Item5=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries -Item6=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries -Item7=C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor -Item8=..\ShaderEditor;..\ECore;C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore\Editor -Item9=..\ECore;C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore\Editor -Item10=..\ECore;C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\ -Item11=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\ -Item12=Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\ -Item13=Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;x:\;..\lib\dx;..\lib -Item14=Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;x:;..\lib\dx;..\lib -Item15=Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib -Item16=lib;Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib;..\lib\dx -Item17=Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib;..\lib\dx -Item18=Engine\Animations;Engine\BLENDERS;lib;lib\DX;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source -Item19=Engine\Animations;Engine\BLENDERS;lib;lib\DX;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\Components\Eldos\Code -Item20=Engine\Animations;Engine\BLENDERS;lib;lib\DX;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx\;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\Components\Eldos\Code\ -Item21=Engine\Animations;Engine\BLENDERS;c:\rad\borland\CBuilder5\Projects\;lib;lib\DX;engine;editor;shared;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ -Item22=Engine\BLENDERS;c:\rad\borland\CBuilder5\Projects\;lib;lib\DX;engine;editor;shared;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ -Item23=c:\rad\borland\CBuilder5\Projects\;lib;lib\DX;engine;editor;shared;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ -Item24=c:\rad\borland\CBuilder5\Projects;lib;lib\DX;engine;editor;shared;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ -Item25=lib;lib\DX;engine;editor;shared;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx;R:\Borland\Components\Eldos\Code\Source;R:\Borland\Components\Eldos\Code -Item26=r:\borland\components\alexmx;editor;lib;lib\X;engine;engin;eng;en;e;lib\DX;c:\rad\Borland\CBuilder5\Bin\;c:\rad\borland\CBuilder5\Projects\;shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ -Item27=lib;lib\X;engine;engin;eng;en;e;lib\DX;c:\rad\Borland\CBuilder5\Bin\;c:\rad\borland\CBuilder5\Projects\;shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ -Item28=engine;engin;eng;en;e;lib\DX;c:\rad\Borland\CBuilder5\Bin\;c:\rad\borland\CBuilder5\Projects\;shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ -Item29=engine;engin;eng;en\;e\;lib\DX;c:\rad\Borland\CBuilder5\Bin\;c:\rad\borland\CBuilder5\Projects\;shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ +Item0=..\..\..\sdk\components\AlexMX;..\..\..\sdk\components\ElPack\Code;..\..\..\sdk\components\ElPack\Code\Source;..\..;..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(OUT_LIB_DIR) +Item1=..\..\..\sdk\components\AlexMX;..\..\..\sdk\components\ElPack\Code;..\..\..\sdk\components\ElPack\Code\Source;..\..\;..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(OUT_LIB_DIR) +Item2=..\..\..\sdk\components\ElPack\Code;..\..;..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) +Item3=..\..;..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) +Item4=..\..;..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source +Item5=..\..;..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries +Item6=..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries +Item7=..\..\Layers\xrRender;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries +Item8=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries +Item9=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries +Item10=C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor +Item11=..\ShaderEditor;..\ECore;C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore\Editor +Item12=..\ECore;C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore\Editor +Item13=..\ECore;C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\ +Item14=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\ +Item15=Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\ +Item16=Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;x:\;..\lib\dx;..\lib +Item17=Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;x:;..\lib\dx;..\lib +Item18=Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib +Item19=lib;Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib;..\lib\dx +Item20=Engine\Animations;Engine\BLENDERS;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib;..\lib\dx +Item21=Engine\Animations;Engine\BLENDERS;lib;lib\DX;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source +Item22=Engine\Animations;Engine\BLENDERS;lib;lib\DX;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\Components\Eldos\Code +Item23=Engine\Animations;Engine\BLENDERS;lib;lib\DX;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx\;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\Components\Eldos\Code\ +Item24=Engine\Animations;Engine\BLENDERS;c:\rad\borland\CBuilder5\Projects\;lib;lib\DX;engine;editor;shared;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ +Item25=Engine\BLENDERS;c:\rad\borland\CBuilder5\Projects\;lib;lib\DX;engine;editor;shared;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ +Item26=c:\rad\borland\CBuilder5\Projects\;lib;lib\DX;engine;editor;shared;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ +Item27=c:\rad\borland\CBuilder5\Projects;lib;lib\DX;engine;editor;shared;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ +Item28=lib;lib\DX;engine;editor;shared;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx;R:\Borland\Components\Eldos\Code\Source;R:\Borland\Components\Eldos\Code +Item29=r:\borland\components\alexmx;editor;lib;lib\X;engine;engin;eng;en;e;lib\DX;c:\rad\Borland\CBuilder5\Bin\;c:\rad\borland\CBuilder5\Projects\;shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ [HistoryLists\hlDebugSourcePath] -Count=6 -Item0=$(COMPONENTS)\AlexMX\ -Item1=c:\rad\borland\cbuilder5\source\vcl;R:\Borland\Components6\AlexMX\ -Item2=c:\rad\borland\cbuilder5\source\vcl;R:\Borland\Components6\AlexMX\;..\ECore\Editor -Item3=c:\rad\borland\cbuilder5\source\vcl -Item4=c:\rad\borland\cbuilder5\source\vcl;P:\Editor\QHull\ -Item5=$(BCB)\source\vcl +Count=7 +Item0=..\..\..\sdk\components\AlexMX\ +Item1=$(COMPONENTS)\AlexMX\ +Item2=c:\rad\borland\cbuilder5\source\vcl;R:\Borland\Components6\AlexMX\ +Item3=c:\rad\borland\cbuilder5\source\vcl;R:\Borland\Components6\AlexMX\;..\ECore\Editor +Item4=c:\rad\borland\cbuilder5\source\vcl +Item5=c:\rad\borland\cbuilder5\source\vcl;P:\Editor\QHull\ +Item6=$(BCB)\source\vcl [HistoryLists\hlConditionals] Count=12 @@ -213,37 +222,44 @@ Item10=_DEBUG;_ED Item11=_DEBUG [HistoryLists\hlIntOutputDir] -Count=4 -Item0=x:\intermediate_ed\ae -Item1=$(OUTPUT_INTERMEDIATE_DIR)\ae -Item2=Intermediate -Item3=ActorEditor +Count=7 +Item0=..\..\..\intermediate\editors\ActorEditor +Item1=..\..\..\intermediate\ActorEditor +Item2=..\..\..\intermediate\ActorEditor\ +Item3=x:\intermediate_ed\ae +Item4=$(OUTPUT_INTERMEDIATE_DIR)\ae +Item5=Intermediate +Item6=ActorEditor [HistoryLists\hlFinalOutputDir] -Count=13 -Item0=$(OUTPUT_BINARIES_DIR)\ -Item1=x:\stalker_addon\binaries\ -Item2=x:\binaries\ -Item3=x:\binaries -Item4=x:\ -Item5=x:\build\ -Item6=x:\build -Item7=u:\preliminary\ -Item8=u:\preliminary -Item9=s:\bin\ -Item10=s:\bin -Item11=!run\ -Item12=P:\Editor\!run +Count=15 +Item0=..\..\..\bin\editors\ +Item1=..\..\..\bin\editors +Item2=$(OUTPUT_BINARIES_DIR)\ +Item3=x:\stalker_addon\binaries\ +Item4=x:\binaries\ +Item5=x:\binaries +Item6=x:\ +Item7=x:\build\ +Item8=x:\build +Item9=u:\preliminary\ +Item10=u:\preliminary +Item11=s:\bin\ +Item12=s:\bin +Item13=!run\ +Item14=P:\Editor\!run [HistoryLists\hIBPIOutputDir] -Count=4 -Item0=x:\stalker_addon\libraries -Item1=$(OUTPUT_LIBRARIES_DIR) -Item2=$(OUTPUT_LIBRARIES_DIR)\ -Item3=x:\libraries +Count=6 +Item0=..\..\..\lib\editors +Item1=..\..\..\lib\editors\ +Item2=x:\stalker_addon\libraries +Item3=$(OUTPUT_LIBRARIES_DIR) +Item4=$(OUTPUT_LIBRARIES_DIR)\ +Item5=x:\libraries [Debugging] -DebugSourceDirs=$(COMPONENTS)\AlexMX\ +DebugSourceDirs=..\..\..\sdk\components\AlexMX\ [Parameters] RunParams=-wf x:\stalker_addon\resources -editor diff --git a/src/editors/ECore/xrECoreB.bpr b/src/editors/ECore/xrECoreB.bpr index b83ddf1fc9a..ab1647156b5 100644 --- a/src/editors/ECore/xrECoreB.bpr +++ b/src/editors/ECore/xrECoreB.bpr @@ -3,168 +3,185 @@ - - + + @@ -175,7 +192,7 @@ - + @@ -185,35 +202,36 @@ - - + + - + -I..\..\Layers\xrRenderPC_R1 -I..\..\xrCDB -IEngine\Blenders + -I..\..\xrEngine -I$(DXSDK_DIR)\Include -IWildMagic -IEditor -IEngine + -I$(BCB)\include -I$(BCB)\include\vcl -I..\..\..\sdk\components\AlexMX + -I..\..\..\sdk\components\ElPack\Code\Source -I$(BCB)\Include\Mfc + -I$(CORE_DIR) -I..\xrEProps -I$(XIPH_DIR) -I$(MAGIC_SW_DIR) + -I$(SDK_DIR)\include\freeimage -I$(ETOOLS_DIR) -src_suffix cpp -D_EDITOR + -D_ECOREB -DXRCDB_EXPORTS -D_DEBUG -boa"/> - + - + @@ -448,53 +466,59 @@ ProductVersion=1.0.0.0 Comments= [HistoryLists\hlIncludePath] -Count=17 -Item0=D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) -Item1=$(VC_INCLUDE);D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) -Item2=D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) -Item3=D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) -Item4=..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) -Item5=..\..\common\NvMender2003;D:\STALKER\sources\engine\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) -Item6=..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) -Item7=..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) -Item8=..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage -Item9=..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage -Item10=I:\Program Files\Borland\CBuilder6\Projects;blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\freeimage -Item11=blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\freeimage -Item12=blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR) -Item13=..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR) -Item14=..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR) -Item15=..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR)\include -Item16=$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR)\include +Count=20 +Item0=..\..\xrCPU_Pipe;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core2D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Containment3D;D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCDB;Engine\Blenders;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;..\..\..\sdk\components\AlexMX;..\..\..\sdk\components\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item1=..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core2D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Containment3D;D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..\;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCDB;Engine\Blenders;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;..\..\..\sdk\components\AlexMX;..\..\..\sdk\components\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps\;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item2=..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core2D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Containment3D;D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item3=D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item4=$(VC_INCLUDE);D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item5=D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item6=D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item7=..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item8=..\..\common\NvMender2003;D:\STALKER\sources\engine\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item9=..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item10=..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage;$(ETOOLS_DIR) +Item11=..\..\xrEngine\xrRender_R1;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage +Item12=..\..\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrCPU_Pipe;Engine\Blenders;..\..\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\include\freeimage +Item13=I:\Program Files\Borland\CBuilder6\Projects;blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\freeimage +Item14=blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR);$(SDK_DIR)\freeimage +Item15=blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR) +Item16=..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR);$(MAGIC_SW_DIR) +Item17=..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR) +Item18=..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR)\include +Item19=$(DXSDK_DIR)\Include;WildMagic;Editor;Engine;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code\Source;$(BCB)\Include\Mfc;$(CORE_DIR);..\xrEProps;$(XIPH_DIR)\include [HistoryLists\hlLibraryPath] -Count=26 -Item0=..\..\..\sdk\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(OUT_LIB_DIR) -Item1=..\..\..\sdk\components\ElPack\Code;..\..\..\SDK\components\AlexMX;$(COMPONENTS)\ElPack\Code;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(OUT_LIB_DIR) -Item2=..\..\..\SDK\components\AlexMX;$(COMPONENTS)\ElPack\Code;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(OUT_LIB_DIR) -Item3=..\..\..\SDK\components\AlexMX;$(COMPONENTS)\ElPack\Code;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk -Item4=..\..\..\SDK\components\AlexMX;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk -Item5=$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk -Item6=..\..\..\SDK\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk -Item7=..\..\..\SDK\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;x:\libraries -Item8=..\..\..\SDK\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries -Item9=..\..\..\SDK\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries -Item10=..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries -Item11=..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries -Item12=..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries -Item13=..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries -Item14=..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries -Item15=..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;$(XRAY_LIBS) -Item16=D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;D:\STALKER\sources\engine\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;$(XRAY_LIBS) -Item17=..\..\common\NvMender2003;D:\STALKER\sources\engine\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;$(XRAY_LIBS) -Item18=..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;$(XRAY_LIBS) -Item19=..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries -Item20=WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries -Item21=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries -Item22=I:\Program Files\Borland\CBuilder6\Projects;blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;WildMagic;Editor;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries -Item23=blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;WildMagic;Editor;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries -Item24=WildMagic;Editor;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries -Item25=Editor;WildMagic;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries +Count=29 +Item0=..\..\xrCPU_Pipe;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core2D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Containment3D;..\..\..\sdk\components\ElPack\Code;..\..\..\sdk\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(OUT_LIB_DIR) +Item1=..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core2D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Containment3D;..\..\..\sdk\components\ElPack\Code;..\..\..\sdk\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(OUT_LIB_DIR) +Item2=..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core2D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Containment3D;..\..\..\sdk\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(OUT_LIB_DIR) +Item3=..\..\..\sdk\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(OUT_LIB_DIR) +Item4=..\..\..\sdk\components\ElPack\Code;..\..\..\SDK\components\AlexMX;$(COMPONENTS)\ElPack\Code;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(OUT_LIB_DIR) +Item5=..\..\..\SDK\components\AlexMX;$(COMPONENTS)\ElPack\Code;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(OUT_LIB_DIR) +Item6=..\..\..\SDK\components\AlexMX;$(COMPONENTS)\ElPack\Code;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk +Item7=..\..\..\SDK\components\AlexMX;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk +Item8=$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk +Item9=..\..\..\SDK\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;WildMagic;Editor;Engine\blenders;..\..\xrCDB;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk +Item10=..\..\..\SDK\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;x:\libraries +Item11=..\..\..\SDK\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries +Item12=..\..\..\SDK\components\ElPack\Code;..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries +Item13=..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries +Item14=..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries +Item15=..\..\..\SDK\components\AlexMX;..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries +Item16=..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries +Item17=..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries +Item18=..\..\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;$(XRAY_LIBS) +Item19=D:\Program Files\Borland\CBuilder6\Projects;..\..\common\NvMender2003;D:\STALKER\sources\engine\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;$(XRAY_LIBS) +Item20=..\..\common\NvMender2003;D:\STALKER\sources\engine\common\NvMender2003;..\..;..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;$(XRAY_LIBS) +Item21=..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;$(XRAY_LIBS) +Item22=..\..\Layers\xrRenderDX9;..\..\Layers\xrRender\blenders;E:\Program Files\Borland\CBuilder6\Projects;..\..\Layers\xrRender;..\..\Layers\xrRenderPC_R1;..\..\xrRender_R1;..\..\xrCPU_Pipe;..\..\xrRender;WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries +Item23=WildMagic;Editor;Engine\blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries +Item24=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries +Item25=I:\Program Files\Borland\CBuilder6\Projects;blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;WildMagic;Editor;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries +Item26=blenders;..\..\xrEngine\xrRender_R1;..\..\xrEngine\blenders;WildMagic;Editor;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries +Item27=WildMagic;Editor;..\..\xrCDB;..\..\xrEngine\xrCPU_Pipe;Engine\Blenders;..\..\xrEngine\xrRender;..\..\xrEngine;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries +Item28=Editor;WildMagic;Engine;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;$(BCB)\Lib\Psdk;x:\libraries [HistoryLists\hlDebugSourcePath] Count=1 @@ -508,26 +532,32 @@ Item2=_EDITOR;_ECOREB;_DEBUG;XRCDB_EXPORTS Item3=_EDITOR;_ECOREB;_DEBUG [HistoryLists\hlIntOutputDir] -Count=5 -Item0=x:\intermediate_ed\ecore -Item1=$(OUTPUT_INTERMEDIATE_DIR)\ecore -Item2=Intermediate -Item3=XRLC_Intermediate -Item4=xrLC_Options +Count=7 +Item0=..\..\..\intermediate\editors\xrECoreB +Item1=..\..\..\intermediate\editors\ECore +Item2=x:\intermediate_ed\ecore +Item3=$(OUTPUT_INTERMEDIATE_DIR)\ecore +Item4=Intermediate +Item5=XRLC_Intermediate +Item6=xrLC_Options [HistoryLists\hlFinalOutputDir] -Count=3 -Item0=$(OUTPUT_BINARIES_DIR)\ -Item1=x:\stalker_addon\binaries\ -Item2=x:\binaries\ +Count=5 +Item0=..\..\..\bin\editors\ +Item1=..\..\..\bin\editors +Item2=$(OUTPUT_BINARIES_DIR)\ +Item3=x:\stalker_addon\binaries\ +Item4=x:\binaries\ [HistoryLists\hIBPIOutputDir] -Count=5 -Item0=x:\stalker_addon\libraries -Item1=$(OUTPUT_LIBRARIES_DIR) -Item2=$(OUTPUT_LIBRARIES_DIR)\ -Item3=X:\libraries -Item4=X:\libraries\ +Count=7 +Item0=..\..\..\lib\editors +Item1=..\..\..\lib\editors\ +Item2=x:\stalker_addon\libraries +Item3=$(OUTPUT_LIBRARIES_DIR) +Item4=$(OUTPUT_LIBRARIES_DIR)\ +Item5=X:\libraries +Item6=X:\libraries\ [Debugging] DebugSourceDirs=$(BCB)\source\vcl diff --git a/src/editors/LevelEditor/LevelEditor.bpr b/src/editors/LevelEditor/LevelEditor.bpr index 9c8e9206b90..4a585b7aede 100644 --- a/src/editors/LevelEditor/LevelEditor.bpr +++ b/src/editors/LevelEditor/LevelEditor.bpr @@ -3,124 +3,154 @@ - - + + @@ -136,7 +166,7 @@ - + @@ -146,32 +176,34 @@ - + - + -I$(BCB)\include\vcl -I$(BCB)\include -I..\..\..\sdk\components\AlexMX + -I..\..\..\sdk\components\ElPack\Code + -I..\..\..\sdk\components\ElPack\Code\Source -I$(CORE_DIR) + -I../../xrEngine -I$(MAGIC_SW_DIR) -I$(ETOOLS_DIR) -src_suffix cpp + -D_EDITOR -D_LEVEL_EDITOR -D_DEBUG"/> - + - + @@ -349,7 +381,7 @@ AutoIncBuild=1 MajorVer=1 MinorVer=0 Release=2 -Build=156 +Build=157 Debug=1 PreRelease=0 Special=0 @@ -361,7 +393,7 @@ CodePage=1252 [Version Info Keys] CompanyName= FileDescription= -FileVersion=1.0.2.156 +FileVersion=1.0.2.157 InternalName= LegalCopyright= LegalTrademarks= @@ -371,41 +403,46 @@ ProductVersion=1.0.0.0 Comments= [HistoryLists\hlIncludePath] -Count=12 -Item0=..\..;..\..\xrServerEntities;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(MAGIC_SW_DIR);$(ETOOLS_DIR) -Item1=$(VC_INCLUDE);..\..;..\..\xrServerEntities;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(MAGIC_SW_DIR);$(ETOOLS_DIR) -Item2=..\..;..\..\xrServerEntities;..\..\Layers\xrRender;..\..\xrEngine\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(MAGIC_SW_DIR);$(ETOOLS_DIR) -Item3=..\..\xrServerEntities;..\..\Layers\xrRender;..\..\xrEngine\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(MAGIC_SW_DIR);$(ETOOLS_DIR) -Item4=..\..\xrEngine\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(MAGIC_SW_DIR);$(ETOOLS_DIR) -Item5=..\..\xrEngine\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(MAGIC_SW_DIR) -Item6=$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(MAGIC_SW_DIR) -Item7=$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender;$(MAGIC_SW_DIR) -Item8=$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender -Item9=Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender -Item10=Edit;H:\RAD\Borland\CBuilder6\Projects;"R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include"Edit;Engine;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\xrSound -Item11=H:\RAD\Borland\CBuilder6\Projects;R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;Engine\Game;Edit;Engine;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\xrSound +Count=15 +Item0=..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core2D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Numerics;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Approximation3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Containment2D;..\..\;..\..\xrServerEntities;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;..\..\..\sdk\components\AlexMX;..\..\..\sdk\components\ElPack\Code;..\..\..\sdk\components\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(MAGIC_SW_DIR);$(ETOOLS_DIR) +Item1=..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core2D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Numerics;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Approximation3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Containment2D;..\..;..\..\xrServerEntities;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;..\..\..\sdk\components\AlexMX;..\..\..\sdk\components\ElPack\Code;..\..\..\sdk\components\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(MAGIC_SW_DIR);$(ETOOLS_DIR) +Item2=..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core2D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Numerics;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Approximation3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Containment2D;..\..;..\..\xrServerEntities;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(MAGIC_SW_DIR);$(ETOOLS_DIR) +Item3=..\..;..\..\xrServerEntities;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(MAGIC_SW_DIR);$(ETOOLS_DIR) +Item4=$(VC_INCLUDE);..\..;..\..\xrServerEntities;..\..\Layers\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(MAGIC_SW_DIR);$(ETOOLS_DIR) +Item5=..\..;..\..\xrServerEntities;..\..\Layers\xrRender;..\..\xrEngine\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(MAGIC_SW_DIR);$(ETOOLS_DIR) +Item6=..\..\xrServerEntities;..\..\Layers\xrRender;..\..\xrEngine\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(MAGIC_SW_DIR);$(ETOOLS_DIR) +Item7=..\..\xrEngine\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(MAGIC_SW_DIR);$(ETOOLS_DIR) +Item8=..\..\xrEngine\xrRender;$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(MAGIC_SW_DIR) +Item9=$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(MAGIC_SW_DIR) +Item10=$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender;$(MAGIC_SW_DIR) +Item11=$(DXSDK_DIR)\Include;Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender +Item12=Edit;Engine;$(BCB)\Projects;$(BCB)\include\vcl;$(BCB)\include;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender +Item13=Edit;H:\RAD\Borland\CBuilder6\Projects;"R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include"Edit;Engine;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\xrSound +Item14=H:\RAD\Borland\CBuilder6\Projects;R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;Engine\Game;Edit;Engine;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\xrSound [HistoryLists\hlLibraryPath] -Count=14 -Item0=..\..;..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) -Item1=..\..;..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source -Item2=..\..;..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries -Item3=..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries -Item4=..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries -Item5=..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries -Item6=..\..\xrServerEntities;..\..\Layers\xrRender;..\..\..\SDK\components\ElPack\Code;..\..\xrEngine\xrRender;..\..\xrRender;..\..\xrEngine;Edit;Engine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries -Item7=..\..\xrEngine\xrRender;..\..\xrRender;..\..\xrEngine;Edit;Engine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries -Item8=..\..\xrRender;..\..\xrEngine;Edit;Engine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries -Item9=..\..\xrEngine\xrRender;..\..\xrEngine;Edit;Engine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries -Item10=Edit;Engine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries -Item11=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries -Item12=H:\RAD\Borland\CBuilder6\Projects;Edit;Engine;C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor -Item13=H:\RAD\Borland\CBuilder6\Projects;Engine\Game;Edit;Engine;C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor +Count=15 +Item0=..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core2D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Core3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Numerics;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Approximation3D;..\..\..\sdk\sources\MagicSoftware\FreeMagic\Source\Containment2D;..\..;..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) +Item1=..\..;..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) +Item2=..\..;..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source +Item3=..\..;..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries +Item4=..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries +Item5=..\..\Layers\xrRender;..\..\xrServerEntities;..\..\xrEngine;Edit;..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries +Item6=..\..\..\SDK\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries +Item7=..\..\xrServerEntities;..\..\Layers\xrRender;..\..\..\SDK\components\ElPack\Code;..\..\xrEngine\xrRender;..\..\xrRender;..\..\xrEngine;Edit;Engine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries +Item8=..\..\xrEngine\xrRender;..\..\xrRender;..\..\xrEngine;Edit;Engine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries +Item9=..\..\xrRender;..\..\xrEngine;Edit;Engine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries +Item10=..\..\xrEngine\xrRender;..\..\xrEngine;Edit;Engine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries +Item11=Edit;Engine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries +Item12=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries +Item13=H:\RAD\Borland\CBuilder6\Projects;Edit;Engine;C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor +Item14=H:\RAD\Borland\CBuilder6\Projects;Engine\Game;Edit;Engine;C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor [HistoryLists\hlDebugSourcePath] -Count=2 -Item0=X:\stalker_addon\sources\engine\editors\ECore\Editor\ -Item1=c:\rad\borland\cbuilder5\source\vcl;R:\Borland\Components6\AlexMX\ +Count=3 +Item0=..\ECore\Editor\ +Item1=X:\stalker_addon\sources\engine\editors\ECore\Editor\ +Item2=c:\rad\borland\cbuilder5\source\vcl;R:\Borland\Components6\AlexMX\ [HistoryLists\hlConditionals] Count=2 @@ -413,28 +450,31 @@ Item0=_EDITOR;_LEVEL_EDITOR;_DEBUG Item1=_EDITOR;_LEVEL_EDITOR [HistoryLists\hlIntOutputDir] -Count=3 -Item0=x:\intermediate_ed\le -Item1=$(OUTPUT_INTERMEDIATE_DIR)\le -Item2=intermediate +Count=4 +Item0=..\..\..\intermediate\editors\LevelEditor +Item1=x:\intermediate_ed\le +Item2=$(OUTPUT_INTERMEDIATE_DIR)\le +Item3=intermediate [HistoryLists\hlFinalOutputDir] -Count=5 -Item0=$(OUTPUT_BINARIES_DIR)\ -Item1=x:\stalker_addon\binaries\ -Item2=x:\binaries\ -Item3=x:\binaries -Item4=x:\ +Count=6 +Item0=..\..\..\bin\editors\ +Item1=$(OUTPUT_BINARIES_DIR)\ +Item2=x:\stalker_addon\binaries\ +Item3=x:\binaries\ +Item4=x:\binaries +Item5=x:\ [HistoryLists\hIBPIOutputDir] -Count=4 -Item0=x:\stalker_addon\libraries -Item1=$(OUTPUT_LIBRARIES_DIR) -Item2=$(OUTPUT_LIBRARIES_DIR)\ -Item3=x:\libraries +Count=5 +Item0=..\..\..\lib\editors +Item1=x:\stalker_addon\libraries +Item2=$(OUTPUT_LIBRARIES_DIR) +Item3=$(OUTPUT_LIBRARIES_DIR)\ +Item4=x:\libraries [Debugging] -DebugSourceDirs=X:\stalker_addon\sources\engine\editors\ECore\Editor\ +DebugSourceDirs=..\ECore\Editor\ [Parameters] RunParams=-wf x:\stalker_addon\resources -editor diff --git a/src/editors/PPEditor/Postprocess.bpr b/src/editors/PPEditor/Postprocess.bpr index b15f92596bb..5fab58b91ce 100644 --- a/src/editors/PPEditor/Postprocess.bpr +++ b/src/editors/PPEditor/Postprocess.bpr @@ -3,13 +3,16 @@ - - + + @@ -33,22 +36,22 @@ - - + + - + - + @@ -101,37 +104,36 @@ ProductName= ProductVersion=1.0.0.0 Comments= -[Excluded Packages] -e:\program files\borland\cbuilder6\Bin\bcb2kaxserver60.bpl=Borland C++Builder COM Server Components Sample Package - [HistoryLists\hlIncludePath] -Count=13 -Item0=..\..\xrGame;..\..\xrEngine;$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);$(COMPONENTS)\AlexMX -Item1=..\..\xrGame;..\..\xrEngine;$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);$(COMPONENTS)\AlexMX;$(3DA_DIR) -Item2=$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);$(COMPONENTS)\AlexMX;$(3DA_DIR) -Item3=$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);$(COMPONENTS)\AlexMX -Item4=$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);X:\stalker_addon\sources\sdk\components\AlexMX -Item5=$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR) -Item6=..;$(BCB)\include;$(BCB)\include\vcl -Item7=..\..\components\AlexMX;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl;e:\projects\xrcore -Item8=..\RX\Units;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl;e:\projects\xrcore -Item9=..\RX\Units;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl;Y:\postprocess\core_hdr;Y:\postprocess -Item10=..\RX\Units;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl;Y:\postprocess\core_hdr -Item11=Y:\postprocess\core_hdr;..\RX\Units;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl -Item12=..\RX\Units;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl +Count=14 +Item0=..\..\xrGame;..\..\xrEngine;$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);..\..\..\sdk\components\AlexMX +Item1=..\..\xrGame;..\..\xrEngine;$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);$(COMPONENTS)\AlexMX +Item2=..\..\xrGame;..\..\xrEngine;$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);$(COMPONENTS)\AlexMX;$(3DA_DIR) +Item3=$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);$(COMPONENTS)\AlexMX;$(3DA_DIR) +Item4=$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);$(COMPONENTS)\AlexMX +Item5=$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR);X:\stalker_addon\sources\sdk\components\AlexMX +Item6=$(BCB)\include;$(BCB)\include\vcl;$(CORE_DIR) +Item7=..;$(BCB)\include;$(BCB)\include\vcl +Item8=..\..\components\AlexMX;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl;e:\projects\xrcore +Item9=..\RX\Units;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl;e:\projects\xrcore +Item10=..\RX\Units;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl;Y:\postprocess\core_hdr;Y:\postprocess +Item11=..\RX\Units;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl;Y:\postprocess\core_hdr +Item12=Y:\postprocess\core_hdr;..\RX\Units;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl +Item13=..\RX\Units;..;Postprocess;$(BCB)\include;$(BCB)\include\vcl [HistoryLists\hlLibraryPath] -Count=10 -Item0=..\..\..\SDK\components\AlexMX;..\..\xrGame;..\..\xrEngine;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;x:\stalker_addon\libraries -Item1=..\..\..\SDK\components\AlexMX;..\..\xrGame;..\..\xrEngine;$(COMPONENTS)\AlexMX;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;x:\stalker_addon\libraries -Item2=$(COMPONENTS)\AlexMX;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;x:\stalker_addon\libraries -Item3=..\..\..\SDK\components\AlexMX;..\..\xrGame;..\..\xrEngine;$(COMPONENTS)\AlexMX;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib -Item4=$(COMPONENTS)\AlexMX;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib -Item5=..\..\..\sdk\components\AlexMX;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib -Item6=$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib -Item7=..\..\components\AlexMX;Y:\postprocess;..;Postprocess;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib -Item8=Y:\postprocess;..\RX\Units;..;Postprocess;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib -Item9=..\RX\Units;..;Postprocess;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib +Count=11 +Item0=..\..\..\sdk\components\AlexMX;..\..\xrGame;..\..\xrEngine;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;..\..\..\lib\editors\ +Item1=..\..\..\SDK\components\AlexMX;..\..\xrGame;..\..\xrEngine;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;x:\stalker_addon\libraries +Item2=..\..\..\SDK\components\AlexMX;..\..\xrGame;..\..\xrEngine;$(COMPONENTS)\AlexMX;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;x:\stalker_addon\libraries +Item3=$(COMPONENTS)\AlexMX;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;x:\stalker_addon\libraries +Item4=..\..\..\SDK\components\AlexMX;..\..\xrGame;..\..\xrEngine;$(COMPONENTS)\AlexMX;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib +Item5=$(COMPONENTS)\AlexMX;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib +Item6=..\..\..\sdk\components\AlexMX;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib +Item7=$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib +Item8=..\..\components\AlexMX;Y:\postprocess;..;Postprocess;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib +Item9=Y:\postprocess;..\RX\Units;..;Postprocess;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib +Item10=..\RX\Units;..;Postprocess;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib [HistoryLists\hlDebugSourcePath] Count=1 @@ -162,15 +164,17 @@ Item19=_DEBUG,_EDITOR,_CPPUNWIND Item20=_DEBUG,__BORLANDC__ [HistoryLists\hlIntOutputDir] -Count=1 -Item0=x:\intermediate_ed\ppe +Count=2 +Item0=..\..\..\intermediate\editors\PPEditor\ +Item1=x:\intermediate_ed\ppe [HistoryLists\hlFinalOutputDir] -Count=4 -Item0=x:\stalker_addon\binaries\ -Item1=x:\binaries\ -Item2=x:\binaries -Item3=x:\ +Count=5 +Item0=..\..\..\bin\editors\ +Item1=x:\stalker_addon\binaries\ +Item2=x:\binaries\ +Item3=x:\binaries +Item4=x:\ [Debugging] DebugSourceDirs=$(BCB)\source\vcl diff --git a/src/editors/ParticleEditor/ParticleEditor.bpr b/src/editors/ParticleEditor/ParticleEditor.bpr index 4fd366a5d02..2d963b12374 100644 --- a/src/editors/ParticleEditor/ParticleEditor.bpr +++ b/src/editors/ParticleEditor/ParticleEditor.bpr @@ -3,20 +3,26 @@ - - + + @@ -27,7 +33,7 @@ - + @@ -37,26 +43,28 @@ - - + + - + - + - + @@ -99,7 +107,7 @@ AutoIncBuild=1 MajorVer=1 MinorVer=0 Release=2 -Build=137 +Build=138 Debug=1 PreRelease=0 Special=0 @@ -111,7 +119,7 @@ CodePage=1252 [Version Info Keys] CompanyName=GSC Game World FileDescription= -FileVersion=1.0.2.137 +FileVersion=1.0.2.138 InternalName= LegalCopyright= LegalTrademarks= @@ -121,39 +129,42 @@ ProductVersion=1.0.0.0 Comments= [HistoryLists\hlIncludePath] -Count=21 -Item0=E:\Program Files\Borland\CBuilder6\Projects;..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR) -Item1=$(VC_INCLUDE);E:\Program Files\Borland\CBuilder6\Projects;..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR) -Item2=E:\Program Files\Borland\CBuilder6\Projects;..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR);..\..\xrRender -Item3=..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR);..\..\xrRender -Item4=..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR);..\..\xrEngine\xrRender -Item5=..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR) -Item6=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR) -Item7=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include\vcl;$(BCB)\include;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\xrParticles -Item8=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include\vcl;$(BCB)\include;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\xrParticles -Item9=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\Tools\ETools;..\..\xrParticles -Item10=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\Tools\ETools;..\..\xrParticles -Item11=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\Tools\ETools -Item12=R:\SDK\DirectX9.0_sum_2004\Include;C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\Tools\ETools -Item13=R:\SDK\DirectX9.0_sum_2004\Include;C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps -Item14=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0_beta3\Include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps -Item15=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\DirectX9.0_beta3\Include;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps -Item16=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps -Item17=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps -Item18=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals -Item19=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals -Item20=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore +Count=22 +Item0=E:\Program Files\Borland\CBuilder6\Projects;..\ECore\Editor;$(DXSDK_DIR)\Include;..\..\..\sdk\components\AlexMX;$(BCB)\include\vcl;$(BCB)\include;..\..\..\sdk\components\ElPack\Code;..\..\..\sdk\components\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR) +Item1=E:\Program Files\Borland\CBuilder6\Projects;..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR) +Item2=$(VC_INCLUDE);E:\Program Files\Borland\CBuilder6\Projects;..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR) +Item3=E:\Program Files\Borland\CBuilder6\Projects;..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR);..\..\xrRender +Item4=..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR);..\..\xrRender +Item5=..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR);..\..\xrEngine\xrRender +Item6=..\ECore\Editor;$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR) +Item7=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include\vcl;$(BCB)\include;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;..\..\xrEngine;$(CORE_DIR) +Item8=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include\vcl;$(BCB)\include;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\xrParticles +Item9=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include\vcl;$(BCB)\include;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;..\..\xrParticles +Item10=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\Tools\ETools;..\..\xrParticles +Item11=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\Tools\ETools;..\..\xrParticles +Item12=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\Tools\ETools +Item13=R:\SDK\DirectX9.0_sum_2004\Include;C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps;P:\Tools\ETools +Item14=R:\SDK\DirectX9.0_sum_2004\Include;C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps +Item15=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0_beta3\Include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps +Item16=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\DirectX9.0_beta3\Include;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps +Item17=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps +Item18=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;..\xrEProps +Item19=C:\Rad\Borland\CBuilder6\Projects;r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals +Item20=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals +Item21=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore [HistoryLists\hlLibraryPath] -Count=8 -Item0=..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) -Item1=..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source -Item2=..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries -Item3=..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries -Item4=..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries -Item5=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries -Item6=C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor -Item7=lib;Engine\Animations;Engine\BLENDERS;c:\rad\borland\CBuilder6\Projects;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\Elpack\Code\Source;R:\Borland\Components6\Elpack\Code;..\lib\dx;..\lib;x:\ +Count=10 +Item0=..\..\..\sdk\components\AlexMX;..\..\..\sdk\components\ElPack\Code;..\..\..\sdk\components\ElPack\Code\Source;..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(OUT_LIB_DIR) +Item1=..\..\..\sdk\components\ElPack\Code;..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) +Item2=..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) +Item3=..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source +Item4=..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries +Item5=..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries +Item6=..\ECore\Editor;..\..\xrEngine;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries +Item7=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries +Item8=C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor +Item9=lib;Engine\Animations;Engine\BLENDERS;c:\rad\borland\CBuilder6\Projects;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\Elpack\Code\Source;R:\Borland\Components6\Elpack\Code;..\lib\dx;..\lib;x:\ [HistoryLists\hlDebugSourcePath] Count=3 @@ -180,34 +191,37 @@ Item13=_DEBUG;_ED Item14=_DEBUG [HistoryLists\hlIntOutputDir] -Count=4 -Item0=x:\intermediate_ed\pe -Item1=$(OUTPUT_INTERMEDIATE_DIR)\pe -Item2=Intermediate -Item3=ParticleEditor +Count=5 +Item0=..\..\..\intermediate\editors\ParticlesEditor +Item1=x:\intermediate_ed\pe +Item2=$(OUTPUT_INTERMEDIATE_DIR)\pe +Item3=Intermediate +Item4=ParticleEditor [HistoryLists\hlFinalOutputDir] -Count=13 -Item0=$(OUTPUT_BINARIES_DIR)\ -Item1=x:\stalker_addon\binaries\ -Item2=x:\binaries\ -Item3=x:\binaries -Item4=x:\ -Item5=x:\build\ -Item6=x:\build -Item7=x:\build\bins\editors\ -Item8=x:\build\bins\editors -Item9=x:\build_karma\ -Item10=x:\build_karma -Item11=!run\ -Item12=P:\Editor\!run +Count=14 +Item0=..\..\..\bin\editors\ +Item1=$(OUTPUT_BINARIES_DIR)\ +Item2=x:\stalker_addon\binaries\ +Item3=x:\binaries\ +Item4=x:\binaries +Item5=x:\ +Item6=x:\build\ +Item7=x:\build +Item8=x:\build\bins\editors\ +Item9=x:\build\bins\editors +Item10=x:\build_karma\ +Item11=x:\build_karma +Item12=!run\ +Item13=P:\Editor\!run [HistoryLists\hIBPIOutputDir] -Count=4 -Item0=x:\stalker_addon\libraries -Item1=$(OUTPUT_LIBRARIES_DIR) -Item2=$(OUTPUT_LIBRARIES_DIR)\ -Item3=x:\libraries +Count=5 +Item0=..\..\..\lib\editors\ +Item1=x:\stalker_addon\libraries +Item2=$(OUTPUT_LIBRARIES_DIR) +Item3=$(OUTPUT_LIBRARIES_DIR)\ +Item4=x:\libraries [Debugging] DebugSourceDirs=$(BCB)\source\vcl diff --git a/src/editors/ShaderEditor/ShaderEditor.bpr b/src/editors/ShaderEditor/ShaderEditor.bpr index ffcb7354a31..ba46a632756 100644 --- a/src/editors/ShaderEditor/ShaderEditor.bpr +++ b/src/editors/ShaderEditor/ShaderEditor.bpr @@ -3,22 +3,25 @@ - - + + @@ -38,24 +41,28 @@ - - + + - + - + - + @@ -97,7 +104,7 @@ AutoIncBuild=1 MajorVer=1 MinorVer=0 Release=2 -Build=131 +Build=132 Debug=1 PreRelease=0 Special=0 @@ -109,7 +116,7 @@ CodePage=1252 [Version Info Keys] CompanyName= FileDescription= -FileVersion=1.0.2.131 +FileVersion=1.0.2.132 InternalName= LegalCopyright= LegalTrademarks= @@ -119,42 +126,48 @@ ProductVersion=1.0.0.0 Comments= [HistoryLists\hlIncludePath] -Count=25 -Item0=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(EAX_DIR) -Item1=$(VC_INCLUDE);$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(EAX_DIR) -Item2=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(EAX_DIR) -Item3=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender;$(EAX_DIR) -Item4=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender;$(EAX_DIR)\Include -Item5=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender -Item6=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine -Item7=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps -Item8=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps -Item9=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include;P:\Tools\ETools -Item10=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include;P:\Tools\ETools -Item11=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include;P:\Tools\ETools -Item12=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include -Item13=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include -Item14=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps -Item15=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include -Item16=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals -Item17=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;R:\SDK\boost-03-12-12-0400 -Item18=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;R:\SDK\BOOST -Item19=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;P:\boost_1_30_2 -Item20=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;P:\boost_1_30_0 -Item21=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind -Item22=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;P:\luabind\luabind -Item23=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind\luabind -Item24=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound +Count=29 +Item0=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\blenders;..\..\..\sdk\components\AlexMX;editor;$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;..\..\..\sdk\components\Elpack\Code;..\..\..\sdk\components\Elpack\Code\Source;..\..\ +Item1=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\blenders;..\..\..\sdk\components\AlexMX;editor;$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;..\..\..\sdk\components\Elpack\Code;..\..\..\sdk\components\Elpack\Code\Source;..\.. +Item2=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;..\..\..\sdk\components\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;..\..\..\sdk\components\Elpack\Code;..\..\..\sdk\components\Elpack\Code\Source;..\.. +Item3=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;..\..\..\sdk\components\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;..\..\..\sdk\components\Elpack\Code;..\..\..\sdk\components\Elpack\Code\Source;..\..\ +Item4=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound +Item5=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(EAX_DIR) +Item6=$(VC_INCLUDE);$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(EAX_DIR) +Item7=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(EAX_DIR) +Item8=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender;$(EAX_DIR) +Item9=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender;$(EAX_DIR)\Include +Item10=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender +Item11=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine +Item12=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps +Item13=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps +Item14=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include;P:\Tools\ETools +Item15=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include;P:\Tools\ETools +Item16=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include;P:\Tools\ETools +Item17=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include +Item18=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include +Item19=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps +Item20=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include +Item21=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals +Item22=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;R:\SDK\boost-03-12-12-0400 +Item23=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;R:\SDK\BOOST +Item24=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;P:\boost_1_30_2 +Item25=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;P:\boost_1_30_0 +Item26=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind +Item27=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;P:\luabind\luabind +Item28=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind\luabind [HistoryLists\hlLibraryPath] -Count=7 -Item0=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) -Item1=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source -Item2=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries -Item3=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries -Item4=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries -Item5=C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor -Item6=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;c:\rad\borland\CBuilder5\Projects;..\lib\DX;..\lib;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\Elpack\Code\Source;R:\Borland\Components6\Elpack\Code;x:\ +Count=9 +Item0=..\..\..\sdk\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;..\..\..\sdk\components\AlexMX;..\..\..\sdk\components\ElPack\Code\Source;$(OUT_LIB_DIR) +Item1=..\..\..\sdk\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) +Item2=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) +Item3=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source +Item4=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries +Item5=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries +Item6=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries +Item7=C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor +Item8=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;c:\rad\borland\CBuilder5\Projects;..\lib\DX;..\lib;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\Elpack\Code\Source;R:\Borland\Components6\Elpack\Code;x:\ [HistoryLists\hlDebugSourcePath] Count=3 @@ -178,32 +191,36 @@ Item10=_DEBUG;_ED Item11=_DEBUG [HistoryLists\hlIntOutputDir] -Count=4 -Item0=x:\intermediate_ed\se -Item1=$(OUTPUT_INTERMEDIATE_DIR)\se -Item2=Intermediate -Item3=ShaderEditor +Count=5 +Item0=..\..\..\intermediate\editors\ShaderEditor +Item1=x:\intermediate_ed\se +Item2=$(OUTPUT_INTERMEDIATE_DIR)\se +Item3=Intermediate +Item4=ShaderEditor [HistoryLists\hlFinalOutputDir] -Count=11 -Item0=$(OUTPUT_BINARIES_DIR)\ -Item1=x:\stalker_addon\binaries\ -Item2=x:\binaries\ -Item3=x:\binaries -Item4=x:\ -Item5=x:\build\ -Item6=x:\build -Item7=u:\preliminary\ -Item8=u:\preliminary -Item9=!run\ -Item10=P:\Editor\!run +Count=13 +Item0=..\..\..\bin\editors\ +Item1=..\..\..\bin\editors +Item2=$(OUTPUT_BINARIES_DIR)\ +Item3=x:\stalker_addon\binaries\ +Item4=x:\binaries\ +Item5=x:\binaries +Item6=x:\ +Item7=x:\build\ +Item8=x:\build +Item9=u:\preliminary\ +Item10=u:\preliminary +Item11=!run\ +Item12=P:\Editor\!run [HistoryLists\hIBPIOutputDir] -Count=4 -Item0=x:\stalker_addon\libraries -Item1=$(OUTPUT_LIBRARIES_DIR) -Item2=$(OUTPUT_LIBRARIES_DIR)\ -Item3=x:\libraries +Count=5 +Item0=..\..\..\lib\editors +Item1=x:\stalker_addon\libraries +Item2=$(OUTPUT_LIBRARIES_DIR) +Item3=$(OUTPUT_LIBRARIES_DIR)\ +Item4=x:\libraries [Debugging] DebugSourceDirs=$(BCB)\source\vcl diff --git a/src/editors/xrEProps/xrEPropsB.bpr b/src/editors/xrEProps/xrEPropsB.bpr index 4ef18da19b8..15f001b7f2b 100644 --- a/src/editors/xrEProps/xrEPropsB.bpr +++ b/src/editors/xrEProps/xrEPropsB.bpr @@ -3,23 +3,23 @@ - - + + @@ -41,23 +41,24 @@ - - + + - + - + - + @@ -120,37 +121,40 @@ ProductVersion=1.0.0.0 Comments= [HistoryLists\hlIncludePath] -Count=12 -Item0=$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR);$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code\source -Item1=$(VC_INCLUDE);$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR);$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code\source -Item2=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR);$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code\source -Item3=$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR);$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack -Item4=$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR) -Item5=$(BCB)\include;$(BCB)\include\vcl;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;P:\xrCore -Item6=$(BCB)\include;$(BCB)\include\vcl;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;P:\xrCore;R:\SDK\DirectX9.0_sum_2004\Include -Item7=R:\SDK\DirectX9.0_sum_2004\Include;C:\Rad\Borland\CBuilder6\Projects;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;P:\xrCore -Item8=C:\Rad\Borland\CBuilder6\Projects;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;P:\xrCore -Item9=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;P:\xrCore -Item10=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc -Item11=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include;R:\Borland\CBuilder6\Include\Mfc +Count=13 +Item0=$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR);..\..\..\sdk\components\AlexMX;..\..\..\sdk\components\ElPack\code\source +Item1=$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR);$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code\source +Item2=$(VC_INCLUDE);$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR);$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code\source +Item3=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR);$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code\source +Item4=$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR);$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack +Item5=$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc;$(CORE_DIR) +Item6=$(BCB)\include;$(BCB)\include\vcl;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;P:\xrCore +Item7=$(BCB)\include;$(BCB)\include\vcl;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;P:\xrCore;R:\SDK\DirectX9.0_sum_2004\Include +Item8=R:\SDK\DirectX9.0_sum_2004\Include;C:\Rad\Borland\CBuilder6\Projects;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;P:\xrCore +Item9=C:\Rad\Borland\CBuilder6\Projects;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;P:\xrCore +Item10=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;P:\xrCore +Item11=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc +Item12=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include;R:\Borland\CBuilder6\Include\Mfc [HistoryLists\hlLibraryPath] -Count=15 -Item0=z:\Program Files (x86)\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code;$(OUT_LIB_DIR) -Item1=z:\Program Files (x86)\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code;$(OUT_LIB_DIR);z:\Program Files (x86)\Borland\CBuilder6\Projects\Lib -Item2=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code;$(OUT_LIB_DIR) -Item3=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code -Item4=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx -Item5=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;$(COMPONENTS)\alexmx;X:\stalker_addon\sources\sdk\components\ElPack\Code;x:\libraries -Item6=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;$(COMPONENTS)\alexmx;X:\stalker_addon\sources\sdk\components\ElPack\Code -Item7=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;$(COMPONENTS)\alexmx -Item8=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;$(COMPONENTS)\alexmx -Item9=I:\Projects\editors\components\ElPack\Code;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\libraries;$(COMPONENTS)\alexmx -Item10=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\libraries;$(COMPONENTS)\alexmx -Item11=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\;x:\libraries -Item12=C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;x:\ -Item13=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;x:\ -Item14=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\Editors\lib\dx;..\Editors\lib;x:\ +Count=17 +Item0=..\..\..\sdk\components\AlexMX;..\..\..\sdk\components\ElPack\code;z:\Program Files (x86)\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(OUT_LIB_DIR) +Item1=..\..\..\sdk\components\alexmx;..\..\..\sdk\components\elpack\code;z:\Program Files (x86)\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code;$(OUT_LIB_DIR) +Item2=z:\Program Files (x86)\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code;$(OUT_LIB_DIR) +Item3=z:\Program Files (x86)\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code;$(OUT_LIB_DIR);z:\Program Files (x86)\Borland\CBuilder6\Projects\Lib +Item4=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code;$(OUT_LIB_DIR) +Item5=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx;$(COMPONENTS)\elpack\code +Item6=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\alexmx +Item7=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;$(COMPONENTS)\alexmx;X:\stalker_addon\sources\sdk\components\ElPack\Code;x:\libraries +Item8=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;$(COMPONENTS)\alexmx;X:\stalker_addon\sources\sdk\components\ElPack\Code +Item9=E:\Program Files\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;$(COMPONENTS)\alexmx +Item10=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;$(COMPONENTS)\alexmx +Item11=I:\Projects\editors\components\ElPack\Code;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\libraries;$(COMPONENTS)\alexmx +Item12=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\libraries;$(COMPONENTS)\alexmx +Item13=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\;x:\libraries +Item14=C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;x:\ +Item15=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;x:\ +Item16=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\Editors\lib\dx;..\Editors\lib;x:\ [HistoryLists\hlDebugSourcePath] Count=1 @@ -165,27 +169,34 @@ Item3=_EDITOR;_EPROPSB;_DEBUG Item4=_DEBUG [HistoryLists\hlIntOutputDir] -Count=3 -Item0=x:\intermediate_ed\eprops -Item1=$(OUTPUT_INTERMEDIATE_DIR)\eprops -Item2=intermediate +Count=6 +Item0=..\..\..\intermediate\editors\xrEPropsB +Item1=..\..\..\intermediate\editors\EProps +Item2=..\..\..\intermediate\editors\EProps\ +Item3=x:\intermediate_ed\eprops +Item4=$(OUTPUT_INTERMEDIATE_DIR)\eprops +Item5=intermediate [HistoryLists\hlFinalOutputDir] -Count=7 -Item0=$(OUTPUT_BINARIES_DIR)\ -Item1=x:\stalker_addon\binaries\ -Item2=x:\binaries\ -Item3=x:\binaries -Item4=x:\ -Item5=x:\build\ -Item6=x:\build +Count=9 +Item0=..\..\..\bin\editors\ +Item1=..\..\..\bin\editors +Item2=$(OUTPUT_BINARIES_DIR)\ +Item3=x:\stalker_addon\binaries\ +Item4=x:\binaries\ +Item5=x:\binaries +Item6=x:\ +Item7=x:\build\ +Item8=x:\build [HistoryLists\hIBPIOutputDir] -Count=4 -Item0=x:\stalker_addon\libraries -Item1=$(OUTPUT_LIBRARIES_DIR) -Item2=$(OUTPUT_LIBRARIES_DIR)\ -Item3=x:\libraries +Count=6 +Item0=..\..\..\\lib\editors +Item1=..\..\..\\lib\editors\ +Item2=x:\stalker_addon\libraries +Item3=$(OUTPUT_LIBRARIES_DIR) +Item4=$(OUTPUT_LIBRARIES_DIR)\ +Item5=x:\libraries [Debugging] DebugSourceDirs=$(BCB)\source\vcl diff --git a/src/xrCore/xrCoreB.bpr b/src/xrCore/xrCoreB.bpr index 63484cd6993..2ac09578ed0 100644 --- a/src/xrCore/xrCoreB.bpr +++ b/src/xrCore/xrCoreB.bpr @@ -3,49 +3,59 @@ - - - + + + @@ -54,7 +64,7 @@ - + @@ -65,23 +75,23 @@ - + - + -I$(BCB)\include\vcl -I$(BCB)\Include\Mfc -src_suffix cpp -D_EDITOR + -D_XRCOREB -DXRCORE_EXPORTS -D_DEBUG -boa"/> - + - @@ -208,10 +218,10 @@ - + - + @@ -267,69 +277,69 @@ Comments= [HistoryLists\hlIncludePath] Count=30 -Item0=blackbox;$(ETOOLS_DIR);$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc -Item1=$(VC_INCLUDE);blackbox;$(ETOOLS_DIR);$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc -Item2=blackbox;$(ETOOLS_DIR);$(DXSDK_DIR)\Include;$(BCB)\_include_;$(BCB)\include\vcl;$(BCB)\Include\Mfc -Item3=$(ETOOLS_DIR);$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc -Item4=$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc -Item5=$(DXSDK)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc -Item6=I:\Program Files\Microsoft DirectX SDK (October 2006)\Include;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;$(BCB)\Include\Mfc -Item7=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;$(BCB)\Include\Mfc -Item8=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc -Item9=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;..\Tools\Etools -Item10=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;..\Tools\Etools -Item11=R:\SDK\DirectX9.0_sum_2004\Include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;..\Tools\Etools -Item12=R:\SDK\DirectX9.0_sum_2004\Include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc -Item13=$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc -Item14=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc -Item15=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include;R:\Borland\CBuilder6\Include\Mfc -Item16=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include -Item17=R:\SDK\DirectX8.1\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include -Item18=R:\SDK\DirectX8.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include -Item19=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include;$(BCB)\include\mfc -Item20=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;$(BCB)\include\mfc -Item21=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source -Item22=R:\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source -Item23=R:\DirectX9\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source -Item24=R:\DirectX8.1\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source -Item25=..\LevelOptions\Engine;..\LevelOptions\Editor;..\LevelOptions;Editor;R:\DirectX8.1\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source -Item26=Editor;R:\DirectX8.1\include\;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include\;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source -Item27=Editor;Engine\Blenders;R:\Borland\Components\Eldos\Code\Source\;r:\borland\components\alexmx\;lib\DX;R:\DirectX8.1\include\;c:\rad\Borland\CBuilder5\Bin\;c:\rad\borland\CBuilder5\Projects\;$(BCB)\include;$(BCB)\include\vcl;engine;edit;Import\LWO;Collide;P:\MagicFM_Borland\Sdk\Include\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;c:\rad\borland\components\renderwindow\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ -Item28=Engine\Blenders;R:\Borland\Components\Eldos\Code\Source\;r:\borland\components\alexmx\;lib\DX;R:\DirectX8.1\include\;c:\rad\Borland\CBuilder5\Bin\;c:\rad\borland\CBuilder5\Projects\;$(BCB)\include;$(BCB)\include\vcl;engine;edit;Import\LWO;Collide;P:\MagicFM_Borland\Sdk\Include\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;c:\rad\borland\components\renderwindow\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ -Item29=$(BCB)\include;shared;$(BCB)\include\vcl;edit;edit\Shader;Import\LWO;Collide;P:\MagicFM_Borland\Sdk\Include\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;c:\rad\borland\components\renderwindow\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ +Item0=..\editors\ECore;E:\Program Files (x86)\Borland\CBuilder6\Projects;blackbox;$(ETOOLS_DIR);$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc +Item1=blackbox;$(ETOOLS_DIR);$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc +Item2=$(VC_INCLUDE);blackbox;$(ETOOLS_DIR);$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc +Item3=blackbox;$(ETOOLS_DIR);$(DXSDK_DIR)\Include;$(BCB)\_include_;$(BCB)\include\vcl;$(BCB)\Include\Mfc +Item4=$(ETOOLS_DIR);$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc +Item5=$(DXSDK_DIR)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc +Item6=$(DXSDK)\Include;$(BCB)\include;$(BCB)\include\vcl;$(BCB)\Include\Mfc +Item7=I:\Program Files\Microsoft DirectX SDK (October 2006)\Include;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;$(BCB)\Include\Mfc +Item8=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;$(BCB)\Include\Mfc +Item9=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc +Item10=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;..\Tools\Etools +Item11=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;..\Tools\Etools +Item12=R:\SDK\DirectX9.0_sum_2004\Include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc;..\Tools\Etools +Item13=R:\SDK\DirectX9.0_sum_2004\Include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc +Item14=$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc +Item15=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\Borland\CBuilder6\Include\Mfc +Item16=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include;R:\Borland\CBuilder6\Include\Mfc +Item17=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include +Item18=R:\SDK\DirectX8.1\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include +Item19=R:\SDK\DirectX8.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include +Item20=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;R:\VS7.NET\Vc7\atlmfc\include;$(BCB)\include\mfc +Item21=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source;$(BCB)\include\mfc +Item22=R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source +Item23=R:\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source +Item24=R:\DirectX9\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source +Item25=R:\DirectX8.1\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source +Item26=..\LevelOptions\Engine;..\LevelOptions\Editor;..\LevelOptions;Editor;R:\DirectX8.1\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source +Item27=Editor;R:\DirectX8.1\include\;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include\;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code\Source +Item28=Editor;Engine\Blenders;R:\Borland\Components\Eldos\Code\Source\;r:\borland\components\alexmx\;lib\DX;R:\DirectX8.1\include\;c:\rad\Borland\CBuilder5\Bin\;c:\rad\borland\CBuilder5\Projects\;$(BCB)\include;$(BCB)\include\vcl;engine;edit;Import\LWO;Collide;P:\MagicFM_Borland\Sdk\Include\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;c:\rad\borland\components\renderwindow\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ +Item29=Engine\Blenders;R:\Borland\Components\Eldos\Code\Source\;r:\borland\components\alexmx\;lib\DX;R:\DirectX8.1\include\;c:\rad\Borland\CBuilder5\Bin\;c:\rad\borland\CBuilder5\Projects\;$(BCB)\include;$(BCB)\include\vcl;engine;edit;Import\LWO;Collide;P:\MagicFM_Borland\Sdk\Include\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;c:\rad\borland\components\renderwindow\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ [HistoryLists\hlLibraryPath] Count=30 -Item0=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(OUT_LIB_DIR);$(COMPONENTS)\Elpack\Code;$(COMPONENTS)\AlexMX -Item1=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(COMPONENTS)\ElPack\Code;$(OUT_LIB_DIR) -Item2=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(COMPONENTS)\ElPack\Code;$(OUTPUT_LIBRARIES_DIR) -Item3=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(COMPONENTS)\ElPack\Code;$(OUTPUT_LINRARIES_DIR) -Item4=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(COMPONENTS)\ElPack\Code -Item5=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(COMPONENTS_DIR)\ElPack\Code -Item6=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\stalker_addon\libraries;$(BCB)\lib\psdk;X:\stalker_addon\sources\sdk\components\ElPack\Code;x:\libraries;X:\sources\sdk\components\ElPack\Code -Item7=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\stalker_addon\libraries;$(BCB)\lib\psdk;X:\stalker_addon\sources\sdk\components\ElPack\Code;x:\libraries -Item8=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\stalker_addon\libraries;$(BCB)\lib\psdk;X:\stalker_addon\sources\sdk\components\ElPack\Code;x:\libraries\ -Item9=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\stalker_addon\libraries;$(BCB)\lib\psdk;X:\stalker_addon\sources\sdk\components\ElPack\Code -Item10=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\stalker_addon\libraries;$(BCB)\lib\psdk -Item11=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\libraries;$(BCB)\lib\psdk -Item12=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\libraries -Item13=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\libraries -Item14=i:\Projects\editors\components\Alexmx;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\libraries -Item15=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;x:\libraries -Item16=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\Editors\lib\dx;..\Editors\lib;x:\ -Item17=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\Editors\lib\dx;..\Editors\lib;x:\ -Item18=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\Editors\lib\dx;..\Editors\lib -Item19=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\lib\dx;..\lib -Item20=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;lib;lib\dx -Item21=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;lib -Item22=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk -Item23=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk\ -Item24=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code -Item25=..\LevelOptions\Engine;..\LevelOptions\Editor;..\LevelOptions;c:\rad\borland\CBuilder5\Projects;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code -Item26=c:\rad\borland\CBuilder5\Projects\;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code -Item27=c:\rad\borland\CBuilder5\Projects\;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ -Item28=Editor;shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ -Item29=shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ +Item0=..\editors\ECore;E:\Program Files (x86)\Borland\CBuilder6\Projects;blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(OUT_LIB_DIR);..\..\sdk\components\Elpack\Code;..\..\sdk\components\AlexMX +Item1=..\editors\ECore;E:\Program Files (x86)\Borland\CBuilder6\Projects;blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(OUT_LIB_DIR);$(COMPONENTS)\Elpack\Code;$(COMPONENTS)\AlexMX +Item2=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(OUT_LIB_DIR);$(COMPONENTS)\Elpack\Code;$(COMPONENTS)\AlexMX +Item3=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(COMPONENTS)\ElPack\Code;$(OUT_LIB_DIR) +Item4=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(COMPONENTS)\ElPack\Code;$(OUTPUT_LIBRARIES_DIR) +Item5=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(COMPONENTS)\ElPack\Code;$(OUTPUT_LINRARIES_DIR) +Item6=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(COMPONENTS)\ElPack\Code +Item7=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\lib\psdk;$(COMPONENTS_DIR)\ElPack\Code +Item8=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\stalker_addon\libraries;$(BCB)\lib\psdk;X:\stalker_addon\sources\sdk\components\ElPack\Code;x:\libraries;X:\sources\sdk\components\ElPack\Code +Item9=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\stalker_addon\libraries;$(BCB)\lib\psdk;X:\stalker_addon\sources\sdk\components\ElPack\Code;x:\libraries +Item10=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\stalker_addon\libraries;$(BCB)\lib\psdk;X:\stalker_addon\sources\sdk\components\ElPack\Code;x:\libraries\ +Item11=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\stalker_addon\libraries;$(BCB)\lib\psdk;X:\stalker_addon\sources\sdk\components\ElPack\Code +Item12=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\stalker_addon\libraries;$(BCB)\lib\psdk +Item13=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\libraries;$(BCB)\lib\psdk +Item14=blackbox;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\libraries +Item15=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\libraries +Item16=i:\Projects\editors\components\Alexmx;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;x:\libraries +Item17=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;$(COMPONENTS)\ElPack\Code;x:\libraries +Item18=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\Editors\lib\dx;..\Editors\lib;x:\ +Item19=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\Editors\lib\dx;..\Editors\lib;x:\ +Item20=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\Editors\lib\dx;..\Editors\lib +Item21=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\lib\dx;..\lib +Item22=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;lib;lib\dx +Item23=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;lib +Item24=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk +Item25=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk\ +Item26=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code +Item27=..\LevelOptions\Engine;..\LevelOptions\Editor;..\LevelOptions;c:\rad\borland\CBuilder5\Projects;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code +Item28=c:\rad\borland\CBuilder5\Projects\;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code +Item29=c:\rad\borland\CBuilder5\Projects\;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ [HistoryLists\hlDebugSourcePath] Count=1 @@ -347,46 +357,49 @@ Item6=_OPTIONS Item7=_DEBUG [HistoryLists\hlIntOutputDir] -Count=8 -Item0=x:\intermediate_ed\core -Item1=$(OUTPUT_INTERMEDIATE_DIR)\core -Item2=$(OUTPUT_INTERMEDIATE_DIR) -Item3=$(OUTPUT_INTERMEDIATE_DIR)\ -Item4=x:\intermediate_ed -Item5=Intermediate -Item6=XRLC_Intermediate -Item7=xrLC_Options +Count=9 +Item0=..\..\intermediate\editors\xrCoreB\ +Item1=x:\intermediate_ed\core +Item2=$(OUTPUT_INTERMEDIATE_DIR)\core +Item3=$(OUTPUT_INTERMEDIATE_DIR) +Item4=$(OUTPUT_INTERMEDIATE_DIR)\ +Item5=x:\intermediate_ed +Item6=Intermediate +Item7=XRLC_Intermediate +Item8=xrLC_Options [HistoryLists\hlFinalOutputDir] -Count=18 -Item0=$(OUTPUT_BINARIES_DIR)\ -Item1=x:\stalker_addon\binaries\ -Item2=x:\binaries\ -Item3=x:\binaries -Item4=C:\Program Files\THQ\S.T.A.L.K.E.R. - Shadow of Chernobyl\ -Item5=x:\ -Item6=x:\build\ -Item7=x:\build -Item8=u:\preliminary\ -Item9=u:\preliminary -Item10=s:\bin\ -Item11=z:\ -Item12=S:\build_zmey\ -Item13=S:\build_zmey -Item14=x:\xrCoreB.dll\ -Item15=x:\xrCoreB.dll -Item16=!run\ -Item17=!run +Count=19 +Item0=..\..\bin\editors\ +Item1=$(OUTPUT_BINARIES_DIR)\ +Item2=x:\stalker_addon\binaries\ +Item3=x:\binaries\ +Item4=x:\binaries +Item5=C:\Program Files\THQ\S.T.A.L.K.E.R. - Shadow of Chernobyl\ +Item6=x:\ +Item7=x:\build\ +Item8=x:\build +Item9=u:\preliminary\ +Item10=u:\preliminary +Item11=s:\bin\ +Item12=z:\ +Item13=S:\build_zmey\ +Item14=S:\build_zmey +Item15=x:\xrCoreB.dll\ +Item16=x:\xrCoreB.dll +Item17=!run\ +Item18=!run [HistoryLists\hIBPIOutputDir] -Count=7 -Item0=x:\stalker_addon\libraries -Item1=$(OUT_LIB_DIR) -Item2=$(OUT_LIB_DIR)\ -Item3=$(OUTPUT_LIBRARIES_DIR) -Item4=$(OUTPUT_LIBRARIES_DIR)\ -Item5=x:\libraries -Item6=x:\libraries\ +Count=8 +Item0=..\..\lib\editors\ +Item1=x:\stalker_addon\libraries +Item2=$(OUT_LIB_DIR) +Item3=$(OUT_LIB_DIR)\ +Item4=$(OUTPUT_LIBRARIES_DIR) +Item5=$(OUTPUT_LIBRARIES_DIR)\ +Item6=x:\libraries +Item7=x:\libraries\ [Debugging] DebugSourceDirs=$(BCB)\source\vcl diff --git a/src/xrParticles/xrParticlesB.bpr b/src/xrParticles/xrParticlesB.bpr index 81a76c33367..d54eb717401 100644 --- a/src/xrParticles/xrParticlesB.bpr +++ b/src/xrParticles/xrParticlesB.bpr @@ -3,15 +3,15 @@ - - + + @@ -38,7 +38,7 @@ - + @@ -47,12 +47,12 @@ -D_EDITOR -DXR_PARTICLES_EXPORTS -D_DEBUG -boa"/> - + - + @@ -134,32 +134,33 @@ Item24=$(BCB)\include;$(BCB)\include\vcl;edit Item25=$(BCB)\include;$(BCB)\include\vcl [HistoryLists\hlLibraryPath] -Count=25 -Item0=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\Elpack\code;$(OUT_LIB_DIR);$(COMPONENTS)\alexMX -Item1=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\Elpack\code;$(OUT_LIB_DIR) -Item2=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\Elpack\code -Item3=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk -Item4=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;X:\stalker_addon\sources\sdk\components\ElPack\Code;x:\libraries -Item5=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;X:\stalker_addon\sources\sdk\components\ElPack\Code -Item6=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries -Item7=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\libraries -Item8=P:\Editors\ParticleEditor;C:\Rad\Borland\CBuilder6\Projects;c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;\Editors\lib\dx;\Editors\lib -Item9=C:\Rad\Borland\CBuilder6\Projects;c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;\Editors\lib\dx;\Editors\lib -Item10=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;\Editors\lib\dx;\Editors\lib -Item11=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\Editors\lib\dx;..\Editors\lib -Item12=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\lib\dx;..\lib -Item13=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;lib;lib\dx -Item14=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;lib -Item15=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk -Item16=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk\ -Item17=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code -Item18=..\LevelOptions\Engine;..\LevelOptions\Editor;..\LevelOptions;c:\rad\borland\CBuilder5\Projects;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code -Item19=c:\rad\borland\CBuilder5\Projects\;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code -Item20=c:\rad\borland\CBuilder5\Projects\;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ -Item21=Editor;shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ -Item22=shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ -Item23=edit;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib -Item24=$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib +Count=26 +Item0=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;..\..\sdk\components\ElPack\code;..\..\sdk\components\AlexMX;$(OUT_LIB_DIR) +Item1=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\Elpack\code;$(OUT_LIB_DIR);$(COMPONENTS)\alexMX +Item2=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\Elpack\code;$(OUT_LIB_DIR) +Item3=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;$(COMPONENTS)\Elpack\code +Item4=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk +Item5=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;X:\stalker_addon\sources\sdk\components\ElPack\Code;x:\libraries +Item6=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries;X:\stalker_addon\sources\sdk\components\ElPack\Code +Item7=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\stalker_addon\libraries +Item8=$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(BCB)\Lib\Psdk;x:\libraries +Item9=P:\Editors\ParticleEditor;C:\Rad\Borland\CBuilder6\Projects;c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;\Editors\lib\dx;\Editors\lib +Item10=C:\Rad\Borland\CBuilder6\Projects;c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;\Editors\lib\dx;\Editors\lib +Item11=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;\Editors\lib\dx;\Editors\lib +Item12=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\Editors\lib\dx;..\Editors\lib +Item13=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;..\lib\dx;..\lib +Item14=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;lib;lib\dx +Item15=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk;lib +Item16=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk +Item17=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code;R:\Borland\CBuilder6\Lib\Psdk\ +Item18=c:\rad\borland\CBuilder5\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code +Item19=..\LevelOptions\Engine;..\LevelOptions\Editor;..\LevelOptions;c:\rad\borland\CBuilder5\Projects;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code +Item20=c:\rad\borland\CBuilder5\Projects\;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;R:\Borland\Components6\AlexMX;R:\Borland\Components6\ElPack\Code +Item21=c:\rad\borland\CBuilder5\Projects\;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components\alexmx\;R:\Borland\Components\Eldos\Code\Source\;R:\Borland\Components\Eldos\Code\ +Item22=Editor;shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ +Item23=shared;edit;edit\Shader;Collide;Import\LWO;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;c:\rad\borland\components\renderwindow\;c:\rad\borland\components\extbtn\;c:\rad\borland\components\multi\;C:\RAD\borland\Components\RX\Units\;C:\RAD\borland\Components\ElTree\Code\Source\ +Item24=edit;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib +Item25=$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib [HistoryLists\hlDebugSourcePath] Count=1 @@ -173,31 +174,37 @@ Item2=_EDITOR;PARTICLEDLL_EXPORTS;_DEBUG Item3=_EDITOR;_PARTICLEDLLB;PARTICLEDLL_EXPORTS;_DEBUG [HistoryLists\hlIntOutputDir] -Count=6 -Item0=x:\intermediate_ed\particles -Item1=$(OUTPUT_INTERMEDIATE_DIR)\particles -Item2=$(OUTPUT_INTERMEDIATE_DIR) -Item3=$(OUTPUT_INTERMEDIATE_DIR)\ -Item4=x:\intermediate_ed -Item5=Intermediate +Count=9 +Item0=..\..\intermediate\editors\xrParticlesB +Item1=..\..\intermediate\editors\Particles +Item2=..\..\intermediate\editors\Particles\ +Item3=x:\intermediate_ed\particles +Item4=$(OUTPUT_INTERMEDIATE_DIR)\particles +Item5=$(OUTPUT_INTERMEDIATE_DIR) +Item6=$(OUTPUT_INTERMEDIATE_DIR)\ +Item7=x:\intermediate_ed +Item8=Intermediate [HistoryLists\hlFinalOutputDir] -Count=7 -Item0=$(OUTPUT_BINARIES_DIR)\ -Item1=x:\stalker_addon\binaries\ -Item2=x:\binaries\ -Item3=x:\binaries -Item4=x:\ -Item5=x:\build\ -Item6=x:\build +Count=8 +Item0=..\..\bin\editors\ +Item1=$(OUTPUT_BINARIES_DIR)\ +Item2=x:\stalker_addon\binaries\ +Item3=x:\binaries\ +Item4=x:\binaries +Item5=x:\ +Item6=x:\build\ +Item7=x:\build [HistoryLists\hIBPIOutputDir] -Count=5 -Item0=x:\stalker_addon\libraries -Item1=$(OUTPUT_LIBRARIES_DIR) -Item2=$(OUTPUT_LIBRARIES_DIR)\ -Item3=x:\libraries -Item4=x:\ +Count=7 +Item0=..\..\lib\editors +Item1=..\..\lib\editors\ +Item2=x:\stalker_addon\libraries +Item3=$(OUTPUT_LIBRARIES_DIR) +Item4=$(OUTPUT_LIBRARIES_DIR)\ +Item5=x:\libraries +Item6=x:\ [Debugging] DebugSourceDirs=$(BCB)\source\vcl diff --git a/src/xrSound/xrSoundB.bpr b/src/xrSound/xrSoundB.bpr index 17d7d41ed7d..b8f1c044b1f 100644 --- a/src/xrSound/xrSoundB.bpr +++ b/src/xrSound/xrSoundB.bpr @@ -3,27 +3,28 @@ - - + + @@ -54,11 +55,11 @@ -D_EDITOR -D_XRSOUNDB -DXRSOUND_EXPORTS -D_DEBUG -boa"/> - + - @@ -202,35 +203,38 @@ Item1=_EDITOR;_XRSOUNDB;XRSOUND_EXPORTS Item2=_XRSOUNDB;XRSOUND_EXPORTS;_DEBUG [HistoryLists\hlIntOutputDir] -Count=7 -Item0=x:\intermediate_ed\sound -Item1=$(OUTPUT_INTERMEDIATE_DIR)\sound -Item2=$(OUTPUT_INTERMEDIATE_DIR) -Item3=$(OUTPUT_INTERMEDIATE_DIR)\ -Item4=Intermediate -Item5=XRLC_Intermediate -Item6=xrLC_Options +Count=8 +Item0=..\..\intermediate\editors\xrSoundB +Item1=x:\intermediate_ed\sound +Item2=$(OUTPUT_INTERMEDIATE_DIR)\sound +Item3=$(OUTPUT_INTERMEDIATE_DIR) +Item4=$(OUTPUT_INTERMEDIATE_DIR)\ +Item5=Intermediate +Item6=XRLC_Intermediate +Item7=xrLC_Options [HistoryLists\hlFinalOutputDir] -Count=10 -Item0=$(OUTPUT_BINARIES_DIR)\ -Item1=x:\stalker_addon\binaries\ -Item2=x:\binaries\ -Item3=x:\binaries -Item4=x:\ -Item5=x:\build\ -Item6=x:\xrCoreB.dll\ -Item7=x:\xrCoreB.dll -Item8=!run\ -Item9=!run +Count=11 +Item0=..\..\bin\editors\ +Item1=$(OUTPUT_BINARIES_DIR)\ +Item2=x:\stalker_addon\binaries\ +Item3=x:\binaries\ +Item4=x:\binaries +Item5=x:\ +Item6=x:\build\ +Item7=x:\xrCoreB.dll\ +Item8=x:\xrCoreB.dll +Item9=!run\ +Item10=!run [HistoryLists\hIBPIOutputDir] -Count=5 -Item0=x:\stalker_addon\libraries -Item1=$(OUT_LIB_DIR) -Item2=$(OUTPUT_LIBRARIES_DIR) -Item3=$(OUTPUT_LIBRARIES_DIR)\ -Item4=x:\libraries +Count=6 +Item0=..\..\lib\editors\ +Item1=x:\stalker_addon\libraries +Item2=$(OUT_LIB_DIR) +Item3=$(OUTPUT_LIBRARIES_DIR) +Item4=$(OUTPUT_LIBRARIES_DIR)\ +Item5=x:\libraries [Debugging] DebugSourceDirs=$(BCB)\source\vcl From a149793f8bb55568f7d5eda51f520605c42020af Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 4 Dec 2015 06:30:07 +0500 Subject: [PATCH 03/10] xrEProps: fixed includes and formatted code --- src/editors/xrEProps/EditorChooseEvents.h | 8 +++---- src/editors/xrEProps/FolderLib.cpp | 2 +- src/editors/xrEProps/GameTypeForm.cpp | 2 +- src/editors/xrEProps/ItemList.h | 2 +- src/editors/xrEProps/ItemListHelper.h | 2 +- src/editors/xrEProps/PropertiesList.h | 2 +- src/editors/xrEProps/PropertiesListHelper.cpp | 2 +- src/editors/xrEProps/PropertiesListTypes.cpp | 2 +- src/editors/xrEProps/stdafx.h | 21 +++++++++++-------- src/editors/xrEProps/xrEProps.cpp | 2 +- 10 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/editors/xrEProps/EditorChooseEvents.h b/src/editors/xrEProps/EditorChooseEvents.h index 805ff84e741..1eb294ee5c3 100644 --- a/src/editors/xrEProps/EditorChooseEvents.h +++ b/src/editors/xrEProps/EditorChooseEvents.h @@ -2,11 +2,11 @@ #define EditorChooseEventsH #include "ChooseTypes.h" -#include "../../Layers/xrRender/SkeletonAnimated.h" -#include "../../Layers/xrRender/ResourceManager.h" +#include "Layers/xrRender/SkeletonAnimated.h" +#include "Layers/xrRender/ResourceManager.h" -#include "../../Layers/xrRender/ParticleEffect.h" -#include "../../Layers/xrRender/ParticleGroup.h" +#include "Layers/xrRender/ParticleEffect.h" +#include "Layers/xrRender/ParticleGroup.h" ref_sound* choose_snd; diff --git a/src/editors/xrEProps/FolderLib.cpp b/src/editors/xrEProps/FolderLib.cpp index cd338249708..5c447d6c33a 100644 --- a/src/editors/xrEProps/FolderLib.cpp +++ b/src/editors/xrEProps/FolderLib.cpp @@ -2,7 +2,7 @@ #pragma hdrstop #include "FolderLib.h" -#include "../../xrServerEntities/PropertiesListHelper.h" +#include "xrServerEntities/PropertiesListHelper.h" //--------------------------------------------------------------------------- #pragma package(smart_init) diff --git a/src/editors/xrEProps/GameTypeForm.cpp b/src/editors/xrEProps/GameTypeForm.cpp index 93b8228b409..505e565738d 100644 --- a/src/editors/xrEProps/GameTypeForm.cpp +++ b/src/editors/xrEProps/GameTypeForm.cpp @@ -2,7 +2,7 @@ #pragma hdrstop #include "GameTypeForm.h" -#include "../../xrServerEntities/gametype_chooser.h" +#include "xrServerEntities/gametype_chooser.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "ExtBtn" diff --git a/src/editors/xrEProps/ItemList.h b/src/editors/xrEProps/ItemList.h index e1d1828d25e..ce7a86e03c5 100644 --- a/src/editors/xrEProps/ItemList.h +++ b/src/editors/xrEProps/ItemList.h @@ -19,7 +19,7 @@ #include "ItemListHelper.h" #include "FolderLib.h" -#include "../../xrServerEntities/PropertiesListTypes.h" +#include "xrServerEntities/PropertiesListTypes.h" class XR_EPROPS_API TItemList: public TForm { diff --git a/src/editors/xrEProps/ItemListHelper.h b/src/editors/xrEProps/ItemListHelper.h index 5a199a184d0..b8831d726f4 100644 --- a/src/editors/xrEProps/ItemListHelper.h +++ b/src/editors/xrEProps/ItemListHelper.h @@ -2,7 +2,7 @@ #ifndef ItemListHelperH #define ItemListHelperH -#include "ItemListTypes.h" +#include "xrServerEntities/ItemListTypes.h" #include "FolderLib.h" //--------------------------------------------------------------------------- diff --git a/src/editors/xrEProps/PropertiesList.h b/src/editors/xrEProps/PropertiesList.h index c697e9fe2cc..b3ab9321742 100644 --- a/src/editors/xrEProps/PropertiesList.h +++ b/src/editors/xrEProps/PropertiesList.h @@ -17,7 +17,7 @@ #include "ElTreeAdvEdit.hpp" #include -#include "../../xrServerEntities/PropertiesListHelper.h" +#include "xrServerEntities/PropertiesListHelper.h" #include "RenderWindow.hpp" #include "MxShortcut.hpp" #include "ExtBtn.hpp" diff --git a/src/editors/xrEProps/PropertiesListHelper.cpp b/src/editors/xrEProps/PropertiesListHelper.cpp index 8507b9bee63..516e838ebd1 100644 --- a/src/editors/xrEProps/PropertiesListHelper.cpp +++ b/src/editors/xrEProps/PropertiesListHelper.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #pragma hdrstop -#include "../../xrServerEntities/PropertiesListHelper.h" +#include "xrServerEntities/PropertiesListHelper.h" #include "ItemListHelper.h" #include "ChoseForm.h" //--------------------------------------------------------------------------- diff --git a/src/editors/xrEProps/PropertiesListTypes.cpp b/src/editors/xrEProps/PropertiesListTypes.cpp index 289cc0c3c02..cae83fd36fc 100644 --- a/src/editors/xrEProps/PropertiesListTypes.cpp +++ b/src/editors/xrEProps/PropertiesListTypes.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #pragma hdrstop -#include "../../xrServerEntities/PropertiesListTypes.h" +#include "xrServerEntities/PropertiesListTypes.h" #include "MxShortcut.hpp" //------------------------------------------------------------------------------ diff --git a/src/editors/xrEProps/stdafx.h b/src/editors/xrEProps/stdafx.h index f6eaf83dee7..2d852ebed00 100644 --- a/src/editors/xrEProps/stdafx.h +++ b/src/editors/xrEProps/stdafx.h @@ -6,29 +6,32 @@ #pragma once -#include +#include #define smart_cast dynamic_cast //refs -namespace CDB{ - class MODEL; +namespace CDB +{ + class MODEL; }; -#include "../../xrServerEntities/xrEProps.h" +#include "xrServerEntities/xrEProps.h" #include "FolderLib.h" +#include "xrCore/Platform.h" + #define ENGINE_API -#define DLL_API __declspec(dllimport) -#define ECORE_API __declspec(dllexport) +#define DLL_API XR_IMPORT +#define ECORE_API XR_EXPORT #include "Defines.h" // libs -#pragma comment (lib,"xrSoundB.lib") -#pragma comment (lib,"xrCoreB.lib") -#pragma comment (lib,"EToolsB.lib") +#pragma comment (lib,"xrSoundB.lib") +#pragma comment (lib,"xrCoreB.lib") +#pragma comment (lib,"EToolsB.lib") #endif //stdafxH diff --git a/src/editors/xrEProps/xrEProps.cpp b/src/editors/xrEProps/xrEProps.cpp index 7030e0754ea..d079e1812b6 100644 --- a/src/editors/xrEProps/xrEProps.cpp +++ b/src/editors/xrEProps/xrEProps.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #pragma hdrstop -#include "../../xrServerEntities/xrEProps.h" +#include "xrServerEntities/xrEProps.h" USEFORM("ChoseForm.cpp", frmChoseItem); USEFORM("ItemDialog.cpp", frmItemDialog); From 85069935326d5c15e47d2ff6591cb50c2314e418 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 4 Dec 2015 06:30:51 +0500 Subject: [PATCH 04/10] ShaderEditor: fixed includes and formatted code --- src/editors/ShaderEditor/BottomBar.cpp | 464 +++---- src/editors/ShaderEditor/BottomBar.h | 138 +-- .../ShaderEditor/GameMtlLib_Editor.cpp | 911 +++++++------- src/editors/ShaderEditor/SHCompilerTools.cpp | 135 ++- src/editors/ShaderEditor/SHCompilerTools.h | 80 +- .../SHCompilerToolsProperties.cpp | 64 +- src/editors/ShaderEditor/SHEngineTools.cpp | 1067 +++++++++-------- src/editors/ShaderEditor/SHEngineTools.h | 255 ++-- .../ShaderEditor/SHEngineToolsProperties.cpp | 315 +++-- .../ShaderEditor/SHGameMtlPairTools.cpp | 134 ++- src/editors/ShaderEditor/SHGameMtlPairTools.h | 72 +- src/editors/ShaderEditor/SHGameMtlTools.cpp | 192 +-- src/editors/ShaderEditor/SHGameMtlTools.h | 80 +- src/editors/ShaderEditor/SHSoundEnvTools.cpp | 419 ++++--- src/editors/ShaderEditor/SHSoundEnvTools.h | 100 +- src/editors/ShaderEditor/SHToolsInterface.cpp | 87 +- src/editors/ShaderEditor/SHToolsInterface.h | 151 ++- src/editors/ShaderEditor/ShaderEditor.cpp | 113 +- src/editors/ShaderEditor/ShaderEditor.res | Bin 3804 -> 3804 bytes src/editors/ShaderEditor/ShaderEditor.~bpr | 251 ++++ src/editors/ShaderEditor/Splash.cpp | 8 +- src/editors/ShaderEditor/Splash.h | 27 +- src/editors/ShaderEditor/TopBar.cpp | 199 +-- src/editors/ShaderEditor/TopBar.h | 55 +- src/editors/ShaderEditor/UI_shadertools.cpp | 347 +++--- src/editors/ShaderEditor/UI_shadertools.h | 169 ++- src/editors/ShaderEditor/leftbar.cpp | 159 ++- src/editors/ShaderEditor/leftbar.h | 208 ++-- src/editors/ShaderEditor/main.cpp | 245 ++-- src/editors/ShaderEditor/main.h | 79 +- src/editors/ShaderEditor/stdafx.cpp | 2 +- src/editors/ShaderEditor/stdafx.h | 167 +-- src/editors/ShaderEditor/ui_shadermain.cpp | 145 ++- src/editors/ShaderEditor/ui_shadermain.h | 66 +- 34 files changed, 4014 insertions(+), 2890 deletions(-) create mode 100644 src/editors/ShaderEditor/ShaderEditor.~bpr diff --git a/src/editors/ShaderEditor/BottomBar.cpp b/src/editors/ShaderEditor/BottomBar.cpp index 827b01b901c..0b220b8c144 100644 --- a/src/editors/ShaderEditor/BottomBar.cpp +++ b/src/editors/ShaderEditor/BottomBar.cpp @@ -3,52 +3,74 @@ #pragma hdrstop #include "BottomBar.h" -#include "../ECore/Editor/LogForm.h" -#include "../ECore/Editor/ui_main.h" -#include "igame_persistent.h" -#include "environment.h" -#include "../../xrServerEntities/PropertiesListHelper.h" -#include "../xrEProps/PropertiesList.h" +#include "editors/ECore/Editor/LogForm.h" +#include "editors/ECore/Editor/ui_main.h" +#include "xrEngine/IGame_Persistent.h" +#include "xrEngine/Environment.h" +#include "xrServerEntities/PropertiesListHelper.h" +#include "editors/xrEProps/PropertiesList.h" //--------------------------------------------------------------------------- #pragma package(smart_init) -#pragma link "ExtBtn" +#pragma link "ExtBtn" #pragma link "MxMenus" #pragma link "mxPlacemnt" -#pragma resource "*.dfm" -TfraBottomBar *fraBottomBar=0; +#pragma resource "*.dfm" +TfraBottomBar *fraBottomBar = 0; + //--------------------------------------------------------------------------- -__fastcall TfraBottomBar::TfraBottomBar(TComponent* Owner) +__fastcall TfraBottomBar::TfraBottomBar(TComponent *Owner) : TFrame(Owner) { DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ClickOptionsMenuItem(TObject *Sender) { - TMenuItem* mi = dynamic_cast(Sender); - if (mi){ + TMenuItem *mi = dynamic_cast(Sender); + if (mi) + { mi->Checked = !mi->Checked; - if (mi==miDrawGrid) ExecCommand(COMMAND_TOGGLE_GRID); - else if (mi==miRenderWithTextures) psDeviceFlags.set(rsRenderTextures,mi->Checked); - else if (mi==miMuteSounds) psDeviceFlags.set(rsMuteSounds,mi->Checked); - else if (mi==miLightScene) psDeviceFlags.set(rsLighting,mi->Checked); - else if (mi==miRenderLinearFilter) psDeviceFlags.set(rsFilterLinear,mi->Checked); - else if (mi==miRenderEdgedFaces) psDeviceFlags.set(rsEdgedFaces,mi->Checked); - else if (mi==miFog) psDeviceFlags.set(rsFog,mi->Checked); - else if (mi==miRealTime) psDeviceFlags.set(rsRenderRealTime,mi->Checked); - else if (mi==miDrawSafeRect) ExecCommand(COMMAND_TOGGLE_SAFE_RECT); - else if (mi==miRenderFillPoint) EDevice.dwFillMode = D3DFILL_POINT; - else if (mi==miRenderFillWireframe) EDevice.dwFillMode = D3DFILL_WIREFRAME; - else if (mi==miRenderFillSolid) EDevice.dwFillMode = D3DFILL_SOLID; - else if (mi==miRenderShadeFlat) EDevice.dwShadeMode = D3DSHADE_FLAT; - else if (mi==miRenderShadeGouraud) EDevice.dwShadeMode = D3DSHADE_GOURAUD; - else if (mi==miRenderHWTransform){ HW.Caps.bForceGPU_SW = !mi->Checked; UI->Resize(); } + if (mi==miDrawGrid) + ExecCommand(COMMAND_TOGGLE_GRID); + else if (mi==miRenderWithTextures) + psDeviceFlags.set(rsRenderTextures, mi->Checked); + else if (mi==miMuteSounds) + psDeviceFlags.set(rsMuteSounds, mi->Checked); + else if (mi==miLightScene) + psDeviceFlags.set(rsLighting, mi->Checked); + else if (mi==miRenderLinearFilter) + psDeviceFlags.set(rsFilterLinear, mi->Checked); + else if (mi==miRenderEdgedFaces) + psDeviceFlags.set(rsEdgedFaces, mi->Checked); + else if (mi==miFog) + psDeviceFlags.set(rsFog, mi->Checked); + else if (mi==miRealTime) + psDeviceFlags.set(rsRenderRealTime, mi->Checked); + else if (mi==miDrawSafeRect) + ExecCommand(COMMAND_TOGGLE_SAFE_RECT); + else if (mi==miRenderFillPoint) + EDevice.dwFillMode = D3DFILL_POINT; + else if (mi==miRenderFillWireframe) + EDevice.dwFillMode = D3DFILL_WIREFRAME; + else if (mi==miRenderFillSolid) + EDevice.dwFillMode = D3DFILL_SOLID; + else if (mi==miRenderShadeFlat) + EDevice.dwShadeMode = D3DSHADE_FLAT; + else if (mi==miRenderShadeGouraud) + EDevice.dwShadeMode = D3DSHADE_GOURAUD; + else if (mi==miRenderHWTransform) + { + HW.Caps.bForceGPU_SW = !mi->Checked; + UI->Resize(); + } } UI->RedrawScene(); ExecCommand(COMMAND_UPDATE_TOOLBAR); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::QualityClick(TObject *Sender) { @@ -56,277 +78,317 @@ void __fastcall TfraBottomBar::QualityClick(TObject *Sender) ((TMenuItem*)Sender)->Checked = true; UI->Resize(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::fsStorageRestorePlacement(TObject *Sender) { // fill mode - if (miRenderFillPoint->Checked) EDevice.dwFillMode=D3DFILL_POINT; - else if (miRenderFillWireframe->Checked)EDevice.dwFillMode=D3DFILL_WIREFRAME; - else if (miRenderFillSolid->Checked) EDevice.dwFillMode=D3DFILL_SOLID; + if (miRenderFillPoint->Checked) + EDevice.dwFillMode = D3DFILL_POINT; + else if (miRenderFillWireframe->Checked) + EDevice.dwFillMode = D3DFILL_WIREFRAME; + else if (miRenderFillSolid->Checked) + EDevice.dwFillMode = D3DFILL_SOLID; // shade mode - if (miRenderShadeFlat->Checked) EDevice.dwShadeMode=D3DSHADE_FLAT; - else if (miRenderShadeGouraud->Checked) EDevice.dwShadeMode=D3DSHADE_GOURAUD; + if (miRenderShadeFlat->Checked) + EDevice.dwShadeMode = D3DSHADE_FLAT; + else if (miRenderShadeGouraud->Checked) + EDevice.dwShadeMode = D3DSHADE_GOURAUD; // hw transform - HW.Caps.bForceGPU_SW = !miRenderHWTransform->Checked; + HW.Caps.bForceGPU_SW = !miRenderHWTransform->Checked; // quality - if (N200->Checked) QualityClick(N200); - else if (N150->Checked) QualityClick(N150); - else if (N125->Checked) QualityClick(N125); - else if (N100->Checked) QualityClick(N100); - else if (N75->Checked) QualityClick(N75); - else if (N50->Checked) QualityClick(N50); - else if (N25->Checked) QualityClick(N25); + if (N200->Checked) + QualityClick(N200); + else if (N150->Checked) + QualityClick(N150); + else if (N125->Checked) + QualityClick(N125); + else if (N100->Checked) + QualityClick(N100); + else if (N75->Checked) + QualityClick(N75); + else if (N50->Checked) + QualityClick(N50); + else if (N25->Checked) + QualityClick(N25); // setup menu miWeather->Clear(); - TMenuItem* mi = xr_new((TComponent*)0); - mi->Caption = "none"; - mi->OnClick = miWeatherClick; - mi->Tag = -1; - mi->Checked = true; - mi->RadioItem = true; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); -/* - // append weathers - CEnvironment::EnvsMapIt _I=g_pGamePersistent->Environment().WeatherCycles.begin(); - CEnvironment::EnvsMapIt _E=g_pGamePersistent->Environment().WeatherCycles.end(); - for (; _I!=_E; _I++){ - mi = xr_new((TComponent*)0); - mi->Caption = *_I->first; - mi->OnClick = miWeatherClick; - mi->RadioItem = true; - miWeather->Add (mi); - } -*/ - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Reload"; - mi->OnClick = miWeatherClick; - mi->Tag = -2; - miWeather->Add (mi); - - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Properties..."; - mi->OnClick = miWeatherClick; - mi->Tag = -3; - miWeather->Add (mi); - - psDeviceFlags.set (rsEnvironment,FALSE); + TMenuItem *mi = xr_new((TComponent*)0); + mi->Caption = "none"; + mi->OnClick = miWeatherClick; + mi->Tag = -1; + mi->Checked = true; + mi->RadioItem = true; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + /* + // append weathers + CEnvironment::EnvsMapIt _I=g_pGamePersistent->Environment().WeatherCycles.begin(); + CEnvironment::EnvsMapIt _E=g_pGamePersistent->Environment().WeatherCycles.end(); + for (; _I!=_E; _I++){ + mi = xr_new((TComponent*)0); + mi->Caption = *_I->first; + mi->OnClick = miWeatherClick; + mi->RadioItem = true; + miWeather->Add (mi); + } + */ + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "Reload"; + mi->OnClick = miWeatherClick; + mi->Tag = -2; + miWeather->Add(mi); + + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "Properties..."; + mi->OnClick = miWeatherClick; + mi->Tag = -3; + miWeather->Add(mi); + + psDeviceFlags.set(rsEnvironment, FALSE); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebLogClick(TObject *Sender) { - TfrmLog::ChangeVisible(); + TfrmLog::ChangeVisible(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebStopClick(TObject *Sender) { - ExecCommand(COMMAND_BREAK_LAST_OPERATION); + ExecCommand(COMMAND_BREAK_LAST_OPERATION); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebStatClick(TObject *Sender) { - psDeviceFlags.set(rsStatistic,!psDeviceFlags.is(rsStatistic)); + psDeviceFlags.set(rsStatistic, !psDeviceFlags.is(rsStatistic)); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebOptionsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { POINT pt; GetCursorPos(&pt); - pmOptions->Popup(pt.x,pt.y); - TExtBtn* btn = dynamic_cast(Sender); VERIFY(btn); btn->MouseManualUp(); + pmOptions->Popup(pt.x, pt.y); + TExtBtn *btn = dynamic_cast(Sender); + VERIFY(btn); + btn->MouseManualUp(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::pmOptionsPopup(TObject *Sender) { - miRenderWithTextures->Checked = psDeviceFlags.is(rsRenderTextures); - miLightScene->Checked = psDeviceFlags.is(rsLighting); - miMuteSounds->Checked = psDeviceFlags.is(rsMuteSounds); - miRenderLinearFilter->Checked = psDeviceFlags.is(rsFilterLinear); - miRenderEdgedFaces->Checked = psDeviceFlags.is(rsEdgedFaces); - miRealTime->Checked = psDeviceFlags.is(rsRenderRealTime); - miFog->Checked = psDeviceFlags.is(rsFog); - miDrawGrid->Checked = psDeviceFlags.is(rsDrawGrid); - miDrawSafeRect->Checked = psDeviceFlags.is(rsDrawSafeRect); - - for(int i=0; i < miWeather->Count; ++i) + miRenderWithTextures->Checked = psDeviceFlags.is(rsRenderTextures); + miLightScene->Checked = psDeviceFlags.is(rsLighting); + miMuteSounds->Checked = psDeviceFlags.is(rsMuteSounds); + miRenderLinearFilter->Checked = psDeviceFlags.is(rsFilterLinear); + miRenderEdgedFaces->Checked = psDeviceFlags.is(rsEdgedFaces); + miRealTime->Checked = psDeviceFlags.is(rsRenderRealTime); + miFog->Checked = psDeviceFlags.is(rsFog); + miDrawGrid->Checked = psDeviceFlags.is(rsDrawGrid); + miDrawSafeRect->Checked = psDeviceFlags.is(rsDrawSafeRect); + + for (int i = 0; iCount; ++i) { - TMenuItem* mi = miWeather->Items[i]; + TMenuItem *mi = miWeather->Items[i]; BOOL bch; - bch = ((EPrefs->sWeather.size()) && (0==stricmp(mi->Caption.c_str(), EPrefs->sWeather.c_str()))) || - (mi->Caption=="none" && EPrefs->sWeather.size()==0) ; - mi->Checked = bch; + bch = ((EPrefs->sWeather.size())&&(0==stricmp(mi->Caption.c_str(), EPrefs->sWeather.c_str())))|| + (mi->Caption=="none"&&EPrefs->sWeather.size()==0) ; + mi->Checked = bch; } } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::miWeatherClick(TObject *Sender) { -/* - TMenuItem* mi = dynamic_cast(Sender); - if (mi){ - if (mi->Tag==0){ - psDeviceFlags.set (rsEnvironment,TRUE); - g_pGamePersistent->Environment().SetWeather(mi->Caption.c_str()); - EPrefs->sWeather = mi->Caption.c_str(); - mi->Checked = !mi->Checked; - }else if (mi->Tag==-1){ - psDeviceFlags.set (rsEnvironment,FALSE); - g_pGamePersistent->Environment().SetWeather(0); - EPrefs->sWeather = ""; - mi->Checked = !mi->Checked; - }else if (mi->Tag==-2){ - Engine.ReloadSettings(); - g_pGamePersistent->Environment().ED_Reload(); - }else if (mi->Tag==-3){ - TProperties* P = TProperties::CreateModalForm("Weather properties"); - CEnvironment& env = g_pGamePersistent->Environment(); - PropItemVec items; - float ft=env.ed_from_time,tt=env.ed_to_time,sp=env.fTimeFactor; - PHelper().CreateTime (items,"From Time", &ft); - PHelper().CreateTime (items,"To Time", &tt); - PHelper().CreateFloat (items,"Speed", &sp, 1.f,10000.f,1.f,1); - - P->AssignItems (items); - if (mrOk==P->ShowPropertiesModal()){ - env.ed_from_time = ft; - env.ed_to_time = tt; - env.fTimeFactor = sp; + /* + TMenuItem* mi = dynamic_cast(Sender); + if (mi){ + if (mi->Tag==0){ + psDeviceFlags.set (rsEnvironment,TRUE); + g_pGamePersistent->Environment().SetWeather(mi->Caption.c_str()); + EPrefs->sWeather = mi->Caption.c_str(); + mi->Checked = !mi->Checked; + }else if (mi->Tag==-1){ + psDeviceFlags.set (rsEnvironment,FALSE); + g_pGamePersistent->Environment().SetWeather(0); + EPrefs->sWeather = ""; + mi->Checked = !mi->Checked; + }else if (mi->Tag==-2){ + Engine.ReloadSettings(); + g_pGamePersistent->Environment().ED_Reload(); + }else if (mi->Tag==-3){ + TProperties* P = TProperties::CreateModalForm("Weather properties"); + CEnvironment& env = g_pGamePersistent->Environment(); + PropItemVec items; + float ft=env.ed_from_time,tt=env.ed_to_time,sp=env.fTimeFactor; + PHelper().CreateTime (items,"From Time", &ft); + PHelper().CreateTime (items,"To Time", &tt); + PHelper().CreateFloat (items,"Speed", &sp, 1.f,10000.f,1.f,1); + + P->AssignItems (items); + if (mrOk==P->ShowPropertiesModal()){ + env.ed_from_time = ft; + env.ed_to_time = tt; + env.fTimeFactor = sp; + } + TProperties::DestroyForm(P); } - TProperties::DestroyForm(P); } - } -*/ + */ } + //--------------------------------------------------------------------------- void TfraBottomBar::RedrawBar() { - SPBItem* pbi = UI->ProgressLast(); - if (pbi){ - AnsiString txt; - float p,m; - pbi->GetInfo(txt,p,m); + SPBItem *pbi = UI->ProgressLast(); + if (pbi) + { + AnsiString txt; + float p, m; + pbi->GetInfo(txt, p, m); // status line - if (paStatus->Caption!=txt){ - paStatus->Caption = txt; - paStatus->Repaint (); + if (paStatus->Caption!=txt) + { + paStatus->Caption = txt; + paStatus->Repaint(); } // progress - int val = fis_zero(m)?0:(int)((p/m)*100); - if (val!=cgProgress->Progress){ - cgProgress->Progress = val; - cgProgress->Repaint (); + int val = fis_zero(m) ? 0 : (int)((p/m)*100); + if (val!=cgProgress->Progress) + { + cgProgress->Progress = val; + cgProgress->Repaint(); } - if (false==cgProgress->Visible) - cgProgress->Visible = true; - }else{ - if (cgProgress->Visible){ + if (false==cgProgress->Visible) + cgProgress->Visible = true; + } + else + { + if (cgProgress->Visible) + { // status line - paStatus->Caption = ""; - paStatus->Repaint (); - // progress - cgProgress->Visible = false; - cgProgress->Progress = 0; + paStatus->Caption = ""; + paStatus->Repaint(); + // progress + cgProgress->Visible = false; + cgProgress->Progress = 0; } } } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroAssignClick(TObject *Sender) { - ExecCommand(COMMAND_ASSIGN_MACRO,((TMenuItem*)Sender)->Tag,0); + ExecCommand(COMMAND_ASSIGN_MACRO, ((TMenuItem*)Sender)->Tag, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroClearClick(TObject *Sender) { - ExecCommand(COMMAND_ASSIGN_MACRO,((TMenuItem*)Sender)->Tag,xr_string("")); + ExecCommand(COMMAND_ASSIGN_MACRO, ((TMenuItem*)Sender)->Tag, xr_string("")); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroExecuteClick(TObject *Sender) { - ExecCommand(COMMAND_RUN_MACRO,((TMenuItem*)Sender)->Tag,0); + ExecCommand(COMMAND_RUN_MACRO, ((TMenuItem*)Sender)->Tag, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroLogCommandsClick(TObject *Sender) { - ExecCommand(COMMAND_LOG_COMMANDS,((TMenuItem*)Sender)->Checked,0); + ExecCommand(COMMAND_LOG_COMMANDS, ((TMenuItem*)Sender)->Checked, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroEditCommandListClick(TObject *Sender) { - ExecCommand(COMMAND_EDIT_COMMAND_LIST); + ExecCommand(COMMAND_EDIT_COMMAND_LIST); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebMacroMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - SECommand* CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; VERIFY(CMD); + SECommand *CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; + VERIFY(CMD); // fill macroses - pmMacro->Items->Clear(); - TMenuItem* mi; - for (u32 k=0; ksub_commands.size(); ++k){ - SESubCommand* SUB = CMD->sub_commands[k]; - BOOL bValid = !xr_string(SUB->p0).empty(); - mi = xr_new((TComponent*)0); - mi->Caption = AnsiString().sprintf("%d: %s",k+1,bValid?xr_string(SUB->p0).c_str():""); - TMenuItem* e = xr_new((TComponent*)0); - e->Caption = "Execute"; - e->OnClick = MacroExecuteClick; - e->Enabled = bValid; - e->Tag = k; - e->ShortCut = SUB->shortcut.hotkey; - TMenuItem* a = xr_new((TComponent*)0); - a->Caption = "Assign"; - a->OnClick = MacroAssignClick; - a->Tag = k; - TMenuItem* c = xr_new((TComponent*)0); - c->Caption = "Clear"; - c->OnClick = MacroClearClick; - c->Tag = k; - mi->Add (e); - mi->Add (a); - mi->Add (c); + pmMacro->Items->Clear(); + TMenuItem *mi; + for (u32 k = 0; ksub_commands.size(); ++k) + { + SESubCommand *SUB = CMD->sub_commands[k]; + BOOL bValid = !xr_string(SUB->p0).empty(); + mi = xr_new((TComponent*)0); + mi->Caption = AnsiString().sprintf("%d: %s", k+1, bValid ? xr_string(SUB->p0).c_str() : ""); + TMenuItem *e = xr_new((TComponent*)0); + e->Caption = "Execute"; + e->OnClick = MacroExecuteClick; + e->Enabled = bValid; + e->Tag = k; + e->ShortCut = SUB->shortcut.hotkey; + TMenuItem *a = xr_new((TComponent*)0); + a->Caption = "Assign"; + a->OnClick = MacroAssignClick; + a->Tag = k; + TMenuItem *c = xr_new((TComponent*)0); + c->Caption = "Clear"; + c->OnClick = MacroClearClick; + c->Tag = k; + mi->Add(e); + mi->Add(a); + mi->Add(c); pmMacro->Items->Add(mi); } - mi = xr_new((TComponent*)0); - mi->Caption = "-"; + mi = xr_new((TComponent*)0); + mi->Caption = "-"; pmMacro->Items->Add(mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Edit Command List..."; - mi->OnClick = MacroEditCommandListClick; + mi = xr_new((TComponent*)0); + mi->Caption = "Edit Command List..."; + mi->OnClick = MacroEditCommandListClick; pmMacro->Items->Add(mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Log Commands"; - mi->AutoCheck = true; - mi->Checked = AllowLogCommands(); - mi->OnClick = MacroLogCommandsClick; + mi = xr_new((TComponent*)0); + mi->Caption = "Log Commands"; + mi->AutoCheck = true; + mi->Checked = AllowLogCommands(); + mi->OnClick = MacroLogCommandsClick; pmMacro->Items->Add(mi); - // popup menu + // popup menu POINT pt; - GetCursorPos (&pt); - pmMacro->Popup (pt.x,pt.y); - TExtBtn* btn = dynamic_cast(Sender); VERIFY(btn); btn->MouseManualUp(); + GetCursorPos(&pt); + pmMacro->Popup(pt.x, pt.y); + TExtBtn *btn = dynamic_cast(Sender); + VERIFY(btn); + btn->MouseManualUp(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ShaderEditor/BottomBar.h b/src/editors/ShaderEditor/BottomBar.h index b1b47889d30..f208ad2cb4c 100644 --- a/src/editors/ShaderEditor/BottomBar.h +++ b/src/editors/ShaderEditor/BottomBar.h @@ -14,87 +14,89 @@ #include "CGAUGES.h" #include #include + //--------------------------------------------------------------------------- class ECORE_API TfraBottomBar : public TFrame { -__published: // IDE-managed Components - TFormStorage *fsStorage; - TMxPopupMenu *pmOptions; + __published: // IDE-managed Components + TFormStorage *fsStorage; + TMxPopupMenu *pmOptions; TMenuItem *Quality1; - TMenuItem *N25; - TMenuItem *N50; - TMenuItem *N75; - TMenuItem *N100; - TMenuItem *N125; - TMenuItem *N150; - TMenuItem *N200; + TMenuItem *N25; + TMenuItem *N50; + TMenuItem *N75; + TMenuItem *N100; + TMenuItem *N125; + TMenuItem *N150; + TMenuItem *N200; TMenuItem *N2; TMenuItem *miDrawGrid; - TMenuItem *Render1; - TMenuItem *FillMode1; - TMenuItem *miRenderFillSolid; - TMenuItem *miRenderFillWireframe; - TMenuItem *miRenderFillPoint; - TMenuItem *ShadeMode1; - TMenuItem *miRenderShadeGouraud; - TMenuItem *miRenderShadeFlat; - TMenuItem *miRenderEdgedFaces; - TMenuItem *miRenderHWTransform; - TMenuItem *miRenderLinearFilter; - TMenuItem *miRenderWithTextures; - TMenuItem *N7; - TMenuItem *N8; - TMenuItem *miLightScene; - TMenuItem *miFog; - TMenuItem *miRealTime; + TMenuItem *Render1; + TMenuItem *FillMode1; + TMenuItem *miRenderFillSolid; + TMenuItem *miRenderFillWireframe; + TMenuItem *miRenderFillPoint; + TMenuItem *ShadeMode1; + TMenuItem *miRenderShadeGouraud; + TMenuItem *miRenderShadeFlat; + TMenuItem *miRenderEdgedFaces; + TMenuItem *miRenderHWTransform; + TMenuItem *miRenderLinearFilter; + TMenuItem *miRenderWithTextures; + TMenuItem *N7; + TMenuItem *N8; + TMenuItem *miLightScene; + TMenuItem *miFog; + TMenuItem *miRealTime; TMenuItem *N1; - TPanel *paBottomBar; - TPanel *paInfo; - TPanel *paStatusBar; - TPanel *paTools; - TExtBtn *ebOptions; - TExtBtn *ebLog; - TExtBtn *ebStat; - TExtBtn *ebStop; - TPanel *paStatusLabel; - TPanel *paStatus; - TCGauge *cgProgress; - TPanel *paSel; - TPanel *paGridSquareSize; - TPanel *paUICursor; - TPanel *paCamera; - TMenuItem *miDrawSafeRect; - TMenuItem *miMuteSounds; - TMenuItem *N5; - TMenuItem *miWeather; - TMenuItem *miWeatherNone; - TMenuItem *N6; - TExtBtn *ebMacro; - TMxPopupMenu *pmMacro; + TPanel *paBottomBar; + TPanel *paInfo; + TPanel *paStatusBar; + TPanel *paTools; + TExtBtn *ebOptions; + TExtBtn *ebLog; + TExtBtn *ebStat; + TExtBtn *ebStop; + TPanel *paStatusLabel; + TPanel *paStatus; + TCGauge *cgProgress; + TPanel *paSel; + TPanel *paGridSquareSize; + TPanel *paUICursor; + TPanel *paCamera; + TMenuItem *miDrawSafeRect; + TMenuItem *miMuteSounds; + TMenuItem *N5; + TMenuItem *miWeather; + TMenuItem *miWeatherNone; + TMenuItem *N6; + TExtBtn *ebMacro; + TMxPopupMenu *pmMacro; void __fastcall ClickOptionsMenuItem(TObject *Sender); void __fastcall QualityClick(TObject *Sender); void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall ebLogClick(TObject *Sender); - void __fastcall ebStopClick(TObject *Sender); - void __fastcall ebStatClick(TObject *Sender); - void __fastcall ebOptionsMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall pmOptionsPopup(TObject *Sender); - void __fastcall miWeatherClick(TObject *Sender); - void __fastcall ebMacroMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); -private: // User declarations - void __fastcall MacroAssignClick(TObject *Sender); - void __fastcall MacroClearClick(TObject *Sender); - void __fastcall MacroExecuteClick(TObject *Sender); - void __fastcall MacroLogCommandsClick(TObject *Sender); - void __fastcall MacroEditCommandListClick(TObject *Sender); -public: // User declarations + void __fastcall ebLogClick(TObject *Sender); + void __fastcall ebStopClick(TObject *Sender); + void __fastcall ebStatClick(TObject *Sender); + void __fastcall ebOptionsMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall pmOptionsPopup(TObject *Sender); + void __fastcall miWeatherClick(TObject *Sender); + void __fastcall ebMacroMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + private: // User declarations + void __fastcall MacroAssignClick(TObject *Sender); + void __fastcall MacroClearClick(TObject *Sender); + void __fastcall MacroExecuteClick(TObject *Sender); + void __fastcall MacroLogCommandsClick(TObject *Sender); + void __fastcall MacroEditCommandListClick(TObject *Sender); + public: // User declarations __fastcall TfraBottomBar(TComponent* Owner); void RefreshBar(){;} - void RedrawBar(); +void RedrawBar(); }; //--------------------------------------------------------------------------- -extern PACKAGE TfraBottomBar *fraBottomBar; +extern PACKAGE TfraBottomBar * fraBottomBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ShaderEditor/GameMtlLib_Editor.cpp b/src/editors/ShaderEditor/GameMtlLib_Editor.cpp index e693105ad3e..42ebfcfd550 100644 --- a/src/editors/ShaderEditor/GameMtlLib_Editor.cpp +++ b/src/editors/ShaderEditor/GameMtlLib_Editor.cpp @@ -2,53 +2,54 @@ #include "stdafx.h" #pragma hdrstop -#include "GameMtlLib.h" +#include "xrEngine/GameMtlLib.h" #include "xr_trims.h" -#include "../../xrServerEntities/PropertiesListTypes.h" -#include "../../xrServerEntities/PropertiesListHelper.h" -#include "../xrEProps/FolderLib.h" +#include "xrServerEntities/PropertiesListTypes.h" +#include "xrServerEntities/PropertiesListHelper.h" +#include "editors/xrEProps/FolderLib.h" #include "LeftBar.h" -#include "../xrEProps/ChoseForm.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/xrEProps/ChoseForm.h" +#include "editors/ECore/Editor/ui_main.h" //------------------------------------------------------------------------------ // material routines //------------------------------------------------------------------------------ -void SGameMtl::FillProp (PropItemVec& items, ListItem* owner) -{ - PropValue* V=0; - PHelper().CreateName (items, "Name", &m_Name, owner); - PHelper().CreateRText (items, "Desc", &m_Desc); - // flags - V=PHelper().CreateFlag32 (items, "Flags\\Dynamic", &Flags, flDynamic); V->Owner()->Enable(FALSE); - PHelper().CreateFlag32 (items, "Flags\\Passable", &Flags, flPassable); +void SGameMtl::FillProp(PropItemVec &items, ListItem *owner) +{ + PropValue *V = 0; + PHelper().CreateName(items, "Name", &m_Name, owner); + PHelper().CreateRText(items, "Desc", &m_Desc); + // flags + V = PHelper().CreateFlag32(items, "Flags\\Dynamic", &Flags, flDynamic); + V->Owner()->Enable(FALSE); + PHelper().CreateFlag32(items, "Flags\\Passable", &Flags, flPassable); if (Flags.is(flDynamic)) - PHelper().CreateFlag32 (items, "Flags\\Breakable", &Flags, flBreakable); - PHelper().CreateFlag32 (items, "Flags\\Bounceable", &Flags, flBounceable); - PHelper().CreateFlag32 (items, "Flags\\Skidmark", &Flags, flSkidmark); - PHelper().CreateFlag32 (items, "Flags\\Bloodmark", &Flags, flBloodmark); - PHelper().CreateFlag32 (items, "Flags\\Climable", &Flags, flClimable); - PHelper().CreateFlag32 (items, "Flags\\Liquid", &Flags, flLiquid); - PHelper().CreateFlag32 (items, "Flags\\Suppress Shadows", &Flags, flSuppressShadows); - PHelper().CreateFlag32 (items, "Flags\\Suppress Wallmarks", &Flags, flSuppressWallmarks); - PHelper().CreateFlag32 (items, "Flags\\Actor Obstacle", &Flags, flActorObstacle); - PHelper().CreateFlag32 (items, "Flags\\Bullet No Ricoshet", &Flags, flNoRicoshet); + PHelper().CreateFlag32(items, "Flags\\Breakable", &Flags, flBreakable); + PHelper().CreateFlag32(items, "Flags\\Bounceable", &Flags, flBounceable); + PHelper().CreateFlag32(items, "Flags\\Skidmark", &Flags, flSkidmark); + PHelper().CreateFlag32(items, "Flags\\Bloodmark", &Flags, flBloodmark); + PHelper().CreateFlag32(items, "Flags\\Climable", &Flags, flClimable); + PHelper().CreateFlag32(items, "Flags\\Liquid", &Flags, flLiquid); + PHelper().CreateFlag32(items, "Flags\\Suppress Shadows", &Flags, flSuppressShadows); + PHelper().CreateFlag32(items, "Flags\\Suppress Wallmarks", &Flags, flSuppressWallmarks); + PHelper().CreateFlag32(items, "Flags\\Actor Obstacle", &Flags, flActorObstacle); + PHelper().CreateFlag32(items, "Flags\\Bullet No Ricoshet", &Flags, flNoRicoshet); // physics part - PHelper().CreateFloat (items, "Physics\\Friction", &fPHFriction, 0.f, 100.f, 0.001f, 3); - PHelper().CreateFloat (items, "Physics\\Damping", &fPHDamping, 0.001f, 100.f, 0.001f, 3); - PHelper().CreateFloat (items, "Physics\\Spring", &fPHSpring, 0.001f, 100.f, 0.001f, 3); - PHelper().CreateFloat (items, "Physics\\Bounce start vel", &fPHBounceStartVelocity,0.f, 100.f, 0.01f, 2); - PHelper().CreateFloat (items, "Physics\\Bouncing", &fPHBouncing, 0.f, 1.f, 0.001f, 3); + PHelper().CreateFloat(items, "Physics\\Friction", &fPHFriction, 0.f, 100.f, 0.001f, 3); + PHelper().CreateFloat(items, "Physics\\Damping", &fPHDamping, 0.001f, 100.f, 0.001f, 3); + PHelper().CreateFloat(items, "Physics\\Spring", &fPHSpring, 0.001f, 100.f, 0.001f, 3); + PHelper().CreateFloat(items, "Physics\\Bounce start vel", &fPHBounceStartVelocity, 0.f, 100.f, 0.01f, 2); + PHelper().CreateFloat(items, "Physics\\Bouncing", &fPHBouncing, 0.f, 1.f, 0.001f, 3); // factors - PHelper().CreateFloat (items, "Factors\\Bounce Damage", &fBounceDamageFactor, 0.f,100.f,0.1f,1); - PHelper().CreateFloat (items, "Factors\\Injurious", &fInjuriousSpeed, 0.f,10000.f); - PHelper().CreateFloat (items, "Factors\\Shooting (1-went through)", &fShootFactor); - PHelper().CreateFloat (items, "Factors\\Shooting MP (1-went through)", &fShootFactorMP); - PHelper().CreateFloat (items, "Factors\\Transparency (1-full transp)", &fVisTransparencyFactor); - PHelper().CreateFloat (items, "Factors\\Sound occlusion (1-full hear)", &fSndOcclusionFactor); - PHelper().CreateFloat (items, "Factors\\Flotation (1-full passable)", &fFlotationFactor); + PHelper().CreateFloat(items, "Factors\\Bounce Damage", &fBounceDamageFactor, 0.f, 100.f, 0.1f, 1); + PHelper().CreateFloat(items, "Factors\\Injurious", &fInjuriousSpeed, 0.f, 10000.f); + PHelper().CreateFloat(items, "Factors\\Shooting (1-went through)", &fShootFactor); + PHelper().CreateFloat(items, "Factors\\Shooting MP (1-went through)", &fShootFactorMP); + PHelper().CreateFloat(items, "Factors\\Transparency (1-full transp)", &fVisTransparencyFactor); + PHelper().CreateFloat(items, "Factors\\Sound occlusion (1-full hear)", &fSndOcclusionFactor); + PHelper().CreateFloat(items, "Factors\\Flotation (1-full passable)", &fFlotationFactor); - PHelper().CreateFloat (items, "Factors\\Density Factor", &fDensityFactor, 0.0f, 1000.0f, 1.0f, 1); + PHelper().CreateFloat(items, "Factors\\Density Factor", &fDensityFactor, 0.0f, 1000.0f, 1.0f, 1); } SGameMtlPair::SGameMtlPair(const SGameMtlPair &src) @@ -66,30 +67,32 @@ void CGameMtlLibrary::CopyMtlPairs(SGameMtl *src, SGameMtl *dst) { for (auto &mtl : materials) { - SGameMtlPair *srcPair = GetMaterialPair(src->GetID(), mtl->GetID()); - SGameMtlPair *dstPair = GetMaterialPair(dst->GetID(), mtl->GetID()); - if (srcPair && dstPair) - new (dstPair)SGameMtlPair(*srcPair); + SGameMtlPair*srcPair = GetMaterialPair(src->GetID(), mtl->GetID()); + SGameMtlPair*dstPair = GetMaterialPair(dst->GetID(), mtl->GetID()); + if (srcPair&&dstPair) + new(dstPair)SGameMtlPair(*srcPair); } } -BOOL CGameMtlLibrary::UpdateMtlPairs(SGameMtl* src) +BOOL CGameMtlLibrary::UpdateMtlPairs(SGameMtl *src) { - BOOL bRes = FALSE; - SGameMtl* M0 = src; - for (GameMtlIt m1_it=materials.begin(); m1_it!=materials.end(); ++m1_it) + BOOL bRes = FALSE; + SGameMtl *M0 = src; + for (GameMtlIt m1_it = materials.begin(); m1_it!=materials.end(); ++m1_it) { - SGameMtl* M1 = *m1_it; - GameMtlPairIt p_it = GetMaterialPairIt(M0->GetID(),M1->GetID()); + SGameMtl *M1 = *m1_it; + GameMtlPairIt p_it = GetMaterialPairIt(M0->GetID(), M1->GetID()); if ((!M0->Flags.is(SGameMtl::flDynamic))&&(!M1->Flags.is(SGameMtl::flDynamic))) { - R_ASSERT (p_it==material_pairs.end()); + R_ASSERT(p_it==material_pairs.end()); continue; - }else{ - if (p_it==material_pairs.end()) + } + else + { + if (p_it==material_pairs.end()) { // create pair - CreateMaterialPair(M0->GetID(),M1->GetID(),0); + CreateMaterialPair(M0->GetID(), M1->GetID(), 0); bRes = TRUE; } } @@ -99,47 +102,51 @@ BOOL CGameMtlLibrary::UpdateMtlPairs(SGameMtl* src) BOOL CGameMtlLibrary::UpdateMtlPairs() { - BOOL bRes = FALSE; - for (GameMtlIt m0_it=materials.begin(); m0_it!=materials.end(); m0_it++) - if (UpdateMtlPairs(*m0_it)) bRes = TRUE; + BOOL bRes = FALSE; + for (GameMtlIt m0_it = materials.begin(); m0_it!=materials.end(); m0_it++) + if (UpdateMtlPairs(*m0_it)) + bRes = TRUE; return bRes; } -SGameMtl* CGameMtlLibrary::AppendMaterial(SGameMtl* parent) +SGameMtl *CGameMtlLibrary::AppendMaterial(SGameMtl *parent) { - SGameMtl* M = xr_new(); - if (parent) - *M =*parent;//base params - - M->ID = material_index++; - - materials.push_back (M); - UpdateMtlPairs (M); - CopyMtlPairs (parent, M); - return M; + SGameMtl *M = xr_new(); + if (parent) + *M = *parent;//base params + + M->ID = material_index++; + + materials.push_back(M); + UpdateMtlPairs(M); + CopyMtlPairs(parent, M); + return M; } + void CGameMtlLibrary::RemoveMaterial(LPCSTR name) { // find material - GameMtlIt rem_it=GetMaterialIt(name); - R_ASSERT (rem_it!=materials.end()); + GameMtlIt rem_it = GetMaterialIt(name); + R_ASSERT(rem_it!=materials.end()); // remove dependent pairs RemoveMaterialPair((*rem_it)->GetID()); // destroy material - xr_delete (*rem_it); - materials.erase (rem_it); + xr_delete(*rem_it); + materials.erase(rem_it); } //------------------------------------------------------------------------------ // material pair routines //------------------------------------------------------------------------------ -static IC bool ValidateParent(const SGameMtlPair *who, const SGameMtlPair *parent) +static IC + +bool ValidateParent(const SGameMtlPair *who, const SGameMtlPair *parent) { if (!parent) return true; - if (who == parent) + if (who==parent) return false; return ValidateParent(who, parent->m_Owner->GetMaterialPair(parent->GetParent())); } @@ -148,7 +155,7 @@ bool SGameMtlPair::SetParent(int parentId) { int ID_parent_save = ID_parent; ID_parent = parentId; - for (GameMtlPairIt it = m_Owner->FirstMaterialPair(); it != m_Owner->LastMaterialPair(); it++) + for (GameMtlPairIt it = m_Owner->FirstMaterialPair(); it!=m_Owner->LastMaterialPair(); it++) { if (!ValidateParent(*it, m_Owner->GetMaterialPair((*it)->GetParent()))) { @@ -157,7 +164,7 @@ bool SGameMtlPair::SetParent(int parentId) } } // all right - if (GAMEMTL_NONE_ID == ID_parent) + if (GAMEMTL_NONE_ID==ID_parent) OwnProps.one(); else { @@ -171,303 +178,382 @@ bool SGameMtlPair::SetParent(int parentId) return true; } -void __fastcall SGameMtlPair::OnFlagChange(PropValue* sender) -{ - bool bChecked = sender->Owner()->m_Flags.is(PropItem::flCBChecked); - u32 mask=0; - if (sender==propBreakingSounds) mask = flBreakingSounds; - else if (sender==propStepSounds) mask = flStepSounds; - else if (sender==propCollideSounds) mask = flCollideSounds; - else if (sender==propCollideParticles) mask = flCollideParticles; - else if (sender==propCollideMarks) mask = flCollideMarks; - else THROW; +void __fastcall SGameMtlPair::OnFlagChange(PropValue *sender) +{ + bool bChecked = sender->Owner()->m_Flags.is(PropItem::flCBChecked); + u32 mask = 0; + if (sender==propBreakingSounds) + mask = flBreakingSounds; + else if (sender==propStepSounds) + mask = flStepSounds; + else if (sender==propCollideSounds) + mask = flCollideSounds; + else if (sender==propCollideParticles) + mask = flCollideParticles; + else if (sender==propCollideMarks) + mask = flCollideMarks; + else + THROW; - OwnProps.set (mask,bChecked); - sender->Owner()->m_Flags.set(PropItem::flDisabled,!bChecked); + OwnProps.set(mask, bChecked); + sender->Owner()->m_Flags.set(PropItem::flDisabled, !bChecked); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -IC u32 SetMask(u32 mask, Flags32 flags, u32 flag ) +IC u32 SetMask(u32 mask, Flags32 flags, u32 flag) { - return mask?(mask|(flags.is(flag)?PropItem::flCBChecked:PropItem::flDisabled)):0; + return mask ? (mask|(flags.is(flag) ? PropItem::flCBChecked : PropItem::flDisabled)) : 0; } -IC SGameMtlPair* GetLastParentValue(SGameMtlPair* who, u32 flag) +IC SGameMtlPair*GetLastParentValue(SGameMtlPair *who, u32 flag) { - if (!who) return 0; - if ((GAMEMTL_NONE_ID==who->GetParent())||(who->OwnProps.is(flag))) return who; - else return GetLastParentValue(who->m_Owner->GetMaterialPair(who->GetParent()),flag); + if (!who) + return 0; + if ((GAMEMTL_NONE_ID==who->GetParent())||(who->OwnProps.is(flag))) + return who; + else + return GetLastParentValue(who->m_Owner->GetMaterialPair(who->GetParent()), flag); } -void __fastcall SGameMtlPair::FillChooseMtl(ChooseItemVec& items, void* param) +void __fastcall SGameMtlPair::FillChooseMtl(ChooseItemVec &items, void *param) { - for (GameMtlIt m0_it=m_Owner->FirstMaterial(); m0_it!=m_Owner->LastMaterial(); m0_it++){ - SGameMtl* M0 = *m0_it; - for (GameMtlIt m1_it=m_Owner->FirstMaterial(); m1_it!=m_Owner->LastMaterial(); m1_it++){ - SGameMtl* M1 = *m1_it; - GameMtlPairIt p_it = GMLib.GetMaterialPairIt(M0->GetID(),M1->GetID()); + for (GameMtlIt m0_it = m_Owner->FirstMaterial(); m0_it!=m_Owner->LastMaterial(); m0_it++) + { + SGameMtl *M0 = *m0_it; + for (GameMtlIt m1_it = m_Owner->FirstMaterial(); m1_it!=m_Owner->LastMaterial(); m1_it++) + { + SGameMtl *M1 = *m1_it; + GameMtlPairIt p_it = GMLib.GetMaterialPairIt(M0->GetID(), M1->GetID()); if (p_it!=GMLib.LastMaterialPair()) - items.push_back (SChooseItem(GMLib.MtlPairToName(M0->GetID(),M1->GetID()),"")); + items.push_back(SChooseItem(GMLib.MtlPairToName(M0->GetID(), M1->GetID()), "")); } } } -void __fastcall SGameMtlPair::OnParentClick(ButtonValue* V, bool& bModif, bool& bSafe) +void __fastcall SGameMtlPair::OnParentClick(ButtonValue *V, bool &bModif, bool &bSafe) { bModif = false; - switch (V->btn_num){ - case 0:{ - LPCSTR MP=0; - SGameMtlPair* P = m_Owner->GetMaterialPair(ID_parent); - AnsiString nm = P?m_Owner->MtlPairToName(P->GetMtl0(),P->GetMtl1()):NONE_CAPTION; - - if (TfrmChoseItem::SelectItem(smCustom,MP,1,(nm==NONE_CAPTION)?0:nm.c_str(),fastdelegate::bind(this,&SGameMtlPair::FillChooseMtl))){ - if (MP){ - int m0, m1; - m_Owner->NameToMtlPair (MP,m0,m1); - SGameMtlPair* p = m_Owner->GetMaterialPair(m0,m1); VERIFY(p); - if (!SetParent (p->GetID())){ - ELog.DlgMsg(mtError,"Pair can't inherit from self."); - }else{ - bModif = true; - ExecCommand (COMMAND_UPDATE_PROPERTIES); + switch (V->btn_num) + { + case 0: + { + LPCSTR MP = 0; + SGameMtlPair *P = m_Owner->GetMaterialPair(ID_parent); + AnsiString nm = P ? m_Owner->MtlPairToName(P->GetMtl0(), P->GetMtl1()) : NONE_CAPTION; + + if (TfrmChoseItem::SelectItem(smCustom, MP, 1, (nm==NONE_CAPTION) ? 0 : nm.c_str(), fastdelegate::bind(this, &SGameMtlPair::FillChooseMtl))) + { + if (MP) + { + int m0, m1; + m_Owner->NameToMtlPair(MP, m0, m1); + SGameMtlPair *p = m_Owner->GetMaterialPair(m0, m1); + VERIFY(p); + if (!SetParent(p->GetID())) + { + ELog.DlgMsg(mtError, "Pair can't inherit from self."); + } + else + { + bModif = true; + ExecCommand(COMMAND_UPDATE_PROPERTIES); + } + } + else + { + SetParent(GAMEMTL_NONE_ID); + bModif = true; + ExecCommand(COMMAND_UPDATE_PROPERTIES); } - }else{ - SetParent (GAMEMTL_NONE_ID); - bModif = true; - ExecCommand (COMMAND_UPDATE_PROPERTIES); } } - }break; - } + break; + } } -void __fastcall SGameMtlPair::OnCommandClick(ButtonValue* V, bool& bModif, bool& bSafe) +void __fastcall SGameMtlPair::OnCommandClick(ButtonValue *V, bool &bModif, bool &bSafe) { bModif = false; - switch (V->btn_num){ - case 0:{ - LPCSTR MP=0; - SGameMtlPair* P = m_Owner->GetMaterialPair(ID_parent); - AnsiString nm = P?m_Owner->MtlPairToName(P->GetMtl0(),P->GetMtl1()):NONE_CAPTION; - if (TfrmChoseItem::SelectItem(smCustom,MP,128,0,fastdelegate::bind(this,&SGameMtlPair::FillChooseMtl))){ - if (MP){ - AStringVec lst; - _SequenceToList(lst,MP); - for (AStringIt it=lst.begin(); it!=lst.end(); it++){ - int m0, m1; - m_Owner->NameToMtlPair (it->c_str(),m0,m1); - SGameMtlPair* p = m_Owner->GetMaterialPair(m0,m1); VERIFY(p); - if (!p->SetParent(GetID())){ - ELog.DlgMsg(mtError,"Pair can't inherit from self."); - }else{ - bModif = true; + switch (V->btn_num) + { + case 0: + { + LPCSTR MP = 0; + SGameMtlPair *P = m_Owner->GetMaterialPair(ID_parent); + AnsiString nm = P ? m_Owner->MtlPairToName(P->GetMtl0(), P->GetMtl1()) : NONE_CAPTION; + if (TfrmChoseItem::SelectItem(smCustom, MP, 128, 0, fastdelegate::bind(this, &SGameMtlPair::FillChooseMtl))) + { + if (MP) + { + AStringVec lst; + _SequenceToList(lst, MP); + for (AStringIt it = lst.begin(); it!=lst.end(); it++) + { + int m0, m1; + m_Owner->NameToMtlPair(it->c_str(), m0, m1); + SGameMtlPair *p = m_Owner->GetMaterialPair(m0, m1); + VERIFY(p); + if (!p->SetParent(GetID())) + { + ELog.DlgMsg(mtError, "Pair can't inherit from self."); + } + else + { + bModif = true; + } } + if (bModif) + ExecCommand(COMMAND_UPDATE_PROPERTIES); } - if (bModif) ExecCommand(COMMAND_UPDATE_PROPERTIES); } } - }break; - } + break; + } } -void SGameMtlPair::FillProp(PropItemVec& items) +void SGameMtlPair::FillProp(PropItemVec &items) { - PropValue::TOnChange OnChange = 0; - u32 show_CB = 0; - SGameMtlPair* P = 0; - if (ID_parent!=GAMEMTL_NONE_ID){ - OnChange.bind (this,&SGameMtlPair::OnFlagChange); - show_CB = PropItem::flShowCB; - P = m_Owner->GetMaterialPair(ID_parent); + PropValue::TOnChange OnChange = 0; + u32 show_CB = 0; + SGameMtlPair *P = 0; + if (ID_parent!=GAMEMTL_NONE_ID) + { + OnChange.bind(this, &SGameMtlPair::OnFlagChange); + show_CB = PropItem::flShowCB; + P = m_Owner->GetMaterialPair(ID_parent); } - ButtonValue* B; - B = PHelper().CreateButton(items, "Command", "Set As Parent To...",0); - B->OnBtnClickEvent.bind(this,&SGameMtlPair::OnCommandClick); - B = PHelper().CreateButton(items, "Parent", P?m_Owner->MtlPairToName(P->GetMtl0(),P->GetMtl1()):NONE_CAPTION,0); - B->OnBtnClickEvent.bind(this,&SGameMtlPair::OnParentClick); - - propBreakingSounds = PHelper().CreateChoose (items, "Breaking Sounds", &BreakingSounds, smSoundSource, 0,0, GAMEMTL_SUBITEM_COUNT); - propStepSounds = PHelper().CreateChoose (items, "Step Sounds", &StepSounds, smSoundSource, 0,0, GAMEMTL_SUBITEM_COUNT+2); - propCollideSounds = PHelper().CreateChoose (items, "Collide Sounds", &CollideSounds, smSoundSource, 0,0, GAMEMTL_SUBITEM_COUNT); - propCollideParticles= PHelper().CreateChoose (items, "Collide Particles",&CollideParticles, smParticles, 0,0, GAMEMTL_SUBITEM_COUNT); - propCollideMarks = PHelper().CreateChoose (items, "Collide Marks", &CollideMarks, smTexture, 0,0, GAMEMTL_SUBITEM_COUNT); - - propBreakingSounds->Owner()->m_Flags.assign (SetMask(show_CB,OwnProps,flBreakingSounds)); - propStepSounds->Owner()->m_Flags.assign (SetMask(show_CB,OwnProps,flStepSounds)); - propCollideSounds->Owner()->m_Flags.assign (SetMask(show_CB,OwnProps,flCollideSounds)); - propCollideParticles->Owner()->m_Flags.assign(SetMask(show_CB,OwnProps,flCollideParticles)); - propCollideMarks->Owner()->m_Flags.assign (SetMask(show_CB,OwnProps,flCollideMarks)); - - propBreakingSounds->OnChangeEvent = OnChange; - propStepSounds->OnChangeEvent = OnChange; - propCollideSounds->OnChangeEvent = OnChange; - propCollideParticles->OnChangeEvent = OnChange; - propCollideMarks->OnChangeEvent = OnChange; + ButtonValue *B; + B = PHelper().CreateButton(items, "Command", "Set As Parent To...", 0); + B->OnBtnClickEvent.bind(this, &SGameMtlPair::OnCommandClick); + B = PHelper().CreateButton(items, "Parent", P ? m_Owner->MtlPairToName(P->GetMtl0(), P->GetMtl1()) : NONE_CAPTION, 0); + B->OnBtnClickEvent.bind(this, &SGameMtlPair::OnParentClick); + + propBreakingSounds = PHelper().CreateChoose(items, "Breaking Sounds", &BreakingSounds, smSoundSource, 0, 0, GAMEMTL_SUBITEM_COUNT); + propStepSounds = PHelper().CreateChoose(items, "Step Sounds", &StepSounds, smSoundSource, 0, 0, GAMEMTL_SUBITEM_COUNT+2); + propCollideSounds = PHelper().CreateChoose(items, "Collide Sounds", &CollideSounds, smSoundSource, 0, 0, GAMEMTL_SUBITEM_COUNT); + propCollideParticles = PHelper().CreateChoose(items, "Collide Particles", &CollideParticles, smParticles, 0, 0, GAMEMTL_SUBITEM_COUNT); + propCollideMarks = PHelper().CreateChoose(items, "Collide Marks", &CollideMarks, smTexture, 0, 0, GAMEMTL_SUBITEM_COUNT); + + propBreakingSounds->Owner()->m_Flags.assign(SetMask(show_CB, OwnProps, flBreakingSounds)); + propStepSounds->Owner()->m_Flags.assign(SetMask(show_CB, OwnProps, flStepSounds)); + propCollideSounds->Owner()->m_Flags.assign(SetMask(show_CB, OwnProps, flCollideSounds)); + propCollideParticles->Owner()->m_Flags.assign(SetMask(show_CB, OwnProps, flCollideParticles)); + propCollideMarks->Owner()->m_Flags.assign(SetMask(show_CB, OwnProps, flCollideMarks)); + + propBreakingSounds->OnChangeEvent = OnChange; + propStepSounds->OnChangeEvent = OnChange; + propCollideSounds->OnChangeEvent = OnChange; + propCollideParticles->OnChangeEvent = OnChange; + propCollideMarks->OnChangeEvent = OnChange; if (show_CB) { - SGameMtlPair* O; - if (0!=(O=GetLastParentValue(this,flBreakingSounds))) BreakingSounds = O->BreakingSounds; - if (0!=(O=GetLastParentValue(this,flStepSounds))) StepSounds = O->StepSounds; - if (0!=(O=GetLastParentValue(this,flCollideSounds))) CollideSounds = O->CollideSounds; - if (0!=(O=GetLastParentValue(this,flCollideParticles))) CollideParticles= O->CollideParticles; - if (0!=(O=GetLastParentValue(this,flCollideMarks))) CollideMarks = O->CollideMarks; + SGameMtlPair *O; + if (0!=(O = GetLastParentValue(this, flBreakingSounds))) + BreakingSounds = O->BreakingSounds; + if (0!=(O = GetLastParentValue(this, flStepSounds))) + StepSounds = O->StepSounds; + if (0!=(O = GetLastParentValue(this, flCollideSounds))) + CollideSounds = O->CollideSounds; + if (0!=(O = GetLastParentValue(this, flCollideParticles))) + CollideParticles = O->CollideParticles; + if (0!=(O = GetLastParentValue(this, flCollideMarks))) + CollideMarks = O->CollideMarks; } } -void SGameMtlPair::TransferFromParent(SGameMtlPair* parent) +void SGameMtlPair::TransferFromParent(SGameMtlPair *parent) { R_ASSERT(parent); - if (!OwnProps.is(flBreakingSounds)) BreakingSounds = parent->BreakingSounds; - if (!OwnProps.is(flStepSounds)) StepSounds = parent->StepSounds; - if (!OwnProps.is(flCollideSounds)) CollideSounds = parent->CollideSounds; - if (!OwnProps.is(flCollideParticles)) CollideParticles= parent->CollideParticles; - if (!OwnProps.is(flCollideMarks)) CollideMarks = parent->CollideMarks; + if (!OwnProps.is(flBreakingSounds)) + BreakingSounds = parent->BreakingSounds; + if (!OwnProps.is(flStepSounds)) + StepSounds = parent->StepSounds; + if (!OwnProps.is(flCollideSounds)) + CollideSounds = parent->CollideSounds; + if (!OwnProps.is(flCollideParticles)) + CollideParticles = parent->CollideParticles; + if (!OwnProps.is(flCollideMarks)) + CollideMarks = parent->CollideMarks; } -void SGameMtlPair::CopyFrom(SGameMtlPair* parent) +void SGameMtlPair::CopyFrom(SGameMtlPair *parent) { - R_ASSERT (parent); - OwnProps = parent->OwnProps; - ID_parent = parent->ID_parent; - - BreakingSounds = parent->BreakingSounds; - + R_ASSERT(parent); + OwnProps = parent->OwnProps; + ID_parent = parent->ID_parent; + + BreakingSounds = parent->BreakingSounds; + + + StepSounds = parent->StepSounds; - StepSounds = parent->StepSounds; - - CollideSounds = parent->CollideSounds; - - CollideParticles = parent->CollideParticles; - - CollideMarks = parent->CollideMarks; + CollideSounds = parent->CollideSounds; + + CollideParticles = parent->CollideParticles; + + CollideMarks = parent->CollideMarks; } //------------------------------------------------------------------------------ // material library routines //------------------------------------------------------------------------------ -LPCSTR CGameMtlLibrary::MtlPairToName (int mtl0, int mtl1) +LPCSTR CGameMtlLibrary::MtlPairToName(int mtl0, int mtl1) { static string512 buf; - SGameMtl* M0 = GetMaterialByID(mtl0); R_ASSERT(M0); - SGameMtl* M1 = GetMaterialByID(mtl1); R_ASSERT(M1); + SGameMtl *M0 = GetMaterialByID(mtl0); + R_ASSERT(M0); + SGameMtl *M1 = GetMaterialByID(mtl1); + R_ASSERT(M1); string256 buf0, buf1; - strcpy (buf0,*M0->m_Name); _ChangeSymbol (buf0,'\\','/'); - strcpy (buf1,*M1->m_Name); _ChangeSymbol (buf1,'\\','/'); - sprintf (buf,"%s \\ %s",buf0,buf1); + strcpy(buf0, *M0->m_Name); + _ChangeSymbol(buf0, '\\', '/'); + strcpy(buf1, *M1->m_Name); + _ChangeSymbol(buf1, '\\', '/'); + sprintf(buf, "%s \\ %s", buf0, buf1); return buf; } -void CGameMtlLibrary::NameToMtlPair (LPCSTR name, int& mtl0, int& mtl1) + +void CGameMtlLibrary::NameToMtlPair(LPCSTR name, int &mtl0, int &mtl1) { - string256 buf0, buf1; - if (_GetItemCount(name,'\\')<2){ - mtl0 = GAMEMTL_NONE_ID; - mtl1 = GAMEMTL_NONE_ID; - return; + string256 buf0, buf1; + if (_GetItemCount(name, '\\')<2) + { + mtl0 = GAMEMTL_NONE_ID; + mtl1 = GAMEMTL_NONE_ID; + return; } - _GetItem (name,0,buf0,'\\'); - _GetItem (name,1,buf1,'\\'); - _ChangeSymbol (buf0,'/','\\'); - _ChangeSymbol (buf1,'/','\\'); - SGameMtl* M0 = GetMaterial(buf0); mtl0=M0?M0->GetID():GAMEMTL_NONE_ID; - SGameMtl* M1 = GetMaterial(buf1); mtl1=M1?M1->GetID():GAMEMTL_NONE_ID; + _GetItem(name, 0, buf0, '\\'); + _GetItem(name, 1, buf1, '\\'); + _ChangeSymbol(buf0, '/', '\\'); + _ChangeSymbol(buf1, '/', '\\'); + SGameMtl *M0 = GetMaterial(buf0); + mtl0 = M0 ? M0->GetID() : GAMEMTL_NONE_ID; + SGameMtl *M1 = GetMaterial(buf1); + mtl1 = M1 ? M1->GetID() : GAMEMTL_NONE_ID; } -void CGameMtlLibrary::MtlNameToMtlPair (LPCSTR name, int& mtl0, int& mtl1) + +void CGameMtlLibrary::MtlNameToMtlPair(LPCSTR name, int &mtl0, int &mtl1) { string256 buf; - SGameMtl* M0 = GetMaterial(_GetItem(name,0,buf,',')); R_ASSERT(M0); mtl0=M0->GetID(); - SGameMtl* M1 = GetMaterial(_GetItem(name,1,buf,',')); R_ASSERT(M1); mtl1=M1->GetID(); + SGameMtl *M0 = GetMaterial(_GetItem(name, 0, buf, ',')); + R_ASSERT(M0); + mtl0 = M0->GetID(); + SGameMtl *M1 = GetMaterial(_GetItem(name, 1, buf, ',')); + R_ASSERT(M1); + mtl1 = M1->GetID(); } -SGameMtlPair* CGameMtlLibrary::CreateMaterialPair(int m0, int m1, SGameMtlPair* parent) +SGameMtlPair *CGameMtlLibrary::CreateMaterialPair(int m0, int m1, SGameMtlPair *parent) { - SGameMtlPair* M = xr_new(this); - if (parent){ + SGameMtlPair *M = xr_new(this); + if (parent) + { M->ID_parent = parent->ID; M->OwnProps.zero(); } - M->ID = material_pair_index++; - M->SetPair (m0,m1); - material_pairs.push_back (M); - return M; + M->ID = material_pair_index++; + M->SetPair(m0, m1); + material_pairs.push_back(M); + return M; } -SGameMtlPair* CGameMtlLibrary::AppendMaterialPair(int m0, int m1, SGameMtlPair* parent) + +SGameMtlPair *CGameMtlLibrary::AppendMaterialPair(int m0, int m1, SGameMtlPair *parent) { - SGameMtlPair* S = GetMaterialPair(m0,m1); - if (!S){ - return CreateMaterialPair(m0,m1,parent); - }else{ - return S; - } + SGameMtlPair *S = GetMaterialPair(m0, m1); + if (!S) + { + return CreateMaterialPair(m0, m1, parent); + } + else + { + return S; + } } + void CGameMtlLibrary::RemoveMaterialPair(LPCSTR name) { - int mtl0,mtl1; - NameToMtlPair (name,mtl0,mtl1); + int mtl0, mtl1; + NameToMtlPair(name, mtl0, mtl1); RemoveMaterialPair(mtl0, mtl1); } + void CGameMtlLibrary::RemoveMaterialPair(GameMtlPairIt rem_it) { - if (rem_it==material_pairs.end()) return; + if (rem_it==material_pairs.end()) + return; // delete parent dependent - for (GameMtlPairIt it=material_pairs.begin(); it!=material_pairs.end(); it++) - if ((*it)->ID_parent==(*rem_it)->ID){ + for (GameMtlPairIt it = material_pairs.begin(); it!=material_pairs.end(); it++) + if ((*it)->ID_parent==(*rem_it)->ID) + { // transfer parented props to child (*it)->TransferFromParent(*rem_it); // reset parenting - (*it)->ID_parent=-1; + (*it)->ID_parent = -1; } // erase from list and remove physically - xr_delete (*rem_it); - material_pairs.erase (rem_it); + xr_delete(*rem_it); + material_pairs.erase(rem_it); } + void CGameMtlLibrary::RemoveMaterialPair(int mtl) { - for (int i=0; i<(int)material_pairs.size(); i++){ + for (int i = 0; i<(int)material_pairs.size(); i++) + { GameMtlPairIt it = material_pairs.begin()+i; - if (((*it)->mtl0==mtl)||((*it)->mtl1==mtl)){ + if (((*it)->mtl0==mtl)||((*it)->mtl1==mtl)) + { RemoveMaterialPair(it); i--; } } } + void CGameMtlLibrary::RemoveMaterialPair(int mtl0, int mtl1) { - GameMtlPairIt rem_it=GetMaterialPairIt(mtl0,mtl1); - if (rem_it==material_pairs.end()) return; - RemoveMaterialPair (rem_it); + GameMtlPairIt rem_it = GetMaterialPairIt(mtl0, mtl1); + if (rem_it==material_pairs.end()) + return; + RemoveMaterialPair(rem_it); } + GameMtlPairIt CGameMtlLibrary::GetMaterialPairIt(int id) { - for (GameMtlPairIt it=material_pairs.begin(); it!=material_pairs.end(); it++) - if ((*it)->ID==id) return it; + for (GameMtlPairIt it = material_pairs.begin(); it!=material_pairs.end(); it++) + if ((*it)->ID==id) + return it; return material_pairs.end(); } -SGameMtlPair* CGameMtlLibrary::GetMaterialPair(int id) + +SGameMtlPair *CGameMtlLibrary::GetMaterialPair(int id) { - GameMtlPairIt it=GetMaterialPairIt(id); - return it!=material_pairs.end()?*it:0; + GameMtlPairIt it = GetMaterialPairIt(id); + return it!=material_pairs.end() ? *it : 0; } -GameMtlPairIt CGameMtlLibrary::GetMaterialPairIt (int mtl0, int mtl1) + +GameMtlPairIt CGameMtlLibrary::GetMaterialPairIt(int mtl0, int mtl1) { - for (GameMtlPairIt it=material_pairs.begin(); it!=material_pairs.end(); it++) - if ((*it)->IsPair(mtl0,mtl1)) return it; + for (GameMtlPairIt it = material_pairs.begin(); it!=material_pairs.end(); it++) + if ((*it)->IsPair(mtl0, mtl1)) + return it; return material_pairs.end(); } -SGameMtlPair* CGameMtlLibrary::GetMaterialPair(int mtl0, int mtl1) + +SGameMtlPair *CGameMtlLibrary::GetMaterialPair(int mtl0, int mtl1) { - GameMtlPairIt it=GetMaterialPairIt(mtl0, mtl1); - return it!=material_pairs.end()?*it:0; + GameMtlPairIt it = GetMaterialPairIt(mtl0, mtl1); + return it!=material_pairs.end() ? *it : 0; } -SGameMtlPair* CGameMtlLibrary::GetMaterialPair(LPCSTR name) + +SGameMtlPair *CGameMtlLibrary::GetMaterialPair(LPCSTR name) { - if (name&&name[0]){ + if (name&&name[0]) + { int mtl0, mtl1; - NameToMtlPair (name,mtl0,mtl1); - GameMtlPairIt it=GetMaterialPairIt(mtl0, mtl1); - return it!=material_pairs.end()?*it:0; + NameToMtlPair(name, mtl0, mtl1); + GameMtlPairIt it = GetMaterialPairIt(mtl0, mtl1); + return it!=material_pairs.end() ? *it : 0; } return 0; } @@ -475,166 +561,173 @@ SGameMtlPair* CGameMtlLibrary::GetMaterialPair(LPCSTR name) //------------------------------------------------------------------------------ // IO - routines //------------------------------------------------------------------------------ -void SGameMtl::Save(IWriter& fs) -{ - Flags.set (flSlowDown, !fis_zero(1.f-fFlotationFactor,EPS_L)); - Flags.set (flShootable, fis_zero(fShootFactor,EPS_L)); - Flags.set (flTransparent, fis_zero(fVisTransparencyFactor,EPS_L)); - Flags.set (flInjurious, !fis_zero(fInjuriousSpeed,EPS_L)); - - fs.open_chunk (GAMEMTL_CHUNK_MAIN); - fs.w_u32 (ID); - fs.w_stringZ (m_Name); - fs.close_chunk (); - - fs.open_chunk (GAMEMTL_CHUNK_DESC); - fs.w_stringZ (m_Desc); - fs.close_chunk (); - - fs.open_chunk (GAMEMTL_CHUNK_FLAGS); - fs.w_u32 (Flags.get()); - fs.close_chunk (); - - fs.open_chunk (GAMEMTL_CHUNK_PHYSICS); - fs.w_float (fPHFriction); - fs.w_float (fPHDamping); - fs.w_float (fPHSpring); - fs.w_float (fPHBounceStartVelocity); - fs.w_float (fPHBouncing); - fs.close_chunk (); - - fs.open_chunk (GAMEMTL_CHUNK_FACTORS); - fs.w_float (fShootFactor); - fs.w_float (fBounceDamageFactor); - fs.w_float (fVisTransparencyFactor); - fs.w_float (fSndOcclusionFactor); - fs.close_chunk (); - - fs.open_chunk (GAMEMTL_CHUNK_FACTORS_MP); - fs.w_float (fShootFactorMP); - fs.close_chunk (); - - fs.open_chunk (GAMEMTL_CHUNK_FLOTATION); - fs.w_float (fFlotationFactor); - fs.close_chunk (); - - fs.open_chunk (GAMEMTL_CHUNK_INJURIOUS); - fs.w_float (fInjuriousSpeed); - fs.close_chunk (); - - fs.open_chunk (GAMEMTL_CHUNK_DENSITY); - fs.w_float (fDensityFactor); - fs.close_chunk (); - - } - -void SGameMtlPair::Load(IReader& fs) -{ - shared_str buf; - - R_ASSERT(fs.find_chunk(GAMEMTLPAIR_CHUNK_PAIR)); - mtl0 = fs.r_u32(); - mtl1 = fs.r_u32(); - ID = fs.r_u32(); - ID_parent = fs.r_u32(); - OwnProps.assign (fs.r_u32()); +void SGameMtl::Save(IWriter &fs) +{ + Flags.set(flSlowDown, !fis_zero(1.f-fFlotationFactor, EPS_L)); + Flags.set(flShootable, fis_zero(fShootFactor, EPS_L)); + Flags.set(flTransparent, fis_zero(fVisTransparencyFactor, EPS_L)); + Flags.set(flInjurious, !fis_zero(fInjuriousSpeed, EPS_L)); + + fs.open_chunk(GAMEMTL_CHUNK_MAIN); + fs.w_u32(ID); + fs.w_stringZ(m_Name); + fs.close_chunk(); + + fs.open_chunk(GAMEMTL_CHUNK_DESC); + fs.w_stringZ(m_Desc); + fs.close_chunk(); + + fs.open_chunk(GAMEMTL_CHUNK_FLAGS); + fs.w_u32(Flags.get()); + fs.close_chunk(); + + fs.open_chunk(GAMEMTL_CHUNK_PHYSICS); + fs.w_float(fPHFriction); + fs.w_float(fPHDamping); + fs.w_float(fPHSpring); + fs.w_float(fPHBounceStartVelocity); + fs.w_float(fPHBouncing); + fs.close_chunk(); + + fs.open_chunk(GAMEMTL_CHUNK_FACTORS); + fs.w_float(fShootFactor); + fs.w_float(fBounceDamageFactor); + fs.w_float(fVisTransparencyFactor); + fs.w_float(fSndOcclusionFactor); + fs.close_chunk(); + + fs.open_chunk(GAMEMTL_CHUNK_FACTORS_MP); + fs.w_float(fShootFactorMP); + fs.close_chunk(); + + fs.open_chunk(GAMEMTL_CHUNK_FLOTATION); + fs.w_float(fFlotationFactor); + fs.close_chunk(); + + fs.open_chunk(GAMEMTL_CHUNK_INJURIOUS); + fs.w_float(fInjuriousSpeed); + fs.close_chunk(); + + fs.open_chunk(GAMEMTL_CHUNK_DENSITY); + fs.w_float(fDensityFactor); + fs.close_chunk(); +} + +void SGameMtlPair::Load(IReader &fs) +{ + shared_str buf; + + R_ASSERT(fs.find_chunk(GAMEMTLPAIR_CHUNK_PAIR)); + mtl0 = fs.r_u32(); + mtl1 = fs.r_u32(); + ID = fs.r_u32(); + ID_parent = fs.r_u32(); + OwnProps.assign(fs.r_u32()); R_ASSERT(fs.find_chunk(GAMEMTLPAIR_CHUNK_BREAKING)); - fs.r_stringZ (buf); BreakingSounds = *buf; - + fs.r_stringZ(buf); + BreakingSounds = *buf; + R_ASSERT(fs.find_chunk(GAMEMTLPAIR_CHUNK_STEP)); - fs.r_stringZ (buf); StepSounds = *buf; - + fs.r_stringZ(buf); + StepSounds = *buf; + R_ASSERT(fs.find_chunk(GAMEMTLPAIR_CHUNK_COLLIDE)); - fs.r_stringZ (buf); CollideSounds = *buf; - fs.r_stringZ (buf); CollideParticles= *buf; - fs.r_stringZ (buf); CollideMarks = *buf; -} - -void SGameMtlPair::Save(IWriter& fs) -{ - fs.open_chunk (GAMEMTLPAIR_CHUNK_PAIR); - fs.w_u32 (mtl0); - fs.w_u32 (mtl1); - fs.w_u32 (ID); - fs.w_u32 (ID_parent); - fs.w_u32 (OwnProps.get()); - fs.close_chunk (); - -// copy from parent - if (ID_parent!=GAMEMTL_NONE_ID){ - SGameMtlPair* P; - if ((0!=(P=GetLastParentValue(this,flBreakingSounds)))&&(P!=this)) - BreakingSounds = P->BreakingSounds; - if ((0!=(P=GetLastParentValue(this,flStepSounds)))&&(P!=this)) - StepSounds = P->StepSounds; - if ((0!=(P=GetLastParentValue(this,flCollideSounds)))&&(P!=this)) - CollideSounds = P->CollideSounds; - if ((0!=(P=GetLastParentValue(this,flCollideParticles)))&&(P!=this)) - CollideParticles= P->CollideParticles; - if ((0!=(P=GetLastParentValue(this,flCollideMarks)))&&(P!=this)) - CollideMarks = P->CollideMarks; - } -/* - else{ - OwnProps.zero(); - if (!BreakingSounds.IsEmpty()) OwnProps.set(flBreakingSounds,TRUE); - if (!StepSounds.IsEmpty()) OwnProps.set(flStepSounds,TRUE); - if (!CollideSounds.IsEmpty()) OwnProps.set(flCollideSounds,TRUE); - if (!CollideParticles.IsEmpty())OwnProps.set(flCollideParticles,TRUE); - if (!CollideMarks.IsEmpty()) OwnProps.set(flCollideMarks,TRUE); + fs.r_stringZ(buf); + CollideSounds = *buf; + fs.r_stringZ(buf); + CollideParticles = *buf; + fs.r_stringZ(buf); + CollideMarks = *buf; +} + +void SGameMtlPair::Save(IWriter &fs) +{ + fs.open_chunk(GAMEMTLPAIR_CHUNK_PAIR); + fs.w_u32(mtl0); + fs.w_u32(mtl1); + fs.w_u32(ID); + fs.w_u32(ID_parent); + fs.w_u32(OwnProps.get()); + fs.close_chunk(); + + // copy from parent + if (ID_parent!=GAMEMTL_NONE_ID) + { + SGameMtlPair *P; + if ((0!=(P = GetLastParentValue(this, flBreakingSounds)))&&(P!=this)) + BreakingSounds = P->BreakingSounds; + if ((0!=(P = GetLastParentValue(this, flStepSounds)))&&(P!=this)) + StepSounds = P->StepSounds; + if ((0!=(P = GetLastParentValue(this, flCollideSounds)))&&(P!=this)) + CollideSounds = P->CollideSounds; + if ((0!=(P = GetLastParentValue(this, flCollideParticles)))&&(P!=this)) + CollideParticles = P->CollideParticles; + if ((0!=(P = GetLastParentValue(this, flCollideMarks)))&&(P!=this)) + CollideMarks = P->CollideMarks; } -*/ -// save - fs.open_chunk (GAMEMTLPAIR_CHUNK_BREAKING); - fs.w_stringZ (BreakingSounds); - fs.close_chunk (); + /* + else{ + OwnProps.zero(); + if (!BreakingSounds.IsEmpty()) OwnProps.set(flBreakingSounds,TRUE); + if (!StepSounds.IsEmpty()) OwnProps.set(flStepSounds,TRUE); + if (!CollideSounds.IsEmpty()) OwnProps.set(flCollideSounds,TRUE); + if (!CollideParticles.IsEmpty())OwnProps.set(flCollideParticles,TRUE); + if (!CollideMarks.IsEmpty()) OwnProps.set(flCollideMarks,TRUE); + } + */ + // save + fs.open_chunk(GAMEMTLPAIR_CHUNK_BREAKING); + fs.w_stringZ(BreakingSounds); + fs.close_chunk(); - fs.open_chunk (GAMEMTLPAIR_CHUNK_STEP); - fs.w_stringZ (StepSounds); - fs.close_chunk (); + fs.open_chunk(GAMEMTLPAIR_CHUNK_STEP); + fs.w_stringZ(StepSounds); + fs.close_chunk(); - fs.open_chunk (GAMEMTLPAIR_CHUNK_COLLIDE); - fs.w_stringZ (CollideSounds); - fs.w_stringZ (CollideParticles); - fs.w_stringZ (CollideMarks); - fs.close_chunk (); + fs.open_chunk(GAMEMTLPAIR_CHUNK_COLLIDE); + fs.w_stringZ(CollideSounds); + fs.w_stringZ(CollideParticles); + fs.w_stringZ(CollideMarks); + fs.close_chunk(); } bool CGameMtlLibrary::Save() { - R_ASSERT (FALSE==UpdateMtlPairs()); - // save - CMemoryWriter fs; - fs.open_chunk (GAMEMTLS_CHUNK_VERSION); - fs.w_u16 (GAMEMTL_CURRENT_VERSION); - fs.close_chunk (); - - fs.open_chunk (GAMEMTLS_CHUNK_AUTOINC); - fs.w_u32 (material_index); - fs.w_u32 (material_pair_index); - fs.close_chunk (); - - fs.open_chunk (GAMEMTLS_CHUNK_MTLS); + R_ASSERT(FALSE==UpdateMtlPairs()); + // save + CMemoryWriter fs; + fs.open_chunk(GAMEMTLS_CHUNK_VERSION); + fs.w_u16(GAMEMTL_CURRENT_VERSION); + fs.close_chunk(); + + fs.open_chunk(GAMEMTLS_CHUNK_AUTOINC); + fs.w_u32(material_index); + fs.w_u32(material_pair_index); + fs.close_chunk(); + + fs.open_chunk(GAMEMTLS_CHUNK_MTLS); int count = 0; - for(GameMtlIt m_it=materials.begin(); m_it!=materials.end(); m_it++){ - fs.open_chunk (count++); - (*m_it)->Save (fs); - fs.close_chunk (); + for (GameMtlIt m_it = materials.begin(); m_it!=materials.end(); m_it++) + { + fs.open_chunk(count++); + (*m_it)->Save(fs); + fs.close_chunk(); } - fs.close_chunk (); - - fs.open_chunk (GAMEMTLS_CHUNK_MTLS_PAIR); + fs.close_chunk(); + + fs.open_chunk(GAMEMTLS_CHUNK_MTLS_PAIR); count = 0; - for(GameMtlPairIt p_it=material_pairs.begin(); p_it!=material_pairs.end(); p_it++){ - fs.open_chunk (count++); - (*p_it)->Save (fs); - fs.close_chunk (); + for (GameMtlPairIt p_it = material_pairs.begin(); p_it!=material_pairs.end(); p_it++) + { + fs.open_chunk(count++); + (*p_it)->Save(fs); + fs.close_chunk(); } - fs.close_chunk (); + fs.close_chunk(); - string_path fn; - FS.update_path (fn,_game_data_,GAMEMTL_FILENAME); - return fs.save_to (fn); + string_path fn; + FS.update_path(fn, _game_data_, GAMEMTL_FILENAME); + return fs.save_to(fn); } diff --git a/src/editors/ShaderEditor/SHCompilerTools.cpp b/src/editors/ShaderEditor/SHCompilerTools.cpp index 805752f8b5a..7296314b3b5 100644 --- a/src/editors/ShaderEditor/SHCompilerTools.cpp +++ b/src/editors/ShaderEditor/SHCompilerTools.cpp @@ -5,40 +5,43 @@ #include "SHCompilerTools.h" #include "ui_shadermain.h" -#include "../xrEProps/folderlib.h" -#include "leftbar.h" -#include "../xrEProps/ItemList.h" +#include "editors/xrEProps/FolderLib.h" +#include "LeftBar.h" +#include "editors/xrEProps/ItemList.h" + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -CSHCompilerTools::CSHCompilerTools(ISHInit& init):ISHTools(init) +CSHCompilerTools::CSHCompilerTools(ISHInit &init): ISHTools(init) { - m_Shader = 0; + m_Shader = 0; } -CSHCompilerTools::~CSHCompilerTools(){ -} +CSHCompilerTools::~CSHCompilerTools() {} + //--------------------------------------------------------------------------- void CSHCompilerTools::OnActivate() { // fill items - FillItemList (); - Ext.m_Items->SetOnModifiedEvent (fastdelegate::bind(this,&CSHCompilerTools::Modified)); - Ext.m_Items->SetOnItemRenameEvent (fastdelegate::bind(this,&CSHCompilerTools::OnRenameItem)); - Ext.m_Items->SetOnItemRemoveEvent (fastdelegate::bind(this,&CSHCompilerTools::OnRemoveItem)); + FillItemList(); + Ext.m_Items->SetOnModifiedEvent(fastdelegate::bind(this, &CSHCompilerTools::Modified)); + Ext.m_Items->SetOnItemRenameEvent(fastdelegate::bind(this, &CSHCompilerTools::OnRenameItem)); + Ext.m_Items->SetOnItemRemoveEvent(fastdelegate::bind(this, &CSHCompilerTools::OnRemoveItem)); - inherited::OnActivate (); + inherited::OnActivate(); } + void CSHCompilerTools::OnDeactivate() { - inherited::OnDeactivate (); + inherited::OnDeactivate(); } void CSHCompilerTools::OnFrame() { - inherited::OnFrame(); + inherited::OnFrame(); } + //--------------------------------------------------------------------------- bool CSHCompilerTools::OnCreate() @@ -49,85 +52,93 @@ bool CSHCompilerTools::OnCreate() void CSHCompilerTools::OnDestroy() { - m_bModified = FALSE; + m_bModified = FALSE; } -void CSHCompilerTools::ApplyChanges(bool bForced) -{ -} +void CSHCompilerTools::ApplyChanges(bool bForced) {} void CSHCompilerTools::Reload() { - ResetCurrentItem (); - Load (); - FillItemList (); + ResetCurrentItem(); + Load(); + FillItemList(); } void CSHCompilerTools::Load() { - string_path fn; - FS.update_path(fn,_game_data_,"shaders_xrlc.xr"); + string_path fn; + FS.update_path(fn, _game_data_, "shaders_xrlc.xr"); if (FS.exist(fn)) { - m_Library.Load(fn); - }else{ - ELog.DlgMsg(mtInformation,"Can't find file '%s'",fn); + m_Library.Load(fn); + } + else + { + ELog.DlgMsg(mtInformation, "Can't find file '%s'", fn); } } bool CSHCompilerTools::Save() { - ApplyChanges (); + ApplyChanges(); // save - string_path fn; - FS.update_path (fn,_game_data_,"shaders_xrlc.xr"); + string_path fn; + FS.update_path(fn, _game_data_, "shaders_xrlc.xr"); - EFS.MarkFile (fn,false); - bool bRes = m_Library.Save(fn); + EFS.MarkFile(fn, false); + bool bRes = m_Library.Save(fn); - if (bRes) m_bModified = FALSE; + if (bRes) + m_bModified = FALSE; return bRes; } -Shader_xrLC* CSHCompilerTools::FindItem(LPCSTR name) +Shader_xrLC *CSHCompilerTools::FindItem(LPCSTR name) { - if (name && name[0]){ - return m_Library.Get(name); - }else return 0; + if (name&&name[0]) + { + return m_Library.Get(name); + } + else + return 0; } -LPCSTR CSHCompilerTools::AppendItem(LPCSTR folder_name, LPCSTR parent_name) +LPCSTR CSHCompilerTools::AppendItem(LPCSTR folder_name, LPCSTR parent_name) { - Shader_xrLC* parent = FindItem(parent_name); - AnsiString pref = parent_name?AnsiString(parent_name):AnsiString(folder_name)+"shader"; - m_LastSelection = FHelper.GenerateName(pref.c_str(),2,fastdelegate::bind(this,&CSHCompilerTools::ItemExist),false,true); - Shader_xrLC* S = m_Library.Append(parent); - strcpy (S->Name,m_LastSelection.c_str()); - ExecCommand (COMMAND_UPDATE_LIST); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - Modified (); + Shader_xrLC *parent = FindItem(parent_name); + AnsiString pref = parent_name ? AnsiString(parent_name) : AnsiString(folder_name)+"shader"; + m_LastSelection = FHelper.GenerateName(pref.c_str(), 2, fastdelegate::bind(this, &CSHCompilerTools::ItemExist), false, true); + Shader_xrLC *S = m_Library.Append(parent); + strcpy(S->Name, m_LastSelection.c_str()); + ExecCommand(COMMAND_UPDATE_LIST); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + Modified(); return S->Name; } void CSHCompilerTools::OnRenameItem(LPCSTR old_full_name, LPCSTR new_full_name, EItemType type) { - if (type==TYPE_OBJECT){ + if (type==TYPE_OBJECT) + { ApplyChanges(); - Shader_xrLC* S = FindItem(old_full_name); R_ASSERT(S); - strcpy(S->Name,new_full_name); - if (S==m_Shader){ - ExecCommand (COMMAND_UPDATE_PROPERTIES); - ExecCommand (COMMAND_UPDATE_LIST); + Shader_xrLC *S = FindItem(old_full_name); + R_ASSERT(S); + strcpy(S->Name, new_full_name); + if (S==m_Shader) + { + ExecCommand(COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_LIST); } } } -void CSHCompilerTools::OnRemoveItem(LPCSTR name, EItemType type, bool& res) +void CSHCompilerTools::OnRemoveItem(LPCSTR name, EItemType type, bool &res) { - if (type==TYPE_OBJECT){ - R_ASSERT(name && name[0]); + if (type==TYPE_OBJECT) + { + R_ASSERT(name&&name[0]); m_Library.Remove(name); } res = TRUE; @@ -135,20 +146,22 @@ void CSHCompilerTools::OnRemoveItem(LPCSTR name, EItemType type, bool& res) void CSHCompilerTools::SetCurrentItem(LPCSTR name, bool bView) { - if (m_bLockUpdate) return; + if (m_bLockUpdate) + return; - Shader_xrLC* S = FindItem(name); + Shader_xrLC *S = FindItem(name); // load shader - if (m_Shader!=S){ + if (m_Shader!=S) + { m_Shader = S; - ExecCommand(COMMAND_UPDATE_PROPERTIES); - if (bView) ViewSetCurrentItem(name); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + if (bView) + ViewSetCurrentItem(name); } } void CSHCompilerTools::ResetCurrentItem() { - m_Shader=0; + m_Shader = 0; } - diff --git a/src/editors/ShaderEditor/SHCompilerTools.h b/src/editors/ShaderEditor/SHCompilerTools.h index 5407d7a2985..fcfd8a2620a 100644 --- a/src/editors/ShaderEditor/SHCompilerTools.h +++ b/src/editors/ShaderEditor/SHCompilerTools.h @@ -2,53 +2,73 @@ #ifndef SHCompilerToolsH #define SHCompilerToolsH -#include "Shader_xrLC.h" +#include "utils/Shader_xrLC.h" #include "SHToolsInterface.h" // refs -class PropValue; +class PropValue; class CSHCompilerTools: public ISHTools { - void __stdcall ItemExist (LPCSTR name, bool& res){res = !!FindItem(name);} - Shader_xrLC* FindItem (LPCSTR name); - Shader_xrLC_LIB m_Library; + void __stdcall ItemExist(LPCSTR name, bool &res) + { + res = !!FindItem(name); + } - ListItem* m_Selected; + Shader_xrLC *FindItem(LPCSTR name); + Shader_xrLC_LIB m_Library; + + ListItem *m_Selected; public: - Shader_xrLC* m_Shader; - virtual void __stdcall OnRemoveItem (LPCSTR name, EItemType type, bool& res); - virtual void __stdcall OnRenameItem (LPCSTR old_full_name, LPCSTR new_full_name, EItemType type); - virtual LPCSTR AppendItem (LPCSTR folder, LPCSTR parent=0); - virtual void FillItemList (); + Shader_xrLC *m_Shader; + virtual void __stdcall OnRemoveItem(LPCSTR name, EItemType type, bool &res); + virtual void __stdcall OnRenameItem(LPCSTR old_full_name, LPCSTR new_full_name, EItemType type); + virtual LPCSTR AppendItem(LPCSTR folder, LPCSTR parent = 0); + virtual void FillItemList(); public: - CSHCompilerTools (ISHInit& init); - virtual ~CSHCompilerTools (); + CSHCompilerTools(ISHInit &init); + virtual ~CSHCompilerTools(); - virtual LPCSTR ToolsName (){return "Compiler Shader";} + virtual LPCSTR ToolsName() + { + return "Compiler Shader"; + } - virtual void Reload (); - virtual void Load (); - virtual bool Save (); + virtual void Reload(); + virtual void Load(); + virtual bool Save(); - virtual bool OnCreate (); - virtual void OnDestroy (); - virtual void OnActivate (); - virtual void OnDeactivate (); + virtual bool OnCreate(); + virtual void OnDestroy(); + virtual void OnActivate(); + virtual void OnDeactivate(); // misc - virtual void ResetCurrentItem (); - virtual void SetCurrentItem (LPCSTR name, bool bView); - virtual void ApplyChanges (bool bForced=false); + virtual void ResetCurrentItem(); + virtual void SetCurrentItem(LPCSTR name, bool bView); + virtual void ApplyChanges(bool bForced = false); + + virtual void RealUpdateProperties(); + virtual void RealUpdateList(); + + virtual void OnFrame(); - virtual void RealUpdateProperties(); - virtual void RealUpdateList (); + virtual void OnRender() + { + ; + } - virtual void OnFrame (); - virtual void OnRender (){;} + virtual void OnDeviceCreate() + { + ; + } - virtual void OnDeviceCreate (){;} - virtual void OnDeviceDestroy (){;} + virtual void OnDeviceDestroy() + { + ; + } }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ShaderEditor/SHCompilerToolsProperties.cpp b/src/editors/ShaderEditor/SHCompilerToolsProperties.cpp index d80d9d6b210..6ad74b2f584 100644 --- a/src/editors/ShaderEditor/SHCompilerToolsProperties.cpp +++ b/src/editors/ShaderEditor/SHCompilerToolsProperties.cpp @@ -3,54 +3,58 @@ #pragma hdrstop #include "SHCompilerTools.h" -#include "../xrEProps/folderlib.h" -#include "../xrEProps/ItemList.h" +#include "editors/xrEProps/FolderLib.h" +#include "editors/xrEProps/ItemList.h" + //------------------------------------------------------------------------------ void CSHCompilerTools::FillItemList() { - // store folders - RStrVec folders; - Ext.m_Items->GetFolders(folders); + // store folders + RStrVec folders; + Ext.m_Items->GetFolders(folders); // fill items - ListItemsVec items; - Shader_xrLCVec& lst = m_Library.Library(); - for (Shader_xrLCIt it=lst.begin(); it!=lst.end(); it++) - LHelper().CreateItem(items,it->Name,0); + ListItemsVec items; + Shader_xrLCVec &lst = m_Library.Library(); + for (Shader_xrLCIt it = lst.begin(); it!=lst.end(); it++) + LHelper().CreateItem(items, it->Name, 0); // fill folders - for (RStringVecIt s_it=folders.begin(); s_it!=folders.end(); s_it++) - LHelper().CreateItem(items,**s_it,0); + for (RStringVecIt s_it = folders.begin(); s_it!=folders.end(); s_it++) + LHelper().CreateItem(items, **s_it, 0); // assign items - Ext.m_Items->AssignItems(items,false,true); + Ext.m_Items->AssignItems(items, false, true); } //------------------------------------------------------------------------------ void CSHCompilerTools::RealUpdateList() { - FillItemList (); + FillItemList(); } + //------------------------------------------------------------------------------ void CSHCompilerTools::RealUpdateProperties() { - PropItemVec items; - if (m_Shader){ - Shader_xrLC& L = *m_Shader; - PHelper().CreateCName (items, "Name", L.Name, sizeof(L.Name), m_CurrentItem); - PHelper().CreateFloat (items, "Translucency", &L.vert_translucency); - PHelper().CreateFloat (items, "Ambient", &L.vert_ambient); - PHelper().CreateFloat (items, "LM density", &L.lm_density, 0.01f,20.f); - - PHelper().CreateFlag32 (items, "Flags\\Collision", &L.m_Flags, Shader_xrLC::flCollision); - PHelper().CreateFlag32 (items, "Flags\\Rendering", &L.m_Flags, Shader_xrLC::flRendering); - PHelper().CreateFlag32 (items, "Flags\\OptimizeUV", &L.m_Flags, Shader_xrLC::flOptimizeUV); - PHelper().CreateFlag32 (items, "Flags\\Vertex light", &L.m_Flags, Shader_xrLC::flLIGHT_Vertex); - PHelper().CreateFlag32 (items, "Flags\\Cast shadow", &L.m_Flags, Shader_xrLC::flLIGHT_CastShadow); -//. PHelper().CreateFlag32 (items, "Flags\\Sharp", &L.m_Flags, Shader_xrLC::flLIGHT_Sharp); + PropItemVec items; + if (m_Shader) + { + Shader_xrLC &L = *m_Shader; + PHelper().CreateCName(items, "Name", L.Name, sizeof(L.Name), m_CurrentItem); + PHelper().CreateFloat(items, "Translucency", &L.vert_translucency); + PHelper().CreateFloat(items, "Ambient", &L.vert_ambient); + PHelper().CreateFloat(items, "LM density", &L.lm_density, 0.01f, 20.f); + + PHelper().CreateFlag32(items, "Flags\\Collision", &L.m_Flags, Shader_xrLC::flCollision); + PHelper().CreateFlag32(items, "Flags\\Rendering", &L.m_Flags, Shader_xrLC::flRendering); + PHelper().CreateFlag32(items, "Flags\\OptimizeUV", &L.m_Flags, Shader_xrLC::flOptimizeUV); + PHelper().CreateFlag32(items, "Flags\\Vertex light", &L.m_Flags, Shader_xrLC::flLIGHT_Vertex); + PHelper().CreateFlag32(items, "Flags\\Cast shadow", &L.m_Flags, Shader_xrLC::flLIGHT_CastShadow); + //. PHelper().CreateFlag32 (items, "Flags\\Sharp", &L.m_Flags, Shader_xrLC::flLIGHT_Sharp); } - Ext.m_ItemProps->AssignItems (items); - Ext.m_ItemProps->SetModifiedEvent (fastdelegate::bind(this,&CSHCompilerTools::Modified)); + Ext.m_ItemProps->AssignItems(items); + Ext.m_ItemProps->SetModifiedEvent(fastdelegate::bind(this, &CSHCompilerTools::Modified)); } + //--------------------------------------------------------------------------- - \ No newline at end of file + diff --git a/src/editors/ShaderEditor/SHEngineTools.cpp b/src/editors/ShaderEditor/SHEngineTools.cpp index d75eb182be6..0cd407d7a50 100644 --- a/src/editors/ShaderEditor/SHEngineTools.cpp +++ b/src/editors/ShaderEditor/SHEngineTools.cpp @@ -1,88 +1,104 @@ //--------------------------------------------------------------------------- #include "stdafx.h" #pragma hdrstop - + #include "SHEngineTools.h" -#include "../../Layers/xrRender/blenders/Blender.h" +#include "Layers/xrRender/blenders/Blender.h" #include "UI_ShaderTools.h" #include "ui_shadermain.h" #include "LeftBar.h" #include "xr_trims.h" -#include "../xrEProps/folderlib.h" -#include "../ECore/Editor/EditMesh.h" -#include "../ECore/Editor/Library.h" -#include "../xrEProps/ChoseForm.h" -#include "../xrEProps/ItemList.h" +#include "editors/xrEProps/FolderLib.h" +#include "editors/ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/Library.h" +#include "editors/xrEProps/ChoseForm.h" +#include "editors/xrEProps/ItemList.h" //------------------------------------------------------------------------------ -class CCollapseBlender: public CParseBlender{ +class CCollapseBlender: public CParseBlender +{ public: - virtual void Parse(CSHEngineTools* owner, DWORD type, LPCSTR key, LPVOID data){ - switch(type){ - case xrPID_MATRIX: owner->CollapseMatrix ((LPSTR)data); break; - case xrPID_CONSTANT: owner->CollapseConstant ((LPSTR)data); break; + virtual void Parse(CSHEngineTools *owner, DWORD type, LPCSTR key, LPVOID data) + { + switch (type) + { + case xrPID_MATRIX: owner->CollapseMatrix((LPSTR)data); + break; + case xrPID_CONSTANT: owner->CollapseConstant((LPSTR)data); + break; }; } }; -class CRefsBlender: public CParseBlender{ +class CRefsBlender: public CParseBlender +{ public: - virtual void Parse(CSHEngineTools* owner, DWORD type, LPCSTR key, LPVOID data){ - switch(type){ - case xrPID_MATRIX: owner->UpdateMatrixRefs ((LPSTR)data); break; - case xrPID_CONSTANT: owner->UpdateConstantRefs ((LPSTR)data); break; + virtual void Parse(CSHEngineTools *owner, DWORD type, LPCSTR key, LPVOID data) + { + switch (type) + { + case xrPID_MATRIX: owner->UpdateMatrixRefs((LPSTR)data); + break; + case xrPID_CONSTANT: owner->UpdateConstantRefs((LPSTR)data); + break; }; } }; -class CRemoveBlender: public CParseBlender{ +class CRemoveBlender: public CParseBlender +{ public: - virtual void Parse(CSHEngineTools* owner, DWORD type, LPCSTR key, LPVOID data){ - switch(type){ - case xrPID_MATRIX: owner->RemoveMatrix((LPSTR)data); break; - case xrPID_CONSTANT: owner->RemoveConstant((LPSTR)data); break; + virtual void Parse(CSHEngineTools *owner, DWORD type, LPCSTR key, LPVOID data) + { + switch (type) + { + case xrPID_MATRIX: owner->RemoveMatrix((LPSTR)data); + break; + case xrPID_CONSTANT: owner->RemoveConstant((LPSTR)data); + break; }; } }; static CCollapseBlender ST_CollapseBlender; -static CRefsBlender ST_UpdateBlenderRefs; -static CRemoveBlender ST_RemoveBlender; +static CRefsBlender ST_UpdateBlenderRefs; +static CRemoveBlender ST_RemoveBlender; //------------------------------------------------------------------------------ -CSHEngineTools::CSHEngineTools(ISHInit& init):ISHTools(init) +CSHEngineTools::CSHEngineTools(ISHInit &init): ISHTools(init) { - m_PreviewObjectType = pvoNone; - m_PreviewObject = NULL; - m_bCustomEditObject = FALSE; - m_bFreezeUpdate = FALSE; - m_CurrentBlender = 0; + m_PreviewObjectType = pvoNone; + m_PreviewObject = NULL; + m_bCustomEditObject = FALSE; + m_bFreezeUpdate = FALSE; + m_CurrentBlender = 0; m_BlenderStream.clear(); - m_bNeedResetShaders = TRUE; - m_RemoteRenBlender = FALSE; - - MCString.push_back ("Custom..."); - MCString.push_back ("-"); - MCString.push_back ("$null"); - MCString.push_back ("$base0"); - MCString.push_back ("$base1"); - MCString.push_back ("$base2"); - MCString.push_back ("$base3"); - MCString.push_back ("$base4"); - MCString.push_back ("$base5"); - MCString.push_back ("$base6"); - MCString.push_back ("$base7"); + m_bNeedResetShaders = TRUE; + m_RemoteRenBlender = FALSE; + + MCString.push_back("Custom..."); + MCString.push_back("-"); + MCString.push_back("$null"); + MCString.push_back("$base0"); + MCString.push_back("$base1"); + MCString.push_back("$base2"); + MCString.push_back("$base3"); + MCString.push_back("$base4"); + MCString.push_back("$base5"); + MCString.push_back("$base6"); + MCString.push_back("$base7"); } CSHEngineTools::~CSHEngineTools() { - MCString.clear (); + MCString.clear(); } + //--------------------------------------------------------------------------- bool CSHEngineTools::OnCreate() { - IBlender::CreatePalette(m_TemplatePalette); + IBlender::CreatePalette(m_TemplatePalette); Load(); return true; } @@ -90,9 +106,9 @@ bool CSHEngineTools::OnCreate() void CSHEngineTools::OnDestroy() { Lib.RemoveEditObject(m_PreviewObject); - // free palette - for (TemplateIt it=m_TemplatePalette.begin(); it!=m_TemplatePalette.end(); it++) - xr_delete(*it); + // free palette + for (TemplateIt it = m_TemplatePalette.begin(); it!=m_TemplatePalette.end(); it++) + xr_delete(*it); m_TemplatePalette.clear(); ClearData(); @@ -100,285 +116,315 @@ void CSHEngineTools::OnDestroy() m_bModified = FALSE; } -xr_token preview_obj_token[]={ - { "None", pvoNone }, - { "-", pvoNone }, - { "Plane", pvoPlane }, - { "Box", pvoBox }, - { "Sphere", pvoSphere }, - { "Teapot", pvoTeapot }, - { "-", pvoNone }, - { "Custom...", pvoCustom }, - { 0, 0 } +xr_token preview_obj_token[] = { + {"None", pvoNone}, + {"-", pvoNone}, + {"Plane", pvoPlane}, + {"Box", pvoBox}, + {"Sphere", pvoSphere}, + {"Teapot", pvoTeapot}, + {"-", pvoNone}, + {"Custom...", pvoCustom}, + {0, 0} }; -bool CSHEngineTools::OnPreviewObjectRefChange(PropValue* sender, u32& new_val) -{ - LPCSTR fn=0; - m_bCustomEditObject = false; - switch (new_val){ - case pvoPlane: fn = "editor\\ShaderTest_Plane"; break; - case pvoBox: fn = "editor\\ShaderTest_Box"; break; - case pvoSphere: fn = "editor\\ShaderTest_Sphere"; break; - case pvoTeapot: fn = "editor\\ShaderTest_Teapot"; break; - case pvoCustom: fn = m_PreviewObject?m_PreviewObject->GetName():""; if (!TfrmChoseItem::SelectItem(smObject,fn)) return false; m_bCustomEditObject = true; break; - } - if (AnsiString(fn).LowerCase()!=AnsiString(m_PreviewObject?m_PreviewObject->GetName():"").LowerCase()){ +bool CSHEngineTools::OnPreviewObjectRefChange(PropValue *sender, u32 &new_val) +{ + LPCSTR fn = 0; + m_bCustomEditObject = false; + switch (new_val) + { + case pvoPlane: fn = "editor\\ShaderTest_Plane"; + break; + case pvoBox: fn = "editor\\ShaderTest_Box"; + break; + case pvoSphere: fn = "editor\\ShaderTest_Sphere"; + break; + case pvoTeapot: fn = "editor\\ShaderTest_Teapot"; + break; + case pvoCustom: fn = m_PreviewObject ? m_PreviewObject->GetName() : ""; + if (!TfrmChoseItem::SelectItem(smObject, fn)) + return false; + m_bCustomEditObject = true; + break; + } + if (AnsiString(fn).LowerCase()!=AnsiString(m_PreviewObject ? m_PreviewObject->GetName() : "").LowerCase()) + { Lib.RemoveEditObject(m_PreviewObject); - m_PreviewObject = (fn&&fn[0])?Lib.CreateEditObject(fn):0; - ZoomObject (false); - UpdateObjectShader (); - UI->RedrawScene (); + m_PreviewObject = (fn&&fn[0]) ? Lib.CreateEditObject(fn) : 0; + ZoomObject(false); + UpdateObjectShader(); + UI->RedrawScene(); } return true; } void CSHEngineTools::OnActivate() { - PropItemVec items; - TokenValue* V = PHelper().CreateToken32 (items,PrepareKey("Object","Reference"), &m_PreviewObjectType, preview_obj_token); - V->OnAfterEditEvent.bind (this,&CSHEngineTools::OnPreviewObjectRefChange); - Ext.m_PreviewProps->AssignItems (items); - Ext.m_PreviewProps->ShowProperties (); + PropItemVec items; + TokenValue *V = PHelper().CreateToken32(items, PrepareKey("Object", "Reference"), &m_PreviewObjectType, preview_obj_token); + V->OnAfterEditEvent.bind(this, &CSHEngineTools::OnPreviewObjectRefChange); + Ext.m_PreviewProps->AssignItems(items); + Ext.m_PreviewProps->ShowProperties(); // fill items - FillItemList (); - Ext.m_Items->SetOnModifiedEvent (fastdelegate::bind(this,&CSHEngineTools::Modified)); - Ext.m_Items->SetOnItemRenameEvent (fastdelegate::bind(this,&CSHEngineTools::OnRenameItem)); - Ext.m_Items->SetOnItemRemoveEvent (fastdelegate::bind(this,&CSHEngineTools::OnRemoveItem)); - inherited::OnActivate (); + FillItemList(); + Ext.m_Items->SetOnModifiedEvent(fastdelegate::bind(this, &CSHEngineTools::Modified)); + Ext.m_Items->SetOnItemRenameEvent(fastdelegate::bind(this, &CSHEngineTools::OnRenameItem)); + Ext.m_Items->SetOnItemRemoveEvent(fastdelegate::bind(this, &CSHEngineTools::OnRemoveItem)); + inherited::OnActivate(); } + //--------------------------------------------------------------------------- void CSHEngineTools::OnDeactivate() { - inherited::OnDeactivate (); + inherited::OnDeactivate(); } void CSHEngineTools::ClearData() { // free constants, matrices, blenders - // Blender - for (BlenderPairIt b=m_Blenders.begin(); b!=m_Blenders.end(); b++) - { - xr_free ((LPSTR)b->first); - xr_delete (b->second); - } - m_Blenders.clear (); - - // Matrices - for (MatrixPairIt m=m_Matrices.begin(); m!=m_Matrices.end(); m++){ - xr_free ((LPSTR)m->first); - xr_delete (m->second); - } - m_Matrices.clear (); - - // Constants - for (ConstantPairIt c=m_Constants.begin(); c!=m_Constants.end(); c++){ - xr_free ((LPSTR)c->first); - xr_delete (c->second); - } - m_Constants.clear (); + // Blender + for (BlenderPairIt b = m_Blenders.begin(); b!=m_Blenders.end(); b++) + { + xr_free((LPSTR)b->first); + xr_delete(b->second); + } + m_Blenders.clear(); + + // Matrices + for (MatrixPairIt m = m_Matrices.begin(); m!=m_Matrices.end(); m++) + { + xr_free((LPSTR)m->first); + xr_delete(m->second); + } + m_Matrices.clear(); + + // Constants + for (ConstantPairIt c = m_Constants.begin(); c!=m_Constants.end(); c++) + { + xr_free((LPSTR)c->first); + xr_delete(c->second); + } + m_Constants.clear(); } void CSHEngineTools::OnFrame() { - if (m_bNeedResetShaders){ - RealResetShaders(); - ExecCommand (COMMAND_UPDATE_LIST); + if (m_bNeedResetShaders) + { + RealResetShaders(); + ExecCommand(COMMAND_UPDATE_LIST); } - if (m_RemoteRenBlender){ - RealRenameItem (m_RenBlenderOldName.c_str(),m_RenBlenderNewName.c_str()); - m_RemoteRenBlender = FALSE; + if (m_RemoteRenBlender) + { + RealRenameItem(m_RenBlenderOldName.c_str(), m_RenBlenderNewName.c_str()); + m_RemoteRenBlender = FALSE; } - if (m_PreviewObject) m_PreviewObject->OnFrame(); - inherited::OnFrame(); + if (m_PreviewObject) + m_PreviewObject->OnFrame(); + inherited::OnFrame(); } void CSHEngineTools::OnRender() { - if (m_PreviewObject) m_PreviewObject->RenderSingle(Fidentity); + if (m_PreviewObject) + m_PreviewObject->RenderSingle(Fidentity); } void CSHEngineTools::ZoomObject(bool bOnlySel) { - if (m_PreviewObject){ - Fbox bb = m_PreviewObject->GetBox(); + if (m_PreviewObject) + { + Fbox bb = m_PreviewObject->GetBox(); EDevice.m_Camera.ZoomExtents(bb); - }else{ - ISHTools::ZoomObject(bOnlySel); + } + else + { + ISHTools::ZoomObject(bOnlySel); } } + //--------------------------------------------------------------------------- -void CSHEngineTools::RealResetShaders() +void CSHEngineTools::RealResetShaders() { - Ext.m_ItemProps->LockUpdating(); - // disable props vis update - m_bFreezeUpdate = TRUE; + Ext.m_ItemProps->LockUpdating(); + // disable props vis update + m_bFreezeUpdate = TRUE; - ResetCurrentItem (); - UpdateObjectShader (); + ResetCurrentItem(); + UpdateObjectShader(); // save to temp file - PrepareRender (); + PrepareRender(); // reset device shaders from temp file - IReader data (m_RenderShaders.pointer(), m_RenderShaders.size()); - EDevice.Reset (&data,TRUE); - // enable props vis update - m_bFreezeUpdate = FALSE; + IReader data(m_RenderShaders.pointer(), m_RenderShaders.size()); + EDevice.Reset(&data, TRUE); + // enable props vis update + m_bFreezeUpdate = FALSE; + + Ext.m_ItemProps->UnlockUpdating(); - Ext.m_ItemProps->UnlockUpdating(); - - m_bNeedResetShaders = FALSE; + m_bNeedResetShaders = FALSE; } void CSHEngineTools::FillItemList() { - // store folders - RStrVec folders; - Ext.m_Items->GetFolders(folders); + // store folders + RStrVec folders; + Ext.m_Items->GetFolders(folders); // fill items - ListItemsVec items; - for (BlenderPairIt b=m_Blenders.begin(); b!=m_Blenders.end(); b++) - LHelper().CreateItem(items,b->first,0); + ListItemsVec items; + for (BlenderPairIt b = m_Blenders.begin(); b!=m_Blenders.end(); b++) + LHelper().CreateItem(items, b->first, 0); // fill folders - for (RStringVecIt s_it=folders.begin(); s_it!=folders.end(); s_it++) - LHelper().CreateItem(items,**s_it,0); + for (RStringVecIt s_it = folders.begin(); s_it!=folders.end(); s_it++) + LHelper().CreateItem(items, **s_it, 0); // assign items - Ext.m_Items->AssignItems(items,false,true); + Ext.m_Items->AssignItems(items, false, true); } void CSHEngineTools::ApplyChanges(bool bForced) { - if (m_CurrentBlender&&(Ext.m_ItemProps->IsModified()||bForced)){ - UpdateObjectFromStream(); - Ext.m_ItemProps->ResetModified(); - ResetShaders(false);// required 'false' for matrix + if (m_CurrentBlender&&(Ext.m_ItemProps->IsModified()||bForced)) + { + UpdateObjectFromStream(); + Ext.m_ItemProps->ResetModified(); + ResetShaders(false);// required 'false' for matrix } } void CSHEngineTools::Reload() { - ResetCurrentItem (); - ClearData (); - Load (); - FillItemList (); - ResetShaders (false);// required 'false' for matrix + ResetCurrentItem(); + ClearData(); + Load(); + FillItemList(); + ResetShaders(false);// required 'false' for matrix } void CSHEngineTools::Load() { - string_path fn; - FS.update_path (fn,_game_data_,"shaders.xr"); + string_path fn; + FS.update_path(fn, _game_data_, "shaders.xr"); - m_bFreezeUpdate = TRUE; - m_bLockUpdate = TRUE; + m_bFreezeUpdate = TRUE; + m_bLockUpdate = TRUE; if (FS.exist(fn)) { - IReader* F = FS.r_open(fn); - char name[256]; + IReader *F = FS.r_open(fn); + char name[256]; // Load constants { - IReader* fs = F->open_chunk(0); - while (fs&&!fs->eof()) { - fs->r_stringZ (name,sizeof(name)); - CConstant* C = xr_new(); - C->Load (fs); - m_Constants.insert(mk_pair(xr_strdup(name),C)); + IReader *fs = F->open_chunk(0); + while (fs&&!fs->eof()) + { + fs->r_stringZ(name, sizeof(name)); + CConstant *C = xr_new(); + C->Load(fs); + m_Constants.insert(mk_pair(xr_strdup(name), C)); } fs->close(); } // Load matrices { - IReader* fs = F->open_chunk(1); - while (fs&&!fs->eof()) { - fs->r_stringZ (name,sizeof(name)); - CMatrix* M = xr_new(); - M->Load (fs); - m_Matrices.insert(mk_pair(xr_strdup(name),M)); + IReader *fs = F->open_chunk(1); + while (fs&&!fs->eof()) + { + fs->r_stringZ(name, sizeof(name)); + CMatrix *M = xr_new(); + M->Load(fs); + m_Matrices.insert(mk_pair(xr_strdup(name), M)); } fs->close(); } // Load blenders { - IReader* fs = F->open_chunk(2); - IReader* chunk = NULL; - int chunk_id= 0; + IReader *fs = F->open_chunk(2); + IReader *chunk = NULL; + int chunk_id = 0; - while ((chunk=fs->open_chunk(chunk_id))!=NULL) + while ((chunk = fs->open_chunk(chunk_id))!=NULL) { - CBlender_DESC desc; - chunk->r (&desc,sizeof(desc)); - IBlender* B = IBlender::Create(desc.CLS); - if (B){ - if (B->getDescription().version != desc.version) + CBlender_DESC desc; + chunk->r(&desc, sizeof(desc)); + IBlender *B = IBlender::Create(desc.CLS); + if (B) + { + if (B->getDescription().version!=desc.version) { - Msg ("! Version conflict in shader '%s'",desc.cName); + Msg("! Version conflict in shader '%s'", desc.cName); } - chunk->seek (0); - B->Load (*chunk,desc.version); + chunk->seek(0); + B->Load(*chunk, desc.version); LPSTR blender_name = xr_strdup(desc.cName); - std::pair I = m_Blenders.insert(mk_pair(blender_name,B)); - R_ASSERT2 (I.second,"shader.xr - found duplicate name!!!"); + std::pair I = m_Blenders.insert(mk_pair(blender_name, B)); + R_ASSERT2(I.second, "shader.xr - found duplicate name!!!"); } - chunk->close (); + chunk->close(); chunk_id++; } fs->close(); } - FS.r_close (F); - UpdateRefCounters (); - ResetCurrentItem (); - }else{ - ELog.DlgMsg(mtInformation,"Can't find file '%s'",fn); + FS.r_close(F); + UpdateRefCounters(); + ResetCurrentItem(); + } + else + { + ELog.DlgMsg(mtInformation, "Can't find file '%s'", fn); } - m_bLockUpdate = FALSE; - m_bFreezeUpdate = FALSE; + m_bLockUpdate = FALSE; + m_bFreezeUpdate = FALSE; } -void CSHEngineTools::Save(CMemoryWriter& F) +void CSHEngineTools::Save(CMemoryWriter &F) { // Save constants { - F.open_chunk(0); - for (ConstantPairIt c=m_Constants.begin(); c!=m_Constants.end(); c++){ - F.w_stringZ(c->first); - c->second->Save(&F); - } + F.open_chunk(0); + for (ConstantPairIt c = m_Constants.begin(); c!=m_Constants.end(); c++) + { + F.w_stringZ(c->first); + c->second->Save(&F); + } F.close_chunk(); } // Save matrices { - F.open_chunk(1); - for (MatrixPairIt m=m_Matrices.begin(); m!=m_Matrices.end(); m++){ - F.w_stringZ(m->first); - m->second->Save(&F); + F.open_chunk(1); + for (MatrixPairIt m = m_Matrices.begin(); m!=m_Matrices.end(); m++) + { + F.w_stringZ(m->first); + m->second->Save(&F); } F.close_chunk(); } // Save blenders { - F.open_chunk(2); - int chunk_id=0; - for (BlenderPairIt b=m_Blenders.begin(); b!=m_Blenders.end(); b++){ - F.open_chunk(chunk_id++); - b->second->Save(F); - F.close_chunk(); + F.open_chunk(2); + int chunk_id = 0; + for (BlenderPairIt b = m_Blenders.begin(); b!=m_Blenders.end(); b++) + { + F.open_chunk(chunk_id++); + b->second->Save(F); + F.close_chunk(); } F.close_chunk(); } // Save blender names { - F.open_chunk(3); - F.w_u32(m_Blenders.size()); - for (BlenderPairIt b=m_Blenders.begin(); b!=m_Blenders.end(); b++) - F.w_stringZ(b->first); + F.open_chunk(3); + F.w_u32(m_Blenders.size()); + for (BlenderPairIt b = m_Blenders.begin(); b!=m_Blenders.end(); b++) + F.w_stringZ(b->first); F.close_chunk(); } } @@ -386,11 +432,11 @@ void CSHEngineTools::Save(CMemoryWriter& F) bool CSHEngineTools::Save() { // set name - string_path fn; - FS.update_path (fn,_game_data_,"shaders.xr"); + string_path fn; + FS.update_path(fn, _game_data_, "shaders.xr"); // collapse reference - CollapseReferences(); + CollapseReferences(); // save to stream CMemoryWriter F; @@ -398,66 +444,80 @@ bool CSHEngineTools::Save() Save(F); // save new file - EFS.MarkFile (fn,false); - bool bRes = F.save_to(fn); + EFS.MarkFile(fn, false); + bool bRes = F.save_to(fn); - if (bRes){ - m_bModified = FALSE; - Ext.m_ItemProps->ResetModified(); - // restore shader - ResetShaders (); + if (bRes) + { + m_bModified = FALSE; + Ext.m_ItemProps->ResetModified(); + // restore shader + ResetShaders(); } return bRes; } void CSHEngineTools::PrepareRender() { - CollapseReferences(); + CollapseReferences(); m_RenderShaders.clear(); Save(m_RenderShaders); } -IBlender* CSHEngineTools::FindItem(LPCSTR name){ - if (name && name[0]){ - LPSTR N = LPSTR(name); - BlenderPairIt I = m_Blenders.find (N); - if (I==m_Blenders.end())return 0; - else return I->second; - }else return 0; +IBlender *CSHEngineTools::FindItem(LPCSTR name) +{ + if (name&&name[0]) + { + LPSTR N = LPSTR(name); + BlenderPairIt I = m_Blenders.find(N); + if (I==m_Blenders.end()) + return 0; + else + return I->second; + } + else + return 0; } -CMatrix* CSHEngineTools::FindMatrix(LPCSTR name) +CMatrix *CSHEngineTools::FindMatrix(LPCSTR name) { - R_ASSERT(name && name[0]); - MatrixPairIt I = m_Matrices.find ((LPSTR)name); - if (I==m_Matrices.end()) return 0; - else return I->second; + R_ASSERT(name&&name[0]); + MatrixPairIt I = m_Matrices.find((LPSTR)name); + if (I==m_Matrices.end()) + return 0; + else + return I->second; } -CMatrix* CSHEngineTools::AppendMatrix(LPSTR name) +CMatrix *CSHEngineTools::AppendMatrix(LPSTR name) { - CMatrix* M = FindMatrix(name); VERIFY(M); - if (M->dwReference>1){ - M->dwReference--; - strcpy(name,AppendMatrix(M,&M)); + CMatrix *M = FindMatrix(name); + VERIFY(M); + if (M->dwReference>1) + { + M->dwReference--; + strcpy(name, AppendMatrix(M, &M)); } return M; } -CConstant* CSHEngineTools::FindConstant(LPCSTR name) +CConstant *CSHEngineTools::FindConstant(LPCSTR name) { - R_ASSERT(name && name[0]); - ConstantPairIt I = m_Constants.find ((LPSTR)name); - if (I==m_Constants.end()) return 0; - else return I->second; + R_ASSERT(name&&name[0]); + ConstantPairIt I = m_Constants.find((LPSTR)name); + if (I==m_Constants.end()) + return 0; + else + return I->second; } -CConstant* CSHEngineTools::AppendConstant(LPSTR name) +CConstant *CSHEngineTools::AppendConstant(LPSTR name) { - CConstant* C = FindConstant(name); - if (C->dwReference>1){ - C->dwReference--; - strcpy(name,AppendConstant(C,&C)); + CConstant *C = FindConstant(name); + if (C->dwReference>1) + { + C->dwReference--; + strcpy(name, AppendConstant(C, &C)); } return C; } @@ -465,308 +525,360 @@ CConstant* CSHEngineTools::AppendConstant(LPSTR name) LPCSTR CSHEngineTools::GenerateMatrixName(LPSTR name) { int cnt = 0; - do sprintf(name,"%04x",cnt++); - while(FindMatrix(name)); + do + sprintf(name, "%04x", cnt++); while (FindMatrix(name)); return name; } LPCSTR CSHEngineTools::GenerateConstantName(LPSTR name) { int cnt = 0; - do sprintf(name,"%04x",cnt++); - while(FindConstant(name)); + do + sprintf(name, "%04x", cnt++); while (FindConstant(name)); return name; } -void CSHEngineTools::FillChooseTemplate(ChooseItemVec& items, void* param) +void CSHEngineTools::FillChooseTemplate(ChooseItemVec &items, void *param) { - for (TemplateIt it=m_TemplatePalette.begin(); it!=m_TemplatePalette.end(); it++) - items.push_back(SChooseItem((*it)->getComment(),"")); + for (TemplateIt it = m_TemplatePalette.begin(); it!=m_TemplatePalette.end(); it++) + items.push_back(SChooseItem((*it)->getComment(), "")); } - + LPCSTR CSHEngineTools::AppendItem(LPCSTR folder_name, LPCSTR parent_name) { - IBlender* parent = FindItem(parent_name); - CLASS_ID cls_id; - if (!parent){ - LPCSTR M=0; - if (!TfrmChoseItem::SelectItem(smCustom,M,1,0,fastdelegate::bind(this,&CSHEngineTools::FillChooseTemplate))||!M) return 0; - for (TemplateIt it=m_TemplatePalette.begin(); it!=m_TemplatePalette.end(); it++) - if (0==strcmp((*it)->getComment(),M)){ - cls_id = (*it)->getDescription().CLS; + IBlender *parent = FindItem(parent_name); + CLASS_ID cls_id; + if (!parent) + { + LPCSTR M = 0; + if (!TfrmChoseItem::SelectItem(smCustom, M, 1, 0, fastdelegate::bind(this, &CSHEngineTools::FillChooseTemplate))||!M) + return 0; + for (TemplateIt it = m_TemplatePalette.begin(); it!=m_TemplatePalette.end(); it++) + if (0==strcmp((*it)->getComment(), M)) + { + cls_id = (*it)->getDescription().CLS; break; } - }else{ - cls_id = parent->getDescription().CLS; } - R_ASSERT2 (cls_id,"Invalid CLASS_ID."); - // append blender - IBlender* B = IBlender::Create(cls_id); + else + { + cls_id = parent->getDescription().CLS; + } + R_ASSERT2(cls_id, "Invalid CLASS_ID."); + // append blender + IBlender *B = IBlender::Create(cls_id); // append matrix& constant CMemoryWriter M; - if (parent) parent->Save(M); else B->Save(M); - // parse data + if (parent) + parent->Save(M); else + B->Save(M); + // parse data IReader data(M.pointer(), M.size()); data.advance(sizeof(CBlender_DESC)); DWORD type; string256 key; - while (!data.eof()){ - int sz=0; + while (!data.eof()) + { + int sz = 0; type = data.r_u32(); - data.r_stringZ(key,sizeof(key)); - switch(type){ - case xrPID_MARKER: break; - case xrPID_MATRIX: - sz=sizeof(string64); - if (strcmp((LPSTR)data.pointer(),"$null")!=0){ - if (!parent) strcpy((LPSTR)data.pointer(),AppendMatrix()); - else AddMatrixRef((LPSTR)data.pointer()); - } - break; - case xrPID_CONSTANT: - sz=sizeof(string64); - if (strcmp((LPSTR)data.pointer(),"$null")!=0){ - if (!parent) strcpy((LPSTR)data.pointer(),AppendConstant()); - else AddConstantRef((LPSTR)data.pointer()); - } - break; - case xrPID_TEXTURE: sz=sizeof(string64); break; - case xrPID_INTEGER: sz=sizeof(xrP_Integer); break; - case xrPID_FLOAT: sz=sizeof(xrP_Float); break; - case xrPID_BOOL: sz=sizeof(xrP_BOOL); break; - case xrPID_TOKEN: sz=sizeof(xrP_TOKEN)+sizeof(xrP_TOKEN::Item)*(((xrP_TOKEN*)data.pointer())->Count); break; - default: THROW2("xrPID_????"); + data.r_stringZ(key, sizeof(key)); + switch (type) + { + case xrPID_MARKER: break; + case xrPID_MATRIX: + sz = sizeof(string64); + if (strcmp((LPSTR)data.pointer(), "$null")!=0) + { + if (!parent) + strcpy((LPSTR)data.pointer(), AppendMatrix()); + else + AddMatrixRef((LPSTR)data.pointer()); + } + break; + case xrPID_CONSTANT: + sz = sizeof(string64); + if (strcmp((LPSTR)data.pointer(), "$null")!=0) + { + if (!parent) + strcpy((LPSTR)data.pointer(), AppendConstant()); + else + AddConstantRef((LPSTR)data.pointer()); + } + break; + case xrPID_TEXTURE: sz = sizeof(string64); + break; + case xrPID_INTEGER: sz = sizeof(xrP_Integer); + break; + case xrPID_FLOAT: sz = sizeof(xrP_Float); + break; + case xrPID_BOOL: sz = sizeof(xrP_BOOL); + break; + case xrPID_TOKEN: sz = sizeof(xrP_TOKEN)+sizeof(xrP_TOKEN::Item)*(((xrP_TOKEN*)data.pointer())->Count); + break; + default: THROW2("xrPID_????"); } data.advance(sz); } data.seek(0); - B->Load(data,B->getDescription().version); - // set name - AnsiString pref = parent_name?AnsiString(parent_name):AnsiString(folder_name)+"shader"; - m_LastSelection = FHelper.GenerateName(pref.c_str(),2,fastdelegate::bind(this,&CSHEngineTools::ItemExist),false,true); + B->Load(data, B->getDescription().version); + // set name + AnsiString pref = parent_name ? AnsiString(parent_name) : AnsiString(folder_name)+"shader"; + m_LastSelection = FHelper.GenerateName(pref.c_str(), 2, fastdelegate::bind(this, &CSHEngineTools::ItemExist), false, true); B->getDescription().Setup(m_LastSelection.c_str()); // insert blender - std::pair I = m_Blenders.insert(mk_pair(xr_strdup(m_LastSelection.c_str()),B)); - R_ASSERT2 (I.second,"shader.xr - found duplicate name!!!"); + std::pair I = m_Blenders.insert(mk_pair(xr_strdup(m_LastSelection.c_str()), B)); + R_ASSERT2(I.second, "shader.xr - found duplicate name!!!"); // insert to TreeView - ExecCommand (COMMAND_UPDATE_LIST); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_LIST); + ExecCommand(COMMAND_UPDATE_PROPERTIES); - ResetShaders (true); - Modified (); + ResetShaders(true); + Modified(); return B->getName(); } void CSHEngineTools::RealRenameItem(LPCSTR old_full_name, LPCSTR new_full_name) { - ApplyChanges (); - LPSTR N = LPSTR(old_full_name); - BlenderPairIt I = m_Blenders.find (N); + ApplyChanges(); + LPSTR N = LPSTR(old_full_name); + BlenderPairIt I = m_Blenders.find(N); R_ASSERT(I!=m_Blenders.end()); - xr_free ((LPSTR)I->first); - IBlender* B = I->second; - m_Blenders.erase(I); - // rename + xr_free((LPSTR)I->first); + IBlender *B = I->second; + m_Blenders.erase(I); + // rename B->getDescription().Setup(new_full_name); - std::pair RES = m_Blenders.insert(mk_pair(xr_strdup(new_full_name),B)); - R_ASSERT2 (RES.second,"shader.xr - found duplicate name!!!"); + std::pair RES = m_Blenders.insert(mk_pair(xr_strdup(new_full_name), B)); + R_ASSERT2(RES.second, "shader.xr - found duplicate name!!!"); - if (B==m_CurrentBlender) UpdateStreamFromObject(); - ApplyChanges (); - ResetShaders (); - if (B==m_CurrentBlender) SetCurrentItem(B->getName(),true); + if (B==m_CurrentBlender) + UpdateStreamFromObject(); + ApplyChanges(); + ResetShaders(); + if (B==m_CurrentBlender) + SetCurrentItem(B->getName(), true); - m_LastSelection = new_full_name; - ExecCommand (COMMAND_UPDATE_LIST); - ExecCommand (COMMAND_UPDATE_PROPERTIES); -//. RealUpdateProperties(); + m_LastSelection = new_full_name; + ExecCommand(COMMAND_UPDATE_LIST); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + //. RealUpdateProperties(); } void CSHEngineTools::AddMatrixRef(LPSTR name) { - CMatrix* M = FindMatrix(name); R_ASSERT(M); + CMatrix *M = FindMatrix(name); + R_ASSERT(M); M->dwReference++; } void CSHEngineTools::AddConstantRef(LPSTR name) { - CConstant* C = FindConstant(name); R_ASSERT(C); + CConstant *C = FindConstant(name); + R_ASSERT(C); C->dwReference++; } -LPCSTR CSHEngineTools::AppendConstant(CConstant* src, CConstant** dest) +LPCSTR CSHEngineTools::AppendConstant(CConstant *src, CConstant **dest) { - CConstant* C = xr_new(); - if (src) *C = *src; + CConstant *C = xr_new(); + if (src) + *C = *src; C->dwReference = 1; char name[128]; - std::pair I = m_Constants.insert(mk_pair(xr_strdup(GenerateConstantName(name)),C)); + std::pair I = m_Constants.insert(mk_pair(xr_strdup(GenerateConstantName(name)), C)); VERIFY(I.second); - if (dest) *dest = C; + if (dest) + *dest = C; return I.first->first; } -LPCSTR CSHEngineTools::AppendMatrix(CMatrix* src, CMatrix** dest) +LPCSTR CSHEngineTools::AppendMatrix(CMatrix *src, CMatrix **dest) { - CMatrix* M = xr_new(); - if (src) *M = *src; + CMatrix *M = xr_new(); + if (src) + *M = *src; M->dwReference = 1; char name[128]; - std::pair I = m_Matrices.insert(mk_pair(xr_strdup(GenerateMatrixName(name)),M)); + std::pair I = m_Matrices.insert(mk_pair(xr_strdup(GenerateMatrixName(name)), M)); VERIFY(I.second); - if (dest) *dest = M; + if (dest) + *dest = M; return I.first->first; } void CSHEngineTools::OnRenameItem(LPCSTR old_full_name, LPCSTR new_full_name, EItemType type) { - if (type==TYPE_OBJECT) - RemoteRenameBlender (old_full_name, new_full_name); + if (type==TYPE_OBJECT) + RemoteRenameBlender(old_full_name, new_full_name); } -void CSHEngineTools::OnRemoveItem(LPCSTR name, EItemType type, bool& res) +void CSHEngineTools::OnRemoveItem(LPCSTR name, EItemType type, bool &res) { - if (type==TYPE_OBJECT){ - R_ASSERT(name && name[0]); - IBlender* B = FindItem(name); + if (type==TYPE_OBJECT) + { + R_ASSERT(name&&name[0]); + IBlender *B = FindItem(name); R_ASSERT(B); // remove refs - ParseBlender(B,ST_RemoveBlender); - LPSTR N = LPSTR(name); - BlenderPairIt I = m_Blenders.find (N); - xr_free ((LPSTR)I->first); - xr_delete (I->second); + ParseBlender(B, ST_RemoveBlender); + LPSTR N = LPSTR(name); + BlenderPairIt I = m_Blenders.find(N); + xr_free((LPSTR)I->first); + xr_delete(I->second); m_Blenders.erase(I); - ApplyChanges (); - ResetShaders (); + ApplyChanges(); + ResetShaders(); } res = true; } void CSHEngineTools::RemoveMatrix(LPCSTR name) { - if (*name=='$') return; - R_ASSERT(name && name[0]); - CMatrix* M = FindMatrix(name); VERIFY(M); + if (*name=='$') + return; + R_ASSERT(name&&name[0]); + CMatrix *M = FindMatrix(name); + VERIFY(M); M->dwReference--; - if (M->dwReference==0){ - LPSTR N = LPSTR(name); - MatrixPairIt I = m_Matrices.find (N); - xr_free ((LPSTR)I->first); - xr_delete (I->second); - m_Matrices.erase(I); + if (M->dwReference==0) + { + LPSTR N = LPSTR(name); + MatrixPairIt I = m_Matrices.find(N); + xr_free((LPSTR)I->first); + xr_delete(I->second); + m_Matrices.erase(I); } } void CSHEngineTools::RemoveConstant(LPCSTR name) { - if (*name=='$') return; - R_ASSERT(name && name[0]); - CConstant* C = FindConstant(name); VERIFY(C); + if (*name=='$') + return; + R_ASSERT(name&&name[0]); + CConstant *C = FindConstant(name); + VERIFY(C); C->dwReference--; - if (C->dwReference==0){ - LPSTR N = LPSTR(name); - ConstantPairIt I = m_Constants.find (N); - xr_free ((LPSTR)I->first); - xr_delete (I->second); - m_Constants.erase(I); + if (C->dwReference==0) + { + LPSTR N = LPSTR(name); + ConstantPairIt I = m_Constants.find(N); + xr_free((LPSTR)I->first); + xr_delete(I->second); + m_Constants.erase(I); } } void CSHEngineTools::UpdateStreamFromObject() { m_BlenderStream.clear(); - if (m_CurrentBlender) m_CurrentBlender->Save(m_BlenderStream); - // init properties + if (m_CurrentBlender) + m_CurrentBlender->Save(m_BlenderStream); + // init properties ExecCommand(COMMAND_UPDATE_PROPERTIES); } void CSHEngineTools::UpdateObjectFromStream() { - if (m_CurrentBlender){ + if (m_CurrentBlender) + { IReader data(m_BlenderStream.pointer(), m_BlenderStream.size()); - m_CurrentBlender->Load(data,m_CurrentBlender->getDescription().version); + m_CurrentBlender->Load(data, m_CurrentBlender->getDescription().version); } } void CSHEngineTools::SetCurrentItem(LPCSTR name, bool bView) { - if (m_bLockUpdate) return; + if (m_bLockUpdate) + return; - IBlender* B = FindItem(name); - if (m_CurrentBlender!=B){ + IBlender *B = FindItem(name); + if (m_CurrentBlender!=B) + { m_CurrentBlender = B; UpdateStreamFromObject(); // apply this shader to non custom object UpdateObjectShader(); - if (bView) ViewSetCurrentItem(name); + if (bView) + ViewSetCurrentItem(name); } } void CSHEngineTools::ResetCurrentItem() { - m_CurrentBlender=0; + m_CurrentBlender = 0; UpdateStreamFromObject(); } void CSHEngineTools::CollapseMatrix(LPSTR name) { - if (*name=='$') return; - R_ASSERT(name&&name[0]); - CMatrix* M = FindMatrix(name); VERIFY(M); - M->dwReference--; - for (MatrixPairIt m=m_OptMatrices.begin(); m!=m_OptMatrices.end(); m++){ - if (m->second->Similar(*M)){ - strcpy(name,m->first); + if (*name=='$') + return; + R_ASSERT(name&&name[0]); + CMatrix *M = FindMatrix(name); + VERIFY(M); + M->dwReference--; + for (MatrixPairIt m = m_OptMatrices.begin(); m!=m_OptMatrices.end(); m++) + { + if (m->second->Similar(*M)) + { + strcpy(name, m->first); m->second->dwReference++; return; } } // append new optimized matrix - CMatrix* N = xr_new(*M); - N->dwReference=1; - m_OptMatrices.insert(mk_pair(xr_strdup(name),N)); + CMatrix *N = xr_new(*M); + N->dwReference = 1; + m_OptMatrices.insert(mk_pair(xr_strdup(name), N)); } void CSHEngineTools::CollapseConstant(LPSTR name) { - if (*name=='$') return; - R_ASSERT(name&&name[0]); - CConstant* C = FindConstant(name); VERIFY(C); - C->dwReference--; - for (ConstantPairIt c=m_OptConstants.begin(); c!=m_OptConstants.end(); c++){ - if (c->second->Similar(*C)){ - strcpy(name,c->first); + if (*name=='$') + return; + R_ASSERT(name&&name[0]); + CConstant *C = FindConstant(name); + VERIFY(C); + C->dwReference--; + for (ConstantPairIt c = m_OptConstants.begin(); c!=m_OptConstants.end(); c++) + { + if (c->second->Similar(*C)) + { + strcpy(name, c->first); c->second->dwReference++; return; } } // append opt constant - CConstant* N = xr_new(*C); - N->dwReference=1; - m_OptConstants.insert(mk_pair(xr_strdup(name),N)); + CConstant *N = xr_new(*C); + N->dwReference = 1; + m_OptConstants.insert(mk_pair(xr_strdup(name), N)); } void CSHEngineTools::UpdateMatrixRefs(LPSTR name) { - if (*name=='$') return; - R_ASSERT(name&&name[0]); - CMatrix* M = FindMatrix(name); R_ASSERT(M); - M->dwReference++; + if (*name=='$') + return; + R_ASSERT(name&&name[0]); + CMatrix *M = FindMatrix(name); + R_ASSERT(M); + M->dwReference++; } void CSHEngineTools::UpdateConstantRefs(LPSTR name) { - if (*name=='$') return; - R_ASSERT(name&&name[0]); - CConstant* C = FindConstant(name); R_ASSERT(C); - C->dwReference++; + if (*name=='$') + return; + R_ASSERT(name&&name[0]); + CConstant *C = FindConstant(name); + R_ASSERT(C); + C->dwReference++; } -void CSHEngineTools::ParseBlender(IBlender* B, CParseBlender& P) +void CSHEngineTools::ParseBlender(IBlender *B, CParseBlender &P) { CMemoryWriter M; B->Save(M); @@ -776,103 +888,120 @@ void CSHEngineTools::ParseBlender(IBlender* B, CParseBlender& P) DWORD type; string256 key; - while (!data.eof()){ - int sz=0; + while (!data.eof()) + { + int sz = 0; type = data.r_u32(); - data.r_stringZ(key,sizeof(key)); - switch(type){ - case xrPID_MARKER: break; - case xrPID_MATRIX: sz=sizeof(string64); break; - case xrPID_CONSTANT:sz=sizeof(string64); break; - case xrPID_TEXTURE: sz=sizeof(string64); break; - case xrPID_INTEGER: sz=sizeof(xrP_Integer); break; - case xrPID_FLOAT: sz=sizeof(xrP_Float); break; - case xrPID_BOOL: sz=sizeof(xrP_BOOL); break; - case xrPID_TOKEN: sz=sizeof(xrP_TOKEN)+sizeof(xrP_TOKEN::Item)*(((xrP_TOKEN*)data.pointer())->Count); break; - default: - THROW2("xrPID_????"); + data.r_stringZ(key, sizeof(key)); + switch (type) + { + case xrPID_MARKER: break; + case xrPID_MATRIX: sz = sizeof(string64); + break; + case xrPID_CONSTANT: sz = sizeof(string64); + break; + case xrPID_TEXTURE: sz = sizeof(string64); + break; + case xrPID_INTEGER: sz = sizeof(xrP_Integer); + break; + case xrPID_FLOAT: sz = sizeof(xrP_Float); + break; + case xrPID_BOOL: sz = sizeof(xrP_BOOL); + break; + case xrPID_TOKEN: sz = sizeof(xrP_TOKEN)+sizeof(xrP_TOKEN::Item)*(((xrP_TOKEN*)data.pointer())->Count); + break; + default: + THROW2("xrPID_????"); } - P.Parse(this,type, key, data.pointer()); + P.Parse(this, type, key, data.pointer()); data.advance(sz); } data.seek(0); - B->Load(data,B->getDescription().version); + B->Load(data, B->getDescription().version); } void CSHEngineTools::CollapseReferences() { - for (BlenderPairIt b=m_Blenders.begin(); b!=m_Blenders.end(); b++) - ParseBlender(b->second,ST_CollapseBlender); - for (MatrixPairIt m=m_Matrices.begin(); m!=m_Matrices.end(); m++){ - VERIFY (m->second->dwReference==0); - xr_free ((LPSTR)m->first); - xr_delete (m->second); - } - for (ConstantPairIt c=m_Constants.begin(); c!=m_Constants.end(); c++){ - VERIFY (c->second->dwReference==0); - xr_free ((LPSTR)c->first); - xr_delete (c->second); - } - m_Matrices.clear (); - m_Constants.clear (); - m_Matrices = m_OptMatrices; - m_Constants = m_OptConstants; - m_OptConstants.clear(); - m_OptMatrices.clear (); + for (BlenderPairIt b = m_Blenders.begin(); b!=m_Blenders.end(); b++) + ParseBlender(b->second, ST_CollapseBlender); + for (MatrixPairIt m = m_Matrices.begin(); m!=m_Matrices.end(); m++) + { + VERIFY(m->second->dwReference==0); + xr_free((LPSTR)m->first); + xr_delete(m->second); + } + for (ConstantPairIt c = m_Constants.begin(); c!=m_Constants.end(); c++) + { + VERIFY(c->second->dwReference==0); + xr_free((LPSTR)c->first); + xr_delete(c->second); + } + m_Matrices.clear(); + m_Constants.clear(); + m_Matrices = m_OptMatrices; + m_Constants = m_OptConstants; + m_OptConstants.clear(); + m_OptMatrices.clear(); } void CSHEngineTools::UpdateRefCounters() { - for (BlenderPairIt b=m_Blenders.begin(); b!=m_Blenders.end(); b++) - ParseBlender(b->second,ST_UpdateBlenderRefs); + for (BlenderPairIt b = m_Blenders.begin(); b!=m_Blenders.end(); b++) + ParseBlender(b->second, ST_UpdateBlenderRefs); } void CSHEngineTools::OnDeviceCreate() { - ResetShaders (); + ResetShaders(); } void CSHEngineTools::UpdateObjectShader() { // apply this shader to non custom object - CEditableObject* E = m_PreviewObject; - if (E&&!m_bCustomEditObject){ - CSurface* surf = *E->FirstSurface(); R_ASSERT(surf); -/* - u32 cnt = _GetItemCount(surf->_Texture()); - string512 tex; - string128 elem; - if (0==cnt){ - strcpy (elem,"$shadertest"); - }else{ - _GetItem(surf->_Texture(),0,elem); - } - strcpy (tex,surf->_Texture()); - for (int i=cnt; i<8; i++){ strcat(tex,","); strcat(tex,elem);} - surf->SetTexture(tex); -*/ - if (m_CurrentBlender) surf->SetShader(m_CurrentBlender->getName()); - else surf->SetShader("editor\\wire"); + CEditableObject *E = m_PreviewObject; + if (E&&!m_bCustomEditObject) + { + CSurface *surf = *E->FirstSurface(); + R_ASSERT(surf); + /* + u32 cnt = _GetItemCount(surf->_Texture()); + string512 tex; + string128 elem; + if (0==cnt){ + strcpy (elem,"$shadertest"); + }else{ + _GetItem(surf->_Texture(),0,elem); + } + strcpy (tex,surf->_Texture()); + for (int i=cnt; i<8; i++){ strcat(tex,","); strcat(tex,elem);} + surf->SetTexture(tex); + */ + if (m_CurrentBlender) + surf->SetShader(m_CurrentBlender->getName()); + else + surf->SetShader("editor\\wire"); UI->RedrawScene(); - E->OnDeviceDestroy(); + E->OnDeviceDestroy(); } } -void CSHEngineTools::OnShowHint(AStringVec& ss) +void CSHEngineTools::OnShowHint(AStringVec &ss) { - if (m_PreviewObject){ - float dist=UI->ZFar(); + if (m_PreviewObject) + { + float dist = UI->ZFar(); SRayPickInfo pinf; - if (m_PreviewObject->RayPick(dist,UI->m_CurrentRStart,UI->m_CurrentRDir,Fidentity,&pinf)){ - R_ASSERT(pinf.e_mesh); - CSurface* surf=pinf.e_mesh->GetSurfaceByFaceID(pinf.inf.id); + if (m_PreviewObject->RayPick(dist, UI->m_CurrentRStart, UI->m_CurrentRDir, Fidentity, &pinf)) + { + R_ASSERT(pinf.e_mesh); + CSurface *surf = pinf.e_mesh->GetSurfaceByFaceID(pinf.inf.id); ss.push_back(AnsiString("Surface: ")+AnsiString(surf->_Name())); ss.push_back(AnsiString("Texture: ")+AnsiString(surf->_Texture())); ss.push_back(AnsiString("Shader: ")+AnsiString(surf->_ShaderName())); ss.push_back(AnsiString("LC Shader: ")+AnsiString(surf->_ShaderXRLCName())); ss.push_back(AnsiString("Game Mtl: ")+AnsiString(surf->_GameMtlName())); - ss.push_back(AnsiString("2 Sided: ")+AnsiString(surf->m_Flags.is(CSurface::sf2Sided)?"on":"off")); + ss.push_back(AnsiString("2 Sided: ")+AnsiString(surf->m_Flags.is(CSurface::sf2Sided) ? "on" : "off")); } } } diff --git a/src/editors/ShaderEditor/SHEngineTools.h b/src/editors/ShaderEditor/SHEngineTools.h index c43ae3ca49b..ff83c74bbbb 100644 --- a/src/editors/ShaderEditor/SHEngineTools.h +++ b/src/editors/ShaderEditor/SHEngineTools.h @@ -1,27 +1,29 @@ //--------------------------------------------------------------------------- -#ifndef SHEngineToolsH +#ifndef SHEngineToolsH #define SHEngineToolsH #include "SHToolsInterface.h" -#include "../xrEProps/PropertiesList.h" +#include "editors/xrEProps/PropertiesList.h" -DEFINE_VECTOR(IBlender*,TemplateVec,TemplateIt); -DEFINE_MAP_PRED(LPSTR,CConstant*,ConstantMap,ConstantPairIt,str_pred); -DEFINE_MAP_PRED(LPSTR,CMatrix*,MatrixMap,MatrixPairIt,str_pred); -DEFINE_MAP_PRED(LPSTR,IBlender*,BlenderMap,BlenderPairIt,str_pred); +DEFINE_VECTOR(IBlender*, TemplateVec, TemplateIt); +DEFINE_MAP_PRED(LPSTR, CConstant*, ConstantMap, ConstantPairIt, str_pred); +DEFINE_MAP_PRED(LPSTR, CMatrix*, MatrixMap, MatrixPairIt, str_pred); +DEFINE_MAP_PRED(LPSTR, IBlender*, BlenderMap, BlenderPairIt, str_pred); // refs class CSHEngineTools; class CEditableObject; -class CParseBlender{ +class CParseBlender +{ public: - virtual void Parse(CSHEngineTools* owner, DWORD type, LPCSTR key, LPVOID data)=0; + virtual void Parse(CSHEngineTools *owner, DWORD type, LPCSTR key, LPVOID data) =0; }; -enum EPreviewObj{ - pvoNone, - pvoPlane, +enum EPreviewObj +{ + pvoNone, + pvoPlane, pvoBox, pvoSphere, pvoTeapot, @@ -31,133 +33,158 @@ enum EPreviewObj{ class CSHEngineTools: public ISHTools { - SStringVec MCString; - - u32 m_PreviewObjectType; - CEditableObject* m_PreviewObject; - bool m_bCustomEditObject; - - BOOL m_bFreezeUpdate; - BOOL m_bNeedResetShaders; - BOOL m_RemoteRenBlender; - AnsiString m_RenBlenderOldName; - AnsiString m_RenBlenderNewName; - - TemplateVec m_TemplatePalette; - - ConstantMap m_OptConstants; - MatrixMap m_OptMatrices; - ConstantMap m_Constants; - MatrixMap m_Matrices; - BlenderMap m_Blenders; - - void __stdcall ItemExist (LPCSTR name, bool& res){res = !!FindItem(name);} - IBlender* FindItem (LPCSTR name); - - void AddMatrixRef (LPSTR name); - CMatrix* FindMatrix (LPCSTR name); - CMatrix* AppendMatrix (LPSTR name); - LPCSTR GenerateMatrixName (LPSTR name); - LPCSTR AppendMatrix (CMatrix* src=0, CMatrix** dest=0); - void RemoveMatrix (LPCSTR name); - - void AddConstantRef (LPSTR name); - CConstant* FindConstant (LPCSTR name); - CConstant* AppendConstant (LPSTR name); - LPCSTR GenerateConstantName(LPSTR name); - LPCSTR AppendConstant (CConstant* src=0, CConstant** dest=0); - void RemoveConstant (LPCSTR name); - -friend class CCollapseBlender; -friend class CRefsBlender; -friend class CRemoveBlender; -friend class TfrmShaderProperties; - void CollapseMatrix (LPSTR name); - void CollapseConstant (LPSTR name); - void CollapseReferences (); - void UpdateMatrixRefs (LPSTR name); - void UpdateConstantRefs (LPSTR name); - void UpdateRefCounters (); - - void ParseBlender (IBlender* B, CParseBlender& P); - - CMemoryWriter m_BlenderStream; // ïîëüçîâàòüñÿ ôóíêöèÿìè îáíîâëåíèÿ ñòðèìà äëÿ ñèíõðîíèçàöèè - bool m_bUpdateCurrent; // åñëè ìåíÿëñÿ îáúåêò íåïîñðåäñòâåííî Update____From___() - bool m_bCurBlenderChanged; - - void Save (CMemoryWriter& F); - void PrepareRender (); + SStringVec MCString; + + u32 m_PreviewObjectType; + CEditableObject *m_PreviewObject; + bool m_bCustomEditObject; + + BOOL m_bFreezeUpdate; + BOOL m_bNeedResetShaders; + BOOL m_RemoteRenBlender; + AnsiString m_RenBlenderOldName; + AnsiString m_RenBlenderNewName; + + TemplateVec m_TemplatePalette; + + ConstantMap m_OptConstants; + MatrixMap m_OptMatrices; + ConstantMap m_Constants; + MatrixMap m_Matrices; + BlenderMap m_Blenders; + + void __stdcall ItemExist(LPCSTR name, bool &res) + { + res = !!FindItem(name); + } + + IBlender *FindItem(LPCSTR name); + + void AddMatrixRef(LPSTR name); + CMatrix *FindMatrix(LPCSTR name); + CMatrix *AppendMatrix(LPSTR name); + LPCSTR GenerateMatrixName(LPSTR name); + LPCSTR AppendMatrix(CMatrix *src = 0, CMatrix **dest = 0); + void RemoveMatrix(LPCSTR name); + + void AddConstantRef(LPSTR name); + CConstant *FindConstant(LPCSTR name); + CConstant *AppendConstant(LPSTR name); + LPCSTR GenerateConstantName(LPSTR name); + LPCSTR AppendConstant(CConstant *src = 0, CConstant **dest = 0); + void RemoveConstant(LPCSTR name); + + friend class CCollapseBlender; + friend class CRefsBlender; + friend class CRemoveBlender; + friend class TfrmShaderProperties; + void CollapseMatrix(LPSTR name); + void CollapseConstant(LPSTR name); + void CollapseReferences(); + void UpdateMatrixRefs(LPSTR name); + void UpdateConstantRefs(LPSTR name); + void UpdateRefCounters(); + + void ParseBlender(IBlender *B, CParseBlender &P); + + CMemoryWriter m_BlenderStream; // ïîëüçîâàòüñÿ ôóíêöèÿìè îáíîâëåíèÿ ñòðèìà äëÿ ñèíõðîíèçàöèè + bool m_bUpdateCurrent; // åñëè ìåíÿëñÿ îáúåêò íåïîñðåäñòâåííî Update____From___() + bool m_bCurBlenderChanged; + + void Save(CMemoryWriter &F); + void PrepareRender(); // template - void __stdcall FillChooseTemplate (ChooseItemVec& items, void* param); + void __stdcall FillChooseTemplate(ChooseItemVec &items, void *param); // matrix props - bool __stdcall MatrixOnAfterEdit (PropValue* sender, xr_string& edit_val); - void __stdcall FillMatrixProps (PropItemVec& items, LPCSTR pref, LPSTR name); - void __stdcall MCOnDraw (PropValue* sender, xr_string& draw_val); + bool __stdcall MatrixOnAfterEdit(PropValue *sender, xr_string &edit_val); + void __stdcall FillMatrixProps(PropItemVec &items, LPCSTR pref, LPSTR name); + void __stdcall MCOnDraw(PropValue *sender, xr_string &draw_val); // constant props - bool __stdcall ConstOnAfterEdit (PropValue* sender, xr_string& edit_val); - void __stdcall FillConstProps (PropItemVec& items, LPCSTR pref, LPSTR name); + bool __stdcall ConstOnAfterEdit(PropValue *sender, xr_string &edit_val); + void __stdcall FillConstProps(PropItemVec &items, LPCSTR pref, LPSTR name); // name - bool __stdcall NameOnAfterEdit (PropValue* sender, xr_string& edit_val); + bool __stdcall NameOnAfterEdit(PropValue *sender, xr_string &edit_val); - void RealResetShaders (); + void RealResetShaders(); - void __stdcall FillMatrix (PropItemVec& values, LPCSTR pref, CMatrix* m); - void __stdcall FillConst (PropItemVec& values, LPCSTR pref, CConstant* c); - void __stdcall RefreshProperties (); + void __stdcall FillMatrix(PropItemVec &values, LPCSTR pref, CMatrix *m); + void __stdcall FillConst(PropItemVec &values, LPCSTR pref, CConstant *c); + void __stdcall RefreshProperties(); - void ResetShaders (bool bForced=false){m_bNeedResetShaders=true; if (bForced) RealResetShaders(); } - void UpdateObjectShader (); + void ResetShaders(bool bForced = false) + { + m_bNeedResetShaders = true; + if (bForced) + RealResetShaders(); + } - bool __stdcall OnPreviewObjectRefChange(PropValue* sender, u32& edit_val); + void UpdateObjectShader(); + + bool __stdcall OnPreviewObjectRefChange(PropValue *sender, u32 &edit_val); public: - CMemoryWriter m_RenderShaders; + CMemoryWriter m_RenderShaders; + + IBlender *m_CurrentBlender; - IBlender* m_CurrentBlender; - void RemoteRenameBlender (LPCSTR old_full_name, LPCSTR new_full_name){m_RemoteRenBlender=TRUE;m_RenBlenderOldName=old_full_name;m_RenBlenderNewName=new_full_name;} + void RemoteRenameBlender(LPCSTR old_full_name, LPCSTR new_full_name) + { + m_RemoteRenBlender = TRUE; + m_RenBlenderOldName = old_full_name; + m_RenBlenderNewName = new_full_name; + } - Shader_xrLC* m_Shader; - virtual LPCSTR AppendItem (LPCSTR folder_name, LPCSTR parent=0); - virtual void RealRenameItem (LPCSTR old_full_name, LPCSTR new_full_name); - virtual void __stdcall OnRemoveItem (LPCSTR name, EItemType type, bool& res); - virtual void __stdcall OnRenameItem (LPCSTR old_full_name, LPCSTR new_full_name, EItemType type); - virtual void FillItemList (); + Shader_xrLC *m_Shader; + virtual LPCSTR AppendItem(LPCSTR folder_name, LPCSTR parent = 0); + virtual void RealRenameItem(LPCSTR old_full_name, LPCSTR new_full_name); + virtual void __stdcall OnRemoveItem(LPCSTR name, EItemType type, bool &res); + virtual void __stdcall OnRenameItem(LPCSTR old_full_name, LPCSTR new_full_name, EItemType type); + virtual void FillItemList(); - void UpdateStreamFromObject(); - void UpdateObjectFromStream(); + void UpdateStreamFromObject(); + void UpdateObjectFromStream(); - void ClearData (); + void ClearData(); public: - CSHEngineTools (ISHInit& init); - virtual ~CSHEngineTools (); + CSHEngineTools(ISHInit &init); + virtual ~CSHEngineTools(); - virtual LPCSTR ToolsName (){return "Engine Shader";} + virtual LPCSTR ToolsName() + { + return "Engine Shader"; + } - virtual void Reload (); - virtual void Load (); - virtual bool Save (); + virtual void Reload(); + virtual void Load(); + virtual bool Save(); - virtual bool OnCreate (); - virtual void OnDestroy (); - virtual void OnActivate (); - virtual void OnDeactivate (); + virtual bool OnCreate(); + virtual void OnDestroy(); + virtual void OnActivate(); + virtual void OnDeactivate(); // misc - virtual void ResetCurrentItem (); - virtual void SetCurrentItem (LPCSTR name, bool bView); - virtual void ApplyChanges (bool bForced=false); + virtual void ResetCurrentItem(); + virtual void SetCurrentItem(LPCSTR name, bool bView); + virtual void ApplyChanges(bool bForced = false); - virtual void RealUpdateProperties(); - virtual void RealUpdateList (); + virtual void RealUpdateProperties(); + virtual void RealUpdateList(); - virtual void OnFrame (); - virtual void OnRender (); + virtual void OnFrame(); + virtual void OnRender(); - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (){;} + virtual void OnDeviceCreate(); - virtual void ZoomObject (bool bOnlySel); - virtual void OnShowHint (AStringVec& ss); + virtual void OnDeviceDestroy() + { + ; + } + + virtual void ZoomObject(bool bOnlySel); + virtual void OnShowHint(AStringVec &ss); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ShaderEditor/SHEngineToolsProperties.cpp b/src/editors/ShaderEditor/SHEngineToolsProperties.cpp index 61639704612..c1bbccde8ae 100644 --- a/src/editors/ShaderEditor/SHEngineToolsProperties.cpp +++ b/src/editors/ShaderEditor/SHEngineToolsProperties.cpp @@ -3,202 +3,251 @@ #pragma hdrstop #include "SHEngineTools.h" -#include "../../Layers/xrRender/blenders/Blender.h" -#include "../xrEProps/PropertiesList.h" -#include "../xrEProps/folderlib.h" -#include "../ECore/Editor/ui_main.h" +#include "Layers/xrRender/blenders/Blender.h" +#include "editors/xrEProps/PropertiesList.h" +#include "editors/xrEProps/FolderLib.h" +#include "editors/ECore/Editor/ui_main.h" //--------------------------------------------------------------------------- -xr_token mode_token [ ]={ - { "Programmable", CMatrix::modeProgrammable }, - { "TCM", CMatrix::modeTCM }, - { "Spherical Reflection", CMatrix::modeS_refl }, - { "Cube Reflection", CMatrix::modeC_refl }, - { 0, 0 } +xr_token mode_token [ ] = { + {"Programmable", CMatrix::modeProgrammable}, + {"TCM", CMatrix::modeTCM}, + {"Spherical Reflection", CMatrix::modeS_refl}, + {"Cube Reflection", CMatrix::modeC_refl}, + {0, 0} }; + //--------------------------------------------------------------------------- -void __fastcall CSHEngineTools::FillMatrixProps(PropItemVec& items, LPCSTR pref, LPSTR name) +void __fastcall CSHEngineTools::FillMatrixProps(PropItemVec &items, LPCSTR pref, LPSTR name) { - CMatrix* M = AppendMatrix(name); + CMatrix *M = AppendMatrix(name); R_ASSERT(M); - PHelper().CreateToken32 (items,PrepareKey(pref,"Mode"),&M->dwMode,mode_token); - - if (M->dwMode==CMatrix::modeTCM){ - PHelper().CreateFlag32 (items, PrepareKey(pref,"Scale enabled"), &M->tcm_flags,CMatrix::tcmScale); - PHelper().CreateWave (items, PrepareKey(pref,"Scale U"), &M->scaleU); - PHelper().CreateWave (items, PrepareKey(pref,"Scale V"), &M->scaleV); - PHelper().CreateFlag32 (items, PrepareKey(pref,"Rotate enabled"), &M->tcm_flags,CMatrix::tcmRotate); - PHelper().CreateWave (items, PrepareKey(pref,"Rotate"), &M->rotate); - PHelper().CreateFlag32 (items, PrepareKey(pref,"Scroll enabled"), &M->tcm_flags,CMatrix::tcmScroll); - PHelper().CreateWave (items, PrepareKey(pref,"Scroll U"), &M->scrollU); - PHelper().CreateWave (items, PrepareKey(pref,"Scroll V"), &M->scrollV); + PHelper().CreateToken32(items, PrepareKey(pref, "Mode"), &M->dwMode, mode_token); + + if (M->dwMode==CMatrix::modeTCM) + { + PHelper().CreateFlag32(items, PrepareKey(pref, "Scale enabled"), &M->tcm_flags, CMatrix::tcmScale); + PHelper().CreateWave(items, PrepareKey(pref, "Scale U"), &M->scaleU); + PHelper().CreateWave(items, PrepareKey(pref, "Scale V"), &M->scaleV); + PHelper().CreateFlag32(items, PrepareKey(pref, "Rotate enabled"), &M->tcm_flags, CMatrix::tcmRotate); + PHelper().CreateWave(items, PrepareKey(pref, "Rotate"), &M->rotate); + PHelper().CreateFlag32(items, PrepareKey(pref, "Scroll enabled"), &M->tcm_flags, CMatrix::tcmScroll); + PHelper().CreateWave(items, PrepareKey(pref, "Scroll U"), &M->scrollU); + PHelper().CreateWave(items, PrepareKey(pref, "Scroll V"), &M->scrollV); } } + //--------------------------------------------------------------------------- -void __fastcall CSHEngineTools::MCOnDraw(PropValue* sender, xr_string& draw_val) +void __fastcall CSHEngineTools::MCOnDraw(PropValue *sender, xr_string &draw_val) { - if (draw_val[0]!='$') draw_val="Custom"; + if (draw_val[0]!='$') + draw_val = "Custom"; } + //--------------------------------------------------------------------------- -bool CSHEngineTools::MatrixOnAfterEdit(PropValue* sender, xr_string& nm) +bool CSHEngineTools::MatrixOnAfterEdit(PropValue *sender, xr_string &nm) { - CListValue* V = dynamic_cast(sender); R_ASSERT(V); - VERIFY (nm.size()); - LPCSTR src_val = V->GetValue(); - - if (nm[0]!='$'){ - if (src_val[0]=='$'){ - nm = AppendMatrix(); - }else{ - nm = src_val; + CListValue *V = dynamic_cast(sender); + R_ASSERT(V); + VERIFY(nm.size()); + LPCSTR src_val = V->GetValue(); + + if (nm[0]!='$') + { + if (src_val[0]=='$') + { + nm = AppendMatrix(); + } + else + { + nm = src_val; } - }else{ - if (src_val[0]!='$'){ - RemoveMatrix (src_val); - V->ApplyValue (src_val); + } + else + { + if (src_val[0]!='$') + { + RemoveMatrix(src_val); + V->ApplyValue(src_val); } } return true; } + //------------------------------------------------------------------------------ -void __fastcall CSHEngineTools::FillConstProps(PropItemVec& items, LPCSTR pref, LPSTR name) +void __fastcall CSHEngineTools::FillConstProps(PropItemVec &items, LPCSTR pref, LPSTR name) { - CConstant* C = AppendConstant(name); + CConstant *C = AppendConstant(name); R_ASSERT(C); - PHelper().CreateWave(items,PrepareKey(pref,"R"),&C->_R); - PHelper().CreateWave(items,PrepareKey(pref,"G"),&C->_G); - PHelper().CreateWave(items,PrepareKey(pref,"B"),&C->_B); - PHelper().CreateWave(items,PrepareKey(pref,"A"),&C->_A); + PHelper().CreateWave(items, PrepareKey(pref, "R"), &C->_R); + PHelper().CreateWave(items, PrepareKey(pref, "G"), &C->_G); + PHelper().CreateWave(items, PrepareKey(pref, "B"), &C->_B); + PHelper().CreateWave(items, PrepareKey(pref, "A"), &C->_A); } + //--------------------------------------------------------------------------- -bool CSHEngineTools::ConstOnAfterEdit(PropValue* sender, xr_string& nm) +bool CSHEngineTools::ConstOnAfterEdit(PropValue *sender, xr_string &nm) { - CListValue* V = dynamic_cast(sender); R_ASSERT(V); - VERIFY (nm.size()); - LPCSTR src_val = V->GetValue(); - - if (nm[0]!='$'){ - if (src_val[0]=='$'){ + CListValue *V = dynamic_cast(sender); + R_ASSERT(V); + VERIFY(nm.size()); + LPCSTR src_val = V->GetValue(); + + if (nm[0]!='$') + { + if (src_val[0]=='$') + { nm = AppendConstant(); - }else{ + } + else + { nm = src_val; } - }else{ - if (src_val[0]!='$'){ + } + else + { + if (src_val[0]!='$') + { RemoveConstant(src_val); V->ApplyValue(src_val); } } return true; } + //------------------------------------------------------------------------------ -bool CSHEngineTools::NameOnAfterEdit(PropValue* sender, xr_string& new_name) +bool CSHEngineTools::NameOnAfterEdit(PropValue *sender, xr_string &new_name) { - CTextValue* V = dynamic_cast(sender); R_ASSERT(V); - AnsiString nn = new_name.c_str(); - if (FHelper.NameAfterEdit((TElTreeItem*)m_CurrentItem->Item(),V->GetValue(),nn)){ - new_name = nn.c_str(); - RemoteRenameBlender(V->GetValue(),new_name.c_str()); + CTextValue *V = dynamic_cast(sender); + R_ASSERT(V); + AnsiString nn = new_name.c_str(); + if (FHelper.NameAfterEdit((TElTreeItem*)m_CurrentItem->Item(), V->GetValue(), nn)) + { + new_name = nn.c_str(); + RemoteRenameBlender(V->GetValue(), new_name.c_str()); } return true; } + //------------------------------------------------------------------------------ void CSHEngineTools::RealUpdateList() { - if (m_bFreezeUpdate) return; - FillItemList (); + if (m_bFreezeUpdate) + return; + FillItemList(); } + //------------------------------------------------------------------------------ void CSHEngineTools::RealUpdateProperties() { - if (m_bFreezeUpdate) return; - - PropItemVec items; - if (m_CurrentBlender){ // fill Tree - AnsiString marker_text=""; - - IReader data(m_BlenderStream.pointer(), m_BlenderStream.size()); - CBlender_DESC* desc=(CBlender_DESC*)data.pointer(); + if (m_bFreezeUpdate) + return; + + PropItemVec items; + if (m_CurrentBlender) + { // fill Tree + AnsiString marker_text = ""; + + IReader data(m_BlenderStream.pointer(), m_BlenderStream.size()); + CBlender_DESC *desc = (CBlender_DESC*)data.pointer(); data.advance(sizeof(CBlender_DESC)); DWORD type; string256 key; - PHelper().CreateCaption(items,"Type",m_CurrentBlender->getComment()); - PHelper().CreateCaption(items,"Owner",desc->cComputer); - CTextValue* V = PHelper().CreateCText(items,"Name",desc->cName,sizeof(desc->cName)); - V->OnAfterEditEvent.bind (this,&CSHEngineTools::NameOnAfterEdit); - V->OnBeforeEditEvent.bind (&PHelper(),&IPropHelper::CNameBeforeEdit); - V->Owner()->OnDrawTextEvent.bind(&PHelper(),&IPropHelper::CNameDraw); - - while (!data.eof()){ - int sz=0; - type = data.r_u32(); - data.r_stringZ(key,sizeof(key)); - switch(type){ - case xrPID_MARKER: - marker_text = key; - break; - case xrPID_TOKEN:{ - xrP_TOKEN* V = (xrP_TOKEN*)data.pointer(); - sz = sizeof(xrP_TOKEN)+sizeof(xrP_TOKEN::Item)*V->Count; - PHelper().CreateTokenSH(items,PrepareKey(marker_text.c_str(),key),&V->IDselected,(TokenValueSH::Item*)(LPBYTE(data.pointer()) + sizeof(xrP_TOKEN)),V->Count); - }break; - case xrPID_MATRIX:{ - sz = sizeof(string64); - LPSTR V = (LPSTR)data.pointer(); - CListValue* P = PHelper().CreateCList(items,PrepareKey(marker_text.c_str(),key),V,sz,&*MCString.begin(),MCString.size()); - AnsiString pref = AnsiString(PrepareKey(marker_text.c_str(),"Custom ").c_str())+key; - if (V&&V[0]&&(*V!='$')) FillMatrixProps(items,pref.c_str(),V); - P->OnAfterEditEvent.bind(this,&CSHEngineTools::MatrixOnAfterEdit); - P->Owner()->OnDrawTextEvent.bind(this,&CSHEngineTools::MCOnDraw); - }break; - case xrPID_CONSTANT:{ - sz=sizeof(string64); - sz = sizeof(string64); - LPSTR V = (LPSTR)data.pointer(); - CListValue* P = PHelper().CreateCList(items,PrepareKey(marker_text.c_str(),key),V,sz,&*MCString.begin(),MCString.size()); - AnsiString pref = AnsiString(PrepareKey(marker_text.c_str(),"Custom ").c_str())+key; - if (V&&V[0]&&(*V!='$')) FillConstProps(items,pref.c_str(),V); - P->OnAfterEditEvent.bind(this,&CSHEngineTools::ConstOnAfterEdit); - P->Owner()->OnDrawTextEvent.bind(this,&CSHEngineTools::MCOnDraw); - }break; - case xrPID_TEXTURE: - sz=sizeof(string64); - PHelper().CreateTexture(items,PrepareKey(marker_text.c_str(),key),(LPSTR)data.pointer(),sz); - break; - case xrPID_INTEGER:{ - sz=sizeof(xrP_Integer); - xrP_Integer* V=(xrP_Integer*)data.pointer(); - PHelper().CreateS32(items,PrepareKey(marker_text.c_str(),key),&V->value,V->min,V->max,1); - }break; - case xrPID_FLOAT:{ - sz=sizeof(xrP_Float); - xrP_Float* V=(xrP_Float*)data.pointer(); - PHelper().CreateFloat(items,PrepareKey(marker_text.c_str(),key),&V->value,V->min,V->max,0.01f,2); - }break; - case xrPID_BOOL:{ - sz=sizeof(xrP_BOOL); - xrP_BOOL* V=(xrP_BOOL*)data.pointer(); - PHelper().CreateBOOL(items,PrepareKey(marker_text.c_str(),key),&V->value); - }break; - default: THROW2("UNKNOWN xrPID_????"); + PHelper().CreateCaption(items, "Type", m_CurrentBlender->getComment()); + PHelper().CreateCaption(items, "Owner", desc->cComputer); + CTextValue *V = PHelper().CreateCText(items, "Name", desc->cName, sizeof(desc->cName)); + V->OnAfterEditEvent.bind(this, &CSHEngineTools::NameOnAfterEdit); + V->OnBeforeEditEvent.bind(&PHelper(), &IPropHelper::CNameBeforeEdit); + V->Owner()->OnDrawTextEvent.bind(&PHelper(), &IPropHelper::CNameDraw); + + while (!data.eof()) + { + int sz = 0; + type = data.r_u32(); + data.r_stringZ(key, sizeof(key)); + switch (type) + { + case xrPID_MARKER: + marker_text = key; + break; + case xrPID_TOKEN: + { + xrP_TOKEN*V = (xrP_TOKEN*)data.pointer(); + sz = sizeof(xrP_TOKEN)+sizeof(xrP_TOKEN::Item)*V->Count; + PHelper().CreateTokenSH(items, PrepareKey(marker_text.c_str(), key), &V->IDselected, (TokenValueSH::Item*)(LPBYTE(data.pointer())+sizeof(xrP_TOKEN)), V->Count); + } + break; + case xrPID_MATRIX: + { + sz = sizeof(string64); + LPSTR V = (LPSTR)data.pointer(); + CListValue *P = PHelper().CreateCList(items, PrepareKey(marker_text.c_str(), key), V, sz, &*MCString.begin(), MCString.size()); + AnsiString pref = AnsiString(PrepareKey(marker_text.c_str(), "Custom ").c_str())+key; + if (V&&V[0]&&(*V!='$')) + FillMatrixProps(items, pref.c_str(), V); + P->OnAfterEditEvent.bind(this, &CSHEngineTools::MatrixOnAfterEdit); + P->Owner()->OnDrawTextEvent.bind(this, &CSHEngineTools::MCOnDraw); + } + break; + case xrPID_CONSTANT: + { + sz = sizeof(string64); + sz = sizeof(string64); + LPSTR V = (LPSTR)data.pointer(); + CListValue *P = PHelper().CreateCList(items, PrepareKey(marker_text.c_str(), key), V, sz, &*MCString.begin(), MCString.size()); + AnsiString pref = AnsiString(PrepareKey(marker_text.c_str(), "Custom ").c_str())+key; + if (V&&V[0]&&(*V!='$')) + FillConstProps(items, pref.c_str(), V); + P->OnAfterEditEvent.bind(this, &CSHEngineTools::ConstOnAfterEdit); + P->Owner()->OnDrawTextEvent.bind(this, &CSHEngineTools::MCOnDraw); + } + break; + case xrPID_TEXTURE: + sz = sizeof(string64); + PHelper().CreateTexture(items, PrepareKey(marker_text.c_str(), key), (LPSTR)data.pointer(), sz); + break; + case xrPID_INTEGER: + { + sz = sizeof(xrP_Integer); + xrP_Integer*V = (xrP_Integer*)data.pointer(); + PHelper().CreateS32(items, PrepareKey(marker_text.c_str(), key), &V->value, V->min, V->max, 1); + } + break; + case xrPID_FLOAT: + { + sz = sizeof(xrP_Float); + xrP_Float*V = (xrP_Float*)data.pointer(); + PHelper().CreateFloat(items, PrepareKey(marker_text.c_str(), key), &V->value, V->min, V->max, 0.01f, 2); + } + break; + case xrPID_BOOL: + { + sz = sizeof(xrP_BOOL); + xrP_BOOL*V = (xrP_BOOL*)data.pointer(); + PHelper().CreateBOOL(items, PrepareKey(marker_text.c_str(), key), &V->value); + } + break; + default: THROW2("UNKNOWN xrPID_????"); } data.advance(sz); } -// âìåñòî ApplyChanges(true); + // âìåñòî ApplyChanges(true); UpdateObjectFromStream(); Ext.m_ItemProps->ResetModified(); -//--------------------------- + //--------------------------- } Ext.m_ItemProps->AssignItems(items); - Ext.m_ItemProps->SetModifiedEvent(fastdelegate::bind(this,&CSHEngineTools::Modified)); + Ext.m_ItemProps->SetModifiedEvent(fastdelegate::bind(this, &CSHEngineTools::Modified)); } + //------------------------------------------------------------------------------ + diff --git a/src/editors/ShaderEditor/SHGameMtlPairTools.cpp b/src/editors/ShaderEditor/SHGameMtlPairTools.cpp index fd9cc317233..235fa3dc010 100644 --- a/src/editors/ShaderEditor/SHGameMtlPairTools.cpp +++ b/src/editors/ShaderEditor/SHGameMtlPairTools.cpp @@ -4,154 +4,174 @@ #include "SHGameMtlPairTools.h" #include "UI_ShaderTools.h" -#include "../xrEProps/folderlib.h" -#include "../xrEProps/ChoseForm.h" -#include "../ECore/Editor/UI_Main.h" -#include "../xrEProps/ItemList.h" +#include "editors/xrEProps/FolderLib.h" +#include "editors/xrEProps/ChoseForm.h" +#include "editors/ECore/Editor/UI_Main.h" +#include "editors/xrEProps/ItemList.h" + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -CSHGameMtlPairTools::CSHGameMtlPairTools(ISHInit& init):ISHTools(init) +CSHGameMtlPairTools::CSHGameMtlPairTools(ISHInit &init): ISHTools(init) { - m_MtlPair = 0; - m_GameMtlTools = 0; + m_MtlPair = 0; + m_GameMtlTools = 0; } -CSHGameMtlPairTools::~CSHGameMtlPairTools() -{ -} +CSHGameMtlPairTools::~CSHGameMtlPairTools() {} + //--------------------------------------------------------------------------- void CSHGameMtlPairTools::OnFrame() { - inherited::OnFrame(); + inherited::OnFrame(); } + //--------------------------------------------------------------------------- bool CSHGameMtlPairTools::OnCreate() { - m_GameMtlTools = STools->FindTools(aeMtl); R_ASSERT(m_GameMtlTools); + m_GameMtlTools = STools->FindTools(aeMtl); + R_ASSERT(m_GameMtlTools); Load(); return true; } + //--------------------------------------------------------------------------- void CSHGameMtlPairTools::OnDestroy() { m_bModified = FALSE; } + //--------------------------------------------------------------------------- void CSHGameMtlPairTools::Reload() { - // mtl + // mtl ResetCurrentItem(); // mtl pair m_GameMtlTools->ResetCurrentItem(); // load Load(); // mtl pair - m_GameMtlTools->FillItemList(); - FillItemList (); + m_GameMtlTools->FillItemList(); + FillItemList(); } + //--------------------------------------------------------------------------- void CSHGameMtlPairTools::FillItemList() { - ListItemsVec items; - for (GameMtlIt m0_it=GMLib.FirstMaterial(); m0_it!=GMLib.LastMaterial(); m0_it++){ - SGameMtl* M0 = *m0_it; - for (GameMtlIt m1_it=GMLib.FirstMaterial(); m1_it!=GMLib.LastMaterial(); m1_it++){ - SGameMtl* M1 = *m1_it; - GameMtlPairIt p_it = GMLib.GetMaterialPairIt(M0->GetID(),M1->GetID()); + ListItemsVec items; + for (GameMtlIt m0_it = GMLib.FirstMaterial(); m0_it!=GMLib.LastMaterial(); m0_it++) + { + SGameMtl *M0 = *m0_it; + for (GameMtlIt m1_it = GMLib.FirstMaterial(); m1_it!=GMLib.LastMaterial(); m1_it++) + { + SGameMtl *M1 = *m1_it; + GameMtlPairIt p_it = GMLib.GetMaterialPairIt(M0->GetID(), M1->GetID()); if (p_it!=GMLib.LastMaterialPair()) - LHelper().CreateItem(items,GMLib.MtlPairToName(M0->GetID(),M1->GetID()),0); + LHelper().CreateItem(items, GMLib.MtlPairToName(M0->GetID(), M1->GetID()), 0); } } - Ext.m_Items->AssignItems(items,false,true); - m_MtlPair=0; + Ext.m_Items->AssignItems(items, false, true); + m_MtlPair = 0; } + //--------------------------------------------------------------------------- void CSHGameMtlPairTools::Load() { - m_bLockUpdate = TRUE; + m_bLockUpdate = TRUE; - GMLib.Unload (); - GMLib.Load (); - ResetCurrentItem (); + GMLib.Unload(); + GMLib.Load(); + ResetCurrentItem(); - m_bLockUpdate = FALSE; + m_bLockUpdate = FALSE; } + //--------------------------------------------------------------------------- bool CSHGameMtlPairTools::Save() { - m_bLockUpdate = TRUE; + m_bLockUpdate = TRUE; // save - string_path fn; - FS.update_path (fn,_game_data_,GAMEMTL_FILENAME); - EFS.MarkFile (fn,false); - bool bRes = GMLib.Save(); - m_bLockUpdate = FALSE; - if (bRes) m_bModified = FALSE; + string_path fn; + FS.update_path(fn, _game_data_, GAMEMTL_FILENAME); + EFS.MarkFile(fn, false); + bool bRes = GMLib.Save(); + m_bLockUpdate = FALSE; + if (bRes) + m_bModified = FALSE; return bRes; } + //--------------------------------------------------------------------------- void CSHGameMtlPairTools::RealUpdateList() { - FillItemList (); + FillItemList(); } + //------------------------------------------------------------------------------ void CSHGameMtlPairTools::RealUpdateProperties() { - PropItemVec items; - if (m_MtlPair) m_MtlPair->FillProp(items); - Ext.m_ItemProps->AssignItems (items); - Ext.m_ItemProps->SetModifiedEvent (fastdelegate::bind(this,&CSHGameMtlPairTools::Modified)); + PropItemVec items; + if (m_MtlPair) + m_MtlPair->FillProp(items); + Ext.m_ItemProps->AssignItems(items); + Ext.m_ItemProps->SetModifiedEvent(fastdelegate::bind(this, &CSHGameMtlPairTools::Modified)); } + //--------------------------------------------------------------------------- -void CSHGameMtlPairTools::ApplyChanges(bool bForced) -{ -} +void CSHGameMtlPairTools::ApplyChanges(bool bForced) {} + //--------------------------------------------------------------------------- void CSHGameMtlPairTools::OnActivate() { FillItemList(); - Ext.m_Items->SetOnModifiedEvent(fastdelegate::bind(this,&CSHGameMtlPairTools::Modified)); - inherited::OnActivate (); - m_StoreFlags = Ext.m_Items->GetFlags(); - Ext.m_Items->SetFlags (TItemList::ilFolderStore); + Ext.m_Items->SetOnModifiedEvent(fastdelegate::bind(this, &CSHGameMtlPairTools::Modified)); + inherited::OnActivate(); + m_StoreFlags = Ext.m_Items->GetFlags(); + Ext.m_Items->SetFlags(TItemList::ilFolderStore); } + //--------------------------------------------------------------------------- void CSHGameMtlPairTools::OnDeactivate() { - inherited::OnDeactivate (); - Ext.m_Items->SetFlags (m_StoreFlags); + inherited::OnDeactivate(); + Ext.m_Items->SetFlags(m_StoreFlags); } void CSHGameMtlPairTools::SetCurrentItem(LPCSTR name, bool bView) { - if (m_bLockUpdate) return; - SGameMtlPair* S=GMLib.GetMaterialPair(name); + if (m_bLockUpdate) + return; + SGameMtlPair *S = GMLib.GetMaterialPair(name); // set material - if (m_MtlPair!=S){ + if (m_MtlPair!=S) + { m_MtlPair = S; - ExecCommand(COMMAND_UPDATE_PROPERTIES); - if (bView) ViewSetCurrentItem(name); - } + ExecCommand(COMMAND_UPDATE_PROPERTIES); + if (bView) + ViewSetCurrentItem(name); + } } + //--------------------------------------------------------------------------- void CSHGameMtlPairTools::ResetCurrentItem() { - m_MtlPair = 0; + m_MtlPair = 0; } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ShaderEditor/SHGameMtlPairTools.h b/src/editors/ShaderEditor/SHGameMtlPairTools.h index e1b38a29c14..0d71f6ac73a 100644 --- a/src/editors/ShaderEditor/SHGameMtlPairTools.h +++ b/src/editors/ShaderEditor/SHGameMtlPairTools.h @@ -3,47 +3,69 @@ #define SHGameMtlPairToolsH #include "SHToolsInterface.h" -#include "GameMtlLib.h" +#include "xrEngine/GameMtlLib.h" // refs class PropValue; class CSHGameMtlPairTools: public ISHTools { - ISHTools* m_GameMtlTools; - u32 m_StoreFlags; + ISHTools *m_GameMtlTools; + u32 m_StoreFlags; public: - SGameMtlPair* m_MtlPair; - virtual LPCSTR AppendItem (LPCSTR folder_name, LPCSTR parent_name=0){return 0;} - virtual void FillItemList (); + SGameMtlPair *m_MtlPair; + + virtual LPCSTR AppendItem(LPCSTR folder_name, LPCSTR parent_name = 0) + { + return 0; + } + + virtual void FillItemList(); public: - CSHGameMtlPairTools (ISHInit& init); - virtual ~CSHGameMtlPairTools(); + CSHGameMtlPairTools(ISHInit &init); + virtual ~CSHGameMtlPairTools(); - virtual LPCSTR ToolsName (){return "Game Material Pairs";} + virtual LPCSTR ToolsName() + { + return "Game Material Pairs"; + } - virtual void Reload (); - virtual void Load (); - virtual bool Save (); - virtual void ApplyChanges (bool bForced=false); + virtual void Reload(); + virtual void Load(); + virtual bool Save(); + virtual void ApplyChanges(bool bForced = false); - virtual bool OnCreate (); - virtual void OnDestroy (); - virtual void OnActivate (); - virtual void OnDeactivate (); + virtual bool OnCreate(); + virtual void OnDestroy(); + virtual void OnActivate(); + virtual void OnDeactivate(); // misc - virtual void ResetCurrentItem (); - virtual void SetCurrentItem (LPCSTR name, bool bView); + virtual void ResetCurrentItem(); + virtual void SetCurrentItem(LPCSTR name, bool bView); + + virtual void RealUpdateProperties(); + virtual void RealUpdateList(); + + virtual void OnFrame(); - virtual void RealUpdateProperties(); - virtual void RealUpdateList (); + virtual void OnRender() + { + ; + } - virtual void OnFrame (); - virtual void OnRender (){;} + virtual void OnDeviceCreate() + { + ; + } - virtual void OnDeviceCreate (){;} - virtual void OnDeviceDestroy (){;} + virtual void OnDeviceDestroy() + { + ; + } }; + //--------------------------------------------------------------------------- #endif // SHGameMaterialToolsH + + diff --git a/src/editors/ShaderEditor/SHGameMtlTools.cpp b/src/editors/ShaderEditor/SHGameMtlTools.cpp index f498ca94162..78c96a90aa0 100644 --- a/src/editors/ShaderEditor/SHGameMtlTools.cpp +++ b/src/editors/ShaderEditor/SHGameMtlTools.cpp @@ -3,51 +3,53 @@ #pragma hdrstop #include "SHGameMtlTools.h" -#include "../../xrServerEntities/PropertiesListHelper.h" +#include "xrServerEntities/PropertiesListHelper.h" #include "ui_shadermain.h" -#include "../xrEProps/folderlib.h" +#include "editors/xrEProps/FolderLib.h" #include "UI_ShaderTools.h" -#include "../xrEProps/ChoseForm.h" -#include "leftbar.h" -#include "../xrEProps/ItemList.h" +#include "editors/xrEProps/ChoseForm.h" +#include "LeftBar.h" +#include "editors/xrEProps/ItemList.h" + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -CSHGameMtlTools::CSHGameMtlTools(ISHInit& init):ISHTools(init) +CSHGameMtlTools::CSHGameMtlTools(ISHInit &init): ISHTools(init) { - m_Mtl = 0; - m_GameMtlPairTools = 0; + m_Mtl = 0; + m_GameMtlPairTools = 0; } -CSHGameMtlTools::~CSHGameMtlTools() -{ -} +CSHGameMtlTools::~CSHGameMtlTools() {} + //--------------------------------------------------------------------------- void CSHGameMtlTools::OnActivate() { // fill items - FillItemList (); - Ext.m_Items->SetOnModifiedEvent (fastdelegate::bind(this,&CSHGameMtlTools::Modified)); - Ext.m_Items->SetOnItemRenameEvent (fastdelegate::bind(this,&CSHGameMtlTools::OnRenameItem)); - Ext.m_Items->SetOnItemRemoveEvent (fastdelegate::bind(this,&CSHGameMtlTools::OnRemoveItem)); - inherited::OnActivate (); + FillItemList(); + Ext.m_Items->SetOnModifiedEvent(fastdelegate::bind(this, &CSHGameMtlTools::Modified)); + Ext.m_Items->SetOnItemRenameEvent(fastdelegate::bind(this, &CSHGameMtlTools::OnRenameItem)); + Ext.m_Items->SetOnItemRemoveEvent(fastdelegate::bind(this, &CSHGameMtlTools::OnRemoveItem)); + inherited::OnActivate(); } void CSHGameMtlTools::OnDeactivate() { - inherited::OnDeactivate (); + inherited::OnDeactivate(); } void CSHGameMtlTools::OnFrame() { - inherited::OnFrame(); + inherited::OnFrame(); } + //--------------------------------------------------------------------------- bool CSHGameMtlTools::OnCreate() { - m_GameMtlPairTools = STools->FindTools(aeMtlPair); R_ASSERT(m_GameMtlPairTools); + m_GameMtlPairTools = STools->FindTools(aeMtlPair); + R_ASSERT(m_GameMtlPairTools); Load(); return true; } @@ -59,106 +61,117 @@ void CSHGameMtlTools::OnDestroy() void CSHGameMtlTools::Reload() { - // mtl + // mtl ResetCurrentItem(); // mtl pair m_GameMtlPairTools->ResetCurrentItem(); // load Load(); - FillItemList (); + FillItemList(); } void CSHGameMtlTools::FillItemList() { - // store folders - RStrVec folders; - Ext.m_Items->GetFolders(folders); + // store folders + RStrVec folders; + Ext.m_Items->GetFolders(folders); // fill items - ListItemsVec items; - for (GameMtlIt m_it=GMLib.FirstMaterial(); m_it!=GMLib.LastMaterial(); m_it++) - LHelper().CreateItem(items,*(*m_it)->m_Name,0); + ListItemsVec items; + for (GameMtlIt m_it = GMLib.FirstMaterial(); m_it!=GMLib.LastMaterial(); m_it++) + LHelper().CreateItem(items, *(*m_it)->m_Name, 0); // fill folders - for (RStringVecIt s_it=folders.begin(); s_it!=folders.end(); s_it++) - LHelper().CreateItem(items,**s_it,0); + for (RStringVecIt s_it = folders.begin(); s_it!=folders.end(); s_it++) + LHelper().CreateItem(items, **s_it, 0); // assign items - Ext.m_Items->AssignItems(items,false,true); + Ext.m_Items->AssignItems(items, false, true); } void CSHGameMtlTools::Load() { - m_bLockUpdate = TRUE; + m_bLockUpdate = TRUE; - GMLib.Unload (); - GMLib.Load (); + GMLib.Unload(); + GMLib.Load(); ResetCurrentItem(); - m_bLockUpdate = FALSE; + m_bLockUpdate = FALSE; } bool CSHGameMtlTools::Save() { - ResetCurrentItem (); - m_bLockUpdate = TRUE; + ResetCurrentItem(); + m_bLockUpdate = TRUE; // save - string_path fn; - FS.update_path (fn,_game_data_,GAMEMTL_FILENAME); - EFS.MarkFile (fn,false); - bool bRes = GMLib.Save(); - - m_bLockUpdate = FALSE; - - if (bRes) m_bModified = FALSE; + string_path fn; + FS.update_path(fn, _game_data_, GAMEMTL_FILENAME); + EFS.MarkFile(fn, false); + bool bRes = GMLib.Save(); + + m_bLockUpdate = FALSE; + + if (bRes) + m_bModified = FALSE; return bRes; } -SGameMtl* CSHGameMtlTools::FindItem(LPCSTR name) +SGameMtl *CSHGameMtlTools::FindItem(LPCSTR name) { - if (name && name[0]){ - return GMLib.GetMaterial(name); - }else return 0; + if (name&&name[0]) + { + return GMLib.GetMaterial(name); + } + else + return 0; } -void CSHGameMtlTools::FillChooseMtlType(ChooseItemVec& items, void* param) +void CSHGameMtlTools::FillChooseMtlType(ChooseItemVec &items, void *param) { - items.push_back(SChooseItem("Dynamic", "Dynamic material")); - items.push_back(SChooseItem("Static", "Static material")); + items.push_back(SChooseItem("Dynamic", "Dynamic material")); + items.push_back(SChooseItem("Static", "Static material")); } LPCSTR CSHGameMtlTools::AppendItem(LPCSTR folder_name, LPCSTR parent_name) { - LPCSTR M=0; - SGameMtl* parent = FindItem(parent_name); - if (!parent){ - if (!TfrmChoseItem::SelectItem(smCustom,M,1,0,fastdelegate::bind(this,&CSHGameMtlTools::FillChooseMtlType))||!M) return 0; + LPCSTR M = 0; + SGameMtl *parent = FindItem(parent_name); + if (!parent) + { + if (!TfrmChoseItem::SelectItem(smCustom, M, 1, 0, fastdelegate::bind(this, &CSHGameMtlTools::FillChooseMtlType))||!M) + return 0; } - AnsiString pref = parent_name?AnsiString(parent_name):AnsiString(folder_name)+M; - m_LastSelection = FHelper.GenerateName(pref.c_str(),2,fastdelegate::bind(this,&CSHGameMtlTools::ItemExist),false,true); - SGameMtl* S = GMLib.AppendMaterial(parent); - S->m_Name = m_LastSelection.c_str(); - if (!parent) S->Flags.set (SGameMtl::flDynamic,0==strcmp(M,"Dynamic")); - ExecCommand (COMMAND_UPDATE_LIST); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - Modified (); + AnsiString pref = parent_name ? AnsiString(parent_name) : AnsiString(folder_name)+M; + m_LastSelection = FHelper.GenerateName(pref.c_str(), 2, fastdelegate::bind(this, &CSHGameMtlTools::ItemExist), false, true); + SGameMtl *S = GMLib.AppendMaterial(parent); + S->m_Name = m_LastSelection.c_str(); + if (!parent) + S->Flags.set(SGameMtl::flDynamic, 0==strcmp(M, "Dynamic")); + ExecCommand(COMMAND_UPDATE_LIST); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + Modified(); return *S->m_Name; } void CSHGameMtlTools::OnRenameItem(LPCSTR old_full_name, LPCSTR new_full_name, EItemType type) { - if (type==TYPE_OBJECT){ - SGameMtl* S = FindItem(old_full_name); R_ASSERT(S); - S->m_Name = new_full_name; - if (S==m_Mtl){ - ExecCommand (COMMAND_UPDATE_PROPERTIES); - ExecCommand (COMMAND_UPDATE_LIST); + if (type==TYPE_OBJECT) + { + SGameMtl *S = FindItem(old_full_name); + R_ASSERT(S); + S->m_Name = new_full_name; + if (S==m_Mtl) + { + ExecCommand(COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_LIST); } } } -void CSHGameMtlTools::OnRemoveItem(LPCSTR name, EItemType type, bool& res) +void CSHGameMtlTools::OnRemoveItem(LPCSTR name, EItemType type, bool &res) { - if (type==TYPE_OBJECT){ - R_ASSERT(name && name[0]); + if (type==TYPE_OBJECT) + { + R_ASSERT(name&&name[0]); GMLib.RemoveMaterial(name); } res = true; @@ -166,42 +179,47 @@ void CSHGameMtlTools::OnRemoveItem(LPCSTR name, EItemType type, bool& res) void CSHGameMtlTools::SetCurrentItem(LPCSTR name, bool bView) { - if (m_bLockUpdate) return; + if (m_bLockUpdate) + return; - SGameMtl* S = FindItem(name); + SGameMtl *S = FindItem(name); // load material - if (m_Mtl!=S){ + if (m_Mtl!=S) + { m_Mtl = S; - ExecCommand(COMMAND_UPDATE_PROPERTIES); - if (bView) ViewSetCurrentItem(name); - } + ExecCommand(COMMAND_UPDATE_PROPERTIES); + if (bView) + ViewSetCurrentItem(name); + } } void CSHGameMtlTools::ResetCurrentItem() { - m_Mtl=0; + m_Mtl = 0; } + //--------------------------------------------------------------------------- void CSHGameMtlTools::RealUpdateList() { - FillItemList (); + FillItemList(); } + //------------------------------------------------------------------------------ void CSHGameMtlTools::RealUpdateProperties() { - PropItemVec items; + PropItemVec items; if (m_Mtl) - m_Mtl->FillProp (items,m_CurrentItem); - Ext.m_ItemProps->AssignItems (items); - Ext.m_ItemProps->SetModifiedEvent (fastdelegate::bind(this,&CSHGameMtlTools::Modified)); + m_Mtl->FillProp(items, m_CurrentItem); + Ext.m_ItemProps->AssignItems(items); + Ext.m_ItemProps->SetModifiedEvent(fastdelegate::bind(this, &CSHGameMtlTools::Modified)); } + //--------------------------------------------------------------------------- -void CSHGameMtlTools::ApplyChanges(bool bForced) -{ -} +void CSHGameMtlTools::ApplyChanges(bool bForced) {} + //--------------------------------------------------------------------------- diff --git a/src/editors/ShaderEditor/SHGameMtlTools.h b/src/editors/ShaderEditor/SHGameMtlTools.h index 7e16c9d8df9..20d6bd94c06 100644 --- a/src/editors/ShaderEditor/SHGameMtlTools.h +++ b/src/editors/ShaderEditor/SHGameMtlTools.h @@ -3,52 +3,74 @@ #define SHGameMtlToolsH #include "SHToolsInterface.h" -#include "GameMtlLib.h" +#include "xrEngine/GameMtlLib.h" // refs class PropValue; class CSHGameMtlTools: public ISHTools { - ISHTools* m_GameMtlPairTools; - void __stdcall ItemExist (LPCSTR name, bool& res){res = !!FindItem(name);} - SGameMtl* FindItem (LPCSTR name); + ISHTools *m_GameMtlPairTools; + + void __stdcall ItemExist(LPCSTR name, bool &res) + { + res = !!FindItem(name); + } + + SGameMtl *FindItem(LPCSTR name); public: - SGameMtl* m_Mtl; - virtual LPCSTR AppendItem (LPCSTR folder_name, LPCSTR parent_name=0); - virtual void __stdcall OnRemoveItem (LPCSTR name, EItemType type, bool& res); - virtual void __stdcall OnRenameItem (LPCSTR old_full_name, LPCSTR new_full_name, EItemType type); - void __stdcall FillChooseMtlType (ChooseItemVec& items, void* param); + SGameMtl *m_Mtl; + virtual LPCSTR AppendItem(LPCSTR folder_name, LPCSTR parent_name = 0); + virtual void __stdcall OnRemoveItem(LPCSTR name, EItemType type, bool &res); + virtual void __stdcall OnRenameItem(LPCSTR old_full_name, LPCSTR new_full_name, EItemType type); + void __stdcall FillChooseMtlType(ChooseItemVec &items, void *param); - virtual void FillItemList (); + virtual void FillItemList(); public: - CSHGameMtlTools (ISHInit& init); - virtual ~CSHGameMtlTools (); + CSHGameMtlTools(ISHInit &init); + virtual ~CSHGameMtlTools(); - virtual LPCSTR ToolsName (){return "Game Materials";} + virtual LPCSTR ToolsName() + { + return "Game Materials"; + } - virtual void Reload (); - virtual void Load (); - virtual bool Save (); - virtual void ApplyChanges (bool bForced=false); + virtual void Reload(); + virtual void Load(); + virtual bool Save(); + virtual void ApplyChanges(bool bForced = false); - virtual bool OnCreate (); - virtual void OnDestroy (); - virtual void OnActivate (); - virtual void OnDeactivate (); + virtual bool OnCreate(); + virtual void OnDestroy(); + virtual void OnActivate(); + virtual void OnDeactivate(); // misc - virtual void ResetCurrentItem (); - virtual void SetCurrentItem (LPCSTR name, bool bView); + virtual void ResetCurrentItem(); + virtual void SetCurrentItem(LPCSTR name, bool bView); + + virtual void RealUpdateProperties(); + virtual void RealUpdateList(); + + virtual void OnFrame(); - virtual void RealUpdateProperties(); - virtual void RealUpdateList (); + virtual void OnRender() + { + ; + } - virtual void OnFrame (); - virtual void OnRender (){;} + virtual void OnDeviceCreate() + { + ; + } - virtual void OnDeviceCreate (){;} - virtual void OnDeviceDestroy (){;} + virtual void OnDeviceDestroy() + { + ; + } }; + //--------------------------------------------------------------------------- #endif // SHGameMtlToolsH + + diff --git a/src/editors/ShaderEditor/SHSoundEnvTools.cpp b/src/editors/ShaderEditor/SHSoundEnvTools.cpp index 2b2ea677326..af2ec1dac08 100644 --- a/src/editors/ShaderEditor/SHSoundEnvTools.cpp +++ b/src/editors/ShaderEditor/SHSoundEnvTools.cpp @@ -6,120 +6,128 @@ /* #include "SHSoundEnvTools.h" #include "ui_shadermain.h" -#include "../xrEProps/folderlib.h" -#include "../xrEProps/ChoseForm.h" -#include "leftbar.h" -#include "../xrEProps/ItemList.h" +#include "editors/xrEProps/FolderLib.h" +#include "editors/xrEProps/ChoseForm.h" +#include "LeftBar.h" +#include "editors/xrEProps/ItemList.h" #include "eax.h" -#include "../../xrSound/SoundRender_Source.h" -#include "../ECORE/Editor/D3DUtils.h" +#include "xrSound/SoundRender_Source.h" +#include "editors/ECore/Editor/D3DUtils.h" //------------------------------------------------------------------------------ -xr_token eax_environment[] = { - {"Alley", EAX_ENVIRONMENT_ALLEY }, - {"Arena", EAX_ENVIRONMENT_ARENA }, - {"Auditorium", EAX_ENVIRONMENT_AUDITORIUM }, - {"Bathroom", EAX_ENVIRONMENT_BATHROOM }, - {"Carpeted Hallway", EAX_ENVIRONMENT_CARPETEDHALLWAY }, - {"Cave", EAX_ENVIRONMENT_CAVE }, - {"City", EAX_ENVIRONMENT_CITY }, - {"Concert Hall", EAX_ENVIRONMENT_CONCERTHALL }, - {"Dizzy", EAX_ENVIRONMENT_DIZZY }, - {"Drugged", EAX_ENVIRONMENT_DRUGGED }, - {"Forest", EAX_ENVIRONMENT_FOREST }, - {"Generic", EAX_ENVIRONMENT_GENERIC }, - {"Hallway", EAX_ENVIRONMENT_HALLWAY }, - {"Hangar", EAX_ENVIRONMENT_HANGAR }, - {"Livingroom", EAX_ENVIRONMENT_LIVINGROOM }, - {"Mountains", EAX_ENVIRONMENT_MOUNTAINS }, - {"Padded Cell", EAX_ENVIRONMENT_PADDEDCELL }, - {"Parkinglot", EAX_ENVIRONMENT_PARKINGLOT }, - {"Plain", EAX_ENVIRONMENT_PLAIN }, - {"Psychotic", EAX_ENVIRONMENT_PSYCHOTIC }, - {"Quarry", EAX_ENVIRONMENT_QUARRY }, - {"Room", EAX_ENVIRONMENT_ROOM }, - {"Sewer Pipe", EAX_ENVIRONMENT_SEWERPIPE }, - {"Stone Corridor", EAX_ENVIRONMENT_STONECORRIDOR }, - {"Stone Room", EAX_ENVIRONMENT_STONEROOM }, - {"Under Water", EAX_ENVIRONMENT_UNDERWATER }, - {0, 0 } +xr_token eax_environment[] = { + {"Alley", EAX_ENVIRONMENT_ALLEY}, + {"Arena", EAX_ENVIRONMENT_ARENA}, + {"Auditorium", EAX_ENVIRONMENT_AUDITORIUM}, + {"Bathroom", EAX_ENVIRONMENT_BATHROOM}, + {"Carpeted Hallway", EAX_ENVIRONMENT_CARPETEDHALLWAY}, + {"Cave", EAX_ENVIRONMENT_CAVE}, + {"City", EAX_ENVIRONMENT_CITY}, + {"Concert Hall", EAX_ENVIRONMENT_CONCERTHALL}, + {"Dizzy", EAX_ENVIRONMENT_DIZZY}, + {"Drugged", EAX_ENVIRONMENT_DRUGGED}, + {"Forest", EAX_ENVIRONMENT_FOREST}, + {"Generic", EAX_ENVIRONMENT_GENERIC}, + {"Hallway", EAX_ENVIRONMENT_HALLWAY}, + {"Hangar", EAX_ENVIRONMENT_HANGAR}, + {"Livingroom", EAX_ENVIRONMENT_LIVINGROOM}, + {"Mountains", EAX_ENVIRONMENT_MOUNTAINS}, + {"Padded Cell", EAX_ENVIRONMENT_PADDEDCELL}, + {"Parkinglot", EAX_ENVIRONMENT_PARKINGLOT}, + {"Plain", EAX_ENVIRONMENT_PLAIN}, + {"Psychotic", EAX_ENVIRONMENT_PSYCHOTIC}, + {"Quarry", EAX_ENVIRONMENT_QUARRY}, + {"Room", EAX_ENVIRONMENT_ROOM}, + {"Sewer Pipe", EAX_ENVIRONMENT_SEWERPIPE}, + {"Stone Corridor", EAX_ENVIRONMENT_STONECORRIDOR}, + {"Stone Room", EAX_ENVIRONMENT_STONEROOM}, + {"Under Water", EAX_ENVIRONMENT_UNDERWATER}, + {0, 0} }; + //------------------------------------------------------------------------------ -CSHSoundEnvTools::CSHSoundEnvTools(ISHInit& init):ISHTools(init) +CSHSoundEnvTools::CSHSoundEnvTools(ISHInit &init): ISHTools(init) { - m_Env = 0; - m_SoundName = "alexmx\\beep"; - OnChangeWAV (0); + m_Env = 0; + m_SoundName = "alexmx\\beep"; + OnChangeWAV(0); } -CSHSoundEnvTools::~CSHSoundEnvTools() -{ -} +CSHSoundEnvTools::~CSHSoundEnvTools() {} + //--------------------------------------------------------------------------- -void CSHSoundEnvTools::OnChangeWAV (PropValue* prop) +void CSHSoundEnvTools::OnChangeWAV(PropValue *prop) { - - BOOL bPlay = !!m_PreviewSnd._feedback(); - m_PreviewSnd.destroy(); - if (m_SoundName.size()){ - m_PreviewSnd.create (*m_SoundName,st_Effect,sg_Undefined); - CSoundRender_Source* src= (CSoundRender_Source*)m_PreviewSnd._handle(); - m_Params.min_distance = src->m_fMinDist; - m_Params.max_distance = src->m_fMaxDist; + BOOL bPlay = !!m_PreviewSnd._feedback(); + m_PreviewSnd.destroy(); + if (m_SoundName.size()) + { + m_PreviewSnd.create(*m_SoundName, st_Effect, sg_Undefined); + CSoundRender_Source *src = (CSoundRender_Source*)m_PreviewSnd._handle(); + m_Params.min_distance = src->m_fMinDist; + m_Params.max_distance = src->m_fMaxDist; } - if (bPlay) m_PreviewSnd.play (0,sm_Looped); - + if (bPlay) + m_PreviewSnd.play(0, sm_Looped); } -void CSHSoundEnvTools::OnControlClick(ButtonValue* V, bool& bModif, bool& bSafe) +void CSHSoundEnvTools::OnControlClick(ButtonValue *V, bool &bModif, bool &bSafe) { - - switch (V->btn_num){ - case 0: m_PreviewSnd.play (0,sm_Looped); break; - case 1: m_PreviewSnd.stop (); break; - } + switch (V->btn_num) + { + case 0: m_PreviewSnd.play(0, sm_Looped); + break; + case 1: m_PreviewSnd.stop(); + break; + } bModif = false; } void CSHSoundEnvTools::OnActivate() { - if (!psSoundFlags.is(ss_Hardware|ss_EAX)){ - Log("#!HARDWARE or FX flags are not set. Preview is disabled."); - }else{ - m_PreviewSnd.play (0,sm_Looped); + if (!psSoundFlags.is(ss_Hardware|ss_EAX)) + { + Log("#!HARDWARE or FX flags are not set. Preview is disabled."); + } + else + { + m_PreviewSnd.play(0, sm_Looped); PropItemVec items; - PropValue* V; - V = PHelper().CreateChoose (items,"Source\\WAVE name", &m_SoundName, smSoundSource); - V->OnChangeEvent.bind (this,&CSHSoundEnvTools::OnChangeWAV); - ButtonValue* B = PHelper().CreateButton (items,"Source\\Controls", "Play,Stop",0); - B->OnBtnClickEvent.bind (this,&CSHSoundEnvTools::OnControlClick); - + PropValue *V; + V = PHelper().CreateChoose(items, "Source\\WAVE name", &m_SoundName, smSoundSource); + V->OnChangeEvent.bind(this, &CSHSoundEnvTools::OnChangeWAV); + ButtonValue *B = PHelper().CreateButton(items, "Source\\Controls", "Play,Stop", 0); + B->OnBtnClickEvent.bind(this, &CSHSoundEnvTools::OnControlClick); + Ext.m_PreviewProps->AssignItems(items); Ext.m_PreviewProps->ShowProperties(); } // fill items - FillItemList (); - Ext.m_Items->SetOnModifiedEvent (fastdelegate::bind(this,&CSHSoundEnvTools::Modified)); - Ext.m_Items->SetOnItemRenameEvent (fastdelegate::bind(this,&CSHSoundEnvTools::OnRenameItem)); - Ext.m_Items->SetOnItemRemoveEvent (fastdelegate::bind(this,&CSHSoundEnvTools::OnRemoveItem)); - inherited::OnActivate (); + FillItemList(); + Ext.m_Items->SetOnModifiedEvent(fastdelegate::bind(this, &CSHSoundEnvTools::Modified)); + Ext.m_Items->SetOnItemRenameEvent(fastdelegate::bind(this, &CSHSoundEnvTools::OnRenameItem)); + Ext.m_Items->SetOnItemRemoveEvent(fastdelegate::bind(this, &CSHSoundEnvTools::OnRemoveItem)); + inherited::OnActivate(); } + //--------------------------------------------------------------------------- void CSHSoundEnvTools::OnDeactivate() { - m_PreviewSnd.stop (); - inherited::OnDeactivate (); + m_PreviewSnd.stop(); + inherited::OnDeactivate(); } + //--------------------------------------------------------------------------- void CSHSoundEnvTools::OnFrame() { - inherited::OnFrame(); + inherited::OnFrame(); } + //--------------------------------------------------------------------------- #define SOUND_SEL0_COLOR 0x00A0A0F0 @@ -127,132 +135,145 @@ void CSHSoundEnvTools::OnFrame() void CSHSoundEnvTools::OnRender() { - if (m_PreviewSnd._handle()){ - RCache.set_xform_world (Fidentity); - EDevice.SetShader (EDevice.m_WireShader); - u32 clr0 = SOUND_SEL0_COLOR; - u32 clr1 = SOUND_SEL1_COLOR; - DU_impl.DrawLineSphere (Fvector().set(0,0,0), m_Params.max_distance, clr1, true); - DU_impl.DrawLineSphere (Fvector().set(0,0,0), m_Params.min_distance, clr0, false); + if (m_PreviewSnd._handle()) + { + RCache.set_xform_world(Fidentity); + EDevice.SetShader(EDevice.m_WireShader); + u32 clr0 = SOUND_SEL0_COLOR; + u32 clr1 = SOUND_SEL1_COLOR; + DU_impl.DrawLineSphere(Fvector().set(0, 0, 0), m_Params.max_distance, clr1, true); + DU_impl.DrawLineSphere(Fvector().set(0, 0, 0), m_Params.min_distance, clr0, false); } } + //--------------------------------------------------------------------------- bool CSHSoundEnvTools::OnCreate() { - Load (); + Load(); return true; } void CSHSoundEnvTools::OnDestroy() { - m_Library.Unload (); - m_bModified = FALSE; + m_Library.Unload(); + m_bModified = FALSE; } + //--------------------------------------------------------------------------- void CSHSoundEnvTools::ApplyChanges(bool bForced) { - UseEnvironment (); + UseEnvironment(); } void CSHSoundEnvTools::Reload() { - ResetCurrentItem (); - Load (); - FillItemList (); + ResetCurrentItem(); + Load(); + FillItemList(); } void CSHSoundEnvTools::FillItemList() { - // store folders - RStrVec folders; - Ext.m_Items->GetFolders(folders); + // store folders + RStrVec folders; + Ext.m_Items->GetFolders(folders); // fill items - ListItemsVec items; - SoundEnvironment_LIB::SE_VEC& lst = m_Library.Library(); - for (SoundEnvironment_LIB::SE_IT it=lst.begin(); it!=lst.end(); it++) - LHelper().CreateItem(items,*(*it)->name,0); + ListItemsVec items; + SoundEnvironment_LIB::SE_VEC &lst = m_Library.Library(); + for (SoundEnvironment_LIB::SE_IT it = lst.begin(); it!=lst.end(); it++) + LHelper().CreateItem(items, *(*it)->name, 0); // fill folders - for (RStringVecIt s_it=folders.begin(); s_it!=folders.end(); s_it++) - LHelper().CreateItem(items,**s_it,0); + for (RStringVecIt s_it = folders.begin(); s_it!=folders.end(); s_it++) + LHelper().CreateItem(items, **s_it, 0); // assign items - Ext.m_Items->AssignItems(items,false,true); + Ext.m_Items->AssignItems(items, false, true); } void CSHSoundEnvTools::Load() { - string_path fn; - FS.update_path (fn,_game_data_,SNDENV_FILENAME); + string_path fn; + FS.update_path(fn, _game_data_, SNDENV_FILENAME); - m_bLockUpdate = TRUE; + m_bLockUpdate = TRUE; if (FS.exist(fn)) { - m_Library.Unload(); - m_Library.Load (fn); - }else{ - ELog.DlgMsg(mtInformation,"Can't find file '%s'",fn); + m_Library.Unload(); + m_Library.Load(fn); + } + else + { + ELog.DlgMsg(mtInformation, "Can't find file '%s'", fn); } - m_bLockUpdate = FALSE; + m_bLockUpdate = FALSE; } bool CSHSoundEnvTools::Save() { ApplyChanges(); - m_bLockUpdate = TRUE; + m_bLockUpdate = TRUE; // save - string_path fn; - FS.update_path (fn,_game_data_,SNDENV_FILENAME); + string_path fn; + FS.update_path(fn, _game_data_, SNDENV_FILENAME); // save new file - EFS.MarkFile (fn,false); - bool bRes = m_Library.Save(fn); - m_bLockUpdate = FALSE; + EFS.MarkFile(fn, false); + bool bRes = m_Library.Save(fn); + m_bLockUpdate = FALSE; - if (bRes) m_bModified = FALSE; + if (bRes) + m_bModified = FALSE; return bRes; } -CSoundRender_Environment* CSHSoundEnvTools::FindItem(LPCSTR name) +CSoundRender_Environment *CSHSoundEnvTools::FindItem(LPCSTR name) { - if (name && name[0]){ - return m_Library.Get(name); - }else return 0; + if (name&&name[0]) + { + return m_Library.Get(name); + } + else + return 0; } LPCSTR CSHSoundEnvTools::AppendItem(LPCSTR folder_name, LPCSTR parent_name) { - CSoundRender_Environment* parent= FindItem(parent_name); - AnsiString pref = parent_name?AnsiString(parent_name):AnsiString(folder_name)+"env"; - m_LastSelection = FHelper.GenerateName(pref.c_str(),2,fastdelegate::bind(this,&CSHSoundEnvTools::ItemExist),false,true); - CSoundRender_Environment* S = m_Library.Append(parent); - if (!parent) S->set_default(); - S->name = m_LastSelection.c_str(); - ExecCommand (COMMAND_UPDATE_LIST); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - Modified (); + CSoundRender_Environment *parent = FindItem(parent_name); + AnsiString pref = parent_name ? AnsiString(parent_name) : AnsiString(folder_name)+"env"; + m_LastSelection = FHelper.GenerateName(pref.c_str(), 2, fastdelegate::bind(this, &CSHSoundEnvTools::ItemExist), false, true); + CSoundRender_Environment *S = m_Library.Append(parent); + if (!parent) + S->set_default(); + S->name = m_LastSelection.c_str(); + ExecCommand(COMMAND_UPDATE_LIST); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + Modified(); return *S->name; } void CSHSoundEnvTools::OnRenameItem(LPCSTR old_full_name, LPCSTR new_full_name, EItemType type) { - if (type==TYPE_OBJECT){ - ApplyChanges (); - CSoundRender_Environment* S = m_Library.Get(old_full_name); R_ASSERT(S); - S->name = new_full_name; - ExecCommand (COMMAND_UPDATE_PROPERTIES); - ExecCommand (COMMAND_UPDATE_LIST); + if (type==TYPE_OBJECT) + { + ApplyChanges(); + CSoundRender_Environment *S = m_Library.Get(old_full_name); + R_ASSERT(S); + S->name = new_full_name; + ExecCommand(COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_LIST); } } -void CSHSoundEnvTools::OnRemoveItem(LPCSTR name, EItemType type, bool& res) +void CSHSoundEnvTools::OnRemoveItem(LPCSTR name, EItemType type, bool &res) { - if (type==TYPE_OBJECT){ - R_ASSERT (name && name[0]); + if (type==TYPE_OBJECT) + { + R_ASSERT(name&&name[0]); m_Library.Remove(name); } res = true; @@ -260,91 +281,101 @@ void CSHSoundEnvTools::OnRemoveItem(LPCSTR name, EItemType type, bool& res) void CSHSoundEnvTools::SetCurrentItem(LPCSTR name, bool bView) { - if (m_bLockUpdate) return; - CSoundRender_Environment* S = FindItem(name); - if (m_Env!=S){ - m_Env = S; - if (m_Env) m_EnvSrc = *m_Env; - ExecCommand(COMMAND_UPDATE_PROPERTIES); - if (bView) ViewSetCurrentItem(name); + if (m_bLockUpdate) + return; + CSoundRender_Environment *S = FindItem(name); + if (m_Env!=S) + { + m_Env = S; + if (m_Env) + m_EnvSrc = *m_Env; + ExecCommand(COMMAND_UPDATE_PROPERTIES); + if (bView) + ViewSetCurrentItem(name); } - UseEnvironment (); + UseEnvironment(); } void CSHSoundEnvTools::ResetCurrentItem() { - m_Env=0; - UseEnvironment (); + m_Env = 0; + UseEnvironment(); } -void __fastcall CSHSoundEnvTools::OnRevResetClick(ButtonValue* V, bool& bModif, bool& bSafe) +void __fastcall CSHSoundEnvTools::OnRevResetClick(ButtonValue *V, bool &bModif, bool &bSafe) { - switch (V->btn_num){ - case 0: m_Env->set_identity(); break; - case 1: OnEnvChange(V); break; - } + switch (V->btn_num) + { + case 0: m_Env->set_identity(); + break; + case 1: OnEnvChange(V); + break; + } Ext.m_ItemProps->RefreshForm(); Modified(); } -void __fastcall CSHSoundEnvTools::OnEnvSizeChange(PropValue* sender) +void __fastcall CSHSoundEnvTools::OnEnvSizeChange(PropValue *sender) { - CSoundRender_Environment test_env=*m_Env; - test_env.EnvironmentSize = m_EnvSrc.EnvironmentSize; - test_env.DecayTime = m_EnvSrc.DecayTime; - test_env.Reflections = m_EnvSrc.Reflections; - test_env.ReflectionsDelay = m_EnvSrc.ReflectionsDelay; - test_env.Reverb = m_EnvSrc.Reverb; - test_env.ReverbDelay = m_EnvSrc.ReverbDelay; - CSound_environment* E = m_Env; - Sound->set_environment_size (&test_env,&E); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + CSoundRender_Environment test_env = *m_Env; + test_env.EnvironmentSize = m_EnvSrc.EnvironmentSize; + test_env.DecayTime = m_EnvSrc.DecayTime; + test_env.Reflections = m_EnvSrc.Reflections; + test_env.ReflectionsDelay = m_EnvSrc.ReflectionsDelay; + test_env.Reverb = m_EnvSrc.Reverb; + test_env.ReverbDelay = m_EnvSrc.ReverbDelay; + CSound_environment *E = m_Env; + Sound->set_environment_size(&test_env, &E); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void __fastcall CSHSoundEnvTools::OnEnvChange(PropValue* sender) +void __fastcall CSHSoundEnvTools::OnEnvChange(PropValue *sender) { - CSound_environment* E = m_Env; - Sound->set_environment (m_Env->Environment,&E); - m_EnvSrc = *m_Env; - ExecCommand (COMMAND_UPDATE_PROPERTIES); + CSound_environment *E = m_Env; + Sound->set_environment(m_Env->Environment, &E); + m_EnvSrc = *m_Env; + ExecCommand(COMMAND_UPDATE_PROPERTIES); } void CSHSoundEnvTools::RealUpdateList() { - FillItemList (); + FillItemList(); } + //------------------------------------------------------------------------------ void CSHSoundEnvTools::RealUpdateProperties() { - PropItemVec items; - if (m_Env){ + PropItemVec items; + if (m_Env) + { // fill environment - CSoundRender_Environment& S = *m_Env; - ButtonValue* B = 0; - PHelper().CreateName (items, "Name", &S.name, m_CurrentItem); - B=PHelper().CreateButton(items, "Environment\\Set", "Identity,Reset", ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CSHSoundEnvTools::OnRevResetClick); - PropValue* V=0; - V=PHelper().CreateToken32(items,"Environment\\Preset", &S.Environment ,eax_environment); - V->OnChangeEvent.bind (this,&CSHSoundEnvTools::OnEnvChange); - V=PHelper().CreateFloat (items, "Environment\\Size", &S.EnvironmentSize ,EAXLISTENER_MINENVIRONMENTSIZE, EAXLISTENER_MAXENVIRONMENTSIZE ,0.01f, 3); - V->OnChangeEvent.bind (this,&CSHSoundEnvTools::OnEnvSizeChange); - PHelper().CreateFloat (items, "Environment\\Diffusion", &S.EnvironmentDiffusion,EAXLISTENER_MINENVIRONMENTDIFFUSION,EAXLISTENER_MAXENVIRONMENTDIFFUSION ,0.01f, 3); - PHelper().CreateFloat (items, "Room\\Room", &S.Room ,(float)EAXLISTENER_MINROOM, (float)EAXLISTENER_MAXROOM ,1.f, 0); - PHelper().CreateFloat (items, "Room\\RoomHF", &S.RoomHF ,(float)EAXLISTENER_MINROOMHF, (float)EAXLISTENER_MAXROOMHF ,1.f, 0); - PHelper().CreateFloat (items, "Distance Effects\\RoomRolloffFactor", &S.RoomRolloffFactor ,EAXLISTENER_MINROOMROLLOFFFACTOR, EAXLISTENER_MAXROOMROLLOFFFACTOR ,0.01f, 3); - PHelper().CreateFloat (items, "Distance Effects\\AirAbsorptionHF", &S.AirAbsorptionHF ,EAXLISTENER_MINAIRABSORPTIONHF, EAXLISTENER_MAXAIRABSORPTIONHF ,0.01f, 3); - PHelper().CreateFloat (items, "Reflections\\Reflections", &S.Reflections ,(float)EAXLISTENER_MINREFLECTIONS, (float)EAXLISTENER_MAXREFLECTIONS ,1.f, 0); - PHelper().CreateFloat (items, "Reflections\\ReflectionsDelay", &S.ReflectionsDelay ,EAXLISTENER_MINREFLECTIONSDELAY, EAXLISTENER_MAXREFLECTIONSDELAY ,0.01f, 3); - PHelper().CreateFloat (items, "Reverb\\Reverb", &S.Reverb ,(float)EAXLISTENER_MINREVERB, (float)EAXLISTENER_MAXREVERB ,1.f, 0); - PHelper().CreateFloat (items, "Reverb\\ReverbDelay", &S.ReverbDelay ,EAXLISTENER_MINREVERBDELAY, EAXLISTENER_MAXREVERBDELAY ,0.01f, 3); - PHelper().CreateFloat (items, "Decay\\DecayTime", &S.DecayTime ,EAXLISTENER_MINDECAYTIME, EAXLISTENER_MAXDECAYTIME ,0.01f, 3); - PHelper().CreateFloat (items, "Decay\\DecayHFRatio", &S.DecayHFRatio ,EAXLISTENER_MINDECAYHFRATIO, EAXLISTENER_MAXDECAYHFRATIO ,0.01f, 3); + CSoundRender_Environment &S = *m_Env; + ButtonValue *B = 0; + PHelper().CreateName(items, "Name", &S.name, m_CurrentItem); + B = PHelper().CreateButton(items, "Environment\\Set", "Identity,Reset", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CSHSoundEnvTools::OnRevResetClick); + PropValue *V = 0; + V = PHelper().CreateToken32(items, "Environment\\Preset", &S.Environment, eax_environment); + V->OnChangeEvent.bind(this, &CSHSoundEnvTools::OnEnvChange); + V = PHelper().CreateFloat(items, "Environment\\Size", &S.EnvironmentSize, EAXLISTENER_MINENVIRONMENTSIZE, EAXLISTENER_MAXENVIRONMENTSIZE, 0.01f, 3); + V->OnChangeEvent.bind(this, &CSHSoundEnvTools::OnEnvSizeChange); + PHelper().CreateFloat(items, "Environment\\Diffusion", &S.EnvironmentDiffusion, EAXLISTENER_MINENVIRONMENTDIFFUSION, EAXLISTENER_MAXENVIRONMENTDIFFUSION, 0.01f, 3); + PHelper().CreateFloat(items, "Room\\Room", &S.Room, (float)EAXLISTENER_MINROOM, (float)EAXLISTENER_MAXROOM, 1.f, 0); + PHelper().CreateFloat(items, "Room\\RoomHF", &S.RoomHF, (float)EAXLISTENER_MINROOMHF, (float)EAXLISTENER_MAXROOMHF, 1.f, 0); + PHelper().CreateFloat(items, "Distance Effects\\RoomRolloffFactor", &S.RoomRolloffFactor, EAXLISTENER_MINROOMROLLOFFFACTOR, EAXLISTENER_MAXROOMROLLOFFFACTOR, 0.01f, 3); + PHelper().CreateFloat(items, "Distance Effects\\AirAbsorptionHF", &S.AirAbsorptionHF, EAXLISTENER_MINAIRABSORPTIONHF, EAXLISTENER_MAXAIRABSORPTIONHF, 0.01f, 3); + PHelper().CreateFloat(items, "Reflections\\Reflections", &S.Reflections, (float)EAXLISTENER_MINREFLECTIONS, (float)EAXLISTENER_MAXREFLECTIONS, 1.f, 0); + PHelper().CreateFloat(items, "Reflections\\ReflectionsDelay", &S.ReflectionsDelay, EAXLISTENER_MINREFLECTIONSDELAY, EAXLISTENER_MAXREFLECTIONSDELAY, 0.01f, 3); + PHelper().CreateFloat(items, "Reverb\\Reverb", &S.Reverb, (float)EAXLISTENER_MINREVERB, (float)EAXLISTENER_MAXREVERB, 1.f, 0); + PHelper().CreateFloat(items, "Reverb\\ReverbDelay", &S.ReverbDelay, EAXLISTENER_MINREVERBDELAY, EAXLISTENER_MAXREVERBDELAY, 0.01f, 3); + PHelper().CreateFloat(items, "Decay\\DecayTime", &S.DecayTime, EAXLISTENER_MINDECAYTIME, EAXLISTENER_MAXDECAYTIME, 0.01f, 3); + PHelper().CreateFloat(items, "Decay\\DecayHFRatio", &S.DecayHFRatio, EAXLISTENER_MINDECAYHFRATIO, EAXLISTENER_MAXDECAYHFRATIO, 0.01f, 3); } - Ext.m_ItemProps->AssignItems (items); - Ext.m_ItemProps->SetModifiedEvent (fastdelegate::bind(this,&CSHSoundEnvTools::Modified)); + Ext.m_ItemProps->AssignItems(items); + Ext.m_ItemProps->SetModifiedEvent(fastdelegate::bind(this, &CSHSoundEnvTools::Modified)); } + //--------------------------------------------------------------------------- */ diff --git a/src/editors/ShaderEditor/SHSoundEnvTools.h b/src/editors/ShaderEditor/SHSoundEnvTools.h index 4342a7b6d0a..94ae5be23d3 100644 --- a/src/editors/ShaderEditor/SHSoundEnvTools.h +++ b/src/editors/ShaderEditor/SHSoundEnvTools.h @@ -3,67 +3,87 @@ #define SHSoundEnvToolsH /* #include "SHToolsInterface.h" -#include "../../xrSound/soundrender_environment.h" +#include "xrSound/soundrender_environment.h" // refs class PropValue; class CSHSoundEnvTools: public ISHTools { - void __stdcall ItemExist (LPCSTR name, bool& res){res = !!FindItem(name);} - CSoundRender_Environment* FindItem (LPCSTR name); - void SetCurrentEnv (CSoundRender_Environment* B); + void __stdcall ItemExist(LPCSTR name, bool &res) + { + res = !!FindItem(name); + } - SoundEnvironment_LIB m_Library; + CSoundRender_Environment *FindItem(LPCSTR name); + void SetCurrentEnv(CSoundRender_Environment *B); - shared_str m_SoundName; - CSound_params m_Params; - ref_sound m_PreviewSnd; - void __stdcall OnControlClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnChangeWAV (PropValue* prop); + SoundEnvironment_LIB m_Library; + shared_str m_SoundName; + CSound_params m_Params; + ref_sound m_PreviewSnd; + void __stdcall OnControlClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnChangeWAV(PropValue *prop); - void __stdcall OnRevResetClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnEnvSizeChange (PropValue* sender); - void __stdcall OnEnvChange (PropValue* sender); + + void __stdcall OnRevResetClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnEnvSizeChange(PropValue *sender); + void __stdcall OnEnvChange(PropValue *sender); public: - CSoundRender_Environment m_EnvSrc; - CSoundRender_Environment* m_Env; - virtual LPCSTR AppendItem (LPCSTR folder_name, LPCSTR parent=0); - virtual void __stdcall OnRemoveItem (LPCSTR name, EItemType type, bool& res); - virtual void __stdcall OnRenameItem (LPCSTR old_full_name, LPCSTR new_full_name, EItemType type); - virtual void FillItemList (); - - void UseEnvironment (){Sound->set_user_env(m_Env);} + CSoundRender_Environment m_EnvSrc; + CSoundRender_Environment *m_Env; + virtual LPCSTR AppendItem(LPCSTR folder_name, LPCSTR parent = 0); + virtual void __stdcall OnRemoveItem(LPCSTR name, EItemType type, bool &res); + virtual void __stdcall OnRenameItem(LPCSTR old_full_name, LPCSTR new_full_name, EItemType type); + virtual void FillItemList(); + + void UseEnvironment() + { + Sound->set_user_env(m_Env); + } + public: - CSHSoundEnvTools (ISHInit& init); - virtual ~CSHSoundEnvTools (); + CSHSoundEnvTools(ISHInit &init); + virtual ~CSHSoundEnvTools(); - virtual LPCSTR ToolsName (){return "Sound Environment";} + virtual LPCSTR ToolsName() + { + return "Sound Environment"; + } - virtual void Reload (); - virtual void Load (); - virtual bool Save (); + virtual void Reload(); + virtual void Load(); + virtual bool Save(); - virtual bool OnCreate (); - virtual void OnDestroy (); - virtual void OnActivate (); - virtual void OnDeactivate (); + virtual bool OnCreate(); + virtual void OnDestroy(); + virtual void OnActivate(); + virtual void OnDeactivate(); // misc - virtual void ResetCurrentItem (); - virtual void SetCurrentItem (LPCSTR name, bool bView); - virtual void ApplyChanges (bool bForced=false); + virtual void ResetCurrentItem(); + virtual void SetCurrentItem(LPCSTR name, bool bView); + virtual void ApplyChanges(bool bForced = false); - virtual void RealUpdateProperties(); - virtual void RealUpdateList (); + virtual void RealUpdateProperties(); + virtual void RealUpdateList(); - virtual void OnFrame (); - virtual void OnRender (); + virtual void OnFrame(); + virtual void OnRender(); - virtual void OnDeviceCreate (){;} - virtual void OnDeviceDestroy (){;} + virtual void OnDeviceCreate() + { + ; + } + + virtual void OnDeviceDestroy() + { + ; + } }; + //--------------------------------------------------------------------------- */ #endif + diff --git a/src/editors/ShaderEditor/SHToolsInterface.cpp b/src/editors/ShaderEditor/SHToolsInterface.cpp index 32ed0d0068b..00c3660292b 100644 --- a/src/editors/ShaderEditor/SHToolsInterface.cpp +++ b/src/editors/ShaderEditor/SHToolsInterface.cpp @@ -3,103 +3,122 @@ #pragma hdrstop #include "SHToolsInterface.h" -#include "../xrEProps/FolderLib.h" -#include "../ECore/Editor/ui_main.h" -#include "../xrEProps/itemlist.h" +#include "editors/xrEProps/FolderLib.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/xrEProps/itemlist.h" -ISHTools::ISHTools(ISHInit& init) +ISHTools::ISHTools(ISHInit &init) { - m_bModified = FALSE; - m_bLockUpdate = FALSE; - Ext = init; + m_bModified = FALSE; + m_bLockUpdate = FALSE; + Ext = init; } + //--------------------------------------------------------------------------- void ISHTools::ViewSetCurrentItem(LPCSTR full_name) { - if (m_bLockUpdate) return; + if (m_bLockUpdate) + return; - m_bLockUpdate = TRUE; - Ext.m_Items->SelectItem(full_name,TRUE,false,true); - m_bLockUpdate = FALSE; + m_bLockUpdate = TRUE; + Ext.m_Items->SelectItem(full_name, TRUE, false, true); + m_bLockUpdate = FALSE; } + //--------------------------------------------------------------------------- void ISHTools::Modified() { - m_bModified=TRUE; + m_bModified = TRUE; ExecCommand(COMMAND_UPDATE_CAPTION); ApplyChanges(); } + //--------------------------------------------------------------------------- bool ISHTools::IfModified() { - if (m_bModified){ - int mr = ELog.DlgMsg(mtConfirmation, "The '%s' has been modified.\nDo you want to save your changes?",ToolsName()); - switch(mr){ - case mrYes: Save(); m_bModified = FALSE; break; - case mrNo: m_bModified = FALSE; break; - case mrCancel: return false; + if (m_bModified) + { + int mr = ELog.DlgMsg(mtConfirmation, "The '%s' has been modified.\nDo you want to save your changes?", ToolsName()); + switch (mr) + { + case mrYes: Save(); + m_bModified = FALSE; + break; + case mrNo: m_bModified = FALSE; + break; + case mrCancel: return false; } } return true; } + //--------------------------------------------------------------------------- void ISHTools::ZoomObject(bool bOnlySel) { Fbox BB; - BB.set(-5,-5,-5,5,5,5); + BB.set(-5, -5, -5, 5, 5, 5); EDevice.m_Camera.ZoomExtents(BB); } + //--------------------------------------------------------------------------- AnsiString ISHTools::ViewGetCurrentItem(bool bFolderOnly) { AnsiString name; - TElTreeItem* item = Ext.m_Items->GetSelected(); - FHelper.MakeName (item,0,name,bFolderOnly); + TElTreeItem *item = Ext.m_Items->GetSelected(); + FHelper.MakeName(item, 0, name, bFolderOnly); return name; } + //--------------------------------------------------------------------------- -TElTreeItem* ISHTools::ViewGetCurrentItem() +TElTreeItem *ISHTools::ViewGetCurrentItem() { - return Ext.m_Items->GetSelected(); + return Ext.m_Items->GetSelected(); } + //--------------------------------------------------------------------------- void ISHTools::RemoveCurrent() { - Ext.m_Items->RemoveSelItems(); + Ext.m_Items->RemoveSelItems(); } + //--------------------------------------------------------------------------- void ISHTools::RenameCurrent() { - Ext.m_Items->RenameSelItem(); + Ext.m_Items->RenameSelItem(); } + //--------------------------------------------------------------------------- void ISHTools::OnFrame() { - if (m_LastSelection.Length()){ - SetCurrentItem (m_LastSelection.c_str(),true); - m_LastSelection = ""; + if (m_LastSelection.Length()) + { + SetCurrentItem(m_LastSelection.c_str(), true); + m_LastSelection = ""; } -} +} + void ISHTools::OnActivate() { - SetCurrentItem (m_LastSelection.c_str(),true); + SetCurrentItem(m_LastSelection.c_str(), true); } + void ISHTools::OnDeactivate() { - Ext.m_PreviewProps->ClearProperties(); - m_LastSelection = ViewGetCurrentItem(false); - ResetCurrentItem (); - Ext.m_Items->ClearList (); + Ext.m_PreviewProps->ClearProperties(); + m_LastSelection = ViewGetCurrentItem(false); + ResetCurrentItem(); + Ext.m_Items->ClearList(); } + //--------------------------------------------------------------------------- diff --git a/src/editors/ShaderEditor/SHToolsInterface.h b/src/editors/ShaderEditor/SHToolsInterface.h index daa99026e2b..694e9d0c10d 100644 --- a/src/editors/ShaderEditor/SHToolsInterface.h +++ b/src/editors/ShaderEditor/SHToolsInterface.h @@ -5,13 +5,14 @@ #include "ElTree.hpp" #include "MxMenus.hpp" #include "ElPgCtl.hpp" -#include "../xrEprops/PropertiesList.h" +#include "editors/xrEprops/PropertiesList.h" // refs -enum EToolsID{ - aeFirstTool = 0, - aeEngine = 0, +enum EToolsID +{ + aeFirstTool = 0, + aeEngine = 0, aeCompiler, aeMtl, aeMtlPair, @@ -21,83 +22,111 @@ enum EToolsID{ struct ISHInit { - EToolsID tools_id; - TItemList* m_Items; - TProperties* m_ItemProps; - TProperties* m_PreviewProps; - TElTabSheet* m_Sheet; - ISHInit(){ZeroMemory(this,sizeof(ISHInit));} - ISHInit(EToolsID id, TItemList* il, TElTabSheet* sh, TProperties* ip, TProperties* pp) + EToolsID tools_id; + TItemList *m_Items; + TProperties *m_ItemProps; + TProperties *m_PreviewProps; + TElTabSheet *m_Sheet; + + ISHInit() { - tools_id = id; - m_Items = il; - m_ItemProps = ip; - m_PreviewProps = pp; - m_Sheet = sh; + ZeroMemory(this, sizeof(ISHInit)); + } + + ISHInit(EToolsID id, TItemList *il, TElTabSheet *sh, TProperties *ip, TProperties *pp) + { + tools_id = id; + m_Items = il; + m_ItemProps = ip; + m_PreviewProps = pp; + m_Sheet = sh; } }; + class ISHTools { protected: - typedef ISHTools inherited; + typedef ISHTools inherited; - ISHInit Ext; + ISHInit Ext; - BOOL m_bModified; + BOOL m_bModified; - BOOL m_bLockUpdate; // åñëè ìåíÿëñÿ îáúåêò íåïîñðåäñòâåííî Update____From___() + BOOL m_bLockUpdate; // åñëè ìåíÿëñÿ îáúåêò íåïîñðåäñòâåííî Update____From___() - AnsiString m_LastSelection; + AnsiString m_LastSelection; public: - ListItem* m_CurrentItem; + ListItem *m_CurrentItem; public: - void ViewSetCurrentItem (LPCSTR full_name); - AnsiString ViewGetCurrentItem (bool bFolderOnly); - TElTreeItem* ViewGetCurrentItem (); + void ViewSetCurrentItem(LPCSTR full_name); + AnsiString ViewGetCurrentItem(bool bFolderOnly); + TElTreeItem *ViewGetCurrentItem(); public: - virtual LPCSTR AppendItem (LPCSTR folder_name, LPCSTR parent=0)=0; - virtual void FillItemList ()=0; + virtual LPCSTR AppendItem(LPCSTR folder_name, LPCSTR parent = 0) =0; + virtual void FillItemList() =0; public: - ISHTools (ISHInit& init); - virtual ~ISHTools (){;} - - EToolsID ID (){return Ext.tools_id;} - TElTabSheet* Sheet (){return Ext.m_Sheet;} - AnsiString SelectedName (); - void RemoveCurrent (); - void RenameCurrent (); - - virtual LPCSTR ToolsName ()=0; - - virtual void Reload ()=0; - virtual void Load ()=0; - virtual bool Save ()=0; - - bool IsModified (){return m_bModified;} - virtual bool IfModified (); - virtual void __stdcall Modified (); - - virtual bool OnCreate ()=0; - virtual void OnDestroy ()=0; - virtual void OnActivate ()=0; - virtual void OnDeactivate ()=0; + ISHTools(ISHInit &init); + + virtual ~ISHTools() + { + ; + } + + EToolsID ID() + { + return Ext.tools_id; + } + + TElTabSheet *Sheet() + { + return Ext.m_Sheet; + } + + AnsiString SelectedName(); + void RemoveCurrent(); + void RenameCurrent(); + + virtual LPCSTR ToolsName() =0; + + virtual void Reload() =0; + virtual void Load() =0; + virtual bool Save() =0; + + bool IsModified() + { + return m_bModified; + } + + virtual bool IfModified(); + virtual void __stdcall Modified(); + + virtual bool OnCreate() =0; + virtual void OnDestroy() =0; + virtual void OnActivate() =0; + virtual void OnDeactivate() =0; // misc - virtual void ResetCurrentItem ()=0; - virtual void SetCurrentItem (LPCSTR name, bool bView)=0; - virtual void ApplyChanges (bool bForced=false)=0; + virtual void ResetCurrentItem() =0; + virtual void SetCurrentItem(LPCSTR name, bool bView) =0; + virtual void ApplyChanges(bool bForced = false) =0; - virtual void RealUpdateProperties()=0; - virtual void RealUpdateList ()=0; + virtual void RealUpdateProperties() =0; + virtual void RealUpdateList() =0; - virtual void OnFrame ()=0; - virtual void OnRender ()=0; + virtual void OnFrame() =0; + virtual void OnRender() =0; - virtual void OnDeviceCreate ()=0; - virtual void OnDeviceDestroy ()=0; + virtual void OnDeviceCreate() =0; + virtual void OnDeviceDestroy() =0; - virtual void ZoomObject (bool bOnlySel); - virtual void OnShowHint (AStringVec& ss){;} + virtual void ZoomObject(bool bOnlySel); + + virtual void OnShowHint(AStringVec &ss) + { + ; + } }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ShaderEditor/ShaderEditor.cpp b/src/editors/ShaderEditor/ShaderEditor.cpp index ef5efd48510..1090edb058c 100644 --- a/src/editors/ShaderEditor/ShaderEditor.cpp +++ b/src/editors/ShaderEditor/ShaderEditor.cpp @@ -1,81 +1,78 @@ #include "stdafx.h" #pragma hdrstop #include "splash.h" -#include "../ECore/Editor/LogForm.h" +#include "editors/ECore/Editor/LogForm.h" #include "main.h" #include "ui_shadermain.h" -#include "UI_shadertools.h" +#include "UI_ShaderTools.h" //--------------------------------------------------------------------------- -USEFORM("BottomBar.cpp", fraBottomBar); /* TFrame: File Type */ -USEFORM("LeftBar.cpp", fraLeftBar); /* TFrame: File Type */ -USEFORM("main.cpp", frmMain); -USEFORM("Splash.cpp", frmSplash); -USEFORM("TopBar.cpp", fraTopBar); /* TFrame: File Type */ +USEFORM ("BottomBar.cpp", fraBottomBar); /* TFrame: File Type */ +USEFORM ("LeftBar.cpp", fraLeftBar); /* TFrame: File Type */ +USEFORM ("main.cpp", frmMain); +USEFORM ("Splash.cpp", frmSplash); +USEFORM ("TopBar.cpp", fraTopBar); /* TFrame: File Type */ //--------------------------------------------------------------------------- -struct SInit{ - SInit() +struct SInit +{ + SInit() { - int y = 0; -// LoadLibrary(); + int y = 0; + // LoadLibrary(); } }; + SInit init; WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int) { -// try{ - if (!Application->Handle){ - Application->CreateHandle (); - Application->Icon->Handle = LoadIcon(MainInstance, "MAINICON"); - Application->Title = "Loading..."; - } - frmSplash = xr_new((TComponent*)0); - frmSplash->Show (); - frmSplash->Repaint (); - frmSplash->SetStatus ("Core initializing..."); - - Core._initialize ("shader",ELogCallback); - - Application->Initialize (); - - frmSplash->SetStatus ("Loading..."); - -// startup create - Tools = xr_new(); - UI = xr_new(); - UI->RegisterCommands (); - - Application->Title = UI->EditorDesc(); - TfrmLog::CreateLog (); - - Application->CreateForm(__classid(TfrmMain), &frmMain); - frmMain->SetHInst (hInst); - - xr_delete(frmSplash); - - Application->Run (); - - TfrmLog::DestroyLog (); - - UI->ClearCommands (); - xr_delete (Tools); - xr_delete (UI); - - Core._destroy (); -// } -// catch (Exception &exception) -// { -// Application->ShowException(&exception); -// } - return 0; -} -//--------------------------------------------------------------------------- + // try{ + if (!Application->Handle) + { + Application->CreateHandle(); + Application->Icon->Handle = LoadIcon(MainInstance, "MAINICON"); + Application->Title = "Loading..."; + } + frmSplash = xr_new((TComponent*)0); + frmSplash->Show(); + frmSplash->Repaint(); + frmSplash->SetStatus("Core initializing..."); + + Core._initialize("shader", ELogCallback); + Application->Initialize(); + frmSplash->SetStatus("Loading..."); + // startup create + Tools = xr_new(); + UI = xr_new(); + UI->RegisterCommands(); + Application->Title = UI->EditorDesc(); + TfrmLog::CreateLog(); + Application->CreateForm(__classid(TfrmMain), &frmMain); + frmMain->SetHInst(hInst); + xr_delete(frmSplash); + Application->Run(); + + TfrmLog::DestroyLog(); + + UI->ClearCommands(); + xr_delete(Tools); + xr_delete(UI); + + Core._destroy(); + // } + // catch (Exception &exception) + // { + // Application->ShowException(&exception); + // } + return 0; +} + +//--------------------------------------------------------------------------- diff --git a/src/editors/ShaderEditor/ShaderEditor.res b/src/editors/ShaderEditor/ShaderEditor.res index b01ed76d16fb93cc7e6cd2c0ef64547798771339..059770ab0e6e5f64c366e1d9bd53b04374a8bf40 100644 GIT binary patch delta 30 kcmca3dq;MH8KdN6duH*Cejk_^B{$nMU*`Z);yg#00G)^lRR910 delta 30 kcmca3dq;MH8Kcr + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=1 +MajorVer=1 +MinorVer=0 +Release=2 +Build=132 +Debug=1 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.2.132 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=26 +Item0=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;..\..\..\sdk\components\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;..\..\..\sdk\components\Elpack\Code;..\..\..\sdk\components\Elpack\Code\Source;..\..\ +Item1=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound +Item2=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(EAX_DIR) +Item3=$(VC_INCLUDE);$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;$(EAX_DIR) +Item4=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrRender;$(EAX_DIR) +Item5=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender;$(EAX_DIR) +Item6=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender;$(EAX_DIR)\Include +Item7=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine;../../xrEngine/xrRender +Item8=$(DXSDK_DIR)\Include;$(COMPONENTS)\alexmx;$(BCB)\include;$(BCB)\include\vcl;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(CORE_DIR);../../xrEngine +Item9=R:\SDK\Microsoft DirectX 9.0 SDK (April 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps +Item10=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps +Item11=R:\SDK\Microsoft DirectX 9.0 SDK (February 2005)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include;P:\Tools\ETools +Item12=R:\SDK\Microsoft DirectX 9.0 SDK (October 2004)\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;R:\SDK\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include;P:\Tools\ETools +Item13=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include;P:\Tools\ETools +Item14=R:\SDK\DirectX9.0_sum_2004\Include;r:\borland\components6\alexmx;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include +Item15=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps;R:\SDK\DirectX9.0_beta3\Include +Item16=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include;..\xrEProps +Item17=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals;R:\SDK\eax20\Include +Item18=r:\borland\components6\alexmx;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;P:\xrCore;P:\xrCDB;P:\xrSound;..\ECore;..\ECore\Editor;..\ECore\Engine;..\ECore\Engine\blenders;..\ECore\Engine\visuals +Item19=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;R:\SDK\boost-03-12-12-0400 +Item20=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;R:\SDK\BOOST +Item21=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;P:\boost_1_30_2 +Item22=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;P:\boost_1_30_0 +Item23=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind +Item24=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind;P:\luabind\luabind +Item25=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;r:\borland\components6\alexmx;editor;R:\SDK\DirectX9.0\include;$(BCB)\include;$(BCB)\include\vcl;engine;P:\MagicFM_Borland\Sdk\Include;R:\Borland\Components6\Elpack\Code;R:\Borland\Components6\Elpack\Code\Source;P:\xrCore;P:\xrSound;P:\luabind\luabind + +[HistoryLists\hlLibraryPath] +Count=8 +Item0=..\..\..\sdk\components\ElPack\Code;$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) +Item1=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;$(OUT_LIB_DIR) +Item2=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source +Item3=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries;X:\libraries +Item4=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;X:\stalker_addon\libraries +Item5=$(BCB)\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;$(COMPONENTS)\alexmx;$(COMPONENTS)\ElPack\Code;$(COMPONENTS)\ElPack\Code\Source;x:\libraries +Item6=C:\Rad\Borland\CBuilder6\Projects;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\ElPack\Code;R:\Borland\Components6\ElPack\Code\Source;..\lib\dx;..\lib;x:\;..\ECore;..\ECore\Editor +Item7=C:\Rad\Borland\CBuilder6\Projects;Engine\Animations;Engine\BLENDERS;c:\rad\borland\CBuilder5\Projects;..\lib\DX;..\lib;engine;editor;$(BCB)\lib;$(BCB)\lib\obj;$(BCB)\Projects\Lib;r:\borland\components6\alexmx;R:\Borland\Components6\Elpack\Code\Source;R:\Borland\Components6\Elpack\Code;x:\ + +[HistoryLists\hlDebugSourcePath] +Count=3 +Item0=$(BCB)\source\vcl +Item1=c:\rad\borland\cbuilder5\source\vcl +Item2=c:\rad\borland\cbuilder5\source\vcl;P:\Editor\QHull\ + +[HistoryLists\hlConditionals] +Count=12 +Item0=_EDITOR;_SHADER_EDITOR;_DEBUG +Item1=_EDITOR;_SHADER_EDITOR +Item2=_EDITORS;_SHADER_EDITOR;_DEBUG +Item3=_EDITOR_FAMILY;_SHADER_EDITOR;_DEBUG +Item4=_SHADER_EDITOR;_DEBUG +Item5=_EDITOR;_DEBUG +Item6=_EDITOR +Item7=_EDITOR;_DEBUG;_STLP_USE_OWN_NAMESPACE +Item8=_EDITOR;_DEBUG;_BORLAND +Item9=_DEBUG;_EDITOR +Item10=_DEBUG;_ED +Item11=_DEBUG + +[HistoryLists\hlIntOutputDir] +Count=5 +Item0=..\..\..\intermediate\editors\ShaderEditor +Item1=x:\intermediate_ed\se +Item2=$(OUTPUT_INTERMEDIATE_DIR)\se +Item3=Intermediate +Item4=ShaderEditor + +[HistoryLists\hlFinalOutputDir] +Count=13 +Item0=..\..\..\bin\editors\ +Item1=..\..\..\bin\editors +Item2=$(OUTPUT_BINARIES_DIR)\ +Item3=x:\stalker_addon\binaries\ +Item4=x:\binaries\ +Item5=x:\binaries +Item6=x:\ +Item7=x:\build\ +Item8=x:\build +Item9=u:\preliminary\ +Item10=u:\preliminary +Item11=!run\ +Item12=P:\Editor\!run + +[HistoryLists\hIBPIOutputDir] +Count=5 +Item0=..\..\..\lib\editors +Item1=x:\stalker_addon\libraries +Item2=$(OUTPUT_LIBRARIES_DIR) +Item3=$(OUTPUT_LIBRARIES_DIR)\ +Item4=x:\libraries + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams=-wf x:\stalker_addon\resources +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication=x:\stalker_addon\binaries\ShaderEditor.exe +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/src/editors/ShaderEditor/Splash.cpp b/src/editors/ShaderEditor/Splash.cpp index 14c433d6819..5ccdcf3f3d6 100644 --- a/src/editors/ShaderEditor/Splash.cpp +++ b/src/editors/ShaderEditor/Splash.cpp @@ -7,8 +7,8 @@ #pragma resource "*.dfm" TfrmSplash *frmSplash; //--------------------------------------------------------------------------- -__fastcall TfrmSplash::TfrmSplash(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfrmSplash::TfrmSplash(TComponent *Owner) + : TForm(Owner) {} //--------------------------------------------------------------------------- + + diff --git a/src/editors/ShaderEditor/Splash.h b/src/editors/ShaderEditor/Splash.h index 7cf4c06f31b..c62612c5ac5 100644 --- a/src/editors/ShaderEditor/Splash.h +++ b/src/editors/ShaderEditor/Splash.h @@ -12,18 +12,29 @@ #include #include #include + //--------------------------------------------------------------------------- class TfrmSplash : public TForm { -__published: // IDE-managed Components - TImage *Image1; - TMxLabel *lbStatus; -private: // User declarations -public: // User declarations - __fastcall TfrmSplash(TComponent* Owner); - void SetStatus(LPSTR log){ if (log){ lbStatus->Caption = log; lbStatus->Repaint(); };} + __published: // IDE-managed Components + TImage*Image1; + TMxLabel *lbStatus; +private: // User declarations +public: // User declarations + __fastcall TfrmSplash(TComponent *Owner); + + void SetStatus(LPSTR log) + { + if (log) + { + lbStatus->Caption = log; + lbStatus->Repaint(); + }; + } }; + //--------------------------------------------------------------------------- -extern PACKAGE TfrmSplash *frmSplash; +extern PACKAGE TfrmSplash * frmSplash; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ShaderEditor/TopBar.cpp b/src/editors/ShaderEditor/TopBar.cpp index bde638ff510..3192b520f9e 100644 --- a/src/editors/ShaderEditor/TopBar.cpp +++ b/src/editors/ShaderEditor/TopBar.cpp @@ -2,173 +2,208 @@ #pragma hdrstop #include "TopBar.h" -#include "../ECore/Editor/UI_ToolsCustom.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/UI_ToolsCustom.h" +#include "editors/ECore/Editor/ui_main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "ExtBtn" #pragma link "mxPlacemnt" #pragma resource "*.dfm" TfraTopBar *fraTopBar; + //--------------------------------------------------------------------------- -__fastcall TfraTopBar::TfraTopBar(TComponent* Owner) - : TFrame(Owner) +__fastcall TfraTopBar::TfraTopBar(TComponent *Owner) + : TFrame(Owner) { - ebActionSelect->Tag = etaSelect; - ebActionAdd->Tag = etaAdd; - ebActionMove->Tag = etaMove; - ebActionRotate->Tag = etaRotate; - ebActionScale->Tag = etaScale; - - ebAxisX->Tag = etAxisX; - ebAxisY->Tag = etAxisY; - ebAxisZ->Tag = etAxisZ; - ebAxisZX->Tag = etAxisZX; - - ebCSParent->Tag = etfCSParent; - ebNUScale->Tag = etfNUScale; - ebNormalAlign->Tag = etfNormalAlign; - ebGSnap->Tag = etfGSnap; - ebOSnap->Tag = etfOSnap; - ebMTSnap->Tag = etfMTSnap; - ebVSnap->Tag = etfVSnap; - ebASnap->Tag = etfASnap; - ebMSnap->Tag = etfMSnap; + ebActionSelect->Tag = etaSelect; + ebActionAdd->Tag = etaAdd; + ebActionMove->Tag = etaMove; + ebActionRotate->Tag = etaRotate; + ebActionScale->Tag = etaScale; + + ebAxisX->Tag = etAxisX; + ebAxisY->Tag = etAxisY; + ebAxisZ->Tag = etAxisZ; + ebAxisZX->Tag = etAxisZX; + + ebCSParent->Tag = etfCSParent; + ebNUScale->Tag = etfNUScale; + ebNormalAlign->Tag = etfNormalAlign; + ebGSnap->Tag = etfGSnap; + ebOSnap->Tag = etfOSnap; + ebMTSnap->Tag = etfMTSnap; + ebVSnap->Tag = etfVSnap; + ebASnap->Tag = etfASnap; + ebMSnap->Tag = etfMSnap; DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- -void TfraTopBar::OnTimer(){ - for (int j=0; j(temp) != NULL) +void TfraTopBar::OnTimer() +{ + for (int j = 0; j(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebEditUndoClick(TObject *Sender) -{ - ExecCommand( COMMAND_UNDO ); +{ + ExecCommand(COMMAND_UNDO); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebEditRedoClick(TObject *Sender) { - ExecCommand( COMMAND_REDO ); + ExecCommand(COMMAND_REDO); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ActionClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_CHANGE_ACTION, btn->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebAxisClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_CHANGE_AXIS, btn->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebSettingsClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_SET_SETTINGS, btn->Tag, btn->Down); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebViewClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); - if (btn){ - if (btn==ebViewFront) EDevice.m_Camera.ViewFront(); - if (btn==ebViewBack) EDevice.m_Camera.ViewBack(); - if (btn==ebViewLeft) EDevice.m_Camera.ViewLeft(); - if (btn==ebViewRight) EDevice.m_Camera.ViewRight(); - if (btn==ebViewTop) EDevice.m_Camera.ViewTop(); - if (btn==ebViewBottom) EDevice.m_Camera.ViewBottom(); - if (btn==ebViewReset) EDevice.m_Camera.ViewReset(); + TExtBtn *btn = dynamic_cast(Sender); + if (btn) + { + if (btn==ebViewFront) + EDevice.m_Camera.ViewFront(); + if (btn==ebViewBack) + EDevice.m_Camera.ViewBack(); + if (btn==ebViewLeft) + EDevice.m_Camera.ViewLeft(); + if (btn==ebViewRight) + EDevice.m_Camera.ViewRight(); + if (btn==ebViewTop) + EDevice.m_Camera.ViewTop(); + if (btn==ebViewBottom) + EDevice.m_Camera.ViewBottom(); + if (btn==ebViewReset) + EDevice.m_Camera.ViewReset(); } UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::RefreshBar() { - TExtBtn* btn = 0; - //actions - switch(Tools->GetAction()){ - case etaSelect: btn=ebActionSelect; break; - case etaAdd: btn=ebActionAdd; break; - case etaMove: btn=ebActionMove; break; - case etaRotate: btn=ebActionRotate; break; - case etaScale: btn=ebActionScale; break; - default: THROW; + TExtBtn *btn = 0; + //actions + switch (Tools->GetAction()) + { + case etaSelect: btn = ebActionSelect; + break; + case etaAdd: btn = ebActionAdd; + break; + case etaMove: btn = ebActionMove; + break; + case etaRotate: btn = ebActionRotate; + break; + case etaScale: btn = ebActionScale; + break; + default: THROW; } - btn->Down = true; + btn->Down = true; // axis - switch (Tools->GetAxis()){ - case etAxisX: btn=ebAxisX; break; - case etAxisY: btn=ebAxisY; break; - case etAxisZ: btn=ebAxisZ; break; - case etAxisZX: btn=ebAxisZX; break; - case etAxisUndefined: btn=NULL; break; - default: THROW; + switch (Tools->GetAxis()) + { + case etAxisX: btn = ebAxisX; + break; + case etAxisY: btn = ebAxisY; + break; + case etAxisZ: btn = ebAxisZ; + break; + case etAxisZX: btn = ebAxisZX; + break; + case etAxisUndefined: btn = NULL; + break; + default: THROW; } - if(btn) - btn->Down = true; + if (btn) + btn->Down = true; // settings - ebCSParent->Down = Tools->GetSettings(etfCSParent); - ebNUScale->Down = Tools->GetSettings(etfNUScale); - ebNormalAlign->Down = Tools->GetSettings(etfNormalAlign); - ebGSnap->Down = Tools->GetSettings(etfGSnap); - ebOSnap->Down = Tools->GetSettings(etfOSnap); - ebMTSnap->Down = Tools->GetSettings(etfMTSnap); - ebVSnap->Down = Tools->GetSettings(etfVSnap); - ebASnap->Down = Tools->GetSettings(etfASnap); - ebMSnap->Down = Tools->GetSettings(etfMSnap); + ebCSParent->Down = Tools->GetSettings(etfCSParent); + ebNUScale->Down = Tools->GetSettings(etfNUScale); + ebNormalAlign->Down = Tools->GetSettings(etfNormalAlign); + ebGSnap->Down = Tools->GetSettings(etfGSnap); + ebOSnap->Down = Tools->GetSettings(etfOSnap); + ebMTSnap->Down = Tools->GetSettings(etfMTSnap); + ebVSnap->Down = Tools->GetSettings(etfVSnap); + ebASnap->Down = Tools->GetSettings(etfASnap); + ebMSnap->Down = Tools->GetSettings(etfMSnap); // redraw scene - UI->RedrawScene (); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebZoomExtentsClick(TObject *Sender) { - ExecCommand( COMMAND_ZOOM_EXTENTS, FALSE ); + ExecCommand(COMMAND_ZOOM_EXTENTS, FALSE); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebZoomExtentsSelectedClick(TObject *Sender) { - ExecCommand( COMMAND_ZOOM_EXTENTS, TRUE ); + ExecCommand(COMMAND_ZOOM_EXTENTS, TRUE); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebCameraStyleClick(TObject *Sender) { - EDevice.m_Camera.SetStyle((ECameraStyle)((TExtBtn*)Sender)->Tag); + EDevice.m_Camera.SetStyle((ECameraStyle)((TExtBtn*)Sender)->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::fsStorageRestorePlacement(TObject *Sender) { - if (ebCameraPlane->Down) EDevice.m_Camera.SetStyle(csPlaneMove); - else if (ebCameraArcBall->Down) EDevice.m_Camera.SetStyle(cs3DArcBall); - else if (ebCameraFly->Down) EDevice.m_Camera.SetStyle(csFreeFly); + if (ebCameraPlane->Down) + EDevice.m_Camera.SetStyle(csPlaneMove); + else if (ebCameraArcBall->Down) + EDevice.m_Camera.SetStyle(cs3DArcBall); + else if (ebCameraFly->Down) + EDevice.m_Camera.SetStyle(csFreeFly); UI->RedrawScene(); } -//--------------------------------------------------------------------------- - - - +//--------------------------------------------------------------------------- diff --git a/src/editors/ShaderEditor/TopBar.h b/src/editors/ShaderEditor/TopBar.h index 92a93edad09..2934f1bf83d 100644 --- a/src/editors/ShaderEditor/TopBar.h +++ b/src/editors/ShaderEditor/TopBar.h @@ -12,10 +12,14 @@ #include #include "ExtBtn.hpp" #include "mxPlacemnt.hpp" + //--------------------------------------------------------------------------- -class ECORE_API TfraTopBar : public TFrame +class ECORE_API TfraTopBar : + +public +TFrame { -__published: // IDE-managed Components + __published: // IDE-managed Components TPanel *paTBEdit; TExtBtn *ebEditUndo; TExtBtn *ebEditRedo; @@ -28,7 +32,7 @@ class ECORE_API TfraTopBar : public TFrame TPanel *paSnap; TExtBtn *ebMSnap; TExtBtn *ebASnap; - TExtBtn *ebCSParent; + TExtBtn *ebCSParent; TPanel *paAxis; TExtBtn *ebAxisX; TExtBtn *ebAxisY; @@ -43,35 +47,36 @@ class ECORE_API TfraTopBar : public TFrame TExtBtn *ebViewBack; TExtBtn *ebViewRight; TExtBtn *ebViewBottom; - TExtBtn *ebNUScale; - TPanel *Panel1; - TExtBtn *ebZoomExtents; - TExtBtn *ebZoomExtentsSelected; - TExtBtn *ebVSnap; - TFormStorage *fsStorage; - TExtBtn *ebCameraPlane; - TExtBtn *ebCameraArcBall; - TExtBtn *ebCameraFly; - TExtBtn *ebViewReset; - TExtBtn *ebMTSnap; - TExtBtn *ebNormalAlign; + TExtBtn *ebNUScale; + TPanel *Panel1; + TExtBtn *ebZoomExtents; + TExtBtn *ebZoomExtentsSelected; + TExtBtn *ebVSnap; + TFormStorage *fsStorage; + TExtBtn *ebCameraPlane; + TExtBtn *ebCameraArcBall; + TExtBtn *ebCameraFly; + TExtBtn *ebViewReset; + TExtBtn *ebMTSnap; + TExtBtn *ebNormalAlign; void __fastcall ebEditUndoClick(TObject *Sender); void __fastcall ebEditRedoClick(TObject *Sender); void __fastcall ActionClick(TObject *Sender); void __fastcall ebViewClick(TObject *Sender); - void __fastcall ebZoomExtentsClick(TObject *Sender); - void __fastcall ebZoomExtentsSelectedClick(TObject *Sender); - void __fastcall ebCameraStyleClick(TObject *Sender); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall ebAxisClick(TObject *Sender); - void __fastcall ebSettingsClick(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TfraTopBar(TComponent* Owner); + void __fastcall ebZoomExtentsClick(TObject *Sender); + void __fastcall ebZoomExtentsSelectedClick(TObject *Sender); + void __fastcall ebCameraStyleClick(TObject *Sender); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall ebAxisClick(TObject *Sender); + void __fastcall ebSettingsClick(TObject *Sender); + private: // User declarations + public: // User declarations + __fastcall TfraTopBar(TComponent* Owner); void OnTimer(); void __fastcall RefreshBar(); }; //--------------------------------------------------------------------------- -extern PACKAGE TfraTopBar *fraTopBar; +extern PACKAGE TfraTopBar * fraTopBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ShaderEditor/UI_shadertools.cpp b/src/editors/ShaderEditor/UI_shadertools.cpp index 864eed34683..787089b9c2b 100644 --- a/src/editors/ShaderEditor/UI_shadertools.cpp +++ b/src/editors/ShaderEditor/UI_shadertools.cpp @@ -4,228 +4,245 @@ #pragma hdrstop #include "UI_ShaderTools.h" -#include "../xrEProps/ChoseForm.h" -#include "../ECore/Editor/ui_main.h" -#include "leftbar.h" -#include "../xrEProps/PropertiesList.h" -#include "../../Layers/xrRender/blenders/Blender.h" -#include "GameMtlLib.h" -#include "../xrEProps/ItemList.h" +#include "editors/xrEProps/ChoseForm.h" +#include "editors/ECore/Editor/ui_main.h" +#include "LeftBar.h" +#include "editors/xrEProps/PropertiesList.h" +#include "Layers/xrRender/blenders/Blender.h" +#include "xrEngine/GameMtlLib.h" +#include "editors/xrEProps/ItemList.h" //------------------------------------------------------------------------------ -CShaderTool*& STools=(CShaderTool*)Tools; +CShaderTool *&STools = (CShaderTool*)Tools; //------------------------------------------------------------------------------ CShaderTool::CShaderTool() { - m_Current = 0; - m_Items = 0; - m_ItemProps = 0; - m_PreviewProps = 0; - fFogness = 0.9f; - dwFogColor = 0xffffffff; - m_Flags.zero (); + m_Current = 0; + m_Items = 0; + m_ItemProps = 0; + m_PreviewProps = 0; + fFogness = 0.9f; + dwFogColor = 0xffffffff; + m_Flags.zero(); } + //--------------------------------------------------------------------------- -CShaderTool::~CShaderTool() -{ -} +CShaderTool::~CShaderTool() {} + //--------------------------------------------------------------------------- -void CShaderTool::OnChangeEditor(ISHTools* tools) +void CShaderTool::OnChangeEditor(ISHTools *tools) { - if (m_Current) m_Current->OnDeactivate(); - m_Current = tools; R_ASSERT(m_Current); - m_Current->OnActivate(); + if (m_Current) + m_Current->OnDeactivate(); + m_Current = tools; + R_ASSERT(m_Current); + m_Current->OnActivate(); ExecCommand(COMMAND_UPDATE_PROPERTIES); - ExecCommand(COMMAND_UPDATE_CAPTION); + ExecCommand(COMMAND_UPDATE_CAPTION); } + //--------------------------------------------------------------------------- bool CShaderTool::IfModified() -{ - for (ToolsPairIt it=m_Tools.begin(); it!=m_Tools.end(); it++) - if (!it->second->IfModified()) return false; - return true; +{ + for (ToolsPairIt it = m_Tools.begin(); it!=m_Tools.end(); it++) + if (!it->second->IfModified()) + return false; + return true; } bool CShaderTool::IsModified() { - for (ToolsPairIt it=m_Tools.begin(); it!=m_Tools.end(); it++) - if (it->second->IsModified()) return true; - return false; + for (ToolsPairIt it = m_Tools.begin(); it!=m_Tools.end(); it++) + if (it->second->IsModified()) + return true; + return false; } void CShaderTool::Modified() { - Current()->Modified(); + Current()->Modified(); } + //--------------------------------------------------------------------------- bool CShaderTool::OnCreate() { - // create props - m_Items = TItemList::CreateForm ("Items", fraLeftBar->paItemList, alClient,TItemList::ilEditMenu|TItemList::ilDragAllowed|TItemList::ilFolderStore); - m_Items->SetOnItemsFocusedEvent(fastdelegate::bind(this,&CShaderTool::OnItemFocused)); - m_ItemProps = TProperties::CreateForm ("Item Properties", fraLeftBar->paShaderProps, alClient); - m_PreviewProps = TProperties::CreateForm ("Preview Properties", fraLeftBar->paPreviewProps, alClient); + m_Items = TItemList::CreateForm("Items", fraLeftBar->paItemList, alClient, TItemList::ilEditMenu|TItemList::ilDragAllowed|TItemList::ilFolderStore); + m_Items->SetOnItemsFocusedEvent(fastdelegate::bind(this, &CShaderTool::OnItemFocused)); + m_ItemProps = TProperties::CreateForm("Item Properties", fraLeftBar->paShaderProps, alClient); + m_PreviewProps = TProperties::CreateForm("Preview Properties", fraLeftBar->paPreviewProps, alClient); // create tools - RegisterTools (); + RegisterTools(); - for (ToolsPairIt it=m_Tools.begin(); it!=m_Tools.end(); it++) - if (!it->second->OnCreate()) return false; + for (ToolsPairIt it = m_Tools.begin(); it!=m_Tools.end(); it++) + if (!it->second->OnCreate()) + return false; return true; } void CShaderTool::OnDestroy() { - // destroy props - TItemList::DestroyForm (m_Items); - TProperties::DestroyForm(m_ItemProps); + // destroy props + TItemList::DestroyForm(m_Items); + TProperties::DestroyForm(m_ItemProps); TProperties::DestroyForm(m_PreviewProps); - // - for (ToolsPairIt it=m_Tools.begin(); it!=m_Tools.end(); it++) - it->second->OnDestroy(); + // + for (ToolsPairIt it = m_Tools.begin(); it!=m_Tools.end(); it++) + it->second->OnDestroy(); - UnregisterTools (); + UnregisterTools(); } -#include "igame_persistent.h" +#include "xrEngine/IGame_Persistent.h" void CShaderTool::RenderEnvironment() { -/* if (psDeviceFlags.is(rsEnvironment)){ - g_pGamePersistent->Environment().RenderSky (); - g_pGamePersistent->Environment().RenderClouds (); - } -*/ + /* if (psDeviceFlags.is(rsEnvironment)){ + g_pGamePersistent->Environment().RenderSky (); + g_pGamePersistent->Environment().RenderClouds (); + } + */ } void CShaderTool::Render() { - PrepareLighting (); - Current()->OnRender (); -// if (psDeviceFlags.is(rsEnvironment)) g_pGamePersistent->Environment().RenderLast (); - inherited::Render (); + PrepareLighting(); + Current()->OnRender(); + // if (psDeviceFlags.is(rsEnvironment)) g_pGamePersistent->Environment().RenderLast (); + inherited::Render(); } void CShaderTool::OnFrame() { - if (m_Flags.is(flRefreshList)) - RealUpdateList(); - if (m_Flags.is(flRefreshProps)) - RealUpdateProperties(); - Current()->OnFrame(); + if (m_Flags.is(flRefreshList)) + RealUpdateList(); + if (m_Flags.is(flRefreshProps)) + RealUpdateProperties(); + Current()->OnFrame(); } void CShaderTool::ZoomObject(BOOL bOnlySel) { - Current()->ZoomObject(bOnlySel); + Current()->ZoomObject(bOnlySel); } void CShaderTool::PrepareLighting() { // add directional light Flight L; - ZeroMemory(&L,sizeof(Flight)); + ZeroMemory(&L, sizeof(Flight)); L.type = D3DLIGHT_DIRECTIONAL; - L.diffuse.set(1,1,1,1); - L.direction.set(1,-1,1); L.direction.normalize(); - EDevice.SetLight(0,L); - EDevice.LightEnable(0,true); - - L.diffuse.set(0.3,0.3,0.3,1); - L.direction.set(-1,-1,-1); L.direction.normalize(); - EDevice.SetLight(1,L); - EDevice.LightEnable(1,true); - - L.diffuse.set(0.3,0.3,0.3,1); - L.direction.set(1,-1,-1); L.direction.normalize(); - EDevice.SetLight(2,L); - EDevice.LightEnable(2,true); - - L.diffuse.set(0.3,0.3,0.3,1); - L.direction.set(-1,-1,1); L.direction.normalize(); - EDevice.SetLight(3,L); - EDevice.LightEnable(3,true); - - L.diffuse.set(1.0,0.8,0.7,1); - L.direction.set(0,1,0); L.direction.normalize(); - EDevice.SetLight(4,L); - EDevice.LightEnable(4,true); + L.diffuse.set(1, 1, 1, 1); + L.direction.set(1, -1, 1); + L.direction.normalize(); + EDevice.SetLight(0, L); + EDevice.LightEnable(0, true); + + L.diffuse.set(0.3, 0.3, 0.3, 1); + L.direction.set(-1, -1, -1); + L.direction.normalize(); + EDevice.SetLight(1, L); + EDevice.LightEnable(1, true); + + L.diffuse.set(0.3, 0.3, 0.3, 1); + L.direction.set(1, -1, -1); + L.direction.normalize(); + EDevice.SetLight(2, L); + EDevice.LightEnable(2, true); + + L.diffuse.set(0.3, 0.3, 0.3, 1); + L.direction.set(-1, -1, 1); + L.direction.normalize(); + EDevice.SetLight(3, L); + EDevice.LightEnable(3, true); + + L.diffuse.set(1.0, 0.8, 0.7, 1); + L.direction.set(0, 1, 0); + L.direction.normalize(); + EDevice.SetLight(4, L); + EDevice.LightEnable(4, true); } void CShaderTool::OnDeviceCreate() { - for (ToolsPairIt it=m_Tools.begin(); it!=m_Tools.end(); it++) - if (it->second) it->second->OnDeviceCreate(); + for (ToolsPairIt it = m_Tools.begin(); it!=m_Tools.end(); it++) + if (it->second) + it->second->OnDeviceCreate(); } void CShaderTool::OnDeviceDestroy() { - for (ToolsPairIt it=m_Tools.begin(); it!=m_Tools.end(); it++) - if (it->second) it->second->OnDeviceDestroy(); + for (ToolsPairIt it = m_Tools.begin(); it!=m_Tools.end(); it++) + if (it->second) + it->second->OnDeviceDestroy(); } -void CShaderTool::OnShowHint(AStringVec& ss) +void CShaderTool::OnShowHint(AStringVec &ss) { - Current()->OnShowHint(ss); + Current()->OnShowHint(ss); } void CShaderTool::ApplyChanges() { - Current()->ApplyChanges(); + Current()->ApplyChanges(); } void CShaderTool::ShowProperties(LPCSTR focused_item) { - m_ItemProps->ShowProperties(); + m_ItemProps->ShowProperties(); } LPCSTR CShaderTool::CurrentToolsName() { - return Current()?Current()->ToolsName():""; + return Current() ? Current()->ToolsName() : ""; } LPCSTR CShaderTool::GetInfo() { - return 0; + return 0; } -ISHTools* CShaderTool::FindTools(EToolsID id) +ISHTools *CShaderTool::FindTools(EToolsID id) { - ToolsPairIt it = m_Tools.find(id); R_ASSERT(it!=m_Tools.end()); + ToolsPairIt it = m_Tools.find(id); + R_ASSERT(it!=m_Tools.end()); return it->second; } -ISHTools* CShaderTool::FindTools(TElTabSheet* sheet) +ISHTools *CShaderTool::FindTools(TElTabSheet *sheet) { - for (ToolsPairIt it=m_Tools.begin(); it!=m_Tools.end(); it++) - if (it->second->Sheet()==sheet) return it->second; + for (ToolsPairIt it = m_Tools.begin(); it!=m_Tools.end(); it++) + if (it->second->Sheet()==sheet) + return it->second; return 0; } bool CShaderTool::Load(LPCSTR name) { - return true; + return true; } bool CShaderTool::Save(LPCSTR name, bool bInternal) { - bool bRes = true; - for (ToolsPairIt it=m_Tools.begin(); it!=m_Tools.end(); it++) - if (!it->second->Save()) bRes=false; - return bRes; + bool bRes = true; + for (ToolsPairIt it = m_Tools.begin(); it!=m_Tools.end(); it++) + if (!it->second->Save()) + bRes = false; + return bRes; } void CShaderTool::Reload() { - if (!Current()->IfModified()) return; - if (ELog.DlgMsg(mtConfirmation,"Reload current items?")==mrYes) + if (!Current()->IfModified()) + return; + if (ELog.DlgMsg(mtConfirmation, "Reload current items?")==mrYes) Current()->Reload(); } @@ -237,85 +254,101 @@ void CShaderTool::Reload() void CShaderTool::RegisterTools() { - for (int k=aeFirstTool; k (ISHInit( EToolsID(k), m_Items, fraLeftBar->tsEngine, m_ItemProps, m_PreviewProps)); break; - case aeCompiler: tools = xr_new (ISHInit( EToolsID(k), m_Items, fraLeftBar->tsCompiler, m_ItemProps, m_PreviewProps)); break; - case aeMtl: tools = xr_new (ISHInit( EToolsID(k), m_Items, fraLeftBar->tsMaterial, m_ItemProps, m_PreviewProps)); break; - case aeMtlPair: tools = xr_new (ISHInit( EToolsID(k), m_Items, fraLeftBar->tsMaterialPair,m_ItemProps, m_PreviewProps)); break; -// case aeSoundEnv: tools = xr_new (ISHInit( EToolsID(k), m_Items, fraLeftBar->tsSoundEnv, m_ItemProps, m_PreviewProps)); break; + for (int k = aeFirstTool; k(ISHInit(EToolsID(k), m_Items, fraLeftBar->tsEngine, m_ItemProps, m_PreviewProps)); + break; + case aeCompiler: tools = xr_new(ISHInit(EToolsID(k), m_Items, fraLeftBar->tsCompiler, m_ItemProps, m_PreviewProps)); + break; + case aeMtl: tools = xr_new(ISHInit(EToolsID(k), m_Items, fraLeftBar->tsMaterial, m_ItemProps, m_PreviewProps)); + break; + case aeMtlPair: tools = xr_new(ISHInit(EToolsID(k), m_Items, fraLeftBar->tsMaterialPair, m_ItemProps, m_PreviewProps)); + break; + //case aeSoundEnv: tools = xr_new(ISHInit(EToolsID(k), m_Items, fraLeftBar->tsSoundEnv, m_ItemProps, m_PreviewProps)); + break; } R_ASSERT(tools); - m_Tools.insert(mk_pair(k,tools)); + m_Tools.insert(mk_pair(k, tools)); } } void CShaderTool::UnregisterTools() { - for (ToolsPairIt it=m_Tools.begin(); it!=m_Tools.end(); it++) - xr_delete(it->second); + for (ToolsPairIt it = m_Tools.begin(); it!=m_Tools.end(); it++) + xr_delete(it->second); } -#include "../ECore/Editor/EditMesh.h" -bool CShaderTool::RayPick(const Fvector& start, const Fvector& dir, float& dist, Fvector* pt, Fvector* n) +#include "editors/ECore/Editor/EditMesh.h" + +bool CShaderTool::RayPick(const Fvector &start, const Fvector &dir, float &dist, Fvector *pt, Fvector *n) { -/* - if (m_EditObject) - { - SRayPickInfo pinf; - if (m_EditObject->RayPick(dist,start,dir,Fidentity,&pinf)){ - if (pt) pt->set(pinf.pt); - if (n){ - const Fvector* PT[3]; - pinf.e_mesh->GetFacePT(pinf.inf.id, PT); - n->mknormal(*PT[0],*PT[1],*PT[2]); - } - return true; - }else return false; - }else -*/ + /* + if (m_EditObject) + { + SRayPickInfo pinf; + if (m_EditObject->RayPick(dist,start,dir,Fidentity,&pinf)){ + if (pt) pt->set(pinf.pt); + if (n){ + const Fvector* PT[3]; + pinf.e_mesh->GetFacePT(pinf.inf.id, PT); + n->mknormal(*PT[0],*PT[1],*PT[2]); + } + return true; + }else return false; + }else + */ { - Fvector np; np.mad(start,dir,dist); - if ((start.y>0)&&(np.y<0.f)){ - if (pt) pt->set(start); - if (n) n->set(0.f,1.f,0.f); + Fvector np; + np.mad(start, dir, dist); + if ((start.y>0)&&(np.y<0.f)) + { + if (pt) + pt->set(start); + if (n) + n->set(0.f, 1.f, 0.f); return true; - }else return false; + } + else + return false; } } void CShaderTool::RealUpdateProperties() { Current()->RealUpdateProperties(); - m_Flags.set(flRefreshProps,FALSE); + m_Flags.set(flRefreshProps, FALSE); } void CShaderTool::RealUpdateList() { Current()->RealUpdateList(); - m_Flags.set(flRefreshList,FALSE); + m_Flags.set(flRefreshList, FALSE); } -void __fastcall CShaderTool::OnItemFocused(ListItemsVec& items) +void __fastcall CShaderTool::OnItemFocused(ListItemsVec &items) { - LPCSTR name = 0; - Current()->m_CurrentItem= 0; - - if (!items.empty()){ - VERIFY(items.size()==1); - Current()->m_CurrentItem = *items.begin(); - name = Current()->m_CurrentItem->Key(); + LPCSTR name = 0; + Current()->m_CurrentItem = 0; + + if (!items.empty()) + { + VERIFY(items.size()==1); + Current()->m_CurrentItem = *items.begin(); + name = Current()->m_CurrentItem->Key(); } - Current()->SetCurrentItem(name,false); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + Current()->SetCurrentItem(name, false); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -bool CShaderTool::GetSelectionPosition (Fmatrix& result) +bool CShaderTool::GetSelectionPosition(Fmatrix &result) { - result = Fidentity; - return true; + result = Fidentity; + return true; } //------------------------------------------------------------------------------ + diff --git a/src/editors/ShaderEditor/UI_shadertools.h b/src/editors/ShaderEditor/UI_shadertools.h index a494816929c..0d4699dd459 100644 --- a/src/editors/ShaderEditor/UI_shadertools.h +++ b/src/editors/ShaderEditor/UI_shadertools.h @@ -3,8 +3,8 @@ #define UI_ShaderToolsH #include "SHToolsInterface.h" -#include "../ECore/Editor/UI_ToolsCustom.h" -#include "../ECore/Editor/ui_maincommand.h" +#include "editors/ECore/Editor/UI_ToolsCustom.h" +#include "editors/ECore/Editor/UI_MainCommand.h" // refs class CEditableObject; @@ -14,91 +14,136 @@ class TProperties; class CShaderTool: public CToolCustom { - typedef CToolCustom inherited; + typedef CToolCustom inherited; - void RegisterTools (); - void UnregisterTools (); - void RealUpdateProperties(); - void RealUpdateList (); + void RegisterTools(); + void UnregisterTools(); + void RealUpdateProperties(); + void RealUpdateList(); - enum{ - flRefreshProps = (1ul<<0ul), - flRefreshList = (1ul<<1ul), + enum + { + flRefreshProps = (1ul<<0ul), + flRefreshList = (1ul<<1ul), }; - Flags32 m_Flags; - void PrepareLighting (); + Flags32 m_Flags; + + void PrepareLighting(); public: - TItemList* m_Items; - TProperties* m_ItemProps; - TProperties* m_PreviewProps; + TItemList *m_Items; + TProperties *m_ItemProps; + TProperties *m_PreviewProps; + + DEFINE_MAP(EToolsID, ISHTools *, ToolsMap, ToolsPairIt); + ToolsMap m_Tools; + ISHTools *m_Current; - DEFINE_MAP (EToolsID,ISHTools*,ToolsMap,ToolsPairIt); - ToolsMap m_Tools; - ISHTools* m_Current; - ISHTools* Current (){return m_Current;} + ISHTools *Current() + { + return m_Current; + } - void __stdcall OnItemFocused (ListItemsVec& items); + void __stdcall OnItemFocused(ListItemsVec &items); public: - CShaderTool (); - virtual ~CShaderTool (); + CShaderTool(); + virtual ~CShaderTool(); + + virtual void Render(); + virtual void RenderEnvironment(); + virtual void OnFrame(); + + virtual bool OnCreate(); + virtual void OnDestroy(); + + virtual bool IfModified(); + virtual bool IsModified(); + virtual void Modified(); + + virtual LPCSTR GetInfo(); + + virtual void ZoomObject(BOOL bSelOnly); - virtual void Render (); - virtual void RenderEnvironment () ; - virtual void OnFrame (); + virtual bool Load(LPCSTR name); + virtual bool Save(LPCSTR name, bool bInternal = false); + virtual void Reload(); - virtual bool OnCreate (); - virtual void OnDestroy (); + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); - virtual bool IfModified (); - virtual bool IsModified (); - virtual void Modified (); + virtual void Clear() + { + inherited::Clear(); + } - virtual LPCSTR GetInfo (); - - virtual void ZoomObject (BOOL bSelOnly); + virtual void OnShowHint(AStringVec &SS); - virtual bool Load (LPCSTR name); - virtual bool Save (LPCSTR name, bool bInternal=false); - virtual void Reload (); - - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); + virtual bool __fastcall MouseStart(TShiftState Shift) + { + return inherited::MouseStart(Shift); + return false; + } - virtual void Clear (){inherited::Clear();} + virtual bool __fastcall MouseEnd(TShiftState Shift) + { + inherited::MouseEnd(Shift); + return false; + } - virtual void OnShowHint (AStringVec& SS); + virtual void __fastcall MouseMove(TShiftState Shift) + { + inherited::MouseMove(Shift); + } - virtual bool __fastcall MouseStart (TShiftState Shift){return inherited::MouseStart(Shift);return false;} - virtual bool __fastcall MouseEnd (TShiftState Shift){inherited::MouseEnd(Shift); return false;} - virtual void __fastcall MouseMove (TShiftState Shift){inherited::MouseMove(Shift);} + virtual bool Pick(TShiftState Shift) + { + return false; + } - virtual bool Pick (TShiftState Shift){return false;} - virtual bool RayPick (const Fvector& start, const Fvector& dir, float& dist, Fvector* pt, Fvector* n); + virtual bool RayPick(const Fvector &start, const Fvector &dir, float &dist, Fvector *pt, Fvector *n); - virtual void ShowProperties (LPCSTR focused_item); - virtual void UpdateProperties (BOOL bForced=false){m_Flags.set(flRefreshProps,TRUE); if (bForced) RealUpdateProperties();} - virtual void RefreshProperties (){;} - virtual void UpdateList (bool bForced=false){m_Flags.set(flRefreshList,TRUE); if (bForced) RealUpdateList();} - virtual bool GetSelectionPosition (Fmatrix& result); + virtual void ShowProperties(LPCSTR focused_item); - LPCSTR CurrentToolsName (); + virtual void UpdateProperties(BOOL bForced = false) + { + m_Flags.set(flRefreshProps, TRUE); + if (bForced) + RealUpdateProperties(); + } - void OnChangeEditor (ISHTools* tools); + virtual void RefreshProperties() + { + ; + } - void ApplyChanges (); + virtual void UpdateList(bool bForced = false) + { + m_Flags.set(flRefreshList, TRUE); + if (bForced) + RealUpdateList(); + } - ISHTools* FindTools (EToolsID id); - ISHTools* FindTools (TElTabSheet* sheet); + virtual bool GetSelectionPosition(Fmatrix &result); + + LPCSTR CurrentToolsName(); + + void OnChangeEditor(ISHTools *tools); + + void ApplyChanges(); + + ISHTools *FindTools(EToolsID id); + ISHTools *FindTools(TElTabSheet *sheet); // commands - CCommandVar CommandSave (CCommandVar p1, CCommandVar p2); - CCommandVar CommandSaveBackup (CCommandVar p1, CCommandVar p2); - CCommandVar CommandReload (CCommandVar p1, CCommandVar p2); - CCommandVar CommandClear (CCommandVar p1, CCommandVar p2); + CCommandVar CommandSave(CCommandVar p1, CCommandVar p2); + CCommandVar CommandSaveBackup(CCommandVar p1, CCommandVar p2); + CCommandVar CommandReload(CCommandVar p1, CCommandVar p2); + CCommandVar CommandClear(CCommandVar p1, CCommandVar p2); - CCommandVar CommandUpdateList (CCommandVar p1, CCommandVar p2); + CCommandVar CommandUpdateList(CCommandVar p1, CCommandVar p2); }; -extern CShaderTool*& STools; + +extern CShaderTool *&STools; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ShaderEditor/leftbar.cpp b/src/editors/ShaderEditor/leftbar.cpp index a4745128aff..60825e954c2 100644 --- a/src/editors/ShaderEditor/leftbar.cpp +++ b/src/editors/ShaderEditor/leftbar.cpp @@ -4,13 +4,13 @@ #include "LeftBar.h" #include "BottomBar.h" #include "main.h" -#include "../../Layers/xrRender/blenders/Blender.h" +#include "Layers/xrRender/blenders/Blender.h" #include "xr_trims.h" #include "UI_ShaderTools.h" #include "UI_ShaderMain.h" -#include "../xrEProps/FolderLib.h" -#include "../xrEProps/PropertiesList.h" -#include "../xrEProps/ChoseForm.h" +#include "editors/xrEProps/FolderLib.h" +#include "editors/xrEProps/PropertiesList.h" +#include "editors/xrEProps/ChoseForm.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "ExtBtn" @@ -24,79 +24,99 @@ TfraLeftBar *fraLeftBar; #define MIN_PANEL_HEIGHT 15 + //--------------------------------------------------------------------------- -__fastcall TfraLeftBar::TfraLeftBar(TComponent* Owner) - : TFrame(Owner) +__fastcall TfraLeftBar::TfraLeftBar(TComponent *Owner) + : TFrame(Owner) { - DEFINE_INI(fsStorage); + DEFINE_INI(fsStorage); - frmMain->paLeftBar->Width = paLeftBar->Width+2; - frmMain->sbToolsMin->Left = paLeftBar->Width-frmMain->sbToolsMin->Width-3; + frmMain->paLeftBar->Width = paLeftBar->Width+2; + frmMain->sbToolsMin->Left = paLeftBar->Width-frmMain->sbToolsMin->Width-3; } + //--------------------------------------------------------------------------- -void UpdatePanel(TPanel* p){ - if (p){ - for (int j=0; jControlCount; j++){ - TExtBtn* btn = dynamic_cast(p->Controls[j]); - if (btn) btn->UpdateMouseInControl(); +void UpdatePanel(TPanel *p) +{ + if (p) + { + for (int j = 0; jControlCount; j++) + { + TExtBtn *btn = dynamic_cast(p->Controls[j]); + if (btn) + btn->UpdateMouseInControl(); } } } + //--------------------------------------------------------------------------- -void TfraLeftBar::UpdateBar(){ +void TfraLeftBar::UpdateBar() +{ int i; - for (i=0; iComponentCount; i++){ - TComponent* temp = fraLeftBar->Components[i]; - if (dynamic_cast(temp) != NULL) + for (i = 0; iComponentCount; i++) + { + TComponent *temp = fraLeftBar->Components[i]; + if (dynamic_cast(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } } + //--------------------------------------------------------------------------- void TfraLeftBar::OnTimer() { - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- void TfraLeftBar::MinimizeAllFrames() { - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(paLeftBar->Controls[j]); - if (pa) PanelMinimize(pa); + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(paLeftBar->Controls[j]); + if (pa) + PanelMinimize(pa); } - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- void TfraLeftBar::MaximizeAllFrames() { - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(paLeftBar->Controls[j]); - if (pa) PanelMaximize(pa); + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(paLeftBar->Controls[j]); + if (pa) + PanelMaximize(pa); } - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSaveClick(TObject *Sender) { - ExecCommand( COMMAND_SAVE ); + ExecCommand(COMMAND_SAVE); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebReloadClick(TObject *Sender) { - ExecCommand( COMMAND_LOAD ); + ExecCommand(COMMAND_LOAD); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebRefreshTexturesClick(TObject *Sender) { - ExecCommand( COMMAND_REFRESH_TEXTURES ); + ExecCommand(COMMAND_REFRESH_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::PanelMimimizeClick(TObject *Sender) @@ -104,6 +124,7 @@ void __fastcall TfraLeftBar::PanelMimimizeClick(TObject *Sender) ::PanelMinMaxClick(Sender); UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::PanelMaximizeClick(TObject *Sender) @@ -111,115 +132,135 @@ void __fastcall TfraLeftBar::PanelMaximizeClick(TObject *Sender) ::PanelMaximizeClick(Sender); UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebEditorPreferencesClick(TObject *Sender) { - ExecCommand(COMMAND_EDITOR_PREF); + ExecCommand(COMMAND_EDITOR_PREF); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebCustomFileMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmCustomFile,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmCustomFile, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebImageCommandsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmImages,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmImages, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebCreateItemClick(TObject *Sender) { AnsiString folder = STools->Current()->ViewGetCurrentItem(true); STools->Current()->AppendItem(folder.c_str()); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::pcShadersChange(TObject *Sender) { - STools->OnChangeEditor(STools->FindTools(pcShaders->ActivePage)); + STools->OnChangeEditor(STools->FindTools(pcShaders->ActivePage)); } + //--------------------------------------------------------------------------- -void __fastcall TfraLeftBar::ebRemoveItemClick(TObject* Sender) +void __fastcall TfraLeftBar::ebRemoveItemClick(TObject *Sender) { - STools->Current()->RemoveCurrent(); + STools->Current()->RemoveCurrent(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebCloneItemClick(TObject *Sender) { - TElTreeItem* pNode = STools->Current()->ViewGetCurrentItem(); - if (pNode&&FHelper.IsObject(pNode)){ - AnsiString full_name; - FHelper.MakeName(pNode,0,full_name,false); - STools->Current()->AppendItem(0,full_name.c_str()); - }else{ - ELog.DlgMsg(mtInformation, "At first select item."); + TElTreeItem *pNode = STools->Current()->ViewGetCurrentItem(); + if (pNode&&FHelper.IsObject(pNode)) + { + AnsiString full_name; + FHelper.MakeName(pNode, 0, full_name, false); + STools->Current()->AppendItem(0, full_name.c_str()); + } + else + { + ELog.DlgMsg(mtInformation, "At first select item."); } } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::fsStorageRestorePlacement(TObject *Sender) { - STools->m_ItemProps->RestoreParams(fsStorage); - STools->m_PreviewProps->RestoreParams(fsStorage); + STools->m_ItemProps->RestoreParams(fsStorage); + STools->m_PreviewProps->RestoreParams(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::fsStorageSavePlacement(TObject *Sender) { - STools->m_ItemProps->SaveParams(fsStorage); - STools->m_PreviewProps->SaveParams(fsStorage); + STools->m_ItemProps->SaveParams(fsStorage); + STools->m_PreviewProps->SaveParams(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ImageEditor1Click(TObject *Sender) { - ExecCommand( COMMAND_IMAGE_EDITOR ); + ExecCommand(COMMAND_IMAGE_EDITOR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Refresh1Click(TObject *Sender) { - ExecCommand( COMMAND_REFRESH_TEXTURES ); + ExecCommand(COMMAND_REFRESH_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Checknewtextures1Click(TObject *Sender) { - ExecCommand( COMMAND_CHECK_TEXTURES ); + ExecCommand(COMMAND_CHECK_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExtBtn10MouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmSounds,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmSounds, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MenuItem5Click(TObject *Sender) { - ExecCommand( COMMAND_SOUND_EDITOR ); + ExecCommand(COMMAND_SOUND_EDITOR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MenuItem7Click(TObject *Sender) { - ExecCommand( COMMAND_SYNC_SOUNDS ); + ExecCommand(COMMAND_SYNC_SOUNDS); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::tvEngineKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if (Key==VK_DELETE) ebRemoveItemClick(Sender); + if (Key==VK_DELETE) + ebRemoveItemClick(Sender); } -//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- diff --git a/src/editors/ShaderEditor/leftbar.h b/src/editors/ShaderEditor/leftbar.h index 405d0cdb52c..5df3ada8c07 100644 --- a/src/editors/ShaderEditor/leftbar.h +++ b/src/editors/ShaderEditor/leftbar.h @@ -15,7 +15,7 @@ #include "mxPlacemnt.hpp" #include "ElTree.hpp" #include "ElXPThemedControl.hpp" -#include "../xrEProps/FolderLib.h" +#include "editors/xrEProps/FolderLib.h" #include "ElTreeAdvEdit.hpp" #include "ElPgCtl.hpp" @@ -23,114 +23,120 @@ //--------------------------------------------------------------------------- class TfraLeftBar : public TFrame { -__published: // IDE-managed Components - TPanel *paLeftBar; + __published: // IDE-managed Components + TPanel*paLeftBar; TPanel *paScene; - TFormStorage *fsStorage; - TLabel *APHeadLabel2; - TExtBtn *ebSceneMin; - TExtBtn *ebPreferences; - TPanel *paEngineShaders; - TLabel *Label1; - TElPageControl *pcShaders; - TElTabSheet *tsEngine; - TBevel *Bevel1; - TPanel *Panel1; - TExtBtn *ebEngineShaderRemove; - TExtBtn *ebEngineShaderClone; - TExtBtn *ebEngineShaderFile; - TElTabSheet *tsCompiler; - TPanel *Panel4; - TExtBtn *ebCompilerShaderRemove; - TExtBtn *ebCompilerShaderClone; - TExtBtn *ExtBtn4; - TExtBtn *ebCShaderCreate; - TBevel *Bevel3; - TPanel *paShaderProperties; - TLabel *Label6; - TExtBtn *ExtBtn5; - TBevel *Bevel6; - TPanel *paShaderProps; - TSplitter *Splitter1; - TExtBtn *ebImageCommands; - TMxPopupMenu *pmImages; - TMenuItem *ImageEditor1; - TMenuItem *N6; - TMenuItem *Refresh1; - TMenuItem *Checknewtextures1; - TElTabSheet *tsMaterial; - TElTabSheet *tsMaterialPair; - TPanel *Panel2; - TExtBtn *ebMaterialRemove; - TExtBtn *ebMaterialClone; - TExtBtn *ExtBtn3; - TExtBtn *ebMaterialCreate; - TBevel *Bevel2; - TBevel *Bevel4; - TPanel *Panel3; - TExtBtn *ExtBtn6; - TElTabSheet *tsSoundEnv; - TBevel *Bevel5; - TPanel *Panel5; - TExtBtn *ExtBtn2; - TExtBtn *ExtBtn7; - TExtBtn *ExtBtn8; - TExtBtn *ebCreateSoundEnv; - TExtBtn *ebEngineShaderCreate; - TMxPopupMenu *pmCustomFile; - TMenuItem *MenuItem1; - TMenuItem *MenuItem2; - TMenuItem *MenuItem3; - TMenuItem *MenuItem14; - TMenuItem *MenuItem15; - TPanel *paPreview; - TLabel *Label2; - TExtBtn *ExtBtn9; - TPanel *paPreviewProps; - TSplitter *Splitter2; - TExtBtn *ExtBtn10; - TMxPopupMenu *pmSounds; - TMenuItem *MenuItem4; - TMenuItem *MenuItem5; - TMenuItem *MenuItem6; - TMenuItem *MenuItem7; - TPanel *paItemList; + TFormStorage *fsStorage; + TLabel *APHeadLabel2; + TExtBtn *ebSceneMin; + TExtBtn *ebPreferences; + TPanel *paEngineShaders; + TLabel *Label1; + TElPageControl *pcShaders; + TElTabSheet *tsEngine; + TBevel *Bevel1; + TPanel *Panel1; + TExtBtn *ebEngineShaderRemove; + TExtBtn *ebEngineShaderClone; + TExtBtn *ebEngineShaderFile; + TElTabSheet *tsCompiler; + TPanel *Panel4; + TExtBtn *ebCompilerShaderRemove; + TExtBtn *ebCompilerShaderClone; + TExtBtn *ExtBtn4; + TExtBtn *ebCShaderCreate; + TBevel *Bevel3; + TPanel *paShaderProperties; + TLabel *Label6; + TExtBtn *ExtBtn5; + TBevel *Bevel6; + TPanel *paShaderProps; + TSplitter *Splitter1; + TExtBtn *ebImageCommands; + TMxPopupMenu *pmImages; + TMenuItem *ImageEditor1; + TMenuItem *N6; + TMenuItem *Refresh1; + TMenuItem *Checknewtextures1; + TElTabSheet *tsMaterial; + TElTabSheet *tsMaterialPair; + TPanel *Panel2; + TExtBtn *ebMaterialRemove; + TExtBtn *ebMaterialClone; + TExtBtn *ExtBtn3; + TExtBtn *ebMaterialCreate; + TBevel *Bevel2; + TBevel *Bevel4; + TPanel *Panel3; + TExtBtn *ExtBtn6; + TElTabSheet *tsSoundEnv; + TBevel *Bevel5; + TPanel *Panel5; + TExtBtn *ExtBtn2; + TExtBtn *ExtBtn7; + TExtBtn *ExtBtn8; + TExtBtn *ebCreateSoundEnv; + TExtBtn *ebEngineShaderCreate; + TMxPopupMenu *pmCustomFile; + TMenuItem *MenuItem1; + TMenuItem *MenuItem2; + TMenuItem *MenuItem3; + TMenuItem *MenuItem14; + TMenuItem *MenuItem15; + TPanel *paPreview; + TLabel *Label2; + TExtBtn *ExtBtn9; + TPanel *paPreviewProps; + TSplitter *Splitter2; + TExtBtn *ExtBtn10; + TMxPopupMenu *pmSounds; + TMenuItem *MenuItem4; + TMenuItem *MenuItem5; + TMenuItem *MenuItem6; + TMenuItem *MenuItem7; + TPanel *paItemList; void __fastcall ebSaveClick(TObject *Sender); void __fastcall ebReloadClick(TObject *Sender); void __fastcall PanelMimimizeClick(TObject *Sender); void __fastcall PanelMaximizeClick(TObject *Sender); void __fastcall ebEditorPreferencesClick(TObject *Sender); void __fastcall ebRefreshTexturesClick(TObject *Sender); - void __fastcall ebCustomFileMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall tvEngineKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall ebCreateItemClick(TObject *Sender); - void __fastcall pcShadersChange(TObject *Sender); - void __fastcall ebRemoveItemClick(TObject *Sender); - void __fastcall ebCloneItemClick(TObject *Sender); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); - void __fastcall ebImageCommandsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y); - void __fastcall ImageEditor1Click(TObject *Sender); - void __fastcall Refresh1Click(TObject *Sender); - void __fastcall Checknewtextures1Click(TObject *Sender); - void __fastcall ExtBtn10MouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall MenuItem5Click(TObject *Sender); - void __fastcall MenuItem7Click(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TfraLeftBar (TComponent* Owner); - void ChangeTarget (int tgt); - void UpdateBar (); - void OnTimer (); - void MinimizeAllFrames (); - void MaximizeAllFrames (); - void RefreshBar (){;} + void __fastcall ebCustomFileMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall tvEngineKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall ebCreateItemClick(TObject *Sender); + void __fastcall pcShadersChange(TObject *Sender); + void __fastcall ebRemoveItemClick(TObject *Sender); + void __fastcall ebCloneItemClick(TObject *Sender); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); + void __fastcall ebImageCommandsMouseDown(TObject *Sender, + TMouseButton Button, TShiftState Shift, int X, int Y); + void __fastcall ImageEditor1Click(TObject *Sender); + void __fastcall Refresh1Click(TObject *Sender); + void __fastcall Checknewtextures1Click(TObject *Sender); + void __fastcall ExtBtn10MouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall MenuItem5Click(TObject *Sender); + void __fastcall MenuItem7Click(TObject *Sender); +private: // User declarations +public: // User declarations + __fastcall TfraLeftBar(TComponent *Owner); + void ChangeTarget(int tgt); + void UpdateBar(); + void OnTimer(); + void MinimizeAllFrames(); + void MaximizeAllFrames(); + + void RefreshBar() + { + ; + } }; + //--------------------------------------------------------------------------- -extern PACKAGE TfraLeftBar *fraLeftBar; +extern PACKAGE TfraLeftBar * fraLeftBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ShaderEditor/main.cpp b/src/editors/ShaderEditor/main.cpp index 45a36f22a2d..c3b791d8c0a 100644 --- a/src/editors/ShaderEditor/main.cpp +++ b/src/editors/ShaderEditor/main.cpp @@ -11,92 +11,101 @@ TfrmMain *frmMain; #pragma link "RenderWindow" #pragma resource "*.dfm" -#include "topbar.h" -#include "leftbar.h" -#include "bottombar.h" +#include "TopBar.h" +#include "LeftBar.h" +#include "BottomBar.h" //------------------------------------------------------------------------------ -#include "../xrEProps/ChoseForm.h" -#include "../../Layers/xrRender/shader.h" -#include "shader_xrlc.h" -#include "../ECore/Engine/texture.h" -#include "../ECore/Editor/Library.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EThumbnail.h" -#include "../xrEProps/FolderLib.h" -#include "LightAnimLibrary.h" -#include "../ECore/Editor/ImageManager.h" -#include "../ECore/Editor/SoundManager.h" -#include "../ECore/Editor/ui_main.h" -#include "..\..\Layers\xrRender\PSLibrary.h" -#include "GameMtlLib.h" -#include "../../xrSound/soundrender_source.h" -#include "../ECore/Editor/render.h" -#include "ResourceManager.h" -#include "../xrEProps/EditorChooseEvents.h" - - -__fastcall TfrmMain::TfrmMain(TComponent* Owner) - : TForm(Owner) +#include "editors/xrEProps/ChoseForm.h" +#include "Layers/xrRender/shader.h" +#include "utils/Shader_xrLC.h" +#include "editors/ECore/Engine/texture.h" +#include "editors/ECore/Editor/Library.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EThumbnail.h" +#include "editors/xrEProps/FolderLib.h" +#include "xrEngine/LightAnimLibrary.h" +#include "editors/ECore/Editor/ImageManager.h" +#include "editors/ECore/Editor/SoundManager.h" +#include "editors/ECore/Editor/ui_main.h" +#include "Layers/xrRender/PSLibrary.h" +#include "xrEngine/GameMtlLib.h" +#include "xrSound/SoundRender_Source.h" +#include "editors/ECore/Editor/render.h" +#include "Layers/xrRender/ResourceManager.h" +#include "editors/xrEProps/EditorChooseEvents.h" + + +__fastcall TfrmMain::TfrmMain(TComponent *Owner) + : TForm(Owner) { -// forms - fraBottomBar = xr_new ((TComponent*)0); - fraTopBar = xr_new ((TComponent*)0); - fraLeftBar = xr_new ((TComponent*)0); -//- - - fraBottomBar->Parent = paBottomBar; - fraTopBar->Parent = paTopBar; - fraLeftBar->Parent = paLeftBar; - if (paLeftBar->Tag > 0) paLeftBar->Parent = paTopBar; - else paLeftBar->Parent = frmMain; - - EDevice.SetHandle (Handle,D3DWindow->Handle); - EnableReceiveCommands (); - if (!ExecCommand(COMMAND_INITIALIZE,(u32)D3DWindow,(u32)paRender)){ - FlushLog (); - TerminateProcess(GetCurrentProcess(),-1); + // forms + fraBottomBar = xr_new((TComponent*)0); + fraTopBar = xr_new((TComponent*)0); + fraLeftBar = xr_new((TComponent*)0); + //- + + fraBottomBar->Parent = paBottomBar; + fraTopBar->Parent = paTopBar; + fraLeftBar->Parent = paLeftBar; + if (paLeftBar->Tag>0) + paLeftBar->Parent = paTopBar; + else + paLeftBar->Parent = frmMain; + + EDevice.SetHandle(Handle, D3DWindow->Handle); + EnableReceiveCommands(); + if (!ExecCommand(COMMAND_INITIALIZE, (u32)D3DWindow, (u32)paRender)) + { + FlushLog(); + TerminateProcess(GetCurrentProcess(), -1); } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormShow(TObject *Sender) { - tmRefresh->Enabled = true; tmRefreshTimer(Sender); - ExecCommand (COMMAND_UPDATE_GRID); - ExecCommand (COMMAND_RENDER_FOCUS); - FillChooseEvents (); + tmRefresh->Enabled = true; + tmRefreshTimer(Sender); + ExecCommand(COMMAND_UPDATE_GRID); + ExecCommand(COMMAND_RENDER_FOCUS); + FillChooseEvents(); // special case :( - frmMain->WindowState = (TWindowState)fsStorage->ReadInteger("window_state",frmMain->WindowState); + frmMain->WindowState = (TWindowState)fsStorage->ReadInteger("window_state", frmMain->WindowState); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormClose(TObject *Sender, TCloseAction &Action) { - Application->OnIdle = 0; + Application->OnIdle = 0; - ClearChooseEvents (); + ClearChooseEvents(); - ExecCommand (COMMAND_DESTROY); + ExecCommand(COMMAND_DESTROY); - fraTopBar->Parent = 0; - fraLeftBar->Parent = 0; - fraBottomBar->Parent = 0; + fraTopBar->Parent = 0; + fraLeftBar->Parent = 0; + fraBottomBar->Parent = 0; xr_delete(fraTopBar); xr_delete(fraBottomBar); - xr_delete(fraLeftBar); + xr_delete(fraLeftBar); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormCloseQuery(TObject *Sender, bool &CanClose) { tmRefresh->Enabled = false; CanClose = ExecCommand(COMMAND_EXIT); - if (!CanClose) tmRefresh->Enabled = true; + if (!CanClose) + tmRefresh->Enabled = true; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormCreate(TObject *Sender) { - DEFINE_INI(fsStorage); + DEFINE_INI(fsStorage); Application->OnIdle = IdleHandler; } @@ -104,27 +113,34 @@ void __fastcall TfrmMain::FormCreate(TObject *Sender) #define MIN_PANEL_HEIGHT 17 + void __fastcall TfrmMain::sbToolsMinClick(TObject *Sender) { - if (paLeftBar->Tag > 0){ + if (paLeftBar->Tag>0) + { paLeftBar->Parent = frmMain; - paLeftBar->Tag = 0; - }else{ + paLeftBar->Tag = 0; + } + else + { paLeftBar->Parent = paTopBar; - paLeftBar->Tag = 1; + paLeftBar->Tag = 1; } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::TopClick(TObject *Sender) { - if (paLeftBar->Tag > 0){ - paLeftBar->Align = alRight; + if (paLeftBar->Tag>0) + { + paLeftBar->Align = alRight; paLeftBar->Parent = frmMain; paLeftBar->Height = paLeftBar->Tag; - paLeftBar->Tag = 0; + paLeftBar->Tag = 0; } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::IdleHandler(TObject *Sender, bool &Done) @@ -132,132 +148,169 @@ void __fastcall TfrmMain::IdleHandler(TObject *Sender, bool &Done) Done = false; UI->Idle(); } + void __fastcall TfrmMain::D3DWindowResize(TObject *Sender) { UI->Resize(); -} +} + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { ShiftKey = Shift; - if (!UI->KeyDown(Key, Shift)){UI->ApplyShortCut(Key, Shift);} + if (!UI->KeyDown(Key, Shift)) + { + UI->ApplyShortCut(Key, Shift); + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyUp(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if (!UI->KeyUp(Key, Shift)){;} + if (!UI->KeyUp(Key, Shift)) + { + ; + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyPress(TObject *Sender, char &Key) { - if (!UI->KeyPress(Key, ShiftKey)){;} + if (!UI->KeyPress(Key, ShiftKey)) + { + ; + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { - if (!D3DWindow->Focused()) UI->ApplyGlobalShortCut(Key, Shift); - if (Key==VK_MENU) Key=0; + if (!D3DWindow->Focused()) + UI->ApplyGlobalShortCut(Key, Shift); + if (Key==VK_MENU) + Key = 0; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::UpdateCaption() { AnsiString name; - name.sprintf("%s - [%s%s]",UI->EditorDesc(),UI->GetCaption(),UI->IsModified()?"*":""); + name.sprintf("%s - [%s%s]", UI->EditorDesc(), UI->GetCaption(), UI->IsModified() ? "*" : ""); Caption = name; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::tmRefreshTimer(TObject *Sender) { int i; - for (i=0; iComponentCount; i++){ - TComponent* temp = frmMain->Components[i]; - if (dynamic_cast(temp) != NULL) + for (i = 0; iComponentCount; i++) + { + TComponent *temp = frmMain->Components[i]; + if (dynamic_cast(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } - fraLeftBar->OnTimer(); - fraTopBar->OnTimer(); + fraLeftBar->OnTimer(); + fraTopBar->OnTimer(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowPaint(TObject *Sender) { - if (!UI||!UI->m_bReady) return; + if (!UI||!UI->m_bReady) + return; UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowChangeFocus(TObject *Sender) { - if (!UI||!UI->m_bReady) return; - if (D3DWindow->Focused()){ + if (!UI||!UI->m_bReady) + return; + if (D3DWindow->Focused()) + { UI->IR_Capture(); - UI->OnAppActivate(); - }else{ - UI->OnAppDeactivate(); + UI->OnAppActivate(); + } + else + { + UI->OnAppDeactivate(); UI->IR_Release(); -// paRender->Color=paRender->Color; // ÷òîáû íå áûëî internal code gen error + // paRender->Color=paRender->Color; // ÷òîáû íå áûëî internal code gen error } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - UI->MousePress(Shift,X,Y); + UI->MousePress(Shift, X, Y); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseUp(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - UI->MouseRelease(Shift,X,Y); + UI->MouseRelease(Shift, X, Y); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseMove(TObject *Sender, - TShiftState Shift, int X, int Y) + TShiftState Shift, int X, int Y) { - UI->MouseMove(Shift,X,Y); + UI->MouseMove(Shift, X, Y); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::ebAllMinClick(TObject *Sender) { - fraLeftBar->MinimizeAllFrames(); + fraLeftBar->MinimizeAllFrames(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::ebAllMaxClick(TObject *Sender) { - fraLeftBar->MaximizeAllFrames(); + fraLeftBar->MaximizeAllFrames(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormResize(TObject *Sender) { - if (fraLeftBar) fraLeftBar->UpdateBar(); + if (fraLeftBar) + fraLeftBar->UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::paRenderResize(TObject *Sender) { - ExecCommand(COMMAND_RENDER_RESIZE); + ExecCommand(COMMAND_RENDER_RESIZE); } + //--------------------------------------------------------------------------- - + void __fastcall TfrmMain::fsStorageSavePlacement(TObject *Sender) { - fsStorage->WriteInteger("window_state",frmMain->WindowState); + fsStorage->WriteInteger("window_state", frmMain->WindowState); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ShaderEditor/main.h b/src/editors/ShaderEditor/main.h index 54f0a90a0ee..bda0375dab8 100644 --- a/src/editors/ShaderEditor/main.h +++ b/src/editors/ShaderEditor/main.h @@ -5,7 +5,7 @@ //--------------------------------------------------------------------------- #include #include -#include +#include #include #include #include @@ -15,31 +15,35 @@ #include "MxMenus.hpp" #include "mxPlacemnt.hpp" #include "RenderWindow.hpp" + //--------------------------------------------------------------------------- // refs -class ECORE_API TfrmMain : public TForm +class ECORE_API TfrmMain : + +public +TForm { -__published: // IDE-managed Components - TPanel *paLeftBar; - TPanel *paBottomBar; + __published: // IDE-managed Components + TPanel *paLeftBar; + TPanel *paBottomBar; TPanel *paTools; TTimer *tmRefresh; - TFormStorage *fsStorage; + TFormStorage *fsStorage; TPanel *paMain; TPanel *paTopBar; - TPanel *paRender; - TLabel *APHeadLabel2; - TExtBtn *sbToolsMin; - TD3DWindow *D3DWindow; - TExtBtn *ebAllMin; - TExtBtn *ebAllMax; - void __fastcall FormCreate(TObject *Sender); + TPanel *paRender; + TLabel *APHeadLabel2; + TExtBtn *sbToolsMin; + TD3DWindow *D3DWindow; + TExtBtn *ebAllMin; + TExtBtn *ebAllMax; + void __fastcall FormCreate(TObject *Sender); void __fastcall D3DWindowResize(TObject *Sender); void __fastcall D3DWindowKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall D3DWindowKeyUp(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall sbToolsMinClick(TObject *Sender); void __fastcall TopClick(TObject *Sender); void __fastcall FormShow(TObject *Sender); @@ -48,32 +52,33 @@ class ECORE_API TfrmMain : public TForm void __fastcall D3DWindowKeyPress(TObject *Sender, char &Key); void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); - void __fastcall D3DWindowChangeFocus(TObject *Sender); - void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall D3DWindowMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall D3DWindowMouseUp(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall D3DWindowMouseMove(TObject *Sender, TShiftState Shift, - int X, int Y); - void __fastcall ebAllMinClick(TObject *Sender); - void __fastcall ebAllMaxClick(TObject *Sender); - void __fastcall FormResize(TObject *Sender); - void __fastcall paRenderResize(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); -private: // User declarations + void __fastcall D3DWindowChangeFocus(TObject *Sender); + void __fastcall FormKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall D3DWindowMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall D3DWindowMouseUp(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall D3DWindowMouseMove(TObject *Sender, TShiftState Shift, + int X, int Y); + void __fastcall ebAllMinClick(TObject *Sender); + void __fastcall ebAllMaxClick(TObject *Sender); + void __fastcall FormResize(TObject *Sender); + void __fastcall paRenderResize(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); + private: // User declarations void __fastcall IdleHandler(TObject *Sender, bool &Done); - TShiftState ShiftKey; - HINSTANCE m_HInstance; -public: // User declarations - __fastcall TfrmMain(TComponent* Owner); + TShiftState ShiftKey; + HINSTANCE m_HInstance; + public: // User declarations + __fastcall TfrmMain(TComponent* Owner); void __fastcall UpdateCaption(); - __inline void SetHInst(HINSTANCE inst){ m_HInstance=inst; } - bool IsFocused(){return D3DWindow->Focused();} + __inline void SetHInst(HINSTANCE inst){ m_HInstance=inst; } +bool IsFocused(){return D3DWindow->Focused();} }; //--------------------------------------------------------------------------- -extern /*ECORE_API*/ PACKAGE TfrmMain *frmMain; +extern /*ECORE_API*/ PACKAGE TfrmMain * frmMain; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ShaderEditor/stdafx.cpp b/src/editors/ShaderEditor/stdafx.cpp index 8b2e610bee9..f06dfef160d 100644 --- a/src/editors/ShaderEditor/stdafx.cpp +++ b/src/editors/ShaderEditor/stdafx.cpp @@ -4,7 +4,7 @@ // external dependencies #ifndef _ECOREB -# pragma comment(lib,"xrECoreB.lib") +#pragma comment(lib,"xrECoreB.lib") #endif #pragma comment(lib,"xrEPropsB.lib") diff --git a/src/editors/ShaderEditor/stdafx.h b/src/editors/ShaderEditor/stdafx.h index 905637bf245..62a7f2b6706 100644 --- a/src/editors/ShaderEditor/stdafx.h +++ b/src/editors/ShaderEditor/stdafx.h @@ -18,9 +18,9 @@ #define DIRECTINPUT_VERSION 0x0800 -#define R_R1 1 -#define R_R2 2 -#define RENDER R_R1 +#define R_R1 1 +#define R_R2 2 +#define RENDER R_R1 // Std C++ headers #include @@ -35,134 +35,153 @@ #ifdef _eof #undef _eof #endif -__inline int _eof (int _a) { return ::eof(_a); } +__inline int _eof(int _a) +{ + return ::eof(_a); +} #ifdef _access #undef _access #endif -__inline int _access(const char *_a, int _b) { return ::access(_a,_b); } +__inline int _access(const char *_a, int _b) +{ + return ::access(_a, _b); +} #ifdef _lseek #undef _lseek #endif -__inline long _lseek(int handle, long offset, int fromwhere){ return ::lseek(handle, offset, fromwhere);} +__inline long _lseek(int handle, long offset, int fromwhere) +{ + return ::lseek(handle, offset, fromwhere); +} #ifdef _dup #undef _dup #endif #define fmodf fmod -__inline int _dup (int handle) { return ::dup(handle);} -__inline float modff(float a, float *b){ - double x,y; - y = modf(double(a),&x); +__inline int _dup(int handle) +{ + return ::dup(handle); +} +__inline float modff(float a, float *b) +{ + double x, y; + y = modf(double(a), &x); *b = x; return float(y); } -__inline float expf (float val) { return ::exp(val);} - +__inline float expf(float val) +{ + return ::exp(val); +} -#ifdef _ECOREB - #define ECORE_API __declspec(dllexport) - #define ENGINE_API __declspec(dllexport) +#include "xrCore/Platform.h" +#ifdef _ECOREB +#define ECORE_API XR_IMPORT +#define ENGINE_API XR_EXPORT #else - #define ECORE_API __declspec(dllimport) - #define ENGINE_API __declspec(dllimport) +#define ECORE_API XR_IMPORT +#define ENGINE_API XR_IMPORT #endif -#define DLL_API __declspec(dllimport) -#define PropertyGP(a,b) __declspec( property( get=a, put=b ) ) -#define THROW FATAL("THROW"); -#define THROW2(a) FATAL(a); +#define DLL_API XR_IMPORT +#define PropertyGP(a,b) __declspec(property(get=a, put=b)) +#define THROW FATAL("THROW"); +#define THROW2(a) FATAL(a); #define NO_XRC_STATS -#define clMsg Msg +#define clMsg Msg // core -#include +#include #ifdef _EDITOR - class PropValue; - class PropItem; - DEFINE_VECTOR(PropItem*,PropItemVec,PropItemIt); +class PropValue; +class PropItem; +DEFINE_VECTOR(PropItem *, PropItemVec, PropItemIt); - class ListItem; - DEFINE_VECTOR(ListItem*,ListItemsVec,ListItemsIt); +class ListItem; +DEFINE_VECTOR(ListItem *, ListItemsVec, ListItemsIt); #endif -#include "../../xrCDB/xrCDB.h" -#include "../../xrSound/Sound.h" +#include "xrCDB/xrCDB.h" +#include "xrSound/Sound.h" #include "PSystem.h" // DirectX headers #include #include -#include "..\..\Layers\xrRender\xrD3dDefs.h" +#include "Layers/xrRender/xrD3DDefs.h" #include #include // some user components -#include "fmesh.h" -#include "_d3d_extensions.h" +#include "xrCore/FMesh.hpp" +#include "Common/_d3d_extensions.h" -#include "../ECore/Editor/D3DX_Wrapper.h" +#include "editors/ECore/Editor/D3DX_Wrapper.h" -DEFINE_VECTOR (AnsiString,AStringVec,AStringIt); -DEFINE_VECTOR (AnsiString*,LPAStringVec,LPAStringIt); +DEFINE_VECTOR(AnsiString, AStringVec, AStringIt); +DEFINE_VECTOR(AnsiString*, LPAStringVec, LPAStringIt); -#include "../../xrServerEntities/xrEProps.h" -#include "Log.h" -#include "../ECore/Editor/engine.h" -#include "defines.h" +#include "xrServerEntities/xrEProps.h" +#include "xrCore/Log.h" +#include "editors/ECore/Editor/engine.h" +#include "xrEngine/defines.h" -struct str_pred : public std::binary_function +struct str_pred : public std::binary_function { IC bool operator()(LPCSTR x, LPCSTR y) const - { return strcmp(x,y)<0; } + { + return strcmp(x, y) < 0; + } }; struct astr_pred : public std::binary_function { - IC bool operator()(const AnsiString& x, const AnsiString& y) const - { return xEditorName(),".ini").c_str());} -//#define INI_NAME(buf) {buf = buf+xr_string(Core.WorkingPath)+xr_string("\\")+EFS.ChangeFileExt(UI->EditorName(),".ini");} -#define DEFINE_INI(storage) {string_path buf; INI_NAME(buf); storage->IniFileName=buf;} +#define INI_NAME(buf) {FS.update_path(buf,"$local_root$",EFS.ChangeFileExt(UI->EditorName(),".ini").c_str());} +//#define INI_NAME(buf) {buf = buf+xr_string(Core.WorkingPath)+xr_string("\\")+EFS.ChangeFileExt(UI->EditorName(),".ini");} +#define DEFINE_INI(storage) {string_path buf; INI_NAME(buf); storage->IniFileName=buf;} #define NONE_CAPTION "" #define MULTIPLESEL_CAPTION "" // path definition -#define _server_root_ "$server_root$" -#define _server_data_root_ "$server_data_root$" -#define _local_root_ "$local_root$" -#define _import_ "$import$" -#define _sounds_ "$sounds$" -#define _textures_ "$textures$" -#define _objects_ "$objects$" -#define _maps_ "$maps$" -#define _groups_ "$groups$" -#define _temp_ "$temp$" -#define _omotion_ "$omotion$" -#define _omotions_ "$omotions$" -#define _smotion_ "$smotion$" -#define _detail_objects_ "$detail_objects$" +#define _server_root_ "$server_root$" +#define _server_data_root_ "$server_data_root$" +#define _local_root_ "$local_root$" +#define _import_ "$import$" +#define _sounds_ "$sounds$" +#define _textures_ "$textures$" +#define _objects_ "$objects$" +#define _maps_ "$maps$" +#define _groups_ "$groups$" +#define _temp_ "$temp$" +#define _omotion_ "$omotion$" +#define _omotions_ "$omotions$" +#define _smotion_ "$smotion$" +#define _detail_objects_ "$detail_objects$" #endif -#define TEX_POINT_ATT "internal\\internal_light_attpoint" -#define TEX_SPOT_ATT "internal\\internal_light_attclip" +#define TEX_POINT_ATT "internal\\internal_light_attpoint" +#define TEX_SPOT_ATT "internal\\internal_light_attclip" #pragma hdrstop - diff --git a/src/editors/ShaderEditor/ui_shadermain.cpp b/src/editors/ShaderEditor/ui_shadermain.cpp index aa63ad355a7..8a7af0ffdec 100644 --- a/src/editors/ShaderEditor/ui_shadermain.cpp +++ b/src/editors/ShaderEditor/ui_shadermain.cpp @@ -4,65 +4,74 @@ #include "UI_ShaderMain.h" #include "UI_ShaderTools.h" -#include "topbar.h" -#include "leftbar.h" -#include "../../Layers/xrRender/D3DUtils.h" -#include "bottombar.h" +#include "TopBar.h" +#include "LeftBar.h" +#include "Layers/xrRender/D3DUtils.h" +#include "BottomBar.h" #include "xr_trims.h" #include "main.h" #include "xr_input.h" //--------------------------------------------------------------------------- -CShaderMain*& PUI=(CShaderMain*)UI; +CShaderMain *&PUI = (CShaderMain*)UI; + //--------------------------------------------------------------------------- CShaderMain::CShaderMain() { - EPrefs = xr_new(); + EPrefs = xr_new(); } + //--------------------------------------------------------------------------- CShaderMain::~CShaderMain() { - xr_delete (EPrefs); + xr_delete(EPrefs); } + //--------------------------------------------------------------------------- CCommandVar CShaderTool::CommandSave(CCommandVar p1, CCommandVar p2) { - Save (0,0); - ExecCommand (COMMAND_UPDATE_CAPTION); + Save(0, 0); + ExecCommand(COMMAND_UPDATE_CAPTION); return TRUE; } + CCommandVar CShaderTool::CommandSaveBackup(CCommandVar p1, CCommandVar p2) { - ExecCommand (COMMAND_SAVE); + ExecCommand(COMMAND_SAVE); return TRUE; } + CCommandVar CShaderTool::CommandReload(CCommandVar p1, CCommandVar p2) { - Reload (); - ExecCommand (COMMAND_UPDATE_CAPTION); + Reload(); + ExecCommand(COMMAND_UPDATE_CAPTION); return TRUE; } + CCommandVar CShaderTool::CommandClear(CCommandVar p1, CCommandVar p2) { EDevice.m_Camera.Reset(); - ExecCommand (COMMAND_UPDATE_CAPTION); + ExecCommand(COMMAND_UPDATE_CAPTION); return TRUE; } + CCommandVar CShaderTool::CommandUpdateList(CCommandVar p1, CCommandVar p2) { - UpdateList (); + UpdateList(); return TRUE; } + CCommandVar CommandRefreshUIBar(CCommandVar p1, CCommandVar p2) { - fraTopBar->RefreshBar (); - fraLeftBar->RefreshBar (); + fraTopBar->RefreshBar(); + fraLeftBar->RefreshBar(); fraBottomBar->RefreshBar(); return TRUE; } + CCommandVar CommandRestoreUIBar(CCommandVar p1, CCommandVar p2) { fraTopBar->fsStorage->RestoreFormPlacement(); @@ -70,6 +79,7 @@ CCommandVar CommandRestoreUIBar(CCommandVar p1, CCommandVar p2) fraBottomBar->fsStorage->RestoreFormPlacement(); return TRUE; } + CCommandVar CommandSaveUIBar(CCommandVar p1, CCommandVar p2) { fraTopBar->fsStorage->SaveFormPlacement(); @@ -77,11 +87,13 @@ CCommandVar CommandSaveUIBar(CCommandVar p1, CCommandVar p2) fraBottomBar->fsStorage->SaveFormPlacement(); return TRUE; } + CCommandVar CommandUpdateToolBar(CCommandVar p1, CCommandVar p2) { fraLeftBar->UpdateBar(); return TRUE; } + CCommandVar CommandUpdateCaption(CCommandVar p1, CCommandVar p2) { frmMain->UpdateCaption(); @@ -90,41 +102,44 @@ CCommandVar CommandUpdateCaption(CCommandVar p1, CCommandVar p2) void CShaderMain::RegisterCommands() { - inherited::RegisterCommands(); + inherited::RegisterCommands(); // tools - REGISTER_CMD_CE (COMMAND_SAVE, "File\\Save", STools,CShaderTool::CommandSave,true); - REGISTER_CMD_C (COMMAND_SAVE_BACKUP, STools,CShaderTool::CommandSaveBackup); - REGISTER_CMD_CE (COMMAND_LOAD, "File\\Reload", STools,CShaderTool::CommandReload,true); - REGISTER_CMD_CE (COMMAND_CLEAR, "File\\Clear", STools,CShaderTool::CommandClear,true); - REGISTER_CMD_CE (COMMAND_UPDATE_LIST, "Update List", STools,CShaderTool::CommandUpdateList,true); - REGISTER_CMD_S (COMMAND_REFRESH_UI_BAR, CommandRefreshUIBar); - REGISTER_CMD_S (COMMAND_RESTORE_UI_BAR, CommandRestoreUIBar); - REGISTER_CMD_S (COMMAND_SAVE_UI_BAR, CommandSaveUIBar); - REGISTER_CMD_S (COMMAND_UPDATE_TOOLBAR, CommandUpdateToolBar); - REGISTER_CMD_S (COMMAND_UPDATE_CAPTION, CommandUpdateCaption); + REGISTER_CMD_CE(COMMAND_SAVE, "File\\Save", STools, CShaderTool::CommandSave, true); + REGISTER_CMD_C(COMMAND_SAVE_BACKUP, STools, CShaderTool::CommandSaveBackup); + REGISTER_CMD_CE(COMMAND_LOAD, "File\\Reload", STools, CShaderTool::CommandReload, true); + REGISTER_CMD_CE(COMMAND_CLEAR, "File\\Clear", STools, CShaderTool::CommandClear, true); + REGISTER_CMD_CE(COMMAND_UPDATE_LIST, "Update List", STools, CShaderTool::CommandUpdateList, true); + REGISTER_CMD_S(COMMAND_REFRESH_UI_BAR, CommandRefreshUIBar); + REGISTER_CMD_S(COMMAND_RESTORE_UI_BAR, CommandRestoreUIBar); + REGISTER_CMD_S(COMMAND_SAVE_UI_BAR, CommandSaveUIBar); + REGISTER_CMD_S(COMMAND_UPDATE_TOOLBAR, CommandUpdateToolBar); + REGISTER_CMD_S(COMMAND_UPDATE_CAPTION, CommandUpdateCaption); } -char* CShaderMain::GetCaption() +char *CShaderMain::GetCaption() { - return (LPSTR)STools->CurrentToolsName();// "shaders&materials"; -} + return (LPSTR)STools->CurrentToolsName();// "shaders&materials"; +} bool __fastcall CShaderMain::ApplyShortCut(WORD Key, TShiftState Shift) { - return inherited::ApplyShortCut(Key,Shift); + return inherited::ApplyShortCut(Key, Shift); } + //--------------------------------------------------------------------------- bool __fastcall CShaderMain::ApplyGlobalShortCut(WORD Key, TShiftState Shift) { - return inherited::ApplyGlobalShortCut(Key,Shift); + return inherited::ApplyGlobalShortCut(Key, Shift); } + //--------------------------------------------------------------------------- void CShaderMain::RealUpdateScene() { - inherited::RealUpdateScene (); + inherited::RealUpdateScene(); } + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -132,60 +147,78 @@ void CShaderMain::RealUpdateScene() //--------------------------------------------------------------------------- void CShaderMain::ResetStatus() { - VERIFY(m_bReady); - if (fraBottomBar->paStatus->Caption!=""){ - fraBottomBar->paStatus->Caption=""; fraBottomBar->paStatus->Repaint(); + VERIFY(m_bReady); + if (fraBottomBar->paStatus->Caption!="") + { + fraBottomBar->paStatus->Caption = ""; + fraBottomBar->paStatus->Repaint(); } } + void CShaderMain::SetStatus(LPSTR s, bool bOutLog) { - VERIFY(m_bReady); - if (fraBottomBar->paStatus->Caption!=s){ - fraBottomBar->paStatus->Caption=s; fraBottomBar->paStatus->Repaint(); - if (bOutLog&&s&&s[0]) ELog.Msg(mtInformation,s); + VERIFY(m_bReady); + if (fraBottomBar->paStatus->Caption!=s) + { + fraBottomBar->paStatus->Caption = s; + fraBottomBar->paStatus->Repaint(); + if (bOutLog&&s&&s[0]) + ELog.Msg(mtInformation, s); } } + void CShaderMain::ProgressDraw() { - fraBottomBar->RedrawBar(); + fraBottomBar->RedrawBar(); } + //--------------------------------------------------------------------------- void CShaderMain::OutCameraPos() { - VERIFY(m_bReady); + VERIFY(m_bReady); AnsiString s; - const Fvector& c = EDevice.m_Camera.GetPosition(); - s.sprintf("C: %3.1f, %3.1f, %3.1f",c.x,c.y,c.z); -// const Fvector& hpb = EDevice.m_Camera.GetHPB(); -// s.sprintf(" Cam: %3.1f°, %3.1f°, %3.1f°",rad2deg(hpb.y),rad2deg(hpb.x),rad2deg(hpb.z)); - fraBottomBar->paCamera->Caption=s; fraBottomBar->paCamera->Repaint(); + const Fvector &c = EDevice.m_Camera.GetPosition(); + s.sprintf("C: %3.1f, %3.1f, %3.1f", c.x, c.y, c.z); + // const Fvector& hpb = EDevice.m_Camera.GetHPB(); + // s.sprintf(" Cam: %3.1f°, %3.1f°, %3.1f°",rad2deg(hpb.y),rad2deg(hpb.x),rad2deg(hpb.z)); + fraBottomBar->paCamera->Caption = s; + fraBottomBar->paCamera->Repaint(); } + //--------------------------------------------------------------------------- void CShaderMain::OutUICursorPos() { - VERIFY(fraBottomBar); - AnsiString s; POINT pt; + VERIFY(fraBottomBar); + AnsiString s; + POINT pt; GetCursorPos(&pt); - s.sprintf("Cur: %d, %d",pt.x,pt.y); - fraBottomBar->paUICursor->Caption=s; fraBottomBar->paUICursor->Repaint(); + s.sprintf("Cur: %d, %d", pt.x, pt.y); + fraBottomBar->paUICursor->Caption = s; + fraBottomBar->paUICursor->Repaint(); } + //--------------------------------------------------------------------------- void CShaderMain::OutGridSize() { - VERIFY(fraBottomBar); + VERIFY(fraBottomBar); AnsiString s; - s.sprintf("Grid: %1.1f",EPrefs->grid_cell_size); - fraBottomBar->paGridSquareSize->Caption=s; fraBottomBar->paGridSquareSize->Repaint(); + s.sprintf("Grid: %1.1f", EPrefs->grid_cell_size); + fraBottomBar->paGridSquareSize->Caption = s; + fraBottomBar->paGridSquareSize->Repaint(); } + //--------------------------------------------------------------------------- void CShaderMain::OutInfo() { - fraBottomBar->paSel->Caption = Tools->GetInfo(); + fraBottomBar->paSel->Caption = Tools->GetInfo(); } + //--------------------------------------------------------------------------- void CShaderMain::RealQuit() { - frmMain->Close(); + frmMain->Close(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ShaderEditor/ui_shadermain.h b/src/editors/ShaderEditor/ui_shadermain.h index dddd1081e4a..9feba703563 100644 --- a/src/editors/ShaderEditor/ui_shadermain.h +++ b/src/editors/ShaderEditor/ui_shadermain.h @@ -1,45 +1,55 @@ #ifndef UI_ShaderMainH #define UI_ShaderMainH -#include "../ECore/Editor/UI_MainCommand.h" -#include "../ECore/Editor/UI_Main.h" +#include "editors/ECore/Editor/UI_MainCommand.h" +#include "editors/ECore/Editor/UI_Main.h" -enum { - COMMAND_EXTFIRST_EXT = COMMAND_MAIN_LAST-1, - COMMAND_UPDATE_LIST, +enum +{ + COMMAND_EXTFIRST_EXT = COMMAND_MAIN_LAST-1, + COMMAND_UPDATE_LIST, }; + //------------------------------------------------------------------------------ -class CShaderMain: public TUI{ - typedef TUI inherited; - - virtual void RealUpdateScene (); - virtual void RealQuit (); +class CShaderMain: public TUI +{ + typedef TUI inherited; + + virtual void RealUpdateScene(); + virtual void RealQuit(); public: - CShaderMain (); - virtual ~CShaderMain (); + CShaderMain(); + virtual ~CShaderMain(); + + virtual LPSTR GetCaption(); - virtual LPSTR GetCaption (); + virtual void ResetStatus(); + virtual void SetStatus(LPSTR s, bool bOutLog); + virtual void ProgressDraw(); + virtual void OutCameraPos(); + virtual void OutUICursorPos(); + virtual void OutGridSize(); + virtual void OutInfo(); - virtual void ResetStatus (); - virtual void SetStatus (LPSTR s, bool bOutLog); - virtual void ProgressDraw (); - virtual void OutCameraPos (); - virtual void OutUICursorPos (); - virtual void OutGridSize (); - virtual void OutInfo (); + virtual LPCSTR EditorName() + { + return "shader"; + } - virtual LPCSTR EditorName (){return "shader";} - virtual LPCSTR EditorDesc (){return "Shader Editor";} + virtual LPCSTR EditorDesc() + { + return "Shader Editor"; + } - virtual bool ApplyShortCut (WORD Key, TShiftState Shift); - virtual bool ApplyGlobalShortCut (WORD Key, TShiftState Shift); + virtual bool ApplyShortCut(WORD Key, TShiftState Shift); + virtual bool ApplyGlobalShortCut(WORD Key, TShiftState Shift); // commands - virtual void RegisterCommands (); -}; -extern CShaderMain*& PUI; + virtual void RegisterCommands(); +}; -#endif //UI_MainCommandH +extern CShaderMain *&PUI; +#endif //UI_MainCommandH From 2fbddc48a1eec4307f748f6e6ddbfae31bbd59fd Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 4 Dec 2015 06:49:21 +0500 Subject: [PATCH 05/10] ParticleEditor: fixed includes and formatted code --- src/editors/ParticleEditor/BottomBar.cpp | 459 ++-- src/editors/ParticleEditor/BottomBar.h | 146 +- .../ParticleEditor/ItemPropFormUnit.cpp | 20 +- src/editors/ParticleEditor/ItemPropFormUnit.h | 17 +- src/editors/ParticleEditor/LeftBar.cpp | 159 +- src/editors/ParticleEditor/LeftBar.h | 194 +- src/editors/ParticleEditor/ObjectAnimator.cpp | 175 +- src/editors/ParticleEditor/ObjectAnimator.h | 87 +- .../ParticleEditor/PSLibraryEditor.cpp | 118 +- src/editors/ParticleEditor/ParticleEditor.cpp | 87 +- .../ParticleEffectActionsImpl.cpp | 2150 +++++++++-------- .../ParticleEditor/ParticleEffectEditor.cpp | 28 +- .../ParticleEditor/ParticleEffectParser.cpp | 1679 +++++++------ .../ParticleEditor/ParticleGroupEditor.cpp | 295 +-- src/editors/ParticleEditor/Splash.cpp | 10 +- src/editors/ParticleEditor/Splash.h | 27 +- src/editors/ParticleEditor/StatGraph.cpp | 617 ++--- src/editors/ParticleEditor/StatGraph.h | 301 ++- src/editors/ParticleEditor/TopBar.cpp | 195 +- src/editors/ParticleEditor/TopBar.h | 53 +- .../ParticleEditor/UI_ParticleMain.cpp | 187 +- src/editors/ParticleEditor/UI_ParticleMain.h | 60 +- .../ParticleEditor/UI_ParticleTools.cpp | 1184 +++++---- src/editors/ParticleEditor/UI_ParticleTools.h | 289 ++- .../ParticleEditor/UI_ParticleToolsProps.cpp | 108 +- src/editors/ParticleEditor/main.cpp | 226 +- src/editors/ParticleEditor/main.h | 83 +- src/editors/ParticleEditor/noise.cpp | 284 +-- src/editors/ParticleEditor/noise.h | 7 +- src/editors/ParticleEditor/stdafx.cpp | 2 +- src/editors/ParticleEditor/stdafx.h | 123 +- 31 files changed, 5184 insertions(+), 4186 deletions(-) diff --git a/src/editors/ParticleEditor/BottomBar.cpp b/src/editors/ParticleEditor/BottomBar.cpp index 6d15e913973..f11bcdb866e 100644 --- a/src/editors/ParticleEditor/BottomBar.cpp +++ b/src/editors/ParticleEditor/BottomBar.cpp @@ -5,50 +5,72 @@ #include "BottomBar.h" #include "LogForm.h" #include "ui_main.h" -#include "igame_persistent.h" -#include "environment.h" -#include "../../xrServerEntities/PropertiesListHelper.h" -#include "../xrEProps/PropertiesList.h" +#include "xrEngine/IGame_Persistent.h" +#include "xrEngine/Environment.h" +#include "xrServerEntities/PropertiesListHelper.h" +#include "editors/xrEProps/PropertiesList.h" //--------------------------------------------------------------------------- #pragma package(smart_init) -#pragma link "ExtBtn" +#pragma link "ExtBtn" #pragma link "MxMenus" #pragma link "mxPlacemnt" -#pragma resource "*.dfm" -TfraBottomBar *fraBottomBar=0; +#pragma resource "*.dfm" +TfraBottomBar *fraBottomBar = 0; + //--------------------------------------------------------------------------- -__fastcall TfraBottomBar::TfraBottomBar(TComponent* Owner) +__fastcall TfraBottomBar::TfraBottomBar(TComponent *Owner) : TFrame(Owner) { DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ClickOptionsMenuItem(TObject *Sender) { - TMenuItem* mi = dynamic_cast(Sender); - if (mi){ + TMenuItem *mi = dynamic_cast(Sender); + if (mi) + { mi->Checked = !mi->Checked; - if (mi==miDrawGrid) ExecCommand(COMMAND_TOGGLE_GRID); - else if (mi==miRenderWithTextures) psDeviceFlags.set(rsRenderTextures,mi->Checked); - else if (mi==miMuteSounds) psDeviceFlags.set(rsMuteSounds,mi->Checked); - else if (mi==miLightScene) psDeviceFlags.set(rsLighting,mi->Checked); - else if (mi==miRenderLinearFilter) psDeviceFlags.set(rsFilterLinear,mi->Checked); - else if (mi==miRenderEdgedFaces) psDeviceFlags.set(rsEdgedFaces,mi->Checked); - else if (mi==miFog) psDeviceFlags.set(rsFog,mi->Checked); - else if (mi==miRealTime) psDeviceFlags.set(rsRenderRealTime,mi->Checked); - else if (mi==miDrawSafeRect) ExecCommand(COMMAND_TOGGLE_SAFE_RECT); - else if (mi==miRenderFillPoint) EDevice.dwFillMode = D3DFILL_POINT; - else if (mi==miRenderFillWireframe) EDevice.dwFillMode = D3DFILL_WIREFRAME; - else if (mi==miRenderFillSolid) EDevice.dwFillMode = D3DFILL_SOLID; - else if (mi==miRenderShadeFlat) EDevice.dwShadeMode = D3DSHADE_FLAT; - else if (mi==miRenderShadeGouraud) EDevice.dwShadeMode = D3DSHADE_GOURAUD; - else if (mi==miRenderHWTransform){ HW.Caps.bForceGPU_SW = !mi->Checked; UI->Resize(); } + if (mi==miDrawGrid) + ExecCommand(COMMAND_TOGGLE_GRID); + else if (mi==miRenderWithTextures) + psDeviceFlags.set(rsRenderTextures, mi->Checked); + else if (mi==miMuteSounds) + psDeviceFlags.set(rsMuteSounds, mi->Checked); + else if (mi==miLightScene) + psDeviceFlags.set(rsLighting, mi->Checked); + else if (mi==miRenderLinearFilter) + psDeviceFlags.set(rsFilterLinear, mi->Checked); + else if (mi==miRenderEdgedFaces) + psDeviceFlags.set(rsEdgedFaces, mi->Checked); + else if (mi==miFog) + psDeviceFlags.set(rsFog, mi->Checked); + else if (mi==miRealTime) + psDeviceFlags.set(rsRenderRealTime, mi->Checked); + else if (mi==miDrawSafeRect) + ExecCommand(COMMAND_TOGGLE_SAFE_RECT); + else if (mi==miRenderFillPoint) + EDevice.dwFillMode = D3DFILL_POINT; + else if (mi==miRenderFillWireframe) + EDevice.dwFillMode = D3DFILL_WIREFRAME; + else if (mi==miRenderFillSolid) + EDevice.dwFillMode = D3DFILL_SOLID; + else if (mi==miRenderShadeFlat) + EDevice.dwShadeMode = D3DSHADE_FLAT; + else if (mi==miRenderShadeGouraud) + EDevice.dwShadeMode = D3DSHADE_GOURAUD; + else if (mi==miRenderHWTransform) + { + HW.Caps.bForceGPU_SW = !mi->Checked; + UI->Resize(); + } } UI->RedrawScene(); ExecCommand(COMMAND_UPDATE_TOOLBAR); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::QualityClick(TObject *Sender) { @@ -56,277 +78,316 @@ void __fastcall TfraBottomBar::QualityClick(TObject *Sender) ((TMenuItem*)Sender)->Checked = true; UI->Resize(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::fsStorageRestorePlacement(TObject *Sender) { // fill mode - if (miRenderFillPoint->Checked) EDevice.dwFillMode=D3DFILL_POINT; - else if (miRenderFillWireframe->Checked)EDevice.dwFillMode=D3DFILL_WIREFRAME; - else if (miRenderFillSolid->Checked) EDevice.dwFillMode=D3DFILL_SOLID; + if (miRenderFillPoint->Checked) + EDevice.dwFillMode = D3DFILL_POINT; + else if (miRenderFillWireframe->Checked) + EDevice.dwFillMode = D3DFILL_WIREFRAME; + else if (miRenderFillSolid->Checked) + EDevice.dwFillMode = D3DFILL_SOLID; // shade mode - if (miRenderShadeFlat->Checked) EDevice.dwShadeMode=D3DSHADE_FLAT; - else if (miRenderShadeGouraud->Checked) EDevice.dwShadeMode=D3DSHADE_GOURAUD; + if (miRenderShadeFlat->Checked) + EDevice.dwShadeMode = D3DSHADE_FLAT; + else if (miRenderShadeGouraud->Checked) + EDevice.dwShadeMode = D3DSHADE_GOURAUD; // hw transform - HW.Caps.bForceGPU_SW = !miRenderHWTransform->Checked; + HW.Caps.bForceGPU_SW = !miRenderHWTransform->Checked; // quality - if (N200->Checked) QualityClick(N200); - else if (N150->Checked) QualityClick(N150); - else if (N125->Checked) QualityClick(N125); - else if (N100->Checked) QualityClick(N100); - else if (N75->Checked) QualityClick(N75); - else if (N50->Checked) QualityClick(N50); - else if (N25->Checked) QualityClick(N25); + if (N200->Checked) + QualityClick(N200); + else if (N150->Checked) + QualityClick(N150); + else if (N125->Checked) + QualityClick(N125); + else if (N100->Checked) + QualityClick(N100); + else if (N75->Checked) + QualityClick(N75); + else if (N50->Checked) + QualityClick(N50); + else if (N25->Checked) + QualityClick(N25); // setup menu miWeather->Clear(); - TMenuItem* mi = xr_new((TComponent*)0); - mi->Caption = "none"; - mi->OnClick = miWeatherClick; - mi->Tag = -1; - mi->Checked = true; - mi->RadioItem = true; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); -/* - // append weathers - CEnvironment::EnvsMapIt _I=g_pGamePersistent->Environment().WeatherCycles.begin(); - CEnvironment::EnvsMapIt _E=g_pGamePersistent->Environment().WeatherCycles.end(); - for (; _I!=_E; _I++){ - mi = xr_new((TComponent*)0); - mi->Caption = *_I->first; - mi->OnClick = miWeatherClick; - mi->RadioItem = true; - miWeather->Add (mi); - } -*/ - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Reload"; - mi->OnClick = miWeatherClick; - mi->Tag = -2; - miWeather->Add (mi); - - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Properties..."; - mi->OnClick = miWeatherClick; - mi->Tag = -3; - miWeather->Add (mi); - - psDeviceFlags.set (rsEnvironment,FALSE); + TMenuItem *mi = xr_new((TComponent*)0); + mi->Caption = "none"; + mi->OnClick = miWeatherClick; + mi->Tag = -1; + mi->Checked = true; + mi->RadioItem = true; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + /* + // append weathers + CEnvironment::EnvsMapIt _I=g_pGamePersistent->Environment().WeatherCycles.begin(); + CEnvironment::EnvsMapIt _E=g_pGamePersistent->Environment().WeatherCycles.end(); + for (; _I!=_E; _I++){ + mi = xr_new((TComponent*)0); + mi->Caption = *_I->first; + mi->OnClick = miWeatherClick; + mi->RadioItem = true; + miWeather->Add (mi); + } + */ + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "Reload"; + mi->OnClick = miWeatherClick; + mi->Tag = -2; + miWeather->Add(mi); + + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "Properties..."; + mi->OnClick = miWeatherClick; + mi->Tag = -3; + miWeather->Add(mi); + + psDeviceFlags.set(rsEnvironment, FALSE); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebLogClick(TObject *Sender) { - TfrmLog::ChangeVisible(); + TfrmLog::ChangeVisible(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebStopClick(TObject *Sender) { - ExecCommand(COMMAND_BREAK_LAST_OPERATION); + ExecCommand(COMMAND_BREAK_LAST_OPERATION); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebStatClick(TObject *Sender) { - psDeviceFlags.set(rsStatistic,!psDeviceFlags.is(rsStatistic)); + psDeviceFlags.set(rsStatistic, !psDeviceFlags.is(rsStatistic)); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebOptionsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { POINT pt; GetCursorPos(&pt); - pmOptions->Popup(pt.x,pt.y); - TExtBtn* btn = dynamic_cast(Sender); VERIFY(btn); btn->MouseManualUp(); + pmOptions->Popup(pt.x, pt.y); + TExtBtn *btn = dynamic_cast(Sender); + VERIFY(btn); + btn->MouseManualUp(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::pmOptionsPopup(TObject *Sender) { - miRenderWithTextures->Checked = psDeviceFlags.is(rsRenderTextures); - miLightScene->Checked = psDeviceFlags.is(rsLighting); - miMuteSounds->Checked = psDeviceFlags.is(rsMuteSounds); - miRenderLinearFilter->Checked = psDeviceFlags.is(rsFilterLinear); - miRenderEdgedFaces->Checked = psDeviceFlags.is(rsEdgedFaces); - miRealTime->Checked = psDeviceFlags.is(rsRenderRealTime); - miFog->Checked = psDeviceFlags.is(rsFog); - miDrawGrid->Checked = psDeviceFlags.is(rsDrawGrid); - miDrawSafeRect->Checked = psDeviceFlags.is(rsDrawSafeRect); - for(int i=0; i < miWeather->Count; ++i) + miRenderWithTextures->Checked = psDeviceFlags.is(rsRenderTextures); + miLightScene->Checked = psDeviceFlags.is(rsLighting); + miMuteSounds->Checked = psDeviceFlags.is(rsMuteSounds); + miRenderLinearFilter->Checked = psDeviceFlags.is(rsFilterLinear); + miRenderEdgedFaces->Checked = psDeviceFlags.is(rsEdgedFaces); + miRealTime->Checked = psDeviceFlags.is(rsRenderRealTime); + miFog->Checked = psDeviceFlags.is(rsFog); + miDrawGrid->Checked = psDeviceFlags.is(rsDrawGrid); + miDrawSafeRect->Checked = psDeviceFlags.is(rsDrawSafeRect); + for (int i = 0; iCount; ++i) { - TMenuItem* mi = miWeather->Items[i]; + TMenuItem *mi = miWeather->Items[i]; BOOL bch; - bch = ((EPrefs->sWeather.size()) && (0==stricmp(mi->Caption.c_str(), EPrefs->sWeather.c_str()))) || - (mi->Caption=="none" && EPrefs->sWeather.size()==0) ; - mi->Checked = bch; + bch = ((EPrefs->sWeather.size())&&(0==stricmp(mi->Caption.c_str(), EPrefs->sWeather.c_str())))|| + (mi->Caption=="none"&&EPrefs->sWeather.size()==0) ; + mi->Checked = bch; } - } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::miWeatherClick(TObject *Sender) { -/* - TMenuItem* mi = dynamic_cast(Sender); - if (mi){ - if (mi->Tag==0){ - psDeviceFlags.set (rsEnvironment,TRUE); - g_pGamePersistent->Environment().SetWeather(mi->Caption.c_str()); - EPrefs->sWeather = mi->Caption.c_str(); - mi->Checked = !mi->Checked; - }else if (mi->Tag==-1){ - psDeviceFlags.set (rsEnvironment,FALSE); - g_pGamePersistent->Environment().SetWeather(0); - EPrefs->sWeather = ""; - mi->Checked = !mi->Checked; - }else if (mi->Tag==-2){ - Engine.ReloadSettings(); - g_pGamePersistent->Environment().ED_Reload(); - }else if (mi->Tag==-3){ - TProperties* P = TProperties::CreateModalForm("Weather properties"); - CEnvironment& env = g_pGamePersistent->Environment(); - PropItemVec items; - float ft=env.ed_from_time,tt=env.ed_to_time,sp=env.fTimeFactor; - PHelper().CreateTime (items,"From Time", &ft); - PHelper().CreateTime (items,"To Time", &tt); - PHelper().CreateFloat (items,"Speed", &sp, 1.f,10000.f,1.f,1); - - P->AssignItems (items); - if (mrOk==P->ShowPropertiesModal()){ - env.ed_from_time = ft; - env.ed_to_time = tt; - env.fTimeFactor = sp; + /* + TMenuItem* mi = dynamic_cast(Sender); + if (mi){ + if (mi->Tag==0){ + psDeviceFlags.set (rsEnvironment,TRUE); + g_pGamePersistent->Environment().SetWeather(mi->Caption.c_str()); + EPrefs->sWeather = mi->Caption.c_str(); + mi->Checked = !mi->Checked; + }else if (mi->Tag==-1){ + psDeviceFlags.set (rsEnvironment,FALSE); + g_pGamePersistent->Environment().SetWeather(0); + EPrefs->sWeather = ""; + mi->Checked = !mi->Checked; + }else if (mi->Tag==-2){ + Engine.ReloadSettings(); + g_pGamePersistent->Environment().ED_Reload(); + }else if (mi->Tag==-3){ + TProperties* P = TProperties::CreateModalForm("Weather properties"); + CEnvironment& env = g_pGamePersistent->Environment(); + PropItemVec items; + float ft=env.ed_from_time,tt=env.ed_to_time,sp=env.fTimeFactor; + PHelper().CreateTime (items,"From Time", &ft); + PHelper().CreateTime (items,"To Time", &tt); + PHelper().CreateFloat (items,"Speed", &sp, 1.f,10000.f,1.f,1); + + P->AssignItems (items); + if (mrOk==P->ShowPropertiesModal()){ + env.ed_from_time = ft; + env.ed_to_time = tt; + env.fTimeFactor = sp; + } + TProperties::DestroyForm(P); } - TProperties::DestroyForm(P); } - } -*/ + */ } + //--------------------------------------------------------------------------- void TfraBottomBar::RedrawBar() { - SPBItem* pbi = UI->ProgressLast(); - if (pbi){ - AnsiString txt; - float p,m; - pbi->GetInfo(txt,p,m); + SPBItem *pbi = UI->ProgressLast(); + if (pbi) + { + AnsiString txt; + float p, m; + pbi->GetInfo(txt, p, m); // status line - if (paStatus->Caption!=txt){ - paStatus->Caption = txt; - paStatus->Repaint (); + if (paStatus->Caption!=txt) + { + paStatus->Caption = txt; + paStatus->Repaint(); } // progress - int val = fis_zero(m)?0:(int)((p/m)*100); - if (val!=cgProgress->Progress){ - cgProgress->Progress = val; - cgProgress->Repaint (); + int val = fis_zero(m) ? 0 : (int)((p/m)*100); + if (val!=cgProgress->Progress) + { + cgProgress->Progress = val; + cgProgress->Repaint(); } - if (false==cgProgress->Visible) - cgProgress->Visible = true; - }else{ - if (cgProgress->Visible){ + if (false==cgProgress->Visible) + cgProgress->Visible = true; + } + else + { + if (cgProgress->Visible) + { // status line - paStatus->Caption = ""; - paStatus->Repaint (); - // progress - cgProgress->Visible = false; - cgProgress->Progress = 0; + paStatus->Caption = ""; + paStatus->Repaint(); + // progress + cgProgress->Visible = false; + cgProgress->Progress = 0; } } } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroAssignClick(TObject *Sender) { - ExecCommand(COMMAND_ASSIGN_MACRO,((TMenuItem*)Sender)->Tag,0); + ExecCommand(COMMAND_ASSIGN_MACRO, ((TMenuItem*)Sender)->Tag, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroClearClick(TObject *Sender) { - ExecCommand(COMMAND_ASSIGN_MACRO,((TMenuItem*)Sender)->Tag,xr_string("")); + ExecCommand(COMMAND_ASSIGN_MACRO, ((TMenuItem*)Sender)->Tag, xr_string("")); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroExecuteClick(TObject *Sender) { - ExecCommand(COMMAND_RUN_MACRO,((TMenuItem*)Sender)->Tag,0); + ExecCommand(COMMAND_RUN_MACRO, ((TMenuItem*)Sender)->Tag, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroLogCommandsClick(TObject *Sender) { - ExecCommand(COMMAND_LOG_COMMANDS,((TMenuItem*)Sender)->Checked,0); + ExecCommand(COMMAND_LOG_COMMANDS, ((TMenuItem*)Sender)->Checked, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroEditCommandListClick(TObject *Sender) { - ExecCommand(COMMAND_EDIT_COMMAND_LIST); + ExecCommand(COMMAND_EDIT_COMMAND_LIST); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebMacroMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - SECommand* CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; VERIFY(CMD); + SECommand *CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; + VERIFY(CMD); // fill macroses - pmMacro->Items->Clear(); - TMenuItem* mi; - for (u32 k=0; ksub_commands.size(); ++k){ - SESubCommand* SUB = CMD->sub_commands[k]; - BOOL bValid = !xr_string(SUB->p0).empty(); - mi = xr_new((TComponent*)0); - mi->Caption = AnsiString().sprintf("%d: %s",k+1,bValid?xr_string(SUB->p0).c_str():""); - TMenuItem* e = xr_new((TComponent*)0); - e->Caption = "Execute"; - e->OnClick = MacroExecuteClick; - e->Enabled = bValid; - e->Tag = k; - e->ShortCut = SUB->shortcut.hotkey; - TMenuItem* a = xr_new((TComponent*)0); - a->Caption = "Assign"; - a->OnClick = MacroAssignClick; - a->Tag = k; - TMenuItem* c = xr_new((TComponent*)0); - c->Caption = "Clear"; - c->OnClick = MacroClearClick; - c->Tag = k; - mi->Add (e); - mi->Add (a); - mi->Add (c); + pmMacro->Items->Clear(); + TMenuItem *mi; + for (u32 k = 0; ksub_commands.size(); ++k) + { + SESubCommand *SUB = CMD->sub_commands[k]; + BOOL bValid = !xr_string(SUB->p0).empty(); + mi = xr_new((TComponent*)0); + mi->Caption = AnsiString().sprintf("%d: %s", k+1, bValid ? xr_string(SUB->p0).c_str() : ""); + TMenuItem *e = xr_new((TComponent*)0); + e->Caption = "Execute"; + e->OnClick = MacroExecuteClick; + e->Enabled = bValid; + e->Tag = k; + e->ShortCut = SUB->shortcut.hotkey; + TMenuItem *a = xr_new((TComponent*)0); + a->Caption = "Assign"; + a->OnClick = MacroAssignClick; + a->Tag = k; + TMenuItem *c = xr_new((TComponent*)0); + c->Caption = "Clear"; + c->OnClick = MacroClearClick; + c->Tag = k; + mi->Add(e); + mi->Add(a); + mi->Add(c); pmMacro->Items->Add(mi); } - mi = xr_new((TComponent*)0); - mi->Caption = "-"; + mi = xr_new((TComponent*)0); + mi->Caption = "-"; pmMacro->Items->Add(mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Edit Command List..."; - mi->OnClick = MacroEditCommandListClick; + mi = xr_new((TComponent*)0); + mi->Caption = "Edit Command List..."; + mi->OnClick = MacroEditCommandListClick; pmMacro->Items->Add(mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Log Commands"; - mi->AutoCheck = true; - mi->Checked = AllowLogCommands(); - mi->OnClick = MacroLogCommandsClick; + mi = xr_new((TComponent*)0); + mi->Caption = "Log Commands"; + mi->AutoCheck = true; + mi->Checked = AllowLogCommands(); + mi->OnClick = MacroLogCommandsClick; pmMacro->Items->Add(mi); - // popup menu + // popup menu POINT pt; - GetCursorPos (&pt); - pmMacro->Popup (pt.x,pt.y); - TExtBtn* btn = dynamic_cast(Sender); VERIFY(btn); btn->MouseManualUp(); + GetCursorPos(&pt); + pmMacro->Popup(pt.x, pt.y); + TExtBtn *btn = dynamic_cast(Sender); + VERIFY(btn); + btn->MouseManualUp(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ParticleEditor/BottomBar.h b/src/editors/ParticleEditor/BottomBar.h index b1b47889d30..439b19ec7ac 100644 --- a/src/editors/ParticleEditor/BottomBar.h +++ b/src/editors/ParticleEditor/BottomBar.h @@ -14,87 +14,95 @@ #include "CGAUGES.h" #include #include + //--------------------------------------------------------------------------- class ECORE_API TfraBottomBar : public TFrame { -__published: // IDE-managed Components - TFormStorage *fsStorage; - TMxPopupMenu *pmOptions; + __published: // IDE-managed Components + TFormStorage*fsStorage; + TMxPopupMenu *pmOptions; TMenuItem *Quality1; - TMenuItem *N25; - TMenuItem *N50; - TMenuItem *N75; - TMenuItem *N100; - TMenuItem *N125; - TMenuItem *N150; - TMenuItem *N200; + TMenuItem *N25; + TMenuItem *N50; + TMenuItem *N75; + TMenuItem *N100; + TMenuItem *N125; + TMenuItem *N150; + TMenuItem *N200; TMenuItem *N2; TMenuItem *miDrawGrid; - TMenuItem *Render1; - TMenuItem *FillMode1; - TMenuItem *miRenderFillSolid; - TMenuItem *miRenderFillWireframe; - TMenuItem *miRenderFillPoint; - TMenuItem *ShadeMode1; - TMenuItem *miRenderShadeGouraud; - TMenuItem *miRenderShadeFlat; - TMenuItem *miRenderEdgedFaces; - TMenuItem *miRenderHWTransform; - TMenuItem *miRenderLinearFilter; - TMenuItem *miRenderWithTextures; - TMenuItem *N7; - TMenuItem *N8; - TMenuItem *miLightScene; - TMenuItem *miFog; - TMenuItem *miRealTime; + TMenuItem *Render1; + TMenuItem *FillMode1; + TMenuItem *miRenderFillSolid; + TMenuItem *miRenderFillWireframe; + TMenuItem *miRenderFillPoint; + TMenuItem *ShadeMode1; + TMenuItem *miRenderShadeGouraud; + TMenuItem *miRenderShadeFlat; + TMenuItem *miRenderEdgedFaces; + TMenuItem *miRenderHWTransform; + TMenuItem *miRenderLinearFilter; + TMenuItem *miRenderWithTextures; + TMenuItem *N7; + TMenuItem *N8; + TMenuItem *miLightScene; + TMenuItem *miFog; + TMenuItem *miRealTime; TMenuItem *N1; - TPanel *paBottomBar; - TPanel *paInfo; - TPanel *paStatusBar; - TPanel *paTools; - TExtBtn *ebOptions; - TExtBtn *ebLog; - TExtBtn *ebStat; - TExtBtn *ebStop; - TPanel *paStatusLabel; - TPanel *paStatus; - TCGauge *cgProgress; - TPanel *paSel; - TPanel *paGridSquareSize; - TPanel *paUICursor; - TPanel *paCamera; - TMenuItem *miDrawSafeRect; - TMenuItem *miMuteSounds; - TMenuItem *N5; - TMenuItem *miWeather; - TMenuItem *miWeatherNone; - TMenuItem *N6; - TExtBtn *ebMacro; - TMxPopupMenu *pmMacro; + TPanel *paBottomBar; + TPanel *paInfo; + TPanel *paStatusBar; + TPanel *paTools; + TExtBtn *ebOptions; + TExtBtn *ebLog; + TExtBtn *ebStat; + TExtBtn *ebStop; + TPanel *paStatusLabel; + TPanel *paStatus; + TCGauge *cgProgress; + TPanel *paSel; + TPanel *paGridSquareSize; + TPanel *paUICursor; + TPanel *paCamera; + TMenuItem *miDrawSafeRect; + TMenuItem *miMuteSounds; + TMenuItem *N5; + TMenuItem *miWeather; + TMenuItem *miWeatherNone; + TMenuItem *N6; + TExtBtn *ebMacro; + TMxPopupMenu *pmMacro; void __fastcall ClickOptionsMenuItem(TObject *Sender); void __fastcall QualityClick(TObject *Sender); void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall ebLogClick(TObject *Sender); - void __fastcall ebStopClick(TObject *Sender); - void __fastcall ebStatClick(TObject *Sender); - void __fastcall ebOptionsMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall pmOptionsPopup(TObject *Sender); - void __fastcall miWeatherClick(TObject *Sender); - void __fastcall ebMacroMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); -private: // User declarations - void __fastcall MacroAssignClick(TObject *Sender); - void __fastcall MacroClearClick(TObject *Sender); - void __fastcall MacroExecuteClick(TObject *Sender); - void __fastcall MacroLogCommandsClick(TObject *Sender); - void __fastcall MacroEditCommandListClick(TObject *Sender); -public: // User declarations - __fastcall TfraBottomBar(TComponent* Owner); - void RefreshBar(){;} + void __fastcall ebLogClick(TObject *Sender); + void __fastcall ebStopClick(TObject *Sender); + void __fastcall ebStatClick(TObject *Sender); + void __fastcall ebOptionsMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall pmOptionsPopup(TObject *Sender); + void __fastcall miWeatherClick(TObject *Sender); + void __fastcall ebMacroMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); +private: // User declarations + void __fastcall MacroAssignClick(TObject *Sender); + void __fastcall MacroClearClick(TObject *Sender); + void __fastcall MacroExecuteClick(TObject *Sender); + void __fastcall MacroLogCommandsClick(TObject *Sender); + void __fastcall MacroEditCommandListClick(TObject *Sender); +public: // User declarations + __fastcall TfraBottomBar(TComponent *Owner); + + void RefreshBar() + { + ; + } + void RedrawBar(); }; + //--------------------------------------------------------------------------- -extern PACKAGE TfraBottomBar *fraBottomBar; +extern PACKAGE TfraBottomBar * fraBottomBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ParticleEditor/ItemPropFormUnit.cpp b/src/editors/ParticleEditor/ItemPropFormUnit.cpp index dff451fd099..7391ac60bd0 100644 --- a/src/editors/ParticleEditor/ItemPropFormUnit.cpp +++ b/src/editors/ParticleEditor/ItemPropFormUnit.cpp @@ -9,21 +9,25 @@ #pragma link "mxPlacemnt" #pragma resource "*.dfm" TfmItemProp *fmItemProp; + //--------------------------------------------------------------------------- -__fastcall TfmItemProp::TfmItemProp(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfmItemProp::TfmItemProp(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TfmItemProp::FormCloseQuery(TObject *Sender, - bool &CanClose) + bool &CanClose) { - CanClose = false; + CanClose = false; } + //--------------------------------------------------------------------------- void __fastcall TfmItemProp::FormClose(TObject *Sender, - TCloseAction &Action) + TCloseAction &Action) { - Action = caMinimize; + Action = caMinimize; } + //--------------------------------------------------------------------------- + + diff --git a/src/editors/ParticleEditor/ItemPropFormUnit.h b/src/editors/ParticleEditor/ItemPropFormUnit.h index efd14acc474..442e032d9b6 100644 --- a/src/editors/ParticleEditor/ItemPropFormUnit.h +++ b/src/editors/ParticleEditor/ItemPropFormUnit.h @@ -8,18 +8,21 @@ #include #include #include "mxPlacemnt.hpp" + //--------------------------------------------------------------------------- class TfmItemProp : public TForm { -__published: // IDE-managed Components - TFormStorage *fsStorage; - void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); - void __fastcall FormClose(TObject *Sender, TCloseAction &Action); -private: // User declarations -public: // User declarations - __fastcall TfmItemProp(TComponent* Owner); + __published: // IDE-managed Components + TFormStorage*fsStorage; + void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); + void __fastcall FormClose(TObject *Sender, TCloseAction &Action); +private: // User declarations +public: // User declarations + __fastcall TfmItemProp(TComponent *Owner); }; + //--------------------------------------------------------------------------- extern TfmItemProp *fmItemProp; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ParticleEditor/LeftBar.cpp b/src/editors/ParticleEditor/LeftBar.cpp index 06cc3a59526..296cb937ac5 100644 --- a/src/editors/ParticleEditor/LeftBar.cpp +++ b/src/editors/ParticleEditor/LeftBar.cpp @@ -6,7 +6,7 @@ #include "UI_ParticleMain.h" #include "main.h" #include "xr_trims.h" -#include "../xrEProps/FolderLib.h" +#include "editors/xrEProps/FolderLib.h" #include "UI_ParticleTools.h" //--------------------------------------------------------------------------- #pragma package(smart_init) @@ -16,94 +16,114 @@ #pragma link "ElTree" #pragma link "ElXPThemedControl" #pragma link "ElTreeAdvEdit" -#pragma link "ElPgCtl" +#pragma link "ElPgCtl" #pragma link "MXCtrls" #pragma link "ElTree" #pragma resource "*.dfm" TfraLeftBar *fraLeftBar; #define MIN_PANEL_HEIGHT 15 + //--------------------------------------------------------------------------- -__fastcall TfraLeftBar::TfraLeftBar(TComponent* Owner) - : TFrame(Owner) +__fastcall TfraLeftBar::TfraLeftBar(TComponent *Owner) + : TFrame(Owner) { - DEFINE_INI(fsStorage); + DEFINE_INI(fsStorage); frmMain->paLeftBar->Width = paLeftBar->Width+2; frmMain->sbToolsMin->Left = paLeftBar->Width-frmMain->sbToolsMin->Width-3; } + //--------------------------------------------------------------------------- -void UpdatePanel(TPanel* p){ - if (p){ - for (int j=0; jControlCount; j++){ - TExtBtn* btn = dynamic_cast(p->Controls[j]); - if (btn) btn->UpdateMouseInControl(); +void UpdatePanel(TPanel *p) +{ + if (p) + { + for (int j = 0; jControlCount; j++) + { + TExtBtn *btn = dynamic_cast(p->Controls[j]); + if (btn) + btn->UpdateMouseInControl(); } } } + //--------------------------------------------------------------------------- void TfraLeftBar::OnTimer() { - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- void TfraLeftBar::UpdateBar() { int i; - for (i=0; iComponentCount; i++){ - TComponent* temp = fraLeftBar->Components[i]; - if (dynamic_cast(temp) != NULL) + for (i = 0; iComponentCount; i++) + { + TComponent *temp = fraLeftBar->Components[i]; + if (dynamic_cast(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } } + //--------------------------------------------------------------------------- void TfraLeftBar::MinimizeAllFrames() { - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(paLeftBar->Controls[j]); - if (pa) PanelMinimize(pa); + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(paLeftBar->Controls[j]); + if (pa) + PanelMinimize(pa); } - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- void TfraLeftBar::MaximizeAllFrames() { - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(paLeftBar->Controls[j]); - if (pa) PanelMaximize(pa); + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(paLeftBar->Controls[j]); + if (pa) + PanelMaximize(pa); } - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSaveClick(TObject *Sender) { - ExecCommand( COMMAND_SAVE ); + ExecCommand(COMMAND_SAVE); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebReloadClick(TObject *Sender) { -//. - ExecCommand( COMMAND_LOAD ); + //. + ExecCommand(COMMAND_LOAD); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Validate1Click(TObject *Sender) { - ExecCommand( COMMAND_VALIDATE ); + ExecCommand(COMMAND_VALIDATE); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebRefreshTexturesClick(TObject *Sender) { - ExecCommand( COMMAND_REFRESH_TEXTURES ); + ExecCommand(COMMAND_REFRESH_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::PanelMimimizeClick(TObject *Sender) @@ -111,6 +131,7 @@ void __fastcall TfraLeftBar::PanelMimimizeClick(TObject *Sender) ::PanelMinMaxClick(Sender); UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::PanelMaximizeClick(TObject *Sender) @@ -118,163 +139,185 @@ void __fastcall TfraLeftBar::PanelMaximizeClick(TObject *Sender) ::PanelMaximizeClick(Sender); UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebEditorPreferencesClick(TObject *Sender) { - ExecCommand(COMMAND_EDITOR_PREF); + ExecCommand(COMMAND_EDITOR_PREF); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSceneCommandsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmPreviewObject,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmPreviewObject, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebImageCommandsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmImages,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmImages, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSoundCommandsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmSounds,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmSounds, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::PreviewClick(TObject *Sender) { - ExecCommand( COMMAND_SELECT_PREVIEW_OBJ, dynamic_cast(Sender)->Tag ); + ExecCommand(COMMAND_SELECT_PREVIEW_OBJ, dynamic_cast(Sender)->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebEngineRemoveClick(TObject *Sender) { - PTools->RemoveCurrent(); + PTools->RemoveCurrent(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebParticleCloneClick(TObject *Sender) { - PTools->CloneCurrent(); + PTools->CloneCurrent(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebPECreateClick(TObject *Sender) { PTools->AppendPE(0); - PTools->Modified(); + PTools->Modified(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebPGCreateClick(TObject *Sender) { PTools->AppendPG(0); - PTools->Modified(); + PTools->Modified(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ImageEditor1Click(TObject *Sender) { - ExecCommand( COMMAND_IMAGE_EDITOR ); + ExecCommand(COMMAND_IMAGE_EDITOR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Refresh1Click(TObject *Sender) { - ExecCommand( COMMAND_REFRESH_TEXTURES ); + ExecCommand(COMMAND_REFRESH_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Checknewtextures1Click(TObject *Sender) { - ExecCommand( COMMAND_CHECK_TEXTURES ); + ExecCommand(COMMAND_CHECK_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebFileMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmEngineShadersFile,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmEngineShadersFile, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebCreateMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmCreateMenu,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmCreateMenu, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::fsStorageRestorePlacement(TObject *Sender) { PTools->m_ItemProps->RestoreParams(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::fsStorageSavePlacement(TObject *Sender) { PTools->m_ItemProps->SaveParams(fsStorage); } + //--------------------------------------------------------------------------- - + void __fastcall TfraLeftBar::MenuItem3Click(TObject *Sender) { - ExecCommand( COMMAND_SOUND_EDITOR ); + ExecCommand(COMMAND_SOUND_EDITOR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MenuItem5Click(TObject *Sender) { - ExecCommand( COMMAND_SYNC_SOUNDS ); + ExecCommand(COMMAND_SYNC_SOUNDS); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Preferneces1Click(TObject *Sender) { - ExecCommand( COMMAND_EDIT_PREVIEW_PROPS ); + ExecCommand(COMMAND_EDIT_PREVIEW_PROPS); } -//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- void __fastcall TfraLeftBar::refLBClick(TObject *Sender) { - ExecCommand( COMMAND_JUMP_TO_ITEM ); + ExecCommand(COMMAND_JUMP_TO_ITEM); } -//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Savexr1Click(TObject *Sender) { - ExecCommand( COMMAND_SAVE_XR ); - + ExecCommand(COMMAND_SAVE_XR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Loadxr1Click(TObject *Sender) { - ExecCommand( COMMAND_LOAD_XR ); + ExecCommand(COMMAND_LOAD_XR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Compact1Click(TObject *Sender) { - ExecCommand( COMMAND_COMPACT_PARTICLES ); + ExecCommand(COMMAND_COMPACT_PARTICLES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Groupfromcurrenteffect1Click(TObject *Sender) { - ExecCommand( COMMAND_CREATE_GROUP_FROM_SELECTED ); + ExecCommand(COMMAND_CREATE_GROUP_FROM_SELECTED); } + //--------------------------------------------------------------------------- diff --git a/src/editors/ParticleEditor/LeftBar.h b/src/editors/ParticleEditor/LeftBar.h index 1ffe33a017c..acac14bb117 100644 --- a/src/editors/ParticleEditor/LeftBar.h +++ b/src/editors/ParticleEditor/LeftBar.h @@ -24,108 +24,114 @@ //--------------------------------------------------------------------------- class TfraLeftBar : public TFrame { -__published: // IDE-managed Components - TPanel *paLeftBar; + __published: // IDE-managed Components + TPanel*paLeftBar; TPanel *paScene; - TFormStorage *fsStorage; - TLabel *APHeadLabel2; - TExtBtn *ebSceneMin; - TExtBtn *ebSceneCommands; - TExtBtn *ebPreferences; - TMxPopupMenu *pmEngineShadersFile; - TMenuItem *Save1; - TMenuItem *Reload1; - TMxPopupMenu *pmPreviewObject; - TMenuItem *Custom1; - TMenuItem *N2; - TExtBtn *ebImageCommands; - TMxPopupMenu *pmImages; - TMenuItem *ImageEditor1; - TMenuItem *N6; - TMenuItem *Refresh1; - TMenuItem *Checknewtextures1; - TMxPopupMenu *pmCreateMenu; - TMenuItem *MenuItem2; - TMenuItem *N3; - TMenuItem *N4; - TMenuItem *N5; - TMenuItem *N7; - TImageList *ilModeIcons; - TMenuItem *ParticleGroup1; - TMxPopupMenu *pmSounds; - TMenuItem *MenuItem1; - TMenuItem *MenuItem3; - TMenuItem *MenuItem4; - TMenuItem *MenuItem5; - TExtBtn *ebSoundCommands; - TMenuItem *N1; - TMenuItem *Preferneces1; - TMenuItem *Validate1; - TPanel *paParticles; - TLabel *Label1; - TPanel *paPSList; - TBevel *Bevel1; - TPanel *Panel1; - TExtBtn *ebEngineRemove; - TExtBtn *ebEngineClone; - TExtBtn *ebFile; - TExtBtn *ebCreate; - TPanel *paItemList; - TPanel *Panel2; - TSplitter *Splitter1; - TLabel *refName; - TListBox *refLB; - TMenuItem *Savexr1; - TMenuItem *Loadxr1; - TMenuItem *N8; - TMenuItem *Compact1; - TMenuItem *N9; - TMenuItem *Groupfromcurrenteffect1; + TFormStorage *fsStorage; + TLabel *APHeadLabel2; + TExtBtn *ebSceneMin; + TExtBtn *ebSceneCommands; + TExtBtn *ebPreferences; + TMxPopupMenu *pmEngineShadersFile; + TMenuItem *Save1; + TMenuItem *Reload1; + TMxPopupMenu *pmPreviewObject; + TMenuItem *Custom1; + TMenuItem *N2; + TExtBtn *ebImageCommands; + TMxPopupMenu *pmImages; + TMenuItem *ImageEditor1; + TMenuItem *N6; + TMenuItem *Refresh1; + TMenuItem *Checknewtextures1; + TMxPopupMenu *pmCreateMenu; + TMenuItem *MenuItem2; + TMenuItem *N3; + TMenuItem *N4; + TMenuItem *N5; + TMenuItem *N7; + TImageList *ilModeIcons; + TMenuItem *ParticleGroup1; + TMxPopupMenu *pmSounds; + TMenuItem *MenuItem1; + TMenuItem *MenuItem3; + TMenuItem *MenuItem4; + TMenuItem *MenuItem5; + TExtBtn *ebSoundCommands; + TMenuItem *N1; + TMenuItem *Preferneces1; + TMenuItem *Validate1; + TPanel *paParticles; + TLabel *Label1; + TPanel *paPSList; + TBevel *Bevel1; + TPanel *Panel1; + TExtBtn *ebEngineRemove; + TExtBtn *ebEngineClone; + TExtBtn *ebFile; + TExtBtn *ebCreate; + TPanel *paItemList; + TPanel *Panel2; + TSplitter *Splitter1; + TLabel *refName; + TListBox *refLB; + TMenuItem *Savexr1; + TMenuItem *Loadxr1; + TMenuItem *N8; + TMenuItem *Compact1; + TMenuItem *N9; + TMenuItem *Groupfromcurrenteffect1; void __fastcall ebSaveClick(TObject *Sender); void __fastcall ebReloadClick(TObject *Sender); void __fastcall PanelMimimizeClick(TObject *Sender); void __fastcall PanelMaximizeClick(TObject *Sender); void __fastcall ebEditorPreferencesClick(TObject *Sender); void __fastcall ebRefreshTexturesClick(TObject *Sender); - void __fastcall ebSceneCommandsMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y); - void __fastcall PreviewClick(TObject *Sender); - void __fastcall ebParticleCloneClick(TObject *Sender); - void __fastcall ebImageCommandsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y); - void __fastcall ImageEditor1Click(TObject *Sender); - void __fastcall Refresh1Click(TObject *Sender); - void __fastcall Checknewtextures1Click(TObject *Sender); - void __fastcall ebPECreateClick(TObject *Sender); - void __fastcall ebFileMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y); - void __fastcall ebCreateMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); - void __fastcall ebPGCreateClick(TObject *Sender); - void __fastcall ebEngineRemoveClick(TObject *Sender); - void __fastcall ebSoundCommandsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y); - void __fastcall MenuItem3Click(TObject *Sender); - void __fastcall MenuItem5Click(TObject *Sender); - void __fastcall Preferneces1Click(TObject *Sender); - void __fastcall Validate1Click(TObject *Sender); - void __fastcall refLBClick(TObject *Sender); - void __fastcall Savexr1Click(TObject *Sender); - void __fastcall Loadxr1Click(TObject *Sender); - void __fastcall Compact1Click(TObject *Sender); - void __fastcall Groupfromcurrenteffect1Click(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TfraLeftBar (TComponent* Owner); - void UpdateBar (); - void OnTimer (); - void ClearParticleList(); - void MinimizeAllFrames(); - void MaximizeAllFrames(); - void RefreshBar (){;} + void __fastcall ebSceneCommandsMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y); + void __fastcall PreviewClick(TObject *Sender); + void __fastcall ebParticleCloneClick(TObject *Sender); + void __fastcall ebImageCommandsMouseDown(TObject *Sender, + TMouseButton Button, TShiftState Shift, int X, int Y); + void __fastcall ImageEditor1Click(TObject *Sender); + void __fastcall Refresh1Click(TObject *Sender); + void __fastcall Checknewtextures1Click(TObject *Sender); + void __fastcall ebPECreateClick(TObject *Sender); + void __fastcall ebFileMouseDown(TObject *Sender, + TMouseButton Button, TShiftState Shift, int X, int Y); + void __fastcall ebCreateMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); + void __fastcall ebPGCreateClick(TObject *Sender); + void __fastcall ebEngineRemoveClick(TObject *Sender); + void __fastcall ebSoundCommandsMouseDown(TObject *Sender, + TMouseButton Button, TShiftState Shift, int X, int Y); + void __fastcall MenuItem3Click(TObject *Sender); + void __fastcall MenuItem5Click(TObject *Sender); + void __fastcall Preferneces1Click(TObject *Sender); + void __fastcall Validate1Click(TObject *Sender); + void __fastcall refLBClick(TObject *Sender); + void __fastcall Savexr1Click(TObject *Sender); + void __fastcall Loadxr1Click(TObject *Sender); + void __fastcall Compact1Click(TObject *Sender); + void __fastcall Groupfromcurrenteffect1Click(TObject *Sender); +private: // User declarations +public: // User declarations + __fastcall TfraLeftBar(TComponent *Owner); + void UpdateBar(); + void OnTimer(); + void ClearParticleList(); + void MinimizeAllFrames(); + void MaximizeAllFrames(); + + void RefreshBar() + { + ; + } }; + //--------------------------------------------------------------------------- -extern PACKAGE TfraLeftBar *fraLeftBar; +extern PACKAGE TfraLeftBar * fraLeftBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ParticleEditor/ObjectAnimator.cpp b/src/editors/ParticleEditor/ObjectAnimator.cpp index a79d7b7579f..f6d033ce07f 100644 --- a/src/editors/ParticleEditor/ObjectAnimator.cpp +++ b/src/editors/ParticleEditor/ObjectAnimator.cpp @@ -2,110 +2,137 @@ #pragma hdrstop #include "ObjectAnimator.h" -#include "motion.h" - -bool motion_sort_pred (COMotion* a, COMotion* b) { return a->namename;} -bool motion_find_pred (COMotion* a, shared_str b) { return a->namenamename; +} + +bool motion_find_pred(COMotion *a, shared_str b) +{ + return a->name (); - if (M->LoadMotion(full_path)) m_Motions.push_back(M); - else FATAL("ERROR: Can't load motion. Incorrect file version."); - }else if (0==xr_strcmp(ext,".anms")){ - IReader* F = FS.r_open(full_path); - u32 dwMCnt = F->r_u32(); VERIFY(dwMCnt); - for (u32 i=0; i (); - bool bRes = M->Load(*F); - if (!bRes) FATAL("ERROR: Can't load motion. Incorrect file version."); + string_path full_path; + if (!FS.exist(full_path, "$level$", fname)) + if (!FS.exist(full_path, "$game_anims$", fname)) + Debug.fatal(DEBUG_INFO, "Can't find motion file '%s'.", fname); + + LPCSTR ext = strext(full_path); + if (ext) + { + Clear(); + if (0==xr_strcmp(ext, ".anm")) + { + COMotion *M = xr_new(); + if (M->LoadMotion(full_path)) + m_Motions.push_back(M); + else + FATAL("ERROR: Can't load motion. Incorrect file version."); + } + else if (0==xr_strcmp(ext, ".anms")) + { + IReader *F = FS.r_open(full_path); + u32 dwMCnt = F->r_u32(); + VERIFY(dwMCnt); + for (u32 i = 0; i(); + bool bRes = M->Load(*F); + if (!bRes) + FATAL("ERROR: Can't load motion. Incorrect file version."); m_Motions.push_back(M); } - FS.r_close (F); + FS.r_close(F); } - std::sort(m_Motions.begin(),m_Motions.end(),motion_sort_pred); + std::sort(m_Motions.begin(), m_Motions.end(), motion_sort_pred); } } -void CObjectAnimator::Load(const char * name) +void CObjectAnimator::Load(const char *name) { - m_Name = name; - LoadMotions (name); - SetActiveMotion (0); + m_Name = name; + LoadMotions(name); + SetActiveMotion(0); } void CObjectAnimator::Update(float dt) { - if (m_Current){ - Fvector R,P; - m_Current->_Evaluate(m_MParam.Frame(),P,R); - m_MParam.Update (dt,m_Speed,bLoop); - m_XFORM.setXYZi (R.x,R.y,R.z); + if (m_Current) + { + Fvector R, P; + m_Current->_Evaluate(m_MParam.Frame(), P, R); + m_MParam.Update(dt, m_Speed, bLoop); + m_XFORM.setXYZi(R.x, R.y, R.z); m_XFORM.translate_over(P); - } + } } -COMotion* CObjectAnimator::Play(bool loop, LPCSTR name) +COMotion *CObjectAnimator::Play(bool loop, LPCSTR name) { - if (name&&name[0]){ - MotionIt it = std::lower_bound(m_Motions.begin(),m_Motions.end(),name,motion_find_pred); - if ((it!=m_Motions.end())&&(0==xr_strcmp((*it)->Name(),name))){ - bLoop = loop; + if (name&&name[0]) + { + MotionIt it = std::lower_bound(m_Motions.begin(), m_Motions.end(), name, motion_find_pred); + if ((it!=m_Motions.end())&&(0==xr_strcmp((*it)->Name(), name))) + { + bLoop = loop; SetActiveMotion(*it); - m_MParam.Play (); - return *it; - }else{ - Debug.fatal (DEBUG_INFO,"OBJ ANIM::Cycle '%s' not found.",name); + m_MParam.Play(); + return *it; + } + else + { + Debug.fatal(DEBUG_INFO, "OBJ ANIM::Cycle '%s' not found.", name); return NULL; } - }else{ - if (!m_Motions.empty()){ - bLoop = loop; + } + else + { + if (!m_Motions.empty()) + { + bLoop = loop; SetActiveMotion(m_Motions.front()); - m_MParam.Play (); - return m_Motions.front(); - }else{ - Debug.fatal (DEBUG_INFO,"OBJ ANIM::Cycle '%s' not found.",name); + m_MParam.Play(); + return m_Motions.front(); + } + else + { + Debug.fatal(DEBUG_INFO, "OBJ ANIM::Cycle '%s' not found.", name); return NULL; } } @@ -113,27 +140,28 @@ COMotion* CObjectAnimator::Play(bool loop, LPCSTR name) void CObjectAnimator::Stop() { - SetActiveMotion (0); - m_MParam.Stop (); + SetActiveMotion(0); + m_MParam.Stop(); } -float CObjectAnimator::GetLength () +float CObjectAnimator::GetLength() { - if(!m_Current) return 0.0f; - float res = m_Current->Length()/m_Current->FPS(); - return res; + if (!m_Current) + return 0.0f; + float res = m_Current->Length()/m_Current->FPS(); + return res; } #ifdef _EDITOR -#include "d3dutils.h" +#include "D3DUtils.h" #include "envelope.h" static FvectorVec path_points; void CObjectAnimator::DrawPath() { - // motion path +// motion path if (m_Current){ float fps = m_Current->FPS(); float min_t = (float)m_Current->FrameStart()/fps; @@ -161,3 +189,4 @@ void CObjectAnimator::DrawPath() } } #endif + diff --git a/src/editors/ParticleEditor/ObjectAnimator.h b/src/editors/ParticleEditor/ObjectAnimator.h index 30cff774267..b599c107786 100644 --- a/src/editors/ParticleEditor/ObjectAnimator.h +++ b/src/editors/ParticleEditor/ObjectAnimator.h @@ -8,40 +8,63 @@ class ENGINE_API CObjectAnimator { private: - DEFINE_VECTOR (COMotion*,MotionVec,MotionIt); + DEFINE_VECTOR(COMotion *, MotionVec, MotionIt); protected: - bool bLoop; - - shared_str m_Name; - - Fmatrix m_XFORM; - SAnimParams m_MParam; - MotionVec m_Motions; - float m_Speed; - - COMotion* m_Current; - void LoadMotions (LPCSTR fname); - void SetActiveMotion (COMotion* mot); - COMotion* FindMotionByName(LPCSTR name); + bool bLoop; + + shared_str m_Name; + + Fmatrix m_XFORM; + SAnimParams m_MParam; + MotionVec m_Motions; + float m_Speed; + + COMotion *m_Current; + void LoadMotions(LPCSTR fname); + void SetActiveMotion(COMotion *mot); + COMotion *FindMotionByName(LPCSTR name); public: - CObjectAnimator (); - virtual ~CObjectAnimator(); - - void Clear (); - void Load (LPCSTR name); - IC LPCSTR Name (){return *m_Name;} - float& Speed (){return m_Speed;} - - COMotion* Play (bool bLoop, LPCSTR name=0); - void Pause (bool val){return m_MParam.Pause(val);} - void Stop (); - IC BOOL IsPlaying (){return m_MParam.bPlay;} - - IC const Fmatrix& XFORM (){return m_XFORM;} - float GetLength (); - // Update - void Update (float dt); - void DrawPath (); + CObjectAnimator(); + virtual ~CObjectAnimator(); + + void Clear(); + void Load(LPCSTR name); + + IC LPCSTR Name() + { + return *m_Name; + } + + float &Speed() + { + return m_Speed; + } + + COMotion *Play(bool bLoop, LPCSTR name = 0); + + void Pause(bool val) + { + return m_MParam.Pause(val); + } + + void Stop(); + + IC BOOL IsPlaying() + { + return m_MParam.bPlay; + } + + IC const Fmatrix&XFORM() + { + return m_XFORM; + } + + float GetLength(); + // Update + void Update(float dt); + void DrawPath(); }; #endif //ObjectAnimatorH + + diff --git a/src/editors/ParticleEditor/PSLibraryEditor.cpp b/src/editors/ParticleEditor/PSLibraryEditor.cpp index 8cf3a119a83..f95480b4e62 100644 --- a/src/editors/ParticleEditor/PSLibraryEditor.cpp +++ b/src/editors/ParticleEditor/PSLibraryEditor.cpp @@ -1,106 +1,114 @@ #include "stdafx.h" #pragma hdrstop -#include "..\..\Layers\xrRender\PSLibrary.h" -#include "..\..\Layers\xrRender\ParticleEffect.h" -#include "..\..\Layers\xrRender\ParticleGroup.h" -#include "..\ECore\Editor\ui_main.h" +#include "Layers/xrRender/PSLibrary.h" +#include "Layers/xrRender/ParticleEffect.h" +#include "Layers/xrRender/ParticleGroup.h" +#include "editors/ECore/Editor/ui_main.h" + //------------------------------------------------------------------------------ -void __fastcall CPSLibrary::FindByName(LPCSTR new_name, bool& res) +void __fastcall CPSLibrary::FindByName(LPCSTR new_name, bool &res) { - res = (FindPED(new_name)||FindPGD(new_name)); + res = (FindPED(new_name)||FindPGD(new_name)); } -PS::CPEDef* CPSLibrary::AppendPED(PS::CPEDef* src) +PS::CPEDef *CPSLibrary::AppendPED(PS::CPEDef *src) { - m_PEDs.push_back(xr_new()); + m_PEDs.push_back(xr_new()); #ifdef _PARTICLE_EDITOR if (src) m_PEDs.back()->Copy(*src); #endif return m_PEDs.back(); } + //------------------------------------------------------------------------------ -PS::CPGDef* CPSLibrary::AppendPGD(PS::CPGDef* src) +PS::CPGDef *CPSLibrary::AppendPGD(PS::CPGDef *src) { - m_PGDs.push_back(xr_new()); - if (src) m_PGDs.back()->Clone(src); + m_PGDs.push_back(xr_new()); + if (src) + m_PGDs.back()->Clone(src); return m_PGDs.back(); } + //------------------------------------------------------------------------------ bool CPSLibrary::Save() { - xr_string temp_fn; - if (EFS.GetSaveName ( "$game_data$", temp_fn)) - { - return Save (temp_fn.c_str()); - }else - return false; + xr_string temp_fn; + if (EFS.GetSaveName("$game_data$", temp_fn)) + { + return Save(temp_fn.c_str()); + } + else + return false; } + //------------------------------------------------------------------------------ - bool CPSLibrary::Save2() +bool CPSLibrary::Save2() { - FS.dir_delete("$game_particles$","",TRUE); - string_path fn; - SPBItem* pb = UI->ProgressStart(m_PEDs.size()+m_PGDs.size(),"Saving particles..."); - for (PS::PEDIt it=m_PEDs.begin(); it!=m_PEDs.end(); ++it) + FS.dir_delete("$game_particles$", "", TRUE); + string_path fn; + SPBItem *pb = UI->ProgressStart(m_PEDs.size()+m_PGDs.size(), "Saving particles..."); + for (PS::PEDIt it = m_PEDs.begin(); it!=m_PEDs.end(); ++it) { - pb->Inc (); - PS::CPEDef* pe = (*it); - FS.update_path (fn, "$game_particles$", pe->m_Name.c_str()); - strcat (fn,".pe"); - CInifile ini(fn,FALSE,FALSE,FALSE); - pe->Save2 (ini); - ini.save_as (fn); + pb->Inc(); + PS::CPEDef *pe = (*it); + FS.update_path(fn, "$game_particles$", pe->m_Name.c_str()); + strcat(fn, ".pe"); + CInifile ini(fn, FALSE, FALSE, FALSE); + pe->Save2(ini); + ini.save_as(fn); } - for (PS::PGDIt g_it=m_PGDs.begin(); g_it!=m_PGDs.end(); ++g_it) + for (PS::PGDIt g_it = m_PGDs.begin(); g_it!=m_PGDs.end(); ++g_it) { - pb->Inc (); - PS::CPGDef* pg = (*g_it); - FS.update_path (fn, "$game_particles$", pg->m_Name.c_str()); - strcat (fn,".pg"); - CInifile ini(fn,FALSE,FALSE,FALSE); - pg->Save2 (ini); - ini.save_as (fn); + pb->Inc(); + PS::CPGDef *pg = (*g_it); + FS.update_path(fn, "$game_particles$", pg->m_Name.c_str()); + strcat(fn, ".pg"); + CInifile ini(fn, FALSE, FALSE, FALSE); + pg->Save2(ini); + ini.save_as(fn); } - UI->ProgressEnd (pb); + UI->ProgressEnd(pb); return true; } -bool CPSLibrary::Save(const char* nm) +bool CPSLibrary::Save(const char *nm) { CMemoryWriter F; - F.open_chunk (PS_CHUNK_VERSION); - F.w_u16 (PS_VERSION); - F.close_chunk (); + F.open_chunk(PS_CHUNK_VERSION); + F.w_u16(PS_VERSION); + F.close_chunk(); - F.open_chunk (PS_CHUNK_SECONDGEN); + F.open_chunk(PS_CHUNK_SECONDGEN); u32 chunk_id = 0; - for (PS::PEDIt it=m_PEDs.begin(); it!=m_PEDs.end(); ++it,++chunk_id) + for (PS::PEDIt it = m_PEDs.begin(); it!=m_PEDs.end(); ++it,++chunk_id) { - F.open_chunk (chunk_id); - (*it)->Save (F); - F.close_chunk (); + F.open_chunk(chunk_id); + (*it)->Save(F); + F.close_chunk(); } - F.close_chunk (); + F.close_chunk(); + - - F.open_chunk (PS_CHUNK_THIRDGEN); + F.open_chunk(PS_CHUNK_THIRDGEN); chunk_id = 0; - for (PS::PGDIt g_it=m_PGDs.begin(); g_it!=m_PGDs.end(); ++g_it,++chunk_id) + for (PS::PGDIt g_it = m_PGDs.begin(); g_it!=m_PGDs.end(); ++g_it,++chunk_id) { - F.open_chunk (chunk_id); - (*g_it)->Save (F); - F.close_chunk (); + F.open_chunk(chunk_id); + (*g_it)->Save(F); + F.close_chunk(); } - F.close_chunk (); + F.close_chunk(); return F.save_to(nm); } + //------------------------------------------------------------------------------ + diff --git a/src/editors/ParticleEditor/ParticleEditor.cpp b/src/editors/ParticleEditor/ParticleEditor.cpp index a38d2c485ac..722a91990dc 100644 --- a/src/editors/ParticleEditor/ParticleEditor.cpp +++ b/src/editors/ParticleEditor/ParticleEditor.cpp @@ -1,68 +1,69 @@ #include "stdafx.h" #pragma hdrstop -#include "splash.h" +#include "Splash.h" #include "LogForm.h" #include "main.h" #include "ui_particlemain.h" #include "UI_ParticleTools.h" //--------------------------------------------------------------------------- -USEFORM("Splash.cpp", frmSplash); -USEFORM("main.cpp", frmMain); -USEFORM("BottomBar.cpp", fraBottomBar); /* TFrame: File Type */ -USEFORM("TopBar.cpp", fraTopBar); /* TFrame: File Type */ -USEFORM("LeftBar.cpp", fraLeftBar); /* TFrame: File Type */ -USEFORM("ItemPropFormUnit.cpp", fmItemProp); +USEFORM ("Splash.cpp", frmSplash); +USEFORM ("main.cpp", frmMain); +USEFORM ("BottomBar.cpp", fraBottomBar); /* TFrame: File Type */ +USEFORM ("TopBar.cpp", fraTopBar); /* TFrame: File Type */ +USEFORM ("LeftBar.cpp", fraLeftBar); /* TFrame: File Type */ +USEFORM ("ItemPropFormUnit.cpp", fmItemProp); + //--------------------------------------------------------------------------- WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int) { -// try{ - if (!Application->Handle){ - Application->CreateHandle (); - Application->Icon->Handle = LoadIcon(MainInstance, "MAINICON"); - Application->Title = "Loading..."; - } - frmSplash = xr_new((TComponent*)0); - frmSplash->Show (); - frmSplash->Repaint (); - frmSplash->SetStatus ("Core initializing..."); + // try{ + if (!Application->Handle) + { + Application->CreateHandle(); + Application->Icon->Handle = LoadIcon(MainInstance, "MAINICON"); + Application->Title = "Loading..."; + } + frmSplash = xr_new((TComponent*)0); + frmSplash->Show(); + frmSplash->Repaint(); + frmSplash->SetStatus("Core initializing..."); + + Core._initialize("particle", ELogCallback); - Core._initialize ("particle",ELogCallback); + Application->Initialize(); - Application->Initialize (); - - frmSplash->SetStatus ("Loading..."); + frmSplash->SetStatus("Loading..."); -// startup create - Tools = xr_new(); - UI = xr_new(); - UI->RegisterCommands (); + // startup create + Tools = xr_new(); + UI = xr_new(); + UI->RegisterCommands(); - Application->Title = UI->EditorDesc(); - TfrmLog::CreateLog (); + Application->Title = UI->EditorDesc(); + TfrmLog::CreateLog(); - Application->CreateForm(__classid(TfrmMain), &frmMain); - frmMain->SetHInst (hInst); + Application->CreateForm(__classid(TfrmMain), &frmMain); + frmMain->SetHInst(hInst); - xr_delete(frmSplash); + xr_delete(frmSplash); - Application->Run (); + Application->Run(); - TfrmLog::DestroyLog (); + TfrmLog::DestroyLog(); - UI->ClearCommands (); - xr_delete (Tools); - xr_delete (UI); + UI->ClearCommands(); + xr_delete(Tools); + xr_delete(UI); - Core._destroy (); -// } -// catch (Exception &exception) -// { -// Application->ShowException(&exception); -// } + Core._destroy(); + // } + // catch (Exception &exception) + // { + // Application->ShowException(&exception); + // } return 0; } -//--------------------------------------------------------------------------- - +//--------------------------------------------------------------------------- diff --git a/src/editors/ParticleEditor/ParticleEffectActionsImpl.cpp b/src/editors/ParticleEditor/ParticleEffectActionsImpl.cpp index 8d460296295..4756888308b 100644 --- a/src/editors/ParticleEditor/ParticleEffectActionsImpl.cpp +++ b/src/editors/ParticleEditor/ParticleEffectActionsImpl.cpp @@ -3,708 +3,766 @@ #pragma hdrstop #include "ParticleEffectActions.h" -#include "../xrEProps/folderlib.h" -#include "../../xrServerEntities/PropertiesListHelper.h" -#include "../../xrParticles/particle_actions_collection.h" -#include "d3dutils.h" +#include "editors/xrEProps/FolderLib.h" +#include "xrServerEntities/PropertiesListHelper.h" +#include "xrParticles/particle_actions_collection.h" +#include "D3DUtils.h" -using namespace PAPI; +using namespace PAPI; #define PARTICLE_ACTION_VERSION 0x0001 //--------------------------------------------------------------------------- -xr_token2 actions_token [ ]={ - { "Avoid", "Steer particles away from a domain of space.", PAAvoidID }, - { "Bounce", "Bounce particles off a domain of space.", PABounceID }, - { "Copy VertexB", "Set the secondary position from current position.", PACopyVertexBID }, - { "Damping", "Simulate air by slowing down particle velocities.", PADampingID }, - { "Explosion", "An Explosion.", PAExplosionID }, - { "Follow", "Accelerate toward the next particle in the group.", PAFollowID }, - { "Gravitate", "Accelerate each particle toward each other particle.", PAGravitateID }, - { "Gravity", "Accelerate particles in the given direction.", PAGravityID }, - { "Jet", "Accelerate particles that are near the center of the jet.", PAJetID }, - { "Kill Old", "Remove old particles.", PAKillOldID }, - { "Match Velocity", "Modify each particle’s velocity to be similar to that of its neighbors.", PAMatchVelocityID }, - { "Move", "Move particle positions based on velocities.", PAMoveID }, - { "Orbit Line", "Accelerate toward the closest point on the given line.", PAOrbitLineID }, - { "Orbit Point", "Accelerate toward the given center point.", PAOrbitPointID }, - { "Random Accel", "Accelerate particles in random directions.", PARandomAccelID }, - { "Random Displace", "Immediately replace position with a position from the domain.", PARandomDisplaceID }, - { "Random Velocity", "Immediately replace velocity with a velocity from the domain.", PARandomVelocityID }, - { "Restore", "Over time, restore particles to their secondary positions.", PARestoreID }, - { "Scatter", "Scatter particles from center.", PAScatterID }, - { "Sink", "Kill particles with positions on wrong side of the specified domain.", PASinkID }, - { "Sink Velocity", "Kill particles with velocities on wrong side of the specified domain.", PASinkVelocityID }, - { "Source", "Add particles in the specified domain.", PASourceID }, - { "Speed Limit", "Clamp each particle’s speed to the given min and max.", PASpeedLimitID }, - { "Target Color", "Change color of all particles toward the specified color.", PATargetColorID }, - { "Target Size", "Change sizes of all particles toward the specified size.", PATargetSizeID }, - { "Target Rotate", "Change rotate of all particles toward the specified rotation.", PATargetRotateID }, - { "Target Velocity", "Change velocity of all particles toward the specified velocity.", PATargetVelocityID }, - { "Vortex", "Swirl particles around a vortex.", PAVortexID }, - { "Turbulence", "A Turbulence.", PATurbulenceID }, - { 0, 0 } +xr_token2 actions_token [ ] = { + {"Avoid", "Steer particles away from a domain of space.", PAAvoidID}, + {"Bounce", "Bounce particles off a domain of space.", PABounceID}, + {"Copy VertexB", "Set the secondary position from current position.", PACopyVertexBID}, + {"Damping", "Simulate air by slowing down particle velocities.", PADampingID}, + {"Explosion", "An Explosion.", PAExplosionID}, + {"Follow", "Accelerate toward the next particle in the group.", PAFollowID}, + {"Gravitate", "Accelerate each particle toward each other particle.", PAGravitateID}, + {"Gravity", "Accelerate particles in the given direction.", PAGravityID}, + {"Jet", "Accelerate particles that are near the center of the jet.", PAJetID}, + {"Kill Old", "Remove old particles.", PAKillOldID}, + {"Match Velocity", "Modify each particle’s velocity to be similar to that of its neighbors.", PAMatchVelocityID}, + {"Move", "Move particle positions based on velocities.", PAMoveID}, + {"Orbit Line", "Accelerate toward the closest point on the given line.", PAOrbitLineID}, + {"Orbit Point", "Accelerate toward the given center point.", PAOrbitPointID}, + {"Random Accel", "Accelerate particles in random directions.", PARandomAccelID}, + {"Random Displace", "Immediately replace position with a position from the domain.", PARandomDisplaceID}, + {"Random Velocity", "Immediately replace velocity with a velocity from the domain.", PARandomVelocityID}, + {"Restore", "Over time, restore particles to their secondary positions.", PARestoreID}, + {"Scatter", "Scatter particles from center.", PAScatterID}, + {"Sink", "Kill particles with positions on wrong side of the specified domain.", PASinkID}, + {"Sink Velocity", "Kill particles with velocities on wrong side of the specified domain.", PASinkVelocityID}, + {"Source", "Add particles in the specified domain.", PASourceID}, + {"Speed Limit", "Clamp each particle’s speed to the given min and max.", PASpeedLimitID}, + {"Target Color", "Change color of all particles toward the specified color.", PATargetColorID}, + {"Target Size", "Change sizes of all particles toward the specified size.", PATargetSizeID}, + {"Target Rotate", "Change rotate of all particles toward the specified rotation.", PATargetRotateID}, + {"Target Velocity", "Change velocity of all particles toward the specified velocity.", PATargetVelocityID}, + {"Vortex", "Swirl particles around a vortex.", PAVortexID}, + {"Turbulence", "A Turbulence.", PATurbulenceID}, + {0, 0} }; -EParticleAction* pCreateEActionImpl(PAPI::PActionEnum type) -{ - EParticleAction* pa = 0; - switch(type){ - case PAPI::PAAvoidID: pa = xr_new (); break; - case PAPI::PABounceID: pa = xr_new (); break; - case PAPI::PACopyVertexBID: pa = xr_new (); break; - case PAPI::PADampingID: pa = xr_new (); break; - case PAPI::PAExplosionID: pa = xr_new (); break; - case PAPI::PAFollowID: pa = xr_new (); break; - case PAPI::PAGravitateID: pa = xr_new (); break; - case PAPI::PAGravityID: pa = xr_new (); break; - case PAPI::PAJetID: pa = xr_new (); break; - case PAPI::PAKillOldID: pa = xr_new (); break; - case PAPI::PAMatchVelocityID: pa = xr_new (); break; - case PAPI::PAMoveID: pa = xr_new (); break; - case PAPI::PAOrbitLineID: pa = xr_new (); break; - case PAPI::PAOrbitPointID: pa = xr_new (); break; - case PAPI::PARandomAccelID: pa = xr_new (); break; - case PAPI::PARandomDisplaceID: pa = xr_new (); break; - case PAPI::PARandomVelocityID: pa = xr_new (); break; - case PAPI::PARestoreID: pa = xr_new (); break; - case PAPI::PAScatterID: pa = xr_new (); break; - case PAPI::PASinkID: pa = xr_new (); break; - case PAPI::PASinkVelocityID: pa = xr_new (); break; - case PAPI::PASourceID: pa = xr_new (); break; - case PAPI::PASpeedLimitID: pa = xr_new (); break; - case PAPI::PATargetColorID: pa = xr_new (); break; - case PAPI::PATargetSizeID: pa = xr_new (); break; - case PAPI::PATargetRotateID: pa = xr_new (); break; - case PAPI::PATargetRotateDID: pa = xr_new (); break; - case PAPI::PATargetVelocityID: pa = xr_new (); break; - case PAPI::PATargetVelocityDID: pa = xr_new (); break; - case PAPI::PAVortexID: pa = xr_new (); break; - case PAPI::PATurbulenceID: pa = xr_new (); break; - default: NODEFAULT; +EParticleAction *pCreateEActionImpl(PAPI::PActionEnum type) +{ + EParticleAction *pa = 0; + switch (type) + { + case PAPI::PAAvoidID: pa = xr_new(); + break; + case PAPI::PABounceID: pa = xr_new(); + break; + case PAPI::PACopyVertexBID: pa = xr_new(); + break; + case PAPI::PADampingID: pa = xr_new(); + break; + case PAPI::PAExplosionID: pa = xr_new(); + break; + case PAPI::PAFollowID: pa = xr_new(); + break; + case PAPI::PAGravitateID: pa = xr_new(); + break; + case PAPI::PAGravityID: pa = xr_new(); + break; + case PAPI::PAJetID: pa = xr_new(); + break; + case PAPI::PAKillOldID: pa = xr_new(); + break; + case PAPI::PAMatchVelocityID: pa = xr_new(); + break; + case PAPI::PAMoveID: pa = xr_new(); + break; + case PAPI::PAOrbitLineID: pa = xr_new(); + break; + case PAPI::PAOrbitPointID: pa = xr_new(); + break; + case PAPI::PARandomAccelID: pa = xr_new(); + break; + case PAPI::PARandomDisplaceID: pa = xr_new(); + break; + case PAPI::PARandomVelocityID: pa = xr_new(); + break; + case PAPI::PARestoreID: pa = xr_new(); + break; + case PAPI::PAScatterID: pa = xr_new(); + break; + case PAPI::PASinkID: pa = xr_new(); + break; + case PAPI::PASinkVelocityID: pa = xr_new(); + break; + case PAPI::PASourceID: pa = xr_new(); + break; + case PAPI::PASpeedLimitID: pa = xr_new(); + break; + case PAPI::PATargetColorID: pa = xr_new(); + break; + case PAPI::PATargetSizeID: pa = xr_new(); + break; + case PAPI::PATargetRotateID: pa = xr_new(); + break; + case PAPI::PATargetRotateDID: pa = xr_new(); + break; + case PAPI::PATargetVelocityID: pa = xr_new(); + break; + case PAPI::PATargetVelocityDID: pa = xr_new(); + break; + case PAPI::PAVortexID: pa = xr_new(); + break; + case PAPI::PATurbulenceID: pa = xr_new(); + break; + default: NODEFAULT; } - pa->type = type; - return pa; + pa->type = type; + return pa; } + //--------------------------------------------------------------------------- -void EParticleAction::Render (const Fmatrix& parent) -{ - for (PDomainMapIt it=domains.begin(); it!=domains.end(); it++) - it->second.Render (it->second.clr,parent); -} -void EParticleAction::Load (IReader& F) -{ - u32 vers = F.r_u32(); - R_ASSERT (vers==PARTICLE_ACTION_VERSION); - F.r_stringZ (actionName); - flags.assign (F.r_u32()); - for (PFloatMapIt f_it=floats.begin(); f_it!=floats.end(); f_it++) f_it->second.val = F.r_float(); - for (PVectorMapIt v_it=vectors.begin(); v_it!=vectors.end(); v_it++) F.r_fvector3(v_it->second.val); - for (PDomainMapIt d_it=domains.begin(); d_it!=domains.end(); d_it++) d_it->second.Load (F); - for (PBoolMapIt b_it=bools.begin(); b_it!=bools.end(); b_it++) b_it->second.val = F.r_u8(); - for (PIntMapIt i_it=ints.begin(); i_it!=ints.end(); i_it++) i_it->second.val = F.r_s32(); -} - -void EParticleAction::Load2(CInifile& ini, const shared_str& sect) -{ - u32 ver = ini.r_u32(sect.c_str(), "version"); - actionName = ini.r_string(sect.c_str(), "action_name"); - flags.assign (ini.r_u32(sect.c_str(), "flags")); - - u32 counter = 0; - string256 buff; - for (PFloatMapIt f_it=floats.begin(); f_it!=floats.end(); ++f_it,++counter) - { - xr_sprintf (buff, sizeof(buff),"flt_%04d",counter); - if(ver==0) +void EParticleAction::Render(const Fmatrix &parent) +{ + for (PDomainMapIt it = domains.begin(); it!=domains.end(); it++) + it->second.Render(it->second.clr, parent); +} + +void EParticleAction::Load(IReader &F) +{ + u32 vers = F.r_u32(); + R_ASSERT(vers==PARTICLE_ACTION_VERSION); + F.r_stringZ(actionName); + flags.assign(F.r_u32()); + for (PFloatMapIt f_it = floats.begin(); f_it!=floats.end(); f_it++) + f_it->second.val = F.r_float(); + for (PVectorMapIt v_it = vectors.begin(); v_it!=vectors.end(); v_it++) + F.r_fvector3(v_it->second.val); + for (PDomainMapIt d_it = domains.begin(); d_it!=domains.end(); d_it++) + d_it->second.Load(F); + for (PBoolMapIt b_it = bools.begin(); b_it!=bools.end(); b_it++) + b_it->second.val = F.r_u8(); + for (PIntMapIt i_it = ints.begin(); i_it!=ints.end(); i_it++) + i_it->second.val = F.r_s32(); +} + +void EParticleAction::Load2(CInifile &ini, const shared_str §) +{ + u32 ver = ini.r_u32(sect.c_str(), "version"); + actionName = ini.r_string(sect.c_str(), "action_name"); + flags.assign(ini.r_u32(sect.c_str(), "flags")); + + u32 counter = 0; + string256 buff; + for (PFloatMapIt f_it = floats.begin(); f_it!=floats.end(); ++f_it,++counter) + { + xr_sprintf(buff, sizeof(buff), "flt_%04d", counter); + if (ver==0) { - if(ini.line_exist(sect.c_str(), buff)) - f_it->second.val = ini.r_float(sect.c_str(), buff); - }else - f_it->second.val = ini.r_float(sect.c_str(), buff); - } - counter=0; - for (PVectorMapIt v_it=vectors.begin(); v_it!=vectors.end(); ++v_it,++counter) - { - xr_sprintf (buff, sizeof(buff),"vec_%04d",counter); - v_it->second.val = ini.r_fvector3 (sect.c_str(), buff); - } - - counter=0; - for (PDomainMapIt d_it=domains.begin(); d_it!=domains.end(); ++d_it,++counter) - { - xr_sprintf (buff, sizeof(buff),"domain_%s_%04d", sect.c_str(), counter); - d_it->second.Load2 (ini, buff); - } - - counter=0; - for (PBoolMapIt b_it=bools.begin(); b_it!=bools.end(); ++b_it,++counter) - { - xr_sprintf (buff, sizeof(buff),"bool_%04d",counter); - b_it->second.val = ini.r_bool (sect.c_str(), buff); - } - - counter=0; - for (PIntMapIt i_it=ints.begin(); i_it!=ints.end(); ++i_it,++counter) - { - xr_sprintf (buff, sizeof(buff),"int_%04d",counter); - i_it->second.val = ini.r_s32 (sect.c_str(), buff); - } - -} -void EParticleAction::Save (IWriter& F) -{ - F.w_u32 (PARTICLE_ACTION_VERSION); - F.w_stringZ (actionName); - F.w_u32 (flags.get()); - for (PFloatMapIt f_it=floats.begin(); f_it!=floats.end(); f_it++) F.w_float (f_it->second.val); - for (PVectorMapIt v_it=vectors.begin(); v_it!=vectors.end(); v_it++) F.w_fvector3(v_it->second.val); - for (PDomainMapIt d_it=domains.begin(); d_it!=domains.end(); d_it++) d_it->second.Save (F); - for (PBoolMapIt b_it=bools.begin(); b_it!=bools.end(); b_it++) F.w_u8 ((u8)b_it->second.val); - for (PIntMapIt i_it=ints.begin(); i_it!=ints.end(); i_it++) F.w_s32 (i_it->second.val); -} - -void EParticleAction::Save2(CInifile& ini, const shared_str& sect) -{ - ini.w_u32 (sect.c_str(), "version", PARTICLE_ACTION_VERSION); - ini.w_string (sect.c_str(), "action_name", actionName.c_str()); - ini.w_u32 (sect.c_str(), "flags", flags.get()); - - u32 counter = 0; - string256 buff; - for (PFloatMapIt f_it=floats.begin(); f_it!=floats.end(); ++f_it,++counter) - { - xr_sprintf (buff, sizeof(buff),"flt_%04d",counter); - ini.w_float (sect.c_str(), buff, f_it->second.val); - } - counter=0; - for (PVectorMapIt v_it=vectors.begin(); v_it!=vectors.end(); ++v_it,++counter) - { - xr_sprintf (buff, sizeof(buff),"vec_%04d",counter); - ini.w_fvector3 (sect.c_str(), buff, v_it->second.val); - } - - counter=0; - for (PDomainMapIt d_it=domains.begin(); d_it!=domains.end(); ++d_it,++counter) - { - xr_sprintf (buff, sizeof(buff),"domain_%s_%04d", sect.c_str(), counter); - d_it->second.Save2(ini, buff); - } - - counter=0; - for (PBoolMapIt b_it=bools.begin(); b_it!=bools.end(); ++b_it,++counter) - { - xr_sprintf (buff, sizeof(buff),"bool_%04d",counter); - ini.w_bool (sect.c_str(), buff, b_it->second.val); - } - - counter=0; - for (PIntMapIt i_it=ints.begin(); i_it!=ints.end(); ++i_it,++counter) - { - xr_sprintf (buff, sizeof(buff),"int_%04d",counter); - ini.w_s32 (sect.c_str(), buff, i_it->second.val); - } -} - -void EParticleAction::FillProp (PropItemVec& items, LPCSTR pref, u32 clr) -{ - PropValue* V=0; - for (OrderVecIt o_it=orders.begin(); o_it!=orders.end(); o_it++) + if (ini.line_exist(sect.c_str(), buff)) + f_it->second.val = ini.r_float(sect.c_str(), buff); + } + else + f_it->second.val = ini.r_float(sect.c_str(), buff); + } + counter = 0; + for (PVectorMapIt v_it = vectors.begin(); v_it!=vectors.end(); ++v_it,++counter) { - LPCSTR name = o_it->name.c_str(); - switch (o_it->type){ - case tpDomain: - domains[o_it->name].FillProp(items, PrepareKey(pref,name).c_str(),clr); - break; - case tpVector:{ - PVector& vect = vectors[o_it->name]; - switch (vect.type){ - case PVector::vNum: - V=PHelper().CreateVector (items, PrepareKey(pref,name).c_str(), &vect.val, vect.mn, vect.mx, 0.001f, 3); - break; - case PVector::vAngle: - V=PHelper().CreateAngle3 (items, PrepareKey(pref,name).c_str(), &vect.val, vect.mn, vect.mx, 0.001f, 3); - break; - case PVector::vColor: - V=PHelper().CreateVColor (items, PrepareKey(pref,name).c_str(), &vect.val); - break; + xr_sprintf(buff, sizeof(buff), "vec_%04d", counter); + v_it->second.val = ini.r_fvector3(sect.c_str(), buff); + } + + counter = 0; + for (PDomainMapIt d_it = domains.begin(); d_it!=domains.end(); ++d_it,++counter) + { + xr_sprintf(buff, sizeof(buff), "domain_%s_%04d", sect.c_str(), counter); + d_it->second.Load2(ini, buff); + } + + counter = 0; + for (PBoolMapIt b_it = bools.begin(); b_it!=bools.end(); ++b_it,++counter) + { + xr_sprintf(buff, sizeof(buff), "bool_%04d", counter); + b_it->second.val = ini.r_bool(sect.c_str(), buff); + } + + counter = 0; + for (PIntMapIt i_it = ints.begin(); i_it!=ints.end(); ++i_it,++counter) + { + xr_sprintf(buff, sizeof(buff), "int_%04d", counter); + i_it->second.val = ini.r_s32(sect.c_str(), buff); + } +} + +void EParticleAction::Save(IWriter &F) +{ + F.w_u32(PARTICLE_ACTION_VERSION); + F.w_stringZ(actionName); + F.w_u32(flags.get()); + for (PFloatMapIt f_it = floats.begin(); f_it!=floats.end(); f_it++) + F.w_float(f_it->second.val); + for (PVectorMapIt v_it = vectors.begin(); v_it!=vectors.end(); v_it++) + F.w_fvector3(v_it->second.val); + for (PDomainMapIt d_it = domains.begin(); d_it!=domains.end(); d_it++) + d_it->second.Save(F); + for (PBoolMapIt b_it = bools.begin(); b_it!=bools.end(); b_it++) + F.w_u8((u8)b_it->second.val); + for (PIntMapIt i_it = ints.begin(); i_it!=ints.end(); i_it++) + F.w_s32(i_it->second.val); +} + +void EParticleAction::Save2(CInifile &ini, const shared_str §) +{ + ini.w_u32(sect.c_str(), "version", PARTICLE_ACTION_VERSION); + ini.w_string(sect.c_str(), "action_name", actionName.c_str()); + ini.w_u32(sect.c_str(), "flags", flags.get()); + + u32 counter = 0; + string256 buff; + for (PFloatMapIt f_it = floats.begin(); f_it!=floats.end(); ++f_it,++counter) + { + xr_sprintf(buff, sizeof(buff), "flt_%04d", counter); + ini.w_float(sect.c_str(), buff, f_it->second.val); + } + counter = 0; + for (PVectorMapIt v_it = vectors.begin(); v_it!=vectors.end(); ++v_it,++counter) + { + xr_sprintf(buff, sizeof(buff), "vec_%04d", counter); + ini.w_fvector3(sect.c_str(), buff, v_it->second.val); + } + + counter = 0; + for (PDomainMapIt d_it = domains.begin(); d_it!=domains.end(); ++d_it,++counter) + { + xr_sprintf(buff, sizeof(buff), "domain_%s_%04d", sect.c_str(), counter); + d_it->second.Save2(ini, buff); + } + + counter = 0; + for (PBoolMapIt b_it = bools.begin(); b_it!=bools.end(); ++b_it,++counter) + { + xr_sprintf(buff, sizeof(buff), "bool_%04d", counter); + ini.w_bool(sect.c_str(), buff, b_it->second.val); + } + + counter = 0; + for (PIntMapIt i_it = ints.begin(); i_it!=ints.end(); ++i_it,++counter) + { + xr_sprintf(buff, sizeof(buff), "int_%04d", counter); + ini.w_s32(sect.c_str(), buff, i_it->second.val); + } +} + +void EParticleAction::FillProp(PropItemVec &items, LPCSTR pref, u32 clr) +{ + PropValue *V = 0; + for (OrderVecIt o_it = orders.begin(); o_it!=orders.end(); o_it++) + { + LPCSTR name = o_it->name.c_str(); + switch (o_it->type) + { + case tpDomain: + domains[o_it->name].FillProp(items, PrepareKey(pref, name).c_str(), clr); + break; + case tpVector: + { + PVector &vect = vectors[o_it->name]; + switch (vect.type) + { + case PVector::vNum: + V = PHelper().CreateVector(items, PrepareKey(pref, name).c_str(), &vect.val, vect.mn, vect.mx, 0.001f, 3); + break; + case PVector::vAngle: + V = PHelper().CreateAngle3(items, PrepareKey(pref, name).c_str(), &vect.val, vect.mn, vect.mx, 0.001f, 3); + break; + case PVector::vColor: + V = PHelper().CreateVColor(items, PrepareKey(pref, name).c_str(), &vect.val); + break; + } } - }break; - case tpFloat:{ - PFloat& flt = floats[o_it->name]; - V=PHelper().CreateFloat (items, PrepareKey(pref,name).c_str(), &flt.val, flt.mn, flt.mx, 0.001f, 3); - }break; - case tpInt:{ - PInt& el = ints[o_it->name]; - V=PHelper().CreateS32 (items, PrepareKey(pref,name).c_str(), &el.val, el.mn, el.mx); - }break; - case tpBool: - V=PHelper().CreateBOOL (items, PrepareKey(pref,name).c_str(), &bools[o_it->name].val); - break; + break; + case tpFloat: + { + PFloat &flt = floats[o_it->name]; + V = PHelper().CreateFloat(items, PrepareKey(pref, name).c_str(), &flt.val, flt.mn, flt.mx, 0.001f, 3); + } + break; + case tpInt: + { + PInt &el = ints[o_it->name]; + V = PHelper().CreateS32(items, PrepareKey(pref, name).c_str(), &el.val, el.mn, el.mx); + } + break; + case tpBool: + V = PHelper().CreateBOOL(items, PrepareKey(pref, name).c_str(), &bools[o_it->name].val); + break; } - if (V) V->Owner()->prop_color = clr; + if (V) + V->Owner()->prop_color = clr; } - V=PHelper().CreateFlag32 (items, PrepareKey(pref,"Draw").c_str(), &flags, flDraw); - V->Owner()->prop_color = clr; - V=PHelper().CreateFlag32 (items, PrepareKey(pref,"Enabled").c_str(), &flags, flEnabled); - V->Owner()->prop_color = clr; + V = PHelper().CreateFlag32(items, PrepareKey(pref, "Draw").c_str(), &flags, flDraw); + V->Owner()->prop_color = clr; + V = PHelper().CreateFlag32(items, PrepareKey(pref, "Enabled").c_str(), &flags, flEnabled); + V->Owner()->prop_color = clr; } -void EParticleAction::appendFloat (LPCSTR name, float v, float mn, float mx) + +void EParticleAction::appendFloat(LPCSTR name, float v, float mn, float mx) { - orders.push_back (SOrder(tpFloat,name)); - floats[name] = PFloat(v,mn,mx); + orders.push_back(SOrder(tpFloat, name)); + floats[name] = PFloat(v, mn, mx); } -void EParticleAction::appendInt (LPCSTR name, int v, int mn, int mx) + +void EParticleAction::appendInt(LPCSTR name, int v, int mn, int mx) { - orders.push_back (SOrder(tpInt,name)); - ints[name] = PInt(v,mn,mx); + orders.push_back(SOrder(tpInt, name)); + ints[name] = PInt(v, mn, mx); } -void EParticleAction::appendVector (LPCSTR name, PVector::EType type, float vx, float vy, float vz, float mn, float mx) + +void EParticleAction::appendVector(LPCSTR name, PVector::EType type, float vx, float vy, float vz, float mn, float mx) { - orders.push_back (SOrder(tpVector,name)); - vectors[name] = PVector(type,Fvector().set(vx,vy,vz),mn,mx); + orders.push_back(SOrder(tpVector, name)); + vectors[name] = PVector(type, Fvector().set(vx, vy, vz), mn, mx); } -void EParticleAction::appendDomain (LPCSTR name, PDomain v) + +void EParticleAction::appendDomain(LPCSTR name, PDomain v) { - orders.push_back (SOrder(tpDomain,name)); - domains[name] = v; + orders.push_back(SOrder(tpDomain, name)); + domains[name] = v; } -void EParticleAction::appendBool (LPCSTR name, BOOL v) +void EParticleAction::appendBool(LPCSTR name, BOOL v) { - orders.push_back (SOrder(tpBool,name)); - bools[name] = PBool(v); + orders.push_back(SOrder(tpBool, name)); + bools[name] = PBool(v); } //--------------------------------------------------------------------------- -void pAvoid(IWriter& F, float magnitude, float epsilon, float look_ahead, pDomain D, BOOL allow_rotate) -{ - PAAvoid S; - S.type = PAAvoidID; +void pAvoid(IWriter &F, float magnitude, float epsilon, float look_ahead, pDomain D, BOOL allow_rotate) +{ + PAAvoid S; + S.type = PAAvoidID; + + S.positionL = D; + S.position = S.positionL; + S.magnitude = magnitude; + S.epsilon = epsilon; + S.look_ahead = look_ahead; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pBounce(IWriter &F, float friction, float resilience, float cutoff, pDomain D, BOOL allow_rotate) +{ + PABounce S; + S.type = PABounceID; + + S.positionL = D; + S.position = S.positionL; + S.oneMinusFriction = 1.0f-friction; + S.resilience = resilience; + S.cutoffSqr = _sqr(cutoff); + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pCopyVertexB(IWriter &F, BOOL copy_pos) +{ + PACopyVertexB S; + S.type = PACopyVertexBID; + + S.copy_pos = copy_pos; + + F.w_u32(S.type); + S.Save(F); +} + +void pDamping(IWriter &F, const Fvector &damping, + float vlow, float vhigh) +{ + PADamping S; + S.type = PADampingID; + + S.damping = pVector(damping.x, damping.y, damping.z); + S.vlowSqr = _sqr(vlow); + S.vhighSqr = _sqr(vhigh); + + F.w_u32(S.type); + S.Save(F); +} + +void pExplosion(IWriter &F, const Fvector ¢er, float velocity, + float magnitude, float stdev, float epsilon, float age, BOOL allow_rotate) +{ + PAExplosion S; + S.type = PAExplosionID; + + S.centerL = pVector(center.x, center.y, center.z); + S.center = S.centerL; + S.velocity = velocity; + S.magnitude = magnitude; + S.stdev = stdev; + S.epsilon = epsilon; + S.age = age; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + if (S.epsilon<0.0f) + S.epsilon = EPS_L; + + F.w_u32(S.type); + S.Save(F); +} + +void pFollow(IWriter &F, float magnitude, float epsilon, float max_radius) +{ + PAFollow S; + S.type = PAFollowID; + + S.magnitude = magnitude; + S.epsilon = epsilon; + S.max_radius = max_radius; + + F.w_u32(S.type); + S.Save(F); +} + +void pGravitate(IWriter &F, float magnitude, float epsilon, float max_radius) +{ + PAGravitate S; + S.type = PAGravitateID; + + S.magnitude = magnitude; + S.epsilon = epsilon; + S.max_radius = max_radius; + + F.w_u32(S.type); + S.Save(F); +} + +void pGravity(IWriter &F, const Fvector &dir, BOOL allow_rotate) +{ + PAGravity S; + S.type = PAGravityID; + + S.directionL = pVector(dir.x, dir.y, dir.z); + S.direction = S.directionL; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pJet(IWriter &F, pDomain acc, const Fvector ¢er, + float magnitude, float epsilon, float max_radius, BOOL allow_rotate) +{ + PAJet S; + S.type = PAJetID; + + S.centerL = pVector(center.x, center.y, center.z); + S.center = S.centerL; + S.accL = acc; + S.acc = S.accL; + S.magnitude = magnitude; + S.epsilon = epsilon; + S.max_radius = max_radius; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pKillOld(IWriter &F, float age_limit, BOOL kill_less_than) +{ + PAKillOld S; + S.type = PAKillOldID; + + S.age_limit = age_limit; + S.kill_less_than = kill_less_than; + + F.w_u32(S.type); + S.Save(F); +} - S.positionL = D; - S.position = S.positionL; - S.magnitude = magnitude; - S.epsilon = epsilon; - S.look_ahead = look_ahead; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); +void pMove(IWriter &F) +{ + PAMove S; + S.type = PAMoveID; + + F.w_u32(S.type); + S.Save(F); +} + +void pMatchVelocity(IWriter &F, float magnitude, float epsilon, float max_radius) +{ + PAMatchVelocity S; + S.type = PAMatchVelocityID; + + S.magnitude = magnitude; + S.epsilon = epsilon; + S.max_radius = max_radius; + + F.w_u32(S.type); + S.Save(F); +} + +void pOrbitLine(IWriter &F, const Fvector &p, const Fvector &axis, + float magnitude, float epsilon, float max_radius, BOOL allow_rotate) +{ + PAOrbitLine S; + S.type = PAOrbitLineID; + + S.pL = pVector(p.x, p.y, p.z); + S.p = S.pL; + S.axisL = pVector(axis.x, axis.y, axis.z); + S.axisL.normalize_safe(); + S.axis = S.axisL; + S.magnitude = magnitude; + S.epsilon = epsilon; + S.max_radius = max_radius; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pOrbitPoint(IWriter &F, const Fvector ¢er, + float magnitude, float epsilon, float max_radius, BOOL allow_rotate) +{ + PAOrbitPoint S; + S.type = PAOrbitPointID; + + S.centerL = pVector(center.x, center.y, center.z); + S.center = S.centerL; + S.magnitude = magnitude; + S.epsilon = epsilon; + S.max_radius = max_radius; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pRandomAccel(IWriter &F, pDomain D, BOOL allow_rotate) +{ + PARandomAccel S; + S.type = PARandomAccelID; + + S.gen_accL = D; + S.gen_acc = S.gen_accL; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pRandomDisplace(IWriter &F, pDomain D, BOOL allow_rotate) +{ + PARandomDisplace S; + S.type = PARandomDisplaceID; + + S.gen_dispL = D; + S.gen_disp = S.gen_dispL; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pRandomVelocity(IWriter &F, pDomain D, BOOL allow_rotate) +{ + PARandomVelocity S; + S.type = PARandomVelocityID; + + S.gen_velL = D; + S.gen_vel = S.gen_velL; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pRestore(IWriter &F, float time_left) +{ + PARestore S; + S.type = PARestoreID; + + S.time_left = time_left; + + F.w_u32(S.type); + S.Save(F); +} + +void pScatter(IWriter &F, const Fvector ¢er, float magnitude, float epsilon, float max_radius, BOOL allow_rotate) +{ + PAScatter S; + S.type = PAScatterID; + + S.centerL = pVector(center.x, center.y, center.z); + S.center = S.centerL; + S.magnitude = magnitude; + S.epsilon = epsilon; + S.max_radius = max_radius; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pSink(IWriter &F, BOOL kill_inside, pDomain D, BOOL allow_rotate) +{ + PASink S; + S.type = PASinkID; + + S.kill_inside = kill_inside; + S.positionL = D; + S.position = S.positionL; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pSinkVelocity(IWriter &F, BOOL kill_inside, pDomain D, BOOL allow_rotate) +{ + PASinkVelocity S; + S.type = PASinkVelocityID; + + S.kill_inside = kill_inside; + S.velocityL = D; + S.velocity = S.velocityL; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pSource(IWriter &F, float particle_rate, pDomain pos, pDomain vel, pDomain rot, pDomain size, BOOL single_size, + pDomain color, float alpha, float age, float age_sigma, float parent_motion, + BOOL allow_rotate) +{ + PASource S; + S.type = PASourceID; + + S.particle_rate = particle_rate; + S.positionL = pos; + S.position = S.positionL; + S.velocityL = vel; + S.velocity = S.velocityL; + S.size = size; + S.rot = rot; + S.color = color; + S.alpha = alpha; + S.age = age; + S.age_sigma = age_sigma; + S.m_Flags.assign((single_size ? PASource::flSingleSize : 0)|PASource::flVertexB_tracks); + S.parent_vel = pVector(0, 0, 0); + S.parent_motion = parent_motion; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); } - -void pBounce(IWriter& F, float friction, float resilience, float cutoff, pDomain D, BOOL allow_rotate) + +void pSpeedLimit(IWriter &F, float min_speed, float max_speed) +{ + PASpeedLimit S; + S.type = PASpeedLimitID; + + S.min_speed = min_speed; + S.max_speed = max_speed; + + F.w_u32(S.type); + S.Save(F); +} + +void pTargetColor(IWriter &F, const Fvector &color, float alpha, float scale, float time_from, float time_to) { - PABounce S; - S.type = PABounceID; - - S.positionL = D; - S.position = S.positionL; - S.oneMinusFriction = 1.0f - friction; - S.resilience = resilience; - S.cutoffSqr = _sqr(cutoff); - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pCopyVertexB(IWriter& F, BOOL copy_pos) -{ - PACopyVertexB S; - S.type = PACopyVertexBID; - - S.copy_pos = copy_pos; - - F.w_u32 (S.type); - S.Save (F); -} - -void pDamping(IWriter& F, const Fvector& damping, - float vlow, float vhigh) -{ - PADamping S; - S.type = PADampingID; - - S.damping = pVector(damping.x, damping.y, damping.z); - S.vlowSqr = _sqr(vlow); - S.vhighSqr = _sqr(vhigh); - - F.w_u32 (S.type); - S.Save (F); -} + PATargetColor S; + S.type = PATargetColorID; -void pExplosion(IWriter& F, const Fvector& center, float velocity, - float magnitude, float stdev, float epsilon, float age, BOOL allow_rotate) + S.color = pVector(color.x, color.y, color.z); + S.alpha = alpha; + S.scale = scale; + S.timeFrom = time_from; + S.timeTo = time_to; + + F.w_u32(S.type); + S.Save(F); +} + +void pTargetSize(IWriter &F, const Fvector &size, const Fvector &scale) { - PAExplosion S; - S.type = PAExplosionID; + PATargetSize S; + S.type = PATargetSizeID; - S.centerL = pVector(center.x, center.y, center.z); - S.center = S.centerL; - S.velocity = velocity; - S.magnitude = magnitude; - S.stdev = stdev; - S.epsilon = epsilon; - S.age = age; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); + S.size = pVector(size.x, size.y, size.z); + S.scale = pVector(scale.x, scale.y, scale.z); - if(S.epsilon < 0.0f) - S.epsilon = EPS_L; - - F.w_u32 (S.type); - S.Save (F); + F.w_u32(S.type); + S.Save(F); } -void pFollow(IWriter& F, float magnitude, float epsilon, float max_radius) -{ - PAFollow S; - S.type = PAFollowID; - - S.magnitude = magnitude; - S.epsilon = epsilon; - S.max_radius = max_radius; - - F.w_u32 (S.type); - S.Save (F); -} - -void pGravitate(IWriter& F, float magnitude, float epsilon, float max_radius) -{ - PAGravitate S; - S.type = PAGravitateID; - - S.magnitude = magnitude; - S.epsilon = epsilon; - S.max_radius = max_radius; - - F.w_u32 (S.type); - S.Save (F); -} - -void pGravity(IWriter& F, const Fvector& dir, BOOL allow_rotate) -{ - PAGravity S; - S.type = PAGravityID; - - S.directionL = pVector(dir.x, dir.y, dir.z); - S.direction = S.directionL; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pJet(IWriter& F, pDomain acc, const Fvector& center, - float magnitude, float epsilon, float max_radius, BOOL allow_rotate) -{ - PAJet S; - S.type = PAJetID; - - S.centerL = pVector(center.x, center.y, center.z); - S.center = S.centerL; - S.accL = acc; - S.acc = S.accL; - S.magnitude = magnitude; - S.epsilon = epsilon; - S.max_radius = max_radius; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pKillOld(IWriter& F, float age_limit, BOOL kill_less_than) -{ - PAKillOld S; - S.type = PAKillOldID; - - S.age_limit = age_limit; - S.kill_less_than = kill_less_than; - - F.w_u32 (S.type); - S.Save (F); -} - -void pMove(IWriter& F) -{ - PAMove S; - S.type = PAMoveID; - - F.w_u32 (S.type); - S.Save (F); -} - -void pMatchVelocity(IWriter& F, float magnitude, float epsilon, float max_radius) -{ - PAMatchVelocity S; - S.type = PAMatchVelocityID; - - S.magnitude = magnitude; - S.epsilon = epsilon; - S.max_radius = max_radius; - - F.w_u32 (S.type); - S.Save (F); -} - -void pOrbitLine(IWriter& F, const Fvector& p, const Fvector& axis, - float magnitude, float epsilon, float max_radius, BOOL allow_rotate) -{ - PAOrbitLine S; - S.type = PAOrbitLineID; - - S.pL = pVector(p.x, p.y, p.z); - S.p = S.pL; - S.axisL = pVector(axis.x, axis.y, axis.z); - S.axisL.normalize_safe(); - S.axis = S.axisL; - S.magnitude = magnitude; - S.epsilon = epsilon; - S.max_radius = max_radius; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pOrbitPoint(IWriter& F, const Fvector& center, - float magnitude, float epsilon, float max_radius, BOOL allow_rotate) -{ - PAOrbitPoint S; - S.type = PAOrbitPointID; - - S.centerL = pVector(center.x, center.y, center.z); - S.center = S.centerL; - S.magnitude = magnitude; - S.epsilon = epsilon; - S.max_radius = max_radius; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pRandomAccel(IWriter& F, pDomain D, BOOL allow_rotate) -{ - PARandomAccel S; - S.type = PARandomAccelID; - - S.gen_accL = D; - S.gen_acc = S.gen_accL; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pRandomDisplace(IWriter& F, pDomain D, BOOL allow_rotate) -{ - PARandomDisplace S; - S.type = PARandomDisplaceID; - - S.gen_dispL = D; - S.gen_disp = S.gen_dispL; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pRandomVelocity(IWriter& F, pDomain D, BOOL allow_rotate) -{ - PARandomVelocity S; - S.type = PARandomVelocityID; - - S.gen_velL = D; - S.gen_vel = S.gen_velL; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pRestore(IWriter& F, float time_left) -{ - PARestore S; - S.type = PARestoreID; - - S.time_left = time_left; - - F.w_u32 (S.type); - S.Save (F); -} - -void pScatter(IWriter& F, const Fvector& center, float magnitude, float epsilon, float max_radius, BOOL allow_rotate) -{ - PAScatter S; - S.type = PAScatterID; - - S.centerL = pVector(center.x, center.y, center.z); - S.center = S.centerL; - S.magnitude = magnitude; - S.epsilon = epsilon; - S.max_radius = max_radius; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pSink(IWriter& F, BOOL kill_inside, pDomain D, BOOL allow_rotate) -{ - PASink S; - S.type = PASinkID; - - S.kill_inside = kill_inside; - S.positionL = D; - S.position = S.positionL; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pSinkVelocity(IWriter& F, BOOL kill_inside, pDomain D, BOOL allow_rotate) -{ - PASinkVelocity S; - S.type = PASinkVelocityID; - - S.kill_inside = kill_inside; - S.velocityL = D; - S.velocity = S.velocityL; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pSource(IWriter& F, float particle_rate, pDomain pos, pDomain vel, pDomain rot, pDomain size, BOOL single_size, - pDomain color, float alpha, float age, float age_sigma, float parent_motion, - BOOL allow_rotate) -{ - PASource S; - S.type = PASourceID; - - S.particle_rate = particle_rate; - S.positionL = pos; - S.position = S.positionL; - S.velocityL = vel; - S.velocity = S.velocityL; - S.size = size; - S.rot = rot; - S.color = color; - S.alpha = alpha; - S.age = age; - S.age_sigma = age_sigma; - S.m_Flags.assign((single_size?PASource::flSingleSize:0)|PASource::flVertexB_tracks); - S.parent_vel = pVector(0,0,0); - S.parent_motion = parent_motion; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pSpeedLimit(IWriter& F, float min_speed, float max_speed) -{ - PASpeedLimit S; - S.type = PASpeedLimitID; - - S.min_speed = min_speed; - S.max_speed = max_speed; - - F.w_u32 (S.type); - S.Save (F); -} - -void pTargetColor(IWriter& F, const Fvector& color, float alpha, float scale, float time_from, float time_to) -{ - PATargetColor S; - S.type = PATargetColorID; - - S.color = pVector(color.x, color.y, color.z); - S.alpha = alpha; - S.scale = scale; - S.timeFrom = time_from; - S.timeTo = time_to; - - F.w_u32 (S.type); - S.Save (F); -} - -void pTargetSize(IWriter& F, const Fvector& size, const Fvector& scale) -{ - PATargetSize S; - S.type = PATargetSizeID; - - S.size = pVector(size.x, size.y, size.z); - S.scale = pVector(scale.x, scale.y, scale.z); - - F.w_u32 (S.type); - S.Save (F); -} - -void pTargetRotate(IWriter& F, const Fvector& rot, float scale) -{ - PATargetRotate S; - S.type = PATargetRotateID; - - S.rot = pVector(rot.x, rot.y, rot.z); - S.scale = scale; - - F.w_u32 (S.type); - S.Save (F); -} - -void pTargetVelocity(IWriter& F, const Fvector& vel, float scale, BOOL allow_rotate) -{ - PATargetVelocity S; - S.type = PATargetVelocityID; - - S.velocityL = pVector(vel.x, vel.y, vel.z); - S.velocity = S.velocityL; - S.scale = scale; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); -} - -void pVortex(IWriter& F, const Fvector& center, const Fvector& axis, - float magnitude, float epsilon, float max_radius, BOOL allow_rotate) -{ - PAVortex S; - S.type = PAVortexID; - - S.centerL = pVector(center.x, center.y, center.z); - S.center = S.centerL; - S.axisL = pVector(axis.x, axis.y, axis.z); - S.axisL.normalize_safe(); - S.axis = S.axisL; - S.magnitude = magnitude; - S.epsilon = epsilon; - S.max_radius = max_radius; - S.m_Flags.set (ParticleAction::ALLOW_ROTATE,allow_rotate); - - F.w_u32 (S.type); - S.Save (F); +void pTargetRotate(IWriter &F, const Fvector &rot, float scale) +{ + PATargetRotate S; + S.type = PATargetRotateID; + + S.rot = pVector(rot.x, rot.y, rot.z); + S.scale = scale; + + F.w_u32(S.type); + S.Save(F); } -void pTurbulence(IWriter& F, float freq, int octaves, float magnitude, float epsilon, const Fvector& offs) +void pTargetVelocity(IWriter &F, const Fvector &vel, float scale, BOOL allow_rotate) { - PATurbulence S; - S.type = PATurbulenceID; - - S.frequency = freq; - S.octaves = octaves; - S.magnitude = magnitude; - S.epsilon = epsilon; - S.offset.set (offs); + PATargetVelocity S; + S.type = PATargetVelocityID; + + S.velocityL = pVector(vel.x, vel.y, vel.z); + S.velocity = S.velocityL; + S.scale = scale; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); - S.age = 0.f; - - F.w_u32 (S.type); - S.Save (F); + F.w_u32(S.type); + S.Save(F); +} + +void pVortex(IWriter &F, const Fvector ¢er, const Fvector &axis, + float magnitude, float epsilon, float max_radius, BOOL allow_rotate) +{ + PAVortex S; + S.type = PAVortexID; + + S.centerL = pVector(center.x, center.y, center.z); + S.center = S.centerL; + S.axisL = pVector(axis.x, axis.y, axis.z); + S.axisL.normalize_safe(); + S.axis = S.axisL; + S.magnitude = magnitude; + S.epsilon = epsilon; + S.max_radius = max_radius; + S.m_Flags.set(ParticleAction::ALLOW_ROTATE, allow_rotate); + + F.w_u32(S.type); + S.Save(F); +} + +void pTurbulence(IWriter &F, float freq, int octaves, float magnitude, float epsilon, const Fvector &offs) +{ + PATurbulence S; + S.type = PATurbulenceID; + + S.frequency = freq; + S.octaves = octaves; + S.magnitude = magnitude; + S.epsilon = epsilon; + S.offset.set(offs); + + S.age = 0.f; + + F.w_u32(S.type); + S.Save(F); } //------------------------------------------------------------------------------ @@ -712,567 +770,625 @@ void pTurbulence(IWriter& F, float freq, int octaves, float magnitude, float eps D.f[0], D.f[1], D.f[2],\ D.f[3], D.f[4], D.f[5],\ D.f[6], D.f[7], D.f[8] - -EPAAvoid::EPAAvoid ():EParticleAction(PAPI::PAAvoidID) + +EPAAvoid::EPAAvoid(): EParticleAction(PAPI::PAAvoidID) { - actionType = "Avoid"; - actionName = actionType; - appendDomain ("Position", PDomain(PDomain::vNum,TRUE,0x6096FF96)); - appendFloat ("Magnitude", 0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Epsilon", 0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Look Ahead", 0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendBool ("Allow Rotate",TRUE); + actionType = "Avoid"; + actionName = actionType; + appendDomain("Position", PDomain(PDomain::vNum, TRUE, 0x6096FF96)); + appendFloat("Magnitude", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Epsilon", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Look Ahead", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendBool("Allow Rotate", TRUE); } -void EPAAvoid::Compile (IWriter& F) + +void EPAAvoid::Compile(IWriter &F) { pAvoid(F, _float("Magnitude").val, _float("Epsilon").val, _float("Look Ahead").val, pDomain(EXPAND_DOMAIN(_domain("Position"))), _bool("Allow Rotate").val); } -EPABounce::EPABounce ():EParticleAction(PAPI::PABounceID) +EPABounce::EPABounce(): EParticleAction(PAPI::PABounceID) { - actionType = "Bounce"; - actionName = actionType; - appendDomain ("Position",PDomain(PDomain::vNum,TRUE,0x6096FEEC)); - appendFloat ("Friction",0.5f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Resilience",0.1f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Cutoff",1.f, -P_MAXFLOAT, P_MAXFLOAT); - appendBool ("Allow Rotate", TRUE); + actionType = "Bounce"; + actionName = actionType; + appendDomain("Position", PDomain(PDomain::vNum, TRUE, 0x6096FEEC)); + appendFloat("Friction", 0.5f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Resilience", 0.1f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Cutoff", 1.f, -P_MAXFLOAT, P_MAXFLOAT); + appendBool("Allow Rotate", TRUE); } -void EPABounce::Compile (IWriter& F) + +void EPABounce::Compile(IWriter &F) { - pBounce(F,_float("Friction").val, _float("Resilience").val, _float("Cutoff").val, pDomain(EXPAND_DOMAIN(_domain("Position"))), _bool("Allow Rotate").val); + pBounce(F, _float("Friction").val, _float("Resilience").val, _float("Cutoff").val, pDomain(EXPAND_DOMAIN(_domain("Position"))), _bool("Allow Rotate").val); } -EPACopyVertexB::EPACopyVertexB ():EParticleAction(PAPI::PACopyVertexBID) +EPACopyVertexB::EPACopyVertexB(): EParticleAction(PAPI::PACopyVertexBID) { - actionType = "CopyVertexB"; - actionName = actionType; - appendBool ("Copy Position", TRUE); + actionType = "CopyVertexB"; + actionName = actionType; + appendBool("Copy Position", TRUE); } -void EPACopyVertexB::Compile (IWriter& F) + +void EPACopyVertexB::Compile(IWriter &F) { - pCopyVertexB(F,_bool("Copy Position").val); + pCopyVertexB(F, _bool("Copy Position").val); } -EPADamping::EPADamping ():EParticleAction(PAPI::PADampingID) +EPADamping::EPADamping(): EParticleAction(PAPI::PADampingID) { - actionType = "Damping"; - actionName = actionType; - appendVector ("Damping", PVector::vNum, 0.f,0.f,0.f); - appendFloat ("V Low",0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("V High",P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); + actionType = "Damping"; + actionName = actionType; + appendVector("Damping", PVector::vNum, 0.f, 0.f, 0.f); + appendFloat("V Low", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("V High", P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); } -void EPADamping::Compile (IWriter& F) + +void EPADamping::Compile(IWriter &F) { - pDamping(F,_vector("Damping").val, _float("V Low").val, _float("V High").val); + pDamping(F, _vector("Damping").val, _float("V Low").val, _float("V High").val); } -EPAExplosion::EPAExplosion ():EParticleAction(PAPI::PAExplosionID) +EPAExplosion::EPAExplosion(): EParticleAction(PAPI::PAExplosionID) { - actionType = "Explosion"; - actionName = actionType; - appendVector ("Center",PVector::vNum, 0.f,0.f,0.f); - appendFloat ("Velocity", 1.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Magnitude", 2.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Standart Dev", 3.f, EPS, P_MAXFLOAT); - appendFloat ("Epsilon", EPS_L, EPS, P_MAXFLOAT); - appendFloat ("Age", 0.f, 0.f, P_MAXFLOAT); - appendBool ("Allow Rotate", TRUE); + actionType = "Explosion"; + actionName = actionType; + appendVector("Center", PVector::vNum, 0.f, 0.f, 0.f); + appendFloat("Velocity", 1.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Magnitude", 2.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Standart Dev", 3.f, EPS, P_MAXFLOAT); + appendFloat("Epsilon", EPS_L, EPS, P_MAXFLOAT); + appendFloat("Age", 0.f, 0.f, P_MAXFLOAT); + appendBool("Allow Rotate", TRUE); } -void EPAExplosion::Compile (IWriter& F) + +void EPAExplosion::Compile(IWriter &F) { - pExplosion(F,_vector("Center").val, _float("Velocity").val, _float("Magnitude").val, _float("Standart Dev").val, _float("Epsilon").val, _float("Age").val, _bool("Allow Rotate").val); + pExplosion(F, _vector("Center").val, _float("Velocity").val, _float("Magnitude").val, _float("Standart Dev").val, _float("Epsilon").val, _float("Age").val, _bool("Allow Rotate").val); } -EPAFollow::EPAFollow ():EParticleAction(PAPI::PAFollowID) +EPAFollow::EPAFollow(): EParticleAction(PAPI::PAFollowID) { - actionType = "Follow"; - actionName = actionType; - appendFloat ("Magnitude",0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Epsilon",EPS_L, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Max Radius",P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); + actionType = "Follow"; + actionName = actionType; + appendFloat("Magnitude", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Epsilon", EPS_L, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Max Radius", P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); } -void EPAFollow::Compile (IWriter& F) + +void EPAFollow::Compile(IWriter &F) { - pFollow(F,_float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val); + pFollow(F, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val); } -EPAGravitate::EPAGravitate ():EParticleAction(PAPI::PAGravitateID) +EPAGravitate::EPAGravitate(): EParticleAction(PAPI::PAGravitateID) { - actionType = "Gravitate"; - actionName = actionType; - appendFloat ("Magnitude",1.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Epsilon",0.001f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Max Radius",10.0f, -P_MAXFLOAT, P_MAXFLOAT); + actionType = "Gravitate"; + actionName = actionType; + appendFloat("Magnitude", 1.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Epsilon", 0.001f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Max Radius", 10.0f, -P_MAXFLOAT, P_MAXFLOAT); } -void EPAGravitate::Compile (IWriter& F) + +void EPAGravitate::Compile(IWriter &F) { - pGravitate(F,_float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val); + pGravitate(F, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val); } -EPAGravity::EPAGravity ():EParticleAction(PAPI::PAGravityID) +EPAGravity::EPAGravity(): EParticleAction(PAPI::PAGravityID) { - actionType = "Gravity"; - actionName = actionType; - appendVector ("Direction", PVector::vNum, 0.f,-9.8f,0.f); - appendBool ("Allow Rotate", TRUE); + actionType = "Gravity"; + actionName = actionType; + appendVector("Direction", PVector::vNum, 0.f, -9.8f, 0.f); + appendBool("Allow Rotate", TRUE); } -void EPAGravity::Compile (IWriter& F) + +void EPAGravity::Compile(IWriter &F) { - pGravity(F,_vector("Direction").val, _bool("Allow Rotate").val); + pGravity(F, _vector("Direction").val, _bool("Allow Rotate").val); } -EPAJet::EPAJet ():EParticleAction(PAPI::PAJetID) +EPAJet::EPAJet(): EParticleAction(PAPI::PAJetID) { - actionType = "Jet"; - actionName = actionType; - appendDomain ("Accelerate",PDomain(PDomain::vNum,FALSE)); - appendVector ("Center",PVector::vNum, 0.f,0.f,0.f); - appendFloat ("Magnitude",0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Epsilon",EPS_L, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Max Radius",P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); - appendBool ("Allow Rotate", TRUE); + actionType = "Jet"; + actionName = actionType; + appendDomain("Accelerate", PDomain(PDomain::vNum, FALSE)); + appendVector("Center", PVector::vNum, 0.f, 0.f, 0.f); + appendFloat("Magnitude", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Epsilon", EPS_L, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Max Radius", P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); + appendBool("Allow Rotate", TRUE); } -void EPAJet::Compile (IWriter& F) + +void EPAJet::Compile(IWriter &F) { - pJet(F,pDomain(EXPAND_DOMAIN(_domain("Accelerate"))),_vector("Center").val, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val, _bool("Allow Rotate").val); + pJet(F, pDomain(EXPAND_DOMAIN(_domain("Accelerate"))), _vector("Center").val, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val, _bool("Allow Rotate").val); } -void EPAJet::Render (const Fmatrix& parent) + +void EPAJet::Render(const Fmatrix &parent) { - EParticleAction::Render (parent); - RCache.set_xform_world (parent); - EDevice.SetShader (EDevice.m_WireShader); - DU_impl.DrawCross (_vector("Center").val, 0.05f,0.05f,0.05f, 0.05f,0.05f,0.05f, 0x600000ff); + EParticleAction::Render(parent); + RCache.set_xform_world(parent); + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawCross(_vector("Center").val, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0x600000ff); } -EPAKillOld::EPAKillOld ():EParticleAction(PAPI::PAKillOldID) +EPAKillOld::EPAKillOld(): EParticleAction(PAPI::PAKillOldID) { - actionType = "KillOld"; - actionName = actionType; - appendFloat ("Age Limit", 5.f, 0.0f, P_MAXFLOAT); - appendBool ("Kill Less Than", FALSE); + actionType = "KillOld"; + actionName = actionType; + appendFloat("Age Limit", 5.f, 0.0f, P_MAXFLOAT); + appendBool("Kill Less Than", FALSE); } -void EPAKillOld::Compile (IWriter& F) + +void EPAKillOld::Compile(IWriter &F) { - pKillOld(F,_float("Age Limit").val, _bool("Kill Less Than").val); + pKillOld(F, _float("Age Limit").val, _bool("Kill Less Than").val); } -EPAMatchVelocity::EPAMatchVelocity ():EParticleAction(PAPI::PAMatchVelocityID) +EPAMatchVelocity::EPAMatchVelocity(): EParticleAction(PAPI::PAMatchVelocityID) { - actionType = "MatchVelocity"; - actionName = actionType; - appendFloat ("Magnitude",0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Epsilon",EPS_L, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Max Radius",P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); + actionType = "MatchVelocity"; + actionName = actionType; + appendFloat("Magnitude", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Epsilon", EPS_L, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Max Radius", P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); } -void EPAMatchVelocity::Compile (IWriter& F) + +void EPAMatchVelocity::Compile(IWriter &F) { - pMatchVelocity(F,_float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val); + pMatchVelocity(F, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val); } -EPAMove::EPAMove ():EParticleAction(PAPI::PAMoveID) +EPAMove::EPAMove(): EParticleAction(PAPI::PAMoveID) { - actionType = "Move"; - actionName = actionType; + actionType = "Move"; + actionName = actionType; } -void EPAMove::Compile (IWriter& F) + +void EPAMove::Compile(IWriter &F) { pMove(F); } -EPAOrbitLine::EPAOrbitLine ():EParticleAction(PAPI::PAOrbitLineID) +EPAOrbitLine::EPAOrbitLine(): EParticleAction(PAPI::PAOrbitLineID) { - actionType = "OrbitLine"; - actionName = actionType; - appendVector ("Position", PVector::vNum, 0.f,0.f,0.f); - appendVector ("Axis", PVector::vNum, 0.f,0.f,0.f); - appendFloat ("Magnitude", 1.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Epsilon", EPS_L, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Max Radius", P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); - appendBool ("Allow Rotate", TRUE); + actionType = "OrbitLine"; + actionName = actionType; + appendVector("Position", PVector::vNum, 0.f, 0.f, 0.f); + appendVector("Axis", PVector::vNum, 0.f, 0.f, 0.f); + appendFloat("Magnitude", 1.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Epsilon", EPS_L, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Max Radius", P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); + appendBool("Allow Rotate", TRUE); } -void EPAOrbitLine::Compile (IWriter& F) + +void EPAOrbitLine::Compile(IWriter &F) { - pOrbitLine(F,_vector("Position").val, _vector("Axis").val, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val, _bool("Allow Rotate").val); + pOrbitLine(F, _vector("Position").val, _vector("Axis").val, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val, _bool("Allow Rotate").val); } -void EPAOrbitLine::Render (const Fmatrix& parent) + +void EPAOrbitLine::Render(const Fmatrix &parent) { - EParticleAction::Render (parent); - RCache.set_xform_world (parent); - EDevice.SetShader (EDevice.m_WireShader); - Fvector p0,p1; - p0 = _vector("Position").val; - p1.add (p0,_vector("Axis").val); - DU_impl.DrawCross (p0, 0.05f,0.05f,0.05f, 0.05f,0.05f,0.05f, 0x6000ff00); - DU_impl.DrawCross (p1, 0.05f,0.05f,0.05f, 0.05f,0.05f,0.05f, 0x6000ff00); - DU_impl.DrawLine (p0, p1, 0x6000ff00); + EParticleAction::Render(parent); + RCache.set_xform_world(parent); + EDevice.SetShader(EDevice.m_WireShader); + Fvector p0, p1; + p0 = _vector("Position").val; + p1.add(p0, _vector("Axis").val); + DU_impl.DrawCross(p0, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0x6000ff00); + DU_impl.DrawCross(p1, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0x6000ff00); + DU_impl.DrawLine(p0, p1, 0x6000ff00); } -EPAOrbitPoint::EPAOrbitPoint ():EParticleAction(PAPI::PAOrbitPointID) +EPAOrbitPoint::EPAOrbitPoint(): EParticleAction(PAPI::PAOrbitPointID) { - actionType = "OrbitPoint"; - actionName = actionType; - appendVector ("Center", PVector::vNum, 0.f,0.f,0.f); - appendFloat ("Magnitude", 400.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Epsilon", 0.1f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Max Radius", 100.0f, -P_MAXFLOAT, P_MAXFLOAT); - appendBool ("Allow Rotate", TRUE); + actionType = "OrbitPoint"; + actionName = actionType; + appendVector("Center", PVector::vNum, 0.f, 0.f, 0.f); + appendFloat("Magnitude", 400.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Epsilon", 0.1f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Max Radius", 100.0f, -P_MAXFLOAT, P_MAXFLOAT); + appendBool("Allow Rotate", TRUE); } -void EPAOrbitPoint::Compile (IWriter& F) + +void EPAOrbitPoint::Compile(IWriter &F) { - pOrbitPoint(F,_vector("Center").val, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val, _bool("Allow Rotate").val); + pOrbitPoint(F, _vector("Center").val, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val, _bool("Allow Rotate").val); } -void EPAOrbitPoint::Render (const Fmatrix& parent) + +void EPAOrbitPoint::Render(const Fmatrix &parent) { - EParticleAction::Render (parent); - RCache.set_xform_world (parent); - EDevice.SetShader (EDevice.m_WireShader); - DU_impl.DrawCross (_vector("Center").val, 0.05f,0.05f,0.05f, 0.05f,0.05f,0.05f, 0x6000ff00); + EParticleAction::Render(parent); + RCache.set_xform_world(parent); + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawCross(_vector("Center").val, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0x6000ff00); } -EPARandomAccel::EPARandomAccel ():EParticleAction(PAPI::PARandomAccelID) +EPARandomAccel::EPARandomAccel(): EParticleAction(PAPI::PARandomAccelID) { - actionType = "RandomAccel"; - actionName = actionType; - appendDomain ("Accelerate",PDomain(PDomain::vNum,FALSE)); - appendBool ("Allow Rotate", TRUE); + actionType = "RandomAccel"; + actionName = actionType; + appendDomain("Accelerate", PDomain(PDomain::vNum, FALSE)); + appendBool("Allow Rotate", TRUE); } -void EPARandomAccel::Compile (IWriter& F) + +void EPARandomAccel::Compile(IWriter &F) { - pRandomAccel(F,pDomain(EXPAND_DOMAIN(_domain("Accelerate"))), _bool("Allow Rotate").val); + pRandomAccel(F, pDomain(EXPAND_DOMAIN(_domain("Accelerate"))), _bool("Allow Rotate").val); } -EPARandomDisplace::EPARandomDisplace():EParticleAction(PAPI::PARandomDisplaceID) +EPARandomDisplace::EPARandomDisplace(): EParticleAction(PAPI::PARandomDisplaceID) { - actionType = "RandomDisplace"; - actionName = actionType; - appendDomain ("Displace",PDomain(PDomain::vNum,FALSE)); - appendBool ("Allow Rotate", TRUE); + actionType = "RandomDisplace"; + actionName = actionType; + appendDomain("Displace", PDomain(PDomain::vNum, FALSE)); + appendBool("Allow Rotate", TRUE); } -void EPARandomDisplace::Compile (IWriter& F) + +void EPARandomDisplace::Compile(IWriter &F) { - pRandomDisplace(F,pDomain(EXPAND_DOMAIN(_domain("Displace"))), _bool("Allow Rotate").val); + pRandomDisplace(F, pDomain(EXPAND_DOMAIN(_domain("Displace"))), _bool("Allow Rotate").val); } -EPARandomVelocity::EPARandomVelocity():EParticleAction(PAPI::PARandomVelocityID) +EPARandomVelocity::EPARandomVelocity(): EParticleAction(PAPI::PARandomVelocityID) { - actionType = "RandomVelocity"; - actionName = actionType; - appendDomain ("Velocity",PDomain(PDomain::vNum,FALSE)); - appendBool ("Allow Rotate", TRUE); + actionType = "RandomVelocity"; + actionName = actionType; + appendDomain("Velocity", PDomain(PDomain::vNum, FALSE)); + appendBool("Allow Rotate", TRUE); } -void EPARandomVelocity::Compile (IWriter& F) + +void EPARandomVelocity::Compile(IWriter &F) { - pRandomVelocity(F,pDomain(EXPAND_DOMAIN(_domain("Velocity"))), _bool("Allow Rotate").val); + pRandomVelocity(F, pDomain(EXPAND_DOMAIN(_domain("Velocity"))), _bool("Allow Rotate").val); } -EPARestore::EPARestore ():EParticleAction(PAPI::PARestoreID) +EPARestore::EPARestore(): EParticleAction(PAPI::PARestoreID) { - actionType = "Restore"; - actionName = actionType; - appendFloat ("Time", 0.f, 0.0f, P_MAXFLOAT); + actionType = "Restore"; + actionName = actionType; + appendFloat("Time", 0.f, 0.0f, P_MAXFLOAT); } -void EPARestore::Compile (IWriter& F) + +void EPARestore::Compile(IWriter &F) { - pRestore(F,_float("Time").val); + pRestore(F, _float("Time").val); } -EPAScatter::EPAScatter ():EParticleAction(PAPI::PAScatterID) +EPAScatter::EPAScatter(): EParticleAction(PAPI::PAScatterID) { - actionType = "Scatter"; - actionName = actionType; - appendVector ("Center",PVector::vNum, 0.f,0.f,0.f); - appendFloat ("Magnitude",0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Epsilon",EPS_L, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Max Radius",P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); - appendBool ("Allow Rotate", TRUE); + actionType = "Scatter"; + actionName = actionType; + appendVector("Center", PVector::vNum, 0.f, 0.f, 0.f); + appendFloat("Magnitude", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Epsilon", EPS_L, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Max Radius", P_MAXFLOAT, -P_MAXFLOAT, P_MAXFLOAT); + appendBool("Allow Rotate", TRUE); } -void EPAScatter::Compile (IWriter& F) + +void EPAScatter::Compile(IWriter &F) { - pScatter(F,_vector("Center").val, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val, _bool("Allow Rotate").val); + pScatter(F, _vector("Center").val, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val, _bool("Allow Rotate").val); } -void EPAScatter::Render (const Fmatrix& parent) + +void EPAScatter::Render(const Fmatrix &parent) { - EParticleAction::Render (parent); - RCache.set_xform_world (parent); - EDevice.SetShader (EDevice.m_WireShader); - DU_impl.DrawCross (_vector("Center").val, 0.05f,0.05f,0.05f, 0.05f,0.05f,0.05f, 0x600000ff); + EParticleAction::Render(parent); + RCache.set_xform_world(parent); + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawCross(_vector("Center").val, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0x600000ff); } -EPASink::EPASink ():EParticleAction(PAPI::PASinkID) +EPASink::EPASink(): EParticleAction(PAPI::PASinkID) { - actionType = "Sink"; - actionName = actionType; - appendBool ("Kill Inside", TRUE); - appendDomain ("Domain", PDomain(PDomain::vNum,TRUE,0x60ff0000)); - appendBool ("Allow Rotate", TRUE); + actionType = "Sink"; + actionName = actionType; + appendBool("Kill Inside", TRUE); + appendDomain("Domain", PDomain(PDomain::vNum, TRUE, 0x60ff0000)); + appendBool("Allow Rotate", TRUE); } -void EPASink::Compile (IWriter& F) + +void EPASink::Compile(IWriter &F) { - pSink(F,_bool("Kill Inside").val, pDomain(EXPAND_DOMAIN(_domain("Domain"))), _bool("Allow Rotate").val); + pSink(F, _bool("Kill Inside").val, pDomain(EXPAND_DOMAIN(_domain("Domain"))), _bool("Allow Rotate").val); } -EPASinkVelocity::EPASinkVelocity ():EParticleAction(PAPI::PASinkVelocityID) +EPASinkVelocity::EPASinkVelocity(): EParticleAction(PAPI::PASinkVelocityID) { - actionType = "SinkVelocity"; - actionName = actionType; - appendBool ("Kill Inside", TRUE); - appendDomain ("Domain",PDomain(PDomain::vNum,FALSE)); - appendBool ("Allow Rotate", TRUE); + actionType = "SinkVelocity"; + actionName = actionType; + appendBool("Kill Inside", TRUE); + appendDomain("Domain", PDomain(PDomain::vNum, FALSE)); + appendBool("Allow Rotate", TRUE); } -void EPASinkVelocity::Compile (IWriter& F) + +void EPASinkVelocity::Compile(IWriter &F) { - pSinkVelocity(F,_bool("Kill Inside").val, pDomain(EXPAND_DOMAIN(_domain("Domain"))), _bool("Allow Rotate").val); + pSinkVelocity(F, _bool("Kill Inside").val, pDomain(EXPAND_DOMAIN(_domain("Domain"))), _bool("Allow Rotate").val); } -EPASource::EPASource ():EParticleAction(PAPI::PASourceID) +EPASource::EPASource(): EParticleAction(PAPI::PASourceID) { - actionType = "Source"; - actionName = actionType; - appendFloat ("Rate", 100.f, -P_MAXFLOAT, P_MAXFLOAT); - appendDomain ("Domain", PDomain(PDomain::vNum,TRUE,0x60FFEBAA)); - appendDomain ("Velocity", PDomain(PDomain::vNum,FALSE)); - appendDomain ("Rotation", PDomain(PDomain::vAngle,FALSE)); - appendDomain ("Size", PDomain(PDomain::vNum,FALSE)); - appendBool ("Single Size", FALSE); - appendDomain ("Color", PDomain(PDomain::vColor, FALSE, 0x00000000, PAPI::PDPoint,1.f,1.f,1.f,1.f,1.f,1.f,1.f,1.f,1.f)); - appendFloat ("Color\\Alpha", 0.f, 0.f, 1.f); - appendFloat ("Starting Age", 0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Age Sigma", 0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Parent Motion", 0.f, -P_MAXFLOAT, P_MAXFLOAT); - appendBool ("Allow Rotate", FALSE); + actionType = "Source"; + actionName = actionType; + appendFloat("Rate", 100.f, -P_MAXFLOAT, P_MAXFLOAT); + appendDomain("Domain", PDomain(PDomain::vNum, TRUE, 0x60FFEBAA)); + appendDomain("Velocity", PDomain(PDomain::vNum, FALSE)); + appendDomain("Rotation", PDomain(PDomain::vAngle, FALSE)); + appendDomain("Size", PDomain(PDomain::vNum, FALSE)); + appendBool("Single Size", FALSE); + appendDomain("Color", PDomain(PDomain::vColor, FALSE, 0x00000000, PAPI::PDPoint, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f)); + appendFloat("Color\\Alpha", 0.f, 0.f, 1.f); + appendFloat("Starting Age", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Age Sigma", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Parent Motion", 0.f, -P_MAXFLOAT, P_MAXFLOAT); + appendBool("Allow Rotate", FALSE); } -void EPASource::Compile (IWriter& F) + +void EPASource::Compile(IWriter &F) { - pSource(F,_float("Rate").val, pDomain(EXPAND_DOMAIN(_domain("Domain"))), - pDomain(EXPAND_DOMAIN(_domain("Velocity"))), - pDomain(EXPAND_DOMAIN(_domain("Rotation"))), - pDomain(EXPAND_DOMAIN(_domain("Size"))), _bool("Single Size").val, - pDomain(EXPAND_DOMAIN(_domain("Color"))), _float("Color\\Alpha").val, - _float("Starting Age").val, _float("Age Sigma").val, _float("Parent Motion").val, - _bool("Allow Rotate").val); + pSource(F, _float("Rate").val, pDomain(EXPAND_DOMAIN(_domain("Domain"))), + pDomain(EXPAND_DOMAIN(_domain("Velocity"))), + pDomain(EXPAND_DOMAIN(_domain("Rotation"))), + pDomain(EXPAND_DOMAIN(_domain("Size"))), _bool("Single Size").val, + pDomain(EXPAND_DOMAIN(_domain("Color"))), _float("Color\\Alpha").val, + _float("Starting Age").val, _float("Age Sigma").val, _float("Parent Motion").val, + _bool("Allow Rotate").val); } -EPASpeedLimit::EPASpeedLimit ():EParticleAction(PAPI::PASpeedLimitID) +EPASpeedLimit::EPASpeedLimit(): EParticleAction(PAPI::PASpeedLimitID) { - actionType = "SpeedLimit"; - actionName = actionType; - appendFloat ("Min Speed", -1.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Max Speed", 15.0f, -P_MAXFLOAT, P_MAXFLOAT); + actionType = "SpeedLimit"; + actionName = actionType; + appendFloat("Min Speed", -1.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Max Speed", 15.0f, -P_MAXFLOAT, P_MAXFLOAT); } -void EPASpeedLimit::Compile (IWriter& F) + +void EPASpeedLimit::Compile(IWriter &F) { - pSpeedLimit(F,_float("Min Speed").val, _float("Max Speed").val); + pSpeedLimit(F, _float("Min Speed").val, _float("Max Speed").val); } -EPATargetColor::EPATargetColor ():EParticleAction(PAPI::PATargetColorID) +EPATargetColor::EPATargetColor(): EParticleAction(PAPI::PATargetColorID) { - actionType = "TargetColor"; - actionName = actionType; - appendVector ("Color", PVector::vColor, 1.f,1.f,1.f, 0.f,1.f); - appendFloat ("Alpha", 1.f, 0.0f,1.0f); - appendFloat ("Scale", 1.f, 0.01f, P_MAXFLOAT); - appendFloat ("TimeFrom", 0.0f, 0.0f, 1.0f); - appendFloat ("TimeTo", 1.0f, 0.0f, 1.0f); + actionType = "TargetColor"; + actionName = actionType; + appendVector("Color", PVector::vColor, 1.f, 1.f, 1.f, 0.f, 1.f); + appendFloat("Alpha", 1.f, 0.0f, 1.0f); + appendFloat("Scale", 1.f, 0.01f, P_MAXFLOAT); + appendFloat("TimeFrom", 0.0f, 0.0f, 1.0f); + appendFloat("TimeTo", 1.0f, 0.0f, 1.0f); } -void EPATargetColor::Compile (IWriter& F) + +void EPATargetColor::Compile(IWriter &F) { - pTargetColor(F,_vector("Color").val, _float("Alpha").val, _float("Scale").val, _float("TimeFrom").val, _float("TimeTo").val); + pTargetColor(F, _vector("Color").val, _float("Alpha").val, _float("Scale").val, _float("TimeFrom").val, _float("TimeTo").val); } -EPATargetSize::EPATargetSize ():EParticleAction(PAPI::PATargetSizeID) +EPATargetSize::EPATargetSize(): EParticleAction(PAPI::PATargetSizeID) { - actionType = "TargetSize"; - actionName = actionType; - appendVector ("Size", PVector::vNum, 2.f,2.f,0.001f, EPS_L); - appendVector ("Scale", PVector::vNum, 1.f,1.f,0.f); + actionType = "TargetSize"; + actionName = actionType; + appendVector("Size", PVector::vNum, 2.f, 2.f, 0.001f, EPS_L); + appendVector("Scale", PVector::vNum, 1.f, 1.f, 0.f); } -void EPATargetSize::Compile (IWriter& F) + +void EPATargetSize::Compile(IWriter &F) { - pTargetSize(F,_vector("Size").val, _vector("Scale").val); + pTargetSize(F, _vector("Size").val, _vector("Scale").val); } -EPATargetRotate::EPATargetRotate ():EParticleAction(PAPI::PATargetRotateID) +EPATargetRotate::EPATargetRotate(): EParticleAction(PAPI::PATargetRotateID) { - actionType = "TargetRotate"; - actionName = actionType; - appendVector ("Rotation", PVector::vAngle, 0.f,0.f,0.f); - appendFloat ("Scale", 1.f, 0.0f, P_MAXFLOAT); + actionType = "TargetRotate"; + actionName = actionType; + appendVector("Rotation", PVector::vAngle, 0.f, 0.f, 0.f); + appendFloat("Scale", 1.f, 0.0f, P_MAXFLOAT); } -void EPATargetRotate::Compile (IWriter& F) + +void EPATargetRotate::Compile(IWriter &F) { - pTargetRotate(F,_vector("Rotation").val, _float("Scale").val); + pTargetRotate(F, _vector("Rotation").val, _float("Scale").val); } -EPATargetVelocity::EPATargetVelocity():EParticleAction(PAPI::PATargetVelocityID) +EPATargetVelocity::EPATargetVelocity(): EParticleAction(PAPI::PATargetVelocityID) { - actionType = "TargetVelocity"; - actionName = actionType; - appendVector ("Velocity", PVector::vNum, 0.f,0.f,0.f); - appendFloat ("Scale", 1.f, 0.0f, P_MAXFLOAT); - appendBool ("Allow Rotate", TRUE); + actionType = "TargetVelocity"; + actionName = actionType; + appendVector("Velocity", PVector::vNum, 0.f, 0.f, 0.f); + appendFloat("Scale", 1.f, 0.0f, P_MAXFLOAT); + appendBool("Allow Rotate", TRUE); } -void EPATargetVelocity::Compile (IWriter& F) + +void EPATargetVelocity::Compile(IWriter &F) { - pTargetVelocity(F,_vector("Velocity").val, _float("Scale").val, _bool("Allow Rotate").val); + pTargetVelocity(F, _vector("Velocity").val, _float("Scale").val, _bool("Allow Rotate").val); } -EPAVortex::EPAVortex ():EParticleAction(PAPI::PAVortexID) +EPAVortex::EPAVortex(): EParticleAction(PAPI::PAVortexID) { - actionType = "Vortex"; - actionName = actionType; - appendVector ("Center", PVector::vNum, 0.f,0.f,0.f); - appendVector ("Axis", PVector::vNum, 0.f,1.f,0.f); - appendFloat ("Magnitude", 1.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Epsilon", EPS_L, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Max Radius", 1.0f, -P_MAXFLOAT, P_MAXFLOAT); - appendBool ("Allow Rotate", TRUE); + actionType = "Vortex"; + actionName = actionType; + appendVector("Center", PVector::vNum, 0.f, 0.f, 0.f); + appendVector("Axis", PVector::vNum, 0.f, 1.f, 0.f); + appendFloat("Magnitude", 1.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Epsilon", EPS_L, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Max Radius", 1.0f, -P_MAXFLOAT, P_MAXFLOAT); + appendBool("Allow Rotate", TRUE); } -void EPAVortex::Compile (IWriter& F) + +void EPAVortex::Compile(IWriter &F) { - pVortex(F,_vector("Center").val, _vector("Axis").val, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val, _bool("Allow Rotate").val); + pVortex(F, _vector("Center").val, _vector("Axis").val, _float("Magnitude").val, _float("Epsilon").val, _float("Max Radius").val, _bool("Allow Rotate").val); } -void EPAVortex::Render (const Fmatrix& parent) + +void EPAVortex::Render(const Fmatrix &parent) { - EParticleAction::Render (parent); + EParticleAction::Render(parent); } -EPATurbulence::EPATurbulence ():EParticleAction(PAPI::PATurbulenceID) +EPATurbulence::EPATurbulence(): EParticleAction(PAPI::PATurbulenceID) { - actionType = "Turbulence"; - actionName = actionType; - appendFloat ("Frequency", 2.f, -P_MAXFLOAT, P_MAXFLOAT); - appendInt ("Octaves", 1,1); - appendFloat ("Magnitude", 10.f, -P_MAXFLOAT, P_MAXFLOAT); - appendFloat ("Delta", 0.01f, -P_MAXFLOAT, P_MAXFLOAT); - appendVector ("Movement", PVector::vNum, 1,1,1); -// - - nval=0; - age = 0.f; + actionType = "Turbulence"; + actionName = actionType; + appendFloat("Frequency", 2.f, -P_MAXFLOAT, P_MAXFLOAT); + appendInt("Octaves", 1, 1); + appendFloat("Magnitude", 10.f, -P_MAXFLOAT, P_MAXFLOAT); + appendFloat("Delta", 0.01f, -P_MAXFLOAT, P_MAXFLOAT); + appendVector("Movement", PVector::vNum, 1, 1, 1); + // - + nval = 0; + age = 0.f; } -static const int detail=16; +static const int detail = 16; -void EPATurbulence::Compile (IWriter& F) +void EPATurbulence::Compile(IWriter &F) { - pTurbulence(F,_float("Frequency").val, _int("Octaves").val, _float("Magnitude").val, _float("Delta").val, _vector("Movement").val); - if(nval != 0){ - for(int i = 0; i < detail; i++){ - for(int j = 0; j < detail; j++) + pTurbulence(F, _float("Frequency").val, _int("Octaves").val, _float("Magnitude").val, _float("Delta").val, _vector("Movement").val); + if (nval!=0) + { + for (int i = 0; ib; -} -void EPATurbulence::Render (const Fmatrix& parent) -{ - EParticleAction::Render (parent); - Fvector vec; - int i, j, k; - int kb; - int ke; - Fcolor clr; - - float draw_area = 1; - float csz = ((draw_area*2.f)/detail)/2.f; - bool draw_p=true,draw_n=true; +IC + +bool sort_tp_pred(const Stp &x, const Stp &y) +{ + float a = EDevice.vCameraPosition.distance_to_sqr(x.p); + float b = EDevice.vCameraPosition.distance_to_sqr(y.p); + return a>b; +} + +void EPATurbulence::Render(const Fmatrix &parent) +{ + EParticleAction::Render(parent); + Fvector vec; + int i, j, k; + int kb; + int ke; + Fcolor clr; + + float draw_area = 1; + float csz = ((draw_area*2.f)/detail)/2.f; + bool draw_p = true, draw_n = true; pts.clear(); - - age += EDevice.fTimeDelta; + + age += EDevice.fTimeDelta; // fill - if (nval == 0){ + if (nval==0) + { nval = new float**[detail]; - for(i = 0; i < detail; i++) + for (i = 0; i 0.0){ + + clr.set(0, 0, 0, 0); + if (draw_p&&draw_n) + { + if (nval[i][j][k]>0.0) + { clr.r = nval[i][j][k]; clr.a = nval[i][j][k]; - }else{ + } + else + { clr.b = fabs(nval[i][j][k]); clr.a = fabs(nval[i][j][k]); } - }else if (draw_p){ - if(nval[i][j][k] > 0.0) + } + else if (draw_p) + { + if (nval[i][j][k]>0.0) clr.set(nval[i][j][k]); - }else if (draw_n){ - if(nval[i][j][k] < 0.0) + } + else if (draw_n) + { + if (nval[i][j][k]<0.0) clr.set(fabs(nval[i][j][k])); } - pts.push_back(Stp(vec,clr)); + pts.push_back(Stp(vec, clr)); } } } - std::sort(pts.begin(),pts.end(),sort_tp_pred); + std::sort(pts.begin(), pts.end(), sort_tp_pred); EDevice.SetShader(EDevice.m_SelectionShader); RCache.set_xform_world(Fidentity); - for (StpVecIt it=pts.begin(); it!=pts.end(); it++) - DU_impl.DrawCross (it->p, csz,csz,csz, csz,csz,csz, it->c.get(), false); + for (StpVecIt it = pts.begin(); it!=pts.end(); it++) + DU_impl.DrawCross(it->p, csz, csz, csz, csz, csz, csz, it->c.get(), false); } #include "../../Layers/xrRender/ParticleEffect.h" #include "../../Layers/xrRender/ParticleGroup.h" -void PS::CPEDef::Render(const Fmatrix& parent) + +void PS::CPEDef::Render(const Fmatrix &parent) { - Fmatrix trans; trans.translate(parent.c); - for (EPAVecIt it=m_EActionList.begin(); it!=m_EActionList.end(); it++) - if ((*it)->flags.is(EParticleAction::flDraw|EParticleAction::flEnabled)){ - PBool* ar = (*it)->_bool_safe("Allow Rotate"); - (*it)->Render((ar&&ar->val)?parent:trans); + Fmatrix trans; + trans.translate(parent.c); + for (EPAVecIt it = m_EActionList.begin(); it!=m_EActionList.end(); it++) + if ((*it)->flags.is(EParticleAction::flDraw|EParticleAction::flEnabled)) + { + PBool *ar = (*it)->_bool_safe("Allow Rotate"); + (*it)->Render((ar&&ar->val) ? parent : trans); } } diff --git a/src/editors/ParticleEditor/ParticleEffectEditor.cpp b/src/editors/ParticleEditor/ParticleEffectEditor.cpp index a563ac0ef01..ffe73838771 100644 --- a/src/editors/ParticleEditor/ParticleEffectEditor.cpp +++ b/src/editors/ParticleEditor/ParticleEffectEditor.cpp @@ -4,13 +4,13 @@ #ifdef _PARTICLE_EDITOR -#include "../xrEProps/ChoseForm.h" -#include "..\..\Layers\xrRender\ParticleEffect.h" +#include "editors/xrEProps/ChoseForm.h" +#include "Layers/xrRender/ParticleEffect.h" #include "ParticleEffectActions.h" -#include "../../xrServerEntities/PropertiesListHelper.h" -#include "ui_particletools.h" +#include "xrServerEntities/PropertiesListHelper.h" +#include "UI_ParticleTools.h" #include "ui_main.h" -#include "../xrEProps/FolderLib.h" +#include "editors/xrEProps/FolderLib.h" BOOL PS::CPEDef::Equal(const CPEDef* pe) { @@ -219,15 +219,15 @@ void PS::CPEDef::FillProp(LPCSTR pref, ::PropItemVec& items, ::ListItem* owner) R->OnAfterEditEvent.bind (this,&PS::CPEDef::NameOnAfterEdit); - // max particles +// max particles PHelper().CreateS32 (items,PrepareKey (pref,"Max Particles"), &m_MaxParticles, 0, 100000); // P->OnChangeEvent = OnFlagChange; - // time limit +// time limit P=PHelper().CreateFlag32(items,PrepareKey (pref,"Time Limit"), &m_Flags, dfTimeLimit); P->OnChangeEvent.bind (this,&PS::CPEDef::OnFlagChange); if (m_Flags.is(dfTimeLimit)) PHelper().CreateFloat (items,PrepareKey (pref,"Time Limit\\Value (sec)"), &m_fTimeLimit, 0, 10000.f); - // sprite +// sprite P=PHelper().CreateFlag32(items,PrepareKey (pref,"Sprite"), &m_Flags, dfSprite); P->OnChangeEvent.bind (this,&PS::CPEDef::OnFlagChange); if (m_Flags.is(dfSprite)){ @@ -235,7 +235,7 @@ void PS::CPEDef::FillProp(LPCSTR pref, ::PropItemVec& items, ::ListItem* owner) P->OnChangeEvent.bind (this,&PS::CPEDef::OnShaderChange); P=PHelper().CreateChoose(items,PrepareKey (pref,"Sprite\\Shader"), &m_ShaderName, smEShader); P->OnChangeEvent.bind (this,&PS::CPEDef::OnShaderChange); - // frame +// frame P=PHelper().CreateFlag32(items,PrepareKey (pref,"Sprite\\Culling"), &m_Flags, dfCulling); P->OnChangeEvent.bind (this,&PS::CPEDef::OnFlagChange); if (m_Flags.is(CPEDef::dfCulling)) @@ -248,7 +248,7 @@ void PS::CPEDef::FillProp(LPCSTR pref, ::PropItemVec& items, ::ListItem* owner) P=PHelper().CreateFloat(items,PrepareKey (pref,"Sprite\\Frame\\Size U (0..1)"), &m_Frame.m_fTexSize.x, EPS_S,1.f,0.001f,8); P->OnChangeEvent.bind (this,&PS::CPEDef::OnFrameResize); PHelper().CreateFloat (items,PrepareKey (pref,"Sprite\\Frame\\Size V (0..1)"), &m_Frame.m_fTexSize.y, EPS_S,1.f,0.001f,8); - // animate +// animate P=PHelper().CreateFlag32(items,PrepareKey (pref,"Sprite\\Animated"), &m_Flags, dfAnimated); P->OnChangeEvent.bind (this,&PS::CPEDef::OnFlagChange); if (m_Flags.is(dfAnimated)){ @@ -257,7 +257,7 @@ void PS::CPEDef::FillProp(LPCSTR pref, ::PropItemVec& items, ::ListItem* owner) } } } - // align to path +// align to path P=PHelper().CreateFlag32(items,PrepareKey (pref,"Movement\\Align To Path"), &m_Flags, dfAlignToPath); P->OnChangeEvent.bind (this,&PS::CPEDef::OnFlagChange); if (m_Flags.is(dfAlignToPath)){ @@ -265,12 +265,12 @@ void PS::CPEDef::FillProp(LPCSTR pref, ::PropItemVec& items, ::ListItem* owner) PHelper().CreateFlag32(items,PrepareKey (pref,"Movement\\Align To Path\\Default World Align"), &m_Flags, dfWorldAlign); PHelper().CreateAngle3(items,PrepareKey (pref,"Movement\\Align To Path\\Default Rotate"), &m_APDefaultRotation); } - // velocity scale +// velocity scale P=PHelper().CreateFlag32(items,PrepareKey (pref,"Movement\\Velocity Scale"), &m_Flags, dfVelocityScale); P->OnChangeEvent.bind (this,&PS::CPEDef::OnFlagChange); if (m_Flags.is(dfVelocityScale)) PHelper().CreateVector(items,PrepareKey (pref,"Movement\\Velocity Scale\\Value"), &m_VelocityScale, -1000.f, 1000.f); - // collision +// collision P=PHelper().CreateFlag32(items,PrepareKey (pref,"Movement\\Collision"), &m_Flags, dfCollision); P->OnChangeEvent.bind (this,&PS::CPEDef::OnFlagChange); FloatValue* V = 0; @@ -287,7 +287,7 @@ void PS::CPEDef::FillProp(LPCSTR pref, ::PropItemVec& items, ::ListItem* owner) V->OnAfterEditEvent.bind (this,&PS::CPEDef::CollisionCutoffOnAfterEdit); V->Owner()->OnDrawTextEvent.bind(this,&PS::CPEDef::CollisionCutoffOnDraw); } - // actions +// actions B=::PHelper().CreateButton(items,PrepareKey(pref,"Actions\\Edit"),"Append",ButtonValue::flFirstOnly); B->OnBtnClickEvent.bind (this,&PS::CPEDef::OnActionsClick); for (EPAVecIt s_it=m_EActionList.begin(); s_it!=m_EActionList.end(); s_it++) diff --git a/src/editors/ParticleEditor/ParticleEffectParser.cpp b/src/editors/ParticleEditor/ParticleEffectParser.cpp index dab746133b2..9288d9e05c9 100644 --- a/src/editors/ParticleEditor/ParticleEffectParser.cpp +++ b/src/editors/ParticleEditor/ParticleEffectParser.cpp @@ -9,393 +9,391 @@ using namespace PAPI2; using namespace PS; -static CPEDef* g_parent=0; +static CPEDef *g_parent = 0; -void _pSendAction(EParticleAction* a) +void _pSendAction(EParticleAction *a) { - VERIFY(g_parent); - g_parent->m_EActionList.push_back(a); + VERIFY(g_parent); + g_parent->m_EActionList.push_back(a); } - + void pEAvoid(float magnitude, float epsilon, float look_ahead, - PDomainEnum dtype, - float a0, float a1, float a2, - float a3, float a4, float a5, - float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) + PDomainEnum dtype, + float a0, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) { - EPAAvoid* S = dynamic_cast(pCreateEAction(PAAvoidID)); - - S->_domain("Position").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); - S->_float("Magnitude").set(magnitude); - S->_float("Epsilon").set(epsilon); - S->_float("Look Ahead").set(look_ahead); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPAAvoid *S = dynamic_cast(pCreateEAction(PAAvoidID)); + + S->_domain("Position").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); + S->_float("Magnitude").set(magnitude); + S->_float("Epsilon").set(epsilon); + S->_float("Look Ahead").set(look_ahead); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pEBounce(float friction, float resilience, float cutoff, - PDomainEnum dtype, - float a0, float a1, float a2, - float a3, float a4, float a5, - float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) + PDomainEnum dtype, + float a0, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) { - EPABounce* S = dynamic_cast(pCreateEAction(PABounceID)); - - S->_domain("Position").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); - S->_float("Friction").set(friction); - S->_float("Resilience").set(resilience); - S->_float("Cutoff").set(cutoff); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPABounce *S = dynamic_cast(pCreateEAction(PABounceID)); + + S->_domain("Position").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); + S->_float("Friction").set(friction); + S->_float("Resilience").set(resilience); + S->_float("Cutoff").set(cutoff); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pECopyVertexB(BOOL copy_pos) { - EPACopyVertexB* S= dynamic_cast(pCreateEAction(PACopyVertexBID)); + EPACopyVertexB *S = dynamic_cast(pCreateEAction(PACopyVertexBID)); + + S->_float("Copy Position").set(copy_pos); - S->_float("Copy Position").set(copy_pos); - - _pSendAction (S); + _pSendAction(S); } void pEDamping(float damping_x, float damping_y, float damping_z, - float vlow, float vhigh) + float vlow, float vhigh) { - EPADamping* S = dynamic_cast(pCreateEAction(PADampingID)); - - S->_vector("Damping").set(damping_x, damping_y, damping_z); - S->_float("V Low").set(vlow); - S->_float("V High").set(vhigh); - - _pSendAction (S); + EPADamping *S = dynamic_cast(pCreateEAction(PADampingID)); + + S->_vector("Damping").set(damping_x, damping_y, damping_z); + S->_float("V Low").set(vlow); + S->_float("V High").set(vhigh); + + _pSendAction(S); } - + void pEExplosion(float center_x, float center_y, float center_z, float velocity, - float magnitude, float stdev, float epsilon, float age, BOOL allow_translate, BOOL allow_rotate) + float magnitude, float stdev, float epsilon, float age, BOOL allow_translate, BOOL allow_rotate) { - EPAExplosion* S = dynamic_cast(pCreateEAction(PAExplosionID)); - - S->_vector("Center").set(center_x, center_y, center_z); - S->_float("Velocity").set(velocity); - S->_float("Magnitude").set(magnitude); - S->_float("Standart Dev").set(stdev); - S->_float("Epsilon").set(epsilon); - S->_float("Age").set(age); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPAExplosion *S = dynamic_cast(pCreateEAction(PAExplosionID)); + + S->_vector("Center").set(center_x, center_y, center_z); + S->_float("Velocity").set(velocity); + S->_float("Magnitude").set(magnitude); + S->_float("Standart Dev").set(stdev); + S->_float("Epsilon").set(epsilon); + S->_float("Age").set(age); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pEFollow(float magnitude, float epsilon, float max_radius) { - EPAFollow* S = dynamic_cast(pCreateEAction(PAFollowID)); - - S->_float("Magnitude").set(magnitude); - S->_float("Epsilon").set(epsilon); - S->_float("Max Radius").set(max_radius); - - _pSendAction (S); + EPAFollow *S = dynamic_cast(pCreateEAction(PAFollowID)); + + S->_float("Magnitude").set(magnitude); + S->_float("Epsilon").set(epsilon); + S->_float("Max Radius").set(max_radius); + + _pSendAction(S); } void pEGravitate(float magnitude, float epsilon, float max_radius) { - EPAGravitate* S = dynamic_cast(pCreateEAction(PAGravitateID)); - - S->_float("Magnitude").set(magnitude); - S->_float("Epsilon").set(epsilon); - S->_float("Max Radius").set(max_radius); - - _pSendAction (S); + EPAGravitate *S = dynamic_cast(pCreateEAction(PAGravitateID)); + + S->_float("Magnitude").set(magnitude); + S->_float("Epsilon").set(epsilon); + S->_float("Max Radius").set(max_radius); + + _pSendAction(S); } void pEGravity(float dir_x, float dir_y, float dir_z, BOOL allow_translate, BOOL allow_rotate) { - EPAGravity* S = dynamic_cast(pCreateEAction(PAGravityID)); - - S->_vector("Direction").set(dir_x, dir_y, dir_z); - S->_bool("Allow Rotate").set(allow_rotate); + EPAGravity *S = dynamic_cast(pCreateEAction(PAGravityID)); - _pSendAction (S); + S->_vector("Direction").set(dir_x, dir_y, dir_z); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } #define parse_xd(xd)xd.type,xd.f[0],xd.f[1],xd.f[2],xd.f[3],xd.f[4],xd.f[5],xd.f[6],xd.f[7],xd.f[8] void pEJet(float center_x, float center_y, float center_z, - float magnitude, float epsilon, float max_radius, BOOL allow_translate, BOOL allow_rotate) + float magnitude, float epsilon, float max_radius, BOOL allow_translate, BOOL allow_rotate) { - _ParticleState &_ps = _GetPState(); - - EPAJet* S = dynamic_cast(pCreateEAction(PAJetID)); - - S->_vector("Center").set(center_x, center_y, center_z); - S->_domain("Accelerate").set(parse_xd(_ps.Vel)); - S->_float("Magnitude").set(magnitude); - S->_float("Epsilon").set(epsilon); - S->_float("Max Radius").set(max_radius); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + _ParticleState &_ps = _GetPState(); + + EPAJet *S = dynamic_cast(pCreateEAction(PAJetID)); + + S->_vector("Center").set(center_x, center_y, center_z); + S->_domain("Accelerate").set(parse_xd(_ps.Vel)); + S->_float("Magnitude").set(magnitude); + S->_float("Epsilon").set(epsilon); + S->_float("Max Radius").set(max_radius); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pEKillOld(float age_limit, BOOL kill_less_than) { - EPAKillOld* S = dynamic_cast(pCreateEAction(PAKillOldID)); - - S->_float("Age Limit").set(age_limit); - S->_bool("Kill Less Than").set(kill_less_than); - - _pSendAction (S); + EPAKillOld *S = dynamic_cast(pCreateEAction(PAKillOldID)); + + S->_float("Age Limit").set(age_limit); + S->_bool("Kill Less Than").set(kill_less_than); + + _pSendAction(S); } void pEMatchVelocity(float magnitude, float epsilon, float max_radius) { - EPAMatchVelocity* S = dynamic_cast(pCreateEAction(PAMatchVelocityID)); - - S->_float("Magnitude").set(magnitude); - S->_float("Epsilon").set(epsilon); - S->_float("Max Radius").set(max_radius); - - _pSendAction (S); + EPAMatchVelocity *S = dynamic_cast(pCreateEAction(PAMatchVelocityID)); + + S->_float("Magnitude").set(magnitude); + S->_float("Epsilon").set(epsilon); + S->_float("Max Radius").set(max_radius); + + _pSendAction(S); } void pEMove() { - EPAMove* S = dynamic_cast(pCreateEAction(PAMoveID)); - - _pSendAction (S); + EPAMove *S = dynamic_cast(pCreateEAction(PAMoveID)); + + _pSendAction(S); } void pEOrbitLine(float p_x, float p_y, float p_z, - float axis_x, float axis_y, float axis_z, - float magnitude, float epsilon, float max_radius, BOOL allow_translate, BOOL allow_rotate) + float axis_x, float axis_y, float axis_z, + float magnitude, float epsilon, float max_radius, BOOL allow_translate, BOOL allow_rotate) { - EPAOrbitLine* S = dynamic_cast(pCreateEAction(PAOrbitLineID)); - - S->_vector("").set(p_x, p_y, p_z); - S->_vector("Axis").set(axis_x, axis_y, axis_z); - S->_float("Magnitude").set(magnitude); - S->_float("Epsilon").set(epsilon); - S->_float("Max Radius").set(max_radius); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPAOrbitLine *S = dynamic_cast(pCreateEAction(PAOrbitLineID)); + + S->_vector("").set(p_x, p_y, p_z); + S->_vector("Axis").set(axis_x, axis_y, axis_z); + S->_float("Magnitude").set(magnitude); + S->_float("Epsilon").set(epsilon); + S->_float("Max Radius").set(max_radius); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pEOrbitPoint(float center_x, float center_y, float center_z, - float magnitude, float epsilon, float max_radius, BOOL allow_translate, BOOL allow_rotate) + float magnitude, float epsilon, float max_radius, BOOL allow_translate, BOOL allow_rotate) { - EPAOrbitPoint* S = dynamic_cast(pCreateEAction(PAOrbitPointID)); - - S->_vector("Center").set(center_x, center_y, center_z); - S->_float("Magnitude").set(magnitude); - S->_float("Epsilon").set(epsilon); - S->_float("Max Radius").set(max_radius); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPAOrbitPoint *S = dynamic_cast(pCreateEAction(PAOrbitPointID)); + + S->_vector("Center").set(center_x, center_y, center_z); + S->_float("Magnitude").set(magnitude); + S->_float("Epsilon").set(epsilon); + S->_float("Max Radius").set(max_radius); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pERandomAccel(PDomainEnum dtype, - float a0, float a1, float a2, - float a3, float a4, float a5, - float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) + float a0, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) { - EPARandomAccel* S= dynamic_cast(pCreateEAction(PARandomAccelID)); - - S->_domain("Accelerate").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPARandomAccel *S = dynamic_cast(pCreateEAction(PARandomAccelID)); + + S->_domain("Accelerate").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pERandomDisplace(PDomainEnum dtype, - float a0, float a1, float a2, - float a3, float a4, float a5, - float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) + float a0, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) { - EPARandomDisplace* S = dynamic_cast(pCreateEAction(PARandomDisplaceID)); - - S->_domain("Displace").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPARandomDisplace *S = dynamic_cast(pCreateEAction(PARandomDisplaceID)); + + S->_domain("Displace").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pERandomVelocity(PDomainEnum dtype, - float a0, float a1, float a2, - float a3, float a4, float a5, - float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) + float a0, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) { - EPARandomVelocity* S = dynamic_cast(pCreateEAction(PARandomVelocityID)); - - S->_domain("Velocity").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPARandomVelocity *S = dynamic_cast(pCreateEAction(PARandomVelocityID)); + + S->_domain("Velocity").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pERestore(float time_left) { - EPARestore* S = dynamic_cast(pCreateEAction(PARestoreID)); - - S->_float("Time Left").set(time_left); - - _pSendAction (S); + EPARestore *S = dynamic_cast(pCreateEAction(PARestoreID)); + + S->_float("Time Left").set(time_left); + + _pSendAction(S); } void pESink(BOOL kill_inside, PDomainEnum dtype, - float a0, float a1, float a2, - float a3, float a4, float a5, - float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) + float a0, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) { - EPASink* S = dynamic_cast(pCreateEAction(PASinkID)); - - S->_bool("Kill Inside").set(kill_inside); - S->_domain("Domain").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPASink *S = dynamic_cast(pCreateEAction(PASinkID)); + + S->_bool("Kill Inside").set(kill_inside); + S->_domain("Domain").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pESinkVelocity(BOOL kill_inside, PDomainEnum dtype, - float a0, float a1, float a2, - float a3, float a4, float a5, - float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) + float a0, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) { - EPASinkVelocity* S= dynamic_cast(pCreateEAction(PASinkVelocityID)); - - S->_bool("Kill Inside").set(kill_inside); - S->_domain("Domain").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPASinkVelocity *S = dynamic_cast(pCreateEAction(PASinkVelocityID)); + + S->_bool("Kill Inside").set(kill_inside); + S->_domain("Domain").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pESource(float particle_rate, PDomainEnum dtype, - float a0, float a1, float a2, - float a3, float a4, float a5, - float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) + float a0, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) { - _ParticleState &_ps = _GetPState(); - - EPASource* S = dynamic_cast(pCreateEAction(PASourceID)); - - S->_float("Rate").set(particle_rate); - S->_domain("Domain").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); - S->_domain("Velocity").set(parse_xd(_ps.Vel)); - S->_domain("Size").set(parse_xd(_ps.Size)); - S->_domain("Rotation").set(parse_xd(_ps.Rot)); - S->_domain("Color").set(parse_xd(_ps.Color)); - S->_float("Alpha").set(_ps.Alpha); - S->_float("Starting Age").set(_ps.Age); - S->_float("Age Sigma").set(_ps.AgeSigma); - S->_bool("Single Size").set(_ps.flags.is(PASource::flSingleSize)); - S->_float("Parent Motion").set(_ps.parent_motion); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + _ParticleState &_ps = _GetPState(); + + EPASource *S = dynamic_cast(pCreateEAction(PASourceID)); + + S->_float("Rate").set(particle_rate); + S->_domain("Domain").set(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); + S->_domain("Velocity").set(parse_xd(_ps.Vel)); + S->_domain("Size").set(parse_xd(_ps.Size)); + S->_domain("Rotation").set(parse_xd(_ps.Rot)); + S->_domain("Color").set(parse_xd(_ps.Color)); + S->_float("Alpha").set(_ps.Alpha); + S->_float("Starting Age").set(_ps.Age); + S->_float("Age Sigma").set(_ps.AgeSigma); + S->_bool("Single Size").set(_ps.flags.is(PASource::flSingleSize)); + S->_float("Parent Motion").set(_ps.parent_motion); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pESpeedLimit(float min_speed, float max_speed) { - EPASpeedLimit* S = dynamic_cast(pCreateEAction(PASpeedLimitID)); + EPASpeedLimit *S = dynamic_cast(pCreateEAction(PASpeedLimitID)); - S->_float("Min Speed").set(min_speed); - S->_float("Max Speed").set(max_speed); + S->_float("Min Speed").set(min_speed); + S->_float("Max Speed").set(max_speed); - _pSendAction (S); + _pSendAction(S); } void pETargetColor(float color_x, float color_y, float color_z, - float alpha, float scale) + float alpha, float scale) { - EPATargetColor* S = dynamic_cast(pCreateEAction(PATargetColorID)); - - S->_vector("Color").set(color_x, color_y, color_z); - S->_float("Alpha").set(alpha); - S->_float("Scale").set(scale); - - _pSendAction (S); + EPATargetColor *S = dynamic_cast(pCreateEAction(PATargetColorID)); + + S->_vector("Color").set(color_x, color_y, color_z); + S->_float("Alpha").set(alpha); + S->_float("Scale").set(scale); + + _pSendAction(S); } void pETargetSize(float size_x, float size_y, float size_z, - float scale_x, float scale_y, float scale_z) + float scale_x, float scale_y, float scale_z) { - EPATargetSize* S = dynamic_cast(pCreateEAction(PATargetSizeID)); - - S->_vector("Size").set(size_x, size_y, size_z); - S->_vector("Scale").set(scale_x, scale_y, scale_z); - - _pSendAction (S); + EPATargetSize *S = dynamic_cast(pCreateEAction(PATargetSizeID)); + + S->_vector("Size").set(size_x, size_y, size_z); + S->_vector("Scale").set(scale_x, scale_y, scale_z); + + _pSendAction(S); } void pETargetRotate(float rot_x, float rot_y, float rot_z, float scale) { - EPATargetRotate* S = dynamic_cast(pCreateEAction(PATargetRotateID)); + EPATargetRotate *S = dynamic_cast(pCreateEAction(PATargetRotateID)); - S->_vector("Rotation").set(rot_x, rot_y, rot_z); - S->_float("Scale").set(scale); + S->_vector("Rotation").set(rot_x, rot_y, rot_z); + S->_float("Scale").set(scale); - _pSendAction (S); + _pSendAction(S); } void pETargetRotateD(float scale, PDomainEnum dtype, - float a0, float a1, float a2, - float a3, float a4, float a5, - float a6, float a7, float a8) -{ - // generate random target value - pDomain Domain = pDomain(dtype,a0,a1,a2,a3,a4,a5,a6,a7,a8); - pVector r; - Domain.Generate(r); - - pETargetRotate(r.x,r.y,r.z,scale); + float a0, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8) +{ + // generate random target value + pDomain Domain = pDomain(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); + pVector r; + Domain.Generate(r); + + pETargetRotate(r.x, r.y, r.z, scale); } void pETargetVelocity(float vel_x, float vel_y, float vel_z, float scale, BOOL allow_translate, BOOL allow_rotate) { - EPATargetVelocity* S = dynamic_cast(pCreateEAction(PATargetVelocityID)); - - S->_vector("Velocity").set(vel_x, vel_y, vel_z); - S->_float("Scale").set(scale); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); + EPATargetVelocity *S = dynamic_cast(pCreateEAction(PATargetVelocityID)); + + S->_vector("Velocity").set(vel_x, vel_y, vel_z); + S->_float("Scale").set(scale); + S->_bool("Allow Rotate").set(allow_rotate); + + _pSendAction(S); } void pETargetVelocityD(float scale, PDomainEnum dtype, - float a0, float a1, float a2, - float a3, float a4, float a5, - float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) + float a0, float a1, float a2, + float a3, float a4, float a5, + float a6, float a7, float a8, BOOL allow_translate, BOOL allow_rotate) { - // generate random target velocity - pVector v; - pDomain Domain = pDomain(dtype,a0,a1,a2,a3,a4,a5,a6,a7,a8); - Domain.Generate(v); + // generate random target velocity + pVector v; + pDomain Domain = pDomain(dtype, a0, a1, a2, a3, a4, a5, a6, a7, a8); + Domain.Generate(v); - pETargetVelocity(v.x,v.y,v.z,scale,allow_translate,allow_rotate); + pETargetVelocity(v.x, v.y, v.z, scale, allow_translate, allow_rotate); } void pEVortex(float center_x, float center_y, float center_z, - float axis_x, float axis_y, float axis_z, - float magnitude, float epsilon, float max_radius, BOOL allow_translate, BOOL allow_rotate) + float axis_x, float axis_y, float axis_z, + float magnitude, float epsilon, float max_radius, BOOL allow_translate, BOOL allow_rotate) { - EPAVortex* S = dynamic_cast(pCreateEAction(PAVortexID)); - - S->_vector("Center").set(center_x, center_y, center_z); - S->_vector("Axis").set(axis_x, axis_y, axis_z); - S->_float("Magnitude").set(magnitude); - S->_float("Epsilon").set(epsilon); - S->_float("Max Radius").set(max_radius); - S->_bool("Allow Rotate").set(allow_rotate); - - _pSendAction (S); -} + EPAVortex *S = dynamic_cast(pCreateEAction(PAVortexID)); + S->_vector("Center").set(center_x, center_y, center_z); + S->_vector("Axis").set(axis_x, axis_y, axis_z); + S->_float("Magnitude").set(magnitude); + S->_float("Epsilon").set(epsilon); + S->_float("Max Radius").set(max_radius); + S->_bool("Allow Rotate").set(allow_rotate); + _pSendAction(S); +} //------------------------------------------------------------------------------ @@ -408,14 +406,9 @@ void pEVortex(float center_x, float center_y, float center_z, //------------------------------------------------------------------------------ - - - - - - -enum PParamType{ - ptUnknown=-1, +enum PParamType +{ + ptUnknown=-1, ptDomain=0, ptBOOL, ptFloat, @@ -424,82 +417,161 @@ enum PParamType{ ptDWORD, ptString, }; -xr_token pddomain_token [ ]={ - { "PDPoint", PDPoint }, - { "PDLine", PDLine }, - { "PDTriangle", PDTriangle }, - { "PDPlane", PDPlane }, - { "PDBox", PDBox }, - { "PDSphere", PDSphere }, - { "PDCylinder", PDCylinder }, - { "PDCone", PDCone }, - { "PDBlob", PDBlob }, - { "PDDisc", PDDisc }, - { "PDRectangle", PDRectangle }, - { 0, 0 }, + +xr_token pddomain_token [ ] = { + {"PDPoint", PDPoint}, + {"PDLine", PDLine}, + {"PDTriangle", PDTriangle}, + {"PDPlane", PDPlane}, + {"PDBox", PDBox}, + {"PDSphere", PDSphere}, + {"PDCylinder", PDCylinder}, + {"PDCone", PDCone}, + {"PDBlob", PDBlob}, + {"PDDisc", PDDisc}, + {"PDRectangle", PDRectangle}, + {0, 0}, }; -xr_token type_token [ ]={ - { "PDomainEnum", ptDomain }, - { "BOOL", ptBOOL }, - { "float", ptFloat }, - { "int", ptInt }, - { "WORD", ptWORD }, - { "u16", ptWORD }, - { "DWORD", ptDWORD }, - { "u32", ptDWORD }, - { "LPSTR", ptString }, - { "LPCSTR", ptString }, - { 0, 0 }, +xr_token type_token [ ] = { + {"PDomainEnum", ptDomain}, + {"BOOL", ptBOOL}, + {"float", ptFloat}, + {"int", ptInt}, + {"WORD", ptWORD}, + {"u16", ptWORD}, + {"DWORD", ptDWORD}, + {"u32", ptDWORD}, + {"LPSTR", ptString}, + {"LPCSTR", ptString}, + {0, 0}, }; union var { - PDomainEnum d; - float f; - int i; - BOOL b; - WORD w; - DWORD o; - string128 s; - - operator PDomainEnum() {return d;} - operator float () {return f;} - operator int () {return i;} - operator WORD () {return w;} - operator DWORD () {return o;} - operator string128& () {return s;} - - var& operator = (PDomainEnum _d) { d=_d; return *this; } - var& operator = (float _f) { f=_f; return *this; } - var& operator = (int _i) { i=_i; return *this; } - var& operator = (WORD _w) { w=_w; return *this; } - var& operator = (DWORD _o) { o=_o; return *this; } - var& operator = (string128& _s) { strcpy(s,_s); return *this; } - - var () { } - var (PDomainEnum _d): d(_d) { } - var (float _f) : f(_f) { } - var (int _i) : i(_i) { } - var (WORD _w) : w(_w) { } - var (DWORD _o) : o(_o) { } - var (string128& _s) { strcpy(s,_s); } + PDomainEnum d; + float f; + int i; + BOOL b; + WORD w; + DWORD o; + string128 s; + + operator PDomainEnum() + { + return d; + } + + operator float() + { + return f; + } + + operator int() + { + return i; + } + + operator WORD() + { + return w; + } + + operator DWORD() + { + return o; + } + + operator string128&() + { + return s; + } + + var &operator =(PDomainEnum _d) + { + d = _d; + return *this; + } + + var &operator =(float _f) + { + f = _f; + return *this; + } + + var &operator =(int _i) + { + i = _i; + return *this; + } + + var &operator =(WORD _w) + { + w = _w; + return *this; + } + + var &operator =(DWORD _o) + { + o = _o; + return *this; + } + + var &operator =(string128 &_s) + { + strcpy(s, _s); + return *this; + } + + var() { } + + var(PDomainEnum _d): d(_d) { } + + var(float _f) : f(_f) { } + + var(int _i) : i(_i) { } + + var(WORD _w) : w(_w) { } + + var(DWORD _o) : o(_o) { } + + var(string128 &_s) + { + strcpy(s, _s); + } }; -IC bool get_int(LPCSTR a, var& val) +IC + +bool get_int(LPCSTR a, var &val) { - for (int k=0; a[k]; k++) + for (int k = 0; a[k]; k++) if (!isdigit(a[k])&&(a[k]!='-')&&(a[k]!='+')) return false; val = atoi(a); return true; } -IC bool get_float(LPCSTR a, var& val) +IC + +bool get_float(LPCSTR a, var &val) { - if (strstr(a,"P_MAXFLOAT")) {val = P_MAXFLOAT; return true;} - if (strstr(a,"P_EPS")) {val = EPS_L; return true;} - if (strstr(a,"EPS_L")) {val = EPS_L; return true;} - for (int k=0; a[k]; k++){ + if (strstr(a, "P_MAXFLOAT")) + { + val = P_MAXFLOAT; + return true; + } + if (strstr(a, "P_EPS")) + { + val = EPS_L; + return true; + } + if (strstr(a, "EPS_L")) + { + val = EPS_L; + return true; + } + for (int k = 0; a[k]; k++) + { if (!isdigit(a[k])&&(a[k]!='.')&&(a[k]!='-')&&(a[k]!='+')&&(a[k]!='f')&&(a[k]!='F')) return false; } @@ -507,536 +579,678 @@ IC bool get_float(LPCSTR a, var& val) return true; } -IC bool get_bool(LPCSTR a, var& val) +IC + +bool get_bool(LPCSTR a, var &val) { - bool b0 = (0==stricmp(a,"false")); - bool b1 = (0==stricmp(a,"true")); - if (b0==b1) return false; + bool b0 = (0==stricmp(a, "false")); + bool b1 = (0==stricmp(a, "true")); + if (b0==b1) + return false; val = (BOOL)b1; return true; } -IC bool get_string(LPCSTR src, var& val) +IC + +bool get_string(LPCSTR src, var &val) { - string128 v; - _GetItem(src,1,v,'"'); - val = v; - return src&&src[0]; + string128 v; + _GetItem(src, 1, v, '"'); + val = v; + return src&&src[0]; } -IC int get_token_ID(xr_token* token_list, LPCSTR name){ - for( int i=0; token_list[i].name; i++ ) - if( !strcmp(name,token_list[i].name) ) - return token_list[i].id; +IC + +int get_token_ID(xr_token *token_list, LPCSTR name) +{ + for (int i = 0; token_list[i].name; i++) + if (!strcmp(name, token_list[i].name)) + return token_list[i].id; return -1; } -IC bool get_domain_type(LPCSTR src, var& val) +IC + +bool get_domain_type(LPCSTR src, var &val) { - val = (PDomainEnum)get_token_ID(pddomain_token,src); + val = (PDomainEnum)get_token_ID(pddomain_token, src); return (int)val>=0; } // error constants -static const int BAD_COMMAND = 0; -static const int FEW_PARAMS = 1; -static const int MANY_PARAMS = 2; -static const int BAD_PARAM = 3; -static const int STA_MISSING = 4; +static const int BAD_COMMAND = 0; +static const int FEW_PARAMS = 1; +static const int MANY_PARAMS = 2; +static const int BAD_PARAM = 3; +static const int STA_MISSING = 4; void ErrMsg(LPCSTR ps, int c, int l, int v, LPCSTR line) { - switch (c){ - case BAD_COMMAND: ELog.Msg(mtError,"[Error] '%s'(%d): Unrecognized command: '%s'",ps,l+1,line); break; - case FEW_PARAMS: ELog.Msg(mtError,"[Error] '%s': Too few parameters in call to '%s'",ps,line); break; - case MANY_PARAMS: ELog.Msg(mtError,"[Error] '%s': Extra parameters in call to '%s'",ps,line); break; - case BAD_PARAM: ELog.Msg(mtError,"[Error] '%s'(%d): Bad parameter '%d' - '%s'",ps,l+1,v,line); break; - case STA_MISSING: ELog.Msg(mtError,"[Error] '%s'(%d): Statement missing ';'",ps,l+1,line); break; + switch (c) + { + case BAD_COMMAND: ELog.Msg(mtError, "[Error] '%s'(%d): Unrecognized command: '%s'", ps, l+1, line); + break; + case FEW_PARAMS: ELog.Msg(mtError, "[Error] '%s': Too few parameters in call to '%s'", ps, line); + break; + case MANY_PARAMS: ELog.Msg(mtError, "[Error] '%s': Extra parameters in call to '%s'", ps, line); + break; + case BAD_PARAM: ELog.Msg(mtError, "[Error] '%s'(%d): Bad parameter '%d' - '%s'", ps, l+1, v, line); + break; + case STA_MISSING: ELog.Msg(mtError, "[Error] '%s'(%d): Statement missing ';'", ps, l+1, line); + break; } } -namespace PS{ -class PFunction{ +namespace PS +{ +class PFunction +{ public: - CPEDef* parent; - // command - AnsiString command; + CPEDef *parent; + // command + AnsiString command; + // type - enum Type{ - ftState, + enum Type + { + ftState, ftAction }; - Type type; + + Type type; + // params - struct Param{ - PParamType type; - AnsiString hint; - AnsiString s_data; - var data; - Param(){hint="";s_data="";data=0;} + struct Param + { + PParamType type; + AnsiString hint; + AnsiString s_data; + var data; + + Param() + { + hint = ""; + s_data = ""; + data = 0; + } }; - - int req_params; - DEFINE_VECTOR(Param,ParamVec,ParamIt); - ParamVec params; - - LPCSTR src; -public: - PFunction (){req_params=-1;parent=0;} - bool LoadTemplate(LPCSTR line) + + int req_params; + DEFINE_VECTOR(Param, ParamVec, ParamIt); + ParamVec params; + + LPCSTR src; +public: + PFunction() + { + req_params = -1; + parent = 0; + } + + bool LoadTemplate(LPCSTR line) { - src = line; - AnsiString pms; - _GetItem (line,0,command,'('); - _GetItem (line,1,pms,'('); - _GetItem (pms.c_str(),0,pms,')'); - bool bRes = true; - int p_cnt = _GetItemCount(pms.c_str()); - for (int k=0; kparams.size()){ - ErrMsg (*parent->m_Name,MANY_PARAMS,l,0,line); - return false; + AnsiString pms, pm; + _GetItem(line, 1, pms, '('); + _GetItem(pms.c_str(), 0, pms, ')'); + bool bRes = true; + int p_cnt = _GetItemCount(pms.c_str()); + if (p_cnt>params.size()) + { + ErrMsg(*parent->m_Name, MANY_PARAMS, l, 0, line); + return false; } - if (p_cntm_Name,FEW_PARAMS,l,0,line); - return false; + if (p_cntm_Name, FEW_PARAMS, l, 0, line); + return false; } - for (int k=0; km_Name,BAD_PARAM,l,k,pm.c_str()); - break; + if (!bRes) + { + ErrMsg(*parent->m_Name, BAD_PARAM, l, k, pm.c_str()); + break; } } return bRes; } + void Execute() - { - #define p(i) params[i].data - #define P1 p(0) - #define P2 P1,p(1) - #define P3 P2,p(2) - #define P4 P3,p(3) - #define P5 P4,p(4) - #define P6 P5,p(5) - #define P7 P6,p(6) - #define P8 P7,p(7) - #define P9 P8,p(8) - #define P10 P9,p(9) - #define P11 P10,p(10) - #define P12 P11,p(11) - #define P13 P12,p(12) - #define P14 P13,p(13) - #define P15 P14,p(14) - // state - if (command=="pColor") pColor (P4); - else if (command=="pColorD") pColorD (P11); - else if (command=="pVelocity") pVelocity (P3); - else if (command=="pVelocityD") pVelocityD (P10); - else if (command=="pVertexB") pVertexB (P3); - else if (command=="pVertexBD") pVertexBD (P10); - else if (command=="pVertexBTracks") pVertexBTracks (P1); - else if (command=="pSize") pSize (P3); - else if (command=="pSizeD") pSizeD (P11); - else if (command=="pRotate") pRotate (P3); - else if (command=="pRotateD") pRotateD (P10); - else if (command=="pStartingAge") pStartingAge (P2); - else if (command=="pSetMaxParticles") pSetMaxParticles(P1); -// else if (command=="pObject") parent->pObject (P1); -// else if (command=="pAlignToPath") parent->pAlignToPath(P3); -// else if (command=="pVelocityScale") parent->pVelocityScale(P3); -// else if (command=="pCollision") parent->pCollision(P4); -// else if (command=="pSprite") parent->pSprite (P2); -// else if (command=="pFrame") parent->pFrame (P6); -// else if (command=="pTimeLimit") parent->pTimeLimit(P1); -// else if (command=="pParentMotion") pParentMotion (P1); + { +#define p(i) params[i].data +#define P1 p(0) +#define P2 P1,p(1) +#define P3 P2,p(2) +#define P4 P3,p(3) +#define P5 P4,p(4) +#define P6 P5,p(5) +#define P7 P6,p(6) +#define P8 P7,p(7) +#define P9 P8,p(8) +#define P10 P9,p(9) +#define P11 P10,p(10) +#define P12 P11,p(11) +#define P13 P12,p(12) +#define P14 P13,p(13) +#define P15 P14,p(14) + // state + if (command=="pColor") + pColor(P4); + else if (command=="pColorD") + pColorD(P11); + else if (command=="pVelocity") + pVelocity(P3); + else if (command=="pVelocityD") + pVelocityD(P10); + else if (command=="pVertexB") + pVertexB(P3); + else if (command=="pVertexBD") + pVertexBD(P10); + else if (command=="pVertexBTracks") + pVertexBTracks(P1); + else if (command=="pSize") + pSize(P3); + else if (command=="pSizeD") + pSizeD(P11); + else if (command=="pRotate") + pRotate(P3); + else if (command=="pRotateD") + pRotateD(P10); + else if (command=="pStartingAge") + pStartingAge(P2); + else if (command=="pSetMaxParticles") + pSetMaxParticles(P1); + // else if (command=="pObject") parent->pObject (P1); + // else if (command=="pAlignToPath") parent->pAlignToPath(P3); + // else if (command=="pVelocityScale") parent->pVelocityScale(P3); + // else if (command=="pCollision") parent->pCollision(P4); + // else if (command=="pSprite") parent->pSprite (P2); + // else if (command=="pFrame") parent->pFrame (P6); + // else if (command=="pTimeLimit") parent->pTimeLimit(P1); + // else if (command=="pParentMotion") pParentMotion (P1); // actions -// else if (command=="pAnimate") parent->pAnimate(P2); - else if (command=="pAvoid") pEAvoid (P15); - else if (command=="pBounce") pEBounce (P15); - else if (command=="pCopyVertexB") pECopyVertexB (P1); - else if (command=="pDamping") pEDamping (P5); - else if (command=="pExplosion") pEExplosion (P10); - else if (command=="pFollow") pEFollow (P3); - else if (command=="pGravitate") pEGravitate (P3); - else if (command=="pGravity") pEGravity (P5); - else if (command=="pJet") pEJet (P8); - else if (command=="pKillOld") pEKillOld (P2); - else if (command=="pMatchVelocity") pEMatchVelocity (P3); - else if (command=="pMove") pEMove (); - else if (command=="pOrbitLine") pEOrbitLine (P11); - else if (command=="pOrbitPoint") pEOrbitPoint (P8); - else if (command=="pRandomAccel") pERandomAccel (P12); - else if (command=="pRandomDisplace") pERandomDisplace (P12); - else if (command=="pRandomVelocity") pERandomVelocity (P12); - else if (command=="pRestore") pERestore (P1); - else if (command=="pSink") pESink (P13); - else if (command=="pSinkVelocity") pESinkVelocity (P13); - else if (command=="pSource") pESource (P13); - else if (command=="pSpeedLimit") pESpeedLimit (P2); - else if (command=="pTargetColor") pETargetColor (P5); - else if (command=="pTargetSize") pETargetSize (P6); - else if (command=="pTargetRotate") pETargetRotate (P4); - else if (command=="pTargetRotateD") pETargetRotateD (P11); - else if (command=="pTargetVelocity") pETargetVelocity (P6); - else if (command=="pTargetVelocityD") pETargetVelocityD(P13); - else if (command=="pVortex") pEVortex (P11); -// else THROW2("Unknown Command."); - #undef p - #undef P1 - #undef P2 - #undef P3 - #undef P4 - #undef P5 - #undef P6 - #undef P7 - #undef P8 - #undef P9 - #undef P10 - #undef P11 - #undef P12 - #undef P13 - #undef P14 - #undef P15 + // else if (command=="pAnimate") parent->pAnimate(P2); + else if (command=="pAvoid") + pEAvoid(P15); + else if (command=="pBounce") + pEBounce(P15); + else if (command=="pCopyVertexB") + pECopyVertexB(P1); + else if (command=="pDamping") + pEDamping(P5); + else if (command=="pExplosion") + pEExplosion(P10); + else if (command=="pFollow") + pEFollow(P3); + else if (command=="pGravitate") + pEGravitate(P3); + else if (command=="pGravity") + pEGravity(P5); + else if (command=="pJet") + pEJet(P8); + else if (command=="pKillOld") + pEKillOld(P2); + else if (command=="pMatchVelocity") + pEMatchVelocity(P3); + else if (command=="pMove") + pEMove(); + else if (command=="pOrbitLine") + pEOrbitLine(P11); + else if (command=="pOrbitPoint") + pEOrbitPoint(P8); + else if (command=="pRandomAccel") + pERandomAccel(P12); + else if (command=="pRandomDisplace") + pERandomDisplace(P12); + else if (command=="pRandomVelocity") + pERandomVelocity(P12); + else if (command=="pRestore") + pERestore(P1); + else if (command=="pSink") + pESink(P13); + else if (command=="pSinkVelocity") + pESinkVelocity(P13); + else if (command=="pSource") + pESource(P13); + else if (command=="pSpeedLimit") + pESpeedLimit(P2); + else if (command=="pTargetColor") + pETargetColor(P5); + else if (command=="pTargetSize") + pETargetSize(P6); + else if (command=="pTargetRotate") + pETargetRotate(P4); + else if (command=="pTargetRotateD") + pETargetRotateD(P11); + else if (command=="pTargetVelocity") + pETargetVelocity(P6); + else if (command=="pTargetVelocityD") + pETargetVelocityD(P13); + else if (command=="pVortex") + pEVortex(P11); + // else THROW2("Unknown Command."); +#undef p +#undef P1 +#undef P2 +#undef P3 +#undef P4 +#undef P5 +#undef P6 +#undef P7 +#undef P8 +#undef P9 +#undef P10 +#undef P11 +#undef P12 +#undef P13 +#undef P14 +#undef P15 } }; } -DEFINE_MAP(AnsiString,PFunction,PFuncMap,PFuncPairIt); -DEFINE_VECTOR(PFunction,PFuncVec,PFuncIt); +DEFINE_MAP(AnsiString, PFunction, PFuncMap, PFuncPairIt); +DEFINE_VECTOR(PFunction, PFuncVec, PFuncIt); static PFuncMap CommandTemplates; -static LPCSTR PStateCommands[]={ -// "pResetState();", - "pColor(float red, float green, float blue, float alpha=1.0f);", - "pColorD(float alpha, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f);", - "pRotate(float rot_x, float rot_y=0.f, float rot_z=0.f);", - "pRotateD(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f);", - "pSize(float size_x, float size_y=1.0f, float size_z=1.0f);", - "pSizeD(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL single_size=TRUE);", - "pStartingAge(float age, float sigma=1.0f);", - "pVelocity(float x, float y, float z);", - "pVelocityD(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f);", - "pVertexB(float x, float y, float z);", - "pVertexBD(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f);", - "pVertexBTracks(BOOL track_vertex=TRUE);", - "pSetMaxParticles(int max_count);", -// our - "pParentMotion(float scale);", - "pAlignToPath(float rot_x=-1.57f, float rot_y=0.f, float rot_z=0.f);", +static LPCSTR PStateCommands[] = { + // "pResetState();", + "pColor(float red, float green, float blue, float alpha=1.0f);", + "pColorD(float alpha, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f);", + "pRotate(float rot_x, float rot_y=0.f, float rot_z=0.f);", + "pRotateD(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f);", + "pSize(float size_x, float size_y=1.0f, float size_z=1.0f);", + "pSizeD(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL single_size=TRUE);", + "pStartingAge(float age, float sigma=1.0f);", + "pVelocity(float x, float y, float z);", + "pVelocityD(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f);", + "pVertexB(float x, float y, float z);", + "pVertexBD(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f);", + "pVertexBTracks(BOOL track_vertex=TRUE);", + "pSetMaxParticles(int max_count);", + // our + "pParentMotion(float scale);", + "pAlignToPath(float rot_x=-1.57f, float rot_y=0.f, float rot_z=0.f);", "pVelocityScale(float scale_x=0.f, float scale_y=0.f, float scale_z=0.f);", "pCollision(float friction, float resilience, float cutoff, BOOL destroy_on_contact=FALSE);", -// "pObject(LPCSTR obj_name);", + // "pObject(LPCSTR obj_name);", "pSprite(LPCSTR sh_name, LPCSTR tex_name);", "pFrame(BOOL random_frame=TRUE, u32 frame_count=16, u32 texture_width=128, u32 texture_height=128, u32 frame_width=32, u32 frame_height=32);", - "pTimeLimit(float time_limit);", + "pTimeLimit(float time_limit);", 0 }; -static LPCSTR PActionCommands[]={ - "pAvoid(float magnitude, float epsilon, float look_ahead, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pBounce(float friction, float resilience, float cutoff, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pCopyVertexB(BOOL copy_pos=TRUE);", - "pDamping(float damping_x, float damping_y, float damping_z, float vlow=0.0f, float vhigh=P_MAXFLOAT);", - "pExplosion(float center_x, float center_y, float center_z, float velocity, float magnitude, float stdev, float epsilon=EPS_L, float age=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pFollow(float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT);", - "pGravitate(float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT);", - "pGravity(float dir_x, float dir_y, float dir_z, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pJet(float center_x, float center_y, float center_z, float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pKillOld(float age_limit, BOOL kill_less_than=FALSE);", - "pMatchVelocity(float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT);", - "pMove();", - "pOrbitLine(float p_x, float p_y, float p_z, float axis_x, float axis_y, float axis_z, float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pOrbitPoint(float center_x, float center_y, float center_z, float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pRandomAccel(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pRandomDisplace(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pRandomVelocity(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pRestore(float time);", - "pSink(BOOL kill_inside, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pSinkVelocity(BOOL kill_inside, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pSource(float particle_rate, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pSpeedLimit(float min_speed, float max_speed=P_MAXFLOAT);", - "pTargetColor(float color_x, float color_y, float color_z, float alpha, float scale);", - "pTargetSize(float size_x, float size_y, float size_z, float scale_x=0.0f, float scale_y=0.0f, float scale_z=0.0f);", - "pTargetRotate(float rot_x, float rot_y, float rot_z, float scale=0.0f);", - "pTargetRotateD(float scale, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f);", - "pTargetVelocity(float vel_x, float vel_y, float vel_z, float scale, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pTargetVelocityD(float scale, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", - "pVertex(float x, float y, float z);", - "pVortex(float center_x, float center_y, float center_z, float axis_x, float axis_y, float axis_z, float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", +static LPCSTR PActionCommands[] = { + "pAvoid(float magnitude, float epsilon, float look_ahead, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pBounce(float friction, float resilience, float cutoff, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pCopyVertexB(BOOL copy_pos=TRUE);", + "pDamping(float damping_x, float damping_y, float damping_z, float vlow=0.0f, float vhigh=P_MAXFLOAT);", + "pExplosion(float center_x, float center_y, float center_z, float velocity, float magnitude, float stdev, float epsilon=EPS_L, float age=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pFollow(float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT);", + "pGravitate(float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT);", + "pGravity(float dir_x, float dir_y, float dir_z, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pJet(float center_x, float center_y, float center_z, float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pKillOld(float age_limit, BOOL kill_less_than=FALSE);", + "pMatchVelocity(float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT);", + "pMove();", + "pOrbitLine(float p_x, float p_y, float p_z, float axis_x, float axis_y, float axis_z, float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pOrbitPoint(float center_x, float center_y, float center_z, float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pRandomAccel(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pRandomDisplace(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pRandomVelocity(PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pRestore(float time);", + "pSink(BOOL kill_inside, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pSinkVelocity(BOOL kill_inside, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pSource(float particle_rate, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pSpeedLimit(float min_speed, float max_speed=P_MAXFLOAT);", + "pTargetColor(float color_x, float color_y, float color_z, float alpha, float scale);", + "pTargetSize(float size_x, float size_y, float size_z, float scale_x=0.0f, float scale_y=0.0f, float scale_z=0.0f);", + "pTargetRotate(float rot_x, float rot_y, float rot_z, float scale=0.0f);", + "pTargetRotateD(float scale, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f);", + "pTargetVelocity(float vel_x, float vel_y, float vel_z, float scale, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pTargetVelocityD(float scale, PDomainEnum dtype, float a0=0.0f, float a1=0.0f, float a2=0.0f, float a3=0.0f, float a4=0.0f, float a5=0.0f, float a6=0.0f, float a7=0.0f, float a8=0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", + "pVertex(float x, float y, float z);", + "pVortex(float center_x, float center_y, float center_z, float axis_x, float axis_y, float axis_z, float magnitude=1.0f, float epsilon=EPS_L, float max_radius=P_MAXFLOAT, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE);", // our - "pAnimate(float speed=24.f, BOOL random_playback=FALSE);", + "pAnimate(float speed=24.f, BOOL random_playback=FALSE);", 0 }; bool InitCommandTemplates() { - PFuncMap& ct = CommandTemplates; - bool bRes=true; - do{ - int k; + PFuncMap &ct = CommandTemplates; + bool bRes = true; + do + { + int k; // load state commands - for (k=0; PStateCommands[k]; k++){ - PS::PFunction F; F.type = PFunction::ftState; - if (!(bRes=F.LoadTemplate(PStateCommands[k]))) break; - ct.insert(mk_pair(F.command,F)); + for (k = 0; PStateCommands[k]; k++) + { + PS::PFunction F; + F.type = PFunction::ftState; + if (!(bRes = F.LoadTemplate(PStateCommands[k]))) + break; + ct.insert(mk_pair(F.command, F)); } - if (!bRes) break; - // load action commands - for (k=0; PActionCommands[k]; k++){ - PFunction F; F.type = PS::PFunction::ftAction; - if (!(bRes=F.LoadTemplate(PActionCommands[k]))) break; - ct.insert(mk_pair(F.command,F)); + if (!bRes) + break; + // load action commands + for (k = 0; PActionCommands[k]; k++) + { + PFunction F; + F.type = PS::PFunction::ftAction; + if (!(bRes = F.LoadTemplate(PActionCommands[k]))) + break; + ct.insert(mk_pair(F.command, F)); } - }while(0); - if (!bRes) ct.clear(); + } while (0); + if (!bRes) + ct.clear(); return bRes; } #include -const AnsiString GetFunctionTemplate(const AnsiString& command) + +const AnsiString GetFunctionTemplate(const AnsiString &command) { - LPCSTR dest=0; - PFunction* F = CPEDef::FindCommandPrototype(command.c_str(),dest); - AnsiString text = ""; - if (F){ - text.sprintf("%-16s(",F->command); - if (!F->params.empty()){ - for (PFunction::ParamIt it=F->params.begin(); it!=F->params.end(); it++){ - text += it->s_data; - text += ", "; + LPCSTR dest = 0; + PFunction *F = CPEDef::FindCommandPrototype(command.c_str(), dest); + AnsiString text = ""; + if (F) + { + text.sprintf("%-16s(", F->command); + if (!F->params.empty()) + { + for (PFunction::ParamIt it = F->params.begin(); it!=F->params.end(); it++) + { + text += it->s_data; + text += ", "; } - text.Delete (text.Length()-1,2); + text.Delete(text.Length()-1, 2); } - text += ");"; + text += ");"; } return text; } -void FillStateMenu(TMenuItem* root, TNotifyEvent on_click) +void FillStateMenu(TMenuItem *root, TNotifyEvent on_click) { - // load templates - if (CommandTemplates.empty()) R_ASSERT(InitCommandTemplates()); - - for (PFuncPairIt b=CommandTemplates.begin(); b!=CommandTemplates.end(); b++){ - if (b->second.type==PFunction::ftState){ - TMenuItem* mi = xr_new((TComponent*)0); - mi->Caption = b->second.command; - mi->OnClick = on_click; - root->Insert (root->Count,mi); + // load templates + if (CommandTemplates.empty()) + R_ASSERT(InitCommandTemplates()); + + for (PFuncPairIt b = CommandTemplates.begin(); b!=CommandTemplates.end(); b++) + { + if (b->second.type==PFunction::ftState) + { + TMenuItem *mi = xr_new((TComponent*)0); + mi->Caption = b->second.command; + mi->OnClick = on_click; + root->Insert(root->Count, mi); } } } -void FillActionMenu(TMenuItem* root, TNotifyEvent on_click) + +void FillActionMenu(TMenuItem *root, TNotifyEvent on_click) { - // load templates - if (CommandTemplates.empty()) R_ASSERT(InitCommandTemplates()); - - for (PFuncPairIt b=CommandTemplates.begin(); b!=CommandTemplates.end(); b++){ - if (b->second.type==PFunction::ftAction){ - TMenuItem* mi = xr_new((TComponent*)0); - mi->Caption = b->second.command; - mi->OnClick = on_click; - root->Insert (root->Count,mi); + // load templates + if (CommandTemplates.empty()) + R_ASSERT(InitCommandTemplates()); + + for (PFuncPairIt b = CommandTemplates.begin(); b!=CommandTemplates.end(); b++) + { + if (b->second.type==PFunction::ftAction) + { + TMenuItem *mi = xr_new((TComponent*)0); + mi->Caption = b->second.command; + mi->OnClick = on_click; + root->Insert(root->Count, mi); } } } -PFunction* CPEDef::FindCommandPrototype(LPCSTR src, LPCSTR& dest) +PFunction *CPEDef::FindCommandPrototype(LPCSTR src, LPCSTR &dest) { - // load templates - if (CommandTemplates.empty()) R_ASSERT(InitCommandTemplates()); + // load templates + if (CommandTemplates.empty()) + R_ASSERT(InitCommandTemplates()); - AnsiString command; - _GetItem (src,0,command,'('); + AnsiString command; + _GetItem(src, 0, command, '('); // comment - if (command==strstr(command.c_str(),"//")){ dest=0; return 0; } + if (command==strstr(command.c_str(), "//")) + { + dest = 0; + return 0; + } // find command in templates PFuncPairIt pfp_it = CommandTemplates.find(command); - if (pfp_it==CommandTemplates.end()) return 0; - else{ - dest = pfp_it->second.src; - return &pfp_it->second; + if (pfp_it==CommandTemplates.end()) + return 0; + else + { + dest = pfp_it->second.src; + return &pfp_it->second; } } void CPEDef::Compile() { -/* - m_Actions.clear (); - m_Actions.w_u32 (m_EActionList.size()); - for (EPAVecIt it=m_EActionList.begin(); it!=m_EActionList.end(); it++){ - (*it)->Compile(m_Actions); - } -*/ - // load templates - if (CommandTemplates.empty()) R_ASSERT(InitCommandTemplates()); + /* + m_Actions.clear (); + m_Actions.w_u32 (m_EActionList.size()); + for (EPAVecIt it=m_EActionList.begin(); it!=m_EActionList.end(); it++){ + (*it)->Compile(m_Actions); + } + */ + // load templates + if (CommandTemplates.empty()) + R_ASSERT(InitCommandTemplates()); // parse - LPSTRVec lst; - _SequenceToList (lst,m_SourceText.c_str(),'\r'); // 0x0d 0x0a \n \r + LPSTRVec lst; + _SequenceToList(lst, m_SourceText.c_str(), '\r'); // 0x0d 0x0a \n \r // reset flags -//. m_Flags.zero (); - + //. m_Flags.zero (); + // parse commands - static PFuncVec Commands; - Commands.clear (); - bool bRes=true; - for (int i_line=0; i_line<(int)lst.size(); i_line++){ - LPSTRIt it = lst.begin() + i_line; - AnsiString command,line; - _GetItem (*it,0,command,'('); + static PFuncVec Commands; + Commands.clear(); + bool bRes = true; + for (int i_line = 0; i_line<(int)lst.size(); i_line++) + { + LPSTRIt it = lst.begin()+i_line; + AnsiString command, line; + _GetItem(*it, 0, command, '('); // comment - if (command==strstr(command.c_str(),"//")) continue; + if (command==strstr(command.c_str(), "//")) + continue; // check ';' found - _GetItem (*it,1,line,')'); - if (line!=strstr(line.c_str(),";")){ - ErrMsg (*m_Name,STA_MISSING,i_line,0,*it); - bRes = false; + _GetItem(*it, 1, line, ')'); + if (line!=strstr(line.c_str(), ";")) + { + ErrMsg(*m_Name, STA_MISSING, i_line, 0, *it); + bRes = false; break; } // find command in templates - PFuncPairIt pfp_it = CommandTemplates.find(command.c_str()); - if (pfp_it==CommandTemplates.end()){ - ErrMsg (*m_Name,BAD_COMMAND,i_line,0,*it); - bRes = false; + PFuncPairIt pfp_it = CommandTemplates.find(command.c_str()); + if (pfp_it==CommandTemplates.end()) + { + ErrMsg(*m_Name, BAD_COMMAND, i_line, 0, *it); + bRes = false; break; } Commands.push_back(PFunction()); - PFunction& F = Commands.back(); - F = pfp_it->second; - F.parent = this; + PFunction &F = Commands.back(); + F = pfp_it->second; + F.parent = this; // parse params - if (!(bRes=F.Parse(i_line,*it))) break; + if (!(bRes = F.Parse(i_line, *it))) + break; } // free list - for (LPSTRIt it=lst.begin(); it!=lst.end(); it++) - xr_free(*it); + for (LPSTRIt it = lst.begin(); it!=lst.end(); it++) + xr_free(*it); + + if (!bRes) + return; - if (!bRes) return; - // destroy shader (may be changed) -//. m_CachedShader.destroy (); - + //. m_CachedShader.destroy (); + // create temporary handles - int effect_handle = pGenParticleEffects(1, 1); - int action_list_handle = pGenActionLists(); - pCurrentEffect (effect_handle); + int effect_handle = pGenParticleEffects(1, 1); + int action_list_handle = pGenActionLists(); + pCurrentEffect(effect_handle); // reset state (îäèíàêîâûå íà÷àëüíûå óñëîâèÿ) - pResetState (); - - try{ - g_parent = this; + pResetState(); + + try + { + g_parent = this; // execute commands PFuncIt pf_it; // at first state commands - for (pf_it=Commands.begin(); pf_it!=Commands.end(); pf_it++) - if (PFunction::ftState==pf_it->type) pf_it->Execute(); + for (pf_it = Commands.begin(); pf_it!=Commands.end(); pf_it++) + if (PFunction::ftState==pf_it->type) + pf_it->Execute(); // at next action commands - pNewActionList (action_list_handle); - for (pf_it=Commands.begin(); pf_it!=Commands.end(); pf_it++) - if (PFunction::ftAction==pf_it->type) pf_it->Execute(); - pEndActionList (); - + pNewActionList(action_list_handle); + for (pf_it = Commands.begin(); pf_it!=Commands.end(); pf_it++) + if (PFunction::ftAction==pf_it->type) + pf_it->Execute(); + pEndActionList(); + // save effect data - ParticleEffect *pe = _GetEffectPtr(effect_handle); R_ASSERT(pe); - m_MaxParticles = pe->max_particles; - + ParticleEffect *pe = _GetEffectPtr(effect_handle); + R_ASSERT(pe); + m_MaxParticles = pe->max_particles; + // save action list -// ParticleActions* pa = _GetListPtr(action_list_handle); R_ASSERT(pa); -// m_Actions.clear (); -// m_Actions.w_u32 (pa->size()); -// for (PAVecIt it=pa->begin(); it!=pa->end(); it++){ -// m_Actions.w_u32 ((*it)->type); -// (*it)->Save (m_Actions); -// } - - }catch(...){ - g_parent = 0; + // ParticleActions* pa = _GetListPtr(action_list_handle); R_ASSERT(pa); + // m_Actions.clear (); + // m_Actions.w_u32 (pa->size()); + // for (PAVecIt it=pa->begin(); it!=pa->end(); it++){ + // m_Actions.w_u32 ((*it)->type); + // (*it)->Save (m_Actions); + // } + } catch (...) + { + g_parent = 0; } - g_parent = 0; + g_parent = 0; // destroy temporary handls - pDeleteParticleEffects (effect_handle); - pDeleteActionLists (action_list_handle); + pDeleteParticleEffects(effect_handle); + pDeleteActionLists(action_list_handle); -//. if (m_ShaderName&&m_ShaderName[0]&&m_TextureName&&m_TextureName[0]) -//. m_CachedShader.create(m_ShaderName,m_TextureName); + //. if (m_ShaderName&&m_ShaderName[0]&&m_TextureName&&m_TextureName[0]) + //. m_CachedShader.create(m_ShaderName,m_TextureName); } + /* void CPEDef::Compile() { - // load templates - if (CommandTemplates.empty()) R_ASSERT(InitCommandTemplates()); + // load templates + if (CommandTemplates.empty()) R_ASSERT(InitCommandTemplates()); // parse LPSTRVec lst; _SequenceToList (lst,m_SourceText.c_str(),'\r'); // 0x0d 0x0a \n \r // reset flags - m_Flags.zero (); + m_Flags.zero (); // parse commands - static PFuncVec Commands; + static PFuncVec Commands; Commands.clear (); bool bRes=true; - for (int i_line=0; i_line<(int)lst.size(); i_line++){ - LPSTRIt it = lst.begin() + i_line; + for (int i_line=0; i_line<(int)lst.size(); i_line++){ + LPSTRIt it = lst.begin() + i_line; AnsiString command,line; _GetItem (*it,0,command,'('); // comment @@ -1044,19 +1258,19 @@ void CPEDef::Compile() // check ';' found _GetItem (*it,1,line,')'); if (line!=strstr(line.c_str(),";")){ - ErrMsg (STA_MISSING,i_line,0,*it); + ErrMsg (STA_MISSING,i_line,0,*it); bRes = false; break; } // find command in templates - PFuncPairIt pfp_it = CommandTemplates.find(command.c_str()); + PFuncPairIt pfp_it = CommandTemplates.find(command.c_str()); if (pfp_it==CommandTemplates.end()){ - ErrMsg (BAD_COMMAND,i_line,0,*it); + ErrMsg (BAD_COMMAND,i_line,0,*it); bRes = false; break; } Commands.push_back(PFunction()); - PFunction& F = Commands.back(); + PFunction& F = Commands.back(); F = pfp_it->second; F.parent = this; // parse params @@ -1064,7 +1278,7 @@ void CPEDef::Compile() } // free list for (LPSTRIt it=lst.begin(); it!=lst.end(); it++) - xr_free(*it); + xr_free(*it); if (!bRes) return; @@ -1072,9 +1286,9 @@ void CPEDef::Compile() m_CachedShader.destroy (); // create temporary handles - int effect_handle = pGenParticleEffects(1, 1); + int effect_handle = pGenParticleEffects(1, 1); int action_list_handle = pGenActionLists(); - pCurrentEffect (effect_handle); + pCurrentEffect (effect_handle); // reset state (îäèíàêîâûå íà÷àëüíûå óñëîâèÿ) pResetState (); @@ -1083,32 +1297,31 @@ void CPEDef::Compile() PFuncIt pf_it; // at first state commands for (pf_it=Commands.begin(); pf_it!=Commands.end(); pf_it++) - if (PFunction::ftState==pf_it->type) pf_it->Execute(); + if (PFunction::ftState==pf_it->type) pf_it->Execute(); // at next action commands - pNewActionList (action_list_handle); + pNewActionList (action_list_handle); for (pf_it=Commands.begin(); pf_it!=Commands.end(); pf_it++) - if (PFunction::ftAction==pf_it->type) pf_it->Execute(); - pEndActionList (); + if (PFunction::ftAction==pf_it->type) pf_it->Execute(); + pEndActionList (); // save effect data - ParticleEffect *pe = _GetEffectPtr(effect_handle); R_ASSERT(pe); + ParticleEffect *pe = _GetEffectPtr(effect_handle); R_ASSERT(pe); m_MaxParticles = pe->max_particles; // save action list - PAPI::PAHeader *pa = _GetListPtr(action_list_handle); R_ASSERT(pa); - m_ActionCount = pa->count-1; - PAPI::PAHeader *action = pa+1; + PAPI::PAHeader *pa = _GetListPtr(action_list_handle); R_ASSERT(pa); + m_ActionCount = pa->count-1; + PAPI::PAHeader *action = pa+1; xr_free (m_ActionList); m_ActionList = xr_alloc(m_ActionCount); Memory.mem_copy (m_ActionList,action,m_ActionCount*sizeof(PAPI::PAHeader)); // destroy temporary handls - pDeleteParticleEffects (effect_handle); - pDeleteActionLists (action_list_handle); + pDeleteParticleEffects (effect_handle); + pDeleteActionLists (action_list_handle); if (m_ShaderName&&m_ShaderName[0]&&m_TextureName&&m_TextureName[0]) - m_CachedShader.create(m_ShaderName,m_TextureName); + m_CachedShader.create(m_ShaderName,m_TextureName); } */ - diff --git a/src/editors/ParticleEditor/ParticleGroupEditor.cpp b/src/editors/ParticleEditor/ParticleGroupEditor.cpp index b9ac8eb7459..f2d7ed6eafc 100644 --- a/src/editors/ParticleEditor/ParticleGroupEditor.cpp +++ b/src/editors/ParticleEditor/ParticleGroupEditor.cpp @@ -2,192 +2,215 @@ #include "stdafx.h" #pragma hdrstop -#include "..\..\Layers\xrRender\ParticleGroup.h" -#include "../../xrServerEntities/PropertiesListHelper.h" +#include "Layers/xrRender/ParticleGroup.h" +#include "xrServerEntities/PropertiesListHelper.h" #include "ui_main.h" -#include "ui_particletools.h" +#include "UI_ParticleTools.h" -BOOL PS::CPGDef::SEffect::Equal(const SEffect& src) +BOOL PS::CPGDef::SEffect::Equal(const SEffect &src) { - if (!m_Flags.equal(src.m_Flags)) return FALSE; - if (!m_EffectName.equal(src.m_EffectName)) return FALSE; - if (!fsimilar(m_Time0,src.m_Time0)) return FALSE; - if (!fsimilar(m_Time1,src.m_Time1)) return FALSE; - return TRUE; + if (!m_Flags.equal(src.m_Flags)) + return FALSE; + if (!m_EffectName.equal(src.m_EffectName)) + return FALSE; + if (!fsimilar(m_Time0, src.m_Time0)) + return FALSE; + if (!fsimilar(m_Time1, src.m_Time1)) + return FALSE; + return TRUE; } -BOOL PS::CPGDef::Equal(const CPGDef* pg) +BOOL PS::CPGDef::Equal(const CPGDef *pg) { - if (!m_Flags.equal(pg->m_Flags)) return FALSE; - if (!fsimilar(m_fTimeLimit,pg->m_fTimeLimit)) return FALSE; - if (m_Effects.size()!=pg->m_Effects.size()) return FALSE; - EffectIt s_it=m_Effects.begin(); - for (EffectIt d_it=m_Effects.begin(); d_it!=m_Effects.end(); s_it++,d_it++) - if (!(*s_it)->Equal(**d_it)) return FALSE; - return TRUE; + if (!m_Flags.equal(pg->m_Flags)) + return FALSE; + if (!fsimilar(m_fTimeLimit, pg->m_fTimeLimit)) + return FALSE; + if (m_Effects.size()!=pg->m_Effects.size()) + return FALSE; + EffectIt s_it = m_Effects.begin(); + for (EffectIt d_it = m_Effects.begin(); d_it!=m_Effects.end(); s_it++,d_it++) + if (!(*s_it)->Equal(**d_it)) + return FALSE; + return TRUE; } bool PS::CPGDef::Validate(bool bMsg) { - bool failed = false; + bool failed = false; - xr_vector::const_iterator pe_it = m_Effects.begin(); - xr_vector::const_iterator pe_it_e = m_Effects.end(); + xr_vector::const_iterator pe_it = m_Effects.begin(); + xr_vector::const_iterator pe_it_e = m_Effects.end(); - for(;pe_it!=pe_it_e;++pe_it) - { - PS::CPGDef::SEffect* Eff = (*pe_it); - PS::CPEDef* ped = ::Render->PSLibrary.FindPED(Eff->m_EffectName.c_str()); - if(!ped) + for (; pe_it!=pe_it_e; ++pe_it) + { + PS::CPGDef::SEffect *Eff = (*pe_it); + PS::CPEDef *ped = ::Render->PSLibrary.FindPED(Eff->m_EffectName.c_str()); + if (!ped) { failed = failed||true; Msg("Validation FAILED (non-existent effect used) group[%s] effect[%s]", m_Name.c_str(), Eff->m_EffectName.c_str()); - break; + break; } - - if(Eff->m_Flags.test(SEffect::flOnPlayChild) && Eff->m_OnPlayChildName.size()==0) + + if (Eff->m_Flags.test(SEffect::flOnPlayChild)&&Eff->m_OnPlayChildName.size()==0) failed = failed||true; - if(Eff->m_Flags.test(SEffect::flOnBirthChild) && Eff->m_OnBirthChildName.size()==0) + if (Eff->m_Flags.test(SEffect::flOnBirthChild)&&Eff->m_OnBirthChildName.size()==0) failed = failed||true; - if(Eff->m_Flags.test(SEffect::flOnDeadChild) && Eff->m_OnDeadChildName.size()==0) + if (Eff->m_Flags.test(SEffect::flOnDeadChild)&&Eff->m_OnDeadChildName.size()==0) failed = failed||true; - if(failed && bMsg) + if (failed&&bMsg) Msg("Validation FAILED (incorrect child event settings) group[%s] effect[%s]", m_Name.c_str(), Eff->m_EffectName.c_str()); - if(failed) - break; + if (failed) + break; } return !failed; } -void PS::CPGDef::OnEffectsEditClick(ButtonValue* B, bool& bDataModified, bool& bSafe) +void PS::CPGDef::OnEffectsEditClick(ButtonValue *B, bool &bDataModified, bool &bSafe) { - switch (B->btn_num){ - case 0: - m_Effects.push_back(xr_new()); - m_Effects.back()->m_Flags.set(CPGDef::SEffect::flEnabled,FALSE); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - OnParamsChange (B); - bDataModified = true; - break; + switch (B->btn_num) + { + case 0: + m_Effects.push_back(xr_new()); + m_Effects.back()->m_Flags.set(CPGDef::SEffect::flEnabled, FALSE); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + OnParamsChange(B); + bDataModified = true; + break; } } -void PS::CPGDef::OnEffectTypeChange(PropValue* sender) +void PS::CPGDef::OnEffectTypeChange(PropValue *sender) { - ExecCommand (COMMAND_UPDATE_PROPERTIES); - OnParamsChange (sender); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + OnParamsChange(sender); } -void PS::CPGDef::OnControlClick(ButtonValue* B, bool& bDataModified, bool& bSafe) +void PS::CPGDef::OnControlClick(ButtonValue *B, bool &bDataModified, bool &bSafe) { - switch (B->btn_num){ - case 0: PTools->PlayCurrent(); break; - case 1: PTools->StopCurrent(false); break; - case 2: PTools->StopCurrent(true); break; + switch (B->btn_num) + { + case 0: PTools->PlayCurrent(); + break; + case 1: PTools->StopCurrent(false); + break; + case 2: PTools->StopCurrent(true); + break; } - bDataModified = false; + bDataModified = false; } -void PS::CPGDef::OnEffectEditClick(ButtonValue* B, bool& bDataModified, bool& bSafe) +void PS::CPGDef::OnEffectEditClick(ButtonValue *B, bool &bDataModified, bool &bSafe) { - switch (B->btn_num){ - case 0: - PTools->PlayCurrent (B->tag); - bDataModified = false; - break; - case 1:{ - CPGDef::SEffect* eff = *(m_Effects.begin()+B->tag); VERIFY(eff); - PTools->SelectEffect(*eff->m_EffectName); - bDataModified = false; - bSafe = true; - }break; - case 2: - if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons() << mbYes << mbNo,"Remove effect?") == mrYes){ - SEffect* eff = *(m_Effects.begin()+B->tag); - xr_delete (eff); - m_Effects.erase (m_Effects.begin()+B->tag); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - OnParamsChange (B); - bDataModified = true; - bSafe = true; - }else{ - bDataModified = false; + switch (B->btn_num) + { + case 0: + PTools->PlayCurrent(B->tag); + bDataModified = false; + break; + case 1: + { + CPGDef::SEffect *eff = *(m_Effects.begin()+B->tag); + VERIFY(eff); + PTools->SelectEffect(*eff->m_EffectName); + bDataModified = false; + bSafe = true; } - break; + break; + case 2: + if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<tag); + xr_delete(eff); + m_Effects.erase(m_Effects.begin()+B->tag); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + OnParamsChange(B); + bDataModified = true; + bSafe = true; + } + else + { + bDataModified = false; + } + break; } } -void PS::CPGDef::OnParamsChange(PropValue* sender) +void PS::CPGDef::OnParamsChange(PropValue *sender) { - PTools->SetCurrentPG (0); - PTools->SetCurrentPG (this); + PTools->SetCurrentPG(0); + PTools->SetCurrentPG(this); } -void PS::CPGDef::FillProp(LPCSTR pref, ::PropItemVec& items, ::ListItem* owner) -{ - ButtonValue* B; - B=PHelper().CreateButton (items,PrepareKey(pref,"Control"),"Play,Stop,Stop...",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&PS::CPGDef::OnControlClick); - B=PHelper().CreateButton (items,PrepareKey(pref,"Edit"),"Append Effect",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&PS::CPGDef::OnEffectsEditClick); - PropValue* V; - PHelper().CreateName (items,PrepareKey(pref,"Name"),&m_Name,owner); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Time Limit (s)"), &m_fTimeLimit, -1.f,1000.f); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); +void PS::CPGDef::FillProp(LPCSTR pref, ::PropItemVec &items, ::ListItem *owner) +{ + ButtonValue *B; + B = PHelper().CreateButton(items, PrepareKey(pref, "Control"), "Play,Stop,Stop...", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &PS::CPGDef::OnControlClick); + B = PHelper().CreateButton(items, PrepareKey(pref, "Edit"), "Append Effect", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &PS::CPGDef::OnEffectsEditClick); + PropValue *V; + PHelper().CreateName(items, PrepareKey(pref, "Name"), &m_Name, owner); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Time Limit (s)"), &m_fTimeLimit, -1.f, 1000.f); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); u32 i = 0; - for (EffectIt it=m_Effects.begin(); it!=m_Effects.end(); ++it,++i) + for (EffectIt it = m_Effects.begin(); it!=m_Effects.end(); ++it,++i) { - u32 clr = (*it)->m_Flags.is(CPGDef::SEffect::flEnabled)?clBlack:clSilver; - AnsiString nm = AnsiString("Effect #")+(i+1); - - B=PHelper().CreateButton(items,PrepareKey(pref,nm.c_str()),"Preview,Select,Remove",ButtonValue::flFirstOnly); B->tag = it-m_Effects.begin(); - B->OnBtnClickEvent.bind (this,&PS::CPGDef::OnEffectEditClick); - B->Owner()->prop_color = clr; - V=PHelper().CreateChoose(items,PrepareKey(pref,nm.c_str(),"Name"),&(*it)->m_EffectName,smPE); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; - V=PHelper().CreateFloat (items,PrepareKey(pref,nm.c_str(),"Start Time (s)"),&(*it)->m_Time0, 0.f,1000.f); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; - V=PHelper().CreateFloat (items,PrepareKey(pref,nm.c_str(),"End Time (s)"), &(*it)->m_Time1, 0.f,1000.f); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; - V=PHelper().CreateFlag32(items,PrepareKey(pref,nm.c_str(),"Deferred Stop"),&(*it)->m_Flags, SEffect::flDefferedStop); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; - V=PHelper().CreateFlag32(items,PrepareKey(pref,nm.c_str(),"Enabled"), &(*it)->m_Flags, SEffect::flEnabled); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; - V=PHelper().CreateFlag32(items,PrepareKey(pref,nm.c_str(),"Children\\On Birth"), &(*it)->m_Flags, SEffect::flOnBirthChild); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; - if ((*it)->m_Flags.is(SEffect::flOnBirthChild)){ - V=PHelper().CreateChoose(items,PrepareKey(pref,nm.c_str(),"Children\\On Birth\\Effect Name"), &(*it)->m_OnBirthChildName,smPE); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; + u32 clr = (*it)->m_Flags.is(CPGDef::SEffect::flEnabled) ? clBlack : clSilver; + AnsiString nm = AnsiString("Effect #")+(i+1); + + B = PHelper().CreateButton(items, PrepareKey(pref, nm.c_str()), "Preview,Select,Remove", ButtonValue::flFirstOnly); + B->tag = it-m_Effects.begin(); + B->OnBtnClickEvent.bind(this, &PS::CPGDef::OnEffectEditClick); + B->Owner()->prop_color = clr; + V = PHelper().CreateChoose(items, PrepareKey(pref, nm.c_str(), "Name"), &(*it)->m_EffectName, smPE); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; + V = PHelper().CreateFloat(items, PrepareKey(pref, nm.c_str(), "Start Time (s)"), &(*it)->m_Time0, 0.f, 1000.f); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; + V = PHelper().CreateFloat(items, PrepareKey(pref, nm.c_str(), "End Time (s)"), &(*it)->m_Time1, 0.f, 1000.f); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; + V = PHelper().CreateFlag32(items, PrepareKey(pref, nm.c_str(), "Deferred Stop"), &(*it)->m_Flags, SEffect::flDefferedStop); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; + V = PHelper().CreateFlag32(items, PrepareKey(pref, nm.c_str(), "Enabled"), &(*it)->m_Flags, SEffect::flEnabled); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; + V = PHelper().CreateFlag32(items, PrepareKey(pref, nm.c_str(), "Children\\On Birth"), &(*it)->m_Flags, SEffect::flOnBirthChild); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; + if ((*it)->m_Flags.is(SEffect::flOnBirthChild)) + { + V = PHelper().CreateChoose(items, PrepareKey(pref, nm.c_str(), "Children\\On Birth\\Effect Name"), &(*it)->m_OnBirthChildName, smPE); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; } - V=PHelper().CreateFlag32(items,PrepareKey(pref,nm.c_str(),"Children\\On Play"), &(*it)->m_Flags, SEffect::flOnPlayChild); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; - if ((*it)->m_Flags.is(SEffect::flOnPlayChild)){ - V=PHelper().CreateChoose (items,PrepareKey(pref,nm.c_str(),"Children\\On Play\\Effect Name"), &(*it)->m_OnPlayChildName,smPE); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; - V=PHelper().CreateFlag32(items,PrepareKey(pref,nm.c_str(),"Children\\On Play\\Play After Stop"), &(*it)->m_Flags, SEffect::flOnPlayChildRewind); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; + V = PHelper().CreateFlag32(items, PrepareKey(pref, nm.c_str(), "Children\\On Play"), &(*it)->m_Flags, SEffect::flOnPlayChild); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; + if ((*it)->m_Flags.is(SEffect::flOnPlayChild)) + { + V = PHelper().CreateChoose(items, PrepareKey(pref, nm.c_str(), "Children\\On Play\\Effect Name"), &(*it)->m_OnPlayChildName, smPE); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; + V = PHelper().CreateFlag32(items, PrepareKey(pref, nm.c_str(), "Children\\On Play\\Play After Stop"), &(*it)->m_Flags, SEffect::flOnPlayChildRewind); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; } - V=PHelper().CreateFlag32(items,PrepareKey(pref,nm.c_str(),"Children\\On Dead"), &(*it)->m_Flags, SEffect::flOnDeadChild); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; - if ((*it)->m_Flags.is(SEffect::flOnDeadChild)){ - V=PHelper().CreateChoose (items,PrepareKey(pref,nm.c_str(),"Children\\On Dead\\Effect Name"), &(*it)->m_OnDeadChildName,smPE); - V->OnChangeEvent.bind (this,&PS::CPGDef::OnParamsChange); - V->Owner()->prop_color = clr; + V = PHelper().CreateFlag32(items, PrepareKey(pref, nm.c_str(), "Children\\On Dead"), &(*it)->m_Flags, SEffect::flOnDeadChild); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; + if ((*it)->m_Flags.is(SEffect::flOnDeadChild)) + { + V = PHelper().CreateChoose(items, PrepareKey(pref, nm.c_str(), "Children\\On Dead\\Effect Name"), &(*it)->m_OnDeadChildName, smPE); + V->OnChangeEvent.bind(this, &PS::CPGDef::OnParamsChange); + V->Owner()->prop_color = clr; } } } - \ No newline at end of file diff --git a/src/editors/ParticleEditor/Splash.cpp b/src/editors/ParticleEditor/Splash.cpp index 14c433d6819..22b97ef289c 100644 --- a/src/editors/ParticleEditor/Splash.cpp +++ b/src/editors/ParticleEditor/Splash.cpp @@ -6,9 +6,11 @@ #pragma package(smart_init) #pragma resource "*.dfm" TfrmSplash *frmSplash; + //--------------------------------------------------------------------------- -__fastcall TfrmSplash::TfrmSplash(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfrmSplash::TfrmSplash(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- + + diff --git a/src/editors/ParticleEditor/Splash.h b/src/editors/ParticleEditor/Splash.h index 7cf4c06f31b..c62612c5ac5 100644 --- a/src/editors/ParticleEditor/Splash.h +++ b/src/editors/ParticleEditor/Splash.h @@ -12,18 +12,29 @@ #include #include #include + //--------------------------------------------------------------------------- class TfrmSplash : public TForm { -__published: // IDE-managed Components - TImage *Image1; - TMxLabel *lbStatus; -private: // User declarations -public: // User declarations - __fastcall TfrmSplash(TComponent* Owner); - void SetStatus(LPSTR log){ if (log){ lbStatus->Caption = log; lbStatus->Repaint(); };} + __published: // IDE-managed Components + TImage*Image1; + TMxLabel *lbStatus; +private: // User declarations +public: // User declarations + __fastcall TfrmSplash(TComponent *Owner); + + void SetStatus(LPSTR log) + { + if (log) + { + lbStatus->Caption = log; + lbStatus->Repaint(); + }; + } }; + //--------------------------------------------------------------------------- -extern PACKAGE TfrmSplash *frmSplash; +extern PACKAGE TfrmSplash * frmSplash; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ParticleEditor/StatGraph.cpp b/src/editors/ParticleEditor/StatGraph.cpp index 37b893c0edf..528f3e2c578 100644 --- a/src/editors/ParticleEditor/StatGraph.cpp +++ b/src/editors/ParticleEditor/StatGraph.cpp @@ -2,334 +2,377 @@ #pragma hdrstop #include "StatGraph.h" + //--------------------------------------------- CStatGraph::CStatGraph() { - EDevice.seqRender.Add (this,REG_PRIORITY_LOW-1000); - OnDeviceCreate(); - mn = 0; - mx = 1; - max_item_count = 1; - lt.set (0,0); - rb.set (200,200); - grid.set (1,1); - grid_color = 0xFF000000; - rect_color = 0xFF000000; - grid_step.set (1, 1); - - AppendSubGraph(stCurve); + EDevice.seqRender.Add(this, REG_PRIORITY_LOW-1000); + OnDeviceCreate(); + mn = 0; + mx = 1; + max_item_count = 1; + lt.set(0, 0); + rb.set(200, 200); + grid.set(1, 1); + grid_color = 0xFF000000; + rect_color = 0xFF000000; + grid_step.set(1, 1); + + AppendSubGraph(stCurve); } CStatGraph::~CStatGraph() { - EDevice.seqRender.Remove (this); - OnDeviceDestroy(); - m_Markers.clear(); + EDevice.seqRender.Remove(this); + OnDeviceDestroy(); + m_Markers.clear(); } void CStatGraph::OnDeviceCreate() { - hGeomLine.create (FVF::F_TL0uv,RCache.Vertex.Buffer(),RCache.Index.Buffer()); - hGeomTri.create (FVF::F_TL0uv,RCache.Vertex.Buffer(),RCache.QuadIB); + hGeomLine.create(FVF::F_TL0uv, RCache.Vertex.Buffer(), RCache.Index.Buffer()); + hGeomTri.create(FVF::F_TL0uv, RCache.Vertex.Buffer(), RCache.QuadIB); } void CStatGraph::OnDeviceDestroy() { - hGeomLine.destroy (); - hGeomTri.destroy (); + hGeomLine.destroy(); + hGeomTri.destroy(); } -void CStatGraph::RenderBack () +void CStatGraph::RenderBack() { - // draw back - u32 dwOffset,dwCount; - FVF::TL0uv* pv_start = (FVF::TL0uv*)RCache.Vertex.Lock(4,hGeomTri->vb_stride,dwOffset); - FVF::TL0uv* pv = pv_start; - // base rect - pv->set (lt.x,rb.y,back_color); pv++; // 0 - pv->set (lt.x,lt.y,back_color); pv++; // 1 - pv->set (rb.x,rb.y,back_color); pv++; // 2 - pv->set (rb.x,lt.y,back_color); pv++; // 3 - // render - dwCount = u32(pv-pv_start); - RCache.Vertex.Unlock (dwCount,hGeomTri->vb_stride); - RCache.set_Geometry (hGeomTri); - RCache.Render (D3DPT_TRIANGLELIST,dwOffset,0, dwCount, 0, dwCount/2); - - //draw rect - pv_start = (FVF::TL0uv*)RCache.Vertex.Lock(5,hGeomLine->vb_stride,dwOffset); - pv = pv_start; - // base rect - pv->set (lt.x,lt.y,rect_color); pv++; // 0 - pv->set (rb.x-1,lt.y,rect_color); pv++; // 1 - pv->set (rb.x-1,rb.y,rect_color); pv++; // 2 - pv->set (lt.x,rb.y,rect_color); pv++; // 3 - pv->set (lt.x,lt.y,rect_color); pv++; // 0 - // render - dwCount = u32(pv-pv_start); - RCache.Vertex.Unlock (dwCount,hGeomLine->vb_stride); - RCache.set_Geometry (hGeomLine); - RCache.Render (D3DPT_LINESTRIP,dwOffset,4); - - // draw grid - float elem_factor = float(rb.y-lt.y)/float(mx-mn); - float base_y = float(rb.y)+(mn*elem_factor); - - int PNum_H_LinesUp = int((base_y - float(lt.y)) / (grid_step.y*elem_factor)); - int PNum_H_LinesDwn = u32((float(rb.y) - base_y) / (grid_step.y*elem_factor)); - int Num_H_LinesUp = (grid.y < PNum_H_LinesUp) ? grid.y : PNum_H_LinesUp; - int Num_H_LinesDwn = (grid.y < PNum_H_LinesUp) ? grid.y : PNum_H_LinesDwn; - - pv_start = (FVF::TL0uv*)RCache.Vertex.Lock( 2 + 2*grid.x + Num_H_LinesUp*2 + Num_H_LinesDwn*2, - hGeomLine->vb_stride,dwOffset); - pv = pv_start; + // draw back + u32 dwOffset, dwCount; + FVF::TL0uv *pv_start = (FVF::TL0uv*)RCache.Vertex.Lock(4, hGeomTri->vb_stride, dwOffset); + FVF::TL0uv *pv = pv_start; + // base rect + pv->set(lt.x, rb.y, back_color); + pv++; // 0 + pv->set(lt.x, lt.y, back_color); + pv++; // 1 + pv->set(rb.x, rb.y, back_color); + pv++; // 2 + pv->set(rb.x, lt.y, back_color); + pv++; // 3 + // render + dwCount = u32(pv-pv_start); + RCache.Vertex.Unlock(dwCount, hGeomTri->vb_stride); + RCache.set_Geometry(hGeomTri); + RCache.Render(D3DPT_TRIANGLELIST, dwOffset, 0, dwCount, 0, dwCount/2); + + //draw rect + pv_start = (FVF::TL0uv*)RCache.Vertex.Lock(5, hGeomLine->vb_stride, dwOffset); + pv = pv_start; + // base rect + pv->set(lt.x, lt.y, rect_color); + pv++; // 0 + pv->set(rb.x-1, lt.y, rect_color); + pv++; // 1 + pv->set(rb.x-1, rb.y, rect_color); + pv++; // 2 + pv->set(lt.x, rb.y, rect_color); + pv++; // 3 + pv->set(lt.x, lt.y, rect_color); + pv++; // 0 + // render + dwCount = u32(pv-pv_start); + RCache.Vertex.Unlock(dwCount, hGeomLine->vb_stride); + RCache.set_Geometry(hGeomLine); + RCache.Render(D3DPT_LINESTRIP, dwOffset, 4); + + // draw grid + float elem_factor = float(rb.y-lt.y)/float(mx-mn); + float base_y = float(rb.y)+(mn*elem_factor); + + int PNum_H_LinesUp = int((base_y-float(lt.y))/(grid_step.y*elem_factor)); + int PNum_H_LinesDwn = u32((float(rb.y)-base_y)/(grid_step.y*elem_factor)); + int Num_H_LinesUp = (grid.yvb_stride, dwOffset); + pv = pv_start; // base Coordinate Line - pv->set (lt.x, int(base_y), base_color); pv++; // 0 - pv->set (rb.x, int(base_y), base_color); pv++; // 0 + pv->set(lt.x, int(base_y), base_color); + pv++; // 0 + pv->set(rb.x, int(base_y), base_color); + pv++; // 0 // grid -// float grid_offs_x = float(rb.x-lt.x)/float(grid.x+1); -// float grid_offs_y = float(rb.y-lt.y)/float(grid.y+1); - for (int g_x=1; g_x<=grid.x; g_x++) - { - pv->set (int(lt.x + g_x*grid_step.x*elem_factor),lt.y,grid_color); pv++; - pv->set (int(lt.x + g_x*grid_step.x*elem_factor),rb.y,grid_color); pv++; - } - for (int g_y=1; g_y<=Num_H_LinesDwn; g_y++) - { - pv->set (lt.x,int(base_y+g_y*grid_step.y*elem_factor),grid_color); pv++; - pv->set (rb.x,int(base_y+g_y*grid_step.y*elem_factor),grid_color); pv++; - }; - - for (g_y=1; g_y<=Num_H_LinesUp; g_y++) - { - pv->set (lt.x,int(base_y-g_y*grid_step.y*elem_factor),grid_color); pv++; - pv->set (rb.x,int(base_y-g_y*grid_step.y*elem_factor),grid_color); pv++; - } - - -// for (int g_y=1; g_y<=grid.y; g_y++){ -// pv->set (lt.x,iFloor(g_y*grid_offs_y+lt.y),grid_color); pv++; -// pv->set (rb.x,iFloor(g_y*grid_offs_y+lt.y),grid_color); pv++; -// } - - dwCount = u32(pv-pv_start); - RCache.Vertex.Unlock (dwCount,hGeomLine->vb_stride); - RCache.set_Geometry (hGeomLine); - RCache.Render (D3DPT_LINELIST,dwOffset,dwCount/2); - - + // float grid_offs_x = float(rb.x-lt.x)/float(grid.x+1); + // float grid_offs_y = float(rb.y-lt.y)/float(grid.y+1); + for (int g_x = 1; g_x<=grid.x; g_x++) + { + pv->set(int(lt.x+g_x*grid_step.x*elem_factor), lt.y, grid_color); + pv++; + pv->set(int(lt.x+g_x*grid_step.x*elem_factor), rb.y, grid_color); + pv++; + } + for (int g_y = 1; g_y<=Num_H_LinesDwn; g_y++) + { + pv->set(lt.x, int(base_y+g_y*grid_step.y*elem_factor), grid_color); + pv++; + pv->set(rb.x, int(base_y+g_y*grid_step.y*elem_factor), grid_color); + pv++; + }; + + for (g_y = 1; g_y<=Num_H_LinesUp; g_y++) + { + pv->set(lt.x, int(base_y-g_y*grid_step.y*elem_factor), grid_color); + pv++; + pv->set(rb.x, int(base_y-g_y*grid_step.y*elem_factor), grid_color); + pv++; + } + + + // for (int g_y=1; g_y<=grid.y; g_y++){ + // pv->set (lt.x,iFloor(g_y*grid_offs_y+lt.y),grid_color); pv++; + // pv->set (rb.x,iFloor(g_y*grid_offs_y+lt.y),grid_color); pv++; + // } + + dwCount = u32(pv-pv_start); + RCache.Vertex.Unlock(dwCount, hGeomLine->vb_stride); + RCache.set_Geometry(hGeomLine); + RCache.Render(D3DPT_LINELIST, dwOffset, dwCount/2); }; -void CStatGraph::RenderBars(FVF::TL0uv** ppv, ElementsDeq* pelements) +void CStatGraph::RenderBars(FVF::TL0uv **ppv, ElementsDeq *pelements) { - float elem_offs = float(rb.x-lt.x)/max_item_count; - float elem_factor = float(rb.y-lt.y)/float(mx-mn); - float base_y = float(rb.y)+(mn*elem_factor); - - float column_width = elem_offs; - if (column_width > 1) column_width--; - for (ElementsDeqIt it=pelements->begin(); it!=pelements->end(); it++) - { - float X = float(it-pelements->begin())*elem_offs+lt.x; - float Y0 = base_y; - float Y1 = base_y - it->data*elem_factor; - - if (Y1 > Y0) - { - (*ppv)->set (X,Y1,it->color); (*ppv)++; - (*ppv)->set (X,Y0,it->color); (*ppv)++; - (*ppv)->set (X+column_width,Y1,it->color); (*ppv)++; - (*ppv)->set (X+column_width,Y0,it->color); (*ppv)++; - } - else - { - (*ppv)->set (X,Y0,it->color); (*ppv)++; - (*ppv)->set (X,Y1,it->color); (*ppv)++; - (*ppv)->set (X+column_width,Y0,it->color); (*ppv)++; - (*ppv)->set (X+column_width,Y1,it->color); (*ppv)++; - }; - }; + float elem_offs = float(rb.x-lt.x)/max_item_count; + float elem_factor = float(rb.y-lt.y)/float(mx-mn); + float base_y = float(rb.y)+(mn*elem_factor); + + float column_width = elem_offs; + if (column_width>1) + column_width--; + for (ElementsDeqIt it = pelements->begin(); it!=pelements->end(); it++) + { + float X = float(it-pelements->begin())*elem_offs+lt.x; + float Y0 = base_y; + float Y1 = base_y-it->data*elem_factor; + + if (Y1>Y0) + { + (*ppv)->set(X, Y1, it->color); + (*ppv)++; + (*ppv)->set(X, Y0, it->color); + (*ppv)++; + (*ppv)->set(X+column_width, Y1, it->color); + (*ppv)++; + (*ppv)->set(X+column_width, Y0, it->color); + (*ppv)++; + } + else + { + (*ppv)->set(X, Y0, it->color); + (*ppv)++; + (*ppv)->set(X, Y1, it->color); + (*ppv)++; + (*ppv)->set(X+column_width, Y0, it->color); + (*ppv)++; + (*ppv)->set(X+column_width, Y1, it->color); + (*ppv)++; + }; + }; }; -void CStatGraph::RenderLines( FVF::TL0uv** ppv, ElementsDeq* pelements ) +void CStatGraph::RenderLines(FVF::TL0uv **ppv, ElementsDeq *pelements) { - float elem_offs = float(rb.x-lt.x)/max_item_count; - float elem_factor = float(rb.y-lt.y)/float(mx-mn); - float base_y = float(rb.y)+(mn*elem_factor); - - for (ElementsDeqIt it=pelements->begin()+1; it!=pelements->end() && it!=pelements->end()+1; it++) - { - ElementsDeqIt it_prev = it-1; - float X0 = float(it_prev-pelements->begin())*elem_offs+lt.x; - float Y0 = base_y-it_prev->data*elem_factor; - (*ppv)->set (X0,Y0,it->color); (*ppv)++; - float X1 = float(it-pelements->begin())*elem_offs+lt.x; - float Y1 = base_y-it->data*elem_factor; - (*ppv)->set (X1,Y1,it->color); (*ppv)++; - } + float elem_offs = float(rb.x-lt.x)/max_item_count; + float elem_factor = float(rb.y-lt.y)/float(mx-mn); + float base_y = float(rb.y)+(mn*elem_factor); + + for (ElementsDeqIt it = pelements->begin()+1; it!=pelements->end()&&it!=pelements->end()+1; it++) + { + ElementsDeqIt it_prev = it-1; + float X0 = float(it_prev-pelements->begin())*elem_offs+lt.x; + float Y0 = base_y-it_prev->data*elem_factor; + (*ppv)->set(X0, Y0, it->color); + (*ppv)++; + float X1 = float(it-pelements->begin())*elem_offs+lt.x; + float Y1 = base_y-it->data*elem_factor; + (*ppv)->set(X1, Y1, it->color); + (*ppv)++; + } }; -void CStatGraph::RenderBarLines( FVF::TL0uv** ppv, ElementsDeq* pelements ) +void CStatGraph::RenderBarLines(FVF::TL0uv **ppv, ElementsDeq *pelements) { - float elem_offs = float(rb.x-lt.x)/max_item_count; - float elem_factor = float(rb.y-lt.y)/float(mx-mn); - float base_y = float(rb.y)+(mn*elem_factor); - - for (ElementsDeqIt it=pelements->begin()+1; it!=pelements->end() && it!=pelements->end()+1; it++) - { - ElementsDeqIt it_prev = it-1; - float X0 = float(it_prev-pelements->begin())*elem_offs+lt.x+elem_offs; - float Y0 = base_y-it_prev->data*elem_factor; - (*ppv)->set (X0,Y0,it->color); (*ppv)++; - float X1 = float(it-pelements->begin())*elem_offs+lt.x; - float Y1 = base_y-it->data*elem_factor; - (*ppv)->set (X1,Y1,it->color); (*ppv)++; - (*ppv)->set (X1,Y1,it->color); (*ppv)++; - X1 += elem_offs; - (*ppv)->set (X1,Y1,it->color); (*ppv)++; - } + float elem_offs = float(rb.x-lt.x)/max_item_count; + float elem_factor = float(rb.y-lt.y)/float(mx-mn); + float base_y = float(rb.y)+(mn*elem_factor); + + for (ElementsDeqIt it = pelements->begin()+1; it!=pelements->end()&&it!=pelements->end()+1; it++) + { + ElementsDeqIt it_prev = it-1; + float X0 = float(it_prev-pelements->begin())*elem_offs+lt.x+elem_offs; + float Y0 = base_y-it_prev->data*elem_factor; + (*ppv)->set(X0, Y0, it->color); + (*ppv)++; + float X1 = float(it-pelements->begin())*elem_offs+lt.x; + float Y1 = base_y-it->data*elem_factor; + (*ppv)->set(X1, Y1, it->color); + (*ppv)++; + (*ppv)->set(X1, Y1, it->color); + (*ppv)++; + X1 += elem_offs; + (*ppv)->set(X1, Y1, it->color); + (*ppv)++; + } }; /* void CStatGraph::RenderPoints( FVF::TL0uv** ppv, ElementsDeq* pelements ) { - float elem_offs = float(rb.x-lt.x)/max_item_count; - float elem_factor = float(rb.y-lt.y)/float(mx-mn); - float base_y = float(rb.y)+(mn*elem_factor); - - for (ElementsDeqIt it=pelements->begin()+1; it!=pelements->end(); it++) - { - float X1 = float(it-pelements->begin())*elem_offs+lt.x; - float Y1 = base_y-it->data*elem_factor; - (*ppv)->set (X1,Y1,it->color); (*ppv)++; - } + float elem_offs = float(rb.x-lt.x)/max_item_count; + float elem_factor = float(rb.y-lt.y)/float(mx-mn); + float base_y = float(rb.y)+(mn*elem_factor); + + for (ElementsDeqIt it=pelements->begin()+1; it!=pelements->end(); it++) + { + float X1 = float(it-pelements->begin())*elem_offs+lt.x; + float Y1 = base_y-it->data*elem_factor; + (*ppv)->set (X1,Y1,it->color); (*ppv)++; + } }; */ -void CStatGraph::RenderMarkers ( FVF::TL0uv** ppv, MarkersDeq* pmarkers ) +void CStatGraph::RenderMarkers(FVF::TL0uv **ppv, MarkersDeq *pmarkers) { - float elem_offs = float(rb.x-lt.x)/max_item_count; - float elem_factor = float(rb.y-lt.y)/float(mx-mn); - float base_y = float(rb.y)+(mn*elem_factor); - - for (MarkersDeqIt it=pmarkers->begin(); it!=pmarkers->end() && it!=pmarkers->end()+1; it++) - { - SMarker &CurMarker = *it; - float X0 = 0, Y0 = 0, X1 = 0, Y1 = 0; - switch (CurMarker.m_eStyle) - { - case stVert: - { - X0 = CurMarker.m_fPos*elem_offs+lt.x; - clamp(X0, float(lt.x), float(rb.x)); - X1 = X0; - Y0 = float(lt.y); - Y1 = float(rb.y); - }break; - case stHor: - { - X0 = float(lt.x); - X1 = float(rb.x); - Y0 = base_y - CurMarker.m_fPos*elem_factor; - clamp(Y0, float(lt.y), float(rb.y)); - Y1 = Y0; - }break; - } - (*ppv)->set (X0,Y0,CurMarker.m_dwColor); (*ppv)++; - (*ppv)->set (X1,Y1,CurMarker.m_dwColor); (*ppv)++; - } + float elem_offs = float(rb.x-lt.x)/max_item_count; + float elem_factor = float(rb.y-lt.y)/float(mx-mn); + float base_y = float(rb.y)+(mn*elem_factor); + + for (MarkersDeqIt it = pmarkers->begin(); it!=pmarkers->end()&&it!=pmarkers->end()+1; it++) + { + SMarker&CurMarker = *it; + float X0 = 0, Y0 = 0, X1 = 0, Y1 = 0; + switch (CurMarker.m_eStyle) + { + case stVert: + { + X0 = CurMarker.m_fPos*elem_offs+lt.x; + clamp(X0, float(lt.x), float(rb.x)); + X1 = X0; + Y0 = float(lt.y); + Y1 = float(rb.y); + } + break; + case stHor: + { + X0 = float(lt.x); + X1 = float(rb.x); + Y0 = base_y-CurMarker.m_fPos*elem_factor; + clamp(Y0, float(lt.y), float(rb.y)); + Y1 = Y0; + } + break; + } + (*ppv)->set(X0, Y0, CurMarker.m_dwColor); + (*ppv)++; + (*ppv)->set(X1, Y1, CurMarker.m_dwColor); + (*ppv)++; + } } void CStatGraph::OnRender() { - RCache.OnFrameEnd(); - - RenderBack(); - - u32 TriElem = 0; - u32 LineElem = 0; - for (SubGraphVecIt it=subgraphs.begin(); it!=subgraphs.end(); it++) - { - switch (it->style) - { - case stBar: - { - TriElem += it->elements.size()*4; - }break; - case stCurve: - { - LineElem += it->elements.size()*2; - }break; - case stBarLine: - { - LineElem += it->elements.size()*4; - }break; - case stPoint: - { -// TriElem += it->elements.size()*4; - }break; - }; - }; - - u32 dwOffsetTri = 0, dwOffsetLine = 0,dwCount; - FVF::TL0uv* pv_Tri_start = NULL; - FVF::TL0uv* pv_Tri; - FVF::TL0uv* pv_Line_start = NULL; - FVF::TL0uv* pv_Line; - - if (TriElem) - { - pv_Tri_start = (FVF::TL0uv*)RCache.Vertex.Lock(TriElem,hGeomTri->vb_stride,dwOffsetTri); - pv_Tri = pv_Tri_start; - - pv_Tri = pv_Tri_start; - for (SubGraphVecIt it=subgraphs.begin(); it!=subgraphs.end(); it++) - { - switch(it->style) - { - case stBar: RenderBars (&pv_Tri, &(it->elements)); break; - }; - }; - dwCount = u32(pv_Tri-pv_Tri_start); - RCache.Vertex.Unlock (dwCount,hGeomTri->vb_stride); - RCache.set_Geometry (hGeomTri); - RCache.Render (D3DPT_TRIANGLELIST,dwOffsetTri,0, dwCount, 0, dwCount/2); - }; - - if (LineElem) - { - pv_Line_start = (FVF::TL0uv*)RCache.Vertex.Lock(LineElem,hGeomLine->vb_stride,dwOffsetLine); - pv_Line = pv_Line_start; - - for (SubGraphVecIt it=subgraphs.begin(); it!=subgraphs.end(); it++) - { - switch(it->style) - { - case stCurve: RenderLines (&pv_Line, &(it->elements)); break; - case stBarLine: RenderBarLines (&pv_Line, &(it->elements)); break; - }; - }; - - dwCount = u32(pv_Line-pv_Line_start); - RCache.Vertex.Unlock (dwCount,hGeomLine->vb_stride); - RCache.set_Geometry (hGeomLine); - RCache.Render (D3DPT_LINELIST,dwOffsetLine,dwCount/2); - }; - - if (!m_Markers.empty()) - { - dwOffsetLine = 0; - LineElem = m_Markers.size()*2; - - pv_Line_start = (FVF::TL0uv*)RCache.Vertex.Lock(LineElem,hGeomLine->vb_stride,dwOffsetLine); - pv_Line = pv_Line_start; - - RenderMarkers (&pv_Line, &(m_Markers)); - - dwCount = u32(pv_Line-pv_Line_start); - RCache.Vertex.Unlock (dwCount,hGeomLine->vb_stride); - RCache.set_Geometry (hGeomLine); - RCache.Render (D3DPT_LINELIST,dwOffsetLine,dwCount/2); - } + RCache.OnFrameEnd(); + + RenderBack(); + + u32 TriElem = 0; + u32 LineElem = 0; + for (SubGraphVecIt it = subgraphs.begin(); it!=subgraphs.end(); it++) + { + switch (it->style) + { + case stBar: + { + TriElem += it->elements.size()*4; + } + break; + case stCurve: + { + LineElem += it->elements.size()*2; + } + break; + case stBarLine: + { + LineElem += it->elements.size()*4; + } + break; + case stPoint: + { + // TriElem += it->elements.size()*4; + } + break; + }; + }; + + u32 dwOffsetTri = 0, dwOffsetLine = 0, dwCount; + FVF::TL0uv *pv_Tri_start = NULL; + FVF::TL0uv *pv_Tri; + FVF::TL0uv *pv_Line_start = NULL; + FVF::TL0uv *pv_Line; + + if (TriElem) + { + pv_Tri_start = (FVF::TL0uv*)RCache.Vertex.Lock(TriElem, hGeomTri->vb_stride, dwOffsetTri); + pv_Tri = pv_Tri_start; + + pv_Tri = pv_Tri_start; + for (SubGraphVecIt it = subgraphs.begin(); it!=subgraphs.end(); it++) + { + switch (it->style) + { + case stBar: RenderBars(&pv_Tri, &(it->elements)); + break; + }; + }; + dwCount = u32(pv_Tri-pv_Tri_start); + RCache.Vertex.Unlock(dwCount, hGeomTri->vb_stride); + RCache.set_Geometry(hGeomTri); + RCache.Render(D3DPT_TRIANGLELIST, dwOffsetTri, 0, dwCount, 0, dwCount/2); + }; + + if (LineElem) + { + pv_Line_start = (FVF::TL0uv*)RCache.Vertex.Lock(LineElem, hGeomLine->vb_stride, dwOffsetLine); + pv_Line = pv_Line_start; + + for (SubGraphVecIt it = subgraphs.begin(); it!=subgraphs.end(); it++) + { + switch (it->style) + { + case stCurve: RenderLines(&pv_Line, &(it->elements)); + break; + case stBarLine: RenderBarLines(&pv_Line, &(it->elements)); + break; + }; + }; + + dwCount = u32(pv_Line-pv_Line_start); + RCache.Vertex.Unlock(dwCount, hGeomLine->vb_stride); + RCache.set_Geometry(hGeomLine); + RCache.Render(D3DPT_LINELIST, dwOffsetLine, dwCount/2); + }; + + if (!m_Markers.empty()) + { + dwOffsetLine = 0; + LineElem = m_Markers.size()*2; + + pv_Line_start = (FVF::TL0uv*)RCache.Vertex.Lock(LineElem, hGeomLine->vb_stride, dwOffsetLine); + pv_Line = pv_Line_start; + + RenderMarkers(&pv_Line, &(m_Markers)); + + dwCount = u32(pv_Line-pv_Line_start); + RCache.Vertex.Unlock(dwCount, hGeomLine->vb_stride); + RCache.set_Geometry(hGeomLine); + RCache.Render(D3DPT_LINELIST, dwOffsetLine, dwCount/2); + } }; + diff --git a/src/editors/ParticleEditor/StatGraph.h b/src/editors/ParticleEditor/StatGraph.h index 0fd92f597e1..666dd0fe4d9 100644 --- a/src/editors/ParticleEditor/StatGraph.h +++ b/src/editors/ParticleEditor/StatGraph.h @@ -1,160 +1,201 @@ //--------------------------------------------------------------------------- #ifndef StatGraphH #define StatGraphH + //--------------------------------------------------------------------------- -class ENGINE_API CStatGraph : public pureRender +class ENGINE_API CStatGraph : public pureRender { public: - enum EStyle{ - stBar, + enum EStyle + { + stBar, stCurve, - stBarLine, - stPoint, - stVert, - stHor, - }; + stBarLine, + stPoint, + stVert, + stHor, + }; + protected: - struct SElement{ - u32 color; - float data; - SElement(float d, u32 clr) + struct SElement + { + u32 color; + float data; + + SElement(float d, u32 clr) { - color = clr; - data = d; + color = clr; + data = d; } }; - DEFINE_DEQUE (SElement,ElementsDeq,ElementsDeqIt); - struct SSubGraph - { - EStyle style; - ElementsDeq elements; - SSubGraph(EStyle s) - { - style = s; - }; - void SetStyle (EStyle s) - { - style = s; - }; - }; - DEFINE_VECTOR (SSubGraph,SubGraphVec,SubGraphVecIt); - SubGraphVec subgraphs; - - float mn, mx; - u32 max_item_count; - Ivector2 lt,rb; - Ivector2 grid; - Fvector2 grid_step; - u32 grid_color; - u32 base_color; - u32 rect_color; - u32 back_color; - ref_geom hGeomTri; - ref_geom hGeomLine; - - - struct SMarker { - EStyle m_eStyle; - float m_fPos; - u32 m_dwColor; - }; - - DEFINE_DEQUE (SMarker,MarkersDeq,MarkersDeqIt); - MarkersDeq m_Markers; + + DEFINE_DEQUE(SElement, ElementsDeq, ElementsDeqIt); + + struct SSubGraph + { + EStyle style; + ElementsDeq elements; + + SSubGraph(EStyle s) + { + style = s; + }; + + void SetStyle(EStyle s) + { + style = s; + }; + }; + + DEFINE_VECTOR(SSubGraph, SubGraphVec, SubGraphVecIt); + SubGraphVec subgraphs; + + float mn, mx; + u32 max_item_count; + Ivector2 lt, rb; + Ivector2 grid; + Fvector2 grid_step; + u32 grid_color; + u32 base_color; + u32 rect_color; + u32 back_color; + ref_geom hGeomTri; + ref_geom hGeomLine; + + + struct SMarker + { + EStyle m_eStyle; + float m_fPos; + u32 m_dwColor; + }; + + DEFINE_DEQUE(SMarker, MarkersDeq, MarkersDeqIt); + MarkersDeq m_Markers; protected: - virtual void RenderBack (); + virtual void RenderBack(); - virtual void RenderBars ( FVF::TL0uv** ppv, ElementsDeq* pelements ); - virtual void RenderLines ( FVF::TL0uv** ppv, ElementsDeq* pelements ); - virtual void RenderBarLines ( FVF::TL0uv** ppv, ElementsDeq* pelements ); -// virtual void RenderPoints ( FVF::TL0uv** ppv, ElementsDeq* pelements ); - virtual void RenderMarkers ( FVF::TL0uv** ppv, MarkersDeq* pmarkers ); + virtual void RenderBars(FVF::TL0uv **ppv, ElementsDeq *pelements); + virtual void RenderLines(FVF::TL0uv **ppv, ElementsDeq *pelements); + virtual void RenderBarLines(FVF::TL0uv **ppv, ElementsDeq *pelements); + // virtual void RenderPoints ( FVF::TL0uv** ppv, ElementsDeq* pelements ); + virtual void RenderMarkers(FVF::TL0uv **ppv, MarkersDeq *pmarkers); public: - CStatGraph (); - ~CStatGraph (); - virtual void OnRender (); - void OnDeviceCreate (); - void OnDeviceDestroy (); + CStatGraph(); + ~CStatGraph(); + virtual void OnRender(); + void OnDeviceCreate(); + void OnDeviceDestroy(); - IC void SetStyle (EStyle s, u32 SubGraphID = 0) + IC + + void SetStyle(EStyle s, u32 SubGraphID = 0) { - if (SubGraphID >= subgraphs.size()) return; - SubGraphVecIt it = subgraphs.begin() + SubGraphID; - it->SetStyle(s); + if (SubGraphID>=subgraphs.size()) + return; + SubGraphVecIt it = subgraphs.begin()+SubGraphID; + it->SetStyle(s); } - - IC void SetRect (int l, int t, int w, int h, u32 rect_clr, u32 back_clr) + + IC + + void SetRect(int l, int t, int w, int h, u32 rect_clr, u32 back_clr) { - lt.set (l,t); - rb.set (l+w,t+h); - rect_color = rect_clr; - back_color = back_clr; + lt.set(l, t); + rb.set(l+w, t+h); + rect_color = rect_clr; + back_color = back_clr; } - IC void SetGrid (int w_div, float w_step, int h_div, float h_step, u32 grid_clr, u32 base_clr) + + IC + + void SetGrid(int w_div, float w_step, int h_div, float h_step, u32 grid_clr, u32 base_clr) { - grid.set (w_div,h_div); - grid_step.set (w_step, h_step); - grid_color = grid_clr; - base_color = base_clr; + grid.set(w_div, h_div); + grid_step.set(w_step, h_step); + grid_color = grid_clr; + base_color = base_clr; } - IC void SetMinMax (float _mn, float _mx, u32 item_count) + + IC + + void SetMinMax(float _mn, float _mx, u32 item_count) { - mn = _mn; - mx = _mx; + mn = _mn; + mx = _mx; max_item_count = item_count; - for (SubGraphVecIt it=subgraphs.begin(); it!=subgraphs.end(); it++) - { - while(it->elements.size()>max_item_count) it->elements.pop_front(); - }; + for (SubGraphVecIt it = subgraphs.begin(); it!=subgraphs.end(); it++) + { + while (it->elements.size()>max_item_count) + it->elements.pop_front(); + }; } - IC void AppendItem (float d, u32 clr, u32 SubGraphID = 0) + + IC + + void AppendItem(float d, u32 clr, u32 SubGraphID = 0) + { + if (SubGraphID>=subgraphs.size()) + return; + + clamp(d, mn, mx); + + SubGraphVecIt it = subgraphs.begin()+SubGraphID; + it->elements.push_back(SElement(d, clr)); + while (it->elements.size()>max_item_count) + it->elements.pop_front(); + }; + + IC u32 AppendSubGraph(EStyle S) + { + subgraphs.push_back(SSubGraph(S)); + return subgraphs.size()-1; + }; + + IC + + void AddMarker(EStyle Style, float pos, u32 Color) + { + SMarker NewMarker; + NewMarker.m_dwColor = Color; + NewMarker.m_eStyle = Style; + NewMarker.m_fPos = pos; + + m_Markers.push_back(NewMarker); + }; + + IC const SMarker&Marker(u32 ID) { - if (SubGraphID>=subgraphs.size()) return; + VERIFY(IDelements.push_back(SElement(d,clr)); - while(it->elements.size()>max_item_count) it->elements.pop_front(); + void UpdateMarkerPos(u32 ID, float NewPos) + { + if (ID>=m_Markers.size()) + return; + SMarker&pMarker = m_Markers[ID]; + pMarker.m_fPos = NewPos; }; - IC u32 AppendSubGraph (EStyle S) - { - subgraphs.push_back(SSubGraph(S)); - return subgraphs.size()-1; - }; - - IC void AddMarker (EStyle Style, float pos, u32 Color) - { - SMarker NewMarker; - NewMarker.m_dwColor = Color; - NewMarker.m_eStyle = Style; - NewMarker.m_fPos = pos; - - m_Markers.push_back(NewMarker); - }; - - IC const SMarker& Marker(u32 ID) - { - VERIFY(ID= m_Markers.size()) return; - SMarker &pMarker = m_Markers[ID]; - pMarker.m_fPos = NewPos; - }; - IC void ClearMarkers() - { - m_Markers.clear(); - } - - IC void RemoveMarker(u32 ID) - { - if (ID >= m_Markers.size()) return; - m_Markers.erase(m_Markers.begin()+ID); - } + + IC + + void ClearMarkers() + { + m_Markers.clear(); + } + + IC + + void RemoveMarker(u32 ID) + { + if (ID>=m_Markers.size()) + return; + m_Markers.erase(m_Markers.begin()+ID); + } }; #endif + diff --git a/src/editors/ParticleEditor/TopBar.cpp b/src/editors/ParticleEditor/TopBar.cpp index e58dd29541b..3522a8d5cc2 100644 --- a/src/editors/ParticleEditor/TopBar.cpp +++ b/src/editors/ParticleEditor/TopBar.cpp @@ -10,165 +10,200 @@ #pragma link "mxPlacemnt" #pragma resource "*.dfm" TfraTopBar *fraTopBar; + //--------------------------------------------------------------------------- -__fastcall TfraTopBar::TfraTopBar(TComponent* Owner) - : TFrame(Owner) +__fastcall TfraTopBar::TfraTopBar(TComponent *Owner) + : TFrame(Owner) { - ebActionSelect->Tag = etaSelect; - ebActionAdd->Tag = etaAdd; - ebActionMove->Tag = etaMove; - ebActionRotate->Tag = etaRotate; - ebActionScale->Tag = etaScale; - - ebAxisX->Tag = etAxisX; - ebAxisY->Tag = etAxisY; - ebAxisZ->Tag = etAxisZ; - ebAxisZX->Tag = etAxisZX; - - ebCSParent->Tag = etfCSParent; - ebNUScale->Tag = etfNUScale; - ebNormalAlign->Tag = etfNormalAlign; - ebGSnap->Tag = etfGSnap; - ebOSnap->Tag = etfOSnap; - ebMTSnap->Tag = etfMTSnap; - ebVSnap->Tag = etfVSnap; - ebASnap->Tag = etfASnap; - ebMSnap->Tag = etfMSnap; + ebActionSelect->Tag = etaSelect; + ebActionAdd->Tag = etaAdd; + ebActionMove->Tag = etaMove; + ebActionRotate->Tag = etaRotate; + ebActionScale->Tag = etaScale; + + ebAxisX->Tag = etAxisX; + ebAxisY->Tag = etAxisY; + ebAxisZ->Tag = etAxisZ; + ebAxisZX->Tag = etAxisZX; + + ebCSParent->Tag = etfCSParent; + ebNUScale->Tag = etfNUScale; + ebNormalAlign->Tag = etfNormalAlign; + ebGSnap->Tag = etfGSnap; + ebOSnap->Tag = etfOSnap; + ebMTSnap->Tag = etfMTSnap; + ebVSnap->Tag = etfVSnap; + ebASnap->Tag = etfASnap; + ebMSnap->Tag = etfMSnap; DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- -void TfraTopBar::OnTimer(){ - for (int j=0; j(temp) != NULL) +void TfraTopBar::OnTimer() +{ + for (int j = 0; j(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebEditUndoClick(TObject *Sender) -{ - ExecCommand( COMMAND_UNDO ); +{ + ExecCommand(COMMAND_UNDO); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebEditRedoClick(TObject *Sender) { - ExecCommand( COMMAND_REDO ); + ExecCommand(COMMAND_REDO); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ActionClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_CHANGE_ACTION, btn->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebAxisClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_CHANGE_AXIS, btn->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebSettingsClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_SET_SETTINGS, btn->Tag, btn->Down); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebViewClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); - if (btn){ - if (btn==ebViewFront) EDevice.m_Camera.ViewFront(); - if (btn==ebViewBack) EDevice.m_Camera.ViewBack(); - if (btn==ebViewLeft) EDevice.m_Camera.ViewLeft(); - if (btn==ebViewRight) EDevice.m_Camera.ViewRight(); - if (btn==ebViewTop) EDevice.m_Camera.ViewTop(); - if (btn==ebViewBottom) EDevice.m_Camera.ViewBottom(); - if (btn==ebViewReset) EDevice.m_Camera.ViewReset(); + TExtBtn *btn = dynamic_cast(Sender); + if (btn) + { + if (btn==ebViewFront) + EDevice.m_Camera.ViewFront(); + if (btn==ebViewBack) + EDevice.m_Camera.ViewBack(); + if (btn==ebViewLeft) + EDevice.m_Camera.ViewLeft(); + if (btn==ebViewRight) + EDevice.m_Camera.ViewRight(); + if (btn==ebViewTop) + EDevice.m_Camera.ViewTop(); + if (btn==ebViewBottom) + EDevice.m_Camera.ViewBottom(); + if (btn==ebViewReset) + EDevice.m_Camera.ViewReset(); } UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::RefreshBar() { - TExtBtn* btn = 0; - //actions - switch(Tools->GetAction()){ - case etaSelect: btn=ebActionSelect; break; - case etaAdd: btn=ebActionAdd; break; - case etaMove: btn=ebActionMove; break; - case etaRotate: btn=ebActionRotate; break; - case etaScale: btn=ebActionScale; break; - default: THROW; + TExtBtn *btn = 0; + //actions + switch (Tools->GetAction()) + { + case etaSelect: btn = ebActionSelect; + break; + case etaAdd: btn = ebActionAdd; + break; + case etaMove: btn = ebActionMove; + break; + case etaRotate: btn = ebActionRotate; + break; + case etaScale: btn = ebActionScale; + break; + default: THROW; } - btn->Down = true; + btn->Down = true; // axis - switch (Tools->GetAxis()){ - case etAxisX: btn=ebAxisX; break; - case etAxisY: btn=ebAxisY; break; - case etAxisZ: btn=ebAxisZ; break; - case etAxisZX: btn=ebAxisZX; break; - case etAxisUndefined: btn=NULL; break; - default: THROW; + switch (Tools->GetAxis()) + { + case etAxisX: btn = ebAxisX; + break; + case etAxisY: btn = ebAxisY; + break; + case etAxisZ: btn = ebAxisZ; + break; + case etAxisZX: btn = ebAxisZX; + break; + case etAxisUndefined: btn = NULL; + break; + default: THROW; } - if(btn) - btn->Down = true; + if (btn) + btn->Down = true; // settings - ebCSParent->Down = Tools->GetSettings(etfCSParent); - ebNUScale->Down = Tools->GetSettings(etfNUScale); - ebNormalAlign->Down = Tools->GetSettings(etfNormalAlign); - ebGSnap->Down = Tools->GetSettings(etfGSnap); - ebOSnap->Down = Tools->GetSettings(etfOSnap); - ebMTSnap->Down = Tools->GetSettings(etfMTSnap); - ebVSnap->Down = Tools->GetSettings(etfVSnap); - ebASnap->Down = Tools->GetSettings(etfASnap); - ebMSnap->Down = Tools->GetSettings(etfMSnap); + ebCSParent->Down = Tools->GetSettings(etfCSParent); + ebNUScale->Down = Tools->GetSettings(etfNUScale); + ebNormalAlign->Down = Tools->GetSettings(etfNormalAlign); + ebGSnap->Down = Tools->GetSettings(etfGSnap); + ebOSnap->Down = Tools->GetSettings(etfOSnap); + ebMTSnap->Down = Tools->GetSettings(etfMTSnap); + ebVSnap->Down = Tools->GetSettings(etfVSnap); + ebASnap->Down = Tools->GetSettings(etfASnap); + ebMSnap->Down = Tools->GetSettings(etfMSnap); // redraw scene - UI->RedrawScene (); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebZoomExtentsClick(TObject *Sender) { - ExecCommand( COMMAND_ZOOM_EXTENTS, FALSE ); + ExecCommand(COMMAND_ZOOM_EXTENTS, FALSE); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebZoomExtentsSelectedClick(TObject *Sender) { - ExecCommand( COMMAND_ZOOM_EXTENTS, TRUE ); + ExecCommand(COMMAND_ZOOM_EXTENTS, TRUE); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebCameraStyleClick(TObject *Sender) { - EDevice.m_Camera.SetStyle((ECameraStyle)((TExtBtn*)Sender)->Tag); + EDevice.m_Camera.SetStyle((ECameraStyle)((TExtBtn*)Sender)->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::fsStorageRestorePlacement(TObject *Sender) { - if (ebCameraPlane->Down) EDevice.m_Camera.SetStyle(csPlaneMove); - else if (ebCameraArcBall->Down) EDevice.m_Camera.SetStyle(cs3DArcBall); - else if (ebCameraFly->Down) EDevice.m_Camera.SetStyle(csFreeFly); + if (ebCameraPlane->Down) + EDevice.m_Camera.SetStyle(csPlaneMove); + else if (ebCameraArcBall->Down) + EDevice.m_Camera.SetStyle(cs3DArcBall); + else if (ebCameraFly->Down) + EDevice.m_Camera.SetStyle(csFreeFly); UI->RedrawScene(); } -//--------------------------------------------------------------------------- - - - +//--------------------------------------------------------------------------- diff --git a/src/editors/ParticleEditor/TopBar.h b/src/editors/ParticleEditor/TopBar.h index 92a93edad09..326b4ab2e5f 100644 --- a/src/editors/ParticleEditor/TopBar.h +++ b/src/editors/ParticleEditor/TopBar.h @@ -12,11 +12,12 @@ #include #include "ExtBtn.hpp" #include "mxPlacemnt.hpp" + //--------------------------------------------------------------------------- class ECORE_API TfraTopBar : public TFrame { -__published: // IDE-managed Components - TPanel *paTBEdit; + __published: // IDE-managed Components + TPanel*paTBEdit; TExtBtn *ebEditUndo; TExtBtn *ebEditRedo; TPanel *paTBAction; @@ -28,7 +29,7 @@ class ECORE_API TfraTopBar : public TFrame TPanel *paSnap; TExtBtn *ebMSnap; TExtBtn *ebASnap; - TExtBtn *ebCSParent; + TExtBtn *ebCSParent; TPanel *paAxis; TExtBtn *ebAxisX; TExtBtn *ebAxisY; @@ -43,35 +44,37 @@ class ECORE_API TfraTopBar : public TFrame TExtBtn *ebViewBack; TExtBtn *ebViewRight; TExtBtn *ebViewBottom; - TExtBtn *ebNUScale; - TPanel *Panel1; - TExtBtn *ebZoomExtents; - TExtBtn *ebZoomExtentsSelected; - TExtBtn *ebVSnap; - TFormStorage *fsStorage; - TExtBtn *ebCameraPlane; - TExtBtn *ebCameraArcBall; - TExtBtn *ebCameraFly; - TExtBtn *ebViewReset; - TExtBtn *ebMTSnap; - TExtBtn *ebNormalAlign; + TExtBtn *ebNUScale; + TPanel *Panel1; + TExtBtn *ebZoomExtents; + TExtBtn *ebZoomExtentsSelected; + TExtBtn *ebVSnap; + TFormStorage *fsStorage; + TExtBtn *ebCameraPlane; + TExtBtn *ebCameraArcBall; + TExtBtn *ebCameraFly; + TExtBtn *ebViewReset; + TExtBtn *ebMTSnap; + TExtBtn *ebNormalAlign; void __fastcall ebEditUndoClick(TObject *Sender); void __fastcall ebEditRedoClick(TObject *Sender); void __fastcall ActionClick(TObject *Sender); void __fastcall ebViewClick(TObject *Sender); - void __fastcall ebZoomExtentsClick(TObject *Sender); - void __fastcall ebZoomExtentsSelectedClick(TObject *Sender); - void __fastcall ebCameraStyleClick(TObject *Sender); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall ebAxisClick(TObject *Sender); - void __fastcall ebSettingsClick(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TfraTopBar(TComponent* Owner); + void __fastcall ebZoomExtentsClick(TObject *Sender); + void __fastcall ebZoomExtentsSelectedClick(TObject *Sender); + void __fastcall ebCameraStyleClick(TObject *Sender); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall ebAxisClick(TObject *Sender); + void __fastcall ebSettingsClick(TObject *Sender); +private: // User declarations +public: // User declarations + __fastcall TfraTopBar(TComponent *Owner); void OnTimer(); void __fastcall RefreshBar(); }; + //--------------------------------------------------------------------------- -extern PACKAGE TfraTopBar *fraTopBar; +extern PACKAGE TfraTopBar * fraTopBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ParticleEditor/UI_ParticleMain.cpp b/src/editors/ParticleEditor/UI_ParticleMain.cpp index 4a5a110a625..55917bd71d2 100644 --- a/src/editors/ParticleEditor/UI_ParticleMain.cpp +++ b/src/editors/ParticleEditor/UI_ParticleMain.cpp @@ -1,32 +1,35 @@ //--------------------------------------------------------------------------- #include "stdafx.h" -#pragma hdrstop +#pragma hdrstop #include "UI_ParticleMain.h" #include "UI_ParticleTools.h" -#include "topbar.h" -#include "leftbar.h" +#include "TopBar.h" +#include "LeftBar.h" #include "EditorPreferences.h" #include "D3DUtils.h" -#include "bottombar.h" +#include "BottomBar.h" #include "xr_trims.h" #include "main.h" #include "xr_input.h" //--------------------------------------------------------------------------- -CParticleMain*& PUI=(CParticleMain*)UI; +CParticleMain *&PUI = (CParticleMain*)UI; + //--------------------------------------------------------------------------- -CParticleMain::CParticleMain() +CParticleMain::CParticleMain() { - EPrefs = xr_new(); + EPrefs = xr_new(); } + //--------------------------------------------------------------------------- CParticleMain::~CParticleMain() { - xr_delete (EPrefs); + xr_delete(EPrefs); } + //--------------------------------------------------------------------------- CCommandVar CParticleTool::CommandSelectPreviewObj(CCommandVar p1, CCommandVar p2) @@ -34,6 +37,7 @@ CCommandVar CParticleTool::CommandSelectPreviewObj(CCommandVar p1, CCommandVar p SelectPreviewObject(p1); return TRUE; } + CCommandVar CParticleTool::CommandEditPreviewProps(CCommandVar p1, CCommandVar p2) { EditPreviewPrefs(); @@ -42,19 +46,19 @@ CCommandVar CParticleTool::CommandEditPreviewProps(CCommandVar p1, CCommandVar p CCommandVar CParticleTool::CommandSaveXR(CCommandVar p1, CCommandVar p2) { - Save (true); - ExecCommand (COMMAND_UPDATE_CAPTION); + Save(true); + ExecCommand(COMMAND_UPDATE_CAPTION); return TRUE; } CCommandVar CParticleTool::CommandLoadXR(CCommandVar p1, CCommandVar p2) { - xr_string temp_fn; - if (EFS.GetOpenName ( "$game_data$", temp_fn, false, NULL, 0)) - { - ::Render->PSLibrary.OnDestroy (); - ::Render->PSLibrary.Load (temp_fn.c_str()); - ResetCurrent(); + xr_string temp_fn; + if (EFS.GetOpenName("$game_data$", temp_fn, false, NULL, 0)) + { + ::Render->PSLibrary.OnDestroy(); + ::Render->PSLibrary.Load(temp_fn.c_str()); + ResetCurrent(); ExecCommand(COMMAND_UPDATE_PROPERTIES); ExecCommand(COMMAND_UPDATE_CAPTION); } @@ -63,27 +67,32 @@ CCommandVar CParticleTool::CommandLoadXR(CCommandVar p1, CCommandVar p2) CCommandVar CParticleTool::CommandSave(CCommandVar p1, CCommandVar p2) { - Save (false); - ExecCommand (COMMAND_UPDATE_CAPTION); - return TRUE; + Save(false); + ExecCommand(COMMAND_UPDATE_CAPTION); + return TRUE; } + CCommandVar CParticleTool::CommandSaveBackup(CCommandVar p1, CCommandVar p2) { ExecCommand(COMMAND_SAVE); return TRUE; } + CCommandVar CParticleTool::CommandReload(CCommandVar p1, CCommandVar p2) { - if (!IfModified()) return FALSE; - Reload (); + if (!IfModified()) + return FALSE; + Reload(); ExecCommand(COMMAND_UPDATE_CAPTION); return TRUE; } + CCommandVar CParticleTool::CommandValidate(CCommandVar p1, CCommandVar p2) { - Validate(true); + Validate(true); return TRUE; } + CCommandVar CParticleTool::CommandClear(CCommandVar p1, CCommandVar p2) { EDevice.m_Camera.Reset(); @@ -91,23 +100,27 @@ CCommandVar CParticleTool::CommandClear(CCommandVar p1, CCommandVar p2) ExecCommand(COMMAND_UPDATE_CAPTION); return TRUE; } + CCommandVar CParticleTool::CommandPlayCurrent(CCommandVar p1, CCommandVar p2) { PlayCurrent(); return TRUE; } + CCommandVar CParticleTool::CommandStopCurrent(CCommandVar p1, CCommandVar p2) { StopCurrent(p1); return TRUE; } + CCommandVar CommandRefreshUIBar(CCommandVar p1, CCommandVar p2) { - fraTopBar->RefreshBar (); - fraLeftBar->RefreshBar (); + fraTopBar->RefreshBar(); + fraLeftBar->RefreshBar(); fraBottomBar->RefreshBar(); return TRUE; } + CCommandVar CommandRestoreUIBar(CCommandVar p1, CCommandVar p2) { fraTopBar->fsStorage->RestoreFormPlacement(); @@ -115,6 +128,7 @@ CCommandVar CommandRestoreUIBar(CCommandVar p1, CCommandVar p2) fraBottomBar->fsStorage->RestoreFormPlacement(); return TRUE; } + CCommandVar CommandSaveUIBar(CCommandVar p1, CCommandVar p2) { fraTopBar->fsStorage->SaveFormPlacement(); @@ -122,11 +136,13 @@ CCommandVar CommandSaveUIBar(CCommandVar p1, CCommandVar p2) fraBottomBar->fsStorage->SaveFormPlacement(); return TRUE; } + CCommandVar CommandUpdateToolBar(CCommandVar p1, CCommandVar p2) { fraLeftBar->UpdateBar(); return TRUE; } + CCommandVar CommandUpdateCaption(CCommandVar p1, CCommandVar p2) { frmMain->UpdateCaption(); @@ -141,53 +157,56 @@ CCommandVar CommandJumpToItem(CCommandVar p1, CCommandVar p2) void CParticleMain::RegisterCommands() { - inherited::RegisterCommands(); + inherited::RegisterCommands(); // tools - REGISTER_CMD_CE (COMMAND_SELECT_PREVIEW_OBJ,"Select Preview Object",PTools,CParticleTool::CommandSelectPreviewObj, true); - REGISTER_CMD_CE (COMMAND_EDIT_PREVIEW_PROPS,"Select Preview Props", PTools,CParticleTool::CommandEditPreviewProps, true); - REGISTER_CMD_CE (COMMAND_SAVE, "File\\Save", PTools,CParticleTool::CommandSave, true); - REGISTER_CMD_C (COMMAND_SAVE_BACKUP, PTools,CParticleTool::CommandSaveBackup); - REGISTER_CMD_CE (COMMAND_LOAD, "File\\Reload", PTools,CParticleTool::CommandReload, true); - REGISTER_CMD_C (COMMAND_VALIDATE, PTools,CParticleTool::CommandValidate); - REGISTER_CMD_CE (COMMAND_CLEAR, "File\\Clear", PTools,CParticleTool::CommandClear, true); - REGISTER_CMD_CE (COMMAND_PLAY_CURRENT, "Particles\\Play", PTools,CParticleTool::CommandPlayCurrent, true); - REGISTER_SUB_CMD_CE (COMMAND_STOP_CURRENT, "Particles", PTools,CParticleTool::CommandStopCurrent, true); - APPEND_SUB_CMD ("Stop Immediate", 0,0); - APPEND_SUB_CMD ("Stop Deffered", 1,0); + REGISTER_CMD_CE(COMMAND_SELECT_PREVIEW_OBJ, "Select Preview Object", PTools, CParticleTool::CommandSelectPreviewObj, true); + REGISTER_CMD_CE(COMMAND_EDIT_PREVIEW_PROPS, "Select Preview Props", PTools, CParticleTool::CommandEditPreviewProps, true); + REGISTER_CMD_CE(COMMAND_SAVE, "File\\Save", PTools, CParticleTool::CommandSave, true); + REGISTER_CMD_C(COMMAND_SAVE_BACKUP, PTools, CParticleTool::CommandSaveBackup); + REGISTER_CMD_CE(COMMAND_LOAD, "File\\Reload", PTools, CParticleTool::CommandReload, true); + REGISTER_CMD_C(COMMAND_VALIDATE, PTools, CParticleTool::CommandValidate); + REGISTER_CMD_CE(COMMAND_CLEAR, "File\\Clear", PTools, CParticleTool::CommandClear, true); + REGISTER_CMD_CE(COMMAND_PLAY_CURRENT, "Particles\\Play", PTools, CParticleTool::CommandPlayCurrent, true); + REGISTER_SUB_CMD_CE(COMMAND_STOP_CURRENT, "Particles", PTools, CParticleTool::CommandStopCurrent, true); + APPEND_SUB_CMD("Stop Immediate", 0, 0); + APPEND_SUB_CMD("Stop Deffered", 1, 0); REGISTER_SUB_CMD_END; - REGISTER_CMD_S (COMMAND_REFRESH_UI_BAR, CommandRefreshUIBar); - REGISTER_CMD_S (COMMAND_RESTORE_UI_BAR, CommandRestoreUIBar); - REGISTER_CMD_S (COMMAND_SAVE_UI_BAR, CommandSaveUIBar); - REGISTER_CMD_S (COMMAND_UPDATE_TOOLBAR, CommandUpdateToolBar); - REGISTER_CMD_S (COMMAND_UPDATE_CAPTION, CommandUpdateCaption); - REGISTER_CMD_S (COMMAND_JUMP_TO_ITEM, CommandJumpToItem); - REGISTER_CMD_C (COMMAND_SAVE_XR, PTools, CParticleTool::CommandSaveXR); - REGISTER_CMD_C (COMMAND_LOAD_XR, PTools, CParticleTool::CommandLoadXR); - REGISTER_CMD_C (COMMAND_COMPACT_PARTICLES, PTools, CParticleTool::Compact); - REGISTER_CMD_CE (COMMAND_CREATE_GROUP_FROM_SELECTED,"Particles\\CreateGroupFromEffect", PTools, CParticleTool::CreateGroupFromSelected, true); -} + REGISTER_CMD_S(COMMAND_REFRESH_UI_BAR, CommandRefreshUIBar); + REGISTER_CMD_S(COMMAND_RESTORE_UI_BAR, CommandRestoreUIBar); + REGISTER_CMD_S(COMMAND_SAVE_UI_BAR, CommandSaveUIBar); + REGISTER_CMD_S(COMMAND_UPDATE_TOOLBAR, CommandUpdateToolBar); + REGISTER_CMD_S(COMMAND_UPDATE_CAPTION, CommandUpdateCaption); + REGISTER_CMD_S(COMMAND_JUMP_TO_ITEM, CommandJumpToItem); + REGISTER_CMD_C(COMMAND_SAVE_XR, PTools, CParticleTool::CommandSaveXR); + REGISTER_CMD_C(COMMAND_LOAD_XR, PTools, CParticleTool::CommandLoadXR); + REGISTER_CMD_C(COMMAND_COMPACT_PARTICLES, PTools, CParticleTool::Compact); + REGISTER_CMD_CE(COMMAND_CREATE_GROUP_FROM_SELECTED, "Particles\\CreateGroupFromEffect", PTools, CParticleTool::CreateGroupFromSelected, true); +} -char* CParticleMain::GetCaption() +char *CParticleMain::GetCaption() { - return "particles"; + return "particles"; } bool __fastcall CParticleMain::ApplyShortCut(WORD Key, TShiftState Shift) { - return inherited::ApplyShortCut(Key,Shift); + return inherited::ApplyShortCut(Key, Shift); } + //--------------------------------------------------------------------------- bool __fastcall CParticleMain::ApplyGlobalShortCut(WORD Key, TShiftState Shift) { - return inherited::ApplyGlobalShortCut(Key,Shift); + return inherited::ApplyGlobalShortCut(Key, Shift); } + //--------------------------------------------------------------------------- void CParticleMain::RealUpdateScene() { - inherited::RealUpdateScene (); + inherited::RealUpdateScene(); } + //--------------------------------------------------------------------------- @@ -196,60 +215,78 @@ void CParticleMain::RealUpdateScene() //--------------------------------------------------------------------------- void CParticleMain::ResetStatus() { - VERIFY(m_bReady); - if (fraBottomBar->paStatus->Caption!=""){ - fraBottomBar->paStatus->Caption=""; fraBottomBar->paStatus->Repaint(); + VERIFY(m_bReady); + if (fraBottomBar->paStatus->Caption!="") + { + fraBottomBar->paStatus->Caption = ""; + fraBottomBar->paStatus->Repaint(); } } + void CParticleMain::SetStatus(LPSTR s, bool bOutLog) { - VERIFY(m_bReady); - if (fraBottomBar->paStatus->Caption!=s){ - fraBottomBar->paStatus->Caption=s; fraBottomBar->paStatus->Repaint(); - if (bOutLog&&s&&s[0]) ELog.Msg(mtInformation,s); + VERIFY(m_bReady); + if (fraBottomBar->paStatus->Caption!=s) + { + fraBottomBar->paStatus->Caption = s; + fraBottomBar->paStatus->Repaint(); + if (bOutLog&&s&&s[0]) + ELog.Msg(mtInformation, s); } } + void CParticleMain::ProgressDraw() { - fraBottomBar->RedrawBar(); + fraBottomBar->RedrawBar(); } + //--------------------------------------------------------------------------- void CParticleMain::OutCameraPos() { - VERIFY(m_bReady); + VERIFY(m_bReady); AnsiString s; - const Fvector& c = EDevice.m_Camera.GetPosition(); - s.sprintf("C: %3.1f, %3.1f, %3.1f",c.x,c.y,c.z); -// const Fvector& hpb = EDevice.m_Camera.GetHPB(); -// s.sprintf(" Cam: %3.1f°, %3.1f°, %3.1f°",rad2deg(hpb.y),rad2deg(hpb.x),rad2deg(hpb.z)); - fraBottomBar->paCamera->Caption=s; fraBottomBar->paCamera->Repaint(); + const Fvector &c = EDevice.m_Camera.GetPosition(); + s.sprintf("C: %3.1f, %3.1f, %3.1f", c.x, c.y, c.z); + // const Fvector& hpb = EDevice.m_Camera.GetHPB(); + // s.sprintf(" Cam: %3.1f°, %3.1f°, %3.1f°",rad2deg(hpb.y),rad2deg(hpb.x),rad2deg(hpb.z)); + fraBottomBar->paCamera->Caption = s; + fraBottomBar->paCamera->Repaint(); } + //--------------------------------------------------------------------------- void CParticleMain::OutUICursorPos() { - VERIFY(m_bReady); - AnsiString s; POINT pt; + VERIFY(m_bReady); + AnsiString s; + POINT pt; GetCursorPos(&pt); - s.sprintf("Cur: %d, %d",pt.x,pt.y); - fraBottomBar->paUICursor->Caption=s; fraBottomBar->paUICursor->Repaint(); + s.sprintf("Cur: %d, %d", pt.x, pt.y); + fraBottomBar->paUICursor->Caption = s; + fraBottomBar->paUICursor->Repaint(); } + //--------------------------------------------------------------------------- void CParticleMain::OutGridSize() { - VERIFY(fraBottomBar); + VERIFY(fraBottomBar); AnsiString s; - s.sprintf("Grid: %1.1f",EPrefs->grid_cell_size); - fraBottomBar->paGridSquareSize->Caption=s; fraBottomBar->paGridSquareSize->Repaint(); + s.sprintf("Grid: %1.1f", EPrefs->grid_cell_size); + fraBottomBar->paGridSquareSize->Caption = s; + fraBottomBar->paGridSquareSize->Repaint(); } + //--------------------------------------------------------------------------- void CParticleMain::OutInfo() { - fraBottomBar->paSel->Caption = Tools->GetInfo(); + fraBottomBar->paSel->Caption = Tools->GetInfo(); } + //--------------------------------------------------------------------------- void CParticleMain::RealQuit() { - frmMain->Close(); + frmMain->Close(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ParticleEditor/UI_ParticleMain.h b/src/editors/ParticleEditor/UI_ParticleMain.h index 6b3d088215a..7ef6127c307 100644 --- a/src/editors/ParticleEditor/UI_ParticleMain.h +++ b/src/editors/ParticleEditor/UI_ParticleMain.h @@ -3,8 +3,9 @@ #include "ui_main.h" -enum { - COMMAND_EXTFIRST_EXT = COMMAND_MAIN_LAST-1, +enum +{ + COMMAND_EXTFIRST_EXT = COMMAND_MAIN_LAST-1, COMMAND_VALIDATE, @@ -19,39 +20,48 @@ enum { COMMAND_COMPACT_PARTICLES, COMMAND_CREATE_GROUP_FROM_SELECTED }; + //------------------------------------------------------------------------------ -class CParticleMain: public TUI{ - typedef TUI inherited; - - virtual void RealUpdateScene (); - virtual void RealQuit (); +class CParticleMain: public TUI +{ + typedef TUI inherited; + + virtual void RealUpdateScene(); + virtual void RealQuit(); public: - CParticleMain (); - virtual ~CParticleMain (); + CParticleMain(); + virtual ~CParticleMain(); + + virtual LPSTR GetCaption(); - virtual LPSTR GetCaption (); + virtual void ResetStatus(); + virtual void SetStatus(LPSTR s, bool bOutLog); + virtual void ProgressDraw(); + virtual void OutCameraPos(); + virtual void OutUICursorPos(); + virtual void OutGridSize(); + virtual void OutInfo(); - virtual void ResetStatus (); - virtual void SetStatus (LPSTR s, bool bOutLog); - virtual void ProgressDraw (); - virtual void OutCameraPos (); - virtual void OutUICursorPos (); - virtual void OutGridSize (); - virtual void OutInfo (); + virtual LPCSTR EditorName() + { + return "particle"; + } - virtual LPCSTR EditorName (){return "particle";} - virtual LPCSTR EditorDesc (){return "Particle Editor";} + virtual LPCSTR EditorDesc() + { + return "Particle Editor"; + } - virtual bool ApplyShortCut (WORD Key, TShiftState Shift); - virtual bool ApplyGlobalShortCut (WORD Key, TShiftState Shift); + virtual bool ApplyShortCut(WORD Key, TShiftState Shift); + virtual bool ApplyGlobalShortCut(WORD Key, TShiftState Shift); // commands - virtual void RegisterCommands (); -}; -extern CParticleMain*& PUI; + virtual void RegisterCommands(); +}; + +extern CParticleMain *&PUI; //--------------------------------------------------------------------------- #endif //UI_MainCommandH - diff --git a/src/editors/ParticleEditor/UI_ParticleTools.cpp b/src/editors/ParticleEditor/UI_ParticleTools.cpp index e7eef3ac6d4..2092b79af35 100644 --- a/src/editors/ParticleEditor/UI_ParticleTools.cpp +++ b/src/editors/ParticleEditor/UI_ParticleTools.cpp @@ -3,115 +3,124 @@ #include "stdafx.h" #pragma hdrstop -#include "../xrEProps/ChoseForm.h" +#include "editors/xrEProps/ChoseForm.h" #include "UI_ParticleTools.h" -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditObject.h" #include "ui_main.h" -#include "leftbar.h" -#include "..\..\Layers\xrRender\PSLibrary.h" +#include "LeftBar.h" +#include "Layers/xrRender/PSLibrary.h" #include "xr_trims.h" -#include "../ECore/Editor/library.h" -#include "../ECore/Editor/Render.h" -#include "../xrEProps/folderlib.h" -#include "../xrEProps/itemdialog.h" +#include "editors/ECore/Editor/Library.h" +#include "editors/ECore/Editor/Render.h" +#include "editors/xrEProps/FolderLib.h" +#include "editors/xrEProps/ItemDialog.h" -#include "../xrEProps/TextForm.h" -#include "d3dutils.h" +#include "editors/xrEProps/TextForm.h" +#include "D3DUtils.h" #include "ObjectAnimator.h" -#include "../xrEProps/ItemList.h" +#include "editors/xrEProps/ItemList.h" #include "ParticleEffectActions.h" #include "ItemPropFormUnit.h" //------------------------------------------------------------------------------ -CParticleTool*& PTools=(CParticleTool*)Tools; +CParticleTool *&PTools = (CParticleTool*)Tools; //------------------------------------------------------------------------------ #define CHECK_SNAP(R,A,C){ R+=A; if(fabsf(R)>=C){ A=snapto(R,C); R=0; }else{A=0;}} //static Fvector zero_vec={0.f,0.f,0.f}; -EParticleAction* pCreateEActionImpl(PAPI::PActionEnum type); +EParticleAction *pCreateEActionImpl(PAPI::PActionEnum type); CParticleTool::CParticleTool() { - m_EditMode = emNone; - m_ItemProps = 0; - m_EditObject = 0; - m_bModified = false; - m_bReady = false; + m_EditMode = emNone; + m_ItemProps = 0; + m_EditObject = 0; + m_bModified = false; + m_bReady = false; m_Transform.identity(); - m_Vel.set (0,0,0); - fFogness = 0.9f; - dwFogColor = 0xffffffff; - m_Flags.zero (); - pCreateEAction = pCreateEActionImpl; + m_Vel.set(0, 0, 0); + fFogness = 0.9f; + dwFogColor = 0xffffffff; + m_Flags.zero(); + pCreateEAction = pCreateEActionImpl; } + //--------------------------------------------------------------------------- CParticleTool::~CParticleTool() { - xr_delete(fmItemProp); + xr_delete(fmItemProp); } + //--------------------------------------------------------------------------- bool CParticleTool::OnCreate() { - fmItemProp = xr_new((TComponent*)NULL); - fmItemProp->Visible = true; + fmItemProp = xr_new((TComponent*)NULL); + fmItemProp->Visible = true; - m_bReady = true; + m_bReady = true; - Load (0); + Load(0); - SetAction (etaSelect); + SetAction(etaSelect); - m_EditPE = (PS::CParticleEffect*)::Render->Models->CreatePE(0); - m_EditPG = (PS::CParticleGroup*)::Render->Models->CreatePG(0); - m_ItemProps = TProperties::CreateForm( "Item Props", - fmItemProp, - alClient, - fastdelegate::bind(this,&CParticleTool::OnItemModified), - 0, - 0, - TProperties::plFolderStore | TProperties::plFullExpand /*| TProperties::plItemFolders*/ | TProperties::plIFTop ); - m_ItemProps->Visible = true; + m_EditPE = (PS::CParticleEffect*)::Render->Models->CreatePE(0); + m_EditPG = (PS::CParticleGroup*)::Render->Models->CreatePG(0); + m_ItemProps = TProperties::CreateForm("Item Props", + fmItemProp, + alClient, + fastdelegate::bind(this, &CParticleTool::OnItemModified), + 0, + 0, + TProperties::plFolderStore|TProperties::plFullExpand /*| TProperties::plItemFolders*/|TProperties::plIFTop); + m_ItemProps->Visible = true; // item list - m_PList = TItemList::CreateForm( "Items", - fraLeftBar->paPSList, - alClient, - TItemList::ilEditMenu | TItemList::ilDragAllowed); - - m_PList->SetOnItemsFocusedEvent (fastdelegate::bind(this,&CParticleTool::OnParticleItemFocused)); - m_PList->SetOnItemRenameEvent (fastdelegate::bind(this,&CParticleTool::OnParticleItemRename)); - m_PList->SetOnItemRemoveEvent (fastdelegate::bind(this,&CParticleTool::OnParticleItemRemove)); - m_PList->SetImages (fraLeftBar->ilModeIcons); - - m_ParentAnimator= xr_new(); + m_PList = TItemList::CreateForm("Items", + fraLeftBar->paPSList, + alClient, + TItemList::ilEditMenu|TItemList::ilDragAllowed); + + m_PList->SetOnItemsFocusedEvent(fastdelegate::bind(this, &CParticleTool::OnParticleItemFocused)); + m_PList->SetOnItemRenameEvent(fastdelegate::bind(this, &CParticleTool::OnParticleItemRename)); + m_PList->SetOnItemRemoveEvent(fastdelegate::bind(this, &CParticleTool::OnParticleItemRemove)); + m_PList->SetImages(fraLeftBar->ilModeIcons); + + m_ParentAnimator = xr_new(); return true; } void CParticleTool::OnDestroy() { - VERIFY (m_bReady); - m_bReady = false; + VERIFY(m_bReady); + m_bReady = false; - xr_delete (m_ParentAnimator); + xr_delete(m_ParentAnimator); - Lib.RemoveEditObject(m_EditObject); + Lib.RemoveEditObject(m_EditObject); TItemList::DestroyForm(m_PList); - TProperties::DestroyForm(m_ItemProps); - xr_delete (m_EditPG); - xr_delete (m_EditPE); + TProperties::DestroyForm(m_ItemProps); + xr_delete(m_EditPG); + xr_delete(m_EditPE); } + //--------------------------------------------------------------------------- bool CParticleTool::IfModified() { - if (m_bModified){ + if (m_bModified) + { int mr = ELog.DlgMsg(mtConfirmation, "The particles has been modified.\nDo you want to save your changes?"); - switch(mr){ - case mrYes: if (!ExecCommand(COMMAND_SAVE)) return false; else m_bModified = FALSE; break; - case mrNo: m_bModified = FALSE; break; - case mrCancel: return false; + switch (mr) + { + case mrYes: if (!ExecCommand(COMMAND_SAVE)) + return false; else + m_bModified = FALSE; + break; + case mrNo: m_bModified = FALSE; + break; + case mrCancel: return false; } } return true; @@ -119,139 +128,166 @@ bool CParticleTool::IfModified() void CParticleTool::Modified() { - m_bModified = true; - ExecCommand(COMMAND_UPDATE_CAPTION); + m_bModified = true; + ExecCommand(COMMAND_UPDATE_CAPTION); } + //--------------------------------------------------------------------------- void CParticleTool::OnItemModified() { - Modified(); + Modified(); if (m_LibPED) - CompileEffect (); - ExecCommand(COMMAND_UPDATE_PROPERTIES); + CompileEffect(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } + #include "igame_persistent.h" void CParticleTool::RenderEnvironment() { -/* - if (psDeviceFlags.is(rsEnvironment)){ - g_pGamePersistent->Environment().RenderSky (); - g_pGamePersistent->Environment().RenderClouds (); - } -*/ + /* + if (psDeviceFlags.is(rsEnvironment)){ + g_pGamePersistent->Environment().RenderSky (); + g_pGamePersistent->Environment().RenderClouds (); + } + */ } void CParticleTool::Render() { - if (!m_bReady) return; - - PrepareLighting (); - - if (m_EditObject) m_EditObject->RenderSingle(Fidentity); - // draw parent axis - DU_impl.DrawObjectAxis (m_Transform,0.05f,true); - // draw domains - switch(m_EditMode){ - case emNone: break; - case emEffect:{ - if (m_EditPE&&m_EditPE->GetDefinition()) - m_EditPE->GetDefinition()->Render(m_Transform); - }break; - case emGroup:{ - if (m_EditPG){ - int cnt = m_EditPG->items.size(); - for (int k=0; kitems[k]._effect; - if (E&&E->GetDefinition()&&m_LibPGD->m_Effects[k]->m_Flags.is(PS::CPGDef::SEffect::flEnabled)) - E->GetDefinition()->Render(m_Transform); + if (!m_bReady) + return; + + PrepareLighting(); + + if (m_EditObject) + m_EditObject->RenderSingle(Fidentity); + // draw parent axis + DU_impl.DrawObjectAxis(m_Transform, 0.05f, true); + // draw domains + switch (m_EditMode) + { + case emNone: break; + case emEffect: + { + if (m_EditPE&&m_EditPE->GetDefinition()) + m_EditPE->GetDefinition()->Render(m_Transform); + } + break; + case emGroup: + { + if (m_EditPG) + { + int cnt = m_EditPG->items.size(); + for (int k = 0; kitems[k]._effect; + if (E&&E->GetDefinition()&&m_LibPGD->m_Effects[k]->m_Flags.is(PS::CPGDef::SEffect::flEnabled)) + E->GetDefinition()->Render(m_Transform); + } } } - }break; - default: THROW; + break; + default: THROW; } - // Draw the particles. - ::Render->Models->RenderSingle(m_EditPG,Fidentity,1.f); - ::Render->Models->RenderSingle(m_EditPE,Fidentity,1.f); + // Draw the particles. + ::Render->Models->RenderSingle(m_EditPG, Fidentity, 1.f); + ::Render->Models->RenderSingle(m_EditPE, Fidentity, 1.f); if (m_Flags.is(flAnimatedPath)) - m_ParentAnimator->DrawPath(); + m_ParentAnimator->DrawPath(); -//. if (psDeviceFlags.is(rsEnvironment)) g_pGamePersistent->Environment().RenderLast (); - inherited::Render (); + //. if (psDeviceFlags.is(rsEnvironment)) g_pGamePersistent->Environment().RenderLast (); + inherited::Render(); } void CParticleTool::OnFrame() { - if (!m_bReady) return; - if (m_EditObject) - m_EditObject->OnFrame(); - - if (m_Flags.is(flAnimatedParent)){ - m_ParentAnimator->Update(EDevice.fTimeDelta); - if (m_ParentAnimator->IsPlaying()){ - Fvector new_vel; - new_vel.sub (m_ParentAnimator->XFORM().c,m_Transform.c); - new_vel.div (EDevice.fTimeDelta); - m_Vel.lerp (m_Vel,new_vel,0.9); - m_Transform = m_ParentAnimator->XFORM(); - m_Flags.set (flApplyParent,TRUE); + if (!m_bReady) + return; + if (m_EditObject) + m_EditObject->OnFrame(); + + if (m_Flags.is(flAnimatedParent)) + { + m_ParentAnimator->Update(EDevice.fTimeDelta); + if (m_ParentAnimator->IsPlaying()) + { + Fvector new_vel; + new_vel.sub(m_ParentAnimator->XFORM().c, m_Transform.c); + new_vel.div(EDevice.fTimeDelta); + m_Vel.lerp(m_Vel, new_vel, 0.9); + m_Transform = m_ParentAnimator->XFORM(); + m_Flags.set(flApplyParent, TRUE); } } if (m_Flags.is(flRemoveAction)) - RealRemoveAction(); - if (m_Flags.is(flApplyParent)) - RealApplyParent(); - if (m_Flags.is(flCompileEffect)) - RealCompileEffect(); + RealRemoveAction(); + if (m_Flags.is(flApplyParent)) + RealApplyParent(); + if (m_Flags.is(flCompileEffect)) + RealCompileEffect(); m_EditPE->OnFrame(EDevice.dwTimeDelta); m_EditPG->OnFrame(EDevice.dwTimeDelta); - if (m_Flags.is(flRefreshProps)) - RealUpdateProperties(); + if (m_Flags.is(flRefreshProps)) + RealUpdateProperties(); - if (m_Flags.is(flSelectEffect)){ - m_PList->SelectItem (sel_eff_name.c_str(),true,false,true); - m_Flags.set (flSelectEffect,FALSE); - sel_eff_name = ""; + if (m_Flags.is(flSelectEffect)) + { + m_PList->SelectItem(sel_eff_name.c_str(), true, false, true); + m_Flags.set(flSelectEffect, FALSE); + sel_eff_name = ""; } AnsiString tmp; - switch(m_EditMode){ - case emNone: break; - case emEffect: - if (m_EditPE->IsPlaying()) - UI->SetStatus(AnsiString().sprintf(" PE Playing...[%d]",m_EditPE->ParticlesCount()).c_str(),false); - else - UI->SetStatus(" Stopped.",false); - break; - case emGroup: - if (m_EditPG->IsPlaying()) - UI->SetStatus(AnsiString().sprintf(" PE Playing...[%d]",m_EditPG->ParticlesCount()).c_str(),false); - else - UI->SetStatus(" Stopped.",false); - break; - default: THROW; + switch (m_EditMode) + { + case emNone: break; + case emEffect: + if (m_EditPE->IsPlaying()) + UI->SetStatus(AnsiString().sprintf(" PE Playing...[%d]", m_EditPE->ParticlesCount()).c_str(), false); + else + UI->SetStatus(" Stopped.", false); + break; + case emGroup: + if (m_EditPG->IsPlaying()) + UI->SetStatus(AnsiString().sprintf(" PE Playing...[%d]", m_EditPG->ParticlesCount()).c_str(), false); + else + UI->SetStatus(" Stopped.", false); + break; + default: THROW; } } void CParticleTool::ZoomObject(BOOL bSelOnly) { - VERIFY(m_bReady); - if (!bSelOnly&&m_EditObject){ + VERIFY(m_bReady); + if (!bSelOnly&&m_EditObject) + { EDevice.m_Camera.ZoomExtents(m_EditObject->GetBox()); - }else{ - Fbox box; box.invalidate(); - switch(m_EditMode){ - case emNone: break; - case emEffect: box.set(m_EditPE->vis.box); break; - case emGroup: box.set(m_EditPG->vis.box); break; - default: THROW; + } + else + { + Fbox box; + box.invalidate(); + switch (m_EditMode) + { + case emNone: break; + case emEffect: box.set(m_EditPE->vis.box); + break; + case emGroup: box.set(m_EditPG->vis.box); + break; + default: THROW; + } + if (box.is_valid()) + { + box.grow(1.f); + EDevice.m_Camera.ZoomExtents(box); } - if (box.is_valid()){ box.grow(1.f); EDevice.m_Camera.ZoomExtents(box); } } } @@ -259,60 +295,63 @@ void CParticleTool::PrepareLighting() { // add directional light Flight L; - ZeroMemory(&L,sizeof(Flight)); + ZeroMemory(&L, sizeof(Flight)); L.type = D3DLIGHT_DIRECTIONAL; - L.diffuse.set(1,1,1,1); - L.direction.set(1,-1,1); L.direction.normalize(); - EDevice.SetLight(0,L); - EDevice.LightEnable(0,true); + L.diffuse.set(1, 1, 1, 1); + L.direction.set(1, -1, 1); + L.direction.normalize(); + EDevice.SetLight(0, L); + EDevice.LightEnable(0, true); - L.diffuse.set(0.3,0.3,0.3,1); - L.direction.set(-1,-1,-1); L.direction.normalize(); - EDevice.SetLight(1,L); - EDevice.LightEnable(1,true); + L.diffuse.set(0.3, 0.3, 0.3, 1); + L.direction.set(-1, -1, -1); + L.direction.normalize(); + EDevice.SetLight(1, L); + EDevice.LightEnable(1, true); - L.diffuse.set(0.3,0.3,0.3,1); - L.direction.set(1,-1,-1); L.direction.normalize(); - EDevice.SetLight(2,L); - EDevice.LightEnable(2,true); + L.diffuse.set(0.3, 0.3, 0.3, 1); + L.direction.set(1, -1, -1); + L.direction.normalize(); + EDevice.SetLight(2, L); + EDevice.LightEnable(2, true); - L.diffuse.set(0.3,0.3,0.3,1); - L.direction.set(-1,-1,1); L.direction.normalize(); - EDevice.SetLight(3,L); - EDevice.LightEnable(3,true); + L.diffuse.set(0.3, 0.3, 0.3, 1); + L.direction.set(-1, -1, 1); + L.direction.normalize(); + EDevice.SetLight(3, L); + EDevice.LightEnable(3, true); - L.diffuse.set(1.0,0.8,0.7,1); - L.direction.set(0,1,0); L.direction.normalize(); - EDevice.SetLight(4,L); - EDevice.LightEnable(4,true); + L.diffuse.set(1.0, 0.8, 0.7, 1); + L.direction.set(0, 1, 0); + L.direction.normalize(); + EDevice.SetLight(4, L); + EDevice.LightEnable(4, true); } -void CParticleTool::OnDeviceCreate() -{ -} +void CParticleTool::OnDeviceCreate() {} -void CParticleTool::OnDeviceDestroy() -{ -} +void CParticleTool::OnDeviceDestroy() {} -void CParticleTool::SelectPreviewObject(int p){ +void CParticleTool::SelectPreviewObject(int p) +{ LPCSTR fn; - if (!TfrmChoseItem::SelectItem(smObject,fn,1,m_EditObject?m_EditObject->GetName():0)) return; + if (!TfrmChoseItem::SelectItem(smObject, fn, 1, m_EditObject ? m_EditObject->GetName() : 0)) + return; Lib.RemoveEditObject(m_EditObject); - m_EditObject = fn?Lib.CreateEditObject(fn):0; -// ZoomObject(TRUE); + m_EditObject = fn ? Lib.CreateEditObject(fn) : 0; + // ZoomObject(TRUE); UI->RedrawScene(); } void CParticleTool::ResetPreviewObject() { - VERIFY(m_bReady); + VERIFY(m_bReady); UI->RedrawScene(); } bool CParticleTool::Load(LPCSTR name) { - VERIFY(m_bReady); + VERIFY(m_bReady); UpdateProperties(); return true; } @@ -320,590 +359,661 @@ bool CParticleTool::Load(LPCSTR name) bool CParticleTool::Save(bool bAsXR) { - VERIFY (m_bReady); + VERIFY(m_bReady); // validate if (!Validate(true)) { - ELog.DlgMsg (mtError,"Invalid particle's found. Validate library and try again."); + ELog.DlgMsg(mtError, "Invalid particle's found. Validate library and try again."); return false; } - bool bRes = false; - if(bAsXR) + bool bRes = false; + if (bAsXR) { - bRes = ::Render->PSLibrary.Save(); - }else + bRes = ::Render->PSLibrary.Save(); + } + else { - bRes = ::Render->PSLibrary.Save2(); + bRes = ::Render->PSLibrary.Save2(); } - if (bRes) m_bModified = false; + if (bRes) + m_bModified = false; return bRes; } void CParticleTool::Reload() { - VERIFY(m_bReady); - ResetCurrent (); - ::Render->PSLibrary.Reload(); + VERIFY(m_bReady); + ResetCurrent(); + ::Render->PSLibrary.Reload(); // visual part m_ItemProps->ClearProperties(); UpdateProperties(true); } -void CheckEffect(const xr_string& group_path, const shared_str& eff_full_name, xr_string& res_name, bool bRenameOnly) +void CheckEffect(const xr_string &group_path, const shared_str &eff_full_name, xr_string &res_name, bool bRenameOnly) { - res_name = group_path + "effects\\" + EFS.ExtractFileName(eff_full_name.c_str()); + res_name = group_path+"effects\\"+EFS.ExtractFileName(eff_full_name.c_str()); - if(0!=stricmp(res_name.c_str(),eff_full_name.c_str())) + if (0!=stricmp(res_name.c_str(), eff_full_name.c_str())) { - PS::CPEDef* old_ped = ::Render->PSLibrary.FindPED(eff_full_name.c_str()); - PS::CPEDef* new_ped = ::Render->PSLibrary.FindPED(res_name.c_str()); - if(bRenameOnly) + PS::CPEDef *old_ped = ::Render->PSLibrary.FindPED(eff_full_name.c_str()); + PS::CPEDef *new_ped = ::Render->PSLibrary.FindPED(res_name.c_str()); + if (bRenameOnly) { - ::Render->PSLibrary.Remove (res_name.c_str()); - new_ped = NULL; + ::Render->PSLibrary.Remove(res_name.c_str()); + new_ped = NULL; } - if(!new_ped) + if (!new_ped) { - new_ped = (bRenameOnly)? old_ped : ::Render->PSLibrary.AppendPED(old_ped); - new_ped->m_Name = res_name.c_str(); - if(bRenameOnly) - Msg ("rename effect [%s]->[%s]", eff_full_name.c_str(), res_name.c_str()); + new_ped = (bRenameOnly) ? old_ped : ::Render->PSLibrary.AppendPED(old_ped); + new_ped->m_Name = res_name.c_str(); + if (bRenameOnly) + Msg("rename effect [%s]->[%s]", eff_full_name.c_str(), res_name.c_str()); else - Msg ("create new effect [%s]", res_name.c_str()); + Msg("create new effect [%s]", res_name.c_str()); } - VERIFY( 0==stricmp(new_ped->m_Name.c_str(), res_name.c_str()) ); + VERIFY(0==stricmp(new_ped->m_Name.c_str(), res_name.c_str())); } - } CCommandVar CParticleTool::CreateGroupFromSelected(CCommandVar p1, CCommandVar p2) { - PS::CPEDef* curr = m_LibPED; - if(!curr) + PS::CPEDef *curr = m_LibPED; + if (!curr) { - ELog.DlgMsg (mtError,"Select Effect first."); + ELog.DlgMsg(mtError, "Select Effect first."); return false; } - const shared_str& eff_name = curr->m_Name; - PS::CPGDef* pg = AppendPG(0); + const shared_str &eff_name = curr->m_Name; + PS::CPGDef *pg = AppendPG(0); + + AnsiString grp_name = eff_name.c_str(); + pg->m_Name = grp_name.c_str(); - AnsiString grp_name = eff_name.c_str(); - pg->m_Name = grp_name.c_str(); + pg->m_fTimeLimit = 0.0f; + PS::CPGDef::SEffect *eff = xr_new(); + pg->m_Effects.push_back(eff); + eff->m_EffectName = eff_name; - pg->m_fTimeLimit = 0.0f; - PS::CPGDef::SEffect* eff = xr_new(); - pg->m_Effects.push_back (eff); - eff->m_EffectName = eff_name; + eff->m_Flags.set(PS::CPGDef::SEffect::flEnabled, TRUE); + eff->m_Time0 = 0.0f; + eff->m_Time1 = 0.0f; - eff->m_Flags.set (PS::CPGDef::SEffect::flEnabled,TRUE); - eff->m_Time0 = 0.0f; - eff->m_Time1 = 0.0f; + xr_string tmp; + xr_string group_path = EFS.ExtractFilePath(grp_name.c_str()); + CheckEffect(group_path, eff->m_EffectName, tmp, true); - xr_string tmp; - xr_string group_path = EFS.ExtractFilePath(grp_name.c_str()); - CheckEffect (group_path, eff->m_EffectName, tmp, true); + eff->m_EffectName = tmp.c_str(); - eff->m_EffectName = tmp.c_str(); + curr->m_Name = tmp.c_str(); - curr->m_Name = tmp.c_str(); - - ExecCommand (COMMAND_UPDATE_PROPERTIES); - - m_PList->SelectItem (grp_name.c_str(), true, false, true); - - return TRUE; + ExecCommand(COMMAND_UPDATE_PROPERTIES); + + m_PList->SelectItem(grp_name.c_str(), true, false, true); + + return TRUE; } CCommandVar CParticleTool::Compact(CCommandVar p1, CCommandVar p2) { if (!Validate(true)) { - ELog.DlgMsg (mtError,"Invalid particle's found. Validate library and try again."); + ELog.DlgMsg(mtError, "Invalid particle's found. Validate library and try again."); return false; } - - for (PS::PGDIt g_it= ::Render->PSLibrary.FirstPGD(); g_it!=::Render->PSLibrary.LastPGD(); ++g_it) - { - PS::CPGDef* pg = (*g_it); - shared_str& group_name = pg->m_Name; - xr_string group_path = EFS.ExtractFilePath(group_name.c_str()); - - xr_vector::const_iterator pe_it = pg->m_Effects.begin(); - xr_vector::const_iterator pe_it_e = pg->m_Effects.end(); - - xr_string tmp; - - for(;pe_it!=pe_it_e;++pe_it) - { - PS::CPGDef::SEffect* Eff = (*pe_it); - CheckEffect (group_path, Eff->m_EffectName, tmp, false); - Eff->m_EffectName = tmp.c_str(); - - if(Eff->m_Flags.test(PS::CPGDef::SEffect::flOnPlayChild)) + + for (PS::PGDIt g_it = ::Render->PSLibrary.FirstPGD(); g_it!=::Render->PSLibrary.LastPGD(); ++g_it) + { + PS::CPGDef *pg = (*g_it); + shared_str&group_name = pg->m_Name; + xr_string group_path = EFS.ExtractFilePath(group_name.c_str()); + + xr_vector::const_iterator pe_it = pg->m_Effects.begin(); + xr_vector::const_iterator pe_it_e = pg->m_Effects.end(); + + xr_string tmp; + + for (; pe_it!=pe_it_e; ++pe_it) + { + PS::CPGDef::SEffect *Eff = (*pe_it); + CheckEffect(group_path, Eff->m_EffectName, tmp, false); + Eff->m_EffectName = tmp.c_str(); + + if (Eff->m_Flags.test(PS::CPGDef::SEffect::flOnPlayChild)) { - CheckEffect (group_path, Eff->m_OnPlayChildName, tmp, false); - Eff->m_OnPlayChildName = tmp.c_str(); + CheckEffect(group_path, Eff->m_OnPlayChildName, tmp, false); + Eff->m_OnPlayChildName = tmp.c_str(); } - if(Eff->m_Flags.test(PS::CPGDef::SEffect::flOnBirthChild)) + if (Eff->m_Flags.test(PS::CPGDef::SEffect::flOnBirthChild)) { - CheckEffect (group_path, Eff->m_OnBirthChildName, tmp, false); - Eff->m_OnBirthChildName = tmp.c_str(); + CheckEffect(group_path, Eff->m_OnBirthChildName, tmp, false); + Eff->m_OnBirthChildName = tmp.c_str(); } - if(Eff->m_Flags.test(PS::CPGDef::SEffect::flOnDeadChild)) + if (Eff->m_Flags.test(PS::CPGDef::SEffect::flOnDeadChild)) { - CheckEffect (group_path, Eff->m_OnDeadChildName, tmp, false); - Eff->m_OnDeadChildName = tmp.c_str(); + CheckEffect(group_path, Eff->m_OnDeadChildName, tmp, false); + Eff->m_OnDeadChildName = tmp.c_str(); } } } - ResetCurrent (); - UpdateProperties (true); + ResetCurrent(); + UpdateProperties(true); - return TRUE; + return TRUE; } bool CParticleTool::Validate(bool bMsg) { - if (bMsg) ELog.Msg (mtInformation,"Begin validation..."); - PS::PEDIt _eI = ::Render->PSLibrary.FirstPED(); - PS::PEDIt _eE = ::Render->PSLibrary.LastPED(); - u32 error_cnt = 0; + if (bMsg) + ELog.Msg(mtInformation, "Begin validation..."); + PS::PEDIt _eI = ::Render->PSLibrary.FirstPED(); + PS::PEDIt _eE = ::Render->PSLibrary.LastPED(); + u32 error_cnt = 0; for (; _eI!=_eE; ++_eI) { - if (!(*_eI)->Validate(bMsg)) - error_cnt++; + if (!(*_eI)->Validate(bMsg)) + error_cnt++; } - for (PS::PGDIt g_it= ::Render->PSLibrary.FirstPGD(); g_it!=::Render->PSLibrary.LastPGD(); ++g_it) + for (PS::PGDIt g_it = ::Render->PSLibrary.FirstPGD(); g_it!=::Render->PSLibrary.LastPGD(); ++g_it) { - PS::CPGDef* pg = (*g_it); - if (!pg->Validate(bMsg)) - error_cnt++; - } + PS::CPGDef *pg = (*g_it); + if (!pg->Validate(bMsg)) + error_cnt++; + } - if (bMsg){ - if (error_cnt>0)ELog.DlgMsg (mtError,"Validation FAILED! Found %d error's.",error_cnt); - else ELog.DlgMsg (mtInformation,"Validation OK."); + if (bMsg) + { + if (error_cnt>0) + ELog.DlgMsg(mtError, "Validation FAILED! Found %d error's.", error_cnt); + else + ELog.DlgMsg(mtInformation, "Validation OK."); } return error_cnt==0; } void CParticleTool::Rename(LPCSTR old_full_name, LPCSTR ren_part, int level) { - VERIFY(level<_GetItemCount(old_full_name,'\\')); + VERIFY(level<_GetItemCount(old_full_name, '\\')); AnsiString new_full_name; - _ReplaceItem(old_full_name,level,ren_part,new_full_name,'\\'); + _ReplaceItem(old_full_name, level, ren_part, new_full_name, '\\'); Rename(old_full_name, new_full_name.c_str()); } void CParticleTool::Rename(LPCSTR old_full_name, LPCSTR new_full_name) { - VERIFY(m_bReady); + VERIFY(m_bReady); // is effect - PS::CPEDef* E = ::Render->PSLibrary.FindPED(old_full_name); - if (E){ - ::Render->PSLibrary.RenamePED(E,new_full_name); - return; + PS::CPEDef *E = ::Render->PSLibrary.FindPED(old_full_name); + if (E) + { + ::Render->PSLibrary.RenamePED(E, new_full_name); + return; } // is group - PS::CPGDef* G = ::Render->PSLibrary.FindPGD(old_full_name); - if (G){ - ::Render->PSLibrary.RenamePGD(G,new_full_name); - return; + PS::CPGDef *G = ::Render->PSLibrary.FindPGD(old_full_name); + if (G) + { + ::Render->PSLibrary.RenamePGD(G, new_full_name); + return; } } void CParticleTool::Remove(LPCSTR name) { - VERIFY(m_bReady); - ::Render->PSLibrary.Remove (name); - SetCurrentPE (0); - SetCurrentPG (0); + VERIFY(m_bReady); + ::Render->PSLibrary.Remove(name); + SetCurrentPE(0); + SetCurrentPG(0); } void CParticleTool::RemoveCurrent() { - m_PList->RemoveSelItems (); + m_PList->RemoveSelItems(); } void CParticleTool::CloneCurrent() { - TElTreeItem* pNode = m_PList->GetSelected(); - if (pNode&&FHelper.IsObject(pNode)){ - AnsiString full_name; - FHelper.MakeName(pNode,0,full_name,false); - PS::CPEDef* PE=FindPE(full_name.c_str()); - if (PE){ - AppendPE(PE); + TElTreeItem *pNode = m_PList->GetSelected(); + if (pNode&&FHelper.IsObject(pNode)) + { + AnsiString full_name; + FHelper.MakeName(pNode, 0, full_name, false); + PS::CPEDef *PE = FindPE(full_name.c_str()); + if (PE) + { + AppendPE(PE); Modified(); - }else{ - PS::CPGDef* PG=FindPG(full_name.c_str()); - if (PG){ - AppendPG(PG); - Modified(); + } + else + { + PS::CPGDef *PG = FindPG(full_name.c_str()); + if (PG) + { + AppendPG(PG); + Modified(); } } - }else{ - ELog.DlgMsg(mtInformation, "At first select object."); + } + else + { + ELog.DlgMsg(mtInformation, "At first select object."); } } void CParticleTool::ResetCurrent() { - VERIFY(m_bReady); - if (m_LibPED) m_EditPE->Stop(FALSE); - if (m_LibPGD) m_EditPG->Stop(FALSE); - m_LibPED= 0; - m_LibPGD= 0; + VERIFY(m_bReady); + if (m_LibPED) + m_EditPE->Stop(FALSE); + if (m_LibPGD) + m_EditPG->Stop(FALSE); + m_LibPED = 0; + m_LibPGD = 0; } -void CParticleTool::SetCurrentPE(PS::CPEDef* P) +void CParticleTool::SetCurrentPE(PS::CPEDef *P) { - VERIFY(m_bReady); - m_EditPG->Compile (0); - if (m_LibPED!=P){ - m_LibPED = P; - m_EditPE->Compile (m_LibPED); - if (m_LibPED) - m_EditMode = emEffect; + VERIFY(m_bReady); + m_EditPG->Compile(0); + if (m_LibPED!=P) + { + m_LibPED = P; + m_EditPE->Compile(m_LibPED); + if (m_LibPED) + m_EditMode = emEffect; } - FillReferenceList (); + FillReferenceList(); } -void CParticleTool::SetCurrentPG(PS::CPGDef* P) +void CParticleTool::SetCurrentPG(PS::CPGDef *P) { - VERIFY(m_bReady); - m_EditPE->Compile (0); - if (m_LibPGD!=P){ - m_LibPGD = P; - m_EditPG->Compile (m_LibPGD); + VERIFY(m_bReady); + m_EditPE->Compile(0); + if (m_LibPGD!=P) + { + m_LibPGD = P; + m_EditPG->Compile(m_LibPGD); if (m_LibPGD) - m_EditMode = emGroup; + m_EditMode = emGroup; } - FillReferenceList (); + FillReferenceList(); } void CParticleTool::FillReferenceList() { - string128 str = ""; - fraLeftBar->refLB->Clear(); - if(m_EditMode==emGroup) + string128 str = ""; + fraLeftBar->refLB->Clear(); + if (m_EditMode==emGroup) { - if(m_EditPG->GetDefinition()) + if (m_EditPG->GetDefinition()) { - xr_vector::const_iterator pe_it = m_EditPG->GetDefinition()->m_Effects.begin(); - xr_vector::const_iterator pe_it_e = m_EditPG->GetDefinition()->m_Effects.end(); - for(;pe_it!=pe_it_e;++pe_it) + xr_vector::const_iterator pe_it = m_EditPG->GetDefinition()->m_Effects.begin(); + xr_vector::const_iterator pe_it_e = m_EditPG->GetDefinition()->m_Effects.end(); + for (; pe_it!=pe_it_e; ++pe_it) { - fraLeftBar->refLB->AddItem( (*pe_it)->m_EffectName.c_str(), NULL ); + fraLeftBar->refLB->AddItem((*pe_it)->m_EffectName.c_str(), NULL); } - if(m_EditPG->GetDefinition()->m_Flags.test(PS::CPGDef::SEffect::flOnPlayChild)) - fraLeftBar->refLB->AddItem( (*pe_it)->m_OnPlayChildName.c_str(), NULL ); - if(m_EditPG->GetDefinition()->m_Flags.test(PS::CPGDef::SEffect::flOnBirthChild)) - fraLeftBar->refLB->AddItem( (*pe_it)->m_OnBirthChildName.c_str(), NULL ); - if(m_EditPG->GetDefinition()->m_Flags.test(PS::CPGDef::SEffect::flOnDeadChild)) - fraLeftBar->refLB->AddItem( (*pe_it)->m_OnDeadChildName.c_str(), NULL ); + if (m_EditPG->GetDefinition()->m_Flags.test(PS::CPGDef::SEffect::flOnPlayChild)) + fraLeftBar->refLB->AddItem((*pe_it)->m_OnPlayChildName.c_str(), NULL); + if (m_EditPG->GetDefinition()->m_Flags.test(PS::CPGDef::SEffect::flOnBirthChild)) + fraLeftBar->refLB->AddItem((*pe_it)->m_OnBirthChildName.c_str(), NULL); + if (m_EditPG->GetDefinition()->m_Flags.test(PS::CPGDef::SEffect::flOnDeadChild)) + fraLeftBar->refLB->AddItem((*pe_it)->m_OnDeadChildName.c_str(), NULL); } - xr_sprintf (str, sizeof(str), "Effect(s): %d", fraLeftBar->refLB->Count ); - }else + xr_sprintf(str, sizeof(str), "Effect(s): %d", fraLeftBar->refLB->Count); + } + else { - if(m_EditPE->GetDefinition()) + if (m_EditPE->GetDefinition()) { - PS::PGDIt G = ::Render->PSLibrary.FirstPGD(); - PS::PGDIt G_e = ::Render->PSLibrary.LastPGD(); + PS::PGDIt G = ::Render->PSLibrary.FirstPGD(); + PS::PGDIt G_e = ::Render->PSLibrary.LastPGD(); for (; G!=G_e; ++G) { - PS::CPGDef* def = (*G); - PS::CPGDef::EffectIt pe_it = def->m_Effects.begin(); - PS::CPGDef::EffectIt pe_it_e = def->m_Effects.end(); - for(;pe_it!=pe_it_e;++pe_it) + PS::CPGDef *def = (*G); + PS::CPGDef::EffectIt pe_it = def->m_Effects.begin(); + PS::CPGDef::EffectIt pe_it_e = def->m_Effects.end(); + for (; pe_it!=pe_it_e; ++pe_it) { - if( (*pe_it)->m_EffectName==m_EditPE->Name() ) - fraLeftBar->refLB->AddItem(def->m_Name.c_str(), NULL); - else - if( (*pe_it)->m_OnPlayChildName==m_EditPE->Name() ) - fraLeftBar->refLB->AddItem(def->m_Name.c_str(), NULL); - else - if( (*pe_it)->m_OnBirthChildName==m_EditPE->Name() ) - fraLeftBar->refLB->AddItem(def->m_Name.c_str(), NULL); - else - if( (*pe_it)->m_OnDeadChildName==m_EditPE->Name() ) - fraLeftBar->refLB->AddItem(def->m_Name.c_str(), NULL); + if ((*pe_it)->m_EffectName==m_EditPE->Name()) + fraLeftBar->refLB->AddItem(def->m_Name.c_str(), NULL); + else if ((*pe_it)->m_OnPlayChildName==m_EditPE->Name()) + fraLeftBar->refLB->AddItem(def->m_Name.c_str(), NULL); + else if ((*pe_it)->m_OnBirthChildName==m_EditPE->Name()) + fraLeftBar->refLB->AddItem(def->m_Name.c_str(), NULL); + else if ((*pe_it)->m_OnDeadChildName==m_EditPE->Name()) + fraLeftBar->refLB->AddItem(def->m_Name.c_str(), NULL); } } } - xr_sprintf (str, sizeof(str), "Group(s): %d", fraLeftBar->refLB->Count ); + xr_sprintf(str, sizeof(str), "Group(s): %d", fraLeftBar->refLB->Count); } - fraLeftBar->refName->Caption = str; + fraLeftBar->refName->Caption = str; } + void CParticleTool::CommandJumpToItem() { - for(int i=0; irefLB->Count; ++i) - { - if(fraLeftBar->refLB->Selected[i]) + for (int i = 0; irefLB->Count; ++i) + { + if (fraLeftBar->refLB->Selected[i]) { - m_PList->SelectItem((fraLeftBar->refLB->Items->Strings[i]).c_str(),true,false,true); - break; + m_PList->SelectItem((fraLeftBar->refLB->Items->Strings[i]).c_str(), true, false, true); + break; } } } -PS::CPEDef* CParticleTool::FindPE(LPCSTR name) +PS::CPEDef *CParticleTool::FindPE(LPCSTR name) { - return ::Render->PSLibrary.FindPED(name); + return ::Render->PSLibrary.FindPED(name); } -PS::CPGDef* CParticleTool::FindPG(LPCSTR name) +PS::CPGDef *CParticleTool::FindPG(LPCSTR name) { - return ::Render->PSLibrary.FindPGD(name); + return ::Render->PSLibrary.FindPGD(name); } void CParticleTool::PlayCurrent(int idx) { - VERIFY(m_bReady); - StopCurrent (false); - switch(m_EditMode){ - case emNone: break; - case emEffect: m_EditPE->Play(); break; - case emGroup: - if (idx>-1){ - VERIFY(idx<(int)m_EditPG->items.size()); - m_LibPED = ((PS::CParticleEffect*)m_EditPG->items[idx]._effect)->GetDefinition(); - m_EditPE->Compile(m_LibPED); - m_EditPE->Play (); - }else{ - // play all - m_EditPG->Play(); - } - break; - default: THROW; + VERIFY(m_bReady); + StopCurrent(false); + switch (m_EditMode) + { + case emNone: break; + case emEffect: m_EditPE->Play(); + break; + case emGroup: + if (idx>-1) + { + VERIFY(idx<(int)m_EditPG->items.size()); + m_LibPED = ((PS::CParticleEffect*)m_EditPG->items[idx]._effect)->GetDefinition(); + m_EditPE->Compile(m_LibPED); + m_EditPE->Play(); + } + else + { + // play all + m_EditPG->Play(); + } + break; + default: THROW; } - ApplyParent (); + ApplyParent(); } void CParticleTool::StopCurrent(bool bFinishPlaying) { - VERIFY(m_bReady); + VERIFY(m_bReady); m_EditPE->Stop(bFinishPlaying); m_EditPG->Stop(bFinishPlaying); } void CParticleTool::SelectEffect(LPCSTR name) { - sel_eff_name = name; - m_Flags.set (flSelectEffect,TRUE); + sel_eff_name = name; + m_Flags.set(flSelectEffect, TRUE); } -void CParticleTool::OnShowHint(AStringVec& SS) -{ -} +void CParticleTool::OnShowHint(AStringVec &SS) {} bool CParticleTool::MouseStart(TShiftState Shift) { - inherited::MouseStart(Shift); - switch(m_Action){ - case etaSelect: break; - case etaAdd: break; - case etaMove:{ - if (Shift.Contains(ssCtrl)){ - if (m_EditObject){ - float dist = UI->ZFar(); - SRayPickInfo pinf; - if (m_EditObject->RayPick(dist,UI->m_CurrentRStart,UI->m_CurrentRDir,Fidentity,&pinf)) - m_Transform.c.set(pinf.pt); - }else{ - // pick grid - Fvector normal={0.f, 1.f, 0.f}; - float clcheck = UI->m_CurrentRDir.dotproduct( normal ); - if( fis_zero( clcheck ) ) return false; - float alpha = - UI->m_CurrentRStart.dotproduct(normal) / clcheck; - if( alpha <= 0 ) return false; - - m_Transform.c.mad(UI->m_CurrentRStart,UI->m_CurrentRDir,alpha); - - if (m_Settings.is(etfGSnap)){ - m_Transform.c.x = snapto( m_Transform.c.x, m_MoveSnap ); - m_Transform.c.z = snapto( m_Transform.c.z, m_MoveSnap ); - m_Transform.c.y = 0.f; + inherited::MouseStart(Shift); + switch (m_Action) + { + case etaSelect: break; + case etaAdd: break; + case etaMove: + { + if (Shift.Contains(ssCtrl)) + { + if (m_EditObject) + { + float dist = UI->ZFar(); + SRayPickInfo pinf; + if (m_EditObject->RayPick(dist, UI->m_CurrentRStart, UI->m_CurrentRDir, Fidentity, &pinf)) + m_Transform.c.set(pinf.pt); + } + else + { + // pick grid + Fvector normal = {0.f, 1.f, 0.f}; + float clcheck = UI->m_CurrentRDir.dotproduct(normal); + if (fis_zero(clcheck)) + return false; + float alpha = - UI->m_CurrentRStart.dotproduct(normal)/clcheck; + if (alpha<=0) + return false; + + m_Transform.c.mad(UI->m_CurrentRStart, UI->m_CurrentRDir, alpha); + + if (m_Settings.is(etfGSnap)) + { + m_Transform.c.x = snapto(m_Transform.c.x, m_MoveSnap); + m_Transform.c.z = snapto(m_Transform.c.z, m_MoveSnap); + m_Transform.c.y = 0.f; + } } } } - }break; - case etaRotate: break; - case etaScale: break; + break; + case etaRotate: break; + case etaScale: break; } - ApplyParent (); - return m_bHiddenMode; + ApplyParent(); + return m_bHiddenMode; } bool CParticleTool::MouseEnd(TShiftState Shift) { - inherited::MouseEnd(Shift); - return true; + inherited::MouseEnd(Shift); + return true; } void CParticleTool::MouseMove(TShiftState Shift) { - inherited::MouseMove(Shift); - switch(m_Action){ - case etaSelect: break; - case etaAdd: break; - case etaMove: - m_Transform.c.add(m_MovedAmount); - break; - case etaRotate:{ - Fmatrix mR; mR.identity(); - if (!fis_zero(m_RotateVector.x)) mR.rotateX(m_RotateAmount); - else if (!fis_zero(m_RotateVector.y)) mR.rotateY(m_RotateAmount); - else if (!fis_zero(m_RotateVector.z)) mR.rotateZ(m_RotateAmount); - m_Transform.mulB_43 (mR); - }break; - case etaScale: break; - } - ApplyParent (); + inherited::MouseMove(Shift); + switch (m_Action) + { + case etaSelect: break; + case etaAdd: break; + case etaMove: + m_Transform.c.add(m_MovedAmount); + break; + case etaRotate: + { + Fmatrix mR; + mR.identity(); + if (!fis_zero(m_RotateVector.x)) + mR.rotateX(m_RotateAmount); + else if (!fis_zero(m_RotateVector.y)) + mR.rotateY(m_RotateAmount); + else if (!fis_zero(m_RotateVector.z)) + mR.rotateZ(m_RotateAmount); + m_Transform.mulB_43(mR); + } + break; + case etaScale: break; + } + ApplyParent(); } + //------------------------------------------------------------------------------ void CParticleTool::RealApplyParent() { - switch(m_EditMode){ - case emNone: break; - case emEffect: m_EditPE->UpdateParent(m_Transform,m_Vel,m_Flags.is(flSetXFORM)); break; - case emGroup: m_EditPG->UpdateParent(m_Transform,m_Vel,m_Flags.is(flSetXFORM)); break; - default: THROW; + switch (m_EditMode) + { + case emNone: break; + case emEffect: m_EditPE->UpdateParent(m_Transform, m_Vel, m_Flags.is(flSetXFORM)); + break; + case emGroup: m_EditPG->UpdateParent(m_Transform, m_Vel, m_Flags.is(flSetXFORM)); + break; + default: THROW; } - m_Flags.set (flApplyParent,FALSE); + m_Flags.set(flApplyParent, FALSE); } void CParticleTool::RealCompileEffect() { - if (m_LibPED) m_LibPED->Compile(m_LibPED->m_EActionList); - m_Flags.set (flCompileEffect,FALSE); + if (m_LibPED) + m_LibPED->Compile(m_LibPED->m_EActionList); + m_Flags.set(flCompileEffect, FALSE); } void CParticleTool::RealRemoveAction() { - if (m_LibPED){ - xr_delete (m_LibPED->m_EActionList[remove_action_num]); - m_LibPED->m_EActionList.erase (m_LibPED->m_EActionList.begin()+remove_action_num); + if (m_LibPED) + { + xr_delete(m_LibPED->m_EActionList[remove_action_num]); + m_LibPED->m_EActionList.erase(m_LibPED->m_EActionList.begin()+remove_action_num); } - m_Flags.set (flRemoveAction,FALSE); + m_Flags.set(flRemoveAction, FALSE); } LPCSTR CParticleTool::GetInfo() { - return 0; + return 0; } + //------------------------------------------------------------------------------ void CParticleTool::SelectListItem(LPCSTR pref, LPCSTR name, bool bVal, bool bLeaveSel, bool bExpand) { - AnsiString nm = (name&&name[0])?PrepareKey(pref,name).c_str():pref; - m_PList->SelectItem(nm.c_str(),bVal,bLeaveSel,bExpand); - if (pref){ - m_PList->SelectItem(pref,true,true,bExpand); + AnsiString nm = (name&&name[0]) ? PrepareKey(pref, name).c_str() : pref; + m_PList->SelectItem(nm.c_str(), bVal, bLeaveSel, bExpand); + if (pref) + { + m_PList->SelectItem(pref, true, true, bExpand); } } + //------------------------------------------------------------------------------ -PS::CPEDef* CParticleTool::AppendPE(PS::CPEDef* src) -{ - VERIFY(m_bReady); - AnsiString folder_name; - FHelper.MakeName (m_PList->GetSelected(),0,folder_name,true); - string64 pref ={0}; - if (src){ - strcpy(pref,*src->m_Name);folder_name=""; - }else - strconcat (sizeof(pref),pref,folder_name.c_str(),"pe"); - - AnsiString new_name = FHelper.GenerateName(pref,2,fastdelegate::bind(&(::Render->PSLibrary),&CPSLibrary::FindByName),false,true); - PS::CPEDef* S = ::Render->PSLibrary.AppendPED(src); - S->m_Name = new_name.c_str(); - ExecCommand (COMMAND_UPDATE_PROPERTIES,true); - if (!new_name.IsEmpty()) SelectListItem(0,new_name.c_str(),true,false,true); +PS::CPEDef *CParticleTool::AppendPE(PS::CPEDef *src) +{ + VERIFY(m_bReady); + AnsiString folder_name; + FHelper.MakeName(m_PList->GetSelected(), 0, folder_name, true); + string64 pref = {0}; + if (src) + { + strcpy(pref, *src->m_Name); + folder_name = ""; + } + else + strconcat(sizeof(pref), pref, folder_name.c_str(), "pe"); + + AnsiString new_name = FHelper.GenerateName(pref, 2, fastdelegate::bind(&(::Render->PSLibrary), &CPSLibrary::FindByName), false, true); + PS::CPEDef *S = ::Render->PSLibrary.AppendPED(src); + S->m_Name = new_name.c_str(); + ExecCommand(COMMAND_UPDATE_PROPERTIES, true); + if (!new_name.IsEmpty()) + SelectListItem(0, new_name.c_str(), true, false, true); return S; } -PS::CPGDef* CParticleTool::AppendPG(PS::CPGDef* src) +PS::CPGDef *CParticleTool::AppendPG(PS::CPGDef *src) { - VERIFY(m_bReady); - AnsiString folder_name; - FHelper.MakeName (m_PList->GetSelected(),0,folder_name,true); - string64 pref ={0}; - if (src){ strcpy(pref,*src->m_Name);folder_name="";} - else strconcat (sizeof(pref),pref,folder_name.c_str(),"pg"); - AnsiString new_name = FHelper.GenerateName(pref,2,fastdelegate::bind(&(::Render->PSLibrary),&CPSLibrary::FindByName),false,true); - PS::CPGDef* S = ::Render->PSLibrary.AppendPGD(src); - S->m_Name = new_name.c_str(); - - ExecCommand (COMMAND_UPDATE_PROPERTIES,true); - if (!new_name.IsEmpty()) SelectListItem(0,new_name.c_str(),true,false,true); + VERIFY(m_bReady); + AnsiString folder_name; + FHelper.MakeName(m_PList->GetSelected(), 0, folder_name, true); + string64 pref = {0}; + if (src) + { + strcpy(pref, *src->m_Name); + folder_name = ""; + } + else + strconcat(sizeof(pref), pref, folder_name.c_str(), "pg"); + AnsiString new_name = FHelper.GenerateName(pref, 2, fastdelegate::bind(&(::Render->PSLibrary), &CPSLibrary::FindByName), false, true); + PS::CPGDef *S = ::Render->PSLibrary.AppendPGD(src); + S->m_Name = new_name.c_str(); + + ExecCommand(COMMAND_UPDATE_PROPERTIES, true); + if (!new_name.IsEmpty()) + SelectListItem(0, new_name.c_str(), true, false, true); return S; } #include "EditMesh.h" -bool CParticleTool::RayPick(const Fvector& start, const Fvector& dir, float& dist, Fvector* pt, Fvector* n) +bool CParticleTool::RayPick(const Fvector &start, const Fvector &dir, float &dist, Fvector *pt, Fvector *n) { - if (m_EditObject){ - SRayPickInfo pinf; - if (m_EditObject->RayPick(dist,start,dir,Fidentity,&pinf)){ - if (pt) pt->set(pinf.pt); - if (n){ - const Fvector* PT[3]; + if (m_EditObject) + { + SRayPickInfo pinf; + if (m_EditObject->RayPick(dist, start, dir, Fidentity, &pinf)) + { + if (pt) + pt->set(pinf.pt); + if (n) + { + const Fvector *PT[3]; pinf.e_mesh->GetFacePT(pinf.inf.id, PT); - n->mknormal(*PT[0],*PT[1],*PT[2]); + n->mknormal(*PT[0], *PT[1], *PT[2]); } return true; - }else return false; - }else{ - Fvector np; np.mad(start,dir,dist); - if ((start.y>0)&&(np.y<0.f)){ - if (pt) pt->set(start); - if (n) n->set(0.f,1.f,0.f); + } + else + return false; + } + else + { + Fvector np; + np.mad(start, dir, dist); + if ((start.y>0)&&(np.y<0.f)) + { + if (pt) + pt->set(start); + if (n) + n->set(0.f, 1.f, 0.f); return true; - }else return false; + } + else + return false; } } -void CParticleTool::OnChangeMotion (PropValue* sender) +void CParticleTool::OnChangeMotion(PropValue *sender) { - ChooseValue* V = dynamic_cast(sender); - if (V){ - m_ParentAnimator->Clear (); + ChooseValue *V = dynamic_cast(sender); + if (V) + { + m_ParentAnimator->Clear(); if (V->value->size()) - m_ParentAnimator->Load (V->value->c_str()); + m_ParentAnimator->Load(V->value->c_str()); } if (m_Flags.is(flAnimatedParent)) - m_ParentAnimator->Play (true); + m_ParentAnimator->Play(true); } void CParticleTool::EditPreviewPrefs() { - PropItemVec items; - shared_str motion_name = m_ParentAnimator->Name(); - PropValue *V; - V=PHelper().CreateFlag32 (items, "Parent\\Allow Animated", &m_Flags, flAnimatedParent); - V->OnChangeEvent.bind (this,&CParticleTool::OnChangeMotion); - PHelper().CreateFlag32 (items, "Parent\\Draw Path", &m_Flags, flAnimatedPath); - V=PHelper().CreateChoose (items, "Parent\\Motion", &motion_name, smGameAnim); - V->OnChangeEvent.bind (this,&CParticleTool::OnChangeMotion); - PHelper().CreateFloat (items, "Parent\\Motion Speed", &m_ParentAnimator->Speed(), 0.f, 10000.f); - TProperties* P = TProperties::CreateModalForm("Preview properties"); - P->AssignItems (items); - P->ShowPropertiesModal (); - TProperties::DestroyForm (P); -} - -bool CParticleTool::GetSelectionPosition (Fmatrix& result) -{ - result = m_Transform; - return true; + PropItemVec items; + shared_str motion_name = m_ParentAnimator->Name(); + PropValue *V; + V = PHelper().CreateFlag32(items, "Parent\\Allow Animated", &m_Flags, flAnimatedParent); + V->OnChangeEvent.bind(this, &CParticleTool::OnChangeMotion); + PHelper().CreateFlag32(items, "Parent\\Draw Path", &m_Flags, flAnimatedPath); + V = PHelper().CreateChoose(items, "Parent\\Motion", &motion_name, smGameAnim); + V->OnChangeEvent.bind(this, &CParticleTool::OnChangeMotion); + PHelper().CreateFloat(items, "Parent\\Motion Speed", &m_ParentAnimator->Speed(), 0.f, 10000.f); + TProperties *P = TProperties::CreateModalForm("Preview properties"); + P->AssignItems(items); + P->ShowPropertiesModal(); + TProperties::DestroyForm(P); +} + +bool CParticleTool::GetSelectionPosition(Fmatrix &result) +{ + result = m_Transform; + return true; } diff --git a/src/editors/ParticleEditor/UI_ParticleTools.h b/src/editors/ParticleEditor/UI_ParticleTools.h index 5068e17d9b1..5b1ef3f2efb 100644 --- a/src/editors/ParticleEditor/UI_ParticleTools.h +++ b/src/editors/ParticleEditor/UI_ParticleTools.h @@ -2,181 +2,238 @@ #ifndef UI_ParticleToolsH #define UI_ParticleToolsH -//. ?#include "ParticleSystem.h" -#include "..\..\Layers\xrRender\ParticleEffect.h" -#include "..\..\Layers\xrRender\ParticleGroup.h" +//#include "ParticleSystem.h" +#include "Layers/xrRender/ParticleEffect.h" +#include "Layers/xrRender/ParticleGroup.h" #include "pure.h" -#include "../xrEProps/PropertiesList.h" -#include "ui_toolscustom.h" +#include "editors/xrEProps/PropertiesList.h" +#include "UI_ToolsCustom.h" #include "ui_maincommand.h" // refs class CEditableObject; class CObjectAnimator; -enum EEditMode{ - emNone, +enum EEditMode +{ + emNone, emEffect, emGroup }; class CParticleTool: public CToolCustom { - typedef CToolCustom inherited; - friend class TfraLeftBar; + typedef CToolCustom inherited; + friend class TfraLeftBar; - CEditableObject* m_EditObject; - bool m_bModified; + CEditableObject *m_EditObject; + bool m_bModified; // PE variables - PS::CPEDef* m_LibPED; - PS::CParticleEffect*m_EditPE; + PS::CPEDef *m_LibPED; + PS::CParticleEffect *m_EditPE; // PG variables - PS::CPGDef* m_LibPGD; - PS::CParticleGroup* m_EditPG; + PS::CPGDef *m_LibPGD; + PS::CParticleGroup *m_EditPG; + + Fmatrix m_Transform; + Fvector m_Vel; + + void __stdcall OnItemModified(void); + + void __stdcall OnParticleItemFocused(ListItemsVec &items); + void __stdcall OnParticleItemRename(LPCSTR old_name, LPCSTR new_name, EItemType type); + void __stdcall OnParticleItemRemove(LPCSTR name, EItemType type, bool &res); + + void RealUpdateProperties(); + void SelectListItem(LPCSTR pref, LPCSTR name, bool bVal, bool bLeaveSel, bool bExpand); - Fmatrix m_Transform; - Fvector m_Vel; + void RealApplyParent(); - void __stdcall OnItemModified (void); + void ApplyParent(bool bForce = false) + { + m_Flags.set(flApplyParent, TRUE); + if (bForce) + RealApplyParent(); + } - void __stdcall OnParticleItemFocused (ListItemsVec& items); - void __stdcall OnParticleItemRename (LPCSTR old_name, LPCSTR new_name, EItemType type); - void __stdcall OnParticleItemRemove (LPCSTR name, EItemType type, bool& res); + void RealCompileEffect(); - void RealUpdateProperties(); - void SelectListItem (LPCSTR pref, LPCSTR name, bool bVal, bool bLeaveSel, bool bExpand); + void CompileEffect(bool bForced = false) + { + m_Flags.set(flCompileEffect, TRUE); + if (bForced) + RealCompileEffect(); + } - void RealApplyParent (); - void ApplyParent (bool bForce=false){m_Flags.set(flApplyParent,TRUE); if (bForce) RealApplyParent();} - void RealCompileEffect (); - void CompileEffect (bool bForced=false){m_Flags.set(flCompileEffect,TRUE); if (bForced) RealCompileEffect();} - u32 remove_action_num; - void RealRemoveAction (); + u32 remove_action_num; + void RealRemoveAction(); - void __stdcall OnControlClick (ButtonValue* sender, bool& bDataModified, bool& bSafe); + void __stdcall OnControlClick(ButtonValue *sender, bool &bDataModified, bool &bSafe); public: - void RemoveAction (u32 idx, bool bForced=false){remove_action_num=idx;m_Flags.set(flRemoveAction,TRUE); if (bForced) RealRemoveAction();} + void RemoveAction(u32 idx, bool bForced = false) + { + remove_action_num = idx; + m_Flags.set(flRemoveAction, TRUE); + if (bForced) + RealRemoveAction(); + } + public: - EEditMode m_EditMode; + EEditMode m_EditMode; - TProperties* m_ItemProps; - TItemList* m_PList; + TProperties *m_ItemProps; + TItemList *m_PList; public: - // flags - enum{ - flRefreshProps = (1<<0), - flApplyParent = (1<<1), - flCompileEffect = (1<<2), - flRemoveAction = (1<<3), - flAnimatedParent = (1<<4), - flAnimatedPath = (1<<5), - flSelectEffect = (1<<6), - flSetXFORM = (1<<7), + // flags + enum + { + flRefreshProps = (1<<0), + flApplyParent = (1<<1), + flCompileEffect = (1<<2), + flRemoveAction = (1<<3), + flAnimatedParent = (1<<4), + flAnimatedPath = (1<<5), + flSelectEffect = (1<<6), + flSetXFORM = (1<<7), }; - Flags32 m_Flags; + + Flags32 m_Flags; protected: - xr_string sel_eff_name; + xr_string sel_eff_name; - void __stdcall OnChangeMotion (PropValue* sender); - CObjectAnimator* m_ParentAnimator; + void __stdcall OnChangeMotion(PropValue *sender); + CObjectAnimator *m_ParentAnimator; - void PrepareLighting (); + void PrepareLighting(); public: - CParticleTool (); - virtual ~CParticleTool (); + CParticleTool(); + virtual ~CParticleTool(); + + virtual void Render(); + virtual void RenderEnvironment(); + virtual void OnFrame(); + + virtual bool OnCreate(); + virtual void OnDestroy(); + + virtual bool IfModified(); - virtual void Render (); - virtual void RenderEnvironment (); - virtual void OnFrame (); + virtual bool IsModified() + { + return m_bModified; + } - virtual bool OnCreate (); - virtual void OnDestroy (); + virtual void Modified(); - virtual bool IfModified (); - virtual bool IsModified (){return m_bModified;} - virtual void Modified (); + virtual LPCSTR GetInfo(); - virtual LPCSTR GetInfo (); - - virtual void ZoomObject (BOOL bSelOnly); + virtual void ZoomObject(BOOL bSelOnly); - virtual bool Load (LPCSTR name); - virtual bool Save (LPCSTR name, bool bInternal=false){R_ASSERT(0);return true;}; - bool Save (bool bAsXR); - virtual void Reload (); - - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); + virtual bool Load(LPCSTR name); - virtual void Clear (){inherited::Clear();} + virtual bool Save(LPCSTR name, bool bInternal = false) + { + R_ASSERT(0); + return true; + }; + + bool Save(bool bAsXR); + virtual void Reload(); + + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); + + virtual void Clear() + { + inherited::Clear(); + } + + virtual void OnShowHint(AStringVec &SS); - virtual void OnShowHint (AStringVec& SS); + virtual bool __fastcall MouseStart(TShiftState Shift); + virtual bool __fastcall MouseEnd(TShiftState Shift); + virtual void __fastcall MouseMove(TShiftState Shift); - virtual bool __fastcall MouseStart (TShiftState Shift); - virtual bool __fastcall MouseEnd (TShiftState Shift); - virtual void __fastcall MouseMove (TShiftState Shift); + virtual bool Pick(TShiftState Shift) + { + return false; + } - virtual bool Pick (TShiftState Shift){return false;} - virtual bool RayPick (const Fvector& start, const Fvector& dir, float& dist, Fvector* pt, Fvector* n); + virtual bool RayPick(const Fvector &start, const Fvector &dir, float &dist, Fvector *pt, Fvector *n); - virtual void ShowProperties (LPCSTR){;} - virtual void UpdateProperties (BOOL bForced=FALSE){m_Flags.set(flRefreshProps,TRUE); if (bForced) RealUpdateProperties();} - virtual void RefreshProperties (){;} + virtual void ShowProperties(LPCSTR) + { + ; + } - void PlayCurrent (int idx=-1); - void StopCurrent (bool bFinishPlaying); - void SelectEffect (LPCSTR name); + virtual void UpdateProperties(BOOL bForced = FALSE) + { + m_Flags.set(flRefreshProps, TRUE); + if (bForced) + RealUpdateProperties(); + } - void Rename (LPCSTR src_name, LPCSTR part_name, int part_idx); - void Rename (LPCSTR src_name, LPCSTR dest_name); + virtual void RefreshProperties() + { + ; + } + + void PlayCurrent(int idx = -1); + void StopCurrent(bool bFinishPlaying); + void SelectEffect(LPCSTR name); + + void Rename(LPCSTR src_name, LPCSTR part_name, int part_idx); + void Rename(LPCSTR src_name, LPCSTR dest_name); // PS routine - void CloneCurrent (); - void ResetCurrent (); - void RemoveCurrent (); - void Remove (LPCSTR name); + void CloneCurrent(); + void ResetCurrent(); + void RemoveCurrent(); + void Remove(LPCSTR name); // PG routine - PS::CPEDef* FindPE (LPCSTR name); - PS::CPEDef* AppendPE (PS::CPEDef* src); - void SetCurrentPE (PS::CPEDef* P); - void CommandJumpToItem (); + PS::CPEDef *FindPE(LPCSTR name); + PS::CPEDef *AppendPE(PS::CPEDef *src); + void SetCurrentPE(PS::CPEDef *P); + void CommandJumpToItem(); // PG routine - PS::CPGDef* FindPG (LPCSTR name); - PS::CPGDef* AppendPG (PS::CPGDef* src); - void SetCurrentPG (PS::CPGDef* P); - void FillReferenceList (); + PS::CPGDef *FindPG(LPCSTR name); + PS::CPGDef *AppendPG(PS::CPGDef *src); + void SetCurrentPG(PS::CPGDef *P); + void FillReferenceList(); + + void SelectPreviewObject(int p); + void ResetPreviewObject(); + void EditPreviewPrefs(); - void SelectPreviewObject (int p); - void ResetPreviewObject (); - void EditPreviewPrefs (); + bool Validate(bool bMsg); - bool Validate (bool bMsg); + virtual bool GetSelectionPosition(Fmatrix &result); - virtual bool GetSelectionPosition (Fmatrix& result); - - CCommandVar Compact (CCommandVar p1, CCommandVar p2); - CCommandVar CreateGroupFromSelected(CCommandVar p1, CCommandVar p2); + CCommandVar Compact(CCommandVar p1, CCommandVar p2); + CCommandVar CreateGroupFromSelected(CCommandVar p1, CCommandVar p2); // commands - CCommandVar CommandSelectPreviewObj (CCommandVar p1, CCommandVar p2); - CCommandVar CommandEditPreviewProps (CCommandVar p1, CCommandVar p2); - CCommandVar CommandSave (CCommandVar p1, CCommandVar p2); - CCommandVar CommandSaveXR (CCommandVar p1, CCommandVar p2); - CCommandVar CommandLoadXR (CCommandVar p1, CCommandVar p2); - CCommandVar CommandSaveBackup (CCommandVar p1, CCommandVar p2); - CCommandVar CommandReload (CCommandVar p1, CCommandVar p2); - CCommandVar CommandValidate (CCommandVar p1, CCommandVar p2); - CCommandVar CommandClear (CCommandVar p1, CCommandVar p2); - CCommandVar CommandPlayCurrent (CCommandVar p1, CCommandVar p2); - CCommandVar CommandStopCurrent (CCommandVar p1, CCommandVar p2); + CCommandVar CommandSelectPreviewObj(CCommandVar p1, CCommandVar p2); + CCommandVar CommandEditPreviewProps(CCommandVar p1, CCommandVar p2); + CCommandVar CommandSave(CCommandVar p1, CCommandVar p2); + CCommandVar CommandSaveXR(CCommandVar p1, CCommandVar p2); + CCommandVar CommandLoadXR(CCommandVar p1, CCommandVar p2); + CCommandVar CommandSaveBackup(CCommandVar p1, CCommandVar p2); + CCommandVar CommandReload(CCommandVar p1, CCommandVar p2); + CCommandVar CommandValidate(CCommandVar p1, CCommandVar p2); + CCommandVar CommandClear(CCommandVar p1, CCommandVar p2); + CCommandVar CommandPlayCurrent(CCommandVar p1, CCommandVar p2); + CCommandVar CommandStopCurrent(CCommandVar p1, CCommandVar p2); }; + #define SYSTEM_PREFIX "Systems" #define EFFECT_PREFIX "Effects" #define GROUP_PREFIX "Groups" -extern CParticleTool*& PTools; +extern CParticleTool *&PTools; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ParticleEditor/UI_ParticleToolsProps.cpp b/src/editors/ParticleEditor/UI_ParticleToolsProps.cpp index 156c1af97d7..c587cabd4c8 100644 --- a/src/editors/ParticleEditor/UI_ParticleToolsProps.cpp +++ b/src/editors/ParticleEditor/UI_ParticleToolsProps.cpp @@ -4,95 +4,105 @@ #include "UI_ParticleTools.h" #include "UI_ParticleMain.h" -#include "../xrEProps/TextForm.h" -#include "../xrEProps/ItemList.h" +#include "editors/xrEProps/TextForm.h" +#include "editors/xrEProps/ItemList.h" void CParticleTool::OnParticleItemRename(LPCSTR old_name, LPCSTR new_name, EItemType type) { - Rename (old_name,new_name); - Modified (); + Rename(old_name, new_name); + Modified(); } -void CParticleTool::OnParticleItemRemove(LPCSTR name, EItemType type, bool& res) +void CParticleTool::OnParticleItemRemove(LPCSTR name, EItemType type, bool &res) { - Remove (name); - Modified (); - res = true; + Remove(name); + Modified(); + res = true; } -void CParticleTool::OnControlClick(ButtonValue* sender, bool& bDataModified, bool& bSafe) +void CParticleTool::OnControlClick(ButtonValue *sender, bool &bDataModified, bool &bSafe) { - m_Transform.identity(); - bDataModified = false; + m_Transform.identity(); + bDataModified = false; } -void CParticleTool::OnParticleItemFocused(ListItemsVec& items) +void CParticleTool::OnParticleItemFocused(ListItemsVec &items) { - PropItemVec props; - m_EditMode = emEffect; + PropItemVec props; + m_EditMode = emEffect; - ButtonValue* B; - B=PHelper().CreateButton (props,"Transform\\Edit", "Reset", ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CParticleTool::OnControlClick); - PHelper().CreateFlag32 (props,"Transform\\Type", &m_Flags, flSetXFORM,"Update","Set"); + ButtonValue *B; + B = PHelper().CreateButton(props, "Transform\\Edit", "Reset", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CParticleTool::OnControlClick); + PHelper().CreateFlag32(props, "Transform\\Type", &m_Flags, flSetXFORM, "Update", "Set"); // reset to default - ResetCurrent (); + ResetCurrent(); - if (!items.empty()){ - for (ListItemsIt it=items.begin(); it!=items.end(); it++){ - ListItem* item = *it; - if (item){ - m_EditMode = EEditMode(item->Type()); - switch(m_EditMode){ - case emEffect:{ - PS::CPEDef* def = ((PS::CPEDef*)item->m_Object); - SetCurrentPE (def); - def->FillProp (EFFECT_PREFIX,props,item); - }break; - case emGroup:{ - PS::CPGDef* def = ((PS::CPGDef*)item->m_Object); - SetCurrentPG (def); - def->FillProp (GROUP_PREFIX,props,item); - }break; - default: THROW; + if (!items.empty()) + { + for (ListItemsIt it = items.begin(); it!=items.end(); it++) + { + ListItem *item = *it; + if (item) + { + m_EditMode = EEditMode(item->Type()); + switch (m_EditMode) + { + case emEffect: + { + PS::CPEDef *def = ((PS::CPEDef*)item->m_Object); + SetCurrentPE(def); + def->FillProp(EFFECT_PREFIX, props, item); + } + break; + case emGroup: + { + PS::CPGDef *def = ((PS::CPGDef*)item->m_Object); + SetCurrentPG(def); + def->FillProp(GROUP_PREFIX, props, item); + } + break; + default: THROW; } } } } - m_ItemProps->AssignItems(props); + m_ItemProps->AssignItems(props); UI->RedrawScene(); } + //------------------------------------------------------------------------------ extern AnsiString _item_to_select_after_edit; void CParticleTool::RealUpdateProperties() { - m_Flags.set(flRefreshProps,FALSE); + m_Flags.set(flRefreshProps, FALSE); - ListItemsVec items; + ListItemsVec items; { PS::PEDIt Pe = ::Render->PSLibrary.FirstPED(); PS::PEDIt Ee = ::Render->PSLibrary.LastPED(); - for (; Pe!=Ee; Pe++){ - ListItem* I=LHelper().CreateItem(items,*(*Pe)->m_Name,emEffect,0,*Pe); + for (; Pe!=Ee; Pe++) + { + ListItem *I = LHelper().CreateItem(items, *(*Pe)->m_Name, emEffect, 0, *Pe); I->SetIcon(1); } - } + } { PS::PGDIt Pg = ::Render->PSLibrary.FirstPGD(); PS::PGDIt Eg = ::Render->PSLibrary.LastPGD(); - for (; Pg!=Eg; Pg++){ - ListItem* I=LHelper().CreateItem(items,*(*Pg)->m_Name,emGroup,0,*Pg); + for (; Pg!=Eg; Pg++) + { + ListItem *I = LHelper().CreateItem(items, *(*Pg)->m_Name, emGroup, 0, *Pg); I->SetIcon(2); } - } - m_PList->AssignItems(items,false,true); - if(_item_to_select_after_edit.Length()) + } + m_PList->AssignItems(items, false, true); + if (_item_to_select_after_edit.Length()) { - m_PList->SelectItem(_item_to_select_after_edit.c_str(),true,false,true); + m_PList->SelectItem(_item_to_select_after_edit.c_str(), true, false, true); _item_to_select_after_edit = ""; } - } diff --git a/src/editors/ParticleEditor/main.cpp b/src/editors/ParticleEditor/main.cpp index 86a8eede8c6..74766a932f2 100644 --- a/src/editors/ParticleEditor/main.cpp +++ b/src/editors/ParticleEditor/main.cpp @@ -11,92 +11,101 @@ TfrmMain *frmMain; #pragma link "RenderWindow" #pragma resource "*.dfm" -#include "topbar.h" -#include "leftbar.h" +#include "TopBar.h" +#include "LeftBar.h" #include "bottombar.h" //------------------------------------------------------------------------------ -#include "../xrEProps/ChoseForm.h" -#include "../../Layers/xrRender/shader.h" -#include "shader_xrlc.h" -#include "../ECore/Engine/texture.h" -#include "../ECore/Editor/Library.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EThumbnail.h" -#include "../xrEProps/FolderLib.h" +#include "editors/xrEProps/ChoseForm.h" +#include "Layers/xrRender/Shader.h" +#include "utils/Shader_xrLC.h" +#include "editors/ECore/Engine/texture.h" +#include "editors/ECore/Editor/Library.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EThumbnail.h" +#include "editors/xrEProps/FolderLib.h" #include "LightAnimLibrary.h" #include "ImageManager.h" #include "SoundManager.h" #include "ui_main.h" -#include "..\..\Layers\xrRender\PSLibrary.h" -#include "GameMtlLib.h" -#include "../../xrSound/soundrender_source.h" +#include "Layers/xrRender/PSLibrary.h" +#include "xrEngine/GameMtlLib.h" +#include "xrSound/SoundRender_Source.h" #include "render.h" #include "ResourceManager.h" -#include "../xrEProps/EditorChooseEvents.h" +#include "editors/xrEProps/EditorChooseEvents.h" -__fastcall TfrmMain::TfrmMain(TComponent* Owner) - : TForm(Owner) +__fastcall TfrmMain::TfrmMain(TComponent *Owner) + : TForm(Owner) { -// forms - fraBottomBar = xr_new ((TComponent*)0); - fraTopBar = xr_new ((TComponent*)0); - fraLeftBar = xr_new ((TComponent*)0); -//- - - fraBottomBar->Parent = paBottomBar; - fraTopBar->Parent = paTopBar; - fraLeftBar->Parent = paLeftBar; - if (paLeftBar->Tag > 0) paLeftBar->Parent = paTopBar; - else paLeftBar->Parent = frmMain; - - EDevice.SetHandle (Handle,D3DWindow->Handle); - EnableReceiveCommands (); - if (!ExecCommand(COMMAND_INITIALIZE,(u32)D3DWindow,(u32)paRender)){ - FlushLog (); - TerminateProcess(GetCurrentProcess(),-1); + // forms + fraBottomBar = xr_new((TComponent*)0); + fraTopBar = xr_new((TComponent*)0); + fraLeftBar = xr_new((TComponent*)0); + //- + + fraBottomBar->Parent = paBottomBar; + fraTopBar->Parent = paTopBar; + fraLeftBar->Parent = paLeftBar; + if (paLeftBar->Tag>0) + paLeftBar->Parent = paTopBar; + else + paLeftBar->Parent = frmMain; + + EDevice.SetHandle(Handle, D3DWindow->Handle); + EnableReceiveCommands(); + if (!ExecCommand(COMMAND_INITIALIZE, (u32)D3DWindow, (u32)paRender)) + { + FlushLog(); + TerminateProcess(GetCurrentProcess(), -1); } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormShow(TObject *Sender) { - tmRefresh->Enabled = true; tmRefreshTimer(Sender); - ExecCommand (COMMAND_UPDATE_GRID); - ExecCommand (COMMAND_RENDER_FOCUS); - FillChooseEvents (); + tmRefresh->Enabled = true; + tmRefreshTimer(Sender); + ExecCommand(COMMAND_UPDATE_GRID); + ExecCommand(COMMAND_RENDER_FOCUS); + FillChooseEvents(); // special case :( - frmMain->WindowState = (TWindowState)fsStorage->ReadInteger("window_state",frmMain->WindowState); + frmMain->WindowState = (TWindowState)fsStorage->ReadInteger("window_state", frmMain->WindowState); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormClose(TObject *Sender, TCloseAction &Action) { - Application->OnIdle = 0; + Application->OnIdle = 0; - ClearChooseEvents (); + ClearChooseEvents(); - ExecCommand (COMMAND_DESTROY); + ExecCommand(COMMAND_DESTROY); - fraTopBar->Parent = 0; - fraLeftBar->Parent = 0; - fraBottomBar->Parent = 0; + fraTopBar->Parent = 0; + fraLeftBar->Parent = 0; + fraBottomBar->Parent = 0; xr_delete(fraTopBar); xr_delete(fraBottomBar); - xr_delete(fraLeftBar); + xr_delete(fraLeftBar); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormCloseQuery(TObject *Sender, bool &CanClose) { tmRefresh->Enabled = false; CanClose = ExecCommand(COMMAND_EXIT); - if (!CanClose) tmRefresh->Enabled = true; + if (!CanClose) + tmRefresh->Enabled = true; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormCreate(TObject *Sender) { - DEFINE_INI(fsStorage); + DEFINE_INI(fsStorage); Application->OnIdle = IdleHandler; } @@ -104,27 +113,34 @@ void __fastcall TfrmMain::FormCreate(TObject *Sender) #define MIN_PANEL_HEIGHT 17 + void __fastcall TfrmMain::sbToolsMinClick(TObject *Sender) { - if (paLeftBar->Tag > 0){ + if (paLeftBar->Tag>0) + { paLeftBar->Parent = frmMain; - paLeftBar->Tag = 0; - }else{ + paLeftBar->Tag = 0; + } + else + { paLeftBar->Parent = paTopBar; - paLeftBar->Tag = 1; + paLeftBar->Tag = 1; } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::TopClick(TObject *Sender) { - if (paLeftBar->Tag > 0){ - paLeftBar->Align = alRight; + if (paLeftBar->Tag>0) + { + paLeftBar->Align = alRight; paLeftBar->Parent = frmMain; paLeftBar->Height = paLeftBar->Tag; - paLeftBar->Tag = 0; + paLeftBar->Tag = 0; } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::IdleHandler(TObject *Sender, bool &Done) @@ -132,133 +148,169 @@ void __fastcall TfrmMain::IdleHandler(TObject *Sender, bool &Done) Done = false; UI->Idle(); } + void __fastcall TfrmMain::D3DWindowResize(TObject *Sender) { UI->Resize(); -} +} + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { ShiftKey = Shift; - if (!UI->KeyDown(Key, Shift)){UI->ApplyShortCut(Key, Shift);} + if (!UI->KeyDown(Key, Shift)) + { + UI->ApplyShortCut(Key, Shift); + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyUp(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if (!UI->KeyUp(Key, Shift)){;} + if (!UI->KeyUp(Key, Shift)) + { + ; + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyPress(TObject *Sender, char &Key) { - if (!UI->KeyPress(Key, ShiftKey)){;} + if (!UI->KeyPress(Key, ShiftKey)) + { + ; + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { - if (!D3DWindow->Focused()) UI->ApplyGlobalShortCut(Key, Shift); - if (Key==VK_MENU) Key=0; + if (!D3DWindow->Focused()) + UI->ApplyGlobalShortCut(Key, Shift); + if (Key==VK_MENU) + Key = 0; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::UpdateCaption() { AnsiString name; - name.sprintf("%s - [%s%s]",UI->EditorDesc(),UI->GetCaption(),UI->IsModified()?"*":""); + name.sprintf("%s - [%s%s]", UI->EditorDesc(), UI->GetCaption(), UI->IsModified() ? "*" : ""); Caption = name; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::tmRefreshTimer(TObject *Sender) { int i; - for (i=0; iComponentCount; i++){ - TComponent* temp = frmMain->Components[i]; - if (dynamic_cast(temp) != NULL) + for (i = 0; iComponentCount; i++) + { + TComponent *temp = frmMain->Components[i]; + if (dynamic_cast(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } - fraLeftBar->OnTimer(); - fraTopBar->OnTimer(); + fraLeftBar->OnTimer(); + fraTopBar->OnTimer(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowPaint(TObject *Sender) { - if (!UI||!UI->m_bReady) return; + if (!UI||!UI->m_bReady) + return; UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowChangeFocus(TObject *Sender) { - if (!UI||!UI->m_bReady) return; - if (D3DWindow->Focused()){ + if (!UI||!UI->m_bReady) + return; + if (D3DWindow->Focused()) + { UI->IR_Capture(); - UI->OnAppActivate(); - }else{ - UI->OnAppDeactivate(); + UI->OnAppActivate(); + } + else + { + UI->OnAppDeactivate(); UI->IR_Release(); -// paRender->Color=paRender->Color; // ÷òîáû íå áûëî internal code gen error + // paRender->Color=paRender->Color; // ÷òîáû íå áûëî internal code gen error } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - UI->MousePress(Shift,X,Y); + UI->MousePress(Shift, X, Y); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseUp(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - UI->MouseRelease(Shift,X,Y); + UI->MouseRelease(Shift, X, Y); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseMove(TObject *Sender, - TShiftState Shift, int X, int Y) + TShiftState Shift, int X, int Y) { - UI->MouseMove(Shift,X,Y); + UI->MouseMove(Shift, X, Y); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::ebAllMinClick(TObject *Sender) { - fraLeftBar->MinimizeAllFrames(); + fraLeftBar->MinimizeAllFrames(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::ebAllMaxClick(TObject *Sender) { - fraLeftBar->MaximizeAllFrames(); + fraLeftBar->MaximizeAllFrames(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormResize(TObject *Sender) { - if (fraLeftBar) fraLeftBar->UpdateBar(); + if (fraLeftBar) + fraLeftBar->UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::paRenderResize(TObject *Sender) { - ExecCommand(COMMAND_RENDER_RESIZE); + ExecCommand(COMMAND_RENDER_RESIZE); } + //--------------------------------------------------------------------------- - + void __fastcall TfrmMain::fsStorageSavePlacement(TObject *Sender) { - fsStorage->WriteInteger("window_state",frmMain->WindowState); + fsStorage->WriteInteger("window_state", frmMain->WindowState); } + //--------------------------------------------------------------------------- diff --git a/src/editors/ParticleEditor/main.h b/src/editors/ParticleEditor/main.h index 54f0a90a0ee..5fe93c62fef 100644 --- a/src/editors/ParticleEditor/main.h +++ b/src/editors/ParticleEditor/main.h @@ -5,7 +5,7 @@ //--------------------------------------------------------------------------- #include #include -#include +#include #include #include #include @@ -15,31 +15,32 @@ #include "MxMenus.hpp" #include "mxPlacemnt.hpp" #include "RenderWindow.hpp" + //--------------------------------------------------------------------------- // refs class ECORE_API TfrmMain : public TForm { -__published: // IDE-managed Components - TPanel *paLeftBar; - TPanel *paBottomBar; + __published: // IDE-managed Components + TPanel*paLeftBar; + TPanel *paBottomBar; TPanel *paTools; TTimer *tmRefresh; - TFormStorage *fsStorage; + TFormStorage *fsStorage; TPanel *paMain; TPanel *paTopBar; - TPanel *paRender; - TLabel *APHeadLabel2; - TExtBtn *sbToolsMin; - TD3DWindow *D3DWindow; - TExtBtn *ebAllMin; - TExtBtn *ebAllMax; - void __fastcall FormCreate(TObject *Sender); + TPanel *paRender; + TLabel *APHeadLabel2; + TExtBtn *sbToolsMin; + TD3DWindow *D3DWindow; + TExtBtn *ebAllMin; + TExtBtn *ebAllMax; + void __fastcall FormCreate(TObject *Sender); void __fastcall D3DWindowResize(TObject *Sender); void __fastcall D3DWindowKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall D3DWindowKeyUp(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall sbToolsMinClick(TObject *Sender); void __fastcall TopClick(TObject *Sender); void __fastcall FormShow(TObject *Sender); @@ -48,32 +49,42 @@ class ECORE_API TfrmMain : public TForm void __fastcall D3DWindowKeyPress(TObject *Sender, char &Key); void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); - void __fastcall D3DWindowChangeFocus(TObject *Sender); - void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall D3DWindowMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall D3DWindowMouseUp(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall D3DWindowMouseMove(TObject *Sender, TShiftState Shift, - int X, int Y); - void __fastcall ebAllMinClick(TObject *Sender); - void __fastcall ebAllMaxClick(TObject *Sender); - void __fastcall FormResize(TObject *Sender); - void __fastcall paRenderResize(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); -private: // User declarations + void __fastcall D3DWindowChangeFocus(TObject *Sender); + void __fastcall FormKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall D3DWindowMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall D3DWindowMouseUp(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall D3DWindowMouseMove(TObject *Sender, TShiftState Shift, + int X, int Y); + void __fastcall ebAllMinClick(TObject *Sender); + void __fastcall ebAllMaxClick(TObject *Sender); + void __fastcall FormResize(TObject *Sender); + void __fastcall paRenderResize(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); +private: // User declarations void __fastcall IdleHandler(TObject *Sender, bool &Done); - TShiftState ShiftKey; - HINSTANCE m_HInstance; -public: // User declarations - __fastcall TfrmMain(TComponent* Owner); + TShiftState ShiftKey; + HINSTANCE m_HInstance; +public: // User declarations + __fastcall TfrmMain(TComponent *Owner); void __fastcall UpdateCaption(); - __inline void SetHInst(HINSTANCE inst){ m_HInstance=inst; } - bool IsFocused(){return D3DWindow->Focused();} + + __inline void SetHInst(HINSTANCE inst) + { + m_HInstance = inst; + } + + bool IsFocused() + { + return D3DWindow->Focused(); + } }; + //--------------------------------------------------------------------------- -extern /*ECORE_API*/ PACKAGE TfrmMain *frmMain; +extern /*ECORE_API*/ PACKAGE TfrmMain * frmMain; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ParticleEditor/noise.cpp b/src/editors/ParticleEditor/noise.cpp index 36c821d8539..281974911d1 100644 --- a/src/editors/ParticleEditor/noise.cpp +++ b/src/editors/ParticleEditor/noise.cpp @@ -2,7 +2,7 @@ #pragma hdrstop #include "noise.h" - + //============================================================================== // Perlin's noise from Texturing and Modeling... #define B 256 @@ -18,157 +18,165 @@ r0 = t - iFloor(t);\ r1 = r0 - 1.f; -static int start = 1; -static int p[B+B+2]; -static float g[B+B+2][3]; +static int start = 1; +static int p[B+B+2]; +static float g[B+B+2][3]; -void noise3Init(); +void noise3Init(); //-------------------------------------------------------------------- -float noise3(const Fvector& vec) +float noise3(const Fvector &vec) { - int bx0, bx1; - int by0, by1; - int bz0, bz1; - int b00, b10, b01, b11; - float rx0, rx1; - float ry0, ry1; - float rz0, rz1; - float *q; - float sx, sy, sz; - float a, b, c, d, t, u, v; - int i, j; - - if (start) - { - start = 0; - noise3Init(); - } - - PN_SETUP(0, bx0, bx1, rx0, rx1); - PN_SETUP(1, by0, by1, ry0, ry1); - PN_SETUP(2, bz0, bz1, rz0, rz1); - - i = p[bx0]; - j = p[bx1]; - - b00 = p[ i+by0 ]; - b10 = p[ j+by0 ]; - b01 = p[ i+by1 ]; - b11 = p[ j+by1 ]; - - sx = S_CURVE(rx0); - sy = S_CURVE(ry0); - sz = S_CURVE(rz0); - - q = g[ b00+bz0 ]; u = AT(rx0, ry0, rz0); - q = g[ b10+bz0 ]; v = AT(rx1, ry0, rz0); - a = LERP( sx, u, v ); - - q = g[ b01+bz0 ]; u = AT(rx0, ry1, rz0); - q = g[ b11+bz0 ]; v = AT(rx1, ry1, rz0); - b = LERP( sx, u, v ); - - c = LERP(sy, a, b); - - q = g[ b00+bz1 ]; u = AT(rx0, ry0, rz1); - q = g[ b10+bz1 ]; v = AT(rx1, ry0, rz1); - a = LERP( sx, u, v ); - - q = g[ b01+bz1 ]; u = AT(rx0, ry1, rz1); - q = g[ b11+bz1 ]; v = AT(rx1, ry1, rz1); - b = LERP( sx, u, v ); - - d = LERP(sy, a, b); - - return 1.5f * LERP(sz, c, d); + int bx0, bx1; + int by0, by1; + int bz0, bz1; + int b00, b10, b01, b11; + float rx0, rx1; + float ry0, ry1; + float rz0, rz1; + float *q; + float sx, sy, sz; + float a, b, c, d, t, u, v; + int i, j; + + if (start) + { + start = 0; + noise3Init(); + } + + PN_SETUP(0, bx0, bx1, rx0, rx1); + PN_SETUP(1, by0, by1, ry0, ry1); + PN_SETUP(2, bz0, bz1, rz0, rz1); + + i = p[bx0]; + j = p[bx1]; + + b00 = p[i+by0]; + b10 = p[j+by0]; + b01 = p[i+by1]; + b11 = p[j+by1]; + + sx = S_CURVE(rx0); + sy = S_CURVE(ry0); + sz = S_CURVE(rz0); + + q = g[b00+bz0]; + u = AT(rx0, ry0, rz0); + q = g[b10+bz0]; + v = AT(rx1, ry0, rz0); + a = LERP( sx, u, v ); + + q = g[b01+bz0]; + u = AT(rx0, ry1, rz0); + q = g[b11+bz0]; + v = AT(rx1, ry1, rz0); + b = LERP( sx, u, v ); + + c = LERP(sy, a, b); + + q = g[b00+bz1]; + u = AT(rx0, ry0, rz1); + q = g[b10+bz1]; + v = AT(rx1, ry0, rz1); + a = LERP( sx, u, v ); + + q = g[b01+bz1]; + u = AT(rx0, ry1, rz1); + q = g[b11+bz1]; + v = AT(rx1, ry1, rz1); + b = LERP( sx, u, v ); + + d = LERP(sy, a, b); + + return 1.5f*LERP(sz, c, d); } - + //-------------------------------------------------------------------- -void noise3Init() +void noise3Init() { - int i, j, k; - float v[3], s; - int rnd; - - srand(1); - - for(i = 0; i < B; i++ ) - { - do - { - for(j = 0; j < 3; j++) - { - rnd = rand(); - v[j] = float((rnd % (B+B)) - B) / B; - } - s = DOT(v,v); - } while ( s > 1.0 ); - s = _sqrt(s); - for (j = 0; j < 3; j++) - g[i][j] = v[j] / s; - } - - for (i = 0; i < B; i++) - p[i] = i; - - for (i = B; i > 0; i -= 2) - { - rnd = rand(); - k = p[i]; - p[i] = p[ (j = rnd%B) ]; - p[j] = k; - } - - for (i = 0; i < B+2; i++) - { - p[B+i] = p[i]; - for (j = 0; j < 3; j++) - g[B+i][j] = g[i][j]; - } + int i, j, k; + float v[3], s; + int rnd; + + srand(1); + + for (i = 0; i1.0); + s = _sqrt(s); + for (j = 0; j<3; j++) + g[i][j] = v[j]/s; + } + + for (i = 0; i0; i -= 2) + { + rnd = rand(); + k = p[i]; + p[i] = p[(j = rnd%B)]; + p[j] = k; + } + + for (i = 0; i @@ -35,38 +35,58 @@ #ifdef _eof #undef _eof #endif -__inline int _eof (int _a) { return ::eof(_a); } +__inline int _eof(int _a) +{ + return ::eof(_a); +} #ifdef _access #undef _access #endif -__inline int _access(const char *_a, int _b) { return ::access(_a,_b); } +__inline int _access(const char *_a, int _b) +{ + return ::access(_a, _b); +} #ifdef _lseek #undef _lseek #endif -__inline long _lseek(int handle, long offset, int fromwhere){ return ::lseek(handle, offset, fromwhere);} +__inline long _lseek(int handle, long offset, int fromwhere) +{ + return ::lseek(handle, offset, fromwhere); +} #ifdef _dup #undef _dup #endif #define fmodf fmod -__inline int _dup (int handle) { return ::dup(handle);} -__inline float modff(float a, float *b){ - double x,y; - y = modf(double(a),&x); + +__inline int _dup(int handle) +{ + return ::dup(handle); +} + +__inline float modff(float a, float *b) +{ + double x, y; + y = modf(double(a), &x); *b = x; return float(y); } -__inline float expf (float val) { return ::exp(val);} +__inline float expf(float val) +{ + return ::exp(val); +} + +#include "xrCore/Platform.h" -#ifdef _ECOREB - #define ECORE_API __declspec(dllexport) - #define ENGINE_API __declspec(dllexport) +#ifdef _ECOREB +#define ECORE_API XR_EXPORT +#define ENGINE_API XR_EXPORT #else - #define ECORE_API __declspec(dllimport) - #define ENGINE_API __declspec(dllimport) +#define ECORE_API XR_IMPORT +#define ENGINE_API XR_IMPORT #endif -#define DLL_API __declspec(dllimport) +#define DLL_API XR_IMPORT #define PropertyGP(a,b) __declspec( property( get=a, put=b ) ) #define THROW FATAL("THROW"); #define THROW2(a) FATAL(a); @@ -75,7 +95,7 @@ __inline float expf (float val) { return ::exp(val);} #define clMsg Msg // core -#include +#include #ifdef _EDITOR class PropValue; @@ -86,56 +106,65 @@ __inline float expf (float val) { return ::exp(val);} DEFINE_VECTOR(ListItem*,ListItemsVec,ListItemsIt); #endif -#include "../../xrCDB/xrCDB.h" -#include "../../xrSound/Sound.h" +#include "xrCDB/xrCDB.h" +#include "xrSound/Sound.h" #include // DirectX headers #include #include -#include "..\..\Layers\xrRender\xrD3dDefs.h" +#include "Layers/xrRender/xrD3DDefs.h" #include #include // some user components -#include "fmesh.h" -#include "_d3d_extensions.h" +#include "xrCore/FMesh.hpp" +#include "Common/_d3d_extensions.h" -#include "../ECore/Editor/D3DX_Wrapper.h" +#include "editors/ECore/Editor/D3DX_Wrapper.h" -DEFINE_VECTOR (AnsiString,AStringVec,AStringIt); -DEFINE_VECTOR (AnsiString*,LPAStringVec,LPAStringIt); +DEFINE_VECTOR(AnsiString, AStringVec, AStringIt); +DEFINE_VECTOR(AnsiString *, LPAStringVec, LPAStringIt); -#include "../../xrServerEntities/xrEProps.h" -#include "Log.h" -#include "../ECore/editor/engine.h" -#include "defines.h" +#include "xrServerEntities/xrEProps.h" +#include "xrCore/Log.h" +#include "editors/ECore/editor/engine.h" +#include "xrEngine/defines.h" struct str_pred : public std::binary_function { - IC bool operator()(LPCSTR x, LPCSTR y) const - { return strcmp(x,y)<0; } + IC + + bool operator()(LPCSTR x, LPCSTR y) const + { + return strcmp(x, y)<0; + } }; + struct astr_pred : public std::binary_function { - IC bool operator()(const AnsiString& x, const AnsiString& y) const - { return xEditorName(),".ini").c_str());} @@ -161,8 +190,8 @@ struct astr_pred : public std::binary_function Date: Fri, 4 Dec 2015 07:02:52 +0500 Subject: [PATCH 06/10] PPEditor: fixed includes and formatted code + add stdafx missing in project file --- src/editors/PPEditor/NoiseFGen.cpp | 31 +- src/editors/PPEditor/NoiseFGen.h | 15 +- src/editors/PPEditor/NoiseGen.cpp | 51 ++- src/editors/PPEditor/NoiseGen.h | 15 +- src/editors/PPEditor/PPEditor.vcxproj | 1 + src/editors/PPEditor/PPEditor.vcxproj.filters | 1 + src/editors/PPEditor/Postprocess.bpr | 18 +- src/editors/PPEditor/Postprocess.cpp | 54 +-- src/editors/PPEditor/Unit6.cpp | 123 ++--- src/editors/PPEditor/Unit6.h | 36 +- src/editors/PPEditor/Unit7.cpp | 12 +- src/editors/PPEditor/Unit7.h | 23 +- src/editors/PPEditor/Unit8.cpp | 119 ++--- src/editors/PPEditor/Unit8.h | 29 +- src/editors/PPEditor/Unit9.cpp | 6 +- src/editors/PPEditor/Unit9.h | 15 +- src/editors/PPEditor/base.h | 35 +- src/editors/PPEditor/color.cpp | 350 +++++++------- src/editors/PPEditor/color.h | 79 ++-- src/editors/PPEditor/effect.cpp | 64 +-- src/editors/PPEditor/effect.h | 57 ++- src/editors/PPEditor/float_constructor.cpp | 142 +++--- src/editors/PPEditor/float_constructor.h | 41 +- src/editors/PPEditor/float_param.cpp | 6 +- src/editors/PPEditor/float_param.h | 23 +- src/editors/PPEditor/main.cpp | 428 +++++++++--------- src/editors/PPEditor/main.h | 90 ++-- src/editors/PPEditor/newdialog.cpp | 17 +- src/editors/PPEditor/newdialog.h | 15 +- src/editors/PPEditor/single_param.cpp | 335 +++++++------- src/editors/PPEditor/single_param.h | 84 ++-- src/editors/PPEditor/spline.cpp | 142 +++--- src/editors/PPEditor/spline.h | 48 +- src/editors/PPEditor/std.cpp | 4 +- src/editors/PPEditor/stdafx.h | 2 +- 35 files changed, 1357 insertions(+), 1154 deletions(-) diff --git a/src/editors/PPEditor/NoiseFGen.cpp b/src/editors/PPEditor/NoiseFGen.cpp index 715c2a265e8..12ffb2a2d62 100644 --- a/src/editors/PPEditor/NoiseFGen.cpp +++ b/src/editors/PPEditor/NoiseFGen.cpp @@ -8,24 +8,27 @@ #pragma package(smart_init) #pragma resource "*.dfm" TNFGen *NFGen; + //--------------------------------------------------------------------------- -__fastcall TNFGen::TNFGen(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TNFGen::TNFGen(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TNFGen::Button1Click(TObject *Sender) { - if (Period->Value <= 0.0f || Time->Value <= 0.0f) - { - Application->MessageBox ("Invalid period or time for effect", "Error", MB_OK | MB_ICONSTOP); - return; - } - if (Period->Value >= Time->Value) - { - Application->MessageBox ("Period must be less than time effect", "Error", MB_OK | MB_ICONSTOP); - return; - } + if (Period->Value<=0.0f||Time->Value<=0.0f) + { + Application->MessageBox("Invalid period or time for effect", "Error", MB_OK|MB_ICONSTOP); + return; + } + if (Period->Value>=Time->Value) + { + Application->MessageBox("Period must be less than time effect", "Error", MB_OK|MB_ICONSTOP); + return; + } ModalResult = mrOk; } + //--------------------------------------------------------------------------- + + diff --git a/src/editors/PPEditor/NoiseFGen.h b/src/editors/PPEditor/NoiseFGen.h index f16780532e6..3de4c0a4e1e 100644 --- a/src/editors/PPEditor/NoiseFGen.h +++ b/src/editors/PPEditor/NoiseFGen.h @@ -9,11 +9,12 @@ #include #include #include + //--------------------------------------------------------------------------- class TNFGen : public TForm { -__published: // IDE-managed Components - TMxLabel *RxLabel1; + __published: // IDE-managed Components + TMxLabel*RxLabel1; TMxLabel *RxLabel2; TMxLabel *RxLabel3; TMxLabel *RxLabel4; @@ -25,11 +26,13 @@ class TNFGen : public TForm TButton *Button1; TButton *Button2; void __fastcall Button1Click(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TNFGen(TComponent* Owner); +private: // User declarations +public: // User declarations + __fastcall TNFGen(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TNFGen *NFGen; +extern PACKAGE TNFGen * NFGen; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/NoiseGen.cpp b/src/editors/PPEditor/NoiseGen.cpp index 88c63a96c8e..1097c64b0b6 100644 --- a/src/editors/PPEditor/NoiseGen.cpp +++ b/src/editors/PPEditor/NoiseGen.cpp @@ -8,42 +8,49 @@ #pragma package(smart_init) #pragma resource "*.dfm" TNGen *NGen; + //--------------------------------------------------------------------------- -__fastcall TNGen::TNGen(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TNGen::TNGen(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TNGen::FColorClick(TObject *Sender) { - if (ColorDialog->Execute () == false) return; + if (ColorDialog->Execute()==false) + return; FColor->Color = ColorDialog->Color; - FR->Value = (float)(ColorDialog->Color & 0x0000ff) / 255.0f; - FG->Value = (float)((ColorDialog->Color & 0x00ff00) >> 8) / 255.0f; - FB->Value = (float)((ColorDialog->Color & 0xff0000) >> 16) / 255.0f; + FR->Value = (float)(ColorDialog->Color&0x0000ff)/255.0f; + FG->Value = (float)((ColorDialog->Color&0x00ff00)>>8)/255.0f; + FB->Value = (float)((ColorDialog->Color&0xff0000)>>16)/255.0f; } + //--------------------------------------------------------------------------- void __fastcall TNGen::SColorClick(TObject *Sender) { - if (ColorDialog->Execute () == false) return; + if (ColorDialog->Execute()==false) + return; SColor->Color = ColorDialog->Color; - SR->Value = (float)(ColorDialog->Color & 0x0000ff) / 255.0f; - SG->Value = (float)((ColorDialog->Color & 0x00ff00) >> 8) / 255.0f; - SB->Value = (float)((ColorDialog->Color & 0xff0000) >> 16) / 255.0f; + SR->Value = (float)(ColorDialog->Color&0x0000ff)/255.0f; + SG->Value = (float)((ColorDialog->Color&0x00ff00)>>8)/255.0f; + SB->Value = (float)((ColorDialog->Color&0xff0000)>>16)/255.0f; } + //--------------------------------------------------------------------------- void __fastcall TNGen::Button1Click(TObject *Sender) { - if (Period->Value <= 0.0f || Time->Value <= 0.0f) - { - Application->MessageBox ("Invalid period or time for effect", "Error", MB_OK | MB_ICONSTOP); - return; - } - if (Period->Value >= Time->Value) - { - Application->MessageBox ("Period must be less than time effect", "Error", MB_OK | MB_ICONSTOP); - return; - } + if (Period->Value<=0.0f||Time->Value<=0.0f) + { + Application->MessageBox("Invalid period or time for effect", "Error", MB_OK|MB_ICONSTOP); + return; + } + if (Period->Value>=Time->Value) + { + Application->MessageBox("Period must be less than time effect", "Error", MB_OK|MB_ICONSTOP); + return; + } ModalResult = mrOk; } + //--------------------------------------------------------------------------- + + diff --git a/src/editors/PPEditor/NoiseGen.h b/src/editors/PPEditor/NoiseGen.h index cc1ad7325fe..5c8fedd59f8 100644 --- a/src/editors/PPEditor/NoiseGen.h +++ b/src/editors/PPEditor/NoiseGen.h @@ -10,11 +10,12 @@ #include #include #include + //--------------------------------------------------------------------------- class TNGen : public TForm { -__published: // IDE-managed Components - TGroupBox *GroupBox1; + __published: // IDE-managed Components + TGroupBox*GroupBox1; TMultiObjSpinEdit *FR; TMultiObjSpinEdit *FG; TMultiObjSpinEdit *FB; @@ -41,11 +42,13 @@ class TNGen : public TForm void __fastcall FColorClick(TObject *Sender); void __fastcall SColorClick(TObject *Sender); void __fastcall Button1Click(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TNGen(TComponent* Owner); +private: // User declarations +public: // User declarations + __fastcall TNGen(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TNGen *NGen; +extern PACKAGE TNGen * NGen; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/PPEditor.vcxproj b/src/editors/PPEditor/PPEditor.vcxproj index ade81f50ad6..ca28266c922 100644 --- a/src/editors/PPEditor/PPEditor.vcxproj +++ b/src/editors/PPEditor/PPEditor.vcxproj @@ -47,6 +47,7 @@ + diff --git a/src/editors/PPEditor/PPEditor.vcxproj.filters b/src/editors/PPEditor/PPEditor.vcxproj.filters index 23cf44d9439..a1c66b75ab4 100644 --- a/src/editors/PPEditor/PPEditor.vcxproj.filters +++ b/src/editors/PPEditor/PPEditor.vcxproj.filters @@ -107,5 +107,6 @@ Header Files + \ No newline at end of file diff --git a/src/editors/PPEditor/Postprocess.bpr b/src/editors/PPEditor/Postprocess.bpr index 5fab58b91ce..457159ee599 100644 --- a/src/editors/PPEditor/Postprocess.bpr +++ b/src/editors/PPEditor/Postprocess.bpr @@ -4,15 +4,15 @@ - + diff --git a/src/editors/PPEditor/Postprocess.cpp b/src/editors/PPEditor/Postprocess.cpp index 5b24da8b7bc..3da650f0067 100644 --- a/src/editors/PPEditor/Postprocess.cpp +++ b/src/editors/PPEditor/Postprocess.cpp @@ -24,16 +24,17 @@ USEFORM("float_constructor.cpp", frmConstructor); USEFORM("color.cpp", AddColorForm); USEFORM("single_param.cpp", AddFloatForm); //--------------------------------------------------------------------------- -FILE *g_LogFileHandle = NULL; +FILE *g_LogFileHandle = NULL; + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- -void log_callback (LPCSTR lpString) +void log_callback(LPCSTR lpString) { if (!g_LogFileHandle) - return; - fprintf (g_LogFileHandle, "%s\n", lpString); + return; + fprintf(g_LogFileHandle, "%s\n", lpString); } @@ -41,33 +42,34 @@ WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { try { - g_LogFileHandle = fopen ("postprocess.log", "wt"); - Core._initialize ("Postprocess editor", log_callback, FALSE); - FS._initialize (CLocatorAPI::flScanAppRoot, 0, 0); - - Application->Initialize(); - Application->CreateForm(__classid(TMainForm), &MainForm); - Application->Run(); - Core._destroy(); - fclose (g_LogFileHandle); - } - catch (Exception &exception) + g_LogFileHandle = fopen("postprocess.log", "wt"); + Core._initialize("Postprocess editor", log_callback, FALSE); + FS._initialize(CLocatorAPI::flScanAppRoot, 0, 0); + + Application->Initialize(); + Application->CreateForm(__classid(TMainForm), &MainForm); + Application->Run(); + Core._destroy(); + fclose(g_LogFileHandle); + } catch (Exception &exception) { - fclose (g_LogFileHandle); - Application->ShowException(&exception); + fclose(g_LogFileHandle); + Application->ShowException(&exception); } catch (...) { - try - { - throw Exception(""); - } - catch (Exception &exception) - { - fclose (g_LogFileHandle); - Application->ShowException(&exception); - } + try + { + throw Exception(""); + } catch (Exception &exception) + { + fclose(g_LogFileHandle); + Application->ShowException(&exception); + } } return 0; } + //--------------------------------------------------------------------------- + + diff --git a/src/editors/PPEditor/Unit6.cpp b/src/editors/PPEditor/Unit6.cpp index b88a98eebd7..7b3d1b92722 100644 --- a/src/editors/PPEditor/Unit6.cpp +++ b/src/editors/PPEditor/Unit6.cpp @@ -11,13 +11,15 @@ #pragma package(smart_init) #pragma resource "*.dfm" TForm6 *Form6; + //--------------------------------------------------------------------------- -__fastcall TForm6::TForm6(TComponent* Owner) +__fastcall TForm6::TForm6(TComponent *Owner) : TForm(Owner) { m_iTag = 0; - AddEntryTemplate (-1); + AddEntryTemplate(-1); } + //--------------------------------------------------------------------------- //__fastcall TForm6::TForm6 (HWND handle) : TForm (handle) //{ @@ -25,9 +27,9 @@ __fastcall TForm6::TForm6(TComponent* Owner) // AddEntryTemplate (-1); //} //--------------------------------------------------------------------------- -void TForm6::AddEntryTemplate (int iInsertAfter) +void TForm6::AddEntryTemplate(int iInsertAfter) { - TForm7 *form = new TForm7 (this); + TForm7*form = new TForm7(this); form->Parent = this; form->Left = 0; form->Tag = m_iTag++; @@ -38,84 +40,93 @@ void TForm6::AddEntryTemplate (int iInsertAfter) form->DeleteButton->OnClick = OnDelButtonClick; vector temp; iInsertAfter++; - if (!m_Entries.size () || m_Entries.size () == (size_t)iInsertAfter) - { - m_Entries.push_back (form); - } + if (!m_Entries.size()||m_Entries.size()==(size_t)iInsertAfter) + { + m_Entries.push_back(form); + } else - { - for (int a = 0; a < (int)m_Entries.size (); a++) - { - if (a == iInsertAfter) - temp.push_back (form); - temp.push_back (m_Entries[a]); - } - m_Entries.assign (temp.begin (), temp.end ()); - } - ResetPositions (); + { + for (int a = 0; a<(int)m_Entries.size(); a++) + { + if (a==iInsertAfter) + temp.push_back(form); + temp.push_back(m_Entries[a]); + } + m_Entries.assign(temp.begin(), temp.end()); + } + ResetPositions(); } + //--------------------------------------------------------------------------- -void TForm6::ResetPositions () +void TForm6::ResetPositions() { int top = 0; - for (size_t a = 0; a < m_Entries.size (); a++) - { + for (size_t a = 0; aLeft = 0; - m_Entries[a]->Top = (m_Entries[a]->Height + 4) * a + Panel2->Height; + m_Entries[a]->Top = (m_Entries[a]->Height+4)*a+Panel2->Height; top = m_Entries[a]->Top; - } - Button1->Top = top + m_Entries[0]->Height + 4; + } + Button1->Top = top+m_Entries[0]->Height+4; Button2->Top = Button1->Top; - if (m_Entries.size () <= 6) - ClientHeight = Button1->Top + Button1->Height; + if (m_Entries.size()<=6) + ClientHeight = Button1->Top+Button1->Height; } + //--------------------------------------------------------------------------- -void __fastcall TForm6::OnAddButtonClick (TObject *Sender) +void __fastcall TForm6::OnAddButtonClick(TObject *Sender) { - int tag = dynamic_cast (Sender)->Tag; - for (size_t a = 0; a < m_Entries.size (); a++) - if (m_Entries[a]->Tag == tag) - { - AddEntryTemplate (a); - return; - } + int tag = dynamic_cast(Sender)->Tag; + for (size_t a = 0; aTag==tag) + { + AddEntryTemplate(a); + return; + } } + //--------------------------------------------------------------------------- -void __fastcall TForm6::OnDelButtonClick (TObject *Sender) +void __fastcall TForm6::OnDelButtonClick(TObject *Sender) { - if (m_Entries.size () == 1) return; - int tag = dynamic_cast (Sender)->Parent->Parent->Tag; - vector::iterator s = m_Entries.begin(), e = m_Entries.end (); - for (; s != e; ++s) - if ((*s)->Tag == tag) - { - TForm7 *form = (*s); - delete form; - m_Entries.erase (s); - RecalcSize (); - return; - } + if (m_Entries.size()==1) + return; + int tag = dynamic_cast(Sender)->Parent->Parent->Tag; + vector::iterator s = m_Entries.begin(), e = m_Entries.end(); + for (; s!=e; ++s) + if ((*s)->Tag==tag) + { + TForm7*form = (*s); + delete form; + m_Entries.erase(s); + RecalcSize(); + return; + } } + //--------------------------------------------------------------------------- -void TForm6::RecalcSize () +void TForm6::RecalcSize() { int top; - for (int a = 0; a < (int)m_Entries.size (); a++) - { - m_Entries[a]->Top = a * m_Entries[a]->Height + 2; + for (int a = 0; a<(int)m_Entries.size(); a++) + { + m_Entries[a]->Top = a*m_Entries[a]->Height+2; top = m_Entries[a]->Top; - } - Button1->Top = top + m_Entries[0]->Height + 4; + } + Button1->Top = top+m_Entries[0]->Height+4; Button2->Top = Button1->Top; - if (m_Entries.size () <= 6) - ClientHeight = Button1->Top + Button1->Height; + if (m_Entries.size()<=6) + ClientHeight = Button1->Top+Button1->Height; } + //--------------------------------------------------------------------------- void __fastcall TForm6::Panel3Click(TObject *Sender) { - if (ColorDialog->Execute () == false) return; + if (ColorDialog->Execute()==false) + return; Panel3->Color = ColorDialog->Color; m_InitColor = Panel3->Color; } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/Unit6.h b/src/editors/PPEditor/Unit6.h index a8adc9e15ed..96038f0d57f 100644 --- a/src/editors/PPEditor/Unit6.h +++ b/src/editors/PPEditor/Unit6.h @@ -20,8 +20,8 @@ using namespace std; //--------------------------------------------------------------------------- class TForm6 : public TForm { -__published: // IDE-managed Components - TButton *Button1; + __published: // IDE-managed Components + TButton*Button1; TButton *Button2; TColorDialog *ColorDialog; TOpenDialog *OpenDialog; @@ -30,22 +30,24 @@ class TForm6 : public TForm TLabel *Label1; TPanel *Panel3; void __fastcall Panel3Click(TObject *Sender); -private: // User declarations - void RecalcSize (); - void ResetPositions (); - int m_iTag; -public: // User declarations - void AddEntryTemplate (int iInsertAfter); - TColor m_InitColor; - vector m_Entries; - __fastcall TForm6(TComponent* Owner); -// __fastcall TForm6 (HWND handle); - void __fastcall OnAddButtonClick (TObject *Sender); - void __fastcall OnDelButtonClick (TObject *Sender); - void __fastcall SaveData (FILE *file); - void __fastcall LoadData (FILE *file); +private: // User declarations + void RecalcSize(); + void ResetPositions(); + int m_iTag; +public: // User declarations + void AddEntryTemplate(int iInsertAfter); + TColor m_InitColor; + vector m_Entries; + __fastcall TForm6(TComponent *Owner); + // __fastcall TForm6 (HWND handle); + void __fastcall OnAddButtonClick(TObject *Sender); + void __fastcall OnDelButtonClick(TObject *Sender); + void __fastcall SaveData(FILE *file); + void __fastcall LoadData(FILE *file); }; + //--------------------------------------------------------------------------- -extern PACKAGE TForm6 *Form6; +extern PACKAGE TForm6 * Form6; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/Unit7.cpp b/src/editors/PPEditor/Unit7.cpp index f471602db6b..67cf7aa4004 100644 --- a/src/editors/PPEditor/Unit7.cpp +++ b/src/editors/PPEditor/Unit7.cpp @@ -8,8 +8,9 @@ #pragma package(smart_init) #pragma resource "*.dfm" TForm7 *Form7; + //--------------------------------------------------------------------------- -__fastcall TForm7::TForm7(TComponent* Owner) +__fastcall TForm7::TForm7(TComponent *Owner) : TForm(Owner) { ColorPanel->Color = (TColor)0; @@ -19,16 +20,21 @@ __fastcall TForm7::TForm7(TComponent* Owner) tg = cg = bg = 0.0f; tb = cb = bb = 0.0f; } + //--------------------------------------------------------------------------- void __fastcall TForm7::ColorPanelClick(TObject *Sender) { - if (ColorDialog->Execute() == false) return; + if (ColorDialog->Execute()==false) + return; ColorPanel->Color = ColorDialog->Color; } + //--------------------------------------------------------------------------- void __fastcall TForm7::LinearFuncButtonClick(TObject *Sender) { - m_iFunction = dynamic_cast (Sender)->Tag; + m_iFunction = dynamic_cast(Sender)->Tag; } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/Unit7.h b/src/editors/PPEditor/Unit7.h index 34108fda0a2..3c4bbfe476a 100644 --- a/src/editors/PPEditor/Unit7.h +++ b/src/editors/PPEditor/Unit7.h @@ -14,11 +14,12 @@ #include #include #include + //--------------------------------------------------------------------------- class TForm7 : public TForm { -__published: // IDE-managed Components - TPanel *Panel1; + __published: // IDE-managed Components + TPanel*Panel1; TMultiObjSpinEdit *WorkTime; TPanel *ColorPanel; TSpeedButton *AddButton; @@ -27,15 +28,17 @@ class TForm7 : public TForm TImageList *ImageList; void __fastcall ColorPanelClick(TObject *Sender); void __fastcall LinearFuncButtonClick(TObject *Sender); -private: // User declarations -public: // User declarations - int m_iFunction; - float tr, cr, br; - float tg, cg, bg; - float tb, cb, bb; - __fastcall TForm7(TComponent* Owner); +private: // User declarations +public: // User declarations + int m_iFunction; + float tr, cr, br; + float tg, cg, bg; + float tb, cb, bb; + __fastcall TForm7(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TForm7 *Form7; +extern PACKAGE TForm7 * Form7; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/Unit8.cpp b/src/editors/PPEditor/Unit8.cpp index c5e1cedb9d5..2bc35f25992 100644 --- a/src/editors/PPEditor/Unit8.cpp +++ b/src/editors/PPEditor/Unit8.cpp @@ -8,17 +8,19 @@ #pragma package(smart_init) #pragma resource "*.dfm" TForm8 *Form8; + //--------------------------------------------------------------------------- -__fastcall TForm8::TForm8(TComponent* Owner) +__fastcall TForm8::TForm8(TComponent *Owner) : TForm(Owner) { m_iTag = 0; - AddEntryTemplate (-1); + AddEntryTemplate(-1); } + //--------------------------------------------------------------------------- -void TForm8::AddEntryTemplate (int iInsertAfter) +void TForm8::AddEntryTemplate(int iInsertAfter) { - TForm9 *form = new TForm9 (this); + TForm9*form = new TForm9(this); form->Parent = this; form->Left = 0; form->Tag = m_iTag++; @@ -29,77 +31,84 @@ void TForm8::AddEntryTemplate (int iInsertAfter) form->DeleteButton->OnClick = OnDelButtonClick; vector temp; iInsertAfter++; - if (!m_Entries.size () || (int)m_Entries.size () == iInsertAfter) - { - m_Entries.push_back (form); - } + if (!m_Entries.size()||(int)m_Entries.size()==iInsertAfter) + { + m_Entries.push_back(form); + } else - { - for (int a = 0; a < (int)m_Entries.size (); a++) - { - if (a == iInsertAfter) - temp.push_back (form); - temp.push_back (m_Entries[a]); - } - m_Entries.assign (temp.begin (), temp.end ()); - } - ResetPositions (); + { + for (int a = 0; a<(int)m_Entries.size(); a++) + { + if (a==iInsertAfter) + temp.push_back(form); + temp.push_back(m_Entries[a]); + } + m_Entries.assign(temp.begin(), temp.end()); + } + ResetPositions(); } + //--------------------------------------------------------------------------- -void TForm8::ResetPositions () +void TForm8::ResetPositions() { int top = 0; - for (size_t a = 0; a < m_Entries.size (); a++) - { + for (size_t a = 0; aLeft = 0; - m_Entries[a]->Top = (m_Entries[a]->Height + 4) * a + Panel2->Height; + m_Entries[a]->Top = (m_Entries[a]->Height+4)*a+Panel2->Height; top = m_Entries[a]->Top; - } - Button1->Top = top + m_Entries[0]->Height + 4; + } + Button1->Top = top+m_Entries[0]->Height+4; Button2->Top = Button1->Top; - if (m_Entries.size () <= 6) - ClientHeight = Button1->Top + Button1->Height; + if (m_Entries.size()<=6) + ClientHeight = Button1->Top+Button1->Height; } + //--------------------------------------------------------------------------- -void __fastcall TForm8::OnAddButtonClick (TObject *Sender) +void __fastcall TForm8::OnAddButtonClick(TObject *Sender) { - int tag = dynamic_cast (Sender)->Tag; - for (size_t a = 0; a < m_Entries.size (); a++) - if (m_Entries[a]->Tag == tag) - { - AddEntryTemplate (a); - return; - } + int tag = dynamic_cast(Sender)->Tag; + for (size_t a = 0; aTag==tag) + { + AddEntryTemplate(a); + return; + } } + //--------------------------------------------------------------------------- -void __fastcall TForm8::OnDelButtonClick (TObject *Sender) +void __fastcall TForm8::OnDelButtonClick(TObject *Sender) { - if (m_Entries.size () == 1) return; - int tag = dynamic_cast (Sender)->Parent->Parent->Tag; - vector::iterator s = m_Entries.begin(), e = m_Entries.end (); - for (; s != e; ++s) - if ((*s)->Tag == tag) - { - TForm9 *form = (*s); - delete form; - m_Entries.erase (s); - RecalcSize (); - return; - } + if (m_Entries.size()==1) + return; + int tag = dynamic_cast(Sender)->Parent->Parent->Tag; + vector::iterator s = m_Entries.begin(), e = m_Entries.end(); + for (; s!=e; ++s) + if ((*s)->Tag==tag) + { + TForm9*form = (*s); + delete form; + m_Entries.erase(s); + RecalcSize(); + return; + } } + //--------------------------------------------------------------------------- -void TForm8::RecalcSize () +void TForm8::RecalcSize() { int top; - for (int a = 0; a < (int)m_Entries.size (); a++) - { - m_Entries[a]->Top = a * m_Entries[a]->Height + 2; + for (int a = 0; a<(int)m_Entries.size(); a++) + { + m_Entries[a]->Top = a*m_Entries[a]->Height+2; top = m_Entries[a]->Top; - } - Button1->Top = top + m_Entries[0]->Height + 4; + } + Button1->Top = top+m_Entries[0]->Height+4; Button2->Top = Button1->Top; - if (m_Entries.size () <= 6) - ClientHeight = Button1->Top + Button1->Height; + if (m_Entries.size()<=6) + ClientHeight = Button1->Top+Button1->Height; } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/Unit8.h b/src/editors/PPEditor/Unit8.h index cc90dda925f..7740d637043 100644 --- a/src/editors/PPEditor/Unit8.h +++ b/src/editors/PPEditor/Unit8.h @@ -17,29 +17,32 @@ #include using namespace std; + //--------------------------------------------------------------------------- class TForm8 : public TForm { -__published: // IDE-managed Components - TButton *Button1; + __published: // IDE-managed Components + TButton*Button1; TButton *Button2; TOpenDialog *OpenDialog; TSaveDialog *SaveDialog; TPanel *Panel2; TLabel *Label1; TMultiObjSpinEdit *InitValue; -private: // User declarations - void AddEntryTemplate (int iInsertAfter); - void RecalcSize (); - void ResetPositions (); - int m_iTag; -public: // User declarations - vector m_Entries; - __fastcall TForm8(TComponent* Owner); - void __fastcall OnAddButtonClick (TObject *Sender); - void __fastcall OnDelButtonClick (TObject *Sender); +private: // User declarations + void AddEntryTemplate(int iInsertAfter); + void RecalcSize(); + void ResetPositions(); + int m_iTag; +public: // User declarations + vector m_Entries; + __fastcall TForm8(TComponent *Owner); + void __fastcall OnAddButtonClick(TObject *Sender); + void __fastcall OnDelButtonClick(TObject *Sender); }; + //--------------------------------------------------------------------------- -extern PACKAGE TForm8 *Form8; +extern PACKAGE TForm8 * Form8; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/Unit9.cpp b/src/editors/PPEditor/Unit9.cpp index 3737500f0fe..d12af476f20 100644 --- a/src/editors/PPEditor/Unit9.cpp +++ b/src/editors/PPEditor/Unit9.cpp @@ -8,12 +8,14 @@ #pragma package(smart_init) #pragma resource "*.dfm" TForm9 *Form9; + //--------------------------------------------------------------------------- -__fastcall TForm9::TForm9(TComponent* Owner) +__fastcall TForm9::TForm9(TComponent *Owner) : TForm(Owner) { ClientHeight = Panel1->Height; - } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/Unit9.h b/src/editors/PPEditor/Unit9.h index 4981e613273..6407bf5a6df 100644 --- a/src/editors/PPEditor/Unit9.h +++ b/src/editors/PPEditor/Unit9.h @@ -13,21 +13,24 @@ #include #include #include + //--------------------------------------------------------------------------- class TForm9 : public TForm { -__published: // IDE-managed Components - TPanel *Panel1; + __published: // IDE-managed Components + TPanel*Panel1; TMultiObjSpinEdit *WorkTime; TMultiObjSpinEdit *Value; TSpeedButton *AddButton; TSpeedButton *DeleteButton; TImageList *ImageList; -private: // User declarations -public: // User declarations - __fastcall TForm9(TComponent* Owner); +private: // User declarations +public: // User declarations + __fastcall TForm9(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TForm9 *Form9; +extern PACKAGE TForm9 * Form9; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/base.h b/src/editors/PPEditor/base.h index 72445e56b28..c2405f8b755 100644 --- a/src/editors/PPEditor/base.h +++ b/src/editors/PPEditor/base.h @@ -1,26 +1,37 @@ #ifndef BaseH #define BaseH -//#include +//#include #include "PostprocessAnimator.h" + //#include "single_param.h" -enum{tAddColor=0,tBaseColor=1,tGray=2,tDuality=3,tNoise=4,tBlur=5,tColorMap=6}; +enum +{ + tAddColor=0, + tBaseColor=1, + tGray=2, + tDuality=3, + tNoise=4, + tBlur=5, + tColorMap=6 +}; class TPPPropEditor { public: - virtual TForm* GetForm () =0; - virtual void Clear () =0; - virtual void ShowCurrent (u32 keyIdx) =0; - virtual _pp_params GetTimeChannel () =0; - virtual bool DrawChannel (_pp_params) =0; - virtual void Lock (bool b) =0; - virtual void AddNew (u32 keyIdx) =0; - virtual void Remove (u32 keyIdx) =0; - virtual void RemoveAllKeys () =0; - virtual void CreateKey (float t) =0; + virtual TForm *GetForm() =0; + virtual void Clear() =0; + virtual void ShowCurrent(u32 keyIdx) =0; + virtual _pp_params GetTimeChannel() =0; + virtual bool DrawChannel(_pp_params) =0; + virtual void Lock(bool b) =0; + virtual void AddNew(u32 keyIdx) =0; + virtual void Remove(u32 keyIdx) =0; + virtual void RemoveAllKeys() =0; + virtual void CreateKey(float t) =0; }; #endif + diff --git a/src/editors/PPEditor/color.cpp b/src/editors/PPEditor/color.cpp index 5618d7c41e7..b7cdefd3850 100644 --- a/src/editors/PPEditor/color.cpp +++ b/src/editors/PPEditor/color.cpp @@ -9,46 +9,47 @@ #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TAddColorForm::TAddColorForm(TComponent* Owner, _pp_params p) - : TForm(Owner),m_pp_params(p),m_bLocked(false) +__fastcall TAddColorForm::TAddColorForm(TComponent *Owner, _pp_params p) + : TForm(Owner), m_pp_params(p), m_bLocked(false) { - if(m_pp_params==pp_base_color) + if (m_pp_params==pp_base_color) { - RedValue->MinValue = -1.0f; - GreenValue->MinValue = -1.0f; - BlueValue->MinValue = -1.0f; - - RedValue->MaxValue = 1.0f; - GreenValue->MaxValue = 1.0f; - BlueValue->MaxValue = 1.0f; - }else - if(m_pp_params==pp_add_color) + RedValue->MinValue = -1.0f; + GreenValue->MinValue = -1.0f; + BlueValue->MinValue = -1.0f; + + RedValue->MaxValue = 1.0f; + GreenValue->MaxValue = 1.0f; + BlueValue->MaxValue = 1.0f; + } + else if (m_pp_params==pp_add_color) { - RedValue->MinValue = -1.0f; - GreenValue->MinValue = -1.0f; - BlueValue->MinValue = -1.0f; - - RedValue->MaxValue = 1.0f; - GreenValue->MaxValue = 1.0f; - BlueValue->MaxValue = 1.0f; - }else - if(m_pp_params==pp_gray_color) + RedValue->MinValue = -1.0f; + GreenValue->MinValue = -1.0f; + BlueValue->MinValue = -1.0f; + + RedValue->MaxValue = 1.0f; + GreenValue->MaxValue = 1.0f; + BlueValue->MaxValue = 1.0f; + } + else if (m_pp_params==pp_gray_color) { labelIntensity->Visible = true; IntensityValue->Visible = true; - - RedValue->MinValue = -1.0f; - GreenValue->MinValue = -1.0f; - BlueValue->MinValue = -1.0f; - - RedValue->MaxValue = 1.0f; - GreenValue->MaxValue = 1.0f; - BlueValue->MaxValue = 1.0f; - - IntensityValue->MinValue = 0.0f; - IntensityValue->MaxValue = 1.0f; + + RedValue->MinValue = -1.0f; + GreenValue->MinValue = -1.0f; + BlueValue->MinValue = -1.0f; + + RedValue->MaxValue = 1.0f; + GreenValue->MaxValue = 1.0f; + BlueValue->MaxValue = 1.0f; + + IntensityValue->MinValue = 0.0f; + IntensityValue->MaxValue = 1.0f; } } + //--------------------------------------------------------------------------- /* { @@ -66,217 +67,224 @@ __fastcall TAddColorForm::TAddColorForm(TComponent* Owner, _pp_params p) cparam->add_value (time, GreenValue->Value, 1); cparam->add_value (time, BlueValue->Value, 2); - if(m_pp_params==pp_gray_color) + if(m_pp_params==pp_gray_color) { - cparam = MainForm->m_Animator->GetParam (pp_gray_value); - cparam->delete_value (time_prev); - cparam->add_value (time, IntensityValue->Value, 0); + cparam = MainForm->m_Animator->GetParam (pp_gray_value); + cparam->delete_value (time_prev); + cparam->add_value (time, IntensityValue->Value, 0); } MainForm->PointListSetTime (MainForm->PointList->ItemIndex, time); - MainForm->UpdateGraph (); + MainForm->UpdateGraph (); } */ void __fastcall TAddColorForm::TimeValueExit(TObject *Sender) { - if (m_bLocked) return; - if (MainForm->PointList->ItemIndex == -1) return; - TMultiObjSpinEdit* spin = dynamic_cast(Sender); - if(spin->Color == clLime) + if (m_bLocked) + return; + if (MainForm->PointList->ItemIndex==-1) + return; + TMultiObjSpinEdit *spin = dynamic_cast(Sender); + if (spin->Color==clLime) { - if(TimeValue->ValueMinValue) - TimeValue->Value=TimeValue->MinValue; - if(TimeValue->Value>TimeValue->MaxValue) - TimeValue->Value=TimeValue->MaxValue; + if (TimeValue->ValueMinValue) + TimeValue->Value = TimeValue->MinValue; + if (TimeValue->Value>TimeValue->MaxValue) + TimeValue->Value = TimeValue->MaxValue; - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); - float time_prev = cparam->get_key_time(MainForm->PointList->ItemIndex); - cparam->delete_value (time_prev); - - float time = TimeValue->Value; + float time_prev = cparam->get_key_time(MainForm->PointList->ItemIndex); + cparam->delete_value(time_prev); - cparam->add_value (time, RedValue->Value, 0); - cparam->add_value (time, GreenValue->Value, 1); - cparam->add_value (time, BlueValue->Value, 2); + float time = TimeValue->Value; - if(m_pp_params==pp_gray_color) + cparam->add_value(time, RedValue->Value, 0); + cparam->add_value(time, GreenValue->Value, 1); + cparam->add_value(time, BlueValue->Value, 2); + + if (m_pp_params==pp_gray_color) { - cparam = MainForm->m_Animator->GetParam (pp_gray_value); - cparam->delete_value (time_prev); - cparam->add_value (time, IntensityValue->Value, 0); + cparam = MainForm->m_Animator->GetParam(pp_gray_value); + cparam->delete_value(time_prev); + cparam->add_value(time, IntensityValue->Value, 0); } - MainForm->PointListSetTime (MainForm->PointList->ItemIndex, time); - MainForm->UpdateGraph (); - TimeValue->Color = clWindow; - RedValue->Color = clWindow; - GreenValue->Color = clWindow; - BlueValue->Color = clWindow; - IntensityValue->Color = clWindow; + MainForm->PointListSetTime(MainForm->PointList->ItemIndex, time); + MainForm->UpdateGraph(); + TimeValue->Color = clWindow; + RedValue->Color = clWindow; + GreenValue->Color = clWindow; + BlueValue->Color = clWindow; + IntensityValue->Color = clWindow; } } void __fastcall TAddColorForm::CnahgeParam(TObject *Sender) { - if (m_bLocked) return; - if (MainForm->PointList->ItemIndex == -1) return; - TMultiObjSpinEdit* spin = dynamic_cast(Sender); + if (m_bLocked) + return; + if (MainForm->PointList->ItemIndex==-1) + return; + TMultiObjSpinEdit *spin = dynamic_cast(Sender); spin->Color = clLime; } //--------------------------------------------------------------------------- -void TAddColorForm::Clear() +void TAddColorForm::Clear() { Lock(true); - TimeValue->Value = 0.0f; - RedValue->Value = 0.0f; - GreenValue->Value = 0.0f; - BlueValue->Value = 0.0f; - IntensityValue->Value = 0.0f; + TimeValue->Value = 0.0f; + RedValue->Value = 0.0f; + GreenValue->Value = 0.0f; + BlueValue->Value = 0.0f; + IntensityValue->Value = 0.0f; Lock(false); } void TAddColorForm::ShowCurrent(u32 keyIdx) { - if(keyIdx==-1) + if (keyIdx==-1) { - Clear(); + Clear(); return; } - - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - float time = cparam->get_key_time(keyIdx); - MainForm->SetMarkerPosition(time); - - if(keyIdx>0) - TimeValue->MinValue = cparam->get_key_time(keyIdx-1)+0.02f; - else - TimeValue->MinValue = 0.0f; - - - if(cparam->get_keys_count()>keyIdx+1) - TimeValue->MaxValue = cparam->get_key_time(keyIdx+1)-0.02f; - else - TimeValue->MaxValue = 1000.0f; - - TimeValue->Value = time; - - float val; - cparam->get_value (time, val, 0); - RedValue->Value = val; - cparam->get_value (time, val, 1); - GreenValue->Value = val; - cparam->get_value (time, val, 2); - BlueValue->Value = val; - if(m_pp_params==pp_gray_color) - { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (pp_gray_value); - - cparam->get_value (time, val, 0); - IntensityValue->Value = val; - } + + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + float time = cparam->get_key_time(keyIdx); + MainForm->SetMarkerPosition(time); + + if (keyIdx>0) + TimeValue->MinValue = cparam->get_key_time(keyIdx-1)+0.02f; + else + TimeValue->MinValue = 0.0f; + + + if (cparam->get_keys_count()>keyIdx+1) + TimeValue->MaxValue = cparam->get_key_time(keyIdx+1)-0.02f; + else + TimeValue->MaxValue = 1000.0f; + + TimeValue->Value = time; + + float val; + cparam->get_value(time, val, 0); + RedValue->Value = val; + cparam->get_value(time, val, 1); + GreenValue->Value = val; + cparam->get_value(time, val, 2); + BlueValue->Value = val; + if (m_pp_params==pp_gray_color) + { + CPostProcessParam*cparam = MainForm->m_Animator->GetParam(pp_gray_value); + + cparam->get_value(time, val, 0); + IntensityValue->Value = val; + } } -bool TAddColorForm::DrawChannel(_pp_params p) +bool TAddColorForm::DrawChannel(_pp_params p) { - switch(m_pp_params) + switch (m_pp_params) { - case pp_add_color: return (p==pp_add_color); - case pp_base_color: return (p==pp_base_color); - case pp_gray_color: return (p==pp_gray_color)||(p==pp_gray_value); - default:R_ASSERT(0); + case pp_add_color: return (p==pp_add_color); + case pp_base_color: return (p==pp_base_color); + case pp_gray_color: return (p==pp_gray_color)||(p==pp_gray_value); + default: R_ASSERT(0); } return false; }; void TAddColorForm::AddNew(u32 keyIdx) { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); - float time = (keyIdx!=-1)?cparam->get_key_time(keyIdx):0.0f; - - MainForm->SetMarkerPosition (time); - time += 0.01f; - CreateKey (time); + float time = (keyIdx!=-1) ? cparam->get_key_time(keyIdx) : 0.0f; + MainForm->SetMarkerPosition(time); + time += 0.01f; + CreateKey(time); } void TAddColorForm::Remove(u32 keyIdx) { - if(keyIdx==-1) return; - - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - - float time = cparam->get_key_time(keyIdx); - - cparam->delete_value (time); - - if(m_pp_params==pp_gray_color) - { - cparam = MainForm->m_Animator->GetParam (pp_gray_value); - cparam->delete_value (time); - } + if (keyIdx==-1) + return; + + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + + float time = cparam->get_key_time(keyIdx); + + cparam->delete_value(time); + + if (m_pp_params==pp_gray_color) + { + cparam = MainForm->m_Animator->GetParam(pp_gray_value); + cparam->delete_value(time); + } } void TAddColorForm::RemoveAllKeys() { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - cparam->clear_all_keys (); - - if(m_pp_params==pp_gray_color) - { - cparam = MainForm->m_Animator->GetParam (pp_gray_value); - cparam->clear_all_keys (); - } + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + cparam->clear_all_keys(); + + if (m_pp_params==pp_gray_color) + { + cparam = MainForm->m_Animator->GetParam(pp_gray_value); + cparam->clear_all_keys(); + } } -void TAddColorForm::CreateKey(float time) + +void TAddColorForm::CreateKey(float time) { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - - cparam->add_value (time, 0.0f, 0); - cparam->add_value (time, 0.0f, 1); - cparam->add_value (time, 0.0f, 2); - - - if(m_pp_params==pp_gray_color) - { - cparam = MainForm->m_Animator->GetParam (pp_gray_value); - cparam->add_value (time, 0.0f, 0); - } + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + + cparam->add_value(time, 0.0f, 0); + cparam->add_value(time, 0.0f, 1); + cparam->add_value(time, 0.0f, 2); + + + if (m_pp_params==pp_gray_color) + { + cparam = MainForm->m_Animator->GetParam(pp_gray_value); + cparam->add_value(time, 0.0f, 0); + } } void __fastcall TAddColorForm::ColorClick(TObject *Sender) { - float l = _abs((float)RedValue->MaxValue - (float)RedValue->MinValue); + float l = _abs((float)RedValue->MaxValue-(float)RedValue->MinValue); + + float kl = l/255.0f; - float kl = l/255.0f; + ColorDialog->Color = color_rgba((BlueValue->Value-BlueValue->MinValue)/kl, + (GreenValue->Value-GreenValue->MinValue)/kl, + (RedValue->Value-RedValue->MinValue)/kl, + 0.0f); + if (ColorDialog->Execute()) + { + TColor clr = ColorDialog->Color; - ColorDialog->Color = color_rgba( (BlueValue->Value - BlueValue->MinValue)/kl , - (GreenValue->Value - GreenValue->MinValue)/kl, - (RedValue->Value - RedValue->MinValue)/kl, - 0.0f); - if (ColorDialog->Execute() ) - { - TColor clr = ColorDialog->Color; - - RedValue->Value = RedValue->MinValue + color_get_B(clr)*kl; - GreenValue->Value = GreenValue->MinValue + color_get_G(clr)*kl; - BlueValue->Value = BlueValue->MinValue + color_get_R(clr)*kl; // /255 + RedValue->Value = RedValue->MinValue+color_get_B(clr)*kl; + GreenValue->Value = GreenValue->MinValue+color_get_G(clr)*kl; + BlueValue->Value = BlueValue->MinValue+color_get_R(clr)*kl; // /255 - TimeValueExit (RedValue); - } + TimeValueExit(RedValue); + } } //--------------------------------------------------------------------------- void __fastcall TAddColorForm::TimeValueKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if(Key==VK_RETURN) - TimeValueExit(Sender); + if (Key==VK_RETURN) + TimeValueExit(Sender); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/color.h b/src/editors/PPEditor/color.h index 2ac3cccacaf..a6bbbfcc6ba 100644 --- a/src/editors/PPEditor/color.h +++ b/src/editors/PPEditor/color.h @@ -17,42 +17,57 @@ //--------------------------------------------------------------------------- class TAddColorForm : public TForm, public TPPPropEditor { -__published: // IDE-managed Components - TGroupBox *GroupBox1; + __published: // IDE-managed Components + TGroupBox*GroupBox1; TMultiObjSpinEdit *RedValue; TMxLabel *RxLabel2; TPanel *Color; TColorDialog *ColorDialog; - TMxLabel *RxLabel6; - TMultiObjSpinEdit *GreenValue; - TMxLabel *RxLabel10; - TMultiObjSpinEdit *BlueValue; - TMxLabel *labelIntensity; - TMultiObjSpinEdit *IntensityValue; - TMxLabel *MxLabel1; - TMultiObjSpinEdit *TimeValue; + TMxLabel *RxLabel6; + TMultiObjSpinEdit *GreenValue; + TMxLabel *RxLabel10; + TMultiObjSpinEdit *BlueValue; + TMxLabel *labelIntensity; + TMultiObjSpinEdit *IntensityValue; + TMxLabel *MxLabel1; + TMultiObjSpinEdit *TimeValue; void __fastcall CnahgeParam(TObject *Sender); - void __fastcall ColorClick(TObject *Sender); - void __fastcall TimeValueExit(TObject *Sender); - void __fastcall TimeValueKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); -private: // User declarations - void UpdateColor (); - bool m_bLocked; -public: // User declarations - virtual void Lock (bool b){m_bLocked=b;} - _pp_params m_pp_params; - - __fastcall TAddColorForm(TComponent* Owner, _pp_params p); - - virtual void ShowCurrent (u32 keyIdx); - virtual _pp_params GetTimeChannel () {return m_pp_params;}; - virtual bool DrawChannel (_pp_params p);; - virtual void Clear (); - virtual TForm* GetForm () {return this;}; - virtual void AddNew (u32 keyIdx); - virtual void Remove (u32 keyIdx); - virtual void RemoveAllKeys (); - virtual void CreateKey (float t); + void __fastcall ColorClick(TObject *Sender); + void __fastcall TimeValueExit(TObject *Sender); + void __fastcall TimeValueKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); +private: // User declarations + void UpdateColor(); + bool m_bLocked; +public: // User declarations + virtual void Lock(bool b) + { + m_bLocked = b; + } + + _pp_params m_pp_params; + + __fastcall TAddColorForm(TComponent *Owner, _pp_params p); + + virtual void ShowCurrent(u32 keyIdx); + + virtual _pp_params GetTimeChannel() + { + return m_pp_params; + }; + + virtual bool DrawChannel(_pp_params p);; + virtual void Clear(); + + virtual TForm *GetForm() + { + return this; + }; + + virtual void AddNew(u32 keyIdx); + virtual void Remove(u32 keyIdx); + virtual void RemoveAllKeys(); + virtual void CreateKey(float t); }; #endif + diff --git a/src/editors/PPEditor/effect.cpp b/src/editors/PPEditor/effect.cpp index de541d57253..00ce92da11f 100644 --- a/src/editors/PPEditor/effect.cpp +++ b/src/editors/PPEditor/effect.cpp @@ -9,32 +9,35 @@ //--------------------------------------------------------------------------- - Effect::Effect (Graphics::TBitmap *host) +Effect::Effect(Graphics::TBitmap *host) { m_Host = host; - m_BaseColor = new ColorParam (host); - m_AddColor = new ColorParam (host); - m_GrayColor = new ColorParam (host); + m_BaseColor = new ColorParam(host); + m_AddColor = new ColorParam(host); + m_GrayColor = new ColorParam(host); m_Created = false; m_Edit = ee_none; m_Time = 0.0f; } + //--------------------------------------------------------------------------- - Effect::~Effect () +Effect::~Effect() { delete m_GrayColor; delete m_AddColor; delete m_BaseColor; } + //--------------------------------------------------------------------------- -void Effect::clear () +void Effect::clear() { - m_BaseColor->clear (); - m_AddColor->clear (); - m_GrayColor->clear (); + m_BaseColor->clear(); + m_AddColor->clear(); + m_GrayColor->clear(); } + //--------------------------------------------------------------------------- -void Effect::create (float time) +void Effect::create(float time) { m_BaseColor->create(time); m_AddColor->create(time); @@ -42,31 +45,38 @@ void Effect::create (float time) m_Time = time; m_Created = true; } + //--------------------------------------------------------------------------- -void Effect::draw () +void Effect::draw() { - if (m_Created == false) return; - m_BaseColor->draw (); - m_AddColor->draw (); - m_GrayColor->draw (); + if (m_Created==false) + return; + m_BaseColor->draw(); + m_AddColor->draw(); + m_GrayColor->draw(); } + //--------------------------------------------------------------------------- -void Effect::add_point (int _xpos, int _ypos) +void Effect::add_point(int _xpos, int _ypos) { - if (m_Edit == ee_none) return; - float ftime = (float)_xpos / (float)m_Host->Width; - float fvalue = (float)_ypos - (float)m_Host->Height * 0.5f; + if (m_Edit==ee_none) + return; + float ftime = (float)_xpos/(float)m_Host->Width; + float fvalue = (float)_ypos-(float)m_Host->Height*0.5f; switch (m_Edit) - { - case ee_base_color: - break; - case ee_add_color: - break; - case ee_gray_color: - break; - } + { + case ee_base_color: + break; + case ee_add_color: + break; + case ee_gray_color: + break; + } } + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- + + diff --git a/src/editors/PPEditor/effect.h b/src/editors/PPEditor/effect.h index 63ba8b411a1..b0fc8830b46 100644 --- a/src/editors/PPEditor/effect.h +++ b/src/editors/PPEditor/effect.h @@ -3,37 +3,52 @@ #ifndef effectH #define effectH #include "color_param.h" + //--------------------------------------------------------------------------- typedef enum _edit_effect { - ee_none = 0, - ee_base_color = 1, - ee_add_color = 2, - ee_gray_color = 3, - ee_force_dword = 0x7fffffff + ee_none = 0, + ee_base_color = 1, + ee_add_color = 2, + ee_gray_color = 3, + ee_force_dword = 0x7fffffff } edit_effect; class Effect { protected: - Graphics::TBitmap *m_Host; - ColorParam *m_BaseColor; - ColorParam *m_AddColor; - ColorParam *m_GrayColor; - bool m_Created; - edit_effect m_Edit; - float m_Time; + Graphics::TBitmap *m_Host; + ColorParam *m_BaseColor; + ColorParam *m_AddColor; + ColorParam *m_GrayColor; + bool m_Created; + edit_effect m_Edit; + float m_Time; public: - Effect (Graphics::TBitmap *host); - ~Effect (); - void clear (); - void create (float time); - void draw (); - ColorParam* get_base_color () { return m_BaseColor; } - ColorParam* get_add_color () { return m_AddColor; } - ColorParam* get_gray_color () { return m_GrayColor; } - void add_point (int _xpos, int _ypos); + Effect(Graphics::TBitmap *host); + ~Effect(); + void clear(); + void create(float time); + void draw(); + + ColorParam *get_base_color() + { + return m_BaseColor; + } + + ColorParam *get_add_color() + { + return m_AddColor; + } + + ColorParam *get_gray_color() + { + return m_GrayColor; + } + + void add_point(int _xpos, int _ypos); }; #endif + diff --git a/src/editors/PPEditor/float_constructor.cpp b/src/editors/PPEditor/float_constructor.cpp index f18eac08d79..7e13768c1eb 100644 --- a/src/editors/PPEditor/float_constructor.cpp +++ b/src/editors/PPEditor/float_constructor.cpp @@ -5,111 +5,119 @@ #pragma package(smart_init) #pragma resource "*.dfm" TfrmConstructor *frmConstructor; + //--------------------------------------------------------------------------- -__fastcall TfrmConstructor::TfrmConstructor(TComponent* Owner) - : TForm(Owner),b_locked(false) +__fastcall TfrmConstructor::TfrmConstructor(TComponent *Owner) + : TForm(Owner), b_locked(false) { - m_iTag = 0; + m_iTag = 0; } + //--------------------------------------------------------------------------- -TfrmTimeConstructor* TfrmConstructor::AddEntryTemplate(int iInsertAfterIdx) +TfrmTimeConstructor *TfrmConstructor::AddEntryTemplate(int iInsertAfterIdx) { - TfrmTimeConstructor* form = new TfrmTimeConstructor (this); - form->Parent = this; - form->Left = 0; - form->Tag = m_iTag++; - form->Visible = true; - form->AddButton->Tag = form->Tag; - form->DeleteButton->Tag = form->Tag; - form->AddButton->OnClick = OnAddButtonClick; + TfrmTimeConstructor*form = new TfrmTimeConstructor(this); + form->Parent = this; + form->Left = 0; + form->Tag = m_iTag++; + form->Visible = true; + form->AddButton->Tag = form->Tag; + form->DeleteButton->Tag = form->Tag; + form->AddButton->OnClick = OnAddButtonClick; form->DeleteButton->OnClick = OnDelButtonClick; - form->WorkTime->OnChange = OnTimeChangeClick; + form->WorkTime->OnChange = OnTimeChangeClick; - if(iInsertAfterIdx==-1) - m_Entries.push_back (form); - else - { - vector::iterator it = m_Entries.begin(); - std::advance(it,iInsertAfterIdx+1); - m_Entries.insert(it,form); - } + if (iInsertAfterIdx==-1) + m_Entries.push_back(form); + else + { + vector::iterator it = m_Entries.begin(); + std::advance(it, iInsertAfterIdx+1); + m_Entries.insert(it, form); + } return form; } + //--------------------------------------------------------------------------- -void TfrmConstructor::UpdatePositions() +void TfrmConstructor::UpdatePositions() { - if(b_locked) return; - float start_time = 0.0f; - for (size_t a = 0; a < m_Entries.size (); ++a) - { - m_Entries[a]->StartTime->Value = start_time; - m_Entries[a]->Left = 0; - m_Entries[a]->Top = (m_Entries[a]->Height + 4) * a; - start_time += m_Entries[a]->WorkTime->Value; - } - ClientHeight = m_Entries.size()*(30+4) + Button1->Height; + if (b_locked) + return; + float start_time = 0.0f; + for (size_t a = 0; aStartTime->Value = start_time; + m_Entries[a]->Left = 0; + m_Entries[a]->Top = (m_Entries[a]->Height+4)*a; + start_time += m_Entries[a]->WorkTime->Value; + } + ClientHeight = m_Entries.size()*(30+4)+Button1->Height; Button1->Top = ClientHeight-Button1->Height; Button2->Top = ClientHeight-Button2->Height; } -void __fastcall TfrmConstructor::OnTimeChangeClick(TObject *Sender) +void __fastcall TfrmConstructor::OnTimeChangeClick(TObject *Sender) { - UpdatePositions(); + UpdatePositions(); } //--------------------------------------------------------------------------- -void __fastcall TfrmConstructor::OnAddButtonClick (TObject *Sender) +void __fastcall TfrmConstructor::OnAddButtonClick(TObject *Sender) { - int tag = dynamic_cast (Sender)->Tag; - for (size_t a = 0; a < m_Entries.size (); a++) - if (m_Entries[a]->Tag == tag) - { - AddEntryTemplate (a); - UpdatePositions (); - return; - } + int tag = dynamic_cast(Sender)->Tag; + for (size_t a = 0; aTag==tag) + { + AddEntryTemplate(a); + UpdatePositions(); + return; + } } + //--------------------------------------------------------------------------- -void __fastcall TfrmConstructor::OnDelButtonClick (TObject *Sender) +void __fastcall TfrmConstructor::OnDelButtonClick(TObject *Sender) { - if (m_Entries.size () == 1) return; - int tag = dynamic_cast (Sender)->Parent->Parent->Tag; - vector::iterator s = m_Entries.begin(), e = m_Entries.end (); - for (; s != e; ++s) - if ((*s)->Tag == tag) - { - TfrmTimeConstructor *form = (*s); - delete form; - m_Entries.erase (s); - UpdatePositions (); - return; - } + if (m_Entries.size()==1) + return; + int tag = dynamic_cast(Sender)->Parent->Parent->Tag; + vector::iterator s = m_Entries.begin(), e = m_Entries.end(); + for (; s!=e; ++s) + if ((*s)->Tag==tag) + { + TfrmTimeConstructor*form = (*s); + delete form; + m_Entries.erase(s); + UpdatePositions(); + return; + } } + //--------------------------------------------------------------------------- -void __fastcall TfrmConstructor::Reset() +void __fastcall TfrmConstructor::Reset() { - vector::iterator it = m_Entries.begin(); - vector::iterator it_e = m_Entries.end (); + vector::iterator it = m_Entries.begin(); + vector::iterator it_e = m_Entries.end(); for (; it!=it_e; ++it) { - TfrmTimeConstructor* form = (*it); - delete form; + TfrmTimeConstructor*form = (*it); + delete form; } - m_Entries.clear (); + m_Entries.clear(); - AddEntryTemplate (-1); + AddEntryTemplate(-1); m_Entries[0]->WorkTime->Value = 0.0f; - } //--------------------------------------------------------------------------- -TfrmTimeConstructor* __fastcall TfrmConstructor::GetEntry(u32 index) +TfrmTimeConstructor * __fastcall TfrmConstructor::GetEntry(u32 index) { - if (index >= m_Entries.size()) - throw Exception ("Float constructor: invalid index"); + if (index>=m_Entries.size()) + throw Exception("Float constructor: invalid index"); return m_Entries[index]; } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/float_constructor.h b/src/editors/PPEditor/float_constructor.h index 40867f47ba7..8e2d9d316ea 100644 --- a/src/editors/PPEditor/float_constructor.h +++ b/src/editors/PPEditor/float_constructor.h @@ -16,28 +16,35 @@ #include using namespace std; + //--------------------------------------------------------------------------- class TfrmConstructor : public TForm { -__published: // IDE-managed Components - TButton *Button1; + __published: // IDE-managed Components + TButton*Button1; TButton *Button2; -private: // User declarations - int m_iTag; - bool b_locked; -public: // User declarations - vector m_Entries; - __fastcall TfrmConstructor (TComponent* Owner); - TfrmTimeConstructor* AddEntryTemplate (int iInsertAfter); - void __fastcall OnTimeChangeClick (TObject *Sender); - void __fastcall OnAddButtonClick (TObject *Sender); - void __fastcall OnDelButtonClick (TObject *Sender); - void __fastcall Reset (); - TfrmTimeConstructor* __fastcall GetEntry (u32 index); - void UpdatePositions (); - void Lock (bool b){b_locked=b;} +private: // User declarations + int m_iTag; + bool b_locked; +public: // User declarations + vector m_Entries; + __fastcall TfrmConstructor(TComponent *Owner); + TfrmTimeConstructor *AddEntryTemplate(int iInsertAfter); + void __fastcall OnTimeChangeClick(TObject *Sender); + void __fastcall OnAddButtonClick(TObject *Sender); + void __fastcall OnDelButtonClick(TObject *Sender); + void __fastcall Reset(); + TfrmTimeConstructor * __fastcall GetEntry(u32 index); + void UpdatePositions(); + + void Lock(bool b) + { + b_locked = b; + } }; + //--------------------------------------------------------------------------- -extern PACKAGE TfrmConstructor *frmConstructor; +extern PACKAGE TfrmConstructor * frmConstructor; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/float_param.cpp b/src/editors/PPEditor/float_param.cpp index 0cf2c9bfb8b..cb728d546e3 100644 --- a/src/editors/PPEditor/float_param.cpp +++ b/src/editors/PPEditor/float_param.cpp @@ -8,12 +8,14 @@ #pragma link "MXCtrls" #pragma resource "*.dfm" TfrmTimeConstructor *frmTimeConstructor; + //--------------------------------------------------------------------------- -__fastcall TfrmTimeConstructor::TfrmTimeConstructor(TComponent* Owner) +__fastcall TfrmTimeConstructor::TfrmTimeConstructor(TComponent *Owner) : TForm(Owner) { ClientHeight = Panel1->Height; - } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/float_param.h b/src/editors/PPEditor/float_param.h index 06d2fac29ac..7480648cacb 100644 --- a/src/editors/PPEditor/float_param.h +++ b/src/editors/PPEditor/float_param.h @@ -15,23 +15,26 @@ #include #include "multi_edit.hpp" #include "MXCtrls.hpp" + //--------------------------------------------------------------------------- class TfrmTimeConstructor : public TForm { -__published: // IDE-managed Components - TPanel *Panel1; + __published: // IDE-managed Components + TPanel*Panel1; TMultiObjSpinEdit *WorkTime; TSpeedButton *AddButton; TSpeedButton *DeleteButton; - TMxLabel *RxLabel2; - TMxLabel *MxLabel1; - TMultiObjSpinEdit *StartTime; -private: // User declarations -public: // User declarations - float t, c, b; - __fastcall TfrmTimeConstructor(TComponent* Owner); + TMxLabel *RxLabel2; + TMxLabel *MxLabel1; + TMultiObjSpinEdit *StartTime; +private: // User declarations +public: // User declarations + float t, c, b; + __fastcall TfrmTimeConstructor(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TfrmTimeConstructor *frmTimeConstructor; +extern PACKAGE TfrmTimeConstructor * frmTimeConstructor; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/main.cpp b/src/editors/PPEditor/main.cpp index 4f9df5bf7d9..876a4146bc2 100644 --- a/src/editors/PPEditor/main.cpp +++ b/src/editors/PPEditor/main.cpp @@ -13,49 +13,50 @@ TMainForm *MainForm; //--------------------------------------------------------------------------- -__fastcall TMainForm::TMainForm(TComponent* Owner) +__fastcall TMainForm::TMainForm(TComponent *Owner) : TForm(Owner) { - frmConstructor = new TfrmConstructor(this); - Image->Picture->Bitmap->Width = Image->Width; - Image->Picture->Bitmap->Height = Image->Height; - - m_Animator = new CPostprocessAnimator (0, false); - m_ActiveShowForm = NULL; - - m_props[tAddColor] = new TAddColorForm(this, pp_add_color); - m_props[tAddColor]->GetForm()->Parent = WorkArea; - m_props[tAddColor]->GetForm()->Visible = false; - - m_props[tBaseColor] = new TAddColorForm(this,pp_base_color); - m_props[tBaseColor]->GetForm()->Parent = WorkArea; + frmConstructor = new TfrmConstructor(this); + Image->Picture->Bitmap->Width = Image->Width; + Image->Picture->Bitmap->Height = Image->Height; + + m_Animator = new CPostprocessAnimator(0, false); + m_ActiveShowForm = NULL; + + m_props[tAddColor] = new TAddColorForm(this, pp_add_color); + m_props[tAddColor]->GetForm()->Parent = WorkArea; + m_props[tAddColor]->GetForm()->Visible = false; + + m_props[tBaseColor] = new TAddColorForm(this, pp_base_color); + m_props[tBaseColor]->GetForm()->Parent = WorkArea; m_props[tBaseColor]->GetForm()->Visible = false; - m_props[tGray] = new TAddColorForm(this,pp_gray_color); - m_props[tGray]->GetForm()->Parent = WorkArea; - m_props[tGray]->GetForm()->Visible = false; + m_props[tGray] = new TAddColorForm(this, pp_gray_color); + m_props[tGray]->GetForm()->Parent = WorkArea; + m_props[tGray]->GetForm()->Visible = false; - m_props[tDuality] = new TAddFloatForm(this,pp_dual_h); - m_props[tDuality]->GetForm()->Parent = WorkArea; - m_props[tDuality]->GetForm()->Visible = false; + m_props[tDuality] = new TAddFloatForm(this, pp_dual_h); + m_props[tDuality]->GetForm()->Parent = WorkArea; + m_props[tDuality]->GetForm()->Visible = false; - m_props[tNoise] = new TAddFloatForm(this,pp_noise_i); - m_props[tNoise]->GetForm()->Parent = WorkArea; - m_props[tNoise]->GetForm()->Visible = false; + m_props[tNoise] = new TAddFloatForm(this, pp_noise_i); + m_props[tNoise]->GetForm()->Parent = WorkArea; + m_props[tNoise]->GetForm()->Visible = false; - m_props[tBlur] = new TAddColorForm(this,pp_gray_color); - m_props[tBlur]->GetForm()->Parent = WorkArea; - m_props[tBlur]->GetForm()->Visible = false; + m_props[tBlur] = new TAddColorForm(this, pp_gray_color); + m_props[tBlur]->GetForm()->Parent = WorkArea; + m_props[tBlur]->GetForm()->Visible = false; - m_props[tColorMap] = new TAddFloatForm(this,pp_cm_influence); - m_props[tColorMap]->GetForm()->Parent = WorkArea; - m_props[tColorMap]->GetForm()->Visible = false; + m_props[tColorMap] = new TAddFloatForm(this, pp_cm_influence); + m_props[tColorMap]->GetForm()->Parent = WorkArea; + m_props[tColorMap]->GetForm()->Visible = false; - m_Marker = 0.0f; + m_Marker = 0.0f; - TabControl->TabIndex = 0; - TabControlChange (TabControl); + TabControl->TabIndex = 0; + TabControlChange(TabControl); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::FormDestroy(TObject *Sender) { @@ -63,6 +64,7 @@ void __fastcall TMainForm::FormDestroy(TObject *Sender) m_Animator = NULL; delete frmConstructor; } + //--------------------------------------------------------------------------- void __fastcall TMainForm::FormResize(TObject *Sender) { @@ -70,57 +72,62 @@ void __fastcall TMainForm::FormResize(TObject *Sender) Image->Picture->Bitmap->Height = 0; Image->Picture->Bitmap->Width = Image->Width; Image->Picture->Bitmap->Height = Image->Height; - UpdateGraph (); + UpdateGraph(); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::NewEffectButtonClick(TObject *Sender) { - if (Application->MessageBox ("Do you wish to create a new effect ?", "Warning", MB_YESNO | MB_ICONSTOP) == IDNO) - return; - - m_Animator->Create (); - UpdateGraph (); - - m_props[tAddColor]->Clear(); - m_props[tBaseColor]->Clear(); - m_props[tGray]->Clear(); - m_props[tDuality]->Clear(); - m_props[tNoise]->Clear(); - m_props[tBlur]->Clear(); + if (Application->MessageBox("Do you wish to create a new effect ?", "Warning", MB_YESNO|MB_ICONSTOP)==IDNO) + return; + + m_Animator->Create(); + UpdateGraph(); + + m_props[tAddColor]->Clear(); + m_props[tBaseColor]->Clear(); + m_props[tGray]->Clear(); + m_props[tDuality]->Clear(); + m_props[tNoise]->Clear(); + m_props[tBlur]->Clear(); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::FormPaint(TObject *Sender) { - UpdateGraph (); + UpdateGraph(); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::ImageMouseUp(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { -// m_pEffect->add_point (X, Y); + // m_pEffect->add_point (X, Y); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::GrayColorClick(TObject *Sender) { -// m_pEffect->get_add_color()->show_constructor (); + // m_pEffect->get_add_color()->show_constructor (); } + //--------------------------------------------------------------------------- void TMainForm::PointListSetTime(int idx, float time) { string256 str; - sprintf(str,"%2.2f",time); + sprintf(str, "%2.2f", time); PointList->Items->Strings[idx] = str; } void TMainForm::FillPointList() { PointList->Clear(); - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (m_ActiveShowForm->GetTimeChannel()); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(m_ActiveShowForm->GetTimeChannel()); u32 cnt = cparam->get_keys_count(); - for(u32 i=0; iAddItem("", NULL); - float t = cparam->get_key_time(i); + float t = cparam->get_key_time(i); PointListSetTime(PointList->Count-1, t); } } @@ -128,149 +135,154 @@ void TMainForm::FillPointList() void __fastcall TMainForm::TabControlChange(TObject *Sender) { if (m_ActiveShowForm) - { - m_ActiveShowForm->GetForm()->Visible = false; - m_ActiveShowForm = NULL; - } + { + m_ActiveShowForm->GetForm()->Visible = false; + m_ActiveShowForm = NULL; + } m_ActiveShowForm = m_props[TabControl->TabIndex]; - - m_ActiveShowForm->GetForm()->Parent = WorkArea; - m_ActiveShowForm->GetForm()->Left = 0; - m_ActiveShowForm->GetForm()->Top = 0; - m_ActiveShowForm->GetForm()->Width = WorkArea->Width; - m_ActiveShowForm->GetForm()->Height = WorkArea->Height; - m_ActiveShowForm->GetForm()->Visible = true; - - FillPointList (); - - if(PointList->Count) - PointList->ItemIndex = 0; - - PointListClick (NULL); - UpdateGraph (); + + m_ActiveShowForm->GetForm()->Parent = WorkArea; + m_ActiveShowForm->GetForm()->Left = 0; + m_ActiveShowForm->GetForm()->Top = 0; + m_ActiveShowForm->GetForm()->Width = WorkArea->Width; + m_ActiveShowForm->GetForm()->Height = WorkArea->Height; + m_ActiveShowForm->GetForm()->Visible = true; + + FillPointList(); + + if (PointList->Count) + PointList->ItemIndex = 0; + + PointListClick(NULL); + UpdateGraph(); } + //--------------------------------------------------------------------------- -void TMainForm::SetMarkerPosition (float time) +void TMainForm::SetMarkerPosition(float time) { m_Marker = time; - UpdateGraph (); + UpdateGraph(); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::LoadButtonClick(TObject *Sender) { -/* - if (m_Animator->GetLength() != 0.0f) - if (Application->MessageBox ("Do you wish to save current effect ?", "Warning", MB_YESNO | MB_ICONSTOP) == IDYES) - SaveButtonClick (Sender); -*/ - if(OpenDialog->Execute ()) + /* + if (m_Animator->GetLength() != 0.0f) + if (Application->MessageBox ("Do you wish to save current effect ?", "Warning", MB_YESNO | MB_ICONSTOP) == IDYES) + SaveButtonClick (Sender); + */ + if (OpenDialog->Execute()) { m_Marker = 0.0f; - m_Animator->Load (OpenDialog->FileName.c_str ()); - Caption = OpenDialog->FileName.c_str (); + m_Animator->Load(OpenDialog->FileName.c_str()); + Caption = OpenDialog->FileName.c_str(); - TabControl->TabIndex = 0; - TabControlChange (TabControl); + TabControl->TabIndex = 0; + TabControlChange(TabControl); } } void __fastcall TMainForm::SaveButtonClick(TObject *Sender) { - if (m_Animator->GetLength() == 0.0f) return; + if (m_Animator->GetLength()==0.0f) + return; if (SaveDialog->Execute()) { - m_Animator->Save (SaveDialog->FileName.c_str ()); - Caption = SaveDialog->FileName.c_str (); + m_Animator->Save(SaveDialog->FileName.c_str()); + Caption = SaveDialog->FileName.c_str(); } } void TMainForm::UpdateGraph() { - if(!m_Animator) return; - TCanvas *canvas = Image->Picture->Bitmap->Canvas; - canvas->Brush->Color = clWhite; - canvas->FillRect (TRect (0, 0, Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height)); - canvas->Pen->Color = clBlack; - canvas->MoveTo (0, Image->Picture->Bitmap->Height / 2); - canvas->LineTo (Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height / 2); - canvas->MoveTo (0, 0); - canvas->LineTo (Image->Picture->Bitmap->Width, 0); - canvas->MoveTo (0, Image->Picture->Bitmap->Height - 1); - canvas->LineTo (Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height - 1); - canvas->TextOutA (0, Image->Picture->Bitmap->Height / 2 - 14, "0.0"); - canvas->TextOutA (0, Image->Picture->Bitmap->Height - 14, "-1.0"); - canvas->TextOutA (0, 2, "1.0"); - - - float alltime = m_Animator->GetLength (); - string128 buf; - sprintf (buf, "Effect time : %.3f", alltime); + if (!m_Animator) + return; + TCanvas *canvas = Image->Picture->Bitmap->Canvas; + canvas->Brush->Color = clWhite; + canvas->FillRect(TRect(0, 0, Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height)); + canvas->Pen->Color = clBlack; + canvas->MoveTo(0, Image->Picture->Bitmap->Height/2); + canvas->LineTo(Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height/2); + canvas->MoveTo(0, 0); + canvas->LineTo(Image->Picture->Bitmap->Width, 0); + canvas->MoveTo(0, Image->Picture->Bitmap->Height-1); + canvas->LineTo(Image->Picture->Bitmap->Width, Image->Picture->Bitmap->Height-1); + canvas->TextOutA(0, Image->Picture->Bitmap->Height/2-14, "0.0"); + canvas->TextOutA(0, Image->Picture->Bitmap->Height-14, "-1.0"); + canvas->TextOutA(0, 2, "1.0"); + + + float alltime = m_Animator->GetLength(); + string128 buf; + sprintf(buf, "Effect time : %.3f", alltime); StatusBar->Panels->Items[0]->Text = buf; - if (alltime == 0.0f) return; - - float width = (float)Image->Picture->Bitmap->Width, height = (float)Image->Picture->Bitmap->Height * 0.5f; + if (alltime==0.0f) + return; + + float width = (float)Image->Picture->Bitmap->Width, height = (float)Image->Picture->Bitmap->Height*0.5f; //draw marker - int left = (int)(width / alltime * m_Marker); - canvas->MoveTo (left, 0); - canvas->Pen->Style = psDot; - canvas->LineTo (left, Image->Picture->Bitmap->Height); - canvas->Pen->Style = psSolid; + int left = (int)(width/alltime*m_Marker); + canvas->MoveTo(left, 0); + canvas->Pen->Style = psDot; + canvas->LineTo(left, Image->Picture->Bitmap->Height); + canvas->Pen->Style = psSolid; - SPPInfo m_EffectorParams; - ZeroMemory (&m_EffectorParams, sizeof (SPPInfo)); + SPPInfo m_EffectorParams; + ZeroMemory(&m_EffectorParams, sizeof (SPPInfo)); - float increment = alltime / (float)Image->Width; + float increment = alltime/(float)Image->Width; - for (float t = 0.0f; t < alltime; t += increment) + for (float t = 0.0f; tProcess (t, m_EffectorParams); - int x = (int)(width / alltime * t); - - for(u32 idx =pp_base_color;idxProcess(t, m_EffectorParams); + int x = (int)(width/alltime*t); + + for (u32 idx = pp_base_color; idxDrawChannel((_pp_params)idx)) + if (!m_ActiveShowForm->DrawChannel((_pp_params)idx)) continue; - + switch (idx) - { - case pp_base_color: - canvas->Pixels[x][(int)(-m_EffectorParams.color_base.r * height + height)] = clRed; - canvas->Pixels[x][(int)(-m_EffectorParams.color_base.g * height + height)] = clGreen; - canvas->Pixels[x][(int)(-m_EffectorParams.color_base.b * height + height)] = clBlue; - break; - case pp_add_color: - canvas->Pixels[x][(int)(-m_EffectorParams.color_add.r * height + height)] = clRed; - canvas->Pixels[x][(int)(-m_EffectorParams.color_add.g * height + height)] = clGreen; - canvas->Pixels[x][(int)(-m_EffectorParams.color_add.b * height + height)] = clBlue; - break; - case pp_gray_color: - canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.r * height + height)] = clRed; - canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.g * height + height)] = clGreen; - canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.b * height + height)] = clBlue; - break; - case pp_gray_value: - canvas->Pixels[x][(int)(-m_EffectorParams.blur * height + height)] = clBlack; - break; - case pp_blur: - canvas->Pixels[x][(int)(-m_EffectorParams.gray * height + height)] = clBlack; - break; - case pp_dual_h: - canvas->Pixels[x][(int)(-m_EffectorParams.duality.h * height + height)] = clRed; - break; - case pp_dual_v: - canvas->Pixels[x][(int)(-m_EffectorParams.duality.v * height + height)] = clGreen; - break; - case pp_noise_i: - canvas->Pixels[x][(int)(-m_EffectorParams.noise.intensity * height + height)] = clRed; - break; - case pp_noise_g: - canvas->Pixels[x][(int)(-m_EffectorParams.noise.grain * height + height)] = clGreen; - break; - case pp_noise_f: - canvas->Pixels[x][(int)(-m_EffectorParams.noise.fps * height + height)] = clBlue; - break; - }//switch - }//channel + { + case pp_base_color: + canvas->Pixels[x][(int)(-m_EffectorParams.color_base.r*height+height)] = clRed; + canvas->Pixels[x][(int)(-m_EffectorParams.color_base.g*height+height)] = clGreen; + canvas->Pixels[x][(int)(-m_EffectorParams.color_base.b*height+height)] = clBlue; + break; + case pp_add_color: + canvas->Pixels[x][(int)(-m_EffectorParams.color_add.r*height+height)] = clRed; + canvas->Pixels[x][(int)(-m_EffectorParams.color_add.g*height+height)] = clGreen; + canvas->Pixels[x][(int)(-m_EffectorParams.color_add.b*height+height)] = clBlue; + break; + case pp_gray_color: + canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.r*height+height)] = clRed; + canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.g*height+height)] = clGreen; + canvas->Pixels[x][(int)(-m_EffectorParams.color_gray.b*height+height)] = clBlue; + break; + case pp_gray_value: + canvas->Pixels[x][(int)(-m_EffectorParams.blur*height+height)] = clBlack; + break; + case pp_blur: + canvas->Pixels[x][(int)(-m_EffectorParams.gray*height+height)] = clBlack; + break; + case pp_dual_h: + canvas->Pixels[x][(int)(-m_EffectorParams.duality.h*height+height)] = clRed; + break; + case pp_dual_v: + canvas->Pixels[x][(int)(-m_EffectorParams.duality.v*height+height)] = clGreen; + break; + case pp_noise_i: + canvas->Pixels[x][(int)(-m_EffectorParams.noise.intensity*height+height)] = clRed; + break; + case pp_noise_g: + canvas->Pixels[x][(int)(-m_EffectorParams.noise.grain*height+height)] = clGreen; + break; + case pp_noise_f: + canvas->Pixels[x][(int)(-m_EffectorParams.noise.fps*height+height)] = clBlue; + break; + }//switch + }//channel }//time } @@ -278,89 +290,93 @@ void TMainForm::UpdateGraph() void __fastcall TMainForm::PointListClick(TObject *Sender) { - m_ActiveShowForm->Lock(true); - m_ActiveShowForm->ShowCurrent(PointList->ItemIndex); - m_ActiveShowForm->Lock(false); + m_ActiveShowForm->Lock(true); + m_ActiveShowForm->ShowCurrent(PointList->ItemIndex); + m_ActiveShowForm->Lock(false); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::btnAddKeyClick(TObject *Sender) { - int idx = PointList->ItemIndex; - m_ActiveShowForm->Lock (true); - m_ActiveShowForm->AddNew (PointList->ItemIndex); - m_ActiveShowForm->Lock (false); - - TabControlChange (TabControl); - PointList->ItemIndex = idx+1; - PointListClick (NULL); + int idx = PointList->ItemIndex; + m_ActiveShowForm->Lock(true); + m_ActiveShowForm->AddNew(PointList->ItemIndex); + m_ActiveShowForm->Lock(false); + + TabControlChange(TabControl); + PointList->ItemIndex = idx+1; + PointListClick(NULL); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::btnRemoveKeyClick(TObject *Sender) { - int idx = PointList->ItemIndex; - m_ActiveShowForm->Lock (true); - m_ActiveShowForm->Remove (PointList->ItemIndex); - m_ActiveShowForm->Lock (false); - - TabControlChange (TabControl); - if(PointList->Count>idx) - PointList->ItemIndex = idx; + int idx = PointList->ItemIndex; + m_ActiveShowForm->Lock(true); + m_ActiveShowForm->Remove(PointList->ItemIndex); + m_ActiveShowForm->Lock(false); + + TabControlChange(TabControl); + if (PointList->Count>idx) + PointList->ItemIndex = idx; else - PointList->ItemIndex = idx-1; + PointList->ItemIndex = idx-1; } + //--------------------------------------------------------------------------- void __fastcall TMainForm::ClearAllClick(TObject *Sender) { - m_ActiveShowForm->Lock (true); - m_ActiveShowForm->RemoveAllKeys (); - m_ActiveShowForm->Lock (false); + m_ActiveShowForm->Lock(true); + m_ActiveShowForm->RemoveAllKeys(); + m_ActiveShowForm->Lock(false); - TabControlChange (TabControl); + TabControlChange(TabControl); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::copyFromClick(TObject *Sender) { - TPoint P; - P = Mouse->CursorPos; - PopupCopyFrom->Popup(P.x, P.y); + TPoint P; + P = Mouse->CursorPos; + PopupCopyFrom->Popup(P.x, P.y); } + //--------------------------------------------------------------------------- void __fastcall TMainForm::PopupCopyFromChange(TObject *Sender, - TMenuItem *Source, bool Rebuild) + TMenuItem *Source, bool Rebuild) { -// + // } + //--------------------------------------------------------------------------- void __fastcall TMainForm::PopupClick(TObject *Sender) { - // - TMenuItem* itm = dynamic_cast(Sender); + // + TMenuItem *itm = dynamic_cast(Sender); - m_ActiveShowForm->Lock (true); - m_ActiveShowForm->RemoveAllKeys (); + m_ActiveShowForm->Lock(true); + m_ActiveShowForm->RemoveAllKeys(); - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (m_props[itm->Tag]->GetTimeChannel()); - u32 cnt = cparam->get_keys_count(); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(m_props[itm->Tag]->GetTimeChannel()); + u32 cnt = cparam->get_keys_count(); string256 str; - for(u32 i=0; iget_key_time(i); - m_ActiveShowForm->CreateKey (t); + float t = cparam->get_key_time(i); + m_ActiveShowForm->CreateKey(t); } - m_ActiveShowForm->Lock (false); + m_ActiveShowForm->Lock(false); - TabControlChange (NULL); + TabControlChange(NULL); } -//--------------------------------------------------------------------------- - - +//--------------------------------------------------------------------------- diff --git a/src/editors/PPEditor/main.h b/src/editors/PPEditor/main.h index ded346952e8..f0bb597b4ff 100644 --- a/src/editors/PPEditor/main.h +++ b/src/editors/PPEditor/main.h @@ -25,8 +25,8 @@ class TPPPropEditor; class TMainForm : public TForm { -__published: - TPanel *Panel; + __published: + TPanel*Panel; TToolBar *ToolBar1; TStatusBar *StatusBar; TImage *Image; @@ -38,58 +38,60 @@ class TMainForm : public TForm TSaveDialog *SaveDialog; TOpenDialog *OpenDialog; TImageList *ImageList; - TListBox *PointList; - TMxLabel *RxLabel1; - TPanel *WorkArea; - TButton *btnAddKey; - TButton *btnRemoveKey; - TButton *ClearAll; - TButton *copyFrom; - TPopupMenu *PopupCopyFrom; - TMenuItem *Addcolor1; - TMenuItem *BaseColor1; - TMenuItem *Graycolor1; - TMenuItem *Duality1; - TMenuItem *Noise1; - TMenuItem *Blur1; - TMainMenu *MainMenu1; - TMenuItem *File1; - TMenuItem *Save1; - TMenuItem *Load1; - TMenuItem *New1; - TMenuItem *N1; + TListBox *PointList; + TMxLabel *RxLabel1; + TPanel *WorkArea; + TButton *btnAddKey; + TButton *btnRemoveKey; + TButton *ClearAll; + TButton *copyFrom; + TPopupMenu *PopupCopyFrom; + TMenuItem *Addcolor1; + TMenuItem *BaseColor1; + TMenuItem *Graycolor1; + TMenuItem *Duality1; + TMenuItem *Noise1; + TMenuItem *Blur1; + TMainMenu *MainMenu1; + TMenuItem *File1; + TMenuItem *Save1; + TMenuItem *Load1; + TMenuItem *New1; + TMenuItem *N1; void __fastcall FormResize(TObject *Sender); void __fastcall NewEffectButtonClick(TObject *Sender); void __fastcall FormDestroy(TObject *Sender); void __fastcall FormPaint(TObject *Sender); void __fastcall ImageMouseUp(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); + TShiftState Shift, int X, int Y); void __fastcall GrayColorClick(TObject *Sender); void __fastcall TabControlChange(TObject *Sender); void __fastcall LoadButtonClick(TObject *Sender); void __fastcall SaveButtonClick(TObject *Sender); - void __fastcall PointListClick(TObject *Sender); - void __fastcall btnAddKeyClick(TObject *Sender); - void __fastcall btnRemoveKeyClick(TObject *Sender); - void __fastcall ClearAllClick(TObject *Sender); - void __fastcall copyFromClick(TObject *Sender); - void __fastcall PopupCopyFromChange(TObject *Sender, TMenuItem *Source, - bool Rebuild); - void __fastcall PopupClick(TObject *Sender); -private: // User declarations - TPPPropEditor* m_props[6]; - SPPInfo m_Params; - TPPPropEditor* m_ActiveShowForm; - float m_Marker; -public: // User declarations - __fastcall TMainForm (TComponent* Owner); - void SetMarkerPosition (float time); - void UpdateGraph (); - void FillPointList (); - void PointListSetTime (int idx, float time); - CPostprocessAnimator* m_Animator; + void __fastcall PointListClick(TObject *Sender); + void __fastcall btnAddKeyClick(TObject *Sender); + void __fastcall btnRemoveKeyClick(TObject *Sender); + void __fastcall ClearAllClick(TObject *Sender); + void __fastcall copyFromClick(TObject *Sender); + void __fastcall PopupCopyFromChange(TObject *Sender, TMenuItem *Source, + bool Rebuild); + void __fastcall PopupClick(TObject *Sender); +private: // User declarations + TPPPropEditor *m_props[6]; + SPPInfo m_Params; + TPPPropEditor *m_ActiveShowForm; + float m_Marker; +public: // User declarations + __fastcall TMainForm(TComponent *Owner); + void SetMarkerPosition(float time); + void UpdateGraph(); + void FillPointList(); + void PointListSetTime(int idx, float time); + CPostprocessAnimator *m_Animator; }; + //--------------------------------------------------------------------------- -extern PACKAGE TMainForm *MainForm; +extern PACKAGE TMainForm * MainForm; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/newdialog.cpp b/src/editors/PPEditor/newdialog.cpp index 5d2dd84e066..263687ad950 100644 --- a/src/editors/PPEditor/newdialog.cpp +++ b/src/editors/PPEditor/newdialog.cpp @@ -8,17 +8,20 @@ #pragma package(smart_init) #pragma resource "*.dfm" TNewEffectDialog *NewEffectDialog; + //--------------------------------------------------------------------------- -__fastcall TNewEffectDialog::TNewEffectDialog(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TNewEffectDialog::TNewEffectDialog(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TNewEffectDialog::TimeChange(TObject *Sender) { - if (Time->Value > 0.0f) - Button1->Enabled = true; + if (Time->Value>0.0f) + Button1->Enabled = true; else - Button1->Enabled = false; + Button1->Enabled = false; } + //--------------------------------------------------------------------------- + + diff --git a/src/editors/PPEditor/newdialog.h b/src/editors/PPEditor/newdialog.h index 08ac1ffeb50..2b1c9e2d0c6 100644 --- a/src/editors/PPEditor/newdialog.h +++ b/src/editors/PPEditor/newdialog.h @@ -8,20 +8,23 @@ #include #include #include + //--------------------------------------------------------------------------- class TNewEffectDialog : public TForm { -__published: // IDE-managed Components - TMultiObjSpinEdit *Time; + __published: // IDE-managed Components + TMultiObjSpinEdit*Time; TMxLabel *RxLabel1; TButton *Button1; TButton *Button2; void __fastcall TimeChange(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TNewEffectDialog(TComponent* Owner); +private: // User declarations +public: // User declarations + __fastcall TNewEffectDialog(TComponent *Owner); }; + //--------------------------------------------------------------------------- -extern PACKAGE TNewEffectDialog *NewEffectDialog; +extern PACKAGE TNewEffectDialog * NewEffectDialog; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/PPEditor/single_param.cpp b/src/editors/PPEditor/single_param.cpp index e2681297111..bfabeeb6e7d 100644 --- a/src/editors/PPEditor/single_param.cpp +++ b/src/editors/PPEditor/single_param.cpp @@ -10,37 +10,37 @@ #pragma link "multi_edit" #pragma link "MXCtrls" #pragma resource "*.dfm" -__fastcall TAddFloatForm::TAddFloatForm(TComponent* Owner, pp_params p) - : TForm(Owner),m_pp_params(p) +__fastcall TAddFloatForm::TAddFloatForm(TComponent *Owner, pp_params p) + : TForm(Owner), m_pp_params(p) { Value1->MinValue = -1; Value1->MaxValue = 1; Value1->Decimal = 2; Value2->Decimal = 2; - Value1->Increment = 0.01f; - Value2->Increment = 0.01f; + Value1->Increment = 0.01f; + Value2->Increment = 0.01f; cmTextureName->Visible = false; - if(m_pp_params==pp_dual_h) + if (m_pp_params==pp_dual_h) { - Label1->Caption = "Duality-H"; - Label2->Caption = "Duality-V"; + Label1->Caption = "Duality-H"; + Label2->Caption = "Duality-V"; Label2->Visible = true; Value2->Visible = true; Value1->MinValue = -1.0f; Value1->MaxValue = 1.0f; Value1->Decimal = 3; - Value1->Increment = 0.001f; + Value1->Increment = 0.001f; Value2->MinValue = -1.0f; Value2->MaxValue = 1.0f; Value2->Decimal = 3; - Value2->Increment = 0.001f; - }else - if(m_pp_params==pp_noise_i) + Value2->Increment = 0.001f; + } + else if (m_pp_params==pp_noise_i) { - Label1->Caption = "Noise Intensity"; - Label2->Caption = "Noise Grain"; - Label3->Caption = "Noise FPS"; + Label1->Caption = "Noise Intensity"; + Label2->Caption = "Noise Grain"; + Label3->Caption = "Noise FPS"; Label2->Visible = true; Value2->Visible = true; @@ -53,10 +53,10 @@ __fastcall TAddFloatForm::TAddFloatForm(TComponent* Owner, pp_params p) Value2->MaxValue = 1000.0f; Value3->MinValue = 1.0f;; Value3->MaxValue = 1000.0f;; - }else - if(m_pp_params==pp_cm_influence) + } + else if (m_pp_params==pp_cm_influence) { - Label1->Caption = "Influence"; + Label1->Caption = "Influence"; Label2->Visible = false; Value2->Visible = false; @@ -68,229 +68,238 @@ __fastcall TAddFloatForm::TAddFloatForm(TComponent* Owner, pp_params p) cmTextureName->Visible = true; }; } + //--------------------------------------------------------------------------- -void TAddFloatForm::Clear() +void TAddFloatForm::Clear() { - Lock(true); - TimeValue->Value = 0.0f; - Value1->Value = 0.0f; - Value2->Value = 0.0f; - Value3->Value = 0.0f; + Lock(true); + TimeValue->Value = 0.0f; + Value1->Value = 0.0f; + Value2->Value = 0.0f; + Value3->Value = 0.0f; cmTextureName->Text = ""; - Lock(false); + Lock(false); } void TAddFloatForm::ShowCurrent(u32 keyIdx) { - if(keyIdx==-1) + if (keyIdx==-1) { - Clear(); + Clear(); return; } - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - float time = cparam->get_key_time(keyIdx); - MainForm->SetMarkerPosition (time); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + float time = cparam->get_key_time(keyIdx); + MainForm->SetMarkerPosition(time); - if(keyIdx>0) - TimeValue->MinValue = cparam->get_key_time(keyIdx-1)+0.02f; - else - TimeValue->MinValue = 0.0f; + if (keyIdx>0) + TimeValue->MinValue = cparam->get_key_time(keyIdx-1)+0.02f; + else + TimeValue->MinValue = 0.0f; - if(cparam->get_keys_count()>keyIdx+1) - TimeValue->MaxValue = cparam->get_key_time(keyIdx+1)-0.02f; - else - TimeValue->MaxValue = 1000.0f; - - TimeValue->Value = time; + if (cparam->get_keys_count()>keyIdx+1) + TimeValue->MaxValue = cparam->get_key_time(keyIdx+1)-0.02f; + else + TimeValue->MaxValue = 1000.0f; - float val; - cparam->get_value (time, val, 0); - Value1->Value = val; + TimeValue->Value = time; - if(m_pp_params==pp_dual_h) + float val; + cparam->get_value(time, val, 0); + Value1->Value = val; + + if (m_pp_params==pp_dual_h) { - cparam = MainForm->m_Animator->GetParam (pp_dual_v); + cparam = MainForm->m_Animator->GetParam(pp_dual_v); - cparam->get_value (time, val, 0); - Value2->Value = val; - }else - if(m_pp_params==pp_noise_i) + cparam->get_value(time, val, 0); + Value2->Value = val; + } + else if (m_pp_params==pp_noise_i) { - cparam = MainForm->m_Animator->GetParam (pp_noise_g); + cparam = MainForm->m_Animator->GetParam(pp_noise_g); - cparam->get_value (time, val, 0); - Value2->Value = val; + cparam->get_value(time, val, 0); + Value2->Value = val; - cparam = MainForm->m_Animator->GetParam (pp_noise_f); + cparam = MainForm->m_Animator->GetParam(pp_noise_f); - cparam->get_value (time, val, 0); - Value3->Value = val; - }else - if(m_pp_params==pp_cm_influence) + cparam->get_value(time, val, 0); + Value3->Value = val; + } + else if (m_pp_params==pp_cm_influence) { - cmTextureName->Text = MainForm->m_Animator->PPinfo().cm_tex1.c_str(); + cmTextureName->Text = MainForm->m_Animator->PPinfo().cm_tex1.c_str(); } } bool TAddFloatForm::DrawChannel(_pp_params p) { - switch(m_pp_params) + switch (m_pp_params) { - case pp_dual_h: return (p==pp_dual_h)||(p==pp_dual_v); - case pp_noise_i: return (p==pp_noise_i)||(p==pp_noise_g)||(p==pp_noise_f); - case pp_cm_influence: return (p==pp_cm_influence); - default:R_ASSERT(0); + case pp_dual_h: return (p==pp_dual_h)||(p==pp_dual_v); + case pp_noise_i: return (p==pp_noise_i)||(p==pp_noise_g)||(p==pp_noise_f); + case pp_cm_influence: return (p==pp_cm_influence); + default: R_ASSERT(0); } return false; } void __fastcall TAddFloatForm::TimeValueExit(TObject *Sender) { - if (m_bLocked) return; - if (MainForm->PointList->ItemIndex == -1) return; - TMultiObjSpinEdit* spin = dynamic_cast(Sender); - if(spin->Color == clLime) + if (m_bLocked) + return; + if (MainForm->PointList->ItemIndex==-1) + return; + TMultiObjSpinEdit *spin = dynamic_cast(Sender); + if (spin->Color==clLime) { - if(TimeValue->ValueMinValue) - TimeValue->Value=TimeValue->MinValue; - if(TimeValue->Value>TimeValue->MaxValue) - TimeValue->Value=TimeValue->MaxValue; + if (TimeValue->ValueMinValue) + TimeValue->Value = TimeValue->MinValue; + if (TimeValue->Value>TimeValue->MaxValue) + TimeValue->Value = TimeValue->MaxValue; + + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + + float time_prev = cparam->get_key_time(MainForm->PointList->ItemIndex); + cparam->delete_value(time_prev); - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); + float time = TimeValue->Value; + cparam->add_value(time, Value1->Value, 0); - float time_prev = cparam->get_key_time(MainForm->PointList->ItemIndex); - cparam->delete_value (time_prev); - - float time = TimeValue->Value; - cparam->add_value (time, Value1->Value, 0); - - if(m_pp_params==pp_dual_h) + if (m_pp_params==pp_dual_h) { - cparam = MainForm->m_Animator->GetParam (pp_dual_v); - cparam->delete_value (time_prev); - cparam->add_value (time, Value2->Value, 0); - }else - if(m_pp_params==pp_noise_i) + cparam = MainForm->m_Animator->GetParam(pp_dual_v); + cparam->delete_value(time_prev); + cparam->add_value(time, Value2->Value, 0); + } + else if (m_pp_params==pp_noise_i) { - cparam = MainForm->m_Animator->GetParam (pp_noise_g); - cparam->delete_value (time_prev); - cparam->add_value (time, Value2->Value, 0); + cparam = MainForm->m_Animator->GetParam(pp_noise_g); + cparam->delete_value(time_prev); + cparam->add_value(time, Value2->Value, 0); - cparam = MainForm->m_Animator->GetParam (pp_noise_f); - cparam->delete_value (time_prev); - cparam->add_value (time, Value3->Value, 0); + cparam = MainForm->m_Animator->GetParam(pp_noise_f); + cparam->delete_value(time_prev); + cparam->add_value(time, Value3->Value, 0); } - MainForm->PointListSetTime (MainForm->PointList->ItemIndex, time); + MainForm->PointListSetTime(MainForm->PointList->ItemIndex, time); MainForm->UpdateGraph(); - spin->Color = clWindow; + spin->Color = clWindow; } } void __fastcall TAddFloatForm::ChangeParam(TObject *Sender) { - if (m_bLocked) return; - if (MainForm->PointList->ItemIndex == -1) return; - TMultiObjSpinEdit* spin = dynamic_cast(Sender); + if (m_bLocked) + return; + if (MainForm->PointList->ItemIndex==-1) + return; + TMultiObjSpinEdit *spin = dynamic_cast(Sender); spin->Color = clLime; } void TAddFloatForm::AddNew(u32 keyIdx) { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - - float time = (keyIdx!=-1)?cparam->get_key_time(keyIdx):0.0f; - MainForm->SetMarkerPosition (time); - time += 0.01f; - CreateKey (time); + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + float time = (keyIdx!=-1) ? cparam->get_key_time(keyIdx) : 0.0f; + MainForm->SetMarkerPosition(time); + time += 0.01f; + CreateKey(time); } void TAddFloatForm::Remove(u32 keyIdx) { - if(keyIdx==-1) return; - - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - - float time = cparam->get_key_time(keyIdx); - - cparam->delete_value (time); - - if(m_pp_params==pp_dual_h) - { - cparam = MainForm->m_Animator->GetParam (pp_dual_v); - cparam->delete_value (time); - }else - if(m_pp_params==pp_noise_i) - { - cparam = MainForm->m_Animator->GetParam (pp_noise_g); - cparam->delete_value (time); - cparam = MainForm->m_Animator->GetParam (pp_noise_f); - cparam->delete_value (time); - }; + if (keyIdx==-1) + return; + + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + + float time = cparam->get_key_time(keyIdx); + + cparam->delete_value(time); + + if (m_pp_params==pp_dual_h) + { + cparam = MainForm->m_Animator->GetParam(pp_dual_v); + cparam->delete_value(time); + } + else if (m_pp_params==pp_noise_i) + { + cparam = MainForm->m_Animator->GetParam(pp_noise_g); + cparam->delete_value(time); + cparam = MainForm->m_Animator->GetParam(pp_noise_f); + cparam->delete_value(time); + }; } -void TAddFloatForm::RemoveAllKeys() +void TAddFloatForm::RemoveAllKeys() { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - cparam->clear_all_keys (); - - if(m_pp_params==pp_dual_h) - { - cparam = MainForm->m_Animator->GetParam (pp_dual_h); - cparam->clear_all_keys (); - }else - if(m_pp_params==pp_noise_i) - { - cparam = MainForm->m_Animator->GetParam (pp_noise_g); - cparam->clear_all_keys (); - - cparam = MainForm->m_Animator->GetParam (pp_noise_f); - cparam->clear_all_keys (); - } + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + cparam->clear_all_keys(); + + if (m_pp_params==pp_dual_h) + { + cparam = MainForm->m_Animator->GetParam(pp_dual_h); + cparam->clear_all_keys(); + } + else if (m_pp_params==pp_noise_i) + { + cparam = MainForm->m_Animator->GetParam(pp_noise_g); + cparam->clear_all_keys(); + + cparam = MainForm->m_Animator->GetParam(pp_noise_f); + cparam->clear_all_keys(); + } } -void TAddFloatForm::CreateKey(float time) +void TAddFloatForm::CreateKey(float time) { - CPostProcessParam* cparam = MainForm->m_Animator->GetParam (GetTimeChannel()); - - cparam->add_value (time, 0.0f, 0); - cparam->update_value (time, 0.33f, 0); - - - if(m_pp_params==pp_dual_h) - { - cparam = MainForm->m_Animator->GetParam (pp_dual_v); - cparam->add_value (time, 0.0f, 0); - cparam->update_value (time, 0.44f, 0); - } - if(m_pp_params==pp_noise_i) - { - cparam = MainForm->m_Animator->GetParam (pp_noise_g); - cparam->add_value (time, 0.0f, 0); - cparam->update_value (time, 0.11f, 0); - - cparam = MainForm->m_Animator->GetParam (pp_noise_f); - cparam->add_value (time, 0.0f, 0); - cparam->update_value (time, 0.22f, 0); - } + CPostProcessParam *cparam = MainForm->m_Animator->GetParam(GetTimeChannel()); + + cparam->add_value(time, 0.0f, 0); + cparam->update_value(time, 0.33f, 0); + + + if (m_pp_params==pp_dual_h) + { + cparam = MainForm->m_Animator->GetParam(pp_dual_v); + cparam->add_value(time, 0.0f, 0); + cparam->update_value(time, 0.44f, 0); + } + if (m_pp_params==pp_noise_i) + { + cparam = MainForm->m_Animator->GetParam(pp_noise_g); + cparam->add_value(time, 0.0f, 0); + cparam->update_value(time, 0.11f, 0); + + cparam = MainForm->m_Animator->GetParam(pp_noise_f); + cparam->add_value(time, 0.0f, 0); + cparam->update_value(time, 0.22f, 0); + } } + //--------------------------------------------------------------------------- void __fastcall TAddFloatForm::TimeValueKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if(Key==VK_RETURN) - TimeValueExit(Sender); + if (Key==VK_RETURN) + TimeValueExit(Sender); } + //--------------------------------------------------------------------------- void __fastcall TAddFloatForm::cmTextureNameChange(TObject *Sender) { MainForm->m_Animator->PPinfo().cm_tex1 = cmTextureName->Text.c_str(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/PPEditor/single_param.h b/src/editors/PPEditor/single_param.h index 7db0a636c41..21cd41dbe66 100644 --- a/src/editors/PPEditor/single_param.h +++ b/src/editors/PPEditor/single_param.h @@ -8,42 +8,58 @@ #include #include #include + //--------------------------------------------------------------------------- class TAddFloatForm : public TForm, public TPPPropEditor { -__published: // IDE-managed Components - TGroupBox *GroupBox1; - TMxLabel *Label1; - TMultiObjSpinEdit *Value1; - TMxLabel *Label2; - TMultiObjSpinEdit *Value2; - TMxLabel *MxLabel2; - TMultiObjSpinEdit *Value3; - TMxLabel *Label3; - TMxLabel *MxLabel1; - TMultiObjSpinEdit *TimeValue; - TEdit *cmTextureName; - void __fastcall ChangeParam(TObject *Sender); - void __fastcall TimeValueExit(TObject *Sender); - void __fastcall TimeValueKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall cmTextureNameChange(TObject *Sender); -private: // User declarations - pp_params m_Param; - _pp_params m_pp_params; - bool m_bLocked; -public: // User declarations - virtual void Lock (bool b){m_bLocked=b;} - __fastcall TAddFloatForm (TComponent* Owner, pp_params param); - - virtual void ShowCurrent (u32 keyIdx); - virtual _pp_params GetTimeChannel () {return m_pp_params;}; - virtual bool DrawChannel (_pp_params p);; - virtual void Clear (); - virtual TForm* GetForm () {return this;}; - virtual void AddNew (u32 keyIdx); - virtual void Remove (u32 keyIdx); - virtual void RemoveAllKeys (); - virtual void CreateKey (float t); + __published: // IDE-managed Components + TGroupBox*GroupBox1; + TMxLabel *Label1; + TMultiObjSpinEdit *Value1; + TMxLabel *Label2; + TMultiObjSpinEdit *Value2; + TMxLabel *MxLabel2; + TMultiObjSpinEdit *Value3; + TMxLabel *Label3; + TMxLabel *MxLabel1; + TMultiObjSpinEdit *TimeValue; + TEdit *cmTextureName; + void __fastcall ChangeParam(TObject *Sender); + void __fastcall TimeValueExit(TObject *Sender); + void __fastcall TimeValueKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall cmTextureNameChange(TObject *Sender); +private: // User declarations + pp_params m_Param; + _pp_params m_pp_params; + bool m_bLocked; +public: // User declarations + virtual void Lock(bool b) + { + m_bLocked = b; + } + + __fastcall TAddFloatForm(TComponent *Owner, pp_params param); + + virtual void ShowCurrent(u32 keyIdx); + + virtual _pp_params GetTimeChannel() + { + return m_pp_params; + }; + + virtual bool DrawChannel(_pp_params p);; + virtual void Clear(); + + virtual TForm *GetForm() + { + return this; + }; + + virtual void AddNew(u32 keyIdx); + virtual void Remove(u32 keyIdx); + virtual void RemoveAllKeys(); + virtual void CreateKey(float t); }; #endif + diff --git a/src/editors/PPEditor/spline.cpp b/src/editors/PPEditor/spline.cpp index b3e33c30f3d..40d5ae584fd 100644 --- a/src/editors/PPEditor/spline.cpp +++ b/src/editors/PPEditor/spline.cpp @@ -10,125 +10,135 @@ //--------------------------------------------------------------------------- - Spline::Spline () -{ -} +Spline::Spline() {} + //--------------------------------------------------------------------------- - Spline::~Spline () +Spline::~Spline() { m_list.clear(); } + //--------------------------------------------------------------------------- -void Spline::add_point (float value, float deriv, float time) +void Spline::add_point(float value, float deriv, float time) { - for (size_t a = 0; a < m_list.size() - 1; a++) - if (time > m_list[a].time && time < m_list[a + 1].time) - { - point pt = {value, deriv, time}; - m_list.insert (m_list.begin() + a); - get_point (a, pt); - return; - } + for (size_t a = 0; am_list[a].time&&time get_full_time ()) return m_list[m_list.size() - 1].value; - if (time < 0.0f) return ((*(m_list.begin())).value); + if (time>get_full_time()) + return m_list[m_list.size()-1].value; + if (time<0.0f) + return ((*(m_list.begin())).value); size_t index; - for (index = 0; index < m_list.size () - 1; index++) - if (time >= m_list[index].time && time <= m_list[index + 1].time) - break; - - float t = (time - m_list[index].time) / (m_list[index + 1].time - m_list[index].time); - float t2 = t * t; - float t3 = t * t2; - return m_list[index].value * (2 * t3 - 3 * t2 + 1) + - m_list[index].deriv * (t3 - 2 * t2 + 0) + - m_list[index + 1].value * (-2 * t3 + 3 * t2) + - m_list[index + 1].deriv * (t3 - t2); - -// f(t) = p1 * (2*t^3 - 3*t^2 + 1) + -// r1 * (t^3 - 2*t^2 + t) + -// p2 * (-2*t^3 + 3*t^2) + -// r2 * (t^3 - t^2). + for (index = 0; index=m_list[index].time&&time<=m_list[index+1].time) + break; + float t = (time-m_list[index].time)/(m_list[index+1].time-m_list[index].time); + float t2 = t*t; + float t3 = t*t2; + return m_list[index].value*(2*t3-3*t2+1)+ + m_list[index].deriv*(t3-2*t2+0)+ + m_list[index+1].value*(-2*t3+3*t2)+ + m_list[index+1].deriv*(t3-t2); + + // f(t) = p1 * (2*t^3 - 3*t^2 + 1) + + // r1 * (t^3 - 2*t^2 + t) + + // p2 * (-2*t^3 + 3*t^2) + + // r2 * (t^3 - t^2). } + //--------------------------------------------------------------------------- -void Spline::get_point (size_t index, point &pt) +void Spline::get_point(size_t index, point &pt) { - if (index >= m_list.size()) index = m_list.size() - 1; - pt = m_list[index]; + if (index>=m_list.size()) + index = m_list.size()-1; + pt = m_list[index]; } diff --git a/src/editors/PPEditor/spline.h b/src/editors/PPEditor/spline.h index 1602ea274c6..2ce10746eae 100644 --- a/src/editors/PPEditor/spline.h +++ b/src/editors/PPEditor/spline.h @@ -9,35 +9,41 @@ using namespace std; typedef struct _point { - float value; //çíà÷åíèå ôóíêöèè - float deriv; //ïðîèçâîäíàÿ - float time; //âðåìÿ + float value; //çíà÷åíèå ôóíêöèè + float deriv; //ïðîèçâîäíàÿ + float time; //âðåìÿ } point; -typedef vector point_list; +typedef vector point_list; typedef vector::iterator point_list_i; class Spline { private: protected: - point_list m_list; - size_t find_point (float time); + point_list m_list; + size_t find_point(float time); public: - Spline (); - ~Spline (); - void add_point (float value, float deriv, float time); - void remove_point (float time); - float get_full_time (); - void reset (); - void clear (); - float get_value (float time); - float get_deriv (float time); - void set_value (float time, float value); - void set_deriv (float time, float deriv); - void create_new (float time); - float calculate_value (float time); - size_t get_points_count () { return m_list.size(); } - void get_point (size_t index, point &pt); + Spline(); + ~Spline(); + void add_point(float value, float deriv, float time); + void remove_point(float time); + float get_full_time(); + void reset(); + void clear(); + float get_value(float time); + float get_deriv(float time); + void set_value(float time, float value); + void set_deriv(float time, float deriv); + void create_new(float time); + float calculate_value(float time); + + size_t get_points_count() + { + return m_list.size(); + } + + void get_point(size_t index, point &pt); }; #endif + diff --git a/src/editors/PPEditor/std.cpp b/src/editors/PPEditor/std.cpp index ac3195a5582..fa2e74a0e27 100644 --- a/src/editors/PPEditor/std.cpp +++ b/src/editors/PPEditor/std.cpp @@ -1,3 +1,3 @@ -#include +#include "xrCore/xrCore.h" #include "PostprocessAnimator.h" - \ No newline at end of file + diff --git a/src/editors/PPEditor/stdafx.h b/src/editors/PPEditor/stdafx.h index 7c46ea68620..8d8f54b5852 100644 --- a/src/editors/PPEditor/stdafx.h +++ b/src/editors/PPEditor/stdafx.h @@ -1,5 +1,5 @@ #define ENGINE_API -#include +#include #include "PostprocessAnimator.h" #include #include From 3c91dd5740d443347c3b7bc138c319d0e88a2611 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 4 Dec 2015 07:07:33 +0500 Subject: [PATCH 07/10] ActorEditor: fixed includes and formatted code --- src/editors/ActorEditor/ActorEditor.cpp | 93 +- src/editors/ActorEditor/BonePart.cpp | 222 +-- src/editors/ActorEditor/BonePart.h | 111 +- src/editors/ActorEditor/BottomBar.cpp | 456 +++--- src/editors/ActorEditor/BottomBar.h | 146 +- src/editors/ActorEditor/ClipEditor.cpp | 1311 ++++++++------- src/editors/ActorEditor/ClipEditor.h | 459 +++--- src/editors/ActorEditor/KeyBar.cpp | 337 ++-- src/editors/ActorEditor/KeyBar.h | 132 +- src/editors/ActorEditor/LeftBar.cpp | 271 ++-- src/editors/ActorEditor/LeftBar.h | 258 +-- src/editors/ActorEditor/Splash.cpp | 10 +- src/editors/ActorEditor/Splash.h | 27 +- src/editors/ActorEditor/TopBar.cpp | 212 ++- src/editors/ActorEditor/TopBar.h | 57 +- src/editors/ActorEditor/UI_ActorMain.cpp | 521 +++--- src/editors/ActorEditor/UI_ActorMain.h | 77 +- src/editors/ActorEditor/UI_ActorTools.cpp | 1406 +++++++++-------- src/editors/ActorEditor/UI_ActorTools.h | 581 ++++--- .../ActorEditor/UI_ActorToolsMotions.cpp | 534 ++++--- .../ActorEditor/UI_ActorToolsProps.cpp | 1254 ++++++++------- src/editors/ActorEditor/UI_ActorToolsUndo.cpp | 124 +- src/editors/ActorEditor/main.cpp | 199 ++- src/editors/ActorEditor/main.h | 83 +- src/editors/ActorEditor/stdafx.h | 68 +- src/editors/LevelEditor/BottomBar.h | 167 +- src/editors/LevelEditor/DOOneColor.h | 48 +- src/editors/LevelEditor/Edit/BuilderCF.cpp | 1 - src/editors/LevelEditor/Edit/ELight_def.h | 35 +- .../LevelEditor/Edit/ESceneAIMapControls.h | 41 +- .../LevelEditor/Edit/ESceneClassList.h | 49 +- .../Edit/ESceneCustomOToolsFactory.cpp | 2 +- .../LevelEditor/Edit/ESceneDummyTools.cpp | 9 +- .../LevelEditor/Edit/ESceneGroupControls.h | 18 +- .../LevelEditor/Edit/ESceneObjectControls.h | 19 +- .../LevelEditor/Edit/EScenePSControls.h | 23 +- .../LevelEditor/Edit/EScenePortalControls.cpp | 12 +- .../LevelEditor/Edit/EScenePortalControls.h | 13 +- .../LevelEditor/Edit/ESceneSectorControls.h | 50 +- .../LevelEditor/Edit/ESceneShapeControls.h | 17 +- .../LevelEditor/Edit/ESceneSoundSrcTools.cpp | 14 +- .../LevelEditor/Edit/ESceneSpawnControls.h | 17 +- .../LevelEditor/Edit/ESceneSpawnTools.h | 110 +- .../LevelEditor/Edit/ESceneWallmarkControls.h | 29 +- src/editors/LevelEditor/Edit/EShape.h | 102 +- src/editors/LevelEditor/Edit/ESound_Source.h | 146 +- src/editors/LevelEditor/Edit/GroupObject.h | 148 +- src/editors/LevelEditor/Edit/LevelGameDef.cpp | 1 + src/editors/LevelEditor/Edit/LevelGameDef.h | 1 + src/editors/LevelEditor/Edit/SceneGraph.h | 514 +++--- src/editors/LevelEditor/Edit/lwchunks.h | 1 + src/editors/LevelEditor/Edit/portal.h | 83 +- src/editors/LevelEditor/Edit/portalutils.h | 77 +- src/editors/LevelEditor/Engine/ShapeData.h | 35 +- src/editors/LevelEditor/Engine/communicate.h | 286 ++-- src/editors/LevelEditor/FrameAIMap.h | 97 +- src/editors/LevelEditor/FrameDetObj.h | 59 +- src/editors/LevelEditor/FrameLight.h | 33 +- src/editors/LevelEditor/FramePortal.h | 37 +- src/editors/LevelEditor/FrameSector.h | 63 +- src/editors/LevelEditor/FrameShape.h | 51 +- src/editors/LevelEditor/FrameWayPoint.h | 59 +- src/editors/LevelEditor/LeftBar.h | 531 +++---- src/editors/LevelEditor/Splash.cpp | 10 +- src/editors/LevelEditor/Splash.h | 27 +- src/editors/LevelEditor/TopBar.h | 63 +- src/editors/LevelEditor/main.h | 79 +- src/editors/LevelEditor/previewimage.h | 29 +- 68 files changed, 6843 insertions(+), 5312 deletions(-) create mode 100644 src/editors/LevelEditor/Edit/LevelGameDef.cpp create mode 100644 src/editors/LevelEditor/Edit/LevelGameDef.h diff --git a/src/editors/ActorEditor/ActorEditor.cpp b/src/editors/ActorEditor/ActorEditor.cpp index 4ce5ced280a..b29ab180601 100644 --- a/src/editors/ActorEditor/ActorEditor.cpp +++ b/src/editors/ActorEditor/ActorEditor.cpp @@ -5,7 +5,7 @@ #include "splash.h" #include "UI_ActorMain.h" #include "UI_ActorTools.h" -#include "../ECore/Editor/LogForm.h" +#include "editors/ECore/Editor/LogForm.h" //--------------------------------------------------------------------------- USEFORM("BonePart.cpp", frmBonePart); USEFORM("KeyBar.cpp", frmKeyBar); @@ -15,74 +15,57 @@ USEFORM("main.cpp", frmMain); USEFORM("TopBar.cpp", fraTopBar); /* TFrame: File Type */ USEFORM("BottomBar.cpp", fraBottomBar); /* TFrame: File Type */ //--------------------------------------------------------------------------- -WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int) +WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int) { + // try{ + if (!Application->Handle) + { + Application->CreateHandle(); + Application->Icon->Handle = LoadIcon(MainInstance, "MAINICON"); + Application->Title = "Loading..."; + } + frmSplash = xr_new((TComponent*)0); + frmSplash->Show(); + frmSplash->Repaint(); + frmSplash->SetStatus("Core initializing..."); + Core._initialize("actor", ELogCallback); + Application->Initialize(); + frmSplash->SetStatus("Loading..."); -// try{ - if (!Application->Handle){ - Application->CreateHandle (); - Application->Icon->Handle = LoadIcon(MainInstance, "MAINICON"); - Application->Title = "Loading..."; - } - frmSplash = xr_new((TComponent*)0); - frmSplash->Show (); - frmSplash->Repaint (); - frmSplash->SetStatus ("Core initializing..."); + // startup create + Tools = xr_new(); + UI = xr_new(); + UI->RegisterCommands(); - Core._initialize ("actor",ELogCallback); + Application->Title = UI->EditorDesc(); + TfrmLog::CreateLog(); - Application->Initialize (); - - frmSplash->SetStatus ("Loading..."); + Application->CreateForm(__classid(TfrmMain), &frmMain); + Application->CreateForm(__classid(TfrmBonePart), &frmBonePart); + frmMain->SetHInst(hInst); -// startup create - Tools = xr_new(); - UI = xr_new(); - UI->RegisterCommands (); + xr_delete(frmSplash); - Application->Title = UI->EditorDesc(); - TfrmLog::CreateLog (); + Application->Run(); - Application->CreateForm(__classid(TfrmMain), &frmMain); - Application->CreateForm(__classid(TfrmBonePart), &frmBonePart); - frmMain->SetHInst (hInst); + TfrmLog::DestroyLog(); - xr_delete (frmSplash); + UI->ClearCommands(); + xr_delete(Tools); + xr_delete(UI); - Application->Run (); - - TfrmLog::DestroyLog (); - - UI->ClearCommands (); - xr_delete (Tools); - xr_delete (UI); - - Core._destroy (); -// } -// catch (Exception &exception) -// { -// Application->ShowException(&exception); -// } + Core._destroy(); + // } + // catch (Exception &exception) + // { + // Application->ShowException(&exception); + // } return 0; } -//--------------------------------------------------------------------------- - - - - - - - - - - - - - - +//--------------------------------------------------------------------------- diff --git a/src/editors/ActorEditor/BonePart.cpp b/src/editors/ActorEditor/BonePart.cpp index 5f60b222fde..f650dbc2d01 100644 --- a/src/editors/ActorEditor/BonePart.cpp +++ b/src/editors/ActorEditor/BonePart.cpp @@ -3,186 +3,228 @@ #include "stdafx.h" #pragma hdrstop -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditObject.h" #include "BonePart.h" #include "Bone.h" #include "UI_ActorTools.h" -#include "../ECore/Editor/UI_Main.h" -#include "../xrEProps/FolderLib.h" +#include "editors/ECore/Editor/UI_Main.h" +#include "editors/xrEProps/FolderLib.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" -TfrmBonePart *frmBonePart; -TElTree* T[4]; -TEdit* E[4]; -TLabel* L[4]; +TfrmBonePart *frmBonePart; +TElTree *T[4]; +TEdit *E[4]; +TLabel *L[4]; + //--------------------------------------------------------------------------- -bool TfrmBonePart::Run(CEditableObject* object) +bool TfrmBonePart::Run(CEditableObject *object) { - int res = mrCancel; - if (object){ + int res = mrCancel; + if (object) + { m_EditObject = object; m_BoneParts = &object->BoneParts(); res = ShowModal(); - }else{ - ELog.DlgMsg(mtError,"Scene empty. Load object first."); + } + else + { + ELog.DlgMsg(mtError, "Scene empty. Load object first."); } return (res==mrOk); } + //--------------------------------------------------------------------------- -__fastcall TfrmBonePart::TfrmBonePart(TComponent* Owner) - : TForm(Owner) +__fastcall TfrmBonePart::TfrmBonePart(TComponent *Owner) + : TForm(Owner) { T[0] = tvPart1; T[1] = tvPart2; T[2] = tvPart3; T[3] = tvPart4; - E[0] = edPart1Name; + E[0] = edPart1Name; E[1] = edPart2Name; E[2] = edPart3Name; E[3] = edPart4Name; L[0] = lbPart1; - L[1] = lbPart2; + L[1] = lbPart2; L[2] = lbPart3; L[3] = lbPart4; } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::FormShow(TObject *Sender) { - FillBoneParts(); - // check window position - UI->CheckWindowPos(this); + FillBoneParts(); + // check window position + UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::FillBoneParts() { - for (int k=0; k<4; k++) T[k]->IsUpdating = true; - for (k=0; k<4; k++){T[k]->Items->Clear();E[k]->Text="";} - for (BPIt it=m_BoneParts->begin(); it!=m_BoneParts->end(); it++){ + for (int k = 0; k<4; k++) + T[k]->IsUpdating = true; + for (k = 0; k<4; k++) + { + T[k]->Items->Clear(); + E[k]->Text = ""; + } + for (BPIt it = m_BoneParts->begin(); it!=m_BoneParts->end(); it++) + { E[it-m_BoneParts->begin()]->Text = it->alias.c_str(); - for (RStringVecIt w_it=it->bones.begin(); w_it!=it->bones.end(); w_it++) - FHelper.AppendObject(T[it-m_BoneParts->begin()],w_it->c_str(),false,true); + for (RStringVecIt w_it = it->bones.begin(); w_it!=it->bones.end(); w_it++) + FHelper.AppendObject(T[it-m_BoneParts->begin()], w_it->c_str(), false, true); } - for (k=0; k<4; k++) T[k]->IsUpdating = false; + for (k = 0; k<4; k++) + T[k]->IsUpdating = false; lbTotalBones->Caption = m_EditObject->BoneCount(); UpdateCount(); } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::UpdateCount() { - for (int k=0; k<4; k++) L[k]->Caption = AnsiString().sprintf("(%d B)",T[k]->Items->Count); + for (int k = 0; k<4; k++) + L[k]->Caption = AnsiString().sprintf("(%d B)", T[k]->Items->Count); } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if (Key==VK_ESCAPE) return; + if (Key==VK_ESCAPE) + return; } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::tvPartStartDrag(TObject *Sender, - TDragObject *&DragObject) + TDragObject *&DragObject) { - for (TElTreeItem* node=((TElTree*)Sender)->GetNextSelected(0); node; node=((TElTree*)Sender)->GetNextSelected(node)) - FDragItems.push_back(node); + for (TElTreeItem *node = ((TElTree*)Sender)->GetNextSelected(0); node; node = ((TElTree*)Sender)->GetNextSelected(node)) + FDragItems.push_back(node); } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::tvPartDragDrop(TObject *Sender, - TObject *Source, int X, int Y) + TObject *Source, int X, int Y) { - for (int k=0; k<(int)FDragItems.size(); k++){ - FHelper.AppendObject(((TElTree*)Sender),FDragItems[k]->Text,false,true); + for (int k = 0; k<(int)FDragItems.size(); k++) + { + FHelper.AppendObject(((TElTree*)Sender), FDragItems[k]->Text, false, true); FDragItems[k]->Delete(); } FDragItems.clear(); UpdateCount(); } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::tvPartDragOver(TObject *Sender, - TObject *Source, int X, int Y, TDragState State, bool &Accept) + TObject *Source, int X, int Y, TDragState State, bool &Accept) { Accept = false; - if (Source == Sender) return; + if (Source==Sender) + return; Accept = true; } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::ebSaveClick(TObject *Sender) { - for (int k=0; k<4; k++){ - if (T[k]->Items->Count&&E[k]->Text.IsEmpty()){ - ELog.DlgMsg(mtError,"Verify parts name."); - return; + for (int k = 0; k<4; k++) + { + if (T[k]->Items->Count&&E[k]->Text.IsEmpty()) + { + ELog.DlgMsg(mtError, "Verify parts name."); + return; } - for (int i=k-1; i>=0; i--){ - if (!T[k]->Items->Count) continue; - if (E[k]->Text.UpperCase()==E[i]->Text.UpperCase()){ - ELog.DlgMsg(mtError,"Unique name required."); + for (int i = k-1; i>=0; i--) + { + if (!T[k]->Items->Count) + continue; + if (E[k]->Text.UpperCase()==E[i]->Text.UpperCase()) + { + ELog.DlgMsg(mtError, "Unique name required."); return; } } } // verify - U8Vec b_use(m_EditObject->BoneCount(),0); - for (k=0; k<4; k++){ - if (T[k]->Items->Count) - for ( TElTreeItem* node = T[k]->Items->GetFirstNode(); node; node = node->GetNext()) - b_use[m_EditObject->FindBoneByNameIdx(AnsiString(node->Text).c_str())]++; + U8Vec b_use(m_EditObject->BoneCount(), 0); + for (k = 0; k<4; k++) + { + if (T[k]->Items->Count) + for (TElTreeItem *node = T[k]->Items->GetFirstNode(); node; node = node->GetNext()) + b_use[m_EditObject->FindBoneByNameIdx(AnsiString(node->Text).c_str())]++; } - for (U8It u_it=b_use.begin(); u_it!=b_use.end(); u_it++) - if (*u_it!=1){ - ELog.DlgMsg (mtError,"Invalid bone part found (missing or duplicate bones)."); - return; + for (U8It u_it = b_use.begin(); u_it!=b_use.end(); u_it++) + if (*u_it!=1) + { + ELog.DlgMsg(mtError, "Invalid bone part found (missing or duplicate bones)."); + return; } - // save - m_BoneParts->clear(); - for (k=0; k<4; k++){ - if (T[k]->Items->Count){ + // save + m_BoneParts->clear(); + for (k = 0; k<4; k++) + { + if (T[k]->Items->Count) + { m_BoneParts->push_back(SBonePart()); - SBonePart& BP = m_BoneParts->back(); + SBonePart &BP = m_BoneParts->back(); BP.alias = E[k]->Text.c_str(); - for ( TElTreeItem* node = T[k]->Items->GetFirstNode(); node; node = node->GetNext()) - BP.bones.push_back(AnsiString(node->Text).c_str()); + for (TElTreeItem *node = T[k]->Items->GetFirstNode(); node; node = node->GetNext()) + BP.bones.push_back(AnsiString(node->Text).c_str()); } } ATools->OnMotionDefsModified(); Close(); ModalResult = mrOk; } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::ebCancelClick(TObject *Sender) { ModalResult = mrCancel; - Close(); + Close(); } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::ExtBtn1Click(TObject *Sender) { - for (int k=0; k<4; k++) T[k]->IsUpdating = true; - for (k=0; k<4; k++){T[k]->Items->Clear();E[k]->Text="";} + for (int k = 0; k<4; k++) + T[k]->IsUpdating = true; + for (k = 0; k<4; k++) + { + T[k]->Items->Clear(); + E[k]->Text = ""; + } E[0]->Text = "default"; - for (BoneIt it=m_EditObject->FirstBone(); it!=m_EditObject->LastBone(); it++) - FHelper.AppendObject(T[0],(*it)->Name().c_str(),false,true); - for (k=0; k<4; k++) T[k]->IsUpdating = false; + for (BoneIt it = m_EditObject->FirstBone(); it!=m_EditObject->LastBone(); it++) + FHelper.AppendObject(T[0], (*it)->Name().c_str(), false, true); + for (k = 0; k<4; k++) + T[k]->IsUpdating = false; UpdateCount(); } + //--------------------------------------------------------------------------- /* void __fastcall TfrmBonePart::ebAllClick(TObject *Sender) { - TExtBtn* B = dynamic_cast(Sender); VERIFY(B); int idx = B->Tag; + TExtBtn* B = dynamic_cast(Sender); VERIFY(B); int idx = B->Tag; T[idx]->IsUpdating = true; T[idx]->Items->Clear(); for (BoneIt it=m_EditObject->FirstBone(); it!=m_EditObject->LastBone(); it++) @@ -193,64 +235,68 @@ void __fastcall TfrmBonePart::ebAllClick(TObject *Sender) */ void __fastcall TfrmBonePart::ebClearClick(TObject *Sender) { - TExtBtn* B = dynamic_cast(Sender); VERIFY(B); int idx = B->Tag; + TExtBtn *B = dynamic_cast(Sender); + VERIFY(B); + int idx = B->Tag; T[idx]->IsUpdating = true; T[idx]->Items->Clear(); T[idx]->IsUpdating = false; UpdateCount(); } -//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- void __fastcall TfrmBonePart::ebSaveToClick(TObject *Sender) { xr_string temp_fn; - if (EFS.GetSaveName( _import_, temp_fn) ) + if (EFS.GetSaveName(_import_, temp_fn)) { - CInifile ini (temp_fn.c_str(), FALSE, FALSE, TRUE); - string64 buff; - for(int i=0; i<4;++i) + CInifile ini(temp_fn.c_str(), FALSE, FALSE, TRUE); + string64 buff; + for (int i = 0; i<4; ++i) { - sprintf (buff,"part_%d",i); + sprintf(buff, "part_%d", i); ini.w_string(buff, "partition_name", E[i]->Text.c_str()); if (T[i]->Items->Count) { - for ( TElTreeItem* node = T[i]->Items->GetFirstNode(); node; node = node->GetNext()) - ini.w_string(buff, AnsiString(node->Text).c_str(), NULL ); - } - } + for (TElTreeItem *node = T[i]->Items->GetFirstNode(); node; node = node->GetNext()) + ini.w_string(buff, AnsiString(node->Text).c_str(), NULL); + } } + } } + //--------------------------------------------------------------------------- void __fastcall TfrmBonePart::ebLoadFromClick(TObject *Sender) { -//. + //. xr_string temp_fn; - if (EFS.GetOpenName ( _import_, temp_fn, false, NULL, 0)) + if (EFS.GetOpenName(_import_, temp_fn, false, NULL, 0)) { - ebClearClick (Sender); - CInifile ini (temp_fn.c_str(), TRUE, TRUE, FALSE); - string64 buff; - for(int i=0; i<4;++i) + ebClearClick(Sender); + CInifile ini(temp_fn.c_str(), TRUE, TRUE, FALSE); + string64 buff; + for (int i = 0; i<4; ++i) { - sprintf (buff,"part_%d",i); + sprintf(buff, "part_%d", i); LPCSTR part_name = ini.r_string(buff, "partition_name"); E[i]->Text = part_name; - CInifile::Sect& S = ini.r_section(buff); + CInifile::Sect &S = ini.r_section(buff); CInifile::SectCIt it = S.Data.begin(); CInifile::SectCIt e = S.Data.end(); for (; it!=e; ++it) { - if( 0!= stricmp(it->first.c_str(), "partition_name") ) + if (0!=stricmp(it->first.c_str(), "partition_name")) { FHelper.AppendObject(T[i], it->first.c_str(), false, true); } } - } } } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ActorEditor/BonePart.h b/src/editors/ActorEditor/BonePart.h index bc269125ec6..792cc98a0aa 100644 --- a/src/editors/ActorEditor/BonePart.h +++ b/src/editors/ActorEditor/BonePart.h @@ -11,64 +11,67 @@ #include "ExtBtn.hpp" #include "ElXPThemedControl.hpp" #include "mxPlacemnt.hpp" + //--------------------------------------------------------------------------- class TfrmBonePart : public TForm { -__published: // IDE-managed Components - TElTree *tvPart1; - TLabel *RxLabel29; - TEdit *edPart1Name; - TElTree *tvPart2; - TLabel *RxLabel1; - TEdit *edPart2Name; - TElTree *tvPart3; - TLabel *RxLabel2; - TEdit *edPart3Name; - TElTree *tvPart4; - TLabel *RxLabel3; - TEdit *edPart4Name; - TExtBtn *ebSave; - TExtBtn *ebCancel; - TFormStorage *fsStorage; - TExtBtn *ExtBtn1; - TLabel *lbPart1; - TLabel *lbPart3; - TLabel *lbPart4; - TLabel *lbPart2; - TLabel *Label1; - TLabel *lbTotalBones; - TExtBtn *ExtBtn2; - TExtBtn *ExtBtn3; - TExtBtn *ExtBtn4; - TExtBtn *ExtBtn5; - TExtBtn *ebSaveTo; - TExtBtn *ebLoadFrom; - void __fastcall FormShow(TObject *Sender); - void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall tvPartDragDrop(TObject *Sender, TObject *Source, int X, - int Y); - void __fastcall tvPartDragOver(TObject *Sender, TObject *Source, int X, - int Y, TDragState State, bool &Accept); - void __fastcall tvPartStartDrag(TObject *Sender, - TDragObject *&DragObject); - void __fastcall ebSaveClick(TObject *Sender); - void __fastcall ebCancelClick(TObject *Sender); - void __fastcall ExtBtn1Click(TObject *Sender); - void __fastcall ebClearClick(TObject *Sender); - void __fastcall ebSaveToClick(TObject *Sender); - void __fastcall ebLoadFromClick(TObject *Sender); -private: // User declarations - xr_vector FDragItems; - CEditableObject* m_EditObject; - BPVec* m_BoneParts; - void __fastcall FillBoneParts(); - void __fastcall UpdateCount(); -public: // User declarations - __fastcall TfrmBonePart(TComponent* Owner); - bool Run(CEditableObject* object); + __published: // IDE-managed Components + TElTree*tvPart1; + TLabel *RxLabel29; + TEdit *edPart1Name; + TElTree *tvPart2; + TLabel *RxLabel1; + TEdit *edPart2Name; + TElTree *tvPart3; + TLabel *RxLabel2; + TEdit *edPart3Name; + TElTree *tvPart4; + TLabel *RxLabel3; + TEdit *edPart4Name; + TExtBtn *ebSave; + TExtBtn *ebCancel; + TFormStorage *fsStorage; + TExtBtn *ExtBtn1; + TLabel *lbPart1; + TLabel *lbPart3; + TLabel *lbPart4; + TLabel *lbPart2; + TLabel *Label1; + TLabel *lbTotalBones; + TExtBtn *ExtBtn2; + TExtBtn *ExtBtn3; + TExtBtn *ExtBtn4; + TExtBtn *ExtBtn5; + TExtBtn *ebSaveTo; + TExtBtn *ebLoadFrom; + void __fastcall FormShow(TObject *Sender); + void __fastcall FormKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall tvPartDragDrop(TObject *Sender, TObject *Source, int X, + int Y); + void __fastcall tvPartDragOver(TObject *Sender, TObject *Source, int X, + int Y, TDragState State, bool &Accept); + void __fastcall tvPartStartDrag(TObject *Sender, + TDragObject *&DragObject); + void __fastcall ebSaveClick(TObject *Sender); + void __fastcall ebCancelClick(TObject *Sender); + void __fastcall ExtBtn1Click(TObject *Sender); + void __fastcall ebClearClick(TObject *Sender); + void __fastcall ebSaveToClick(TObject *Sender); + void __fastcall ebLoadFromClick(TObject *Sender); +private: // User declarations + xr_vector FDragItems; + CEditableObject *m_EditObject; + BPVec *m_BoneParts; + void __fastcall FillBoneParts(); + void __fastcall UpdateCount(); +public: // User declarations + __fastcall TfrmBonePart(TComponent *Owner); + bool Run(CEditableObject *object); }; + //--------------------------------------------------------------------------- -extern PACKAGE TfrmBonePart *frmBonePart; +extern PACKAGE TfrmBonePart * frmBonePart; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ActorEditor/BottomBar.cpp b/src/editors/ActorEditor/BottomBar.cpp index 6ce060c4e94..07d99e80dc7 100644 --- a/src/editors/ActorEditor/BottomBar.cpp +++ b/src/editors/ActorEditor/BottomBar.cpp @@ -12,43 +12,65 @@ //--------------------------------------------------------------------------- #pragma package(smart_init) -#pragma link "ExtBtn" +#pragma link "ExtBtn" #pragma link "MxMenus" #pragma link "mxPlacemnt" -#pragma resource "*.dfm" -TfraBottomBar *fraBottomBar=0; +#pragma resource "*.dfm" +TfraBottomBar *fraBottomBar = 0; + //--------------------------------------------------------------------------- -__fastcall TfraBottomBar::TfraBottomBar(TComponent* Owner) +__fastcall TfraBottomBar::TfraBottomBar(TComponent *Owner) : TFrame(Owner) { DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ClickOptionsMenuItem(TObject *Sender) { - TMenuItem* mi = dynamic_cast(Sender); - if (mi){ + TMenuItem *mi = dynamic_cast(Sender); + if (mi) + { mi->Checked = !mi->Checked; - if (mi==miDrawGrid) ExecCommand(COMMAND_TOGGLE_GRID); - else if (mi==miRenderWithTextures) psDeviceFlags.set(rsRenderTextures,mi->Checked); - else if (mi==miMuteSounds) psDeviceFlags.set(rsMuteSounds,mi->Checked); - else if (mi==miLightScene) psDeviceFlags.set(rsLighting,mi->Checked); - else if (mi==miRenderLinearFilter) psDeviceFlags.set(rsFilterLinear,mi->Checked); - else if (mi==miRenderEdgedFaces) psDeviceFlags.set(rsEdgedFaces,mi->Checked); - else if (mi==miFog) psDeviceFlags.set(rsFog,mi->Checked); - else if (mi==miRealTime) psDeviceFlags.set(rsRenderRealTime,mi->Checked); - else if (mi==miDrawSafeRect) ExecCommand(COMMAND_TOGGLE_SAFE_RECT); - else if (mi==miRenderFillPoint) EDevice.dwFillMode = D3DFILL_POINT; - else if (mi==miRenderFillWireframe) EDevice.dwFillMode = D3DFILL_WIREFRAME; - else if (mi==miRenderFillSolid) EDevice.dwFillMode = D3DFILL_SOLID; - else if (mi==miRenderShadeFlat) EDevice.dwShadeMode = D3DSHADE_FLAT; - else if (mi==miRenderShadeGouraud) EDevice.dwShadeMode = D3DSHADE_GOURAUD; - else if (mi==miRenderHWTransform){ HW.Caps.bForceGPU_SW = !mi->Checked; UI->Resize(); } + if (mi==miDrawGrid) + ExecCommand(COMMAND_TOGGLE_GRID); + else if (mi==miRenderWithTextures) + psDeviceFlags.set(rsRenderTextures, mi->Checked); + else if (mi==miMuteSounds) + psDeviceFlags.set(rsMuteSounds, mi->Checked); + else if (mi==miLightScene) + psDeviceFlags.set(rsLighting, mi->Checked); + else if (mi==miRenderLinearFilter) + psDeviceFlags.set(rsFilterLinear, mi->Checked); + else if (mi==miRenderEdgedFaces) + psDeviceFlags.set(rsEdgedFaces, mi->Checked); + else if (mi==miFog) + psDeviceFlags.set(rsFog, mi->Checked); + else if (mi==miRealTime) + psDeviceFlags.set(rsRenderRealTime, mi->Checked); + else if (mi==miDrawSafeRect) + ExecCommand(COMMAND_TOGGLE_SAFE_RECT); + else if (mi==miRenderFillPoint) + EDevice.dwFillMode = D3DFILL_POINT; + else if (mi==miRenderFillWireframe) + EDevice.dwFillMode = D3DFILL_WIREFRAME; + else if (mi==miRenderFillSolid) + EDevice.dwFillMode = D3DFILL_SOLID; + else if (mi==miRenderShadeFlat) + EDevice.dwShadeMode = D3DSHADE_FLAT; + else if (mi==miRenderShadeGouraud) + EDevice.dwShadeMode = D3DSHADE_GOURAUD; + else if (mi==miRenderHWTransform) + { + HW.Caps.bForceGPU_SW = !mi->Checked; + UI->Resize(); + } } UI->RedrawScene(); ExecCommand(COMMAND_UPDATE_TOOLBAR); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::QualityClick(TObject *Sender) { @@ -56,279 +78,319 @@ void __fastcall TfraBottomBar::QualityClick(TObject *Sender) ((TMenuItem*)Sender)->Checked = true; UI->Resize(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::fsStorageRestorePlacement(TObject *Sender) { // fill mode - if (miRenderFillPoint->Checked) EDevice.dwFillMode=D3DFILL_POINT; - else if (miRenderFillWireframe->Checked)EDevice.dwFillMode=D3DFILL_WIREFRAME; - else if (miRenderFillSolid->Checked) EDevice.dwFillMode=D3DFILL_SOLID; + if (miRenderFillPoint->Checked) + EDevice.dwFillMode = D3DFILL_POINT; + else if (miRenderFillWireframe->Checked) + EDevice.dwFillMode = D3DFILL_WIREFRAME; + else if (miRenderFillSolid->Checked) + EDevice.dwFillMode = D3DFILL_SOLID; // shade mode - if (miRenderShadeFlat->Checked) EDevice.dwShadeMode=D3DSHADE_FLAT; - else if (miRenderShadeGouraud->Checked) EDevice.dwShadeMode=D3DSHADE_GOURAUD; + if (miRenderShadeFlat->Checked) + EDevice.dwShadeMode = D3DSHADE_FLAT; + else if (miRenderShadeGouraud->Checked) + EDevice.dwShadeMode = D3DSHADE_GOURAUD; // hw transform - HW.Caps.bForceGPU_SW = !miRenderHWTransform->Checked; + HW.Caps.bForceGPU_SW = !miRenderHWTransform->Checked; // quality - if (N200->Checked) QualityClick(N200); - else if (N150->Checked) QualityClick(N150); - else if (N125->Checked) QualityClick(N125); - else if (N100->Checked) QualityClick(N100); - else if (N75->Checked) QualityClick(N75); - else if (N50->Checked) QualityClick(N50); - else if (N25->Checked) QualityClick(N25); + if (N200->Checked) + QualityClick(N200); + else if (N150->Checked) + QualityClick(N150); + else if (N125->Checked) + QualityClick(N125); + else if (N100->Checked) + QualityClick(N100); + else if (N75->Checked) + QualityClick(N75); + else if (N50->Checked) + QualityClick(N50); + else if (N25->Checked) + QualityClick(N25); // setup menu miWeather->Clear(); - TMenuItem* mi = xr_new((TComponent*)0); - mi->Caption = "none"; - mi->OnClick = miWeatherClick; - mi->Tag = -1; - mi->Checked = true; - mi->RadioItem = true; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); -/* - // append weathers - CEnvironment::EnvsMapIt _I=g_pGamePersistent->Environment().WeatherCycles.begin(); - CEnvironment::EnvsMapIt _E=g_pGamePersistent->Environment().WeatherCycles.end(); - for (; _I!=_E; _I++) - { - mi = xr_new((TComponent*)0); - mi->Caption = *_I->first; - mi->OnClick = miWeatherClick; - mi->RadioItem = true; - miWeather->Add (mi); - } -*/ - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Reload"; - mi->OnClick = miWeatherClick; - mi->Tag = -2; - miWeather->Add (mi); - - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Properties..."; - mi->OnClick = miWeatherClick; - mi->Tag = -3; - miWeather->Add (mi); - - psDeviceFlags.set (rsEnvironment,FALSE); + TMenuItem *mi = xr_new((TComponent*)0); + mi->Caption = "none"; + mi->OnClick = miWeatherClick; + mi->Tag = -1; + mi->Checked = true; + mi->RadioItem = true; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + /* + // append weathers + CEnvironment::EnvsMapIt _I=g_pGamePersistent->Environment().WeatherCycles.begin(); + CEnvironment::EnvsMapIt _E=g_pGamePersistent->Environment().WeatherCycles.end(); + for (; _I!=_E; _I++) + { + mi = xr_new((TComponent*)0); + mi->Caption = *_I->first; + mi->OnClick = miWeatherClick; + mi->RadioItem = true; + miWeather->Add (mi); + } + */ + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "Reload"; + mi->OnClick = miWeatherClick; + mi->Tag = -2; + miWeather->Add(mi); + + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "Properties..."; + mi->OnClick = miWeatherClick; + mi->Tag = -3; + miWeather->Add(mi); + + psDeviceFlags.set(rsEnvironment, FALSE); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebLogClick(TObject *Sender) { - TfrmLog::ChangeVisible(); + TfrmLog::ChangeVisible(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebStopClick(TObject *Sender) { - ExecCommand(COMMAND_BREAK_LAST_OPERATION); + ExecCommand(COMMAND_BREAK_LAST_OPERATION); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebStatClick(TObject *Sender) { - psDeviceFlags.set(rsStatistic,!psDeviceFlags.is(rsStatistic)); + psDeviceFlags.set(rsStatistic, !psDeviceFlags.is(rsStatistic)); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebOptionsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { POINT pt; GetCursorPos(&pt); - pmOptions->Popup(pt.x,pt.y); - TExtBtn* btn = dynamic_cast(Sender); VERIFY(btn); btn->MouseManualUp(); + pmOptions->Popup(pt.x, pt.y); + TExtBtn *btn = dynamic_cast(Sender); + VERIFY(btn); + btn->MouseManualUp(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::pmOptionsPopup(TObject *Sender) { - miRenderWithTextures->Checked = psDeviceFlags.is(rsRenderTextures); - miLightScene->Checked = psDeviceFlags.is(rsLighting); - miMuteSounds->Checked = psDeviceFlags.is(rsMuteSounds); - miRenderLinearFilter->Checked = psDeviceFlags.is(rsFilterLinear); - miRenderEdgedFaces->Checked = psDeviceFlags.is(rsEdgedFaces); - miRealTime->Checked = psDeviceFlags.is(rsRenderRealTime); - miFog->Checked = psDeviceFlags.is(rsFog); - miDrawGrid->Checked = psDeviceFlags.is(rsDrawGrid); - miDrawSafeRect->Checked = psDeviceFlags.is(rsDrawSafeRect); - - for(int i=0; i < miWeather->Count; ++i) + miRenderWithTextures->Checked = psDeviceFlags.is(rsRenderTextures); + miLightScene->Checked = psDeviceFlags.is(rsLighting); + miMuteSounds->Checked = psDeviceFlags.is(rsMuteSounds); + miRenderLinearFilter->Checked = psDeviceFlags.is(rsFilterLinear); + miRenderEdgedFaces->Checked = psDeviceFlags.is(rsEdgedFaces); + miRealTime->Checked = psDeviceFlags.is(rsRenderRealTime); + miFog->Checked = psDeviceFlags.is(rsFog); + miDrawGrid->Checked = psDeviceFlags.is(rsDrawGrid); + miDrawSafeRect->Checked = psDeviceFlags.is(rsDrawSafeRect); + + for (int i = 0; iCount; ++i) { - TMenuItem* mi = miWeather->Items[i]; + TMenuItem *mi = miWeather->Items[i]; BOOL bch; - bch = ((EPrefs->sWeather.size()) && (0==stricmp(mi->Caption.c_str(), EPrefs->sWeather.c_str()))) || - (mi->Caption=="none" && EPrefs->sWeather.size()==0) ; - mi->Checked = bch; + bch = ((EPrefs->sWeather.size())&&(0==stricmp(mi->Caption.c_str(), EPrefs->sWeather.c_str())))|| + (mi->Caption=="none"&&EPrefs->sWeather.size()==0) ; + mi->Checked = bch; } } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::miWeatherClick(TObject *Sender) { -/* - TMenuItem* mi = dynamic_cast(Sender); - if (mi){ - if (mi->Tag==0) - { - psDeviceFlags.set (rsEnvironment,TRUE); - g_pGamePersistent->Environment().SetWeather(mi->Caption.c_str()); - EPrefs->sWeather = mi->Caption.c_str(); - mi->Checked = !mi->Checked; - }else if (mi->Tag==-1){ - psDeviceFlags.set (rsEnvironment,FALSE); - g_pGamePersistent->Environment().SetWeather(0); - EPrefs->sWeather = ""; - mi->Checked = !mi->Checked; - }else if (mi->Tag==-2){ - Engine.ReloadSettings(); - g_pGamePersistent->Environment().ED_Reload(); - }else if (mi->Tag==-3){ - TProperties* P = TProperties::CreateModalForm("Weather properties"); - CEnvironment& env = g_pGamePersistent->Environment(); - PropItemVec items; - float ft=env.ed_from_time,tt=env.ed_to_time,sp=env.fTimeFactor; - PHelper().CreateTime (items,"From Time", &ft); - PHelper().CreateTime (items,"To Time", &tt); - PHelper().CreateFloat (items,"Speed", &sp, 1.f,10000.f,1.f,1); - - P->AssignItems (items); - if (mrOk==P->ShowPropertiesModal()){ - env.ed_from_time = ft; - env.ed_to_time = tt; - env.fTimeFactor = sp; + /* + TMenuItem* mi = dynamic_cast(Sender); + if (mi){ + if (mi->Tag==0) + { + psDeviceFlags.set (rsEnvironment,TRUE); + g_pGamePersistent->Environment().SetWeather(mi->Caption.c_str()); + EPrefs->sWeather = mi->Caption.c_str(); + mi->Checked = !mi->Checked; + }else if (mi->Tag==-1){ + psDeviceFlags.set (rsEnvironment,FALSE); + g_pGamePersistent->Environment().SetWeather(0); + EPrefs->sWeather = ""; + mi->Checked = !mi->Checked; + }else if (mi->Tag==-2){ + Engine.ReloadSettings(); + g_pGamePersistent->Environment().ED_Reload(); + }else if (mi->Tag==-3){ + TProperties* P = TProperties::CreateModalForm("Weather properties"); + CEnvironment& env = g_pGamePersistent->Environment(); + PropItemVec items; + float ft=env.ed_from_time,tt=env.ed_to_time,sp=env.fTimeFactor; + PHelper().CreateTime (items,"From Time", &ft); + PHelper().CreateTime (items,"To Time", &tt); + PHelper().CreateFloat (items,"Speed", &sp, 1.f,10000.f,1.f,1); + + P->AssignItems (items); + if (mrOk==P->ShowPropertiesModal()){ + env.ed_from_time = ft; + env.ed_to_time = tt; + env.fTimeFactor = sp; + } + TProperties::DestroyForm(P); } - TProperties::DestroyForm(P); } - } -*/ + */ } + //--------------------------------------------------------------------------- void TfraBottomBar::RedrawBar() { - SPBItem* pbi = UI->ProgressLast(); - if (pbi){ - AnsiString txt; - float p,m; - pbi->GetInfo(txt,p,m); + SPBItem*pbi = UI->ProgressLast(); + if (pbi) + { + AnsiString txt; + float p, m; + pbi->GetInfo(txt, p, m); // status line - if (paStatus->Caption!=txt){ - paStatus->Caption = txt; - paStatus->Repaint (); + if (paStatus->Caption!=txt) + { + paStatus->Caption = txt; + paStatus->Repaint(); } // progress - int val = fis_zero(m)?0:(int)((p/m)*100); - if (val!=cgProgress->Progress){ - cgProgress->Progress = val; - cgProgress->Repaint (); + int val = fis_zero(m) ? 0 : (int)((p/m)*100); + if (val!=cgProgress->Progress) + { + cgProgress->Progress = val; + cgProgress->Repaint(); } - if (false==cgProgress->Visible) - cgProgress->Visible = true; - }else{ - if (cgProgress->Visible){ + if (false==cgProgress->Visible) + cgProgress->Visible = true; + } + else + { + if (cgProgress->Visible) + { // status line - paStatus->Caption = ""; - paStatus->Repaint (); - // progress - cgProgress->Visible = false; - cgProgress->Progress = 0; + paStatus->Caption = ""; + paStatus->Repaint(); + // progress + cgProgress->Visible = false; + cgProgress->Progress = 0; } } } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroAssignClick(TObject *Sender) { - ExecCommand(COMMAND_ASSIGN_MACRO,((TMenuItem*)Sender)->Tag,0); + ExecCommand(COMMAND_ASSIGN_MACRO, ((TMenuItem*)Sender)->Tag, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroClearClick(TObject *Sender) { - ExecCommand(COMMAND_ASSIGN_MACRO,((TMenuItem*)Sender)->Tag,xr_string("")); + ExecCommand(COMMAND_ASSIGN_MACRO, ((TMenuItem*)Sender)->Tag, xr_string("")); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroExecuteClick(TObject *Sender) { - ExecCommand(COMMAND_RUN_MACRO,((TMenuItem*)Sender)->Tag,0); + ExecCommand(COMMAND_RUN_MACRO, ((TMenuItem*)Sender)->Tag, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroLogCommandsClick(TObject *Sender) { - ExecCommand(COMMAND_LOG_COMMANDS,((TMenuItem*)Sender)->Checked,0); + ExecCommand(COMMAND_LOG_COMMANDS, ((TMenuItem*)Sender)->Checked, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroEditCommandListClick(TObject *Sender) { - ExecCommand(COMMAND_EDIT_COMMAND_LIST); + ExecCommand(COMMAND_EDIT_COMMAND_LIST); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebMacroMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - SECommand* CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; VERIFY(CMD); + SECommand*CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; + VERIFY(CMD); // fill macroses - pmMacro->Items->Clear(); - TMenuItem* mi; - for (u32 k=0; ksub_commands.size(); ++k){ - SESubCommand* SUB = CMD->sub_commands[k]; - BOOL bValid = !xr_string(SUB->p0).empty(); - mi = xr_new((TComponent*)0); - mi->Caption = AnsiString().sprintf("%d: %s",k+1,bValid?xr_string(SUB->p0).c_str():""); - TMenuItem* e = xr_new((TComponent*)0); - e->Caption = "Execute"; - e->OnClick = MacroExecuteClick; - e->Enabled = bValid; - e->Tag = k; - e->ShortCut = SUB->shortcut.hotkey; - TMenuItem* a = xr_new((TComponent*)0); - a->Caption = "Assign"; - a->OnClick = MacroAssignClick; - a->Tag = k; - TMenuItem* c = xr_new((TComponent*)0); - c->Caption = "Clear"; - c->OnClick = MacroClearClick; - c->Tag = k; - mi->Add (e); - mi->Add (a); - mi->Add (c); + pmMacro->Items->Clear(); + TMenuItem *mi; + for (u32 k = 0; ksub_commands.size(); ++k) + { + SESubCommand*SUB = CMD->sub_commands[k]; + BOOL bValid = !xr_string(SUB->p0).empty(); + mi = xr_new((TComponent*)0); + mi->Caption = AnsiString().sprintf("%d: %s", k+1, bValid ? xr_string(SUB->p0).c_str() : ""); + TMenuItem *e = xr_new((TComponent*)0); + e->Caption = "Execute"; + e->OnClick = MacroExecuteClick; + e->Enabled = bValid; + e->Tag = k; + e->ShortCut = SUB->shortcut.hotkey; + TMenuItem *a = xr_new((TComponent*)0); + a->Caption = "Assign"; + a->OnClick = MacroAssignClick; + a->Tag = k; + TMenuItem *c = xr_new((TComponent*)0); + c->Caption = "Clear"; + c->OnClick = MacroClearClick; + c->Tag = k; + mi->Add(e); + mi->Add(a); + mi->Add(c); pmMacro->Items->Add(mi); } - mi = xr_new((TComponent*)0); - mi->Caption = "-"; + mi = xr_new((TComponent*)0); + mi->Caption = "-"; pmMacro->Items->Add(mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Edit Command List..."; - mi->OnClick = MacroEditCommandListClick; + mi = xr_new((TComponent*)0); + mi->Caption = "Edit Command List..."; + mi->OnClick = MacroEditCommandListClick; pmMacro->Items->Add(mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Log Commands"; - mi->AutoCheck = true; - mi->Checked = AllowLogCommands(); - mi->OnClick = MacroLogCommandsClick; + mi = xr_new((TComponent*)0); + mi->Caption = "Log Commands"; + mi->AutoCheck = true; + mi->Checked = AllowLogCommands(); + mi->OnClick = MacroLogCommandsClick; pmMacro->Items->Add(mi); - // popup menu + // popup menu POINT pt; - GetCursorPos (&pt); - pmMacro->Popup (pt.x,pt.y); - TExtBtn* btn = dynamic_cast(Sender); VERIFY(btn); btn->MouseManualUp(); + GetCursorPos(&pt); + pmMacro->Popup(pt.x, pt.y); + TExtBtn *btn = dynamic_cast(Sender); + VERIFY(btn); + btn->MouseManualUp(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ActorEditor/BottomBar.h b/src/editors/ActorEditor/BottomBar.h index b1b47889d30..439b19ec7ac 100644 --- a/src/editors/ActorEditor/BottomBar.h +++ b/src/editors/ActorEditor/BottomBar.h @@ -14,87 +14,95 @@ #include "CGAUGES.h" #include #include + //--------------------------------------------------------------------------- class ECORE_API TfraBottomBar : public TFrame { -__published: // IDE-managed Components - TFormStorage *fsStorage; - TMxPopupMenu *pmOptions; + __published: // IDE-managed Components + TFormStorage*fsStorage; + TMxPopupMenu *pmOptions; TMenuItem *Quality1; - TMenuItem *N25; - TMenuItem *N50; - TMenuItem *N75; - TMenuItem *N100; - TMenuItem *N125; - TMenuItem *N150; - TMenuItem *N200; + TMenuItem *N25; + TMenuItem *N50; + TMenuItem *N75; + TMenuItem *N100; + TMenuItem *N125; + TMenuItem *N150; + TMenuItem *N200; TMenuItem *N2; TMenuItem *miDrawGrid; - TMenuItem *Render1; - TMenuItem *FillMode1; - TMenuItem *miRenderFillSolid; - TMenuItem *miRenderFillWireframe; - TMenuItem *miRenderFillPoint; - TMenuItem *ShadeMode1; - TMenuItem *miRenderShadeGouraud; - TMenuItem *miRenderShadeFlat; - TMenuItem *miRenderEdgedFaces; - TMenuItem *miRenderHWTransform; - TMenuItem *miRenderLinearFilter; - TMenuItem *miRenderWithTextures; - TMenuItem *N7; - TMenuItem *N8; - TMenuItem *miLightScene; - TMenuItem *miFog; - TMenuItem *miRealTime; + TMenuItem *Render1; + TMenuItem *FillMode1; + TMenuItem *miRenderFillSolid; + TMenuItem *miRenderFillWireframe; + TMenuItem *miRenderFillPoint; + TMenuItem *ShadeMode1; + TMenuItem *miRenderShadeGouraud; + TMenuItem *miRenderShadeFlat; + TMenuItem *miRenderEdgedFaces; + TMenuItem *miRenderHWTransform; + TMenuItem *miRenderLinearFilter; + TMenuItem *miRenderWithTextures; + TMenuItem *N7; + TMenuItem *N8; + TMenuItem *miLightScene; + TMenuItem *miFog; + TMenuItem *miRealTime; TMenuItem *N1; - TPanel *paBottomBar; - TPanel *paInfo; - TPanel *paStatusBar; - TPanel *paTools; - TExtBtn *ebOptions; - TExtBtn *ebLog; - TExtBtn *ebStat; - TExtBtn *ebStop; - TPanel *paStatusLabel; - TPanel *paStatus; - TCGauge *cgProgress; - TPanel *paSel; - TPanel *paGridSquareSize; - TPanel *paUICursor; - TPanel *paCamera; - TMenuItem *miDrawSafeRect; - TMenuItem *miMuteSounds; - TMenuItem *N5; - TMenuItem *miWeather; - TMenuItem *miWeatherNone; - TMenuItem *N6; - TExtBtn *ebMacro; - TMxPopupMenu *pmMacro; + TPanel *paBottomBar; + TPanel *paInfo; + TPanel *paStatusBar; + TPanel *paTools; + TExtBtn *ebOptions; + TExtBtn *ebLog; + TExtBtn *ebStat; + TExtBtn *ebStop; + TPanel *paStatusLabel; + TPanel *paStatus; + TCGauge *cgProgress; + TPanel *paSel; + TPanel *paGridSquareSize; + TPanel *paUICursor; + TPanel *paCamera; + TMenuItem *miDrawSafeRect; + TMenuItem *miMuteSounds; + TMenuItem *N5; + TMenuItem *miWeather; + TMenuItem *miWeatherNone; + TMenuItem *N6; + TExtBtn *ebMacro; + TMxPopupMenu *pmMacro; void __fastcall ClickOptionsMenuItem(TObject *Sender); void __fastcall QualityClick(TObject *Sender); void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall ebLogClick(TObject *Sender); - void __fastcall ebStopClick(TObject *Sender); - void __fastcall ebStatClick(TObject *Sender); - void __fastcall ebOptionsMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall pmOptionsPopup(TObject *Sender); - void __fastcall miWeatherClick(TObject *Sender); - void __fastcall ebMacroMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); -private: // User declarations - void __fastcall MacroAssignClick(TObject *Sender); - void __fastcall MacroClearClick(TObject *Sender); - void __fastcall MacroExecuteClick(TObject *Sender); - void __fastcall MacroLogCommandsClick(TObject *Sender); - void __fastcall MacroEditCommandListClick(TObject *Sender); -public: // User declarations - __fastcall TfraBottomBar(TComponent* Owner); - void RefreshBar(){;} + void __fastcall ebLogClick(TObject *Sender); + void __fastcall ebStopClick(TObject *Sender); + void __fastcall ebStatClick(TObject *Sender); + void __fastcall ebOptionsMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall pmOptionsPopup(TObject *Sender); + void __fastcall miWeatherClick(TObject *Sender); + void __fastcall ebMacroMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); +private: // User declarations + void __fastcall MacroAssignClick(TObject *Sender); + void __fastcall MacroClearClick(TObject *Sender); + void __fastcall MacroExecuteClick(TObject *Sender); + void __fastcall MacroLogCommandsClick(TObject *Sender); + void __fastcall MacroEditCommandListClick(TObject *Sender); +public: // User declarations + __fastcall TfraBottomBar(TComponent *Owner); + + void RefreshBar() + { + ; + } + void RedrawBar(); }; + //--------------------------------------------------------------------------- -extern PACKAGE TfraBottomBar *fraBottomBar; +extern PACKAGE TfraBottomBar * fraBottomBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ActorEditor/ClipEditor.cpp b/src/editors/ActorEditor/ClipEditor.cpp index 6ec331e4e23..bd7e7ef8e02 100644 --- a/src/editors/ActorEditor/ClipEditor.cpp +++ b/src/editors/ActorEditor/ClipEditor.cpp @@ -30,192 +30,208 @@ #pragma link "ElTrackBar" #pragma resource "*.dfm" -static const TColor CLIP_INACTIVE_COLOR = 0x00686868; -static const TColor CLIP_ACTIVE_COLOR = 0x00A1A1A1; -static const TColor CLIP_ACTIVE_DRAG_COLOR = 0x00FFFFFF; -static const TColor BP_INACTIVE_COLOR = 0x00686868; -static const TColor BP_ACTIVE_COLOR = 0x00A1A1A1; -static const TColor BP_ACTIVE_DRAG_COLOR = 0x00FFFFFF; +static const TColor CLIP_INACTIVE_COLOR = 0x00686868; +static const TColor CLIP_ACTIVE_COLOR = 0x00A1A1A1; +static const TColor CLIP_ACTIVE_DRAG_COLOR = 0x00FFFFFF; +static const TColor BP_INACTIVE_COLOR = 0x00686868; +static const TColor BP_ACTIVE_COLOR = 0x00A1A1A1; +static const TColor BP_ACTIVE_DRAG_COLOR = 0x00FFFFFF; -static TShiftState drag_state; -static int drag_obj = 0xFFFF; -static BOOL g_resizing = FALSE; -static int g_X_prev = 0; -static int g_X_dx = 0; +static TShiftState drag_state; +static int drag_obj = 0xFFFF; +static BOOL g_resizing = FALSE; +static int g_X_prev = 0; +static int g_X_dx = 0; -TClipMaker::CUIClip::CUIClip(LPCSTR n, TClipMaker* own, float r_t) +TClipMaker::CUIClip::CUIClip(LPCSTR n, TClipMaker *own, float r_t) { - owner = own; - run_time = r_t; - length = 2.f; - name = n; - idx = -1; - fx_power = 1.f; + owner = own; + run_time = r_t; + length = 2.f; + name = n; + idx = -1; + fx_power = 1.f; } -TClipMaker::CUIClip::~CUIClip() -{ -}; +TClipMaker::CUIClip::~CUIClip() {}; void TClipMaker::CUIClip::SetCycle(LPCSTR name, u16 part, u16 slot) { - if (part==BI_NONE){ - for (int k=0; k<4; k++) cycles[k].set(name,slot); - }else{ - cycles[part].set(name,slot); + if (part==BI_NONE) + { + for (int k = 0; k<4; k++) + cycles[k].set(name, slot); + } + else + { + cycles[part].set(name, slot); } } void TClipMaker::CUIClip::SetFX(LPCSTR name, u16 slot) { - fx.set(name,slot); + fx.set(name, slot); } -IC bool clip_pred(TClipMaker::CUIClip* x, TClipMaker::CUIClip* y) +IC + +bool clip_pred(TClipMaker::CUIClip *x, TClipMaker::CUIClip *y) { - return x->run_timerun_time; + return x->run_timerun_time; }; -IC bool clip_pred_float(float x, TClipMaker::CUIClip* y) +IC + +bool clip_pred_float(float x, TClipMaker::CUIClip *y) { - return xrun_time; + return xrun_time; }; -TClipMaker* TClipMaker::CreateForm() +TClipMaker *TClipMaker::CreateForm() { - return xr_new((TComponent*)0); + return xr_new((TComponent*)0); } -void TClipMaker::DestroyForm(TClipMaker* form) +void TClipMaker::DestroyForm(TClipMaker *form) { - xr_delete(form); + xr_delete(form); } - -void TClipMaker::ShowEditor(CEditableObject* O) + +void TClipMaker::ShowEditor(CEditableObject *O) { - m_CurrentObject = O; VERIFY(O); - Show (); - UpdateClips (); + m_CurrentObject = O; + VERIFY(O); + Show(); + UpdateClips(); UpdateProperties(); } void TClipMaker::HideEditor() { - m_CurrentObject = 0; - Clear (); - Hide (); + m_CurrentObject = 0; + Clear(); + Hide(); } void TClipMaker::Clear() { - m_ClipProps->ClearProperties(); - m_ClipList->ClearList (); - Stop (); - for (UIClipIt it=clips.begin(); it!=clips.end(); it++) - xr_delete (*it); - clips.clear (); - sel_clip = 0; - UpdateClips (true); - m_RTFlags.zero (); + m_ClipProps->ClearProperties(); + m_ClipList->ClearList(); + Stop(); + for (UIClipIt it = clips.begin(); it!=clips.end(); it++) + xr_delete(*it); + clips.clear(); + sel_clip = 0; + UpdateClips(true); + m_RTFlags.zero(); } -__fastcall TClipMaker::TClipMaker(TComponent* Owner) : TForm(Owner) +__fastcall TClipMaker::TClipMaker(TComponent *Owner) : TForm(Owner) { - DEFINE_INI (fsStorage); - m_LB[0] = lbBPName0; - m_LB[1] = lbBPName1; - m_LB[2] = lbBPName2; - m_LB[3] = lbBPName3; - m_TotalLength = 0.f; - m_Zoom = 24.f; - m_CurrentPlayTime=0.f; + DEFINE_INI (fsStorage); + m_LB[0] = lbBPName0; + m_LB[1] = lbBPName1; + m_LB[2] = lbBPName2; + m_LB[3] = lbBPName3; + m_TotalLength = 0.f; + m_Zoom = 24.f; + m_CurrentPlayTime = 0.f; } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::FormCreate(TObject *Sender) { - m_ClipProps = TProperties::CreateForm("Clip Properties",paClipProps,alClient); - m_ClipList = TItemList::CreateForm("Clips",paClipList,alClient,0); - m_ClipList->SetOnItemsFocusedEvent(TOnILItemsFocused(this,&TClipMaker::OnClipItemFocused)); + m_ClipProps = TProperties::CreateForm("Clip Properties", paClipProps, alClient); + m_ClipList = TItemList::CreateForm("Clips", paClipList, alClient, 0); + m_ClipList->SetOnItemsFocusedEvent(TOnILItemsFocused(this, &TClipMaker::OnClipItemFocused)); - EDevice.seqFrame.Add (this); + EDevice.seqFrame.Add(this); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::FormDestroy(TObject *Sender) { - EDevice.seqFrame.Remove(this); - Clear (); - TProperties::DestroyForm(m_ClipProps); - TItemList::DestroyForm (m_ClipList); + EDevice.seqFrame.Remove(this); + Clear(); + TProperties::DestroyForm(m_ClipProps); + TItemList::DestroyForm(m_ClipList); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::FormShow(TObject *Sender) { - UI->CheckWindowPos(this); + UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::FormCloseQuery(TObject *Sender, bool &CanClose) { - CanClose = true; -/* bool bAsk = false; - ClipVec& tgt = m_CurrentObject->Clips(); - if (tgt.size()!=clips.size()) bAsk=true; - else{ - ClipIt t_it = tgt.begin(); - for (UIClipIt s_it=clips.begin(); s_it!=clips.end(); s_it++,t_it++){ - if (!(*s_it)->Equal(*t_it)){ - bAsk = true; - break; + CanClose = true; + /* bool bAsk = false; + ClipVec& tgt = m_CurrentObject->Clips(); + if (tgt.size()!=clips.size()) bAsk=true; + else{ + ClipIt t_it = tgt.begin(); + for (UIClipIt s_it=clips.begin(); s_it!=clips.end(); s_it++,t_it++){ + if (!(*s_it)->Equal(*t_it)){ + bAsk = true; + break; + } } } - } - if (bAsk){ - int res = ELog.DlgMsg(mtConfirmation, "Save changes before quit?"); - switch (res){ - case mrYes:{ - for (ClipIt it=tgt.begin(); it!=tgt.end(); it++) - xr_delete (*it); - tgt.resize(clips.size()); - ClipIt t_it=tgt.begin(); - for (UIClipIt s_it=clips.begin(); s_it!=clips.end(); s_it++,t_it++){ - *t_it = xr_new(); - **t_it= *(CClip*)*s_it; + if (bAsk){ + int res = ELog.DlgMsg(mtConfirmation, "Save changes before quit?"); + switch (res){ + case mrYes:{ + for (ClipIt it=tgt.begin(); it!=tgt.end(); it++) + xr_delete (*it); + tgt.resize(clips.size()); + ClipIt t_it=tgt.begin(); + for (UIClipIt s_it=clips.begin(); s_it!=clips.end(); s_it++,t_it++){ + *t_it = xr_new(); + **t_it= *(CClip*)*s_it; + } + Tools.Modified(); + }break; + case mrNo: break; + case mrCancel: CanClose=false; break; } - Tools.Modified(); - }break; - case mrNo: break; - case mrCancel: CanClose=false; break; } - } -*/ + */ } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::FormClose(TObject *Sender, - TCloseAction &Action) + TCloseAction &Action) { - Stop (); -//. Clear(); + Stop(); + //. Clear(); } + //--------------------------------------------------------------------------- -TClipMaker::CUIClip* TClipMaker::FindClip(int x) +TClipMaker::CUIClip *TClipMaker::FindClip(int x) { - return FindClip(float(x)/m_Zoom); + return FindClip(float(x)/m_Zoom); } + //--------------------------------------------------------------------------- -TClipMaker::CUIClip* TClipMaker::FindClip(float t) +TClipMaker::CUIClip *TClipMaker::FindClip(float t) { - if (clips.empty()) return 0; - UIClipIt it = std::upper_bound(clips.begin(),clips.end(),t,clip_pred_float); - VERIFY (it!=clips.begin()); + if (clips.empty()) + return 0; + UIClipIt it = std::upper_bound(clips.begin(), clips.end(), t, clip_pred_float); + VERIFY(it!=clips.begin()); it--; return *it; } + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -224,141 +240,185 @@ TClipMaker::CUIClip* TClipMaker::FindClip(float t) //. //--------------------------------------------------------------------------- void __fastcall TClipMaker::ClipDragOver(TObject *Sender, - TObject *Source, int X, int Y, TDragState State, bool &Accept) + TObject *Source, int X, int Y, TDragState State, bool &Accept) { Accept = false; - TElTreeDragObject* obj = dynamic_cast(Source); - if (obj){ - TMxPanel* A = dynamic_cast(Sender); - if (A==paClips){ - TElTree* tv = dynamic_cast(obj->Control); - if (tv->SelectedCount){ - for (TElTreeItem* item = tv->GetNextSelected(0); item; item = tv->GetNextSelected(item)){ - ListItem* prop = (ListItem*)item->Tag; - if (prop&&(prop->Type()==emMotion)){ - Accept = true; + TElTreeDragObject *obj = dynamic_cast(Source); + if (obj) + { + TMxPanel *A = dynamic_cast(Sender); + if (A==paClips) + { + TElTree *tv = dynamic_cast(obj->Control); + if (tv->SelectedCount) + { + for (TElTreeItem *item = tv->GetNextSelected(0); item; item = tv->GetNextSelected(item)) + { + ListItem *prop = (ListItem*)item->Tag; + if (prop&&(prop->Type()==emMotion)) + { + Accept = true; } } } } - }else{ - Accept = (Sender==paClips); + } + else + { + Accept = (Sender==paClips); } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ClipDragDrop(TObject *Sender, - TObject *Source, int X, int Y) -{ - VERIFY (Sender==paClips); - CUIClip* tgt = FindClip(X); VERIFY(tgt); - TElTreeDragObject* obj = dynamic_cast(Source); - if (obj){ - TElTree* tv = dynamic_cast(obj->Control); - if (tv->SelectedCount){ - for (TElTreeItem* item = tv->GetNextSelected(0); item; item = tv->GetNextSelected(item)){ - ListItem* prop = (ListItem*)item->Tag; VERIFY(prop); + TObject *Source, int X, int Y) +{ + VERIFY(Sender==paClips); + CUIClip *tgt = FindClip(X); + VERIFY(tgt); + TElTreeDragObject *obj = dynamic_cast(Source); + if (obj) + { + TElTree *tv = dynamic_cast(obj->Control); + if (tv->SelectedCount) + { + for (TElTreeItem *item = tv->GetNextSelected(0); item; item = tv->GetNextSelected(item)) + { + ListItem *prop = (ListItem*)item->Tag; + VERIFY(prop); u16 bp; BOOL fx; - LPCSTR m_name = ATools->ExtractMotionName(prop->Key()); - u16 m_slot = ATools->ExtractMotionSlot(prop->Key()); - if (m_CurrentObject->m_SMotionRefs.size()){ - CMotionDef* SM = ATools->m_RenderObject.FindMotionDef(m_name,m_slot); VERIFY(SM); - bp = SM->bone_or_part; - fx = SM->flags&esmFX; - }else{ - CSMotion* SM = ATools->FindMotion(m_name); VERIFY(SM); - bp = SM->m_BoneOrPart; - fx = SM->m_Flags.is(esmFX); + LPCSTR m_name = ATools->ExtractMotionName(prop->Key()); + u16 m_slot = ATools->ExtractMotionSlot(prop->Key()); + if (m_CurrentObject->m_SMotionRefs.size()) + { + CMotionDef *SM = ATools->m_RenderObject.FindMotionDef(m_name, m_slot); + VERIFY(SM); + bp = SM->bone_or_part; + fx = SM->flags&esmFX; + } + else + { + CSMotion *SM = ATools->FindMotion(m_name); + VERIFY(SM); + bp = SM->m_BoneOrPart; + fx = SM->m_Flags.is(esmFX); } - if (fx){ - tgt->SetFX (m_name,m_slot); - }else{ - tgt->SetCycle (m_name,bp,m_slot); + if (fx) + { + tgt->SetFX(m_name, m_slot); + } + else + { + tgt->SetCycle(m_name, bp, m_slot); } } } - }else{ - float rt = float(X)/m_Zoom-tgt->RunTime(); - if (rtLength()/2.f) sel_clip->run_time = tgt->run_time-EPS_L; - else sel_clip->run_time = tgt->run_time+EPS_L; } - UpdateClips (); + else + { + float rt = float(X)/m_Zoom-tgt->RunTime(); + if (rtLength()/2.f) + sel_clip->run_time = tgt->run_time-EPS_L; + else + sel_clip->run_time = tgt->run_time+EPS_L; + } + UpdateClips(); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ClipStartDrag(TObject *Sender, - TDragObject *&DragObject) + TDragObject *&DragObject) { - TMxPanel* P = dynamic_cast(Sender); VERIFY(P); - drag_obj = P->Tag; - RepaintClips(); + TMxPanel *P = dynamic_cast(Sender); + VERIFY(P); + drag_obj = P->Tag; + RepaintClips(); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ClipEndDrag(TObject *Sender, - TObject *Target, int X, int Y) + TObject *Target, int X, int Y) { - drag_obj = 0xFFFF; - RepaintClips(); + drag_obj = 0xFFFF; + RepaintClips(); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ClipMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { - if (Button==mbLeft){ - SelectClip (FindClip(X)); - if (paClips->Cursor==crHSplit){ - g_resizing = TRUE; - Stop (); - g_X_prev = X; - g_X_dx = X-sel_clip->PRight(); + if (Button==mbLeft) + { + SelectClip(FindClip(X)); + if (paClips->Cursor==crHSplit) + { + g_resizing = TRUE; + Stop(); + g_X_prev = X; + g_X_dx = X-sel_clip->PRight(); RepaintClips(); - }else{ + } + else + { paClips->BeginDrag(false, 2); - } + } } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ClipMouseMove(TObject *Sender, - TShiftState Shift, int X, int Y) -{ - VERIFY (sel_clip); - - TMxPanel* P = dynamic_cast(Sender); - CUIClip* C = FindClip(X); VERIFY(C); - int cX = X-C->PLeft(); - float w0 = float(cX)/C->PWidth(); - int w1 = C->PWidth()-cX; - if ((w0>0.75f)&&(w0<1.f)&&(w1<7)){ - P->Cursor = crHSplit; - }else{ - if (!g_resizing) - P->Cursor = crDefault; + TShiftState Shift, int X, int Y) +{ + VERIFY(sel_clip); + + TMxPanel *P = dynamic_cast(Sender); + CUIClip *C = FindClip(X); + VERIFY(C); + int cX = X-C->PLeft(); + float w0 = float(cX)/C->PWidth(); + int w1 = C->PWidth()-cX; + if ((w0>0.75f)&&(w0<1.f)&&(w1<7)) + { + P->Cursor = crHSplit; + } + else + { + if (!g_resizing) + P->Cursor = crDefault; } - if (g_resizing){ - float dx = float(X-(g_X_prev+g_X_dx))/m_Zoom; - if (!fis_zero(dx)){ - sel_clip->length += dx; - if (sel_clip->length<0.01f) sel_clip->length=0.01f; - g_X_prev = sel_clip->PRight(); - UI->ShowHint (AnsiString().sprintf("Length: %s",FloatTimeToStrTime(sel_clip->Length(),false,true,true,true).c_str())); + if (g_resizing) + { + float dx = float(X-(g_X_prev+g_X_dx))/m_Zoom; + if (!fis_zero(dx)) + { + sel_clip->length += dx; + if (sel_clip->length<0.01f) + sel_clip->length = 0.01f; + g_X_prev = sel_clip->PRight(); + UI->ShowHint(AnsiString().sprintf("Length: %s", FloatTimeToStrTime(sel_clip->Length(), false, true, true, true).c_str())); } - UpdateClips (); + UpdateClips(); } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ClipMouseUp(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - if (Button==mbLeft){ - UI->HideHint (); - g_resizing = FALSE; - UpdateClips (); + if (Button==mbLeft) + { + UI->HideHint(); + g_resizing = FALSE; + UpdateClips(); } } + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -368,88 +428,117 @@ void __fastcall TClipMaker::ClipMouseUp(TObject *Sender, //--------------------------------------------------------------------------- void __fastcall TClipMaker::BPStartDrag(TObject *Sender, TDragObject *&DragObject) { - TMxPanel* P = dynamic_cast(Sender); VERIFY(P); - drag_obj = P->Tag; - RepaintClips(); + TMxPanel *P = dynamic_cast(Sender); + VERIFY(P); + drag_obj = P->Tag; + RepaintClips(); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::BPEndDrag(TObject *Sender, TObject *Target, int X, int Y) { - drag_obj = 0xFFFF; - RepaintClips(); + drag_obj = 0xFFFF; + RepaintClips(); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::BPDragOver(TObject *Sender, TObject *Source, int X, int Y, TDragState State, bool &Accept) { Accept = false; - if (Sender==Source){ - CUIClip* clip = FindClip(X); + if (Sender==Source) + { + CUIClip *clip = FindClip(X); Accept = (clip&&(clip!=sel_clip)); } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::BPDragDrop(TObject *Sender, TObject *Source, - int X, int Y) -{ - TMxPanel* P = dynamic_cast(Source); VERIFY(P); - CUIClip* tgt = FindClip(X); VERIFY(tgt); - CUIClip* src = sel_clip; - if (P->Tag==-2){ - if (drag_state.Contains(ssAlt)){ - std::swap (tgt->fx,src->fx); - }else if (drag_state.Contains(ssCtrl)){ - tgt->fx = src->fx; - }else{ - tgt->fx = src->fx; - src->fx.clear (); + int X, int Y) +{ + TMxPanel *P = dynamic_cast(Source); + VERIFY(P); + CUIClip *tgt = FindClip(X); + VERIFY(tgt); + CUIClip *src = sel_clip; + if (P->Tag==-2) + { + if (drag_state.Contains(ssAlt)) + { + std::swap(tgt->fx, src->fx); + } + else if (drag_state.Contains(ssCtrl)) + { + tgt->fx = src->fx; } - }else{ - if (drag_state.Contains(ssAlt)){ - std::swap (tgt->cycles[P->Tag],src->cycles[P->Tag]); - }else if (drag_state.Contains(ssCtrl)){ + else + { + tgt->fx = src->fx; + src->fx.clear(); + } + } + else + { + if (drag_state.Contains(ssAlt)) + { + std::swap(tgt->cycles[P->Tag], src->cycles[P->Tag]); + } + else if (drag_state.Contains(ssCtrl)) + { tgt->cycles[P->Tag] = src->cycles[P->Tag]; - }else{ + } + else + { tgt->cycles[P->Tag] = src->cycles[P->Tag]; src->cycles[P->Tag].clear(); } } RepaintClips(); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::BPMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) -{ - TMxPanel* P = dynamic_cast(Sender); - if (P){ - if (Button==mbRight){ -// TPoint pt; pt.x = X; pt.y = Y; -// pt=P->ClientToScreen(pt); -// pmClip->Popup(pt.x,pt.y-10); - }else if (Button==mbLeft){ - SelectClip (FindClip(X)); + TMouseButton Button, TShiftState Shift, int X, int Y) +{ + TMxPanel *P = dynamic_cast(Sender); + if (P) + { + if (Button==mbRight) + { + // TPoint pt; pt.x = X; pt.y = Y; + // pt=P->ClientToScreen(pt); + // pmClip->Popup(pt.x,pt.y-10); + } + else if (Button==mbLeft) + { + SelectClip(FindClip(X)); P->BeginDrag(false, 2); - drag_state = Shift; + drag_state = Shift; } } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::BPMouseUp(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - drag_state = Shift; + drag_state = Shift; } + //--------------------------------------------------------------------------- -void __fastcall TClipMaker::OnClipItemFocused(ListItemsVec& items) +void __fastcall TClipMaker::OnClipItemFocused(ListItemsVec &items) { - if (!items.empty()){ - for (ListItemsIt it=items.begin(); it!=items.end(); it++){ - ListItem* prop = *it; + if (!items.empty()) + { + for (ListItemsIt it = items.begin(); it!=items.end(); it++) + { + ListItem *prop = *it; m_ClipList->LockUpdating(); SelectClip((CUIClip*)prop->m_Object); m_ClipList->UnlockUpdating(); @@ -458,90 +547,105 @@ void __fastcall TClipMaker::OnClipItemFocused(ListItemsVec& items) sbBase->HorzScrollBar->Position = sbBase->HorzScrollBar->Range*(sel_clip->RunTime()/m_TotalLength); } } + //------------------------------------------------------------------------------ -void __fastcall TClipMaker::OnNameChange(PropValue* V) +void __fastcall TClipMaker::OnNameChange(PropValue *V) { - VERIFY(sel_clip); + VERIFY(sel_clip); RepaintClips(); } + //------------------------------------------------------------------------------ -void __fastcall TClipMaker::OnClipLengthChange(PropValue* V) +void __fastcall TClipMaker::OnClipLengthChange(PropValue *V) { - UpdateClips (); + UpdateClips(); } + //------------------------------------------------------------------------------ -void __fastcall TClipMaker::OnZoomChange(PropValue* V) +void __fastcall TClipMaker::OnZoomChange(PropValue *V) { - UpdateClips (); + UpdateClips(); } + //--------------------------------------------------------------------------- void TClipMaker::RealUpdateProperties() { - m_RTFlags.set (flRT_UpdateProperties,FALSE); + m_RTFlags.set(flRT_UpdateProperties, FALSE); // clip props - PropItemVec p_items; - PropValue* V = 0; - PHelper().CreateCaption (p_items,"Length", FloatTimeToStrTime(m_TotalLength,true,true,true,true).c_str()); - V=PHelper().CreateFloat (p_items,"Zoom", &m_Zoom, 1.f,1000.f,0.1f,1); - V->OnChangeEvent.bind (this,&TClipMaker::OnZoomChange); - if (sel_clip){ - ListItem* l_owner = m_ClipList->FindItem(*sel_clip->name); VERIFY(l_owner); - V=PHelper().CreateName (p_items,"Current Clip\\Name", &sel_clip->name, l_owner); - V->OnChangeEvent.bind (this,&TClipMaker::OnNameChange); - V=PHelper().CreateFloat (p_items,"Current Clip\\Length",&sel_clip->length, 0.f,10000.f,0.1f,2); - V->OnChangeEvent.bind (this,&TClipMaker::OnClipLengthChange); - for (u16 k=0; k<4; k++){ - AnsiString mname = sel_clip->CycleName(k); - u16 slot = sel_clip->CycleSlot(k); - if (mname.IsEmpty())continue; - CMotionDef* MD = ATools->m_RenderObject.FindMotionDef (mname.c_str(),slot); - CMotion* MI = ATools->m_RenderObject.FindMotionKeys (mname.c_str(),slot); - SBonePart* BP = (k<(u16)m_CurrentObject->BoneParts().size())?&m_CurrentObject->BoneParts()[k]:0; + PropItemVec p_items; + PropValue *V = 0; + PHelper().CreateCaption(p_items, "Length", FloatTimeToStrTime(m_TotalLength, true, true, true, true).c_str()); + V = PHelper().CreateFloat(p_items, "Zoom", &m_Zoom, 1.f, 1000.f, 0.1f, 1); + V->OnChangeEvent.bind(this, &TClipMaker::OnZoomChange); + if (sel_clip) + { + ListItem *l_owner = m_ClipList->FindItem(*sel_clip->name); + VERIFY(l_owner); + V = PHelper().CreateName(p_items, "Current Clip\\Name", &sel_clip->name, l_owner); + V->OnChangeEvent.bind(this, &TClipMaker::OnNameChange); + V = PHelper().CreateFloat(p_items, "Current Clip\\Length", &sel_clip->length, 0.f, 10000.f, 0.1f, 2); + V->OnChangeEvent.bind(this, &TClipMaker::OnClipLengthChange); + for (u16 k = 0; k<4; k++) + { + AnsiString mname = sel_clip->CycleName(k); + u16 slot = sel_clip->CycleSlot(k); + if (mname.IsEmpty()) + continue; + CMotionDef *MD = ATools->m_RenderObject.FindMotionDef(mname.c_str(), slot); + CMotion *MI = ATools->m_RenderObject.FindMotionKeys(mname.c_str(), slot); + SBonePart*BP = (k<(u16)m_CurrentObject->BoneParts().size()) ? &m_CurrentObject->BoneParts()[k] : 0; shared_str tmp; - if (MI) tmp.sprintf("%s [%3.2fs, %s]",mname.c_str(),MI->GetLength()/MD->Speed(),MD->bone_or_part?"stop at end":"looped"); - if (BP) PHelper().CreateCaption (p_items,PrepareKey("Current Clip\\Cycles",BP->alias.c_str()), tmp); - } - if (sel_clip->fx.valid())PHelper().CreateFloat (p_items,PrepareKey("Current Clip\\FXs",*sel_clip->fx.name), &sel_clip->fx_power, 0.f, 1000.f); + if (MI) + tmp.sprintf("%s [%3.2fs, %s]", mname.c_str(), MI->GetLength()/MD->Speed(), MD->bone_or_part ? "stop at end" : "looped"); + if (BP) + PHelper().CreateCaption(p_items, PrepareKey("Current Clip\\Cycles", BP->alias.c_str()), tmp); + } + if (sel_clip->fx.valid()) + PHelper().CreateFloat(p_items, PrepareKey("Current Clip\\FXs", *sel_clip->fx.name), &sel_clip->fx_power, 0.f, 1000.f); } - m_ClipProps->AssignItems(p_items); + m_ClipProps->AssignItems(p_items); } + //--------------------------------------------------------------------------- -void TClipMaker::SelectClip(CUIClip* clip) +void TClipMaker::SelectClip(CUIClip *clip) { - if (sel_clip!=clip){ - AnsiString nm = clip?*clip->name:""; - sel_clip = clip; - m_ClipList->SelectItem(nm.c_str(),true,false,true); - RepaintClips (); + if (sel_clip!=clip) + { + AnsiString nm = clip ? *clip->name : ""; + sel_clip = clip; + m_ClipList->SelectItem(nm.c_str(), true, false, true); + RepaintClips(); UpdateProperties(); } } void TClipMaker::InsertClip() { - shared_str nm; - m_ClipList->GenerateObjectName (nm,0,"clip",true); - CUIClip* clip = xr_new(*nm,this,sel_clip?sel_clip->RunTime()-EPS_L:0); - clips.push_back (clip); - UpdateClips (true,false); - SelectClip (clip); + shared_str nm; + m_ClipList->GenerateObjectName(nm, 0, "clip", true); + CUIClip *clip = xr_new(*nm, this, sel_clip ? sel_clip->RunTime()-EPS_L : 0); + clips.push_back(clip); + UpdateClips(true, false); + SelectClip(clip); } + //--------------------------------------------------------------------------- void TClipMaker::AppendClip() { - shared_str nm; - m_ClipList->GenerateObjectName (nm,0,"clip",true); - CUIClip* clip = xr_new(*nm,this,sel_clip?sel_clip->RunTime()+sel_clip->Length()-EPS_L:0); - clips.push_back (clip); - UpdateClips (true,false); - SelectClip (clip); + shared_str nm; + m_ClipList->GenerateObjectName(nm, 0, "clip", true); + CUIClip *clip = xr_new(*nm, this, sel_clip ? sel_clip->RunTime()+sel_clip->Length()-EPS_L : 0); + clips.push_back(clip); + UpdateClips(true, false); + SelectClip(clip); } + //--------------------------------------------------------------------------- #define CHUNK_ZOOM 0x9000 @@ -549,477 +653,584 @@ void TClipMaker::AppendClip() void TClipMaker::LoadClips() { - bool bRes=true; - if (EFS.GetOpenName("$clips$",m_ClipFName)){ - Clear (); - IReader* F = FS.r_open(m_ClipFName.c_str()); VERIFY(F); - m_ClipFName = EFS.ExcludeBasePath(m_ClipFName.c_str(),FS.get_path("$clips$")->m_Path); - if (F->find_chunk(CHUNK_ZOOM)){ - m_Zoom = F->r_float(); + bool bRes = true; + if (EFS.GetOpenName("$clips$", m_ClipFName)) + { + Clear(); + IReader *F = FS.r_open(m_ClipFName.c_str()); + VERIFY(F); + m_ClipFName = EFS.ExcludeBasePath(m_ClipFName.c_str(), FS.get_path("$clips$")->m_Path); + if (F->find_chunk(CHUNK_ZOOM)) + { + m_Zoom = F->r_float(); } - IReader* C = F->open_chunk(CHUNK_CLIPS); - if(C){ - IReader* M = C->open_chunk(0); - for (int count=1; M; count++) { - CUIClip* clip = xr_new(this,count); - if (!clip->Load(*M)){ - ELog.Msg(mtError,"Unsupported clip version. Load failed."); + IReader *C = F->open_chunk(CHUNK_CLIPS); + if (C) + { + IReader *M = C->open_chunk(0); + for (int count = 1; M; count++) + { + CUIClip *clip = xr_new(this, count); + if (!clip->Load(*M)) + { + ELog.Msg(mtError, "Unsupported clip version. Load failed."); xr_delete(clip); bRes = false; } M->close(); - if (!bRes) break; + if (!bRes) + break; clips.push_back(clip); M = C->open_chunk(count); } - C->close (); - UpdateClips (); + C->close(); + UpdateClips(); } FS.r_close(F); } } + //--------------------------------------------------------------------------- void TClipMaker::SaveClips() { - if (!clips.empty()){ - if (EFS.GetSaveName("$clips$",m_ClipFName)){ - IWriter* F = FS.w_open(m_ClipFName.c_str()); VERIFY(F); - m_ClipFName = EFS.ExcludeBasePath(m_ClipFName.c_str(),FS.get_path("$clips$")->m_Path); - if (F){ + if (!clips.empty()) + { + if (EFS.GetSaveName("$clips$", m_ClipFName)) + { + IWriter *F = FS.w_open(m_ClipFName.c_str()); + VERIFY(F); + m_ClipFName = EFS.ExcludeBasePath(m_ClipFName.c_str(), FS.get_path("$clips$")->m_Path); + if (F) + { F->open_chunk(CHUNK_ZOOM); - F->w_float (m_Zoom); + F->w_float(m_Zoom); F->close_chunk(); - F->open_chunk (CHUNK_CLIPS); + F->open_chunk(CHUNK_CLIPS); int count = 0; - for (UIClipIt c_it=clips.begin(); c_it!=clips.end(); c_it++){ - F->open_chunk(count); count++; + for (UIClipIt c_it = clips.begin(); c_it!=clips.end(); c_it++) + { + F->open_chunk(count); + count++; (*c_it)->Save(*F); F->close_chunk(); } - F->close_chunk (); + F->close_chunk(); FS.w_close(F); - }else{ - Log ("!Can't save clip:",m_ClipFName.c_str()); + } + else + { + Log("!Can't save clip:", m_ClipFName.c_str()); } } - }else{ - ELog.DlgMsg(mtError,"Clip list empty."); + } + else + { + ELog.DlgMsg(mtError, "Clip list empty."); } } + //--------------------------------------------------------------------------- void TClipMaker::RemoveAllClips() { - SelectClip (0); - for (UIClipIt it=clips.begin(); it!=clips.end(); it++) - xr_delete(*it); - clips.clear (); - UpdateClips (); - Stop (); + SelectClip(0); + for (UIClipIt it = clips.begin(); it!=clips.end(); it++) + xr_delete(*it); + clips.clear(); + UpdateClips(); + Stop(); } + //--------------------------------------------------------------------------- -void TClipMaker::RemoveClip(CUIClip* clip) -{ - if (clip){ - Stop (); - UIClipIt it = std::find(clips.begin(),clips.end(),clip); - if (it!=clips.end()){ - UIClipIt p_it = it; p_it++; - if ((p_it==clips.end())&&(clips.size()>1)){ p_it=it; p_it--;} - CUIClip* C = p_it==clips.end()?0:*p_it; - xr_delete (*it); - clips.erase (it); - SelectClip (C); - UpdateClips (); +void TClipMaker::RemoveClip(CUIClip *clip) +{ + if (clip) + { + Stop(); + UIClipIt it = std::find(clips.begin(), clips.end(), clip); + if (it!=clips.end()) + { + UIClipIt p_it = it; + p_it++; + if ((p_it==clips.end())&&(clips.size()>1)) + { + p_it = it; + p_it--; + } + CUIClip *C = p_it==clips.end() ? 0 : *p_it; + xr_delete(*it); + clips.erase(it); + SelectClip(C); + UpdateClips(); } } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::gtClipPaint(TObject *Sender) { - TCanvas* canvas = gtClip->Canvas; - canvas->Font->Name = "MS Sans Serif"; - canvas->Font->Style = TFontStyles(); - canvas->Pen->Color = clBlack; - canvas->Pen->Width = 1; - canvas->Pen->Style = psSolid; - for (UIClipIt it=clips.begin(); it!=clips.end(); it++){ - canvas->MoveTo ((*it)->PLeft(), 0); - canvas->LineTo ((*it)->PLeft(), 6); - AnsiString s = AnsiString().sprintf("%2.1f",(*it)->RunTime()); - float dx = 2.f; - float dy = canvas->TextHeight(s); - TRect R = TRect((*it)->PLeft()+1-dx, 20-dy, (*it)->PRight()-dx, 20); - canvas->TextRect(R,R.Left,R.Top,s); - } - if (!clips.empty()){ - CUIClip* C = clips.back(); - canvas->MoveTo (C->PRight()-1, 0); - canvas->LineTo (C->PRight()-1, 6); - AnsiString s = AnsiString().sprintf("%2.1f",m_TotalLength); - float dx = canvas->TextWidth(s); - float dy = canvas->TextHeight(s); - TRect R = TRect(C->PRight()-dx, 20-dy, C->PRight(), 20); - canvas->TextRect(R,R.Left,R.Top,s); + TCanvas *canvas = gtClip->Canvas; + canvas->Font->Name = "MS Sans Serif"; + canvas->Font->Style = TFontStyles(); + canvas->Pen->Color = clBlack; + canvas->Pen->Width = 1; + canvas->Pen->Style = psSolid; + for (UIClipIt it = clips.begin(); it!=clips.end(); it++) + { + canvas->MoveTo((*it)->PLeft(), 0); + canvas->LineTo((*it)->PLeft(), 6); + AnsiString s = AnsiString().sprintf("%2.1f", (*it)->RunTime()); + float dx = 2.f; + float dy = canvas->TextHeight(s); + TRect R = TRect((*it)->PLeft()+1-dx, 20-dy, (*it)->PRight()-dx, 20); + canvas->TextRect(R, R.Left, R.Top, s); } -/* if (g_resizing){ - canvas->Pen->Color = clGreen; - canvas->MoveTo (g_X_cur, 0); - canvas->LineTo (g_X_cur, gtClip->Width); + if (!clips.empty()) + { + CUIClip *C = clips.back(); + canvas->MoveTo(C->PRight()-1, 0); + canvas->LineTo(C->PRight()-1, 6); + AnsiString s = AnsiString().sprintf("%2.1f", m_TotalLength); + float dx = canvas->TextWidth(s); + float dy = canvas->TextHeight(s); + TRect R = TRect(C->PRight()-dx, 20-dy, C->PRight(), 20); + canvas->TextRect(R, R.Left, R.Top, s); } -*/ - if (m_RTFlags.is(flRT_Playing)){ - canvas->Pen->Color = clRed; - canvas->MoveTo (m_CurrentPlayTime*m_Zoom, 0); - canvas->LineTo (m_CurrentPlayTime*m_Zoom, gtClip->Width); + /* if (g_resizing){ + canvas->Pen->Color = clGreen; + canvas->MoveTo (g_X_cur, 0); + canvas->LineTo (g_X_cur, gtClip->Width); + } + */ + if (m_RTFlags.is(flRT_Playing)) + { + canvas->Pen->Color = clRed; + canvas->MoveTo(m_CurrentPlayTime*m_Zoom, 0); + canvas->LineTo(m_CurrentPlayTime*m_Zoom, gtClip->Width); } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ClipPaint(TObject *Sender) { - TMxPanel* P = dynamic_cast(Sender); VERIFY(P); - TCanvas* canvas = P->Canvas; - canvas->Font->Name = "MS Sans Serif"; - canvas->Font->Style = TFontStyles(); + TMxPanel *P = dynamic_cast(Sender); + VERIFY(P); + TCanvas *canvas = P->Canvas; + canvas->Font->Name = "MS Sans Serif"; + canvas->Font->Style = TFontStyles(); canvas->Font->Color = clBlack; - canvas->Pen->Color = clBlack; - canvas->Pen->Style = psSolid; - canvas->Brush->Style= bsSolid; - for (UIClipIt it=clips.begin(); it!=clips.end(); it++){ - TRect R = TRect((*it)->PLeft(), 1, (*it)->PRight()-1, paClips->Height); - canvas->Pen->Width = 1; - canvas->Brush->Color= (*it==sel_clip)?(drag_obj==P->Tag?CLIP_ACTIVE_DRAG_COLOR:CLIP_ACTIVE_COLOR):CLIP_INACTIVE_COLOR; - canvas->Rectangle (R); - R.Top += 1; - R.Bottom -= 1; - R.Left += 1; - R.Right -= 1; - canvas->TextRect (R,R.Left,R.Top,*(*it)->name); + canvas->Pen->Color = clBlack; + canvas->Pen->Style = psSolid; + canvas->Brush->Style = bsSolid; + for (UIClipIt it = clips.begin(); it!=clips.end(); it++) + { + TRect R = TRect((*it)->PLeft(), 1, (*it)->PRight()-1, paClips->Height); + canvas->Pen->Width = 1; + canvas->Brush->Color = (*it==sel_clip) ? (drag_obj==P->Tag ? CLIP_ACTIVE_DRAG_COLOR : CLIP_ACTIVE_COLOR) : CLIP_INACTIVE_COLOR; + canvas->Rectangle(R); + R.Top += 1; + R.Bottom -= 1; + R.Left += 1; + R.Right -= 1; + canvas->TextRect(R, R.Left, R.Top, *(*it)->name); } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::BPOnPaint(TObject *Sender) { - TMxPanel* bp = dynamic_cast(Sender); VERIFY(bp); - CEditableObject* O = m_CurrentObject; VERIFY(O); - TCanvas* canvas = bp->Canvas; - canvas->Font->Name = "MS Sans Serif"; - canvas->Font->Style = TFontStyles(); + TMxPanel *bp = dynamic_cast(Sender); + VERIFY(bp); + CEditableObject*O = m_CurrentObject; + VERIFY(O); + TCanvas *canvas = bp->Canvas; + canvas->Font->Name = "MS Sans Serif"; + canvas->Font->Style = TFontStyles(); canvas->Font->Color = clBlack; - canvas->Pen->Color = clBlack; - canvas->Pen->Style = psSolid; - canvas->Brush->Style= bsSolid; - if (-2==bp->Tag){ - for (UIClipIt it=clips.begin(); it!=clips.end(); it++){ - canvas->Brush->Color= (*it==sel_clip)?(drag_obj==bp->Tag?BP_ACTIVE_DRAG_COLOR:BP_ACTIVE_COLOR):BP_INACTIVE_COLOR; - TRect R = TRect((*it)->PLeft(), 1, (*it)->PRight()-1, 15); - AnsiString fx_name = (*it)->FXName(); - if (!fx_name.IsEmpty()){ - canvas->Rectangle (R); - R.Top += 1; - R.Bottom -= 1; - R.Left += 1; - R.Right -= 1; - canvas->TextRect (R,R.Left,R.Top,fx_name); + canvas->Pen->Color = clBlack; + canvas->Pen->Style = psSolid; + canvas->Brush->Style = bsSolid; + if (-2==bp->Tag) + { + for (UIClipIt it = clips.begin(); it!=clips.end(); it++) + { + canvas->Brush->Color = (*it==sel_clip) ? (drag_obj==bp->Tag ? BP_ACTIVE_DRAG_COLOR : BP_ACTIVE_COLOR) : BP_INACTIVE_COLOR; + TRect R = TRect((*it)->PLeft(), 1, (*it)->PRight()-1, 15); + AnsiString fx_name = (*it)->FXName(); + if (!fx_name.IsEmpty()) + { + canvas->Rectangle(R); + R.Top += 1; + R.Bottom -= 1; + R.Left += 1; + R.Right -= 1; + canvas->TextRect(R, R.Left, R.Top, fx_name); } } - }else if ((bp->Tag>=0)&&(bp->Tag<(int)O->BoneParts().size())){ - AnsiString mn_prev = ""; - for (UIClipIt it=clips.begin(); it!=clips.end(); it++){ - AnsiString mn = (*it)->CycleName(u16(bp->Tag)); - TRect R = TRect((*it)->PLeft(), 1, (*it)->PRight()-1, 15); - if (!mn.IsEmpty()){ - canvas->Brush->Color= (*it==sel_clip)?(drag_obj==bp->Tag?BP_ACTIVE_DRAG_COLOR:BP_ACTIVE_COLOR):BP_INACTIVE_COLOR; - canvas->Rectangle (R); - R.Top += 1; - R.Bottom -= 1; - R.Left += 1; - R.Right -= 1; - canvas->TextRect (R,R.Left,R.Top,mn); - mn_prev = mn; - }else if (!mn_prev.IsEmpty()){ - canvas->MoveTo ((*it)->PLeft()+1,13); - canvas->LineTo (R.Right,13); - canvas->LineTo (R.Width()>5?R.Right-5:R.Right-R.Width(),8); - R.Top += 1; - R.Bottom -= 1; - R.Left += 1; - R.Right -= 1; + } + else if ((bp->Tag>=0)&&(bp->Tag<(int)O->BoneParts().size())) + { + AnsiString mn_prev = ""; + for (UIClipIt it = clips.begin(); it!=clips.end(); it++) + { + AnsiString mn = (*it)->CycleName(u16(bp->Tag)); + TRect R = TRect((*it)->PLeft(), 1, (*it)->PRight()-1, 15); + if (!mn.IsEmpty()) + { + canvas->Brush->Color = (*it==sel_clip) ? (drag_obj==bp->Tag ? BP_ACTIVE_DRAG_COLOR : BP_ACTIVE_COLOR) : BP_INACTIVE_COLOR; + canvas->Rectangle(R); + R.Top += 1; + R.Bottom -= 1; + R.Left += 1; + R.Right -= 1; + canvas->TextRect(R, R.Left, R.Top, mn); + mn_prev = mn; + } + else if (!mn_prev.IsEmpty()) + { + canvas->MoveTo((*it)->PLeft()+1, 13); + canvas->LineTo(R.Right, 13); + canvas->LineTo(R.Width()>5 ? R.Right-5 : R.Right-R.Width(), 8); + R.Top += 1; + R.Bottom -= 1; + R.Left += 1; + R.Right -= 1; } } } } + //--------------------------------------------------------------------------- void TClipMaker::RealRepaintClips() { - m_RTFlags.set (flRT_RepaintClips,FALSE); + m_RTFlags.set(flRT_RepaintClips, FALSE); // repaint - paClips->Repaint (); - gtClip->Repaint (); - paBP0->Repaint (); - paBP1->Repaint (); - paBP2->Repaint (); - paBP3->Repaint (); - paFXs->Repaint (); - - // set BP name - CEditableObject* O = m_CurrentObject; - u32 k = 0; - if (O){ - BPVec& bps = O->BoneParts(); + paClips->Repaint(); + gtClip->Repaint(); + paBP0->Repaint(); + paBP1->Repaint(); + paBP2->Repaint(); + paBP3->Repaint(); + paFXs->Repaint(); + + // set BP name + CEditableObject*O = m_CurrentObject; + u32 k = 0; + if (O) + { + BPVec &bps = O->BoneParts(); for (; kCaption = bps[k].alias.c_str(); + m_LB[k]->Caption = bps[k].alias.c_str(); } - for (; k<4; k++) m_LB[k]->Caption = "-"; - UpdateProperties (); + for (; k<4; k++) + m_LB[k]->Caption = "-"; + UpdateProperties(); } + //--------------------------------------------------------------------------- void TClipMaker::RealUpdateClips() { - m_RTFlags.set (flRT_UpdateClips,FALSE); - m_TotalLength = 0.f; - std::sort (clips.begin(),clips.end(),clip_pred); - for (UIClipIt it=clips.begin(); it!=clips.end(); it++){ - (*it)->run_time = m_TotalLength; - m_TotalLength += (*it)->length; - (*it)->idx = it-clips.begin(); + m_RTFlags.set(flRT_UpdateClips, FALSE); + m_TotalLength = 0.f; + std::sort(clips.begin(), clips.end(), clip_pred); + for (UIClipIt it = clips.begin(); it!=clips.end(); it++) + { + (*it)->run_time = m_TotalLength; + m_TotalLength += (*it)->length; + (*it)->idx = it-clips.begin(); } - paFrame->Width = m_TotalLength*m_Zoom; + paFrame->Width = m_TotalLength*m_Zoom; timeTrackBar->Width = paFrame->Width; timeTrackBar->Min = 0; timeTrackBar->Max = m_TotalLength*10000; - Stop (); + Stop(); // clip list - ListItemsVec l_items; - for (it=clips.begin(); it!=clips.end(); it++) - LHelper().CreateItem (l_items,*(*it)->name,0,0,*it); - m_ClipList->AssignItems (l_items,true); - // select default clip - if (!clips.empty()&&(sel_clip==0)) - SelectClip(clips[0]); + ListItemsVec l_items; + for (it = clips.begin(); it!=clips.end(); it++) + LHelper().CreateItem(l_items, *(*it)->name, 0, 0, *it); + m_ClipList->AssignItems(l_items, true); + // select default clip + if (!clips.empty()&&(sel_clip==0)) + SelectClip(clips[0]); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::fsStorageRestorePlacement(TObject *Sender) { - m_ClipProps->RestoreParams (fsStorage); - int idx = fsStorage->ReadInteger("sel_clip",0); - if (idx<(int)clips.size()) SelectClip(clips[idx]); + m_ClipProps->RestoreParams(fsStorage); + int idx = fsStorage->ReadInteger("sel_clip", 0); + if (idx<(int)clips.size()) + SelectClip(clips[idx]); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::fsStorageSavePlacement(TObject *Sender) { - m_ClipProps->SaveParams(fsStorage); - fsStorage->WriteInteger ("sel_clip",sel_clip?sel_clip->idx:0); + m_ClipProps->SaveParams(fsStorage); + fsStorage->WriteInteger("sel_clip", sel_clip ? sel_clip->idx : 0); } + //--------------------------------------------------------------------------- -void TClipMaker::PlayAnimation(CUIClip* clip) +void TClipMaker::PlayAnimation(CUIClip *clip) { - for (u32 k=0; kBoneParts().size(); k++) - if (clip->cycles[k].valid()) - ATools->m_RenderObject.PlayCycle(*clip->cycles[k].name,k,clip->cycles[k].slot); - if (clip->fx.valid()) ATools->m_RenderObject.PlayFX(*clip->fx.name,clip->fx_power,clip->fx.slot); + for (u32 k = 0; kBoneParts().size(); k++) + if (clip->cycles[k].valid()) + ATools->m_RenderObject.PlayCycle(*clip->cycles[k].name, k, clip->cycles[k].slot); + if (clip->fx.valid()) + ATools->m_RenderObject.PlayFX(*clip->fx.name, clip->fx_power, clip->fx.slot); } + //--------------------------------------------------------------------------- void TClipMaker::OnFrame() { - if (m_RTFlags.is(flRT_UpdateClips)) - RealUpdateClips(); - if (m_RTFlags.is(flRT_RepaintClips)) - RealRepaintClips(); + if (m_RTFlags.is(flRT_UpdateClips)) + RealUpdateClips(); + if (m_RTFlags.is(flRT_RepaintClips)) + RealRepaintClips(); if (m_RTFlags.is(flRT_UpdateProperties)) - RealUpdateProperties(); - if (m_RTFlags.is(flRT_Playing)){ - // playing + RealUpdateProperties(); + if (m_RTFlags.is(flRT_Playing)) + { + // playing VERIFY(play_clip(clips[play_clip]->RunTime()+clips[play_clip]->Length())){ - play_clip++; - if (play_clip>=clips.size()){ - if (m_RTFlags.is(flRT_PlayingLooped)){ - play_clip=0; - }else{ - Stop(); + if (m_CurrentPlayTime>(clips[play_clip]->RunTime()+clips[play_clip]->Length())) + { + play_clip++; + if (play_clip>=clips.size()) + { + if (m_RTFlags.is(flRT_PlayingLooped)) + { + play_clip = 0; + } + else + { + Stop(); } } - if (m_RTFlags.is(flRT_Playing)) PlayAnimation(clips[play_clip]); + if (m_RTFlags.is(flRT_Playing)) + PlayAnimation(clips[play_clip]); } - // play onframe - if (m_CurrentPlayTime>m_TotalLength) m_CurrentPlayTime-=m_TotalLength; - m_CurrentPlayTime+=EDevice.fTimeDelta; + // play onframe + if (m_CurrentPlayTime>m_TotalLength) + m_CurrentPlayTime -= m_TotalLength; + m_CurrentPlayTime += EDevice.fTimeDelta; timeTrackBar->Position = m_CurrentPlayTime*10000; gtClip->Repaint(); } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebInsertClipClick(TObject *Sender) { - InsertClip (); + InsertClip(); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebAppendClipClick(TObject *Sender) { - AppendClip (); + AppendClip(); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebLoadClipsClick(TObject *Sender) { - LoadClips (); + LoadClips(); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebSaveClipsClick(TObject *Sender) { - SaveClips (); + SaveClips(); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebSyncClick(TObject *Sender) { - if (ATools->IsEngineMode()){ - for (UIClipIt c_it=clips.begin(); c_it!=clips.end(); c_it++){ + if (ATools->IsEngineMode()) + { + for (UIClipIt c_it = clips.begin(); c_it!=clips.end(); c_it++) + { float len = 0.f; - for (u16 k=0; k<4; k++){ - AnsiString mname = (*c_it)->CycleName(k); - u16 slot = (*c_it)->CycleSlot(k); - CMotion* MI = ATools->m_RenderObject.FindMotionKeys (mname.c_str(),slot); - CMotionDef* MD = ATools->m_RenderObject.FindMotionDef (mname.c_str(),slot); - if (MI){ - float new_len = (MD->StopAtEnd()?MI->GetLength()-SAMPLE_SPF:MI->GetLength())/MD->Speed(); - if (lenCycleName(k); + u16 slot = (*c_it)->CycleSlot(k); + CMotion *MI = ATools->m_RenderObject.FindMotionKeys(mname.c_str(), slot); + CMotionDef *MD = ATools->m_RenderObject.FindMotionDef(mname.c_str(), slot); + if (MI) + { + float new_len = (MD->StopAtEnd() ? MI->GetLength()-SAMPLE_SPF : MI->GetLength())/MD->Speed(); + if (lenlength = fis_zero(len)?2.f:len; + } + (*c_it)->length = fis_zero(len) ? 2.f : len; } - UpdateClips (); - }else{ - ELog.DlgMsg(mtInformation,"Time syncronize only in Engine Mode."); + UpdateClips(); + } + else + { + ELog.DlgMsg(mtInformation, "Time syncronize only in Engine Mode."); } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebPrevClipClick(TObject *Sender) { - if (sel_clip){ - UIClipIt it = std::find(clips.begin(),clips.end(),sel_clip); - if (it!=clips.begin()){ - it--; + if (sel_clip) + { + UIClipIt it = std::find(clips.begin(), clips.end(), sel_clip); + if (it!=clips.begin()) + { + it--; SelectClip(*it); - } + } } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebNextClipClick(TObject *Sender) { - if (sel_clip){ - UIClipIt it = std::find(clips.begin(),clips.end(),sel_clip); - if (it!=clips.end()){ - it++; - if (it!=clips.end()) - SelectClip(*it); - } + if (sel_clip) + { + UIClipIt it = std::find(clips.begin(), clips.end(), sel_clip); + if (it!=clips.end()) + { + it++; + if (it!=clips.end()) + SelectClip(*it); + } } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebPlayClick(TObject *Sender) { - Play (FALSE); + Play(FALSE); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebPlayCycleClick(TObject *Sender) { - Play (TRUE); + Play(TRUE); } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebStopClick(TObject *Sender) { - Stop (); + Stop(); } + //--------------------------------------------------------------------------- void TClipMaker::Play(BOOL bLoop) { - if (ATools->IsEngineMode()){ - if (!ATools->m_RenderObject.m_pVisual){ + if (ATools->IsEngineMode()) + { + if (!ATools->m_RenderObject.m_pVisual) + { Log("!Empty visual."); - }else{ - if (sel_clip){ - m_RTFlags.set (flRT_Playing,TRUE); - m_RTFlags.set (flRT_PlayingLooped,bLoop); - play_clip = sel_clip->idx; - m_CurrentPlayTime=sel_clip->run_time; - PlayAnimation (sel_clip); + } + else + { + if (sel_clip) + { + m_RTFlags.set(flRT_Playing, TRUE); + m_RTFlags.set(flRT_PlayingLooped, bLoop); + play_clip = sel_clip->idx; + m_CurrentPlayTime = sel_clip->run_time; + PlayAnimation(sel_clip); } } - }else{ - ELog.DlgMsg(mtInformation,"Motions play only in Engine Mode."); + } + else + { + ELog.DlgMsg(mtInformation, "Motions play only in Engine Mode."); } } + //--------------------------------------------------------------------------- void TClipMaker::Stop() { - if (m_RTFlags.is(flRT_Playing)){ - m_RTFlags.set (flRT_Playing,FALSE); - m_CurrentPlayTime=0.f; - RepaintClips (); + if (m_RTFlags.is(flRT_Playing)) + { + m_RTFlags.set(flRT_Playing, FALSE); + m_CurrentPlayTime = 0.f; + RepaintClips(); ATools->m_RenderObject.StopAnimation(); } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebTrashClick(TObject *Sender) { - if (!clips.empty()) - if (mrYes==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo, "Remove selected clip?")) - RemoveClip (sel_clip); + if (!clips.empty()) + if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<(Source); - Accept = !!P; + Accept = false; + TMxPanel *P = dynamic_cast(Source); + Accept = !!P; } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebTrashDragDrop(TObject *Sender, - TObject *Source, int X, int Y) -{ - TMxPanel* P = dynamic_cast(Source); - if (P==paClips){ - RemoveClip(sel_clip); - }else{ - if (P->Tag==-2) sel_clip->fx.clear(); - else sel_clip->cycles[P->Tag].clear(); + TObject *Source, int X, int Y) +{ + TMxPanel *P = dynamic_cast(Source); + if (P==paClips) + { + RemoveClip(sel_clip); + } + else + { + if (P->Tag==-2) + sel_clip->fx.clear(); + else + sel_clip->cycles[P->Tag].clear(); UpdateClips(); } } + //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebClearClick(TObject *Sender) { - if (mrYes==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbCancel, "Remove all clips?")) - Clear(); + if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<m_Zoom;} - int PLeft (){return run_time*owner->m_Zoom;} - int PRight (){return PLeft()+PWidth();} - float Length (){return length;} - float RunTime (){return run_time;} - AnsiString CycleName (u16 bp){VERIFY(bp<4); return *cycles[bp].name;} - u16 CycleSlot (u16 bp){VERIFY(bp<4); return cycles[bp].slot; } - AnsiString FXName () { return *fx.name; } - u16 FXSlot () { return fx.slot; } - void SetCycle (LPCSTR name, u16 part, u16 slot); - void SetFX (LPCSTR name, u16 slot); + CUIClip(LPCSTR name, TClipMaker *owner, float r_t); + + CUIClip(TClipMaker *own, float r_t) + { + owner = own; + run_time = r_t; + fx_power = 1.f; + } + + ~CUIClip(); + + int PWidth() + { + return length*owner->m_Zoom; + } + + int PLeft() + { + return run_time*owner->m_Zoom; + } + + int PRight() + { + return PLeft()+PWidth(); + } + + float Length() + { + return length; + } + + float RunTime() + { + return run_time; + } + + AnsiString CycleName(u16 bp) + { + VERIFY(bp<4); + return *cycles[bp].name; + } + + u16 CycleSlot(u16 bp) + { + VERIFY(bp<4); + return cycles[bp].slot; + } + + AnsiString FXName() + { + return *fx.name; + } + + u16 FXSlot() + { + return fx.slot; + } + + void SetCycle(LPCSTR name, u16 part, u16 slot); + void SetFX(LPCSTR name, u16 slot); }; + protected: - enum{ - flRT_RepaintClips = (1<<0), - flRT_UpdateProperties = (1<<1), - flRT_UpdateClips = (1<<2), - flRT_Playing = (1<<3), - flRT_PlayingLooped = (1<<4), + enum + { + flRT_RepaintClips = (1<<0), + flRT_UpdateProperties = (1<<1), + flRT_UpdateClips = (1<<2), + flRT_Playing = (1<<3), + flRT_PlayingLooped = (1<<4), }; - Flags32 m_RTFlags; - - TMxLabel* m_LB[4]; - CEditableObject* m_CurrentObject; - - DEFINE_VECTOR (CUIClip*,UIClipVec,UIClipIt); - UIClipVec clips; - CUIClip* sel_clip; - u32 play_clip; - TProperties* m_ClipProps; - TItemList* m_ClipList; - - void PlayAnimation (CUIClip* clip); - - void RemoveAllClips (); - void LoadClips (); - void SaveClips (); - void InsertClip (); - void AppendClip (); - void RemoveClip (CUIClip* clip); - void SelectClip (CUIClip* clip); - - CUIClip* FindClip (float t); - CUIClip* FindClip (int x); - - void RealRepaintClips(); - void RepaintClips (bool bForced=false){m_RTFlags.set(flRT_RepaintClips,TRUE); if(bForced) RealRepaintClips(); } - void RealUpdateProperties(); - void UpdateProperties(bool bForced=false){m_RTFlags.set(flRT_UpdateProperties,TRUE); if(bForced) RealUpdateProperties(); } - void RealUpdateClips (); - void UpdateClips (bool bForced=false, bool bRepaint=true){m_RTFlags.set(flRT_UpdateClips,TRUE); m_RTFlags.set(flRT_RepaintClips,bRepaint); if(bForced) RealUpdateClips(); } - - void Clear (); - - void __stdcall OnZoomChange (PropValue* V); - void __stdcall OnNameChange (PropValue* V); - void __stdcall OnClipLengthChange (PropValue* V); - - void __stdcall OnClipItemFocused (ListItemsVec& items); + + Flags32 m_RTFlags; + + TMxLabel *m_LB[4]; + CEditableObject *m_CurrentObject; + + DEFINE_VECTOR(CUIClip *, UIClipVec, UIClipIt); + UIClipVec clips; + CUIClip *sel_clip; + u32 play_clip; + TProperties *m_ClipProps; + TItemList *m_ClipList; + + void PlayAnimation(CUIClip *clip); + + void RemoveAllClips(); + void LoadClips(); + void SaveClips(); + void InsertClip(); + void AppendClip(); + void RemoveClip(CUIClip *clip); + void SelectClip(CUIClip *clip); + + CUIClip *FindClip(float t); + CUIClip *FindClip(int x); + + void RealRepaintClips(); + + void RepaintClips(bool bForced = false) + { + m_RTFlags.set(flRT_RepaintClips, TRUE); + if (bForced) + RealRepaintClips(); + } + + void RealUpdateProperties(); + + void UpdateProperties(bool bForced = false) + { + m_RTFlags.set(flRT_UpdateProperties, TRUE); + if (bForced) + RealUpdateProperties(); + } + + void RealUpdateClips(); + + void UpdateClips(bool bForced = false, bool bRepaint = true) + { + m_RTFlags.set(flRT_UpdateClips, TRUE); + m_RTFlags.set(flRT_RepaintClips, bRepaint); + if (bForced) + RealUpdateClips(); + } + + void Clear(); + + void __stdcall OnZoomChange(PropValue *V); + void __stdcall OnNameChange(PropValue *V); + void __stdcall OnClipLengthChange(PropValue *V); + + void __stdcall OnClipItemFocused(ListItemsVec &items); public: - float m_CurrentPlayTime; - float m_TotalLength; - float m_Zoom; + float m_CurrentPlayTime; + float m_TotalLength; + float m_Zoom; - void Play (BOOL bLoop); - void Stop (); -public: // User declarations - __fastcall TClipMaker (TComponent* Owner); + void Play(BOOL bLoop); + void Stop(); +public: // User declarations + __fastcall TClipMaker(TComponent *Owner); - static TClipMaker* CreateForm (); - static void DestroyForm (TClipMaker* form); + static TClipMaker *CreateForm(); + static void DestroyForm(TClipMaker *form); - void ShowEditor (CEditableObject* O); - void HideEditor (); + void ShowEditor(CEditableObject *O); + void HideEditor(); - virtual void OnFrame (void); + virtual void OnFrame(void); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ActorEditor/KeyBar.cpp b/src/editors/ActorEditor/KeyBar.cpp index f0fa6a47438..97e80f959b8 100644 --- a/src/editors/ActorEditor/KeyBar.cpp +++ b/src/editors/ActorEditor/KeyBar.cpp @@ -19,53 +19,56 @@ #pragma link "ElPopBtn" #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfrmKeyBar::TfrmKeyBar(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfrmKeyBar::TfrmKeyBar(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- -TfrmKeyBar* TfrmKeyBar::CreateKeyBar(TWinControl* parent) +TfrmKeyBar *TfrmKeyBar::CreateKeyBar(TWinControl *parent) { - TfrmKeyBar* B = xr_new(parent); - B->Parent= parent; + TfrmKeyBar *B = xr_new(parent); + B->Parent = parent; B->Align = alBottom; - B->Show (); + B->Show(); return B; } void __fastcall TfrmKeyBar::seLODLWChange(TObject *Sender, int Val) { - ATools->m_RenderObject.m_fLOD = seLOD->Value; + ATools->m_RenderObject.m_fLOD = seLOD->Value; } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::seLODKeyPress(TObject *Sender, char &Key) { - if (Key==VK_RETURN) ATools->m_RenderObject.m_fLOD = seLOD->Value; + if (Key==VK_RETURN) + ATools->m_RenderObject.m_fLOD = seLOD->Value; } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::seLODExit(TObject *Sender) { - ATools->m_RenderObject.m_fLOD = seLOD->Value; + ATools->m_RenderObject.m_fLOD = seLOD->Value; } + //--------------------------------------------------------------------------- void TfrmKeyBar::UpdateBar() { - seLOD->Value = ATools->m_RenderObject.m_fLOD; - float a,b,c; - ATools->GetStatTime (a,b,c); - stStartTime->Caption = AnsiString().sprintf("%3.2f",a); - stEndTime->Caption = AnsiString().sprintf("%3.2f",b); - lbCurrentTime->Caption = AnsiString().sprintf("%3.2f",c); - anm_track->Min = iFloor(a*1000); - anm_track->Max = iFloor(b*1000); - - if(auto_ch->Checked) - anm_track->Position = iFloor(c*1000); - - if(m_currentEditMotion != ATools->GetCurrentMotion()) + seLOD->Value = ATools->m_RenderObject.m_fLOD; + float a, b, c; + ATools->GetStatTime(a, b, c); + stStartTime->Caption = AnsiString().sprintf("%3.2f", a); + stEndTime->Caption = AnsiString().sprintf("%3.2f", b); + lbCurrentTime->Caption = AnsiString().sprintf("%3.2f", c); + anm_track->Min = iFloor(a*1000); + anm_track->Max = iFloor(b*1000); + + if (auto_ch->Checked) + anm_track->Position = iFloor(c*1000); + + if (m_currentEditMotion!=ATools->GetCurrentMotion()) { PanelCh1->Repaint(); PanelCh2->Repaint(); @@ -73,38 +76,35 @@ void TfrmKeyBar::UpdateBar() PanelCh4->Repaint(); } - m_currentEditMotion = ATools->GetCurrentMotion(); + m_currentEditMotion = ATools->GetCurrentMotion(); - bool bMarksPresent12 = (m_currentEditMotion && m_currentEditMotion->marks.size()>=2); - bool bMarksPresent34 = (m_currentEditMotion && m_currentEditMotion->marks.size()==4); + bool bMarksPresent12 = (m_currentEditMotion&&m_currentEditMotion->marks.size()>=2); + bool bMarksPresent34 = (m_currentEditMotion&&m_currentEditMotion->marks.size()==4); - PanelCh1->Visible = bMarksPresent12 || ((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar12 || ((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar34; - PanelCh2->Visible = bMarksPresent12 || ((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar12 || ((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar34; - PanelCh3->Visible = bMarksPresent34 || ((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar34; - PanelCh4->Visible = bMarksPresent34 || ((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar34; + PanelCh1->Visible = bMarksPresent12||((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar12||((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar34; + PanelCh2->Visible = bMarksPresent12||((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar12||((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar34; + PanelCh3->Visible = bMarksPresent34||((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar34; + PanelCh4->Visible = bMarksPresent34||((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar34; - PanelCh1->Enabled = bMarksPresent12; - PanelCh2->Enabled = bMarksPresent12; - PanelCh3->Enabled = bMarksPresent34; - PanelCh4->Enabled = bMarksPresent34; + PanelCh1->Enabled = bMarksPresent12; + PanelCh2->Enabled = bMarksPresent12; + PanelCh3->Enabled = bMarksPresent34; + PanelCh4->Enabled = bMarksPresent34; int h = 24; - if(bMarksPresent34 || ((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar34) - h+=60 ; //(4x15) - else - if(bMarksPresent12 || ((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar12) - h+=30 ; //(2x15) - + if (bMarksPresent34||((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar34) + h += 60 ; //(4x15) + else if (bMarksPresent12||((CAEPreferences*)EPrefs)->bAlwaysShowKeyBar12) + h += 30 ; //(2x15) - if(ClientHeight != h) - ClientHeight = h; - + if (ClientHeight!=h) + ClientHeight = h; } -void TfrmKeyBar::draw_marks (int i) +void TfrmKeyBar::draw_marks(int i) { - if(m_currentEditMotion != ATools->GetCurrentMotion()) + if (m_currentEditMotion!=ATools->GetCurrentMotion()) { PanelCh1->Repaint(); PanelCh2->Repaint(); @@ -112,271 +112,284 @@ void TfrmKeyBar::draw_marks (int i) PanelCh4->Repaint(); } - m_currentEditMotion = ATools->GetCurrentMotion(); + m_currentEditMotion = ATools->GetCurrentMotion(); - if(!m_currentEditMotion) - return; + if (!m_currentEditMotion) + return; - if(m_currentEditMotion->marks.size()==0) - return; + if (m_currentEditMotion->marks.size()==0) + return; - if(m_currentEditMotion->marks.size() < (u32)(i+1) ) - return; + if (m_currentEditMotion->marks.size()<(u32)(i+1)) + return; - motion_marks& M = m_currentEditMotion->marks[i]; + motion_marks &M = m_currentEditMotion->marks[i]; - TMxPanel* P = NULL; - if(i==0) - P = PanelCh1; - else - if(i==1) - P = PanelCh2; - else - if(i==2) - P = PanelCh3; - else - if(i==3) - P = PanelCh4; - R_ASSERT (P); + TMxPanel *P = NULL; + if (i==0) + P = PanelCh1; + else if (i==1) + P = PanelCh2; + else if (i==2) + P = PanelCh3; + else if (i==3) + P = PanelCh4; + R_ASSERT(P); - TCanvas* C = P->Canvas; + TCanvas *C = P->Canvas; - Ivector2 start_offset; - TPoint _shift_track; - _shift_track = anm_track->ClientToScreen(TPoint(0,0)); + Ivector2 start_offset; + TPoint _shift_track; + _shift_track = anm_track->ClientToScreen(TPoint(0, 0)); - TPoint _shift_panel; - _shift_panel = P->ClientToScreen(TPoint(0,0)); + TPoint _shift_panel; + _shift_panel = P->ClientToScreen(TPoint(0, 0)); - start_offset.set (_shift_track.x + anm_track->OffsetLeft - _shift_panel.x, 1); + start_offset.set(_shift_track.x+anm_track->OffsetLeft-_shift_panel.x, 1); Ivector2 border_size; - border_size.set (anm_track->Width - anm_track->OffsetLeft - anm_track->OffsetRight, 13); - C->Pen->Style = psSolid; - C->Pen->Color = Graphics::clGray; - C->Rectangle ( start_offset.x, - start_offset.y, - start_offset.x+border_size.x, - start_offset.y+border_size.y); + border_size.set(anm_track->Width-anm_track->OffsetLeft-anm_track->OffsetRight, 13); + C->Pen->Style = psSolid; + C->Pen->Color = Graphics::clGray; + C->Rectangle(start_offset.x, + start_offset.y, + start_offset.x+border_size.x, + start_offset.y+border_size.y); - float a,b,c; - ATools->GetStatTime (a,b,c); - float motion_length = b-a; - float k_len = border_size.x/motion_length; + float a, b, c; + ATools->GetStatTime(a, b, c); + float motion_length = b-a; + float k_len = border_size.x/motion_length; - motion_marks::C_ITERATOR it = M.intervals.begin(); - motion_marks::C_ITERATOR it_e = M.intervals.end(); + motion_marks::C_ITERATOR it = M.intervals.begin(); + motion_marks::C_ITERATOR it_e = M.intervals.end(); - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - const motion_marks::interval& iv = *it; - Ivector2 posLT,posRB; - posLT.set (iFloor(iv.first*k_len), 2); - posRB.set (iFloor(iv.second*k_len), 11); - - posLT.add (start_offset); - posRB.add (start_offset); - - C->Pen->Color = Graphics::clRed; - C->Brush->Color = Graphics::clGreen; - C->Rectangle ( posLT.x, - posLT.y, - posRB.x, - posRB.y); + const motion_marks::interval &iv = *it; + Ivector2 posLT, posRB; + posLT.set(iFloor(iv.first*k_len), 2); + posRB.set(iFloor(iv.second*k_len), 11); + + posLT.add(start_offset); + posRB.add(start_offset); + + C->Pen->Color = Graphics::clRed; + C->Brush->Color = Graphics::clGreen; + C->Rectangle(posLT.x, + posLT.y, + posRB.x, + posRB.y); } } -bool interval_comparer(const motion_marks::interval& i1, const motion_marks::interval& i2) +bool interval_comparer(const motion_marks::interval &i1, const motion_marks::interval &i2) { - return (i1.firstGetCurrentMotion(); + m_currentEditMotion = ATools->GetCurrentMotion(); - if(!m_currentEditMotion) - return; + if (!m_currentEditMotion) + return; - if(m_currentEditMotion->marks.size()==0) - return; + if (m_currentEditMotion->marks.size()==0) + return; - motion_marks& M = m_currentEditMotion->marks[id]; - float a,b,c; - ATools->GetStatTime (a,b,c); - float cur_time = c-a; + motion_marks &M = m_currentEditMotion->marks[id]; + float a, b, c; + ATools->GetStatTime(a, b, c); + float cur_time = c-a; - motion_marks::ITERATOR it = M.intervals.begin(); - motion_marks::ITERATOR it_e = M.intervals.end(); + motion_marks::ITERATOR it = M.intervals.begin(); + motion_marks::ITERATOR it_e = M.intervals.end(); - if(action==3) + if (action==3) { //del current - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - motion_marks::interval& iv = *it; - if(iv.firstcur_time) + motion_marks::interval &iv = *it; + if (iv.firstcur_time) { M.intervals.erase(it); break; } } - }else - if(action==2) + } + else if (action==2) {//up - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - motion_marks::interval& iv = *it; - if(iv.firstcur_time) + motion_marks::interval &iv = *it; + if (iv.firstcur_time) { - iv.second = cur_time; + iv.second = cur_time; break; } } - }else - if(action==1) + } + else if (action==1) {//down - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - motion_marks::interval& iv = *it; - if(iv.firstcur_time) + motion_marks::interval &iv = *it; + if (iv.firstcur_time) { - iv.first = cur_time; + iv.first = cur_time; break; } } - if(it==it_e) + if (it==it_e) {//insert new - M.intervals.push_back(motion_marks::interval(cur_time, b-a)); + M.intervals.push_back(motion_marks::interval(cur_time, b-a)); } } - std::sort (M.intervals.begin(), M.intervals.end(), interval_comparer); - PanelCh1->Repaint (); - PanelCh2->Repaint (); - PanelCh3->Repaint (); - PanelCh4->Repaint (); + std::sort(M.intervals.begin(), M.intervals.end(), interval_comparer); + PanelCh1->Repaint(); + PanelCh2->Repaint(); + PanelCh3->Repaint(); + PanelCh4->Repaint(); } void __fastcall TfrmKeyBar::BtnUpCh1Click(TObject *Sender) { - set_mark(0,2); + set_mark(0, 2); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnUpCh2Click(TObject *Sender) { - set_mark(1,2); + set_mark(1, 2); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnUpCh3Click(TObject *Sender) { - set_mark(2,2); + set_mark(2, 2); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnUpCh4Click(TObject *Sender) { - set_mark(3,2); + set_mark(3, 2); } //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnDownCh1Click(TObject *Sender) { - set_mark(0,1); + set_mark(0, 1); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnDownCh2Click(TObject *Sender) { - set_mark(1,1); + set_mark(1, 1); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnDownCh3Click(TObject *Sender) { - set_mark(2,1); + set_mark(2, 1); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnDownCh4Click(TObject *Sender) { - set_mark(3,1); + set_mark(3, 1); } //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnDelCh1Click(TObject *Sender) { - set_mark(0,3); + set_mark(0, 3); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnDelCh2Click(TObject *Sender) { - set_mark(1,3); + set_mark(1, 3); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnDelCh3Click(TObject *Sender) { - set_mark(2,3); + set_mark(2, 3); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::BtnDelCh4Click(TObject *Sender) { - set_mark(3,3); + set_mark(3, 3); } //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::PanelCh1Paint(TObject *Sender) { - draw_marks(0); + draw_marks(0); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::PanelCh2Paint(TObject *Sender) { - draw_marks(1); + draw_marks(1); } void __fastcall TfrmKeyBar::PanelCh3Paint(TObject *Sender) { - draw_marks(2); + draw_marks(2); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::PanelCh4Paint(TObject *Sender) { - draw_marks(3); + draw_marks(3); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::spinTimeFactorExit(TObject *Sender) { - EDevice.time_factor(spinTimeFactor->Value); + EDevice.time_factor(spinTimeFactor->Value); } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::spinTimeFactorKeyPress(TObject *Sender, - char &Key) + char &Key) { - if (Key==VK_RETURN) + if (Key==VK_RETURN) { - EDevice.time_factor(spinTimeFactor->Value); - } + EDevice.time_factor(spinTimeFactor->Value); + } } + //--------------------------------------------------------------------------- void __fastcall TfrmKeyBar::spinTimeFactorLWChange(TObject *Sender, - int Val) + int Val) { - EDevice.time_factor(spinTimeFactor->Value); + EDevice.time_factor(spinTimeFactor->Value); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ActorEditor/KeyBar.h b/src/editors/ActorEditor/KeyBar.h index 9243322b384..b2c56ea879c 100644 --- a/src/editors/ActorEditor/KeyBar.h +++ b/src/editors/ActorEditor/KeyBar.h @@ -21,72 +21,74 @@ class CSMotion; class TfrmKeyBar : public TForm { -__published: // IDE-managed Components - TPanel *Panel6; - TPanel *Panel1; - TLabel *Label1; - TMultiObjSpinEdit *seLOD; - TMxLabel *lbCurrentTime; - TPanel *Panel2; - TPanel *Panel3; - TStaticText *stStartTime; - TPanel *Panel4; - TGradient *Gradient1; - TElTrackBar *anm_track; - TElCheckBox *auto_ch; - TPanel *Panel5; - TStaticText *stEndTime; - TMxPanel *PanelCh1; - TLabel *Label2; - TElGraphicButton *BtnUpCh1; - TElGraphicButton *BtnDownCh1; - TMxPanel *PanelCh2; - TLabel *Label3; - TElGraphicButton *BtnUpCh2; - TElGraphicButton *BtnDownCh2; - TElGraphicButton *BtnDelCh1; - TElGraphicButton *BtnDelCh2; - TMxPanel *PanelCh3; - TLabel *Label4; - TElGraphicButton *BtnUpCh3; - TElGraphicButton *BtnDownCh3; - TElGraphicButton *BtnDelCh3; - TMxPanel *PanelCh4; - TLabel *Label5; - TElGraphicButton *BtnUpCh4; - TElGraphicButton *BtnDownCh4; - TElGraphicButton *BtnDelCh4; - TMultiObjSpinEdit *spinTimeFactor; - void __fastcall seLODLWChange(TObject *Sender, int Val); - void __fastcall seLODKeyPress(TObject *Sender, char &Key); - void __fastcall seLODExit(TObject *Sender); - void __fastcall PanelCh1Paint(TObject *Sender); - void __fastcall PanelCh2Paint(TObject *Sender); - void __fastcall BtnUpCh1Click(TObject *Sender); - void __fastcall BtnUpCh2Click(TObject *Sender); - void __fastcall BtnDownCh2Click(TObject *Sender); - void __fastcall BtnDownCh1Click(TObject *Sender); - void __fastcall BtnDelCh1Click(TObject *Sender); - void __fastcall BtnDelCh2Click(TObject *Sender); - void __fastcall BtnDelCh3Click(TObject *Sender); - void __fastcall BtnDelCh4Click(TObject *Sender); - void __fastcall BtnUpCh3Click(TObject *Sender); - void __fastcall BtnUpCh4Click(TObject *Sender); - void __fastcall BtnDownCh3Click(TObject *Sender); - void __fastcall BtnDownCh4Click(TObject *Sender); - void __fastcall PanelCh3Paint(TObject *Sender); - void __fastcall PanelCh4Paint(TObject *Sender); - void __fastcall spinTimeFactorExit(TObject *Sender); - void __fastcall spinTimeFactorKeyPress(TObject *Sender, char &Key); - void __fastcall spinTimeFactorLWChange(TObject *Sender, int Val); -private: // User declarations - CSMotion* m_currentEditMotion; - void draw_marks (int id); - void set_mark (int id, int action); -public: // User declarations - __fastcall TfrmKeyBar(TComponent* Owner); - static TfrmKeyBar* CreateKeyBar(TWinControl* parent); + __published: // IDE-managed Components + TPanel*Panel6; + TPanel *Panel1; + TLabel *Label1; + TMultiObjSpinEdit *seLOD; + TMxLabel *lbCurrentTime; + TPanel *Panel2; + TPanel *Panel3; + TStaticText *stStartTime; + TPanel *Panel4; + TGradient *Gradient1; + TElTrackBar *anm_track; + TElCheckBox *auto_ch; + TPanel *Panel5; + TStaticText *stEndTime; + TMxPanel *PanelCh1; + TLabel *Label2; + TElGraphicButton *BtnUpCh1; + TElGraphicButton *BtnDownCh1; + TMxPanel *PanelCh2; + TLabel *Label3; + TElGraphicButton *BtnUpCh2; + TElGraphicButton *BtnDownCh2; + TElGraphicButton *BtnDelCh1; + TElGraphicButton *BtnDelCh2; + TMxPanel *PanelCh3; + TLabel *Label4; + TElGraphicButton *BtnUpCh3; + TElGraphicButton *BtnDownCh3; + TElGraphicButton *BtnDelCh3; + TMxPanel *PanelCh4; + TLabel *Label5; + TElGraphicButton *BtnUpCh4; + TElGraphicButton *BtnDownCh4; + TElGraphicButton *BtnDelCh4; + TMultiObjSpinEdit *spinTimeFactor; + void __fastcall seLODLWChange(TObject *Sender, int Val); + void __fastcall seLODKeyPress(TObject *Sender, char &Key); + void __fastcall seLODExit(TObject *Sender); + void __fastcall PanelCh1Paint(TObject *Sender); + void __fastcall PanelCh2Paint(TObject *Sender); + void __fastcall BtnUpCh1Click(TObject *Sender); + void __fastcall BtnUpCh2Click(TObject *Sender); + void __fastcall BtnDownCh2Click(TObject *Sender); + void __fastcall BtnDownCh1Click(TObject *Sender); + void __fastcall BtnDelCh1Click(TObject *Sender); + void __fastcall BtnDelCh2Click(TObject *Sender); + void __fastcall BtnDelCh3Click(TObject *Sender); + void __fastcall BtnDelCh4Click(TObject *Sender); + void __fastcall BtnUpCh3Click(TObject *Sender); + void __fastcall BtnUpCh4Click(TObject *Sender); + void __fastcall BtnDownCh3Click(TObject *Sender); + void __fastcall BtnDownCh4Click(TObject *Sender); + void __fastcall PanelCh3Paint(TObject *Sender); + void __fastcall PanelCh4Paint(TObject *Sender); + void __fastcall spinTimeFactorExit(TObject *Sender); + void __fastcall spinTimeFactorKeyPress(TObject *Sender, char &Key); + void __fastcall spinTimeFactorLWChange(TObject *Sender, int Val); +private: // User declarations + CSMotion *m_currentEditMotion; + void draw_marks(int id); + void set_mark(int id, int action); +public: // User declarations + __fastcall TfrmKeyBar(TComponent *Owner); + static TfrmKeyBar *CreateKeyBar(TWinControl *parent); void UpdateBar(); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ActorEditor/LeftBar.cpp b/src/editors/ActorEditor/LeftBar.cpp index e53f1a14cdb..2ff4444c7d9 100644 --- a/src/editors/ActorEditor/LeftBar.cpp +++ b/src/editors/ActorEditor/LeftBar.cpp @@ -28,110 +28,135 @@ TfraLeftBar *fraLeftBar; //--------------------------------------------------------------------------- -__fastcall TfraLeftBar::TfraLeftBar(TComponent* Owner) - : TFrame(Owner) +__fastcall TfraLeftBar::TfraLeftBar(TComponent *Owner) + : TFrame(Owner) { - DEFINE_INI(fsStorage); + DEFINE_INI(fsStorage); frmMain->paLeftBar->Width = paLeftBar->Width+2; frmMain->sbToolsMin->Left = paLeftBar->Width-frmMain->sbToolsMin->Width-3; } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::miRecentFilesClick(TObject *Sender) { - TMenuItem* MI = dynamic_cast(Sender); R_ASSERT(MI&&(MI->Tag==0x1001)); - xr_string fn = AnsiString(MI->Caption).c_str(); - ExecCommand(COMMAND_LOAD,fn); + TMenuItem *MI = dynamic_cast(Sender); + R_ASSERT(MI&&(MI->Tag==0x1001)); + xr_string fn = AnsiString(MI->Caption).c_str(); + ExecCommand(COMMAND_LOAD, fn); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::fsStorageSavePlacement(TObject *Sender) -{ - ATools->m_Props->SaveParams (fsStorage); - ATools->m_PreviewObject.SaveParams (fsStorage); - ATools->m_RenderObject.SaveParams (fsStorage); +{ + ATools->m_Props->SaveParams(fsStorage); + ATools->m_PreviewObject.SaveParams(fsStorage); + ATools->m_RenderObject.SaveParams(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::fsStorageRestorePlacement(TObject *Sender) { - ATools->m_Props->RestoreParams (fsStorage); + ATools->m_Props->RestoreParams(fsStorage); ATools->m_PreviewObject.RestoreParams(fsStorage); - ATools->m_RenderObject.RestoreParams (fsStorage); + ATools->m_RenderObject.RestoreParams(fsStorage); } + //--------------------------------------------------------------------------- -void UpdatePanel(TPanel* p){ - if (p){ - for (int j=0; jControlCount; j++){ - TExtBtn* btn = dynamic_cast(p->Controls[j]); - if (btn) btn->UpdateMouseInControl(); +void UpdatePanel(TPanel *p) +{ + if (p) + { + for (int j = 0; jControlCount; j++) + { + TExtBtn *btn = dynamic_cast(p->Controls[j]); + if (btn) + btn->UpdateMouseInControl(); } } } + //--------------------------------------------------------------------------- void TfraLeftBar::OnTimer() { - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- -void TfraLeftBar::UpdateBar(){ +void TfraLeftBar::UpdateBar() +{ int i; - for (i=0; iComponentCount; i++){ - TComponent* temp = fraLeftBar->Components[i]; - if (dynamic_cast(temp) != NULL) + for (i = 0; iComponentCount; i++) + { + TComponent *temp = fraLeftBar->Components[i]; + if (dynamic_cast(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } - if (ebRenderEngineStyle->Down&&!ATools->IsVisualPresent()) SetRenderStyle(false); + if (ebRenderEngineStyle->Down&&!ATools->IsVisualPresent()) + SetRenderStyle(false); } + //--------------------------------------------------------------------------- void TfraLeftBar::MinimizeAllFrames() { - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(paLeftBar->Controls[j]); - if (pa) PanelMinimize(pa); + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(paLeftBar->Controls[j]); + if (pa) + PanelMinimize(pa); } - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- void TfraLeftBar::MaximizeAllFrames() { - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(paLeftBar->Controls[j]); - if (pa) PanelMaximize(pa); + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(paLeftBar->Controls[j]); + if (pa) + PanelMaximize(pa); } - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSaveClick(TObject *Sender) { - ExecCommand( COMMAND_SAVE ); + ExecCommand(COMMAND_SAVE); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Refresh1Click(TObject *Sender) { - ExecCommand( COMMAND_REFRESH_TEXTURES ); + ExecCommand(COMMAND_REFRESH_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Checknewtextures1Click(TObject *Sender) { - ExecCommand( COMMAND_CHECK_TEXTURES ); + ExecCommand(COMMAND_CHECK_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ImageEditor1Click(TObject *Sender) { - ExecCommand( COMMAND_IMAGE_EDITOR ); + ExecCommand(COMMAND_IMAGE_EDITOR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::PanelMimimizeClick(TObject *Sender) @@ -139,6 +164,7 @@ void __fastcall TfraLeftBar::PanelMimimizeClick(TObject *Sender) ::PanelMinMaxClick(Sender); UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::PanelMaximizeClick(TObject *Sender) @@ -146,251 +172,288 @@ void __fastcall TfraLeftBar::PanelMaximizeClick(TObject *Sender) ::PanelMaximizeClick(Sender); UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebEditorPreferencesClick(TObject *Sender) { - ExecCommand(COMMAND_EDITOR_PREF); + ExecCommand(COMMAND_EDITOR_PREF); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebMakePreviewClick(TObject *Sender) { - ExecCommand( COMMAND_MAKE_PREVIEW ); + ExecCommand(COMMAND_MAKE_PREVIEW); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSceneFileMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmSceneFile,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmSceneFile, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSceneCommands1MouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmImages,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmImages, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExtBtn3MouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmSounds,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmSounds, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebPreviewObjectClickMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmPreviewObject,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmPreviewObject, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::tvMotionsStartDrag(TObject *Sender, - TDragObject *&DragObject) + TDragObject *&DragObject) { - FHelper.StartDrag(Sender,DragObject); + FHelper.StartDrag(Sender, DragObject); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::tvMotionsDragOver(TObject *Sender, - TObject *Source, int X, int Y, TDragState State, bool &Accept) + TObject *Source, int X, int Y, TDragState State, bool &Accept) { - FHelper.DragOver(Sender,Source,X,Y,State,Accept); + FHelper.DragOver(Sender, Source, X, Y, State, Accept); } + //--------------------------------------------------------------------------- void TfraLeftBar::RenameItem(LPCSTR p0, LPCSTR p1, EItemType tp) { - ATools->RenameMotion(p0,p1); + ATools->RenameMotion(p0, p1); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::tvMotionsDragDrop(TObject *Sender, - TObject *Source, int X, int Y) + TObject *Source, int X, int Y) { - FHelper.DragDrop(Sender,Source,X,Y,TOnItemRename(this,&TfraLeftBar::RenameItem)); + FHelper.DragDrop(Sender, Source, X, Y, TOnItemRename(this, &TfraLeftBar::RenameItem)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Import1Click(TObject *Sender) { - ExecCommand( COMMAND_IMPORT ); + ExecCommand(COMMAND_IMPORT); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Load1Click(TObject *Sender) { - ExecCommand( COMMAND_LOAD ); + ExecCommand(COMMAND_LOAD); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Clear1Click(TObject *Sender) { - ExecCommand( COMMAND_CLEAR ); + ExecCommand(COMMAND_CLEAR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Save2Click(TObject *Sender) { - ExecCommand( COMMAND_SAVE, xr_string(ATools->m_LastFileName.c_str()), 0 ); + ExecCommand(COMMAND_SAVE, xr_string(ATools->m_LastFileName.c_str()), 0); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSaveAsClick(TObject *Sender) { - ExecCommand( COMMAND_SAVE, 0, 1); + ExecCommand(COMMAND_SAVE, 0, 1); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebExportBatchClick(TObject *Sender) { - ExecCommand( COMMAND_BATCH_CONVERT ); + ExecCommand(COMMAND_BATCH_CONVERT); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebMakeThumbnailClick(TObject *Sender) { - ExecCommand(COMMAND_MAKE_THUMBNAIL); + ExecCommand(COMMAND_MAKE_THUMBNAIL); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebBonePartClick(TObject *Sender) { - frmBonePart->Run(ATools->CurrentObject()); - ExecCommand(COMMAND_UPDATE_PROPERTIES); + frmBonePart->Run(ATools->CurrentObject()); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::miExportOGFClick(TObject *Sender) { - ExecCommand( COMMAND_EXPORT_OGF ); + ExecCommand(COMMAND_EXPORT_OGF); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::miExportOMFClick(TObject *Sender) { - ExecCommand( COMMAND_EXPORT_OMF ); + ExecCommand(COMMAND_EXPORT_OMF); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebRenderStyleClick(TObject *Sender) { - if (Sender==ebRenderEngineStyle){ - if (!ATools->IsVisualPresent()) ExecCommand( COMMAND_MAKE_PREVIEW ); - if (!ATools->IsVisualPresent()) SetRenderStyle(false); - else SetRenderStyle(true); + if (Sender==ebRenderEngineStyle) + { + if (!ATools->IsVisualPresent()) + ExecCommand(COMMAND_MAKE_PREVIEW); + if (!ATools->IsVisualPresent()) + SetRenderStyle(false); + else + SetRenderStyle(true); } - ExecCommand (COMMAND_UPDATE_PROPERTIES); - UI->RedrawScene (); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- void TfraLeftBar::SetRenderStyle(bool bEngineStyle) { - if (ATools->IsVisualPresent()&&bEngineStyle) ebRenderEngineStyle->Down = true; - else ebRenderEditorStyle->Down = true; - ATools->PlayMotion(); + if (ATools->IsVisualPresent()&&bEngineStyle) + ebRenderEngineStyle->Down = true; + else + ebRenderEditorStyle->Down = true; + ATools->PlayMotion(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Custom1Click(TObject *Sender) { - ExecCommand( COMMAND_SELECT_PREVIEW_OBJ, false ); + ExecCommand(COMMAND_SELECT_PREVIEW_OBJ, false); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::none1Click(TObject *Sender) { - ExecCommand( COMMAND_SELECT_PREVIEW_OBJ, true ); + ExecCommand(COMMAND_SELECT_PREVIEW_OBJ, true); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Preferences1Click(TObject *Sender) { - ExecCommand( COMMAND_PREVIEW_OBJ_PREF ); + ExecCommand(COMMAND_PREVIEW_OBJ_PREF); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExportDM1Click(TObject *Sender) { - ExecCommand( COMMAND_EXPORT_DM ); + ExecCommand(COMMAND_EXPORT_DM); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExportWaveFrontOBJ1Click(TObject *Sender) { - ExecCommand( COMMAND_EXPORT_OBJ ); + ExecCommand(COMMAND_EXPORT_OBJ); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExportC1Click(TObject *Sender) { - ExecCommand( COMMAND_EXPORT_CPP ); + ExecCommand(COMMAND_EXPORT_CPP); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExtBtn1Click(TObject *Sender) { - ExecCommand( COMMAND_SHOW_CLIPMAKER ); + ExecCommand(COMMAND_SHOW_CLIPMAKER); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MenuItem2Click(TObject *Sender) { - ExecCommand( COMMAND_SOUND_EDITOR ); + ExecCommand(COMMAND_SOUND_EDITOR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MenuItem4Click(TObject *Sender) { - ExecCommand( COMMAND_SYNC_SOUNDS ); + ExecCommand(COMMAND_SYNC_SOUNDS); } + //--------------------------------------------------------------------------- void TfraLeftBar::RefreshBar() { - miRecentFiles->Clear(); - u32 idx = 0; - for (AStringIt it=EPrefs->scene_recent_list.begin(); it!=EPrefs->scene_recent_list.end(); it++){ - TMenuItem *MI = xr_new((TComponent*)0); - MI->Caption = *it; - MI->OnClick = miRecentFilesClick; - MI->Tag = 0x1001; - miRecentFiles->Insert(idx++,MI); + miRecentFiles->Clear(); + u32 idx = 0; + for (AStringIt it = EPrefs->scene_recent_list.begin(); it!=EPrefs->scene_recent_list.end(); it++) + { + TMenuItem *MI = xr_new((TComponent*)0); + MI->Caption = *it; + MI->OnClick = miRecentFilesClick; + MI->Tag = 0x1001; + miRecentFiles->Insert(idx++, MI); } miRecentFiles->Enabled = miRecentFiles->Count; } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebOptimizeMotionsClick(TObject *Sender) { - ExecCommand( COMMAND_OPTIMIZE_MOTIONS ); + ExecCommand(COMMAND_OPTIMIZE_MOTIONS); } + //--------------------------------------------------------------------------- void TfraLeftBar::SetReadOnly(BOOL val) -{ - ebSave->Enabled = !val; - ebSaveAs->Enabled = !val; - ebMakeThumbnail->Enabled = !val; - ebOptimizeMotions->Enabled = !val; - ebExportBatch->Enabled = !val; - ebExport->Enabled = !val; +{ + ebSave->Enabled = !val; + ebSaveAs->Enabled = !val; + ebMakeThumbnail->Enabled = !val; + ebOptimizeMotions->Enabled = !val; + ebExportBatch->Enabled = !val; + ebExport->Enabled = !val; } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Quit1Click(TObject *Sender) { - ExecCommand(COMMAND_QUIT); + ExecCommand(COMMAND_QUIT); } -//--------------------------------------------------------------------------- - - - - - +//--------------------------------------------------------------------------- diff --git a/src/editors/ActorEditor/LeftBar.h b/src/editors/ActorEditor/LeftBar.h index e95a171e944..87f5eeca280 100644 --- a/src/editors/ActorEditor/LeftBar.h +++ b/src/editors/ActorEditor/LeftBar.h @@ -26,139 +26,141 @@ //--------------------------------------------------------------------------- class TfraLeftBar : public TFrame { -__published: // IDE-managed Components - TPanel *paLeftBar; - TFormStorage *fsStorage; - TMxPopupMenu *pmSceneFile; - TMenuItem *Load1; - TMenuItem *ebSave; - TMenuItem *miExportOGF; - TMenuItem *ebSaveAs; - TMenuItem *N5; - TMenuItem *Import1; - TMenuItem *N2; - TMenuItem *miRecentFiles; - TMxPopupMenu *pmPreviewObject; - TMenuItem *Custom1; - TMenuItem *N3; - TMenuItem *none1; - TMenuItem *Preferences1; - TMenuItem *Clear1; - TMenuItem *N4; - TMxPopupMenu *pmImages; - TMenuItem *Refresh1; - TMenuItem *Checknewtextures1; - TMenuItem *ImageEditor1; - TMenuItem *N6; - TMenuItem *N7; - TMenuItem *N8; - TMenuItem *N9; - TMenuItem *ExportDM1; - TPanel *paScene; - TLabel *APHeadLabel2; - TExtBtn *ebSceneMin; - TExtBtn *ebSceneFile; - TExtBtn *ebPreferences; - TExtBtn *ebPreviewObjectClick; - TExtBtn *ebSceneCommands1; - TPanel *paModel; - TLabel *Label4; - TExtBtn *ExtBtn2; - TExtBtn *ebRenderEditorStyle; - TExtBtn *ebRenderEngineStyle; - TLabel *Label5; - TExtBtn *ebBonePart; - TPanel *paObjectProperties; - TLabel *Label6; - TBevel *Bevel6; - TPanel *paObjectProps; - TPanel *paCurrentMotion; - TLabel *Label1; - TExtBtn *ExtBtn10; - TPanel *paPSList; - TBevel *Bevel1; - TPanel *paItemProps; - TSplitter *Splitter1; - TExtBtn *ExtBtn1; - TExtBtn *ExtBtn3; - TMxPopupMenu *pmSounds; - TMenuItem *MenuItem1; - TMenuItem *MenuItem2; - TMenuItem *MenuItem3; - TMenuItem *MenuItem4; - TMenuItem *miExportOMF; - TMenuItem *N1; - TMenuItem *ebOptimizeMotions; - TMenuItem *ExportWaveFrontOBJ1; - TMenuItem *N10; - TMenuItem *ebMakeThumbnail; - TMenuItem *N11; - TMenuItem *ebExportBatch; - TMenuItem *ebExport; - TMenuItem *ExportC1; - TMenuItem *N12; - TMenuItem *Quit1; + __published: // IDE-managed Components + TPanel*paLeftBar; + TFormStorage *fsStorage; + TMxPopupMenu *pmSceneFile; + TMenuItem *Load1; + TMenuItem *ebSave; + TMenuItem *miExportOGF; + TMenuItem *ebSaveAs; + TMenuItem *N5; + TMenuItem *Import1; + TMenuItem *N2; + TMenuItem *miRecentFiles; + TMxPopupMenu *pmPreviewObject; + TMenuItem *Custom1; + TMenuItem *N3; + TMenuItem *none1; + TMenuItem *Preferences1; + TMenuItem *Clear1; + TMenuItem *N4; + TMxPopupMenu *pmImages; + TMenuItem *Refresh1; + TMenuItem *Checknewtextures1; + TMenuItem *ImageEditor1; + TMenuItem *N6; + TMenuItem *N7; + TMenuItem *N8; + TMenuItem *N9; + TMenuItem *ExportDM1; + TPanel *paScene; + TLabel *APHeadLabel2; + TExtBtn *ebSceneMin; + TExtBtn *ebSceneFile; + TExtBtn *ebPreferences; + TExtBtn *ebPreviewObjectClick; + TExtBtn *ebSceneCommands1; + TPanel *paModel; + TLabel *Label4; + TExtBtn *ExtBtn2; + TExtBtn *ebRenderEditorStyle; + TExtBtn *ebRenderEngineStyle; + TLabel *Label5; + TExtBtn *ebBonePart; + TPanel *paObjectProperties; + TLabel *Label6; + TBevel *Bevel6; + TPanel *paObjectProps; + TPanel *paCurrentMotion; + TLabel *Label1; + TExtBtn *ExtBtn10; + TPanel *paPSList; + TBevel *Bevel1; + TPanel *paItemProps; + TSplitter *Splitter1; + TExtBtn *ExtBtn1; + TExtBtn *ExtBtn3; + TMxPopupMenu *pmSounds; + TMenuItem *MenuItem1; + TMenuItem *MenuItem2; + TMenuItem *MenuItem3; + TMenuItem *MenuItem4; + TMenuItem *miExportOMF; + TMenuItem *N1; + TMenuItem *ebOptimizeMotions; + TMenuItem *ExportWaveFrontOBJ1; + TMenuItem *N10; + TMenuItem *ebMakeThumbnail; + TMenuItem *N11; + TMenuItem *ebExportBatch; + TMenuItem *ebExport; + TMenuItem *ExportC1; + TMenuItem *N12; + TMenuItem *Quit1; void __fastcall ebSaveClick(TObject *Sender); void __fastcall PanelMimimizeClick(TObject *Sender); void __fastcall PanelMaximizeClick(TObject *Sender); void __fastcall ebEditorPreferencesClick(TObject *Sender); - void __fastcall ebSceneFileMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y); - void __fastcall tvMotionsStartDrag(TObject *Sender, - TDragObject *&DragObject); - void __fastcall tvMotionsDragOver(TObject *Sender, TObject *Source, int X, - int Y, TDragState State, bool &Accept); - void __fastcall tvMotionsDragDrop(TObject *Sender, TObject *Source, int X, - int Y); - void __fastcall Import1Click(TObject *Sender); - void __fastcall Load1Click(TObject *Sender); - void __fastcall Save2Click(TObject *Sender); - void __fastcall ebSaveAsClick(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall miRecentFilesClick(TObject *Sender); - void __fastcall ebBonePartClick(TObject *Sender); - void __fastcall miExportOGFClick(TObject *Sender); - void __fastcall ebMakePreviewClick(TObject *Sender); - void __fastcall ebRenderStyleClick(TObject *Sender); - void __fastcall Custom1Click(TObject *Sender); - void __fastcall none1Click(TObject *Sender); - void __fastcall Preferences1Click(TObject *Sender); - void __fastcall ebPreviewObjectClickMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y); - void __fastcall Clear1Click(TObject *Sender); - void __fastcall Refresh1Click(TObject *Sender); - void __fastcall Checknewtextures1Click(TObject *Sender); - void __fastcall ebSceneCommands1MouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y); - void __fastcall ImageEditor1Click(TObject *Sender); - void __fastcall ExportDM1Click(TObject *Sender); - void __fastcall ExtBtn1Click(TObject *Sender); - void __fastcall ExtBtn3MouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall MenuItem2Click(TObject *Sender); - void __fastcall MenuItem4Click(TObject *Sender); - void __fastcall miExportOMFClick(TObject *Sender); - void __fastcall ebOptimizeMotionsClick(TObject *Sender); - void __fastcall ExportWaveFrontOBJ1Click(TObject *Sender); - void __fastcall ebMakeThumbnailClick(TObject *Sender); - void __fastcall ebExportBatchClick(TObject *Sender); - void __fastcall ExportC1Click(TObject *Sender); - void __fastcall Quit1Click(TObject *Sender); -private: // User declarations - void __fastcall ShowPPMenu (TMxPopupMenu* M, TObject* btn); - void RenameItem (LPCSTR p0, LPCSTR p1, EItemType tp); -public: // User declarations - __fastcall TfraLeftBar (TComponent* Owner); - void UpdateBar (); - void OnTimer (); - void SetRenderStyle (bool bEngineStyle); - void MinimizeAllFrames(); - void MaximizeAllFrames(); - void RefreshBar (); - void SetReadOnly (BOOL val); + void __fastcall ebSceneFileMouseDown(TObject *Sender, + TMouseButton Button, TShiftState Shift, int X, int Y); + void __fastcall tvMotionsStartDrag(TObject *Sender, + TDragObject *&DragObject); + void __fastcall tvMotionsDragOver(TObject *Sender, TObject *Source, int X, + int Y, TDragState State, bool &Accept); + void __fastcall tvMotionsDragDrop(TObject *Sender, TObject *Source, int X, + int Y); + void __fastcall Import1Click(TObject *Sender); + void __fastcall Load1Click(TObject *Sender); + void __fastcall Save2Click(TObject *Sender); + void __fastcall ebSaveAsClick(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall miRecentFilesClick(TObject *Sender); + void __fastcall ebBonePartClick(TObject *Sender); + void __fastcall miExportOGFClick(TObject *Sender); + void __fastcall ebMakePreviewClick(TObject *Sender); + void __fastcall ebRenderStyleClick(TObject *Sender); + void __fastcall Custom1Click(TObject *Sender); + void __fastcall none1Click(TObject *Sender); + void __fastcall Preferences1Click(TObject *Sender); + void __fastcall ebPreviewObjectClickMouseDown(TObject *Sender, + TMouseButton Button, TShiftState Shift, int X, int Y); + void __fastcall Clear1Click(TObject *Sender); + void __fastcall Refresh1Click(TObject *Sender); + void __fastcall Checknewtextures1Click(TObject *Sender); + void __fastcall ebSceneCommands1MouseDown(TObject *Sender, + TMouseButton Button, TShiftState Shift, int X, int Y); + void __fastcall ImageEditor1Click(TObject *Sender); + void __fastcall ExportDM1Click(TObject *Sender); + void __fastcall ExtBtn1Click(TObject *Sender); + void __fastcall ExtBtn3MouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall MenuItem2Click(TObject *Sender); + void __fastcall MenuItem4Click(TObject *Sender); + void __fastcall miExportOMFClick(TObject *Sender); + void __fastcall ebOptimizeMotionsClick(TObject *Sender); + void __fastcall ExportWaveFrontOBJ1Click(TObject *Sender); + void __fastcall ebMakeThumbnailClick(TObject *Sender); + void __fastcall ebExportBatchClick(TObject *Sender); + void __fastcall ExportC1Click(TObject *Sender); + void __fastcall Quit1Click(TObject *Sender); +private: // User declarations + void __fastcall ShowPPMenu(TMxPopupMenu *M, TObject *btn); + void RenameItem(LPCSTR p0, LPCSTR p1, EItemType tp); +public: // User declarations + __fastcall TfraLeftBar(TComponent *Owner); + void UpdateBar(); + void OnTimer(); + void SetRenderStyle(bool bEngineStyle); + void MinimizeAllFrames(); + void MaximizeAllFrames(); + void RefreshBar(); + void SetReadOnly(BOOL val); }; + //--------------------------------------------------------------------------- -extern PACKAGE TfraLeftBar *fraLeftBar; +extern PACKAGE TfraLeftBar * fraLeftBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ActorEditor/Splash.cpp b/src/editors/ActorEditor/Splash.cpp index 14c433d6819..22b97ef289c 100644 --- a/src/editors/ActorEditor/Splash.cpp +++ b/src/editors/ActorEditor/Splash.cpp @@ -6,9 +6,11 @@ #pragma package(smart_init) #pragma resource "*.dfm" TfrmSplash *frmSplash; + //--------------------------------------------------------------------------- -__fastcall TfrmSplash::TfrmSplash(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfrmSplash::TfrmSplash(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- + + diff --git a/src/editors/ActorEditor/Splash.h b/src/editors/ActorEditor/Splash.h index 7cf4c06f31b..c62612c5ac5 100644 --- a/src/editors/ActorEditor/Splash.h +++ b/src/editors/ActorEditor/Splash.h @@ -12,18 +12,29 @@ #include #include #include + //--------------------------------------------------------------------------- class TfrmSplash : public TForm { -__published: // IDE-managed Components - TImage *Image1; - TMxLabel *lbStatus; -private: // User declarations -public: // User declarations - __fastcall TfrmSplash(TComponent* Owner); - void SetStatus(LPSTR log){ if (log){ lbStatus->Caption = log; lbStatus->Repaint(); };} + __published: // IDE-managed Components + TImage*Image1; + TMxLabel *lbStatus; +private: // User declarations +public: // User declarations + __fastcall TfrmSplash(TComponent *Owner); + + void SetStatus(LPSTR log) + { + if (log) + { + lbStatus->Caption = log; + lbStatus->Repaint(); + }; + } }; + //--------------------------------------------------------------------------- -extern PACKAGE TfrmSplash *frmSplash; +extern PACKAGE TfrmSplash * frmSplash; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ActorEditor/TopBar.cpp b/src/editors/ActorEditor/TopBar.cpp index 1d10031257b..c8f4f9ce649 100644 --- a/src/editors/ActorEditor/TopBar.cpp +++ b/src/editors/ActorEditor/TopBar.cpp @@ -11,177 +11,215 @@ #pragma link "mxPlacemnt" #pragma resource "*.dfm" TfraTopBar *fraTopBar; + //--------------------------------------------------------------------------- -__fastcall TfraTopBar::TfraTopBar(TComponent* Owner) - : TFrame(Owner) +__fastcall TfraTopBar::TfraTopBar(TComponent *Owner) + : TFrame(Owner) { - ebActionSelect->Tag = etaSelect; - ebActionAdd->Tag = etaAdd; - ebActionMove->Tag = etaMove; - ebActionRotate->Tag = etaRotate; - ebActionScale->Tag = etaScale; - - ebAxisX->Tag = etAxisX; - ebAxisY->Tag = etAxisY; - ebAxisZ->Tag = etAxisZ; - ebAxisZX->Tag = etAxisZX; - - ebCSParent->Tag = etfCSParent; - ebNUScale->Tag = etfNUScale; - ebNormalAlign->Tag = etfNormalAlign; - ebGSnap->Tag = etfGSnap; - ebOSnap->Tag = etfOSnap; - ebMTSnap->Tag = etfMTSnap; - ebVSnap->Tag = etfVSnap; - ebASnap->Tag = etfASnap; - ebMSnap->Tag = etfMSnap; + ebActionSelect->Tag = etaSelect; + ebActionAdd->Tag = etaAdd; + ebActionMove->Tag = etaMove; + ebActionRotate->Tag = etaRotate; + ebActionScale->Tag = etaScale; + + ebAxisX->Tag = etAxisX; + ebAxisY->Tag = etAxisY; + ebAxisZ->Tag = etAxisZ; + ebAxisZX->Tag = etAxisZX; + + ebCSParent->Tag = etfCSParent; + ebNUScale->Tag = etfNUScale; + ebNormalAlign->Tag = etfNormalAlign; + ebGSnap->Tag = etfGSnap; + ebOSnap->Tag = etfOSnap; + ebMTSnap->Tag = etfMTSnap; + ebVSnap->Tag = etfVSnap; + ebASnap->Tag = etfASnap; + ebMSnap->Tag = etfMSnap; DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- -void TfraTopBar::OnTimer(){ - for (int j=0; j(temp) != NULL) +void TfraTopBar::OnTimer() +{ + for (int j = 0; j(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebEditUndoClick(TObject *Sender) -{ - ExecCommand( COMMAND_UNDO ); +{ + ExecCommand(COMMAND_UNDO); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebEditRedoClick(TObject *Sender) { - ExecCommand( COMMAND_REDO ); + ExecCommand(COMMAND_REDO); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ActionClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_CHANGE_ACTION, btn->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebAxisClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_CHANGE_AXIS, btn->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebSettingsClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_SET_SETTINGS, btn->Tag, btn->Down); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebViewClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); - if (btn){ - if (btn==ebViewFront) EDevice.m_Camera.ViewFront(); - if (btn==ebViewBack) EDevice.m_Camera.ViewBack(); - if (btn==ebViewLeft) EDevice.m_Camera.ViewLeft(); - if (btn==ebViewRight) EDevice.m_Camera.ViewRight(); - if (btn==ebViewTop) EDevice.m_Camera.ViewTop(); - if (btn==ebViewBottom) EDevice.m_Camera.ViewBottom(); - if (btn==ebViewReset) EDevice.m_Camera.ViewReset(); + TExtBtn *btn = dynamic_cast(Sender); + if (btn) + { + if (btn==ebViewFront) + EDevice.m_Camera.ViewFront(); + if (btn==ebViewBack) + EDevice.m_Camera.ViewBack(); + if (btn==ebViewLeft) + EDevice.m_Camera.ViewLeft(); + if (btn==ebViewRight) + EDevice.m_Camera.ViewRight(); + if (btn==ebViewTop) + EDevice.m_Camera.ViewTop(); + if (btn==ebViewBottom) + EDevice.m_Camera.ViewBottom(); + if (btn==ebViewReset) + EDevice.m_Camera.ViewReset(); } UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::RefreshBar() { - TExtBtn* btn = 0; - //actions - switch(Tools->GetAction()){ - case etaSelect: btn=ebActionSelect; break; - case etaAdd: btn=ebActionAdd; break; - case etaMove: btn=ebActionMove; break; - case etaRotate: btn=ebActionRotate; break; - case etaScale: btn=ebActionScale; break; - default: THROW; + TExtBtn *btn = 0; + //actions + switch (Tools->GetAction()) + { + case etaSelect: btn = ebActionSelect; + break; + case etaAdd: btn = ebActionAdd; + break; + case etaMove: btn = ebActionMove; + break; + case etaRotate: btn = ebActionRotate; + break; + case etaScale: btn = ebActionScale; + break; + default: THROW; } - btn->Down = true; + btn->Down = true; // axis - switch (Tools->GetAxis()){ - case etAxisX: btn=ebAxisX; break; - case etAxisY: btn=ebAxisY; break; - case etAxisZ: btn=ebAxisZ; break; - case etAxisZX: btn=ebAxisZX; break; - case etAxisUndefined: btn=NULL; break; - default: THROW; + switch (Tools->GetAxis()) + { + case etAxisX: btn = ebAxisX; + break; + case etAxisY: btn = ebAxisY; + break; + case etAxisZ: btn = ebAxisZ; + break; + case etAxisZX: btn = ebAxisZX; + break; + case etAxisUndefined: btn = NULL; + break; + default: THROW; } - if(btn) - btn->Down = true; + if (btn) + btn->Down = true; // settings - ebCSParent->Down = Tools->GetSettings(etfCSParent); - ebNUScale->Down = Tools->GetSettings(etfNUScale); - ebNormalAlign->Down = Tools->GetSettings(etfNormalAlign); - ebGSnap->Down = Tools->GetSettings(etfGSnap); - ebOSnap->Down = Tools->GetSettings(etfOSnap); - ebMTSnap->Down = Tools->GetSettings(etfMTSnap); - ebVSnap->Down = Tools->GetSettings(etfVSnap); - ebASnap->Down = Tools->GetSettings(etfASnap); - ebMSnap->Down = Tools->GetSettings(etfMSnap); + ebCSParent->Down = Tools->GetSettings(etfCSParent); + ebNUScale->Down = Tools->GetSettings(etfNUScale); + ebNormalAlign->Down = Tools->GetSettings(etfNormalAlign); + ebGSnap->Down = Tools->GetSettings(etfGSnap); + ebOSnap->Down = Tools->GetSettings(etfOSnap); + ebMTSnap->Down = Tools->GetSettings(etfMTSnap); + ebVSnap->Down = Tools->GetSettings(etfVSnap); + ebASnap->Down = Tools->GetSettings(etfASnap); + ebMSnap->Down = Tools->GetSettings(etfMSnap); // redraw scene - UI->RedrawScene (); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebZoomExtentsClick(TObject *Sender) { - ExecCommand( COMMAND_ZOOM_EXTENTS, FALSE ); + ExecCommand(COMMAND_ZOOM_EXTENTS, FALSE); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebZoomExtentsSelectedClick(TObject *Sender) { - ExecCommand( COMMAND_ZOOM_EXTENTS, TRUE ); + ExecCommand(COMMAND_ZOOM_EXTENTS, TRUE); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebCameraStyleClick(TObject *Sender) { - EDevice.m_Camera.SetStyle((ECameraStyle)((TExtBtn*)Sender)->Tag); + EDevice.m_Camera.SetStyle((ECameraStyle)((TExtBtn*)Sender)->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::fsStorageRestorePlacement(TObject *Sender) { - if (ebCameraPlane->Down) EDevice.m_Camera.SetStyle(csPlaneMove); - else if (ebCameraArcBall->Down) EDevice.m_Camera.SetStyle(cs3DArcBall); - else if (ebCameraFly->Down) EDevice.m_Camera.SetStyle(csFreeFly); + if (ebCameraPlane->Down) + EDevice.m_Camera.SetStyle(csPlaneMove); + else if (ebCameraArcBall->Down) + EDevice.m_Camera.SetStyle(cs3DArcBall); + else if (ebCameraFly->Down) + EDevice.m_Camera.SetStyle(csFreeFly); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::SimulateButtonClick(TObject *Sender) { - - CActorTools* ActorTools = dynamic_cast( Tools ) ; - if(!ActorTools) - return; - //if(!ActorTools->m_RenderObject.m_pVisual) - // return; - if ( SimulateButton->Down ) - ActorTools->PhysicsSimulate(); //->m_RenderObject.PhysicsSimulate (ActorTools->m_AVTransform); + CActorTools *ActorTools = dynamic_cast(Tools); + if (!ActorTools) + return; + //if(!ActorTools->m_RenderObject.m_pVisual) + // return; + if (SimulateButton->Down) + ActorTools->PhysicsSimulate(); //->m_RenderObject.PhysicsSimulate (ActorTools->m_AVTransform); else - ActorTools->PhysicsStopSimulate ();//->m_RenderObject.PhysicsStopSimulate (); - - + ActorTools->PhysicsStopSimulate();//->m_RenderObject.PhysicsStopSimulate (); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ActorEditor/TopBar.h b/src/editors/ActorEditor/TopBar.h index bf6d34ddffa..9c278631a47 100644 --- a/src/editors/ActorEditor/TopBar.h +++ b/src/editors/ActorEditor/TopBar.h @@ -13,11 +13,12 @@ #include "ExtBtn.hpp" #include "mxPlacemnt.hpp" #include + //--------------------------------------------------------------------------- class ECORE_API TfraTopBar : public TFrame { -__published: // IDE-managed Components - TPanel *paTBEdit; + __published: // IDE-managed Components + TPanel*paTBEdit; TExtBtn *ebEditUndo; TExtBtn *ebEditRedo; TPanel *paTBAction; @@ -29,7 +30,7 @@ class ECORE_API TfraTopBar : public TFrame TPanel *paSnap; TExtBtn *ebMSnap; TExtBtn *ebASnap; - TExtBtn *ebCSParent; + TExtBtn *ebCSParent; TPanel *paAxis; TExtBtn *ebAxisX; TExtBtn *ebAxisY; @@ -44,37 +45,39 @@ class ECORE_API TfraTopBar : public TFrame TExtBtn *ebViewBack; TExtBtn *ebViewRight; TExtBtn *ebViewBottom; - TExtBtn *ebNUScale; - TPanel *Panel1; - TExtBtn *ebZoomExtents; - TExtBtn *ebZoomExtentsSelected; - TExtBtn *ebVSnap; - TFormStorage *fsStorage; - TExtBtn *ebCameraPlane; - TExtBtn *ebCameraArcBall; - TExtBtn *ebCameraFly; - TExtBtn *ebViewReset; - TExtBtn *ebMTSnap; - TExtBtn *ebNormalAlign; - TExtBtn *SimulateButton; + TExtBtn *ebNUScale; + TPanel *Panel1; + TExtBtn *ebZoomExtents; + TExtBtn *ebZoomExtentsSelected; + TExtBtn *ebVSnap; + TFormStorage *fsStorage; + TExtBtn *ebCameraPlane; + TExtBtn *ebCameraArcBall; + TExtBtn *ebCameraFly; + TExtBtn *ebViewReset; + TExtBtn *ebMTSnap; + TExtBtn *ebNormalAlign; + TExtBtn *SimulateButton; void __fastcall ebEditUndoClick(TObject *Sender); void __fastcall ebEditRedoClick(TObject *Sender); void __fastcall ActionClick(TObject *Sender); void __fastcall ebViewClick(TObject *Sender); - void __fastcall ebZoomExtentsClick(TObject *Sender); - void __fastcall ebZoomExtentsSelectedClick(TObject *Sender); - void __fastcall ebCameraStyleClick(TObject *Sender); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall ebAxisClick(TObject *Sender); - void __fastcall ebSettingsClick(TObject *Sender); - void __fastcall SimulateButtonClick(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TfraTopBar(TComponent* Owner); + void __fastcall ebZoomExtentsClick(TObject *Sender); + void __fastcall ebZoomExtentsSelectedClick(TObject *Sender); + void __fastcall ebCameraStyleClick(TObject *Sender); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall ebAxisClick(TObject *Sender); + void __fastcall ebSettingsClick(TObject *Sender); + void __fastcall SimulateButtonClick(TObject *Sender); +private: // User declarations +public: // User declarations + __fastcall TfraTopBar(TComponent *Owner); void OnTimer(); void __fastcall RefreshBar(); }; + //--------------------------------------------------------------------------- -extern PACKAGE TfraTopBar *fraTopBar; +extern PACKAGE TfraTopBar * fraTopBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ActorEditor/UI_ActorMain.cpp b/src/editors/ActorEditor/UI_ActorMain.cpp index 17d26b91737..6b54ee7876e 100644 --- a/src/editors/ActorEditor/UI_ActorMain.cpp +++ b/src/editors/ActorEditor/UI_ActorMain.cpp @@ -13,19 +13,22 @@ #include "../xrEProps/ChoseForm.h" //--------------------------------------------------------------------------- -CActorMain*& AUI=(CActorMain*)UI; +CActorMain *&AUI = (CActorMain*)UI; + //--------------------------------------------------------------------------- CActorMain::CActorMain() { - EPrefs = xr_new(); + EPrefs = xr_new(); } + //--------------------------------------------------------------------------- CActorMain::~CActorMain() { - xr_delete (EPrefs); + xr_delete(EPrefs); } + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -33,241 +36,277 @@ CActorMain::~CActorMain() //--------------------------------------------------------------------------- CCommandVar CActorTools::CommandLoad(CCommandVar p1, CCommandVar p2) { - xr_string temp_fn = p1.IsString()?xr_string(p1):xr_string(""); - if(!p1.IsString()){ - temp_fn = ChangeFileExt(m_LastFileName,"").c_str(); - if (!EFS.GetOpenName ( _objects_, temp_fn )) - return FALSE; + xr_string temp_fn = p1.IsString() ? xr_string(p1) : xr_string(""); + if (!p1.IsString()) + { + temp_fn = ChangeFileExt(m_LastFileName, "").c_str(); + if (!EFS.GetOpenName(_objects_, temp_fn)) + return FALSE; } - if( temp_fn.size() ){ - xr_strlwr (temp_fn); - if (!IfModified()) return FALSE; + if (temp_fn.size()) + { + xr_strlwr(temp_fn); + if (!IfModified()) + return FALSE; - if (!FS.exist(temp_fn.c_str())){ - Msg ("#!Can't load file: %s",temp_fn.c_str()); - return FALSE; + if (!FS.exist(temp_fn.c_str())) + { + Msg("#!Can't load file: %s", temp_fn.c_str()); + return FALSE; } - - - ExecCommand (COMMAND_CLEAR); - - BOOL bReadOnly = !FS.can_modify_file(temp_fn.c_str()); - m_Flags.set (flReadOnlyMode,bReadOnly); - + + + ExecCommand(COMMAND_CLEAR); + + BOOL bReadOnly = !FS.can_modify_file(temp_fn.c_str()); + m_Flags.set(flReadOnlyMode, bReadOnly); + // set enable ... - m_Props->SetReadOnly (bReadOnly); - - fraLeftBar->SetReadOnly (bReadOnly); - + m_Props->SetReadOnly(bReadOnly); + + fraLeftBar->SetReadOnly(bReadOnly); + CTimer T; - T.Start(); - if (!Load(temp_fn.c_str())){ + T.Start(); + if (!Load(temp_fn.c_str())) + { return FALSE; } - m_LastFileName = temp_fn.c_str(); - ELog.Msg(mtInformation,"Object '%s' successfully loaded. Loading time - %3.2f(s).",m_LastFileName.c_str(),T.GetElapsed_sec()); + m_LastFileName = temp_fn.c_str(); + ELog.Msg(mtInformation, "Object '%s' successfully loaded. Loading time - %3.2f(s).", m_LastFileName.c_str(), T.GetElapsed_sec()); EPrefs->AppendRecentFile(m_LastFileName.c_str()); - ExecCommand (COMMAND_UPDATE_CAPTION); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_CAPTION); + ExecCommand(COMMAND_UPDATE_PROPERTIES); UndoClear(); UndoSave(); } return TRUE; } + CCommandVar CActorTools::CommandSaveBackup(CCommandVar p1, CCommandVar p2) { - string_path fn; - strconcat (sizeof(fn), fn, Core.UserName, "_backup.object"); - FS.update_path (fn,"$objects$",fn); - ExecCommand (COMMAND_SAVE,xr_string(fn)); + string_path fn; + strconcat(sizeof(fn), fn, Core.UserName, "_backup.object"); + FS.update_path(fn, "$objects$", fn); + ExecCommand(COMMAND_SAVE, xr_string(fn)); return TRUE; } + CCommandVar CActorTools::CommandSave(CCommandVar p1, CCommandVar p2) { - if (p2==1){ - xr_string temp_fn = ATools->m_LastFileName.c_str(); - if (EFS.GetSaveName ( _objects_, temp_fn )){ - temp_fn = EFS.ChangeFileExt(temp_fn,".object"); - return ExecCommand(COMMAND_SAVE,temp_fn,0); + if (p2==1) + { + xr_string temp_fn = ATools->m_LastFileName.c_str(); + if (EFS.GetSaveName(_objects_, temp_fn)) + { + temp_fn = EFS.ChangeFileExt(temp_fn, ".object"); + return ExecCommand(COMMAND_SAVE, temp_fn, 0); } - }else{ + } + else + { if (p1.IsInteger()) - return ExecCommand(COMMAND_SAVE,xr_string(ATools->m_LastFileName.c_str()),0); - xr_string temp_fn = xr_string(p1); - if (temp_fn.empty()){ - return ExecCommand(COMMAND_SAVE,temp_fn,1); - }else{ - xr_strlwr (temp_fn); + return ExecCommand(COMMAND_SAVE, xr_string(ATools->m_LastFileName.c_str()), 0); + xr_string temp_fn = xr_string(p1); + if (temp_fn.empty()) + { + return ExecCommand(COMMAND_SAVE, temp_fn, 1); + } + else + { + xr_strlwr(temp_fn); CTimer T; T.Start(); - CCommandVar res; - if (Tools->Save(temp_fn.c_str())){ - ELog.Msg (mtInformation,"Object '%s' successfully saved. Saving time - %3.2f(s).",m_LastFileName.c_str(),T.GetElapsed_sec()); - m_LastFileName = temp_fn.c_str(); - EPrefs->AppendRecentFile (m_LastFileName.c_str()); - ExecCommand (COMMAND_UPDATE_CAPTION); - res = TRUE; - }else{ - res = FALSE; + CCommandVar res; + if (Tools->Save(temp_fn.c_str())) + { + ELog.Msg(mtInformation, "Object '%s' successfully saved. Saving time - %3.2f(s).", m_LastFileName.c_str(), T.GetElapsed_sec()); + m_LastFileName = temp_fn.c_str(); + EPrefs->AppendRecentFile(m_LastFileName.c_str()); + ExecCommand(COMMAND_UPDATE_CAPTION); + res = TRUE; } - return res; + else + { + res = FALSE; + } + return res; } } - return FALSE; -} + return FALSE; +} + CCommandVar CActorTools::CommandImport(CCommandVar p1, CCommandVar p2) { - xr_string temp_fn = p1.IsString()?xr_string(p1):xr_string(""); - if(p1.IsString()||EFS.GetOpenName(_import_,temp_fn)) + xr_string temp_fn = p1.IsString() ? xr_string(p1) : xr_string(""); + if (p1.IsString()||EFS.GetOpenName(_import_, temp_fn)) { - FS_Path* pp = FS.get_path(_import_); + FS_Path *pp = FS.get_path(_import_); if (temp_fn.npos!=temp_fn.find(pp->m_Path)) { xr_strlwr(temp_fn); if (!Tools->IfModified()) - return FALSE; - - ExecCommand( COMMAND_CLEAR ); + return FALSE; + + ExecCommand(COMMAND_CLEAR); CTimer T; T.Start(); if (!ATools->Import(NULL, temp_fn.c_str())) - return FALSE; - + return FALSE; + m_LastFileName = temp_fn.c_str(); - ELog.Msg(mtInformation,"Object '%s' successfully imported. Loading time - %3.2f(s).",m_LastFileName.c_str(),T.GetElapsed_sec()); - if (ExecCommand( COMMAND_SAVE,temp_fn,1 )) + ELog.Msg(mtInformation, "Object '%s' successfully imported. Loading time - %3.2f(s).", m_LastFileName.c_str(), T.GetElapsed_sec()); + if (ExecCommand(COMMAND_SAVE, temp_fn, 1)) { xr_string mfn; mfn = temp_fn; - EFS.MarkFile(mfn.c_str(),true); - }else + EFS.MarkFile(mfn.c_str(), true); + } + else { - ExecCommand( COMMAND_CLEAR ); + ExecCommand(COMMAND_CLEAR); } return TRUE; - }else{ - ELog.Msg (mtError,"Invalid file path. "); + } + else + { + ELog.Msg(mtError, "Invalid file path. "); } } return FALSE; } + CCommandVar CActorTools::CommandExportDM(CCommandVar p1, CCommandVar p2) { - CCommandVar res = FALSE; - xr_string fn=p1.IsString()?xr_string(p1):xr_string(""); - if (p1.IsString()||EFS.GetSaveName("$game_dm$",fn)){ - if (0!=(res=ExportDM(fn.c_str()))) ELog.Msg(mtInformation,"Export complete."); - else ELog.Msg(mtError,"Export failed."); + CCommandVar res = FALSE; + xr_string fn = p1.IsString() ? xr_string(p1) : xr_string(""); + if (p1.IsString()||EFS.GetSaveName("$game_dm$", fn)) + { + if (0!=(res = ExportDM(fn.c_str()))) + ELog.Msg(mtInformation, "Export complete."); + else + ELog.Msg(mtError, "Export failed."); } return res; } + CCommandVar CActorTools::CommandExportOBJ(CCommandVar p1, CCommandVar p2) { - CCommandVar res = FALSE; - xr_string fn=p1.IsString()?xr_string(p1):xr_string(""); - - if (p1.IsString()||EFS.GetSaveName("$import$",fn,0,5)) + CCommandVar res = FALSE; + xr_string fn = p1.IsString() ? xr_string(p1) : xr_string(""); + + if (p1.IsString()||EFS.GetSaveName("$import$", fn, 0, 5)) { - if (0!=(res=ExportOBJ(fn.c_str()))) - ELog.Msg(mtInformation,"Export complete."); - else - ELog.Msg(mtError,"Export failed."); + if (0!=(res = ExportOBJ(fn.c_str()))) + ELog.Msg(mtInformation, "Export complete."); + else + ELog.Msg(mtError, "Export failed."); } return res; } + CCommandVar CActorTools::CommandExportOGF(CCommandVar p1, CCommandVar p2) { - CCommandVar res = FALSE; - xr_string fn=p1.IsString()?xr_string(p1):xr_string(""); - if (p1.IsString()||EFS.GetSaveName("$game_meshes$",fn,0,0)){ - if (0!=(res=ATools->ExportOGF(fn.c_str()))) - ELog.Msg(mtInformation,"Export complete."); - else - ELog.Msg(mtError,"Export failed."); + CCommandVar res = FALSE; + xr_string fn = p1.IsString() ? xr_string(p1) : xr_string(""); + if (p1.IsString()||EFS.GetSaveName("$game_meshes$", fn, 0, 0)) + { + if (0!=(res = ATools->ExportOGF(fn.c_str()))) + ELog.Msg(mtInformation, "Export complete."); + else + ELog.Msg(mtError, "Export failed."); } return res; } + CCommandVar CActorTools::CommandExportOMF(CCommandVar p1, CCommandVar p2) { - CCommandVar res = FALSE; - xr_string fn=p1.IsString()?xr_string(p1):xr_string(""); - - if (p1.IsString()||EFS.GetSaveName("$game_meshes$",fn,0,1)) + CCommandVar res = FALSE; + xr_string fn = p1.IsString() ? xr_string(p1) : xr_string(""); + + if (p1.IsString()||EFS.GetSaveName("$game_meshes$", fn, 0, 1)) { - if (0!=(res=ExportOMF(fn.c_str()))) - ELog.Msg(mtInformation,"Export complete."); - else - ELog.Msg(mtError,"Export failed."); + if (0!=(res = ExportOMF(fn.c_str()))) + ELog.Msg(mtInformation, "Export complete."); + else + ELog.Msg(mtError, "Export failed."); } return res; } + CCommandVar CActorTools::CommandExportCPP(CCommandVar p1, CCommandVar p2) { - CCommandVar res = FALSE; - xr_string fn=p1.IsString()?xr_string(p1):xr_string(""); - if (p1.IsString()||EFS.GetSaveName(_import_,fn,0,7)) + CCommandVar res = FALSE; + xr_string fn = p1.IsString() ? xr_string(p1) : xr_string(""); + if (p1.IsString()||EFS.GetSaveName(_import_, fn, 0, 7)) { - if (0!=(res=ExportCPP(fn.c_str()))) - ELog.Msg(mtInformation,"Export complete."); - else - ELog.Msg(mtError,"Export failed."); + if (0!=(res = ExportCPP(fn.c_str()))) + ELog.Msg(mtInformation, "Export complete."); + else + ELog.Msg(mtError, "Export failed."); } return res; } + CCommandVar CActorTools::CommandClear(CCommandVar p1, CCommandVar p2) { - if (!IfModified()) - return FALSE; - - m_LastFileName = ""; + if (!IfModified()) + return FALSE; + + m_LastFileName = ""; EDevice.m_Camera.Reset(); - Clear (); - ExecCommand (COMMAND_UPDATE_CAPTION); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - UndoClear (); + Clear(); + ExecCommand(COMMAND_UPDATE_CAPTION); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + UndoClear(); return TRUE; } + CCommandVar CActorTools::CommandUndo(CCommandVar p1, CCommandVar p2) { - if(!Undo()) - ELog.Msg( mtInformation, "Undo buffer empty" ); - else - return ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); - + if (!Undo()) + ELog.Msg(mtInformation, "Undo buffer empty"); + else + return ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); + return FALSE; } + CCommandVar CActorTools::CommandRedo(CCommandVar p1, CCommandVar p2) { - if(!Redo()) - ELog.Msg( mtInformation, "Redo buffer empty" ); - else - return ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); - + if (!Redo()) + ELog.Msg(mtInformation, "Redo buffer empty"); + else + return ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); + return FALSE; } + CCommandVar CActorTools::CommandOptimizeMotions(CCommandVar p1, CCommandVar p2) { OptimizeMotions(); return TRUE; } + CCommandVar CActorTools::CommandMakeThumbnail(CCommandVar p1, CCommandVar p2) { - MakeThumbnail(); + MakeThumbnail(); return TRUE; } + CCommandVar CActorTools::CommandBatchConvert(CCommandVar p1, CCommandVar p2) { - CCommandVar res = FALSE; + CCommandVar res = FALSE; xr_string fn; - if (EFS.GetOpenName("$import$",fn,false,0,6)) + if (EFS.GetOpenName("$import$", fn, false, 0, 6)) { - if (0!=(res=BatchConvert(fn.c_str()))) - ELog.Msg(mtInformation,"Convert complete."); - else - ELog.Msg(mtError,"Convert failed."); + if (0!=(res = BatchConvert(fn.c_str()))) + ELog.Msg(mtInformation, "Convert complete."); + else + ELog.Msg(mtError, "Convert failed."); } return res; } @@ -280,40 +319,47 @@ CCommandVar CommandShowClipMaker(CCommandVar p1, CCommandVar p2) ATools->ShowClipMaker(); return TRUE; } + CCommandVar CommandMakePreview(CCommandVar p1, CCommandVar p2) { ATools->MakePreview(); return TRUE; } + CCommandVar CommandPreviewObjPref(CCommandVar p1, CCommandVar p2) { ATools->SetPreviewObjectPrefs(); return TRUE; } + CCommandVar CommandSelectPreviewObj(CCommandVar p1, CCommandVar p2) { ATools->SelectPreviewObject(p1); return TRUE; } + CCommandVar CommandLoadFirstRecent(CCommandVar p1, CCommandVar p2) { if (EPrefs->FirstRecentFile()) - return ExecCommand(COMMAND_LOAD,xr_string(EPrefs->FirstRecentFile())); + return ExecCommand(COMMAND_LOAD, xr_string(EPrefs->FirstRecentFile())); return FALSE; } + CCommandVar CommandFileMenu(CCommandVar p1, CCommandVar p2) { - FHelper.ShowPPMenu(fraLeftBar->pmSceneFile,0); + FHelper.ShowPPMenu(fraLeftBar->pmSceneFile, 0); return TRUE; } + CCommandVar CommandRefreshUIBar(CCommandVar p1, CCommandVar p2) { - fraTopBar->RefreshBar (); - fraLeftBar->RefreshBar (); + fraTopBar->RefreshBar(); + fraLeftBar->RefreshBar(); fraBottomBar->RefreshBar(); return TRUE; } + CCommandVar CommandRestoreUIBar(CCommandVar p1, CCommandVar p2) { fraTopBar->fsStorage->RestoreFormPlacement(); @@ -321,6 +367,7 @@ CCommandVar CommandRestoreUIBar(CCommandVar p1, CCommandVar p2) fraBottomBar->fsStorage->RestoreFormPlacement(); return TRUE; } + CCommandVar CommandSaveUIBar(CCommandVar p1, CCommandVar p2) { fraTopBar->fsStorage->SaveFormPlacement(); @@ -328,11 +375,13 @@ CCommandVar CommandSaveUIBar(CCommandVar p1, CCommandVar p2) fraBottomBar->fsStorage->SaveFormPlacement(); return TRUE; } + CCommandVar CommandUpdateToolBar(CCommandVar p1, CCommandVar p2) { fraLeftBar->UpdateBar(); return TRUE; } + CCommandVar CommandUpdateCaption(CCommandVar p1, CCommandVar p2) { frmMain->UpdateCaption(); @@ -341,14 +390,22 @@ CCommandVar CommandUpdateCaption(CCommandVar p1, CCommandVar p2) CCommandVar CommandChangeTarget(CCommandVar p1, CCommandVar p2) { - if (p1.IsString()){ - ATools->SelectListItem(xr_string(p1).c_str(), 0,true,false,true); - }else{ - switch (p1){ - case 0: ATools->SelectListItem(BONES_PREFIX, 0,true,false,true); break; - case 1: ATools->SelectListItem(MOTIONS_PREFIX, 0,true,false,true); break; - case 2: ATools->SelectListItem(OBJECT_PREFIX, 0,true,false,true); break; - case 3: ATools->SelectListItem(SURFACES_PREFIX, 0,true,false,true); break; + if (p1.IsString()) + { + ATools->SelectListItem(xr_string(p1).c_str(), 0, true, false, true); + } + else + { + switch (p1) + { + case 0: ATools->SelectListItem(BONES_PREFIX, 0, true, false, true); + break; + case 1: ATools->SelectListItem(MOTIONS_PREFIX, 0, true, false, true); + break; + case 2: ATools->SelectListItem(OBJECT_PREFIX, 0, true, false, true); + break; + case 3: ATools->SelectListItem(SURFACES_PREFIX, 0, true, false, true); + break; } } return TRUE; @@ -356,153 +413,173 @@ CCommandVar CommandChangeTarget(CCommandVar p1, CCommandVar p2) void CActorMain::RegisterCommands() { - inherited::RegisterCommands(); + inherited::RegisterCommands(); // tools - REGISTER_CMD_CE (COMMAND_CLEAR, "File\\Clear Scene", ATools,CActorTools::CommandClear, true); - REGISTER_CMD_CE (COMMAND_LOAD, "File\\Load", ATools,CActorTools::CommandLoad, true); - REGISTER_CMD_C (COMMAND_SAVE_BACKUP, ATools, CActorTools::CommandSaveBackup); - REGISTER_SUB_CMD_CE (COMMAND_SAVE, "File", ATools,CActorTools::CommandSave, true); - APPEND_SUB_CMD ("Save", 0, 0); - APPEND_SUB_CMD ("Save As", 0, 1); + REGISTER_CMD_CE(COMMAND_CLEAR, "File\\Clear Scene", ATools, CActorTools::CommandClear, true); + REGISTER_CMD_CE(COMMAND_LOAD, "File\\Load", ATools, CActorTools::CommandLoad, true); + REGISTER_CMD_C(COMMAND_SAVE_BACKUP, ATools, CActorTools::CommandSaveBackup); + REGISTER_SUB_CMD_CE(COMMAND_SAVE, "File", ATools, CActorTools::CommandSave, true); + APPEND_SUB_CMD("Save", 0, 0); + APPEND_SUB_CMD("Save As", 0, 1); REGISTER_SUB_CMD_END; - REGISTER_CMD_CE (COMMAND_IMPORT, "File\\Import", ATools,CActorTools::CommandImport, true); - REGISTER_CMD_CE (COMMAND_EXPORT_DM, "File\\Export DM", ATools,CActorTools::CommandExportDM, true); - REGISTER_CMD_CE (COMMAND_EXPORT_OBJ, "File\\Export OBJ", ATools,CActorTools::CommandExportOBJ, true); - REGISTER_CMD_CE (COMMAND_EXPORT_OGF, "File\\Export OGF", ATools,CActorTools::CommandExportOGF, true); - REGISTER_CMD_CE (COMMAND_EXPORT_OMF, "File\\Export OMF", ATools,CActorTools::CommandExportOMF, true); - REGISTER_CMD_CE (COMMAND_EXPORT_CPP, "File\\Export CPP", ATools,CActorTools::CommandExportCPP, true); - REGISTER_CMD_CE (COMMAND_UNDO, "Edit\\Undo", ATools,CActorTools::CommandUndo, false); - REGISTER_CMD_CE (COMMAND_REDO, "Edit\\Redo", ATools,CActorTools::CommandRedo, false); - REGISTER_CMD_C (COMMAND_OPTIMIZE_MOTIONS, ATools, CActorTools::CommandOptimizeMotions); - REGISTER_CMD_CE (COMMAND_MAKE_THUMBNAIL, "Make Thumbnail", ATools,CActorTools::CommandMakeThumbnail, false); - REGISTER_CMD_CE (COMMAND_BATCH_CONVERT, "File\\Batch Convert", ATools,CActorTools::CommandBatchConvert, false); + REGISTER_CMD_CE(COMMAND_IMPORT, "File\\Import", ATools, CActorTools::CommandImport, true); + REGISTER_CMD_CE(COMMAND_EXPORT_DM, "File\\Export DM", ATools, CActorTools::CommandExportDM, true); + REGISTER_CMD_CE(COMMAND_EXPORT_OBJ, "File\\Export OBJ", ATools, CActorTools::CommandExportOBJ, true); + REGISTER_CMD_CE(COMMAND_EXPORT_OGF, "File\\Export OGF", ATools, CActorTools::CommandExportOGF, true); + REGISTER_CMD_CE(COMMAND_EXPORT_OMF, "File\\Export OMF", ATools, CActorTools::CommandExportOMF, true); + REGISTER_CMD_CE(COMMAND_EXPORT_CPP, "File\\Export CPP", ATools, CActorTools::CommandExportCPP, true); + REGISTER_CMD_CE(COMMAND_UNDO, "Edit\\Undo", ATools, CActorTools::CommandUndo, false); + REGISTER_CMD_CE(COMMAND_REDO, "Edit\\Redo", ATools, CActorTools::CommandRedo, false); + REGISTER_CMD_C(COMMAND_OPTIMIZE_MOTIONS, ATools, CActorTools::CommandOptimizeMotions); + REGISTER_CMD_CE(COMMAND_MAKE_THUMBNAIL, "Make Thumbnail", ATools, CActorTools::CommandMakeThumbnail, false); + REGISTER_CMD_CE(COMMAND_BATCH_CONVERT, "File\\Batch Convert", ATools, CActorTools::CommandBatchConvert, false); // ui - REGISTER_CMD_S (COMMAND_SHOW_CLIPMAKER, CommandShowClipMaker); - REGISTER_CMD_S (COMMAND_MAKE_PREVIEW, CommandMakePreview); - REGISTER_CMD_S (COMMAND_PREVIEW_OBJ_PREF, CommandPreviewObjPref); - REGISTER_CMD_S (COMMAND_SELECT_PREVIEW_OBJ,CommandSelectPreviewObj); - REGISTER_CMD_SE (COMMAND_LOAD_FIRSTRECENT, "File\\Load First Recent", CommandLoadFirstRecent, true); - REGISTER_CMD_SE (COMMAND_FILE_MENU, "File Menu", CommandFileMenu, true); - REGISTER_CMD_S (COMMAND_REFRESH_UI_BAR, CommandRefreshUIBar); - REGISTER_CMD_S (COMMAND_RESTORE_UI_BAR, CommandRestoreUIBar); - REGISTER_CMD_S (COMMAND_SAVE_UI_BAR, CommandSaveUIBar); - REGISTER_CMD_S (COMMAND_UPDATE_TOOLBAR, CommandUpdateToolBar); - REGISTER_CMD_S (COMMAND_UPDATE_CAPTION, CommandUpdateCaption); - REGISTER_SUB_CMD_SE (COMMAND_CHANGE_TARGET, "Change Target", CommandChangeTarget, true); - APPEND_SUB_CMD (BONES_PREFIX, xr_string(BONES_PREFIX), 0); - APPEND_SUB_CMD (MOTIONS_PREFIX, xr_string(MOTIONS_PREFIX), 0); - APPEND_SUB_CMD (OBJECT_PREFIX, xr_string(OBJECT_PREFIX), 0); - APPEND_SUB_CMD (SURFACES_PREFIX, xr_string(SURFACES_PREFIX), 0); + REGISTER_CMD_S(COMMAND_SHOW_CLIPMAKER, CommandShowClipMaker); + REGISTER_CMD_S(COMMAND_MAKE_PREVIEW, CommandMakePreview); + REGISTER_CMD_S(COMMAND_PREVIEW_OBJ_PREF, CommandPreviewObjPref); + REGISTER_CMD_S(COMMAND_SELECT_PREVIEW_OBJ, CommandSelectPreviewObj); + REGISTER_CMD_SE(COMMAND_LOAD_FIRSTRECENT, "File\\Load First Recent", CommandLoadFirstRecent, true); + REGISTER_CMD_SE(COMMAND_FILE_MENU, "File Menu", CommandFileMenu, true); + REGISTER_CMD_S(COMMAND_REFRESH_UI_BAR, CommandRefreshUIBar); + REGISTER_CMD_S(COMMAND_RESTORE_UI_BAR, CommandRestoreUIBar); + REGISTER_CMD_S(COMMAND_SAVE_UI_BAR, CommandSaveUIBar); + REGISTER_CMD_S(COMMAND_UPDATE_TOOLBAR, CommandUpdateToolBar); + REGISTER_CMD_S(COMMAND_UPDATE_CAPTION, CommandUpdateCaption); + REGISTER_SUB_CMD_SE(COMMAND_CHANGE_TARGET, "Change Target", CommandChangeTarget, true); + APPEND_SUB_CMD(BONES_PREFIX, xr_string(BONES_PREFIX), 0); + APPEND_SUB_CMD(MOTIONS_PREFIX, xr_string(MOTIONS_PREFIX), 0); + APPEND_SUB_CMD(OBJECT_PREFIX, xr_string(OBJECT_PREFIX), 0); + APPEND_SUB_CMD(SURFACES_PREFIX, xr_string(SURFACES_PREFIX), 0); REGISTER_SUB_CMD_END; -} +} -char* CActorMain::GetCaption() +char *CActorMain::GetCaption() { - return ATools->GetEditFileName().IsEmpty()?"noname":ATools->GetEditFileName().c_str(); + return ATools->GetEditFileName().IsEmpty() ? "noname" : ATools->GetEditFileName().c_str(); } bool __fastcall CActorMain::ApplyShortCut(WORD Key, TShiftState Shift) { - return inherited::ApplyShortCut(Key,Shift); + return inherited::ApplyShortCut(Key, Shift); } + //--------------------------------------------------------------------------- bool __fastcall CActorMain::ApplyGlobalShortCut(WORD Key, TShiftState Shift) { - return inherited::ApplyGlobalShortCut(Key,Shift); + return inherited::ApplyGlobalShortCut(Key, Shift); } + //--------------------------------------------------------------------------- void CActorMain::RealUpdateScene() { - inherited::RealUpdateScene (); + inherited::RealUpdateScene(); } + //--------------------------------------------------------------------------- void CActorMain::ResetStatus() { - VERIFY(m_bReady); - if (fraBottomBar->paStatus->Caption!=""){ - fraBottomBar->paStatus->Caption=""; fraBottomBar->paStatus->Repaint(); + VERIFY(m_bReady); + if (fraBottomBar->paStatus->Caption!="") + { + fraBottomBar->paStatus->Caption = ""; + fraBottomBar->paStatus->Repaint(); } } + void CActorMain::SetStatus(LPSTR s, bool bOutLog) { - VERIFY(m_bReady); + VERIFY(m_bReady); if (fraBottomBar->paStatus->Caption!=s) { - fraBottomBar->paStatus->Caption=s; fraBottomBar->paStatus->Repaint(); - if (bOutLog&&s&&s[0]) ELog.Msg(mtInformation,s); + fraBottomBar->paStatus->Caption = s; + fraBottomBar->paStatus->Repaint(); + if (bOutLog&&s&&s[0]) + ELog.Msg(mtInformation, s); } } void CActorMain::ProgressDraw() { - fraBottomBar->RedrawBar(); + fraBottomBar->RedrawBar(); } + //--------------------------------------------------------------------------- void CActorMain::OutCameraPos() { - VERIFY(m_bReady); + VERIFY(m_bReady); AnsiString s; - const Fvector& c = EDevice.m_Camera.GetPosition(); - s.sprintf("C: %3.1f, %3.1f, %3.1f",c.x,c.y,c.z); -// const Fvector& hpb = EDevice.m_Camera.GetHPB(); -// s.sprintf(" Cam: %3.1f°, %3.1f°, %3.1f°",rad2deg(hpb.y),rad2deg(hpb.x),rad2deg(hpb.z)); - fraBottomBar->paCamera->Caption=s; fraBottomBar->paCamera->Repaint(); + const Fvector &c = EDevice.m_Camera.GetPosition(); + s.sprintf("C: %3.1f, %3.1f, %3.1f", c.x, c.y, c.z); + // const Fvector& hpb = EDevice.m_Camera.GetHPB(); + // s.sprintf(" Cam: %3.1f°, %3.1f°, %3.1f°",rad2deg(hpb.y),rad2deg(hpb.x),rad2deg(hpb.z)); + fraBottomBar->paCamera->Caption = s; + fraBottomBar->paCamera->Repaint(); } + //--------------------------------------------------------------------------- void CActorMain::OutUICursorPos() { - VERIFY(fraBottomBar); - AnsiString s; POINT pt; + VERIFY(fraBottomBar); + AnsiString s; + POINT pt; GetCursorPos(&pt); - s.sprintf("Cur: %d, %d",pt.x,pt.y); - fraBottomBar->paUICursor->Caption=s; fraBottomBar->paUICursor->Repaint(); + s.sprintf("Cur: %d, %d", pt.x, pt.y); + fraBottomBar->paUICursor->Caption = s; + fraBottomBar->paUICursor->Repaint(); } + //--------------------------------------------------------------------------- void CActorMain::OutGridSize() { - VERIFY(fraBottomBar); + VERIFY(fraBottomBar); AnsiString s; - s.sprintf("Grid: %1.1f",EPrefs->grid_cell_size); - fraBottomBar->paGridSquareSize->Caption=s; fraBottomBar->paGridSquareSize->Repaint(); + s.sprintf("Grid: %1.1f", EPrefs->grid_cell_size); + fraBottomBar->paGridSquareSize->Caption = s; + fraBottomBar->paGridSquareSize->Repaint(); } + //--------------------------------------------------------------------------- void CActorMain::OutInfo() { - fraBottomBar->paSel->Caption = Tools->GetInfo(); + fraBottomBar->paSel->Caption = Tools->GetInfo(); } + //--------------------------------------------------------------------------- void CActorMain::RealQuit() { - frmMain->Close(); + frmMain->Close(); } + //--------------------------------------------------------------------------- -void CAEPreferences::Load(CInifile* I) +void CAEPreferences::Load(CInifile *I) { - inherited::Load(I); + inherited::Load(I); - bAlwaysShowKeyBar12 = R_BOOL_SAFE ("ae_prefs","always_show_keybar12" ,bAlwaysShowKeyBar12 ); - bAlwaysShowKeyBar34 = R_BOOL_SAFE ("ae_prefs","always_show_keybar34" ,bAlwaysShowKeyBar34 ); + bAlwaysShowKeyBar12 = R_BOOL_SAFE("ae_prefs", "always_show_keybar12", bAlwaysShowKeyBar12); + bAlwaysShowKeyBar34 = R_BOOL_SAFE("ae_prefs", "always_show_keybar34", bAlwaysShowKeyBar34); } -void CAEPreferences::Save(CInifile* I) +void CAEPreferences::Save(CInifile *I) { - inherited::Save(I); - - I->w_bool ("ae_prefs","always_show_keybar12", bAlwaysShowKeyBar12 ); - I->w_bool ("ae_prefs","always_show_keybar34", bAlwaysShowKeyBar34 ); + inherited::Save(I); + I->w_bool("ae_prefs", "always_show_keybar12", bAlwaysShowKeyBar12); + I->w_bool("ae_prefs", "always_show_keybar34", bAlwaysShowKeyBar34); } + extern ECORE_API BOOL g_force16BitTransformQuant; -void CAEPreferences::FillProp(PropItemVec& props) + +void CAEPreferences::FillProp(PropItemVec &props) { - inherited::FillProp(props); + inherited::FillProp(props); - PHelper().CreateBOOL (props,"Keybar\\show footsteps 12", &bAlwaysShowKeyBar12); - PHelper().CreateBOOL (props,"Keybar\\show footsteps 34", &bAlwaysShowKeyBar34); + PHelper().CreateBOOL(props, "Keybar\\show footsteps 12", &bAlwaysShowKeyBar12); + PHelper().CreateBOOL(props, "Keybar\\show footsteps 34", &bAlwaysShowKeyBar34); - PHelper().CreateBOOL (props,"Tools\\MotionExport\\Force 16bit MotionT", &g_force16BitTransformQuant); + PHelper().CreateBOOL(props, "Tools\\MotionExport\\Force 16bit MotionT", &g_force16BitTransformQuant); } + diff --git a/src/editors/ActorEditor/UI_ActorMain.h b/src/editors/ActorEditor/UI_ActorMain.h index 171c8e70dca..cec72388d2c 100644 --- a/src/editors/ActorEditor/UI_ActorMain.h +++ b/src/editors/ActorEditor/UI_ActorMain.h @@ -2,10 +2,11 @@ #ifndef UI_ActorMainH #define UI_ActorMainH //--------------------------------------------------------------------------- -#include "../Ecore/editor/ui_main.h" +#include "editors/Ecore/editor/ui_main.h" -enum { - COMMAND_EXTFIRST_EXT = COMMAND_MAIN_LAST-1, +enum +{ + COMMAND_EXTFIRST_EXT = COMMAND_MAIN_LAST-1, COMMAND_MAKE_PREVIEW, COMMAND_IMPORT, @@ -17,7 +18,7 @@ enum { COMMAND_BATCH_CONVERT, COMMAND_PREVIEW_OBJ_PREF, COMMAND_SELECT_PREVIEW_OBJ, - COMMAND_SHOW_CLIPMAKER, + COMMAND_SHOW_CLIPMAKER, COMMAND_OPTIMIZE_MOTIONS, COMMAND_MAKE_THUMBNAIL, COMMAND_CHANGE_TARGET, @@ -25,50 +26,62 @@ enum { COMMAND_FILE_MENU, COMMAND_LOAD_FIRSTRECENT, }; + //------------------------------------------------------------------------------ -class CActorMain: public TUI{ - typedef TUI inherited; +class CActorMain: public TUI +{ + typedef TUI inherited; - virtual void RealUpdateScene (); - virtual void RealQuit (); + virtual void RealUpdateScene(); + virtual void RealQuit(); public: - CActorMain (); - virtual ~CActorMain (); + CActorMain(); + virtual ~CActorMain(); + + virtual LPSTR GetCaption(); - virtual LPSTR GetCaption (); + virtual void ResetStatus(); + virtual void SetStatus(LPSTR s, bool bOutLog); + virtual void ProgressDraw(); + virtual void OutCameraPos(); + virtual void OutUICursorPos(); + virtual void OutGridSize(); + virtual void OutInfo(); - virtual void ResetStatus (); - virtual void SetStatus (LPSTR s, bool bOutLog); - virtual void ProgressDraw (); - virtual void OutCameraPos (); - virtual void OutUICursorPos (); - virtual void OutGridSize (); - virtual void OutInfo (); + virtual LPCSTR EditorName() + { + return "actor"; + } - virtual LPCSTR EditorName (){return "actor";} - virtual LPCSTR EditorDesc (){return "Actor Editor";} + virtual LPCSTR EditorDesc() + { + return "Actor Editor"; + } - virtual bool ApplyShortCut (WORD Key, TShiftState Shift); - virtual bool ApplyGlobalShortCut (WORD Key, TShiftState Shift); + virtual bool ApplyShortCut(WORD Key, TShiftState Shift); + virtual bool ApplyGlobalShortCut(WORD Key, TShiftState Shift); // commands - virtual void RegisterCommands (); -}; -extern CActorMain*& AUI; + virtual void RegisterCommands(); +}; + +extern CActorMain *&AUI; class CAEPreferences :public CCustomPreferences { -typedef CCustomPreferences inherited; + typedef CCustomPreferences inherited; public: - CAEPreferences():bAlwaysShowKeyBar12(FALSE),bAlwaysShowKeyBar34(FALSE){} - BOOL bAlwaysShowKeyBar12; - BOOL bAlwaysShowKeyBar34; + CAEPreferences(): bAlwaysShowKeyBar12(FALSE), bAlwaysShowKeyBar34(FALSE) {} - virtual void Load (CInifile*); - virtual void Save (CInifile*); - virtual void FillProp (PropItemVec& items); + BOOL bAlwaysShowKeyBar12; + BOOL bAlwaysShowKeyBar34; + virtual void Load(CInifile *); + virtual void Save(CInifile *); + virtual void FillProp(PropItemVec &items); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ActorEditor/UI_ActorTools.cpp b/src/editors/ActorEditor/UI_ActorTools.cpp index f15fd84c2b4..b3110d122b8 100644 --- a/src/editors/ActorEditor/UI_ActorTools.cpp +++ b/src/editors/ActorEditor/UI_ActorTools.cpp @@ -4,126 +4,136 @@ #pragma hdrstop #include "UI_ActorTools.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EditMesh.h" -#include "../xrEProps/ChoseForm.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditMesh.h" +#include "editors/xrEProps/ChoseForm.h" +#include "editors/ECore/Editor/ui_main.h" #include "leftbar.h" -#include "../xrEProps/PropertiesList.h" -#include "motion.h" +#include "editors/xrEProps/PropertiesList.h" +#include "xrCore/Animation/Motion.hpp" #include "bone.h" -#include "../ECore/Editor/library.h" -#include "fmesh.h" +#include "editors/ECore/Editor/library.h" +#include "xrCore/fmesh.hpp" #include "KeyBar.h" #include "main.h" -#include "../xrEProps/folderlib.h" -#include "../../Layers/xrRender/SkeletonAnimated.h" -#include "../xrEProps/ItemList.h" -#include "../ECore/Editor/ImageManager.h" +#include "editors/xrEProps/folderlib.h" +#include "Layers/xrRender/SkeletonAnimated.h" +#include "editors/xrEProps/ItemList.h" +#include "editors/ECore/Editor/ImageManager.h" -#include "../../xrphysics/iphworld.h" -#include "../../xrcdb/xr_area.h" +#include "xrPhysics/iphworld.h" +#include "xrCDB/xr_area.h" -CActorTools*& ATools=(CActorTools*)Tools; +CActorTools *&ATools = (CActorTools*)Tools; //------------------------------------------------------------------------------ #define CHECK_SNAP(R,A,C){ R+=A; if(fabsf(R)>=C){ A=snapto(R,C); R=0; }else{A=0;}} -void EngineModel::DeleteVisual () +void EngineModel::DeleteVisual() { - DeletePhysicsShell (); - Render->model_Delete(m_pVisual); - m_pVisual = 0; - m_pBlend = 0; + DeletePhysicsShell(); + Render->model_Delete(m_pVisual); + m_pVisual = 0; + m_pBlend = 0; } - - - - -void EngineModel:: OnRender () +void EngineModel::OnRender() { - UpdateObjectXform(Fmatrix()); + UpdateObjectXform(Fmatrix()); } -void PreviewModel::RestoreParams(TFormStorage* s) -{ + +void PreviewModel::RestoreParams(TFormStorage *s) +{ m_Props->RestoreParams(s); - m_LastObjectName = s->ReadString ("preview_name",""); + m_LastObjectName = s->ReadString("preview_name", ""); int val; - val = s->ReadInteger("preview_speed",0); m_fSpeed = *((float*)&val); - val = s->ReadInteger("preview_segment",0); m_fSegment = *((float*)&val); - m_Flags.assign (s->ReadInteger("preview_flags",0)); - m_ScrollAxis = (EScrollAxis)s->ReadInteger("preview_scaxis",0); + val = s->ReadInteger("preview_speed", 0); + m_fSpeed = *((float*)&val); + val = s->ReadInteger("preview_segment", 0); + m_fSegment = *((float*)&val); + m_Flags.assign(s->ReadInteger("preview_flags", 0)); + m_ScrollAxis = (EScrollAxis)s->ReadInteger("preview_scaxis", 0); } -void PreviewModel::SaveParams(TFormStorage* s) +void PreviewModel::SaveParams(TFormStorage *s) { m_Props->SaveParams(s); - s->WriteString ("preview_name", m_LastObjectName); - s->WriteInteger ("preview_speed", *((int*)&m_fSpeed)); - s->WriteInteger ("preview_segment", *((int*)&m_fSegment)); - s->WriteInteger ("preview_flags", m_Flags.get()); - s->WriteInteger ("preview_scaxis", m_ScrollAxis); + s->WriteString("preview_name", m_LastObjectName); + s->WriteInteger("preview_speed", *((int*)&m_fSpeed)); + s->WriteInteger("preview_segment", *((int*)&m_fSegment)); + s->WriteInteger("preview_flags", m_Flags.get()); + s->WriteInteger("preview_scaxis", m_ScrollAxis); } void PreviewModel::OnDestroy() { - TProperties::DestroyForm(m_Props); + TProperties::DestroyForm(m_Props); } void PreviewModel::OnCreate() { - m_Props = TProperties::CreateForm("Preview prefs",0,alNone); + m_Props = TProperties::CreateForm("Preview prefs", 0, alNone); } void PreviewModel::Clear() { Lib.RemoveEditObject(m_pObject); } + void PreviewModel::SelectObject() { LPCSTR fn; - if (!TfrmChoseItem::SelectItem(smObject,fn,1,m_LastObjectName.c_str())) return; + if (!TfrmChoseItem::SelectItem(smObject, fn, 1, m_LastObjectName.c_str())) + return; Lib.RemoveEditObject(m_pObject); m_pObject = Lib.CreateEditObject(fn); - if (!m_pObject) ELog.DlgMsg(mtError,"Object '%s' can't find in object library.",fn); - else m_LastObjectName = fn; + if (!m_pObject) + ELog.DlgMsg(mtError, "Object '%s' can't find in object library.", fn); + else + m_LastObjectName = fn; } -xr_token sa_token [ ]={ - { "+Z", PreviewModel::saZp }, - { "-Z", PreviewModel::saZn }, - { "+X", PreviewModel::saXp }, - { "-X", PreviewModel::saXn }, - { 0, 0 } +xr_token sa_token [ ] = { + {"+Z", PreviewModel::saZp}, + {"-Z", PreviewModel::saZn}, + {"+X", PreviewModel::saXp}, + {"-X", PreviewModel::saXn}, + {0, 0} }; void PreviewModel::SetPreferences() { - PropItemVec items; - PHelper().CreateFlag32 (items, "Scroll", &m_Flags, pmScroll); - PHelper().CreateFloat (items, "Speed (m/c)", &m_fSpeed, -10000.f,10000.f,0.01f,2); - PHelper().CreateFloat (items, "Segment (m)", &m_fSegment, -10000.f,10000.f,0.01f,2); - PHelper().CreateToken32 (items, "Scroll axis", (u32*)&m_ScrollAxis, sa_token); - m_Props->AssignItems (items); - m_Props->ShowProperties (); + PropItemVec items; + PHelper().CreateFlag32(items, "Scroll", &m_Flags, pmScroll); + PHelper().CreateFloat(items, "Speed (m/c)", &m_fSpeed, -10000.f, 10000.f, 0.01f, 2); + PHelper().CreateFloat(items, "Segment (m)", &m_fSegment, -10000.f, 10000.f, 0.01f, 2); + PHelper().CreateToken32(items, "Scroll axis", (u32*)&m_ScrollAxis, sa_token); + m_Props->AssignItems(items); + m_Props->ShowProperties(); } + void PreviewModel::Render() { - if (m_pObject){ + if (m_pObject) + { float angle; - switch (m_ScrollAxis){ - case saZp: angle = 0; break; - case saZn: angle = PI; break; - case saXp: angle = PI_DIV_2;break; - case saXn: angle =-PI_DIV_2;break; - default: THROW; + switch (m_ScrollAxis) + { + case saZp: angle = 0; + break; + case saZn: angle = PI; + break; + case saXp: angle = PI_DIV_2; + break; + case saXn: angle = -PI_DIV_2; + break; + default: THROW; } - Fmatrix R,T; - R.rotateY(angle); - T.translate(m_vPosition); + Fmatrix R, T; + R.rotateY(angle); + T.translate(m_vPosition); T.mulA_43(R); - m_pObject->RenderSingle(T); + m_pObject->RenderSingle(T); } } @@ -132,147 +142,171 @@ void PreviewModel::Update() if (m_Flags.is(pmScroll)) { m_vPosition.z += m_fSpeed*EDevice.fTimeDelta; - if (m_vPosition.z>m_fSegment) m_vPosition.z-=m_fSegment; + if (m_vPosition.z>m_fSegment) + m_vPosition.z -= m_fSegment; } } #include "../ECore/Editor/EThumbnail.h" + void _SynchronizeTextures() -{ - FS_FileSet M_THUM; - FS.file_list(M_THUM,_textures_,FS_ListFiles|FS_ClampExt,"*.thm"); - - FS_FileSetIt it = M_THUM.begin(); - FS_FileSetIt _E = M_THUM.end(); - for (; it!=_E; it++){ - ETextureThumbnail* THM=0; +{ + FS_FileSet M_THUM; + FS.file_list(M_THUM,_textures_, FS_ListFiles|FS_ClampExt, "*.thm"); + + FS_FileSetIt it = M_THUM.begin(); + FS_FileSetIt _E = M_THUM.end(); + for (; it!=_E; it++) + { + ETextureThumbnail*THM = 0; THM = xr_new(it->name.c_str()); - STextureParams& fmt = THM->_Format(); - if (fmt.material==STextureParams::tmOrenNayar_Blin){ - fmt.material=STextureParams::tmBlin_Phong; - THM->Save(0,0); + STextureParams &fmt = THM->_Format(); + if (fmt.material==STextureParams::tmOrenNayar_Blin) + { + fmt.material = STextureParams::tmBlin_Phong; + THM->Save(0, 0); } - xr_delete(THM); + xr_delete(THM); } } CActorTools::CActorTools() { - //. _SynchronizeTextures(); - m_Props = 0; - m_pEditObject = 0; - m_bObjectModified = false; - m_ObjectItems = 0; - m_bReady = false; - m_KeyBar = 0; - m_Flags.zero (); - m_EditMode = emObject; - fFogness = 0.9f; - dwFogColor = 0xffffffff; + //. _SynchronizeTextures(); + m_Props = 0; + m_pEditObject = 0; + m_bObjectModified = false; + m_ObjectItems = 0; + m_bReady = false; + m_KeyBar = 0; + m_Flags.zero(); + m_EditMode = emObject; + fFogness = 0.9f; + dwFogColor = 0xffffffff; } + //--------------------------------------------------------------------------- -CActorTools::~CActorTools() -{ -} +CActorTools::~CActorTools() {} + //--------------------------------------------------------------------------- bool CActorTools::OnCreate() { - inherited::OnCreate (); + inherited::OnCreate(); // props - m_ObjectItems = TItemList::CreateForm("",fraLeftBar->paObjectProps,alClient,TItemList::ilDragCustom|TItemList::ilMultiSelect|TItemList::ilSuppressStatus); - m_ObjectItems->SetOnItemsFocusedEvent(fastdelegate::bind(this,&CActorTools::OnObjectItemFocused)); - m_Props = TProperties::CreateForm("",fraLeftBar->paItemProps,alClient,fastdelegate::bind(this,&CActorTools::OnItemModified)); + m_ObjectItems = TItemList::CreateForm("", fraLeftBar->paObjectProps, alClient, TItemList::ilDragCustom|TItemList::ilMultiSelect|TItemList::ilSuppressStatus); + m_ObjectItems->SetOnItemsFocusedEvent(fastdelegate::bind(this, &CActorTools::OnObjectItemFocused)); + m_Props = TProperties::CreateForm("", fraLeftBar->paItemProps, alClient, fastdelegate::bind(this, &CActorTools::OnItemModified)); m_PreviewObject.OnCreate(); // key bar - m_KeyBar = TfrmKeyBar::CreateKeyBar(frmMain->paMain); + m_KeyBar = TfrmKeyBar::CreateKeyBar(frmMain->paMain); + + OnDeviceCreate(); - OnDeviceCreate (); - return true; } void CActorTools::OnDestroy() { - inherited::OnDestroy(); + inherited::OnDestroy(); - TItemList::DestroyForm (m_ObjectItems); - TProperties::DestroyForm(m_Props); + TItemList::DestroyForm(m_ObjectItems); + TProperties::DestroyForm(m_Props); m_PreviewObject.OnDestroy(); m_PreviewObject.Clear(); m_RenderObject.Clear(); - xr_delete(m_pEditObject); + xr_delete(m_pEditObject); } + //--------------------------------------------------------------------------- void CActorTools::Modified() { - m_bObjectModified = true; - ExecCommand (COMMAND_UPDATE_CAPTION); + m_bObjectModified = true; + ExecCommand(COMMAND_UPDATE_CAPTION); } + //--------------------------------------------------------------------------- bool CActorTools::IfModified() { if (IsModified()) { - int mr = ELog.DlgMsg(mtConfirmation, "The '%s' has been modified.\nDo you want to save your changes?",GetEditFileName().c_str()); - switch(mr) + int mr = ELog.DlgMsg(mtConfirmation, "The '%s' has been modified.\nDo you want to save your changes?", GetEditFileName().c_str()); + switch (mr) { - case mrYes: if (!ExecCommand(COMMAND_SAVE)) return false; else{m_bObjectModified = false;}break; - case mrNo: m_bObjectModified = false; break; - case mrCancel: return false; + case mrYes: if (!ExecCommand(COMMAND_SAVE)) + return false; else + { + m_bObjectModified = false; + } + break; + case mrNo: m_bObjectModified = false; + break; + case mrCancel: return false; } } - return true; + return true; } + //--------------------------------------------------------------------------- void CActorTools::OnObjectModified() { - m_Flags.set (flUpdateGeometry,TRUE); - OnGeometryModified (); + m_Flags.set(flUpdateGeometry, TRUE); + OnGeometryModified(); } + //--------------------------------------------------------------------------- void CActorTools::SetPreviewObjectPrefs() { - m_PreviewObject.SetPreferences(); + m_PreviewObject.SetPreferences(); } + //--------------------------------------------------------------------------- -void CActorTools::SelectPreviewObject(bool bClear){ - if (bClear){ m_PreviewObject.Clear(); return; } +void CActorTools::SelectPreviewObject(bool bClear) +{ + if (bClear) + { + m_PreviewObject.Clear(); + return; + } m_PreviewObject.SelectObject(); } + //--------------------------------------------------------------------------- -void CActorTools::GetStatTime(float& a, float& b, float& c) +void CActorTools::GetStatTime(float &a, float &b, float &c) { - if (m_RenderObject.IsRenderable()&&fraLeftBar->ebRenderEngineStyle->Down&&m_RenderObject.m_pBlend){ - a = 0; - b = m_RenderObject.m_pBlend->timeTotal/m_RenderObject.m_pBlend->speed; + if (m_RenderObject.IsRenderable()&&fraLeftBar->ebRenderEngineStyle->Down&&m_RenderObject.m_pBlend) + { + a = 0; + b = m_RenderObject.m_pBlend->timeTotal/m_RenderObject.m_pBlend->speed; c = m_RenderObject.m_pBlend->timeCurrent/m_RenderObject.m_pBlend->speed; if (c>b) { - int cnt=iFloor(c/b); - c-=(cnt*b); + int cnt = iFloor(c/b); + c -= (cnt*b); } - }else + } + else { - if (fraLeftBar->ebRenderEditorStyle->Down&&m_pEditObject&&m_pEditObject->GetActiveSMotion()) + if (fraLeftBar->ebRenderEditorStyle->Down&&m_pEditObject&&m_pEditObject->GetActiveSMotion()) { - SAnimParams& P=m_pEditObject->m_SMParam; - a = P.min_t; - b = P.max_t; + SAnimParams &P = m_pEditObject->m_SMParam; + a = P.min_t; + b = P.max_t; c = P.t_current; - }else + } + else { - a = 0; + a = 0; b = 0; c = 0; } @@ -280,224 +314,237 @@ void CActorTools::GetStatTime(float& a, float& b, float& c) } CObjectSpace *os = 0; -void CActorTools::CreatePhysicsWorld ( ) + +void CActorTools::CreatePhysicsWorld() { - // m_pobject_matrix = obj_xform; + // m_pobject_matrix = obj_xform; VERIFY(!os); VERIFY(!physics_world()); set_mtl_lib(&GMLib); os = create_object_space(); - CRenderDeviceBase *rd = &EDevice ; - create_physics_world( false, os, 0, rd ); + CRenderDeviceBase *rd = &EDevice; + create_physics_world(false, os, 0, rd); } -void CActorTools::DestroyPhysicsWorld ( ) + +void CActorTools::DestroyPhysicsWorld() { - if(physics_world()) - destroy_physics_world(); - destroy_object_space( os ); + if (physics_world()) + destroy_physics_world(); + destroy_object_space(os); } -void CActorTools::PhysicsSimulate( ) +void CActorTools::PhysicsSimulate() { - - CreatePhysicsWorld( ); - if( fraLeftBar->ebRenderEngineStyle->Down ) - m_RenderObject.CreatePhysicsShell (&m_AVTransform) ; + CreatePhysicsWorld(); + if (fraLeftBar->ebRenderEngineStyle->Down) + m_RenderObject.CreatePhysicsShell(&m_AVTransform) ; else - m_pEditObject->CreatePhysicsShell (&m_AVTransform); + m_pEditObject->CreatePhysicsShell(&m_AVTransform); } -void CActorTools::PhysicsStopSimulate( ) -{ - m_RenderObject.DeletePhysicsShell (); - m_pEditObject->DeletePhysicsShell (); - DestroyPhysicsWorld( ); +void CActorTools::PhysicsStopSimulate() +{ + m_RenderObject.DeletePhysicsShell(); + m_pEditObject->DeletePhysicsShell(); + DestroyPhysicsWorld(); } - //--------------------------------------------------------------------------- //#include "d3dutils.h" //DU.DrawIdentSpherePart(false,true,0xffffffff,0xffff); #include "igame_persistent.h" #include "..\ECore\editor\d3dutils.h" -const u32 color_bone_sel_color =0xFFFFFFFF; -const u32 color_bone_norm_color =0xFFFFFF00; -const u32 color_bone_link_color =0xFFA0A000; -const u32 color_bone_sel_cm =0xFFFF0000; -const u32 color_bone_norm_cm =0xFF700000; -const float joint_size =0.025f; +const u32 color_bone_sel_color = 0xFFFFFFFF; +const u32 color_bone_norm_color = 0xFFFFFF00; +const u32 color_bone_link_color = 0xFFA0A000; +const u32 color_bone_sel_cm = 0xFFFF0000; +const u32 color_bone_norm_cm = 0xFF700000; +const float joint_size = 0.025f; void CActorTools::Render() { - if (!m_bReady) return; - PrepareLighting (); - m_PreviewObject.Render (); - if (m_pEditObject){ - m_RenderObject.OnRender(); + if (!m_bReady) + return; + PrepareLighting(); + m_PreviewObject.Render(); + if (m_pEditObject) + { + m_RenderObject.OnRender(); if (m_RenderObject.IsRenderable()&&fraLeftBar->ebRenderEngineStyle->Down) { - ::Render->model_RenderSingle(m_RenderObject.m_pVisual,m_RenderObject.ObjectXFORM(),m_RenderObject.m_fLOD); - RCache.set_xform_world (Fidentity); - if(EPrefs->object_flags.is(epoDrawJoints)) + ::Render->model_RenderSingle(m_RenderObject.m_pVisual, m_RenderObject.ObjectXFORM(), m_RenderObject.m_fLOD); + RCache.set_xform_world(Fidentity); + if (EPrefs->object_flags.is(epoDrawJoints)) { - CKinematics* K = dynamic_cast(m_RenderObject.m_pVisual); - if(K) + CKinematics *K = dynamic_cast(m_RenderObject.m_pVisual); + if (K) { u16 bcnt = K->LL_BoneCount(); - for(u16 bidx=0; bidxLL_GetTransform(bidx)); + Fmatrix M = Fmatrix().mul(m_RenderObject.ObjectXFORM(), K->LL_GetTransform(bidx)); - Fvector p1 = M.c; - u32 c_joint = /*(*b_it)->flags.is(CBone::flSelected)?color_bone_sel_color:*/color_bone_norm_color; - DU_impl.DrawJoint (p1,joint_size,c_joint); + Fvector p1 = M.c; + u32 c_joint = /*(*b_it)->flags.is(CBone::flSelected)?color_bone_sel_color:*/color_bone_norm_color; + DU_impl.DrawJoint(p1, joint_size, c_joint); if (EPrefs->object_flags.is(epoDrawBoneAxis)) { - DU_impl.DrawObjectAxis(M,0.03f,false); + DU_impl.DrawObjectAxis(M, 0.03f, false); } } } } - }else{ - // update transform matrix + } + else + { + // update transform matrix m_pEditObject->UpdateObjectXform(m_AVTransform); - m_pEditObject->RenderSkeletonSingle(m_AVTransform); + m_pEditObject->RenderSkeletonSingle(m_AVTransform); } } - inherited::Render (); + inherited::Render(); } + //--------------------------------------------------------------------------- void CActorTools::RenderEnvironment() { -/* - if (psDeviceFlags.is(rsEnvironment)){ - g_pGamePersistent->Environment().RenderSky (); - g_pGamePersistent->Environment().RenderClouds (); - } -*/ + /* + if (psDeviceFlags.is(rsEnvironment)){ + g_pGamePersistent->Environment().RenderSky (); + g_pGamePersistent->Environment().RenderClouds (); + } + */ } void CActorTools::OnFrame() { - if (!m_bReady) return; -//. if (m_KeyBar) m_KeyBar->UpdateBar(); + if (!m_bReady) + return; + //. if (m_KeyBar) m_KeyBar->UpdateBar(); m_PreviewObject.Update(); - if (m_pEditObject) + if (m_pEditObject) { - // update matrix - Fmatrix mTranslate,mRotate; - mRotate.setHPB (m_pEditObject->a_vRotate.y, m_pEditObject->a_vRotate.x, m_pEditObject->a_vRotate.z); - mTranslate.translate (m_pEditObject->a_vPosition); - m_AVTransform.mul (mTranslate,mRotate); + // update matrix + Fmatrix mTranslate, mRotate; + mRotate.setHPB(m_pEditObject->a_vRotate.y, m_pEditObject->a_vRotate.x, m_pEditObject->a_vRotate.z); + mTranslate.translate(m_pEditObject->a_vPosition); + m_AVTransform.mul(mTranslate, mRotate); - if(!fraLeftBar->ebRenderEngineStyle->Down) - m_pEditObject->OnFrame(); + if (!fraLeftBar->ebRenderEngineStyle->Down) + m_pEditObject->OnFrame(); - if(!m_KeyBar->auto_ch->Checked) + if (!m_KeyBar->auto_ch->Checked) { m_pEditObject->m_SMParam.t_current = float(m_KeyBar->anm_track->Position)/float(1000); } - // CKinematicsAnimated* KA = dynamic_cast(m_RenderObject.m_pVisual); - if ( m_RenderObject.IsRenderable()&&m_pEditObject->IsSkeleton() && m_RenderObject.m_pVisual ) + // CKinematicsAnimated* KA = dynamic_cast(m_RenderObject.m_pVisual); + if (m_RenderObject.IsRenderable()&&m_pEditObject->IsSkeleton()&&m_RenderObject.m_pVisual) { - - CKinematicsAnimated* KA = dynamic_cast(m_RenderObject.m_pVisual); - if( KA && !m_KeyBar->auto_ch->Checked && m_RenderObject.m_pBlend) + CKinematicsAnimated *KA = dynamic_cast(m_RenderObject.m_pVisual); + if (KA&&!m_KeyBar->auto_ch->Checked&&m_RenderObject.m_pBlend) { - float tm = float(m_KeyBar->anm_track->Position)/float(1000); - for (int k=0; kanm_track->Position)/float(1000); + for (int k = 0; kLL_PartBlendsCount(k)) + if (KA->LL_PartBlendsCount(k)) { - CBlend* B = KA->LL_PartBlend(k, 0); - B->timeCurrent = tm; + CBlend *B = KA->LL_PartBlend(k, 0); + B->timeCurrent = tm; } - } + } } - - IKinematics *K = m_RenderObject.m_pVisual->dcast_PKinematics(); - VERIFY( K ); - // K->Bone_Calculate (&K->LL_GetData(K->LL_GetBoneRoot()),&Fidentity); - if(!m_KeyBar->auto_ch->Checked) - K->Bone_Calculate (&K->LL_GetData(K->LL_GetBoneRoot()),&Fidentity); + + IKinematics *K = m_RenderObject.m_pVisual->dcast_PKinematics(); + VERIFY(K); + // K->Bone_Calculate (&K->LL_GetData(K->LL_GetBoneRoot()),&Fidentity); + if (!m_KeyBar->auto_ch->Checked) + K->Bone_Calculate(&K->LL_GetData(K->LL_GetBoneRoot()), &Fidentity); else - K->CalculateBones (TRUE); - } - + K->CalculateBones(TRUE); + } } - if (m_KeyBar) m_KeyBar->UpdateBar(); - + if (m_KeyBar) + m_KeyBar->UpdateBar(); + if (m_Flags.is(flRefreshShaders)) { - m_Flags.set(flRefreshShaders,FALSE); + m_Flags.set(flRefreshShaders, FALSE); m_pEditObject->OnDeviceDestroy(); } - + if (m_Flags.is(flRefreshSubProps)) { - m_Flags.set(flRefreshSubProps,FALSE); + m_Flags.set(flRefreshSubProps, FALSE); ListItemsVec items; - m_ObjectItems->GetSelected(0,items,false); - OnObjectItemFocused(items); + m_ObjectItems->GetSelected(0, items, false); + OnObjectItemFocused(items); } - - if (m_Flags.is(flRefreshProps)) + + if (m_Flags.is(flRefreshProps)) RealUpdateProperties(); - if(fraLeftBar->ebRenderEditorStyle->Down && !m_CurrentMotion.IsEmpty() && NULL==m_pEditObject->GetActiveSMotion()) + if (fraLeftBar->ebRenderEditorStyle->Down&&!m_CurrentMotion.IsEmpty()&&NULL==m_pEditObject->GetActiveSMotion()) { - AnsiString tmp = m_CurrentMotion; - m_CurrentMotion = ""; + AnsiString tmp = m_CurrentMotion; + m_CurrentMotion = ""; - SetCurrentMotion(tmp.c_str(), m_CurrentSlot); + SetCurrentMotion(tmp.c_str(), m_CurrentSlot); } - } void CActorTools::ZoomObject(BOOL bSelOnly) { - VERIFY(m_bReady); - if (m_pEditObject){ - Fbox BB; - switch(m_EditMode){ - case emBone:{ - BoneVec lst; - if (m_pEditObject->GetSelectedBones(lst)){ - BB.invalidate(); - for (BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++){ - Fvector C = {0,0,0}; - float r = 0.5f; - switch ((*b_it)->shape.type){ - case SBoneShape::stBox: - r = _max(_max((*b_it)->shape.box.m_halfsize.x,(*b_it)->shape.box.m_halfsize.y),(*b_it)->shape.box.m_halfsize.z); - C = (*b_it)->shape.box.m_translate; - break; - case SBoneShape::stSphere: - r = (*b_it)->shape.sphere.R; - C = (*b_it)->shape.sphere.P; - break; - case SBoneShape::stCylinder: - r = _max((*b_it)->shape.cylinder.m_height,(*b_it)->shape.cylinder.m_radius); - C = (*b_it)->shape.cylinder.m_center; - break; + VERIFY(m_bReady); + if (m_pEditObject) + { + Fbox BB; + switch (m_EditMode) + { + case emBone: + { + BoneVec lst; + if (m_pEditObject->GetSelectedBones(lst)) + { + BB.invalidate(); + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); b_it++) + { + Fvector C = {0,0,0}; + float r = 0.5f; + switch ((*b_it)->shape.type) + { + case SBoneShape::stBox: + r = _max(_max((*b_it)->shape.box.m_halfsize.x, (*b_it)->shape.box.m_halfsize.y), (*b_it)->shape.box.m_halfsize.z); + C = (*b_it)->shape.box.m_translate; + break; + case SBoneShape::stSphere: + r = (*b_it)->shape.sphere.R; + C = (*b_it)->shape.sphere.P; + break; + case SBoneShape::stCylinder: + r = _max((*b_it)->shape.cylinder.m_height, (*b_it)->shape.cylinder.m_radius); + C = (*b_it)->shape.cylinder.m_center; + break; + } + (*b_it)->_LTransform().transform_tiny(C); + m_AVTransform.transform_tiny(C); + Fbox bb; + bb.set(C, C); + bb.grow(r); + BB.merge(bb); } - (*b_it)->_LTransform().transform_tiny (C); - m_AVTransform.transform_tiny (C); - Fbox bb; bb.set(C,C); bb.grow(r); - BB.merge (bb); } } - }break; - default: - BB = m_pEditObject->GetBox(); + break; + default: + BB = m_pEditObject->GetBox(); } EDevice.m_Camera.ZoomExtents(BB); } @@ -507,91 +554,100 @@ void CActorTools::PrepareLighting() { // add directional light Flight L; - ZeroMemory(&L,sizeof(Flight)); + ZeroMemory(&L, sizeof(Flight)); L.type = D3DLIGHT_DIRECTIONAL; - L.diffuse.set(1,1,1,1); - L.direction.set(1,-1,1); L.direction.normalize(); - EDevice.SetLight(0,L); - EDevice.LightEnable(0,true); - - L.diffuse.set(0.2,0.2,0.2,1); - L.direction.set(-1,-1,-1); L.direction.normalize(); - EDevice.SetLight(1,L); - EDevice.LightEnable(1,true); - - L.diffuse.set(0.2,0.2,0.2,1); - L.direction.set(1,-1,-1); L.direction.normalize(); - EDevice.SetLight(2,L); - EDevice.LightEnable(2,true); - - L.diffuse.set(0.2,0.2,0.2,1); - L.direction.set(-1,-1,1); L.direction.normalize(); - EDevice.SetLight(3,L); - EDevice.LightEnable(3,true); - - L.diffuse.set(1.0,0.4,0.3,1); - L.direction.set(0,1,0); L.direction.normalize(); - EDevice.SetLight(4,L); - EDevice.LightEnable(4,true); - - L.diffuse.set(0.3,1.0,0.4,1); - L.direction.set(-1,-1,-1); L.direction.normalize(); - EDevice.SetLight(5,L); - EDevice.LightEnable(5,true); + L.diffuse.set(1, 1, 1, 1); + L.direction.set(1, -1, 1); + L.direction.normalize(); + EDevice.SetLight(0, L); + EDevice.LightEnable(0, true); + + L.diffuse.set(0.2, 0.2, 0.2, 1); + L.direction.set(-1, -1, -1); + L.direction.normalize(); + EDevice.SetLight(1, L); + EDevice.LightEnable(1, true); + + L.diffuse.set(0.2, 0.2, 0.2, 1); + L.direction.set(1, -1, -1); + L.direction.normalize(); + EDevice.SetLight(2, L); + EDevice.LightEnable(2, true); + + L.diffuse.set(0.2, 0.2, 0.2, 1); + L.direction.set(-1, -1, 1); + L.direction.normalize(); + EDevice.SetLight(3, L); + EDevice.LightEnable(3, true); + + L.diffuse.set(1.0, 0.4, 0.3, 1); + L.direction.set(0, 1, 0); + L.direction.normalize(); + EDevice.SetLight(4, L); + EDevice.LightEnable(4, true); + + L.diffuse.set(0.3, 1.0, 0.4, 1); + L.direction.set(-1, -1, -1); + L.direction.normalize(); + EDevice.SetLight(5, L); + EDevice.LightEnable(5, true); } void CActorTools::OnDeviceCreate() { - if (m_pEditObject){ - m_pEditObject->OnDeviceCreate(); + if (m_pEditObject) + { + m_pEditObject->OnDeviceCreate(); MakePreview(); } } -void CActorTools::OnDeviceDestroy(){ - if (m_pEditObject){ - m_pEditObject->OnDeviceDestroy(); +void CActorTools::OnDeviceDestroy() +{ + if (m_pEditObject) + { + m_pEditObject->OnDeviceDestroy(); m_RenderObject.DeleteVisual(); } } void CActorTools::Clear() { - inherited::Clear (); - m_CurrentMotion = ""; - m_CurrentSlot = 0; + inherited::Clear(); + m_CurrentMotion = ""; + m_CurrentSlot = 0; // delete visuals - if(m_pEditObject) - m_pEditObject->DeletePhysicsShell(); + if (m_pEditObject) + m_pEditObject->DeletePhysicsShell(); xr_delete(m_pEditObject); m_RenderObject.Clear(); -// m_PreviewObject.Clear(); + // m_PreviewObject.Clear(); m_ObjectItems->ClearList(); m_Props->ClearProperties(); - m_bObjectModified = false; - m_Flags.set (flUpdateGeometry|flUpdateMotionDefs|flUpdateMotionKeys|flReadOnlyMode,FALSE); - m_EditMode = emObject; + m_bObjectModified = false; + m_Flags.set(flUpdateGeometry|flUpdateMotionDefs|flUpdateMotionKeys|flReadOnlyMode, FALSE); + m_EditMode = emObject; - UI->RedrawScene (); + UI->RedrawScene(); } bool CActorTools::Import(LPCSTR initial, LPCSTR obj_name) { - string_path full_name; + string_path full_name; if (initial) - FS.update_path (full_name,initial,obj_name); + FS.update_path(full_name, initial, obj_name); else - strcpy(full_name ,obj_name); + strcpy(full_name, obj_name); - VERIFY(m_bReady); - CEditableObject* O = xr_new(obj_name); - if (O->Load(full_name)) + VERIFY(m_bReady); + CEditableObject *O = xr_new(obj_name); + if (O->Load(full_name)) { - O->m_objectFlags.set(CEditableObject::eoDynamic,TRUE); - O->m_objectFlags.set(CEditableObject::eoProgressive,TRUE); + O->m_objectFlags.set(CEditableObject::eoDynamic, TRUE); + O->m_objectFlags.set(CEditableObject::eoProgressive, TRUE); xr_delete(m_pEditObject); m_pEditObject = O; // delete visual @@ -600,8 +656,10 @@ bool CActorTools::Import(LPCSTR initial, LPCSTR obj_name) UpdateProperties(); return true; - }else{ - ELog.DlgMsg(mtError,"Can't load object file '%s'.",obj_name); + } + else + { + ELog.DlgMsg(mtError, "Can't load object file '%s'.", obj_name); } xr_delete(O); @@ -610,23 +668,26 @@ bool CActorTools::Import(LPCSTR initial, LPCSTR obj_name) bool CActorTools::Load(LPCSTR obj_name) { - xr_string full_name; - full_name = obj_name; + xr_string full_name; + full_name = obj_name; - VERIFY(m_bReady); - CEditableObject* O = xr_new(obj_name); - if (FS.exist(full_name.c_str())&&O->Load(full_name.c_str())){ + VERIFY(m_bReady); + CEditableObject *O = xr_new(obj_name); + if (FS.exist(full_name.c_str())&&O->Load(full_name.c_str())) + { xr_delete(m_pEditObject); - m_pEditObject = O; - m_pEditObject->Optimize (); + m_pEditObject = O; + m_pEditObject->Optimize(); // delete visual m_RenderObject.Clear(); - fraLeftBar->SetRenderStyle(false); + fraLeftBar->SetRenderStyle(false); UpdateProperties(); return true; - }else{ - ELog.DlgMsg(mtError,"Can't load object file '%s'.",obj_name); + } + else + { + ELog.DlgMsg(mtError, "Can't load object file '%s'.", obj_name); } xr_delete(O); @@ -635,39 +696,43 @@ bool CActorTools::Load(LPCSTR obj_name) bool CActorTools::Save(LPCSTR obj_name, bool bInternal) { - xr_string full_name; - full_name = obj_name; - VERIFY(m_bReady); - if (m_pEditObject){ - EFS.MarkFile (full_name.c_str(),true); - if (m_pEditObject->Save(full_name.c_str())) + xr_string full_name; + full_name = obj_name; + VERIFY(m_bReady); + if (m_pEditObject) + { + EFS.MarkFile(full_name.c_str(), true); + if (m_pEditObject->Save(full_name.c_str())) { - if (!bInternal) - m_bObjectModified = false; - return true; + if (!bInternal) + m_bObjectModified = false; + return true; } } - return false; + return false; } bool CActorTools::ExportOGF(LPCSTR name) { - VERIFY(m_bReady); - if (m_pEditObject&&m_pEditObject->ExportOGF(name, 4)) return true; + VERIFY(m_bReady); + if (m_pEditObject&&m_pEditObject->ExportOGF(name, 4)) + return true; return false; } bool CActorTools::ExportOMF(LPCSTR name) { - VERIFY(m_bReady); - if (m_pEditObject&&m_pEditObject->ExportOMF(name)) return true; + VERIFY(m_bReady); + if (m_pEditObject&&m_pEditObject->ExportOMF(name)) + return true; return false; } bool CActorTools::ExportOBJ(LPCSTR name) { - VERIFY(m_bReady); - if (m_pEditObject&&m_pEditObject->ExportOBJ(name)) return true; + VERIFY(m_bReady); + if (m_pEditObject&&m_pEditObject->ExportOBJ(name)) + return true; return false; } @@ -676,50 +741,53 @@ bool CActorTools::ExportCPP(LPCSTR name) { if (m_pEditObject) { - EditMeshVec& meshes = m_pEditObject->Meshes(); + EditMeshVec &meshes = m_pEditObject->Meshes(); string128 tmp; - IWriter* W = FS.w_open(name); + IWriter *W = FS.w_open(name); - for (EditMeshIt m_it=meshes.begin(); m_it!=meshes.end(); m_it++) + for (EditMeshIt m_it = meshes.begin(); m_it!=meshes.end(); m_it++) { - CEditableMesh* mesh = *m_it; - const st_Face* faces= mesh->GetFaces(); - const Fvector* verts= mesh->GetVertices(); - sprintf (tmp,"MESH %s {",mesh->Name().c_str()); - W->w_string (tmp); - sprintf (tmp,"\tVERTEX_COUNT %d",mesh->GetVCount()); - W->w_string (tmp); - sprintf (tmp,"\tFACE_COUNT %d",mesh->GetFCount()); - W->w_string (tmp); - W->w_string ("\tconst Fvector vertices[VERTEX_COUNT] = {"); - for (u32 v_id=0; v_idGetVCount(); v_id++) + CEditableMesh *mesh = *m_it; + const st_Face *faces = mesh->GetFaces(); + const Fvector *verts = mesh->GetVertices(); + sprintf(tmp, "MESH %s {", mesh->Name().c_str()); + W->w_string(tmp); + sprintf(tmp, "\tVERTEX_COUNT %d", mesh->GetVCount()); + W->w_string(tmp); + sprintf(tmp, "\tFACE_COUNT %d", mesh->GetFCount()); + W->w_string(tmp); + W->w_string("\tconst Fvector vertices[VERTEX_COUNT] = {"); + for (u32 v_id = 0; v_idGetVCount(); v_id++) { - sprintf (tmp,"\t\t{% 3.6f,\t% 3.6f,\t% 3.6f},",VPUSH(verts[v_id])); - W->w_string (tmp); + sprintf(tmp, "\t\t{% 3.6f,\t% 3.6f,\t% 3.6f},",VPUSH(verts[v_id])); + W->w_string(tmp); } - W->w_string ("\t}"); - W->w_string ("\tconst u16 faces[FACE_COUNT*3] = {"); - for (u32 f_id=0; f_idGetFCount(); f_id++) + W->w_string("\t}"); + W->w_string("\tconst u16 faces[FACE_COUNT*3] = {"); + for (u32 f_id = 0; f_idGetFCount(); f_id++) { - sprintf (tmp,"\t\t%-d,\t\t%-d,\t\t%-d,",faces[f_id].pv[0].pindex,faces[f_id].pv[1].pindex,faces[f_id].pv[2].pindex); - W->w_string (tmp); + sprintf(tmp, "\t\t%-d,\t\t%-d,\t\t%-d,", faces[f_id].pv[0].pindex, faces[f_id].pv[1].pindex, faces[f_id].pv[2].pindex); + W->w_string(tmp); } - W->w_string ("\t}"); - W->w_string ("}"); + W->w_string("\t}"); + W->w_string("}"); } - FS.w_close (W); + FS.w_close(W); return true; } return false; } #include "../ECore/Editor/EDetailModel.h" + bool CActorTools::ExportDM(LPCSTR name) { - VERIFY(m_bReady); - if (m_pEditObject){ - EDetail DM; - if (!DM.Update(m_pEditObject->GetName())) return false; + VERIFY(m_bReady); + if (m_pEditObject) + { + EDetail DM; + if (!DM.Update(m_pEditObject->GetName())) + return false; DM.Export(name); return true; } @@ -728,247 +796,264 @@ bool CActorTools::ExportDM(LPCSTR name) void CActorTools::Reload() { - VERIFY(m_bReady); + VERIFY(m_bReady); // visual part } -void CActorTools::OnShowHint(AStringVec& SS) -{ -} +void CActorTools::OnShowHint(AStringVec &SS) {} void CActorTools::OnItemModified() { - switch(m_EditMode){ - case emObject: OnObjectModified(); break; - case emMotion: OnMotionDefsModified(); break; - case emBone: OnBoneModified(); break; - case emSurface: OnObjectModified(); break; - case emMesh: break; + switch (m_EditMode) + { + case emObject: OnObjectModified(); + break; + case emMotion: OnMotionDefsModified(); + break; + case emBone: OnBoneModified(); + break; + case emSurface: OnObjectModified(); + break; + case emMesh: break; } } void __fastcall CActorTools::OnBoneModified(void) { - Modified (); - RefreshSubProperties (); - UndoSave (); + Modified(); + RefreshSubProperties(); + UndoSave(); } -extern AnsiString MakeFullBoneName(CBone* bone); +extern AnsiString MakeFullBoneName(CBone*bone); + bool __fastcall CActorTools::MouseStart(TShiftState Shift) { - inherited::MouseStart(Shift); - switch(m_Action){ - case etaSelect: - switch (m_EditMode) - { - case emBone: - { - CBone* B = m_pEditObject->PickBone(UI->m_CurrentRStart,UI->m_CurrentRDir,m_AVTransform); - bool bVal = B?Shift.Contains(ssAlt)?false:(Shift.Contains(ssCtrl)?!B->Selected():true):false; - SelectListItem(BONES_PREFIX,B?MakeFullBoneName(B).c_str():0,bVal,Shift.Contains(ssCtrl)||Shift.Contains(ssAlt),true); - }break; - } - break; - case etaAdd: - break; - case etaMove: break; - case etaRotate: break; + inherited::MouseStart(Shift); + switch (m_Action) + { + case etaSelect: + switch (m_EditMode) + { + case emBone: + { + CBone *B = m_pEditObject->PickBone(UI->m_CurrentRStart, UI->m_CurrentRDir, m_AVTransform); + bool bVal = B ? Shift.Contains(ssAlt) ? false : (Shift.Contains(ssCtrl) ? !B->Selected() : true) : false; + SelectListItem(BONES_PREFIX, B ? MakeFullBoneName(B).c_str() : 0, bVal, Shift.Contains(ssCtrl)||Shift.Contains(ssAlt), true); + } + break; + } + break; + case etaAdd: + break; + case etaMove: break; + case etaRotate: break; } - return m_bHiddenMode; + return m_bHiddenMode; } bool __fastcall CActorTools::MouseEnd(TShiftState Shift) { - inherited::MouseEnd(Shift); - switch(m_Action) + inherited::MouseEnd(Shift); + switch (m_Action) { - case etaSelect: break; - case etaAdd: break; - case etaMove: - { - switch (m_EditMode) + case etaSelect: break; + case etaAdd: break; + case etaMove: { - case emObject: - if (Shift.Contains(ssCtrl)) - OnMotionKeysModified(); - break; - - case emBone: - if (Shift.Contains(ssCtrl)) - OnBoneModified(); - - if (Shift.Contains(ssAlt)) - OnBoneModified(); - break; + switch (m_EditMode) + { + case emObject: + if (Shift.Contains(ssCtrl)) + OnMotionKeysModified(); + break; + + case emBone: + if (Shift.Contains(ssCtrl)) + OnBoneModified(); + + if (Shift.Contains(ssAlt)) + OnBoneModified(); + break; + } } - }break; - case etaRotate: - { - switch (m_EditMode) + break; + case etaRotate: { - case emObject: - if (Shift.Contains(ssCtrl)) - OnMotionKeysModified(); - break; - - case emBone: - if (Shift.Contains(ssCtrl)) - OnBoneModified(); - - if (Shift.Contains(ssAlt)) - OnBoneModified(); - break; + switch (m_EditMode) + { + case emObject: + if (Shift.Contains(ssCtrl)) + OnMotionKeysModified(); + break; + + case emBone: + if (Shift.Contains(ssCtrl)) + OnBoneModified(); + + if (Shift.Contains(ssAlt)) + OnBoneModified(); + break; + } } - }break; - case etaScale: - { - switch (m_EditMode) + break; + case etaScale: { - case emBone: - if (Shift.Contains(ssCtrl)) - OnBoneModified(); - break; + switch (m_EditMode) + { + case emBone: + if (Shift.Contains(ssCtrl)) + OnBoneModified(); + break; + } } - }break; + break; } - return true; + return true; } void __fastcall CActorTools::MouseMove(TShiftState Shift) { - inherited::MouseMove(Shift); - if (!m_pEditObject) return; + inherited::MouseMove(Shift); + if (!m_pEditObject) + return; - switch(m_Action) - { - case etaSelect: break; - case etaAdd: break; - case etaMove: + switch (m_Action) { - switch (m_EditMode) + case etaSelect: break; + case etaAdd: break; + case etaMove: { - case emObject: - if (true || Shift.Contains(ssCtrl)) - m_pEditObject->a_vPosition.add(m_MovedAmount); - break; - - case emBone: - BoneVec lst; - if (m_pEditObject->GetSelectedBones(lst)) + switch (m_EditMode) { - if (Shift.Contains(ssCtrl)){ - for (BoneIt b_it=lst.begin(); b_it!=lst.end(); ++b_it) - (*b_it)->ShapeMove(m_MovedAmount); - - }else - if (Shift.Contains(ssAlt)) - { - for (BoneIt b_it=lst.begin(); b_it!=lst.end(); ++b_it) - (*b_it)->BindMove(m_MovedAmount); - - m_pEditObject->OnBindTransformChange(); - RefreshSubProperties(); - }else{ - for (BoneIt b_it=lst.begin(); b_it!=lst.end(); ++b_it) - (*b_it)->BoneMove(m_MovedAmount); - - RefreshSubProperties(); - } + case emObject: + if (true||Shift.Contains(ssCtrl)) + m_pEditObject->a_vPosition.add(m_MovedAmount); + break; + + case emBone: + BoneVec lst; + if (m_pEditObject->GetSelectedBones(lst)) + { + if (Shift.Contains(ssCtrl)) + { + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); ++b_it) + (*b_it)->ShapeMove(m_MovedAmount); + } + else if (Shift.Contains(ssAlt)) + { + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); ++b_it) + (*b_it)->BindMove(m_MovedAmount); + + m_pEditObject->OnBindTransformChange(); + RefreshSubProperties(); + } + else + { + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); ++b_it) + (*b_it)->BoneMove(m_MovedAmount); + + RefreshSubProperties(); + } + } + break; } - break; } - }break; - case etaRotate: - { - switch (m_EditMode) + break; + case etaRotate: { - case emObject: - if (Shift.Contains(ssCtrl)) - m_pEditObject->a_vRotate.mad(m_RotateVector,m_RotateAmount); - break; - - case emBone: - { - BoneVec lst; - Fvector rot; - rot.mul(m_RotateVector,m_RotateAmount); - if (m_pEditObject->GetSelectedBones(lst)) + switch (m_EditMode) { - if (Shift.Contains(ssCtrl)) - { - for (BoneIt b_it=lst.begin(); b_it!=lst.end(); ++b_it) - (*b_it)->ShapeRotate(rot); - - }else - if (Shift.Contains(ssAlt)) - { - for (BoneIt b_it=lst.begin(); b_it!=lst.end(); ++b_it) - (*b_it)->BindRotate(rot); - - m_pEditObject->OnBindTransformChange(); - RefreshSubProperties(); - }else + case emObject: + if (Shift.Contains(ssCtrl)) + m_pEditObject->a_vRotate.mad(m_RotateVector, m_RotateAmount); + break; + + case emBone: { - for (BoneIt b_it=lst.begin(); b_it!=lst.end(); ++b_it) - (*b_it)->BoneRotate(m_RotateVector,m_RotateAmount); - - RefreshSubProperties(); + BoneVec lst; + Fvector rot; + rot.mul(m_RotateVector, m_RotateAmount); + if (m_pEditObject->GetSelectedBones(lst)) + { + if (Shift.Contains(ssCtrl)) + { + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); ++b_it) + (*b_it)->ShapeRotate(rot); + } + else if (Shift.Contains(ssAlt)) + { + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); ++b_it) + (*b_it)->BindRotate(rot); + + m_pEditObject->OnBindTransformChange(); + RefreshSubProperties(); + } + else + { + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); ++b_it) + (*b_it)->BoneRotate(m_RotateVector, m_RotateAmount); + + RefreshSubProperties(); + } + } } + break; } - }break; } - }break; - case etaScale: - { - switch (m_EditMode) + break; + case etaScale: { - case emBone: - if (Shift.Contains(ssCtrl)) + switch (m_EditMode) { - BoneVec lst; - if (m_pEditObject->GetSelectedBones(lst)) - for (BoneIt b_it=lst.begin(); b_it!=lst.end(); ++b_it) - (*b_it)->ShapeScale(m_ScaleAmount); - } - break; + case emBone: + if (Shift.Contains(ssCtrl)) + { + BoneVec lst; + if (m_pEditObject->GetSelectedBones(lst)) + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); ++b_it) + (*b_it)->ShapeScale(m_ScaleAmount); + } + break; + } } - }break; + break; } } -void CActorTools::WorldMotionRotate(const Fvector& R) +void CActorTools::WorldMotionRotate(const Fvector &R) { - R_ASSERT(m_pEditObject&&(!m_CurrentMotion.IsEmpty())); - CSMotion* M = m_pEditObject->FindSMotionByName(m_CurrentMotion.c_str()); + R_ASSERT(m_pEditObject&&(!m_CurrentMotion.IsEmpty())); + CSMotion *M = m_pEditObject->FindSMotionByName(m_CurrentMotion.c_str()); int rootId = m_pEditObject->GetRootBoneID(); - M->WorldRotate(rootId,R.y,R.x,R.z); + M->WorldRotate(rootId, R.y, R.x, R.z); OnMotionKeysModified(); } -CSMotion* CActorTools::GetCurrentMotion() +CSMotion *CActorTools::GetCurrentMotion() { - return m_pEditObject?m_pEditObject->FindSMotionByName(m_CurrentMotion.c_str()):0; + return m_pEditObject ? m_pEditObject->FindSMotionByName(m_CurrentMotion.c_str()) : 0; } -CSMotion* CActorTools::FindMotion(LPCSTR name) +CSMotion *CActorTools::FindMotion(LPCSTR name) { - return m_pEditObject?m_pEditObject->FindSMotionByName(name):0; + return m_pEditObject ? m_pEditObject->FindSMotionByName(name) : 0; } + void CActorTools::SetCurrentMotion(LPCSTR name, u16 slot) { - if (m_pEditObject) + if (m_pEditObject) { if ((m_CurrentMotion!=name)||(m_CurrentSlot!=slot)) { - m_CurrentMotion = name; - m_CurrentSlot = slot; - CSMotion* M = m_pEditObject->FindSMotionByName(name); - if (M) + m_CurrentMotion = name; + m_CurrentSlot = slot; + CSMotion *M = m_pEditObject->FindSMotionByName(name); + if (M) { - m_pEditObject->SetActiveSMotion(M); + m_pEditObject->SetActiveSMotion(M); } - PlayMotion (); + PlayMotion(); } } } @@ -978,40 +1063,47 @@ bool CActorTools::Pick(TShiftState Shift) return false; } -bool CActorTools::RayPick(const Fvector& start, const Fvector& dir, float& dist, Fvector* pt, Fvector* n) +bool CActorTools::RayPick(const Fvector &start, const Fvector &dir, float &dist, Fvector *pt, Fvector *n) { if (m_PreviewObject.m_pObject) { - SRayPickInfo pinf; - if (m_PreviewObject.m_pObject->RayPick(dist,start,dir,Fidentity,&pinf)) + SRayPickInfo pinf; + if (m_PreviewObject.m_pObject->RayPick(dist, start, dir, Fidentity, &pinf)) { - if (pt) pt->set(pinf.pt); + if (pt) + pt->set(pinf.pt); if (n) - { - const Fvector* PT[3]; + { + const Fvector *PT[3]; pinf.e_mesh->GetFacePT(pinf.inf.id, PT); - n->mknormal(*PT[0],*PT[1],*PT[2]); + n->mknormal(*PT[0], *PT[1], *PT[2]); } return true; - }else - return false; - }else + } + else + return false; + } + else { - Fvector np; np.mad(start,dir,dist); - if ((start.y>0)&&(np.y<0.f)) + Fvector np; + np.mad(start, dir, dist); + if ((start.y>0)&&(np.y<0.f)) { - if (pt) pt->set(start); - if (n) n->set(0.f,1.f,0.f); + if (pt) + pt->set(start); + if (n) + n->set(0.f, 1.f, 0.f); return true; - }else - return false; + } + else + return false; } } void CActorTools::ShowClipMaker() { -//. if (CurrentObject()&&CurrentObject()->IsSkeleton()&&CurrentObject()->IsAnimated()) -//. m_ClipMaker->ShowEditor(CurrentObject()); + //. if (CurrentObject()&&CurrentObject()->IsSkeleton()&&CurrentObject()->IsAnimated()) + //. m_ClipMaker->ShowEditor(CurrentObject()); } bool CActorTools::IsEngineMode() @@ -1021,96 +1113,113 @@ bool CActorTools::IsEngineMode() LPCSTR CActorTools::GetInfo() { - return 0; + return 0; } void CActorTools::OptimizeMotions() { - if (m_pEditObject){ - m_pEditObject->OptimizeSMotions (); - Modified (); - UndoSave (); + if (m_pEditObject) + { + m_pEditObject->OptimizeSMotions(); + Modified(); + UndoSave(); } } void CActorTools::MakeThumbnail() { - if (CurrentObject()){ - CEditableObject* obj = CurrentObject(); - AnsiString tex_name,obj_name; - tex_name = ChangeFileExt(obj->GetName(),".thm"); - obj_name = ChangeFileExt(obj->GetName(),".object"); - FS_File F; - string_path fname; -//. FS.update_path(fname,_objects_,obj_name.c_str()); -//. R_ASSERT (FS.file_find(fname,F)); - R_ASSERT (FS.file_find(obj_name.c_str(),F)); - - if (ImageLib.CreateOBJThumbnail(tex_name.c_str(),obj,F.time_write)){ - ELog.Msg(mtInformation,"Thumbnail successfully created."); - }else{ - ELog.Msg(mtError,"Making thumbnail failed."); + if (CurrentObject()) + { + CEditableObject *obj = CurrentObject(); + AnsiString tex_name, obj_name; + tex_name = ChangeFileExt(obj->GetName(), ".thm"); + obj_name = ChangeFileExt(obj->GetName(), ".object"); + FS_File F; + string_path fname; + //. FS.update_path(fname,_objects_,obj_name.c_str()); + //. R_ASSERT (FS.file_find(fname,F)); + R_ASSERT(FS.file_find(obj_name.c_str(), F)); + + if (ImageLib.CreateOBJThumbnail(tex_name.c_str(), obj, F.time_write)) + { + ELog.Msg(mtInformation, "Thumbnail successfully created."); + } + else + { + ELog.Msg(mtError, "Making thumbnail failed."); } - }else{ - ELog.DlgMsg(mtError,"Can't create thumbnail. Empty scene."); + } + else + { + ELog.DlgMsg(mtError, "Can't create thumbnail. Empty scene."); } } bool CActorTools::BatchConvert(LPCSTR fn) { - bool bRes = true; - CInifile* ini = CInifile::Create(fn); VERIFY(ini); + bool bRes = true; + CInifile *ini = CInifile::Create(fn); + VERIFY(ini); if (ini->section_exist("ogf")) { - CInifile::Sect& sect = ini->r_section("ogf"); - Msg ("Start converting %d items...",sect.Data.size()); - for (CInifile::Item* it=sect.Data.begin(); it!=sect.Data.end(); it++){ - string_path src_name; - string_path tgt_name; - FS.update_path (src_name,_objects_, it->first.c_str()); - FS.update_path (tgt_name,_game_meshes_, it->second.c_str()); - strcpy (src_name,EFS.ChangeFileExt (src_name,".object").c_str()); - strcpy (tgt_name,EFS.ChangeFileExt (tgt_name,".ogf").c_str()); + CInifile::Sect § = ini->r_section("ogf"); + Msg("Start converting %d items...", sect.Data.size()); + for (CInifile::Item *it = sect.Data.begin(); it!=sect.Data.end(); it++) + { + string_path src_name; + string_path tgt_name; + FS.update_path(src_name,_objects_, it->first.c_str()); + FS.update_path(tgt_name, _game_meshes_, it->second.c_str()); + strcpy(src_name, EFS.ChangeFileExt(src_name, ".object").c_str()); + strcpy(tgt_name, EFS.ChangeFileExt(tgt_name, ".ogf").c_str()); if (FS.exist(src_name)) { - Msg (".Converting '%s' <-> '%s'",it->first.c_str(),it->second.c_str()); - CEditableObject* O = xr_new("convert"); - BOOL res = O->Load (src_name); - if (res) res = O->ExportOGF (tgt_name,4); - Log (res?".OK":"!.FAILED"); - xr_delete (O); - }else{ - Log ("!Invalid source file name:",it->first.c_str()); - bRes = false; + Msg(".Converting '%s' <-> '%s'", it->first.c_str(), it->second.c_str()); + CEditableObject *O = xr_new("convert"); + BOOL res = O->Load(src_name); + if (res) + res = O->ExportOGF(tgt_name, 4); + Log(res ? ".OK" : "!.FAILED"); + xr_delete(O); + } + else + { + Log("!Invalid source file name:", it->first.c_str()); + bRes = false; } - if (UI->NeedAbort()) break; + if (UI->NeedAbort()) + break; } } if (ini->section_exist("omf")) { - CInifile::Sect& sect = ini->r_section("omf"); - Msg ("Start converting %d items...",sect.Data.size()); - for (CInifile::Item* it=sect.Data.begin(); it!=sect.Data.end(); ++it) + CInifile::Sect § = ini->r_section("omf"); + Msg("Start converting %d items...", sect.Data.size()); + for (CInifile::Item *it = sect.Data.begin(); it!=sect.Data.end(); ++it) { - string_path src_name; - string_path tgt_name; - FS.update_path (src_name,_objects_, it->first.c_str()); - FS.update_path (tgt_name,_game_meshes_, it->second.c_str()); - strcpy (src_name,EFS.ChangeFileExt (src_name,".object").c_str()); - strcpy (tgt_name,EFS.ChangeFileExt (tgt_name,".omf").c_str()); + string_path src_name; + string_path tgt_name; + FS.update_path(src_name,_objects_, it->first.c_str()); + FS.update_path(tgt_name, _game_meshes_, it->second.c_str()); + strcpy(src_name, EFS.ChangeFileExt(src_name, ".object").c_str()); + strcpy(tgt_name, EFS.ChangeFileExt(tgt_name, ".omf").c_str()); if (FS.exist(src_name)) { - Msg (".Converting '%s' <-> '%s'",it->first.c_str(),it->second.c_str()); - CEditableObject* O = xr_new("convert"); - BOOL res = O->Load (src_name); - if (res) res = O->ExportOMF (tgt_name); - Log (res?".OK":"!.FAILED"); - xr_delete (O); - }else{ - Log ("!Invalid source file name:",it->first.c_str()); - bRes = false; + Msg(".Converting '%s' <-> '%s'", it->first.c_str(), it->second.c_str()); + CEditableObject *O = xr_new("convert"); + BOOL res = O->Load(src_name); + if (res) + res = O->ExportOMF(tgt_name); + Log(res ? ".OK" : "!.FAILED"); + xr_delete(O); + } + else + { + Log("!Invalid source file name:", it->first.c_str()); + bRes = false; } - if (UI->NeedAbort()) break; + if (UI->NeedAbort()) + break; } } return bRes; @@ -1118,54 +1227,55 @@ bool CActorTools::BatchConvert(LPCSTR fn) u16 CActorTools::ExtractMotionSlot(LPCSTR full_name, LPCSTR prefix) { - LPCSTR _templ = "\\Slot "; - u16 slot = 0; - LPCSTR slot_nm = strstr(full_name, _templ); - if (0!=slot_nm) + LPCSTR _templ = "\\Slot "; + u16 slot = 0; + LPCSTR slot_nm = strstr(full_name, _templ); + if (0!=slot_nm) { - string16 tmp; - slot_nm += xr_strlen(_templ); + string16 tmp; + slot_nm += xr_strlen(_templ); u32 ii = 0; - while(isdigit(*slot_nm)) + while (isdigit(*slot_nm)) { - tmp[ii] = slot_nm[0]; + tmp[ii] = slot_nm[0]; ++slot_nm; ++ii; } tmp[ii] = 0; - slot = u16(atoi(tmp)-1); + slot = u16(atoi(tmp)-1); } return slot; } LPCSTR CActorTools::ExtractMotionName(LPCSTR full_name, LPCSTR prefix) { - LPCSTR _templ = "\\Slot "; - if (0==strstr(full_name, _templ)) - return full_name+xr_strlen(prefix)+1; - else + LPCSTR _templ = "\\Slot "; + if (0==strstr(full_name, _templ)) + return full_name+xr_strlen(prefix)+1; + else { - LPCSTR mot_nm = strstr(full_name, _templ); - mot_nm += xr_strlen(_templ); - while(isdigit(*mot_nm)) + LPCSTR mot_nm = strstr(full_name, _templ); + mot_nm += xr_strlen(_templ); + while (isdigit(*mot_nm)) { ++mot_nm; } - return mot_nm + 1; + return mot_nm+1; } -// return full_name + xr_strlen(prefix) + 1 + xr_strlen(_templ) + 1; + // return full_name + xr_strlen(prefix) + 1 + xr_strlen(_templ) + 1; } xr_string CActorTools::BuildMotionPref(u16 slot, LPCSTR prefix) { - VERIFY (slotdcast_PKinematics();} + bool UpdateVisual(CEditableObject *source, bool bUpdGeom, bool bUpdKeys, bool bUpdDefs); + + bool IsRenderable() + { + return !!m_pVisual; + } + + void PlayMotion(LPCSTR name, u16 slot); + void RestoreParams(TFormStorage *s); + void SaveParams(TFormStorage *s); + void OnRender(); + // void PlayCycle(LPCSTR name, int part, u16 slot); + // void PlayFX(LPCSTR name, float power, u16 slot); + void StopAnimation(); + void FillMotionList(LPCSTR pref, ListItemsVec &items, int modeID); + MotionID FindMotionID(LPCSTR name, u16 slot); + CMotionDef *FindMotionDef(LPCSTR name, u16 slot); + CMotion *FindMotionKeys(LPCSTR name, u16 slot); +private: + // virtual Fmatrix& _BCL ObjectXFORM() { return m_pobject_matrix; } + // virtual Fvector& _BCL ObjectPosition() { return m_pobject_matrix.c; } + // virtual IRenderVisual* _BCL ObjectVisual() { return m_pVisual; } + virtual IKinematics* _BCL ObjectKinematics() + { + if (!m_pVisual) + return 0; + return m_pVisual->dcast_PKinematics(); + } }; -class PreviewModel{ - TProperties* m_Props; - float m_fSpeed; - float m_fSegment; - Flags32 m_Flags; - Fvector m_vPosition; - AnsiString m_LastObjectName; +class PreviewModel +{ + TProperties *m_Props; + float m_fSpeed; + float m_fSegment; + Flags32 m_Flags; + Fvector m_vPosition; + AnsiString m_LastObjectName; public: - CEditableObject*m_pObject; + CEditableObject *m_pObject; public: - enum{ - pmScroll = (1<<0), + enum + { + pmScroll = (1<<0), force_dword = u32(-1) }; - enum EScrollAxis{ + + enum EScrollAxis + { saZp, saZn, saXp, saXn, saforceDWORD=u32(-1) }; - EScrollAxis m_ScrollAxis; + + EScrollAxis m_ScrollAxis; public: - PreviewModel (){m_pObject=0;m_fSpeed=5.f;m_fSegment=50.f;m_Flags.zero();m_Props=0;m_vPosition.set(0,0,0);m_ScrollAxis=saZp;} - void OnCreate (); - void OnDestroy (); - void Clear (); - void SelectObject (); - void SetPreferences (); - void Render (); - void Update (); - void RestoreParams (TFormStorage* s); - void SaveParams (TFormStorage* s); + PreviewModel() + { + m_pObject = 0; + m_fSpeed = 5.f; + m_fSegment = 50.f; + m_Flags.zero(); + m_Props = 0; + m_vPosition.set(0, 0, 0); + m_ScrollAxis = saZp; + } + + void OnCreate(); + void OnDestroy(); + void Clear(); + void SelectObject(); + void SetPreferences(); + void Render(); + void Update(); + void RestoreParams(TFormStorage *s); + void SaveParams(TFormStorage *s); }; class CActorTools: public CToolCustom { - typedef CToolCustom inherited; + typedef CToolCustom inherited; + + Fmatrix m_AVTransform; + CEditableObject *m_pEditObject; - Fmatrix m_AVTransform; - CEditableObject* m_pEditObject; + bool m_bObjectModified; + shared_str m_tmp_mot_refs; + EEditMode m_EditMode; + AnsiString m_CurrentMotion; + u16 m_CurrentSlot; - bool m_bObjectModified; - shared_str m_tmp_mot_refs; - EEditMode m_EditMode; - AnsiString m_CurrentMotion; - u16 m_CurrentSlot; + RTokenVec m_BoneParts; - RTokenVec m_BoneParts; + void __stdcall OnMotionTypeChange(PropValue *sender); - void __stdcall OnMotionTypeChange (PropValue* sender); + void __stdcall OnChangeTransform(PropValue *sender); + void __stdcall OnMotionNameChange(PropValue *sender); - void __stdcall OnChangeTransform (PropValue* sender); - void __stdcall OnMotionNameChange (PropValue* sender); + void __stdcall OnBoxAxisClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnCylinderAxisClick(ButtonValue *sender, bool &bModif, bool &bSafe); - void __stdcall OnBoxAxisClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnCylinderAxisClick (ButtonValue* sender, bool& bModif, bool& bSafe); - - void __stdcall OnMotionEditClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnMotionControlClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnExportImportRefsClick (ButtonValue* sender, bool& bModif, bool& bSafe); + void __stdcall OnMotionEditClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnMotionControlClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnExportImportRefsClick(ButtonValue *sender, bool &bModif, bool &bSafe); - void __stdcall OnMarksControlClick12 (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnMarksControlClick34 (ButtonValue* sender, bool& bModif, bool& bSafe); + void __stdcall OnMarksControlClick12(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnMarksControlClick34(ButtonValue *sender, bool &bModif, bool &bSafe); - void __stdcall OnObjectItemFocused (ListItemsVec& items); + void __stdcall OnObjectItemFocused(ListItemsVec &items); - void __stdcall OnBoneShapeClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnBoneCreateDeleteClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnBoneEditClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnBoneFileClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnBoneLimitsChange (PropValue* sender); - - void __stdcall OnJointTypeChange (PropValue* sender); - void __stdcall OnShapeTypeChange (PropValue* sender); + void __stdcall OnBoneShapeClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnBoneCreateDeleteClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnBoneEditClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnBoneFileClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnBoneLimitsChange(PropValue *sender); - void __stdcall OnMotionRefsChange (PropValue* sender); - - void __stdcall OnBindTransformChange (PropValue* V); + void __stdcall OnJointTypeChange(PropValue *sender); + void __stdcall OnShapeTypeChange(PropValue *sender); - SMotionVec appended_motions; + void __stdcall OnMotionRefsChange(PropValue *sender); + + void __stdcall OnBindTransformChange(PropValue *V); + + SMotionVec appended_motions; protected: - // flags - enum{ - flRefreshProps = (1<<0), - flRefreshSubProps = (1<<1), - flRefreshShaders = (1<<2), - flUpdateGeometry = (1<<3), - flUpdateMotionKeys = (1<<4), - flUpdateMotionDefs = (1<<5), - flReadOnlyMode = (1<<6), + // flags + enum + { + flRefreshProps = (1<<0), + flRefreshSubProps = (1<<1), + flRefreshShaders = (1<<2), + flUpdateGeometry = (1<<3), + flUpdateMotionKeys = (1<<4), + flUpdateMotionDefs = (1<<5), + flReadOnlyMode = (1<<6), }; - Flags32 m_Flags; - - void RefreshSubProperties (){m_Flags.set(flRefreshSubProps,TRUE);} - void RefreshShaders (){m_Flags.set(flRefreshShaders,TRUE);} - void __stdcall PMMotionItemClick (TObject *Sender); - - void RealUpdateProperties (); + Flags32 m_Flags; + + void RefreshSubProperties() + { + m_Flags.set(flRefreshSubProps, TRUE); + } - void PrepareLighting (); + void RefreshShaders() + { + m_Flags.set(flRefreshShaders, TRUE); + } + + void __stdcall PMMotionItemClick(TObject *Sender); + + void RealUpdateProperties(); + + void PrepareLighting(); public: - EngineModel m_RenderObject; - PreviewModel m_PreviewObject; + EngineModel m_RenderObject; + PreviewModel m_PreviewObject; - TProperties* m_Props; - TItemList* m_ObjectItems; + TProperties *m_Props; + TItemList *m_ObjectItems; - TfrmKeyBar* m_KeyBar; -// undo part + TfrmKeyBar *m_KeyBar; + // undo part protected: - #pragma pack( push,1 ) - struct UndoItem { +#pragma pack(push, 1) + struct UndoItem + { char m_FileName[MAX_PATH]; }; - #pragma pack( pop ) - xr_deque m_UndoStack; - xr_deque m_RedoStack; +#pragma pack(pop) + xr_deque m_UndoStack; + xr_deque m_RedoStack; public: - void UndoClear (); - void UndoSave (); - bool Undo (); - bool Redo (); + void UndoClear(); + void UndoSave(); + bool Undo(); + bool Redo(); public: - CActorTools (); - virtual ~CActorTools (); - - virtual void Render (); - virtual void RenderEnvironment (); - virtual void OnFrame (); - - virtual bool OnCreate (); - virtual void OnDestroy (); - - ICF bool ReadOnly (){return m_Flags.is(flReadOnlyMode);} - - virtual bool IfModified (); - virtual bool IsModified (){return m_bObjectModified;} - virtual void Modified (); - void __stdcall OnItemModified (void); - - virtual LPCSTR GetInfo (); - - virtual void ZoomObject (BOOL bSelOnly); - - virtual bool Load (LPCSTR name); - virtual bool Save (LPCSTR name, bool bInternal=false); - virtual void Reload (); - - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); - - virtual void Clear (); - - virtual void OnShowHint (AStringVec& SS); - - virtual bool __fastcall MouseStart (TShiftState Shift); - virtual bool __fastcall MouseEnd (TShiftState Shift); - virtual void __fastcall MouseMove (TShiftState Shift); - - virtual bool Pick (TShiftState Shift); - virtual bool RayPick (const Fvector& start, const Fvector& dir, float& dist, Fvector* pt, Fvector* n); - - virtual void ShowProperties (LPCSTR focused_item){;} - virtual void UpdateProperties (BOOL bForced=FALSE){m_Flags.set(flRefreshProps,TRUE); if (bForced) RealUpdateProperties();} - virtual void RefreshProperties (){;} - - void GetStatTime (float& a, float& b, float& c); - - bool IsEngineMode (); - void SelectPreviewObject (bool bClear); - void SetPreviewObjectPrefs(); - - void SelectListItem (LPCSTR pref, LPCSTR name, bool bVal, bool bLeaveSel, bool bExpand); - - void ShowClipMaker (); - bool Import (LPCSTR path, LPCSTR name); - bool ExportOBJ (LPCSTR name); - bool ExportOGF (LPCSTR name); - bool ExportOMF (LPCSTR name); - bool ExportDM (LPCSTR name); - bool ExportCPP (LPCSTR name); - bool SaveMotions (LPCSTR name, bool bSelOnly); - bool AppendMotion (LPCSTR fn); - bool RemoveMotion (LPCSTR name); - void WorldMotionRotate (const Fvector& R); - void MakePreview (); - - bool __stdcall OnBoneNameAfterEdit (PropValue* sender, shared_str& edit_val); - void __stdcall OnBoneModified (void); - void __stdcall OnObjectModified (void); - void __stdcall OnMotionDefsModified(void); - void OnMotionKeysModified(void); - void OnGeometryModified (void); - - bool IsVisualPresent (){return m_RenderObject.IsRenderable();} - - CEditableObject* CurrentObject (){return m_pEditObject;} - void SetCurrentMotion (LPCSTR name, u16 slot); - CSMotion* GetCurrentMotion (); - CSMotion* FindMotion (LPCSTR name); - LPCSTR ExtractMotionName (LPCSTR full_name, LPCSTR prefix=MOTIONS_PREFIX); - u16 ExtractMotionSlot (LPCSTR full_name, LPCSTR prefix=MOTIONS_PREFIX); - xr_string BuildMotionPref (u16 slot, LPCSTR prefix=MOTIONS_PREFIX); - void FillObjectProperties(PropItemVec& items, LPCSTR pref, ListItem* sender); - void FillSurfaceProperties(PropItemVec& items, LPCSTR pref, ListItem* sender); - void FillMotionProperties(PropItemVec& items, LPCSTR pref, ListItem* sender); - void FillBoneProperties (PropItemVec& items, LPCSTR pref, ListItem* sender); - void PlayMotion (); - void StopMotion (); - void PauseMotion (); - bool RenameMotion (LPCSTR old_name, LPCSTR new_name); - void RemoveMarksChannel (bool b12); - void AddMarksChannel (bool b12); - void OptimizeMotions (); - void MakeThumbnail (); - bool BatchConvert (LPCSTR fn); - - - void PhysicsSimulate ( ); - void PhysicsStopSimulate ( ); - void CreatePhysicsWorld ( ); - void DestroyPhysicsWorld ( ); - - virtual bool GetSelectionPosition (Fmatrix& result); + CActorTools(); + virtual ~CActorTools(); + + virtual void Render(); + virtual void RenderEnvironment(); + virtual void OnFrame(); + + virtual bool OnCreate(); + virtual void OnDestroy(); + + ICF + + bool ReadOnly() + { + return m_Flags.is(flReadOnlyMode); + } + + virtual bool IfModified(); + + virtual bool IsModified() + { + return m_bObjectModified; + } + + virtual void Modified(); + void __stdcall OnItemModified(void); + + virtual LPCSTR GetInfo(); + virtual void ZoomObject(BOOL bSelOnly); + + virtual bool Load(LPCSTR name); + virtual bool Save(LPCSTR name, bool bInternal = false); + virtual void Reload(); + + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); + + virtual void Clear(); + + virtual void OnShowHint(AStringVec &SS); + + virtual bool __fastcall MouseStart(TShiftState Shift); + virtual bool __fastcall MouseEnd(TShiftState Shift); + virtual void __fastcall MouseMove(TShiftState Shift); + + virtual bool Pick(TShiftState Shift); + virtual bool RayPick(const Fvector &start, const Fvector &dir, float &dist, Fvector *pt, Fvector *n); + + virtual void ShowProperties(LPCSTR focused_item) {} + + virtual void UpdateProperties(BOOL bForced = FALSE) + { + m_Flags.set(flRefreshProps, TRUE); + if (bForced) + RealUpdateProperties(); + } + + virtual void RefreshProperties() {} + + void GetStatTime(float &a, float &b, float &c); + + bool IsEngineMode(); + void SelectPreviewObject(bool bClear); + void SetPreviewObjectPrefs(); + + void SelectListItem(LPCSTR pref, LPCSTR name, bool bVal, bool bLeaveSel, bool bExpand); + + void ShowClipMaker(); + bool Import(LPCSTR path, LPCSTR name); + bool ExportOBJ(LPCSTR name); + bool ExportOGF(LPCSTR name); + bool ExportOMF(LPCSTR name); + bool ExportDM(LPCSTR name); + bool ExportCPP(LPCSTR name); + bool SaveMotions(LPCSTR name, bool bSelOnly); + bool AppendMotion(LPCSTR fn); + bool RemoveMotion(LPCSTR name); + void WorldMotionRotate(const Fvector &R); + void MakePreview(); + + bool __stdcall OnBoneNameAfterEdit(PropValue *sender, shared_str &edit_val); + void __stdcall OnBoneModified(void); + void __stdcall OnObjectModified(void); + void __stdcall OnMotionDefsModified(void); + void OnMotionKeysModified(void); + void OnGeometryModified(void); + + bool IsVisualPresent() + { + return m_RenderObject.IsRenderable(); + } + + CEditableObject *CurrentObject() + { + return m_pEditObject; + } + void SetCurrentMotion(LPCSTR name, u16 slot); + CSMotion *GetCurrentMotion(); + CSMotion *FindMotion(LPCSTR name); + LPCSTR ExtractMotionName(LPCSTR full_name, LPCSTR prefix = MOTIONS_PREFIX); + u16 ExtractMotionSlot(LPCSTR full_name, LPCSTR prefix = MOTIONS_PREFIX); + xr_string BuildMotionPref(u16 slot, LPCSTR prefix = MOTIONS_PREFIX); + void FillObjectProperties(PropItemVec &items, LPCSTR pref, ListItem *sender); + void FillSurfaceProperties(PropItemVec &items, LPCSTR pref, ListItem *sender); + void FillMotionProperties(PropItemVec &items, LPCSTR pref, ListItem *sender); + void FillBoneProperties(PropItemVec &items, LPCSTR pref, ListItem *sender); + void PlayMotion(); + void StopMotion(); + void PauseMotion(); + bool RenameMotion(LPCSTR old_name, LPCSTR new_name); + void RemoveMarksChannel(bool b12); + void AddMarksChannel(bool b12); + void OptimizeMotions(); + void MakeThumbnail(); + bool BatchConvert(LPCSTR fn); + + + void PhysicsSimulate(); + void PhysicsStopSimulate(); + void CreatePhysicsWorld(); + void DestroyPhysicsWorld(); + + virtual bool GetSelectionPosition(Fmatrix &result); // commands - CCommandVar CommandClear (CCommandVar p1, CCommandVar p2); - CCommandVar CommandLoad (CCommandVar p1, CCommandVar p2); - CCommandVar CommandSaveBackup (CCommandVar p1, CCommandVar p2); - CCommandVar CommandSave (CCommandVar p1, CCommandVar p2); - CCommandVar CommandImport (CCommandVar p1, CCommandVar p2); - CCommandVar CommandExportDM (CCommandVar p1, CCommandVar p2); - CCommandVar CommandExportOBJ (CCommandVar p1, CCommandVar p2); - CCommandVar CommandExportOGF (CCommandVar p1, CCommandVar p2); - CCommandVar CommandExportOMF (CCommandVar p1, CCommandVar p2); - CCommandVar CommandExportCPP (CCommandVar p1, CCommandVar p2); - CCommandVar CommandUndo (CCommandVar p1, CCommandVar p2); - CCommandVar CommandRedo (CCommandVar p1, CCommandVar p2); - CCommandVar CommandOptimizeMotions(CCommandVar p1, CCommandVar p2); - CCommandVar CommandMakeThumbnail(CCommandVar p1, CCommandVar p2); - CCommandVar CommandBatchConvert (CCommandVar p1, CCommandVar p2); + CCommandVar CommandClear(CCommandVar p1, CCommandVar p2); + CCommandVar CommandLoad(CCommandVar p1, CCommandVar p2); + CCommandVar CommandSaveBackup(CCommandVar p1, CCommandVar p2); + CCommandVar CommandSave(CCommandVar p1, CCommandVar p2); + CCommandVar CommandImport(CCommandVar p1, CCommandVar p2); + CCommandVar CommandExportDM(CCommandVar p1, CCommandVar p2); + CCommandVar CommandExportOBJ(CCommandVar p1, CCommandVar p2); + CCommandVar CommandExportOGF(CCommandVar p1, CCommandVar p2); + CCommandVar CommandExportOMF(CCommandVar p1, CCommandVar p2); + CCommandVar CommandExportCPP(CCommandVar p1, CCommandVar p2); + CCommandVar CommandUndo(CCommandVar p1, CCommandVar p2); + CCommandVar CommandRedo(CCommandVar p1, CCommandVar p2); + CCommandVar CommandOptimizeMotions(CCommandVar p1, CCommandVar p2); + CCommandVar CommandMakeThumbnail(CCommandVar p1, CCommandVar p2); + CCommandVar CommandBatchConvert(CCommandVar p1, CCommandVar p2); }; -extern CActorTools*& ATools; +extern CActorTools *&ATools; #define SURFACES_PREFIX "Surfaces" -#define BONES_PREFIX "Bones" -#define MOTIONS_PREFIX "Motions" -#define OBJECT_PREFIX "Object" +#define BONES_PREFIX "Bones" +#define MOTIONS_PREFIX "Motions" +#define OBJECT_PREFIX "Object" //--------------------------------------------------------------------------- #endif diff --git a/src/editors/ActorEditor/UI_ActorToolsMotions.cpp b/src/editors/ActorEditor/UI_ActorToolsMotions.cpp index d817fee23a9..df77a66c4f6 100644 --- a/src/editors/ActorEditor/UI_ActorToolsMotions.cpp +++ b/src/editors/ActorEditor/UI_ActorToolsMotions.cpp @@ -4,73 +4,87 @@ #pragma hdrstop #include "UI_ActorTools.h" -#include "../ECore/Editor/UI_Main.h" +#include "editors/ECore/Editor/UI_Main.h" #include "leftbar.h" -#include "../ECore/Editor/EditObject.h" -#include "../xrEProps/PropertiesList.h" -#include "motion.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/xrEProps/PropertiesList.h" +#include "xrCore/Animation/Motion.hpp" #include "bone.h" -#include "../../Layers/xrRender/SkeletonAnimated.h" -#include "fmesh.h" -#include "../xrEProps/folderlib.h" +#include "Layers/xrRender/SkeletonAnimated.h" +#include "xrCore/fmesh.hpp" +#include "editors/xrEProps/folderlib.h" #include "leftbar.h" -#include "../xrEProps/ItemList.h" -#include "../../xrphysics/physicsshell.h" +#include "editors/xrEProps/ItemList.h" +#include "xrPhysics/PhysicsShell.h" + //--------------------------------------------------------------------------- MotionID EngineModel::FindMotionID(LPCSTR name, u16 slot) { - MotionID M; - CKinematicsAnimated* VA = PKinematicsAnimated(m_pVisual); - if (VA) M = VA->ID_Motion (name,slot); + MotionID M; + CKinematicsAnimated *VA = PKinematicsAnimated(m_pVisual); + if (VA) + M = VA->ID_Motion(name, slot); return M; } -CMotionDef* EngineModel::FindMotionDef(LPCSTR name, u16 slot) + +CMotionDef *EngineModel::FindMotionDef(LPCSTR name, u16 slot) { - CKinematicsAnimated* VA = PKinematicsAnimated(m_pVisual); - if (VA){ - MotionID M = FindMotionID(name,slot); - if (M.valid()) return VA->LL_GetMotionDef(M); + CKinematicsAnimated *VA = PKinematicsAnimated(m_pVisual); + if (VA) + { + MotionID M = FindMotionID(name, slot); + if (M.valid()) + return VA->LL_GetMotionDef(M); } return 0; } -CMotion* EngineModel::FindMotionKeys(LPCSTR name, u16 slot) + +CMotion *EngineModel::FindMotionKeys(LPCSTR name, u16 slot) { - CKinematicsAnimated* VA = PKinematicsAnimated(m_pVisual); - if (VA){ - MotionID M = FindMotionID(name,slot); - if (M.valid()) return VA->LL_GetMotion (M,VA->LL_GetBoneRoot()); + CKinematicsAnimated *VA = PKinematicsAnimated(m_pVisual); + if (VA) + { + MotionID M = FindMotionID(name, slot); + if (M.valid()) + return VA->LL_GetMotion(M, VA->LL_GetBoneRoot()); } return 0; } -void EngineModel::FillMotionList(LPCSTR pref, ListItemsVec& items, int modeID) +void EngineModel::FillMotionList(LPCSTR pref, ListItemsVec &items, int modeID) { - LHelper().CreateItem (items, pref, modeID, 0); - if (IsRenderable()&&fraLeftBar->ebRenderEngineStyle->Down){ - CKinematicsAnimated* SA = PKinematicsAnimated(m_pVisual); - if (SA){ - for (int k=SA->m_Motions.size()-1; k>=0; --k){ - xr_string slot_pref = ATools->BuildMotionPref((u16)k,pref); - LHelper().CreateItem(items, slot_pref.c_str(), modeID, ListItem::flSorted); - // cycles - accel_map::const_iterator I,E; - I = SA->m_Motions[k].motions.cycle()->begin(); - E = SA->m_Motions[k].motions.cycle()->end(); - for ( ; I != E; ++I){ - shared_str tmp = PrepareKey(slot_pref.c_str(),*(*I).first); - LHelper().CreateItem(items, tmp.c_str(), modeID, 0, *(void**)&MotionID((u16)k,I->second)); - } + LHelper().CreateItem(items, pref, modeID, 0); + if (IsRenderable()&&fraLeftBar->ebRenderEngineStyle->Down) + { + CKinematicsAnimated *SA = PKinematicsAnimated(m_pVisual); + if (SA) + { + for (int k = SA->m_Motions.size()-1; k>=0; --k) + { + xr_string slot_pref = ATools->BuildMotionPref((u16)k, pref); + LHelper().CreateItem(items, slot_pref.c_str(), modeID, ListItem::flSorted); + // cycles + accel_map::const_iterator I, E; + I = SA->m_Motions[k].motions.cycle()->begin(); + E = SA->m_Motions[k].motions.cycle()->end(); + for (; I!=E; ++I) + { + shared_str tmp = PrepareKey(slot_pref.c_str(), *(*I).first); + LHelper().CreateItem(items, tmp.c_str(), modeID, 0, *(void**)&MotionID((u16)k, I->second)); + } // fxs - I = SA->m_Motions[k].motions.fx()->begin(); - E = SA->m_Motions[k].motions.fx()->end(); - for ( ; I != E; ++I){ - shared_str tmp = PrepareKey(slot_pref.c_str(),*(*I).first); - LHelper().CreateItem(items, tmp.c_str(), modeID, 0, *(void**)&MotionID((u16)k,I->second)); + I = SA->m_Motions[k].motions.fx()->begin(); + E = SA->m_Motions[k].motions.fx()->end(); + for (; I!=E; ++I) + { + shared_str tmp = PrepareKey(slot_pref.c_str(), *(*I).first); + LHelper().CreateItem(items, tmp.c_str(), modeID, 0, *(void**)&MotionID((u16)k, I->second)); } } } } } + /* void EngineModel::PlayCycle(LPCSTR name, int part, u16 slot) { @@ -83,13 +97,14 @@ void EngineModel::PlayFX(LPCSTR name, float power, u16 slot) { MotionID D = PKinematicsAnimated(m_pVisual)->ID_Motion(name,slot); if (D.valid()) - PKinematicsAnimated(m_pVisual)->PlayFX(D,power); + PKinematicsAnimated(m_pVisual)->PlayFX(D,power); } */ void EngineModel::StopAnimation() { - if (m_pVisual && PKinematicsAnimated(m_pVisual) ){ + if (m_pVisual&&PKinematicsAnimated(m_pVisual)) + { PKinematicsAnimated(m_pVisual)->LL_CloseCycle(0); PKinematicsAnimated(m_pVisual)->LL_CloseCycle(1); PKinematicsAnimated(m_pVisual)->LL_CloseCycle(2); @@ -97,56 +112,71 @@ void EngineModel::StopAnimation() } } -bool EngineModel::UpdateGeometryStream(CEditableObject* source) +bool EngineModel::UpdateGeometryStream(CEditableObject *source) { - m_GeometryStream.clear(); - if (!source) return false; - if (source->IsSkeleton()) return (source->PrepareSVGeometry(m_GeometryStream,4)); - else return (source->PrepareOGF(m_GeometryStream,4,true,NULL)); + m_GeometryStream.clear(); + if (!source) + return false; + if (source->IsSkeleton()) + return (source->PrepareSVGeometry(m_GeometryStream, 4)); + else + return (source->PrepareOGF(m_GeometryStream, 4, true, NULL)); } -bool EngineModel::UpdateMotionDefsStream(CEditableObject* source) +bool EngineModel::UpdateMotionDefsStream(CEditableObject *source) { - m_MotionDefsStream.clear(); - return (source&&source->PrepareSVDefs(m_MotionDefsStream)); + m_MotionDefsStream.clear(); + return (source&&source->PrepareSVDefs(m_MotionDefsStream)); } -bool EngineModel::UpdateMotionKeysStream(CEditableObject* source) +bool EngineModel::UpdateMotionKeysStream(CEditableObject *source) { - m_MotionKeysStream.clear(); - return (source&&source->PrepareSVKeys(m_MotionKeysStream)); + m_MotionKeysStream.clear(); + return (source&&source->PrepareSVKeys(m_MotionKeysStream)); } -bool EngineModel::UpdateVisual(CEditableObject* source, bool bUpdGeom, bool bUpdKeys, bool bUpdDefs) +bool EngineModel::UpdateVisual(CEditableObject *source, bool bUpdGeom, bool bUpdKeys, bool bUpdDefs) { - bool bRes = true; - CMemoryWriter F; - destroy_physics_shell( m_physics_shell ); - if (source->IsSkeleton()){ - if (bUpdGeom) bRes = UpdateGeometryStream(source); - if (!bRes||!m_GeometryStream.size()){ - ELog.Msg(mtError,"Can't create preview geometry."); - return false; + bool bRes = true; + CMemoryWriter F; + destroy_physics_shell(m_physics_shell); + if (source->IsSkeleton()) + { + if (bUpdGeom) + bRes = UpdateGeometryStream(source); + if (!bRes||!m_GeometryStream.size()) + { + ELog.Msg(mtError, "Can't create preview geometry."); + return false; } - F.w(m_GeometryStream.pointer(),m_GeometryStream.size()); - if (bUpdKeys) UpdateMotionKeysStream(source); - if (bUpdDefs) UpdateMotionDefsStream(source); - if (m_MotionKeysStream.size()) F.w(m_MotionKeysStream.pointer(),m_MotionKeysStream.size()); - if (m_MotionDefsStream.size()) F.w(m_MotionDefsStream.pointer(),m_MotionDefsStream.size()); - }else{ + F.w(m_GeometryStream.pointer(), m_GeometryStream.size()); + if (bUpdKeys) + UpdateMotionKeysStream(source); + if (bUpdDefs) + UpdateMotionDefsStream(source); + if (m_MotionKeysStream.size()) + F.w(m_MotionKeysStream.pointer(), m_MotionKeysStream.size()); + if (m_MotionDefsStream.size()) + F.w(m_MotionDefsStream.pointer(), m_MotionDefsStream.size()); + } + else + { bool bRes = true; - if (bUpdGeom) bRes = UpdateGeometryStream(source); - if (!bRes){ - ELog.Msg(mtError,"Can't create preview geometry."); - return false; + if (bUpdGeom) + bRes = UpdateGeometryStream(source); + if (!bRes) + { + ELog.Msg(mtError, "Can't create preview geometry."); + return false; } - if (!m_GeometryStream.size()) return false; - F.w(m_GeometryStream.pointer(),m_GeometryStream.size()); + if (!m_GeometryStream.size()) + return false; + F.w(m_GeometryStream.pointer(), m_GeometryStream.size()); } - IReader R (F.pointer(), F.size()); - ::Render->model_Delete (m_pVisual,TRUE); - g_pMotionsContainer->clean (false); - m_pVisual = ::Render->model_Create (ChangeFileExt(source->GetName(),"").c_str(),&R); + IReader R(F.pointer(), F.size()); + ::Render->model_Delete(m_pVisual, TRUE); + g_pMotionsContainer->clean(false); + m_pVisual = ::Render->model_Create(ChangeFileExt(source->GetName(), "").c_str(), &R); m_pBlend = 0; return bRes; } @@ -155,103 +185,115 @@ bool EngineModel::UpdateVisual(CEditableObject* source, bool bUpdGeom, bool bUpd void EngineModel::PlayMotion(LPCSTR name, u16 slot) { - for (int k=0; kLL_GetMotionDef(motion_ID); VERIFY(mdef); + CKinematicsAnimated *SA = PKinematicsAnimated(m_pVisual); + if (IsRenderable()&&SA) + { + MotionID motion_ID = FindMotionID(name, slot); + if (motion_ID.valid()) + { + CMotionDef *mdef = SA->LL_GetMotionDef(motion_ID); + VERIFY(mdef); if (mdef->flags&esmFX) { - for (int k=0; kID_Motion(m_BPPlayItems[k].name.c_str(),m_BPPlayItems[k].slot); - if (D.valid()) SA->LL_PlayCycle((u16)k,D,false,0,0); + MotionID D = SA->ID_Motion(m_BPPlayItems[k].name.c_str(), m_BPPlayItems[k].slot); + if (D.valid()) + SA->LL_PlayCycle((u16)k, D, false, 0, 0); } - } - m_pBlend = SA->PlayFX(motion_ID,1.f); - }else{ - u16 idx = mdef->bone_or_part; + } + m_pBlend = SA->PlayFX(motion_ID, 1.f); + } + else + { + u16 idx = mdef->bone_or_part; R_ASSERT((idx==BI_NONE)||(idxID_Motion(m_BPPlayItems[k].name.c_str(),m_BPPlayItems[k].slot); - CBlend* B = 0; + MotionID D = SA->ID_Motion(m_BPPlayItems[k].name.c_str(), m_BPPlayItems[k].slot); + CBlend *B = 0; if (D.valid()) { - B = SA->LL_PlayCycle((u16)k,D,false,0,0); - if(B && (idx==k || idx==BI_NONE) ) - m_pBlend = B; + B = SA->LL_PlayCycle((u16)k, D, false, 0, 0); + if (B&&(idx==k||idx==BI_NONE)) + m_pBlend = B; } } - } + } } } } -/* - if (M&&IsRenderable()){ - if (M->flags&esmFX){ - for (int k=0; kID_Cycle_Safe(m_BPPlayCache[k].c_str()); - if (D) D->PlayCycle(PSkeletonAnimated(m_pVisual),k,false,0,0); - } - } - m_pBlend = PSkeletonAnimated(m_pVisual)->PlayFX(M->Name(),1.f); - }else{ - R_ASSERT((M->m_BoneOrPart==BI_NONE)||(M->m_BoneOrPartm_BoneOrPart; - if (BI_NONE==idx)for (int k=0; kName(); - else m_BPPlayCache[idx] = M->Name(); - m_pBlend = 0; - - for (int k=0; kID_Cycle_Safe(m_BPPlayCache[k].c_str()); - CBlend* B=0; - if (D){ - B = D->PlayCycle(PSkeletonAnimated(m_pVisual),k,(idx==k)?!(D->flags&esmNoMix):FALSE,0,0); - if (idx==k) m_pBlend = B; + /* + if (M&&IsRenderable()){ + if (M->flags&esmFX){ + for (int k=0; kID_Cycle_Safe(m_BPPlayCache[k].c_str()); + if (D) D->PlayCycle(PSkeletonAnimated(m_pVisual),k,false,0,0); + } + } + m_pBlend = PSkeletonAnimated(m_pVisual)->PlayFX(M->Name(),1.f); + }else{ + R_ASSERT((M->m_BoneOrPart==BI_NONE)||(M->m_BoneOrPartm_BoneOrPart; + if (BI_NONE==idx)for (int k=0; kName(); + else m_BPPlayCache[idx] = M->Name(); + m_pBlend = 0; + + for (int k=0; kID_Cycle_Safe(m_BPPlayCache[k].c_str()); + CBlend* B=0; + if (D){ + B = D->PlayCycle(PSkeletonAnimated(m_pVisual),k,(idx==k)?!(D->flags&esmNoMix):FALSE,0,0); + if (idx==k) m_pBlend = B; + } } - } - } + } + } } - } -*/ + */ } -void EngineModel::RestoreParams(TFormStorage* s) -{ - for (u16 k=0; kReadString("bp_cache_name_"+AnsiString(k),""); - m_BPPlayItems[k].slot = (u16)s->ReadInteger("bp_cache_slot_"+AnsiString(k),0); + +void EngineModel::RestoreParams(TFormStorage *s) +{ + for (u16 k = 0; kReadString("bp_cache_name_"+AnsiString(k), ""); + m_BPPlayItems[k].slot = (u16)s->ReadInteger("bp_cache_slot_"+AnsiString(k), 0); } } -void EngineModel::SaveParams(TFormStorage* s) +void EngineModel::SaveParams(TFormStorage *s) { - for (int k=0; kWriteString ("bp_cache_name_"+AnsiString(k), m_BPPlayItems[k].name); - s->WriteString ("bp_cache_slot_"+AnsiString(k), m_BPPlayItems[k].slot); + for (int k = 0; kWriteString("bp_cache_name_"+AnsiString(k), m_BPPlayItems[k].name); + s->WriteString("bp_cache_slot_"+AnsiString(k), m_BPPlayItems[k].slot); } } @@ -259,13 +301,17 @@ void EngineModel::SaveParams(TFormStorage* s) void CActorTools::OnMotionKeysModified() { - Modified (); - m_Flags.set (flUpdateMotionKeys,TRUE); - if (fraLeftBar->ebRenderEngineStyle->Down){ - m_Flags.set (flUpdateMotionKeys,FALSE); - if (m_RenderObject.UpdateVisual(m_pEditObject,false,true,false)){ + Modified(); + m_Flags.set(flUpdateMotionKeys, TRUE); + if (fraLeftBar->ebRenderEngineStyle->Down) + { + m_Flags.set(flUpdateMotionKeys, FALSE); + if (m_RenderObject.UpdateVisual(m_pEditObject, false, true, false)) + { PlayMotion(); - }else{ + } + else + { m_RenderObject.DeleteVisual(); fraLeftBar->SetRenderStyle(false); } @@ -275,121 +321,158 @@ void CActorTools::OnMotionKeysModified() void CActorTools::OnMotionDefsModified() { - Modified (); - m_Flags.set (flUpdateMotionDefs,TRUE); - if (fraLeftBar->ebRenderEngineStyle->Down){ - m_Flags.set (flUpdateMotionDefs,FALSE); - if (m_RenderObject.UpdateVisual(m_pEditObject,false,false,true)){ + Modified(); + m_Flags.set(flUpdateMotionDefs, TRUE); + if (fraLeftBar->ebRenderEngineStyle->Down) + { + m_Flags.set(flUpdateMotionDefs, FALSE); + if (m_RenderObject.UpdateVisual(m_pEditObject, false, false, true)) + { PlayMotion(); - }else{ + } + else + { m_RenderObject.DeleteVisual(); fraLeftBar->SetRenderStyle(false); } } - UndoSave (); + UndoSave(); } void CActorTools::OnGeometryModified() { - Modified (); - if (fraLeftBar->ebRenderEngineStyle->Down){ - m_Flags.set (flUpdateGeometry,FALSE); - if (m_RenderObject.UpdateVisual(m_pEditObject,true,false,false)){ + Modified(); + if (fraLeftBar->ebRenderEngineStyle->Down) + { + m_Flags.set(flUpdateGeometry, FALSE); + if (m_RenderObject.UpdateVisual(m_pEditObject, true, false, false)) + { PlayMotion(); - }else{ + } + else + { m_RenderObject.DeleteVisual(); fraLeftBar->SetRenderStyle(false); } } - UndoSave (); + UndoSave(); } + //--------------------------------------------------------------------------- bool CActorTools::AppendMotion(LPCSTR fn) { - VERIFY(m_pEditObject); - bool bRes = m_pEditObject->AppendSMotion(fn,&appended_motions); + VERIFY(m_pEditObject); + bool bRes = m_pEditObject->AppendSMotion(fn, &appended_motions); return bRes; } bool CActorTools::RemoveMotion(LPCSTR name) { - VERIFY(m_pEditObject); + VERIFY(m_pEditObject); return m_pEditObject->RemoveSMotion(name); } bool CActorTools::SaveMotions(LPCSTR name, bool bSelOnly) { - VERIFY(m_pEditObject); + VERIFY(m_pEditObject); ListItemsVec items; - if (bSelOnly){ - if (m_ObjectItems->GetSelected(MOTIONS_PREFIX,items,true)){ - CMemoryWriter F; - F.w_u32 (items.size()); - for (ListItemsIt it=items.begin(); it!=items.end(); it++) + if (bSelOnly) + { + if (m_ObjectItems->GetSelected(MOTIONS_PREFIX, items, true)) + { + CMemoryWriter F; + F.w_u32(items.size()); + for (ListItemsIt it = items.begin(); it!=items.end(); it++) ((CSMotion*)(*it)->m_Object)->Save(F); return F.save_to(name); } - }else{ - return m_pEditObject->SaveSMotions(name); + } + else + { + return m_pEditObject->SaveSMotions(name); } return false; } void CActorTools::MakePreview() { - if (m_pEditObject){ + if (m_pEditObject) + { CMemoryWriter F; - m_Flags.set (flUpdateGeometry|flUpdateMotionDefs|flUpdateMotionKeys,FALSE); - if (m_RenderObject.UpdateVisual(m_pEditObject,true,true,true)){ + m_Flags.set(flUpdateGeometry|flUpdateMotionDefs|flUpdateMotionKeys, FALSE); + if (m_RenderObject.UpdateVisual(m_pEditObject, true, true, true)) + { PlayMotion(); - }else{ - m_RenderObject.DeleteVisual(); - fraLeftBar->SetRenderStyle(false); } - }else{ - ELog.DlgMsg(mtError,"Scene empty. Load object first."); + else + { + m_RenderObject.DeleteVisual(); + fraLeftBar->SetRenderStyle(false); + } + } + else + { + ELog.DlgMsg(mtError, "Scene empty. Load object first."); } } void CActorTools::PlayMotion() { - if (m_pEditObject){ -//. m_ClipMaker->Stop(); - if (fraLeftBar->ebRenderEditorStyle->Down) m_pEditObject->SkeletonPlay(); - else if (fraLeftBar->ebRenderEngineStyle->Down) { - if (m_Flags.is(flUpdateMotionKeys)) { OnMotionKeysModified(); } - if (m_Flags.is(flUpdateMotionDefs)) { OnMotionDefsModified(); } - if (m_Flags.is(flUpdateGeometry)) { OnGeometryModified(); } - m_RenderObject.PlayMotion(m_CurrentMotion.c_str(),m_CurrentSlot); + if (m_pEditObject) + { + //. m_ClipMaker->Stop(); + if (fraLeftBar->ebRenderEditorStyle->Down) + m_pEditObject->SkeletonPlay(); + else if (fraLeftBar->ebRenderEngineStyle->Down) + { + if (m_Flags.is(flUpdateMotionKeys)) + { + OnMotionKeysModified(); + } + if (m_Flags.is(flUpdateMotionDefs)) + { + OnMotionDefsModified(); + } + if (m_Flags.is(flUpdateGeometry)) + { + OnGeometryModified(); + } + m_RenderObject.PlayMotion(m_CurrentMotion.c_str(), m_CurrentSlot); } } } void CActorTools::StopMotion() { - if (m_pEditObject) - if (fraLeftBar->ebRenderEditorStyle->Down) m_pEditObject->SkeletonStop(); - else if (fraLeftBar->ebRenderEngineStyle->Down&&m_RenderObject.m_pBlend) { - m_RenderObject.m_pBlend->playing = false; - m_RenderObject.m_pBlend->timeCurrent = 0; + if (m_pEditObject) + if (fraLeftBar->ebRenderEditorStyle->Down) + m_pEditObject->SkeletonStop(); + else if (fraLeftBar->ebRenderEngineStyle->Down&&m_RenderObject.m_pBlend) + { + m_RenderObject.m_pBlend->playing = false; + m_RenderObject.m_pBlend->timeCurrent = 0; } } void CActorTools::PauseMotion() { - if (m_pEditObject) - if (fraLeftBar->ebRenderEditorStyle->Down) m_pEditObject->SkeletonPause(true); - else if (fraLeftBar->ebRenderEngineStyle->Down&&m_RenderObject.m_pBlend) { - m_RenderObject.m_pBlend->playing=!m_RenderObject.m_pBlend->playing; + if (m_pEditObject) + if (fraLeftBar->ebRenderEditorStyle->Down) + m_pEditObject->SkeletonPause(true); + else if (fraLeftBar->ebRenderEngineStyle->Down&&m_RenderObject.m_pBlend) + { + m_RenderObject.m_pBlend->playing = !m_RenderObject.m_pBlend->playing; } } bool CActorTools::RenameMotion(LPCSTR old_name, LPCSTR new_name) { - R_ASSERT(m_pEditObject); - CSMotion* M = m_pEditObject->FindSMotionByName(old_name); R_ASSERT(M); - CSMotion* MN = m_pEditObject->FindSMotionByName(new_name); R_ASSERT(!MN); + R_ASSERT(m_pEditObject); + CSMotion *M = m_pEditObject->FindSMotionByName(old_name); + R_ASSERT(M); + CSMotion *MN = m_pEditObject->FindSMotionByName(new_name); + R_ASSERT(!MN); M->SetName(new_name); return true; } @@ -397,21 +480,22 @@ bool CActorTools::RenameMotion(LPCSTR old_name, LPCSTR new_name) void CActorTools::AddMarksChannel(bool b12) { - CSMotion* M = m_pEditObject->GetActiveSMotion(); - if(M) + CSMotion *M = m_pEditObject->GetActiveSMotion(); + if (M) { - if(b12) + if (b12) { - M->marks.resize (2); - M->marks[0].name = "Left"; - M->marks[1].name = "Right"; - }else + M->marks.resize(2); + M->marks[0].name = "Left"; + M->marks[1].name = "Right"; + } + else { - M->marks.resize (4); - M->marks[0].name = "Left"; - M->marks[1].name = "Right"; - M->marks[2].name = "Left2"; - M->marks[3].name = "Right2"; + M->marks.resize(4); + M->marks[0].name = "Left"; + M->marks[1].name = "Right"; + M->marks[2].name = "Left2"; + M->marks[3].name = "Right2"; } m_pEditObject->SetActiveSMotion(M); } @@ -419,23 +503,25 @@ void CActorTools::AddMarksChannel(bool b12) void CActorTools::RemoveMarksChannel(bool b12) { - CSMotion* M = m_pEditObject->GetActiveSMotion(); - if(M) + CSMotion *M = m_pEditObject->GetActiveSMotion(); + if (M) { - if(b12) - M->marks.clear (); + if (b12) + M->marks.clear(); else { - if(M->marks.size()==4) + if (M->marks.size()==4) { M->marks.pop_back(); M->marks.pop_back(); - }else + } + else { - R_ASSERT(M->marks.size()==0 || M->marks.size()==2); + R_ASSERT(M->marks.size()==0||M->marks.size()==2); } } - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } } + diff --git a/src/editors/ActorEditor/UI_ActorToolsProps.cpp b/src/editors/ActorEditor/UI_ActorToolsProps.cpp index 8eab25deaed..40fd0bbe9d0 100644 --- a/src/editors/ActorEditor/UI_ActorToolsProps.cpp +++ b/src/editors/ActorEditor/UI_ActorToolsProps.cpp @@ -3,810 +3,932 @@ #pragma hdrstop #include "UI_ActorTools.h" -#include "../ECore/Editor/UI_Main.h" -#include "../ECore/Editor/EditObject.h" -#include "../xrEProps/PropertiesList.h" -#include "motion.h" +#include "editors/ECore/Editor/UI_Main.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/xrEProps/PropertiesList.h" +#include "xrCore/Animation/Motion.hpp" #include "bone.h" #include "leftbar.h" -#include "../../Layers/xrRender/SkeletonAnimated.h" -#include "../xrEProps/ItemList.h" +#include "Layers/xrRender/SkeletonAnimated.h" +#include "editors/xrEProps/ItemList.h" + //------------------------------------------------------------------------------ -void CActorTools::OnObjectItemFocused(ListItemsVec& items) +void CActorTools::OnObjectItemFocused(ListItemsVec &items) { - PropItemVec props; - m_EditMode = emObject; - + PropItemVec props; + m_EditMode = emObject; + // unselect - if (m_pEditObject){ - m_pEditObject->ResetSAnimation(false); -//. StopMotion (); // óáðàë èç-çà òîãî ÷òî íå ìèêñÿòñÿ àíèìàöèè â ðåæèìå åíæèíå - m_pEditObject->SelectBones (false); + if (m_pEditObject) + { + m_pEditObject->ResetSAnimation(false); + //StopMotion(); // óáðàë èç-çà òîãî ÷òî íå ìèêñÿòñÿ àíèìàöèè â ðåæèìå åíæèíå + m_pEditObject->SelectBones(false); } - - if (!items.empty()){ - for (ListItemsIt it=items.begin(); it!=items.end(); it++){ - ListItem* prop = *it; - if (prop){ + + if (!items.empty()) + { + for (ListItemsIt it = items.begin(); it!=items.end(); it++) + { + ListItem *prop = *it; + if (prop) + { m_EditMode = EEditMode(prop->Type()); - switch(m_EditMode){ - case emObject: - FillObjectProperties(props,OBJECT_PREFIX,prop); - break; - case emMotion:{ - LPCSTR m_name = ExtractMotionName(prop->Key()); - u16 slot = ExtractMotionSlot(prop->Key()); - FillMotionProperties(props,MOTIONS_PREFIX,prop); - SetCurrentMotion (m_name,slot); - }break; - case emBone:{ - FillBoneProperties (props,BONES_PREFIX,prop); - CBone* BONE = (CBone*)prop->m_Object; - if (BONE) BONE->Select(TRUE); - }break; - case emSurface: - FillSurfaceProperties(props,SURFACES_PREFIX,prop); - break; - case emMesh: - break; + switch (m_EditMode) + { + case emObject: + FillObjectProperties(props,OBJECT_PREFIX, prop); + break; + case emMotion: + { + LPCSTR m_name = ExtractMotionName(prop->Key()); + u16 slot = ExtractMotionSlot(prop->Key()); + FillMotionProperties(props,MOTIONS_PREFIX, prop); + SetCurrentMotion(m_name, slot); + } + break; + case emBone: + { + FillBoneProperties(props,BONES_PREFIX, prop); + CBone *BONE = (CBone*)prop->m_Object; + if (BONE) + BONE->Select(TRUE); + } + break; + case emSurface: + FillSurfaceProperties(props,SURFACES_PREFIX, prop); + break; + case emMesh: + break; } } } } - m_Props->AssignItems(props); + m_Props->AssignItems(props); UI->RedrawScene(); } + //------------------------------------------------------------------------------ void CActorTools::PMMotionItemClick(TObject *Sender) { - R_ASSERT(m_pEditObject); - TMenuItem* mi = dynamic_cast(Sender); - if (mi){ - PropItem* prop = (PropItem*)mi->Tag; - if (prop){ - } + R_ASSERT(m_pEditObject); + TMenuItem *mi = dynamic_cast(Sender); + if (mi) + { + PropItem *prop = (PropItem*)mi->Tag; + if (prop) { } } } -void CActorTools::OnChangeTransform(PropValue* sender) +void CActorTools::OnChangeTransform(PropValue *sender) { OnMotionKeysModified(); - UI->RedrawScene(); + UI->RedrawScene(); } + //------------------------------------------------------------------------------ -void CActorTools::OnExportImportRefsClick(ButtonValue* V, bool& bModif, bool& bSafe) +void CActorTools::OnExportImportRefsClick(ButtonValue *V, bool &bModif, bool &bSafe) { switch (V->btn_num) { case 0: { // export - xr_string fname; - if(EFS.GetSaveName(_import_, fname)) + xr_string fname; + if (EFS.GetSaveName(_import_, fname)) { - CInifile ini( fname.c_str(), FALSE, FALSE, FALSE); - xr_vector::iterator it = m_pEditObject->m_SMotionRefs.begin(); - xr_vector::iterator it_e = m_pEditObject->m_SMotionRefs.end(); + CInifile ini(fname.c_str(), FALSE, FALSE, FALSE); + xr_vector::iterator + it = m_pEditObject->m_SMotionRefs.begin(); + xr_vector::iterator + it_e = m_pEditObject->m_SMotionRefs.end(); string64 buff; - for(u32 i=0;it!=it_e;++it,++i) + for (u32 i = 0; it!=it_e; ++it,++i) { - sprintf(buff, "%06d", i); - ini.w_string("refs", buff, (*it).c_str()); + sprintf(buff, "%06d", i); + ini.w_string("refs", buff, (*it).c_str()); } ini.save_as(fname.c_str()); - bModif = false; + bModif = false; } - }break; + } + break; case 1: { // import - xr_string fname; - if(EFS.GetOpenName(_import_, fname, false)) + xr_string fname; + if (EFS.GetOpenName(_import_, fname, false)) { - CInifile ini( fname.c_str(), TRUE, TRUE, FALSE); + CInifile ini(fname.c_str(), TRUE, TRUE, FALSE); m_pEditObject->m_SMotionRefs.clear(); - CInifile::Sect& S = ini.r_section("refs"); - CInifile::SectCIt it = S.Data.begin(); - CInifile::SectCIt it_e = S.Data.end(); - for(;it!=it_e;++it) + CInifile::Sect &S = ini.r_section("refs"); + CInifile::SectCIt it = S.Data.begin(); + CInifile::SectCIt it_e = S.Data.end(); + for (; it!=it_e; ++it) { - m_pEditObject->m_SMotionRefs.push_back( it->second); + m_pEditObject->m_SMotionRefs.push_back(it->second); } - OnMotionKeysModified (); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + OnMotionKeysModified(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); bModif = true; - }else + } + else bModif = false; - }break; + } + break; }; } -void CActorTools::OnMotionEditClick(ButtonValue* V, bool& bModif, bool& bSafe) +void CActorTools::OnMotionEditClick(ButtonValue *V, bool &bModif, bool &bSafe) { - R_ASSERT(m_pEditObject); + R_ASSERT(m_pEditObject); xr_string fn; - switch (V->btn_num){ - case 0:{ // append - AnsiString folder,nm,full_name; - xr_string fnames; - if (EFS.GetOpenName(_smotion_,fnames,true)){ - AStringVec lst; - _SequenceToList(lst,fnames.c_str()); - bool bRes = false; - for (AStringIt it=lst.begin(); it!=lst.end(); it++) - if (AppendMotion(it->c_str())) bRes=true; - ExecCommand (COMMAND_UPDATE_PROPERTIES); - if (bRes) OnMotionKeysModified(); - else ELog.DlgMsg(mtError,"Append not completed."); - bModif = false; - }else - bModif = false; - }break; - case 1:{ // delete - ListItemsVec items; - if (m_ObjectItems->GetSelected(MOTIONS_PREFIX,items,true)){ - if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, "Delete selected %d item(s)?",items.size()) == mrYes){ - for (ListItemsIt it=items.begin(); it!=items.end(); it++){ - VERIFY((*it)->m_Object); - RemoveMotion(((CSMotion*)(*it)->m_Object)->Name()); - } - m_ObjectItems->LockUpdating(); - SelectListItem(MOTIONS_PREFIX,0,true,false,false); - m_ObjectItems->UnlockUpdating(); + switch (V->btn_num) + { + case 0: + { // append + AnsiString folder, nm, full_name; + xr_string fnames; + if (EFS.GetOpenName(_smotion_, fnames, true)) + { + AStringVec lst; + _SequenceToList(lst, fnames.c_str()); + bool bRes = false; + for (AStringIt it = lst.begin(); it!=lst.end(); it++) + if (AppendMotion(it->c_str())) + bRes = true; ExecCommand(COMMAND_UPDATE_PROPERTIES); - OnMotionKeysModified(); + if (bRes) + OnMotionKeysModified(); + else + ELog.DlgMsg(mtError, "Append not completed."); bModif = false; - }else{ - bModif = false; } - }else - ELog.DlgMsg(mtInformation,"Select at least one motion."); - }break; - case 2:{ // save - int mr=ELog.DlgMsg(mtConfirmation, "Save selected motions only?"); - if (mr!=mrCancel){ - if (EFS.GetSaveName(_smotion_,fn,0,1)){ - switch (mr){ - case mrYes: SaveMotions(fn.c_str(),true); break; - case mrNo: SaveMotions(fn.c_str(),false);break; + else + bModif = false; + } + break; + case 1: + { // delete + ListItemsVec items; + if (m_ObjectItems->GetSelected(MOTIONS_PREFIX, items, true)) + { + if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<m_Object); + RemoveMotion(((CSMotion*)(*it)->m_Object)->Name()); + } + m_ObjectItems->LockUpdating(); + SelectListItem(MOTIONS_PREFIX, 0, true, false, false); + m_ObjectItems->UnlockUpdating(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + OnMotionKeysModified(); + bModif = false; + } + else + { + bModif = false; + } + } + else + ELog.DlgMsg(mtInformation, "Select at least one motion."); + } + break; + case 2: + { // save + int mr = ELog.DlgMsg(mtConfirmation, "Save selected motions only?"); + if (mr!=mrCancel) + { + if (EFS.GetSaveName(_smotion_, fn, 0, 1)) + { + switch (mr) + { + case mrYes: SaveMotions(fn.c_str(), true); + break; + case mrNo: SaveMotions(fn.c_str(), false); + break; + } } } + bModif = false; } - bModif = false; - }break; - } + break; + } } void CActorTools::RealUpdateProperties() { - m_Flags.set(flRefreshProps,FALSE); - ListItemsVec items; - if (m_pEditObject){ - LHelper().CreateItem (items,OBJECT_PREFIX,0,emObject); - m_pEditObject->FillSurfaceList (SURFACES_PREFIX,items,emSurface); + m_Flags.set(flRefreshProps, FALSE); + ListItemsVec items; + if (m_pEditObject) + { + LHelper().CreateItem(items,OBJECT_PREFIX, 0, emObject); + m_pEditObject->FillSurfaceList(SURFACES_PREFIX, items, emSurface); // skin - if (m_pEditObject->IsSkeleton()){ - if (m_pEditObject->m_SMotionRefs.size()){ - m_RenderObject.FillMotionList(MOTIONS_PREFIX,items,emMotion); - }else{ - m_pEditObject->FillMotionList(MOTIONS_PREFIX,items,emMotion); + if (m_pEditObject->IsSkeleton()) + { + if (m_pEditObject->m_SMotionRefs.size()) + { + m_RenderObject.FillMotionList(MOTIONS_PREFIX, items, emMotion); } - m_pEditObject->FillBoneList (BONES_PREFIX,items,emBone); + else + { + m_pEditObject->FillMotionList(MOTIONS_PREFIX, items, emMotion); + } + m_pEditObject->FillBoneList(BONES_PREFIX, items, emBone); } - } - - m_ObjectItems->AssignItems(items,false);//,"",true); + } + + m_ObjectItems->AssignItems(items, false);//,"",true); // if appended motions exist - select it - if (!appended_motions.empty()){ - SelectListItem(MOTIONS_PREFIX,0,true,false,true); - m_ObjectItems->LockUpdating(); - for (SMotionIt m_it=appended_motions.begin(); m_it!=appended_motions.end(); m_it++) - SelectListItem(MOTIONS_PREFIX,(*m_it)->Name(),true,true,true); - m_ObjectItems->UnlockUpdating(); - appended_motions.clear(); + if (!appended_motions.empty()) + { + SelectListItem(MOTIONS_PREFIX, 0, true, false, true); + m_ObjectItems->LockUpdating(); + for (SMotionIt m_it = appended_motions.begin(); m_it!=appended_motions.end(); m_it++) + SelectListItem(MOTIONS_PREFIX, (*m_it)->Name(), true, true, true); + m_ObjectItems->UnlockUpdating(); + appended_motions.clear(); } } + //------------------------------------------------------------------------------ - -void CActorTools::OnMotionTypeChange(PropValue* sender) + +void CActorTools::OnMotionTypeChange(PropValue *sender) { - RefreshSubProperties(); + RefreshSubProperties(); } + //------------------------------------------------------------------------------ - -void CActorTools::OnMotionNameChange(PropValue* V) + +void CActorTools::OnMotionNameChange(PropValue *V) { OnMotionKeysModified(); } + //------------------------------------------------------------------------------ -void CActorTools::OnMotionControlClick(ButtonValue* V, bool& bModif, bool& bSafe) +void CActorTools::OnMotionControlClick(ButtonValue *V, bool &bModif, bool &bSafe) { - switch (V->btn_num){ - case 0: PlayMotion(); break; - case 1: StopMotion(); break; - case 2: PauseMotion(); break; - } + switch (V->btn_num) + { + case 0: PlayMotion(); + break; + case 1: StopMotion(); + break; + case 2: PauseMotion(); + break; + } bModif = false; } + //------------------------------------------------------------------------------ -void CActorTools::OnMarksControlClick12(ButtonValue* V, bool& bModif, bool& bSafe) +void CActorTools::OnMarksControlClick12(ButtonValue *V, bool &bModif, bool &bSafe) { switch (V->btn_num) { - case 0: AddMarksChannel(true); break; - case 1: RemoveMarksChannel(true); break; - } + case 0: AddMarksChannel(true); + break; + case 1: RemoveMarksChannel(true); + break; + } bModif = true; } + //------------------------------------------------------------------------------ -void CActorTools::OnMarksControlClick34(ButtonValue* V, bool& bModif, bool& bSafe) +void CActorTools::OnMarksControlClick34(ButtonValue *V, bool &bModif, bool &bSafe) { switch (V->btn_num) { - case 0: AddMarksChannel(false); break; - case 1: RemoveMarksChannel(false); break; - } + case 0: AddMarksChannel(false); + break; + case 1: RemoveMarksChannel(false); + break; + } bModif = true; } + //------------------------------------------------------------------------------ -void CActorTools::OnMotionRefsChange(PropValue* sender) +void CActorTools::OnMotionRefsChange(PropValue *sender) { - u32 set_cnt = _GetItemCount(m_tmp_mot_refs.c_str()); + u32 set_cnt = _GetItemCount(m_tmp_mot_refs.c_str()); m_pEditObject->m_SMotionRefs.clear(); m_pEditObject->m_SMotionRefs.reserve(set_cnt); - string_path nm; - for (u32 k=0; km_SMotionRefs.push_back (nm); + _GetItem(m_tmp_mot_refs.c_str(), k, nm); + m_pEditObject->m_SMotionRefs.push_back(nm); } - OnMotionKeysModified (); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + OnMotionKeysModified(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void CActorTools::OnBoxAxisClick(ButtonValue* V, bool& bModif, bool& bSafe) +void CActorTools::OnBoxAxisClick(ButtonValue *V, bool &bModif, bool &bSafe) { - CBone* BONE = (CBone*)V->tag; - switch (V->btn_num){ - case 0: BONE->shape.box.m_rotate.k.set(1,0,0); break; - case 1: BONE->shape.box.m_rotate.k.set(0,1,0); break; - case 2: BONE->shape.box.m_rotate.k.set(0,0,1); break; + CBone *BONE = (CBone*)V->tag; + switch (V->btn_num) + { + case 0: BONE->shape.box.m_rotate.k.set(1, 0, 0); + break; + case 1: BONE->shape.box.m_rotate.k.set(0, 1, 0); + break; + case 2: BONE->shape.box.m_rotate.k.set(0, 0, 1); + break; } - Fvector::generate_orthonormal_basis_normalized(BONE->shape.box.m_rotate.k,BONE->shape.box.m_rotate.j,BONE->shape.box.m_rotate.i); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + Fvector::generate_orthonormal_basis_normalized(BONE->shape.box.m_rotate.k, BONE->shape.box.m_rotate.j, BONE->shape.box.m_rotate.i); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void CActorTools::OnCylinderAxisClick(ButtonValue* V, bool& bModif, bool& bSafe) +void CActorTools::OnCylinderAxisClick(ButtonValue *V, bool &bModif, bool &bSafe) { - CBone* BONE = (CBone*)V->tag; - switch (V->btn_num){ - case 0: BONE->shape.cylinder.m_direction.set(1,0,0); break; - case 1: BONE->shape.cylinder.m_direction.set(0,1,0); break; - case 2: BONE->shape.cylinder.m_direction.set(0,0,1); break; + CBone *BONE = (CBone*)V->tag; + switch (V->btn_num) + { + case 0: BONE->shape.cylinder.m_direction.set(1, 0, 0); + break; + case 1: BONE->shape.cylinder.m_direction.set(0, 1, 0); + break; + case 2: BONE->shape.cylinder.m_direction.set(0, 0, 1); + break; } - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } #include "envelope.h" Fvector StartMotionPoint, EndMotionPoint; -void CActorTools::FillMotionProperties(PropItemVec& items, LPCSTR pref, ListItem* sender) + +void CActorTools::FillMotionProperties(PropItemVec &items, LPCSTR pref, ListItem *sender) { - R_ASSERT(m_pEditObject); - CSMotion* SM = m_pEditObject->m_SMotionRefs.size()?0:(CSMotion*)sender->m_Object; - PropValue* V; + R_ASSERT(m_pEditObject); + CSMotion *SM = m_pEditObject->m_SMotionRefs.size() ? 0 : (CSMotion*)sender->m_Object; + PropValue *V; AnsiString m_cnt; - if (m_pEditObject->m_SMotionRefs.size()){ - if (fraLeftBar->ebRenderEngineStyle->Down){ - CKinematicsAnimated* V = PKinematicsAnimated(m_RenderObject.m_pVisual); - if (V) m_cnt = V->LL_CycleCount()+V->LL_FXCount(); - }else{ - m_cnt = AnsiString(m_pEditObject->SMotionCount())+" (Inaccessible)"; + if (m_pEditObject->m_SMotionRefs.size()) + { + if (fraLeftBar->ebRenderEngineStyle->Down) + { + CKinematicsAnimated*V = PKinematicsAnimated(m_RenderObject.m_pVisual); + if (V) + m_cnt = V->LL_CycleCount()+V->LL_FXCount(); + } + else + { + m_cnt = AnsiString(m_pEditObject->SMotionCount())+" (Inaccessible)"; } - }else{ - m_cnt = m_pEditObject->SMotionCount(); } - - PHelper().CreateCaption (items, PrepareKey(pref,"Global\\Motion count"), m_cnt.c_str()); + else + { + m_cnt = m_pEditObject->SMotionCount(); + } + + PHelper().CreateCaption(items, PrepareKey(pref, "Global\\Motion count"), m_cnt.c_str()); - AnsiString tmp; - for(u32 i=0; im_SMotionRefs.size(); ++i) + AnsiString tmp; + for (u32 i = 0; im_SMotionRefs.size(); ++i) { - if(i!=0) - tmp += ','; - tmp += m_pEditObject->m_SMotionRefs[i].c_str(); + if (i!=0) + tmp += ','; + tmp += m_pEditObject->m_SMotionRefs[i].c_str(); } - m_tmp_mot_refs = tmp.c_str(); - V=PHelper().CreateChoose (items, PrepareKey(pref,"Global\\Motion reference"),&m_tmp_mot_refs, smGameSMotions,0,0,MAX_ANIM_SLOT); + m_tmp_mot_refs = tmp.c_str(); + V = PHelper().CreateChoose(items, PrepareKey(pref, "Global\\Motion reference"), &m_tmp_mot_refs, smGameSMotions, 0, 0, MAX_ANIM_SLOT); // m_pEditObject->m_SMotionRefs - V->OnChangeEvent.bind (this,&CActorTools::OnMotionRefsChange); - ButtonValue* B; + V->OnChangeEvent.bind(this, &CActorTools::OnMotionRefsChange); + ButtonValue *B; - B=PHelper().CreateButton (items, PrepareKey(pref,"Export Import"), "ExportRefs,ImportRefs",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CActorTools::OnExportImportRefsClick); + B = PHelper().CreateButton(items, PrepareKey(pref, "Export Import"), "ExportRefs,ImportRefs", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CActorTools::OnExportImportRefsClick); - if (m_pEditObject->m_SMotionRefs.size()==0) - { - B=PHelper().CreateButton (items, PrepareKey(pref,"Global\\Edit"), "Append,Delete,Save",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CActorTools::OnMotionEditClick); + if (m_pEditObject->m_SMotionRefs.size()==0) + { + B = PHelper().CreateButton(items, PrepareKey(pref, "Global\\Edit"), "Append,Delete,Save", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CActorTools::OnMotionEditClick); } if (SM) { - B=PHelper().CreateButton (items, PrepareKey(pref,"Motion\\Control"), "Play,Stop,Pause",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CActorTools::OnMotionControlClick); - PHelper().CreateCaption (items, PrepareKey(pref,"Motion\\Frame\\Start"), shared_str().printf("%d",SM->FrameStart())); - PHelper().CreateCaption (items, PrepareKey(pref,"Motion\\Frame\\End"), shared_str().printf("%d",SM->FrameEnd())); - PHelper().CreateCaption (items, PrepareKey(pref,"Motion\\Frame\\Length"), shared_str().printf("%d",SM->Length())); - PropValue* P=0; - P=PHelper().CreateName (items,PrepareKey(pref,"Motion\\Name"), &SM->name, sender); - P->OnChangeEvent.bind (this,&CActorTools::OnMotionNameChange); - PHelper().CreateFloat (items,PrepareKey(pref,"Motion\\Speed"), &SM->fSpeed, 0.f,10.f,0.01f,2); - PHelper().CreateFloat (items,PrepareKey(pref,"Motion\\Accrue"), &SM->fAccrue, 0.f,10.f,0.01f,2); - PHelper().CreateFloat (items,PrepareKey(pref,"Motion\\Falloff"), &SM->fFalloff,0.f,10.f,0.01f,2); - - PropValue /**C=0,*/*TV=0; - TV = PHelper().CreateFlag8 (items,PrepareKey(pref,"Motion\\Type FX"), &SM->m_Flags, esmFX); - TV->OnChangeEvent.bind (this,&CActorTools::OnMotionTypeChange); - m_BoneParts.clear (); + B = PHelper().CreateButton(items, PrepareKey(pref, "Motion\\Control"), "Play,Stop,Pause", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CActorTools::OnMotionControlClick); + PHelper().CreateCaption(items, PrepareKey(pref, "Motion\\Frame\\Start"), shared_str().printf("%d", SM->FrameStart())); + PHelper().CreateCaption(items, PrepareKey(pref, "Motion\\Frame\\End"), shared_str().printf("%d", SM->FrameEnd())); + PHelper().CreateCaption(items, PrepareKey(pref, "Motion\\Frame\\Length"), shared_str().printf("%d", SM->Length())); + PropValue *P = 0; + P = PHelper().CreateName(items, PrepareKey(pref, "Motion\\Name"), &SM->name, sender); + P->OnChangeEvent.bind(this, &CActorTools::OnMotionNameChange); + PHelper().CreateFloat(items, PrepareKey(pref, "Motion\\Speed"), &SM->fSpeed, 0.f, 10.f, 0.01f, 2); + PHelper().CreateFloat(items, PrepareKey(pref, "Motion\\Accrue"), &SM->fAccrue, 0.f, 10.f, 0.01f, 2); + PHelper().CreateFloat(items, PrepareKey(pref, "Motion\\Falloff"), &SM->fFalloff, 0.f, 10.f, 0.01f, 2); + + PropValue /**C=0,*/*TV = 0; + TV = PHelper().CreateFlag8(items, PrepareKey(pref, "Motion\\Type FX"), &SM->m_Flags, esmFX); + TV->OnChangeEvent.bind(this, &CActorTools::OnMotionTypeChange); + m_BoneParts.clear(); if (SM->m_Flags.is(esmFX)) { - for (BoneIt it=m_pEditObject->FirstBone(); it!=m_pEditObject->LastBone(); it++) - m_BoneParts.push_back (xr_rtoken((*it)->Name().c_str(),(*it)->SelfID)); - PHelper().CreateRToken16 (items,PrepareKey(pref,"Motion\\FX\\Start bone"), (u16*)&SM->m_BoneOrPart, &*m_BoneParts.begin(), m_BoneParts.size()); - - PHelper().CreateFloat (items,PrepareKey(pref,"Motion\\FX\\Power"), &SM->fPower, 0.f,10.f,0.01f,2); - }else{ - m_BoneParts.push_back(xr_rtoken("--all bones--",BI_NONE)); - for (BPIt it=m_pEditObject->FirstBonePart(); it!=m_pEditObject->LastBonePart(); it++) - m_BoneParts.push_back (xr_rtoken(it->alias.c_str(),it-m_pEditObject->FirstBonePart())); - PHelper().CreateRToken16 (items,PrepareKey(pref,"Motion\\Cycle\\Bone part"), &SM->m_BoneOrPart, &*m_BoneParts.begin(), m_BoneParts.size()); - PHelper().CreateFlag8 (items,PrepareKey(pref,"Motion\\Cycle\\Stop at end"), &SM->m_Flags, esmStopAtEnd); - PHelper().CreateFlag8 (items,PrepareKey(pref,"Motion\\Cycle\\No mix"), &SM->m_Flags, esmNoMix); - PHelper().CreateFlag8 (items,PrepareKey(pref,"Motion\\Cycle\\Sync part"), &SM->m_Flags, esmSyncPart); - - PHelper().CreateFlag8 (items,PrepareKey(pref,"Motion\\Cycle\\UseFootSteps"), &SM->m_Flags, esmUseFootSteps); - PHelper().CreateFlag8 (items,PrepareKey(pref,"Motion\\Cycle\\Move XForm"), &SM->m_Flags, esmRootMover); - PHelper().CreateFlag8 (items,PrepareKey(pref,"Motion\\Cycle\\Idle"), &SM->m_Flags, esmIdle); - PHelper().CreateFlag8 (items,PrepareKey(pref,"Motion\\Cycle\\UseWeaponBone"), &SM->m_Flags, esmUseWeaponBone); + for (BoneIt it = m_pEditObject->FirstBone(); it!=m_pEditObject->LastBone(); it++) + m_BoneParts.push_back(xr_rtoken((*it)->Name().c_str(), (*it)->SelfID)); + PHelper().CreateRToken16(items, PrepareKey(pref, "Motion\\FX\\Start bone"), (u16*)&SM->m_BoneOrPart, &*m_BoneParts.begin(), m_BoneParts.size()); + + PHelper().CreateFloat(items, PrepareKey(pref, "Motion\\FX\\Power"), &SM->fPower, 0.f, 10.f, 0.01f, 2); + } + else + { + m_BoneParts.push_back(xr_rtoken("--all bones--", BI_NONE)); + for (BPIt it = m_pEditObject->FirstBonePart(); it!=m_pEditObject->LastBonePart(); it++) + m_BoneParts.push_back(xr_rtoken(it->alias.c_str(), it-m_pEditObject->FirstBonePart())); + PHelper().CreateRToken16(items, PrepareKey(pref, "Motion\\Cycle\\Bone part"), &SM->m_BoneOrPart, &*m_BoneParts.begin(), m_BoneParts.size()); + PHelper().CreateFlag8(items, PrepareKey(pref, "Motion\\Cycle\\Stop at end"), &SM->m_Flags, esmStopAtEnd); + PHelper().CreateFlag8(items, PrepareKey(pref, "Motion\\Cycle\\No mix"), &SM->m_Flags, esmNoMix); + PHelper().CreateFlag8(items, PrepareKey(pref, "Motion\\Cycle\\Sync part"), &SM->m_Flags, esmSyncPart); + + PHelper().CreateFlag8(items, PrepareKey(pref, "Motion\\Cycle\\UseFootSteps"), &SM->m_Flags, esmUseFootSteps); + PHelper().CreateFlag8(items, PrepareKey(pref, "Motion\\Cycle\\Move XForm"), &SM->m_Flags, esmRootMover); + PHelper().CreateFlag8(items, PrepareKey(pref, "Motion\\Cycle\\Idle"), &SM->m_Flags, esmIdle); + PHelper().CreateFlag8(items, PrepareKey(pref, "Motion\\Cycle\\UseWeaponBone"), &SM->m_Flags, esmUseWeaponBone); } - B=PHelper().CreateButton (items, PrepareKey(pref,"Marks\\Control-12"), "Add,Remove",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CActorTools::OnMarksControlClick12); + B = PHelper().CreateButton(items, PrepareKey(pref, "Marks\\Control-12"), "Add,Remove", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CActorTools::OnMarksControlClick12); - B=PHelper().CreateButton (items, PrepareKey(pref,"Marks\\Control-34"), "Add,Remove",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CActorTools::OnMarksControlClick34); + B = PHelper().CreateButton(items, PrepareKey(pref, "Marks\\Control-34"), "Add,Remove", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CActorTools::OnMarksControlClick34); - for(u32 i=0; i< SM->marks.size(); ++i) + for (u32 i = 0; imarks.size(); ++i) { - string128 buff; - sprintf(buff,"Marks\\%d", i); - P=PHelper().CreateCaption (items,PrepareKey(pref, buff), SM->marks[i].name); + string128 buff; + sprintf(buff, "Marks\\%d", i); + P = PHelper().CreateCaption(items, PrepareKey(pref, buff), SM->marks[i].name); } { - int bidx = 0; - BoneMotionVec& BMV = SM->BoneMotions(); - st_BoneMotion& BM = BMV[bidx]; - StartMotionPoint.x = BM.envs[ctPositionX]->keys.size() ? BM.envs[ctPositionX]->keys.front()->value : -1; - StartMotionPoint.y = BM.envs[ctPositionY]->keys.size() ? BM.envs[ctPositionY]->keys.front()->value : -1; - StartMotionPoint.z = BM.envs[ctPositionZ]->keys.size() ? BM.envs[ctPositionZ]->keys.front()->value : -1; + int bidx = 0; + BoneMotionVec &BMV = SM->BoneMotions(); + st_BoneMotion &BM = BMV[bidx]; + StartMotionPoint.x = BM.envs[ctPositionX]->keys.size() ? BM.envs[ctPositionX]->keys.front()->value : -1; + StartMotionPoint.y = BM.envs[ctPositionY]->keys.size() ? BM.envs[ctPositionY]->keys.front()->value : -1; + StartMotionPoint.z = BM.envs[ctPositionZ]->keys.size() ? BM.envs[ctPositionZ]->keys.front()->value : -1; - PHelper().CreateVector(items,PrepareKey(pref,"Motion\\RootStartTransform"), &StartMotionPoint,-10000,10000,0.001,4); + PHelper().CreateVector(items, PrepareKey(pref, "Motion\\RootStartTransform"), &StartMotionPoint, -10000, 10000, 0.001, 4); - EndMotionPoint.x = BM.envs[ctPositionX]->keys.size() ? BM.envs[ctPositionX]->keys.back()->value : -1; - EndMotionPoint.y = BM.envs[ctPositionY]->keys.size() ? BM.envs[ctPositionY]->keys.back()->value : -1; - EndMotionPoint.z = BM.envs[ctPositionZ]->keys.size() ? BM.envs[ctPositionZ]->keys.back()->value : -1; + EndMotionPoint.x = BM.envs[ctPositionX]->keys.size() ? BM.envs[ctPositionX]->keys.back()->value : -1; + EndMotionPoint.y = BM.envs[ctPositionY]->keys.size() ? BM.envs[ctPositionY]->keys.back()->value : -1; + EndMotionPoint.z = BM.envs[ctPositionZ]->keys.size() ? BM.envs[ctPositionZ]->keys.back()->value : -1; - PHelper().CreateVector(items,PrepareKey(pref,"Motion\\RootEndTransform"), &EndMotionPoint,-10000,10000,0.001,4); + PHelper().CreateVector(items, PrepareKey(pref, "Motion\\RootEndTransform"), &EndMotionPoint, -10000, 10000, 0.001, 4); } - } } + //------------------------------------------------------------------------------ -xr_token joint_types[]={ - { "Rigid", jtRigid }, - { "Cloth", jtCloth }, - { "Joint", jtJoint }, - { "Wheel [Steer-X/Roll-Z]", jtWheel }, - { "Slider", jtSlider }, -// { "Wheel [Steer-X/Roll-Z]", jtWheelXZ }, -// { "Wheel [Steer-X/Roll-Y]", jtWheelXY }, -// { "Wheel [Steer-Y/Roll-X]", jtWheelYX }, -// { "Wheel [Steer-Y/Roll-Z]", jtWheelYZ }, -// { "Wheel [Steer-Z/Roll-X]", jtWheelZX }, -// { "Wheel [Steer-Z/Roll-Y]", jtWheelZY }, - { 0, 0 } +xr_token joint_types[] = { + {"Rigid", jtRigid}, + {"Cloth", jtCloth}, + {"Joint", jtJoint}, + {"Wheel [Steer-X/Roll-Z]", jtWheel}, + {"Slider", jtSlider}, + // { "Wheel [Steer-X/Roll-Z]", jtWheelXZ }, + // { "Wheel [Steer-X/Roll-Y]", jtWheelXY }, + // { "Wheel [Steer-Y/Roll-X]", jtWheelYX }, + // { "Wheel [Steer-Y/Roll-Z]", jtWheelYZ }, + // { "Wheel [Steer-Z/Roll-X]", jtWheelZX }, + // { "Wheel [Steer-Z/Roll-Y]", jtWheelZY }, + {0, 0} }; -xr_token shape_types[]={ - { "None", SBoneShape::stNone }, - { "Box", SBoneShape::stBox }, - { "Sphere", SBoneShape::stSphere }, - { "Cylinder", SBoneShape::stCylinder }, - { 0, 0 } +xr_token shape_types[] = { + {"None", SBoneShape::stNone}, + {"Box", SBoneShape::stBox}, + {"Sphere", SBoneShape::stSphere}, + {"Cylinder", SBoneShape::stCylinder}, + {0, 0} }; -static const LPCSTR axis[3]= -{ "Axis X", "Axis Y", "Axis Z" }; +static const LPCSTR axis[3] = +{"Axis X", "Axis Y", "Axis Z"}; -void CActorTools::OnJointTypeChange(PropValue* V) +void CActorTools::OnJointTypeChange(PropValue *V) { - ExecCommand(COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void CActorTools::OnShapeTypeChange(PropValue* V) + +void CActorTools::OnShapeTypeChange(PropValue *V) { - UI->RedrawScene(); - ExecCommand(COMMAND_UPDATE_PROPERTIES); + UI->RedrawScene(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void CActorTools::OnBindTransformChange(PropValue* V) + +void CActorTools::OnBindTransformChange(PropValue *V) { - R_ASSERT(m_pEditObject); + R_ASSERT(m_pEditObject); m_pEditObject->OnBindTransformChange(); - UI->RedrawScene(); + UI->RedrawScene(); } -void CActorTools::OnBoneShapeClick(ButtonValue* V, bool& bModif, bool& bSafe) +void CActorTools::OnBoneShapeClick(ButtonValue *V, bool &bModif, bool &bSafe) { - R_ASSERT(m_pEditObject); - switch (V->btn_num){ - case 0: m_pEditObject->GenerateBoneShape(false); break; - case 1: m_pEditObject->GenerateBoneShape(true); break; - } + R_ASSERT(m_pEditObject); + switch (V->btn_num) + { + case 0: m_pEditObject->GenerateBoneShape(false); + break; + case 1: m_pEditObject->GenerateBoneShape(true); + break; + } } -void GetBindAbsolutePosition(CBone* B, Fmatrix& dest) +void GetBindAbsolutePosition(CBone *B, Fmatrix &dest) { - - if(B->Parent()) - GetBindAbsolutePosition(B->Parent(), dest); + if (B->Parent()) + GetBindAbsolutePosition(B->Parent(), dest); { - Fmatrix M; - M.setXYZi ( B->_RestRotate() ); - M.c.set ( B->_RestOffset() ); - M.mulA_43 (dest); - dest.set (M); + Fmatrix M; + M.setXYZi(B->_RestRotate()); + M.c.set(B->_RestOffset()); + M.mulA_43(dest); + dest.set(M); } - } + #include "../xrEprops/ChoseForm.h" -void CActorTools::OnBoneCreateDeleteClick(ButtonValue* V, bool& bModif, bool& bSafe) +void CActorTools::OnBoneCreateDeleteClick(ButtonValue *V, bool &bModif, bool &bSafe) { - R_ASSERT(m_pEditObject); - BoneVec sel_bones; - m_pEditObject->GetSelectedBones (sel_bones); + R_ASSERT(m_pEditObject); + BoneVec sel_bones; + m_pEditObject->GetSelectedBones(sel_bones); switch (V->btn_num) { case 0: { //create - CBone* B = sel_bones.size()?sel_bones[0]:NULL; + CBone *B = sel_bones.size() ? sel_bones[0] : NULL; m_pEditObject->AddBone(B); bModif = true; - }break; + } + break; case 1: { //deleet - if(sel_bones.size()!=1) + if (sel_bones.size()!=1) { - Msg("! Select 1 bone please."); + Msg("! Select 1 bone please."); return; } - if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, "Delete selected bone?") == mrYes) - { - m_pEditObject->DeleteBone(sel_bones[0]); - bModif = true; - - } - }break; + if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<DeleteBone(sel_bones[0]); + bModif = true; + } + } + break; case 2: { - if(sel_bones.size()!=1) + if (sel_bones.size()!=1) { Msg("! Select 1 bone please."); return; } - LPCSTR _bone_name = 0; + LPCSTR _bone_name = 0; - if (TfrmChoseItem::SelectItem(smSkeletonBonesInObject, _bone_name, 1, 0, 0, m_pEditObject) ) - { - Msg("selected bone %s", _bone_name); - CBone* BSelected = m_pEditObject->FindBoneByName(_bone_name); - R_ASSERT (BSelected); + if (TfrmChoseItem::SelectItem(smSkeletonBonesInObject, _bone_name, 1, 0, 0, m_pEditObject)) + { + Msg("selected bone %s", _bone_name); + CBone *BSelected = m_pEditObject->FindBoneByName(_bone_name); + R_ASSERT(BSelected); - CBone* BEditable = sel_bones[0]; - Fmatrix matrix1, matrix2; - Fvector offset, rotate1, rotate2, rotate; - float length = 0.01f; + CBone *BEditable = sel_bones[0]; + Fmatrix matrix1, matrix2; + Fvector offset, rotate1, rotate2, rotate; + float length = 0.01f; - m_pEditObject->GotoBindPose(); + m_pEditObject->GotoBindPose(); - matrix1.identity(); - matrix2.identity(); - GetBindAbsolutePosition (BEditable, matrix1); - GetBindAbsolutePosition (BSelected, matrix2); + matrix1.identity(); + matrix2.identity(); + GetBindAbsolutePosition(BEditable, matrix1); + GetBindAbsolutePosition(BSelected, matrix2); - Fmatrix R; - R.mul(matrix1.invert(), matrix2).getXYZi(rotate); - offset.set(R.c); + Fmatrix R; + R.mul(matrix1.invert(), matrix2).getXYZi(rotate); + offset.set(R.c); - BEditable->SetRestParams (length, offset, rotate); + BEditable->SetRestParams(length, offset, rotate); - m_pEditObject->GotoBindPose(); - } - }break; - } - if(bModif) + m_pEditObject->GotoBindPose(); + } + } + break; + } + if (bModif) { - bSafe = false; - m_Flags.set (flRefreshProps, TRUE); + bSafe = false; + m_Flags.set(flRefreshProps, TRUE); } } -bool CActorTools::OnBoneNameAfterEdit (PropValue* sender, shared_str& edit_val) +bool CActorTools::OnBoneNameAfterEdit(PropValue *sender, shared_str &edit_val) { - R_ASSERT(m_pEditObject); - BoneVec sel_bones; - m_pEditObject->GetSelectedBones (sel_bones); - CBone* B = sel_bones.size()?sel_bones[0]:NULL; - R_ASSERT (B); + R_ASSERT(m_pEditObject); + BoneVec sel_bones; + m_pEditObject->GetSelectedBones(sel_bones); + CBone *B = sel_bones.size() ? sel_bones[0] : NULL; + R_ASSERT(B); - m_pEditObject->RenameBone(B, edit_val.c_str()); + m_pEditObject->RenameBone(B, edit_val.c_str()); - m_Flags.set(flRefreshProps, TRUE); + m_Flags.set(flRefreshProps, TRUE); return true; } -void CActorTools::OnBoneEditClick(ButtonValue* V, bool& bModif, bool& bSafe) +void CActorTools::OnBoneEditClick(ButtonValue *V, bool &bModif, bool &bSafe) { - R_ASSERT(m_pEditObject); - switch (V->btn_num){ - case 0: - m_pEditObject->GotoBindPose(); - ExecCommand(COMMAND_UPDATE_PROPERTIES); - bModif = false; - break; - case 1: - if (ELog.DlgMsg(mtConfirmation,"Are you sure to reset IK data?")==mrYes) - m_pEditObject->ResetBones(); - bModif = true; - break; - case 2: - m_pEditObject->ClampByLimits(false); - ExecCommand(COMMAND_UPDATE_PROPERTIES); - bModif = false; - break; - } + R_ASSERT(m_pEditObject); + switch (V->btn_num) + { + case 0: + m_pEditObject->GotoBindPose(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + bModif = false; + break; + case 1: + if (ELog.DlgMsg(mtConfirmation, "Are you sure to reset IK data?")==mrYes) + m_pEditObject->ResetBones(); + bModif = true; + break; + case 2: + m_pEditObject->ClampByLimits(false); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + bModif = false; + break; + } } -void CActorTools::OnBoneFileClick(ButtonValue* V, bool& bModif, bool& bSafe) -{ - R_ASSERT(m_pEditObject); - switch (V->btn_num){ - case 0:{ - xr_string fn; - if (EFS.GetOpenName("$sbones$",fn)){ - IReader* R = FS.r_open(fn.c_str()); - if (m_pEditObject->LoadBoneData(*R)) ELog.DlgMsg(mtInformation,"Bone data succesfully loaded."); - else ELog.DlgMsg(mtError,"Failed to load bone data."); - FS.r_close(R); - }else{ - bModif = false; +void CActorTools::OnBoneFileClick(ButtonValue *V, bool &bModif, bool &bSafe) +{ + R_ASSERT(m_pEditObject); + switch (V->btn_num) + { + case 0: + { + xr_string fn; + if (EFS.GetOpenName("$sbones$", fn)) + { + IReader *R = FS.r_open(fn.c_str()); + if (m_pEditObject->LoadBoneData(*R)) + ELog.DlgMsg(mtInformation, "Bone data succesfully loaded."); + else + ELog.DlgMsg(mtError, "Failed to load bone data."); + FS.r_close(R); + } + else + { + bModif = false; + } } - }break; - case 1:{ - xr_string fn; - if (EFS.GetSaveName("$sbones$",fn)){ - IWriter* W = FS.w_open(fn.c_str()); - if (W){ - m_pEditObject->SaveBoneData(*W); - FS.w_close (W); - }else{ - Log ("!Can't save skeleton bones:",fn.c_str()); + break; + case 1: + { + xr_string fn; + if (EFS.GetSaveName("$sbones$", fn)) + { + IWriter *W = FS.w_open(fn.c_str()); + if (W) + { + m_pEditObject->SaveBoneData(*W); + FS.w_close(W); + } + else + { + Log("!Can't save skeleton bones:", fn.c_str()); + } + bModif = false; } - bModif = false; } - }break; - } + break; + } } -void CActorTools::OnBoneLimitsChange(PropValue* sender) +void CActorTools::OnBoneLimitsChange(PropValue *sender) { - m_pEditObject->ClampByLimits(true); + m_pEditObject->ClampByLimits(true); } -void CActorTools::FillBoneProperties(PropItemVec& items, LPCSTR pref, ListItem* sender) +void CActorTools::FillBoneProperties(PropItemVec &items, LPCSTR pref, ListItem *sender) { - R_ASSERT(m_pEditObject); - CBone* BONE = (CBone*)sender->m_Object; - - PHelper().CreateCaption (items, PrepareKey(pref,"Global\\Bone count"), shared_str().printf("%d",m_pEditObject->BoneCount())); - ButtonValue* B; - B=PHelper().CreateButton (items, PrepareKey(pref,"Global\\File"),"Load,Save",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CActorTools::OnBoneFileClick); - B=PHelper().CreateButton (items, PrepareKey(pref,"Global\\Edit"),"Bind pose,Reset IK,Clamp limits",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CActorTools::OnBoneEditClick); - B=PHelper().CreateButton (items, PrepareKey(pref,"Global\\Generate Shape"),"All, Selected",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CActorTools::OnBoneShapeClick); -//--- - B=PHelper().CreateButton (items, PrepareKey(pref,"Global\\Bone"),"Create, Delete, Orient",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&CActorTools::OnBoneCreateDeleteClick); -//--- - - if (BONE){ - PropValue* V; - PHelper().CreateCaption (items, PrepareKey(pref,"Bone\\Name"), BONE->Name()); - - PHelper().CreateNameCB (items, PrepareKey(pref,"Bone\\NameEditable"), &BONE->NameRef(), 0, 0, RTextValue::TOnAfterEditEvent(this,&CActorTools::OnBoneNameAfterEdit)); - -//. PHelper().CreateCaption (items, PrepareKey(pref,"Bone\\Influence"), shared_str().sprintf("%d vertices",0)); - PHelper().CreateChoose (items, PrepareKey(pref,"Bone\\Game Material"), &BONE->game_mtl, smGameMaterial); - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Mass"), &BONE->mass, 0.f, 10000.f); - PHelper().CreateVector (items, PrepareKey(pref,"Bone\\Center Of Mass"), &BONE->center_of_mass, -10000.f, 10000.f); - V=PHelper().CreateVector (items, PrepareKey(pref,"Bone\\Bind Position"), &BONE->_RestOffset(), -10000.f, 10000.f); V->OnChangeEvent.bind (this,&CActorTools::OnBindTransformChange); - V=PHelper().CreateAngle3 (items, PrepareKey(pref,"Bone\\Bind Rotation"), &BONE->_RestRotate()); V->OnChangeEvent.bind (this,&CActorTools::OnBindTransformChange); - PHelper().CreateFlag16 (items, PrepareKey(pref,"Bone\\Shape\\Flags\\No Pickable"), &BONE->shape.flags, SBoneShape::sfNoPickable); - PHelper().CreateFlag16 (items, PrepareKey(pref,"Bone\\Shape\\Flags\\No Physics"), &BONE->shape.flags, SBoneShape::sfNoPhysics); - PHelper().CreateFlag16 (items, PrepareKey(pref,"Bone\\Shape\\Flags\\Remove After Break"), &BONE->shape.flags,SBoneShape::sfRemoveAfterBreak); - PHelper().CreateFlag16 (items, PrepareKey(pref,"Bone\\Shape\\Flags\\No Fog Collider"), &BONE->shape.flags,SBoneShape::sfNoFogCollider); - - V=PHelper().CreateToken16 (items, PrepareKey(pref,"Bone\\Shape\\Type"), &BONE->shape.type, shape_types); V->OnChangeEvent.bind (this,&CActorTools::OnShapeTypeChange); - switch (BONE->shape.type){ - case SBoneShape::stBox: - PHelper().CreateVector (items, PrepareKey(pref,"Bone\\Shape\\Box\\Center"), &BONE->shape.box.m_translate, -10000.f, 10000.f); - B=PHelper().CreateButton(items, PrepareKey(pref,"Bone\\Shape\\Box\\Align Axis"), "X,Y,Z",0); - B->OnBtnClickEvent.bind (this,&CActorTools::OnBoxAxisClick); - B->tag = (int)BONE; - PHelper().CreateVector (items, PrepareKey(pref,"Bone\\Shape\\Box\\Half Size"), &BONE->shape.box.m_halfsize, 0.f, 1000.f); - break; - case SBoneShape::stSphere: - PHelper().CreateVector (items, PrepareKey(pref,"Bone\\Shape\\Sphere\\Position"), &BONE->shape.sphere.P, -10000.f, 10000.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Shape\\Sphere\\Radius"), &BONE->shape.sphere.R, 0.f, 1000.f); - break; - case SBoneShape::stCylinder: - PHelper().CreateVector (items, PrepareKey(pref,"Bone\\Shape\\Cylinder\\Center"), &BONE->shape.cylinder.m_center, -10000.f, 10000.f); - B=PHelper().CreateButton(items, PrepareKey(pref,"Bone\\Shape\\Cylinder\\Align Axis"),"X,Y,Z",0); - B->OnBtnClickEvent.bind (this,&CActorTools::OnCylinderAxisClick); - B->tag = (int)BONE; - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Shape\\Cylinder\\Height"), &BONE->shape.cylinder.m_height, 0.f, 1000.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Shape\\Cylinder\\Radius"), &BONE->shape.cylinder.m_radius, 0.f, 1000.f); - break; + R_ASSERT(m_pEditObject); + CBone *BONE = (CBone*)sender->m_Object; + + PHelper().CreateCaption(items, PrepareKey(pref, "Global\\Bone count"), shared_str().printf("%d", m_pEditObject->BoneCount())); + ButtonValue *B; + B = PHelper().CreateButton(items, PrepareKey(pref, "Global\\File"), "Load,Save", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CActorTools::OnBoneFileClick); + B = PHelper().CreateButton(items, PrepareKey(pref, "Global\\Edit"), "Bind pose,Reset IK,Clamp limits", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CActorTools::OnBoneEditClick); + B = PHelper().CreateButton(items, PrepareKey(pref, "Global\\Generate Shape"), "All, Selected", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CActorTools::OnBoneShapeClick); + //--- + B = PHelper().CreateButton(items, PrepareKey(pref, "Global\\Bone"), "Create, Delete, Orient", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &CActorTools::OnBoneCreateDeleteClick); + //--- + + if (BONE) + { + PropValue *V; + PHelper().CreateCaption(items, PrepareKey(pref, "Bone\\Name"), BONE->Name()); + + PHelper().CreateNameCB(items, PrepareKey(pref, "Bone\\NameEditable"), &BONE->NameRef(), 0, 0, RTextValue::TOnAfterEditEvent(this, &CActorTools::OnBoneNameAfterEdit)); + + //. PHelper().CreateCaption (items, PrepareKey(pref,"Bone\\Influence"), shared_str().sprintf("%d vertices",0)); + PHelper().CreateChoose(items, PrepareKey(pref, "Bone\\Game Material"), &BONE->game_mtl, smGameMaterial); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Mass"), &BONE->mass, 0.f, 10000.f); + PHelper().CreateVector(items, PrepareKey(pref, "Bone\\Center Of Mass"), &BONE->center_of_mass, -10000.f, 10000.f); + V = PHelper().CreateVector(items, PrepareKey(pref, "Bone\\Bind Position"), &BONE->_RestOffset(), -10000.f, 10000.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBindTransformChange); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Bone\\Bind Rotation"), &BONE->_RestRotate()); + V->OnChangeEvent.bind(this, &CActorTools::OnBindTransformChange); + PHelper().CreateFlag16(items, PrepareKey(pref, "Bone\\Shape\\Flags\\No Pickable"), &BONE->shape.flags, SBoneShape::sfNoPickable); + PHelper().CreateFlag16(items, PrepareKey(pref, "Bone\\Shape\\Flags\\No Physics"), &BONE->shape.flags, SBoneShape::sfNoPhysics); + PHelper().CreateFlag16(items, PrepareKey(pref, "Bone\\Shape\\Flags\\Remove After Break"), &BONE->shape.flags, SBoneShape::sfRemoveAfterBreak); + PHelper().CreateFlag16(items, PrepareKey(pref, "Bone\\Shape\\Flags\\No Fog Collider"), &BONE->shape.flags, SBoneShape::sfNoFogCollider); + + V = PHelper().CreateToken16(items, PrepareKey(pref, "Bone\\Shape\\Type"), &BONE->shape.type, shape_types); + V->OnChangeEvent.bind(this, &CActorTools::OnShapeTypeChange); + switch (BONE->shape.type) + { + case SBoneShape::stBox: + PHelper().CreateVector(items, PrepareKey(pref, "Bone\\Shape\\Box\\Center"), &BONE->shape.box.m_translate, -10000.f, 10000.f); + B = PHelper().CreateButton(items, PrepareKey(pref, "Bone\\Shape\\Box\\Align Axis"), "X,Y,Z", 0); + B->OnBtnClickEvent.bind(this, &CActorTools::OnBoxAxisClick); + B->tag = (int)BONE; + PHelper().CreateVector(items, PrepareKey(pref, "Bone\\Shape\\Box\\Half Size"), &BONE->shape.box.m_halfsize, 0.f, 1000.f); + break; + case SBoneShape::stSphere: + PHelper().CreateVector(items, PrepareKey(pref, "Bone\\Shape\\Sphere\\Position"), &BONE->shape.sphere.P, -10000.f, 10000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Shape\\Sphere\\Radius"), &BONE->shape.sphere.R, 0.f, 1000.f); + break; + case SBoneShape::stCylinder: + PHelper().CreateVector(items, PrepareKey(pref, "Bone\\Shape\\Cylinder\\Center"), &BONE->shape.cylinder.m_center, -10000.f, 10000.f); + B = PHelper().CreateButton(items, PrepareKey(pref, "Bone\\Shape\\Cylinder\\Align Axis"), "X,Y,Z", 0); + B->OnBtnClickEvent.bind(this, &CActorTools::OnCylinderAxisClick); + B->tag = (int)BONE; + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Shape\\Cylinder\\Height"), &BONE->shape.cylinder.m_height, 0.f, 1000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Shape\\Cylinder\\Radius"), &BONE->shape.cylinder.m_radius, 0.f, 1000.f); + break; } Fvector lim_rot; - Fmatrix mLocal,mBind,mBindI; - mBind.setXYZi (BONE->_RestRotate().x,BONE->_RestRotate().y,BONE->_RestRotate().z); - mBindI.invert (mBind); - mLocal.setXYZi (BONE->_Rotate().x,BONE->_Rotate().y,BONE->_Rotate().z); - mLocal.mulA_43 (mBindI); - mLocal.getXYZi (lim_rot); - lim_rot.x = rad2deg(lim_rot.x); - lim_rot.y = rad2deg(lim_rot.y); - lim_rot.z = rad2deg(lim_rot.z); - - PHelper().CreateCaption (items, PrepareKey(pref,"Bone\\Joint\\Current Rotation"), shared_str().printf("{%3.2f, %3.2f, %3.2f}",VPUSH(lim_rot))); - SJointIKData& data = BONE->IK_data; - V=PHelper().CreateFlag32 (items, PrepareKey(pref,"Bone\\Joint\\Breakable"), &data.ik_flags, SJointIKData::flBreakable); - V->OnChangeEvent.bind (this,&CActorTools::OnJointTypeChange); - if (data.ik_flags.is(SJointIKData::flBreakable)){ - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Break Force"), &data.break_force, 0.f, 1000000000.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Break Torque"), &data.break_torque, 0.f, 1000000000.f); - } - V=PHelper().CreateToken32 (items, PrepareKey(pref,"Bone\\Joint\\Type"), (u32*)&data.type, joint_types); V->OnChangeEvent.bind (this,&CActorTools::OnJointTypeChange); - switch (data.type){ - case jtRigid: - break; - case jtCloth:{ - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Friction"), &data.friction, 0.f, 1000000000.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Spring Factor"), &data.spring_factor, 0.f, 1000.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Damping Factor"), &data.damping_factor, 0.f, 1000.f); - }break; - case jtJoint:{ - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Friction"), &data.friction, 0.f, 1000000000.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Spring Factor"), &data.spring_factor, 0.f, 1000.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Damping Factor"), &data.damping_factor, 0.f, 1000.f); - for (int k=0; k<3; k++){ - V=PHelper().CreateAngle (items,PrepareKey(pref,"Bone\\Joint\\Limits",axis[k],"Min"), &data.limits[k].limit.x, -M_PI, 0.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - V=PHelper().CreateAngle (items,PrepareKey(pref,"Bone\\Joint\\Limits",axis[k],"Max"), &data.limits[k].limit.y, 0.f, M_PI); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Limits",axis[k],"Spring Factor"), &data.limits[k].spring_factor, 0.f, 1000.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Limits",axis[k],"Damping Factor"), &data.limits[k].damping_factor, 0.f, 1000.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - } - }break; - case jtWheel: + Fmatrix mLocal, mBind, mBindI; + mBind.setXYZi(BONE->_RestRotate().x, BONE->_RestRotate().y, BONE->_RestRotate().z); + mBindI.invert(mBind); + mLocal.setXYZi(BONE->_Rotate().x, BONE->_Rotate().y, BONE->_Rotate().z); + mLocal.mulA_43(mBindI); + mLocal.getXYZi(lim_rot); + lim_rot.x = rad2deg(lim_rot.x); + lim_rot.y = rad2deg(lim_rot.y); + lim_rot.z = rad2deg(lim_rot.z); + + PHelper().CreateCaption(items, PrepareKey(pref, "Bone\\Joint\\Current Rotation"), shared_str().printf("{%3.2f, %3.2f, %3.2f}",VPUSH(lim_rot))); + SJointIKData &data = BONE->IK_data; + V = PHelper().CreateFlag32(items, PrepareKey(pref, "Bone\\Joint\\Breakable"), &data.ik_flags, SJointIKData::flBreakable); + V->OnChangeEvent.bind(this, &CActorTools::OnJointTypeChange); + if (data.ik_flags.is(SJointIKData::flBreakable)) { -// int idx = (data.type-jtWheelXZ)/2; - int idx = (data.type-jtWheel)/2; - PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Friction"), &data.friction, 0.f, 1000000000.f); - PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Spring Factor"), &data.spring_factor, 0.f, 1000.f); - PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Damping Factor"), &data.damping_factor, 0.f, 1000.f); - V=PHelper().CreateAngle (items,PrepareKey(pref,"Bone\\Joint\\Steer\\Limits Min"), &data.limits[idx].limit.x, -PI_DIV_2, 0.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - V=PHelper().CreateAngle (items,PrepareKey(pref,"Bone\\Joint\\Steer\\Limits Max"), &data.limits[idx].limit.y, 0, PI_DIV_2); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - }break; - case jtSlider: + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Break Force"), &data.break_force, 0.f, 1000000000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Break Torque"), &data.break_torque, 0.f, 1000000000.f); + } + V = PHelper().CreateToken32(items, PrepareKey(pref, "Bone\\Joint\\Type"), (u32*)&data.type, joint_types); + V->OnChangeEvent.bind(this, &CActorTools::OnJointTypeChange); + switch (data.type) { - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Friction"), &data.friction, 0.f, 1000000000.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Spring Factor"), &data.spring_factor, 0.f, 1000.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Bone\\Joint\\Damping Factor"), &data.damping_factor, 0.f, 1000.f); - { // slider - V=PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Slide (Axis Z)\\Limits Min"), &data.limits[0].limit[0], -100.f,0.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Slide (Axis Z)\\Limits Max"), &data.limits[0].limit[1], 0.f, 100.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Slide (Axis Z)\\Spring Factor"),&data.limits[0].spring_factor, 0.f, 1000.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Slide (Axis Z)\\Damping Factor"),&data.limits[0].damping_factor,0.f, 1000.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - } - { // rotate - V=PHelper().CreateAngle (items,PrepareKey(pref,"Bone\\Joint\\Rotate (Axis Z)\\Limits Min"), &data.limits[1].limit[0], -M_PI, 0.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - V=PHelper().CreateAngle (items,PrepareKey(pref,"Bone\\Joint\\Rotate (Axis Z)\\Limits Max"), &data.limits[1].limit[1], 0.f, M_PI); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Rotate (Axis Z)\\Spring Factor"), &data.limits[1].spring_factor, 0.f, 1000.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Bone\\Joint\\Rotate (Axis Z)\\Damping Factor"), &data.limits[1].damping_factor, 0.f, 1000.f); - V->OnChangeEvent.bind (this,&CActorTools::OnBoneLimitsChange); - } - }break; + case jtRigid: + break; + case jtCloth: + { + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Friction"), &data.friction, 0.f, 1000000000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Spring Factor"), &data.spring_factor, 0.f, 1000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Damping Factor"), &data.damping_factor, 0.f, 1000.f); + } + break; + case jtJoint: + { + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Friction"), &data.friction, 0.f, 1000000000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Spring Factor"), &data.spring_factor, 0.f, 1000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Damping Factor"), &data.damping_factor, 0.f, 1000.f); + for (int k = 0; k<3; k++) + { + V = PHelper().CreateAngle(items, PrepareKey(pref, "Bone\\Joint\\Limits", axis[k], "Min"), &data.limits[k].limit.x, -M_PI, 0.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + V = PHelper().CreateAngle(items, PrepareKey(pref, "Bone\\Joint\\Limits", axis[k], "Max"), &data.limits[k].limit.y, 0.f, M_PI); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Limits", axis[k], "Spring Factor"), &data.limits[k].spring_factor, 0.f, 1000.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Limits", axis[k], "Damping Factor"), &data.limits[k].damping_factor, 0.f, 1000.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + } + } + break; + case jtWheel: + { + // int idx = (data.type-jtWheelXZ)/2; + int idx = (data.type-jtWheel)/2; + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Friction"), &data.friction, 0.f, 1000000000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Spring Factor"), &data.spring_factor, 0.f, 1000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Damping Factor"), &data.damping_factor, 0.f, 1000.f); + V = PHelper().CreateAngle(items, PrepareKey(pref, "Bone\\Joint\\Steer\\Limits Min"), &data.limits[idx].limit.x, -PI_DIV_2, 0.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + V = PHelper().CreateAngle(items, PrepareKey(pref, "Bone\\Joint\\Steer\\Limits Max"), &data.limits[idx].limit.y, 0, PI_DIV_2); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + } + break; + case jtSlider: + { + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Friction"), &data.friction, 0.f, 1000000000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Spring Factor"), &data.spring_factor, 0.f, 1000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Damping Factor"), &data.damping_factor, 0.f, 1000.f); + { // slider + V = PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Slide (Axis Z)\\Limits Min"), &data.limits[0].limit[0], -100.f, 0.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Slide (Axis Z)\\Limits Max"), &data.limits[0].limit[1], 0.f, 100.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Slide (Axis Z)\\Spring Factor"), &data.limits[0].spring_factor, 0.f, 1000.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Slide (Axis Z)\\Damping Factor"), &data.limits[0].damping_factor, 0.f, 1000.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + } + { // rotate + V = PHelper().CreateAngle(items, PrepareKey(pref, "Bone\\Joint\\Rotate (Axis Z)\\Limits Min"), &data.limits[1].limit[0], -M_PI, 0.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + V = PHelper().CreateAngle(items, PrepareKey(pref, "Bone\\Joint\\Rotate (Axis Z)\\Limits Max"), &data.limits[1].limit[1], 0.f, M_PI); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Rotate (Axis Z)\\Spring Factor"), &data.limits[1].spring_factor, 0.f, 1000.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Bone\\Joint\\Rotate (Axis Z)\\Damping Factor"), &data.limits[1].damping_factor, 0.f, 1000.f); + V->OnChangeEvent.bind(this, &CActorTools::OnBoneLimitsChange); + } + } + break; } } } + //------------------------------------------------------------------------------ -void CActorTools::FillSurfaceProperties(PropItemVec& items, LPCSTR pref, ListItem* sender) +void CActorTools::FillSurfaceProperties(PropItemVec &items, LPCSTR pref, ListItem *sender) { - R_ASSERT(m_pEditObject); - CSurface* SURF = (CSurface*)sender->m_Object; - PHelper().CreateCaption (items, PrepareKey(pref,"Statistic\\Count"), shared_str().printf("%d",m_pEditObject->SurfaceCount())); - if (SURF){ - PHelper().CreateCaption (items,PrepareKey(pref,"Surface\\Name"), SURF->_Name()); - AnsiString _pref = PrepareKey(pref,"Surface").c_str(); - m_pEditObject->FillSurfaceProps(SURF,_pref.c_str(),items); + R_ASSERT(m_pEditObject); + CSurface *SURF = (CSurface*)sender->m_Object; + PHelper().CreateCaption(items, PrepareKey(pref, "Statistic\\Count"), shared_str().printf("%d", m_pEditObject->SurfaceCount())); + if (SURF) + { + PHelper().CreateCaption(items, PrepareKey(pref, "Surface\\Name"), SURF->_Name()); + AnsiString _pref = PrepareKey(pref, "Surface").c_str(); + m_pEditObject->FillSurfaceProps(SURF, _pref.c_str(), items); } } + //------------------------------------------------------------------------------ -void CActorTools::FillObjectProperties(PropItemVec& items, LPCSTR pref, ListItem* sender) +void CActorTools::FillObjectProperties(PropItemVec &items, LPCSTR pref, ListItem *sender) { - R_ASSERT(m_pEditObject); - PropValue* V=0; - PHelper().CreateFlag32 (items, "Object\\Flags\\Make Progressive", &m_pEditObject->m_objectFlags, CEditableObject::eoProgressive); - PHelper().CreateFlag32 (items, "Object\\Flags\\HQ Geometry", &m_pEditObject->m_objectFlags, CEditableObject::eoHQExport); - - V=PHelper().CreateVector (items, "Object\\Transform\\Position", &m_pEditObject->a_vPosition, -10000, 10000,0.01,2); - V->OnChangeEvent.bind (this,&CActorTools::OnChangeTransform); - V=PHelper().CreateAngle3 (items, "Object\\Transform\\Rotation", &m_pEditObject->a_vRotate, -10000, 10000,0.1,1); - V->OnChangeEvent.bind (this,&CActorTools::OnChangeTransform); - V=PHelper().CreateCaption (items, "Object\\Transform\\BBox Min", shared_str().printf("{%3.2f, %3.2f, %3.2f}",VPUSH(m_pEditObject->GetBox().min))); - V=PHelper().CreateCaption (items, "Object\\Transform\\BBox Max", shared_str().printf("{%3.2f, %3.2f, %3.2f}",VPUSH(m_pEditObject->GetBox().max))); - -//. PHelper().CreateChoose (items, "Object\\LOD\\Reference", &m_pEditObject->m_LODs, smObject); - PHelper().CreateChoose (items, "Object\\LOD\\Reference", &m_pEditObject->m_LODs, smVisual); - m_pEditObject->FillSummaryProps ("Object\\Summary",items); + R_ASSERT(m_pEditObject); + PropValue *V = 0; + PHelper().CreateFlag32(items, "Object\\Flags\\Make Progressive", &m_pEditObject->m_objectFlags, CEditableObject::eoProgressive); + PHelper().CreateFlag32(items, "Object\\Flags\\HQ Geometry", &m_pEditObject->m_objectFlags, CEditableObject::eoHQExport); + + V = PHelper().CreateVector(items, "Object\\Transform\\Position", &m_pEditObject->a_vPosition, -10000, 10000, 0.01, 2); + V->OnChangeEvent.bind(this, &CActorTools::OnChangeTransform); + V = PHelper().CreateAngle3(items, "Object\\Transform\\Rotation", &m_pEditObject->a_vRotate, -10000, 10000, 0.1, 1); + V->OnChangeEvent.bind(this, &CActorTools::OnChangeTransform); + V = PHelper().CreateCaption(items, "Object\\Transform\\BBox Min", shared_str().printf("{%3.2f, %3.2f, %3.2f}",VPUSH(m_pEditObject->GetBox().min))); + V = PHelper().CreateCaption(items, "Object\\Transform\\BBox Max", shared_str().printf("{%3.2f, %3.2f, %3.2f}",VPUSH(m_pEditObject->GetBox().max))); + + //. PHelper().CreateChoose (items, "Object\\LOD\\Reference", &m_pEditObject->m_LODs, smObject); + PHelper().CreateChoose(items, "Object\\LOD\\Reference", &m_pEditObject->m_LODs, smVisual); + m_pEditObject->FillSummaryProps("Object\\Summary", items); } + //------------------------------------------------------------------------------ void CActorTools::SelectListItem(LPCSTR pref, LPCSTR name, bool bVal, bool bLeaveSel, bool bExpand) { - AnsiString nm = (name&&name[0])?PrepareKey(pref,name).c_str():AnsiString(pref).c_str(); - m_ObjectItems->SelectItem(nm.c_str(),bVal,bLeaveSel,bExpand); - if (pref){ - m_ObjectItems->SelectItem(pref,true,true,bExpand); + AnsiString nm = (name&&name[0]) ? PrepareKey(pref, name).c_str() : AnsiString(pref).c_str(); + m_ObjectItems->SelectItem(nm.c_str(), bVal, bLeaveSel, bExpand); + if (pref) + { + m_ObjectItems->SelectItem(pref, true, true, bExpand); } } + //------------------------------------------------------------------------------ + diff --git a/src/editors/ActorEditor/UI_ActorToolsUndo.cpp b/src/editors/ActorEditor/UI_ActorToolsUndo.cpp index d352ccdd5d5..9ffd9aa3ad9 100644 --- a/src/editors/ActorEditor/UI_ActorToolsUndo.cpp +++ b/src/editors/ActorEditor/UI_ActorToolsUndo.cpp @@ -1,85 +1,99 @@ -#include "stdafx.h" -#pragma hdrstop - -#include "UI_ActorTools.h" -#include "../ECore/Editor/ui_main.h" -#include "../ECore/Editor/EditorPreferences.h" - +#include "stdafx.h" +#pragma hdrstop + +#include "UI_ActorTools.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/EditorPreferences.h" + void CActorTools::UndoClear() -{ - while( !m_RedoStack.empty() ){ - unlink( m_RedoStack.back().m_FileName ); - m_RedoStack.pop_back(); } - while( !m_UndoStack.empty() ){ - unlink( m_UndoStack.back().m_FileName ); - m_UndoStack.pop_back(); } +{ + while (!m_RedoStack.empty()) + { + unlink(m_RedoStack.back().m_FileName); + m_RedoStack.pop_back(); + } + while (!m_UndoStack.empty()) + { + unlink(m_UndoStack.back().m_FileName); + m_UndoStack.pop_back(); + } } void CActorTools::UndoSave() { UI->RedrawScene(); - if (0==EPrefs->scene_undo_level) return; - - UndoItem item; - GetTempFileName( FS.get_path(_temp_)->m_Path, "undo", 0, item.m_FileName ); - - Save( item.m_FileName, true ); - m_UndoStack.push_back( item ); - - while( !m_RedoStack.empty() ){ - unlink( m_RedoStack.back().m_FileName ); - m_RedoStack.pop_back(); } - - if( m_UndoStack.size() > EPrefs->scene_undo_level){ - unlink( m_UndoStack.front().m_FileName ); - m_UndoStack.pop_front(); } + if (0==EPrefs->scene_undo_level) + return; + + UndoItem item; + GetTempFileName(FS.get_path(_temp_)->m_Path, "undo", 0, item.m_FileName); + + Save(item.m_FileName, true); + m_UndoStack.push_back(item); + + while (!m_RedoStack.empty()) + { + unlink(m_RedoStack.back().m_FileName); + m_RedoStack.pop_back(); + } + + if (m_UndoStack.size()>EPrefs->scene_undo_level) + { + unlink(m_UndoStack.front().m_FileName); + m_UndoStack.pop_front(); + } } bool CActorTools::Undo() { -// if( !m_UndoStack.empty() ){ - if( m_UndoStack.size()>1 ){ - m_RedoStack.push_back( m_UndoStack.back() ); - m_UndoStack.pop_back(); - - if( m_RedoStack.size() > EPrefs->scene_undo_level){ - unlink( m_RedoStack.front().m_FileName ); - m_RedoStack.pop_front(); + // if( !m_UndoStack.empty() ){ + if (m_UndoStack.size()>1) + { + m_RedoStack.push_back(m_UndoStack.back()); + m_UndoStack.pop_back(); + + if (m_RedoStack.size()>EPrefs->scene_undo_level) + { + unlink(m_RedoStack.front().m_FileName); + m_RedoStack.pop_front(); } - if( !m_UndoStack.empty() ){ - Clear(); - Load( m_UndoStack.back().m_FileName ); + if (!m_UndoStack.empty()) + { + Clear(); + Load(m_UndoStack.back().m_FileName); } Modified(); - - return true; - } - return false; + + return true; + } + return false; } bool CActorTools::Redo() { - if( !m_RedoStack.empty() ){ + if (!m_RedoStack.empty()) + { Clear(); - Load( m_RedoStack.back().m_FileName ); + Load(m_RedoStack.back().m_FileName); - m_UndoStack.push_back( m_RedoStack.back() ); - m_RedoStack.pop_back(); + m_UndoStack.push_back(m_RedoStack.back()); + m_RedoStack.pop_back(); - if( m_UndoStack.size() > EPrefs->scene_undo_level ){ - unlink( m_UndoStack.front().m_FileName ); - m_UndoStack.pop_front(); + if (m_UndoStack.size()>EPrefs->scene_undo_level) + { + unlink(m_UndoStack.front().m_FileName); + m_UndoStack.pop_front(); } Modified(); - return true; - } - return false; + return true; + } + return false; } //---------------------------------------------------- - \ No newline at end of file + diff --git a/src/editors/ActorEditor/main.cpp b/src/editors/ActorEditor/main.cpp index 16c2b28ac63..afdf7ba44f4 100644 --- a/src/editors/ActorEditor/main.cpp +++ b/src/editors/ActorEditor/main.cpp @@ -35,67 +35,76 @@ TfrmMain *frmMain; #include "../xrEProps/EditorChooseEvents.h" -__fastcall TfrmMain::TfrmMain(TComponent* Owner) - : TForm(Owner) +__fastcall TfrmMain::TfrmMain(TComponent *Owner) + : TForm(Owner) { -// forms - fraBottomBar = xr_new ((TComponent*)0); - fraTopBar = xr_new ((TComponent*)0); - fraLeftBar = xr_new ((TComponent*)0); -//- - - fraBottomBar->Parent = paBottomBar; - fraTopBar->Parent = paTopBar; - fraLeftBar->Parent = paLeftBar; - if (paLeftBar->Tag > 0) paLeftBar->Parent = paTopBar; - else paLeftBar->Parent = frmMain; - - EDevice.SetHandle (Handle,D3DWindow->Handle); - EnableReceiveCommands (); - if (!ExecCommand(COMMAND_INITIALIZE,(u32)D3DWindow,(u32)paRender)){ - FlushLog (); - TerminateProcess(GetCurrentProcess(),-1); + // forms + fraBottomBar = xr_new((TComponent*)0); + fraTopBar = xr_new((TComponent*)0); + fraLeftBar = xr_new((TComponent*)0); + //- + + fraBottomBar->Parent = paBottomBar; + fraTopBar->Parent = paTopBar; + fraLeftBar->Parent = paLeftBar; + if (paLeftBar->Tag>0) + paLeftBar->Parent = paTopBar; + else + paLeftBar->Parent = frmMain; + + EDevice.SetHandle(Handle, D3DWindow->Handle); + EnableReceiveCommands(); + if (!ExecCommand(COMMAND_INITIALIZE, (u32)D3DWindow, (u32)paRender)) + { + FlushLog(); + TerminateProcess(GetCurrentProcess(), -1); } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormShow(TObject *Sender) { - tmRefresh->Enabled = true; tmRefreshTimer(Sender); - ExecCommand (COMMAND_UPDATE_GRID); - ExecCommand (COMMAND_RENDER_FOCUS); - FillChooseEvents (); + tmRefresh->Enabled = true; + tmRefreshTimer(Sender); + ExecCommand(COMMAND_UPDATE_GRID); + ExecCommand(COMMAND_RENDER_FOCUS); + FillChooseEvents(); // special case :( - frmMain->WindowState = (TWindowState)fsStorage->ReadInteger("window_state",frmMain->WindowState); + frmMain->WindowState = (TWindowState)fsStorage->ReadInteger("window_state", frmMain->WindowState); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormClose(TObject *Sender, TCloseAction &Action) { - Application->OnIdle = 0; + Application->OnIdle = 0; - ClearChooseEvents (); + ClearChooseEvents(); - ExecCommand (COMMAND_DESTROY); + ExecCommand(COMMAND_DESTROY); - fraTopBar->Parent = 0; - fraLeftBar->Parent = 0; - fraBottomBar->Parent = 0; + fraTopBar->Parent = 0; + fraLeftBar->Parent = 0; + fraBottomBar->Parent = 0; xr_delete(fraTopBar); xr_delete(fraBottomBar); - xr_delete(fraLeftBar); + xr_delete(fraLeftBar); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormCloseQuery(TObject *Sender, bool &CanClose) { tmRefresh->Enabled = false; CanClose = ExecCommand(COMMAND_EXIT); - if (!CanClose) tmRefresh->Enabled = true; + if (!CanClose) + tmRefresh->Enabled = true; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormCreate(TObject *Sender) { - DEFINE_INI(fsStorage); + DEFINE_INI(fsStorage); Application->OnIdle = IdleHandler; } @@ -103,27 +112,34 @@ void __fastcall TfrmMain::FormCreate(TObject *Sender) #define MIN_PANEL_HEIGHT 17 + void __fastcall TfrmMain::sbToolsMinClick(TObject *Sender) { - if (paLeftBar->Tag > 0){ + if (paLeftBar->Tag>0) + { paLeftBar->Parent = frmMain; - paLeftBar->Tag = 0; - }else{ + paLeftBar->Tag = 0; + } + else + { paLeftBar->Parent = paTopBar; - paLeftBar->Tag = 1; + paLeftBar->Tag = 1; } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::TopClick(TObject *Sender) { - if (paLeftBar->Tag > 0){ - paLeftBar->Align = alRight; + if (paLeftBar->Tag>0) + { + paLeftBar->Align = alRight; paLeftBar->Parent = frmMain; paLeftBar->Height = paLeftBar->Tag; - paLeftBar->Tag = 0; + paLeftBar->Tag = 0; } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::IdleHandler(TObject *Sender, bool &Done) @@ -131,132 +147,169 @@ void __fastcall TfrmMain::IdleHandler(TObject *Sender, bool &Done) Done = false; UI->Idle(); } + void __fastcall TfrmMain::D3DWindowResize(TObject *Sender) { UI->Resize(); -} +} + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { ShiftKey = Shift; - if (!UI->KeyDown(Key, Shift)){UI->ApplyShortCut(Key, Shift);} + if (!UI->KeyDown(Key, Shift)) + { + UI->ApplyShortCut(Key, Shift); + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyUp(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if (!UI->KeyUp(Key, Shift)){;} + if (!UI->KeyUp(Key, Shift)) + { + ; + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyPress(TObject *Sender, char &Key) { - if (!UI->KeyPress(Key, ShiftKey)){;} + if (!UI->KeyPress(Key, ShiftKey)) + { + ; + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { - if (!D3DWindow->Focused()) UI->ApplyGlobalShortCut(Key, Shift); - if (Key==VK_MENU) Key=0; + if (!D3DWindow->Focused()) + UI->ApplyGlobalShortCut(Key, Shift); + if (Key==VK_MENU) + Key = 0; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::UpdateCaption() { AnsiString name; - name.sprintf("%s - [%s%s]",UI->EditorDesc(),UI->GetCaption(),UI->IsModified()?"*":""); + name.sprintf("%s - [%s%s]", UI->EditorDesc(), UI->GetCaption(), UI->IsModified() ? "*" : ""); Caption = name; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::tmRefreshTimer(TObject *Sender) { int i; - for (i=0; iComponentCount; i++){ - TComponent* temp = frmMain->Components[i]; - if (dynamic_cast(temp) != NULL) + for (i = 0; iComponentCount; i++) + { + TComponent *temp = frmMain->Components[i]; + if (dynamic_cast(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } - fraLeftBar->OnTimer(); - fraTopBar->OnTimer(); + fraLeftBar->OnTimer(); + fraTopBar->OnTimer(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowPaint(TObject *Sender) { - if (!UI||!UI->m_bReady) return; + if (!UI||!UI->m_bReady) + return; UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowChangeFocus(TObject *Sender) { - if (!UI||!UI->m_bReady) return; - if (D3DWindow->Focused()){ + if (!UI||!UI->m_bReady) + return; + if (D3DWindow->Focused()) + { UI->IR_Capture(); - UI->OnAppActivate(); - }else{ - UI->OnAppDeactivate(); + UI->OnAppActivate(); + } + else + { + UI->OnAppDeactivate(); UI->IR_Release(); -// paRender->Color=paRender->Color; // ÷òîáû íå áûëî internal code gen error + // paRender->Color=paRender->Color; // ÷òîáû íå áûëî internal code gen error } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - UI->MousePress(Shift,X,Y); + UI->MousePress(Shift, X, Y); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseUp(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - UI->MouseRelease(Shift,X,Y); + UI->MouseRelease(Shift, X, Y); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseMove(TObject *Sender, - TShiftState Shift, int X, int Y) + TShiftState Shift, int X, int Y) { - UI->MouseMove(Shift,X,Y); + UI->MouseMove(Shift, X, Y); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::ebAllMinClick(TObject *Sender) { - fraLeftBar->MinimizeAllFrames(); + fraLeftBar->MinimizeAllFrames(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::ebAllMaxClick(TObject *Sender) { - fraLeftBar->MaximizeAllFrames(); + fraLeftBar->MaximizeAllFrames(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormResize(TObject *Sender) { - if (fraLeftBar) fraLeftBar->UpdateBar(); + if (fraLeftBar) + fraLeftBar->UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::paRenderResize(TObject *Sender) { - ExecCommand(COMMAND_RENDER_RESIZE); + ExecCommand(COMMAND_RENDER_RESIZE); } + //--------------------------------------------------------------------------- - + void __fastcall TfrmMain::fsStorageSavePlacement(TObject *Sender) { - fsStorage->WriteInteger("window_state",frmMain->WindowState); + fsStorage->WriteInteger("window_state", frmMain->WindowState); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ActorEditor/main.h b/src/editors/ActorEditor/main.h index a76161a44f4..7544df7c6ed 100644 --- a/src/editors/ActorEditor/main.h +++ b/src/editors/ActorEditor/main.h @@ -5,7 +5,7 @@ //--------------------------------------------------------------------------- #include #include -#include +#include #include #include #include @@ -16,31 +16,32 @@ #include "mxPlacemnt.hpp" #include "RenderWindow.hpp" #include + //--------------------------------------------------------------------------- // refs class ECORE_API TfrmMain : public TForm { -__published: // IDE-managed Components - TPanel *paLeftBar; - TPanel *paBottomBar; + __published: // IDE-managed Components + TPanel*paLeftBar; + TPanel *paBottomBar; TPanel *paTools; TTimer *tmRefresh; - TFormStorage *fsStorage; + TFormStorage *fsStorage; TPanel *paMain; TPanel *paTopBar; - TPanel *paRender; - TLabel *APHeadLabel2; - TExtBtn *sbToolsMin; - TD3DWindow *D3DWindow; - TExtBtn *ebAllMin; - TExtBtn *ebAllMax; - void __fastcall FormCreate(TObject *Sender); + TPanel *paRender; + TLabel *APHeadLabel2; + TExtBtn *sbToolsMin; + TD3DWindow *D3DWindow; + TExtBtn *ebAllMin; + TExtBtn *ebAllMax; + void __fastcall FormCreate(TObject *Sender); void __fastcall D3DWindowResize(TObject *Sender); void __fastcall D3DWindowKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall D3DWindowKeyUp(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall sbToolsMinClick(TObject *Sender); void __fastcall TopClick(TObject *Sender); void __fastcall FormShow(TObject *Sender); @@ -49,32 +50,42 @@ class ECORE_API TfrmMain : public TForm void __fastcall D3DWindowKeyPress(TObject *Sender, char &Key); void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); - void __fastcall D3DWindowChangeFocus(TObject *Sender); - void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall D3DWindowMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall D3DWindowMouseUp(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall D3DWindowMouseMove(TObject *Sender, TShiftState Shift, - int X, int Y); - void __fastcall ebAllMinClick(TObject *Sender); - void __fastcall ebAllMaxClick(TObject *Sender); - void __fastcall FormResize(TObject *Sender); - void __fastcall paRenderResize(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); -private: // User declarations + void __fastcall D3DWindowChangeFocus(TObject *Sender); + void __fastcall FormKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall D3DWindowMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall D3DWindowMouseUp(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall D3DWindowMouseMove(TObject *Sender, TShiftState Shift, + int X, int Y); + void __fastcall ebAllMinClick(TObject *Sender); + void __fastcall ebAllMaxClick(TObject *Sender); + void __fastcall FormResize(TObject *Sender); + void __fastcall paRenderResize(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); +private: // User declarations void __fastcall IdleHandler(TObject *Sender, bool &Done); - TShiftState ShiftKey; - HINSTANCE m_HInstance; -public: // User declarations - __fastcall TfrmMain(TComponent* Owner); + TShiftState ShiftKey; + HINSTANCE m_HInstance; +public: // User declarations + __fastcall TfrmMain(TComponent *Owner); void __fastcall UpdateCaption(); - __inline void SetHInst(HINSTANCE inst){ m_HInstance=inst; } - bool IsFocused(){return D3DWindow->Focused();} + + __inline void SetHInst(HINSTANCE inst) + { + m_HInstance = inst; + } + + bool IsFocused() + { + return D3DWindow->Focused(); + } }; + //--------------------------------------------------------------------------- -extern /*ECORE_API */PACKAGE TfrmMain *frmMain; +extern /*ECORE_API */PACKAGE TfrmMain * frmMain; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ActorEditor/stdafx.h b/src/editors/ActorEditor/stdafx.h index 128cd5b8bd9..002dddfbf13 100644 --- a/src/editors/ActorEditor/stdafx.h +++ b/src/editors/ActorEditor/stdafx.h @@ -18,9 +18,9 @@ #define DIRECTINPUT_VERSION 0x0800 -#define R_R1 1 -#define R_R2 2 -#define RENDER R_R1 +#define R_R1 1 +#define R_R2 2 +#define RENDER R_R1 // Std C++ headers #include @@ -35,35 +35,54 @@ #ifdef _eof #undef _eof #endif -__inline int _eof (int _a) { return ::eof(_a); } +__inline int _eof(int _a) +{ + return ::eof(_a); +} #ifdef _access #undef _access #endif -__inline int _access(const char *_a, int _b) { return ::access(_a,_b); } +__inline int _access(const char *_a, int _b) +{ + return ::access(_a, _b); +} #ifdef _lseek #undef _lseek #endif -__inline long _lseek(int handle, long offset, int fromwhere){ return ::lseek(handle, offset, fromwhere);} +__inline long _lseek(int handle, long offset, int fromwhere) +{ + return ::lseek(handle, offset, fromwhere); +} #ifdef _dup #undef _dup #endif #define fmodf fmod -__inline int _dup (int handle) { return ::dup(handle);} -__inline float modff(float a, float *b){ - double x,y; - y = modf(double(a),&x); + +__inline int _dup(int handle) +{ + return ::dup(handle); +} + +__inline float modff(float a, float *b) +{ + double x, y; + y = modf(double(a), &x); *b = x; return float(y); } -__inline float expf (float val) { return ::exp(val);} + +__inline float expf(float val) +{ + return ::exp(val); +} -#ifdef _ECOREB +#ifdef _ECOREB #define ECORE_API __declspec(dllexport) #define ENGINE_API __declspec(dllexport) #else - #define ECORE_API __declspec(dllimport) - #define ENGINE_API __declspec(dllimport) +#define ECORE_API __declspec(dllimport) +#define ENGINE_API __declspec(dllimport) #endif #define DLL_API __declspec(dllimport) @@ -103,8 +122,8 @@ __inline float expf (float val) { return ::exp(val);} #include "../ECore/editor/D3DX_Wrapper.h" -DEFINE_VECTOR (AnsiString,AStringVec,AStringIt); -DEFINE_VECTOR (AnsiString*,LPAStringVec,LPAStringIt); +DEFINE_VECTOR(AnsiString, AStringVec, AStringIt); +DEFINE_VECTOR(AnsiString *, LPAStringVec, LPAStringIt); #include "../../xrServerEntities/xrEProps.h" #include "../../xrCore/Log.h" @@ -115,13 +134,22 @@ DEFINE_VECTOR (AnsiString*,LPAStringVec,LPAStringIt); struct str_pred : public std::binary_function { - IC bool operator()(LPCSTR x, LPCSTR y) const - { return strcmp(x,y)<0; } + IC + + bool operator()(LPCSTR x, LPCSTR y) const + { + return strcmp(x, y)<0; + } }; + struct astr_pred : public std::binary_function { - IC bool operator()(const AnsiString& x, const AnsiString& y) const - { return x #include + //--------------------------------------------------------------------------- -class ECORE_API TfraBottomBar : public TFrame +class ECORE_API TfraBottomBar : + +public +TFrame { -__published: // IDE-managed Components - TFormStorage *fsStorage; - TMxPopupMenu *pmOptions; + __published: // IDE-managed Components + TFormStorage *fsStorage; + TMxPopupMenu *pmOptions; TMenuItem *Quality1; - TMenuItem *N25; - TMenuItem *N50; - TMenuItem *N75; - TMenuItem *N100; - TMenuItem *N125; - TMenuItem *N150; - TMenuItem *N200; + TMenuItem *N25; + TMenuItem *N50; + TMenuItem *N75; + TMenuItem *N100; + TMenuItem *N125; + TMenuItem *N150; + TMenuItem *N200; TMenuItem *N2; TMenuItem *miDrawGrid; - TMenuItem *Render1; - TMenuItem *FillMode1; - TMenuItem *miRenderFillSolid; - TMenuItem *miRenderFillWireframe; - TMenuItem *miRenderFillPoint; - TMenuItem *ShadeMode1; - TMenuItem *miRenderShadeGouraud; - TMenuItem *miRenderShadeFlat; - TMenuItem *miRenderEdgedFaces; - TMenuItem *miRenderHWTransform; - TMenuItem *miRenderLinearFilter; - TMenuItem *miRenderWithTextures; - TMenuItem *N7; - TMenuItem *N8; - TMenuItem *miLightScene; - TMenuItem *miFog; - TMenuItem *miRealTime; + TMenuItem *Render1; + TMenuItem *FillMode1; + TMenuItem *miRenderFillSolid; + TMenuItem *miRenderFillWireframe; + TMenuItem *miRenderFillPoint; + TMenuItem *ShadeMode1; + TMenuItem *miRenderShadeGouraud; + TMenuItem *miRenderShadeFlat; + TMenuItem *miRenderEdgedFaces; + TMenuItem *miRenderHWTransform; + TMenuItem *miRenderLinearFilter; + TMenuItem *miRenderWithTextures; + TMenuItem *N7; + TMenuItem *N8; + TMenuItem *miLightScene; + TMenuItem *miFog; + TMenuItem *miRealTime; TMenuItem *N1; - TPanel *paBottomBar; - TPanel *paInfo; - TPanel *paStatusBar; - TPanel *paTools; - TExtBtn *ebOptions; - TExtBtn *ebLog; - TExtBtn *ebStat; - TExtBtn *ebStop; - TPanel *paStatusLabel; - TPanel *paStatus; - TCGauge *cgProgress; - TPanel *paSel; - TPanel *paGridSquareSize; - TPanel *paUICursor; - TPanel *paCamera; - TMenuItem *miDrawSafeRect; - TMenuItem *miMuteSounds; - TMenuItem *N5; - TMenuItem *miWeather; - TMenuItem *miWeatherNone; - TMenuItem *N6; - TExtBtn *ebMacro; - TMxPopupMenu *pmMacro; - TMenuItem *Device1; - TMenuItem *TimeFactor1; - TMenuItem *N0051; - TMenuItem *N011; - TMenuItem *N031; - TMenuItem *N051; - TMenuItem *N101; - TMenuItem *N301; - TMenuItem *N501; - TMenuItem *N021; - TMenuItem *N1001; + TPanel *paBottomBar; + TPanel *paInfo; + TPanel *paStatusBar; + TPanel *paTools; + TExtBtn *ebOptions; + TExtBtn *ebLog; + TExtBtn *ebStat; + TExtBtn *ebStop; + TPanel *paStatusLabel; + TPanel *paStatus; + TCGauge *cgProgress; + TPanel *paSel; + TPanel *paGridSquareSize; + TPanel *paUICursor; + TPanel *paCamera; + TMenuItem *miDrawSafeRect; + TMenuItem *miMuteSounds; + TMenuItem *N5; + TMenuItem *miWeather; + TMenuItem *miWeatherNone; + TMenuItem *N6; + TExtBtn *ebMacro; + TMxPopupMenu *pmMacro; + TMenuItem *Device1; + TMenuItem *TimeFactor1; + TMenuItem *N0051; + TMenuItem *N011; + TMenuItem *N031; + TMenuItem *N051; + TMenuItem *N101; + TMenuItem *N301; + TMenuItem *N501; + TMenuItem *N021; + TMenuItem *N1001; void __fastcall ClickOptionsMenuItem(TObject *Sender); void __fastcall QualityClick(TObject *Sender); void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall ebLogClick(TObject *Sender); - void __fastcall ebStopClick(TObject *Sender); - void __fastcall ebStatClick(TObject *Sender); - void __fastcall ebOptionsMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall pmOptionsPopup(TObject *Sender); - void __fastcall miWeatherClick(TObject *Sender); - void __fastcall ebMacroMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall N501Click(TObject *Sender); -private: // User declarations - void __fastcall MacroAssignClick(TObject *Sender); - void __fastcall MacroClearClick(TObject *Sender); - void __fastcall MacroExecuteClick(TObject *Sender); - void __fastcall MacroLogCommandsClick(TObject *Sender); - void __fastcall MacroEditCommandListClick(TObject *Sender); -public: // User declarations + void __fastcall ebLogClick(TObject *Sender); + void __fastcall ebStopClick(TObject *Sender); + void __fastcall ebStatClick(TObject *Sender); + void __fastcall ebOptionsMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall pmOptionsPopup(TObject *Sender); + void __fastcall miWeatherClick(TObject *Sender); + void __fastcall ebMacroMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall N501Click(TObject *Sender); + private: // User declarations + void __fastcall MacroAssignClick(TObject *Sender); + void __fastcall MacroClearClick(TObject *Sender); + void __fastcall MacroExecuteClick(TObject *Sender); + void __fastcall MacroLogCommandsClick(TObject *Sender); + void __fastcall MacroEditCommandListClick(TObject *Sender); + public: // User declarations __fastcall TfraBottomBar(TComponent* Owner); void RefreshBar(){;} - void RedrawBar(); +void RedrawBar(); }; //--------------------------------------------------------------------------- -extern PACKAGE TfraBottomBar *fraBottomBar; +extern PACKAGE TfraBottomBar * fraBottomBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/DOOneColor.h b/src/editors/LevelEditor/DOOneColor.h index c559e9ae558..3fdfad18b7b 100644 --- a/src/editors/LevelEditor/DOOneColor.h +++ b/src/editors/LevelEditor/DOOneColor.h @@ -24,34 +24,36 @@ class TfrmDOShuffle; class TfrmOneColor : public TForm { -__published: // IDE-managed Components - TBevel *Bevel1; - TBevel *Bevel2; - TMultiObjColor *mcColor; - TExtBtn *ebMultiRemove; - TElTree *tvDOList; - void __fastcall mcColorMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y); - void __fastcall FormClose(TObject *Sender, TCloseAction &Action); - void __fastcall ebMultiRemoveClick(TObject *Sender); - void __fastcall tvDOListDragOver(TObject *Sender, TObject *Source, int X, - int Y, TDragState State, bool &Accept); - void __fastcall tvDOListDragDrop(TObject *Sender, TObject *Source, int X, - int Y); - void __fastcall tvDOListStartDrag(TObject *Sender, - TDragObject *&DragObject); - void __fastcall tvDOListItemFocused(TObject *Sender); -private: // User declarations - TfrmDOShuffle* m_Parent; + __published: // IDE-managed Components + TBevel*Bevel1; + TBevel *Bevel2; + TMultiObjColor *mcColor; + TExtBtn *ebMultiRemove; + TElTree *tvDOList; + void __fastcall mcColorMouseDown(TObject *Sender, + TMouseButton Button, TShiftState Shift, int X, int Y); + void __fastcall FormClose(TObject *Sender, TCloseAction &Action); + void __fastcall ebMultiRemoveClick(TObject *Sender); + void __fastcall tvDOListDragOver(TObject *Sender, TObject *Source, int X, + int Y, TDragState State, bool &Accept); + void __fastcall tvDOListDragDrop(TObject *Sender, TObject *Source, int X, + int Y); + void __fastcall tvDOListStartDrag(TObject *Sender, + TDragObject *&DragObject); + void __fastcall tvDOListItemFocused(TObject *Sender); +private: // User declarations + TfrmDOShuffle *m_Parent; public: bool bLoadMode; - TElTreeItem* FDragItem; -public: // User declarations - __fastcall TfrmOneColor(TComponent* Owner); - void __fastcall ShowIndex(TfrmDOShuffle* parent); + TElTreeItem *FDragItem; +public: // User declarations + __fastcall TfrmOneColor(TComponent *Owner); + void __fastcall ShowIndex(TfrmDOShuffle *parent); void __fastcall HideIndex(); void __fastcall RemoveObject(LPCSTR text); void __fastcall AppendObject(LPCSTR text, LPVOID data); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/BuilderCF.cpp b/src/editors/LevelEditor/Edit/BuilderCF.cpp index 732d4dd0650..8b9fe290d6d 100644 --- a/src/editors/LevelEditor/Edit/BuilderCF.cpp +++ b/src/editors/LevelEditor/Edit/BuilderCF.cpp @@ -4,4 +4,3 @@ #include "stdafx.h" #pragma hdrstop - diff --git a/src/editors/LevelEditor/Edit/ELight_def.h b/src/editors/LevelEditor/Edit/ELight_def.h index 9955c6c1e5f..2abd919c308 100644 --- a/src/editors/LevelEditor/Edit/ELight_def.h +++ b/src/editors/LevelEditor/Edit/ELight_def.h @@ -9,23 +9,26 @@ #define LCONTROL_SUN "$sun" // sun #define LCONTROL_STATIC "$static" // all other static lights -namespace ELight{ - enum EFlags{ - flAffectStatic = (1<<0), - flAffectDynamic = (1<<1), - flProcedural = (1<<2), - flBreaking = (1<<3), - flPointFuzzy = (1<<4), - flCastShadow = (1<<5), - }; +namespace ELight +{ +enum EFlags +{ + flAffectStatic = (1<<0), + flAffectDynamic = (1<<1), + flProcedural = (1<<2), + flBreaking = (1<<3), + flPointFuzzy = (1<<4), + flCastShadow = (1<<5), +}; - enum EType{ - ltPoint = D3DLIGHT_POINT, - ltSpot = D3DLIGHT_SPOT, - ltDirect = D3DLIGHT_DIRECTIONAL, - ltMaxCount, - lt_max_type = u32(-1), - }; +enum EType +{ + ltPoint = D3DLIGHT_POINT, + ltSpot = D3DLIGHT_SPOT, + ltDirect = D3DLIGHT_DIRECTIONAL, + ltMaxCount, + lt_max_type = u32(-1), +}; }; #endif diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapControls.h b/src/editors/LevelEditor/Edit/ESceneAIMapControls.h index c9ad2cb1ab3..e24a1b6a2f4 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapControls.h +++ b/src/editors/LevelEditor/Edit/ESceneAIMapControls.h @@ -7,30 +7,39 @@ class ESceneAIMapTool; #define estAIMapNode 0 + //--------------------------------------------------------------------------- -class TUI_ControlAIMapNodeAdd: public TUI_CustomControl{ - int append_nodes; +class TUI_ControlAIMapNodeAdd: public TUI_CustomControl +{ + int append_nodes; public: - TUI_ControlAIMapNodeAdd(int st, int act, ESceneToolBase* parent); - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlAIMapNodeAdd(int st, int act, ESceneToolBase *parent); + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); }; + //--------------------------------------------------------------------------- -class TUI_ControlAIMapNodeMove: public TUI_CustomControl{ +class TUI_ControlAIMapNodeMove: public TUI_CustomControl +{ public: - TUI_ControlAIMapNodeMove(int st, int act, ESceneToolBase* parent); - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlAIMapNodeMove(int st, int act, ESceneToolBase *parent); + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); }; + //--------------------------------------------------------------------------- -class TUI_ControlAIMapNodeRotate: public TUI_CustomControl{ +class TUI_ControlAIMapNodeRotate: public TUI_CustomControl +{ public: - TUI_ControlAIMapNodeRotate(int st, int act, ESceneToolBase* parent); - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlAIMapNodeRotate(int st, int act, ESceneToolBase *parent); + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); }; + //--------------------------------------------------------------------------- #endif //UI_AIMapToolsH + + diff --git a/src/editors/LevelEditor/Edit/ESceneClassList.h b/src/editors/LevelEditor/Edit/ESceneClassList.h index d78e094d79c..e19fb8abd87 100644 --- a/src/editors/LevelEditor/Edit/ESceneClassList.h +++ b/src/editors/LevelEditor/Edit/ESceneClassList.h @@ -4,38 +4,39 @@ // refs class CCustomObject; -typedef u32 ObjClassID; +typedef u32 ObjClassID; //---------------------------------------------------- -enum{ - OBJCLASS_DUMMY = -1, +enum +{ + OBJCLASS_DUMMY = -1, OBJCLASS_FIRST_CLASS= 0, - OBJCLASS_GROUP = 0, - OBJCLASS_GLOW = 1, + OBJCLASS_GROUP = 0, + OBJCLASS_GLOW = 1, OBJCLASS_SCENEOBJECT= 2, - OBJCLASS_LIGHT = 3, - OBJCLASS_SHAPE = 4, - OBJCLASS_SOUND_SRC = 5, - OBJCLASS_SPAWNPOINT = 6, - OBJCLASS_WAY = 7, - OBJCLASS_SECTOR = 8, - OBJCLASS_PORTAL = 9, - OBJCLASS_SOUND_ENV = 10, - OBJCLASS_PS = 11, - OBJCLASS_DO = 12, - OBJCLASS_AIMAP = 13, - OBJCLASS_WM = 14, - OBJCLASS_FOG_VOL = 15, - OBJCLASS_COUNT = 16, + OBJCLASS_LIGHT = 3, + OBJCLASS_SHAPE = 4, + OBJCLASS_SOUND_SRC = 5, + OBJCLASS_SPAWNPOINT = 6, + OBJCLASS_WAY = 7, + OBJCLASS_SECTOR = 8, + OBJCLASS_PORTAL = 9, + OBJCLASS_SOUND_ENV = 10, + OBJCLASS_PS = 11, + OBJCLASS_DO = 12, + OBJCLASS_AIMAP = 13, + OBJCLASS_WM = 14, + OBJCLASS_FOG_VOL = 15, + OBJCLASS_COUNT = 16, OBJCLASS_force_dword = u32(-1) }; + //---------------------------------------------------- -typedef xr_list ObjectList; -typedef ObjectList::iterator ObjectIt; -typedef xr_map ObjectMap; -typedef ObjectMap::iterator ObjectPairIt; +typedef xr_list ObjectList; +typedef ObjectList::iterator ObjectIt; +typedef xr_map ObjectMap; +typedef ObjectMap::iterator ObjectPairIt; #endif - \ No newline at end of file diff --git a/src/editors/LevelEditor/Edit/ESceneCustomOToolsFactory.cpp b/src/editors/LevelEditor/Edit/ESceneCustomOToolsFactory.cpp index e61ac6362d4..49d128f32c0 100644 --- a/src/editors/LevelEditor/Edit/ESceneCustomOToolsFactory.cpp +++ b/src/editors/LevelEditor/Edit/ESceneCustomOToolsFactory.cpp @@ -2,4 +2,4 @@ #pragma hdrstop #include "ESceneCustomOTools.h" - + diff --git a/src/editors/LevelEditor/Edit/ESceneDummyTools.cpp b/src/editors/LevelEditor/Edit/ESceneDummyTools.cpp index 0149b983e3d..0c93852d1c0 100644 --- a/src/editors/LevelEditor/Edit/ESceneDummyTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneDummyTools.cpp @@ -6,13 +6,16 @@ void ESceneDummyTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); + inherited::CreateDefaultControls(estDefault); } + //---------------------------------------------------- - + void ESceneDummyTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneGroupControls.h b/src/editors/LevelEditor/Edit/ESceneGroupControls.h index b4f04fd6483..06fe0c088a8 100644 --- a/src/editors/LevelEditor/Edit/ESceneGroupControls.h +++ b/src/editors/LevelEditor/Edit/ESceneGroupControls.h @@ -4,13 +4,17 @@ #include "ESceneControlsCustom.h" //------------------------------------------------------------------------------ -class TUI_ControlGroupAdd: public TUI_CustomControl{ - bool __fastcall AfterAppendCallback(TShiftState Shift, CCustomObject* obj); +class TUI_ControlGroupAdd: public TUI_CustomControl +{ + bool __fastcall AfterAppendCallback(TShiftState Shift, CCustomObject *obj); public: - TUI_ControlGroupAdd(int st, int act, ESceneToolBase* parent); - virtual ~TUI_ControlGroupAdd(){} - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlGroupAdd(int st, int act, ESceneToolBase *parent); + + virtual ~TUI_ControlGroupAdd() {} + + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); }; #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneObjectControls.h b/src/editors/LevelEditor/Edit/ESceneObjectControls.h index 6deaba1d6da..8881107ebf3 100644 --- a/src/editors/LevelEditor/Edit/ESceneObjectControls.h +++ b/src/editors/LevelEditor/Edit/ESceneObjectControls.h @@ -4,12 +4,19 @@ #include "ESceneControlsCustom.h" //------------------------------------------------------------------------------ -class TUI_ControlObjectAdd: public TUI_CustomControl{ +class TUI_ControlObjectAdd: public TUI_CustomControl +{ public: - TUI_ControlObjectAdd(int st, int act, ESceneToolBase* parent); - virtual ~TUI_ControlObjectAdd(){;} - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlObjectAdd(int st, int act, ESceneToolBase *parent); + + virtual ~TUI_ControlObjectAdd() + { + ; + } + + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); }; #endif + diff --git a/src/editors/LevelEditor/Edit/EScenePSControls.h b/src/editors/LevelEditor/Edit/EScenePSControls.h index 78ab33d72f3..02f8c3329c1 100644 --- a/src/editors/LevelEditor/Edit/EScenePSControls.h +++ b/src/editors/LevelEditor/Edit/EScenePSControls.h @@ -4,14 +4,23 @@ #include "ESceneControlsCustom.h" //--------------------------------------------------------------------------- -class TUI_ControlPSAdd: public TUI_CustomControl{ - bool __fastcall AfterAppendCallback(TShiftState Shift, CCustomObject* obj); +class TUI_ControlPSAdd: public TUI_CustomControl +{ + bool __fastcall AfterAppendCallback(TShiftState Shift, CCustomObject *obj); public: - TUI_ControlPSAdd(int st, int act, ESceneToolBase* parent); - virtual ~TUI_ControlPSAdd(){;} - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlPSAdd(int st, int act, ESceneToolBase *parent); + + virtual ~TUI_ControlPSAdd() + { + ; + } + + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); }; + //--------------------------------------------------------------------------- #endif //UI_PSToolsH + + diff --git a/src/editors/LevelEditor/Edit/EScenePortalControls.cpp b/src/editors/LevelEditor/Edit/EScenePortalControls.cpp index a15d44ab9d3..0f3aae6cb78 100644 --- a/src/editors/LevelEditor/Edit/EScenePortalControls.cpp +++ b/src/editors/LevelEditor/Edit/EScenePortalControls.cpp @@ -7,20 +7,20 @@ //------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ -__fastcall TUI_ControlPortalSelect::TUI_ControlPortalSelect(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent) -{ -} +__fastcall TUI_ControlPortalSelect::TUI_ControlPortalSelect(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} + bool __fastcall TUI_ControlPortalSelect::Start(TShiftState Shift) { - return SelectStart(Shift); + return SelectStart(Shift); } + void __fastcall TUI_ControlPortalSelect::Move(TShiftState Shift) { - SelectProcess(Shift); + SelectProcess(Shift); } bool __fastcall TUI_ControlPortalSelect::End(TShiftState Shift) { - return SelectEnd(Shift); + return SelectEnd(Shift); } diff --git a/src/editors/LevelEditor/Edit/EScenePortalControls.h b/src/editors/LevelEditor/Edit/EScenePortalControls.h index 7be7c72a5bc..4a91a845802 100644 --- a/src/editors/LevelEditor/Edit/EScenePortalControls.h +++ b/src/editors/LevelEditor/Edit/EScenePortalControls.h @@ -4,11 +4,14 @@ #include "ESceneControlsCustom.h" //--------------------------------------------------------------------------- -class TUI_ControlPortalSelect: public TUI_CustomControl{ +class TUI_ControlPortalSelect: public TUI_CustomControl +{ public: - TUI_ControlPortalSelect(int st, int act, ESceneToolBase* parent); - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlPortalSelect(int st, int act, ESceneToolBase *parent); + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); }; #endif //UI_SectorToolsH + + diff --git a/src/editors/LevelEditor/Edit/ESceneSectorControls.h b/src/editors/LevelEditor/Edit/ESceneSectorControls.h index 8a7cf9da960..c4f05e2401f 100644 --- a/src/editors/LevelEditor/Edit/ESceneSectorControls.h +++ b/src/editors/LevelEditor/Edit/ESceneSectorControls.h @@ -7,37 +7,47 @@ // refs class TfraSector; -enum ESectorAction{ +enum ESectorAction +{ saNone, saAddMesh, saDelMesh, saMeshBoxSelection }; -class TUI_ControlSectorAdd: public TUI_CustomControl{ - ESectorAction m_Action; - bool AddSectors(); - bool AddSector(); - void AddMesh(); - void DelMesh(); +class TUI_ControlSectorAdd: public TUI_CustomControl +{ + ESectorAction m_Action; + bool AddSectors(); + bool AddSector(); + void AddMesh(); + void DelMesh(); public: - TUI_ControlSectorAdd(int st, int act, ESceneToolBase* parent); - virtual ~TUI_ControlSectorAdd(){;} - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlSectorAdd(int st, int act, ESceneToolBase *parent); + + virtual ~TUI_ControlSectorAdd() + { + ; + } + + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); virtual void OnEnter(); - virtual void OnExit (); + virtual void OnExit(); }; -class TUI_ControlSectorSelect: public TUI_CustomControl{ - TfraSector* pFrame; +class TUI_ControlSectorSelect: public TUI_CustomControl +{ + TfraSector *pFrame; public: - TUI_ControlSectorSelect(int st, int act, ESceneToolBase* parent); - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlSectorSelect(int st, int act, ESceneToolBase *parent); + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); virtual void OnEnter(); - virtual void OnExit (); + virtual void OnExit(); }; #endif //UI_SectorToolsH + + diff --git a/src/editors/LevelEditor/Edit/ESceneShapeControls.h b/src/editors/LevelEditor/Edit/ESceneShapeControls.h index 1d9dae05ff8..99c782506f0 100644 --- a/src/editors/LevelEditor/Edit/ESceneShapeControls.h +++ b/src/editors/LevelEditor/Edit/ESceneShapeControls.h @@ -4,12 +4,19 @@ #include "ESceneControlsCustom.h" //--------------------------------------------------------------------------- -class TUI_ControlShapeAdd: public TUI_CustomControl{ - bool __fastcall AfterAppendCallback(TShiftState _Shift, CCustomObject* obj); +class TUI_ControlShapeAdd: public TUI_CustomControl +{ + bool __fastcall AfterAppendCallback(TShiftState _Shift, CCustomObject *obj); public: - TUI_ControlShapeAdd(int st, int act, ESceneToolBase* parent); - virtual ~TUI_ControlShapeAdd(){;} - virtual bool Start (TShiftState _Shift); + TUI_ControlShapeAdd(int st, int act, ESceneToolBase *parent); + + virtual ~TUI_ControlShapeAdd() + { + ; + } + + virtual bool Start(TShiftState _Shift); }; #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneSoundSrcTools.cpp b/src/editors/LevelEditor/Edit/ESceneSoundSrcTools.cpp index 664bdadc8bf..2f8249c4d70 100644 --- a/src/editors/LevelEditor/Edit/ESceneSoundSrcTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneSoundSrcTools.cpp @@ -7,21 +7,25 @@ void ESceneSoundSrcTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); + inherited::CreateDefaultControls(estDefault); } + //---------------------------------------------------- void ESceneSoundSrcTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- -CCustomObject* ESceneSoundSrcTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneSoundSrcTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneSpawnControls.h b/src/editors/LevelEditor/Edit/ESceneSpawnControls.h index 6ce24b6f0b9..de5fdcff92e 100644 --- a/src/editors/LevelEditor/Edit/ESceneSpawnControls.h +++ b/src/editors/LevelEditor/Edit/ESceneSpawnControls.h @@ -7,12 +7,19 @@ class TfraRPoint; //--------------------------------------------------------------------------- -class TUI_ControlSpawnAdd: public TUI_CustomControl{ - bool __fastcall AppendCallback(SBeforeAppendCallbackParams* p); +class TUI_ControlSpawnAdd: public TUI_CustomControl +{ + bool __fastcall AppendCallback(SBeforeAppendCallbackParams *p); public: - TUI_ControlSpawnAdd(int st, int act, ESceneToolBase* parent); - virtual ~TUI_ControlSpawnAdd(){;} - virtual bool Start (TShiftState _Shift); + TUI_ControlSpawnAdd(int st, int act, ESceneToolBase *parent); + + virtual ~TUI_ControlSpawnAdd() + { + ; + } + + virtual bool Start(TShiftState _Shift); }; #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneSpawnTools.h b/src/editors/LevelEditor/Edit/ESceneSpawnTools.h index b53310c48dd..86aecf3b545 100644 --- a/src/editors/LevelEditor/Edit/ESceneSpawnTools.h +++ b/src/editors/LevelEditor/Edit/ESceneSpawnTools.h @@ -9,66 +9,98 @@ class CEditableObject; class ESceneSpawnTool: public ESceneCustomOTool { typedef ESceneCustomOTool inherited; - friend class CSpawnPoint; + friend class CSpawnPoint; protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); - enum{ + virtual void CreateControls(); + virtual void RemoveControls(); + + enum + { flPickSpawnType = (1<<30), flShowSpawnType = (1<<31), }; - Flags32 m_Flags; + + Flags32 m_Flags; // class - DEFINE_VECTOR (SChooseItem,SSVec,SSVecIt); - DEFINE_MAP (CLASS_ID,SSVec,ClassSpawnMap,ClassSpawnMapIt); - ClassSpawnMap m_Classes; + DEFINE_VECTOR(SChooseItem, SSVec, SSVecIt); + DEFINE_MAP(CLASS_ID, SSVec, ClassSpawnMap, ClassSpawnMapIt); + ClassSpawnMap m_Classes; // icon list - DEFINE_MAP (shared_str,ref_shader,ShaderMap,ShaderPairIt); - ShaderMap m_Icons; - ref_shader CreateIcon (shared_str name); - ref_shader GetIcon (shared_str name); + DEFINE_MAP(shared_str, ref_shader, ShaderMap, ShaderPairIt); + ShaderMap m_Icons; + ref_shader CreateIcon(shared_str name); + ref_shader GetIcon(shared_str name); xr_vector m_draw_RP_visuals; public: - ESceneSpawnTool (); - virtual ~ESceneSpawnTool (); + ESceneSpawnTool(); + virtual ~ESceneSpawnTool(); // definition - IC LPCSTR ClassName (){return "spawn";} - IC LPCSTR ClassDesc (){return "Spawn";} - IC int RenderPriority (){return 1;} + IC LPCSTR ClassName() + { + return "spawn"; + } + + IC LPCSTR ClassDesc() + { + return "Spawn"; + } + + IC + + int RenderPriority() + { + return 1; + } + + void FillProp(LPCSTR pref, PropItemVec &items); - void FillProp (LPCSTR pref, PropItemVec& items); + virtual void Clear(bool bSpecific = false) + { + inherited::Clear(bSpecific); + m_Flags.zero(); + } - virtual void Clear (bool bSpecific=false){inherited::Clear(bSpecific);m_Flags.zero();} // IO - virtual bool IsNeedSave (){return true;} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool can_use_inifile () {return true;} - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - - virtual int MultiRenameObjects (); -/* - virtual void GetStaticDesc (int& v_cnt, int& f_cnt, bool b_selected_only); - virtual bool ExportStatic (SceneBuilder* B, bool b_selected_only); -*/ - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); - CEditableObject* get_draw_visual (u8 _RP_TeamID, u8 _RP_Type, const GameTypeChooser& _GameType); + virtual bool IsNeedSave() + { + return true; + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + + virtual bool can_use_inifile() + { + return true; + } + + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + + virtual int MultiRenameObjects(); + /* + virtual void GetStaticDesc (int& v_cnt, int& f_cnt, bool b_selected_only); + virtual bool ExportStatic (SceneBuilder* B, bool b_selected_only); + */ + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); + CEditableObject *get_draw_visual(u8 _RP_TeamID, u8 _RP_Type, const GameTypeChooser &_GameType); }; + //--------------------------------------------------------------------------- // refs class IServerEntity; -typedef IServerEntity* (__stdcall *Tcreate_entity) (LPCSTR section); -typedef void (__stdcall *Tdestroy_entity) (IServerEntity *&); +typedef IServerEntity * (__stdcall *Tcreate_entity)(LPCSTR section); +typedef void (__stdcall *Tdestroy_entity)(IServerEntity *&); -extern Tcreate_entity create_entity; -extern Tdestroy_entity destroy_entity; +extern Tcreate_entity create_entity; +extern Tdestroy_entity destroy_entity; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneWallmarkControls.h b/src/editors/LevelEditor/Edit/ESceneWallmarkControls.h index 1b0534b7571..ce172fc1341 100644 --- a/src/editors/LevelEditor/Edit/ESceneWallmarkControls.h +++ b/src/editors/LevelEditor/Edit/ESceneWallmarkControls.h @@ -9,24 +9,29 @@ class ESceneWallmarkTools; //--------------------------------------------------------------------------- -class TUI_ControlWallmarkAdd: public TUI_CustomControl{ - u32 wm_cnt; +class TUI_ControlWallmarkAdd: public TUI_CustomControl +{ + u32 wm_cnt; public: - TUI_ControlWallmarkAdd(int st, int act, ESceneToolBase* parent); - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlWallmarkAdd(int st, int act, ESceneToolBase *parent); + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); }; + //--------------------------------------------------------------------------- -class TUI_ControlWallmarkMove: public TUI_CustomControl{ - u32 wm_cnt; +class TUI_ControlWallmarkMove: public TUI_CustomControl +{ + u32 wm_cnt; public: - TUI_ControlWallmarkMove(int st, int act, ESceneToolBase* parent); - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); + TUI_ControlWallmarkMove(int st, int act, ESceneToolBase *parent); + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/EShape.h b/src/editors/LevelEditor/Edit/EShape.h index 4e496e1e4ad..67370e9337c 100644 --- a/src/editors/LevelEditor/Edit/EShape.h +++ b/src/editors/LevelEditor/Edit/EShape.h @@ -5,68 +5,92 @@ #include "ShapeData.h" #include "CustomObject.h" + //--------------------------------------------------------------------------- -enum eShapeUsage{eShapeCommon=0, eShapeLevelBound}; +enum eShapeUsage +{ + eShapeCommon=0, + eShapeLevelBound +}; class CEditShape: public CCustomObject, CShapeData { - typedef CCustomObject inherited; + typedef CCustomObject inherited; private: -// bounds - Fbox m_Box; - Fsphere m_Sphere; - void ComputeBounds ( ); + // bounds + Fbox m_Box; + Fsphere m_Sphere; + void ComputeBounds(); public: - u8 m_shape_type; - u32 m_DrawTranspColor; - u32 m_DrawEdgeColor; - - void SetDrawColor (u32 transp, u32 edge){m_DrawTranspColor=transp;m_DrawEdgeColor=edge;} - void ApplyScale (); - void add_sphere (const Fsphere& S); - void add_box (const Fmatrix& B); - const shape_def&get_shape (int idx){R_ASSERT(idx<(int)shapes.size());return shapes[idx];} - virtual void FillProp (LPCSTR pref, PropItemVec& values); - + u8 m_shape_type; + u32 m_DrawTranspColor; + u32 m_DrawEdgeColor; + + void SetDrawColor(u32 transp, u32 edge) + { + m_DrawTranspColor = transp; + m_DrawEdgeColor = edge; + } + + void ApplyScale(); + void add_sphere(const Fsphere &S); + void add_box(const Fmatrix &B); + + const shape_def &get_shape(int idx) + { + R_ASSERT(idx<(int)shapes.size()); + return shapes[idx]; + } + + virtual void FillProp(LPCSTR pref, PropItemVec &values); + protected: - virtual void SetScale (const Fvector& val); - virtual void OnUpdateTransform(); + virtual void SetScale(const Fvector &val); + virtual void OnUpdateTransform(); public: - CEditShape (LPVOID data, LPCSTR name); - void Construct (LPVOID data); - virtual ~CEditShape (); - virtual bool CanAttach () {return true;} - + CEditShape(LPVOID data, LPCSTR name); + void Construct(LPVOID data); + virtual ~CEditShape(); + + virtual bool CanAttach() + { + return true; + } + // pick functions - virtual bool RayPick (float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf = NULL); - virtual bool FrustumPick (const CFrustum& frustum); + virtual bool RayPick(float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf = NULL); + virtual bool FrustumPick(const CFrustum &frustum); // placement functions - virtual bool GetBox (Fbox& box) const; + virtual bool GetBox(Fbox &box) const; // change position/orientation methods -// virtual void Scale (Fvector& amount){;} + // virtual void Scale (Fvector& amount){;} // file system function - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); // render utility function - virtual void Render (int priority, bool strictB2F); - virtual void OnFrame (); + virtual void Render(int priority, bool strictB2F); + virtual void OnFrame(); // tools - void Attach (CEditShape* from); - void Detach (); + void Attach(CEditShape *from); + void Detach(); - ShapeVec& GetShapes (){return shapes;} + ShapeVec &GetShapes() + { + return shapes; + } - virtual void OnDetach (); + virtual void OnDetach(); // events - virtual void OnShowHint (AStringVec& dest); + virtual void OnShowHint(AStringVec &dest); }; #endif + diff --git a/src/editors/LevelEditor/Edit/ESound_Source.h b/src/editors/LevelEditor/Edit/ESound_Source.h index d7327a9f5ac..66978ac9a33 100644 --- a/src/editors/LevelEditor/Edit/ESound_Source.h +++ b/src/editors/LevelEditor/Edit/ESound_Source.h @@ -7,68 +7,112 @@ class ESoundSource: public CCustomObject { - typedef CCustomObject inherited; - // static sound - ref_sound m_Source; - shared_str m_WAVName; - CSound_params m_Params; - Fvector2 m_PlayTime; - Fvector2 m_RandomPause; - Fvector2 m_ActiveTime; - u32 m_NextTime; - u32 m_StopTime; + typedef CCustomObject inherited; + // static sound + ref_sound m_Source; + shared_str m_WAVName; + CSound_params m_Params; + Fvector2 m_PlayTime; + Fvector2 m_RandomPause; + Fvector2 m_ActiveTime; + u32 m_NextTime; + u32 m_StopTime; // edit events - void __stdcall OnChangeWAV (PropValue* prop); - void __stdcall OnChangeSource (PropValue* prop); - void __stdcall OnControlClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void ResetSource (); - enum{ - flLooped = (1<<0), - flPlaying = (1<<1), + void __stdcall OnChangeWAV(PropValue *prop); + void __stdcall OnChangeSource(PropValue *prop); + void __stdcall OnControlClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void ResetSource(); + + enum + { + flLooped = (1<<0), + flPlaying = (1<<1), flSimulating= (1<<2) }; - Flags32 m_Flags; - enum ECommand{ - stNothing, - stPlay, + + Flags32 m_Flags; + + enum ECommand + { + stNothing, + stPlay, stStop, stPause, stSimulate, }; - ECommand m_Command; + + ECommand m_Command; public: - enum ESoundType{ - stStaticSource = 0, + enum ESoundType + { + stStaticSource = 0, }; - ESoundType m_Type; + + ESoundType m_Type; public: - virtual const Fvector& GetPosition () const { return m_Params.position; } - virtual void SetPosition (const Fvector& pos) { m_Params.position.set(pos); if (m_Source._feedback()) m_Source.set_position(m_Params.position); } + virtual const Fvector &GetPosition() const + { + return m_Params.position; + } + + virtual void SetPosition(const Fvector &pos) + { + m_Params.position.set(pos); + if (m_Source._feedback()) + m_Source.set_position(m_Params.position); + } + public: - ESoundSource (LPVOID data, LPCSTR name); - void Construct (LPVOID data); - ~ESoundSource (); - virtual bool CanAttach () {return true;} - - LPCSTR GetSourceWAV (){return *m_WAVName;} - void SetSourceWAV (LPCSTR fname); - void Play (){m_Command=stPlay;} - void Stop (){m_Command=stStop;} - void Simulate (){m_Command=stSimulate;} - - virtual void Render (int priority, bool strictB2F); - virtual bool RayPick (float& dist, const Fvector& S, const Fvector& D, SRayPickInfo* pinf = NULL); - virtual bool FrustumPick (const CFrustum& frustum); - virtual void OnFrame (); - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); - virtual bool GetBox (Fbox& box) const; - virtual void Scale (Fvector& amount){;} - virtual void FillProp (LPCSTR pref, PropItemVec& values); - virtual bool GetSummaryInfo (SSceneSummary* inf); - virtual bool ExportGame (SExportStreams* data); + ESoundSource(LPVOID data, LPCSTR name); + void Construct(LPVOID data); + ~ESoundSource(); + + virtual bool CanAttach() + { + return true; + } + + LPCSTR GetSourceWAV() + { + return *m_WAVName; + } + + void SetSourceWAV(LPCSTR fname); + + void Play() + { + m_Command = stPlay; + } + + void Stop() + { + m_Command = stStop; + } + + void Simulate() + { + m_Command = stSimulate; + } + + virtual void Render(int priority, bool strictB2F); + virtual bool RayPick(float &dist, const Fvector &S, const Fvector &D, SRayPickInfo *pinf = NULL); + virtual bool FrustumPick(const CFrustum &frustum); + virtual void OnFrame(); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); + virtual bool GetBox(Fbox &box) const; + + virtual void Scale(Fvector &amount) + { + ; + } + + virtual void FillProp(LPCSTR pref, PropItemVec &values); + virtual bool GetSummaryInfo(SSceneSummary *inf); + virtual bool ExportGame(SExportStreams *data); }; #endif + diff --git a/src/editors/LevelEditor/Edit/GroupObject.h b/src/editors/LevelEditor/Edit/GroupObject.h index 3f5f64b2ddc..7cfbc6619cc 100644 --- a/src/editors/LevelEditor/Edit/GroupObject.h +++ b/src/editors/LevelEditor/Edit/GroupObject.h @@ -2,6 +2,7 @@ #define GroupObjectH #include "CustomObject.h" + //---------------------------------------------------- class CGroupObject: public CCustomObject { @@ -9,76 +10,105 @@ class CGroupObject: public CCustomObject struct SGroupObjectItem { - CCustomObject* pObject; - SGroupObjectItem():pObject(NULL){} + CCustomObject *pObject; + + SGroupObjectItem(): pObject(NULL) {} - bool operator == (const CCustomObject* obj){return obj==pObject;} + bool operator ==(const CCustomObject *obj) + { + return obj==pObject; + } }; + typedef xr_list ObjectsInGroup; - ObjectsInGroup m_ObjectsInGroup; + ObjectsInGroup m_ObjectsInGroup; - bool LL_AppendObject (CCustomObject* object); - bool AppendObjectLoadCB (CCustomObject* object); - shared_str m_ReferenceName_; - void ReferenceChange (PropValue* sender); - void __stdcall OnFreezeAllClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void ClearInternal (ObjectsInGroup& v); + bool LL_AppendObject(CCustomObject *object); + bool AppendObjectLoadCB(CCustomObject *object); + shared_str m_ReferenceName_; + void ReferenceChange(PropValue *sender); + void __stdcall OnFreezeAllClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void ClearInternal(ObjectsInGroup &v); public: - void Clear1 (){ClearInternal(m_ObjectsInGroup);}; - bool UpdateReference (bool bForceReload); + void Clear1() + { + ClearInternal(m_ObjectsInGroup); + }; + + bool UpdateReference(bool bForceReload); public: - CGroupObject (LPVOID data, LPCSTR name); - void Construct (LPVOID data); - virtual ~CGroupObject (); - bool CanUngroup (bool bMsg); - void GroupObjects (ObjectList& lst); - void UngroupObjects (); - u32 GetObjects (ObjectList& lst); - IC int ObjectInGroupCount(){return m_ObjectsInGroup.size();} - - bool SetReference (LPCSTR nm); - virtual LPCSTR RefName (){return m_ReferenceName_.size()?m_ReferenceName_.c_str():"group";} - bool RefCompare (LPCSTR nm){return m_ReferenceName_.equal(nm);} - void SetRefName (LPCSTR nm); - void UpdatePivot (LPCSTR nm, bool center); - virtual bool GetBox (Fbox& box) const; - virtual bool CanAttach () {return false;} - - virtual void NumSetPosition (const Fvector& pos); - virtual void NumSetRotation (const Fvector& rot); - virtual void NumSetScale (const Fvector& scale); - virtual void MoveTo (const Fvector& pos, const Fvector& up); - virtual void Move (Fvector& amount); - virtual void RotateParent (Fvector& axis, float angle ); - virtual void RotateLocal (Fvector& axis, float angle ); - virtual void Scale (Fvector& amount ); - - virtual void Render (int priority, bool strictB2F); - - virtual bool RayPick (float& dist, const Fvector& start,const Fvector& dir, SRayPickInfo* pinf=NULL); - virtual bool FrustumPick (const CFrustum& frustum); - - virtual void OnUpdateTransform(); - virtual void OnFrame (); - virtual void Select (int flag); - - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); - - virtual bool ExportGame (SExportStreams* data); + CGroupObject(LPVOID data, LPCSTR name); + void Construct(LPVOID data); + virtual ~CGroupObject(); + bool CanUngroup(bool bMsg); + void GroupObjects(ObjectList &lst); + void UngroupObjects(); + u32 GetObjects(ObjectList &lst); + IC + + int ObjectInGroupCount() + { + return m_ObjectsInGroup.size(); + } + + bool SetReference(LPCSTR nm); + + virtual LPCSTR RefName() + { + return m_ReferenceName_.size() ? m_ReferenceName_.c_str() : "group"; + } + + bool RefCompare(LPCSTR nm) + { + return m_ReferenceName_.equal(nm); + } + + void SetRefName(LPCSTR nm); + void UpdatePivot(LPCSTR nm, bool center); + virtual bool GetBox(Fbox &box) const; + + virtual bool CanAttach() + { + return false; + } + + virtual void NumSetPosition(const Fvector &pos); + virtual void NumSetRotation(const Fvector &rot); + virtual void NumSetScale(const Fvector &scale); + virtual void MoveTo(const Fvector &pos, const Fvector &up); + virtual void Move(Fvector &amount); + virtual void RotateParent(Fvector &axis, float angle); + virtual void RotateLocal(Fvector &axis, float angle); + virtual void Scale(Fvector &amount); + + virtual void Render(int priority, bool strictB2F); + + virtual bool RayPick(float &dist, const Fvector &start, const Fvector &dir, SRayPickInfo *pinf = NULL); + virtual bool FrustumPick(const CFrustum &frustum); + + virtual void OnUpdateTransform(); + virtual void OnFrame(); + virtual void Select(int flag); + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); + + virtual bool ExportGame(SExportStreams *data); // device dependent routine - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); - virtual void OnShowHint (AStringVec& dest); - virtual void OnObjectRemove (const CCustomObject* object); - virtual void OnSceneUpdate (); + virtual void OnShowHint(AStringVec &dest); + virtual void OnObjectRemove(const CCustomObject *object); + virtual void OnSceneUpdate(); - virtual void FillProp (LPCSTR pref, PropItemVec& items); + virtual void FillProp(LPCSTR pref, PropItemVec &items); }; + //---------------------------------------------------- #endif /* _INCDEF_GroupObject_H_ */ + diff --git a/src/editors/LevelEditor/Edit/LevelGameDef.cpp b/src/editors/LevelEditor/Edit/LevelGameDef.cpp new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/LevelEditor/Edit/LevelGameDef.cpp @@ -0,0 +1 @@ + diff --git a/src/editors/LevelEditor/Edit/LevelGameDef.h b/src/editors/LevelEditor/Edit/LevelGameDef.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/LevelEditor/Edit/LevelGameDef.h @@ -0,0 +1 @@ + diff --git a/src/editors/LevelEditor/Edit/SceneGraph.h b/src/editors/LevelEditor/Edit/SceneGraph.h index 92fb66ba90f..9a990808e90 100644 --- a/src/editors/LevelEditor/Edit/SceneGraph.h +++ b/src/editors/LevelEditor/Edit/SceneGraph.h @@ -4,201 +4,325 @@ template class FixedMAP { public: - struct TNode { - K key; - T val; - TNode *left,*right; - - TNode() { right = left = 0; } - }; - typedef void __fastcall callback(TNode*); + struct TNode + { + K key; + T val; + TNode* left, * right; + + TNode() + { + right = left = 0; + } + }; + + typedef void __fastcall callback(TNode *); private: - TNode* nodes; - DWORD pool; - DWORD limit; - - IC TNode* Alloc(const K& key, const T& val) - { - VERIFY(nodes); - TNode *node = nodes + pool; - node->key = key; - node->val = val; - node->right = node->left = 0; - pool++; - VERIFY(poolkey = key; - node->right = node->left = 0; - pool++; - VERIFY(poolleft) recurseLR(N->left,CB); - CB(N); - if (N->right) recurseLR(N->right,CB); - } - IC void recurseRL (TNode* N, callback CB) - { - if (N->right) recurseRL(N->right,CB); - CB(N); - if (N->left) recurseRL(N->left,CB); - } + TNode *nodes; + DWORD pool; + DWORD limit; + + IC TNode*Alloc(const K &key, const T &val) + { + VERIFY(nodes); + TNode*node = nodes+pool; + node->key = key; + node->val = val; + node->right = node->left = 0; + pool++; + VERIFY(poolkey = key; + node->right = node->left = 0; + pool++; + VERIFY(poolleft) + recurseLR(N->left, CB); + CB(N); + if (N->right) + recurseLR(N->right, CB); + } + + IC + + void recurseRL(TNode *N, callback CB) + { + if (N->right) + recurseRL(N->right, CB); + CB(N); + if (N->left) + recurseRL(N->left, CB); + } + public: - FixedMAP() { - nodes = 0; - pool = 0; - limit = 0; - } - ~FixedMAP() { - delete [] nodes; - } - IC void init (int maxnodes) - { - limit = maxnodes; - nodes = new TNode[limit]; - } - IC TNode* insert(const K& k, const T& v) - { - if (pool) { - TNode* node = nodes; - - once_more: - if (k < node->key) { - if (node->left) { - node = node->left; - goto once_more; - } else { - TNode* N = Alloc(k,v); - node->left = N; - return N; - } - } else if (k > node->key) { - if (node->right) { - node = node->right; - goto once_more; - } else { - TNode* N = Alloc(k,v); - node->right = N; - return N; - } - } else return node; - - } else { - return Alloc(k,v); - } - } - IC TNode* insertInAnyWay(const K& k, const T& v) - { - if (pool) { - TNode* node = nodes; - - once_more: - if (k <= node->key) { - VERIFY(node->val != v); - if (node->left) { - node = node->left; - goto once_more; - } else { - TNode* N = Alloc(k,v); - node->left = N; - return N; - } - } else { - if (node->right) { - node = node->right; - goto once_more; - } else { - TNode* N = Alloc(k,v); - node->right = N; - return N; - } - } - } else { - return Alloc(k,v); - } - } - IC TNode* insert(const K& k) { - if (pool) { - TNode* node = nodes; - - once_more: - if (k < node->key) { - if (node->left) { - node = node->left; - goto once_more; - } else { - TNode* N = Alloc(k); - node->left = N; - return N; - } - } else if (k > node->key) { - if (node->right) { - node = node->right; - goto once_more; - } else { - TNode* N = Alloc(k); - node->right = N; - return N; - } - } else return node; - - } else { - return Alloc(k); - } - } - IC TNode* insertInAnyWay(const K& k) { - if (pool) { - TNode* node = nodes; - - once_more: - if (k <= node->key) { - if (node->left) { - node = node->left; - goto once_more; - } else { - TNode* N = Alloc(k); - node->left = N; - return N; - } - } else { - if (node->right) { - node = node->right; - goto once_more; - } else { - TNode* N = Alloc(k); - node->right = N; - return N; - } - } - } else { - return Alloc(k); - } - } - IC void clear() { pool=0; } - IC TNode* begin() { return nodes; } - IC TNode* end() { return nodes+pool; } - IC TNode* last() { return nodes+limit; } // for setup only - IC TNode* size() { return pool; } - IC TNode& operator[] (int v) { return nodes[v]; } - - IC void traverseLR (callback CB) - { if (pool) recurseLR(nodes,CB); } - IC void traverseRL (callback CB) - { if (pool) recurseRL(nodes,CB); } - IC void traverseANY (callback CB) { - TNode* _end = end(); - for (TNode* cur = begin(); cur!=_end; cur++) - CB(cur); - } - IC void setup(callback CB) { - for (int i=0; ikey) + { + if (node->left) + { + node = node->left; + goto once_more; + } + else + { + TNode*N = Alloc(k, v); + node->left = N; + return N; + } + } + else if (k>node->key) + { + if (node->right) + { + node = node->right; + goto once_more; + } + else + { + TNode*N = Alloc(k, v); + node->right = N; + return N; + } + } + else + return node; + } + else + { + return Alloc(k, v); + } + } + + IC TNode*insertInAnyWay(const K &k, const T &v) + { + if (pool) + { + TNode*node = nodes; + + once_more: + if (k<=node->key) + { + VERIFY(node->val!=v); + if (node->left) + { + node = node->left; + goto once_more; + } + else + { + TNode*N = Alloc(k, v); + node->left = N; + return N; + } + } + else + { + if (node->right) + { + node = node->right; + goto once_more; + } + else + { + TNode*N = Alloc(k, v); + node->right = N; + return N; + } + } + } + else + { + return Alloc(k, v); + } + } + + IC TNode*insert(const K &k) + { + if (pool) + { + TNode*node = nodes; + + once_more: + if (kkey) + { + if (node->left) + { + node = node->left; + goto once_more; + } + else + { + TNode*N = Alloc(k); + node->left = N; + return N; + } + } + else if (k>node->key) + { + if (node->right) + { + node = node->right; + goto once_more; + } + else + { + TNode*N = Alloc(k); + node->right = N; + return N; + } + } + else + return node; + } + else + { + return Alloc(k); + } + } + + IC TNode*insertInAnyWay(const K &k) + { + if (pool) + { + TNode*node = nodes; + + once_more: + if (k<=node->key) + { + if (node->left) + { + node = node->left; + goto once_more; + } + else + { + TNode*N = Alloc(k); + node->left = N; + return N; + } + } + else + { + if (node->right) + { + node = node->right; + goto once_more; + } + else + { + TNode*N = Alloc(k); + node->right = N; + return N; + } + } + } + else + { + return Alloc(k); + } + } + + IC + + void clear() + { + pool = 0; + } + + IC TNode*begin() + { + return nodes; + } + + IC TNode*end() + { + return nodes+pool; + } + + IC TNode*last() + { + return nodes+limit; + } // for setup only + IC TNode*size() + { + return pool; + } + + IC TNode&operator[](int v) + { + return nodes[v]; + } + + IC + + void traverseLR(callback CB) + { + if (pool) + recurseLR(nodes, CB); + } + + IC + + void traverseRL(callback CB) + { + if (pool) + recurseRL(nodes, CB); + } + + IC + + void traverseANY(callback CB) + { + TNode*_end = end(); + for (TNode*cur = begin(); cur!=_end; cur++) + CB(cur); + } + + IC + + void setup(callback CB) + { + for (int i = 0; i=0)link[id].push_back(i0); if (i1>=0)link[id].push_back(i1);} - IC void ConsolidateLink(){ - std::sort(link[0].begin(),link[0].end()); - std::sort(link[1].begin(),link[1].end()); - std::set_intersection( link[0].begin(),link[0].end(), - link[1].begin(),link[1].end(), - inserter(ulink,ulink.begin())); + + SVertex(const Fvector &v) + { + set(v); + portal = -1; + } + + IC + + void SetLink(int id, int i0, int i1) + { + if (i0>=0) + link[id].push_back(i0); + if (i1>=0) + link[id].push_back(i1); + } + + IC + + void ConsolidateLink() + { + std::sort(link[0].begin(), link[0].end()); + std::sort(link[1].begin(), link[1].end()); + std::set_intersection(link[0].begin(), link[0].end(), + link[1].begin(), link[1].end(), + inserter(ulink, ulink.begin())); VERIFY(ulink.size()<=2); } }; -DEFINE_VECTOR(SVertex,SVertexVec,SVertexIt) +DEFINE_VECTOR(SVertex, SVertexVec, SVertexIt) -class CPortalUtils{ -// void FindSVertexLinks(int id, CSector* S, SVertexVec& V); - int CalculateSelectedPortals(ObjectList& sectors); +class CPortalUtils +{ + // void FindSVertexLinks(int id, CSector* S, SVertexVec& V); + int CalculateSelectedPortals(ObjectList §ors); public: - bool CalculateConvexHull(FvectorVec& points); - int CalculatePortals(CSector* SF, CSector* SB); - int CalculateSelectedPortals(); - int CalculateAllPortals(); -//. int CalculateAllPortals2(); - void RemoveAllPortals(); - void RemoveSectorPortal(CSector* S); - bool CreateDefaultSector(); - bool RemoveDefaultSector(); - - CSector* FindSector(CSceneObject* o, CEditableMesh* m); - -// void CreateDebugCollection(); + bool CalculateConvexHull(FvectorVec &points); + int CalculatePortals(CSector *SF, CSector *SB); + int CalculateSelectedPortals(); + int CalculateAllPortals(); + //. int CalculateAllPortals2(); + void RemoveAllPortals(); + void RemoveSectorPortal(CSector *S); + bool CreateDefaultSector(); + bool RemoveDefaultSector(); + + CSector *FindSector(CSceneObject *o, CEditableMesh *m); + + // void CreateDebugCollection(); bool Validate(bool bMsg); - CSector* GetSelectedSector(); + CSector *GetSelectedSector(); }; extern CPortalUtils PortalUtils; #endif /*_INCDEF_PortalUtils_H_*/ + diff --git a/src/editors/LevelEditor/Engine/ShapeData.h b/src/editors/LevelEditor/Engine/ShapeData.h index fccd26da0fc..1b957849557 100644 --- a/src/editors/LevelEditor/Engine/ShapeData.h +++ b/src/editors/LevelEditor/Engine/ShapeData.h @@ -3,22 +3,27 @@ struct CShapeData { - enum{ - cfSphere=0, + enum + { + cfSphere=0, cfBox }; - union shape_data - { - Fsphere sphere; - Fmatrix box; - }; - struct shape_def - { - u8 type; - shape_data data; - }; - DEFINE_VECTOR (shape_def,ShapeVec,ShapeIt); - ShapeVec shapes; + + union shape_data + { + Fsphere sphere; + Fmatrix box; + }; + + struct shape_def + { + u8 type; + shape_data data; + }; + + DEFINE_VECTOR(shape_def, ShapeVec, ShapeIt); + ShapeVec shapes; }; -#endif \ No newline at end of file +#endif + diff --git a/src/editors/LevelEditor/Engine/communicate.h b/src/editors/LevelEditor/Engine/communicate.h index 8e4f3eb362c..a27bb7dffa2 100644 --- a/src/editors/LevelEditor/Engine/communicate.h +++ b/src/editors/LevelEditor/Engine/communicate.h @@ -5,237 +5,241 @@ #pragma pack(push,4) -const u32 XR_MAX_PORTAL_VERTS = 6; +const u32 XR_MAX_PORTAL_VERTS = 6; // internal use struct b_rc_face { - u16 dwMaterial; - u32 dwMaterialGame; - Fvector2 t[3]; // TC - u16 reserved; + u16 dwMaterial; + u32 dwMaterialGame; + Fvector2 t[3]; // TC + u16 reserved; }; + // All types to interact with xrLC -typedef Fvector b_vertex; +typedef Fvector b_vertex; struct b_face { - u32 v[3]; // vertices - Fvector2 t[3]; // TC - u16 dwMaterial; // index of material - u32 dwMaterialGame; // unique-ID of game material + u32 v[3]; // vertices + Fvector2 t[3]; // TC + u16 dwMaterial; // index of material + u32 dwMaterialGame; // unique-ID of game material }; struct b_material { - u16 surfidx; // indices of texture surface - u16 shader; // index of shader that combine them - u16 shader_xrlc; // compiler options - u16 sector; // *** - u16 reserved; // - u32 internal_max_area; // + u16 surfidx; // indices of texture surface + u16 shader; // index of shader that combine them + u16 shader_xrlc; // compiler options + u16 sector; // *** + u16 reserved; // + u32 internal_max_area; // }; struct b_shader { - string128 name; + string128 name; }; struct b_texture { - string128 name; - u32 dwWidth; - u32 dwHeight; - BOOL bHasAlpha; - u32* pSurface; + string128 name; + u32 dwWidth; + u32 dwHeight; + BOOL bHasAlpha; + u32 *pSurface; }; -struct b_light_control // controller or "layer", 30fps +struct b_light_control // controller or "layer", 30fps { - string64 name; // empty for base layer - u32 count; // 0 for base layer - // u32 data[]; + string64 name; // empty for base layer + u32 count; // 0 for base layer + // u32 data[]; }; struct b_light { - u32 controller_ID; // 0 = base layer - Flight data; + u32 controller_ID; // 0 = base layer + Flight data; }; -struct b_light_static : public b_light // For static lighting -{ -}; +struct b_light_static : public b_light // For static lighting +{}; -struct b_light_dynamic : public b_light // For dynamic models +struct b_light_dynamic : public b_light // For dynamic models { - svector sectors; + svector sectors; }; struct b_glow { - Fvector P; - float size; - u32 flags; // 0x01 = non scalable - u32 dwMaterial; // index of material + Fvector P; + float size; + u32 flags; // 0x01 = non scalable + u32 dwMaterial; // index of material }; struct b_portal { - u16 sector_front; - u16 sector_back; - svector vertices; + u16 sector_front; + u16 sector_back; + svector vertices; }; struct b_lod_face { - Fvector v [4]; - Fvector2 t [4]; + Fvector v [4]; + Fvector2 t [4]; }; struct b_lod { - b_lod_face faces [8]; - u32 dwMaterial; + b_lod_face faces [8]; + u32 dwMaterial; }; /* - u32 NUMBER-OF-OBJECTS - - stringZ name - u32 vert_count - b_vertex vertices[] - u32 face_count - b_faces faces[] - u16 lod_id; // u16(-1) = no lod, just static geometry + u32 NUMBER-OF-OBJECTS + + stringZ name + u32 vert_count + b_vertex vertices[] + u32 face_count + b_faces faces[] + u16 lod_id; // u16(-1) = no lod, just static geometry */ struct b_mu_model { - string128 name; - int m_iVertexCount; - b_vertex* m_pVertices; - int m_iFaceCount; - b_face* m_pFaces; - u32* m_smgroups; - u16 lod_id; // u16(-1) = no lod, just static geometry + string128 name; + int m_iVertexCount; + b_vertex *m_pVertices; + int m_iFaceCount; + b_face *m_pFaces; + u32 *m_smgroups; + u16 lod_id; // u16(-1) = no lod, just static geometry }; /* - self-describing + self-describing */ struct b_mu_reference { - u32 model_index; - Fmatrix transform; - Flags32 flags; - u16 sector; - u32 reserved [8]; + u32 model_index; + Fmatrix transform; + Flags32 flags; + u16 sector; + u32 reserved [8]; }; struct b_params { - // Normals & optimization - float m_sm_angle; // normal smooth angle - 89.0 - float m_weld_distance; // by default 0.005f - 5mm + // Normals & optimization + float m_sm_angle; // normal smooth angle - 89.0 + float m_weld_distance; // by default 0.005f - 5mm - // Light maps - float m_lm_pixels_per_meter; // LM - by default: 4 ppm - u32 m_lm_jitter_samples; // 1/4/9 - by default - 4 - u32 m_lm_rms_zero; // RMS - after what the lightmap will be shrinked to ZERO pixels - u32 m_lm_rms; // RMS - shrink and recalc + // Light maps + float m_lm_pixels_per_meter; // LM - by default: 4 ppm + u32 m_lm_jitter_samples; // 1/4/9 - by default - 4 + u32 m_lm_rms_zero; // RMS - after what the lightmap will be shrinked to ZERO pixels + u32 m_lm_rms; // RMS - shrink and recalc // build quality - u16 m_quality; - u16 u_reserved; + u16 m_quality; + u16 u_reserved; - // Progressive - float f_reserved[6]; + // Progressive + float f_reserved[6]; - void SaveLTX(CInifile& ini) + void SaveLTX(CInifile &ini) { - LPCSTR section = "build_params"; - ini.w_float (section,"smooth_angle",m_sm_angle); - ini.w_float (section,"weld_distance",m_weld_distance); - ini.w_float (section,"light_pixel_per_meter",m_lm_pixels_per_meter); - ini.w_u32 (section,"light_jitter_samples",m_lm_jitter_samples); - ini.w_u32 (section,"light_rms_zero",m_lm_rms_zero); - ini.w_u32 (section,"light_rms",m_lm_rms); - ini.w_u16 (section,"light_quality",m_quality); - ini.w_u16 (section,"light_quality_reserved",u_reserved); - for(u32 i=0; i<6; ++i) + LPCSTR section = "build_params"; + ini.w_float(section, "smooth_angle", m_sm_angle); + ini.w_float(section, "weld_distance", m_weld_distance); + ini.w_float(section, "light_pixel_per_meter", m_lm_pixels_per_meter); + ini.w_u32(section, "light_jitter_samples", m_lm_jitter_samples); + ini.w_u32(section, "light_rms_zero", m_lm_rms_zero); + ini.w_u32(section, "light_rms", m_lm_rms); + ini.w_u16(section, "light_quality", m_quality); + ini.w_u16(section, "light_quality_reserved", u_reserved); + for (u32 i = 0; i<6; ++i) { - string128 buff; - xr_sprintf (buff, sizeof(buff), "reserved_%d",i); - ini.w_float (section, buff, f_reserved[i]); + string128 buff; + xr_sprintf(buff, sizeof(buff), "reserved_%d", i); + ini.w_float(section, buff, f_reserved[i]); } } - void LoadLTX(CInifile& ini) + + void LoadLTX(CInifile &ini) { - LPCSTR section = "build_params"; - m_sm_angle = ini.r_float (section,"smooth_angle"); - m_weld_distance = ini.r_float (section,"weld_distance"); - m_lm_pixels_per_meter = ini.r_float (section,"light_pixel_per_meter"); - m_lm_jitter_samples = ini.r_u32 (section,"light_jitter_samples"); - m_lm_rms_zero = ini.r_u32 (section,"light_rms_zero"); - m_lm_rms = ini.r_u32 (section,"light_rms"); - m_quality = ini.r_u16 (section,"light_quality"); - u_reserved = ini.r_u16 (section,"light_quality_reserved"); - for(u32 i=0; i<6; ++i) + LPCSTR section = "build_params"; + m_sm_angle = ini.r_float(section, "smooth_angle"); + m_weld_distance = ini.r_float(section, "weld_distance"); + m_lm_pixels_per_meter = ini.r_float(section, "light_pixel_per_meter"); + m_lm_jitter_samples = ini.r_u32(section, "light_jitter_samples"); + m_lm_rms_zero = ini.r_u32(section, "light_rms_zero"); + m_lm_rms = ini.r_u32(section, "light_rms"); + m_quality = ini.r_u16(section, "light_quality"); + u_reserved = ini.r_u16(section, "light_quality_reserved"); + for (u32 i = 0; i<6; ++i) { - string128 buff; - xr_sprintf (buff, sizeof(buff), "reserved_%d",i); - f_reserved[i] = ini.r_float (section,buff); + string128 buff; + xr_sprintf(buff, sizeof(buff), "reserved_%d", i); + f_reserved[i] = ini.r_float(section, buff); } } - void Init () - { + void Init() + { // Normals & optimization - m_sm_angle = 75.f; - m_weld_distance = 0.005f; + m_sm_angle = 75.f; + m_weld_distance = 0.005f; // Light maps - m_lm_rms_zero = 4; - m_lm_rms = 4; - - setHighQuality (); - } - void setDraftQuality() - { - m_quality = ebqDraft; - m_lm_pixels_per_meter = 0.1f; - m_lm_jitter_samples = 1; - } - void setHighQuality() - { - m_quality = ebqHigh; - m_lm_pixels_per_meter = 10; - m_lm_jitter_samples = 9; - } + m_lm_rms_zero = 4; + m_lm_rms = 4; + + setHighQuality(); + } + + void setDraftQuality() + { + m_quality = ebqDraft; + m_lm_pixels_per_meter = 0.1f; + m_lm_jitter_samples = 1; + } + + void setHighQuality() + { + m_quality = ebqHigh; + m_lm_pixels_per_meter = 10; + m_lm_jitter_samples = 9; + } }; #pragma pack(pop) enum EBUILD_CHUNKS { - EB_Version = 0, // XRCLC_CURRENT_VERSION - EB_Parameters, - EB_Vertices, - EB_Faces, - EB_Materials, - EB_Shaders_Render, - EB_Shaders_Compile, - EB_Textures, - EB_Glows, - EB_Portals, - EB_Light_control, - EB_Light_static, - EB_Light_dynamic, - EB_LOD_models, + EB_Version = 0, // XRCLC_CURRENT_VERSION + EB_Parameters, + EB_Vertices, + EB_Faces, + EB_Materials, + EB_Shaders_Render, + EB_Shaders_Compile, + EB_Textures, + EB_Glows, + EB_Portals, + EB_Light_control, + EB_Light_static, + EB_Light_dynamic, + EB_LOD_models, EB_MU_models, EB_MU_refs, EB_SmoothGroups, - EB_FORCE_DWORD = u32(-1) + EB_FORCE_DWORD = u32(-1) }; #endif + diff --git a/src/editors/LevelEditor/FrameAIMap.h b/src/editors/LevelEditor/FrameAIMap.h index 8a63ed93806..91a25511f9d 100644 --- a/src/editors/LevelEditor/FrameAIMap.h +++ b/src/editors/LevelEditor/FrameAIMap.h @@ -20,58 +20,61 @@ // refs class CEditObject; class ESceneAIMapTool; + //--------------------------------------------------------------------------- class TfraAIMap : public TForm { -__published: // IDE-managed Components - TFormStorage *fsStorage; - TPanel *paObjectList; - TLabel *Label2; - TExtBtn *ExtBtn2; - TPanel *paLink; - TLabel *Label3; - TExtBtn *ExtBtn4; - TExtBtn *ebGenerateMap; - TExtBtn *ebModeAppend; - TExtBtn *ebModeRemove; - TExtBtn *ebUp; - TExtBtn *ebDown; - TExtBtn *ebLeft; - TExtBtn *ebRight; - TExtBtn *ebFull; - TExtBtn *ebModeInvert; - TExtBtn *ebSmoothNodes; - TLabel *Label5; - TExtBtn *ebIgnoreConstraints; - TExtBtn *ebAutoLink; - TBevel *Bevel2; - TExtBtn *ExtBtn1; - TExtBtn *ExtBtn5; - TExtBtn *ExtBtn3; - TExtBtn *ExtBtn6; - TExtBtn *ebGenerateSelected; - TExtBtn *ebResetSelected; - TExtBtn *btnIgnoreMaterialClear; - TListBox *lbIgnoreMaterialsList; - TLabel *Label1; - TExtBtn *btnAddIgnoredMaterial; + __published: // IDE-managed Components + TFormStorage*fsStorage; + TPanel *paObjectList; + TLabel *Label2; + TExtBtn *ExtBtn2; + TPanel *paLink; + TLabel *Label3; + TExtBtn *ExtBtn4; + TExtBtn *ebGenerateMap; + TExtBtn *ebModeAppend; + TExtBtn *ebModeRemove; + TExtBtn *ebUp; + TExtBtn *ebDown; + TExtBtn *ebLeft; + TExtBtn *ebRight; + TExtBtn *ebFull; + TExtBtn *ebModeInvert; + TExtBtn *ebSmoothNodes; + TLabel *Label5; + TExtBtn *ebIgnoreConstraints; + TExtBtn *ebAutoLink; + TBevel *Bevel2; + TExtBtn *ExtBtn1; + TExtBtn *ExtBtn5; + TExtBtn *ExtBtn3; + TExtBtn *ExtBtn6; + TExtBtn *ebGenerateSelected; + TExtBtn *ebResetSelected; + TExtBtn *btnIgnoreMaterialClear; + TListBox *lbIgnoreMaterialsList; + TLabel *Label1; + TExtBtn *btnAddIgnoredMaterial; void __fastcall PanelMinClick(TObject *Sender); void __fastcall ExpandClick(TObject *Sender); - void __fastcall ebGenerateMapClick(TObject *Sender); - void __fastcall ebDrawSnapObjectsClick(TObject *Sender); - void __fastcall ebInvertLinkClick(TObject *Sender); - void __fastcall ebSideClick(TObject *Sender); - void __fastcall ebSmoothNodesClick(TObject *Sender); - void __fastcall ebSelLinkClick(TObject *Sender); - void __fastcall ExtBtn6Click(TObject *Sender); - void __fastcall ebGenerateSelectedClick(TObject *Sender); - void __fastcall ebResetSelectedClick(TObject *Sender); - void __fastcall btnAddIgnoredMaterialClick(TObject *Sender); - void __fastcall btnIgnoreMaterialClearClick(TObject *Sender); -private: // User declarations - ESceneAIMapTool* tools; -public: // User declarations - __fastcall TfraAIMap(TComponent* Owner, ESceneAIMapTool* _tools); + void __fastcall ebGenerateMapClick(TObject *Sender); + void __fastcall ebDrawSnapObjectsClick(TObject *Sender); + void __fastcall ebInvertLinkClick(TObject *Sender); + void __fastcall ebSideClick(TObject *Sender); + void __fastcall ebSmoothNodesClick(TObject *Sender); + void __fastcall ebSelLinkClick(TObject *Sender); + void __fastcall ExtBtn6Click(TObject *Sender); + void __fastcall ebGenerateSelectedClick(TObject *Sender); + void __fastcall ebResetSelectedClick(TObject *Sender); + void __fastcall btnAddIgnoredMaterialClick(TObject *Sender); + void __fastcall btnIgnoreMaterialClearClick(TObject *Sender); +private: // User declarations + ESceneAIMapTool *tools; +public: // User declarations + __fastcall TfraAIMap(TComponent *Owner, ESceneAIMapTool *_tools); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FrameDetObj.h b/src/editors/LevelEditor/FrameDetObj.h index 0df1c5722b9..9e119a390e5 100644 --- a/src/editors/LevelEditor/FrameDetObj.h +++ b/src/editors/LevelEditor/FrameDetObj.h @@ -17,39 +17,42 @@ // refs struct SDOClusterDef; class EDetailManager; + //--------------------------------------------------------------------------- class TfraDetailObject : public TForm { -__published: // IDE-managed Components - TFormStorage *fsStorage; - TPanel *paCommand; - TLabel *Label1; - TExtBtn *ExtBtn3; - TExtBtn *ExtBtn1; - TExtBtn *ExtBtn6; - TExtBtn *ExtBtn4; - TExtBtn *ebResetSlots; - TExtBtn *ExtBtn7; - TExtBtn *ebClearDetails; - TBevel *Bevel3; - TBevel *Bevel4; - TExtBtn *ExtBtn5; - TBevel *Bevel1; - TExtBtn *ebReinitializeSlotObjects; + __published: // IDE-managed Components + TFormStorage*fsStorage; + TPanel *paCommand; + TLabel *Label1; + TExtBtn *ExtBtn3; + TExtBtn *ExtBtn1; + TExtBtn *ExtBtn6; + TExtBtn *ExtBtn4; + TExtBtn *ebResetSlots; + TExtBtn *ExtBtn7; + TExtBtn *ebClearDetails; + TBevel *Bevel3; + TBevel *Bevel4; + TExtBtn *ExtBtn5; + TBevel *Bevel1; + TExtBtn *ebReinitializeSlotObjects; void __fastcall PaneMinClick(TObject *Sender); void __fastcall ExpandClick(TObject *Sender); - void __fastcall ExtBtn1Click(TObject *Sender); - void __fastcall ExtBtn5Click(TObject *Sender); - void __fastcall ebUpdateObjectsClick(TObject *Sender); - void __fastcall ebReinitializeSlotObjectsClick(TObject *Sender); - void __fastcall ExtBtn6Click(TObject *Sender); - void __fastcall ebInvalidateCacheClick(TObject *Sender); - void __fastcall ebResetSlotsClick(TObject *Sender); - void __fastcall ebClearDetailsClick(TObject *Sender); -private: // User declarations - EDetailManager* DM; -public: // User declarations - __fastcall TfraDetailObject(TComponent* Owner, EDetailManager* dm_tools); + void __fastcall ExtBtn1Click(TObject *Sender); + void __fastcall ExtBtn5Click(TObject *Sender); + void __fastcall ebUpdateObjectsClick(TObject *Sender); + void __fastcall ebReinitializeSlotObjectsClick(TObject *Sender); + void __fastcall ExtBtn6Click(TObject *Sender); + void __fastcall ebInvalidateCacheClick(TObject *Sender); + void __fastcall ebResetSlotsClick(TObject *Sender); + void __fastcall ebClearDetailsClick(TObject *Sender); +private: // User declarations + EDetailManager *DM; +public: // User declarations + __fastcall TfraDetailObject(TComponent *Owner, EDetailManager *dm_tools); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FrameLight.h b/src/editors/LevelEditor/FrameLight.h index 34f4a126038..5de590a8673 100644 --- a/src/editors/LevelEditor/FrameLight.h +++ b/src/editors/LevelEditor/FrameLight.h @@ -13,27 +13,30 @@ #include "ExtBtn.hpp" // refs class CEditObject; + //--------------------------------------------------------------------------- class TfraLight : public TForm { -__published: // IDE-managed Components - TPanel *paCommands; - TExtBtn *ebUseSelInD3D; - TLabel *APHeadLabel1; - TExtBtn *ExtBtn2; - TExtBtn *ebUnuseSelInD3D; - TExtBtn *ebUseAllInD3D; - TExtBtn *ebUnuseAllInD3D; + __published: // IDE-managed Components + TPanel*paCommands; + TExtBtn *ebUseSelInD3D; + TLabel *APHeadLabel1; + TExtBtn *ExtBtn2; + TExtBtn *ebUnuseSelInD3D; + TExtBtn *ebUseAllInD3D; + TExtBtn *ebUnuseAllInD3D; void __fastcall PaneMinClick(TObject *Sender); void __fastcall ExpandClick(TObject *Sender); - void __fastcall ebUseSelInD3DClick(TObject *Sender); - void __fastcall ebUnuseSelInD3DClick(TObject *Sender); - void __fastcall ebUseAllInD3DClick(TObject *Sender); - void __fastcall ebUnuseAllInD3DClick(TObject *Sender); -private: // User declarations + void __fastcall ebUseSelInD3DClick(TObject *Sender); + void __fastcall ebUnuseSelInD3DClick(TObject *Sender); + void __fastcall ebUseAllInD3DClick(TObject *Sender); + void __fastcall ebUnuseAllInD3DClick(TObject *Sender); +private: // User declarations void UseInD3D(bool bAll, bool bFlag); -public: // User declarations - __fastcall TfraLight(TComponent* Owner); +public: // User declarations + __fastcall TfraLight(TComponent *Owner); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FramePortal.h b/src/editors/LevelEditor/FramePortal.h index 86ac00b5797..2026481bed3 100644 --- a/src/editors/LevelEditor/FramePortal.h +++ b/src/editors/LevelEditor/FramePortal.h @@ -16,28 +16,31 @@ //refs class CSector; class EScenePortalTool; + //--------------------------------------------------------------------------- class TfraPortal : public TForm { -__published: // IDE-managed Components - TPanel *paCommands; - TLabel *APHeadLabel1; - TExtBtn *ExtBtn2; - TExtBtn *ebInvertOrient; - TExtBtn *ebComputeAllPortals; - TExtBtn *ebComputeSelPortals; - TFormStorage *fsStorage; - TExtBtn *ExtBtn1; + __published: // IDE-managed Components + TPanel*paCommands; + TLabel *APHeadLabel1; + TExtBtn *ExtBtn2; + TExtBtn *ebInvertOrient; + TExtBtn *ebComputeAllPortals; + TExtBtn *ebComputeSelPortals; + TFormStorage *fsStorage; + TExtBtn *ExtBtn1; void __fastcall PanelMinClick(TObject *Sender); void __fastcall TopClick(TObject *Sender); - void __fastcall ebComputeClick(TObject *Sender); - void __fastcall ebComputeAllPortalsClick(TObject *Sender); - void __fastcall ebInvertOrientClick(TObject *Sender); - void __fastcall ExtBtn1Click(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TfraPortal(TComponent* Owner); - EScenePortalTool* tool; + void __fastcall ebComputeClick(TObject *Sender); + void __fastcall ebComputeAllPortalsClick(TObject *Sender); + void __fastcall ebInvertOrientClick(TObject *Sender); + void __fastcall ExtBtn1Click(TObject *Sender); +private: // User declarations +public: // User declarations + __fastcall TfraPortal(TComponent *Owner); + EScenePortalTool *tool; }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FrameSector.h b/src/editors/LevelEditor/FrameSector.h index 3064bc7e3ba..9b9d9719298 100644 --- a/src/editors/LevelEditor/FrameSector.h +++ b/src/editors/LevelEditor/FrameSector.h @@ -14,41 +14,44 @@ #include "MXCtrls.hpp" #include "ESceneCustomMTools.h" #include "mxPlacemnt.hpp" + //--------------------------------------------------------------------------- class TfraSector : public TForm { -__published: // IDE-managed Components - TPanel *paSectorActions; - TExtBtn *ebAddMesh; - TExtBtn *ebDelMesh; - TExtBtn *ebBoxPick; - TLabel *RxLabel1; - TPanel *paCommands; - TExtBtn *ebValidate; - TLabel *APHeadLabel1; - TExtBtn *ExtBtn2; - TLabel *APHeadLabel2; - TExtBtn *ExtBtn1; - TExtBtn *ebCreateNewSingle; - TBevel *Bevel1; - TExtBtn *ebCaptureInside; - TExtBtn *ebCreateDefault; - TExtBtn *ebRemoveDefault; - TBevel *Bevel2; - TFormStorage *fsStorage; - TExtBtn *ebCreateNewMultiple; - TExtBtn *ebDistributeObjects; + __published: // IDE-managed Components + TPanel*paSectorActions; + TExtBtn *ebAddMesh; + TExtBtn *ebDelMesh; + TExtBtn *ebBoxPick; + TLabel *RxLabel1; + TPanel *paCommands; + TExtBtn *ebValidate; + TLabel *APHeadLabel1; + TExtBtn *ExtBtn2; + TLabel *APHeadLabel2; + TExtBtn *ExtBtn1; + TExtBtn *ebCreateNewSingle; + TBevel *Bevel1; + TExtBtn *ebCaptureInside; + TExtBtn *ebCreateDefault; + TExtBtn *ebRemoveDefault; + TBevel *Bevel2; + TFormStorage *fsStorage; + TExtBtn *ebCreateNewMultiple; + TExtBtn *ebDistributeObjects; void __fastcall PanelMinClick(TObject *Sender); void __fastcall TopClick(TObject *Sender); - void __fastcall ebCaptureInsideVolumeClick(TObject *Sender); - void __fastcall ebCreateDefaultClick(TObject *Sender); - void __fastcall ebRemoveDefaultClick(TObject *Sender); - void __fastcall ebValidateClick(TObject *Sender); - void __fastcall ebBoxPickClick(TObject *Sender); - void __fastcall ebDistributeObjectsClick(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TfraSector(TComponent* Owner); + void __fastcall ebCaptureInsideVolumeClick(TObject *Sender); + void __fastcall ebCreateDefaultClick(TObject *Sender); + void __fastcall ebRemoveDefaultClick(TObject *Sender); + void __fastcall ebValidateClick(TObject *Sender); + void __fastcall ebBoxPickClick(TObject *Sender); + void __fastcall ebDistributeObjectsClick(TObject *Sender); +private: // User declarations +public: // User declarations + __fastcall TfraSector(TComponent *Owner); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FrameShape.h b/src/editors/LevelEditor/FrameShape.h index 47ce9f88650..4a4b51e4475 100644 --- a/src/editors/LevelEditor/FrameShape.h +++ b/src/editors/LevelEditor/FrameShape.h @@ -17,35 +17,38 @@ // refs class CEditObject; class ESceneShapeTool; + //--------------------------------------------------------------------------- class TfraShape : public TForm { -__published: // IDE-managed Components - TPanel *paAppend; - TLabel *APHeadLabel1; - TExtBtn *ExtBtn2; - TFormStorage *fsStorage; - TExtBtn *ebTypeSphere; - TExtBtn *ebTypeBox; - TPanel *paEdit; - TLabel *Label1; - TExtBtn *ExtBtn3; - TExtBtn *ebAttachShape; - TExtBtn *ebDetachAllShapes; - TPanel *Panel1; - TExtBtn *ebEditLevelBoundMode; - TExtBtn *ebRecalcLB; + __published: // IDE-managed Components + TPanel*paAppend; + TLabel *APHeadLabel1; + TExtBtn *ExtBtn2; + TFormStorage *fsStorage; + TExtBtn *ebTypeSphere; + TExtBtn *ebTypeBox; + TPanel *paEdit; + TLabel *Label1; + TExtBtn *ExtBtn3; + TExtBtn *ebAttachShape; + TExtBtn *ebDetachAllShapes; + TPanel *Panel1; + TExtBtn *ebEditLevelBoundMode; + TExtBtn *ebRecalcLB; void __fastcall PaneMinClick(TObject *Sender); void __fastcall ExpandClick(TObject *Sender); - void __fastcall ebDetachAllShapesClick(TObject *Sender); - void __fastcall ebAttachShapeClick(TObject *Sender); - void __fastcall ebEditLevelBoundModeClick(TObject *Sender); - void __fastcall ebRecalcLBClick(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TfraShape(TComponent* Owner); - AnsiString GetCurrentEntity(BOOL bForceSelect=FALSE); - ESceneShapeTool* tool; + void __fastcall ebDetachAllShapesClick(TObject *Sender); + void __fastcall ebAttachShapeClick(TObject *Sender); + void __fastcall ebEditLevelBoundModeClick(TObject *Sender); + void __fastcall ebRecalcLBClick(TObject *Sender); +private: // User declarations +public: // User declarations + __fastcall TfraShape(TComponent *Owner); + AnsiString GetCurrentEntity(BOOL bForceSelect = FALSE); + ESceneShapeTool *tool; }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FrameWayPoint.h b/src/editors/LevelEditor/FrameWayPoint.h index 1d834b52124..28756830715 100644 --- a/src/editors/LevelEditor/FrameWayPoint.h +++ b/src/editors/LevelEditor/FrameWayPoint.h @@ -14,39 +14,42 @@ #include "ESceneCustomMTools.h" // refs class CEditObject; + //--------------------------------------------------------------------------- class TfraWayPoint : public TForm { -__published: // IDE-managed Components - TPanel *paCommands; - TLabel *APHeadLabel1; - TExtBtn *ExtBtn2; - TFormStorage *fsStorage; - TExtBtn *ebModeWay; - TPanel *paLink; - TLabel *Label1; - TExtBtn *ExtBtn3; - TExtBtn *ebInvertLink; - TExtBtn *ebAdd1Link; - TExtBtn *ebRemoveLinks; - TExtBtn *ebAdd2Link; - TExtBtn *ebModePoint; - TExtBtn *ebAutoLink; - TBevel *Bevel1; - TExtBtn *ebConvert1; - TExtBtn *ebConvert2; + __published: // IDE-managed Components + TPanel*paCommands; + TLabel *APHeadLabel1; + TExtBtn *ExtBtn2; + TFormStorage *fsStorage; + TExtBtn *ebModeWay; + TPanel *paLink; + TLabel *Label1; + TExtBtn *ExtBtn3; + TExtBtn *ebInvertLink; + TExtBtn *ebAdd1Link; + TExtBtn *ebRemoveLinks; + TExtBtn *ebAdd2Link; + TExtBtn *ebModePoint; + TExtBtn *ebAutoLink; + TBevel *Bevel1; + TExtBtn *ebConvert1; + TExtBtn *ebConvert2; void __fastcall PanelMinClick(TObject *Sender); void __fastcall ExpandClick(TObject *Sender); - void __fastcall ebAdd1LinksClick(TObject *Sender); - void __fastcall ebRemoveLinksClick(TObject *Sender); - void __fastcall ebAdd2LinkClick(TObject *Sender); - void __fastcall ebInvertLinkClick(TObject *Sender); - void __fastcall ebModeWayClick(TObject *Sender); - void __fastcall ebConvert1Click(TObject *Sender); - void __fastcall ebConvert2Click(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TfraWayPoint(TComponent* Owner); + void __fastcall ebAdd1LinksClick(TObject *Sender); + void __fastcall ebRemoveLinksClick(TObject *Sender); + void __fastcall ebAdd2LinkClick(TObject *Sender); + void __fastcall ebInvertLinkClick(TObject *Sender); + void __fastcall ebModeWayClick(TObject *Sender); + void __fastcall ebConvert1Click(TObject *Sender); + void __fastcall ebConvert2Click(TObject *Sender); +private: // User declarations +public: // User declarations + __fastcall TfraWayPoint(TComponent *Owner); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/LeftBar.h b/src/editors/LevelEditor/LeftBar.h index 643617697d9..209ca56543d 100644 --- a/src/editors/LevelEditor/LeftBar.h +++ b/src/editors/LevelEditor/LeftBar.h @@ -14,202 +14,203 @@ #include #include "ESceneClassList.h" + //--------------------------------------------------------------------------- class TfraLeftBar : public TFrame { -__published: // IDE-managed Components - TPanel *paLeftBar; + __published: // IDE-managed Components + TPanel*paLeftBar; TPanel *paScene; TPanel *paEdit; TPanel *paTarget; - TExtBtn *ebTargetObject; - TExtBtn *ebTargetLight; - TExtBtn *ebTargetSoundSrc; - TExtBtn *ebTargetSoundEnv; + TExtBtn *ebTargetObject; + TExtBtn *ebTargetLight; + TExtBtn *ebTargetSoundSrc; + TExtBtn *ebTargetSoundEnv; TPanel *paFrames; - TFormStorage *fsStorage; + TFormStorage *fsStorage; TExtBtn *ebTargetGlow; - TExtBtn *ebTargetSpawnPoint; - TExtBtn *ebTargetWay; - TExtBtn *ebTargetSector; - TExtBtn *ebTargetPortal; - TLabel *APHeadLabel2; - TExtBtn *sbSceneMin; - TLabel *lbTools; - TLabel *lbEditMode; - TExtBtn *sbEditMin; - TExtBtn *sbTargetMin; - TExtBtn *ebTargetGroup; - TExtBtn *ebSceneFile; - TExtBtn *ebScene; - TExtBtn *ebObjectList; - TExtBtn *ebPreferences; - TExtBtn *ExtBtn7; - TExtBtn *ExtBtn8; - TExtBtn *ExtBtn10; - TMxPopupMenu *pmSceneFile; - TMenuItem *Clear1; - TMenuItem *miOpen; - TMenuItem *Save1; - TMenuItem *SaveAs1; - TMxPopupMenu *pmScene; - TMenuItem *Options1; - TMenuItem *Validate1; - TMxPopupMenu *pmToolsEdit; - TMxPopupMenu *pmToolsSelection; - TMxPopupMenu *pmToolsVisibility; - TMenuItem *Cut1; - TMenuItem *Copy1; - TMenuItem *miPaste; - TMenuItem *Undo1; - TMenuItem *Redo1; - TMenuItem *Delete1; - TMenuItem *Invert1; - TMenuItem *SelectAll1; - TMenuItem *UnselectAll1; - TMenuItem *HideAll1; - TMenuItem *HideSelected1; - TMenuItem *N1; - TMenuItem *HideUnselected1; - TMenuItem *UnhideAll1; - TExtBtn *ebTargetPS; - TPanel *paSnapList; - TLabel *Label1; - TExtBtn *ExtBtn16; - TExtBtn *ebUseSnapList; - TExtBtn *ExtBtn1; - TMxPopupMenu *pmSnapListCommand; - TMenuItem *MenuItem3; - TMenuItem *MenuItem4; - TListBox *lbSnapList; - TBevel *Bevel1; - TMenuItem *miAddSelectedToList; - TExtBtn *ebTargetShape; - TMxPopupMenu *pmObjectContext; - TMenuItem *miVisibility; - TMenuItem *HideSelected2; - TMenuItem *HideUnselected2; - TMenuItem *HideAll2; - TMenuItem *N5; - TMenuItem *UnhideAll2; - TMenuItem *Locking1; - TMenuItem *LockSelected1; - TMenuItem *MenuItem1; - TMenuItem *MenuItem2; - TMenuItem *N6; - TMenuItem *MenuItem5; - TMenuItem *MenuItem6; - TMenuItem *MenuItem7; - TMenuItem *Edit1; - TMenuItem *miCopy; - TMenuItem *miPaste2; - TMenuItem *miCut; - TMenuItem *N4; - TMenuItem *miProperties; - TMenuItem *N3; - TMenuItem *miRecentFiles; - TMenuItem *Quit1; - TExtBtn *ebProperties; - TExtBtn *ebLightAnimationEditor; - TExtBtn *ebImages; - TMenuItem *N8; - TMenuItem *N12; - TMenuItem *N13; - TMenuItem *N15; - TMenuItem *N17; - TMenuItem *N18; - TMenuItem *N19; - TMenuItem *N20; - TExtBtn *ebTargetDO; - TMenuItem *N22; - TMenuItem *miSceneSummary; - TExtBtn *ebSounds; - TExtBtn *ExtBtn2; - TExtBtn *ebTargetAIMap; - TExtBtn *ebCompile; - TMxPopupMenu *pmCompile; - TMenuItem *MenuItem19; - TMenuItem *MenuItem23; - TMenuItem *MenuItem24; - TMenuItem *MenuItem25; - TMenuItem *MenuItem26; - TMenuItem *MenuItem27; - TMenuItem *MenuItem29; - TMenuItem *MenuItem32; - TMenuItem *MenuItem33; - TMenuItem *MenuItem34; - TMxPopupMenu *pmObjects; - TMenuItem *MenuItem13; - TMenuItem *MenuItem16; - TMenuItem *MenuItem17; - TMenuItem *ReloadObjects1; - TMenuItem *CleanLibrary; - TMxPopupMenu *pmImages; - TMenuItem *N11; - TMenuItem *ImageEditor1; - TMenuItem *MenuItem8; - TMenuItem *UpdateSceneTextures1; - TMenuItem *N10; - TMenuItem *MenuItem9; - TMenuItem *MenuItem10; - TMxPopupMenu *pmSounds; - TMenuItem *MenuItem11; - TMenuItem *MenuItem12; - TMenuItem *MenuItem15; - TMenuItem *MenuItem14; - TMenuItem *UpdateEnvironmentGeometry1; - TMenuItem *RemoveSelectedFromList1; - TMenuItem *SelectObjectFromList1; - TMenuItem *N9; - TMenuItem *N14; - TExtBtn *ebSnapListMode; - TExtBtn *ebModeInvert; - TBevel *Bevel2; - TMenuItem *N21; - TMenuItem *ebOpenSel; - TMenuItem *ebSaveSel; - TMenuItem *N23; - TMenuItem *SynchronizeSounds1; - TExtBtn *ebTargetWallmarks; - TMenuItem *ExportErrorList1; - TMenuItem *miHightlightTexture; - TMenuItem *MakeSoundOccluder1; - TMenuItem *N24; - TMenuItem *N25; - TMenuItem *ClearDebugDraw1; - TExtBtn *ebMultiRename; + TExtBtn *ebTargetSpawnPoint; + TExtBtn *ebTargetWay; + TExtBtn *ebTargetSector; + TExtBtn *ebTargetPortal; + TLabel *APHeadLabel2; + TExtBtn *sbSceneMin; + TLabel *lbTools; + TLabel *lbEditMode; + TExtBtn *sbEditMin; + TExtBtn *sbTargetMin; + TExtBtn *ebTargetGroup; + TExtBtn *ebSceneFile; + TExtBtn *ebScene; + TExtBtn *ebObjectList; + TExtBtn *ebPreferences; + TExtBtn *ExtBtn7; + TExtBtn *ExtBtn8; + TExtBtn *ExtBtn10; + TMxPopupMenu *pmSceneFile; + TMenuItem *Clear1; + TMenuItem *miOpen; + TMenuItem *Save1; + TMenuItem *SaveAs1; + TMxPopupMenu *pmScene; + TMenuItem *Options1; + TMenuItem *Validate1; + TMxPopupMenu *pmToolsEdit; + TMxPopupMenu *pmToolsSelection; + TMxPopupMenu *pmToolsVisibility; + TMenuItem *Cut1; + TMenuItem *Copy1; + TMenuItem *miPaste; + TMenuItem *Undo1; + TMenuItem *Redo1; + TMenuItem *Delete1; + TMenuItem *Invert1; + TMenuItem *SelectAll1; + TMenuItem *UnselectAll1; + TMenuItem *HideAll1; + TMenuItem *HideSelected1; + TMenuItem *N1; + TMenuItem *HideUnselected1; + TMenuItem *UnhideAll1; + TExtBtn *ebTargetPS; + TPanel *paSnapList; + TLabel *Label1; + TExtBtn *ExtBtn16; + TExtBtn *ebUseSnapList; + TExtBtn *ExtBtn1; + TMxPopupMenu *pmSnapListCommand; + TMenuItem *MenuItem3; + TMenuItem *MenuItem4; + TListBox *lbSnapList; + TBevel *Bevel1; + TMenuItem *miAddSelectedToList; + TExtBtn *ebTargetShape; + TMxPopupMenu *pmObjectContext; + TMenuItem *miVisibility; + TMenuItem *HideSelected2; + TMenuItem *HideUnselected2; + TMenuItem *HideAll2; + TMenuItem *N5; + TMenuItem *UnhideAll2; + TMenuItem *Locking1; + TMenuItem *LockSelected1; + TMenuItem *MenuItem1; + TMenuItem *MenuItem2; + TMenuItem *N6; + TMenuItem *MenuItem5; + TMenuItem *MenuItem6; + TMenuItem *MenuItem7; + TMenuItem *Edit1; + TMenuItem *miCopy; + TMenuItem *miPaste2; + TMenuItem *miCut; + TMenuItem *N4; + TMenuItem *miProperties; + TMenuItem *N3; + TMenuItem *miRecentFiles; + TMenuItem *Quit1; + TExtBtn *ebProperties; + TExtBtn *ebLightAnimationEditor; + TExtBtn *ebImages; + TMenuItem *N8; + TMenuItem *N12; + TMenuItem *N13; + TMenuItem *N15; + TMenuItem *N17; + TMenuItem *N18; + TMenuItem *N19; + TMenuItem *N20; + TExtBtn *ebTargetDO; + TMenuItem *N22; + TMenuItem *miSceneSummary; + TExtBtn *ebSounds; + TExtBtn *ExtBtn2; + TExtBtn *ebTargetAIMap; + TExtBtn *ebCompile; + TMxPopupMenu *pmCompile; + TMenuItem *MenuItem19; + TMenuItem *MenuItem23; + TMenuItem *MenuItem24; + TMenuItem *MenuItem25; + TMenuItem *MenuItem26; + TMenuItem *MenuItem27; + TMenuItem *MenuItem29; + TMenuItem *MenuItem32; + TMenuItem *MenuItem33; + TMenuItem *MenuItem34; + TMxPopupMenu *pmObjects; + TMenuItem *MenuItem13; + TMenuItem *MenuItem16; + TMenuItem *MenuItem17; + TMenuItem *ReloadObjects1; + TMenuItem *CleanLibrary; + TMxPopupMenu *pmImages; + TMenuItem *N11; + TMenuItem *ImageEditor1; + TMenuItem *MenuItem8; + TMenuItem *UpdateSceneTextures1; + TMenuItem *N10; + TMenuItem *MenuItem9; + TMenuItem *MenuItem10; + TMxPopupMenu *pmSounds; + TMenuItem *MenuItem11; + TMenuItem *MenuItem12; + TMenuItem *MenuItem15; + TMenuItem *MenuItem14; + TMenuItem *UpdateEnvironmentGeometry1; + TMenuItem *RemoveSelectedFromList1; + TMenuItem *SelectObjectFromList1; + TMenuItem *N9; + TMenuItem *N14; + TExtBtn *ebSnapListMode; + TExtBtn *ebModeInvert; + TBevel *Bevel2; + TMenuItem *N21; + TMenuItem *ebOpenSel; + TMenuItem *ebSaveSel; + TMenuItem *N23; + TMenuItem *SynchronizeSounds1; + TExtBtn *ebTargetWallmarks; + TMenuItem *ExportErrorList1; + TMenuItem *miHightlightTexture; + TMenuItem *MakeSoundOccluder1; + TMenuItem *N24; + TMenuItem *N25; + TMenuItem *ClearDebugDraw1; + TExtBtn *ebMultiRename; TMenuItem *N7; TMenuItem *Editminimap1; - TMenuItem *SyncTHM1; - TMenuItem *N26; - TMenuItem *Makepack1; - TMenuItem *N27; - TMenuItem *ExportObj; - TMenuItem *e1; - TExtBtn *ebTargetFogVolumes; - TExtBtn *btEnableObject; - TExtBtn *btEnableLight; - TExtBtn *btEnableSoundSrc; - TExtBtn *ExtBtn11; - TExtBtn *ExtBtn12; - TExtBtn *ExtBtn13; - TExtBtn *ExtBtn14; - TExtBtn *ExtBtn15; - TExtBtn *btEnableSoundEnv; - TExtBtn *btEnableGlow; - TExtBtn *btEnableShape; - TExtBtn *btEnableSpawnPoint; - TExtBtn *btEnableWay; - TExtBtn *btEnableSector; - TExtBtn *btEnablePortal; - TExtBtn *btEnableGroup; - TExtBtn *btEnablePS; - TExtBtn *btEnableDO; - TExtBtn *btEnableAIMap; - TExtBtn *btEnableWallmarks; - TExtBtn *btEnableFogVolumes; - TBevel *Bevel3; - TMenuItem *ClipEditor1; + TMenuItem *SyncTHM1; + TMenuItem *N26; + TMenuItem *Makepack1; + TMenuItem *N27; + TMenuItem *ExportObj; + TMenuItem *e1; + TExtBtn *ebTargetFogVolumes; + TExtBtn *btEnableObject; + TExtBtn *btEnableLight; + TExtBtn *btEnableSoundSrc; + TExtBtn *ExtBtn11; + TExtBtn *ExtBtn12; + TExtBtn *ExtBtn13; + TExtBtn *ExtBtn14; + TExtBtn *ExtBtn15; + TExtBtn *btEnableSoundEnv; + TExtBtn *btEnableGlow; + TExtBtn *btEnableShape; + TExtBtn *btEnableSpawnPoint; + TExtBtn *btEnableWay; + TExtBtn *btEnableSector; + TExtBtn *btEnablePortal; + TExtBtn *btEnableGroup; + TExtBtn *btEnablePS; + TExtBtn *btEnableDO; + TExtBtn *btEnableAIMap; + TExtBtn *btEnableWallmarks; + TExtBtn *btEnableFogVolumes; + TBevel *Bevel3; + TMenuItem *ClipEditor1; void __fastcall ebClearClick(TObject *Sender); void __fastcall ebLoadClick(TObject *Sender); void __fastcall ebSaveClick(TObject *Sender); @@ -229,85 +230,85 @@ class TfraLeftBar : public TFrame void __fastcall PanelMaximizeClick(TObject *Sender); void __fastcall ebEditorPreferencesClick(TObject *Sender); void __fastcall ebRefreshEditorClick(TObject *Sender); - void __fastcall ebInvertClick(TObject *Sender); - void __fastcall ebSelectAllClick(TObject *Sender); - void __fastcall ebUnselectAllClick(TObject *Sender); - void __fastcall ebDeleteClick(TObject *Sender); - void __fastcall ebHideAllClick(TObject *Sender); - void __fastcall ebHideSelectedClick(TObject *Sender); - void __fastcall ebUnhideAllClick(TObject *Sender); - void __fastcall ebHideUnselectedClick(TObject *Sender); - void __fastcall ebMakeGameClick(TObject *Sender); - void __fastcall ebSceneFileMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall ebSceneMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y); - void __fastcall ExtBtn7MouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall ExtBtn8MouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall ExtBtn10MouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall ebClearSnapClick(TObject *Sender); - void __fastcall ebSetSnapClick(TObject *Sender); - void __fastcall ExtBtn1MouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall miAddSelectedToListClick(TObject *Sender); - void __fastcall ebUseSnapListClick(TObject *Sender); - void __fastcall RefreshObjects1Click(TObject *Sender); - void __fastcall CheckNewTexturesClick(TObject *Sender); - void __fastcall MakeDetailsClick(TObject *Sender); - void __fastcall miPropertiesClick(TObject *Sender); - void __fastcall CleanLibraryClick(TObject *Sender); - void __fastcall Quit1Click(TObject *Sender); - void __fastcall ebPropertiesClick(TObject *Sender); - void __fastcall ebLightAnimationEditorClick(TObject *Sender); - void __fastcall ebImagesMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall ImageEditor1Click(TObject *Sender); - void __fastcall MenuItem9Click(TObject *Sender); - void __fastcall UpdateSceneTextures1Click(TObject *Sender); - void __fastcall ImportCompilerErrorsClick(TObject *Sender); - void __fastcall ebIgnoreModeClick(TObject *Sender); - void __fastcall miClearErrorListClick(TObject *Sender); - void __fastcall miSceneSummaryClick(TObject *Sender); - void __fastcall MakeHOM1Click(TObject *Sender); - void __fastcall UpdateEnvironmentGeometry1Click(TObject *Sender); - void __fastcall MenuItem14Click(TObject *Sender); - void __fastcall ebSoundsMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall ExtBtn2MouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall MakeAIMap1Click(TObject *Sender); - void __fastcall ebCompileMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall SelectObjectFromList1Click(TObject *Sender); - void __fastcall RemoveSelectedFromList1Click(TObject *Sender); - void __fastcall ebSnapListModeClick(TObject *Sender); - void __fastcall ebOpenSelClick(TObject *Sender); - void __fastcall ebSaveSelClick(TObject *Sender); - void __fastcall MenuItem12Click(TObject *Sender); - void __fastcall SynchronizeSounds1Click(TObject *Sender); - void __fastcall ExportErrorList1Click(TObject *Sender); - void __fastcall miHightlightTextureClick(TObject *Sender); - void __fastcall MakeSoundOccluder1Click(TObject *Sender); - void __fastcall ClearDebugDraw1Click(TObject *Sender); - void __fastcall ebMultiRenameClick(TObject *Sender); + void __fastcall ebInvertClick(TObject *Sender); + void __fastcall ebSelectAllClick(TObject *Sender); + void __fastcall ebUnselectAllClick(TObject *Sender); + void __fastcall ebDeleteClick(TObject *Sender); + void __fastcall ebHideAllClick(TObject *Sender); + void __fastcall ebHideSelectedClick(TObject *Sender); + void __fastcall ebUnhideAllClick(TObject *Sender); + void __fastcall ebHideUnselectedClick(TObject *Sender); + void __fastcall ebMakeGameClick(TObject *Sender); + void __fastcall ebSceneFileMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall ebSceneMouseDown(TObject *Sender, + TMouseButton Button, TShiftState Shift, int X, int Y); + void __fastcall ExtBtn7MouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall ExtBtn8MouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall ExtBtn10MouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall ebClearSnapClick(TObject *Sender); + void __fastcall ebSetSnapClick(TObject *Sender); + void __fastcall ExtBtn1MouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall miAddSelectedToListClick(TObject *Sender); + void __fastcall ebUseSnapListClick(TObject *Sender); + void __fastcall RefreshObjects1Click(TObject *Sender); + void __fastcall CheckNewTexturesClick(TObject *Sender); + void __fastcall MakeDetailsClick(TObject *Sender); + void __fastcall miPropertiesClick(TObject *Sender); + void __fastcall CleanLibraryClick(TObject *Sender); + void __fastcall Quit1Click(TObject *Sender); + void __fastcall ebPropertiesClick(TObject *Sender); + void __fastcall ebLightAnimationEditorClick(TObject *Sender); + void __fastcall ebImagesMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall ImageEditor1Click(TObject *Sender); + void __fastcall MenuItem9Click(TObject *Sender); + void __fastcall UpdateSceneTextures1Click(TObject *Sender); + void __fastcall ImportCompilerErrorsClick(TObject *Sender); + void __fastcall ebIgnoreModeClick(TObject *Sender); + void __fastcall miClearErrorListClick(TObject *Sender); + void __fastcall miSceneSummaryClick(TObject *Sender); + void __fastcall MakeHOM1Click(TObject *Sender); + void __fastcall UpdateEnvironmentGeometry1Click(TObject *Sender); + void __fastcall MenuItem14Click(TObject *Sender); + void __fastcall ebSoundsMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall ExtBtn2MouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall MakeAIMap1Click(TObject *Sender); + void __fastcall ebCompileMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall SelectObjectFromList1Click(TObject *Sender); + void __fastcall RemoveSelectedFromList1Click(TObject *Sender); + void __fastcall ebSnapListModeClick(TObject *Sender); + void __fastcall ebOpenSelClick(TObject *Sender); + void __fastcall ebSaveSelClick(TObject *Sender); + void __fastcall MenuItem12Click(TObject *Sender); + void __fastcall SynchronizeSounds1Click(TObject *Sender); + void __fastcall ExportErrorList1Click(TObject *Sender); + void __fastcall miHightlightTextureClick(TObject *Sender); + void __fastcall MakeSoundOccluder1Click(TObject *Sender); + void __fastcall ClearDebugDraw1Click(TObject *Sender); + void __fastcall ebMultiRenameClick(TObject *Sender); void __fastcall Editminimap1Click(TObject *Sender); - void __fastcall SyncTHM1Click(TObject *Sender); - void __fastcall Makepack1Click(TObject *Sender); - void __fastcall ExportObjClick(TObject *Sender); - void __fastcall e1Click(TObject *Sender); - void __fastcall btEnableObjectClick(TObject *Sender); - void __fastcall ClipEditor1Click(TObject *Sender); -private: // User declarations + void __fastcall SyncTHM1Click(TObject *Sender); + void __fastcall Makepack1Click(TObject *Sender); + void __fastcall ExportObjClick(TObject *Sender); + void __fastcall e1Click(TObject *Sender); + void __fastcall btEnableObjectClick(TObject *Sender); + void __fastcall ClipEditor1Click(TObject *Sender); +private: // User declarations void RedrawBar(); - void __fastcall miRecentFilesClick(TObject *Sender); - - xr_vector > m_TargetButtons; -public: // User declarations - __fastcall TfraLeftBar(TComponent* Owner); - void ChangeTarget(ObjClassID tgt); + void __fastcall miRecentFilesClick(TObject *Sender); + + xr_vector> m_TargetButtons; +public: // User declarations + __fastcall TfraLeftBar(TComponent *Owner); + void ChangeTarget(ObjClassID tgt); void UpdateSnapList(); void MinimizeAllFrames(); void MaximizeAllFrames(); @@ -315,7 +316,9 @@ class TfraLeftBar : public TFrame void OnTimer(); void RefreshBar(); }; + //--------------------------------------------------------------------------- -extern PACKAGE TfraLeftBar *fraLeftBar; +extern PACKAGE TfraLeftBar * fraLeftBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Splash.cpp b/src/editors/LevelEditor/Splash.cpp index 4f39b0dedd9..e5714102b3b 100644 --- a/src/editors/LevelEditor/Splash.cpp +++ b/src/editors/LevelEditor/Splash.cpp @@ -7,9 +7,11 @@ #pragma link "MXCtrls" #pragma resource "*.dfm" TfrmSplash *frmSplash; + //--------------------------------------------------------------------------- -__fastcall TfrmSplash::TfrmSplash(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfrmSplash::TfrmSplash(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- + + diff --git a/src/editors/LevelEditor/Splash.h b/src/editors/LevelEditor/Splash.h index a9496f100a5..41ae039a56d 100644 --- a/src/editors/LevelEditor/Splash.h +++ b/src/editors/LevelEditor/Splash.h @@ -11,18 +11,29 @@ #include "MXCtrls.hpp" #include #include + //--------------------------------------------------------------------------- class TfrmSplash : public TForm { -__published: // IDE-managed Components - TImage *Image1; - TLabel *lbStatus; -private: // User declarations -public: // User declarations - __fastcall TfrmSplash(TComponent* Owner); - void SetStatus(LPSTR log){ if (log){ lbStatus->Caption = log; lbStatus->Repaint(); };} + __published: // IDE-managed Components + TImage*Image1; + TLabel *lbStatus; +private: // User declarations +public: // User declarations + __fastcall TfrmSplash(TComponent *Owner); + + void SetStatus(LPSTR log) + { + if (log) + { + lbStatus->Caption = log; + lbStatus->Repaint(); + }; + } }; + //--------------------------------------------------------------------------- -extern PACKAGE TfrmSplash *frmSplash; +extern PACKAGE TfrmSplash * frmSplash; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/TopBar.h b/src/editors/LevelEditor/TopBar.h index b6870057a39..de951c0c8c1 100644 --- a/src/editors/LevelEditor/TopBar.h +++ b/src/editors/LevelEditor/TopBar.h @@ -12,10 +12,14 @@ #include #include "ExtBtn.hpp" #include "mxPlacemnt.hpp" + //--------------------------------------------------------------------------- -class ECORE_API TfraTopBar : public TFrame +class ECORE_API TfraTopBar : + +public +TFrame { -__published: // IDE-managed Components + __published: // IDE-managed Components TPanel *paTBEdit; TExtBtn *ebEditUndo; TExtBtn *ebEditRedo; @@ -28,7 +32,7 @@ class ECORE_API TfraTopBar : public TFrame TPanel *paSnap; TExtBtn *ebMSnap; TExtBtn *ebASnap; - TExtBtn *ebCSParent; + TExtBtn *ebCSParent; TPanel *paAxis; TExtBtn *ebAxisX; TExtBtn *ebAxisY; @@ -43,39 +47,40 @@ class ECORE_API TfraTopBar : public TFrame TExtBtn *ebViewBack; TExtBtn *ebViewRight; TExtBtn *ebViewBottom; - TExtBtn *ebNUScale; - TPanel *Panel1; - TExtBtn *ebZoomExtents; - TExtBtn *ebZoomExtentsSelected; - TExtBtn *ebVSnap; - TFormStorage *fsStorage; - TExtBtn *ebCameraPlane; - TExtBtn *ebCameraArcBall; - TExtBtn *ebCameraFly; - TExtBtn *ebViewReset; - TExtBtn *ebMTSnap; - TExtBtn *ebNormalAlign; - TExtBtn *SimulateButton; - TExtBtn *UseSimulatePositionsButton; + TExtBtn *ebNUScale; + TPanel *Panel1; + TExtBtn *ebZoomExtents; + TExtBtn *ebZoomExtentsSelected; + TExtBtn *ebVSnap; + TFormStorage *fsStorage; + TExtBtn *ebCameraPlane; + TExtBtn *ebCameraArcBall; + TExtBtn *ebCameraFly; + TExtBtn *ebViewReset; + TExtBtn *ebMTSnap; + TExtBtn *ebNormalAlign; + TExtBtn *SimulateButton; + TExtBtn *UseSimulatePositionsButton; void __fastcall ebEditUndoClick(TObject *Sender); void __fastcall ebEditRedoClick(TObject *Sender); void __fastcall ActionClick(TObject *Sender); void __fastcall ebViewClick(TObject *Sender); - void __fastcall ebZoomExtentsClick(TObject *Sender); - void __fastcall ebZoomExtentsSelectedClick(TObject *Sender); - void __fastcall ebCameraStyleClick(TObject *Sender); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall ebAxisClick(TObject *Sender); - void __fastcall ebSettingsClick(TObject *Sender); - void __fastcall SimulateButtonClick(TObject *Sender); - void __fastcall UseSimulatePositions(TObject *Sender); -private: // User declarations -public: // User declarations - __fastcall TfraTopBar(TComponent* Owner); + void __fastcall ebZoomExtentsClick(TObject *Sender); + void __fastcall ebZoomExtentsSelectedClick(TObject *Sender); + void __fastcall ebCameraStyleClick(TObject *Sender); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall ebAxisClick(TObject *Sender); + void __fastcall ebSettingsClick(TObject *Sender); + void __fastcall SimulateButtonClick(TObject *Sender); + void __fastcall UseSimulatePositions(TObject *Sender); + private: // User declarations + public: // User declarations + __fastcall TfraTopBar(TComponent* Owner); void OnTimer(); void __fastcall RefreshBar(); }; //--------------------------------------------------------------------------- -extern PACKAGE TfraTopBar *fraTopBar; +extern PACKAGE TfraTopBar * fraTopBar; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/main.h b/src/editors/LevelEditor/main.h index 54f0a90a0ee..bda0375dab8 100644 --- a/src/editors/LevelEditor/main.h +++ b/src/editors/LevelEditor/main.h @@ -5,7 +5,7 @@ //--------------------------------------------------------------------------- #include #include -#include +#include #include #include #include @@ -15,31 +15,35 @@ #include "MxMenus.hpp" #include "mxPlacemnt.hpp" #include "RenderWindow.hpp" + //--------------------------------------------------------------------------- // refs -class ECORE_API TfrmMain : public TForm +class ECORE_API TfrmMain : + +public +TForm { -__published: // IDE-managed Components - TPanel *paLeftBar; - TPanel *paBottomBar; + __published: // IDE-managed Components + TPanel *paLeftBar; + TPanel *paBottomBar; TPanel *paTools; TTimer *tmRefresh; - TFormStorage *fsStorage; + TFormStorage *fsStorage; TPanel *paMain; TPanel *paTopBar; - TPanel *paRender; - TLabel *APHeadLabel2; - TExtBtn *sbToolsMin; - TD3DWindow *D3DWindow; - TExtBtn *ebAllMin; - TExtBtn *ebAllMax; - void __fastcall FormCreate(TObject *Sender); + TPanel *paRender; + TLabel *APHeadLabel2; + TExtBtn *sbToolsMin; + TD3DWindow *D3DWindow; + TExtBtn *ebAllMin; + TExtBtn *ebAllMax; + void __fastcall FormCreate(TObject *Sender); void __fastcall D3DWindowResize(TObject *Sender); void __fastcall D3DWindowKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall D3DWindowKeyUp(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall sbToolsMinClick(TObject *Sender); void __fastcall TopClick(TObject *Sender); void __fastcall FormShow(TObject *Sender); @@ -48,32 +52,33 @@ class ECORE_API TfrmMain : public TForm void __fastcall D3DWindowKeyPress(TObject *Sender, char &Key); void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); - void __fastcall D3DWindowChangeFocus(TObject *Sender); - void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall D3DWindowMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall D3DWindowMouseUp(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall D3DWindowMouseMove(TObject *Sender, TShiftState Shift, - int X, int Y); - void __fastcall ebAllMinClick(TObject *Sender); - void __fastcall ebAllMaxClick(TObject *Sender); - void __fastcall FormResize(TObject *Sender); - void __fastcall paRenderResize(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); -private: // User declarations + void __fastcall D3DWindowChangeFocus(TObject *Sender); + void __fastcall FormKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall D3DWindowMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall D3DWindowMouseUp(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall D3DWindowMouseMove(TObject *Sender, TShiftState Shift, + int X, int Y); + void __fastcall ebAllMinClick(TObject *Sender); + void __fastcall ebAllMaxClick(TObject *Sender); + void __fastcall FormResize(TObject *Sender); + void __fastcall paRenderResize(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); + private: // User declarations void __fastcall IdleHandler(TObject *Sender, bool &Done); - TShiftState ShiftKey; - HINSTANCE m_HInstance; -public: // User declarations - __fastcall TfrmMain(TComponent* Owner); + TShiftState ShiftKey; + HINSTANCE m_HInstance; + public: // User declarations + __fastcall TfrmMain(TComponent* Owner); void __fastcall UpdateCaption(); - __inline void SetHInst(HINSTANCE inst){ m_HInstance=inst; } - bool IsFocused(){return D3DWindow->Focused();} + __inline void SetHInst(HINSTANCE inst){ m_HInstance=inst; } +bool IsFocused(){return D3DWindow->Focused();} }; //--------------------------------------------------------------------------- -extern /*ECORE_API*/ PACKAGE TfrmMain *frmMain; +extern /*ECORE_API*/ PACKAGE TfrmMain * frmMain; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/previewimage.h b/src/editors/LevelEditor/previewimage.h index 9be12abd7da..82ae26b5704 100644 --- a/src/editors/LevelEditor/previewimage.h +++ b/src/editors/LevelEditor/previewimage.h @@ -6,25 +6,28 @@ #include //--------------------------------------------------------------------------- class ETextureCore; + class TfrmPreviewImage : public TForm { -__published: // IDE-managed Components - TPanel *paImage; - TPaintBox *pbImage; + __published: // IDE-managed Components + TPanel*paImage; + TPaintBox *pbImage; void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall FormClose(TObject *Sender, TCloseAction &Action); - void __fastcall pbImagePaint(TObject *Sender); - void __fastcall pbImageMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); -private: // User declarations - static TfrmPreviewImage* form; + TShiftState Shift); + void __fastcall FormClose(TObject *Sender, TCloseAction &Action); + void __fastcall pbImagePaint(TObject *Sender); + void __fastcall pbImageMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); +private: // User declarations + static TfrmPreviewImage *form; - ETextureCore* tex; + ETextureCore *tex; float mult; -public: // User declarations - __fastcall TfrmPreviewImage(TComponent* Owner); +public: // User declarations + __fastcall TfrmPreviewImage(TComponent *Owner); static int __fastcall Run(); }; + //--------------------------------------------------------------------------- #endif + From b6efabb3fd9a22f78a8118e1648896a342d03229 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Fri, 4 Dec 2015 07:14:32 +0500 Subject: [PATCH 08/10] ECore: fixed includes and formatted code --- src/editors/ECore/Editor/ArbitraryList.h | 297 ++- src/editors/ECore/Editor/BoneEditor.cpp | 381 +-- src/editors/ECore/Editor/ColorPicker.cpp | 77 +- src/editors/ECore/Editor/ColorPicker.h | 6 +- src/editors/ECore/Editor/D3DUtils.cpp | 2129 ++++++++++------- src/editors/ECore/Editor/D3DUtils.h | 273 ++- src/editors/ECore/Editor/D3DX_Wrapper.h | 391 +-- src/editors/ECore/Editor/DeviceScreenshot.cpp | 73 +- src/editors/ECore/Editor/DrawUtils.h | 1 + src/editors/ECore/Editor/EDetailModel.cpp | 309 +-- src/editors/ECore/Editor/EDetailModel.h | 115 +- src/editors/ECore/Editor/ELog.cpp | 46 +- src/editors/ECore/Editor/ELog.h | 17 +- src/editors/ECore/Editor/EStats.cpp | 241 +- src/editors/ECore/Editor/EStats.h | 82 +- src/editors/ECore/Editor/ETextureParams.cpp | 1 + src/editors/ECore/Editor/ETextureParams.h | 1 + src/editors/ECore/Editor/EThumbnail.cpp | 69 +- src/editors/ECore/Editor/EThumbnail.h | 278 ++- src/editors/ECore/Editor/EThumbnailGroup.cpp | 144 +- src/editors/ECore/Editor/EThumbnailObject.cpp | 134 +- src/editors/ECore/Editor/EThumbnailSound.cpp | 245 +- .../ECore/Editor/EThumbnailTexture.cpp | 319 +-- src/editors/ECore/Editor/EditMesh.cpp | 670 +++--- src/editors/ECore/Editor/EditMesh.h | 513 ++-- src/editors/ECore/Editor/EditMeshIO.cpp | 298 +-- src/editors/ECore/Editor/EditMeshModify.cpp | 553 +++-- src/editors/ECore/Editor/EditMeshPick.cpp | 157 +- src/editors/ECore/Editor/EditMeshRender.cpp | 524 ++-- src/editors/ECore/Editor/EditObject.cpp | 314 +-- src/editors/ECore/Editor/EditObject.h | 711 +++--- src/editors/ECore/Editor/EditObjectEditor.cpp | 422 ++-- src/editors/ECore/Editor/EditObjectIO.cpp | 237 +- src/editors/ECore/Editor/EditObjectImport.cpp | 42 +- .../ECore/Editor/EditObjectMotions.cpp | 684 +++--- src/editors/ECore/Editor/EditObjectProps.cpp | 174 +- src/editors/ECore/Editor/EditObjectSkin.cpp | 672 +++--- .../ECore/Editor/EditorPreferences.cpp | 504 ++-- src/editors/ECore/Editor/EditorPreferences.h | 133 +- src/editors/ECore/Editor/Engine.cpp | 56 +- src/editors/ECore/Editor/ExportObjectOGF.cpp | 797 +++--- src/editors/ECore/Editor/ExportObjectOGF.h | 275 ++- .../Editor/ExportObjectOGFCalculateTB.cpp | 8 +- src/editors/ECore/Editor/ExportSkeleton.cpp | 1541 ++++++------ src/editors/ECore/Editor/ExportSkeleton.h | 276 ++- .../Editor/ExportSkeletonCalculateTB.cpp | 12 +- .../ECore/Editor/GeometryCollector.cpp | 149 +- src/editors/ECore/Editor/GeometryCollector.h | 86 +- src/editors/ECore/Editor/ImageEditor.cpp | 526 ++-- src/editors/ECore/Editor/ImageEditor.h | 196 +- src/editors/ECore/Editor/ImageManager.cpp | 958 ++++---- src/editors/ECore/Editor/ImageManager.h | 127 +- src/editors/ECore/Editor/ImageManagerDO.cpp | 416 ++-- src/editors/ECore/Editor/ImageManagerLOD.cpp | 628 ++--- src/editors/ECore/Editor/LW_ShaderDef.h | 18 +- src/editors/ECore/Editor/Library.cpp | 323 +-- src/editors/ECore/Editor/Library.h | 52 +- src/editors/ECore/Editor/LogForm.cpp | 175 +- src/editors/ECore/Editor/LogForm.h | 88 +- src/editors/ECore/Editor/MinimapEditor.cpp | 312 +-- src/editors/ECore/Editor/MinimapEditor.h | 42 +- .../ECore/Editor/ParticleEffectActions.cpp | 2 +- .../ECore/Editor/ParticleEffectActions.h | 493 ++-- .../Editor/PhysicsShellHolderEditorBase.cpp | 5 +- .../Editor/PhysicsShellHolderEditorBase.h | 2 +- src/editors/ECore/Editor/PropSlimTools.h | 1 + src/editors/ECore/Editor/SkeletonFace.h | 62 +- src/editors/ECore/Editor/SkeletonVert.h | 89 +- src/editors/ECore/Editor/SoundEditor.cpp | 541 +++-- src/editors/ECore/Editor/SoundEditor.h | 169 +- src/editors/ECore/Editor/SoundManager.cpp | 451 ++-- src/editors/ECore/Editor/SoundManager.h | 51 +- src/editors/ECore/Editor/TLSPRITE.CPP | 331 +-- src/editors/ECore/Editor/TLSPRITE.h | 255 +- src/editors/ECore/Editor/UI_Camera.cpp | 420 ++-- src/editors/ECore/Editor/UI_Camera.h | 124 +- src/editors/ECore/Editor/UI_MainCommand.cpp | 1096 +++++---- src/editors/ECore/Editor/UI_MainCommand.h | 204 +- src/editors/ECore/Editor/UI_MainMail.cpp | 167 +- src/editors/ECore/Editor/UI_ToolsCustom.cpp | 505 ++-- src/editors/ECore/Editor/UI_ToolsCustom.h | 364 +-- src/editors/ECore/Editor/c_dinput.cpp | 964 ++++---- src/editors/ECore/Editor/device.cpp | 526 ++-- src/editors/ECore/Editor/device.h | 305 +-- src/editors/ECore/Editor/du_box.cpp | 58 +- src/editors/ECore/Editor/du_box.h | 1 + src/editors/ECore/Editor/du_cone.cpp | 133 +- src/editors/ECore/Editor/du_cone.h | 1 + src/editors/ECore/Editor/du_cylinder.cpp | 232 +- src/editors/ECore/Editor/du_cylinder.h | 1 + src/editors/ECore/Editor/du_sphere.cpp | 794 +++--- src/editors/ECore/Editor/du_sphere.h | 1 + src/editors/ECore/Editor/du_sphere_part.cpp | 1 + src/editors/ECore/Editor/du_sphere_part.h | 1 + src/editors/ECore/Editor/engine.h | 22 +- .../ECore/Editor/itterate_adjacents_dynamic.h | 2 +- src/editors/ECore/Editor/lwo2.h | 1 + src/editors/ECore/Editor/pDomain.cpp | 1150 +++++---- src/editors/ECore/Editor/pick_definition.h | 1 + src/editors/ECore/Editor/render.cpp | 360 +-- src/editors/ECore/Editor/render.h | 245 +- src/editors/ECore/Editor/ui_main.cpp | 738 +++--- src/editors/ECore/Editor/ui_main.h | 351 +-- src/editors/ECore/Editor/xrLoadSurface.cpp | 187 +- src/editors/ECore/Engine/GameMtlLib.cpp | 1 + src/editors/ECore/Engine/GameMtlLib.h | 1 + .../ECore/Engine/GameMtlLib_Engine.cpp | 1 + src/editors/ECore/Engine/Image.cpp | 377 +-- src/editors/ECore/Engine/Image.h | 46 +- src/editors/ECore/Engine/NVMeshMender.cpp | 1262 +++++----- src/editors/ECore/Engine/NVMeshMender.h | 197 +- src/editors/ECore/Engine/Texture.h | 4 +- src/editors/ECore/Engine/ai_sounds.cpp | 47 +- src/editors/ECore/Engine/ai_sounds.h | 134 +- src/editors/ECore/Engine/bone.cpp | 1 + src/editors/ECore/Engine/cl_collector.cpp | 2 + src/editors/ECore/Engine/cl_collector.h | 2 + src/editors/ECore/Engine/cl_intersect.h | 1 + src/editors/ECore/Engine/guid_generator.cpp | 13 +- src/editors/ECore/Engine/guid_generator.h | 2 + src/editors/ECore/Engine/nv_algebra.cpp | 1175 ++++----- src/editors/ECore/Engine/nv_algebra.h | 908 ++++--- src/editors/ECore/Engine/nv_math.h | 9 +- src/editors/ECore/Engine/nv_mathdecl.h | 18 +- src/editors/ECore/stdafx.h | 100 +- 125 files changed, 19000 insertions(+), 16006 deletions(-) create mode 100644 src/editors/ECore/Editor/DrawUtils.h create mode 100644 src/editors/ECore/Editor/ETextureParams.cpp create mode 100644 src/editors/ECore/Editor/ETextureParams.h create mode 100644 src/editors/ECore/Editor/PropSlimTools.h create mode 100644 src/editors/ECore/Editor/du_sphere_part.cpp create mode 100644 src/editors/ECore/Editor/du_sphere_part.h create mode 100644 src/editors/ECore/Editor/lwo2.h create mode 100644 src/editors/ECore/Editor/pick_definition.h create mode 100644 src/editors/ECore/Engine/GameMtlLib.cpp create mode 100644 src/editors/ECore/Engine/GameMtlLib.h create mode 100644 src/editors/ECore/Engine/GameMtlLib_Engine.cpp create mode 100644 src/editors/ECore/Engine/bone.cpp create mode 100644 src/editors/ECore/Engine/cl_intersect.h diff --git a/src/editors/ECore/Editor/ArbitraryList.h b/src/editors/ECore/Editor/ArbitraryList.h index f06f4c12bcc..d58512486d2 100644 --- a/src/editors/ECore/Editor/ArbitraryList.h +++ b/src/editors/ECore/Editor/ArbitraryList.h @@ -18,134 +18,183 @@ // Designed to hold _unsorted_ data, but only RemoveItem() // actually disturbs the order, so you can use it for general arrays // if you don't use that function. -template +template class ArbitraryList { - T *pT; // The list. - u32 iSize; // The current size of the list. - u32 iReservedSize; // The current reserved size of the list. + T *pT; // The list. + u32 iSize; // The current size of the list. + u32 iReservedSize; // The current reserved size of the list. public: - // Constructor, with optional initial size setting. - ArbitraryList ( u32 iInitialSize = 0 ) - { - pT = NULL; - iSize = 0; - iReservedSize = 0; - if ( iInitialSize > 0 ) - resize( iInitialSize ); - } - // Destructor. - ~ArbitraryList ( void ) - { - if ( pT == NULL ){ - VERIFY ( iReservedSize == 0 ); - VERIFY ( iSize == 0 ); - }else{ - VERIFY ( iReservedSize > 0 ); - VERIFY ( iSize > 0 ); - delete[] pT; - pT = NULL; - } - } - // Returns the pointer to the given item. - IC T* item (u32 iItem) - { - VERIFY ( iItem < iSize ); - return ( &pT[iItem] ); - } - // Returns the pointer to the first item. - IC T* ptr ( ) { return (pT);} - // Returns the size of the list - IC u32 size ( ) const { return iSize; } - // Grows or shrinks the list to this number of items. - // Preserves existing items. - // Items that fall off the end of a shrink may vanish. - // Returns the pointer to the first item. - IC T* resize (u32 iNum) - { - VERIFY ( iNum >= 0 ); - iSize = iNum; - if ( iNum <= iReservedSize ){ - if ( iNum == 0 ){ - // Shrunk to 0 - bin the memory. - delete[] pT; - pT = NULL; - iReservedSize = 0; - }else{ - VERIFY ( pT != NULL ); - } - return ( pT ); - }else{ - // Need to grow. Grow by 50% more than - // needed to avoid constant regrows. - u32 iNewSize = ( iNum * 3 ) >> 1; - if ( pT == NULL ){ - VERIFY ( iReservedSize == 0 ); - pT = new T [iNewSize]; - }else{ - VERIFY ( iReservedSize != 0 ); - - T *pOldT = pT; - pT = new T[iNewSize]; - for ( u32 i = 0; i < iReservedSize; i++ ){ - pT[i] = pOldT[i]; - } - delete[] pOldT; - } - VERIFY ( pT != NULL ); - iReservedSize = iNewSize; - return ( pT ); - } - } - // Adds one item to the list and returns a pointer to that new item. - IC T* append ( ) - { - resize ( iSize + 1 ); - return ( &pT[iSize-1] ); - } - // Adds one item to the list and returns a pointer to that new item. - IC void push_back (T& val) - { - resize ( iSize + 1 ); - pT[iSize-1] = val; - } - // Removes the given item number by copying the last item - // to that position and shrinking the list. - IC void erase_fast (u32 iItemNumber) - { - VERIFY ( iItemNumber < iSize ); - pT[iItemNumber] = pT[iSize-1]; - resize ( iSize - 1 ); - } - // Copy the specified data into the list. - IC void insert (u32 iFirstItem, T *p, u32 iNumItems) - { - for ( u32 i = 0; i < iNumItems; i++ ) - *(Item ( i + iFirstItem ) ) = p[i]; - } - // A copy from another arbitrary list of the same type. - IC void insert ( u32 iFirstItem, ArbitraryList &other, u32 iFirstOtherItem, u32 iNumItems ) - { - for ( u32 i = 0; i < iNumItems; i++ ) - *(item ( i + iFirstItem ) ) = *(other.item ( i + iFirstOtherItem ) ); - } - IC T& operator[] (u32 id) { VERIFY(id &other ) - { - u32 iNumItems = other.size(); - - pT = NULL; - iSize = 0; - iReservedSize = 0; - if ( iNumItems > 0 ) - resize ( iNumItems ); - for ( u32 i = 0; i < iNumItems; i++ ) - *(item(i) ) = other[i]; - } + // Constructor, with optional initial size setting. + ArbitraryList(u32 iInitialSize = 0) + { + pT = NULL; + iSize = 0; + iReservedSize = 0; + if (iInitialSize>0) + resize(iInitialSize); + } + + // Destructor. + ~ArbitraryList(void) + { + if (pT==NULL) + { + VERIFY(iReservedSize==0); + VERIFY(iSize==0); + } + else + { + VERIFY(iReservedSize>0); + VERIFY(iSize>0); + delete[] pT; + pT = NULL; + } + } + + // Returns the pointer to the given item. + IC T*item(u32 iItem) + { + VERIFY(iItem=0); + iSize = iNum; + if (iNum<=iReservedSize) + { + if (iNum==0) + { + // Shrunk to 0 - bin the memory. + delete[] pT; + pT = NULL; + iReservedSize = 0; + } + else + { + VERIFY(pT!=NULL); + } + return (pT); + } + else + { + // Need to grow. Grow by 50% more than + // needed to avoid constant regrows. + u32 iNewSize = (iNum*3)>>1; + if (pT==NULL) + { + VERIFY(iReservedSize==0); + pT = new T [iNewSize]; + } + else + { + VERIFY(iReservedSize!=0); + + T *pOldT = pT; + pT = new T[iNewSize]; + for (u32 i = 0; i &other, u32 iFirstOtherItem, u32 iNumItems) + { + for (u32 i = 0; i &other) + { + u32 iNumItems = other.size(); + + pT = NULL; + iSize = 0; + iReservedSize = 0; + if (iNumItems>0) + resize(iNumItems); + for (u32 i = 0; iGetSettings(etfCSParent)) _IT.transform_dir(amount); - shape.box.m_halfsize.add(amount); - if (shape.box.m_halfsize.xGetSettings(etfCSParent)) _IT.transform_dir(amount); + shape.box.m_halfsize.add(amount); + if (shape.box.m_halfsize.xGetSettings(etfCSParent)) _IT.transform_dir(amount); - switch (shape.type){ - case SBoneShape::stBox:{ - Fmatrix R; - R.setXYZi(amount.x,amount.y,amount.z); - shape.box.transform(shape.box,R); - }break; - case SBoneShape::stSphere: break; - case SBoneShape::stCylinder:{ - Fmatrix R; - R.setXYZi(amount.x,amount.y,amount.z); - R.transform_dir(shape.cylinder.m_direction); - }break; + Fvector amount = _amount; + Fmatrix _IT; + _IT.invert(_LTransform()); + if (Tools->GetSettings(etfCSParent)) + _IT.transform_dir(amount); + switch (shape.type) + { + case SBoneShape::stBox: + { + Fmatrix R; + R.setXYZi(amount.x, amount.y, amount.z); + shape.box.transform(shape.box, R); + } + break; + case SBoneShape::stSphere: break; + case SBoneShape::stCylinder: + { + Fmatrix R; + R.setXYZi(amount.x, amount.y, amount.z); + R.transform_dir(shape.cylinder.m_direction); + } + break; } } -void CBone::ShapeMove(const Fvector& _amount) +void CBone::ShapeMove(const Fvector &_amount) { - Fvector amount=_amount; - Fmatrix _IT;_IT.invert(_LTransform()); - if (Tools->GetSettings(etfCSParent)) _IT.transform_dir(amount); - switch (shape.type){ - case SBoneShape::stBox: - shape.box.m_translate.add(amount); - break; - case SBoneShape::stSphere: - shape.sphere.P.add(amount); - break; - case SBoneShape::stCylinder:{ - shape.cylinder.m_center.add(amount); - }break; + Fvector amount = _amount; + Fmatrix _IT; + _IT.invert(_LTransform()); + if (Tools->GetSettings(etfCSParent)) + _IT.transform_dir(amount); + switch (shape.type) + { + case SBoneShape::stBox: + shape.box.m_translate.add(amount); + break; + case SBoneShape::stSphere: + shape.sphere.P.add(amount); + break; + case SBoneShape::stCylinder: + { + shape.cylinder.m_center.add(amount); + } + break; } } -void CBone::BindRotate(const Fvector& _amount) +void CBone::BindRotate(const Fvector &_amount) { - rest_rotate.add(_amount); + rest_rotate.add(_amount); } -void CBone::BindMove(const Fvector& _amount) +void CBone::BindMove(const Fvector &_amount) { - rest_offset.add(_amount); + rest_offset.add(_amount); } -bool CBone::Pick(float& dist, const Fvector& S, const Fvector& D, const Fmatrix& parent) +bool CBone::Pick(float &dist, const Fvector &S, const Fvector &D, const Fmatrix &parent) { - Fvector start, dir; - Fmatrix M; M.mul_43(parent,_LTransform()); + Fvector start, dir; + Fmatrix M; + M.mul_43(parent, _LTransform()); M.invert(); - M.transform_tiny(start,S); - M.transform_dir(dir,D); - switch (shape.type){ - case SBoneShape::stBox: return shape.box.intersect (start,dir,dist); - case SBoneShape::stSphere: return shape.sphere.intersect (start,dir,dist); - case SBoneShape::stCylinder:return shape.cylinder.intersect (start,dir,dist); - default: - Fsphere S; - S.P.set(0,0,0); - S.R=0.025f; - return S.intersect(start,dir,dist); + M.transform_tiny(start, S); + M.transform_dir(dir, D); + switch (shape.type) + { + case SBoneShape::stBox: return shape.box.intersect(start, dir, dist); + case SBoneShape::stSphere: return shape.sphere.intersect(start, dir, dist); + case SBoneShape::stCylinder: return shape.cylinder.intersect(start, dir, dist); + default: + Fsphere S; + S.P.set(0, 0, 0); + S.R = 0.025f; + return S.intersect(start, dir, dist); } } -void CBone::BoneRotate(const Fvector& _axis, float angle) +void CBone::BoneRotate(const Fvector &_axis, float angle) { - if (!fis_zero(angle)){ - if (Tools->GetSettings(etfCSParent)){ - // bind pose CS - mot_rotate.x += _axis.x*angle; + if (!fis_zero(angle)) + { + if (Tools->GetSettings(etfCSParent)) + { + // bind pose CS + mot_rotate.x += _axis.x*angle; mot_rotate.y += _axis.y*angle; mot_rotate.z += _axis.z*angle; - - ClampByLimits (); -/* - Fmatrix mBind,mBindI,mLocal,mRotate,mLocalBP; - mBind.setXYZi (rest_rotate); - mBindI.invert (mBind); - mLocal.setXYZi (mot_rotate); - Fvector axis; - mBind.transform (axis,_axis); - mRotate.rotation (axis,angle); - mLocal.mulA (mRotate); - - mLocalBP.mul (mBindI,mLocal); - Fvector mot; - mLocalBP.getXYZi (mot); - - IK_data.clamp_by_limits(mot); - mLocalBP.setXYZi (mot); - mLocal.mul (mBind,mLocalBP); - mLocal.getXYZi (mot_rotate); -*/ - }else{ - // local CS - Fmatrix mBind,mBindI,mRotate,mLocal,mLocalBP; - mBind.setXYZi (rest_rotate); - mBindI.invert (mBind); + ClampByLimits(); + /* + Fmatrix mBind,mBindI,mLocal,mRotate,mLocalBP; + mBind.setXYZi (rest_rotate); + mBindI.invert (mBind); + mLocal.setXYZi (mot_rotate); + Fvector axis; + mBind.transform (axis,_axis); + mRotate.rotation (axis,angle); + mLocal.mulA (mRotate); + + mLocalBP.mul (mBindI,mLocal); + Fvector mot; + mLocalBP.getXYZi (mot); + + IK_data.clamp_by_limits(mot); + + mLocalBP.setXYZi (mot); + mLocal.mul (mBind,mLocalBP); + mLocal.getXYZi (mot_rotate); + */ + } + else + { + // local CS + Fmatrix mBind, mBindI, mRotate, mLocal, mLocalBP; + mBind.setXYZi(rest_rotate); + mBindI.invert(mBind); Fvector axis; - _MTransform().transform_dir(axis,_axis); - + _MTransform().transform_dir(axis, _axis); + // rotation - mRotate.rotation (axis, angle); - mLocal.mul (mRotate,_MTransform()); - mLocal.getXYZi (mot_rotate); + mRotate.rotation(axis, angle); + mLocal.mul(mRotate, _MTransform()); + mLocal.getXYZi(mot_rotate); // local clamp - Fvector mot; - mLocalBP.mul (mBindI,mLocal); - mLocalBP.getXYZi (mot); + Fvector mot; + mLocalBP.mul(mBindI, mLocal); + mLocalBP.getXYZi(mot); - IK_data.clamp_by_limits(mot); + IK_data.clamp_by_limits(mot); - mLocalBP.setXYZi (mot); - mLocal.mul (mBind,mLocalBP); - mLocal.getXYZi (mot_rotate); + mLocalBP.setXYZi(mot); + mLocal.mul(mBind, mLocalBP); + mLocal.getXYZi(mot_rotate); } } } -void CBone::BoneMove(const Fvector& _amount) + +void CBone::BoneMove(const Fvector &_amount) { - Fvector amount=_amount; - switch (IK_data.type){ - case jtSlider: - amount.x = 0.f; - amount.y = 0.f; - rest_i_transform.transform (mot_offset); - mot_offset.add (amount); - clamp (mot_offset.z,rest_offset.z+IK_data.limits[0].limit.x,rest_offset.z+IK_data.limits[0].limit.y); - rest_transform.transform (mot_offset); - break; + Fvector amount = _amount; + switch (IK_data.type) + { + case jtSlider: + amount.x = 0.f; + amount.y = 0.f; + rest_i_transform.transform(mot_offset); + mot_offset.add(amount); + clamp(mot_offset.z, rest_offset.z+IK_data.limits[0].limit.x, rest_offset.z+IK_data.limits[0].limit.y); + rest_transform.transform(mot_offset); + break; } } void CBone::ClampByLimits() { - Fmatrix mBind,mBindI,mLocal,mLocalBP; - mBind.setXYZi (rest_rotate); - mBindI.invert (mBind); + Fmatrix mBind, mBindI, mLocal, mLocalBP; + mBind.setXYZi(rest_rotate); + mBindI.invert(mBind); - mLocal.setXYZi (mot_rotate); - mLocalBP.mul (mBindI,mLocal); + mLocal.setXYZi(mot_rotate); + mLocalBP.mul(mBindI, mLocal); Fvector mot; - mLocalBP.getXYZi (mot); + mLocalBP.getXYZi(mot); IK_data.clamp_by_limits(mot); - mLocalBP.setXYZi (mot); - mLocal.mul (mBind,mLocalBP); - mLocal.getXYZi (mot_rotate); -} \ No newline at end of file + mLocalBP.setXYZi(mot); + mLocal.mul(mBind, mLocalBP); + mLocal.getXYZi(mot_rotate); +} + diff --git a/src/editors/ECore/Editor/ColorPicker.cpp b/src/editors/ECore/Editor/ColorPicker.cpp index 89334c903af..5ce427c2026 100644 --- a/src/editors/ECore/Editor/ColorPicker.cpp +++ b/src/editors/ECore/Editor/ColorPicker.cpp @@ -4,56 +4,75 @@ #include "ColorPicker.h" -class CTCD{ +class CTCD +{ public: - TColorDialog* cdColor; + TColorDialog *cdColor; public: - CTCD(){ - cdColor = xr_new((TComponent*)0); + CTCD() + { + cdColor = xr_new((TComponent*)0); cdColor->Options = TColorDialogOptions()<Color = TColor(rgb2bgr(*currentcolor)); - if (TCD.cdColor->Execute()){ - *currentcolor = bgr2rgb(TCD.cdColor->Color); - return true; + if (TCD.cdColor->Execute()) + { + *currentcolor = bgr2rgb(TCD.cdColor->Color); + return true; } return false; - }else{ - u32 clr=*currentcolor; - if (FSColorPickerExecute(&clr, 0, 0)){ - *currentcolor = clr; - return true; + } + else + { + u32 clr = *currentcolor; + if (FSColorPickerExecute(&clr, 0, 0)) + { + *currentcolor = clr; + return true; } return false; } } -bool SelectColorWin(u32* currentcolor, bool bDefaultPicker){ - VERIFY(currentcolor); - if (bDefaultPicker){ +bool SelectColorWin(u32 *currentcolor, bool bDefaultPicker) +{ + VERIFY(currentcolor); + if (bDefaultPicker) + { TCD.cdColor->Color = TColor(*currentcolor); - if (TCD.cdColor->Execute()){ - *currentcolor = TCD.cdColor->Color; - return true; + if (TCD.cdColor->Execute()) + { + *currentcolor = TCD.cdColor->Color; + return true; } return false; - }else{ + } + else + { u32 cur = bgr2rgb(*currentcolor); - if (FSColorPickerExecute(&cur, 0, 0)){ - *currentcolor = rgb2bgr(cur); - return true; + if (FSColorPickerExecute(&cur, 0, 0)) + { + *currentcolor = rgb2bgr(cur); + return true; } - return false; + return false; } } diff --git a/src/editors/ECore/Editor/ColorPicker.h b/src/editors/ECore/Editor/ColorPicker.h index 288beaa7f0c..a1563110076 100644 --- a/src/editors/ECore/Editor/ColorPicker.h +++ b/src/editors/ECore/Editor/ColorPicker.h @@ -2,7 +2,9 @@ #ifndef ColorPickerH #define ColorPickerH -bool ECORE_API SelectColor(u32* currentcolor, bool bDefaultPicker=false); -bool ECORE_API SelectColorWin(u32* currentcolor, bool bDefaultPicker=false); +bool ECORE_API SelectColor(u32 *currentcolor, bool bDefaultPicker = false); +bool ECORE_API SelectColorWin(u32 *currentcolor, bool bDefaultPicker = false); #endif //ColorPicker + + diff --git a/src/editors/ECore/Editor/D3DUtils.cpp b/src/editors/ECore/Editor/D3DUtils.cpp index 731a229be54..c02000cd8da 100644 --- a/src/editors/ECore/Editor/D3DUtils.cpp +++ b/src/editors/ECore/Editor/D3DUtils.cpp @@ -3,8 +3,8 @@ #include "stdafx.h" #pragma hdrstop -#include "gamefont.h" -#include "d3dutils.h" +#include "xrEngine/GameFont.h" +#include "D3DUtils.h" #include "du_box.h" #include "du_sphere.h" #include "du_sphere_part.h" @@ -23,61 +23,61 @@ CDrawUtilities DU_impl; #define LINE_DIVISION 32 // íå ìåíüøå 6!!!!! // for drawing sphere -static Fvector circledef1[LINE_DIVISION]; -static Fvector circledef2[LINE_DIVISION]; -static Fvector circledef3[LINE_DIVISION]; +static Fvector circledef1[LINE_DIVISION ]; +static Fvector circledef2[LINE_DIVISION ]; +static Fvector circledef3[LINE_DIVISION ]; -const u32 boxcolor = D3DCOLOR_RGBA(255,255,255,0); +const u32 boxcolor = D3DCOLOR_RGBA(255, 255, 255, 0); static const int boxvertcount = 48; static Fvector boxvert[boxvertcount]; #ifdef _EDITOR -# define DU_DRAW_RS EDevice.SetRS -# define DU_DRAW_SH_C(a,c){EDevice.SetShader(a);EDevice.SetRS(D3DRS_TEXTUREFACTOR,c);} -# define DU_DRAW_SH(a){EDevice.SetShader(a);EDevice.SetRS(D3DRS_TEXTUREFACTOR,0xFFFFFFFF);} +#define DU_DRAW_RS EDevice.SetRS +#define DU_DRAW_SH_C(a,c){EDevice.SetShader(a);EDevice.SetRS(D3DRS_TEXTUREFACTOR,c);} +#define DU_DRAW_SH(a){EDevice.SetShader(a);EDevice.SetRS(D3DRS_TEXTUREFACTOR,0xFFFFFFFF);} #else -# define DU_DRAW_RS RCache.dbg_SetRS -# define DU_DRAW_SH_C(sh,c){RCache.set_Shader(sh); RCache.set_c ("tfactor",float(color_get_R(c))/255.f,float(color_get_G(c))/255.f,float(color_get_B(c))/255.f,float(color_get_A(c))/255.f);} -# define DU_DRAW_SH(sh){RCache.set_Shader(sh); RCache.set_c ("tfactor",1,1,1,1);} +#define DU_DRAW_RS RCache.dbg_SetRS +#define DU_DRAW_SH_C(sh,c){RCache.set_Shader(sh); RCache.set_c ("tfactor",float(color_get_R(c))/255.f,float(color_get_G(c))/255.f,float(color_get_B(c))/255.f,float(color_get_A(c))/255.f);} +#define DU_DRAW_SH(sh){RCache.set_Shader(sh); RCache.set_c ("tfactor",1,1,1,1);} #endif #ifdef _EDITOR -# define FILL_MODE EDevice.dwFillMode -# define SHADE_MODE EDevice.dwShadeMode -# define SCREEN_QUALITY EDevice.m_ScreenQuality +#define FILL_MODE EDevice.dwFillMode +#define SHADE_MODE EDevice.dwShadeMode +#define SCREEN_QUALITY EDevice.m_ScreenQuality #else -# define FILL_MODE D3DFILL_SOLID -# define SHADE_MODE D3DSHADE_GOURAUD -# define SCREEN_QUALITY 1.f +#define FILL_MODE D3DFILL_SOLID +#define SHADE_MODE D3DSHADE_GOURAUD +#define SCREEN_QUALITY 1.f #endif // identity box -const u32 identboxcolor = D3DCOLOR_RGBA(255,255,255,0); +const u32 identboxcolor = D3DCOLOR_RGBA(255, 255, 255, 0); static const int identboxwirecount = 24; static Fvector identboxwire[identboxwirecount] = { - {-0.5f, -0.5f, -0.5f}, {-0.5f, +0.5f, -0.5f}, {-0.5f, +0.5f, -0.5f}, {+0.5f, +0.5f, -0.5f}, - {+0.5f, +0.5f, -0.5f}, {+0.5f, -0.5f, -0.5f}, {+0.5f, -0.5f, -0.5f}, {-0.5f, -0.5f, -0.5f}, - {-0.5f, +0.5f, +0.5f}, {+0.5f, +0.5f, +0.5f}, {+0.5f, +0.5f, +0.5f}, {+0.5f, -0.5f, +0.5f}, - {+0.5f, -0.5f, +0.5f}, {-0.5f, -0.5f, +0.5f}, {-0.5f, -0.5f, +0.5f}, {-0.5f, +0.5f, +0.5f}, - {-0.5f, +0.5f, -0.5f}, {-0.5f, +0.5f, +0.5f}, {+0.5f, +0.5f, -0.5f}, {+0.5f, +0.5f, +0.5f}, - {+0.5f, -0.5f, -0.5f}, {+0.5f, -0.5f, +0.5f}, {-0.5f, -0.5f, -0.5f}, {-0.5f, -0.5f, +0.5f} + {-0.5f, -0.5f, -0.5f},{-0.5f, +0.5f, -0.5f},{-0.5f, +0.5f, -0.5f},{+0.5f, +0.5f, -0.5f}, + {+0.5f, +0.5f, -0.5f},{+0.5f, -0.5f, -0.5f},{+0.5f, -0.5f, -0.5f},{-0.5f, -0.5f, -0.5f}, + {-0.5f, +0.5f, +0.5f},{+0.5f, +0.5f, +0.5f},{+0.5f, +0.5f, +0.5f},{+0.5f, -0.5f, +0.5f}, + {+0.5f, -0.5f, +0.5f},{-0.5f, -0.5f, +0.5f},{-0.5f, -0.5f, +0.5f},{-0.5f, +0.5f, +0.5f}, + {-0.5f, +0.5f, -0.5f},{-0.5f, +0.5f, +0.5f},{+0.5f, +0.5f, -0.5f},{+0.5f, +0.5f, +0.5f}, + {+0.5f, -0.5f, -0.5f},{+0.5f, -0.5f, +0.5f},{-0.5f, -0.5f, -0.5f},{-0.5f, -0.5f, +0.5f} }; /* static const int identboxindexcount = 36; static const WORD identboxindices[identboxindexcount] = { - 0, 1, 2, 2, 3, 0, - 3, 2, 6, 6, 7, 3, - 6, 4, 5, 6, 5, 7, + 0, 1, 2, 2, 3, 0, + 3, 2, 6, 6, 7, 3, + 6, 4, 5, 6, 5, 7, 4, 1, 5, 1, 0, 5, 3, 5, 0, 3, 7, 5, 1, 4, 6, 1, 6, 2}; static const int identboxindexwirecount = 24; static const WORD identboxindiceswire[identboxindexwirecount] = { - 0, 1, 1, 2, - 2, 3, 3, 0, - 4, 6, 6, 7, + 0, 1, 1, 2, + 2, 3, 3, 0, + 4, 6, 6, 7, 7, 5, 5, 4, 1, 4, 2, 6, 3, 7, 0, 5}; @@ -85,483 +85,591 @@ static const WORD identboxindiceswire[identboxindexwirecount] = { #define SIGN(x) ((x<0)?-1:1) -DEFINE_VECTOR(FVF::L,FLvertexVec,FLvertexIt) +DEFINE_VECTOR(FVF::L, FLvertexVec, FLvertexIt) -static FLvertexVec m_GridPoints; +static FLvertexVec m_GridPoints; -u32 m_ColorAxis = 0xff000000; -u32 m_ColorGrid = 0xff909090; +u32 m_ColorAxis = 0xff000000; +u32 m_ColorGrid = 0xff909090; u32 m_ColorGridTh = 0xffb4b4b4; -u32 m_SelectionRect=D3DCOLOR_RGBA(127,255,127,64); +u32 m_SelectionRect = D3DCOLOR_RGBA(127, 255, 127, 64); u32 m_ColorSafeRect = 0xffB040B0; -void SPrimitiveBuffer::CreateFromData(D3DPRIMITIVETYPE _pt, u32 _p_cnt, u32 FVF, LPVOID vertices, u32 _v_cnt, u16* indices, u32 _i_cnt) +void SPrimitiveBuffer::CreateFromData(D3DPRIMITIVETYPE _pt, u32 _p_cnt, u32 FVF, LPVOID vertices, u32 _v_cnt, u16 *indices, u32 _i_cnt) { - IDirect3DVertexBuffer9* pVB=0; - IDirect3DIndexBuffer9* pIB=0; - p_cnt = _p_cnt; - p_type = _pt; - v_cnt = _v_cnt; - i_cnt = _i_cnt; - u32 stride = D3DXGetFVFVertexSize(FVF); - R_CHK(HW.pDevice->CreateVertexBuffer(v_cnt*stride, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &pVB, 0)); - u8* bytes; - R_CHK (pVB->Lock(0,0,(LPVOID*)&bytes,0)); - FLvertexVec verts (v_cnt); - for (u32 k=0; kUnlock()); - if (i_cnt){ - R_CHK(HW.pDevice->CreateIndexBuffer(i_cnt*sizeof(u16),D3DUSAGE_WRITEONLY,D3DFMT_INDEX16,D3DPOOL_MANAGED,&pIB,NULL)); - R_CHK (pIB->Lock(0,0,(LPVOID*)&bytes,0)); - Memory.mem_copy (bytes,indices,i_cnt*sizeof(u16)); - R_CHK (pIB->Unlock()); - OnRender.bind (this,&SPrimitiveBuffer::RenderDIP); - }else{ - OnRender.bind (this,&SPrimitiveBuffer::RenderDP); - } - pGeom.create (FVF,pVB,pIB); + IDirect3DVertexBuffer9 *pVB = 0; + IDirect3DIndexBuffer9 *pIB = 0; + p_cnt = _p_cnt; + p_type = _pt; + v_cnt = _v_cnt; + i_cnt = _i_cnt; + u32 stride = D3DXGetFVFVertexSize(FVF); + R_CHK(HW.pDevice->CreateVertexBuffer(v_cnt*stride, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &pVB, 0)); + u8 *bytes; + R_CHK(pVB->Lock(0, 0, (LPVOID*)&bytes, 0)); + FLvertexVec verts(v_cnt); + for (u32 k = 0; kUnlock()); + if (i_cnt) + { + R_CHK(HW.pDevice->CreateIndexBuffer(i_cnt*sizeof(u16), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_MANAGED, &pIB, NULL)); + R_CHK(pIB->Lock(0, 0, (LPVOID*)&bytes, 0)); + Memory.mem_copy(bytes, indices, i_cnt*sizeof(u16)); + R_CHK(pIB->Unlock()); + OnRender.bind(this, &SPrimitiveBuffer::RenderDIP); + } + else + { + OnRender.bind(this, &SPrimitiveBuffer::RenderDP); + } + pGeom.create(FVF, pVB, pIB); } + void SPrimitiveBuffer::Destroy() -{ - if (pGeom){ - _RELEASE (pGeom->vb); - _RELEASE (pGeom->ib); - pGeom.destroy (); - } +{ + if (pGeom) + { + _RELEASE(pGeom->vb); + _RELEASE(pGeom->ib); + pGeom.destroy(); + } } -void CDrawUtilities::UpdateGrid(int number_of_cell, float square_size, int subdiv){ - m_GridPoints.clear(); -// grid - int m_GridSubDiv[2]; - int m_GridCounts[2]; +void CDrawUtilities::UpdateGrid(int number_of_cell, float square_size, int subdiv) +{ + m_GridPoints.clear(); + // grid + int m_GridSubDiv[2]; + int m_GridCounts[2]; Fvector2 m_GridStep; - m_GridStep.set(square_size,square_size); - m_GridSubDiv[0] = subdiv; - m_GridSubDiv[1] = subdiv; - m_GridCounts[0] = number_of_cell;//iFloor(size/step)*subdiv; - m_GridCounts[1] = number_of_cell;//iFloor(size/step)*subdiv; - - FVF::L left,right; - left.p.y = right.p.y = 0; - - for(int thin=0; thin<2; thin++){ - for(int i=-m_GridCounts[0]; i<=m_GridCounts[0]; i++){ - if( (!!thin) != !!(i%m_GridSubDiv[0]) ){ - left.p.z = -m_GridCounts[1]*m_GridStep.y; - right.p.z = m_GridCounts[1]*m_GridStep.y; - left.p.x = i*m_GridStep.x; - right.p.x = left.p.x; - left.color = (i%m_GridSubDiv[0]) ? m_ColorGrid : m_ColorGridTh; - right.color = left.color; - m_GridPoints.push_back( left ); - m_GridPoints.push_back( right ); - } - } - for(i=-m_GridCounts[1]; i<=m_GridCounts[1]; i++){ - if( (!!thin) != !!(i%m_GridSubDiv[1]) ){ - left.p.x = -m_GridCounts[0]*m_GridStep.x; - right.p.x = m_GridCounts[0]*m_GridStep.x; - left.p.z = i*m_GridStep.y; - right.p.z = left.p.z; - left.color = (i%m_GridSubDiv[1]) ? m_ColorGrid : m_ColorGridTh; - right.color = left.color; - m_GridPoints.push_back( left ); - m_GridPoints.push_back( right ); - } - } - } + m_GridStep.set(square_size, square_size); + m_GridSubDiv[0] = subdiv; + m_GridSubDiv[1] = subdiv; + m_GridCounts[0] = number_of_cell;//iFloor(size/step)*subdiv; + m_GridCounts[1] = number_of_cell;//iFloor(size/step)*subdiv; + + FVF::L left, right; + left.p.y = right.p.y = 0; + + for (int thin = 0; thin<2; thin++) + { + for (int i = -m_GridCounts[0]; i<=m_GridCounts[0]; i++) + { + if ((!!thin)!=!!(i%m_GridSubDiv[0])) + { + left.p.z = -m_GridCounts[1]*m_GridStep.y; + right.p.z = m_GridCounts[1]*m_GridStep.y; + left.p.x = i*m_GridStep.x; + right.p.x = left.p.x; + left.color = (i%m_GridSubDiv[0]) ? m_ColorGrid : m_ColorGridTh; + right.color = left.color; + m_GridPoints.push_back(left); + m_GridPoints.push_back(right); + } + } + for (i = -m_GridCounts[1]; i<=m_GridCounts[1]; i++) + { + if ((!!thin)!=!!(i%m_GridSubDiv[1])) + { + left.p.x = -m_GridCounts[0]*m_GridStep.x; + right.p.x = m_GridCounts[0]*m_GridStep.x; + left.p.z = i*m_GridStep.y; + right.p.z = left.p.z; + left.color = (i%m_GridSubDiv[1]) ? m_ColorGrid : m_ColorGridTh; + right.color = left.color; + m_GridPoints.push_back(left); + m_GridPoints.push_back(right); + } + } + } } void CDrawUtilities::OnDeviceCreate() { - EDevice.seqRender.Add (this,REG_PRIORITY_LOW-1000); - - m_SolidBox.CreateFromData (D3DPT_TRIANGLELIST,DU_BOX_NUMFACES, D3DFVF_XYZ|D3DFVF_DIFFUSE,du_box_vertices, DU_BOX_NUMVERTEX, du_box_faces, DU_BOX_NUMFACES*3); - m_SolidCone.CreateFromData (D3DPT_TRIANGLELIST,DU_CONE_NUMFACES, D3DFVF_XYZ|D3DFVF_DIFFUSE,du_cone_vertices, DU_CONE_NUMVERTEX, du_cone_faces, DU_CONE_NUMFACES*3); - m_SolidSphere.CreateFromData (D3DPT_TRIANGLELIST,DU_SPHERE_NUMFACES, D3DFVF_XYZ|D3DFVF_DIFFUSE,du_sphere_vertices, DU_SPHERE_NUMVERTEX, du_sphere_faces, DU_SPHERE_NUMFACES*3); - m_SolidSpherePart.CreateFromData(D3DPT_TRIANGLELIST,DU_SPHERE_PART_NUMFACES,D3DFVF_XYZ|D3DFVF_DIFFUSE,du_sphere_part_vertices, DU_SPHERE_PART_NUMVERTEX, du_sphere_part_faces, DU_SPHERE_PART_NUMFACES*3); - m_SolidCylinder.CreateFromData (D3DPT_TRIANGLELIST,DU_CYLINDER_NUMFACES, D3DFVF_XYZ|D3DFVF_DIFFUSE,du_cylinder_vertices, DU_CYLINDER_NUMVERTEX, du_cylinder_faces, DU_CYLINDER_NUMFACES*3); - m_WireBox.CreateFromData (D3DPT_LINELIST, DU_BOX_NUMLINES, D3DFVF_XYZ|D3DFVF_DIFFUSE,du_box_vertices, DU_BOX_NUMVERTEX, du_box_lines, DU_BOX_NUMLINES*2); - m_WireCone.CreateFromData (D3DPT_LINELIST, DU_CONE_NUMLINES, D3DFVF_XYZ|D3DFVF_DIFFUSE,du_cone_vertices, DU_CONE_NUMVERTEX, du_cone_lines, DU_CONE_NUMLINES*2); - m_WireSphere.CreateFromData (D3DPT_LINELIST, DU_SPHERE_NUMLINES, D3DFVF_XYZ|D3DFVF_DIFFUSE,du_sphere_verticesl, DU_SPHERE_NUMVERTEXL, du_sphere_lines, DU_SPHERE_NUMLINES*2); - m_WireSpherePart.CreateFromData (D3DPT_LINELIST, DU_SPHERE_PART_NUMLINES,D3DFVF_XYZ|D3DFVF_DIFFUSE,du_sphere_part_vertices, DU_SPHERE_PART_NUMVERTEX, du_sphere_part_lines, DU_SPHERE_PART_NUMLINES*2); - m_WireCylinder.CreateFromData (D3DPT_LINELIST, DU_CYLINDER_NUMLINES, D3DFVF_XYZ|D3DFVF_DIFFUSE,du_cylinder_vertices, DU_CYLINDER_NUMVERTEX, du_cylinder_lines, DU_CYLINDER_NUMLINES*2); - - for(int i=0;i("hud_font_small"); + m_Font = xr_new("hud_font_small"); m_axis_object = NULL; } void CDrawUtilities::OnDeviceDestroy() { - EDevice.seqRender.Remove (this); - xr_delete (m_Font); - m_SolidBox.Destroy (); - m_SolidCone.Destroy (); - m_SolidSphere.Destroy (); - m_SolidSpherePart.Destroy (); - m_SolidCylinder.Destroy (); - m_WireBox.Destroy (); - m_WireCone.Destroy (); - m_WireSphere.Destroy (); - m_WireSpherePart.Destroy (); - m_WireCylinder.Destroy (); - - vs_L.destroy (); - vs_TL.destroy (); - vs_LIT.destroy (); - Lib.RemoveEditObject(m_axis_object); + EDevice.seqRender.Remove(this); + xr_delete(m_Font); + m_SolidBox.Destroy(); + m_SolidCone.Destroy(); + m_SolidSphere.Destroy(); + m_SolidSpherePart.Destroy(); + m_SolidCylinder.Destroy(); + m_WireBox.Destroy(); + m_WireCone.Destroy(); + m_WireSphere.Destroy(); + m_WireSpherePart.Destroy(); + m_WireCylinder.Destroy(); + + vs_L.destroy(); + vs_TL.destroy(); + vs_LIT.destroy(); + Lib.RemoveEditObject(m_axis_object); } + //---------------- -void CDrawUtilities::DrawSpotLight(const Fvector& p, const Fvector& d, float range, float phi, u32 clr) +void CDrawUtilities::DrawSpotLight(const Fvector &p, const Fvector &d, float range, float phi, u32 clr) { Fmatrix T; - Fvector p1; - float H,P; - float da = PI_MUL_2/LINE_DIVISION; - float b = range*_cos(PI_DIV_2-phi/2); - float a = range*_sin(PI_DIV_2-phi/2); - d.getHP (H,P); - T.setHPB (H,P,0); + Fvector p1; + float H, P; + float da = PI_MUL_2/LINE_DIVISION; + float b = range*_cos(PI_DIV_2-phi/2); + float a = range*_sin(PI_DIV_2-phi/2); + d.getHP(H, P); + T.setHPB(H, P, 0); T.translate_over(p); - _VertexStream* Stream = &RCache.Vertex; - u32 vBase; - FVF::L* pv = (FVF::L*)Stream->Lock(LINE_DIVISION*2+2,vs_L->vb_stride,vBase); - for (float angle=0; angleLock(LINE_DIVISION*2+2, vs_L->vb_stride, vBase); + for (float angle = 0; angleset (p,clr); pv++; - pv->set (p1,clr); pv++; + pv->set(p, clr); + pv++; + pv->set(p1, clr); + pv++; } - p1.mad (p,d,range); - pv->set (p,clr); pv++; - pv->set (p1,clr); pv++; - Stream->Unlock (LINE_DIVISION*2+2,vs_L->vb_stride); + p1.mad(p, d, range); + pv->set(p, clr); + pv++; + pv->set(p1, clr); + pv++; + Stream->Unlock(LINE_DIVISION*2+2, vs_L->vb_stride); // and Render it as triangle list - DU_DRAW_DP (D3DPT_LINELIST,vs_L,vBase,LINE_DIVISION+1); + DU_DRAW_DP(D3DPT_LINELIST, vs_L, vBase,LINE_DIVISION+1); } -void CDrawUtilities::DrawDirectionalLight(const Fvector& p, const Fvector& d, float radius, float range, u32 c) +void CDrawUtilities::DrawDirectionalLight(const Fvector &p, const Fvector &d, float radius, float range, u32 c) { - float r=radius*0.71f; - Fvector R,N,D; D.normalize(d); - Fmatrix rot; - - N.set (0,1,0); - if (_abs(D.y)>0.99f) N.set(1,0,0); - R.crossproduct(N,D); R.normalize(); - N.crossproduct(D,R); N.normalize(); - rot.set(R,N,D,p); - float sz=radius+range; - - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase; - FVF::L* pv = (FVF::L*)Stream->Lock(6,vs_L->vb_stride,vBase); - pv->set (0,0,r, c); rot.transform_tiny(pv->p); pv++; - pv->set (0,0,sz, c); rot.transform_tiny(pv->p); pv++; - pv->set (-r,0,r, c); rot.transform_tiny(pv->p); pv++; - pv->set (-r,0,sz, c); rot.transform_tiny(pv->p); pv++; - pv->set (r,0,r, c); rot.transform_tiny(pv->p); pv++; - pv->set (r,0,sz, c); rot.transform_tiny(pv->p); pv++; - Stream->Unlock (6,vs_L->vb_stride); - - // and Render it as triangle list - DU_DRAW_DP (D3DPT_LINELIST,vs_L,vBase,3); + float r = radius*0.71f; + Fvector R, N, D; + D.normalize(d); + Fmatrix rot; + + N.set(0, 1, 0); + if (_abs(D.y)>0.99f) + N.set(1, 0, 0); + R.crossproduct(N, D); + R.normalize(); + N.crossproduct(D, R); + N.normalize(); + rot.set(R, N, D, p); + float sz = radius+range; + + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase; + FVF::L *pv = (FVF::L*)Stream->Lock(6, vs_L->vb_stride, vBase); + pv->set(0, 0, r, c); + rot.transform_tiny(pv->p); + pv++; + pv->set(0, 0, sz, c); + rot.transform_tiny(pv->p); + pv++; + pv->set(-r, 0, r, c); + rot.transform_tiny(pv->p); + pv++; + pv->set(-r, 0, sz, c); + rot.transform_tiny(pv->p); + pv++; + pv->set(r, 0, r, c); + rot.transform_tiny(pv->p); + pv++; + pv->set(r, 0, sz, c); + rot.transform_tiny(pv->p); + pv++; + Stream->Unlock(6, vs_L->vb_stride); + + // and Render it as triangle list + DU_DRAW_DP(D3DPT_LINELIST, vs_L, vBase, 3); Fbox b; - b.min.set(-r,-r,-r); - b.max.set(r,r,r); + b.min.set(-r, -r, -r); + b.max.set(r, r, r); - DrawLineSphere ( p, radius, c, true ); + DrawLineSphere(p, radius, c, true); } -void CDrawUtilities::DrawPointLight(const Fvector& p, float radius, u32 c) +void CDrawUtilities::DrawPointLight(const Fvector &p, float radius, u32 c) { - RCache.set_xform_world(Fidentity); - DrawCross(p, radius,radius,radius, radius,radius,radius, c, true); + RCache.set_xform_world(Fidentity); + DrawCross(p, radius, radius, radius, radius, radius, radius, c, true); } void CDrawUtilities::DrawEntity(u32 clr, ref_shader s) { - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase; - FVF::L* pv = (FVF::L*)Stream->Lock(5,vs_L->vb_stride,vBase); - pv->set (0.f,0.f,0.f,clr); pv++; - pv->set (0.f,1.f,0.f,clr); pv++; - pv->set (0.f,1.f,.5f,clr); pv++; - pv->set (0.f,.5f,.5f,clr); pv++; - pv->set (0.f,.5f,0.f,clr); pv++; - Stream->Unlock (5,vs_L->vb_stride); - // render flagshtok - DU_DRAW_SH (EDevice.m_WireShader); - DU_DRAW_DP (D3DPT_LINESTRIP,vs_L,vBase,4); - - if (s) DU_DRAW_SH(s); + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase; + FVF::L *pv = (FVF::L*)Stream->Lock(5, vs_L->vb_stride, vBase); + pv->set(0.f, 0.f, 0.f, clr); + pv++; + pv->set(0.f, 1.f, 0.f, clr); + pv++; + pv->set(0.f, 1.f, .5f, clr); + pv++; + pv->set(0.f, .5f, .5f, clr); + pv++; + pv->set(0.f, .5f, 0.f, clr); + pv++; + Stream->Unlock(5, vs_L->vb_stride); + // render flagshtok + DU_DRAW_SH (EDevice.m_WireShader); + DU_DRAW_DP(D3DPT_LINESTRIP, vs_L, vBase, 4); + + if (s) + DU_DRAW_SH(s); { // fill VB - FVF::LIT* pv = (FVF::LIT*)Stream->Lock(6,vs_LIT->vb_stride,vBase); - pv->set (0.f,1.f,0.f,clr,0.f,0.f); pv++; - pv->set (0.f,1.f,.5f,clr,1.f,0.f); pv++; - pv->set (0.f,.5f,.5f,clr,1.f,1.f); pv++; - pv->set (0.f,.5f,0.f,clr,0.f,1.f); pv++; - pv->set (0.f,.5f,.5f,clr,1.f,1.f); pv++; - pv->set (0.f,1.f,.5f,clr,1.f,0.f); pv++; - Stream->Unlock (6,vs_LIT->vb_stride); + FVF::LIT*pv = (FVF::LIT*)Stream->Lock(6, vs_LIT->vb_stride, vBase); + pv->set(0.f, 1.f, 0.f, clr, 0.f, 0.f); + pv++; + pv->set(0.f, 1.f, .5f, clr, 1.f, 0.f); + pv++; + pv->set(0.f, .5f, .5f, clr, 1.f, 1.f); + pv++; + pv->set(0.f, .5f, 0.f, clr, 0.f, 1.f); + pv++; + pv->set(0.f, .5f, .5f, clr, 1.f, 1.f); + pv++; + pv->set(0.f, 1.f, .5f, clr, 1.f, 0.f); + pv++; + Stream->Unlock(6, vs_LIT->vb_stride); // and Render it as line list - DU_DRAW_DP (D3DPT_TRIANGLEFAN,vs_LIT,vBase,4); + DU_DRAW_DP(D3DPT_TRIANGLEFAN, vs_LIT, vBase, 4); } } -void CDrawUtilities::DrawFlag(const Fvector& p, float heading, float height, float sz, float sz_fl, u32 clr, BOOL bDrawEntity){ - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase; - FVF::L* pv = (FVF::L*)Stream->Lock(2,vs_L->vb_stride,vBase); - pv->set (p,clr); pv++; - pv->set (p.x,p.y+height,p.z,clr); pv++; - Stream->Unlock (2,vs_L->vb_stride); - // and Render it as triangle list - DU_DRAW_DP (D3DPT_LINELIST,vs_L,vBase,1); - - if (bDrawEntity){ - // fill VB - float rx = _sin(heading); - float rz = _cos(heading); - FVF::L* pv = (FVF::L*)Stream->Lock(6,vs_L->vb_stride,vBase); - sz *= 0.8f; - pv->set (p.x,p.y+height,p.z,clr); pv++; - pv->set (p.x+rx*sz,p.y+height,p.z+rz*sz,clr); pv++; - sz *= 0.5f; - pv->set (p.x,p.y+height*(1.f-sz_fl*.5f),p.z,clr); pv++; - pv->set (p.x+rx*sz*0.6f,p.y+height*(1.f-sz_fl*.5f),p.z+rz*sz*0.75f,clr); pv++; - pv->set (p.x,p.y+height*(1.f-sz_fl),p.z,clr); pv++; - pv->set (p.x+rx*sz,p.y+height*(1.f-sz_fl),p.z+rz*sz,clr); pv++; - Stream->Unlock (6,vs_L->vb_stride); - // and Render it as line list - DU_DRAW_DP (D3DPT_LINELIST,vs_L,vBase,3); - }else{ - // fill VB - FVF::L* pv = (FVF::L*)Stream->Lock(6,vs_L->vb_stride,vBase); - pv->set (p.x,p.y+height*(1.f-sz_fl),p.z,clr); pv++; - pv->set (p.x,p.y+height,p.z,clr); pv++; - pv->set (p.x+_sin(heading)*sz,((pv-2)->p.y+(pv-1)->p.y)/2,p.z+_cos(heading)*sz,clr); pv++; - pv->set (*(pv-3)); pv++; - pv->set (*(pv-2)); pv++; - pv->set (*(pv-4)); pv++; - Stream->Unlock (6,vs_L->vb_stride); - // and Render it as triangle list - DU_DRAW_DP (D3DPT_TRIANGLELIST,vs_L,vBase,2); +void CDrawUtilities::DrawFlag(const Fvector &p, float heading, float height, float sz, float sz_fl, u32 clr, BOOL bDrawEntity) +{ + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase; + FVF::L *pv = (FVF::L*)Stream->Lock(2, vs_L->vb_stride, vBase); + pv->set(p, clr); + pv++; + pv->set(p.x, p.y+height, p.z, clr); + pv++; + Stream->Unlock(2, vs_L->vb_stride); + // and Render it as triangle list + DU_DRAW_DP(D3DPT_LINELIST, vs_L, vBase, 1); + + if (bDrawEntity) + { + // fill VB + float rx = _sin(heading); + float rz = _cos(heading); + FVF::L*pv = (FVF::L*)Stream->Lock(6, vs_L->vb_stride, vBase); + sz *= 0.8f; + pv->set(p.x, p.y+height, p.z, clr); + pv++; + pv->set(p.x+rx*sz, p.y+height, p.z+rz*sz, clr); + pv++; + sz *= 0.5f; + pv->set(p.x, p.y+height*(1.f-sz_fl*.5f), p.z, clr); + pv++; + pv->set(p.x+rx*sz*0.6f, p.y+height*(1.f-sz_fl*.5f), p.z+rz*sz*0.75f, clr); + pv++; + pv->set(p.x, p.y+height*(1.f-sz_fl), p.z, clr); + pv++; + pv->set(p.x+rx*sz, p.y+height*(1.f-sz_fl), p.z+rz*sz, clr); + pv++; + Stream->Unlock(6, vs_L->vb_stride); + // and Render it as line list + DU_DRAW_DP(D3DPT_LINELIST, vs_L, vBase, 3); + } + else + { + // fill VB + FVF::L*pv = (FVF::L*)Stream->Lock(6, vs_L->vb_stride, vBase); + pv->set(p.x, p.y+height*(1.f-sz_fl), p.z, clr); + pv++; + pv->set(p.x, p.y+height, p.z, clr); + pv++; + pv->set(p.x+_sin(heading)*sz, ((pv-2)->p.y+(pv-1)->p.y)/2, p.z+_cos(heading)*sz, clr); + pv++; + pv->set(*(pv-3)); + pv++; + pv->set(*(pv-2)); + pv++; + pv->set(*(pv-4)); + pv++; + Stream->Unlock(6, vs_L->vb_stride); + // and Render it as triangle list + DU_DRAW_DP(D3DPT_TRIANGLELIST, vs_L, vBase, 2); } } //------------------------------------------------------------------------------ -void CDrawUtilities::DrawRomboid(const Fvector& p, float r, u32 c) +void CDrawUtilities::DrawRomboid(const Fvector &p, float r, u32 c) { -static const u32 IL[24]={0,2, 2,5, 0,5, 3,5, 3,0, 4,3, 4,0, 4,2, 1,2, 1,5, 1,3, 1,4}; -static const u32 IT[24]={2,4,0, 4,3,0, 3,5,0, 5,2,0, 4,2,1, 2,5,1, 5,3,1, 3,4,1}; -static Fvector PT [6] = { - {0.0f, 1.0f, 0.0f}, - {0.0f, -1.0f, 0.0f}, - {0.0f, 0.0f, -1.0f}, - {0.0f, 0.0f, 1.0f}, - {-1.0f, 0.0f, 0.0f}, - {1.0f, 0.0f, 0.0f}, -}; + static const u32 IL[24] = {0,2, 2,5, 0,5, 3,5, 3,0, 4,3, 4,0, 4,2, 1,2, 1,5, 1,3, 1,4}; + static const u32 IT[24] = {2,4,0, 4,3,0, 3,5,0, 5,2,0, 4,2,1, 2,5,1, 5,3,1, 3,4,1}; + static Fvector PT [6] = { + {0.0f, 1.0f, 0.0f}, + {0.0f, -1.0f, 0.0f}, + {0.0f, 0.0f, -1.0f}, + {0.0f, 0.0f, 1.0f}, + {-1.0f, 0.0f, 0.0f}, + {1.0f, 0.0f, 0.0f}, + }; Fcolor C; - C.set (c); - C.mul_rgb (0.75); - u32 c1 = C.get(); + C.set(c); + C.mul_rgb(0.75); + u32 c1 = C.get(); - DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 8, p, PT, 6, IT, 24, c1, r); - DrawIndexedPrimitive(D3DPT_LINELIST, 12, p, PT, 6, IL, 24, c, r); - return; + DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 8, p, PT, 6, IT, 24, c1, r); + DrawIndexedPrimitive(D3DPT_LINELIST, 12, p, PT, 6, IL, 24, c, r); + return; u32 vBase, iBase; int k; - FVF::L* pv; - WORD* i; - _VertexStream* Stream = &RCache.Vertex; - _IndexStream* StreamI = &RCache.Index; - - // fill VB - pv = (FVF::L*)Stream->Lock(6,vs_L->vb_stride,vBase); - pv->set (p.x, p.y+r, p.z, c1); pv++; - pv->set (p.x, p.y-r, p.z, c1); pv++; - pv->set (p.x, p.y, p.z-r, c1); pv++; - pv->set (p.x, p.y, p.z+r, c1); pv++; - pv->set (p.x-r, p.y, p.z, c1); pv++; - pv->set (p.x+r, p.y, p.z, c1); pv++; - Stream->Unlock (6,vs_L->vb_stride); - - i = StreamI->Lock(24,iBase); - for (k=0; k<24; k++,i++) *i=IT[k]; + FVF::L *pv; + WORD*i; + _VertexStream *Stream = &RCache.Vertex; + _IndexStream *StreamI = &RCache.Index; + + // fill VB + pv = (FVF::L*)Stream->Lock(6, vs_L->vb_stride, vBase); + pv->set(p.x, p.y+r, p.z, c1); + pv++; + pv->set(p.x, p.y-r, p.z, c1); + pv++; + pv->set(p.x, p.y, p.z-r, c1); + pv++; + pv->set(p.x, p.y, p.z+r, c1); + pv++; + pv->set(p.x-r, p.y, p.z, c1); + pv++; + pv->set(p.x+r, p.y, p.z, c1); + pv++; + Stream->Unlock(6, vs_L->vb_stride); + + i = StreamI->Lock(24, iBase); + for (k = 0; k<24; k++,i++) + *i = IT[k]; StreamI->Unlock(24); - // and Render it as triangle list - DU_DRAW_DIP (D3DPT_TRIANGLELIST,vs_L,vBase,0,6, iBase,12); + // and Render it as triangle list + DU_DRAW_DIP(D3DPT_TRIANGLELIST, vs_L, vBase, 0, 6, iBase, 12); // draw lines - pv = (FVF::L*)Stream->Lock(6,vs_L->vb_stride,vBase); - pv->set (p.x, p.y+r, p.z, c); pv++; - pv->set (p.x, p.y-r, p.z, c); pv++; - pv->set (p.x, p.y, p.z-r, c); pv++; - pv->set (p.x, p.y, p.z+r, c); pv++; - pv->set (p.x-r, p.y, p.z, c); pv++; - pv->set (p.x+r, p.y, p.z, c); pv++; - Stream->Unlock (6,vs_L->vb_stride); - - i = StreamI->Lock(24,iBase); - for (k=0; k<24; k++,i++) *i=IL[k]; - StreamI->Unlock (24); - - DU_DRAW_DIP (D3DPT_LINELIST,vs_L,vBase,0,6, iBase,12); - + pv = (FVF::L*)Stream->Lock(6, vs_L->vb_stride, vBase); + pv->set(p.x, p.y+r, p.z, c); + pv++; + pv->set(p.x, p.y-r, p.z, c); + pv++; + pv->set(p.x, p.y, p.z-r, c); + pv++; + pv->set(p.x, p.y, p.z+r, c); + pv++; + pv->set(p.x-r, p.y, p.z, c); + pv++; + pv->set(p.x+r, p.y, p.z, c); + pv++; + Stream->Unlock(6, vs_L->vb_stride); + + i = StreamI->Lock(24, iBase); + for (k = 0; k<24; k++,i++) + *i = IL[k]; + StreamI->Unlock(24); + + DU_DRAW_DIP(D3DPT_LINELIST, vs_L, vBase, 0, 6, iBase, 12); } + //------------------------------------------------------------------------------ -void CDrawUtilities::DrawSound(const Fvector& p, float r, u32 c){ - DrawCross(p, r,r,r, r,r,r, c, true); +void CDrawUtilities::DrawSound(const Fvector &p, float r, u32 c) +{ + DrawCross(p, r, r, r, r, r, r, c, true); } + //------------------------------------------------------------------------------ -void CDrawUtilities::DrawIdentCone (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w) +void CDrawUtilities::DrawIdentCone(BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w) { - if (bWire){ - DU_DRAW_SH_C (EDevice.m_WireShader, clr_w); - m_WireCone.Render (); + if (bWire) + { + DU_DRAW_SH_C (EDevice.m_WireShader, clr_w); + m_WireCone.Render(); } - if (bSolid){ - DU_DRAW_SH_C (color_get_A(clr_s)>=254?EDevice.m_WireShader:EDevice.m_SelectionShader, clr_s); - m_SolidCone.Render (); + if (bSolid) + { + DU_DRAW_SH_C (color_get_A(clr_s)>=254?EDevice.m_WireShader:EDevice.m_SelectionShader, clr_s); + m_SolidCone.Render(); } - DU_DRAW_RS (D3DRS_TEXTUREFACTOR, 0xffffffff); + DU_DRAW_RS(D3DRS_TEXTUREFACTOR, 0xffffffff); } -void CDrawUtilities::DrawIdentSphere (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w) +void CDrawUtilities::DrawIdentSphere(BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w) { - if (bWire){ - DU_DRAW_SH_C (EDevice.m_WireShader,clr_w); - m_WireSphere.Render (); + if (bWire) + { + DU_DRAW_SH_C (EDevice.m_WireShader,clr_w); + m_WireSphere.Render(); } - if (bSolid){ - DU_DRAW_SH_C (color_get_A(clr_s)>=254?EDevice.m_WireShader:EDevice.m_SelectionShader,clr_s); - m_SolidSphere.Render(); + if (bSolid) + { + DU_DRAW_SH_C (color_get_A(clr_s)>=254?EDevice.m_WireShader:EDevice.m_SelectionShader,clr_s); + m_SolidSphere.Render(); } - DU_DRAW_RS (D3DRS_TEXTUREFACTOR, 0xffffffff); + DU_DRAW_RS(D3DRS_TEXTUREFACTOR, 0xffffffff); } void CDrawUtilities::DrawIdentSpherePart(BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w) { - if (bWire){ - DU_DRAW_SH_C (EDevice.m_WireShader,clr_w); - m_WireSpherePart.Render (); + if (bWire) + { + DU_DRAW_SH_C (EDevice.m_WireShader,clr_w); + m_WireSpherePart.Render(); } - if (bSolid){ - DU_DRAW_SH_C (color_get_A(clr_s)>=254?EDevice.m_WireShader:EDevice.m_SelectionShader,clr_s); - m_SolidSpherePart.Render(); + if (bSolid) + { + DU_DRAW_SH_C (color_get_A(clr_s)>=254?EDevice.m_WireShader:EDevice.m_SelectionShader,clr_s); + m_SolidSpherePart.Render(); } - DU_DRAW_RS (D3DRS_TEXTUREFACTOR, 0xffffffff); + DU_DRAW_RS(D3DRS_TEXTUREFACTOR, 0xffffffff); } -void CDrawUtilities::DrawIdentCylinder (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w) +void CDrawUtilities::DrawIdentCylinder(BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w) { - if (bWire){ - DU_DRAW_SH_C (EDevice.m_WireShader,clr_w); - m_WireCylinder.Render (); + if (bWire) + { + DU_DRAW_SH_C (EDevice.m_WireShader,clr_w); + m_WireCylinder.Render(); } - if (bSolid){ - DU_DRAW_SH_C (color_get_A(clr_s)>=254?EDevice.m_WireShader:EDevice.m_SelectionShader,clr_s); - m_SolidCylinder.Render (); + if (bSolid) + { + DU_DRAW_SH_C (color_get_A(clr_s)>=254?EDevice.m_WireShader:EDevice.m_SelectionShader,clr_s); + m_SolidCylinder.Render(); } - DU_DRAW_RS (D3DRS_TEXTUREFACTOR, 0xffffffff); + DU_DRAW_RS(D3DRS_TEXTUREFACTOR, 0xffffffff); } void CDrawUtilities::DrawIdentBox(BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w) { - if (bWire){ - DU_DRAW_SH_C (EDevice.m_WireShader,clr_w); - m_WireBox.Render (); + if (bWire) + { + DU_DRAW_SH_C (EDevice.m_WireShader,clr_w); + m_WireBox.Render(); } - if (bSolid){ - DU_DRAW_SH_C (color_get_A(clr_s)>=254?EDevice.m_WireShader:EDevice.m_SelectionShader,clr_s); - m_SolidBox.Render (); + if (bSolid) + { + DU_DRAW_SH_C (color_get_A(clr_s)>=254?EDevice.m_WireShader:EDevice.m_SelectionShader,clr_s); + m_SolidBox.Render(); } - DU_DRAW_RS (D3DRS_TEXTUREFACTOR, 0xffffffff); + DU_DRAW_RS(D3DRS_TEXTUREFACTOR, 0xffffffff); } -void CDrawUtilities::DrawLineSphere(const Fvector& p, float radius, u32 c, BOOL bCross) +void CDrawUtilities::DrawLineSphere(const Fvector &p, float radius, u32 c, BOOL bCross) { - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase; + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase; int i; - FVF::L* pv; + FVF::L *pv; // seg 0 - pv = (FVF::L*)Stream->Lock(LINE_DIVISION+1,vs_L->vb_stride,vBase); - for( i=0; ip.mad(p,circledef1[i],radius); pv->color=c;} + pv = (FVF::L*)Stream->Lock(LINE_DIVISION+1, vs_L->vb_stride, vBase); + for (i = 0; ip.mad(p, circledef1[i], radius); + pv->color = c; + } pv->set(*(pv-LINE_DIVISION)); - Stream->Unlock (LINE_DIVISION+1,vs_L->vb_stride); - DU_DRAW_DP (D3DPT_LINESTRIP,vs_L,vBase,LINE_DIVISION); + Stream->Unlock(LINE_DIVISION+1, vs_L->vb_stride); + DU_DRAW_DP(D3DPT_LINESTRIP, vs_L, vBase,LINE_DIVISION); // seg 1 - pv = (FVF::L*)Stream->Lock(LINE_DIVISION+1,vs_L->vb_stride,vBase); - for( i=0; ip.mad(p,circledef2[i],radius); pv->color=c; pv++; } - pv->set(*(pv-LINE_DIVISION)); pv++; - Stream->Unlock (LINE_DIVISION+1,vs_L->vb_stride); - DU_DRAW_DP (D3DPT_LINESTRIP,vs_L,vBase,LINE_DIVISION); + pv = (FVF::L*)Stream->Lock(LINE_DIVISION+1, vs_L->vb_stride, vBase); + for (i = 0; ip.mad(p, circledef2[i], radius); + pv->color = c; + pv++; + } + pv->set(*(pv-LINE_DIVISION)); + pv++; + Stream->Unlock(LINE_DIVISION+1, vs_L->vb_stride); + DU_DRAW_DP(D3DPT_LINESTRIP, vs_L, vBase,LINE_DIVISION); // seg 2 - pv = (FVF::L*)Stream->Lock(LINE_DIVISION+1,vs_L->vb_stride,vBase); - for( i=0; ip.mad(p,circledef3[i],radius); pv->color=c; pv++; } - pv->set(*(pv-LINE_DIVISION)); pv++; - Stream->Unlock (LINE_DIVISION+1,vs_L->vb_stride); - DU_DRAW_DP (D3DPT_LINESTRIP,vs_L,vBase,LINE_DIVISION); + pv = (FVF::L*)Stream->Lock(LINE_DIVISION+1, vs_L->vb_stride, vBase); + for (i = 0; ip.mad(p, circledef3[i], radius); + pv->color = c; + pv++; + } + pv->set(*(pv-LINE_DIVISION)); + pv++; + Stream->Unlock(LINE_DIVISION+1, vs_L->vb_stride); + DU_DRAW_DP(D3DPT_LINESTRIP, vs_L, vBase,LINE_DIVISION); - if (bCross) DrawCross(p, radius,radius,radius, radius,radius,radius, c); + if (bCross) + DrawCross(p, radius, radius, radius, radius, radius, radius, c); } //---------------------------------------------------- @@ -571,737 +679,908 @@ IC float _x2real (float x) IC float _y2real (float y) { return (y+1)*EDevice.m_RenderHeight_2;} #else -IC float _x2real (float x) -{ return (x+1)*EDevice.dwWidth*0.5f; } -IC float _y2real (float y) -{ return (y+1)*EDevice.dwHeight*0.5f;} +IC + +float _x2real(float x) +{ + return (x+1)*EDevice.dwWidth*0.5f; +} + +IC + +float _y2real(float y) +{ + return (y+1)*EDevice.dwHeight*0.5f; +} #endif -void CDrawUtilities::dbgDrawPlacement(const Fvector& p, int sz, u32 clr, LPCSTR caption, u32 clr_font) +void CDrawUtilities::dbgDrawPlacement(const Fvector &p, int sz, u32 clr, LPCSTR caption, u32 clr_font) { - VERIFY( EDevice.b_is_Ready ); + VERIFY(EDevice.b_is_Ready); Fvector c; - float w = p.x*EDevice.mFullTransform._14 + p.y*EDevice.mFullTransform._24 + p.z*EDevice.mFullTransform._34 + EDevice.mFullTransform._44; - if (w<0) return; // culling + float w = p.x*EDevice.mFullTransform._14+p.y*EDevice.mFullTransform._24+p.z*EDevice.mFullTransform._34+EDevice.mFullTransform._44; + if (w<0) + return; // culling - float s = (float)sz; - EDevice.mFullTransform.transform(c,p); - c.x = (float)iFloor(_x2real(c.x)); c.y = (float)iFloor(_y2real(-c.y)); + float s = (float)sz; + EDevice.mFullTransform.transform(c, p); + c.x = (float)iFloor(_x2real(c.x)); + c.y = (float)iFloor(_y2real(-c.y)); - _VertexStream* Stream = &RCache.Vertex; + _VertexStream *Stream = &RCache.Vertex; u32 vBase; - FVF::TL* pv = (FVF::TL*)Stream->Lock(5,vs_TL->vb_stride,vBase); - pv->p.set(c.x-s,c.y-s,0,1); pv->color=clr; pv++; - pv->p.set(c.x+s,c.y-s,0,1); pv->color=clr; pv++; - pv->p.set(c.x+s,c.y+s,0,1); pv->color=clr; pv++; - pv->p.set(c.x-s,c.y+s,0,1); pv->color=clr; pv++; - pv->p.set(c.x-s,c.y-s,0,1); pv->color=clr; pv++; - Stream->Unlock(5,vs_TL->vb_stride); - - // Render it as line strip - DU_DRAW_DP (D3DPT_LINESTRIP,vs_TL,vBase,4); - if (caption){ - m_Font->SetColor(clr_font); - m_Font->Out(c.x,c.y+s,"%s",caption); + FVF::TL *pv = (FVF::TL*)Stream->Lock(5, vs_TL->vb_stride, vBase); + pv->p.set(c.x-s, c.y-s, 0, 1); + pv->color = clr; + pv++; + pv->p.set(c.x+s, c.y-s, 0, 1); + pv->color = clr; + pv++; + pv->p.set(c.x+s, c.y+s, 0, 1); + pv->color = clr; + pv++; + pv->p.set(c.x-s, c.y+s, 0, 1); + pv->color = clr; + pv++; + pv->p.set(c.x-s, c.y-s, 0, 1); + pv->color = clr; + pv++; + Stream->Unlock(5, vs_TL->vb_stride); + + // Render it as line strip + DU_DRAW_DP(D3DPT_LINESTRIP, vs_TL, vBase, 4); + if (caption) + { + m_Font->SetColor(clr_font); + m_Font->Out(c.x, c.y+s, "%s", caption); } } -void CDrawUtilities::dbgDrawVert(const Fvector& p0, u32 clr, LPCSTR caption) +void CDrawUtilities::dbgDrawVert(const Fvector &p0, u32 clr, LPCSTR caption) { - dbgDrawPlacement(p0,1,clr,caption); - DrawCross (p0,0.01f,0.01f,0.01f, 0.01f,0.01f,0.01f, clr,false); + dbgDrawPlacement(p0, 1, clr, caption); + DrawCross(p0, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, clr, false); } -void CDrawUtilities::dbgDrawEdge(const Fvector& p0, const Fvector& p1, u32 clr, LPCSTR caption) +void CDrawUtilities::dbgDrawEdge(const Fvector &p0, const Fvector &p1, u32 clr, LPCSTR caption) { - dbgDrawPlacement(p0,1,clr,caption); - DrawCross (p0,0.01f,0.01f,0.01f, 0.01f,0.01f,0.01f, clr,false); - DrawCross (p1,0.01f,0.01f,0.01f, 0.01f,0.01f,0.01f, clr,false); - DrawLine (p0,p1,clr); + dbgDrawPlacement(p0, 1, clr, caption); + DrawCross(p0, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, clr, false); + DrawCross(p1, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, clr, false); + DrawLine(p0, p1, clr); } -void CDrawUtilities::dbgDrawFace(const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 clr, LPCSTR caption) +void CDrawUtilities::dbgDrawFace(const Fvector &p0, const Fvector &p1, const Fvector &p2, u32 clr, LPCSTR caption) { - dbgDrawPlacement(p0,1,clr,caption); - DrawCross (p0,0.01f,0.01f,0.01f, 0.01f,0.01f,0.01f, clr,false); - DrawCross (p1,0.01f,0.01f,0.01f, 0.01f,0.01f,0.01f, clr,false); - DrawCross (p2,0.01f,0.01f,0.01f, 0.01f,0.01f,0.01f, clr,false); - DrawLine (p0,p1,clr); - DrawLine (p1,p2,clr); - DrawLine (p2,p0,clr); + dbgDrawPlacement(p0, 1, clr, caption); + DrawCross(p0, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, clr, false); + DrawCross(p1, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, clr, false); + DrawCross(p2, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, clr, false); + DrawLine(p0, p1, clr); + DrawLine(p1, p2, clr); + DrawLine(p2, p0, clr); } + //---------------------------------------------------- -void CDrawUtilities::DrawLine(const Fvector& p0, const Fvector& p1, u32 c){ - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase; - FVF::L* pv = (FVF::L*)Stream->Lock(2,vs_L->vb_stride,vBase); - pv->set (p0,c); pv++; - pv->set (p1,c); pv++; - Stream->Unlock (2,vs_L->vb_stride); - // and Render it as triangle list - DU_DRAW_DP (D3DPT_LINELIST,vs_L,vBase,1); +void CDrawUtilities::DrawLine(const Fvector &p0, const Fvector &p1, u32 c) +{ + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase; + FVF::L *pv = (FVF::L*)Stream->Lock(2, vs_L->vb_stride, vBase); + pv->set(p0, c); + pv++; + pv->set(p1, c); + pv++; + Stream->Unlock(2, vs_L->vb_stride); + // and Render it as triangle list + DU_DRAW_DP(D3DPT_LINELIST, vs_L, vBase, 1); } -void CDrawUtilities::DrawSelectionBoxB(const Fbox& box, u32* c) +void CDrawUtilities::DrawSelectionBoxB(const Fbox &box, u32 *c) { - Fvector S,C; + Fvector S, C; box.getsize(S); box.getcenter(C); - DrawSelectionBox(C,S,c); + DrawSelectionBox(C, S, c); } //---------------------------------------------------- -void CDrawUtilities::DrawSelectionBox(const Fvector& C, const Fvector& S, u32* clr) +void CDrawUtilities::DrawSelectionBox(const Fvector &C, const Fvector &S, u32 *clr) { - u32 cc=(clr)?*clr:boxcolor; - - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase; - FVF::L* pv = (FVF::L*)Stream->Lock(boxvertcount,vs_L->vb_stride,vBase); - for (int i=0; ip.mul(boxvert[i],S); + u32 cc = (clr) ? *clr : boxcolor; + + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase; + FVF::L *pv = (FVF::L*)Stream->Lock(boxvertcount, vs_L->vb_stride, vBase); + for (int i = 0; ip.mul(boxvert[i], S); pv->p.add(C); - pv->color = cc; + pv->color = cc; } - Stream->Unlock (boxvertcount,vs_L->vb_stride); + Stream->Unlock(boxvertcount, vs_L->vb_stride); - // and Render it as triangle list - DU_DRAW_RS (D3DRS_FILLMODE,D3DFILL_SOLID); - DU_DRAW_DP (D3DPT_LINELIST,vs_L,vBase,boxvertcount/2); - DU_DRAW_RS (D3DRS_FILLMODE,FILL_MODE); + // and Render it as triangle list + DU_DRAW_RS(D3DRS_FILLMODE, D3DFILL_SOLID); + DU_DRAW_DP(D3DPT_LINELIST, vs_L, vBase, boxvertcount/2); + DU_DRAW_RS(D3DRS_FILLMODE,FILL_MODE); } -void CDrawUtilities::DrawBox(const Fvector& offs, const Fvector& Size, BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w) +void CDrawUtilities::DrawBox(const Fvector &offs, const Fvector &Size, BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w) { - _VertexStream* Stream = &RCache.Vertex; - if (bWire){ - u32 vBase; - FVF::L* pv = (FVF::L*)Stream->Lock(identboxwirecount,vs_L->vb_stride,vBase); - for (int i=0; ip.mul (identboxwire[i],Size); - pv->p.mul (2); - pv->p.add (offs); - pv->color = clr_w; + _VertexStream *Stream = &RCache.Vertex; + if (bWire) + { + u32 vBase; + FVF::L *pv = (FVF::L*)Stream->Lock(identboxwirecount, vs_L->vb_stride, vBase); + for (int i = 0; ip.mul(identboxwire[i], Size); + pv->p.mul(2); + pv->p.add(offs); + pv->color = clr_w; } - Stream->Unlock(identboxwirecount,vs_L->vb_stride); + Stream->Unlock(identboxwirecount, vs_L->vb_stride); - DU_DRAW_DP (D3DPT_LINELIST,vs_L,vBase,identboxwirecount/2); + DU_DRAW_DP(D3DPT_LINELIST, vs_L, vBase, identboxwirecount/2); } - if (bSolid){ - u32 vBase; - FVF::L* pv = (FVF::L*)Stream->Lock(DU_BOX_NUMVERTEX2,vs_L->vb_stride,vBase); - for (int i=0; ip.mul (du_box_vertices2[i],Size); - pv->p.mul (2); - pv->p.add (offs); - pv->color = clr_s; + if (bSolid) + { + u32 vBase; + FVF::L *pv = (FVF::L*)Stream->Lock(DU_BOX_NUMVERTEX2, vs_L->vb_stride, vBase); + for (int i = 0; ip.mul(du_box_vertices2[i], Size); + pv->p.mul(2); + pv->p.add(offs); + pv->color = clr_s; } - Stream->Unlock(DU_BOX_NUMVERTEX2,vs_L->vb_stride); + Stream->Unlock(DU_BOX_NUMVERTEX2, vs_L->vb_stride); - DU_DRAW_DP (D3DPT_TRIANGLELIST,vs_L,vBase,DU_BOX_NUMFACES); + DU_DRAW_DP(D3DPT_TRIANGLELIST, vs_L, vBase,DU_BOX_NUMFACES); } } + //---------------------------------------------------- -void CDrawUtilities::DrawOBB(const Fmatrix& parent, const Fobb& box, u32 clr_s, u32 clr_w) +void CDrawUtilities::DrawOBB(const Fmatrix &parent, const Fobb &box, u32 clr_s, u32 clr_w) { - Fmatrix R,S,X; - box.xform_get (R); - S.scale (box.m_halfsize.x*2.f,box.m_halfsize.y*2.f,box.m_halfsize.z*2.f); - X.mul_43 (R,S); - R.mul_43 (parent,X); - RCache.set_xform_world(R); - DrawIdentBox (true,true,clr_s,clr_w); + Fmatrix R, S, X; + box.xform_get(R); + S.scale(box.m_halfsize.x*2.f, box.m_halfsize.y*2.f, box.m_halfsize.z*2.f); + X.mul_43(R, S); + R.mul_43(parent, X); + RCache.set_xform_world(R); + DrawIdentBox(true, true, clr_s, clr_w); } + //---------------------------------------------------- -void CDrawUtilities::DrawAABB(const Fmatrix& parent, const Fvector& center, const Fvector& size, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) +void CDrawUtilities::DrawAABB(const Fmatrix &parent, const Fvector ¢er, const Fvector &size, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) { - Fmatrix R,S; - S.scale (size.x*2.f,size.y*2.f,size.z*2.f); + Fmatrix R, S; + S.scale(size.x*2.f, size.y*2.f, size.z*2.f); S.translate_over(center); - R.mul_43 (parent,S); - RCache.set_xform_world(R); - DrawIdentBox (bSolid,bWire,clr_s,clr_w); + R.mul_43(parent, S); + RCache.set_xform_world(R); + DrawIdentBox(bSolid, bWire, clr_s, clr_w); } -void CDrawUtilities::DrawAABB(const Fvector& p0, const Fvector& p1, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) +void CDrawUtilities::DrawAABB(const Fvector &p0, const Fvector &p1, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) { - Fmatrix R; - Fvector C; C.set((p1.x+p0.x)*0.5f,(p1.y+p0.y)*0.5f,(p1.z+p0.z)*0.5f); - R.scale (_abs(p1.x-p0.x),_abs(p1.y-p0.y),_abs(p1.z-p0.z)); + Fmatrix R; + Fvector C; + C.set((p1.x+p0.x)*0.5f, (p1.y+p0.y)*0.5f, (p1.z+p0.z)*0.5f); + R.scale(_abs(p1.x-p0.x), _abs(p1.y-p0.y), _abs(p1.z-p0.z)); R.translate_over(C); - RCache.set_xform_world(R); - DrawIdentBox (bSolid,bWire,clr_s,clr_w); + RCache.set_xform_world(R); + DrawIdentBox(bSolid, bWire, clr_s, clr_w); } -void CDrawUtilities::DrawSphere(const Fmatrix& parent, const Fvector& center, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) +void CDrawUtilities::DrawSphere(const Fmatrix &parent, const Fvector ¢er, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) { Fmatrix B; - B.scale (radius,radius,radius); - B.translate_over (center); - B.mulA_43 (parent); + B.scale(radius, radius, radius); + B.translate_over(center); + B.mulA_43(parent); RCache.set_xform_world(B); - DrawIdentSphere (bSolid, bWire, clr_s,clr_w); + DrawIdentSphere(bSolid, bWire, clr_s, clr_w); } + //---------------------------------------------------- -void CDrawUtilities::DrawFace(const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) +void CDrawUtilities::DrawFace(const Fvector &p0, const Fvector &p1, const Fvector &p2, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) { - _VertexStream* Stream = &RCache.Vertex; + _VertexStream *Stream = &RCache.Vertex; - u32 vBase; + u32 vBase; if (bSolid) { - FVF::L* pv = (FVF::L*)Stream->Lock(3,vs_L->vb_stride,vBase); - pv->set (p0,clr_s); pv++; - pv->set (p1,clr_s); pv++; - pv->set (p2,clr_s); pv++; - Stream->Unlock (3,vs_L->vb_stride); - DU_DRAW_DP (D3DPT_TRIANGLELIST,vs_L,vBase,1); + FVF::L *pv = (FVF::L*)Stream->Lock(3, vs_L->vb_stride, vBase); + pv->set(p0, clr_s); + pv++; + pv->set(p1, clr_s); + pv++; + pv->set(p2, clr_s); + pv++; + Stream->Unlock(3, vs_L->vb_stride); + DU_DRAW_DP(D3DPT_TRIANGLELIST, vs_L, vBase, 1); } if (bWire) { - FVF::L* pv = (FVF::L*)Stream->Lock(4,vs_L->vb_stride,vBase); - pv->set (p0,clr_w); pv++; - pv->set (p1,clr_w); pv++; - pv->set (p2,clr_w); pv++; - pv->set (p0,clr_w); pv++; - Stream->Unlock (4,vs_L->vb_stride); - DU_DRAW_DP (D3DPT_LINESTRIP,vs_L,vBase,3); + FVF::L *pv = (FVF::L*)Stream->Lock(4, vs_L->vb_stride, vBase); + pv->set(p0, clr_w); + pv++; + pv->set(p1, clr_w); + pv++; + pv->set(p2, clr_w); + pv++; + pv->set(p0, clr_w); + pv++; + Stream->Unlock(4, vs_L->vb_stride); + DU_DRAW_DP(D3DPT_LINESTRIP, vs_L, vBase, 3); } } + //---------------------------------------------------- -static const u32 MAX_VERT_COUNT = 0xFFFF; +static const u32 MAX_VERT_COUNT = 0xFFFF; + void CDrawUtilities::DD_DrawFace_begin(BOOL bWire) { - VERIFY (m_DD_pv_start==0); - m_DD_wire = bWire; - m_DD_pv_start = (FVF::L*)RCache.Vertex.Lock(MAX_VERT_COUNT,vs_L->vb_stride,m_DD_base); - m_DD_pv = m_DD_pv_start; + VERIFY(m_DD_pv_start==0); + m_DD_wire = bWire; + m_DD_pv_start = (FVF::L*)RCache.Vertex.Lock(MAX_VERT_COUNT, vs_L->vb_stride, m_DD_base); + m_DD_pv = m_DD_pv_start; } + void CDrawUtilities::DD_DrawFace_flush(BOOL try_again) { - RCache.Vertex.Unlock((u32)(m_DD_pv-m_DD_pv_start),vs_L->vb_stride); - if (m_DD_wire) DU_DRAW_RS(D3DRS_FILLMODE,D3DFILL_WIREFRAME); - DU_DRAW_DP (D3DPT_TRIANGLELIST,vs_L,m_DD_base,u32(m_DD_pv-m_DD_pv_start)/3); - if (m_DD_wire) DU_DRAW_RS(D3DRS_FILLMODE,FILL_MODE); - if (try_again){ - m_DD_pv_start = (FVF::L*)RCache.Vertex.Lock(MAX_VERT_COUNT,vs_L->vb_stride,m_DD_base); - m_DD_pv = m_DD_pv_start; + RCache.Vertex.Unlock((u32)(m_DD_pv-m_DD_pv_start), vs_L->vb_stride); + if (m_DD_wire) DU_DRAW_RS(D3DRS_FILLMODE, D3DFILL_WIREFRAME); + DU_DRAW_DP(D3DPT_TRIANGLELIST, vs_L, m_DD_base, u32(m_DD_pv-m_DD_pv_start)/3); + if (m_DD_wire) DU_DRAW_RS(D3DRS_FILLMODE,FILL_MODE); + if (try_again) + { + m_DD_pv_start = (FVF::L*)RCache.Vertex.Lock(MAX_VERT_COUNT, vs_L->vb_stride, m_DD_base); + m_DD_pv = m_DD_pv_start; } } -void CDrawUtilities::DD_DrawFace_push(const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 clr) + +void CDrawUtilities::DD_DrawFace_push(const Fvector &p0, const Fvector &p1, const Fvector &p2, u32 clr) { - m_DD_pv->set (p0,clr); m_DD_pv++; - m_DD_pv->set (p1,clr); m_DD_pv++; - m_DD_pv->set (p2,clr); m_DD_pv++; + m_DD_pv->set(p0, clr); + m_DD_pv++; + m_DD_pv->set(p1, clr); + m_DD_pv++; + m_DD_pv->set(p2, clr); + m_DD_pv++; if (m_DD_pv-m_DD_pv_start==MAX_VERT_COUNT) - DD_DrawFace_flush (TRUE); + DD_DrawFace_flush(TRUE); } + void CDrawUtilities::DD_DrawFace_end() { - DD_DrawFace_flush (FALSE); - m_DD_pv_start = 0; + DD_DrawFace_flush(FALSE); + m_DD_pv_start = 0; } + //---------------------------------------------------- -void CDrawUtilities::DrawCylinder(const Fmatrix& parent, const Fvector& center, const Fvector& dir, float height, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) +void CDrawUtilities::DrawCylinder(const Fmatrix &parent, const Fvector ¢er, const Fvector &dir, float height, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) { Fmatrix mScale; - mScale.scale (2.f*radius,2.f*radius,height); - + mScale.scale(2.f*radius, 2.f*radius, height); + // build final rotation / translation - Fvector L_dir,L_up,L_right; - L_dir.set (dir); L_dir.normalize (); - L_up.set (0,1,0); if (_abs(L_up.dotproduct(L_dir))>.99f) L_up.set(0,0,1); - L_right.crossproduct(L_up,L_dir); L_right.normalize (); - L_up.crossproduct (L_dir,L_right); L_up.normalize (); - - Fmatrix mR; - mR.i = L_right; mR._14 = 0; - mR.j = L_up; mR._24 = 0; - mR.k = L_dir; mR._34 = 0; - mR.c = center; mR._44 = 1; + Fvector L_dir, L_up, L_right; + L_dir.set(dir); + L_dir.normalize(); + L_up.set(0, 1, 0); + if (_abs(L_up.dotproduct(L_dir))>.99f) + L_up.set(0, 0, 1); + L_right.crossproduct(L_up, L_dir); + L_right.normalize(); + L_up.crossproduct(L_dir, L_right); + L_up.normalize(); + + Fmatrix mR; + mR.i = L_right; + mR._14 = 0; + mR.j = L_up; + mR._24 = 0; + mR.k = L_dir; + mR._34 = 0; + mR.c = center; + mR._44 = 1; // final xform - Fmatrix xf; xf.mul (mR,mScale); - xf.mulA_43 (parent); + Fmatrix xf; + xf.mul(mR, mScale); + xf.mulA_43(parent); RCache.set_xform_world(xf); - DrawIdentCylinder (bSolid,bWire,clr_s,clr_w); + DrawIdentCylinder(bSolid, bWire, clr_s, clr_w); } + //---------------------------------------------------- -void CDrawUtilities::DrawCone (const Fmatrix& parent, const Fvector& apex, const Fvector& dir, float height, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) +void CDrawUtilities::DrawCone(const Fmatrix &parent, const Fvector &apex, const Fvector &dir, float height, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) { Fmatrix mScale; - mScale.scale (2.f*radius,2.f*radius,height); - + mScale.scale(2.f*radius, 2.f*radius, height); + // build final rotation / translation - Fvector L_dir,L_up,L_right; - L_dir.set (dir); L_dir.normalize (); - L_up.set (0,1,0); if (_abs(L_up.dotproduct(L_dir))>.99f) L_up.set(0,0,1); - L_right.crossproduct(L_up,L_dir); L_right.normalize (); - L_up.crossproduct (L_dir,L_right); L_up.normalize (); - - Fmatrix mR; - mR.i = L_right; mR._14 = 0; - mR.j = L_up; mR._24 = 0; - mR.k = L_dir; mR._34 = 0; - mR.c = apex; mR._44 = 1; + Fvector L_dir, L_up, L_right; + L_dir.set(dir); + L_dir.normalize(); + L_up.set(0, 1, 0); + if (_abs(L_up.dotproduct(L_dir))>.99f) + L_up.set(0, 0, 1); + L_right.crossproduct(L_up, L_dir); + L_right.normalize(); + L_up.crossproduct(L_dir, L_right); + L_up.normalize(); + + Fmatrix mR; + mR.i = L_right; + mR._14 = 0; + mR.j = L_up; + mR._24 = 0; + mR.k = L_dir; + mR._34 = 0; + mR.c = apex; + mR._44 = 1; // final xform - Fmatrix xf; xf.mul (mR,mScale); - xf.mulA_43 (parent); + Fmatrix xf; + xf.mul(mR, mScale); + xf.mulA_43(parent); RCache.set_xform_world(xf); - DrawIdentCone (bSolid,bWire,clr_s,clr_w); + DrawIdentCone(bSolid, bWire, clr_s, clr_w); } + //---------------------------------------------------- -void CDrawUtilities::DrawPlane (const Fvector& p, const Fvector& n, const Fvector2& scale, u32 clr_s, u32 clr_w, BOOL bCull, BOOL bSolid, BOOL bWire) +void CDrawUtilities::DrawPlane(const Fvector &p, const Fvector &n, const Fvector2 &scale, u32 clr_s, u32 clr_w, BOOL bCull, BOOL bSolid, BOOL bWire) { - if (n.square_magnitude().99f) L_dir.set(1,0,0); - L_right.crossproduct(L_up,L_dir); L_right.normalize (); - L_dir.crossproduct (L_right,L_up); L_dir.normalize (); - - Fmatrix mR; - mR.i = L_right; mR._14 = 0; - mR.j = L_up; mR._24 = 0; - mR.k = L_dir; mR._34 = 0; - mR.c = p; mR._44 = 1; - - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase; - - if (bSolid){ - DU_DRAW_SH(EDevice.m_SelectionShader); - FVF::L* pv = (FVF::L*)Stream->Lock(5,vs_L->vb_stride,vBase); - pv->set (-scale.x, 0, -scale.y, clr_s); mR.transform_tiny(pv->p); pv++; - pv->set (-scale.x, 0, +scale.y, clr_s); mR.transform_tiny(pv->p); pv++; - pv->set (+scale.x, 0, +scale.y, clr_s); mR.transform_tiny(pv->p); pv++; - pv->set (+scale.x, 0, -scale.y, clr_s); mR.transform_tiny(pv->p); pv++; - pv->set (*(pv-4)); - Stream->Unlock(5,vs_L->vb_stride); - if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_NONE); - DU_DRAW_DP (D3DPT_TRIANGLEFAN,vs_L,vBase,2); - if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_CCW); + Fvector L_dir, L_up = n, L_right; + L_dir.set(0, 0, 1); + if (_abs(L_up.dotproduct(L_dir))>.99f) + L_dir.set(1, 0, 0); + L_right.crossproduct(L_up, L_dir); + L_right.normalize(); + L_dir.crossproduct(L_right, L_up); + L_dir.normalize(); + + Fmatrix mR; + mR.i = L_right; + mR._14 = 0; + mR.j = L_up; + mR._24 = 0; + mR.k = L_dir; + mR._34 = 0; + mR.c = p; + mR._44 = 1; + + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase; + + if (bSolid) + { + DU_DRAW_SH(EDevice.m_SelectionShader); + FVF::L *pv = (FVF::L*)Stream->Lock(5, vs_L->vb_stride, vBase); + pv->set(-scale.x, 0, -scale.y, clr_s); + mR.transform_tiny(pv->p); + pv++; + pv->set(-scale.x, 0, +scale.y, clr_s); + mR.transform_tiny(pv->p); + pv++; + pv->set(+scale.x, 0, +scale.y, clr_s); + mR.transform_tiny(pv->p); + pv++; + pv->set(+scale.x, 0, -scale.y, clr_s); + mR.transform_tiny(pv->p); + pv++; + pv->set(*(pv-4)); + Stream->Unlock(5, vs_L->vb_stride); + if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_NONE); + DU_DRAW_DP(D3DPT_TRIANGLEFAN, vs_L, vBase, 2); + if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_CCW); } - if (bWire){ - DU_DRAW_SH(EDevice.m_WireShader); - FVF::L* pv = (FVF::L*)Stream->Lock(5,vs_L->vb_stride,vBase); - pv->set (-scale.x, 0, -scale.y, clr_w); mR.transform_tiny(pv->p); pv++; - pv->set (+scale.x, 0, -scale.y, clr_w); mR.transform_tiny(pv->p); pv++; - pv->set (+scale.x, 0, +scale.y, clr_w); mR.transform_tiny(pv->p); pv++; - pv->set (-scale.x, 0, +scale.y, clr_w); mR.transform_tiny(pv->p); pv++; - pv->set (*(pv-4)); - Stream->Unlock(5,vs_L->vb_stride); - DU_DRAW_DP (D3DPT_LINESTRIP,vs_L,vBase,4); + if (bWire) + { + DU_DRAW_SH(EDevice.m_WireShader); + FVF::L *pv = (FVF::L*)Stream->Lock(5, vs_L->vb_stride, vBase); + pv->set(-scale.x, 0, -scale.y, clr_w); + mR.transform_tiny(pv->p); + pv++; + pv->set(+scale.x, 0, -scale.y, clr_w); + mR.transform_tiny(pv->p); + pv++; + pv->set(+scale.x, 0, +scale.y, clr_w); + mR.transform_tiny(pv->p); + pv++; + pv->set(-scale.x, 0, +scale.y, clr_w); + mR.transform_tiny(pv->p); + pv++; + pv->set(*(pv-4)); + Stream->Unlock(5, vs_L->vb_stride); + DU_DRAW_DP(D3DPT_LINESTRIP, vs_L, vBase, 4); } } + //---------------------------------------------------- -void CDrawUtilities::DrawPlane (const Fvector& center, const Fvector2& scale, const Fvector& rotate, u32 clr_s, u32 clr_w, BOOL bCull, BOOL bSolid, BOOL bWire) +void CDrawUtilities::DrawPlane(const Fvector ¢er, const Fvector2 &scale, const Fvector &rotate, u32 clr_s, u32 clr_w, BOOL bCull, BOOL bSolid, BOOL bWire) { Fmatrix M; - M.setHPB (rotate.y,rotate.x,rotate.z); + M.setHPB(rotate.y, rotate.x, rotate.z); M.translate_over(center); - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase; - - if (bSolid){ - DU_DRAW_SH(EDevice.m_SelectionShader); - FVF::L* pv = (FVF::L*)Stream->Lock(5,vs_L->vb_stride,vBase); - pv->set (-scale.x, 0, -scale.y, clr_s); M.transform_tiny(pv->p); pv++; - pv->set (-scale.x, 0, +scale.y, clr_s); M.transform_tiny(pv->p); pv++; - pv->set (+scale.x, 0, +scale.y, clr_s); M.transform_tiny(pv->p); pv++; - pv->set (+scale.x, 0, -scale.y, clr_s); M.transform_tiny(pv->p); pv++; - pv->set (*(pv-4)); - Stream->Unlock(5,vs_L->vb_stride); - if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_NONE); - DU_DRAW_DP (D3DPT_TRIANGLEFAN,vs_L,vBase,2); - if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_CCW); + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase; + + if (bSolid) + { + DU_DRAW_SH(EDevice.m_SelectionShader); + FVF::L *pv = (FVF::L*)Stream->Lock(5, vs_L->vb_stride, vBase); + pv->set(-scale.x, 0, -scale.y, clr_s); + M.transform_tiny(pv->p); + pv++; + pv->set(-scale.x, 0, +scale.y, clr_s); + M.transform_tiny(pv->p); + pv++; + pv->set(+scale.x, 0, +scale.y, clr_s); + M.transform_tiny(pv->p); + pv++; + pv->set(+scale.x, 0, -scale.y, clr_s); + M.transform_tiny(pv->p); + pv++; + pv->set(*(pv-4)); + Stream->Unlock(5, vs_L->vb_stride); + if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_NONE); + DU_DRAW_DP(D3DPT_TRIANGLEFAN, vs_L, vBase, 2); + if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_CCW); } - if (bWire){ - DU_DRAW_SH(EDevice.m_WireShader); - FVF::L* pv = (FVF::L*)Stream->Lock(5,vs_L->vb_stride,vBase); - pv->set (-scale.x, 0, -scale.y, clr_w); M.transform_tiny(pv->p); pv++; - pv->set (+scale.x, 0, -scale.y, clr_w); M.transform_tiny(pv->p); pv++; - pv->set (+scale.x, 0, +scale.y, clr_w); M.transform_tiny(pv->p); pv++; - pv->set (-scale.x, 0, +scale.y, clr_w); M.transform_tiny(pv->p); pv++; - pv->set (*(pv-4)); - Stream->Unlock(5,vs_L->vb_stride); - DU_DRAW_DP (D3DPT_LINESTRIP,vs_L,vBase,4); + if (bWire) + { + DU_DRAW_SH(EDevice.m_WireShader); + FVF::L *pv = (FVF::L*)Stream->Lock(5, vs_L->vb_stride, vBase); + pv->set(-scale.x, 0, -scale.y, clr_w); + M.transform_tiny(pv->p); + pv++; + pv->set(+scale.x, 0, -scale.y, clr_w); + M.transform_tiny(pv->p); + pv++; + pv->set(+scale.x, 0, +scale.y, clr_w); + M.transform_tiny(pv->p); + pv++; + pv->set(-scale.x, 0, +scale.y, clr_w); + M.transform_tiny(pv->p); + pv++; + pv->set(*(pv-4)); + Stream->Unlock(5, vs_L->vb_stride); + DU_DRAW_DP(D3DPT_LINESTRIP, vs_L, vBase, 4); } } + //---------------------------------------------------- -void CDrawUtilities::DrawRectangle(const Fvector& o, const Fvector& u, const Fvector& v, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) +void CDrawUtilities::DrawRectangle(const Fvector &o, const Fvector &u, const Fvector &v, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire) { - _VertexStream* Stream = &RCache.Vertex; + _VertexStream *Stream = &RCache.Vertex; - u32 vBase; + u32 vBase; if (bSolid) { - DU_DRAW_SH(EDevice.m_SelectionShader); - FVF::L* pv = (FVF::L*)Stream->Lock(6,vs_L->vb_stride,vBase); - pv->set (o.x, o.y, o.z, clr_s); pv++; - pv->set (o.x+u.x+v.x, o.y+u.y+v.y,o.z+u.z+v.z,clr_s); pv++; - pv->set (o.x+v.x, o.y+v.y, o.z+v.z, clr_s); pv++; - pv->set (o.x, o.y, o.z, clr_s); pv++; - pv->set (o.x+u.x, o.y+u.y, o.z+u.z, clr_s); pv++; - pv->set (o.x+u.x+v.x, o.y+u.y+v.y,o.z+u.z+v.z,clr_s); pv++; - Stream->Unlock (6,vs_L->vb_stride); - DU_DRAW_DP (D3DPT_TRIANGLELIST,vs_L,vBase,2); + DU_DRAW_SH(EDevice.m_SelectionShader); + FVF::L *pv = (FVF::L*)Stream->Lock(6, vs_L->vb_stride, vBase); + pv->set(o.x, o.y, o.z, clr_s); + pv++; + pv->set(o.x+u.x+v.x, o.y+u.y+v.y, o.z+u.z+v.z, clr_s); + pv++; + pv->set(o.x+v.x, o.y+v.y, o.z+v.z, clr_s); + pv++; + pv->set(o.x, o.y, o.z, clr_s); + pv++; + pv->set(o.x+u.x, o.y+u.y, o.z+u.z, clr_s); + pv++; + pv->set(o.x+u.x+v.x, o.y+u.y+v.y, o.z+u.z+v.z, clr_s); + pv++; + Stream->Unlock(6, vs_L->vb_stride); + DU_DRAW_DP(D3DPT_TRIANGLELIST, vs_L, vBase, 2); } if (bWire) { - DU_DRAW_SH(EDevice.m_WireShader); - FVF::L* pv = (FVF::L*)Stream->Lock(5,vs_L->vb_stride,vBase); - pv->set (o.x, o.y, o.z, clr_w); pv++; - pv->set (o.x+u.x, o.y+u.y, o.z+u.z, clr_w); pv++; - pv->set (o.x+u.x+v.x, o.y+u.y+v.y,o.z+u.z+v.z,clr_w); pv++; - pv->set (o.x+v.x, o.y+v.y, o.z+v.z, clr_w); pv++; - pv->set (o.x, o.y, o.z, clr_w); pv++; - Stream->Unlock (5,vs_L->vb_stride); - DU_DRAW_DP (D3DPT_LINESTRIP,vs_L,vBase,4); + DU_DRAW_SH(EDevice.m_WireShader); + FVF::L *pv = (FVF::L*)Stream->Lock(5, vs_L->vb_stride, vBase); + pv->set(o.x, o.y, o.z, clr_w); + pv++; + pv->set(o.x+u.x, o.y+u.y, o.z+u.z, clr_w); + pv++; + pv->set(o.x+u.x+v.x, o.y+u.y+v.y, o.z+u.z+v.z, clr_w); + pv++; + pv->set(o.x+v.x, o.y+v.y, o.z+v.z, clr_w); + pv++; + pv->set(o.x, o.y, o.z, clr_w); + pv++; + Stream->Unlock(5, vs_L->vb_stride); + DU_DRAW_DP(D3DPT_LINESTRIP, vs_L, vBase, 4); } } + //---------------------------------------------------- -void CDrawUtilities::DrawCross(const Fvector& p, float szx1, float szy1, float szz1, float szx2, float szy2, float szz2, u32 clr, BOOL bRot45) +void CDrawUtilities::DrawCross(const Fvector &p, float szx1, float szy1, float szz1, float szx2, float szy2, float szz2, u32 clr, BOOL bRot45) { - _VertexStream* Stream = &RCache.Vertex; - // actual rendering - u32 vBase; - FVF::L* pv = (FVF::L*)Stream->Lock(bRot45?12:6,vs_L->vb_stride,vBase); - pv->set(p.x+szx2,p.y,p.z,clr); pv++; - pv->set(p.x-szx1,p.y,p.z,clr); pv++; - pv->set(p.x,p.y+szy2,p.z,clr); pv++; - pv->set(p.x,p.y-szy1,p.z,clr); pv++; - pv->set(p.x,p.y,p.z+szz2,clr); pv++; - pv->set(p.x,p.y,p.z-szz1,clr); pv++; - if (bRot45){ - Fmatrix M; - M.setHPB(PI_DIV_4,PI_DIV_4,PI_DIV_4); - for(int i=0;i<6;i++,pv++){ - pv->p.sub((pv-6)->p,p); - M.transform_dir(pv->p); - pv->p.add(p); + _VertexStream *Stream = &RCache.Vertex; + // actual rendering + u32 vBase; + FVF::L *pv = (FVF::L*)Stream->Lock(bRot45 ? 12 : 6, vs_L->vb_stride, vBase); + pv->set(p.x+szx2, p.y, p.z, clr); + pv++; + pv->set(p.x-szx1, p.y, p.z, clr); + pv++; + pv->set(p.x, p.y+szy2, p.z, clr); + pv++; + pv->set(p.x, p.y-szy1, p.z, clr); + pv++; + pv->set(p.x, p.y, p.z+szz2, clr); + pv++; + pv->set(p.x, p.y, p.z-szz1, clr); + pv++; + if (bRot45) + { + Fmatrix M; + M.setHPB(PI_DIV_4, PI_DIV_4, PI_DIV_4); + for (int i = 0; i<6; i++,pv++) + { + pv->p.sub((pv-6)->p, p); + M.transform_dir(pv->p); + pv->p.add(p); pv->color = clr; } } - // unlock VB and Render it as triangle list - Stream->Unlock(bRot45?12:6,vs_L->vb_stride); - DU_DRAW_DP (D3DPT_LINELIST,vs_L,vBase,bRot45?6:3); + // unlock VB and Render it as triangle list + Stream->Unlock(bRot45 ? 12 : 6, vs_L->vb_stride); + DU_DRAW_DP(D3DPT_LINELIST, vs_L, vBase, bRot45 ? 6 : 3); } -void CDrawUtilities::DrawPivot(const Fvector& pos, float sz){ - DU_DRAW_SH(EDevice.m_WireShader); +void CDrawUtilities::DrawPivot(const Fvector &pos, float sz) +{ + DU_DRAW_SH(EDevice.m_WireShader); DrawCross(pos, sz, sz, sz, sz, sz, sz, 0xFF7FFF7F); } -void CDrawUtilities::DrawAxis(const Fmatrix& T) +void CDrawUtilities::DrawAxis(const Fmatrix &T) { -/* - _VertexStream* Stream = &RCache.Vertex; - Fvector p[6]; - u32 c[6]; - - // colors - c[0]=c[2]=c[4]=0x00222222; c[1]=0x00FF0000; c[3]=0x0000FF00; c[5]=0x000000FF; - - // position - p[0].mad(T.c,T.k,0.25f); - p[1].set(p[0]); p[1].x+=.015f; - p[2].set(p[0]); - p[3].set(p[0]); p[3].y+=.015f; - p[4].set(p[0]); - p[5].set(p[0]); p[5].z+=.015f; - - u32 vBase; - FVF::TL* pv = (FVF::TL*)Stream->Lock(6,vs_TL->vb_stride,vBase); - // transform to screen - float dx=-float(EDevice.dwWidth)/2.2f; - float dy=float(EDevice.dwHeight)/2.25f; - - for (int i=0; i<6; i++,pv++) - { - pv->color = c[i]; - pv->transform (p[i],EDevice.mFullTransform); - pv->p.set((float)iFloor(_x2real(pv->p.x)+dx),(float)iFloor(_y2real(pv->p.y)+dy),0,1); - p[i].set(pv->p.x,pv->p.y,0); - } - - // unlock VB and Render it as triangle list - Stream->Unlock(6,vs_TL->vb_stride); - DU_DRAW_RS(D3DRS_SHADEMODE,D3DSHADE_GOURAUD); - DU_DRAW_SH(EDevice.m_WireShader); - DU_DRAW_DP(D3DPT_LINELIST,vs_TL,vBase,3); - DU_DRAW_RS(D3DRS_SHADEMODE,SHADE_MODE); - - m_Font->SetColor(0xFF909090); - m_Font->Out(p[1].x,p[1].y,"x"); - m_Font->Out(p[3].x,p[3].y,"y"); - m_Font->Out(p[5].x,p[5].y,"z"); - m_Font->SetColor(0xFF000000); - m_Font->Out(p[1].x-1,p[1].y-1,"x"); - m_Font->Out(p[3].x-1,p[3].y-1,"y"); - m_Font->Out(p[5].x-1,p[5].y-1,"z"); -*/ - if(!m_axis_object) - m_axis_object = Lib.CreateEditObject("editor\\axis"); + /* + _VertexStream* Stream = &RCache.Vertex; + Fvector p[6]; + u32 c[6]; + + // colors + c[0]=c[2]=c[4]=0x00222222; c[1]=0x00FF0000; c[3]=0x0000FF00; c[5]=0x000000FF; + + // position + p[0].mad(T.c,T.k,0.25f); + p[1].set(p[0]); p[1].x+=.015f; + p[2].set(p[0]); + p[3].set(p[0]); p[3].y+=.015f; + p[4].set(p[0]); + p[5].set(p[0]); p[5].z+=.015f; + + u32 vBase; + FVF::TL* pv = (FVF::TL*)Stream->Lock(6,vs_TL->vb_stride,vBase); + // transform to screen + float dx=-float(EDevice.dwWidth)/2.2f; + float dy=float(EDevice.dwHeight)/2.25f; - Fmatrix M = Fidentity; - Fmatrix S; - S.scale (0.04f,0.04f,0.04f); - M.mulB_44 (S); + for (int i=0; i<6; i++,pv++) + { + pv->color = c[i]; + pv->transform (p[i],EDevice.mFullTransform); + pv->p.set((float)iFloor(_x2real(pv->p.x)+dx),(float)iFloor(_y2real(pv->p.y)+dy),0,1); + p[i].set(pv->p.x,pv->p.y,0); + } + + // unlock VB and Render it as triangle list + Stream->Unlock(6,vs_TL->vb_stride); + DU_DRAW_RS(D3DRS_SHADEMODE,D3DSHADE_GOURAUD); + DU_DRAW_SH(EDevice.m_WireShader); + DU_DRAW_DP(D3DPT_LINELIST,vs_TL,vBase,3); + DU_DRAW_RS(D3DRS_SHADEMODE,SHADE_MODE); + + m_Font->SetColor(0xFF909090); + m_Font->Out(p[1].x,p[1].y,"x"); + m_Font->Out(p[3].x,p[3].y,"y"); + m_Font->Out(p[5].x,p[5].y,"z"); + m_Font->SetColor(0xFF000000); + m_Font->Out(p[1].x-1,p[1].y-1,"x"); + m_Font->Out(p[3].x-1,p[3].y-1,"y"); + m_Font->Out(p[5].x-1,p[5].y-1,"z"); + */ + if (!m_axis_object) + m_axis_object = Lib.CreateEditObject("editor\\axis"); + + Fmatrix M = Fidentity; + Fmatrix S; + S.scale(0.04f, 0.04f, 0.04f); + M.mulB_44(S); Fvector start, dir; Ivector2 pt; - static int _wh = 50; - static float _kl = 1.0f; + static int _wh = 50; + static float _kl = 1.0f; - pt.x = _wh; - pt.y = iFloor(UI->GetRealHeight()-_wh); + pt.x = _wh; + pt.y = iFloor(UI->GetRealHeight()-_wh); EDevice.m_Camera.MouseRayFromPoint(M.c, dir, pt); M.c.mad(dir, _kl); - m_axis_object->Render (M, 2, false); + m_axis_object->Render(M, 2, false); } -void CDrawUtilities::DrawObjectAxis(const Fmatrix& T, float sz, BOOL sel) +void CDrawUtilities::DrawObjectAxis(const Fmatrix &T, float sz, BOOL sel) { - VERIFY( EDevice.b_is_Ready ); - // RCache.set_xform_world (Fidentity); - _VertexStream* Stream = &RCache.Vertex; - Fvector c,r,n,d; - float w = T.c.x*EDevice.mFullTransform._14 + T.c.y*EDevice.mFullTransform._24 + T.c.z*EDevice.mFullTransform._34 + EDevice.mFullTransform._44; - if (w<0) - return; // culling - - float s = w*sz; - - EDevice.mFullTransform.transform(c,T.c); - r.mul(T.i,s); - r.add(T.c); + VERIFY(EDevice.b_is_Ready); + // RCache.set_xform_world (Fidentity); + _VertexStream *Stream = &RCache.Vertex; + Fvector c, r, n, d; + float w = T.c.x*EDevice.mFullTransform._14+T.c.y*EDevice.mFullTransform._24+T.c.z*EDevice.mFullTransform._34+EDevice.mFullTransform._44; + if (w<0) + return; // culling + + float s = w*sz; + + EDevice.mFullTransform.transform(c, T.c); + r.mul(T.i, s); + r.add(T.c); EDevice.mFullTransform.transform(r); - n.mul(T.j,s); - n.add(T.c); + n.mul(T.j, s); + n.add(T.c); EDevice.mFullTransform.transform(n); - d.mul(T.k,s); - d.add(T.c); + d.mul(T.k, s); + d.add(T.c); EDevice.mFullTransform.transform(d); - c.x = (float)iFloor(_x2real(c.x)); + c.x = (float)iFloor(_x2real(c.x)); c.y = (float)iFloor(_y2real(-c.y)); - r.x = (float)iFloor(_x2real(r.x)); + r.x = (float)iFloor(_x2real(r.x)); r.y = (float)iFloor(_y2real(-r.y)); - n.x = (float)iFloor(_x2real(n.x)); + n.x = (float)iFloor(_x2real(n.x)); n.y = (float)iFloor(_y2real(-n.y)); - d.x = (float)iFloor(_x2real(d.x)); + d.x = (float)iFloor(_x2real(d.x)); d.y = (float)iFloor(_y2real(-d.y)); u32 vBase; - FVF::TL* pv = (FVF::TL*)Stream->Lock(6,vs_TL->vb_stride,vBase); -/* - c.set (200,200,0); - d.set (150,250,0); - r.set (300,200,0); - n.set (200,100,0); -*/ - pv->set (c.x, c.y, 0, 1, 0xFF222222, 0,0); pv++; - pv->set (d.x, d.y, 0, 1, sel?0xFF0000FF:0xFF000080, 0,0); pv++; - pv->set (c.x, c.y, 0, 1, 0xFF222222, 0,0); pv++; - pv->set (r.x, r.y, 0, 1, sel?0xFFFF0000:0xFF800000, 0,0); pv++; - pv->set (c.x, c.y, 0, 1, 0xFF222222, 0,0); pv++; - pv->set (n.x, n.y, 0, 1, sel?0xFF00FF00:0xFF008000, 0,0); - Stream->Unlock(6,vs_TL->vb_stride); - - // Render it as line list - DU_DRAW_RS (D3DRS_SHADEMODE,D3DSHADE_GOURAUD); - DU_DRAW_SH (EDevice.m_WireShader); - DU_DRAW_DP (D3DPT_LINELIST,vs_TL,vBase,3); - DU_DRAW_RS (D3DRS_SHADEMODE,SHADE_MODE); - - m_Font->SetColor(sel?0xFF000000:0xFF909090); - m_Font->Out(r.x,r.y,"x"); - m_Font->Out(n.x,n.y,"y"); - m_Font->Out(d.x,d.y,"z"); - m_Font->SetColor(sel?0xFFFFFFFF:0xFF000000); - m_Font->Out(r.x-1,r.y-1,"x"); - m_Font->Out(n.x-1,n.y-1,"y"); - m_Font->Out(d.x-1,d.y-1,"z"); + FVF::TL *pv = (FVF::TL*)Stream->Lock(6, vs_TL->vb_stride, vBase); + /* + c.set (200,200,0); + d.set (150,250,0); + r.set (300,200,0); + n.set (200,100,0); + */ + pv->set(c.x, c.y, 0, 1, 0xFF222222, 0, 0); + pv++; + pv->set(d.x, d.y, 0, 1, sel ? 0xFF0000FF : 0xFF000080, 0, 0); + pv++; + pv->set(c.x, c.y, 0, 1, 0xFF222222, 0, 0); + pv++; + pv->set(r.x, r.y, 0, 1, sel ? 0xFFFF0000 : 0xFF800000, 0, 0); + pv++; + pv->set(c.x, c.y, 0, 1, 0xFF222222, 0, 0); + pv++; + pv->set(n.x, n.y, 0, 1, sel ? 0xFF00FF00 : 0xFF008000, 0, 0); + Stream->Unlock(6, vs_TL->vb_stride); + + // Render it as line list + DU_DRAW_RS(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); + DU_DRAW_SH (EDevice.m_WireShader); + DU_DRAW_DP(D3DPT_LINELIST, vs_TL, vBase, 3); + DU_DRAW_RS(D3DRS_SHADEMODE,SHADE_MODE); + + m_Font->SetColor(sel ? 0xFF000000 : 0xFF909090); + m_Font->Out(r.x, r.y, "x"); + m_Font->Out(n.x, n.y, "y"); + m_Font->Out(d.x, d.y, "z"); + m_Font->SetColor(sel ? 0xFFFFFFFF : 0xFF000000); + m_Font->Out(r.x-1, r.y-1, "x"); + m_Font->Out(n.x-1, n.y-1, "y"); + m_Font->Out(d.x-1, d.y-1, "z"); } void CDrawUtilities::DrawGrid() { - VERIFY( EDevice.b_is_Ready ); - _VertexStream* Stream = &RCache.Vertex; + VERIFY(EDevice.b_is_Ready); + _VertexStream *Stream = &RCache.Vertex; u32 vBase; - // fill VB - FVF::L* pv = (FVF::L*)Stream->Lock(m_GridPoints.size(),vs_L->vb_stride,vBase); - for (FLvertexIt v_it=m_GridPoints.begin(); v_it!=m_GridPoints.end(); v_it++,pv++) pv->set(*v_it); - Stream->Unlock(m_GridPoints.size(),vs_L->vb_stride); - // Render it as triangle list + // fill VB + FVF::L *pv = (FVF::L*)Stream->Lock(m_GridPoints.size(), vs_L->vb_stride, vBase); + for (FLvertexIt v_it = m_GridPoints.begin(); v_it!=m_GridPoints.end(); v_it++,pv++) + pv->set(*v_it); + Stream->Unlock(m_GridPoints.size(), vs_L->vb_stride); + // Render it as triangle list Fmatrix ddd; ddd.identity(); RCache.set_xform_world(ddd); - DU_DRAW_SH(EDevice.m_WireShader); - DU_DRAW_DP(D3DPT_LINELIST,vs_L,vBase,m_GridPoints.size()/2); + DU_DRAW_SH(EDevice.m_WireShader); + DU_DRAW_DP(D3DPT_LINELIST, vs_L, vBase, m_GridPoints.size()/2); } -void CDrawUtilities::DrawSelectionRect(const Ivector2& m_SelStart, const Ivector2& m_SelEnd){ - VERIFY( EDevice.b_is_Ready ); - // fill VB - _VertexStream* Stream = &RCache.Vertex; +void CDrawUtilities::DrawSelectionRect(const Ivector2 &m_SelStart, const Ivector2 &m_SelEnd) +{ + VERIFY(EDevice.b_is_Ready); + // fill VB + _VertexStream *Stream = &RCache.Vertex; u32 vBase; - FVF::TL* pv = (FVF::TL*)Stream->Lock(4,vs_TL->vb_stride,vBase); - pv->set(m_SelStart.x*SCREEN_QUALITY, m_SelStart.y*SCREEN_QUALITY, m_SelectionRect,0.f,0.f); pv++; - pv->set(m_SelStart.x*SCREEN_QUALITY, m_SelEnd.y*SCREEN_QUALITY, m_SelectionRect,0.f,0.f); pv++; - pv->set(m_SelEnd.x*SCREEN_QUALITY, m_SelEnd.y*SCREEN_QUALITY, m_SelectionRect,0.f,0.f); pv++; - pv->set(m_SelEnd.x*SCREEN_QUALITY, m_SelStart.y*SCREEN_QUALITY, m_SelectionRect,0.f,0.f); pv++; - Stream->Unlock(4,vs_TL->vb_stride); - // Render it as triangle list - DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_NONE); - DU_DRAW_SH(EDevice.m_SelectionShader); - DU_DRAW_DP(D3DPT_TRIANGLEFAN,vs_TL,vBase,2); - DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_CCW); + FVF::TL *pv = (FVF::TL*)Stream->Lock(4, vs_TL->vb_stride, vBase); + pv->set(m_SelStart.x*SCREEN_QUALITY, m_SelStart.y*SCREEN_QUALITY, m_SelectionRect, 0.f, 0.f); + pv++; + pv->set(m_SelStart.x*SCREEN_QUALITY, m_SelEnd.y*SCREEN_QUALITY, m_SelectionRect, 0.f, 0.f); + pv++; + pv->set(m_SelEnd.x*SCREEN_QUALITY, m_SelEnd.y*SCREEN_QUALITY, m_SelectionRect, 0.f, 0.f); + pv++; + pv->set(m_SelEnd.x*SCREEN_QUALITY, m_SelStart.y*SCREEN_QUALITY, m_SelectionRect, 0.f, 0.f); + pv++; + Stream->Unlock(4, vs_TL->vb_stride); + // Render it as triangle list + DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_NONE); + DU_DRAW_SH(EDevice.m_SelectionShader); + DU_DRAW_DP(D3DPT_TRIANGLEFAN, vs_TL, vBase, 2); + DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_CCW); } -void CDrawUtilities::DrawPrimitiveL (D3DPRIMITIVETYPE pt, u32 pc, Fvector* vertices, int vc, u32 color, BOOL bCull, BOOL bCycle) +void CDrawUtilities::DrawPrimitiveL(D3DPRIMITIVETYPE pt, u32 pc, Fvector *vertices, int vc, u32 color, BOOL bCull, BOOL bCycle) { - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase, dwNeed=(bCycle)?vc+1:vc; - FVF::L* pv = (FVF::L*)Stream->Lock(dwNeed,vs_L->vb_stride,vBase); - for(int k=0; kset (vertices[k],color); - if (bCycle) pv->set(*(pv-vc)); - Stream->Unlock(dwNeed,vs_L->vb_stride); - - if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_NONE); - DU_DRAW_DP (pt,vs_L,vBase,pc); - if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_CCW); + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase, dwNeed = (bCycle) ? vc+1 : vc; + FVF::L *pv = (FVF::L*)Stream->Lock(dwNeed, vs_L->vb_stride, vBase); + for (int k = 0; kset(vertices[k], color); + if (bCycle) + pv->set(*(pv-vc)); + Stream->Unlock(dwNeed, vs_L->vb_stride); + + if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_NONE); + DU_DRAW_DP(pt, vs_L, vBase, pc); + if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_CCW); } -void CDrawUtilities::DrawIndexedPrimitive( int pt, - u32 pc, - const Fvector& pos, - const Fvector* vb, - const u32& vb_size, - const u32* ib, - const u32& ib_size, - const u32& clr_argb, - float scale) +void CDrawUtilities::DrawIndexedPrimitive(int pt, + u32 pc, + const Fvector &pos, + const Fvector *vb, + const u32 &vb_size, + const u32 *ib, + const u32 &ib_size, + const u32 &clr_argb, + float scale) { - _VertexStream* Stream = &RCache.Vertex; - _IndexStream* StreamI = &RCache.Index; - - u32 vBase, iBase; - WORD* i; - - FVF::L* pv = (FVF::L*)Stream->Lock(vb_size, vs_L->vb_stride, vBase); - for(int k=0; kset (Fvector().add(pos, Fvector().mul(vb[k],scale)), clr_argb); - - Stream->Unlock(vb_size, vs_L->vb_stride); - - i = StreamI->Lock(ib_size,iBase); - for (k=0; kLock(vb_size, vs_L->vb_stride, vBase); + for (int k = 0; kset(Fvector().add(pos, Fvector().mul(vb[k], scale)), clr_argb); + + Stream->Unlock(vb_size, vs_L->vb_stride); + + i = StreamI->Lock(ib_size, iBase); + for (k = 0; kUnlock(ib_size); - EDevice.SetShader (EDevice.m_SelectionShader); - // and Render it as triangle list - DU_DRAW_DIP ((D3DPRIMITIVETYPE)pt, vs_L, vBase, 0, vb_size, iBase, pc); + EDevice.SetShader(EDevice.m_SelectionShader); + // and Render it as triangle list + DU_DRAW_DIP((D3DPRIMITIVETYPE)pt, vs_L, vBase, 0, vb_size, iBase, pc); } -void CDrawUtilities::DrawPrimitiveTL(D3DPRIMITIVETYPE pt, u32 pc, FVF::TL* vertices, int vc, BOOL bCull, BOOL bCycle) +void CDrawUtilities::DrawPrimitiveTL(D3DPRIMITIVETYPE pt, u32 pc, FVF::TL *vertices, int vc, BOOL bCull, BOOL bCycle) { - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase, dwNeed=(bCycle)?vc+1:vc; - FVF::TL* pv = (FVF::TL*)Stream->Lock(dwNeed,vs_TL->vb_stride,vBase); - for(int k=0; kset (vertices[k]); - if (bCycle) pv->set(*(pv-vc)); - Stream->Unlock(dwNeed,vs_TL->vb_stride); - - if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_NONE); - DU_DRAW_DP (pt,vs_TL,vBase,pc); - if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_CCW); + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase, dwNeed = (bCycle) ? vc+1 : vc; + FVF::TL *pv = (FVF::TL*)Stream->Lock(dwNeed, vs_TL->vb_stride, vBase); + for (int k = 0; kset(vertices[k]); + if (bCycle) + pv->set(*(pv-vc)); + Stream->Unlock(dwNeed, vs_TL->vb_stride); + + if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_NONE); + DU_DRAW_DP(pt, vs_TL, vBase, pc); + if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_CCW); } -void CDrawUtilities::DrawPrimitiveLIT(D3DPRIMITIVETYPE pt, u32 pc, FVF::LIT* vertices, int vc, BOOL bCull, BOOL bCycle) +void CDrawUtilities::DrawPrimitiveLIT(D3DPRIMITIVETYPE pt, u32 pc, FVF::LIT *vertices, int vc, BOOL bCull, BOOL bCycle) { - // fill VB - _VertexStream* Stream = &RCache.Vertex; - u32 vBase, dwNeed=(bCycle)?vc+1:vc; - FVF::LIT* pv = (FVF::LIT*)Stream->Lock(dwNeed,vs_LIT->vb_stride,vBase); - for(int k=0; kset (vertices[k]); - if (bCycle) pv->set(*(pv-vc)); - Stream->Unlock(dwNeed,vs_LIT->vb_stride); - - if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_NONE); - DU_DRAW_DP (pt,vs_LIT,vBase,pc); - if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE,D3DCULL_CCW); + // fill VB + _VertexStream *Stream = &RCache.Vertex; + u32 vBase, dwNeed = (bCycle) ? vc+1 : vc; + FVF::LIT *pv = (FVF::LIT*)Stream->Lock(dwNeed, vs_LIT->vb_stride, vBase); + for (int k = 0; kset(vertices[k]); + if (bCycle) + pv->set(*(pv-vc)); + Stream->Unlock(dwNeed, vs_LIT->vb_stride); + + if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_NONE); + DU_DRAW_DP(pt, vs_LIT, vBase, pc); + if (!bCull) DU_DRAW_RS(D3DRS_CULLMODE, D3DCULL_CCW); } -void CDrawUtilities::DrawLink(const Fvector& p0, const Fvector& p1, float sz, u32 clr) +void CDrawUtilities::DrawLink(const Fvector &p0, const Fvector &p1, float sz, u32 clr) { - DrawLine(p1,p0,clr); - Fvector pp[2],D,R,N={0,1,0}; - D.sub(p1,p0); D.normalize(); - R.crossproduct(N,D); R.mul(0.5f); D.mul(2.0f); N.mul(0.5f); + DrawLine(p1, p0, clr); + Fvector pp[2], D, R, N = {0,1,0}; + D.sub(p1, p0); + D.normalize(); + R.crossproduct(N, D); + R.mul(0.5f); + D.mul(2.0f); + N.mul(0.5f); // LR - pp[0].add(R,D); pp[0].mul(sz*-0.5f); pp[0].add(p1); - R.invert(); - pp[1].add(R,D); pp[1].mul(sz*-0.5f); pp[1].add(p1); - DrawLine(p1,pp[0],clr); - DrawLine(p1,pp[1],clr); + pp[0].add(R, D); + pp[0].mul(sz*-0.5f); + pp[0].add(p1); + R.invert(); + pp[1].add(R, D); + pp[1].mul(sz*-0.5f); + pp[1].add(p1); + DrawLine(p1, pp[0], clr); + DrawLine(p1, pp[1], clr); // UB - pp[0].add(N,D); pp[0].mul(sz*-0.5f); pp[0].add(p1); + pp[0].add(N, D); + pp[0].mul(sz*-0.5f); + pp[0].add(p1); N.invert(); - pp[1].add(N,D); pp[1].mul(sz*-0.5f); pp[1].add(p1); - DrawLine(p1,pp[0],clr); - DrawLine(p1,pp[1],clr); + pp[1].add(N, D); + pp[1].mul(sz*-0.5f); + pp[1].add(p1); + DrawLine(p1, pp[0], clr); + DrawLine(p1, pp[1], clr); } -void CDrawUtilities::DrawJoint(const Fvector& p, float radius, u32 clr) +void CDrawUtilities::DrawJoint(const Fvector &p, float radius, u32 clr) { - // RCache.set_xform_world (Fidentity); - DrawLineSphere(p,radius,clr,false); + // RCache.set_xform_world (Fidentity); + DrawLineSphere(p, radius, clr, false); } void CDrawUtilities::OnRender() { - m_Font->OnRender(); + m_Font->OnRender(); } -void CDrawUtilities::OutText(const Fvector& pos, LPCSTR text, u32 color, u32 shadow_color) +void CDrawUtilities::OutText(const Fvector &pos, LPCSTR text, u32 color, u32 shadow_color) { - Fvector p; - float w = pos.x*EDevice.mFullTransform._14 + pos.y*EDevice.mFullTransform._24 + pos.z*EDevice.mFullTransform._34 + EDevice.mFullTransform._44; - if (w>=0){ - EDevice.mFullTransform.transform(p,pos); - p.x = (float)iFloor(_x2real(p.x)); p.y = (float)iFloor(_y2real(-p.y)); - - m_Font->SetColor(shadow_color); - m_Font->Out(p.x,p.y,(LPSTR)text); - m_Font->SetColor(color); - m_Font->Out(p.x-1,p.y-1,(LPSTR)text); - } + Fvector p; + float w = pos.x*EDevice.mFullTransform._14+pos.y*EDevice.mFullTransform._24+pos.z*EDevice.mFullTransform._34+EDevice.mFullTransform._44; + if (w>=0) + { + EDevice.mFullTransform.transform(p, pos); + p.x = (float)iFloor(_x2real(p.x)); + p.y = (float)iFloor(_y2real(-p.y)); + + m_Font->SetColor(shadow_color); + m_Font->Out(p.x, p.y, (LPSTR)text); + m_Font->SetColor(color); + m_Font->Out(p.x-1, p.y-1, (LPSTR)text); + } } + diff --git a/src/editors/ECore/Editor/D3DUtils.h b/src/editors/ECore/Editor/D3DUtils.h index 38912ce08b9..bae99d9ab34 100644 --- a/src/editors/ECore/Editor/D3DUtils.h +++ b/src/editors/ECore/Editor/D3DUtils.h @@ -4,8 +4,8 @@ #ifndef D3DUtilsH_included #define D3DUtilsH_included - -#include "..\Include\xrRender\DrawUtils.h" + +#include "Include\xrRender\DrawUtils.h" //---------------------------------------------------- #ifdef _EDITOR @@ -18,135 +18,160 @@ class CEditableObject; -struct SPrimitiveBuffer{ - ref_geom pGeom; - u32 v_cnt; - u32 i_cnt; - D3DPRIMITIVETYPE p_type; - u32 p_cnt; - typedef fastdelegate::FastDelegate0<> TOnRender; - TOnRender OnRender; - void xr_stdcall RenderDIP() {DU_DRAW_DIP(p_type,pGeom,0,0,v_cnt,0,p_cnt);} - void xr_stdcall RenderDP() {DU_DRAW_DP (p_type,pGeom,0,p_cnt);} +struct SPrimitiveBuffer +{ + ref_geom pGeom; + u32 v_cnt; + u32 i_cnt; + D3DPRIMITIVETYPE p_type; + u32 p_cnt; + typedef fastdelegate::FastDelegate0<> TOnRender; + TOnRender OnRender; + + void xr_stdcall RenderDIP() + { + DU_DRAW_DIP(p_type, pGeom, 0, 0, v_cnt, 0, p_cnt); + } + + void xr_stdcall RenderDP() + { + DU_DRAW_DP(p_type, pGeom, 0, p_cnt); + } + public: - SPrimitiveBuffer():OnRender(0),pGeom(0){;} - void CreateFromData(D3DPRIMITIVETYPE _pt, u32 _p_cnt, u32 FVF, LPVOID vertices, u32 _v_cnt, u16* indices=0, u32 _i_cnt=0); - void Destroy(); - void Render(){OnRender();} + SPrimitiveBuffer(): OnRender(0), pGeom(0) + { + ; + } + + void CreateFromData(D3DPRIMITIVETYPE _pt, u32 _p_cnt, u32 FVF, LPVOID vertices, u32 _v_cnt, u16 *indices = 0, u32 _i_cnt = 0); + void Destroy(); + + void Render() + { + OnRender(); + } }; //---------------------------------------------------- // Utilities //---------------------------------------------------- -class ECORE_API CDrawUtilities: public CDUInterface, public pureRender{ - SPrimitiveBuffer m_SolidCone; - SPrimitiveBuffer m_WireCone; - SPrimitiveBuffer m_SolidSphere; - SPrimitiveBuffer m_WireSphere; - SPrimitiveBuffer m_SolidSpherePart; - SPrimitiveBuffer m_WireSpherePart; - SPrimitiveBuffer m_SolidCylinder; - SPrimitiveBuffer m_WireCylinder; - SPrimitiveBuffer m_SolidBox; - SPrimitiveBuffer m_WireBox; - CGameFont* m_Font; - CEditableObject* m_axis_object; -public: - ref_geom vs_L; - ref_geom vs_TL; - ref_geom vs_LIT; -protected: - FVF::L* m_DD_pv; - FVF::L* m_DD_pv_start; - u32 m_DD_base; - BOOL m_DD_wire; - void DD_DrawFace_flush (BOOL try_again); -public: - void DD_DrawFace_begin (BOOL bWire); - void DD_DrawFace_push (const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 clr); - void DD_DrawFace_end (); -public: - CDrawUtilities() +class ECORE_API CDrawUtilities: + +public +CDUInterface +, +public +pureRender +{ + SPrimitiveBuffer m_SolidCone; + SPrimitiveBuffer m_WireCone; + SPrimitiveBuffer m_SolidSphere; + SPrimitiveBuffer m_WireSphere; + SPrimitiveBuffer m_SolidSpherePart; + SPrimitiveBuffer m_WireSpherePart; + SPrimitiveBuffer m_SolidCylinder; + SPrimitiveBuffer m_WireCylinder; + SPrimitiveBuffer m_SolidBox; + SPrimitiveBuffer m_WireBox; + CGameFont* m_Font; + CEditableObject* m_axis_object; + public: + ref_geom vs_L; + ref_geom vs_TL; + ref_geom vs_LIT; + protected: + FVF::L* m_DD_pv; + FVF::L* m_DD_pv_start; + u32 m_DD_base; + BOOL m_DD_wire; + void DD_DrawFace_flush (BOOL try_again); + public: + void DD_DrawFace_begin (BOOL bWire); + void DD_DrawFace_push (const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 clr); + void DD_DrawFace_end (); + public: + CDrawUtilities() { - vs_L = 0; - vs_TL = 0; - vs_LIT = 0; - m_DD_pv = 0; - m_DD_pv_start = 0; - m_DD_base = 0; - m_Font = 0; - } - - void OnDeviceCreate (); - void OnDeviceDestroy(); - - void UpdateGrid(int number_of_cell, float square_size, int subdiv=10); - - //---------------------------------------------------- - virtual void __stdcall DrawCross(const Fvector& p, float szx1, float szy1, float szz1, float szx2, float szy2, float szz2, u32 clr, BOOL bRot45=false); - virtual void __stdcall DrawCross(const Fvector& p, float sz, u32 clr, BOOL bRot45=false){ DrawCross(p, sz,sz,sz, sz,sz,sz, clr, bRot45); } - virtual void __stdcall DrawEntity(u32 clr, ref_shader s); - virtual void __stdcall DrawFlag(const Fvector& p, float heading, float height, float sz, float sz_fl, u32 clr, BOOL bDrawEntity); - virtual void __stdcall DrawRomboid(const Fvector& p, float radius, u32 clr); - virtual void __stdcall DrawJoint(const Fvector& p, float radius, u32 clr); - - virtual void __stdcall DrawSpotLight(const Fvector& p, const Fvector& d, float range, float phi, u32 clr); - virtual void __stdcall DrawDirectionalLight(const Fvector& p, const Fvector& d, float radius, float range, u32 clr); - virtual void __stdcall DrawPointLight(const Fvector& p, float radius, u32 clr); - - virtual void __stdcall DrawSound(const Fvector& p, float radius, u32 clr); - virtual void __stdcall DrawLineSphere(const Fvector& p, float radius, u32 clr, BOOL bCross); - - virtual void __stdcall dbgDrawPlacement(const Fvector& p, int sz, u32 clr, LPCSTR caption=0, u32 clr_font=0xffffffff); - virtual void __stdcall dbgDrawVert(const Fvector& p0, u32 clr, LPCSTR caption=0); - virtual void __stdcall dbgDrawEdge(const Fvector& p0, const Fvector& p1, u32 clr, LPCSTR caption=0); - virtual void __stdcall dbgDrawFace(const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 clr, LPCSTR caption=0); - - virtual void __stdcall DrawFace(const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); - virtual void __stdcall DrawLine(const Fvector& p0, const Fvector& p1, u32 clr); - virtual void __stdcall DrawLink(const Fvector& p0, const Fvector& p1, float sz, u32 clr); - IC virtual void __stdcall DrawFaceNormal(const Fvector& p0, const Fvector& p1, const Fvector& p2, float size, u32 clr){ - Fvector N,C,P; N.mknormal(p0,p1,p2); C.set(p0);C.add(p1);C.add(p2);C.div(3); - P.mad(C,N,size); - DrawLine(C,P,clr);} - IC virtual void __stdcall DrawFaceNormal(const Fvector* p, float size, u32 clr){DrawFaceNormal(p[0],p[1],p[2],size,clr);} - IC virtual void __stdcall DrawFaceNormal(const Fvector& C, const Fvector& N, float size, u32 clr){ - Fvector P; P.mad(C,N,size);DrawLine(C,P,clr);} - virtual void __stdcall DrawSelectionBox(const Fvector& center, const Fvector& size, u32* c=0); - virtual void __stdcall DrawSelectionBoxB(const Fbox& box, u32* c=0); - - virtual void __stdcall DrawIdentSphere (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); - virtual void __stdcall DrawIdentSpherePart(BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); - virtual void __stdcall DrawIdentCone (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); - virtual void __stdcall DrawIdentCylinder (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); - virtual void __stdcall DrawIdentBox (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); - - virtual void __stdcall DrawBox (const Fvector& offs, const Fvector& Size, BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); - virtual void __stdcall DrawAABB (const Fvector& p0, const Fvector& p1, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); - virtual void __stdcall DrawAABB (const Fmatrix& parent, const Fvector& center, const Fvector& size, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); - virtual void __stdcall DrawOBB (const Fmatrix& parent, const Fobb& box, u32 clr_s, u32 clr_w); - virtual void __stdcall DrawSphere (const Fmatrix& parent, const Fvector& center, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); - virtual void __stdcall DrawSphere (const Fmatrix& parent, const Fsphere& S, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire){DrawSphere(parent,S.P,S.R,clr_s,clr_w,bSolid,bWire);} - virtual void __stdcall DrawCylinder(const Fmatrix& parent, const Fvector& center, const Fvector& dir, float height, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); - virtual void __stdcall DrawCone (const Fmatrix& parent, const Fvector& apex, const Fvector& dir, float height, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); - virtual void __stdcall DrawPlane (const Fvector& center, const Fvector2& scale, const Fvector& rotate, u32 clr_s, u32 clr_w, BOOL bCull, BOOL bSolid, BOOL bWire); - virtual void __stdcall DrawPlane (const Fvector& p, const Fvector& n, const Fvector2& scale, u32 clr_s, u32 clr_w, BOOL bCull, BOOL bSolid, BOOL bWire); - virtual void __stdcall DrawRectangle(const Fvector& o, const Fvector& u, const Fvector& v, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); - - virtual void __stdcall DrawGrid (); - virtual void __stdcall DrawPivot (const Fvector& pos, float sz=5.f); - virtual void __stdcall DrawAxis (const Fmatrix& T); - virtual void __stdcall DrawObjectAxis(const Fmatrix& T, float sz, BOOL sel); - virtual void __stdcall DrawSelectionRect(const Ivector2& m_SelStart, const Ivector2& m_SelEnd); - virtual void __stdcall DrawIndexedPrimitive (int pt, u32 pc, const Fvector& pos, const Fvector* vb, const u32& vb_size, const u32* ib, const u32& ib_size, const u32& clr_argb, float scale=1.0f); - - virtual void __stdcall DrawPrimitiveL(D3DPRIMITIVETYPE pt, u32 pc, Fvector* vertices, int vc, u32 color, BOOL bCull, BOOL bCycle); - virtual void __stdcall DrawPrimitiveTL(D3DPRIMITIVETYPE pt, u32 pc, FVF::TL* vertices, int vc, BOOL bCull, BOOL bCycle); - virtual void __stdcall DrawPrimitiveLIT(D3DPRIMITIVETYPE pt, u32 pc, FVF::LIT* vertices, int vc, BOOL bCull, BOOL bCycle); - - virtual void __stdcall OutText (const Fvector& pos, LPCSTR text, u32 color=0xFF000000, u32 shadow_color=0xFF909090); - - virtual void OnRender (); + vs_L = 0; + vs_TL = 0; + vs_LIT = 0; + m_DD_pv = 0; + m_DD_pv_start = 0; + m_DD_base = 0; + m_Font = 0; +} + +void OnDeviceCreate (); +void OnDeviceDestroy(); + +void UpdateGrid(int number_of_cell, float square_size, int subdiv=10); + +//---------------------------------------------------- +virtual void __stdcall DrawCross(const Fvector& p, float szx1, float szy1, float szz1, float szx2, float szy2, float szz2, u32 clr, BOOL bRot45=false); +virtual void __stdcall DrawCross(const Fvector& p, float sz, u32 clr, BOOL bRot45=false){ DrawCross(p, sz,sz,sz, sz,sz,sz, clr, bRot45); } +virtual void __stdcall DrawEntity(u32 clr, ref_shader s); +virtual void __stdcall DrawFlag(const Fvector& p, float heading, float height, float sz, float sz_fl, u32 clr, BOOL bDrawEntity); +virtual void __stdcall DrawRomboid(const Fvector& p, float radius, u32 clr); +virtual void __stdcall DrawJoint(const Fvector& p, float radius, u32 clr); + +virtual void __stdcall DrawSpotLight(const Fvector& p, const Fvector& d, float range, float phi, u32 clr); +virtual void __stdcall DrawDirectionalLight(const Fvector& p, const Fvector& d, float radius, float range, u32 clr); +virtual void __stdcall DrawPointLight(const Fvector& p, float radius, u32 clr); + +virtual void __stdcall DrawSound(const Fvector& p, float radius, u32 clr); +virtual void __stdcall DrawLineSphere(const Fvector& p, float radius, u32 clr, BOOL bCross); + +virtual void __stdcall dbgDrawPlacement(const Fvector& p, int sz, u32 clr, LPCSTR caption=0, u32 clr_font=0xffffffff); +virtual void __stdcall dbgDrawVert(const Fvector& p0, u32 clr, LPCSTR caption=0); +virtual void __stdcall dbgDrawEdge(const Fvector& p0, const Fvector& p1, u32 clr, LPCSTR caption=0); +virtual void __stdcall dbgDrawFace(const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 clr, LPCSTR caption=0); + +virtual void __stdcall DrawFace(const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); +virtual void __stdcall DrawLine(const Fvector& p0, const Fvector& p1, u32 clr); +virtual void __stdcall DrawLink(const Fvector& p0, const Fvector& p1, float sz, u32 clr); +IC virtual void __stdcall DrawFaceNormal(const Fvector& p0, const Fvector& p1, const Fvector& p2, float size, u32 clr){ + Fvector N,C,P; N.mknormal(p0,p1,p2); C.set(p0);C.add(p1);C.add(p2);C.div(3); + P.mad(C,N,size); + DrawLine(C,P,clr);} +IC virtual void __stdcall DrawFaceNormal(const Fvector* p, float size, u32 clr){DrawFaceNormal(p[0],p[1],p[2],size,clr);} +IC virtual void __stdcall DrawFaceNormal(const Fvector& C, const Fvector& N, float size, u32 clr){ + Fvector P; P.mad(C,N,size);DrawLine(C,P,clr);} +virtual void __stdcall DrawSelectionBox(const Fvector& center, const Fvector& size, u32* c=0); +virtual void __stdcall DrawSelectionBoxB(const Fbox& box, u32* c=0); + +virtual void __stdcall DrawIdentSphere (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); +virtual void __stdcall DrawIdentSpherePart(BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); +virtual void __stdcall DrawIdentCone (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); +virtual void __stdcall DrawIdentCylinder (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); +virtual void __stdcall DrawIdentBox (BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); + +virtual void __stdcall DrawBox (const Fvector& offs, const Fvector& Size, BOOL bSolid, BOOL bWire, u32 clr_s, u32 clr_w); +virtual void __stdcall DrawAABB (const Fvector& p0, const Fvector& p1, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); +virtual void __stdcall DrawAABB (const Fmatrix& parent, const Fvector& center, const Fvector& size, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); +virtual void __stdcall DrawOBB (const Fmatrix& parent, const Fobb& box, u32 clr_s, u32 clr_w); +virtual void __stdcall DrawSphere (const Fmatrix& parent, const Fvector& center, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); +virtual void __stdcall DrawSphere (const Fmatrix& parent, const Fsphere& S, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire){DrawSphere(parent,S.P,S.R,clr_s,clr_w,bSolid,bWire);} +virtual void __stdcall DrawCylinder(const Fmatrix& parent, const Fvector& center, const Fvector& dir, float height, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); +virtual void __stdcall DrawCone (const Fmatrix& parent, const Fvector& apex, const Fvector& dir, float height, float radius, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); +virtual void __stdcall DrawPlane (const Fvector& center, const Fvector2& scale, const Fvector& rotate, u32 clr_s, u32 clr_w, BOOL bCull, BOOL bSolid, BOOL bWire); +virtual void __stdcall DrawPlane (const Fvector& p, const Fvector& n, const Fvector2& scale, u32 clr_s, u32 clr_w, BOOL bCull, BOOL bSolid, BOOL bWire); +virtual void __stdcall DrawRectangle(const Fvector& o, const Fvector& u, const Fvector& v, u32 clr_s, u32 clr_w, BOOL bSolid, BOOL bWire); + +virtual void __stdcall DrawGrid (); +virtual void __stdcall DrawPivot (const Fvector& pos, float sz=5.f); +virtual void __stdcall DrawAxis (const Fmatrix& T); +virtual void __stdcall DrawObjectAxis(const Fmatrix& T, float sz, BOOL sel); +virtual void __stdcall DrawSelectionRect(const Ivector2& m_SelStart, const Ivector2& m_SelEnd); +virtual void __stdcall DrawIndexedPrimitive (int pt, u32 pc, const Fvector& pos, const Fvector* vb, const u32& vb_size, const u32* ib, const u32& ib_size, const u32& clr_argb, float scale=1.0f); + +virtual void __stdcall DrawPrimitiveL(D3DPRIMITIVETYPE pt, u32 pc, Fvector* vertices, int vc, u32 color, BOOL bCull, BOOL bCycle); +virtual void __stdcall DrawPrimitiveTL(D3DPRIMITIVETYPE pt, u32 pc, FVF::TL* vertices, int vc, BOOL bCull, BOOL bCycle); +virtual void __stdcall DrawPrimitiveLIT(D3DPRIMITIVETYPE pt, u32 pc, FVF::LIT* vertices, int vc, BOOL bCull, BOOL bCycle); + +virtual void __stdcall OutText (const Fvector& pos, LPCSTR text, u32 color=0xFF000000, u32 shadow_color=0xFF909090); + +virtual void OnRender (); }; extern ECORE_API CDrawUtilities DU_impl; //---------------------------------------------------- diff --git a/src/editors/ECore/Editor/D3DX_Wrapper.h b/src/editors/ECore/Editor/D3DX_Wrapper.h index b06701f0271..f65d19c7583 100644 --- a/src/editors/ECore/Editor/D3DX_Wrapper.h +++ b/src/editors/ECore/Editor/D3DX_Wrapper.h @@ -2,206 +2,211 @@ #define D3DX_WraperH #pragma once +#include "xrCore/Platform.h" + #ifdef ETOOLS_EXPORTS -#define ETOOLS_API __declspec( dllexport ) +#define ETOOLS_API XR_EXPORT #else -#define ETOOLS_API __declspec( dllimport ) +#define ETOOLS_API XR_IMPORT #endif -extern "C" { - ETOOLS_API UINT WINAPI - D3DX_GetDriverLevel( - LPDIRECT3DDEVICE9 pDevice); - - ETOOLS_API HRESULT WINAPI - D3DX_GetImageInfoFromFileInMemory( - LPCVOID pSrcData, - UINT SrcDataSize, - D3DXIMAGE_INFO* pSrcInfo); - - ETOOLS_API HRESULT WINAPI - D3DX_CreateCubeTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE9 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE9* ppCubeTexture); - - ETOOLS_API HRESULT WINAPI - D3DX_CreateTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE9 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE9* ppTexture); - - ETOOLS_API HRESULT WINAPI - D3DX_CreateTexture( - LPDIRECT3DDEVICE9 pDevice, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DTEXTURE9* ppTexture); - - ETOOLS_API HRESULT WINAPI - D3DX_ComputeNormalMap( - LPDIRECT3DTEXTURE9 pTexture, - LPDIRECT3DTEXTURE9 pSrcTexture, - const PALETTEENTRY *pSrcPalette, - DWORD Flags, - DWORD Channel, - FLOAT Amplitude); - - ETOOLS_API HRESULT WINAPI - D3DX_LoadSurfaceFromSurface( - LPDIRECT3DSURFACE9 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPDIRECT3DSURFACE9 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey); - - ETOOLS_API HRESULT WINAPI - D3DX_CompileShader( - LPCSTR pSrcData, - UINT SrcDataLen, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pFunctionName, - LPCSTR pTarget, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - - ETOOLS_API HRESULT WINAPI - D3DX_CompileShaderFromFile( - LPCSTR pSrcFile, - CONST D3DXMACRO* pDefines, - LPD3DXINCLUDE pInclude, - LPCSTR pFunctionName, - LPCSTR pTarget, - DWORD Flags, - LPD3DXBUFFER* ppShader, - LPD3DXBUFFER* ppErrorMsgs, - LPD3DXCONSTANTTABLE* ppConstantTable); - - ETOOLS_API HRESULT WINAPI - D3DX_FindShaderComment( - CONST DWORD* pFunction, - DWORD FourCC, - LPCVOID* ppData, - UINT* pSizeInBytes); - - ETOOLS_API HRESULT WINAPI - D3DX_DeclaratorFromFVF( - DWORD FVF, - D3DVERTEXELEMENT9 pDeclarator[MAX_FVF_DECL_SIZE]); - - ETOOLS_API UINT WINAPI - D3DX_GetDeclVertexSize( - CONST D3DVERTEXELEMENT9*pDecl, - DWORD Stream); - - ETOOLS_API UINT WINAPI - D3DX_GetDeclLength( - CONST D3DVERTEXELEMENT9*pDecl); - - ETOOLS_API UINT WINAPI - D3DX_GetFVFVertexSize( - DWORD FVF); - - ETOOLS_API const char* WINAPI - DX_GetErrorDescription9( - HRESULT hr); - - ETOOLS_API D3DXMATRIX* WINAPI - D3DX_MatrixInverse( - D3DXMATRIX *pOut, - FLOAT *pDeterminant, - CONST D3DXMATRIX *pM); - - ETOOLS_API D3DXMATRIX* WINAPI - D3DX_MatrixTranspose( - D3DXMATRIX *pOut, - CONST D3DXMATRIX *pM); - - ETOOLS_API D3DXPLANE* WINAPI - D3DX_PlaneNormalize( - D3DXPLANE *pOut, - CONST D3DXPLANE *pP); - - ETOOLS_API D3DXPLANE* WINAPI - D3DX_PlaneTransform( - D3DXPLANE *pOut, - CONST D3DXPLANE *pP, - CONST D3DXMATRIX *pM); - - ETOOLS_API HRESULT WINAPI - D3DX_OptimizeFaces( - LPCVOID pIndices, - UINT NumFaces, - UINT NumVertices, - BOOL Indices32Bit, - DWORD * pFaceRemap); - - ETOOLS_API HRESULT WINAPI - D3DX_OptimizeVertices( - LPCVOID pIndices, - UINT NumFaces, - UINT NumVertices, - BOOL Indices32Bit, - DWORD * pVertexRemap); +extern "C" +{ + ETOOLS_API UINT WINAPI + D3DX_GetDriverLevel( + LPDIRECT3DDEVICE9 pDevice); + + ETOOLS_API HRESULT WINAPI + D3DX_GetImageInfoFromFileInMemory( + LPCVOID pSrcData, + UINT SrcDataSize, + D3DXIMAGE_INFO *pSrcInfo); + + ETOOLS_API HRESULT WINAPI + D3DX_CreateCubeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE9 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO *pSrcInfo, + PALETTEENTRY *pPalette, + LPDIRECT3DCUBETEXTURE9 *ppCubeTexture); + + ETOOLS_API HRESULT WINAPI + D3DX_CreateTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE9 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO *pSrcInfo, + PALETTEENTRY *pPalette, + LPDIRECT3DTEXTURE9 *ppTexture); + + ETOOLS_API HRESULT WINAPI + D3DX_CreateTexture( + LPDIRECT3DDEVICE9 pDevice, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DTEXTURE9 *ppTexture); + + ETOOLS_API HRESULT WINAPI + D3DX_ComputeNormalMap( + LPDIRECT3DTEXTURE9 pTexture, + LPDIRECT3DTEXTURE9 pSrcTexture, + const PALETTEENTRY *pSrcPalette, + DWORD Flags, + DWORD Channel, + FLOAT Amplitude); + + ETOOLS_API HRESULT WINAPI + D3DX_LoadSurfaceFromSurface( + LPDIRECT3DSURFACE9 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPDIRECT3DSURFACE9 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + ETOOLS_API HRESULT WINAPI + D3DX_CompileShader( + LPCSTR pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pTarget, + DWORD Flags, + LPD3DXBUFFER *ppShader, + LPD3DXBUFFER *ppErrorMsgs, + LPD3DXCONSTANTTABLE *ppConstantTable); + + ETOOLS_API HRESULT WINAPI + D3DX_CompileShaderFromFile( + LPCSTR pSrcFile, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pTarget, + DWORD Flags, + LPD3DXBUFFER *ppShader, + LPD3DXBUFFER *ppErrorMsgs, + LPD3DXCONSTANTTABLE *ppConstantTable); + + ETOOLS_API HRESULT WINAPI + D3DX_FindShaderComment( + CONST DWORD* pFunction, + DWORD FourCC, + LPCVOID *ppData, + UINT *pSizeInBytes); + + ETOOLS_API HRESULT WINAPI + D3DX_DeclaratorFromFVF( + DWORD FVF, + D3DVERTEXELEMENT9 pDeclarator[MAX_FVF_DECL_SIZE]); + + ETOOLS_API UINT WINAPI + D3DX_GetDeclVertexSize( + CONST D3DVERTEXELEMENT9*pDecl, + DWORD Stream); + + ETOOLS_API UINT WINAPI + D3DX_GetDeclLength( + CONST D3DVERTEXELEMENT9*pDecl); + + ETOOLS_API UINT WINAPI + D3DX_GetFVFVertexSize( + DWORD FVF); + + ETOOLS_API const + char *WINAPI + DX_GetErrorDescription9( + HRESULT hr); + + ETOOLS_API D3DXMATRIX* WINAPI + D3DX_MatrixInverse( + D3DXMATRIX *pOut, + FLOAT *pDeterminant, + CONST D3DXMATRIX*pM); + + ETOOLS_API D3DXMATRIX* WINAPI + D3DX_MatrixTranspose( + D3DXMATRIX *pOut, + CONST D3DXMATRIX*pM); + + ETOOLS_API D3DXPLANE* WINAPI + D3DX_PlaneNormalize( + D3DXPLANE *pOut, + CONST D3DXPLANE*pP); + + ETOOLS_API D3DXPLANE* WINAPI + D3DX_PlaneTransform( + D3DXPLANE *pOut, + CONST D3DXPLANE*pP, + CONST D3DXMATRIX*pM); + + ETOOLS_API HRESULT WINAPI + D3DX_OptimizeFaces( + LPCVOID pIndices, + UINT NumFaces, + UINT NumVertices, + BOOL Indices32Bit, + DWORD *pFaceRemap); + + ETOOLS_API HRESULT WINAPI + D3DX_OptimizeVertices( + LPCVOID pIndices, + UINT NumFaces, + UINT NumVertices, + BOOL Indices32Bit, + DWORD *pVertexRemap); } #ifndef ETOOLS_EXPORTS - #undef D3DXCompileShaderFromFile - #undef DXGetErrorDescription9 - #define D3DXGetDriverLevel D3DX_GetDriverLevel - #define D3DXGetImageInfoFromFileInMemory D3DX_GetImageInfoFromFileInMemory - #define D3DXCreateCubeTextureFromFileInMemoryEx D3DX_CreateCubeTextureFromFileInMemoryEx - #define D3DXCreateTextureFromFileInMemoryEx D3DX_CreateTextureFromFileInMemoryEx - #define D3DXCreateTexture D3DX_CreateTexture - #define D3DXComputeNormalMap D3DX_ComputeNormalMap - #define D3DXLoadSurfaceFromSurface D3DX_LoadSurfaceFromSurface - #define D3DXCompileShaderFromFile D3DX_CompileShaderFromFile - #define D3DXCompileShader D3DX_CompileShader - #define D3DXFindShaderComment D3DX_FindShaderComment - #define D3DXDeclaratorFromFVF D3DX_DeclaratorFromFVF - #define D3DXGetDeclVertexSize D3DX_GetDeclVertexSize - #define D3DXGetDeclLength D3DX_GetDeclLength - #define D3DXGetFVFVertexSize D3DX_GetFVFVertexSize - #define DXGetErrorDescription9 DX_GetErrorDescription9 - #define D3DXMatrixInverse D3DX_MatrixInverse - #define D3DXMatrixTranspose D3DX_MatrixTranspose - #define D3DXPlaneNormalize D3DX_PlaneNormalize - #define D3DXPlaneTransform D3DX_PlaneTransform - #define D3DXOptimizeFaces D3DX_OptimizeFaces - #define D3DXOptimizeVertices D3DX_OptimizeVertices +#undef D3DXCompileShaderFromFile +#undef DXGetErrorDescription9 +#define D3DXGetDriverLevel D3DX_GetDriverLevel +#define D3DXGetImageInfoFromFileInMemory D3DX_GetImageInfoFromFileInMemory +#define D3DXCreateCubeTextureFromFileInMemoryEx D3DX_CreateCubeTextureFromFileInMemoryEx +#define D3DXCreateTextureFromFileInMemoryEx D3DX_CreateTextureFromFileInMemoryEx +#define D3DXCreateTexture D3DX_CreateTexture +#define D3DXComputeNormalMap D3DX_ComputeNormalMap +#define D3DXLoadSurfaceFromSurface D3DX_LoadSurfaceFromSurface +#define D3DXCompileShaderFromFile D3DX_CompileShaderFromFile +#define D3DXCompileShader D3DX_CompileShader +#define D3DXFindShaderComment D3DX_FindShaderComment +#define D3DXDeclaratorFromFVF D3DX_DeclaratorFromFVF +#define D3DXGetDeclVertexSize D3DX_GetDeclVertexSize +#define D3DXGetDeclLength D3DX_GetDeclLength +#define D3DXGetFVFVertexSize D3DX_GetFVFVertexSize +#define DXGetErrorDescription9 DX_GetErrorDescription9 +#define D3DXMatrixInverse D3DX_MatrixInverse +#define D3DXMatrixTranspose D3DX_MatrixTranspose +#define D3DXPlaneNormalize D3DX_PlaneNormalize +#define D3DXPlaneTransform D3DX_PlaneTransform +#define D3DXOptimizeFaces D3DX_OptimizeFaces +#define D3DXOptimizeVertices D3DX_OptimizeVertices #endif #endif + diff --git a/src/editors/ECore/Editor/DeviceScreenshot.cpp b/src/editors/ECore/Editor/DeviceScreenshot.cpp index 7b9e82ca073..cb02cced574 100644 --- a/src/editors/ECore/Editor/DeviceScreenshot.cpp +++ b/src/editors/ECore/Editor/DeviceScreenshot.cpp @@ -2,59 +2,61 @@ #include "stdafx.h" #pragma hdrstop -#include "ui_toolscustom.h" +#include "UI_ToolsCustom.h" #include "ui_main.h" -#include "ResourceManager.h" +#include "Layers/xrRender/ResourceManager.h" -bool CEditorRenderDevice::MakeScreenshot(U32Vec& pixels, u32 width, u32 height) +bool CEditorRenderDevice::MakeScreenshot(U32Vec &pixels, u32 width, u32 height) { - if (!b_is_Ready) return false; + if (!b_is_Ready) + return false; // free managed resource Resources->Evict(); - IDirect3DSurface9* poldZB=0; - IDirect3DSurface9* pZB=0; - IDirect3DSurface9* pRT=0; - IDirect3DSurface9* poldRT=0; - D3DVIEWPORT9 oldViewport; - SetRS(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED); - CHK_DX(HW.pDevice->GetRenderTarget(0,&poldRT)); + IDirect3DSurface9 *poldZB = 0; + IDirect3DSurface9 *pZB = 0; + IDirect3DSurface9 *pRT = 0; + IDirect3DSurface9 *poldRT = 0; + D3DVIEWPORT9 oldViewport; + SetRS(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED); + CHK_DX(HW.pDevice->GetRenderTarget(0, &poldRT)); CHK_DX(HW.pDevice->GetDepthStencilSurface(&poldZB)); CHK_DX(HW.pDevice->GetViewport(&oldViewport)); - CHK_DX(HW.pDevice->CreateRenderTarget(width,height,D3DFMT_A8R8G8B8,D3DMULTISAMPLE_NONE,0,FALSE,&pRT,0)); - CHK_DX(HW.pDevice->CreateDepthStencilSurface(width,height,HW.Caps.bStencil?D3DFMT_D24S8:D3DFMT_D24X8,D3DMULTISAMPLE_NONE,0,FALSE,&pZB,0)); - CHK_DX(HW.pDevice->SetRenderTarget(0,pRT)); - CHK_DX(HW.pDevice->SetDepthStencilSurface(pZB)); + CHK_DX(HW.pDevice->CreateRenderTarget(width, height, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &pRT, 0)); + CHK_DX(HW.pDevice->CreateDepthStencilSurface(width, height, HW.Caps.bStencil ? D3DFMT_D24S8 : D3DFMT_D24X8, D3DMULTISAMPLE_NONE, 0, FALSE, &pZB, 0)); + CHK_DX(HW.pDevice->SetRenderTarget(0, pRT)); + CHK_DX(HW.pDevice->SetDepthStencilSurface(pZB)); - UI->PrepareRedraw (); - EDevice.Begin (); - Tools->Render (); - EDevice.End (); + UI->PrepareRedraw(); + EDevice.Begin(); + Tools->Render(); + EDevice.End(); - // Create temp-surface - IDirect3DSurface9* pFB; - R_CHK(HW.pDevice->CreateOffscreenPlainSurface( - width,height,D3DFMT_A8R8G8B8,D3DPOOL_SYSTEMMEM,&pFB,NULL)); - R_CHK(HW.pDevice->GetRenderTargetData(pRT, pFB)); + // Create temp-surface + IDirect3DSurface9 *pFB; + R_CHK(HW.pDevice->CreateOffscreenPlainSurface( + width, height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &pFB, NULL)); + R_CHK(HW.pDevice->GetRenderTargetData(pRT, pFB)); - D3DLOCKED_RECT D; - R_CHK(pFB->LockRect(&D,0,D3DLOCK_NOSYSLOCK)); - pixels.resize(width*height); - // Image processing - u32* pPixel = (u32*)D.pBits; + D3DLOCKED_RECT D; + R_CHK(pFB->LockRect(&D, 0, D3DLOCK_NOSYSLOCK)); + pixels.resize(width*height); + // Image processing + u32 *pPixel = (u32*)D.pBits; - U32It it = pixels.begin(); - for (int h=height-1; h>=0; h--,it+=width){ - LPDWORD dt = LPDWORD(u32(pPixel)+u32(D.Pitch*h)); - CopyMemory (it,dt,sizeof(u32)*width); + U32It it = pixels.begin(); + for (int h = height-1; h>=0; h--,it += width) + { + LPDWORD dt = LPDWORD(u32(pPixel)+u32(D.Pitch*h)); + CopyMemory(it, dt, sizeof(u32)*width); } R_CHK(pFB->UnlockRect()); - CHK_DX(HW.pDevice->SetDepthStencilSurface(poldZB)); - CHK_DX(HW.pDevice->SetRenderTarget(0,poldRT)); + CHK_DX(HW.pDevice->SetDepthStencilSurface(poldZB)); + CHK_DX(HW.pDevice->SetRenderTarget(0, poldRT)); CHK_DX(HW.pDevice->SetViewport(&oldViewport)); _RELEASE(pZB); @@ -66,4 +68,3 @@ bool CEditorRenderDevice::MakeScreenshot(U32Vec& pixels, u32 width, u32 height) return true; } - diff --git a/src/editors/ECore/Editor/DrawUtils.h b/src/editors/ECore/Editor/DrawUtils.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Editor/DrawUtils.h @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Editor/EDetailModel.cpp b/src/editors/ECore/Editor/EDetailModel.cpp index 404f928ad8a..d0dad6ce4f4 100644 --- a/src/editors/ECore/Editor/EDetailModel.cpp +++ b/src/editors/ECore/Editor/EDetailModel.cpp @@ -15,256 +15,281 @@ #define DETOBJ_CHUNK_FLAGS 0x0104 #define DETOBJ_VERSION 0x0001 + //------------------------------------------------------------------------------ -void EDetail::EVertexIn::remapUV(const fvfVertexIn& src, const Fvector2& offs, const Fvector2& scale, bool bRotate) +void EDetail::EVertexIn::remapUV(const fvfVertexIn &src, const Fvector2 &offs, const Fvector2 &scale, bool bRotate) { - P.set (src.P); - ImageLib.MergedTextureRemapUV(u,v,src.u,src.v, offs, scale, bRotate); + P.set(src.P); + ImageLib.MergedTextureRemapUV(u, v, src.u, src.v, offs, scale, bRotate); } EDetail::EDetail() { - shader = 0; - m_Flags.zero (); - m_pRefs = 0; - m_fMinScale = 0.5f; - m_fMaxScale = 2.f; - m_fDensityFactor = 1.f; - m_sRefs = ""; - vertices = 0; - number_vertices = 0; - indices = 0; - number_indices = 0; + shader = 0; + m_Flags.zero(); + m_pRefs = 0; + m_fMinScale = 0.5f; + m_fMaxScale = 2.f; + m_fDensityFactor = 1.f; + m_sRefs = ""; + vertices = 0; + number_vertices = 0; + indices = 0; + number_indices = 0; } EDetail::~EDetail() { - Unload(); + Unload(); } void EDetail::Unload() { - CDetail::Unload (); + CDetail::Unload(); Lib.RemoveEditObject(m_pRefs); - OnDeviceDestroy (); + OnDeviceDestroy(); } -LPCSTR EDetail::GetName () +LPCSTR EDetail::GetName() { - return m_pRefs?m_pRefs->GetName():m_sRefs.c_str(); + return m_pRefs ? m_pRefs->GetName() : m_sRefs.c_str(); } LPCSTR EDetail::GetTextureName() { - VERIFY(m_pRefs); - CSurface* surf = *m_pRefs->FirstSurface(); VERIFY(surf); + VERIFY(m_pRefs); + CSurface*surf = *m_pRefs->FirstSurface(); + VERIFY(surf); return surf->_Texture(); } -void EDetail::DefferedLoad() -{ -} +void EDetail::DefferedLoad() {} void EDetail::OnDeviceCreate() { - if (!m_pRefs) return; - CSurface* surf = *m_pRefs->FirstSurface(); - VERIFY (surf); - AnsiString s_name = surf->_ShaderName(); - AnsiString t_name = surf->_Texture(); - shader.create (s_name.c_str(),t_name.c_str()); + if (!m_pRefs) + return; + CSurface*surf = *m_pRefs->FirstSurface(); + VERIFY(surf); + AnsiString s_name = surf->_ShaderName(); + AnsiString t_name = surf->_Texture(); + shader.create(s_name.c_str(), t_name.c_str()); } void EDetail::OnDeviceDestroy() { - shader.destroy(); + shader.destroy(); } -u16 EDetail::_AddVert(const Fvector& p, float u, float v) +u16 EDetail::_AddVert(const Fvector &p, float u, float v) { - EVertexIn V(p,u,v); - for (u16 k=0; k<(u16)number_vertices; k++) - if (V.similar((EVertexIn&)vertices[k])) return k; + EVertexIn V(p, u, v); + for (u16 k = 0; k<(u16)number_vertices; k++) + if (V.similar((EVertexIn&)vertices[k])) + return k; number_vertices++; - vertices = (fvfVertexIn*)xr_realloc(vertices,number_vertices*sizeof(fvfVertexIn)); + vertices = (fvfVertexIn*)xr_realloc(vertices, number_vertices*sizeof(fvfVertexIn)); vertices[number_vertices-1] = V; return u16(number_vertices-1); } IC BOOL isDegenerated(u16 v[3]) { - return (v[0]==v[1] || v[0]==v[2] || v[1]==v[2]); + return (v[0]==v[1]||v[0]==v[2]||v[1]==v[2]); }; -IC BOOL isEqual(U16Vec& ind, u16 v[3]) + +IC BOOL isEqual(U16Vec &ind, u16 v[3]) { - for (U16It it=ind.begin(); it!=ind.end(); it+=3){ + for (U16It it = ind.begin(); it!=ind.end(); it += 3) + { // Test for 6 variations - if ((*(it+0)==v[0]) && (*(it+1)==v[1]) && (*(it+2)==v[2])) return true; - if ((*(it+0)==v[0]) && (*(it+2)==v[1]) && (*(it+1)==v[2])) return true; - if ((*(it+2)==v[0]) && (*(it+0)==v[1]) && (*(it+1)==v[2])) return true; - if ((*(it+2)==v[0]) && (*(it+1)==v[1]) && (*(it+0)==v[2])) return true; - if ((*(it+1)==v[0]) && (*(it+0)==v[1]) && (*(it+2)==v[2])) return true; - if ((*(it+1)==v[0]) && (*(it+2)==v[1]) && (*(it+0)==v[2])) return true; + if ((*(it+0)==v[0])&&(*(it+1)==v[1])&&(*(it+2)==v[2])) + return true; + if ((*(it+0)==v[0])&&(*(it+2)==v[1])&&(*(it+1)==v[2])) + return true; + if ((*(it+2)==v[0])&&(*(it+0)==v[1])&&(*(it+1)==v[2])) + return true; + if ((*(it+2)==v[0])&&(*(it+1)==v[1])&&(*(it+0)==v[2])) + return true; + if ((*(it+1)==v[0])&&(*(it+0)==v[1])&&(*(it+2)==v[2])) + return true; + if ((*(it+1)==v[0])&&(*(it+2)==v[1])&&(*(it+0)==v[2])) + return true; } return false; } -bool EDetail::Update (LPCSTR name) +bool EDetail::Update(LPCSTR name) { - m_sRefs = name; + m_sRefs = name; // update link - CEditableObject* R = Lib.CreateEditObject(name); - if (!R){ - ELog.Msg (mtError,"Can't load detail object '%s'.", name); + CEditableObject*R = Lib.CreateEditObject(name); + if (!R) + { + ELog.Msg(mtError, "Can't load detail object '%s'.", name); return false; } - if(R->SurfaceCount()!=1){ - ELog.Msg (mtError,"Object must contain 1 material."); - Lib.RemoveEditObject(R); - return false; + if (R->SurfaceCount()!=1) + { + ELog.Msg(mtError, "Object must contain 1 material."); + Lib.RemoveEditObject(R); + return false; } - if(R->MeshCount()==0){ - ELog.Msg (mtError,"Object must contain 1 mesh."); - Lib.RemoveEditObject(R); - return false; + if (R->MeshCount()==0) + { + ELog.Msg(mtError, "Object must contain 1 mesh."); + Lib.RemoveEditObject(R); + return false; } Lib.RemoveEditObject(m_pRefs); - m_pRefs = R; + m_pRefs = R; // fill geometry - CEditableMesh* M = *m_pRefs->FirstMesh(); + CEditableMesh*M = *m_pRefs->FirstMesh(); U16Vec inds; // fill vertices bv_bb.invalidate(); - u32 idx = 0; - for (u32 f_id=0; f_idGetFCount(); f_id++) + u32 idx = 0; + for (u32 f_id = 0; f_idGetFCount(); f_id++) { - st_Face& F = M->GetFaces()[f_id]; - u16 ind[3]; - for (int k=0; k<3; k++,idx++){ - Fvector& P = M->GetVertices()[F.pv[k].pindex]; - st_VMapPt&vm= M->GetVMRefs()[F.pv[k].vmref].pts[0]; - Fvector2& uv= M->GetVMaps()[vm.vmap_index]->getUV(vm.index); - ind[k] = _AddVert (P,uv.x,uv.y); - bv_bb.modify(vertices[ind[k]].P); + st_Face&F = M->GetFaces()[f_id]; + u16 ind[3]; + for (int k = 0; k<3; k++,idx++) + { + Fvector &P = M->GetVertices()[F.pv[k].pindex]; + st_VMapPt&vm = M->GetVMRefs()[F.pv[k].vmref].pts[0]; + Fvector2 &uv = M->GetVMaps()[vm.vmap_index]->getUV(vm.index); + ind[k] = _AddVert(P, uv.x, uv.y); + bv_bb.modify(vertices[ind[k]].P); } - if (isDegenerated(ind)) continue; - if (isEqual(inds,ind)) continue; + if (isDegenerated(ind)) + continue; + if (isEqual(inds, ind)) + continue; inds.push_back(ind[0]); inds.push_back(ind[1]); inds.push_back(ind[2]); } - number_indices = inds.size(); - indices = (u16*)xr_malloc(number_indices*sizeof(u16)); - Memory.mem_copy (indices,inds.begin(),number_indices*sizeof(u16)); + number_indices = inds.size(); + indices = (u16*)xr_malloc(number_indices*sizeof(u16)); + Memory.mem_copy(indices, inds.begin(), number_indices*sizeof(u16)); - bv_bb.getsphere (bv_sphere.P,bv_sphere.R); + bv_bb.getsphere(bv_sphere.P, bv_sphere.R); - OnDeviceCreate (); + OnDeviceCreate(); return true; } -bool EDetail::Load(IReader& F) +bool EDetail::Load(IReader &F) { - // check version - R_ASSERT (F.find_chunk(DETOBJ_CHUNK_VERSION)); - u32 version = F.r_u32(); - if (version!=DETOBJ_VERSION){ - ELog.Msg(mtError,"EDetail: unsupported version."); + // check version + R_ASSERT(F.find_chunk(DETOBJ_CHUNK_VERSION)); + u32 version = F.r_u32(); + if (version!=DETOBJ_VERSION) + { + ELog.Msg(mtError, "EDetail: unsupported version."); return false; } - // references - string256 buf; - R_ASSERT (F.find_chunk(DETOBJ_CHUNK_REFERENCE)); - F.r_stringZ (buf,sizeof(buf)); + // references + string256 buf; + R_ASSERT(F.find_chunk(DETOBJ_CHUNK_REFERENCE)); + F.r_stringZ(buf, sizeof(buf)); // scale - R_ASSERT (F.find_chunk(DETOBJ_CHUNK_SCALE_LIMITS)); - m_fMinScale = F.r_float(); if (fis_zero(m_fMinScale)) m_fMinScale = 0.1f; - m_fMaxScale = F.r_float(); if (m_fMaxScaleFirstSurface(); - R_ASSERT (surf); + R_ASSERT(m_pRefs); + CSurface*surf = *m_pRefs->FirstSurface(); + R_ASSERT(surf); // write data - F.w_stringZ (surf->_ShaderName()); - F.w_stringZ (tex_name);//surf->_Texture()); + F.w_stringZ(surf->_ShaderName()); + F.w_stringZ(tex_name);//surf->_Texture()); - F.w_u32 (m_Flags.get()); - F.w_float (m_fMinScale); - F.w_float (m_fMaxScale); + F.w_u32(m_Flags.get()); + F.w_float(m_fMinScale); + F.w_float(m_fMaxScale); - F.w_u32 (number_vertices); - F.w_u32 (number_indices); + F.w_u32(number_vertices); + F.w_u32(number_indices); // remap UV - EVertexIn* rm_vertices = xr_alloc(number_vertices); - for (u32 k=0; k(number_vertices); + for (u32 k = 0; kFirstSurface(); - R_ASSERT (surf); - IWriter* F = FS.w_open(name); - if (F){ - Fvector2 offs = {0,0}; - Fvector2 scale = {1,1}; - Export (*F,surf->_Texture(),offs,scale,false); - FS.w_close (F); - }else{ - Log ("!Can't export detail:",name); + CSurface*surf = *m_pRefs->FirstSurface(); + R_ASSERT(surf); + IWriter *F = FS.w_open(name); + if (F) + { + Fvector2 offs = {0,0}; + Fvector2 scale = {1,1}; + Export(*F, surf->_Texture(), offs, scale, false); + FS.w_close(F); + } + else + { + Log("!Can't export detail:", name); } } diff --git a/src/editors/ECore/Editor/EDetailModel.h b/src/editors/ECore/Editor/EDetailModel.h index f1503c3a106..244f822cfa6 100644 --- a/src/editors/ECore/Editor/EDetailModel.h +++ b/src/editors/ECore/Editor/EDetailModel.h @@ -2,35 +2,39 @@ #define EDetailModelH #pragma once -#include "..\..\Layers\xrRender\DetailModel.h" +#include "Layers/xrRender/DetailModel.h" // refs class CEditableObject; -class ECORE_API EDetail: public CDetail{ - friend class EDetailManager; - friend class CDetailManager; +class ECORE_API EDetail: + +public +CDetail +{ + friend class EDetailManager; + friend class CDetailManager; friend class TfrmDOShuffle; struct EVertexIn: public fvfVertexIn { - EVertexIn (const Fvector& _P, float _u, float _v){P.set(_P); u=_u; v=_v;}; - IC void set (EVertexIn& src){P.set(src.P); u=src.u; v=src.v;}; - IC void set (const Fvector& _P, float _u, float _v){P.set(_P); u=_u; v=_v;}; - IC BOOL similar (EVertexIn& V) - { - if (!fsimilar (u,V.u,EPS_L)) return FALSE; - if (!fsimilar (v,V.v,EPS_L)) return FALSE; - if (!P.similar (V.P,EPS_L)) return FALSE; - return TRUE; - } - void remapUV (const fvfVertexIn& src, const Fvector2& offs, const Fvector2& scale, bool bRotate); - }; + EVertexIn (const Fvector& _P, float _u, float _v){P.set(_P); u=_u; v=_v;}; +IC void set (EVertexIn& src){P.set(src.P); u=src.u; v=src.v;}; +IC void set (const Fvector& _P, float _u, float _v){P.set(_P); u=_u; v=_v;}; +IC BOOL similar (EVertexIn& V) +{ + if (!fsimilar (u,V.u,EPS_L)) return FALSE; + if (!fsimilar (v,V.v,EPS_L)) return FALSE; + if (!P.similar (V.P,EPS_L)) return FALSE; + return TRUE; +} +void remapUV (const fvfVertexIn& src, const Fvector2& offs, const Fvector2& scale, bool bRotate); +}; /* - struct fvfVertexIn{ - Fvector P; - float u,v; - fvfVertexIn (const Fvector& _P, float _u, float _v){P.set(_P); u=_u; v=_v;}; + struct fvfVertexIn{ + Fvector P; + float u,v; + fvfVertexIn (const Fvector& _P, float _u, float _v){P.set(_P); u=_u; v=_v;}; void set (fvfVertexIn& src){P.set(src.P); u=src.u; v=src.v;}; void set (const Fvector& _P, float _u, float _v){P.set(_P); u=_u; v=_v;}; BOOL similar (fvfVertexIn& V) @@ -40,55 +44,56 @@ class ECORE_API EDetail: public CDetail{ if (!P.similar (V.P,EPS_L)) return FALSE; return TRUE; } - }; - struct fvfVertexOut - { - Fvector P; - DWORD C; - float u,v; - }; + }; + struct fvfVertexOut + { + Fvector P; + DWORD C; + float u,v; + }; float m_fMinScale; float m_fMaxScale; - // render - fvfVertexIn *vertices; - DWORD number_vertices; - WORD *indices; - DWORD number_indices; - ref_shader shader; - Flags32 m_Flags; - Fsphere bv_sphere; - Fbox bv_bb; + // render + fvfVertexIn *vertices; + DWORD number_vertices; + WORD *indices; + DWORD number_indices; + ref_shader shader; + Flags32 m_Flags; + Fsphere bv_sphere; + Fbox bv_bb; */ - float m_fDensityFactor; +float m_fDensityFactor; - // references - AnsiString m_sRefs; - CEditableObject* m_pRefs; +// references +AnsiString m_sRefs; +CEditableObject* m_pRefs; - u16 _AddVert (const Fvector& p, float u, float v); +u16 _AddVert (const Fvector& p, float u, float v); public: // bool m_bMarkDel; public: - EDetail (); - virtual ~EDetail (); +EDetail (); +virtual ~EDetail (); - bool Load (IReader&); - void Save (IWriter&); - void Export (IWriter&, LPCSTR tex_name, const Fvector2& offs, const Fvector2& scale, bool rot); - void Export (LPCSTR name); +bool Load (IReader&); +void Save (IWriter&); +void Export (IWriter&, LPCSTR tex_name, const Fvector2& offs, const Fvector2& scale, bool rot); +void Export (LPCSTR name); - bool Update (LPCSTR name); - virtual void Unload (); +bool Update (LPCSTR name); +virtual void Unload (); - LPCSTR GetName (); - LPCSTR GetTextureName (); - void OnDeviceCreate (); - void OnDeviceDestroy (); - void DefferedLoad (); +LPCSTR GetName (); +LPCSTR GetTextureName (); +void OnDeviceCreate (); +void OnDeviceDestroy (); +void DefferedLoad (); }; -DEFINE_VECTOR(EDetail*,DOVec,DOIt); +DEFINE_VECTOR(EDetail *, DOVec, DOIt); #endif //_INCDEF_DetailModel_H_ + diff --git a/src/editors/ECore/Editor/ELog.cpp b/src/editors/ECore/Editor/ELog.cpp index c78afd834ce..7e9f77379b3 100644 --- a/src/editors/ECore/Editor/ELog.cpp +++ b/src/editors/ECore/Editor/ELog.cpp @@ -60,17 +60,18 @@ //---------------------------------------------------- CLog ELog; + //---------------------------------------------------- -int CLog::DlgMsg (TMsgDlgType mt, TMsgDlgButtons btn, LPCSTR _Format, ...) +int CLog::DlgMsg(TMsgDlgType mt, TMsgDlgButtons btn, LPCSTR _Format, ...) { in_use = true; - char buf[4096]; - va_list l; - va_start( l, _Format ); - vsprintf( buf, _Format, l ); + char buf[4096]; + va_list l; + va_start(l, _Format); + vsprintf(buf, _Format, l); - int res=0; + int res = 0; #ifdef _EDITOR ExecCommand(COMMAND_RENDER_FOCUS); @@ -107,15 +108,15 @@ int CLog::DlgMsg (TMsgDlgType mt, TMsgDlgButtons btn, LPCSTR _Format, ...) } -int CLog::DlgMsg (TMsgDlgType mt, LPCSTR _Format, ...) +int CLog::DlgMsg(TMsgDlgType mt, LPCSTR _Format, ...) { in_use = true; - char buf[4096]; - va_list l; - va_start( l, _Format ); - vsprintf( buf, _Format, l ); + char buf[4096]; + va_list l; + va_start(l, _Format); + vsprintf(buf, _Format, l); - int res=0; + int res = 0; #ifdef _EDITOR ExecCommand(COMMAND_RENDER_FOCUS); @@ -146,19 +147,19 @@ int CLog::DlgMsg (TMsgDlgType mt, LPCSTR _Format, ...) } #endif - Msg(mt,buf); + Msg(mt, buf); in_use = false; - + return res; } void CLog::Msg(TMsgDlgType mt, LPCSTR _Format, ...) { - char buf[4096]; - va_list l; - va_start( l, _Format ); - vsprintf( buf, _Format, l ); + char buf[4096]; + va_list l; + va_start(l, _Format); + vsprintf(buf, _Format, l); #ifdef _EDITOR TfrmLog::AddMessage(mt,AnsiString(buf)); @@ -172,8 +173,11 @@ void CLog::Msg(TMsgDlgType mt, LPCSTR _Format, ...) } #endif - ::LogExecCB = FALSE; - ::Msg (buf); - ::LogExecCB = TRUE; + ::LogExecCB = FALSE; + ::Msg(buf); + ::LogExecCB = TRUE; } + //---------------------------------------------------- + + diff --git a/src/editors/ECore/Editor/ELog.h b/src/editors/ECore/Editor/ELog.h index bef7f68670f..fd99fb3f5d6 100644 --- a/src/editors/ECore/Editor/ELog.h +++ b/src/editors/ECore/Editor/ELog.h @@ -5,14 +5,15 @@ #ifndef ELogH #define ELogH -class ECORE_API CLog{ -public: - bool in_use; -public: - CLog (){in_use=false;} - void Msg (TMsgDlgType mt, LPCSTR _Format, ...); - int DlgMsg (TMsgDlgType mt, LPCSTR _Format, ...); - int DlgMsg (TMsgDlgType mt, TMsgDlgButtons btn, LPCSTR _Format, ...); +class ECORE_API CLog +{ + public: + bool in_use; + public: + CLog(){in_use = false;} + void Msg(TMsgDlgType mt, LPCSTR _Format, ...); + int DlgMsg(TMsgDlgType mt, LPCSTR _Format, ...); + int DlgMsg(TMsgDlgType mt, TMsgDlgButtons btn, LPCSTR _Format, ...); }; void ECORE_API ELogCallback(void *context, LPCSTR txt); diff --git a/src/editors/ECore/Editor/EStats.cpp b/src/editors/ECore/Editor/EStats.cpp index 8f487ad99ab..756d7ae2458 100644 --- a/src/editors/ECore/Editor/EStats.cpp +++ b/src/editors/ECore/Editor/EStats.cpp @@ -2,8 +2,8 @@ #pragma hdrstop #include "EStats.h" -#include "hw.h" -#include "gamefont.h" +#include "Layers/xrRender/HW.h" +#include "xrEngine/GameFont.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -11,130 +11,131 @@ CEStats::CEStats() { - fFPS = 30.f; - fRFPS = 30.f; - fTPS = 0; - dwLevelSelFaceCount = 0; - dwLevelSelVertexCount=0; + fFPS = 30.f; + fRFPS = 30.f; + fTPS = 0; + dwLevelSelFaceCount = 0; + dwLevelSelVertexCount = 0; } -CEStats::~CEStats() -{ +CEStats::~CEStats() {} -} +#include "xrEngine/IGame_Persistent.h" -#include "igame_persistent.h" -void CEStats::Show(CGameFont* font) +void CEStats::Show(CGameFont *font) { - // Stop timers - { - RenderTOTAL.FrameEnd (); - RenderCALC.FrameEnd (); - - RenderDUMP_SKIN.FrameEnd (); - - Animation.FrameEnd (); - Input.FrameEnd (); - clRAY.FrameEnd (); - clBOX.FrameEnd (); - clFRUSTUM.FrameEnd (); - - RenderDUMP_RT.FrameEnd (); - - RenderDUMP_DT_VIS.FrameEnd (); - RenderDUMP_DT_Render.FrameEnd(); - RenderDUMP_DT_Cache.FrameEnd(); - TEST0.FrameEnd (); - TEST1.FrameEnd (); - TEST2.FrameEnd (); - TEST3.FrameEnd (); - } - - // calc FPS & TPS - CBackend::_stats& DPS = RCache.stat; - if (EDevice.fTimeDelta>EPS_S) { - float fps = 1.f/EDevice.fTimeDelta; - float fOne = 0.3f; - float fInv = 1.f-fOne; - fFPS = fInv*fFPS + fOne*fps; - - if (RenderTOTAL.result>EPS_S) { - fTPS = fInv*fTPS + fOne*float(DPS.polys)/(RenderTOTAL.result*1000.f); - fRFPS= fInv*fRFPS+ fOne*1000.f/RenderTOTAL.result; - } - } - - // Show them - if (psDeviceFlags.is(rsStatistic)) - { - CGameFont& F = *font; - F.SetColor (0xFFFFFFFF ); - F.OutSet (5,5); - F.OutNext ("FPS/RFPS: %3.1f/%3.1f", fFPS,fRFPS); - F.OutNext ("TPS: %2.2f M", fTPS); - F.OutNext ("VERT: %d", DPS.verts); - F.OutNext ("POLY: %d", DPS.polys); - F.OutNext ("DIP/DP: %d", DPS.calls); - F.OutNext ("SH/T/M/C: %d/%d/%d/%d", dwShader_Codes,dwShader_Textures,dwShader_Matrices,dwShader_Constants); - F.OutNext ("LIGHT S/T: %d/%d", dwLightInScene,dwTotalLight); - F.OutNext ("Skeletons: %2.2fms, %d", Animation.result,Animation.count); - F.OutNext ("Skinning: %2.2fms", RenderDUMP_SKIN.result); - F.OutSkip (); - F.OutNext ("Input: %2.2fms", Input.result); - F.OutNext ("clRAY: %2.2fms, %d", clRAY.result,clRAY.count); - F.OutNext ("clBOX: %2.2fms, %d", clBOX.result,clBOX.count); - F.OutNext ("clFRUSTUM: %2.2fms, %d", clFRUSTUM.result,clFRUSTUM.count); - F.OutSkip (); -// F.OutNext ("Render: %2.2fms", RenderDUMP.result); - F.OutNext (" RT: %2.2fms, %d", RenderDUMP_RT.result,RenderDUMP_RT.count); - F.OutNext (" DT_Vis: %2.2fms", RenderDUMP_DT_VIS.result); - F.OutNext (" DT_Render: %2.2fms", RenderDUMP_DT_Render.result); - F.OutNext (" DT_Cache: %2.2fms", RenderDUMP_DT_Cache.result); - F.OutSkip (); - F.OutNext ("TEST 0: %2.2fms, %d", TEST0.result,TEST0.count); - F.OutNext ("TEST 1: %2.2fms, %d", TEST1.result,TEST1.count); - F.OutNext ("TEST 2: %2.2fms, %d", TEST2.result,TEST2.count); - F.OutNext ("TEST 3: %2.2fms, %d", TEST3.result,TEST3.count); - F.OutSkip (); -// F.OutNext ("GAME TIME: %s", FloatTimeToStrTime(g_pGamePersistent->Environment().GetGameTime()).c_str()); -// F.OutSkip (2.f); -// F.OutNext ("Level summary:"); -// F.OutNext (" Sel Faces: %d", dwLevelSelFaceCount); -// F.OutNext (" Sel Verts: %d", dwLevelSelVertexCount); - } - - { - Animation.FrameStart (); - RenderTOTAL.FrameStart (); - - Input.FrameStart (); - clRAY.FrameStart (); - clBOX.FrameStart (); - clFRUSTUM.FrameStart (); - - RenderDUMP_SKIN.FrameStart (); - RenderDUMP_RT.FrameStart (); - - RenderDUMP_DT_VIS.FrameStart(); - RenderDUMP_DT_Render.FrameStart(); - RenderDUMP_DT_Cache.FrameStart(); - - TEST0.FrameStart (); - TEST1.FrameStart (); - TEST2.FrameStart (); - TEST3.FrameStart (); - } - dwShader_Codes = dwShader_Textures = dwShader_Matrices = dwShader_Constants = 0; - dwSND_Played = dwSND_Allocated = 0; + // Stop timers + { + RenderTOTAL.FrameEnd(); + RenderCALC.FrameEnd(); + + RenderDUMP_SKIN.FrameEnd(); + + Animation.FrameEnd(); + Input.FrameEnd(); + clRAY.FrameEnd(); + clBOX.FrameEnd(); + clFRUSTUM.FrameEnd(); + + RenderDUMP_RT.FrameEnd(); + + RenderDUMP_DT_VIS.FrameEnd(); + RenderDUMP_DT_Render.FrameEnd(); + RenderDUMP_DT_Cache.FrameEnd(); + TEST0.FrameEnd(); + TEST1.FrameEnd(); + TEST2.FrameEnd(); + TEST3.FrameEnd(); + } + + // calc FPS & TPS + CBackend::_stats &DPS = RCache.stat; + if (EDevice.fTimeDelta>EPS_S) + { + float fps = 1.f/EDevice.fTimeDelta; + float fOne = 0.3f; + float fInv = 1.f-fOne; + fFPS = fInv*fFPS+fOne*fps; + + if (RenderTOTAL.result>EPS_S) + { + fTPS = fInv*fTPS+fOne*float(DPS.polys)/(RenderTOTAL.result*1000.f); + fRFPS = fInv*fRFPS+fOne*1000.f/RenderTOTAL.result; + } + } + + // Show them + if (psDeviceFlags.is(rsStatistic)) + { + CGameFont &F = *font; + F.SetColor(0xFFFFFFFF); + F.OutSet(5, 5); + F.OutNext("FPS/RFPS: %3.1f/%3.1f", fFPS, fRFPS); + F.OutNext("TPS: %2.2f M", fTPS); + F.OutNext("VERT: %d", DPS.verts); + F.OutNext("POLY: %d", DPS.polys); + F.OutNext("DIP/DP: %d", DPS.calls); + F.OutNext("SH/T/M/C: %d/%d/%d/%d", dwShader_Codes, dwShader_Textures, dwShader_Matrices, dwShader_Constants); + F.OutNext("LIGHT S/T: %d/%d", dwLightInScene, dwTotalLight); + F.OutNext("Skeletons: %2.2fms, %d", Animation.result, Animation.count); + F.OutNext("Skinning: %2.2fms", RenderDUMP_SKIN.result); + F.OutSkip(); + F.OutNext("Input: %2.2fms", Input.result); + F.OutNext("clRAY: %2.2fms, %d", clRAY.result, clRAY.count); + F.OutNext("clBOX: %2.2fms, %d", clBOX.result, clBOX.count); + F.OutNext("clFRUSTUM: %2.2fms, %d", clFRUSTUM.result, clFRUSTUM.count); + F.OutSkip(); + // F.OutNext ("Render: %2.2fms", RenderDUMP.result); + F.OutNext(" RT: %2.2fms, %d", RenderDUMP_RT.result, RenderDUMP_RT.count); + F.OutNext(" DT_Vis: %2.2fms", RenderDUMP_DT_VIS.result); + F.OutNext(" DT_Render: %2.2fms", RenderDUMP_DT_Render.result); + F.OutNext(" DT_Cache: %2.2fms", RenderDUMP_DT_Cache.result); + F.OutSkip(); + F.OutNext("TEST 0: %2.2fms, %d", TEST0.result, TEST0.count); + F.OutNext("TEST 1: %2.2fms, %d", TEST1.result, TEST1.count); + F.OutNext("TEST 2: %2.2fms, %d", TEST2.result, TEST2.count); + F.OutNext("TEST 3: %2.2fms, %d", TEST3.result, TEST3.count); + F.OutSkip(); + // F.OutNext ("GAME TIME: %s", FloatTimeToStrTime(g_pGamePersistent->Environment().GetGameTime()).c_str()); + // F.OutSkip (2.f); + // F.OutNext ("Level summary:"); + // F.OutNext (" Sel Faces: %d", dwLevelSelFaceCount); + // F.OutNext (" Sel Verts: %d", dwLevelSelVertexCount); + } + + { + Animation.FrameStart(); + RenderTOTAL.FrameStart(); + + Input.FrameStart(); + clRAY.FrameStart(); + clBOX.FrameStart(); + clFRUSTUM.FrameStart(); + + RenderDUMP_SKIN.FrameStart(); + RenderDUMP_RT.FrameStart(); + + RenderDUMP_DT_VIS.FrameStart(); + RenderDUMP_DT_Render.FrameStart(); + RenderDUMP_DT_Cache.FrameStart(); + + TEST0.FrameStart(); + TEST1.FrameStart(); + TEST2.FrameStart(); + TEST3.FrameStart(); + } + dwShader_Codes = dwShader_Textures = dwShader_Matrices = dwShader_Constants = 0; + dwSND_Played = dwSND_Allocated = 0; dwTotalLight = dwLightInScene = 0; - DPS.polys = 0; - DPS.verts = 0; - DPS.calls = 0; - DPS.vs = 0; -// DPS.vb = 0; -// DPS.ib = 0; + DPS.polys = 0; + DPS.verts = 0; + DPS.calls = 0; + DPS.vs = 0; + // DPS.vb = 0; + // DPS.ib = 0; - dwLevelSelFaceCount = 0; - dwLevelSelVertexCount = 0; + dwLevelSelFaceCount = 0; + dwLevelSelVertexCount = 0; } + diff --git a/src/editors/ECore/Editor/EStats.h b/src/editors/ECore/Editor/EStats.h index 1417533231a..7a61cf83a6d 100644 --- a/src/editors/ECore/Editor/EStats.h +++ b/src/editors/ECore/Editor/EStats.h @@ -5,52 +5,56 @@ #ifndef EStatsH #define EStatsH #pragma once -#include "../../../xrengine/stats.h" +#include "xrEngine/Stats.h" // refs class CGameFont; class ENGINE_API CEStats: - public CStatsPhysics + +public +CStatsPhysics { -public: - float fFPS,fRFPS,fTPS; // FPS, RenderFPS, TPS - u32 dwShader_Codes; // Number of times the shader-code changes - u32 dwShader_Textures; // Number of times the shader-tex changes - u32 dwShader_Matrices; // Number of times the shader-xform changes - u32 dwShader_Constants; // Number of times the shader-consts changes - u32 dwSND_Played,dwSND_Allocated; // Play/Alloc - u32 dwTotalLight,dwLightInScene; - u32 dwLevelSelFaceCount; // Number of faces in scene - u32 dwLevelSelVertexCount; // Number of vertices in scene - - CStatTimer RenderDUMP_RT; - CStatTimer RenderTOTAL; // - CStatTimer RenderTOTAL_Real; - CStatTimer RenderCALC; // portal traversal, frustum culling, entities "OnVisible" - CStatTimer RenderDUMP_SKIN; - CStatTimer Animation; // skeleton calculation - CStatTimer RenderDUMP_DT_VIS; // ...details visibility detection - CStatTimer RenderDUMP_DT_Render;// ...details rendering - CStatTimer RenderDUMP_DT_Cache;// ...details slot cache access - - u32 RenderDUMP_DT_Count; - - CStatTimer Input; // total time taken by input subsystem (accurate only in single-threaded mode) - CStatTimer clRAY; // total: ray-testing - CStatTimer clBOX; // total: box query - CStatTimer clFRUSTUM; // total: frustum query - - CStatTimer TEST0; // debug counter - CStatTimer TEST1; // debug counter - CStatTimer TEST2; // debug counter - CStatTimer TEST3; // debug counter - - void Show (CGameFont* font); - - CEStats (); - ~CEStats (); + public: + float fFPS,fRFPS,fTPS; // FPS, RenderFPS, TPS + u32 dwShader_Codes; // Number of times the shader-code changes + u32 dwShader_Textures; // Number of times the shader-tex changes + u32 dwShader_Matrices; // Number of times the shader-xform changes + u32 dwShader_Constants; // Number of times the shader-consts changes + u32 dwSND_Played,dwSND_Allocated; // Play/Alloc + u32 dwTotalLight,dwLightInScene; + u32 dwLevelSelFaceCount; // Number of faces in scene + u32 dwLevelSelVertexCount; // Number of vertices in scene + + CStatTimer RenderDUMP_RT; + CStatTimer RenderTOTAL; // + CStatTimer RenderTOTAL_Real; + CStatTimer RenderCALC; // portal traversal, frustum culling, entities "OnVisible" + CStatTimer RenderDUMP_SKIN; + CStatTimer Animation; // skeleton calculation + CStatTimer RenderDUMP_DT_VIS; // ...details visibility detection + CStatTimer RenderDUMP_DT_Render;// ...details rendering + CStatTimer RenderDUMP_DT_Cache;// ...details slot cache access + + u32 RenderDUMP_DT_Count; + + CStatTimer Input; // total time taken by input subsystem (accurate only in single-threaded mode) + CStatTimer clRAY; // total: ray-testing + CStatTimer clBOX; // total: box query + CStatTimer clFRUSTUM; // total: frustum query + + CStatTimer TEST0; // debug counter + CStatTimer TEST1; // debug counter + CStatTimer TEST2; // debug counter + CStatTimer TEST3; // debug counter + + void Show (CGameFont* font); + + CEStats (); + ~CEStats (); }; #define UPDATEC(vert,poly,pass) { EDevice.Statistic->dwVert+=(vert)*(pass);EDevice.Statistic->dwPoly+=(poly)*pass; EDevice.Statistic->dwCalls+=pass; } #endif // !defined(AFX_STATS_H__4C8D1860_0EE2_11D4_B4E3_4854E82A090D__INCLUDED_) + + diff --git a/src/editors/ECore/Editor/ETextureParams.cpp b/src/editors/ECore/Editor/ETextureParams.cpp new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Editor/ETextureParams.cpp @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Editor/ETextureParams.h b/src/editors/ECore/Editor/ETextureParams.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Editor/ETextureParams.h @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Editor/EThumbnail.cpp b/src/editors/ECore/Editor/EThumbnail.cpp index 13ada8d40a3..7292ad21763 100644 --- a/src/editors/ECore/Editor/EThumbnail.cpp +++ b/src/editors/ECore/Editor/EThumbnail.cpp @@ -2,7 +2,7 @@ #pragma hdrstop #include "EThumbnail.h" -#include "folderlib.h" +#include "editors/xrEProps/FolderLib.h" #include "xrImage_Resampler.h" #pragma package(smart_init) //------------------------------------------------------------------------------ @@ -10,20 +10,20 @@ //------------------------------------------------------------------------------ ECustomThumbnail::ECustomThumbnail(LPCSTR src_name, THMType type) { - m_Type = type; - m_SrcName = src_name; - m_Name = ChangeFileExt(AnsiString(src_name),".thm"); - m_Age = 0; + m_Type = type; + m_SrcName = src_name; + m_Name = ChangeFileExt(AnsiString(src_name), ".thm"); + m_Age = 0; } + //------------------------------------------------------------------------------ -ECustomThumbnail::~ECustomThumbnail() -{ -} +ECustomThumbnail::~ECustomThumbnail() {} + /* void DrawThumbnail(TCanvas* pCanvas, TRect& r, U32Vec& data, bool bDrawWithAlpha, int _w = THUMB_WIDTH, int _h = THUMB_HEIGHT) { - pCanvas->CopyMode = cmSrcCopy; + pCanvas->CopyMode = cmSrcCopy; Graphics::TBitmap *pBitmap = xr_new(); pBitmap->PixelFormat = pf32bit; @@ -31,7 +31,7 @@ void DrawThumbnail(TCanvas* pCanvas, TRect& r, U32Vec& data, bool bDrawWithAlpha pBitmap->Width = _w; if (bDrawWithAlpha){ - Fcolor back; + Fcolor back; back.set (bgr2rgb(pCanvas->Brush->Color)); back.mul_rgb(255.f); for (int y = 0; y < pBitmap->Height; y++) { @@ -64,45 +64,46 @@ void DrawThumbnail(TCanvas* pCanvas, TRect& r, U32Vec& data, bool bDrawWithAlpha //------------------------------------------------------------------------------ EImageThumbnail::~EImageThumbnail() { - m_Pixels.clear(); + m_Pixels.clear(); } void EImageThumbnail::VFlip() { - R_ASSERT(!m_Pixels.empty()); - u32 line[THUMB_WIDTH]; - u32 sz_ln=sizeof(u32)*THUMB_WIDTH; + R_ASSERT(!m_Pixels.empty()); + u32 line[THUMB_WIDTH]; + u32 sz_ln = sizeof(u32)*THUMB_WIDTH; u32 y2 = THUMB_WIDTH-1; - for (int y=0; y0)&&(h>0)); - m_Pixels.resize(THUMB_SIZE); - imf_Process(m_Pixels.begin(),THUMB_WIDTH,THUMB_HEIGHT,p,w,h,imf_box); + // imf_filter imf_box imf_triangle imf_bell imf_b_spline imf_lanczos3 imf_mitchell + R_ASSERT(p&&(w>0)&&(h>0)); + m_Pixels.resize(THUMB_SIZE); + imf_Process(m_Pixels.begin(), THUMB_WIDTH, THUMB_HEIGHT, p, w, h, imf_box); } -void EImageThumbnail::Draw(HDC hdc, const Irect& r) +void EImageThumbnail::Draw(HDC hdc, const Irect &r) { - if (Valid()) - FHelper.DrawThumbnail(hdc,r,Pixels(),THUMB_WIDTH,THUMB_HEIGHT); + if (Valid()) + FHelper.DrawThumbnail(hdc, r, Pixels(), THUMB_WIDTH, THUMB_HEIGHT); } -EImageThumbnail* CreateThumbnail(LPCSTR src_name, ECustomThumbnail::THMType type, bool bLoad) +EImageThumbnail *CreateThumbnail(LPCSTR src_name, ECustomThumbnail::THMType type, bool bLoad) { - switch (type){ - case ECustomThumbnail::ETObject: return xr_new (src_name,bLoad); - case ECustomThumbnail::ETTexture: return xr_new(src_name,bLoad); - case ECustomThumbnail::ETGroup: return xr_new (src_name,bLoad); - default: NODEFAULT; + switch (type) + { + case ECustomThumbnail::ETObject: return xr_new(src_name,bLoad); + case ECustomThumbnail::ETTexture: return xr_new(src_name,bLoad); + case ECustomThumbnail::ETGroup: return xr_new(src_name,bLoad); + default: NODEFAULT; } - return 0; + return 0; } - diff --git a/src/editors/ECore/Editor/EThumbnail.h b/src/editors/ECore/Editor/EThumbnail.h index 7873d474b03..7940f430580 100644 --- a/src/editors/ECore/Editor/EThumbnail.h +++ b/src/editors/ECore/Editor/EThumbnail.h @@ -1,171 +1,195 @@ #ifndef EThumbnailH #define EThumbnailH -#include "../Layers/xrRender/ETextureParams.h" -#include "../../xrServerEntities/PropertiesListHelper.h" +#include "Layers/xrRender/ETextureParams.h" +#include "xrServerEntities/PropertiesListHelper.h" #include "MXCtrls.hpp" //------------------------------------------------------------------------------ // Custom class //------------------------------------------------------------------------------ -class ECORE_API ECustomThumbnail{ -public: - enum THMType{ - ETUndef = -1, - ETObject = 0, - ETTexture = 1, - ETSound = 2, - ETGroup = 3, +class ECORE_API ECustomThumbnail{ + public: + enum THMType{ + ETUndef = -1, + ETObject = 0, + ETTexture = 1, + ETSound = 2, + ETGroup = 3, force_dword = (-1) }; -protected: - AnsiString m_SrcName; - AnsiString m_Name; - int m_Age; - THMType m_Type; -public: - ECustomThumbnail(LPCSTR src_name, THMType type); - virtual ~ECustomThumbnail(); + protected: + AnsiString m_SrcName; + AnsiString m_Name; + int m_Age; + THMType m_Type; + public: + ECustomThumbnail(LPCSTR src_name, THMType type); + virtual ~ECustomThumbnail(); - LPCSTR Name (){return m_Name.c_str();} - LPCSTR SrcName (){return m_SrcName.c_str();} + LPCSTR Name(){return m_Name.c_str();} + LPCSTR SrcName(){return m_SrcName.c_str();} - IC bool IsClass (THMType type){return m_Type==type;} + IC bool IsClass(THMType type){return m_Type==type;} // thumbnail public routines - virtual bool Load (LPCSTR src_name=0, LPCSTR path=0)=0; - virtual void Save (int age=0,LPCSTR path=0)=0; - virtual bool Valid ()=0; -// virtual void FillProp (PropItemVec& values)=0; - virtual void FillInfo (PropItemVec& values)=0; + virtual bool Load(LPCSTR src_name = 0, LPCSTR path = 0) = 0; + virtual void Save(int age = 0, LPCSTR path = 0) = 0; + virtual bool Valid() = 0; + // virtual void FillProp (PropItemVec& values)=0; + virtual void FillInfo(PropItemVec&values) = 0; }; + //------------------------------------------------------------------------------ -class ECORE_API EImageThumbnail: public ECustomThumbnail{ - friend class CImageManager; -protected: - U32Vec m_Pixels; -protected: - void CreatePixels (u32* p, u32 w, u32 h); - void VFlip (); -public: - EImageThumbnail (LPCSTR src_name, THMType type):ECustomThumbnail(src_name, type){}; - virtual ~EImageThumbnail(); - virtual void Draw (HDC hdc, const Irect& r); - virtual void Draw (TMxPanel* panel){Irect r; r.set(1,1,1+panel->Width,1+panel->Height); Draw(panel->Canvas->Handle,r);} - u32* Pixels (){return &*m_Pixels.begin();} - virtual int MemoryUsage (){return 0;}; +class ECORE_API EImageThumbnail: + +public +ECustomThumbnail +{ + friend class CImageManager; + protected: + U32Vec m_Pixels; + protected: + void CreatePixels (u32* p, u32 w, u32 h); + void VFlip (); + public: + EImageThumbnail (LPCSTR src_name, THMType type):ECustomThumbnail(src_name, type){}; +virtual ~EImageThumbnail(); +virtual void Draw (HDC hdc, const Irect& r); +virtual void Draw (TMxPanel* panel){Irect r; r.set(1,1,1+panel->Width,1+panel->Height); Draw(panel->Canvas->Handle,r);} +u32* Pixels (){return &*m_Pixels.begin();} +virtual int MemoryUsage (){return 0;}; }; -class ECORE_API ETextureThumbnail: public EImageThumbnail{ - friend class CImageManager; - typedef EImageThumbnail inherited; -private: - STextureParams m_TexParams; - bool m_bValid; -public: - ETextureThumbnail (LPCSTR src_name, bool bLoad=true); - virtual ~ETextureThumbnail (); +class ECORE_API ETextureThumbnail: + +public +EImageThumbnail +{ + friend class CImageManager; + typedef EImageThumbnail inherited; + private: + STextureParams m_TexParams; + bool m_bValid; + public: + ETextureThumbnail (LPCSTR src_name, bool bLoad=true); + virtual ~ETextureThumbnail (); // Texture routines - void CreateFromData (u32* p, u32 w, u32 h); - IC u32 _Width (){return m_TexParams.width;} - IC u32 _Height (){return m_TexParams.height;} - IC u32 _Alpha (){return m_TexParams.HasAlphaChannel();} - // thumbnail public routines - IC STextureParams& _Format (){return m_TexParams;} - virtual bool Load (LPCSTR src_name=0, LPCSTR path=0); - virtual void Save (int age=0,LPCSTR path=0); - virtual bool Valid (){return m_bValid; /*return !m_Pixels.empty();*/} - void SetValid () {m_bValid = true;} - virtual void FillProp (PropItemVec& values, PropValue::TOnChange on_type_change); - virtual void FillInfo (PropItemVec& values); - - virtual void Draw (HDC hdc, const Irect& r); - virtual void Draw (TMxPanel* panel){inherited::Draw(panel);} - - virtual int MemoryUsage (); - LPCSTR FormatString (); - BOOL similar (ETextureThumbnail* thm1, xr_vector& sel_params); + void CreateFromData (u32* p, u32 w, u32 h); + IC u32 _Width (){return m_TexParams.width;} +IC u32 _Height (){return m_TexParams.height;} +IC u32 _Alpha (){return m_TexParams.HasAlphaChannel();} +// thumbnail public routines +IC STextureParams& _Format (){return m_TexParams;} +virtual bool Load (LPCSTR src_name=0, LPCSTR path=0); +virtual void Save (int age=0,LPCSTR path=0); +virtual bool Valid (){return m_bValid; /*return !m_Pixels.empty();*/} +void SetValid () {m_bValid = true;} +virtual void FillProp (PropItemVec& values, PropValue::TOnChange on_type_change); +virtual void FillInfo (PropItemVec& values); + +virtual void Draw (HDC hdc, const Irect& r); +virtual void Draw (TMxPanel* panel){inherited::Draw(panel);} + +virtual int MemoryUsage (); +LPCSTR FormatString (); +BOOL similar (ETextureThumbnail* thm1, xr_vector& sel_params); }; + //------------------------------------------------------------------------------ -class ECORE_API EObjectThumbnail: public EImageThumbnail{ - friend class CImageManager; - typedef EImageThumbnail inherited; -private: - u32 face_count; - u32 vertex_count; -public: - EObjectThumbnail (LPCSTR src_name, bool bLoad=true); - virtual ~EObjectThumbnail (); +class ECORE_API EObjectThumbnail: - // Object routines - void CreateFromData (u32* p, u32 w, u32 h, int fc, int vc); - IC int _VertexCount (){return vertex_count;} - IC int _FaceCount (){return face_count;} +public +EImageThumbnail +{ + friend class CImageManager; + typedef EImageThumbnail inherited; + private: + u32 face_count; + u32 vertex_count; + public: + EObjectThumbnail (LPCSTR src_name, bool bLoad=true); + virtual ~EObjectThumbnail (); - // thumbnail public routines - virtual bool Load (LPCSTR src_name=0, LPCSTR path=0); - virtual void Save (int age=0,LPCSTR path=0); - virtual bool Valid (){return !m_Pixels.empty();} - virtual void FillProp (PropItemVec& values); - virtual void FillInfo (PropItemVec& values); + // Object routines + void CreateFromData (u32* p, u32 w, u32 h, int fc, int vc); + IC int _VertexCount (){return vertex_count;} +IC int _FaceCount (){return face_count;} + +// thumbnail public routines +virtual bool Load (LPCSTR src_name=0, LPCSTR path=0); +virtual void Save (int age=0,LPCSTR path=0); +virtual bool Valid (){return !m_Pixels.empty();} +virtual void FillProp (PropItemVec& values); +virtual void FillInfo (PropItemVec& values); }; + //------------------------------------------------------------------------------ -class ECORE_API EGroupThumbnail: public EImageThumbnail{ - friend class CImageManager; - typedef EImageThumbnail inherited; -private: - SStringVec objects; -public: - EGroupThumbnail (LPCSTR src_name, bool bLoad=true); - virtual ~EGroupThumbnail(); +class ECORE_API EGroupThumbnail: + +public +EImageThumbnail +{ + friend class CImageManager; + typedef EImageThumbnail inherited; + private: + SStringVec objects; + public: + EGroupThumbnail (LPCSTR src_name, bool bLoad=true); + virtual ~EGroupThumbnail(); // Object routines - void CreateFromData (u32* p, u32 w, u32 h, const SStringVec& lst); + void CreateFromData (u32* p, u32 w, u32 h, const SStringVec& lst); // thumbnail public routines - virtual bool Load (LPCSTR src_name=0, LPCSTR path=0); - virtual void Save (int age=0,LPCSTR path=0); - virtual bool Valid (){return !m_Pixels.empty();} - virtual void FillProp (PropItemVec& values); - virtual void FillInfo (PropItemVec& values); + virtual bool Load (LPCSTR src_name=0, LPCSTR path=0); + virtual void Save (int age=0,LPCSTR path=0); + virtual bool Valid (){return !m_Pixels.empty();} +virtual void FillProp (PropItemVec& values); +virtual void FillInfo (PropItemVec& values); }; + //------------------------------------------------------------------------------ -class ECORE_API ESoundThumbnail: public ECustomThumbnail{ - friend class CSoundManager; - typedef ECustomThumbnail inherited; -private: - float m_fQuality; - float m_fMinDist; - float m_fMaxDist; - float m_fMaxAIDist; - float m_fBaseVolume; - u32 m_uGameType; - bool OnMaxAIDistAfterEdit(PropValue* sender, float& edit_val); - void OnMaxDistChange (PropValue* sender); -public: - ESoundThumbnail (LPCSTR src_name, bool bLoad=true); - virtual ~ESoundThumbnail(); +class ECORE_API ESoundThumbnail: + +public +ECustomThumbnail +{ + friend class CSoundManager; + typedef ECustomThumbnail inherited; + private: + float m_fQuality; + float m_fMinDist; + float m_fMaxDist; + float m_fMaxAIDist; + float m_fBaseVolume; + u32 m_uGameType; + bool OnMaxAIDistAfterEdit(PropValue* sender, float& edit_val); + void OnMaxDistChange (PropValue* sender); + public: + ESoundThumbnail (LPCSTR src_name, bool bLoad=true); + virtual ~ESoundThumbnail(); // thumbnail public routines - virtual bool Load (LPCSTR src_name=0, LPCSTR path=0); - virtual void Save (int age=0,LPCSTR path=0); - virtual bool Valid (){return true;} - virtual void FillProp (PropItemVec& values); - virtual void FillInfo (PropItemVec& values); - float MinDist (){return m_fMinDist;} - float MaxDist (){return m_fMaxDist;}; - float BaseVolume (){return m_fBaseVolume;}; - void SetMinDist (float d){m_fMinDist=d;} - void SetMaxDist (float d){m_fMaxDist=d;}; + virtual bool Load (LPCSTR src_name=0, LPCSTR path=0); + virtual void Save (int age=0,LPCSTR path=0); + virtual bool Valid (){return true;} +virtual void FillProp (PropItemVec& values); +virtual void FillInfo (PropItemVec& values); +float MinDist (){return m_fMinDist;} +float MaxDist (){return m_fMaxDist;}; +float BaseVolume (){return m_fBaseVolume;}; +void SetMinDist (float d){m_fMinDist=d;} +void SetMaxDist (float d){m_fMaxDist=d;}; }; //------------------------------------------------------------------------------ -EImageThumbnail* CreateThumbnail (LPCSTR src_name, ECustomThumbnail::THMType type, bool bLoad=true); +EImageThumbnail *CreateThumbnail(LPCSTR src_name, ECustomThumbnail::THMType type, bool bLoad = true); #endif diff --git a/src/editors/ECore/Editor/EThumbnailGroup.cpp b/src/editors/ECore/Editor/EThumbnailGroup.cpp index 4c2f1c71a99..f964929ea0a 100644 --- a/src/editors/ECore/Editor/EThumbnailGroup.cpp +++ b/src/editors/ECore/Editor/EThumbnailGroup.cpp @@ -9,109 +9,129 @@ #define THM_GROUP_VERSION 0x0001 //------------------------------------------------------------------------------ #define THM_CHUNK_GROUPPARAM 0x0001 + //------------------------------------------------------------------------------ -EGroupThumbnail::EGroupThumbnail(LPCSTR src_name, bool bLoad):EImageThumbnail(src_name,ETObject) +EGroupThumbnail::EGroupThumbnail(LPCSTR src_name, bool bLoad): EImageThumbnail(src_name, ETObject) { - if (bLoad) Load(); + if (bLoad) + Load(); } + //------------------------------------------------------------------------------ EGroupThumbnail::~EGroupThumbnail() { - m_Pixels.clear(); + m_Pixels.clear(); } + //------------------------------------------------------------------------------ -void EGroupThumbnail::CreateFromData(u32* p, u32 w, u32 h, const SStringVec& lst) +void EGroupThumbnail::CreateFromData(u32 *p, u32 w, u32 h, const SStringVec &lst) { - EImageThumbnail::CreatePixels(p, w, h); - objects = lst; + EImageThumbnail::CreatePixels(p, w, h); + objects = lst; } + //------------------------------------------------------------------------------ bool EGroupThumbnail::Load(LPCSTR src_name, LPCSTR path) { - string_path fn; - strcpy(fn,EFS.ChangeFileExt(src_name?src_name:m_Name.c_str(),".thm").c_str()); - if (path) FS.update_path(fn,path,fn); - else FS.update_path(fn,_objects_,fn); - if (!FS.exist(fn)) return false; - - IReader* F = FS.r_open(fn); - u16 version = 0; - - R_ASSERT(F->r_chunk(THM_CHUNK_VERSION,&version)); - if( version!=THM_GROUP_VERSION ){ - Msg ("!Thumbnail: Unsupported version."); - return false; + string_path fn; + strcpy(fn, EFS.ChangeFileExt(src_name ? src_name : m_Name.c_str(), ".thm").c_str()); + if (path) + FS.update_path(fn, path, fn); + else + FS.update_path(fn, _objects_, fn); + if (!FS.exist(fn)) + return false; + + IReader *F = FS.r_open(fn); + u16 version = 0; + + R_ASSERT(F->r_chunk(THM_CHUNK_VERSION, &version)); + if (version!=THM_GROUP_VERSION) + { + Msg("!Thumbnail: Unsupported version."); + return false; } - IReader* D = F->open_chunk(THM_CHUNK_DATA); R_ASSERT(D); - m_Pixels.resize (THUMB_SIZE); - D->r (m_Pixels.begin(),THUMB_SIZE*sizeof(u32)); - D->close (); + IReader *D = F->open_chunk(THM_CHUNK_DATA); + R_ASSERT(D); + m_Pixels.resize(THUMB_SIZE); + D->r(m_Pixels.begin(), THUMB_SIZE*sizeof(u32)); + D->close(); - R_ASSERT (F->find_chunk(THM_CHUNK_TYPE)); - m_Type = THMType(F->r_u32()); - R_ASSERT (m_Type==ETObject); + R_ASSERT(F->find_chunk(THM_CHUNK_TYPE)); + m_Type = THMType(F->r_u32()); + R_ASSERT(m_Type==ETObject); - R_ASSERT (F->find_chunk(THM_CHUNK_GROUPPARAM)); - objects.resize (F->r_u32()); - for (SStringVecIt it=objects.begin(); it!=objects.end(); it++) - F->r_stringZ(*it); - - m_Age = FS.get_file_age(fn); + R_ASSERT(F->find_chunk(THM_CHUNK_GROUPPARAM)); + objects.resize(F->r_u32()); + for (SStringVecIt it = objects.begin(); it!=objects.end(); it++) + F->r_stringZ(*it); - FS.r_close (F); + m_Age = FS.get_file_age(fn); + + FS.r_close(F); return true; } + //------------------------------------------------------------------------------ void EGroupThumbnail::Save(int age, LPCSTR path) { - if (!Valid()) return; + if (!Valid()) + return; CMemoryWriter F; - F.open_chunk (THM_CHUNK_VERSION); - F.w_u16 (THM_GROUP_VERSION); - F.close_chunk (); - - F.w_chunk (THM_CHUNK_DATA | CFS_CompressMark,m_Pixels.begin(),m_Pixels.size()*sizeof(u32)); - - F.open_chunk (THM_CHUNK_TYPE); - F.w_u32 (m_Type); - F.close_chunk (); - - F.open_chunk (THM_CHUNK_GROUPPARAM); - F.w_u32 (objects.size()); - for (SStringVecIt it=objects.begin(); it!=objects.end(); it++) - F.w_stringZ (*it); - F.close_chunk (); - - string_path fn; - if (path) FS.update_path(fn,path,m_Name.c_str()); - else FS.update_path(fn,_objects_,m_Name.c_str()); + F.open_chunk(THM_CHUNK_VERSION); + F.w_u16(THM_GROUP_VERSION); + F.close_chunk(); + + F.w_chunk(THM_CHUNK_DATA|CFS_CompressMark, m_Pixels.begin(), m_Pixels.size()*sizeof(u32)); + + F.open_chunk(THM_CHUNK_TYPE); + F.w_u32(m_Type); + F.close_chunk(); + + F.open_chunk(THM_CHUNK_GROUPPARAM); + F.w_u32(objects.size()); + for (SStringVecIt it = objects.begin(); it!=objects.end(); it++) + F.w_stringZ(*it); + F.close_chunk(); + + string_path fn; + if (path) + FS.update_path(fn, path, m_Name.c_str()); + else + FS.update_path(fn, _objects_, m_Name.c_str()); if (F.save_to(fn)) { - FS.set_file_age (fn,age?age:m_Age); - }else{ - Log ("!Can't save thumbnail:",fn); + FS.set_file_age(fn, age ? age : m_Age); + } + else + { + Log("!Can't save thumbnail:", fn); } } + //------------------------------------------------------------------------------ -void EGroupThumbnail::FillProp(PropItemVec& items) +void EGroupThumbnail::FillProp(PropItemVec &items) { - PHelper().CreateCaption (items, "Objects\\Count", AnsiString(objects.size()).c_str()); - for (SStringVecIt it=objects.begin(); it!=objects.end(); it++) - PHelper().CreateCaption (items, AnsiString().sprintf("Objects\\#%d",it-objects.begin()).c_str(),it->c_str()); + PHelper().CreateCaption(items, "Objects\\Count", AnsiString(objects.size()).c_str()); + for (SStringVecIt it = objects.begin(); it!=objects.end(); it++) + PHelper().CreateCaption(items, AnsiString().sprintf("Objects\\#%d", it-objects.begin()).c_str(), it->c_str()); } + //------------------------------------------------------------------------------ -void EGroupThumbnail::FillInfo(PropItemVec& items) +void EGroupThumbnail::FillInfo(PropItemVec &items) { - FillProp (items); + FillProp(items); } + //------------------------------------------------------------------------------ + diff --git a/src/editors/ECore/Editor/EThumbnailObject.cpp b/src/editors/ECore/Editor/EThumbnailObject.cpp index 8fffd64bb39..b1aeaf7443c 100644 --- a/src/editors/ECore/Editor/EThumbnailObject.cpp +++ b/src/editors/ECore/Editor/EThumbnailObject.cpp @@ -9,110 +9,128 @@ #define THM_OBJECT_VERSION 0x0012 //------------------------------------------------------------------------------ #define THM_CHUNK_OBJECTPARAM 0x0816 + //------------------------------------------------------------------------------ -EObjectThumbnail::EObjectThumbnail(LPCSTR src_name, bool bLoad):EImageThumbnail(src_name,ETObject) +EObjectThumbnail::EObjectThumbnail(LPCSTR src_name, bool bLoad): EImageThumbnail(src_name, ETObject) { - if (bLoad) Load(); + if (bLoad) + Load(); } + //------------------------------------------------------------------------------ EObjectThumbnail::~EObjectThumbnail() { - m_Pixels.clear(); + m_Pixels.clear(); } + //------------------------------------------------------------------------------ -void EObjectThumbnail::CreateFromData(u32* p, u32 w, u32 h, int fc, int vc) +void EObjectThumbnail::CreateFromData(u32 *p, u32 w, u32 h, int fc, int vc) { - EImageThumbnail::CreatePixels(p, w, h); - face_count = fc; - vertex_count = vc; + EImageThumbnail::CreatePixels(p, w, h); + face_count = fc; + vertex_count = vc; } + //------------------------------------------------------------------------------ bool EObjectThumbnail::Load(LPCSTR src_name, LPCSTR path) { - string_path fn; - strcpy(fn,EFS.ChangeFileExt(src_name?src_name:m_Name.c_str(),".thm").c_str()); - if (path) FS.update_path(fn,path,fn); - else FS.update_path(fn,_objects_,fn); - if (!FS.exist(fn)) return false; - - IReader* F = FS.r_open(fn); - u16 version = 0; - - R_ASSERT(F->r_chunk(THM_CHUNK_VERSION,&version)); - if( version!=THM_OBJECT_VERSION ){ - Msg ("!Thumbnail: Unsupported version."); - return false; + string_path fn; + strcpy(fn, EFS.ChangeFileExt(src_name ? src_name : m_Name.c_str(), ".thm").c_str()); + if (path) + FS.update_path(fn, path, fn); + else + FS.update_path(fn, _objects_, fn); + if (!FS.exist(fn)) + return false; + + IReader *F = FS.r_open(fn); + u16 version = 0; + + R_ASSERT(F->r_chunk(THM_CHUNK_VERSION, &version)); + if (version!=THM_OBJECT_VERSION) + { + Msg("!Thumbnail: Unsupported version."); + return false; } - IReader* D = F->open_chunk(THM_CHUNK_DATA); R_ASSERT(D); - m_Pixels.resize (THUMB_SIZE); - D->r (m_Pixels.begin(),THUMB_SIZE*sizeof(u32)); - D->close (); + IReader *D = F->open_chunk(THM_CHUNK_DATA); + R_ASSERT(D); + m_Pixels.resize(THUMB_SIZE); + D->r(m_Pixels.begin(), THUMB_SIZE*sizeof(u32)); + D->close(); + + R_ASSERT(F->find_chunk(THM_CHUNK_TYPE)); + m_Type = THMType(F->r_u32()); + R_ASSERT(m_Type==ETObject); - R_ASSERT (F->find_chunk(THM_CHUNK_TYPE)); - m_Type = THMType(F->r_u32()); - R_ASSERT (m_Type==ETObject); + R_ASSERT(F->find_chunk(THM_CHUNK_OBJECTPARAM)); + face_count = F->r_u32(); + vertex_count = F->r_u32(); - R_ASSERT (F->find_chunk(THM_CHUNK_OBJECTPARAM)); - face_count = F->r_u32(); - vertex_count = F->r_u32(); - - m_Age = FS.get_file_age(fn); + m_Age = FS.get_file_age(fn); - FS.r_close (F); + FS.r_close(F); return true; } + //------------------------------------------------------------------------------ void EObjectThumbnail::Save(int age, LPCSTR path) { - if (!Valid()) return; + if (!Valid()) + return; CMemoryWriter F; - F.open_chunk (THM_CHUNK_VERSION); - F.w_u16 (THM_OBJECT_VERSION); - F.close_chunk (); + F.open_chunk(THM_CHUNK_VERSION); + F.w_u16(THM_OBJECT_VERSION); + F.close_chunk(); - F.w_chunk (THM_CHUNK_DATA | CFS_CompressMark,m_Pixels.begin(),m_Pixels.size()*sizeof(u32)); + F.w_chunk(THM_CHUNK_DATA|CFS_CompressMark, m_Pixels.begin(), m_Pixels.size()*sizeof(u32)); - F.open_chunk (THM_CHUNK_TYPE); - F.w_u32 (m_Type); - F.close_chunk (); + F.open_chunk(THM_CHUNK_TYPE); + F.w_u32(m_Type); + F.close_chunk(); - F.open_chunk (THM_CHUNK_OBJECTPARAM); - F.w_u32 (face_count); - F.w_u32 (vertex_count); - F.close_chunk (); + F.open_chunk(THM_CHUNK_OBJECTPARAM); + F.w_u32(face_count); + F.w_u32(vertex_count); + F.close_chunk(); - string_path fn; -//. if (path) FS.update_path(fn,path,m_Name.c_str()); -//. else FS.update_path(fn,_objects_,m_Name.c_str()); + string_path fn; + //. if (path) FS.update_path(fn,path,m_Name.c_str()); + //. else FS.update_path(fn,_objects_,m_Name.c_str()); - strcpy (fn,m_Name.c_str()); + strcpy(fn, m_Name.c_str()); if (F.save_to(fn)) { - FS.set_file_age (fn,age?age:m_Age); - }else{ - Log ("!Can't save thumbnail:",fn); + FS.set_file_age(fn, age ? age : m_Age); + } + else + { + Log("!Can't save thumbnail:", fn); } } + //------------------------------------------------------------------------------ -void EObjectThumbnail::FillProp(PropItemVec& items) +void EObjectThumbnail::FillProp(PropItemVec &items) { - PHelper().CreateCaption (items, "Face Count", AnsiString(face_count).c_str()); - PHelper().CreateCaption (items, "Vertex Count", AnsiString(vertex_count).c_str()); + PHelper().CreateCaption(items, "Face Count", AnsiString(face_count).c_str()); + PHelper().CreateCaption(items, "Vertex Count", AnsiString(vertex_count).c_str()); } + //------------------------------------------------------------------------------ -void EObjectThumbnail::FillInfo(PropItemVec& items) +void EObjectThumbnail::FillInfo(PropItemVec &items) { - PHelper().CreateCaption (items, "Face Count", AnsiString(face_count).c_str()); - PHelper().CreateCaption (items, "Vertex Count", AnsiString(vertex_count).c_str()); + PHelper().CreateCaption(items, "Face Count", AnsiString(face_count).c_str()); + PHelper().CreateCaption(items, "Vertex Count", AnsiString(vertex_count).c_str()); } + //------------------------------------------------------------------------------ + diff --git a/src/editors/ECore/Editor/EThumbnailSound.cpp b/src/editors/ECore/Editor/EThumbnailSound.cpp index 92b9da685ef..03523fb6f24 100644 --- a/src/editors/ECore/Editor/EThumbnailSound.cpp +++ b/src/editors/ECore/Editor/EThumbnailSound.cpp @@ -11,164 +11,191 @@ #define THM_CHUNK_SOUNDPARAM 0x1000 #define THM_CHUNK_SOUNDPARAM2 0x1001 #define THM_CHUNK_SOUND_AI_DIST 0x1002 + //------------------------------------------------------------------------------ -ESoundThumbnail::ESoundThumbnail(LPCSTR src_name, bool bLoad):ECustomThumbnail(src_name,ETSound) +ESoundThumbnail::ESoundThumbnail(LPCSTR src_name, bool bLoad): ECustomThumbnail(src_name, ETSound) { - m_fQuality = 0.f; - m_fMinDist = 1.f; - m_fMaxDist = 300.f; - m_fMaxAIDist = 300.f; - m_fBaseVolume = 1.f; - m_uGameType = 0; - if (bLoad) Load(); + m_fQuality = 0.f; + m_fMinDist = 1.f; + m_fMaxDist = 300.f; + m_fMaxAIDist = 300.f; + m_fBaseVolume = 1.f; + m_uGameType = 0; + if (bLoad) + Load(); } + //------------------------------------------------------------------------------ -ESoundThumbnail::~ESoundThumbnail() -{ -} +ESoundThumbnail::~ESoundThumbnail() {} + //------------------------------------------------------------------------------ bool ESoundThumbnail::Load(LPCSTR src_name, LPCSTR path) { - string_path fn; - strcpy(fn,EFS.ChangeFileExt(src_name?src_name:m_Name.c_str(),".thm").c_str()); - if (path) FS.update_path(fn,path,fn); - else FS.update_path(fn,_sounds_,fn); - if (!FS.exist(fn)) return false; - - IReader* F = FS.r_open(fn); - u16 version = 0; - - R_ASSERT(F->r_chunk(THM_CHUNK_VERSION,&version)); - if( version!=THM_SOUND_VERSION ){ - Msg ("!Thumbnail: Unsupported version."); - return false; + string_path fn; + strcpy(fn, EFS.ChangeFileExt(src_name ? src_name : m_Name.c_str(), ".thm").c_str()); + if (path) + FS.update_path(fn, path, fn); + else + FS.update_path(fn, _sounds_, fn); + if (!FS.exist(fn)) + return false; + + IReader *F = FS.r_open(fn); + u16 version = 0; + + R_ASSERT(F->r_chunk(THM_CHUNK_VERSION, &version)); + if (version!=THM_SOUND_VERSION) + { + Msg("!Thumbnail: Unsupported version."); + return false; } - R_ASSERT (F->find_chunk(THM_CHUNK_TYPE)); - m_Type = THMType(F->r_u32()); - R_ASSERT (m_Type==ETSound); + R_ASSERT(F->find_chunk(THM_CHUNK_TYPE)); + m_Type = THMType(F->r_u32()); + R_ASSERT(m_Type==ETSound); - R_ASSERT (F->find_chunk(THM_CHUNK_SOUNDPARAM)); - m_fQuality = F->r_float(); - m_fMinDist = F->r_float(); - m_fMaxDist = F->r_float(); - m_uGameType = F->r_u32(); + R_ASSERT(F->find_chunk(THM_CHUNK_SOUNDPARAM)); + m_fQuality = F->r_float(); + m_fMinDist = F->r_float(); + m_fMaxDist = F->r_float(); + m_uGameType = F->r_u32(); if (F->find_chunk(THM_CHUNK_SOUNDPARAM2)) - m_fBaseVolume = F->r_float(); + m_fBaseVolume = F->r_float(); if (F->find_chunk(THM_CHUNK_SOUND_AI_DIST)) - m_fMaxAIDist= F->r_float(); + m_fMaxAIDist = F->r_float(); else - m_fMaxAIDist= m_fMaxDist; - - m_Age = FS.get_file_age(fn); + m_fMaxAIDist = m_fMaxDist; - FS.r_close (F); + m_Age = FS.get_file_age(fn); + + FS.r_close(F); return true; } + //------------------------------------------------------------------------------ void ESoundThumbnail::Save(int age, LPCSTR path) { - if (!Valid()) return; + if (!Valid()) + return; CMemoryWriter F; - F.open_chunk (THM_CHUNK_VERSION); - F.w_u16 (THM_SOUND_VERSION); - F.close_chunk (); - - F.open_chunk (THM_CHUNK_TYPE); - F.w_u32 (m_Type); - F.close_chunk (); - - F.open_chunk (THM_CHUNK_SOUNDPARAM); - F.w_float (m_fQuality); - F.w_float (m_fMinDist); - F.w_float (m_fMaxDist); - F.w_u32 (m_uGameType); - F.close_chunk (); - - F.open_chunk (THM_CHUNK_SOUNDPARAM2); - F.w_float (m_fBaseVolume); - F.close_chunk (); - - F.open_chunk (THM_CHUNK_SOUND_AI_DIST); - F.w_float (m_fMaxAIDist); - F.close_chunk (); - - string_path fn; - if (path) FS.update_path(fn,path,m_Name.c_str()); - else FS.update_path(fn,_sounds_,m_Name.c_str()); + F.open_chunk(THM_CHUNK_VERSION); + F.w_u16(THM_SOUND_VERSION); + F.close_chunk(); + + F.open_chunk(THM_CHUNK_TYPE); + F.w_u32(m_Type); + F.close_chunk(); + + F.open_chunk(THM_CHUNK_SOUNDPARAM); + F.w_float(m_fQuality); + F.w_float(m_fMinDist); + F.w_float(m_fMaxDist); + F.w_u32(m_uGameType); + F.close_chunk(); + + F.open_chunk(THM_CHUNK_SOUNDPARAM2); + F.w_float(m_fBaseVolume); + F.close_chunk(); + + F.open_chunk(THM_CHUNK_SOUND_AI_DIST); + F.w_float(m_fMaxAIDist); + F.close_chunk(); + + string_path fn; + if (path) + FS.update_path(fn, path, m_Name.c_str()); + else + FS.update_path(fn, _sounds_, m_Name.c_str()); if (F.save_to(fn)) { - FS.set_file_age (fn,age?age:m_Age); - }else{ - Log ("!Can't save thumbnail:",fn); + FS.set_file_age(fn, age ? age : m_Age); + } + else + { + Log("!Can't save thumbnail:", fn); } } + //------------------------------------------------------------------------------ #include "ai_sounds.h" -#include "PropertiesList.h" +#include "editors/xrEProps/PropertiesList.h" -bool ESoundThumbnail::OnMaxAIDistAfterEdit(PropValue* sender, float& edit_val) +bool ESoundThumbnail::OnMaxAIDistAfterEdit(PropValue *sender, float &edit_val) { - TProperties* P = sender->Owner()->Owner(); VERIFY(P); - PropItem* S = P->FindItem("Max Dist"); VERIFY(S); - FloatValue* V = dynamic_cast(S->GetFrontValue());VERIFY(V); - float max_val = V->GetValue (); - return edit_valOwner()->Owner(); + VERIFY(P); + PropItem *S = P->FindItem("Max Dist"); + VERIFY(S); + FloatValue *V = dynamic_cast(S->GetFrontValue()); + VERIFY(V); + float max_val = V->GetValue(); + return edit_val(sender);VERIFY(SV); - TProperties* P = sender->Owner()->Owner(); VERIFY(P); - PropItem* S = P->FindItem("Max AI Dist"); VERIFY(S); - bool bChanged = false; - for (PropItem::PropValueIt it=S->Values().begin(); S->Values().end() != it; ++it){ - FloatValue* CV = dynamic_cast(*it);VERIFY(CV); - CV->lim_mx = *SV->value; - if (*CV->value>CV->lim_mx){ - ELog.DlgMsg (mtInformation,"'Max AI Dist' <= 'Max Dist'. 'Max AI Dist' will be clamped."); - bChanged = true; - *CV->value = CV->lim_mx; + FloatValue *SV = dynamic_cast(sender); + VERIFY(SV); + TProperties *P = sender->Owner()->Owner(); + VERIFY(P); + PropItem *S = P->FindItem("Max AI Dist"); + VERIFY(S); + bool bChanged = false; + for (PropItem::PropValueIt it = S->Values().begin(); S->Values().end()!=it; ++it) + { + FloatValue *CV = dynamic_cast(*it); + VERIFY(CV); + CV->lim_mx = *SV->value; + if (*CV->value>CV->lim_mx) + { + ELog.DlgMsg(mtInformation, "'Max AI Dist' <= 'Max Dist'. 'Max AI Dist' will be clamped."); + bChanged = true; + *CV->value = CV->lim_mx; } if (!CV->Equal(S->Values().front())) - S->m_Flags.set(PropItem::flMixed,TRUE); + S->m_Flags.set(PropItem::flMixed, TRUE); } - if (bChanged){ - P->Modified (); - P->RefreshForm (); + if (bChanged) + { + P->Modified(); + P->RefreshForm(); } } -void ESoundThumbnail::FillProp(PropItemVec& items) -{ - FloatValue* V = 0; - PHelper().CreateFloat (items, "Quality", &m_fQuality); - PHelper().CreateFloat (items, "Min Dist", &m_fMinDist, 0.01f,1000.f); - V = PHelper().CreateFloat (items, "Max Dist", &m_fMaxDist, 0.1f,1000.f); - V->OnChangeEvent.bind (this,&ESoundThumbnail::OnMaxDistChange); - V = PHelper().CreateFloat (items, "Max AI Dist", &m_fMaxAIDist, 0.1f,1000.f); - V->OnAfterEditEvent.bind (this,&ESoundThumbnail::OnMaxAIDistAfterEdit); - PHelper().CreateFloat (items, "Base Volume", &m_fBaseVolume, 0.f,2.f); - PHelper().CreateToken32 (items, "Game Type", &m_uGameType, anomaly_type_token); +void ESoundThumbnail::FillProp(PropItemVec &items) +{ + FloatValue *V = 0; + PHelper().CreateFloat(items, "Quality", &m_fQuality); + PHelper().CreateFloat(items, "Min Dist", &m_fMinDist, 0.01f, 1000.f); + V = PHelper().CreateFloat(items, "Max Dist", &m_fMaxDist, 0.1f, 1000.f); + V->OnChangeEvent.bind(this, &ESoundThumbnail::OnMaxDistChange); + V = PHelper().CreateFloat(items, "Max AI Dist", &m_fMaxAIDist, 0.1f, 1000.f); + V->OnAfterEditEvent.bind(this, &ESoundThumbnail::OnMaxAIDistAfterEdit); + PHelper().CreateFloat(items, "Base Volume", &m_fBaseVolume, 0.f, 2.f); + PHelper().CreateToken32(items, "Game Type", &m_uGameType, anomaly_type_token); } + //------------------------------------------------------------------------------ -void ESoundThumbnail::FillInfo(PropItemVec& items) +void ESoundThumbnail::FillInfo(PropItemVec &items) { - PHelper().CreateCaption (items, "Quality", AnsiString().sprintf("%3.2f",m_fQuality).c_str()); - PHelper().CreateCaption (items, "Min Dist", AnsiString().sprintf("%3.2f",m_fMinDist).c_str()); - PHelper().CreateCaption (items, "Max Dist", AnsiString().sprintf("%3.2f",m_fMaxDist).c_str()); - PHelper().CreateCaption (items, "Max AI Dist", AnsiString().sprintf("%3.2f",m_fMaxAIDist).c_str()); - PHelper().CreateCaption (items, "Base Volume", AnsiString().sprintf("%3.2f",m_fBaseVolume).c_str()); - PHelper().CreateCaption (items, "Game Type", get_token_name(anomaly_type_token,m_uGameType)); + PHelper().CreateCaption(items, "Quality", AnsiString().sprintf("%3.2f", m_fQuality).c_str()); + PHelper().CreateCaption(items, "Min Dist", AnsiString().sprintf("%3.2f", m_fMinDist).c_str()); + PHelper().CreateCaption(items, "Max Dist", AnsiString().sprintf("%3.2f", m_fMaxDist).c_str()); + PHelper().CreateCaption(items, "Max AI Dist", AnsiString().sprintf("%3.2f", m_fMaxAIDist).c_str()); + PHelper().CreateCaption(items, "Base Volume", AnsiString().sprintf("%3.2f", m_fBaseVolume).c_str()); + PHelper().CreateCaption(items, "Game Type", get_token_name(anomaly_type_token, m_uGameType)); } + //------------------------------------------------------------------------------ + diff --git a/src/editors/ECore/Editor/EThumbnailTexture.cpp b/src/editors/ECore/Editor/EThumbnailTexture.cpp index 47f5aa11329..50805b8632c 100644 --- a/src/editors/ECore/Editor/EThumbnailTexture.cpp +++ b/src/editors/ECore/Editor/EThumbnailTexture.cpp @@ -3,215 +3,233 @@ #include "EThumbnail.h" #ifndef XR_EPROPS_EXPORTS - #include "ImageManager.h" +#include "ImageManager.h" #endif #pragma package(smart_init) //------------------------------------------------------------------------------ #define THM_TEXTURE_VERSION 0x0012 + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -ETextureThumbnail::ETextureThumbnail(LPCSTR src_name, bool bLoad):EImageThumbnail(src_name,ETTexture) +ETextureThumbnail::ETextureThumbnail(LPCSTR src_name, bool bLoad): EImageThumbnail(src_name, ETTexture) { - if(!strchr(src_name,'\\')) + if (!strchr(src_name, '\\')) { - xr_string _name = src_name; - ImageLib.UpdateFileName (_name); - m_Name = _name.c_str(); - m_Name = ChangeFileExt(m_Name,".thm"); - } - m_bValid = false; + xr_string _name = src_name; + ImageLib.UpdateFileName(_name); + m_Name = _name.c_str(); + m_Name = ChangeFileExt(m_Name, ".thm"); + } + m_bValid = false; if (bLoad) #ifdef XR_EPROPS_EXPORTS Load(); #else - if (!Load()) - { - ImageLib.CreateTextureThumbnail(this,src_name); - } + if (!Load()) + { + ImageLib.CreateTextureThumbnail(this, src_name); + } #endif } + //------------------------------------------------------------------------------ ETextureThumbnail::~ETextureThumbnail() { - m_Pixels.clear(); + m_Pixels.clear(); } + //------------------------------------------------------------------------------ int ETextureThumbnail::MemoryUsage() { - int mem_usage = _Width()*_Height()*4; - switch (m_TexParams.fmt){ - case STextureParams::tfDXT1: - case STextureParams::tfADXT1: mem_usage/=6; break; - case STextureParams::tfDXT3: - case STextureParams::tfDXT5: mem_usage/=4; break; - case STextureParams::tf4444: - case STextureParams::tf1555: - case STextureParams::tf565: mem_usage/=2; break; - case STextureParams::tfRGBA: break; + int mem_usage = _Width()*_Height()*4; + switch (m_TexParams.fmt) + { + case STextureParams::tfDXT1: + case STextureParams::tfADXT1: mem_usage /= 6; + break; + case STextureParams::tfDXT3: + case STextureParams::tfDXT5: mem_usage /= 4; + break; + case STextureParams::tf4444: + case STextureParams::tf1555: + case STextureParams::tf565: mem_usage /= 2; + break; + case STextureParams::tfRGBA: break; } string_path fn; - FS.update_path (fn,_game_textures_,EFS.ChangeFileExt(m_Name.c_str(),".seq").c_str()); + FS.update_path(fn, _game_textures_, EFS.ChangeFileExt(m_Name.c_str(), ".seq").c_str()); if (FS.exist(fn)) { - string128 buffer; - IReader* F = FS.r_open(0,fn); - F->r_string (buffer,sizeof(buffer)); + string128 buffer; + IReader *F = FS.r_open(0, fn); + F->r_string(buffer, sizeof(buffer)); int cnt = 0; - while (!F->eof()){ - F->r_string(buffer,sizeof(buffer)); + while (!F->eof()) + { + F->r_string(buffer, sizeof(buffer)); cnt++; } - FS.r_close (F); - mem_usage *= cnt?cnt:1; + FS.r_close(F); + mem_usage *= cnt ? cnt : 1; } return mem_usage; } + //------------------------------------------------------------------------------ -void ETextureThumbnail::CreateFromData(u32* p, u32 w, u32 h) +void ETextureThumbnail::CreateFromData(u32 *p, u32 w, u32 h) { - EImageThumbnail::CreatePixels(p, w, h); + EImageThumbnail::CreatePixels(p, w, h); m_TexParams.width = w; - m_TexParams.height= h; - m_TexParams.flags.set(STextureParams::flHasAlpha,FALSE); + m_TexParams.height = h; + m_TexParams.flags.set(STextureParams::flHasAlpha, FALSE); } + //------------------------------------------------------------------------------ -bool Surface_Load(LPCSTR full_name, U32Vec& data, u32& w, u32& h, u32& a); +bool Surface_Load(LPCSTR full_name, U32Vec &data, u32 &w, u32 &h, u32 &a); bool ETextureThumbnail::Load(LPCSTR src_name, LPCSTR path) { string_path fn; - strcpy(fn,EFS.ChangeFileExt(src_name?src_name:m_Name.c_str(),".thm").c_str() ); + strcpy(fn, EFS.ChangeFileExt(src_name ? src_name : m_Name.c_str(), ".thm").c_str()); if (path) - FS.update_path(fn,path,fn); + FS.update_path(fn, path, fn); else { - FS.update_path (fn,_game_textures_,fn); + FS.update_path(fn, _game_textures_, fn); } - if (!FS.exist(fn)) return false; + if (!FS.exist(fn)) + return false; - IReader* F = FS.r_open(fn); - u16 version = 0; + IReader *F = FS.r_open(fn); + u16 version = 0; - R_ASSERT(F->r_chunk(THM_CHUNK_VERSION,&version)); - if( version!=THM_TEXTURE_VERSION ){ - Msg ("!Thumbnail: Unsupported version."); - return false; + R_ASSERT(F->r_chunk(THM_CHUNK_VERSION, &version)); + if (version!=THM_TEXTURE_VERSION) + { + Msg("!Thumbnail: Unsupported version."); + return false; } -/* - IReader* D = F->open_chunk(THM_CHUNK_DATA); R_ASSERT(D); - m_Pixels.resize (THUMB_SIZE); - D->r (m_Pixels.begin(),THUMB_SIZE*sizeof(u32)); - D->close (); -*/ + /* + IReader* D = F->open_chunk(THM_CHUNK_DATA); R_ASSERT(D); + m_Pixels.resize (THUMB_SIZE); + D->r (m_Pixels.begin(),THUMB_SIZE*sizeof(u32)); + D->close (); + */ - R_ASSERT (F->find_chunk(THM_CHUNK_TYPE)); - m_Type = THMType(F->r_u32()); - R_ASSERT (m_Type==ETTexture); + R_ASSERT(F->find_chunk(THM_CHUNK_TYPE)); + m_Type = THMType(F->r_u32()); + R_ASSERT(m_Type==ETTexture); m_TexParams.Load(*F); - m_Age = FS.get_file_age(fn); + m_Age = FS.get_file_age(fn); - FS.r_close (F); - SetValid (); + FS.r_close(F); + SetValid(); return true; } + //------------------------------------------------------------------------------ void ETextureThumbnail::Save(int age, LPCSTR path) { - if (!Valid()) return; + if (!Valid()) + return; CMemoryWriter F; - F.open_chunk (THM_CHUNK_VERSION); - F.w_u16 (THM_TEXTURE_VERSION); - F.close_chunk (); + F.open_chunk(THM_CHUNK_VERSION); + F.w_u16(THM_TEXTURE_VERSION); + F.close_chunk(); -/* - F.w_chunk (THM_CHUNK_DATA | CFS_CompressMark,m_Pixels.begin(),m_Pixels.size()*sizeof(u32)); -*/ + /* + F.w_chunk (THM_CHUNK_DATA | CFS_CompressMark,m_Pixels.begin(),m_Pixels.size()*sizeof(u32)); + */ - F.open_chunk (THM_CHUNK_TYPE); - F.w_u32 (m_Type); - F.close_chunk (); + F.open_chunk(THM_CHUNK_TYPE); + F.w_u32(m_Type); + F.close_chunk(); - m_TexParams.Save(F); + m_TexParams.Save(F); - string_path fn; + string_path fn; if (path) FS.update_path(fn, path, m_Name.c_str()); else - FS.update_path(fn, _game_textures_, m_Name.c_str()); + FS.update_path(fn, _game_textures_, m_Name.c_str()); if (F.save_to(fn)) { - FS.set_file_age (fn,age?age:m_Age); - }else{ - Log ("!Can't save thumbnail:",fn); + FS.set_file_age(fn, age ? age : m_Age); + } + else + { + Log("!Can't save thumbnail:", fn); } } + //------------------------------------------------------------------------------ -void ETextureThumbnail::FillProp(PropItemVec& items, PropValue::TOnChange on_type_change) +void ETextureThumbnail::FillProp(PropItemVec &items, PropValue::TOnChange on_type_change) { - m_TexParams.FillProp (m_SrcName.c_str(),items,on_type_change); + m_TexParams.FillProp(m_SrcName.c_str(), items, on_type_change); } + //------------------------------------------------------------------------------ -void ETextureThumbnail::FillInfo(PropItemVec& items) -{ - STextureParams& F = m_TexParams; - PHelper().CreateCaption (items, "Format", get_token_name(tfmt_token,F.fmt)); - PHelper().CreateCaption (items, "Type", get_token_name(ttype_token,F.type)); - PHelper().CreateCaption (items, "Width", shared_str().printf("%d",_Width())); - PHelper().CreateCaption (items, "Height", shared_str().printf("%d",_Height())); - PHelper().CreateCaption (items, "Alpha", _Alpha()?"on":"off"); +void ETextureThumbnail::FillInfo(PropItemVec &items) +{ + STextureParams &F = m_TexParams; + PHelper().CreateCaption(items, "Format", get_token_name(tfmt_token, F.fmt)); + PHelper().CreateCaption(items, "Type", get_token_name(ttype_token, F.type)); + PHelper().CreateCaption(items, "Width", shared_str().printf("%d", _Width())); + PHelper().CreateCaption(items, "Height", shared_str().printf("%d", _Height())); + PHelper().CreateCaption(items, "Alpha", _Alpha() ? "on" : "off"); } -BOOL ETextureThumbnail::similar(ETextureThumbnail* thm1, xr_vector& sel_params) +BOOL ETextureThumbnail::similar(ETextureThumbnail *thm1, xr_vector &sel_params) { - BOOL res = m_TexParams.similar(thm1->m_TexParams, sel_params); - /* - if(res) - { - xr_vector::iterator it = sel_params.begin(); - xr_vector::iterator it_e = sel_params.end(); - - for(;it!=it_e;++it) - { - const AnsiString& par_name = *it; - if(par_name=="Format") - { - res = (m_TexParams.fmt == thm1->m_TexParams.fmt); - }else - if(par_name=="Type") - { - res = (m_TexParams.type == thm1->m_TexParams.type); - }else - if(par_name=="Width") - { - res = (_Width()==thm1->_Width()); - }else - if(par_name=="Height") - { - res = (_Height()==thm1->_Height()); - }else - if(par_name=="Alpha") - { - res = (_Alpha()==thm1->_Alpha()); - } - if(!res) - break; - } - } -*/ + BOOL res = m_TexParams.similar(thm1->m_TexParams, sel_params); + /* + if(res) + { + xr_vector::iterator it = sel_params.begin(); + xr_vector::iterator it_e = sel_params.end(); + + for(;it!=it_e;++it) + { + const AnsiString& par_name = *it; + if(par_name=="Format") + { + res = (m_TexParams.fmt == thm1->m_TexParams.fmt); + }else + if(par_name=="Type") + { + res = (m_TexParams.type == thm1->m_TexParams.type); + }else + if(par_name=="Width") + { + res = (_Width()==thm1->_Width()); + }else + if(par_name=="Height") + { + res = (_Height()==thm1->_Height()); + }else + if(par_name=="Alpha") + { + res = (_Alpha()==thm1->_Alpha()); + } + if(!res) + break; + } + } + */ return res; } @@ -219,55 +237,58 @@ LPCSTR ETextureThumbnail::FormatString() { return m_TexParams.FormatString(); } + //------------------------------------------------------------------------------ -void ETextureThumbnail::Draw(HDC hdc, const Irect& R) +void ETextureThumbnail::Draw(HDC hdc, const Irect &R) { - if(0==m_Pixels.size()) - { - u32 image_w, image_h, image_a; - xr_string fn_img = EFS.ChangeFileExt(m_Name.c_str(),".tga"); + if (0==m_Pixels.size()) + { + u32 image_w, image_h, image_a; + xr_string fn_img = EFS.ChangeFileExt(m_Name.c_str(), ".tga"); string_path fn; - FS.update_path (fn,_textures_,fn_img.c_str()); + FS.update_path(fn, _textures_, fn_img.c_str()); - if( !FS.exist(fn) ) + if (!FS.exist(fn)) { - fn_img = EFS.ChangeFileExt(m_Name.c_str(),".dds"); - FS.update_path(fn,_game_textures_,fn_img.c_str()); + fn_img = EFS.ChangeFileExt(m_Name.c_str(), ".dds"); + FS.update_path(fn, _game_textures_, fn_img.c_str()); - if( !FS.exist( fn ) ) - { - ELog.Msg(mtError,"Can't make preview for texture '%s'.",m_Name.c_str()); - return; - } + if (!FS.exist(fn)) + { + ELog.Msg(mtError, "Can't make preview for texture '%s'.", m_Name.c_str()); + return; + } } U32Vec data; u32 w, h, a; - if (!Surface_Load(fn,data,image_w,image_h,image_a)) + if (!Surface_Load(fn, data, image_w, image_h, image_a)) { - ELog.Msg(mtError,"Can't make preview for texture '%s'.",m_Name.c_str()); - return; + ELog.Msg(mtError, "Can't make preview for texture '%s'.", m_Name.c_str()); + return; } - ImageLib.MakeThumbnailImage(this,data.begin(),image_w,image_h,image_a); - } + ImageLib.MakeThumbnailImage(this, data.begin(), image_w, image_h, image_a); + } - if (Valid()) - { + if (Valid()) + { Irect r; - r.x1 = R.x1+1; + r.x1 = R.x1+1; r.y1 = R.y1+1; - r.x2 = R.x2-1; + r.x2 = R.x2-1; r.y2 = R.y2-1; - if (_Width()!=_Height()) FHelper.FillRect(hdc,r,0x00000000); + if (_Width()!=_Height()) + FHelper.FillRect(hdc, r, 0x00000000); if (_Width()>_Height()) { - r.y2 -= r.height()-iFloor(r.height()*float(_Height())/float(_Width())); - }else + r.y2 -= r.height()-iFloor(r.height()*float(_Height())/float(_Width())); + } + else { - r.x2 -= r.width()-iFloor(r.width()*float(_Width())/float(_Height())); + r.x2 -= r.width()-iFloor(r.width()*float(_Width())/float(_Height())); } - inherited::Draw(hdc,r); + inherited::Draw(hdc, r); } } diff --git a/src/editors/ECore/Editor/EditMesh.cpp b/src/editors/ECore/Editor/EditMesh.cpp index 646a49e4265..048fe25f60a 100644 --- a/src/editors/ECore/Editor/EditMesh.cpp +++ b/src/editors/ECore/Editor/EditMesh.cpp @@ -7,12 +7,13 @@ #include "utils/xrLC_Light/itterate_adjacents.h" #include "itterate_adjacents_dynamic.h" #ifdef _EDITOR -#include "ETools.h" +#include "utils/ETools/ETools.h" #include "UI_ToolsCustom.h" #endif -CEditableMesh::~CEditableMesh(){ - Clear(); +CEditableMesh::~CEditableMesh() +{ + Clear(); #ifdef _EDITOR R_ASSERT2(0==m_RenderBuffers,"Render buffer still referenced."); #endif @@ -20,141 +21,164 @@ CEditableMesh::~CEditableMesh(){ void CEditableMesh::Construct() { - m_Box.set (0,0,0,0,0,0); - m_Flags.assign (flVisible); - m_Name = ""; + m_Box.set(0, 0, 0, 0, 0, 0); + m_Flags.assign(flVisible); + m_Name = ""; #ifdef _EDITOR m_CFModel = 0; #endif - m_Vertices = 0; - m_SmoothGroups = 0; - m_Adjs = 0; - m_Faces = 0; - m_FaceNormals = 0; - m_VertexNormals = 0; - m_SVertices = 0; - m_SVertInfl = 0; + m_Vertices = 0; + m_SmoothGroups = 0; + m_Adjs = 0; + m_Faces = 0; + m_FaceNormals = 0; + m_VertexNormals = 0; + m_SVertices = 0; + m_SVertInfl = 0; #ifdef _EDITOR m_RenderBuffers = 0; #endif - m_FNormalsRefs = 0; - m_VNormalsRefs = 0; - m_AdjsRefs = 0; - m_SVertRefs = 0; + m_FNormalsRefs = 0; + m_VNormalsRefs = 0; + m_AdjsRefs = 0; + m_SVertRefs = 0; } -void CEditableMesh::Clear() +void CEditableMesh::Clear() { #ifdef _EDITOR UnloadRenderBuffers (); #endif - UnloadAdjacency (); - UnloadCForm (); - UnloadFNormals (); - UnloadVNormals (); - UnloadSVertices (); - - VERIFY (m_FNormalsRefs==0 && m_VNormalsRefs==0 && m_AdjsRefs==0 && m_SVertRefs==0); - - xr_free (m_Vertices); - xr_free (m_Faces); - for (VMapIt vm_it=m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) - xr_delete (*vm_it); - m_VMaps.clear (); - m_SurfFaces.clear (); - for (VMRefsIt ref_it=m_VMRefs.begin(); ref_it!=m_VMRefs.end(); ref_it++) - xr_free (ref_it->pts); - m_VMRefs.clear (); + UnloadAdjacency(); + UnloadCForm(); + UnloadFNormals(); + UnloadVNormals(); + UnloadSVertices(); + + VERIFY(m_FNormalsRefs==0&&m_VNormalsRefs==0&&m_AdjsRefs==0&&m_SVertRefs==0); + + xr_free(m_Vertices); + xr_free(m_Faces); + for (VMapIt vm_it = m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) + xr_delete(*vm_it); + m_VMaps.clear(); + m_SurfFaces.clear(); + for (VMRefsIt ref_it = m_VMRefs.begin(); ref_it!=m_VMRefs.end(); ref_it++) + xr_free(ref_it->pts); + m_VMRefs.clear(); } -void CEditableMesh::UnloadCForm () +void CEditableMesh::UnloadCForm() { #ifdef _EDITOR ETOOLS::destroy_model (m_CFModel); #endif } -void CEditableMesh::UnloadFNormals (bool force) +void CEditableMesh::UnloadFNormals(bool force) { - m_FNormalsRefs--; - if (force||m_FNormalsRefs<=0) { xr_free(m_FaceNormals); m_FNormalsRefs=0; } + m_FNormalsRefs--; + if (force||m_FNormalsRefs<=0) + { + xr_free(m_FaceNormals); + m_FNormalsRefs = 0; + } } -void CEditableMesh::UnloadVNormals (bool force) + +void CEditableMesh::UnloadVNormals(bool force) { - m_VNormalsRefs--; - if (force||m_VNormalsRefs<=0) { xr_free(m_VertexNormals); m_VNormalsRefs=0; } + m_VNormalsRefs--; + if (force||m_VNormalsRefs<=0) + { + xr_free(m_VertexNormals); + m_VNormalsRefs = 0; + } } -void CEditableMesh::UnloadSVertices (bool force) + +void CEditableMesh::UnloadSVertices(bool force) { - m_SVertRefs--; - if (force||m_SVertRefs<=0) { xr_free(m_SVertices); m_SVertRefs=0; } + m_SVertRefs--; + if (force||m_SVertRefs<=0) + { + xr_free(m_SVertices); + m_SVertRefs = 0; + } } -void CEditableMesh::UnloadAdjacency (bool force) + +void CEditableMesh::UnloadAdjacency(bool force) { - m_AdjsRefs--; - if (force||m_AdjsRefs<=0) { xr_delete(m_Adjs); m_AdjsRefs=0; } + m_AdjsRefs--; + if (force||m_AdjsRefs<=0) + { + xr_delete(m_Adjs); + m_AdjsRefs = 0; + } } void CEditableMesh::RecomputeBBox() { - if( 0==m_VertCount ){ - m_Box.set(0,0,0, 0,0,0); - return; + if (0==m_VertCount) + { + m_Box.set(0, 0, 0, 0, 0, 0); + return; } - m_Box.set( m_Vertices[0], m_Vertices[0] ); - for(u32 k=1; k(m_FaceCount); + m_FNormalsRefs++; + if (m_FaceNormals) + return; + m_FaceNormals = xr_alloc(m_FaceCount); // face normals - for (u32 k=0; k(m_FaceCount*3); - - // gen req - GenerateFNormals (); - GenerateAdjacency (); - - for (u32 f_i=0; f_i > iterate_adj ; - iterate_adj::recurse_tri_params p( N, m_SmoothGroups, m_FaceNormals, a_lst, m_Faces, m_FaceCount ); - iterate_adj::RecurseTri( face_adj_it - a_lst.begin(), p ); - float len = N.magnitude(); - if (len>EPS_S) - { - N.div (len); - }else - { -//. Msg ("!Invalid smooth group found (Maya type). Object: '%s'. Vertex: [%3.2f, %3.2f, %3.2f]",m_Parent->GetName(),VPUSH(m_Vertices[m_Faces[f_i].pv[k].pindex])); + m_VNormalsRefs++; + if (m_VertexNormals) + return; + m_VertexNormals = xr_alloc(m_FaceCount*3); + + // gen req + GenerateFNormals(); + GenerateAdjacency(); + + for (u32 f_i = 0; f_i> iterate_adj; + iterate_adj::recurse_tri_params p(N, m_SmoothGroups, m_FaceNormals, a_lst, m_Faces, m_FaceCount); + iterate_adj::RecurseTri(face_adj_it-a_lst.begin(), p); + float len = N.magnitude(); + if (len>EPS_S) + { + N.div(len); + } + else + { + //. Msg ("!Invalid smooth group found (Maya type). Object: '%s'. Vertex: [%3.2f, %3.2f, %3.2f]",m_Parent->GetName(),VPUSH(m_Vertices[m_Faces[f_i].pv[k].pindex])); #ifdef _EDITOR if(parent_xform) @@ -165,342 +189,370 @@ void CEditableMesh::GenerateVNormals(const Fmatrix* parent_xform) } #endif - N.set (m_FaceNormals[a_lst.front()]); - } - } - } + N.set(m_FaceNormals[a_lst.front()]); + } + } + } - UnloadFNormals (); - UnloadAdjacency (); + UnloadFNormals(); + UnloadAdjacency(); } + /* void CEditableMesh::GenerateVNormals(const Fmatrix* parent_xform) { - m_VNormalsRefs++; + m_VNormalsRefs++; if (m_VertexNormals) return; - m_VertexNormals = xr_alloc(m_FaceCount*3); - - // gen req - GenerateFNormals (); - GenerateAdjacency (); - - // vertex normals - if (m_Flags.is(flSGMask)) - { - for (u32 f_i=0; f_i(m_FaceCount*3); + + // gen req + GenerateFNormals (); + GenerateAdjacency (); + + // vertex normals + if (m_Flags.is(flSGMask)) + { + for (u32 f_i=0; f_i > iterate_adj ; - iterate_adj::recurse_tri_params p( N, m_SmoothGroups, m_FaceNormals, a_lst, m_Faces, m_FaceCount ); - iterate_adj::RecurseTri( 0, p ); + typedef itterate_adjacents< itterate_adjacents_params_dynamic > iterate_adj ; + iterate_adj::recurse_tri_params p( N, m_SmoothGroups, m_FaceNormals, a_lst, m_Faces, m_FaceCount ); + iterate_adj::RecurseTri( 0, p ); // - if (sg) - { - N.set (0,0,0); - - VERIFY(a_lst.size()); - for (IntIt i_it=a_lst.begin(); i_it!=a_lst.end(); i_it++) - if (sg&m_SmoothGroups[*i_it]) - N.add (m_FaceNormals[*i_it]); + if (sg) + { + N.set (0,0,0); + + VERIFY(a_lst.size()); + for (IntIt i_it=a_lst.begin(); i_it!=a_lst.end(); i_it++) + if (sg&m_SmoothGroups[*i_it]) + N.add (m_FaceNormals[*i_it]); float len = N.magnitude(); if (len>EPS_S) - { - N.div (len); + { + N.div (len); }else - { + { //. Msg ("!Invalid smooth group found (MAX type). Object: '%s'. Vertex: [%3.2f, %3.2f, %3.2f]",m_Parent->GetName(),VPUSH(m_Vertices[m_Faces[f_i].pv[k].pindex])); #ifdef _EDITOR - Fvector p0; + Fvector p0; p0 = m_Vertices[m_Faces[f_i].pv[k].pindex]; Tools->m_DebugDraw.AppendPoint(p0, 0xffff0000, true, true, "invalid vNORMAL"); #endif N.set (m_FaceNormals[a_lst.front()]); } - }else - { - N.set (FN); - } - } - } - }else{ - for (u32 f_i=0; f_i > iterate_adj ; - iterate_adj::recurse_tri_params p( N, m_SmoothGroups, m_FaceNormals, a_lst, m_Faces, m_FaceCount ); - iterate_adj::RecurseTri( 0, p ); + typedef itterate_adjacents< itterate_adjacents_params_dynamic > iterate_adj ; + iterate_adj::recurse_tri_params p( N, m_SmoothGroups, m_FaceNormals, a_lst, m_Faces, m_FaceCount ); + iterate_adj::RecurseTri( 0, p ); // - VERIFY (a_lst.size()); - for (IntIt i_it=a_lst.begin(); i_it!=a_lst.end(); i_it++) - { - if (sg != m_SmoothGroups[*i_it]) - continue; - N.add (m_FaceNormals[*i_it]); - } + VERIFY (a_lst.size()); + for (IntIt i_it=a_lst.begin(); i_it!=a_lst.end(); i_it++) + { + if (sg != m_SmoothGroups[*i_it]) + continue; + N.add (m_FaceNormals[*i_it]); + } float len = N.magnitude(); if (len>EPS_S) - { - N.div (len); + { + N.div (len); }else - { + { //. Msg ("!Invalid smooth group found (Maya type). Object: '%s'. Vertex: [%3.2f, %3.2f, %3.2f]",m_Parent->GetName(),VPUSH(m_Vertices[m_Faces[f_i].pv[k].pindex])); #ifdef _EDITOR - if(parent_xform) + if(parent_xform) { - Fvector p0; - parent_xform->transform_tiny(p0, m_Vertices[m_Faces[f_i].pv[k].pindex]); + Fvector p0; + parent_xform->transform_tiny(p0, m_Vertices[m_Faces[f_i].pv[k].pindex]); Tools->m_DebugDraw.AppendPoint(p0, 0xffff0000, true, true, "invalid vNORMAL"); } #endif N.set (m_FaceNormals[a_lst.front()]); } - } - else - { - N.set (FN); + } + else + { + N.set (FN); - //IntVec& a_lst=(*m_Adjs)[m_Faces[f_i].pv[k].pindex]; - //VERIFY(a_lst.size()); - //for (IntIt i_it=a_lst.begin(); i_it!=a_lst.end(); i_it++) - // N.add (m_FNormals[*i_it]); + //IntVec& a_lst=(*m_Adjs)[m_Faces[f_i].pv[k].pindex]; + //VERIFY(a_lst.size()); + //for (IntIt i_it=a_lst.begin(); i_it!=a_lst.end(); i_it++) + // N.add (m_FNormals[*i_it]); // float len = N.magnitude(); // if (len>EPS_S){ - // N.div (len); + // N.div (len); // }else{ // Msg ("!Invalid smooth group found (No smooth). Object: '%s'. Vertex: [%3.2f, %3.2f, %3.2f]",m_Parent->GetName(),VPUSH(m_Verts[m_Faces[f_i].pv[k].pindex])); // N.set (m_FNormals[a_lst.front()]); // } - } - } - } - } + } + } + } + } UnloadFNormals (); UnloadAdjacency (); } */ void CEditableMesh::GenerateSVertices(u32 influence) { - if (!m_Parent->IsSkeleton())return; + if (!m_Parent->IsSkeleton()) + return; m_SVertRefs++; - if (m_SVertInfl!=influence) UnloadSVertices(true); - if (m_SVertices) return; - m_SVertices = xr_alloc(m_FaceCount*3); - m_SVertInfl = influence; - -// CSMotion* active_motion=m_Parent->ResetSAnimation(); + if (m_SVertInfl!=influence) + UnloadSVertices(true); + if (m_SVertices) + return; + m_SVertices = xr_alloc(m_FaceCount*3); + m_SVertInfl = influence; + + // CSMotion* active_motion=m_Parent->ResetSAnimation(); m_Parent->CalculateAnimation(0); // generate normals - GenerateFNormals (); - GenerateVNormals (0); + GenerateFNormals(); + GenerateVNormals(0); - for (u32 f_id=0; f_idGetBoneIndexByWMap(VM.name.c_str()),VM.getW(vmpt_lst.pts[vmpt_id].index))); + wb.push_back(st_WB(m_Parent->GetBoneIndexByWMap(VM.name.c_str()), VM.getW(vmpt_lst.pts[vmpt_id].index))); if (wb.back().bone==BI_NONE) { - ELog.DlgMsg (mtError,"Can't find bone assigned to weight map %s",*VM.name); - FATAL ("Editor crashed."); + ELog.DlgMsg(mtError, "Can't find bone assigned to weight map %s", *VM.name); + FATAL("Editor crashed."); return; } - }else if(VM.type==vmtUV) - SV.uv.set (VM.getUV(vmpt_lst.pts[vmpt_id].index)); + } + else if (VM.type==vmtUV) + SV.uv.set(VM.getUV(vmpt_lst.pts[vmpt_id].index)); } VERIFY(m_SVertInfl<=4); - + wb.prepare_weights(m_SVertInfl); - SV.offs = P; - SV.norm = N; + SV.offs = P; + SV.norm = N; SV.bones.resize(wb.size()); - for (u8 k=0; k<(u8)SV.bones.size(); k++) - { - SV.bones[k].id = wb[k].bone; - SV.bones[k].w = wb[k].weight; - } + for (u8 k = 0; k<(u8)SV.bones.size(); k++) + { + SV.bones[k].id = wb[k].bone; + SV.bones[k].w = wb[k].weight; + } } - } + } // restore active motion - UnloadFNormals (); - UnloadVNormals (); + UnloadFNormals(); + UnloadVNormals(); } void CEditableMesh::GenerateAdjacency() { - m_AdjsRefs++; - if (m_Adjs) return; - m_Adjs = xr_new(); - VERIFY (m_Faces); - m_Adjs->resize (m_VertCount); -//. Log (".. Update adjacency"); - for (u32 f_id=0; f_id(); + VERIFY(m_Faces); + m_Adjs->resize(m_VertCount); + //. Log (".. Update adjacency"); + for (u32 f_id = 0; f_idsecond; - IntIt f_it = std::lower_bound(face_lst.begin(),face_lst.end(),(int)fid); - if ((f_it!=face_lst.end())&&(*f_it==(int)fid)) return sp_it->first; -//. if (std::find(face_lst.begin(),face_lst.end(),fid)!=face_lst.end()) return sp_it->first; - } + R_ASSERT(fidsecond; + IntIt f_it = std::lower_bound(face_lst.begin(), face_lst.end(), (int)fid); + if ((f_it!=face_lst.end())&&(*f_it==(int)fid)) + return sp_it->first; + //. if (std::find(face_lst.begin(),face_lst.end(),fid)!=face_lst.end()) return sp_it->first; + } return 0; } -void CEditableMesh::GetFaceTC(u32 fid, const Fvector2* tc[3]) +void CEditableMesh::GetFaceTC(u32 fid, const Fvector2 *tc[3]) { - R_ASSERT(fidgetUV(vmr.index)); + R_ASSERT(fidgetUV(vmr.index)); } } -void CEditableMesh::GetFacePT(u32 fid, const Fvector* pt[3]) +void CEditableMesh::GetFacePT(u32 fid, const Fvector *pt[3]) { - R_ASSERT(fidfirst; - if(S->m_GameMtlName=="materials\\occ" && bIgnoreOCC) - continue; - - if (bMatch2Sided){ - if (S->m_Flags.is(CSurface::sf2Sided)) - f_cnt+=sp_it->second.size()*2; - else - f_cnt+=sp_it->second.size(); - }else{ - f_cnt+=sp_it->second.size(); + CSurface*S = sp_it->first; + if (S->m_GameMtlName=="materials\\occ"&&bIgnoreOCC) + continue; + + if (bMatch2Sided) + { + if (S->m_Flags.is(CSurface::sf2Sided)) + f_cnt += sp_it->second.size()*2; + else + f_cnt += sp_it->second.size(); + } + else + { + f_cnt += sp_it->second.size(); } - } + } return f_cnt; } -float CEditableMesh::CalculateSurfaceArea(CSurface* surf, bool bMatch2Sided) +float CEditableMesh::CalculateSurfaceArea(CSurface *surf, bool bMatch2Sided) { - SurfFacesPairIt sp_it = m_SurfFaces.find(surf); - if (sp_it==m_SurfFaces.end()) return 0; - float area = 0; - IntVec& pol_lst = sp_it->second; - for (int k=0; ksecond; + for (int k = 0; kfirst->m_Flags.is(CSurface::sf2Sided)) area*=2; + if (bMatch2Sided&&sp_it->first->m_Flags.is(CSurface::sf2Sided)) + area *= 2; return area; } -float CEditableMesh::CalculateSurfacePixelArea (CSurface* surf, bool bMatch2Sided) +float CEditableMesh::CalculateSurfacePixelArea(CSurface *surf, bool bMatch2Sided) { - SurfFacesPairIt sp_it = m_SurfFaces.find(surf); - if (sp_it==m_SurfFaces.end()) return 0; - float area = 0; - IntVec& pol_lst = sp_it->second; - for (int k=0; kx,tc[1]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0)); - e02.sub (Fvector().set(tc[2]->x,tc[2]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0)); - area += c.crossproduct(e01,e02).magnitude()/2.f; + SurfFacesPairIt sp_it = m_SurfFaces.find(surf); + if (sp_it==m_SurfFaces.end()) + return 0; + float area = 0; + IntVec &pol_lst = sp_it->second; + for (int k = 0; kx, tc[1]->y, 0), Fvector().set(tc[0]->x, tc[0]->y, 0)); + e02.sub(Fvector().set(tc[2]->x, tc[2]->y, 0), Fvector().set(tc[0]->x, tc[0]->y, 0)); + area += c.crossproduct(e01, e02).magnitude()/2.f; } - if (bMatch2Sided&&sp_it->first->m_Flags.is(CSurface::sf2Sided)) area*=2; + if (bMatch2Sided&&sp_it->first->m_Flags.is(CSurface::sf2Sided)) + area *= 2; return area; } -int CEditableMesh::GetSurfFaceCount(CSurface* surf, bool bMatch2Sided) +int CEditableMesh::GetSurfFaceCount(CSurface *surf, bool bMatch2Sided) { - SurfFacesPairIt sp_it = m_SurfFaces.find(surf); - if (sp_it==m_SurfFaces.end()) return 0; - int f_cnt = sp_it->second.size(); - if (bMatch2Sided&&sp_it->first->m_Flags.is(CSurface::sf2Sided)) f_cnt*=2; + SurfFacesPairIt sp_it = m_SurfFaces.find(surf); + if (sp_it==m_SurfFaces.end()) + return 0; + int f_cnt = sp_it->second.size(); + if (bMatch2Sided&&sp_it->first->m_Flags.is(CSurface::sf2Sided)) + f_cnt *= 2; return f_cnt; } -void CEditableMesh::DumpAdjacency(){ - Log("Adjacency dump."); - Log("------------------------------------------------------------------------"); -/* for (u32 i=0; itype==t)&&(stricmp((*vm_it)->name.c_str(),name)==0)&&(polymap==(*vm_it)->polymap)) return vm_it-vmaps.begin(); - } - return -1; + for (VMapIt vm_it = vmaps.begin(); vm_it!=vmaps.end(); vm_it++) + { + if (((*vm_it)->type==t)&&(stricmp((*vm_it)->name.c_str(), name)==0)&&(polymap==(*vm_it)->polymap)) + return vm_it-vmaps.begin(); + } + return -1; } + //---------------------------------------------------------------------------- bool CEditableMesh::Validate() { - return true; + return true; } + //---------------------------------------------------------------------------- + diff --git a/src/editors/ECore/Editor/EditMesh.h b/src/editors/ECore/Editor/EditMesh.h index 0f195e7b5f5..fb894f22591 100644 --- a/src/editors/ECore/Editor/EditMesh.h +++ b/src/editors/ECore/Editor/EditMesh.h @@ -6,12 +6,12 @@ //---------------------------------------------------- // refs -class CSurface; -struct SRayPickInfo; +class CSurface; +struct SRayPickInfo; //struct CFrustum; -struct FSChunkDef; -class CExporter; -class CCustomObject; +struct FSChunkDef; +class CExporter; +class CCustomObject; #ifdef _EDITOR # include "pick_defs.h" @@ -20,160 +20,167 @@ class CCustomObject; #include "xrCore/Animation/Bone.hpp" #pragma pack( push,1 ) -const u8 vmtUV = 0; -const u8 vmtWeight = 1; - -struct ECORE_API st_WB{ - u16 bone; - float weight; - st_WB ():bone(BI_NONE),weight(0.f){;} - st_WB (u16 b, float w):bone(b),weight(w){;} - void set (u16 b, float w){bone=b;weight=w;} +const u8 vmtUV = 0; +const u8 vmtWeight = 1; + +struct ECORE_API st_WB{ + u16 bone; + float weight; + st_WB():bone(BI_NONE),weight(0.f){;} + st_WB(u16 b, float w):bone(b),weight(w){;} + void set(u16 b, float w){bone = b;weight = w;} }; -DEFINE_VECTOR(st_WB,WBVec,WBIt); -struct ECORE_API st_VertexWB:public WBVec{ -protected: - static bool compare_by_weight(const st_WB& a, const st_WB& b) - { - return a.weight > b.weight; // îòñîðòèðîâàòü ïî óáûâàíèþ - } - static bool compare_by_bone(const st_WB& a, const st_WB& b) - { - return a.bone < b.bone; // îòñîðòèðîâàòü ïî âîçðàñòàíèþ - } +DEFINE_VECTOR(st_WB, WBVec, WBIt); + +struct ECORE_API st_VertexWB: + +public +WBVec +{ + protected: + static bool compare_by_weight(const st_WB& a, const st_WB& b) + { + return a.weight > b.weight; // îòñîðòèðîâàòü ïî óáûâàíèþ +} +static bool compare_by_bone(const st_WB& a, const st_WB& b) +{ + return a.bone < b.bone; // îòñîðòèðîâàòü ïî âîçðàñòàíèþ +} public: - void sort_by_bone() - { - std::sort(begin(),end(),compare_by_bone); - } - void sort_by_weight() - { - std::sort(begin(),end(),compare_by_weight); - } - void prepare_weights(u32 max_influence) - { - sort_by_weight (); - // delete >max_influence weights - if (size()>max_influence) erase(begin()+max_influence,end()); - // accumulate weights - float sum_weight=0; - WBIt it; - for (it=begin(); it!=end(); it++) sum_weight+=it->weight; - // normalize weights - for (it=begin(); it!=end(); it++) it->weight/=sum_weight; -// sort_by_bone (); // need only for export (before add vertex sort_by_bone) - } +void sort_by_bone() +{ + std::sort(begin(),end(),compare_by_bone); +} +void sort_by_weight() +{ + std::sort(begin(),end(),compare_by_weight); +} +void prepare_weights(u32 max_influence) +{ + sort_by_weight (); + // delete >max_influence weights + if (size()>max_influence) erase(begin()+max_influence,end()); + // accumulate weights + float sum_weight=0; + WBIt it; + for (it=begin(); it!=end(); it++) sum_weight+=it->weight; + // normalize weights + for (it=begin(); it!=end(); it++) it->weight/=sum_weight; + // sort_by_bone (); // need only for export (before add vertex sort_by_bone) +} }; -DEFINE_VECTOR(st_VertexWB,VWBVec,VWBIt); +DEFINE_VECTOR(st_VertexWB, VWBVec, VWBIt); struct ECORE_API st_VMapPt{ - int vmap_index; // ññûëêà íà ìàïó - int index; // èíäåêñ â V-ìàïå íà uv/w - st_VMapPt(){vmap_index=-1;index=-1;} + int vmap_index; // ññûëêà íà ìàïó + int index; // èíäåêñ â V-ìàïå íà uv/w + st_VMapPt(){vmap_index = -1;index = -1;} }; // uv's class ECORE_API st_VMap{ - FloatVec vm; // u,v - êîîðäèíàòû èëè weight -public: - shared_str name; // vertex uv map name + FloatVec vm; // u,v - êîîðäèíàòû èëè weight + public: + shared_str name; // vertex uv map name struct{ - u8 type :2; - u8 polymap :1; - u8 dim :2; - u8 reserved:3; + u8 type:2; + u8 polymap:1; + u8 dim:2; + u8 reserved:3; }; - IntVec vindices; - IntVec pindices; -public: - st_VMap (LPCSTR nm=0, u8 t=vmtUV, bool pm=false) + IntVec vindices; + IntVec pindices; + public: + st_VMap(LPCSTR nm = 0, u8 t = vmtUV, bool pm = false) { - type = t; - polymap = pm; - name = nm; - if (t==vmtUV) dim=2; else dim=1; - } - IC const Fvector2& getUV (int idx) const {VERIFY(type==vmtUV); return (Fvector2&)vm[idx*dim];} - IC Fvector2& getUV (int idx) {VERIFY(type==vmtUV); return (Fvector2&)vm[idx*dim];} - IC const float& getW (int idx) const {VERIFY(type==vmtWeight); return vm[idx];} - IC const FloatVec& getVM () const {return vm;} - IC float* getVMdata () {return &*vm.begin();} - IC float* getVMdata (int start) {return &*(vm.begin()+start*dim);} - IC int VMdatasize () {return vm.size()*sizeof(float);} - IC int* getVIdata () {return &*vindices.begin();} - IC int VIdatasize () {return vindices.size()*sizeof(int);} - IC int* getPIdata () {return &*pindices.begin();} - IC int PIdatasize () {return pindices.size()*sizeof(int);} - IC int size () {return vm.size()/dim;} - IC void resize (int cnt) {vm.resize(cnt*dim);vindices.resize(cnt);if (polymap) pindices.resize(cnt); } - IC void appendUV (const float u, const float v) {vm.push_back(u);vm.push_back(v);} - IC void appendUV (const Fvector2& uv) {appendUV(uv.x,uv.y);} - IC void appendW (const float w) {vm.push_back(w);} - IC void appendVI (const int vi) {vindices.push_back(vi);} - IC void appendPI (const int pi) {VERIFY(polymap); pindices.push_back(pi);} - IC void copyfrom (float* src, int cnt) {resize(cnt); CopyMemory(&*vm.begin(),src,cnt*dim*4);} + type = t; + polymap = pm; + name = nm; + if (t==vmtUV) dim = 2;else dim = 1; + } + IC const Fvector2&getUV(int idx) const{VERIFY(type==vmtUV);return (Fvector2&)vm[idx*dim];} + IC Fvector2&getUV(int idx){VERIFY(type==vmtUV);return (Fvector2&)vm[idx*dim];} + IC const float& getW(int idx) const{VERIFY(type==vmtWeight);return vm[idx];} + IC const FloatVec&getVM() const{return vm;} + IC float* getVMdata(){return &*vm.begin();} + IC float* getVMdata(int start){return &*(vm.begin()+start*dim);} + IC int VMdatasize(){return vm.size()*sizeof(float);} + IC int* getVIdata(){return &*vindices.begin();} + IC int VIdatasize(){return vindices.size()*sizeof(int);} + IC int* getPIdata(){return &*pindices.begin();} + IC int PIdatasize(){return pindices.size()*sizeof(int);} + IC int size(){return vm.size()/dim;} + IC void resize(int cnt){vm.resize(cnt*dim);vindices.resize(cnt);if (polymap) pindices.resize(cnt);} + IC void appendUV(const float u, const float v){vm.push_back(u);vm.push_back(v);} + IC void appendUV(const Fvector2&uv){appendUV(uv.x, uv.y);} + IC void appendW(const float w){vm.push_back(w);} + IC void appendVI(const int vi){vindices.push_back(vi);} + IC void appendPI(const int pi){VERIFY(polymap); pindices.push_back(pi);} + IC void copyfrom(float* src, int cnt){resize(cnt); CopyMemory(&*vm.begin(), src, cnt*dim*4);} }; -struct st_VMapPtLst{ - u8 count; - st_VMapPt* pts; +struct st_VMapPtLst +{ + u8 count; + st_VMapPt *pts; }; -DEFINE_VECTOR (st_VMapPtLst,VMRefsVec,VMRefsIt); + +DEFINE_VECTOR(st_VMapPtLst, VMRefsVec, VMRefsIt); struct ECORE_API st_SVert{ - Fvector offs; - Fvector norm; - Fvector2 uv; + Fvector offs; + Fvector norm; + Fvector2 uv; struct bone{ - public: - float w; - u16 id; - bone (){w=0.f;id=BI_NONE;} - bool similar (const bone& b){return (id==b.id) && fsimilar(w,b.w,EPS_L);} + public: + float w; + u16 id; + bone(){w = 0.f;id = BI_NONE;} + bool similar(const bone&b){return (id==b.id)&&fsimilar(w, b.w, EPS_L);} }; - svector bones; + svectorbones; protected: - static bool compare_by_weight(const bone& a, const bone& b) - { - return a.w > b.w; // îòñîðòèðîâàòü ïî óáûâàíèþ - } - static bool compare_by_bone(const bone& a, const bone& b) - { - return a.id < b.id; // îòñîðòèðîâàòü ïî âîçðàñòàíèþ - } + static bool compare_by_weight(const bone&a, const bone&b) + { + return a.w>b.w; // îòñîðòèðîâàòü ïî óáûâàíèþ + } + static bool compare_by_bone(const bone&a, const bone&b) + { + return a.id v.pindex; } - bool eq( const st_FaceVert &v ) const { return pindex == v.pindex; } + typedef st_Face type_face; + int pindex; // point index in PointList + int vmref; // vm-ref index + bool gt(const st_FaceVert&v) const{return pindex>v.pindex;} + bool eq(const st_FaceVert&v) const{return pindex==v.pindex;} }; struct ECORE_API st_Face{ - st_FaceVert pv[3]; // face vertices (P->P...) - void EdgeVerts( u8 e, st_FaceVert &v0, st_FaceVert &v1 ) const - { - VERIFY( e< 3 ); - v0 = pv[ e ]; - v1 = pv[ (e+1)%3 ]; - } + st_FaceVert pv[3]; // face vertices (P->P...) + void EdgeVerts(u8 e, st_FaceVert&v0, st_FaceVert&v1) const + { + VERIFY(e<3); + v0 = pv[e]; + v1 = pv[(e+1)%3]; + } }; // mesh options struct ECORE_API st_MeshOptions{ - int m_Reserved0; - int m_Reserved1; - st_MeshOptions (){m_Reserved0=0;m_Reserved1=0;} + int m_Reserved0; + int m_Reserved1; + st_MeshOptions(){m_Reserved0 = 0;m_Reserved1 = 0;} }; #pragma pack( pop ) -DEFINE_VECTOR (IntVec,AdjVec,AdjIt); -DEFINE_VECTOR (st_VMap*,VMapVec,VMapIt); -DEFINE_MAP (CSurface*,IntVec,SurfFaces,SurfFacesPairIt); +DEFINE_VECTOR(IntVec, AdjVec, AdjIt); +DEFINE_VECTOR(st_VMap *, VMapVec, VMapIt); +DEFINE_MAP(CSurface *, IntVec, SurfFaces, SurfFacesPairIt); //refs struct st_RenderBuffer; @@ -191,130 +198,130 @@ class CSector; DEFINE_MAP(CSurface*,RBVector,RBMap,RBMapPairIt); #endif -class ECORE_API CEditableMesh { - friend class MeshExpUtility; - friend class CEditableObject; - friend class CSectorItem; - friend class CSector; - friend class CPortalUtils; - friend class SceneBuilder; - friend class CExportSkeleton; - friend class CExportObjectOGF; - friend class TfrmEditLibrary; - friend class CExporter; - friend class CXRayObjectExport; - friend class CXRaySkinExport; - - shared_str m_Name; - - CEditableObject* m_Parent; - - void GenerateCFModel (); - void GenerateRenderBuffers(); - void UnloadCForm (); +class ECORE_API CEditableMesh{ + friendclass MeshExpUtility; + friendclass CEditableObject; + friendclass CSectorItem; + friendclass CSector; + friendclass CPortalUtils; + friendclass SceneBuilder; + friendclass CExportSkeleton; + friendclass CExportObjectOGF; + friendclass TfrmEditLibrary; + friendclass CExporter; + friendclass CXRayObjectExport; + friendclass CXRaySkinExport; + + shared_str m_Name; + + CEditableObject*m_Parent; + + void GenerateCFModel(); + void GenerateRenderBuffers(); + void UnloadCForm(); #ifdef _EDITOR void UnloadRenderBuffers (); #endif -public: - static BOOL m_bDraftMeshMode; - void GenerateFNormals (); - void GenerateVNormals (const Fmatrix* parent_xform); - void GenerateSVertices (u32 influence); - void GenerateAdjacency (); - - bool IsGeneratedSVertices(u32 influence) {return (m_SVertices && (m_SVertInfl==influence));} - - void UnloadFNormals (bool force=false); - void UnloadVNormals (bool force=false); - void UnloadSVertices (bool force=false); - void UnloadAdjacency (bool force=false); -IC Fvector* Vertices () { return m_Vertices; } // -IC st_Face* Faces () { return m_Faces; } // + some array size!!! -IC SurfFaces &Surfaces () { return m_SurfFaces; } -private: + public: + static BOOL m_bDraftMeshMode; + void GenerateFNormals(); + void GenerateVNormals(const Fmatrix*parent_xform); + void GenerateSVertices(u32 influence); + void GenerateAdjacency(); + + bool IsGeneratedSVertices(u32 influence){return (m_SVertices&&(m_SVertInfl==influence));} + + void UnloadFNormals(bool force = false); + void UnloadVNormals(bool force = false); + void UnloadSVertices(bool force = false); + void UnloadAdjacency(bool force = false); + IC Fvector*Vertices(){return m_Vertices;} // + IC st_Face*Faces(){return m_Faces;} // + some array size!!! + IC SurfFaces&Surfaces(){return m_SurfFaces;} + private: // internal variables - enum{ - flVisible = (1<<0), - flLocked = (1<<1), - flSGMask = (1<<2), - }; - Flags8 m_Flags; -public: - st_MeshOptions m_Ops; -protected: - Fbox m_Box; - - int m_FNormalsRefs; - int m_VNormalsRefs; - int m_AdjsRefs; - int m_SVertRefs; - - u32 m_SVertInfl; - - u32 m_VertCount; - u32 m_FaceCount; - - Fvector* m_Vertices; // | - AdjVec* m_Adjs; // + some array size!!! - u32* m_SmoothGroups; // | - Fvector* m_FaceNormals; // | - Fvector* m_VertexNormals; // | *3 - st_SVert* m_SVertices;// | *3 - st_Face* m_Faces; // + some array size!!! - SurfFaces m_SurfFaces; - VMapVec m_VMaps; - VMRefsVec m_VMRefs; + enum{ + flVisible = (1<<0), + flLocked = (1<<1), + flSGMask = (1<<2), + }; + Flags8 m_Flags; + public: + st_MeshOptions m_Ops; + protected: + Fbox m_Box; + + int m_FNormalsRefs; + int m_VNormalsRefs; + int m_AdjsRefs; + int m_SVertRefs; + + u32 m_SVertInfl; + + u32 m_VertCount; + u32 m_FaceCount; + + Fvector*m_Vertices; // | + AdjVec*m_Adjs; // + some array size!!! + u32*m_SmoothGroups; // | + Fvector*m_FaceNormals; // | + Fvector*m_VertexNormals; // | *3 + st_SVert*m_SVertices;// | *3 + st_Face*m_Faces; // + some array size!!! + SurfFaces m_SurfFaces; + VMapVec m_VMaps; + VMRefsVec m_VMRefs; #ifdef _EDITOR CDB::MODEL* m_CFModel; RBMap* m_RenderBuffers; #endif - void FillRenderBuffer (IntVec& face_lst, int start_face, int num_face, const CSurface* surf, LPBYTE& data); + void FillRenderBuffer(IntVec&face_lst, int start_face, int num_face, const CSurface*surf, LPBYTE&data); - void RecurseTri (int id); + void RecurseTri(int id); - // mesh optimize routine - bool OptimizeFace (st_Face& face); -public: - void RecomputeBBox (); - void OptimizeMesh (BOOL NoOpt); -public: - CEditableMesh (CEditableObject* parent){m_Parent=parent;Construct();} - CEditableMesh (CEditableMesh* source,CEditableObject* parent){m_Parent=parent;Construct();CloneFrom(source);} - virtual ~CEditableMesh (); - void Construct (); - void Clear (); - - IC void SetName (LPCSTR name){m_Name=name;} - IC shared_str Name (){return m_Name;} - void GetBox (Fbox& box){box.set(m_Box);} - CSurface* GetSurfaceByFaceID (u32 fid); - void GetFaceTC (u32 fid, const Fvector2* tc[3]); - void GetFacePT (u32 fid, const Fvector* pt[3]); - IC BOOL Visible (){return m_Flags.is(flVisible); } - IC void Show (BOOL bVisible){m_Flags.set(flVisible,bVisible);} + // mesh optimize routine + bool OptimizeFace(st_Face&face); + public: + void RecomputeBBox(); + void OptimizeMesh(BOOL NoOpt); + public: + CEditableMesh(CEditableObject*parent){m_Parent = parent;Construct();} + CEditableMesh(CEditableMesh*source, CEditableObject*parent){m_Parent = parent;Construct();CloneFrom(source);} + virtual ~CEditableMesh(); + void Construct(); + void Clear(); + + IC void SetName(LPCSTR name){m_Name = name;} + IC shared_str Name(){return m_Name;} + void GetBox(Fbox&box){box.set(m_Box);} + CSurface*GetSurfaceByFaceID(u32 fid); + void GetFaceTC(u32 fid, const Fvector2*tc[3]); + void GetFacePT(u32 fid, const Fvector*pt[3]); + IC BOOL Visible(){return m_Flags.is(flVisible);} + IC void Show(BOOL bVisible){m_Flags.set(flVisible, bVisible);} // mesh modify routine - void CloneFrom (CEditableMesh *source); - void Transform (const Fmatrix& parent); - - IC CEditableObject* Parent (){ return m_Parent; } - IC u32 GetFCount (){ return m_FaceCount; } - IC const st_Face* GetFaces (){ return m_Faces; } - IC const u32* GetSmoothGroups (){ return m_SmoothGroups; } - IC const Fvector* GetVertices (){ return m_Vertices; } - IC u32 GetVCount (){ return m_VertCount; } - IC const VMapVec& GetVMaps (){ return m_VMaps; } - IC const VMRefsVec& GetVMRefs (){ return m_VMRefs; } - IC const SurfFaces& GetSurfFaces (){ return m_SurfFaces; } - IC const Fvector* GetFNormals (){ VERIFY(0!=m_FaceNormals); return m_FaceNormals; } - IC const Fvector* GetVNormals (){ VERIFY(0!=m_VertexNormals); return m_VertexNormals; } - IC const st_SVert* GetSVertices (){ VERIFY(0!=m_SVertices);return m_SVertices; } - + void CloneFrom(CEditableMesh*source); + void Transform(const Fmatrix&parent); + + IC CEditableObject*Parent(){return m_Parent;} + IC u32 GetFCount(){return m_FaceCount;} + IC const st_Face*GetFaces(){return m_Faces;} + IC const u32*GetSmoothGroups(){return m_SmoothGroups;} + IC const Fvector*GetVertices(){return m_Vertices;} + IC u32 GetVCount(){return m_VertCount;} + IC const VMapVec&GetVMaps(){return m_VMaps;} + IC const VMRefsVec&GetVMRefs(){return m_VMRefs;} + IC const SurfFaces&GetSurfFaces(){return m_SurfFaces;} + IC const Fvector*GetFNormals(){VERIFY(0!=m_FaceNormals);return m_FaceNormals;} + IC const Fvector*GetVNormals(){VERIFY(0!=m_VertexNormals);return m_VertexNormals;} + IC const st_SVert*GetSVertices(){VERIFY(0!=m_SVertices);return m_SVertices;} + // pick routine - bool RayPick (float& dist, const Fvector& start, const Fvector& dir, const Fmatrix& inv_parent, SRayPickInfo* pinf = NULL); + bool RayPick(float& dist, const Fvector&start, const Fvector&dir, const Fmatrix&inv_parent, SRayPickInfo*pinf = NULL); #ifdef _EDITOR void RayQuery (SPickQuery& pinf); void RayQuery (const Fmatrix& parent, const Fmatrix& inv_parent, SPickQuery& pinf); @@ -327,27 +334,27 @@ IC SurfFaces &Surfaces () { return m_SurfFaces; } #endif // render routine - void Render (const Fmatrix& parent, CSurface* S); - void RenderSkeleton (const Fmatrix& parent, CSurface* S); - void RenderList (const Fmatrix& parent, u32 color, bool bEdge, IntVec& fl); - void RenderSelection (const Fmatrix& parent, CSurface* s, u32 color); - void RenderEdge (const Fmatrix& parent, CSurface* s, u32 color); + void Render(const Fmatrix&parent, CSurface*S); + void RenderSkeleton(const Fmatrix&parent, CSurface*S); + void RenderList(const Fmatrix&parent, u32 color, bool bEdge, IntVec&fl); + void RenderSelection(const Fmatrix&parent, CSurface*s, u32 color); + void RenderEdge(const Fmatrix&parent, CSurface*s, u32 color); // statistics methods - int GetFaceCount (bool bMatch2Sided=true, bool bIgnoreOCC=true); - int GetVertexCount (){return m_VertCount;} - int GetSurfFaceCount (CSurface* surf, bool bMatch2Sided=true); - float CalculateSurfaceArea (CSurface* surf, bool bMatch2Sided); - float CalculateSurfacePixelArea(CSurface* surf, bool bMatch2Sided); + int GetFaceCount(bool bMatch2Sided = true, bool bIgnoreOCC = true); + int GetVertexCount(){return m_VertCount;} + int GetSurfFaceCount(CSurface*surf, bool bMatch2Sided = true); + float CalculateSurfaceArea(CSurface*surf, bool bMatch2Sided); + float CalculateSurfacePixelArea(CSurface*surf, bool bMatch2Sided); // IO - routine - void SaveMesh (IWriter&); - bool LoadMesh (IReader&); + void SaveMesh(IWriter&); + bool LoadMesh(IReader&); // debug - void DumpAdjacency (); + void DumpAdjacency(); - // convert + // convert #ifdef _MAX_EXPORT void FlipFaces (); TriObject* ExtractTriObject (INode *node, int &deleteIt); @@ -355,12 +362,12 @@ IC SurfFaces &Surfaces () { return m_SurfFaces; } bool Convert (CExporter* exporter); #endif - int FindSimilarUV (st_VMap* vmap, Fvector2& _uv); - int FindSimilarWeight (st_VMap* vmap, float _w); - int FindVMapByName (VMapVec& vmaps, const char* name, u8 t, bool polymap); - void RebuildVMaps (); + int FindSimilarUV(st_VMap*vmap, Fvector2&_uv); + int FindSimilarWeight(st_VMap*vmap, float _w); + int FindVMapByName(VMapVec&vmaps, const char* name, u8 t, bool polymap); + void RebuildVMaps(); - bool Validate (); + bool Validate(); }; //---------------------------------------------------- #endif /*_INCDEF_EditableMesh_H_*/ diff --git a/src/editors/ECore/Editor/EditMeshIO.cpp b/src/editors/ECore/Editor/EditMeshIO.cpp index a85748a2656..45c233a9ac2 100644 --- a/src/editors/ECore/Editor/EditMeshIO.cpp +++ b/src/editors/ECore/Editor/EditMeshIO.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------- // file: StaticMesh.cpp //---------------------------------------------------- - + #include "stdafx.h" #pragma hdrstop @@ -25,193 +25,203 @@ #define EMESH_CHUNK_VMAPS_2 0x1012 #define EMESH_CHUNK_SG 0x1013 -void CEditableMesh::SaveMesh(IWriter& F) +void CEditableMesh::SaveMesh(IWriter &F) { - F.open_chunk (EMESH_CHUNK_VERSION); - F.w_u16 (EMESH_CURRENT_VERSION); - F.close_chunk (); + F.open_chunk(EMESH_CHUNK_VERSION); + F.w_u16(EMESH_CURRENT_VERSION); + F.close_chunk(); - F.open_chunk (EMESH_CHUNK_MESHNAME); - F.w_stringZ (m_Name); - F.close_chunk (); + F.open_chunk(EMESH_CHUNK_MESHNAME); + F.w_stringZ(m_Name); + F.close_chunk(); - F.w_chunk (EMESH_CHUNK_BBOX,&m_Box, sizeof(m_Box)); - F.w_chunk (EMESH_CHUNK_FLAGS,&m_Flags,1); - F.w_chunk (EMESH_CHUNK_BOP,&m_Ops, sizeof(m_Ops)); + F.w_chunk(EMESH_CHUNK_BBOX, &m_Box, sizeof(m_Box)); + F.w_chunk(EMESH_CHUNK_FLAGS, &m_Flags, 1); + F.w_chunk(EMESH_CHUNK_BOP, &m_Ops, sizeof(m_Ops)); - F.open_chunk (EMESH_CHUNK_VERTS); - F.w_u32 (m_VertCount); - F.w (m_Vertices, m_VertCount*sizeof(Fvector)); + F.open_chunk(EMESH_CHUNK_VERTS); + F.w_u32(m_VertCount); + F.w(m_Vertices, m_VertCount*sizeof(Fvector)); - F.close_chunk (); + F.close_chunk(); - F.open_chunk (EMESH_CHUNK_FACES); - F.w_u32 (m_FaceCount); - F.w (m_Faces, m_FaceCount*sizeof(st_Face)); - F.close_chunk (); + F.open_chunk(EMESH_CHUNK_FACES); + F.w_u32(m_FaceCount); + F.w(m_Faces, m_FaceCount*sizeof(st_Face)); + F.close_chunk(); if (GetSmoothGroups()) { - F.open_chunk (EMESH_CHUNK_SG); - F.w (GetSmoothGroups(), m_FaceCount*sizeof(u32)); - F.close_chunk (); + F.open_chunk(EMESH_CHUNK_SG); + F.w(GetSmoothGroups(), m_FaceCount*sizeof(u32)); + F.close_chunk(); } - F.open_chunk (EMESH_CHUNK_VMREFS); - F.w_u32 (m_VMRefs.size()); - for (VMRefsIt r_it=m_VMRefs.begin(); r_it!=m_VMRefs.end(); r_it++) + F.open_chunk(EMESH_CHUNK_VMREFS); + F.w_u32(m_VMRefs.size()); + for (VMRefsIt r_it = m_VMRefs.begin(); r_it!=m_VMRefs.end(); r_it++) { - int sz = r_it->count; VERIFY(sz<=255); - F.w_u8 ((u8)sz); - F.w (r_it->pts, sizeof(st_VMapPt)*sz); + int sz = r_it->count; + VERIFY(sz<=255); + F.w_u8((u8)sz); + F.w(r_it->pts, sizeof(st_VMapPt)*sz); } - F.close_chunk (); + F.close_chunk(); - F.open_chunk (EMESH_CHUNK_SFACE); - F.w_u16 ((u16)m_SurfFaces.size()); /* surface polygon count*/ - for (SurfFacesPairIt plp_it=m_SurfFaces.begin(); plp_it!=m_SurfFaces.end(); plp_it++) + F.open_chunk(EMESH_CHUNK_SFACE); + F.w_u16((u16)m_SurfFaces.size()); /* surface polygon count*/ + for (SurfFacesPairIt plp_it = m_SurfFaces.begin(); plp_it!=m_SurfFaces.end(); plp_it++) { - F.w_stringZ (plp_it->first->_Name()); /* surface name*/ - IntVec& pol_lst = plp_it->second; - F.w_u32 (pol_lst.size()); /* surface-polygon indices*/ - F.w (&*pol_lst.begin(), sizeof(int)*pol_lst.size()); + F.w_stringZ(plp_it->first->_Name()); /* surface name*/ + IntVec &pol_lst = plp_it->second; + F.w_u32(pol_lst.size()); /* surface-polygon indices*/ + F.w(&*pol_lst.begin(), sizeof(int)*pol_lst.size()); } - F.close_chunk (); + F.close_chunk(); - F.open_chunk (EMESH_CHUNK_VMAPS_2); - F.w_u32 (m_VMaps.size()); - for (VMapIt vm_it=m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) + F.open_chunk(EMESH_CHUNK_VMAPS_2); + F.w_u32(m_VMaps.size()); + for (VMapIt vm_it = m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) { - F.w_stringZ ((*vm_it)->name); - F.w_u8 ((*vm_it)->dim); - F.w_u8 ((u8)(*vm_it)->polymap); - F.w_u8 ((*vm_it)->type); - F.w_u32 ((*vm_it)->size()); - F.w ((*vm_it)->getVMdata(), (*vm_it)->VMdatasize()); - F.w ((*vm_it)->getVIdata(), (*vm_it)->VIdatasize()); - if ((*vm_it)->polymap) - F.w ((*vm_it)->getPIdata(), (*vm_it)->PIdatasize()); + F.w_stringZ((*vm_it)->name); + F.w_u8((*vm_it)->dim); + F.w_u8((u8)(*vm_it)->polymap); + F.w_u8((*vm_it)->type); + F.w_u32((*vm_it)->size()); + F.w((*vm_it)->getVMdata(), (*vm_it)->VMdatasize()); + F.w((*vm_it)->getVIdata(), (*vm_it)->VIdatasize()); + if ((*vm_it)->polymap) + F.w((*vm_it)->getPIdata(), (*vm_it)->PIdatasize()); } - F.close_chunk (); + F.close_chunk(); } -bool CEditableMesh::LoadMesh(IReader& F){ - u32 version=0; +bool CEditableMesh::LoadMesh(IReader &F) +{ + u32 version = 0; - R_ASSERT(F.r_chunk(EMESH_CHUNK_VERSION,&version)); - if (version!=EMESH_CURRENT_VERSION){ - ELog.DlgMsg( mtError, "CEditableMesh: unsuported file version. Mesh can't load."); + R_ASSERT(F.r_chunk(EMESH_CHUNK_VERSION, &version)); + if (version!=EMESH_CURRENT_VERSION) + { + ELog.DlgMsg(mtError, "CEditableMesh: unsuported file version. Mesh can't load."); return false; } R_ASSERT(F.find_chunk(EMESH_CHUNK_MESHNAME)); - F.r_stringZ (m_Name); + F.r_stringZ(m_Name); - R_ASSERT(F.r_chunk(EMESH_CHUNK_BBOX,&m_Box)); - R_ASSERT(F.r_chunk(EMESH_CHUNK_FLAGS,&m_Flags)); - F.r_chunk(EMESH_CHUNK_BOP,&m_Ops); + R_ASSERT(F.r_chunk(EMESH_CHUNK_BBOX, &m_Box)); + R_ASSERT(F.r_chunk(EMESH_CHUNK_FLAGS, &m_Flags)); + F.r_chunk(EMESH_CHUNK_BOP, &m_Ops); R_ASSERT(F.find_chunk(EMESH_CHUNK_VERTS)); - m_VertCount = F.r_u32(); - if (m_VertCount<3){ - Log ("!CEditableMesh: Vertices<3."); - return false; + m_VertCount = F.r_u32(); + if (m_VertCount<3) + { + Log("!CEditableMesh: Vertices<3."); + return false; } - m_Vertices = xr_alloc(m_VertCount); - F.r (m_Vertices, m_VertCount*sizeof(Fvector)); + m_Vertices = xr_alloc(m_VertCount); + F.r(m_Vertices, m_VertCount*sizeof(Fvector)); R_ASSERT(F.find_chunk(EMESH_CHUNK_FACES)); - m_FaceCount = F.r_u32(); - m_Faces = xr_alloc(m_FaceCount); - if (m_FaceCount==0){ - Log ("!CEditableMesh: Faces==0."); - return false; + m_FaceCount = F.r_u32(); + m_Faces = xr_alloc(m_FaceCount); + if (m_FaceCount==0) + { + Log("!CEditableMesh: Faces==0."); + return false; } - F.r (m_Faces, m_FaceCount*sizeof(st_Face)); + F.r(m_Faces, m_FaceCount*sizeof(st_Face)); - m_SmoothGroups = xr_alloc(m_FaceCount); - Memory.mem_fill32 (m_SmoothGroups,m_Flags.is(flSGMask)?0:u32(-1),m_FaceCount); - u32 sg_chunk_size = F.find_chunk(EMESH_CHUNK_SG); - if (sg_chunk_size){ - VERIFY (m_FaceCount*sizeof(u32)==sg_chunk_size); - F.r (m_SmoothGroups, m_FaceCount*sizeof(u32)); - } + m_SmoothGroups = xr_alloc(m_FaceCount); + Memory.mem_fill32(m_SmoothGroups, m_Flags.is(flSGMask) ? 0 : u32(-1), m_FaceCount); + u32 sg_chunk_size = F.find_chunk(EMESH_CHUNK_SG); + if (sg_chunk_size) + { + VERIFY(m_FaceCount*sizeof(u32)==sg_chunk_size); + F.r(m_SmoothGroups, m_FaceCount*sizeof(u32)); + } R_ASSERT(F.find_chunk(EMESH_CHUNK_VMREFS)); - m_VMRefs.resize (F.r_u32()); - int sz_vmpt = sizeof(st_VMapPt); - for (VMRefsIt r_it=m_VMRefs.begin(); r_it!=m_VMRefs.end(); r_it++){ - r_it->count = F.r_u8(); - r_it->pts = xr_alloc(r_it->count); - F.r (r_it->pts, sz_vmpt*r_it->count); + m_VMRefs.resize(F.r_u32()); + int sz_vmpt = sizeof(st_VMapPt); + for (VMRefsIt r_it = m_VMRefs.begin(); r_it!=m_VMRefs.end(); r_it++) + { + r_it->count = F.r_u8(); + r_it->pts = xr_alloc(r_it->count); + F.r(r_it->pts, sz_vmpt*r_it->count); } R_ASSERT(F.find_chunk(EMESH_CHUNK_SFACE)); string128 surf_name; - u32 sface_cnt = F.r_u16(); // surface-face count - for (u32 sp_i=0; sp_iFindSurfaceByName(surf_name, &surf_id); VERIFY(surf); - IntVec& face_lst = m_SurfFaces[surf]; - face_lst.resize (F.r_u32()); + CSurface*surf = m_Parent->FindSurfaceByName(surf_name, &surf_id); + VERIFY(surf); + IntVec &face_lst = m_SurfFaces[surf]; + face_lst.resize(F.r_u32()); if (face_lst.empty()) { - Log ("!Empty surface found: %s",surf->_Name()); - return false; + Log("!Empty surface found: %s", surf->_Name()); + return false; } - F.r (&*face_lst.begin(), face_lst.size()*sizeof(int)); - std::sort (face_lst.begin(),face_lst.end()); + F.r(&*face_lst.begin(), face_lst.size()*sizeof(int)); + std::sort(face_lst.begin(), face_lst.end()); } - if(F.find_chunk(EMESH_CHUNK_VMAPS_2)) - { - m_VMaps.resize (F.r_u32()); - for (VMapIt vm_it=m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) + if (F.find_chunk(EMESH_CHUNK_VMAPS_2)) + { + m_VMaps.resize(F.r_u32()); + for (VMapIt vm_it = m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) { - *vm_it = xr_new(); - F.r_stringZ ((*vm_it)->name); - (*vm_it)->dim = F.r_u8(); - (*vm_it)->polymap=F.r_u8(); - (*vm_it)->type = F.r_u8(); - (*vm_it)->resize(F.r_u32()); - F.r ((*vm_it)->getVMdata(), (*vm_it)->VMdatasize()); - F.r ((*vm_it)->getVIdata(), (*vm_it)->VIdatasize()); - if ((*vm_it)->polymap) - F.r ((*vm_it)->getPIdata(), (*vm_it)->PIdatasize()); - } - }else - { - if(F.find_chunk(EMESH_CHUNK_VMAPS_1)) - { - m_VMaps.resize (F.r_u32()); - for (VMapIt vm_it=m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) - { - *vm_it = xr_new(); - F.r_stringZ ((*vm_it)->name); - (*vm_it)->dim = F.r_u8(); - (*vm_it)->type = F.r_u8(); - (*vm_it)->resize(F.r_u32()); - F.r ((*vm_it)->getVMdata(), (*vm_it)->VMdatasize() ); - } - }else - { - R_ASSERT(F.find_chunk(EMESH_CHUNK_VMAPS_0)); - m_VMaps.resize (F.r_u32()); - for (VMapIt vm_it=m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) - { - *vm_it = xr_new(); - F.r_stringZ ((*vm_it)->name); - (*vm_it)->dim = 2; - (*vm_it)->type = vmtUV; - (*vm_it)->resize(F.r_u32()); - F.r ((*vm_it)->getVMdata(), (*vm_it)->VMdatasize() ); - } - } - // update vmaps - RebuildVMaps(); - } + *vm_it = xr_new(); + F.r_stringZ((*vm_it)->name); + (*vm_it)->dim = F.r_u8(); + (*vm_it)->polymap = F.r_u8(); + (*vm_it)->type = F.r_u8(); + (*vm_it)->resize(F.r_u32()); + F.r((*vm_it)->getVMdata(), (*vm_it)->VMdatasize()); + F.r((*vm_it)->getVIdata(), (*vm_it)->VIdatasize()); + if ((*vm_it)->polymap) + F.r((*vm_it)->getPIdata(), (*vm_it)->PIdatasize()); + } + } + else + { + if (F.find_chunk(EMESH_CHUNK_VMAPS_1)) + { + m_VMaps.resize(F.r_u32()); + for (VMapIt vm_it = m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) + { + *vm_it = xr_new(); + F.r_stringZ((*vm_it)->name); + (*vm_it)->dim = F.r_u8(); + (*vm_it)->type = F.r_u8(); + (*vm_it)->resize(F.r_u32()); + F.r((*vm_it)->getVMdata(), (*vm_it)->VMdatasize()); + } + } + else + { + R_ASSERT(F.find_chunk(EMESH_CHUNK_VMAPS_0)); + m_VMaps.resize(F.r_u32()); + for (VMapIt vm_it = m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) + { + *vm_it = xr_new(); + F.r_stringZ((*vm_it)->name); + (*vm_it)->dim = 2; + (*vm_it)->type = vmtUV; + (*vm_it)->resize(F.r_u32()); + F.r((*vm_it)->getVMdata(), (*vm_it)->VMdatasize()); + } + } + // update vmaps + RebuildVMaps(); + } #ifdef _EDITOR if (!EPrefs->object_flags.is(epoDeffLoadRB)) @@ -228,10 +238,12 @@ bool CEditableMesh::LoadMesh(IReader& F){ if (!EPrefs->object_flags.is(epoDeffLoadCF)) GenerateCFModel(); #endif - OptimizeMesh (false); - RebuildVMaps (); + OptimizeMesh(false); + RebuildVMaps(); - return true; + return true; } + //---------------------------------------------------- + diff --git a/src/editors/ECore/Editor/EditMeshModify.cpp b/src/editors/ECore/Editor/EditMeshModify.cpp index 3c219037f40..08f22a327e4 100644 --- a/src/editors/ECore/Editor/EditMeshModify.cpp +++ b/src/editors/ECore/Editor/EditMeshModify.cpp @@ -7,312 +7,345 @@ #include "EditMesh.h" #include "EditObject.h" + //---------------------------------------------------- -void CEditableMesh::Transform(const Fmatrix& parent) +void CEditableMesh::Transform(const Fmatrix &parent) { - // transform position - for(u32 k=0; ksize(); - for (int k=0; kgetUV(k); - if (uv.similar(_uv)) - return k; - } - return -1; + int sz = vmap->size(); + for (int k = 0; kgetUV(k); + if (uv.similar(_uv)) + return k; + } + return -1; } -int CEditableMesh::FindSimilarWeight(st_VMap* vmap, float _w) +int CEditableMesh::FindSimilarWeight(st_VMap *vmap, float _w) { - int sz = vmap->size(); - for (int k=0; kgetW(k); - if (fsimilar(w,_w)) return k; - } - return -1; + int sz = vmap->size(); + for (int k = 0; kgetW(k); + if (fsimilar(w, _w)) + return k; + } + return -1; } void CEditableMesh::RebuildVMaps() { -//. Log ("Rebuilding VMaps..."); - IntVec m_VertVMap; - m_VertVMap.resize(m_VertCount,-1); - VMapVec nVMaps; - VMRefsVec nVMRefs; - // refs copy to new - { - nVMRefs.resize(m_VMRefs.size()); - for (VMRefsIt o_it=m_VMRefs.begin(),n_it=nVMRefs.begin(); o_it!=m_VMRefs.end(); o_it++,n_it++){ - n_it->count = o_it->count; - n_it->pts = xr_alloc(n_it->count); - } - } - - for (u32 f_id=0; f_idvmap_index]; - switch (vmap->type){ - case vmtUV:{ - int& pm=m_VertVMap[F.pv[k].pindex]; - if (-1==pm){ // point map - pm=F.pv[k].vmref; - int vm_idx=FindVMapByName(nVMaps,vmap->name.c_str(),vmap->type,false); - if (-1==vm_idx){ - nVMaps.push_back(xr_new(vmap->name.c_str(),vmap->type,false)); - vm_idx=nVMaps.size()-1; - } - st_VMap* nVMap=nVMaps[vm_idx]; - -// int uv_idx = FindSimilarUV(nVMap,vmap->getUV(pt_it->index)); -// if (uv_idx==-1){ -// uv_idx = nVMap->size(); -// nVMap->appendUV(vmap->getUV(pt_it->index)); -// nVMap->appendVI(F.pv[k].pindex); -// } - - nVMap->appendUV(vmap->getUV(o_pt_it->index)); - nVMap->appendVI(F.pv[k].pindex); - n_pt_it->index = nVMap->size()-1; - n_pt_it->vmap_index=vm_idx; - } - else{ // poly map - int vm_idx=FindVMapByName(nVMaps,vmap->name.c_str(),vmap->type,true); - if (-1==vm_idx){ - nVMaps.push_back(xr_new(vmap->name.c_str(),vmap->type,true)); - vm_idx=nVMaps.size()-1; - } - st_VMap* nVMapPM=nVMaps[vm_idx]; - -// int uv_idx = FindSimilarUV(nVMapPM,vmap->getUV(pt_it->index)); -// if (uv_idx==-1){ -// uv_idx = nVMapPM->size(); -// nVMapPM->appendUV(vmap->getUV(pt_it->index)); -// nVMapPM->appendVI(F.pv[k].pindex); -// nVMapPM->appendPI(f_it-m_Faces.begin()); -// } -// n_pt_it->index = uv_idx; - - nVMapPM->appendUV(vmap->getUV(o_pt_it->index)); - nVMapPM->appendVI(F.pv[k].pindex); - nVMapPM->appendPI(f_id); - n_pt_it->index = nVMapPM->size()-1; - n_pt_it->vmap_index=vm_idx; - } - }break; - case vmtWeight:{ - int vm_idx=FindVMapByName(nVMaps,vmap->name.c_str(),vmap->type,false); - if (-1==vm_idx){ - nVMaps.push_back(xr_new(vmap->name.c_str(),vmap->type,false)); - vm_idx=nVMaps.size()-1; - } - st_VMap* nWMap=nVMaps[vm_idx]; - nWMap->appendW (vmap->getW(o_pt_it->index)); - nWMap->appendVI (F.pv[k].pindex); - n_pt_it->index = nWMap->size()-1; - n_pt_it->vmap_index=vm_idx; - }break; - } - } - } - } - for (VMapIt vm_it=m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) - xr_delete(*vm_it); - - m_VMaps.clear(); - m_VMaps=nVMaps; - // clear refs - for (VMRefsIt ref_it=m_VMRefs.begin(); ref_it!=m_VMRefs.end(); ref_it++) - xr_free (ref_it->pts); - m_VMRefs.clear(); - m_VMRefs = nVMRefs; + //. Log ("Rebuilding VMaps..."); + IntVec m_VertVMap; + m_VertVMap.resize(m_VertCount, -1); + VMapVec nVMaps; + VMRefsVec nVMRefs; + // refs copy to new + { + nVMRefs.resize(m_VMRefs.size()); + for (VMRefsIt o_it = m_VMRefs.begin(), n_it = nVMRefs.begin(); o_it!=m_VMRefs.end(); o_it++,n_it++) + { + n_it->count = o_it->count; + n_it->pts = xr_alloc(n_it->count); + } + } + + for (u32 f_id = 0; f_idvmap_index]; + switch (vmap->type) + { + case vmtUV: + { + int &pm = m_VertVMap[F.pv[k].pindex]; + if (-1==pm) + { // point map + pm = F.pv[k].vmref; + int vm_idx = FindVMapByName(nVMaps, vmap->name.c_str(), vmap->type, false); + if (-1==vm_idx) + { + nVMaps.push_back(xr_new(vmap->name.c_str(),vmap->type,false)); + vm_idx = nVMaps.size()-1; + } + st_VMap*nVMap = nVMaps[vm_idx]; + + // int uv_idx = FindSimilarUV(nVMap,vmap->getUV(pt_it->index)); + // if (uv_idx==-1){ + // uv_idx = nVMap->size(); + // nVMap->appendUV(vmap->getUV(pt_it->index)); + // nVMap->appendVI(F.pv[k].pindex); + // } + + nVMap->appendUV(vmap->getUV(o_pt_it->index)); + nVMap->appendVI(F.pv[k].pindex); + n_pt_it->index = nVMap->size()-1; + n_pt_it->vmap_index = vm_idx; + } + else + { // poly map + int vm_idx = FindVMapByName(nVMaps, vmap->name.c_str(), vmap->type, true); + if (-1==vm_idx) + { + nVMaps.push_back(xr_new(vmap->name.c_str(),vmap->type,true)); + vm_idx = nVMaps.size()-1; + } + st_VMap*nVMapPM = nVMaps[vm_idx]; + + // int uv_idx = FindSimilarUV(nVMapPM,vmap->getUV(pt_it->index)); + // if (uv_idx==-1){ + // uv_idx = nVMapPM->size(); + // nVMapPM->appendUV(vmap->getUV(pt_it->index)); + // nVMapPM->appendVI(F.pv[k].pindex); + // nVMapPM->appendPI(f_it-m_Faces.begin()); + // } + // n_pt_it->index = uv_idx; + + nVMapPM->appendUV(vmap->getUV(o_pt_it->index)); + nVMapPM->appendVI(F.pv[k].pindex); + nVMapPM->appendPI(f_id); + n_pt_it->index = nVMapPM->size()-1; + n_pt_it->vmap_index = vm_idx; + } + } + break; + case vmtWeight: + { + int vm_idx = FindVMapByName(nVMaps, vmap->name.c_str(), vmap->type, false); + if (-1==vm_idx) + { + nVMaps.push_back(xr_new(vmap->name.c_str(),vmap->type,false)); + vm_idx = nVMaps.size()-1; + } + st_VMap*nWMap = nVMaps[vm_idx]; + nWMap->appendW(vmap->getW(o_pt_it->index)); + nWMap->appendVI(F.pv[k].pindex); + n_pt_it->index = nWMap->size()-1; + n_pt_it->vmap_index = vm_idx; + } + break; + } + } + } + } + for (VMapIt vm_it = m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) + xr_delete(*vm_it); + + m_VMaps.clear(); + m_VMaps = nVMaps; + // clear refs + for (VMRefsIt ref_it = m_VMRefs.begin(); ref_it!=m_VMRefs.end(); ref_it++) + xr_free(ref_it->pts); + m_VMRefs.clear(); + m_VMRefs = nVMRefs; } #define MX 25 #define MY 15 #define MZ 25 -static Fvector VMmin, VMscale; -static U32Vec VM[MX+1][MY+1][MZ+1]; -static Fvector VMeps; - -static FvectorVec m_NewPoints; -bool CEditableMesh::OptimizeFace(st_Face& face){ - Fvector points[3]; - int mface[3]; - int k; - - for (k=0; k<3; k++){ - points[k].set(m_Vertices[face.pv[k].pindex]); - mface[k] = -1; +static Fvector VMmin, VMscale; +static U32Vec VM[MX+1][MY+1][MZ+1]; +static Fvector VMeps; + +static FvectorVec m_NewPoints; + +bool CEditableMesh::OptimizeFace(st_Face &face) +{ + Fvector points[3]; + int mface[3]; + int k; + + for (k = 0; k<3; k++) + { + points[k].set(m_Vertices[face.pv[k].pindex]); + mface[k] = -1; } - // get similar vert idx list - for (k=0; k<3; k++){ - U32Vec* vl; - int ix,iy,iz; - ix = iFloor(float(points[k].x-VMmin.x)/VMscale.x*MX); - iy = iFloor(float(points[k].y-VMmin.y)/VMscale.y*MY); - iz = iFloor(float(points[k].z-VMmin.z)/VMscale.z*MZ); - vl = &(VM[ix][iy][iz]); - for(U32It it=vl->begin();it!=vl->end(); it++){ - FvectorIt v = m_NewPoints.begin()+(*it); - if( v->similar(points[k],EPS) ) + // get similar vert idx list + for (k = 0; k<3; k++) + { + U32Vec *vl; + int ix, iy, iz; + ix = iFloor(float(points[k].x-VMmin.x)/VMscale.x*MX); + iy = iFloor(float(points[k].y-VMmin.y)/VMscale.y*MY); + iz = iFloor(float(points[k].z-VMmin.z)/VMscale.z*MZ); + vl = &(VM[ix][iy][iz]); + for (U32It it = vl->begin(); it!=vl->end(); it++) + { + FvectorIt v = m_NewPoints.begin()+(*it); + if (v->similar(points[k], EPS)) mface[k] = *it; - } - } - for(k=0; k<3; k++ ){ - if( mface[k] == -1 ){ - mface[k] = m_NewPoints.size(); - m_NewPoints.push_back( points[k] ); - int ix,iy,iz; - ix = iFloor(float(points[k].x-VMmin.x)/VMscale.x*MX); - iy = iFloor(float(points[k].y-VMmin.y)/VMscale.y*MY); - iz = iFloor(float(points[k].z-VMmin.z)/VMscale.z*MZ); - VM[ix][iy][iz].push_back(mface[k]); - int ixE,iyE,izE; - ixE = iFloor(float(points[k].x+VMeps.x-VMmin.x)/VMscale.x*MX); - iyE = iFloor(float(points[k].y+VMeps.y-VMmin.y)/VMscale.y*MY); - izE = iFloor(float(points[k].z+VMeps.z-VMmin.z)/VMscale.z*MZ); - if (ixE!=ix) - VM[ixE][iy][iz].push_back(mface[k]); - if (iyE!=iy) - VM[ix][iyE][iz].push_back(mface[k]); - if (izE!=iz) - VM[ix][iy][izE].push_back(mface[k]); - if ((ixE!=ix)&&(iyE!=iy)) - VM[ixE][iyE][iz].push_back(mface[k]); - if ((ixE!=ix)&&(izE!=iz)) - VM[ixE][iy][izE].push_back(mface[k]); - if ((iyE!=iy)&&(izE!=iz)) - VM[ix][iyE][izE].push_back(mface[k]); - if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) - VM[ixE][iyE][izE].push_back(mface[k]); - } - } - - if ((mface[0]==mface[1])||(mface[1]==mface[2])||(mface[0]==mface[2])){ - Msg("!Optimize: Invalid face found. Removed."); + } + } + for (k = 0; k<3; k++) + { + if (mface[k]==-1) + { + mface[k] = m_NewPoints.size(); + m_NewPoints.push_back(points[k]); + int ix, iy, iz; + ix = iFloor(float(points[k].x-VMmin.x)/VMscale.x*MX); + iy = iFloor(float(points[k].y-VMmin.y)/VMscale.y*MY); + iz = iFloor(float(points[k].z-VMmin.z)/VMscale.z*MZ); + VM[ix][iy][iz].push_back(mface[k]); + int ixE, iyE, izE; + ixE = iFloor(float(points[k].x+VMeps.x-VMmin.x)/VMscale.x*MX); + iyE = iFloor(float(points[k].y+VMeps.y-VMmin.y)/VMscale.y*MY); + izE = iFloor(float(points[k].z+VMeps.z-VMmin.z)/VMscale.z*MZ); + if (ixE!=ix) + VM[ixE][iy][iz].push_back(mface[k]); + if (iyE!=iy) + VM[ix][iyE][iz].push_back(mface[k]); + if (izE!=iz) + VM[ix][iy][izE].push_back(mface[k]); + if ((ixE!=ix)&&(iyE!=iy)) + VM[ixE][iyE][iz].push_back(mface[k]); + if ((ixE!=ix)&&(izE!=iz)) + VM[ixE][iy][izE].push_back(mface[k]); + if ((iyE!=iy)&&(izE!=iz)) + VM[ix][iyE][izE].push_back(mface[k]); + if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) + VM[ixE][iyE][izE].push_back(mface[k]); + } + } + + if ((mface[0]==mface[1])||(mface[1]==mface[2])||(mface[0]==mface[2])) + { + Msg("!Optimize: Invalid face found. Removed."); return false; - }else{ - face.pv[0].pindex = mface[0]; - face.pv[1].pindex = mface[1]; - face.pv[2].pindex = mface[2]; + } + else + { + face.pv[0].pindex = mface[0]; + face.pv[1].pindex = mface[1]; + face.pv[2].pindex = mface[2]; return true; - } + } } void CEditableMesh::OptimizeMesh(BOOL NoOpt) { - if (!NoOpt){ + if (!NoOpt) + { #ifdef _EDITOR UnloadRenderBuffers (); UnloadCForm (); #endif - UnloadFNormals (true); - UnloadVNormals (true); - UnloadSVertices (true); - UnloadAdjacency (true); - - // clear static data - for (int x=0; x(m_VertCount); - Memory.mem_copy (m_Vertices,&*m_NewPoints.begin(),m_NewPoints.size()*sizeof(Fvector)); - - if (i_del_face){ - st_Face* old_faces = m_Faces; - u32* old_sg = m_SmoothGroups; - - m_Faces = xr_alloc (m_FaceCount-i_del_face); - m_SmoothGroups = xr_alloc (m_FaceCount-i_del_face); - - u32 new_dk = 0; - for (u32 dk=0; dksecond; - for (int k=0; k(m_VertCount); + Memory.mem_copy(m_Vertices, &*m_NewPoints.begin(), m_NewPoints.size()*sizeof(Fvector)); + + if (i_del_face) + { + st_Face*old_faces = m_Faces; + u32 *old_sg = m_SmoothGroups; + + m_Faces = xr_alloc(m_FaceCount-i_del_face); + m_SmoothGroups = xr_alloc(m_FaceCount-i_del_face); + + u32 new_dk = 0; + for (u32 dk = 0; dksecond; + for (int k = 0; k(int)dk) - { - --f; - }else if (f==(int)dk) - { + { + --f; + } + else if (f==(int)dk) + { pol_lst.erase(pol_lst.begin()+k); --k; } } } - continue; - } -//. -----in plugin -//. new_dk++; + continue; + } + //. -----in plugin + //. new_dk++; - m_Faces[new_dk] = old_faces[dk]; - m_SmoothGroups[new_dk] = old_sg[dk]; + m_Faces[new_dk] = old_faces[dk]; + m_SmoothGroups[new_dk] = old_sg[dk]; -//. -----in editors - ++new_dk; + //. -----in editors + ++new_dk; } - m_FaceCount = m_FaceCount-i_del_face; - xr_free (old_faces); - xr_free (old_sg); - } - } + m_FaceCount = m_FaceCount-i_del_face; + xr_free(old_faces); + xr_free(old_sg); + } + } } + diff --git a/src/editors/ECore/Editor/EditMeshPick.cpp b/src/editors/ECore/Editor/EditMeshPick.cpp index de573801bfc..5ad26c77db6 100644 --- a/src/editors/ECore/Editor/EditMeshPick.cpp +++ b/src/editors/ECore/Editor/EditMeshPick.cpp @@ -7,30 +7,31 @@ #include "EditMesh.h" #include "EditObject.h" -#include "cl_collector.h" +#include "editors/ECore/Engine/cl_collector.h" #include "ui_main.h" #include "pick_defs.h" -#include "../ETools/ETools.h" +#include "utils/ETools/ETools.h" /* void CEditableMesh::CHullPickFaces(PlaneVec& pl, Fmatrix& parent, U32Vec& fl){ - u32 i=0; - Fvector p; + u32 i=0; + Fvector p; vector inside(m_Points.size(),true); for(FvectorIt v_it=m_Points.begin();v_it!=m_Points.end();v_it++){ parent.transform_tiny(p,*v_it); for(PlaneIt p_it=pl.begin(); p_it!=pl.end(); p_it++) - if (p_it->classify(p)>EPS_L) { inside[v_it-m_Points.begin()]=false; break; } + if (p_it->classify(p)>EPS_L) { inside[v_it-m_Points.begin()]=false; break; } } for(FaceIt f_it=m_Faces.begin();f_it!=m_Faces.end();f_it++,i++) - if (inside[f_it->pv[0].pindex]&&inside[f_it->pv[1].pindex]&&inside[f_it->pv[2].pindex]) fl.push_back(i); + if (inside[f_it->pv[0].pindex]&&inside[f_it->pv[1].pindex]&&inside[f_it->pv[2].pindex]) fl.push_back(i); } */ //---------------------------------------------------- -static IntVec sml_processed; -static Fvector sml_normal; -static float m_fSoftAngle; +static IntVec sml_processed; +static Fvector sml_normal; +static float m_fSoftAngle; + //---------------------------------------------------- //---------------------------------------------------- @@ -38,87 +39,98 @@ static float m_fSoftAngle; //---------------------------------------------------- void CEditableMesh::GenerateCFModel() { - UnloadCForm (); - // Collect faces - CDB::Collector* CL = ETOOLS::create_collector(); - // double sided - for (SurfFacesPairIt sp_it=m_SurfFaces.begin(); sp_it!=m_SurfFaces.end(); sp_it++){ - IntVec& face_lst = sp_it->second; - for (IntIt it=face_lst.begin(); it!=face_lst.end(); it++){ - st_Face& F = m_Faces[*it]; - ETOOLS::collector_add_face_d(CL,m_Vertices[F.pv[0].pindex],m_Vertices[F.pv[1].pindex],m_Vertices[F.pv[2].pindex], *it); - if (sp_it->first->m_Flags.is(CSurface::sf2Sided)) - ETOOLS::collector_add_face_d(CL,m_Vertices[F.pv[2].pindex],m_Vertices[F.pv[1].pindex],m_Vertices[F.pv[0].pindex], *it); - } - } - m_CFModel = ETOOLS::create_model_cl(CL); - ETOOLS::destroy_collector(CL); + UnloadCForm(); + // Collect faces + CDB::Collector *CL = ETOOLS::create_collector(); + // double sided + for (SurfFacesPairIt sp_it = m_SurfFaces.begin(); sp_it!=m_SurfFaces.end(); sp_it++) + { + IntVec &face_lst = sp_it->second; + for (IntIt it = face_lst.begin(); it!=face_lst.end(); it++) + { + st_Face&F = m_Faces[*it]; + ETOOLS::collector_add_face_d(CL, m_Vertices[F.pv[0].pindex], m_Vertices[F.pv[1].pindex], m_Vertices[F.pv[2].pindex], *it); + if (sp_it->first->m_Flags.is(CSurface::sf2Sided)) + ETOOLS::collector_add_face_d(CL, m_Vertices[F.pv[2].pindex], m_Vertices[F.pv[1].pindex], m_Vertices[F.pv[0].pindex], *it); + } + } + m_CFModel = ETOOLS::create_model_cl(CL); + ETOOLS::destroy_collector(CL); } -void CEditableMesh::RayQuery(SPickQuery& pinf) +void CEditableMesh::RayQuery(SPickQuery &pinf) { - if (!m_CFModel) GenerateCFModel(); -//* - ETOOLS::ray_query (m_CFModel, pinf.m_Start, pinf.m_Direction, pinf.m_Dist); - for (int r=0; rinf.range+EPS_L:UI->ZFar();// (bugs: íå âñåãäà âûáèðàåò) //S ???? - - ETOOLS::ray_options (CDB::OPT_ONLYNEAREST | CDB::OPT_CULL); - ETOOLS::ray_query_m (inv_parent, m_CFModel, start, direction, _sqrt_flt_max); - - if (ETOOLS::r_count()){ - CDB::RESULT* I = ETOOLS::r_begin (); - if (I->rangeSetRESULT (m_CFModel,I); - pinf->e_obj = m_Parent; - pinf->e_mesh = this; - pinf->pt.mul (direction,pinf->inf.range); - pinf->pt.add (start); + if (!m_Flags.is(flVisible)) + return false; + + if (!m_CFModel) + GenerateCFModel(); + //. float m_r = pinf?pinf->inf.range+EPS_L:UI->ZFar();// (bugs: íå âñåãäà âûáèðàåò) //S ???? + + ETOOLS::ray_options(CDB::OPT_ONLYNEAREST|CDB::OPT_CULL); + ETOOLS::ray_query_m(inv_parent, m_CFModel, start, direction, _sqrt_flt_max); + + if (ETOOLS::r_count()) + { + CDB::RESULT *I = ETOOLS::r_begin(); + if (I->rangeSetRESULT(m_CFModel, I); + pinf->e_obj = m_Parent; + pinf->e_mesh = this; + pinf->pt.mul(direction, pinf->inf.range); + pinf->pt.add(start); } distance = I->range; return true; - } + } } - return false; + return false; } + //---------------------------------------------------- #ifdef _EDITOR bool CEditableMesh::CHullPickMesh(PlaneVec& pl, const Fmatrix& parent) @@ -138,13 +150,13 @@ bool CEditableMesh::CHullPickMesh(PlaneVec& pl, const Fmatrix& parent) void CEditableMesh::RecurseTri(int id) { - // Check if triangle already processed +// Check if triangle already processed if (std::find(sml_processed.begin(),sml_processed.end(),id)!=sml_processed.end()) return; sml_processed.push_back(id); - // recurse +// recurse for (int k=0; k<3; k++){ IntVec& PL = (*m_Adjs)[m_Faces[id].pv[k].pindex]; for (IntIt pl_it=PL.begin(); pl_it!=PL.end(); pl_it++){ @@ -231,4 +243,3 @@ void CEditableMesh::FrustumPickFaces(const CFrustum& frustum, const Fmatrix& par #endif // - diff --git a/src/editors/ECore/Editor/EditMeshRender.cpp b/src/editors/ECore/Editor/EditMeshRender.cpp index 114fa9c31e4..682c948ecab 100644 --- a/src/editors/ECore/Editor/EditMeshRender.cpp +++ b/src/editors/ECore/Editor/EditMeshRender.cpp @@ -9,348 +9,416 @@ #include "EditMesh.h" #include "EditObject.h" #include "ui_main.h" -#include "d3dutils.h" +#include "D3DUtils.h" #include "render.h" //---------------------------------------------------- #define F_LIM (10000) #define V_LIM (F_LIM*3) + //---------------------------------------------------- void CEditableMesh::GenerateRenderBuffers() { -// CTimer T; -// T.Start(); -/* - CMemoryWriter F; - m_Parent->PrepareOGF(F,false,this); - IReader R (F.pointer(), F.size()); - m_Visual = ::Render->Models->Create(GetName(),&R); -// Log ("Time: ",T.GetElapsed_sec()); -// string_path fn; -// strconcat (fn,"_alexmx_\\",GetName(),".ogf"); -// FS.update_path (fn,_import_,fn); -// F.save_to (fn); - return; -*/ - if (m_RenderBuffers) return; - m_RenderBuffers = xr_new(); - - GenerateVNormals (0); - - VERIFY (m_VertexNormals); - - for (SurfFacesPairIt sp_it=m_SurfFaces.begin(); sp_it!=m_SurfFaces.end(); sp_it++){ - IntVec& face_lst = sp_it->second; - CSurface* _S = sp_it->first; - int num_verts=face_lst.size()*3; + // CTimer T; + // T.Start(); + /* + CMemoryWriter F; + m_Parent->PrepareOGF(F,false,this); + IReader R (F.pointer(), F.size()); + m_Visual = ::Render->Models->Create(GetName(),&R); + // Log ("Time: ",T.GetElapsed_sec()); + // string_path fn; + // strconcat (fn,"_alexmx_\\",GetName(),".ogf"); + // FS.update_path (fn,_import_,fn); + // F.save_to (fn); + return; + */ + if (m_RenderBuffers) + return; + m_RenderBuffers = xr_new(); + + GenerateVNormals(0); + + VERIFY(m_VertexNormals); + + for (SurfFacesPairIt sp_it = m_SurfFaces.begin(); sp_it!=m_SurfFaces.end(); sp_it++) + { + IntVec &face_lst = sp_it->second; + CSurface*_S = sp_it->first; + int num_verts = face_lst.size()*3; RBVector rb_vec; - int v_cnt=num_verts; - int start_face=0; + int v_cnt = num_verts; + int start_face = 0; int num_face; - VERIFY3 (v_cnt,"Empty surface arrive.",_S->_Name()); - do{ - rb_vec.push_back (st_RenderBuffer(0,(v_cntm_Flags.is(CSurface::sf2Sided)) rb.dwNumVertex *= 2; - num_face = (v_cnt_FVF())*rb.dwNumVertex; - R_ASSERT2 (buf_size,"Empty buffer size or bad FVF."); - u8* bytes = 0; - IDirect3DVertexBuffer9* pVB=0; -// IDirect3DIndexBuffer9* pIB=0; - R_CHK(HW.pDevice->CreateVertexBuffer(buf_size, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &pVB, 0)); -// R_CHK(HW.pDevice->CreateIndexBuffer(i_cnt*sizeof(u16),D3DUSAGE_WRITEONLY,D3DFMT_INDEX16,D3DPOOL_MANAGED,&pIB,NULL)); - rb.pGeom.create (_S->_FVF(),pVB,0); - - R_CHK (pVB->Lock(0,0,(LPVOID*)&bytes,0)); - FillRenderBuffer (face_lst,start_face,num_face,_S,bytes); - pVB->Unlock (); - - v_cnt -= V_LIM; - start_face += (_S->m_Flags.is(CSurface::sf2Sided))?rb.dwNumVertex/6:rb.dwNumVertex/3; - }while(v_cnt>0); - if (num_verts>0) m_RenderBuffers->insert(mk_pair(_S,rb_vec)); + VERIFY3(v_cnt, "Empty surface arrive.", _S->_Name()); + do + { + rb_vec.push_back(st_RenderBuffer(0, (v_cntm_Flags.is(CSurface::sf2Sided)) + rb.dwNumVertex *= 2; + num_face = (v_cnt_FVF())*rb.dwNumVertex; + R_ASSERT2(buf_size, "Empty buffer size or bad FVF."); + u8 *bytes = 0; + IDirect3DVertexBuffer9 *pVB = 0; + // IDirect3DIndexBuffer9* pIB=0; + R_CHK(HW.pDevice->CreateVertexBuffer(buf_size, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &pVB, 0)); + // R_CHK(HW.pDevice->CreateIndexBuffer(i_cnt*sizeof(u16),D3DUSAGE_WRITEONLY,D3DFMT_INDEX16,D3DPOOL_MANAGED,&pIB,NULL)); + rb.pGeom.create(_S->_FVF(), pVB, 0); + + R_CHK(pVB->Lock(0, 0, (LPVOID*)&bytes, 0)); + FillRenderBuffer(face_lst, start_face, num_face, _S, bytes); + pVB->Unlock(); + + v_cnt -= V_LIM; + start_face += (_S->m_Flags.is(CSurface::sf2Sided)) ? rb.dwNumVertex/6 : rb.dwNumVertex/3; + } while (v_cnt>0); + if (num_verts>0) + m_RenderBuffers->insert(mk_pair(_S, rb_vec)); } UnloadVNormals(); } + //---------------------------------------------------- void CEditableMesh::UnloadRenderBuffers() { - if (m_RenderBuffers){ - for (RBMapPairIt rbmp_it=m_RenderBuffers->begin(); rbmp_it!=m_RenderBuffers->end(); rbmp_it++){ - for(RBVecIt rb_it=rbmp_it->second.begin(); rb_it!=rbmp_it->second.end(); rb_it++) - if (rb_it->pGeom){ - _RELEASE (rb_it->pGeom->vb); - _RELEASE (rb_it->pGeom->ib); + if (m_RenderBuffers) + { + for (RBMapPairIt rbmp_it = m_RenderBuffers->begin(); rbmp_it!=m_RenderBuffers->end(); rbmp_it++) + { + for (RBVecIt rb_it = rbmp_it->second.begin(); rb_it!=rbmp_it->second.end(); rb_it++) + if (rb_it->pGeom) + { + _RELEASE(rb_it->pGeom->vb); + _RELEASE(rb_it->pGeom->ib); rb_it->pGeom.destroy(); } } - xr_delete (m_RenderBuffers); + xr_delete(m_RenderBuffers); } } + //---------------------------------------------------- -void CEditableMesh::FillRenderBuffer(IntVec& face_lst, int start_face, int num_face, const CSurface* surf, LPBYTE& src_data) +void CEditableMesh::FillRenderBuffer(IntVec &face_lst, int start_face, int num_face, const CSurface *surf, LPBYTE &src_data) { - LPBYTE data = src_data; - u32 dwFVF = surf->_FVF(); - u32 dwTexCnt = ((dwFVF&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT); - for (int fl_i=start_face; fl_i_FVF(); + u32 dwTexCnt = ((dwFVF&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT); + for (int fl_i = start_face; fl_itype!=vmtUV){ - offs++; + sz = sizeof(Fvector2); + int offs = 0; + for (int t = 0; t<(int)dwTexCnt; t++) + { + VERIFY2((t+offs)<(int)m_VMRefs[fv.vmref].count, "- VMap layer index out of range"); + st_VMapPt&vm_pt = m_VMRefs[fv.vmref].pts[t+offs]; + if (m_VMaps[vm_pt.vmap_index]->type!=vmtUV) + { + offs++; t--; continue; } - VERIFY2 (vm_pt.vmap_indexsize(),"- VMap point index out of range"); - CopyMemory(data,&vmap->getUV(vm_pt.index),sz); data+=sz; -// Msg("%3.2f, %3.2f",vmap->getUV(vm_pt.index).x,vmap->getUV(vm_pt.index).y); + VERIFY2(vm_pt.vmap_indexsize(), "- VMap point index out of range"); + CopyMemory(data, &vmap->getUV(vm_pt.index), sz); + data += sz; + // Msg("%3.2f, %3.2f",vmap->getUV(vm_pt.index).x,vmap->getUV(vm_pt.index).y); } } - if (surf->m_Flags.is(CSurface::sf2Sided)){ - for (int k=2; k>=0; k--){ - st_FaceVert& fv = face.pv[k]; - Fvector& PN = m_VertexNormals[f_index*3+k]; + if (surf->m_Flags.is(CSurface::sf2Sided)) + { + for (int k = 2; k>=0; k--) + { + st_FaceVert&fv = face.pv[k]; + Fvector &PN = m_VertexNormals[f_index*3+k]; int sz; - if (dwFVF&D3DFVF_XYZ){ - sz=sizeof(Fvector); - VERIFY2(fv.pindextype!=vmtUV){ + sz = sizeof(Fvector2); + int offs = 0; + for (int t = 0; t<(int)dwTexCnt; t++) + { + VERIFY2((t+offs)<(int)m_VMRefs[fv.vmref].count, "- VMap layer index out of range"); + st_VMapPt&vm_pt = m_VMRefs[fv.vmref].pts[t]; + if (m_VMaps[vm_pt.vmap_index]->type!=vmtUV) + { offs++; t--; continue; } - VERIFY2(vm_pt.vmap_indexsize(),"- VMap point index out of range"); - CopyMemory(data,&vmap->getUV(vm_pt.index),sz); data+=sz; + VERIFY2(vm_pt.vmap_indexsize(), "- VMap point index out of range"); + CopyMemory(data, &vmap->getUV(vm_pt.index), sz); + data += sz; -// Msg("%3.2f, %3.2f",vmap->getUV(vm_pt.index).x,vmap->getUV(vm_pt.index).y); + // Msg("%3.2f, %3.2f",vmap->getUV(vm_pt.index).x,vmap->getUV(vm_pt.index).y); } } } } } + //---------------------------------------------------- -void CEditableMesh::Render(const Fmatrix& parent, CSurface* S) +void CEditableMesh::Render(const Fmatrix &parent, CSurface *S) { - if (0==m_RenderBuffers) GenerateRenderBuffers(); + if (0==m_RenderBuffers) + GenerateRenderBuffers(); // visibility test - if (!m_Flags.is(flVisible)) return; + if (!m_Flags.is(flVisible)) + return; // frustum test - Fbox bb; bb.set(m_Box); + Fbox bb; + bb.set(m_Box); bb.xform(parent); - if (!::Render->occ_visible(bb)) return; + if (!::Render->occ_visible(bb)) + return; // render RBMapPairIt rb_pair = m_RenderBuffers->find(S); - if (rb_pair!=m_RenderBuffers->end()){ - RBVector& rb_vec = rb_pair->second; - for (RBVecIt rb_it=rb_vec.begin(); rb_it!=rb_vec.end(); rb_it++) - EDevice.DP(D3DPT_TRIANGLELIST,rb_it->pGeom,0,rb_it->dwNumVertex/3); + if (rb_pair!=m_RenderBuffers->end()) + { + RBVector &rb_vec = rb_pair->second; + for (RBVecIt rb_it = rb_vec.begin(); rb_it!=rb_vec.end(); rb_it++) + EDevice.DP(D3DPT_TRIANGLELIST, rb_it->pGeom, 0, rb_it->dwNumVertex/3); } } + //---------------------------------------------------- #define MAX_VERT_COUNT 0xFFFF static Fvector RB[MAX_VERT_COUNT]; -static RB_cnt=0; +static RB_cnt += +0; -void CEditableMesh::RenderList(const Fmatrix& parent, u32 color, bool bEdge, IntVec& fl) +void CEditableMesh::RenderList(const Fmatrix &parent, u32 color, bool bEdge, IntVec &fl) { -// if (!m_Visible) return; -// if (!m_LoadState.is(LS_RBUFFERS)) CreateRenderBuffers(); - - if (fl.size()==0) return; - RCache.set_xform_world(parent); - EDevice.RenderNearer(0.0006); - RB_cnt = 0; - if (bEdge){ - EDevice.SetShader(EDevice.m_WireShader); - EDevice.SetRS(D3DRS_FILLMODE,D3DFILL_WIREFRAME); - }else - EDevice.SetShader(EDevice.m_SelectionShader); - for (IntIt dw_it=fl.begin(); dw_it!=fl.end(); ++dw_it) + // if (!m_Visible) return; + // if (!m_LoadState.is(LS_RBUFFERS)) CreateRenderBuffers(); + + if (fl.size()==0) + return; + RCache.set_xform_world(parent); + EDevice.RenderNearer(0.0006); + RB_cnt = 0; + if (bEdge) + { + EDevice.SetShader(EDevice.m_WireShader); + EDevice.SetRS(D3DRS_FILLMODE, D3DFILL_WIREFRAME); + } + else + EDevice.SetShader(EDevice.m_SelectionShader); + for (IntIt dw_it = fl.begin(); dw_it!=fl.end(); ++dw_it) { - st_Face& face = m_Faces[*dw_it]; - for (int k=0; k<3; ++k) - RB[RB_cnt++].set(m_Vertices[face.pv[k].pindex]); + st_Face&face = m_Faces[*dw_it]; + for (int k = 0; k<3; ++k) + RB[RB_cnt++].set(m_Vertices[face.pv[k].pindex]); - if (RB_cnt==MAX_VERT_COUNT) + if (RB_cnt==MAX_VERT_COUNT) { - DU_impl.DrawPrimitiveL(D3DPT_TRIANGLELIST,RB_cnt/3,RB,RB_cnt,color,true,false); - RB_cnt = 0; + DU_impl.DrawPrimitiveL(D3DPT_TRIANGLELIST, RB_cnt/3, RB, RB_cnt, color, true, false); + RB_cnt = 0; } } - if (RB_cnt) - DU_impl.DrawPrimitiveL(D3DPT_TRIANGLELIST,RB_cnt/3,RB,RB_cnt,color,true,false); + if (RB_cnt) + DU_impl.DrawPrimitiveL(D3DPT_TRIANGLELIST, RB_cnt/3, RB, RB_cnt, color, true, false); if (bEdge) - EDevice.SetRS(D3DRS_FILLMODE,EDevice.dwFillMode); + EDevice.SetRS(D3DRS_FILLMODE, EDevice.dwFillMode); - EDevice.ResetNearer(); + EDevice.ResetNearer(); } + //---------------------------------------------------- -void CEditableMesh::RenderSelection(const Fmatrix& parent, CSurface* s, u32 color) +void CEditableMesh::RenderSelection(const Fmatrix &parent, CSurface *s, u32 color) { - if (0==m_RenderBuffers) GenerateRenderBuffers(); -// if (!m_Visible) return; - Fbox bb; bb.set(m_Box); + if (0==m_RenderBuffers) + GenerateRenderBuffers(); + // if (!m_Visible) return; + Fbox bb; + bb.set(m_Box); bb.xform(parent); - if (!::Render->occ_visible(bb)) return; + if (!::Render->occ_visible(bb)) + return; // render - RCache.set_xform_world(parent); - if (s){ + RCache.set_xform_world(parent); + if (s) + { SurfFacesPairIt sp_it = m_SurfFaces.find(s); - if (sp_it!=m_SurfFaces.end()) RenderList(parent,color,false,sp_it->second); - }else{ - EDevice.SetRS(D3DRS_TEXTUREFACTOR, color); - for (RBMapPairIt p_it=m_RenderBuffers->begin(); p_it!=m_RenderBuffers->end(); p_it++){ - RBVector& rb_vec = p_it->second; - for (RBVecIt rb_it=rb_vec.begin(); rb_it!=rb_vec.end(); rb_it++) - EDevice.DP(D3DPT_TRIANGLELIST,rb_it->pGeom,0,rb_it->dwNumVertex/3); + if (sp_it!=m_SurfFaces.end()) + RenderList(parent, color, false, sp_it->second); + } + else + { + EDevice.SetRS(D3DRS_TEXTUREFACTOR, color); + for (RBMapPairIt p_it = m_RenderBuffers->begin(); p_it!=m_RenderBuffers->end(); p_it++) + { + RBVector &rb_vec = p_it->second; + for (RBVecIt rb_it = rb_vec.begin(); rb_it!=rb_vec.end(); rb_it++) + EDevice.DP(D3DPT_TRIANGLELIST, rb_it->pGeom, 0, rb_it->dwNumVertex/3); } - EDevice.SetRS(D3DRS_TEXTUREFACTOR, 0xffffffff); + EDevice.SetRS(D3DRS_TEXTUREFACTOR, 0xffffffff); } } + //---------------------------------------------------- -void CEditableMesh::RenderEdge(const Fmatrix& parent, CSurface* s, u32 color) +void CEditableMesh::RenderEdge(const Fmatrix &parent, CSurface *s, u32 color) { - if (0==m_RenderBuffers) GenerateRenderBuffers(); -// if (!m_Visible) return; - RCache.set_xform_world(parent); - EDevice.SetShader(EDevice.m_WireShader); - EDevice.RenderNearer(0.001); + if (0==m_RenderBuffers) + GenerateRenderBuffers(); + // if (!m_Visible) return; + RCache.set_xform_world(parent); + EDevice.SetShader(EDevice.m_WireShader); + EDevice.RenderNearer(0.001); // render - EDevice.SetRS(D3DRS_FILLMODE,D3DFILL_WIREFRAME); - if (s){ + EDevice.SetRS(D3DRS_FILLMODE, D3DFILL_WIREFRAME); + if (s) + { SurfFacesPairIt sp_it = m_SurfFaces.find(s); - if (sp_it!=m_SurfFaces.end()) RenderList(parent,color,true,sp_it->second); - }else{ - EDevice.SetRS(D3DRS_TEXTUREFACTOR, color); - for (RBMapPairIt p_it=m_RenderBuffers->begin(); p_it!=m_RenderBuffers->end(); p_it++){ - RBVector& rb_vec = p_it->second; - for (RBVecIt rb_it=rb_vec.begin(); rb_it!=rb_vec.end(); rb_it++) - EDevice.DP(D3DPT_TRIANGLELIST,rb_it->pGeom,0,rb_it->dwNumVertex/3); + if (sp_it!=m_SurfFaces.end()) + RenderList(parent, color, true, sp_it->second); + } + else + { + EDevice.SetRS(D3DRS_TEXTUREFACTOR, color); + for (RBMapPairIt p_it = m_RenderBuffers->begin(); p_it!=m_RenderBuffers->end(); p_it++) + { + RBVector &rb_vec = p_it->second; + for (RBVecIt rb_it = rb_vec.begin(); rb_it!=rb_vec.end(); rb_it++) + EDevice.DP(D3DPT_TRIANGLELIST, rb_it->pGeom, 0, rb_it->dwNumVertex/3); } - EDevice.SetRS(D3DRS_TEXTUREFACTOR, 0xffffffff); + EDevice.SetRS(D3DRS_TEXTUREFACTOR, 0xffffffff); } - EDevice.SetRS(D3DRS_FILLMODE,EDevice.dwFillMode); + EDevice.SetRS(D3DRS_FILLMODE, EDevice.dwFillMode); EDevice.ResetNearer(); } + //---------------------------------------------------- #define SKEL_MAX_FACE_COUNT 10000 + struct svertRender { - Fvector P; - Fvector N; - Fvector2 uv; + Fvector P; + Fvector N; + Fvector2 uv; }; -void CEditableMesh::RenderSkeleton(const Fmatrix&, CSurface* S) + +void CEditableMesh::RenderSkeleton(const Fmatrix &, CSurface *S) { if (false==IsGeneratedSVertices(RENDER_SKELETON_LINKS)) - GenerateSVertices(RENDER_SKELETON_LINKS); - - R_ASSERT2(m_SVertices,"SVertices empty!"); - SurfFacesPairIt sp_it = m_SurfFaces.find(S); R_ASSERT(sp_it!=m_SurfFaces.end()); - IntVec& face_lst = sp_it->second; - _VertexStream* Stream = &RCache.Vertex; - u32 vBase; - - svertRender* pv = (svertRender*)Stream->Lock(SKEL_MAX_FACE_COUNT*3,m_Parent->vs_SkeletonGeom->vb_stride,vBase); - Fvector P0,N0,P1,N1; - - int f_cnt=0; - for (IntIt i_it=face_lst.begin(); i_it!=face_lst.end(); i_it++) + GenerateSVertices(RENDER_SKELETON_LINKS); + + R_ASSERT2(m_SVertices, "SVertices empty!"); + SurfFacesPairIt sp_it = m_SurfFaces.find(S); + R_ASSERT(sp_it!=m_SurfFaces.end()); + IntVec &face_lst = sp_it->second; + _VertexStream *Stream = &RCache.Vertex; + u32 vBase; + + svertRender *pv = (svertRender*)Stream->Lock(SKEL_MAX_FACE_COUNT*3, m_Parent->vs_SkeletonGeom->vb_stride, vBase); + Fvector P0, N0, P1, N1; + + int f_cnt = 0; + for (IntIt i_it = face_lst.begin(); i_it!=face_lst.end(); i_it++) { - for (int k=0; k<3; k++,pv++) + for (int k = 0; k<3; k++,pv++) { - st_SVert& SV = m_SVertices[*i_it*3+k]; - pv->uv.set (SV.uv); - float total = SV.bones[0].w; + st_SVert&SV = m_SVertices[*i_it*3+k]; + pv->uv.set(SV.uv); + float total = SV.bones[0].w; - const Fmatrix& M = m_Parent->m_Bones[SV.bones[0].id]->_RenderTransform(); - M.transform_tiny (pv->P,SV.offs); - M.transform_dir (pv->N,SV.norm); + const Fmatrix &M = m_Parent->m_Bones[SV.bones[0].id]->_RenderTransform(); + M.transform_tiny(pv->P, SV.offs); + M.transform_dir(pv->N, SV.norm); - Fvector P,N; + Fvector P, N; - for (u8 cnt=1; cnt<(u8)SV.bones.size(); cnt++) + for (u8 cnt = 1; cnt<(u8)SV.bones.size(); cnt++) { - total += SV.bones[cnt].w; - const Fmatrix& M = m_Parent->m_Bones[SV.bones[cnt].id]->_RenderTransform(); - M.transform_tiny (P,SV.offs); - M.transform_dir (N,SV.norm); - pv->P.lerp (pv->P,P,SV.bones[cnt].w/total); - pv->N.lerp (pv->N,N,SV.bones[cnt].w/total); + total += SV.bones[cnt].w; + const Fmatrix &M = m_Parent->m_Bones[SV.bones[cnt].id]->_RenderTransform(); + M.transform_tiny(P, SV.offs); + M.transform_dir(N, SV.norm); + pv->P.lerp(pv->P, P, SV.bones[cnt].w/total); + pv->N.lerp(pv->N, N, SV.bones[cnt].w/total); } } f_cnt++; if (S->m_Flags.is(CSurface::sf2Sided)) { - pv->P.set((pv-1)->P); pv->N.invert((pv-1)->N); pv->uv.set((pv-1)->uv); pv++; - pv->P.set((pv-3)->P); pv->N.invert((pv-3)->N); pv->uv.set((pv-3)->uv); pv++; - pv->P.set((pv-5)->P); pv->N.invert((pv-5)->N); pv->uv.set((pv-5)->uv); pv++; - f_cnt++; + pv->P.set((pv-1)->P); + pv->N.invert((pv-1)->N); + pv->uv.set((pv-1)->uv); + pv++; + pv->P.set((pv-3)->P); + pv->N.invert((pv-3)->N); + pv->uv.set((pv-3)->uv); + pv++; + pv->P.set((pv-5)->P); + pv->N.invert((pv-5)->N); + pv->uv.set((pv-5)->uv); + pv++; + f_cnt++; } if (f_cnt>=SKEL_MAX_FACE_COUNT-1) { - Stream->Unlock (f_cnt*3,m_Parent->vs_SkeletonGeom->vb_stride); - EDevice.DP (D3DPT_TRIANGLELIST,m_Parent->vs_SkeletonGeom,vBase,f_cnt); - pv = (svertRender*)Stream->Lock(SKEL_MAX_FACE_COUNT*3,m_Parent->vs_SkeletonGeom->vb_stride,vBase); - f_cnt = 0; + Stream->Unlock(f_cnt*3, m_Parent->vs_SkeletonGeom->vb_stride); + EDevice.DP(D3DPT_TRIANGLELIST, m_Parent->vs_SkeletonGeom, vBase, f_cnt); + pv = (svertRender*)Stream->Lock(SKEL_MAX_FACE_COUNT*3, m_Parent->vs_SkeletonGeom->vb_stride, vBase); + f_cnt = 0; } } - Stream->Unlock (f_cnt*3,m_Parent->vs_SkeletonGeom->vb_stride); - if (f_cnt) - EDevice.DP (D3DPT_TRIANGLELIST,m_Parent->vs_SkeletonGeom,vBase,f_cnt); + Stream->Unlock(f_cnt*3, m_Parent->vs_SkeletonGeom->vb_stride); + if (f_cnt) + EDevice.DP(D3DPT_TRIANGLELIST, m_Parent->vs_SkeletonGeom, vBase, f_cnt); } + //---------------------------------------------------- diff --git a/src/editors/ECore/Editor/EditObject.cpp b/src/editors/ECore/Editor/EditObject.cpp index f366445b5f4..ec14bf6b974 100644 --- a/src/editors/ECore/Editor/EditObject.cpp +++ b/src/editors/ECore/Editor/EditObject.cpp @@ -11,13 +11,13 @@ #include "EditMesh.h" #ifdef _EDITOR - #include "motion.h" - #include "bone.h" - #include "ImageManager.h" +#include "xrCore/Animation/Motion.hpp" +#include "xrCore/Animation/Bone.hpp" +#include "ImageManager.h" #endif // mimimal bounding box size -float g_MinBoxSize = 0.05f; +float g_MinBoxSize = 0.05f; #ifdef _EDITOR void CSurface::CreateImageData() @@ -35,86 +35,91 @@ void CSurface::RemoveImageData() #endif CEditableObject::CEditableObject(LPCSTR name): - m_physics_shell(0), + m_physics_shell(0), m_object_xform(0) { - m_LibName = name; + m_LibName = name; - m_objectFlags.zero (); - m_ObjectVersion = 0; + m_objectFlags.zero(); + m_ObjectVersion = 0; #ifdef _EDITOR vs_SkeletonGeom = 0; #endif - m_BBox.invalidate(); + m_BBox.invalidate(); m_LoadState.zero(); m_ActiveSMotion = 0; - t_vPosition.set (0.f,0.f,0.f); - t_vScale.set (1.f,1.f,1.f); - t_vRotate.set (0.f,0.f,0.f); + t_vPosition.set(0.f, 0.f, 0.f); + t_vScale.set(1.f, 1.f, 1.f); + t_vRotate.set(0.f, 0.f, 0.f); + + a_vPosition.set(0.f, 0.f, 0.f); + a_vRotate.set(0.f, 0.f, 0.f); - a_vPosition.set (0.f,0.f,0.f); - a_vRotate.set (0.f,0.f,0.f); + bOnModified = false; - bOnModified = false; + m_RefCount = 0; - m_RefCount = 0; + m_LODShader = 0; - m_LODShader = 0; - - m_CreateName = "unknown"; - m_CreateTime = 0; - m_ModifName = "unknown"; - m_ModifTime = 0; + m_CreateName = "unknown"; + m_CreateTime = 0; + m_ModifName = "unknown"; + m_ModifTime = 0; } CEditableObject::~CEditableObject() { ClearGeometry(); } + //---------------------------------------------------- void CEditableObject::VerifyMeshNames() { - int idx=0; - string1024 nm,pref; - for(EditMeshIt m_def=m_Meshes.begin();m_def!=m_Meshes.end();m_def++){ - strcpy (pref,(*m_def)->m_Name.size()?(*m_def)->m_Name.c_str():"mesh"); - _Trim (pref); - strcpy (nm,pref); - while (FindMeshByName(nm,*m_def)) - sprintf(nm,"%s%2d",pref,idx++); + int idx = 0; + string1024 nm, pref; + for (EditMeshIt m_def = m_Meshes.begin(); m_def!=m_Meshes.end(); m_def++) + { + strcpy(pref, (*m_def)->m_Name.size() ? (*m_def)->m_Name.c_str() : "mesh"); + _Trim(pref); + strcpy(nm, pref); + while (FindMeshByName(nm, *m_def)) + sprintf(nm, "%s%2d", pref, idx++); (*m_def)->SetName(nm); } } -bool CEditableObject::ContainsMesh(const CEditableMesh* m) +bool CEditableObject::ContainsMesh(const CEditableMesh *m) { VERIFY(m); - for(EditMeshIt m_def=m_Meshes.begin();m_def!=m_Meshes.end();m_def++) - if (m==(*m_def)) return true; + for (EditMeshIt m_def = m_Meshes.begin(); m_def!=m_Meshes.end(); m_def++) + if (m==(*m_def)) + return true; return false; } -CEditableMesh* CEditableObject::FindMeshByName (const char* name, CEditableMesh* Ignore) +CEditableMesh *CEditableObject::FindMeshByName(const char *name, CEditableMesh *Ignore) { - for(EditMeshIt m=m_Meshes.begin();m!=m_Meshes.end();m++) - if ((Ignore!=(*m))&&(stricmp((*m)->Name().c_str(),name)==0)) return (*m); + for (EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); m++) + if ((Ignore!=(*m))&&(stricmp((*m)->Name().c_str(), name)==0)) + return (*m); return 0; } -void CEditableObject::ClearGeometry () +void CEditableObject::ClearGeometry() { #ifdef _EDITOR OnDeviceDestroy(); #endif if (!m_Meshes.empty()) - for(EditMeshIt m=m_Meshes.begin(); m!=m_Meshes.end();m++)xr_delete(*m); + for (EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); m++) + xr_delete(*m); if (!m_Surfaces.empty()) - for(SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) + for (SurfaceIt s_it = m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) xr_delete(*s_it); m_Meshes.clear(); m_Surfaces.clear(); @@ -131,188 +136,215 @@ void CEditableObject::ClearGeometry () int CEditableObject::GetFaceCount(bool bMatch2Sided, bool bIgnoreOCC) { - int cnt=0; - for(EditMeshIt m = m_Meshes.begin();m!=m_Meshes.end();m++) - cnt+=(*m)->GetFaceCount(bMatch2Sided, bIgnoreOCC); - return cnt; + int cnt = 0; + for (EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); m++) + cnt += (*m)->GetFaceCount(bMatch2Sided, bIgnoreOCC); + return cnt; } -int CEditableObject::GetSurfFaceCount(const char* surf_name){ - int cnt=0; - CSurface* surf = FindSurfaceByName(surf_name); - for(EditMeshIt m = m_Meshes.begin();m!=m_Meshes.end();m++) - cnt+=(*m)->GetSurfFaceCount(surf); - return cnt; +int CEditableObject::GetSurfFaceCount(const char *surf_name) +{ + int cnt = 0; + CSurface*surf = FindSurfaceByName(surf_name); + for (EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); m++) + cnt += (*m)->GetSurfFaceCount(surf); + return cnt; } -int CEditableObject::GetVertexCount(){ - int cnt=0; - for(EditMeshIt m = m_Meshes.begin();m!=m_Meshes.end();m++) - cnt+=(*m)->GetVertexCount(); - return cnt; +int CEditableObject::GetVertexCount() +{ + int cnt = 0; + for (EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); m++) + cnt += (*m)->GetVertexCount(); + return cnt; } void CEditableObject::UpdateBox() { - VERIFY (!m_Meshes.empty()); - EditMeshIt m = m_Meshes.begin(); + VERIFY(!m_Meshes.empty()); + EditMeshIt m = m_Meshes.begin(); m_BBox.invalidate(); - for(; m!=m_Meshes.end(); ++m) - { + for (; m!=m_Meshes.end(); ++m) + { Fbox meshbox; (*m)->GetBox(meshbox); - for(int i=0; i<8; ++i) - { + for (int i = 0; i<8; ++i) + { Fvector pt; meshbox.getpoint(i, pt); m_BBox.modify(pt); } } } + //---------------------------------------------------- -void CEditableObject::RemoveMesh(CEditableMesh* mesh){ - EditMeshIt m_it = std::find(m_Meshes.begin(),m_Meshes.end(),mesh); +void CEditableObject::RemoveMesh(CEditableMesh *mesh) +{ + EditMeshIt m_it = std::find(m_Meshes.begin(), m_Meshes.end(), mesh); VERIFY(m_it!=m_Meshes.end()); - m_Meshes.erase(m_it); + m_Meshes.erase(m_it); xr_delete(mesh); } -void CEditableObject::TranslateToWorld(const Fmatrix& parent) +void CEditableObject::TranslateToWorld(const Fmatrix &parent) { - EditMeshIt m = m_Meshes.begin(); - for(;m!=m_Meshes.end();m++) (*m)->Transform( parent ); + EditMeshIt m = m_Meshes.begin(); + for (; m!=m_Meshes.end(); m++) + (*m)->Transform(parent); #ifdef _EDITOR OnDeviceDestroy(); #endif - UpdateBox(); + UpdateBox(); } -CSurface* CEditableObject::FindSurfaceByName(const char* surf_name, int* s_id){ - for(SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) - if (stricmp((*s_it)->_Name(),surf_name)==0){ if (s_id) *s_id=s_it-m_Surfaces.begin(); return *s_it;} +CSurface *CEditableObject::FindSurfaceByName(const char *surf_name, int *s_id) +{ + for (SurfaceIt s_it = m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) + if (stricmp((*s_it)->_Name(), surf_name)==0) + { + if (s_id) + *s_id = s_it-m_Surfaces.begin(); + return *s_it; + } return 0; } -LPCSTR CEditableObject::GenerateSurfaceName(const char* base_name) +LPCSTR CEditableObject::GenerateSurfaceName(const char *base_name) { - static string1024 nm; - strcpy(nm, base_name); - if (FindSurfaceByName(nm)){ - DWORD idx=0; - do{ - sprintf(nm,"%s_%d",base_name,idx); - idx++; - }while(FindSurfaceByName(nm)); - } - return nm; + static string1024 nm; + strcpy(nm, base_name); + if (FindSurfaceByName(nm)) + { + DWORD idx = 0; + do + { + sprintf(nm, "%s_%d", base_name, idx); + idx++; + } while (FindSurfaceByName(nm)); + } + return nm; } bool CEditableObject::VerifyBoneParts() { - U8Vec b_use(BoneCount(),0); - for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++) - for (int i=0; ibones.size()); i++){ - int idx = FindBoneByNameIdx(bp_it->bones[i].c_str()); - if (idx==-1){ - bp_it->bones.erase(bp_it->bones.begin()+i); - i--; - }else{ - b_use[idx]++; + U8Vec b_use(BoneCount(), 0); + for (BPIt bp_it = m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++) + for (int i = 0; ibones.size()); i++) + { + int idx = FindBoneByNameIdx(bp_it->bones[i].c_str()); + if (idx==-1) + { + bp_it->bones.erase(bp_it->bones.begin()+i); + i--; + } + else + { + b_use[idx]++; } } - for (U8It u_it=b_use.begin(); u_it!=b_use.end(); u_it++) - if (*u_it!=1) return false; + for (U8It u_it = b_use.begin(); u_it!=b_use.end(); u_it++) + if (*u_it!=1) + return false; return true; } -void CEditableObject::PrepareOGFDesc(ogf_desc& desc) +void CEditableObject::PrepareOGFDesc(ogf_desc &desc) { - string512 tmp; - desc.source_file = m_LibName.c_str(); - desc.create_name = m_CreateName.c_str(); - desc.create_time = m_CreateTime; - desc.modif_name = m_ModifName.c_str(); - desc.modif_time = m_ModifTime; - desc.build_name = strconcat(sizeof(tmp),tmp,"\\\\",Core.CompName,"\\",Core.UserName); - ctime (&desc.build_time); + string512 tmp; + desc.source_file = m_LibName.c_str(); + desc.create_name = m_CreateName.c_str(); + desc.create_time = m_CreateTime; + desc.modif_name = m_ModifName.c_str(); + desc.modif_time = m_ModifTime; + desc.build_name = strconcat(sizeof(tmp), tmp, "\\\\", Core.CompName, "\\", Core.UserName); + ctime(&desc.build_time); } void CEditableObject::SetVersionToCurrent(BOOL bCreate, BOOL bModif) { - string512 tmp; - if (bCreate){ - m_CreateName = strconcat(sizeof(tmp),tmp,"\\\\",Core.CompName,"\\",Core.UserName); - m_CreateTime = time(NULL); - } - if (bModif){ - m_ModifName = strconcat(sizeof(tmp),tmp,"\\\\",Core.CompName,"\\",Core.UserName); - m_ModifTime = time(NULL); - } + string512 tmp; + if (bCreate) + { + m_CreateName = strconcat(sizeof(tmp), tmp, "\\\\", Core.CompName, "\\", Core.UserName); + m_CreateTime = time(NULL); + } + if (bModif) + { + m_ModifName = strconcat(sizeof(tmp), tmp, "\\\\", Core.CompName, "\\", Core.UserName); + m_ModifTime = time(NULL); + } } -void CEditableObject::GetFaceWorld(const Fmatrix& parent, CEditableMesh* M, int idx, Fvector* verts) +void CEditableObject::GetFaceWorld(const Fmatrix &parent, CEditableMesh *M, int idx, Fvector *verts) { - const Fvector* PT[3]; - M->GetFacePT(idx, PT); - parent.transform_tiny(verts[0],*PT[0]); - parent.transform_tiny(verts[1],*PT[1]); - parent.transform_tiny(verts[2],*PT[2]); + const Fvector *PT[3]; + M->GetFacePT(idx, PT); + parent.transform_tiny(verts[0], *PT[0]); + parent.transform_tiny(verts[1], *PT[1]); + parent.transform_tiny(verts[2], *PT[2]); } void CEditableObject::Optimize() { - for(EditMeshIt m_def=m_Meshes.begin();m_def!=m_Meshes.end();m_def++){ - (*m_def)->OptimizeMesh (false); - (*m_def)->RebuildVMaps (); + for (EditMeshIt m_def = m_Meshes.begin(); m_def!=m_Meshes.end(); m_def++) + { + (*m_def)->OptimizeMesh(false); + (*m_def)->RebuildVMaps(); } } bool CEditableObject::Validate() { - bool bRes = true; - for(SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) - if (false==(*s_it)->Validate()){ - Msg("!Invalid surface found: Object [%s], Surface [%s].",GetName(),(*s_it)->_Name()); - bRes=false; + bool bRes = true; + for (SurfaceIt s_it = m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) + if (false==(*s_it)->Validate()) + { + Msg("!Invalid surface found: Object [%s], Surface [%s].", GetName(), (*s_it)->_Name()); + bRes = false; } - for(EditMeshIt m_def=m_Meshes.begin();m_def!=m_Meshes.end();m_def++) - if (false==(*m_def)->Validate()){ - Msg("!Invalid mesh found: Object [%s], Mesh [%s].",m_LibName.c_str(),(*m_def)->Name().c_str()); - bRes=false; + for (EditMeshIt m_def = m_Meshes.begin(); m_def!=m_Meshes.end(); m_def++) + if (false==(*m_def)->Validate()) + { + Msg("!Invalid mesh found: Object [%s], Mesh [%s].", m_LibName.c_str(), (*m_def)->Name().c_str()); + bRes = false; } return bRes; } + //---------------------------------------------------------------------------- //#ifdef DEBUG -LPCSTR CEditableObject::LL_BoneName_dbg(u16 ID) +LPCSTR CEditableObject::LL_BoneName_dbg(u16 ID) { - return GetBone( ID )->Name().c_str(); + return GetBone(ID)->Name().c_str(); } //#endif -CBoneInstance& CEditableObject::LL_GetBoneInstance(u16 bone_id) +CBoneInstance &CEditableObject::LL_GetBoneInstance(u16 bone_id) { return *GetBone(bone_id); } -CBoneData& CEditableObject::LL_GetData(u16 bone_id) + +CBoneData &CEditableObject::LL_GetData(u16 bone_id) { - VERIFY(false); - static CBoneData dummy_bone_data(0); - return dummy_bone_data; + VERIFY(false); + static CBoneData dummy_bone_data(0); + return dummy_bone_data; } -Fmatrix& CEditableObject::LL_GetTransform_R(u16 bone_id) +Fmatrix &CEditableObject::LL_GetTransform_R(u16 bone_id) { - // VERIFY(false); - // static Fmatrix dummy_matrix; + // VERIFY(false); + // static Fmatrix dummy_matrix; return GetBone(bone_id)->_RenderTransform(); } -Fobb& CEditableObject::LL_GetBox(u16 bone_id) + +Fobb &CEditableObject::LL_GetBox(u16 bone_id) { - VERIFY(false); - static Fobb dummy_box; + VERIFY(false); + static Fobb dummy_box; return dummy_box; } + diff --git a/src/editors/ECore/Editor/EditObject.h b/src/editors/ECore/Editor/EditObject.h index c5e2103ebca..f156e046779 100644 --- a/src/editors/ECore/Editor/EditObject.h +++ b/src/editors/ECore/Editor/EditObject.h @@ -3,33 +3,34 @@ #include "xrCore/Animation/Bone.hpp" #include "xrCore/Animation/Motion.hpp" -#ifdef _EDITOR -# include "xrServerEntities/PropertiesListTypes.h" -# include "xrCore/MaterialLib/GameMtlLib.h" -# include "pick_defs.h" +#ifdef _EDITOR +#include "xrServerEntities/PropertiesListTypes.h" +#include "xrEngine/GameMtlLib.h" +#include "pick_defs.h" #endif -# include "Include/xrRender/kinematics.h" -#include "physicsshellholdereditorbase.h" +#include "Include/xrRender/Kinematics.h" + +#include "PhysicsShellHolderEditorBase.h" //---------------------------------------------------- -struct SRayPickInfo; -class CEditableMesh; -class CFrustum; -class CCustomMotion; -class CBone; -class Shader; -class Mtl; -class CExporter; -class CMayaTranslator; -struct st_ObjectDB; -struct SXRShaderData; -struct ogf_desc; -class CCustomObject; +struct SRayPickInfo; +class CEditableMesh; +class CFrustum; +class CCustomMotion; +class CBone; +class Shader; +class Mtl; +class CExporter; +class CMayaTranslator; +struct st_ObjectDB; +struct SXRShaderData; +struct ogf_desc; +class CCustomObject; #ifndef _EDITOR - class PropValue; - #define ref_shader LPVOID +class PropValue; +#define ref_shader LPVOID #endif #define LOD_SHADER_NAME "details\\lod" @@ -43,48 +44,48 @@ class SSimpleImage; class ECORE_API CSurface { - u32 m_GameMtlID; - ref_shader m_Shader; - enum ERTFlags{ - rtValidShader = (1<<0), - }; -public: - enum EFlags{ - sf2Sided = (1<<0), + u32 m_GameMtlID; + ref_shader m_Shader; + enum ERTFlags{ + rtValidShader = (1<<0), + }; + public: + enum EFlags{ + sf2Sided = (1<<0), }; - shared_str m_Name; - shared_str m_Texture; // - shared_str m_VMap; // - shared_str m_ShaderName; - shared_str m_ShaderXRLCName; - shared_str m_GameMtlName; - Flags32 m_Flags; - u32 m_dwFVF; + shared_str m_Name; + shared_str m_Texture; // + shared_str m_VMap; // + shared_str m_ShaderName; + shared_str m_ShaderXRLCName; + shared_str m_GameMtlName; + Flags32 m_Flags; + u32 m_dwFVF; #ifdef _MAX_EXPORT u32 mid; Mtl* mtl; #endif - Flags32 m_RTFlags; - u32 tag; - SSimpleImage* m_ImageData; -public: - CSurface () - { - m_GameMtlName="default"; - m_ImageData = 0; - m_Shader = 0; - m_RTFlags.zero (); - m_Flags.zero (); - m_dwFVF = 0; + Flags32 m_RTFlags; + u32 tag; + SSimpleImage*m_ImageData; + public: + CSurface() + { + m_GameMtlName = "default"; + m_ImageData = 0; + m_Shader = 0; + m_RTFlags.zero(); + m_Flags.zero(); + m_dwFVF = 0; #ifdef _MAX_EXPORT mtl = 0; mid = 0; #endif - tag = 0; - } - IC bool Validate () + tag = 0; + } + IC bool Validate() { - return (0!=xr_strlen(m_Texture))&&(0!=xr_strlen(m_ShaderName)); + return (0!=xr_strlen(m_Texture))&&(0!=xr_strlen(m_ShaderName)); } #ifdef _EDITOR ~CSurface (){R_ASSERT(!m_Shader);xr_delete(m_ImageData);} @@ -93,27 +94,27 @@ class ECORE_API CSurface IC bool _StrictB2F () {return _Shader()?_Shader()->E[0]->flags.bStrictB2F:false;} IC ref_shader _Shader () {if (!m_RTFlags.is(rtValidShader)) OnDeviceCreate(); return m_Shader;} #endif - IC LPCSTR _Name ()const {return *m_Name;} - IC LPCSTR _ShaderName ()const {return *m_ShaderName;} - IC LPCSTR _GameMtlName ()const {return *m_GameMtlName;} - IC LPCSTR _ShaderXRLCName ()const {return *m_ShaderXRLCName;} - IC LPCSTR _Texture ()const {return *m_Texture;} - IC LPCSTR _VMap ()const {return *m_VMap;} - IC u32 _FVF ()const {return m_dwFVF;} - IC void SetName (LPCSTR name){m_Name=name;} - IC void SetShader (LPCSTR name) - { - R_ASSERT2(name&&name[0],"Empty shader name."); - m_ShaderName=name; + IC LPCSTR _Name()const{return *m_Name;} + IC LPCSTR _ShaderName()const{return *m_ShaderName;} + IC LPCSTR _GameMtlName()const{return *m_GameMtlName;} + IC LPCSTR _ShaderXRLCName()const{return *m_ShaderXRLCName;} + IC LPCSTR _Texture()const{return *m_Texture;} + IC LPCSTR _VMap()const{return *m_VMap;} + IC u32 _FVF()const{return m_dwFVF;} + IC void SetName(LPCSTR name){m_Name = name;} + IC void SetShader(LPCSTR name) + { + R_ASSERT2(name&&name[0], "Empty shader name."); + m_ShaderName = name; #ifdef _EDITOR OnDeviceDestroy(); #endif - } - IC void SetShaderXRLC (LPCSTR name){m_ShaderXRLCName=name;} - IC void SetGameMtl (LPCSTR name){m_GameMtlName=name;} - IC void SetFVF (u32 fvf){m_dwFVF=fvf;} - IC void SetTexture (LPCSTR name){string512 buf; xr_strcpy(buf, sizeof(buf), name); if(strext(buf)) *strext(buf)=0; m_Texture=buf;} - IC void SetVMap (LPCSTR name){m_VMap=name;} + } + IC void SetShaderXRLC(LPCSTR name){m_ShaderXRLCName = name;} + IC void SetGameMtl(LPCSTR name){m_GameMtlName = name;} + IC void SetFVF(u32 fvf){m_dwFVF = fvf;} + IC void SetTexture(LPCSTR name){string512 buf; xr_strcpy(buf, sizeof(buf), name);if(strext(buf))*strext(buf) = 0; m_Texture = buf;} + IC void SetVMap(LPCSTR name){m_VMap = name;} #ifdef _EDITOR IC u32 _GameMtl ()const {return GMLib.GetMaterialID (*m_GameMtlName);} IC void OnDeviceCreate () @@ -133,215 +134,219 @@ class ECORE_API CSurface #endif }; -DEFINE_VECTOR (CSurface*,SurfaceVec,SurfaceIt); -DEFINE_VECTOR (CEditableMesh*,EditMeshVec,EditMeshIt); -DEFINE_VECTOR (COMotion*,OMotionVec,OMotionIt); -DEFINE_VECTOR (CSMotion*,SMotionVec,SMotionIt); +DEFINE_VECTOR(CSurface *, SurfaceVec, SurfaceIt); +DEFINE_VECTOR(CEditableMesh *, EditMeshVec, EditMeshIt); +DEFINE_VECTOR(COMotion *, OMotionVec, OMotionIt); +DEFINE_VECTOR(CSMotion *, SMotionVec, SMotionIt); struct ECORE_API SBonePart{ - shared_str alias; - RStringVec bones; + shared_str alias; + RStringVec bones; }; -DEFINE_VECTOR(SBonePart,BPVec,BPIt); +DEFINE_VECTOR(SBonePart, BPVec, BPIt); -const u32 FVF_SV = D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_NORMAL; +const u32 FVF_SV = D3DFVF_XYZ|D3DFVF_TEX1|D3DFVF_NORMAL; class ECORE_API CEditableObject: -public IKinematics, -public CPhysicsShellHolderEditorBase + +public +IKinematics +, +public +CPhysicsShellHolderEditorBase { - friend class CSceneObject; - friend class CEditableMesh; + friend class CSceneObject; + friend class CEditableMesh; friend class TfrmPropertiesEObject; friend class CSector; friend class TUI_ControlSectorAdd; - friend class ELibrary; - friend class TfrmEditLibrary; - friend class MeshExpUtility; + friend class ELibrary; + friend class TfrmEditLibrary; + friend class MeshExpUtility; #ifdef _EDITOR ref_geom vs_SkeletonGeom; #endif -// desc - shared_str m_CreateName; - time_t m_CreateTime; - shared_str m_ModifName; - time_t m_ModifTime; - -// general - xr_string m_ClassScript; - - SurfaceVec m_Surfaces; - EditMeshVec m_Meshes; - - ref_shader m_LODShader; - - // skeleton - BoneVec m_Bones; - SMotionVec m_SMotions; - BPVec m_BoneParts; - CSMotion* m_ActiveSMotion; - CPhysicsShell* m_physics_shell; - Fmatrix* m_object_xform; -public: - SAnimParams m_SMParam; - xr_vector m_SMotionRefs; - shared_str m_LODs; -public: - // options - Flags32 m_objectFlags; - enum{ - eoDynamic = (1<<0), - eoProgressive = (1<<1), - eoUsingLOD = (1<<2), - eoHOM = (1<<3), - eoMultipleUsage = (1<<4), - eoSoundOccluder = (1<<5), - eoHQExport = (1<<6), - eoFORCE32 = u32(-1) - }; - IC BOOL IsDynamic (){return m_objectFlags.is(eoDynamic);} - IC BOOL IsStatic (){return !m_objectFlags.is(eoSoundOccluder)&&!m_objectFlags.is(eoDynamic)&&!m_objectFlags.is(eoHOM)&&!m_objectFlags.is(eoMultipleUsage);} - IC BOOL IsMUStatic (){return !m_objectFlags.is(eoSoundOccluder)&&!m_objectFlags.is(eoDynamic)&&!m_objectFlags.is(eoHOM)&&m_objectFlags.is(eoMultipleUsage);} -private: - // bounding volume - Fbox m_BBox; -public: - // temp variable for actor - Fvector a_vPosition; - Fvector a_vRotate; + // desc + shared_str m_CreateName; + time_t m_CreateTime; + shared_str m_ModifName; + time_t m_ModifTime; - // temp variables for transformation - Fvector t_vPosition; - Fvector t_vScale; - Fvector t_vRotate; + // general + xr_string m_ClassScript; - bool bOnModified; - IC bool IsModified (){return bOnModified;} - IC void Modified (){bOnModified=true;} + SurfaceVec m_Surfaces; + EditMeshVec m_Meshes; - AnsiString m_LoadName; - int m_RefCount; -protected: - int m_ObjectVersion; - - void ClearGeometry (); - - void PrepareBones (); - void DefferedLoadRP (); - void DefferedUnloadRP (); + ref_shader m_LODShader; - void __stdcall OnChangeTransform (PropValue* prop); - void __stdcall OnChangeShader (PropValue* prop); + // skeleton + BoneVec m_Bones; + SMotionVec m_SMotions; + BPVec m_BoneParts; + CSMotion* m_ActiveSMotion; + CPhysicsShell* m_physics_shell; + Fmatrix* m_object_xform; + public: + SAnimParams m_SMParam; + xr_vector m_SMotionRefs; + shared_str m_LODs; + public: + // options + Flags32 m_objectFlags; + enum{ + eoDynamic = (1<<0), + eoProgressive = (1<<1), + eoUsingLOD = (1<<2), + eoHOM = (1<<3), + eoMultipleUsage = (1<<4), + eoSoundOccluder = (1<<5), + eoHQExport = (1<<6), + eoFORCE32 = u32(-1) +}; +IC BOOL IsDynamic (){return m_objectFlags.is(eoDynamic);} +IC BOOL IsStatic (){return !m_objectFlags.is(eoSoundOccluder)&&!m_objectFlags.is(eoDynamic)&&!m_objectFlags.is(eoHOM)&&!m_objectFlags.is(eoMultipleUsage);} +IC BOOL IsMUStatic (){return !m_objectFlags.is(eoSoundOccluder)&&!m_objectFlags.is(eoDynamic)&&!m_objectFlags.is(eoHOM)&&m_objectFlags.is(eoMultipleUsage);} +private: +// bounding volume +Fbox m_BBox; public: - enum{ - LS_RBUFFERS = (1<<0), - }; - Flags32 m_LoadState; +// temp variable for actor +Fvector a_vPosition; +Fvector a_vRotate; - AnsiString m_LibName; -public: - // constructor/destructor methods - CEditableObject (LPCSTR name); - virtual ~CEditableObject (); +// temp variables for transformation +Fvector t_vPosition; +Fvector t_vScale; +Fvector t_vRotate; - LPCSTR GetName (){ return m_LibName.c_str();} +bool bOnModified; +IC bool IsModified (){return bOnModified;} +IC void Modified (){bOnModified=true;} - void SetVersionToCurrent (BOOL bCreate, BOOL bModif); +AnsiString m_LoadName; +int m_RefCount; +protected: +int m_ObjectVersion; - void Optimize (); +void ClearGeometry (); - IC EditMeshIt FirstMesh () {return m_Meshes.begin();} - IC EditMeshIt LastMesh () {return m_Meshes.end();} - IC EditMeshVec& Meshes () {return m_Meshes; } - IC int MeshCount () {return m_Meshes.size();} - IC void AppendMesh (CEditableMesh* M){m_Meshes.push_back(M);} - IC SurfaceVec& Surfaces () {return m_Surfaces;} - IC SurfaceIt FirstSurface () {return m_Surfaces.begin();} - IC SurfaceIt LastSurface () {return m_Surfaces.end();} - IC int SurfaceCount () {return m_Surfaces.size();} - IC int Version () {return m_ObjectVersion;} +void PrepareBones (); +void DefferedLoadRP (); +void DefferedUnloadRP (); - // LOD - xr_string GetLODTextureName (); - LPCSTR GetLODShaderName (){return LOD_SHADER_NAME;} - void GetLODFrame (int frame, Fvector p[4], Fvector2 t[4], const Fmatrix* parent=0); +void __stdcall OnChangeTransform (PropValue* prop); +void __stdcall OnChangeShader (PropValue* prop); +public: +enum{ + LS_RBUFFERS = (1<<0), +}; +Flags32 m_LoadState; - // skeleton - IC BPIt FirstBonePart () {return m_BoneParts.begin();} - IC BPIt LastBonePart () {return m_BoneParts.end();} - IC BPVec& BoneParts () {return m_BoneParts;} - IC int BonePartCount () {return m_BoneParts.size();} - IC BPIt BonePart (CBone* B); - - IC BoneIt FirstBone () {return m_Bones.begin();} - IC BoneIt LastBone () {return m_Bones.end();} - IC BoneVec& Bones () {return m_Bones;} - IC int BoneCount ()const {return m_Bones.size();} - shared_str BoneNameByID (int id); - int GetRootBoneID (); - int PartIDByName (LPCSTR name); - IC CBone* GetBone (u32 idx){VERIFY(idx_LTransform(); } - virtual ICF const Fmatrix& LL_GetTransform(u16 bone_id) const { return GetBone( bone_id )->_LTransform(); } - virtual ICF Fmatrix& LL_GetTransform_R(u16 bone_id); - virtual Fobb& LL_GetBox(u16 bone_id); - virtual void LL_GetBindTransform(xr_vector& matrices) { VERIFY(false); } - virtual int LL_GetBoneGroups(xr_vector >& groups) { VERIFY(false); return 0; } +virtual u16 LL_BoneCount()const { return (u16)BoneCount(); } +virtual u16 LL_VisibleBoneCount() { VERIFY(false); return 0; } +virtual ICF Fmatrix& LL_GetTransform(u16 bone_id) { return GetBone( bone_id )->_LTransform(); } +virtual ICF const Fmatrix& LL_GetTransform(u16 bone_id) const { return GetBone( bone_id )->_LTransform(); } +virtual ICF Fmatrix& LL_GetTransform_R(u16 bone_id); +virtual Fobb& LL_GetBox(u16 bone_id); +virtual void LL_GetBindTransform(xr_vector& matrices) { VERIFY(false); } +virtual int LL_GetBoneGroups(xr_vector >& groups) { VERIFY(false); return 0; } - virtual u16 LL_GetBoneRoot() { u16 root_id = (u16)GetRootBoneID(); VERIFY( root_id < u16(-1) ); return root_id; } - virtual void LL_SetBoneRoot(u16 bone_id) { VERIFY(false); } +virtual u16 LL_GetBoneRoot() { u16 root_id = (u16)GetRootBoneID(); VERIFY( root_id < u16(-1) ); return root_id; } +virtual void LL_SetBoneRoot(u16 bone_id) { VERIFY(false); } - virtual BOOL LL_GetBoneVisible(u16 bone_id) { return TRUE; } - virtual void LL_SetBoneVisible(u16 bone_id, BOOL val, BOOL bRecursive) { VERIFY(false); } - virtual u64 LL_GetBonesVisible() { return u64(-1); } - virtual void LL_SetBonesVisible(u64 mask) { VERIFY(false); } +virtual BOOL LL_GetBoneVisible(u16 bone_id) { return TRUE; } +virtual void LL_SetBoneVisible(u16 bone_id, BOOL val, BOOL bRecursive) { VERIFY(false); } +virtual u64 LL_GetBonesVisible() { return u64(-1); } +virtual void LL_SetBonesVisible(u64 mask) { VERIFY(false); } - // Main functionality - virtual void CalculateBones(BOOL bForceExact = FALSE) { } // Recalculate skeleton - virtual void CalculateBones_Invalidate() { } - virtual void Callback(UpdateCallback C, void* Param) { VERIFY(false); } +// Main functionality +virtual void CalculateBones(BOOL bForceExact = FALSE) { } // Recalculate skeleton +virtual void CalculateBones_Invalidate() { } +virtual void Callback(UpdateCallback C, void* Param) { VERIFY(false); } - // Callback: data manipulation - virtual void SetUpdateCallback(UpdateCallback pCallback) { VERIFY(false); } - virtual void SetUpdateCallbackParam(void* pCallbackParam) { VERIFY(false); } +// Callback: data manipulation +virtual void SetUpdateCallback(UpdateCallback pCallback) { VERIFY(false); } +virtual void SetUpdateCallbackParam(void* pCallbackParam) { VERIFY(false); } - virtual UpdateCallback GetUpdateCallback() { VERIFY(false); return 0; } - virtual void* GetUpdateCallbackParam() { VERIFY(false); return 0; } - //UpdateCallback Update_Callback; - //void* Update_Callback_Param; - virtual IRenderVisual* dcast_RenderVisual() { return 0; } - virtual IKinematicsAnimated* dcast_PKinematicsAnimated() { VERIFY(false); return 0; } +virtual UpdateCallback GetUpdateCallback() { VERIFY(false); return 0; } +virtual void* GetUpdateCallbackParam() { VERIFY(false); return 0; } +//UpdateCallback Update_Callback; +//void* Update_Callback_Param; +virtual IRenderVisual* dcast_RenderVisual() { return 0; } +virtual IKinematicsAnimated* dcast_PKinematicsAnimated() { VERIFY(false); return 0; } - // debug +// debug #ifdef DEBUG virtual void DebugRender (Fmatrix& XFORM) {VERIFY(false);} virtual shared_str getDebugName () {return m_ModifName;} #endif private: - virtual IKinematics* ObjectKinematics () { return this;} +virtual IKinematics* ObjectKinematics () { return this;} }; //---------------------------------------------------- @@ -547,13 +552,3 @@ virtual const IBoneData& GetBoneData(u16 bone_id) const { return #endif /*_INCDEF_EditObject_H_*/ - - - - - - - - - - diff --git a/src/editors/ECore/Editor/EditObjectEditor.cpp b/src/editors/ECore/Editor/EditObjectEditor.cpp index 65eadebe9fb..b929df99e7a 100644 --- a/src/editors/ECore/Editor/EditObjectEditor.cpp +++ b/src/editors/ECore/Editor/EditObjectEditor.cpp @@ -3,67 +3,67 @@ #include "EditObject.h" #include "EditMesh.h" -#include "motion.h" -#include "bone.h" +#include "xrCore/Animation/Motion.hpp" +#include "xrCore/Animation/Bone.hpp" #include "ExportSkeleton.h" #include "ExportObjectOGF.h" -#include "d3dutils.h" +#include "D3DUtils.h" #include "ui_main.h" #include "render.h" -#include "../../xrServerEntities/PropertiesListHelper.h" -#include "ResourceManager.h" +#include "xrServerEntities/PropertiesListHelper.h" +#include "Layers/xrRender/ResourceManager.h" #include "ImageManager.h" -const float tex_w = LOD_SAMPLE_COUNT*LOD_IMAGE_SIZE; -const float tex_h = 1*LOD_IMAGE_SIZE; -const float half_p_x= 0.5f*(1.f/tex_w); -const float half_p_y= 0.5f*(1.f/tex_h); -const float offs_x = 1.f/tex_w; -const float offs_y = 1.f/tex_h; - -static Fvector LOD_pos[4]={ - {-1.0f+offs_x, 1.0f-offs_y, 0.0f}, - { 1.0f-offs_x, 1.0f-offs_y, 0.0f}, - { 1.0f-offs_x,-1.0f+offs_y, 0.0f}, - {-1.0f+offs_x,-1.0f+offs_y, 0.0f} +const float tex_w = LOD_SAMPLE_COUNT*LOD_IMAGE_SIZE; +const float tex_h = 1*LOD_IMAGE_SIZE; +const float half_p_x = 0.5f*(1.f/tex_w); +const float half_p_y = 0.5f*(1.f/tex_h); +const float offs_x = 1.f/tex_w; +const float offs_y = 1.f/tex_h; + +static Fvector LOD_pos[4] = { + {-1.0f+offs_x, 1.0f-offs_y, 0.0f}, + {1.0f-offs_x, 1.0f-offs_y, 0.0f}, + {1.0f-offs_x,-1.0f+offs_y, 0.0f}, + {-1.0f+offs_x,-1.0f+offs_y, 0.0f} }; -static FVF::LIT LOD[4]={ - {{-1.0f, 1.0f, 0.0f}, 0xFFFFFFFF, {0.0f,0.0f}}, // F 0 - {{ 1.0f, 1.0f, 0.0f}, 0xFFFFFFFF, {0.0f,0.0f}}, // F 1 - {{ 1.0f,-1.0f, 0.0f}, 0xFFFFFFFF, {0.0f,0.0f}}, // F 2 - {{-1.0f,-1.0f, 0.0f}, 0xFFFFFFFF, {0.0f,0.0f}}, // F 3 +static FVF::LIT LOD[4] = { + {{-1.0f, 1.0f, 0.0f}, 0xFFFFFFFF,{0.0f,0.0f}}, // F 0 + {{1.0f, 1.0f, 0.0f}, 0xFFFFFFFF,{0.0f,0.0f}}, // F 1 + {{1.0f,-1.0f, 0.0f}, 0xFFFFFFFF,{0.0f,0.0f}}, // F 2 + {{-1.0f,-1.0f, 0.0f}, 0xFFFFFFFF,{0.0f,0.0f}}, // F 3 }; bool CEditableObject::Reload() { - ClearGeometry(); + ClearGeometry(); return Load(m_LoadName.c_str()); } -bool CEditableObject::RayPick(float& dist, const Fvector& S, const Fvector& D, const Fmatrix& inv_parent, SRayPickInfo* pinf) +bool CEditableObject::RayPick(float &dist, const Fvector &S, const Fvector &D, const Fmatrix &inv_parent, SRayPickInfo *pinf) { - bool picked = false; - for(EditMeshIt m = m_Meshes.begin();m!=m_Meshes.end();m++) - if( (*m)->RayPick( dist, S, D, inv_parent, pinf ) ) + bool picked = false; + for (EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); m++) + if ((*m)->RayPick(dist, S, D, inv_parent, pinf)) picked = true; - return picked; + return picked; } -void CEditableObject::RayQuery(SPickQuery& pinf) +void CEditableObject::RayQuery(SPickQuery &pinf) { - for(EditMeshIt m = m_Meshes.begin();m!=m_Meshes.end();m++) + for (EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); m++) (*m)->RayQuery(pinf); } -void CEditableObject::RayQuery(const Fmatrix& parent, const Fmatrix& inv_parent, SPickQuery& pinf) +void CEditableObject::RayQuery(const Fmatrix &parent, const Fmatrix &inv_parent, SPickQuery &pinf) { - for(EditMeshIt m = m_Meshes.begin();m!=m_Meshes.end();m++) + for (EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); m++) (*m)->RayQuery(parent, inv_parent, pinf); } -void CEditableObject::BoxQuery(const Fmatrix& parent, const Fmatrix& inv_parent, SPickQuery& pinf) +void CEditableObject::BoxQuery(const Fmatrix &parent, const Fmatrix &inv_parent, SPickQuery &pinf) { - for(EditMeshIt m = m_Meshes.begin();m!=m_Meshes.end();m++) + for (EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); m++) (*m)->BoxQuery(parent, inv_parent, pinf); } @@ -85,230 +85,259 @@ bool CEditableObject::BoxPick(CCustomObject* obj, const Fbox& box, const Fmatrix } #endif -extern float ssaLIMIT; -extern float g_fSCREEN; +extern float ssaLIMIT; +extern float g_fSCREEN; static const float ssaLim = 64.f*64.f/(640*480); -void CEditableObject::Render(const Fmatrix& parent, int priority, bool strictB2F){ + +void CEditableObject::Render(const Fmatrix &parent, int priority, bool strictB2F) +{ if (!(m_LoadState.is(LS_RBUFFERS))) - DefferedLoadRP(); + DefferedLoadRP(); - Fvector v; + Fvector v; float r; - Fbox bb; - bb.xform (m_BBox,parent); - bb.getsphere (v,r); + Fbox bb; + bb.xform(m_BBox, parent); + bb.getsphere(v, r); - if (EPrefs->object_flags.is(epoDrawLOD)&&(m_objectFlags.is(eoUsingLOD)&&(CalcSSA(v,r)object_flags.is(epoDrawLOD)&&(m_objectFlags.is(eoUsingLOD)&&(CalcSSA(v, r)_Priority(); + int pr = (*s_it)->_Priority(); bool strict = (*s_it)->_StrictB2F(); - + if ((priority==pr)&&(strictB2F==strict)) { EDevice.SetShader((*s_it)->_Shader()); - for (EditMeshIt _M=m_Meshes.begin(); _M!=m_Meshes.end(); _M++) + for (EditMeshIt _M = m_Meshes.begin(); _M!=m_Meshes.end(); _M++) if (IsSkeleton()) - (*_M)->RenderSkeleton (parent,*s_it); + (*_M)->RenderSkeleton(parent, *s_it); else - (*_M)->Render (parent,*s_it); + (*_M)->Render(parent, *s_it); } } } } } -void CEditableObject::RenderSingle(const Fmatrix& parent) +void CEditableObject::RenderSingle(const Fmatrix &parent) { - for (int i=0; i<4; i++){ - Render(parent, i, false); - Render(parent, i, true); + for (int i = 0; i<4; i++) + { + Render(parent, i, false); + Render(parent, i, true); } } -void CEditableObject::RenderAnimation(const Fmatrix&){ -} +void CEditableObject::RenderAnimation(const Fmatrix &) {} -void CEditableObject::RenderEdge(const Fmatrix& parent, CEditableMesh* mesh, CSurface* surf, u32 color) +void CEditableObject::RenderEdge(const Fmatrix &parent, CEditableMesh *mesh, CSurface *surf, u32 color) { - if (!(m_LoadState.is(LS_RBUFFERS))) DefferedLoadRP(); + if (!(m_LoadState.is(LS_RBUFFERS))) + DefferedLoadRP(); EDevice.SetShader(EDevice.m_WireShader); - if(mesh) mesh->RenderEdge(parent, surf, color); - else for(EditMeshIt _M = m_Meshes.begin();_M!=m_Meshes.end();_M++) + if (mesh) + mesh->RenderEdge(parent, surf, color); + else + for (EditMeshIt _M = m_Meshes.begin(); _M!=m_Meshes.end(); _M++) (*_M)->RenderEdge(parent, surf, color); } -void CEditableObject::RenderSelection(const Fmatrix& parent, CEditableMesh* mesh, CSurface* surf, u32 color) +void CEditableObject::RenderSelection(const Fmatrix &parent, CEditableMesh *mesh, CSurface *surf, u32 color) { - if (!(m_LoadState.is(LS_RBUFFERS))) DefferedLoadRP(); + if (!(m_LoadState.is(LS_RBUFFERS))) + DefferedLoadRP(); RCache.set_xform_world(parent); EDevice.SetShader(EDevice.m_SelectionShader); EDevice.RenderNearer(0.0005); - if(mesh) mesh->RenderSelection(parent, surf, color); - else for(EditMeshIt _M = m_Meshes.begin();_M!=m_Meshes.end();_M++) - (*_M)->RenderSelection(parent, surf, color); + if (mesh) + mesh->RenderSelection(parent, surf, color); + else + for (EditMeshIt _M = m_Meshes.begin(); _M!=m_Meshes.end(); _M++) + (*_M)->RenderSelection(parent, surf, color); EDevice.ResetNearer(); } -IC static void CalculateLODTC(int frame, int w_cnt, int h_cnt, Fvector2& lt, Fvector2& rb) +IC static + +void CalculateLODTC(int frame, int w_cnt, int h_cnt, Fvector2 <, Fvector2 &rb) { - Fvector2 ts; - ts.set (1.f/(float)w_cnt,1.f/(float)h_cnt); - lt.x = (frame%w_cnt+0)*ts.x+half_p_x; - lt.y = (frame/w_cnt+0)*ts.y+half_p_y; - rb.x = (frame%w_cnt+1)*ts.x-half_p_x; - rb.y = (frame/w_cnt+1)*ts.y-half_p_y; + Fvector2 ts; + ts.set(1.f/(float)w_cnt, 1.f/(float)h_cnt); + lt.x = (frame%w_cnt+0)*ts.x+half_p_x; + lt.y = (frame/w_cnt+0)*ts.y+half_p_y; + rb.x = (frame%w_cnt+1)*ts.x-half_p_x; + rb.y = (frame/w_cnt+1)*ts.y-half_p_y; } -void CEditableObject::GetLODFrame(int frame, Fvector p[4], Fvector2 t[4], const Fmatrix* parent) +void CEditableObject::GetLODFrame(int frame, Fvector p[4], Fvector2 t[4], const Fmatrix *parent) { - R_ASSERT(m_objectFlags.is(eoUsingLOD)); - Fvector P,S; - m_BBox.get_CD (P,S); - float r = _max(S.x,S.z);//sqrtf(S.x*S.x+S.z*S.z); - Fmatrix T,matrix,rot; - T.scale (r,S.y,r); + R_ASSERT(m_objectFlags.is(eoUsingLOD)); + Fvector P, S; + m_BBox.get_CD(P, S); + float r = _max(S.x, S.z);//sqrtf(S.x*S.x+S.z*S.z); + Fmatrix T, matrix, rot; + T.scale(r, S.y, r); T.translate_over(P); - if (parent) - T.mulA_43(*parent); + if (parent) + T.mulA_43(*parent); - float angle = frame*(PI_MUL_2/float(LOD_SAMPLE_COUNT)); + float angle = frame*(PI_MUL_2/float(LOD_SAMPLE_COUNT)); rot.rotateY(-angle); - matrix.mul(T,rot); + matrix.mul(T, rot); Fvector2 lt, rb; - CalculateLODTC(frame,LOD_SAMPLE_COUNT,1,lt,rb); + CalculateLODTC(frame,LOD_SAMPLE_COUNT, 1, lt, rb); t[0].set(lt); - t[1].set(rb.x,lt.y); + t[1].set(rb.x, lt.y); t[2].set(rb); - t[3].set(lt.x,rb.y); - matrix.transform_tiny(p[0],LOD_pos[0]); - matrix.transform_tiny(p[1],LOD_pos[1]); - matrix.transform_tiny(p[2],LOD_pos[2]); - matrix.transform_tiny(p[3],LOD_pos[3]); + t[3].set(lt.x, rb.y); + matrix.transform_tiny(p[0], LOD_pos[0]); + matrix.transform_tiny(p[1], LOD_pos[1]); + matrix.transform_tiny(p[2], LOD_pos[2]); + matrix.transform_tiny(p[3], LOD_pos[3]); } -void CEditableObject::RenderLOD(const Fmatrix& parent) +void CEditableObject::RenderLOD(const Fmatrix &parent) { Fvector C; - C.sub (parent.c,EDevice.m_Camera.GetPosition()); C.y = 0; - float m = C.magnitude(); - if (mmax_dot){ - max_dot = dot; + if (dot>max_dot) + { + max_dot = dot; max_frame = frame; } } - { - Fvector p[4]; - Fvector2 t[4]; - GetLODFrame(max_frame,p,t); - for (int i=0; i<4; i++){ LOD[i].p.set(p[i]); LOD[i].t.set(t[i]); } - RCache.set_xform_world(parent); - EDevice.SetShader (m_LODShader?m_LODShader:EDevice.m_WireShader); - DU_impl.DrawPrimitiveLIT (D3DPT_TRIANGLEFAN, 2, LOD, 4, true, false); + { + Fvector p[4]; + Fvector2 t[4]; + GetLODFrame(max_frame, p, t); + for (int i = 0; i<4; i++) + { + LOD[i].p.set(p[i]); + LOD[i].t.set(t[i]); + } + RCache.set_xform_world(parent); + EDevice.SetShader(m_LODShader ? m_LODShader : EDevice.m_WireShader); + DU_impl.DrawPrimitiveLIT(D3DPT_TRIANGLEFAN, 2, LOD, 4, true, false); } } xr_string CEditableObject::GetLODTextureName() { - string512 nm; strcpy (nm,m_LibName.c_str()); _ChangeSymbol(nm,'\\','_'); - xr_string l_name; - l_name = xr_string("lod_")+nm; + string512 nm; + strcpy(nm, m_LibName.c_str()); + _ChangeSymbol(nm, '\\', '_'); + xr_string l_name; + l_name = xr_string("lod_")+nm; return ImageLib.UpdateFileName(l_name); } -void CEditableObject::OnDeviceCreate() -{ -} +void CEditableObject::OnDeviceCreate() {} void CEditableObject::OnDeviceDestroy() { - DefferedUnloadRP(); + DefferedUnloadRP(); } void CEditableObject::DefferedLoadRP() { - if (m_LoadState.is(LS_RBUFFERS)) return; + if (m_LoadState.is(LS_RBUFFERS)) + return; // skeleton - if (IsSkeleton()) - vs_SkeletonGeom.create(FVF_SV,RCache.Vertex.Buffer(),RCache.Index.Buffer()); + if (IsSkeleton()) + vs_SkeletonGeom.create(FVF_SV, RCache.Vertex.Buffer(), RCache.Index.Buffer()); -//*/ - // ñîçäàòü LOD shader - xr_string l_name = GetLODTextureName(); + //*/ + // ñîçäàòü LOD shader + xr_string l_name = GetLODTextureName(); xr_string fname = xr_string(l_name)+xr_string(".dds"); m_LODShader.destroy(); -// if (FS.exist(_game_textures_,fname.c_str())) + // if (FS.exist(_game_textures_,fname.c_str())) if (m_objectFlags.is(eoUsingLOD)) - m_LODShader.create(GetLODShaderName(),l_name.c_str()); - m_LoadState.set(LS_RBUFFERS,TRUE); + m_LODShader.create(GetLODShaderName(), l_name.c_str()); + m_LoadState.set(LS_RBUFFERS, TRUE); } + void CEditableObject::DefferedUnloadRP() { - if (!(m_LoadState.is(LS_RBUFFERS))) return; + if (!(m_LoadState.is(LS_RBUFFERS))) + return; // skeleton - vs_SkeletonGeom.destroy(); + vs_SkeletonGeom.destroy(); // óäàëèòü áóôåðà - for (EditMeshIt _M=m_Meshes.begin(); _M!=m_Meshes.end(); _M++) - if (*_M) (*_M)->GenerateRenderBuffers(); - // óäàëèòü shaders - for(SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) + for (EditMeshIt _M = m_Meshes.begin(); _M!=m_Meshes.end(); _M++) + if (*_M) + (*_M)->GenerateRenderBuffers(); + // óäàëèòü shaders + for (SurfaceIt s_it = m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) (*s_it)->OnDeviceDestroy(); // LOD m_LODShader.destroy(); - m_LoadState.set(LS_RBUFFERS,FALSE); + m_LoadState.set(LS_RBUFFERS, FALSE); } + void CEditableObject::EvictObject() { - EditMeshIt m = m_Meshes.begin(); - for(;m!=m_Meshes.end();m++){ - (*m)->UnloadCForm (); - (*m)->UnloadVNormals (true); - (*m)->UnloadSVertices (true); - (*m)->UnloadFNormals (true); + EditMeshIt m = m_Meshes.begin(); + for (; m!=m_Meshes.end(); m++) + { + (*m)->UnloadCForm(); + (*m)->UnloadVNormals(true); + (*m)->UnloadSVertices(true); + (*m)->UnloadFNormals(true); } - DefferedUnloadRP (); + DefferedUnloadRP(); } //bool CEditableObject::PrepareOGF(IWriter& F, u8 infl, bool gen_tb, CEditableMesh* mesh) @@ -353,33 +382,39 @@ void CEditableObject::EvictObject() //} //--------------------------------------------------------------------------- -void __fastcall CEditableObject::OnChangeTransform(PropValue*) +void __fastcall CEditableObject::OnChangeTransform(PropValue *) { - UI->RedrawScene(); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- -//. #include "../../xrEngine/blenders/Blender.h" -IC BOOL BE (BOOL A, BOOL B) +//#include "Layers/xrRender/blenders/Blender.h" +IC BOOL BE(BOOL A, BOOL B) { bool a = !!A; bool b = !!B; return a==b; } + bool CEditableObject::CheckShaderCompatible() { - bool bRes = true; - for(SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) + bool bRes = true; + for (SurfaceIt s_it = m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) { - IBlender* B = EDevice.Resources->_FindBlender(*(*s_it)->m_ShaderName); - Shader_xrLC* C = EDevice.ShaderXRLC.Get(*(*s_it)->m_ShaderXRLCName); - if (!B||!C){ - ELog.Msg (mtError,"Object '%s': invalid or missing shader [E:'%s', C:'%s']",GetName(),(*s_it)->_ShaderName(),(*s_it)->_ShaderXRLCName()); - bRes = false; - }else{ - if (!BE(B->canBeLMAPped(),!C->flags.bLIGHT_Vertex)){ - ELog.Msg (mtError,"Object '%s': engine shader '%s' non compatible with compiler shader '%s'",GetName(),(*s_it)->_ShaderName(),(*s_it)->_ShaderXRLCName()); - bRes = false; + IBlender *B = EDevice.Resources->_FindBlender(*(*s_it)->m_ShaderName); + Shader_xrLC *C = EDevice.ShaderXRLC.Get(*(*s_it)->m_ShaderXRLCName); + if (!B||!C) + { + ELog.Msg(mtError, "Object '%s': invalid or missing shader [E:'%s', C:'%s']", GetName(), (*s_it)->_ShaderName(), (*s_it)->_ShaderXRLCName()); + bRes = false; + } + else + { + if (!BE(B->canBeLMAPped(), !C->flags.bLIGHT_Vertex)) + { + ELog.Msg(mtError, "Object '%s': engine shader '%s' non compatible with compiler shader '%s'", GetName(), (*s_it)->_ShaderName(), (*s_it)->_ShaderXRLCName()); + bRes = false; } } } @@ -468,58 +503,57 @@ void CEditableObject::DeleteBone(CBone* bone) #endif //--------------------------------------------------------------------------- -BPIt CEditableObject::BonePart(CBone* B) +BPIt CEditableObject::BonePart(CBone *B) { - BPIt it = FirstBonePart(); - BPIt it_e = LastBonePart(); - for( ;it!=it_e; ++it) + BPIt it = FirstBonePart(); + BPIt it_e = LastBonePart(); + for (; it!=it_e; ++it) { - RStringVec::iterator iit = (*it).bones.begin(); - RStringVec::iterator iit_e = (*it).bones.end(); - for( ;iit!=iit_e; ++iit) + RStringVec::iterator iit = (*it).bones.begin(); + RStringVec::iterator iit_e = (*it).bones.end(); + for (; iit!=iit_e; ++iit) { - if(*iit==B->Name()) - return it; + if (*iit==B->Name()) + return it; } } return it_e; } -void CEditableObject::RenameBone(CBone* bone, LPCSTR new_name) +void CEditableObject::RenameBone(CBone *bone, LPCSTR new_name) { - BPIt bpit = BonePart(bone); - RStringVec::iterator iit = (*bpit).bones.begin(); - RStringVec::iterator iit_e = (*bpit).bones.end(); + BPIt bpit = BonePart(bone); + RStringVec::iterator iit = (*bpit).bones.begin(); + RStringVec::iterator iit_e = (*bpit).bones.end(); - for( ;iit!=iit_e; ++iit) + for (; iit!=iit_e; ++iit) { - if(*iit==bone->Name()) + if (*iit==bone->Name()) { *iit = new_name; break; } } - for (BoneIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); ++b_it) + for (BoneIt b_it = m_Bones.begin(); b_it!=m_Bones.end(); ++b_it) { - CBone* B = *b_it; - if(B->ParentName()==bone->Name()) - B->SetParentName(new_name); + CBone *B = *b_it; + if (B->ParentName()==bone->Name()) + B->SetParentName(new_name); } - for (SMotionIt s_it=m_SMotions.begin(); s_it!=m_SMotions.end(); ++s_it) + for (SMotionIt s_it = m_SMotions.begin(); s_it!=m_SMotions.end(); ++s_it) { - CSMotion* M = *s_it; - for(BoneMotionIt bm_it=M->BoneMotions().begin(); bm_it!=M->BoneMotions().end(); ++bm_it) + CSMotion *M = *s_it; + for (BoneMotionIt bm_it = M->BoneMotions().begin(); bm_it!=M->BoneMotions().end(); ++bm_it) { - if(bm_it->name == bone->Name()) + if (bm_it->name==bone->Name()) bm_it->name = new_name; } - } - bone->SetName(new_name); - + bone->SetName(new_name); + Modified(); } diff --git a/src/editors/ECore/Editor/EditObjectIO.cpp b/src/editors/ECore/Editor/EditObjectIO.cpp index c30597a7508..4e12222bfb1 100644 --- a/src/editors/ECore/Editor/EditObjectIO.cpp +++ b/src/editors/ECore/Editor/EditObjectIO.cpp @@ -10,11 +10,11 @@ #include "xrCore/Animation/Bone.hpp" #include "xrCore/Animation/Motion.hpp" - #include "exportskeleton.h" - #include "exportobjectOGF.h" +#include "exportskeleton.h" +#include "exportobjectOGF.h" #ifdef _EDITOR - #include "Shader.h" +#include "Layers/xrRender/Shader.h" bool CEditableObject::Load(const char* fname) { @@ -38,165 +38,167 @@ bool CEditableObject::Load(const char* fname) } #endif -bool CEditableObject::Save(const char* fname) +bool CEditableObject::Save(const char *fname) { - if (IsModified()) - { + if (IsModified()) + { // update transform matrix - Fmatrix mTransform, mScale, mTranslate, mRotate; - if ( !fsimilar(t_vRotate.magnitude(),0)|| - !fsimilar(t_vScale.magnitude(),1.73205f)|| - !fsimilar(t_vPosition.magnitude(),0)) + Fmatrix mTransform, mScale, mTranslate, mRotate; + if (!fsimilar(t_vRotate.magnitude(), 0)|| + !fsimilar(t_vScale.magnitude(), 1.73205f)|| + !fsimilar(t_vPosition.magnitude(), 0)) { - mRotate.setHPB (t_vRotate.y, t_vRotate.x, t_vRotate.z); - mScale.scale (t_vScale); - mTranslate.translate (t_vPosition); - mTransform.mul (mTranslate,mRotate); - mTransform.mulB_43 (mScale); - TranslateToWorld (mTransform); - t_vRotate.set (0,0,0); - t_vPosition.set (0,0,0); - t_vScale.set (1,1,1); + mRotate.setHPB(t_vRotate.y, t_vRotate.x, t_vRotate.z); + mScale.scale(t_vScale); + mTranslate.translate(t_vPosition); + mTransform.mul(mTranslate, mRotate); + mTransform.mulB_43(mScale); + TranslateToWorld(mTransform); + t_vRotate.set(0, 0, 0); + t_vPosition.set(0, 0, 0); + t_vScale.set(1, 1, 1); } } // save object - IWriter* F = FS.w_open(fname); - if (F) - { - F->open_chunk (EOBJ_CHUNK_OBJECT_BODY); - Save (*F); - F->close_chunk (); - - FS.w_close (F); - - m_LoadName = fname; - m_ObjectVersion = (int)FS.get_file_age(fname); - VERIFY3 (m_ObjectVersion>0,"Invalid file age:",fname); - return true; - }else{ - return false; + IWriter *F = FS.w_open(fname); + if (F) + { + F->open_chunk(EOBJ_CHUNK_OBJECT_BODY); + Save(*F); + F->close_chunk(); + + FS.w_close(F); + + m_LoadName = fname; + m_ObjectVersion = (int)FS.get_file_age(fname); + VERIFY3(m_ObjectVersion>0, "Invalid file age:", fname); + return true; + } + else + { + return false; } } -void CEditableObject::Save(IWriter& F) +void CEditableObject::Save(IWriter &F) { - F.open_chunk (EOBJ_CHUNK_VERSION); - F.w_u16 (EOBJ_CURRENT_VERSION); - F.close_chunk (); + F.open_chunk(EOBJ_CHUNK_VERSION); + F.w_u16(EOBJ_CURRENT_VERSION); + F.close_chunk(); - F.open_chunk (EOBJ_CHUNK_CLASSSCRIPT); - F.w_stringZ (m_ClassScript); - F.close_chunk (); + F.open_chunk(EOBJ_CHUNK_CLASSSCRIPT); + F.w_stringZ(m_ClassScript); + F.close_chunk(); - F.open_chunk (EOBJ_CHUNK_LODS); - F.w_stringZ (m_LODs); - F.close_chunk (); + F.open_chunk(EOBJ_CHUNK_LODS); + F.w_stringZ(m_LODs); + F.close_chunk(); - F.w_chunk (EOBJ_CHUNK_FLAGS,&m_objectFlags.flags,sizeof(m_objectFlags.flags)); + F.w_chunk(EOBJ_CHUNK_FLAGS, &m_objectFlags.flags, sizeof(m_objectFlags.flags)); // meshes - F.open_chunk (EOBJ_CHUNK_EDITMESHES); - int count = 0; + F.open_chunk(EOBJ_CHUNK_EDITMESHES); + int count = 0; - for(EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); ++m) - { - F.open_chunk(count); - ++count; + for (EditMeshIt m = m_Meshes.begin(); m!=m_Meshes.end(); ++m) + { + F.open_chunk(count); + ++count; (*m)->SaveMesh(F); F.close_chunk(); } - F.close_chunk (); + F.close_chunk(); - // surfaces - F.open_chunk (EOBJ_CHUNK_SURFACES3); - F.w_u32 (m_Surfaces.size()); + // surfaces + F.open_chunk(EOBJ_CHUNK_SURFACES3); + F.w_u32(m_Surfaces.size()); - for (SurfaceIt sf_it=m_Surfaces.begin(); sf_it!=m_Surfaces.end(); ++sf_it) - { - F.w_stringZ ((*sf_it)->_Name ()); - F.w_stringZ ((*sf_it)->_ShaderName ()); - F.w_stringZ ((*sf_it)->_ShaderXRLCName ()); - F.w_stringZ ((*sf_it)->_GameMtlName ()); - F.w_stringZ ((*sf_it)->_Texture ()); - F.w_stringZ ((*sf_it)->_VMap ()); - F.w_u32 ((*sf_it)->m_Flags.get ()); - F.w_u32 ((*sf_it)->_FVF ()); - F.w_u32 (1); + for (SurfaceIt sf_it = m_Surfaces.begin(); sf_it!=m_Surfaces.end(); ++sf_it) + { + F.w_stringZ((*sf_it)->_Name()); + F.w_stringZ((*sf_it)->_ShaderName()); + F.w_stringZ((*sf_it)->_ShaderXRLCName()); + F.w_stringZ((*sf_it)->_GameMtlName()); + F.w_stringZ((*sf_it)->_Texture()); + F.w_stringZ((*sf_it)->_VMap()); + F.w_u32((*sf_it)->m_Flags.get()); + F.w_u32((*sf_it)->_FVF()); + F.w_u32(1); } - F.close_chunk (); + F.close_chunk(); // bones - if (!m_Bones.empty()){ - F.open_chunk (EOBJ_CHUNK_BONES2); - for (BoneIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); ++b_it) - { - F.open_chunk (b_it-m_Bones.begin()); - (*b_it)->Save (F); - F.close_chunk (); + if (!m_Bones.empty()) + { + F.open_chunk(EOBJ_CHUNK_BONES2); + for (BoneIt b_it = m_Bones.begin(); b_it!=m_Bones.end(); ++b_it) + { + F.open_chunk(b_it-m_Bones.begin()); + (*b_it)->Save(F); + F.close_chunk(); } - F.close_chunk (); + F.close_chunk(); } // skeleton motions if (!m_SMotions.empty()) { - F.open_chunk (EOBJ_CHUNK_SMOTIONS); - F.w_u32 (m_SMotions.size()); - - for (SMotionIt s_it=m_SMotions.begin(); s_it!=m_SMotions.end(); ++s_it) - (*s_it)->Save(F); + F.open_chunk(EOBJ_CHUNK_SMOTIONS); + F.w_u32(m_SMotions.size()); + + for (SMotionIt s_it = m_SMotions.begin(); s_it!=m_SMotions.end(); ++s_it) + (*s_it)->Save(F); - F.close_chunk (); + F.close_chunk(); } // skeleton motions refs if (m_SMotionRefs.size()) { - F.open_chunk (EOBJ_CHUNK_SMOTIONS3); - F.w_u32 (m_SMotionRefs.size()); + F.open_chunk(EOBJ_CHUNK_SMOTIONS3); + F.w_u32(m_SMotionRefs.size()); - for(u32 i=0; ialias); - F.w_u32 (bp_it->bones.size()); - - for (RStringVecIt s_it=bp_it->bones.begin(); s_it!=bp_it->bones.end(); ++s_it) - F.w_stringZ(s_it->c_str()); + { + F.open_chunk(EOBJ_CHUNK_BONEPARTS2); + F.w_u32(m_BoneParts.size()); + for (BPIt bp_it = m_BoneParts.begin(); bp_it!=m_BoneParts.end(); ++bp_it) + { + F.w_stringZ(bp_it->alias); + F.w_u32(bp_it->bones.size()); + for (RStringVecIt s_it = bp_it->bones.begin(); s_it!=bp_it->bones.end(); ++s_it) + F.w_stringZ(s_it->c_str()); } - F.close_chunk (); + F.close_chunk(); } if (IsDynamic()) - { - F.open_chunk (EOBJ_CHUNK_ACTORTRANSFORM); - F.w_fvector3 (a_vPosition); - F.w_fvector3 (a_vRotate); - F.close_chunk (); + { + F.open_chunk(EOBJ_CHUNK_ACTORTRANSFORM); + F.w_fvector3(a_vPosition); + F.w_fvector3(a_vRotate); + F.close_chunk(); } - F.open_chunk (EOBJ_CHUNK_DESC); - F.w_stringZ (m_CreateName.c_str()); - F.w (&m_CreateTime,sizeof(m_CreateTime)); - F.w_stringZ (m_ModifName.c_str()); - F.w (&m_ModifTime,sizeof(m_ModifTime)); - F.close_chunk (); + F.open_chunk(EOBJ_CHUNK_DESC); + F.w_stringZ(m_CreateName.c_str()); + F.w(&m_CreateTime, sizeof(m_CreateTime)); + F.w_stringZ(m_ModifName.c_str()); + F.w(&m_ModifTime, sizeof(m_ModifTime)); + F.close_chunk(); // set modif desc - SetVersionToCurrent (FALSE, TRUE); + SetVersionToCurrent(FALSE, TRUE); - bOnModified = false; + bOnModified = false; } #if defined(_EDITOR) || defined(_MAYA_EXPORT) @@ -224,7 +226,7 @@ bool CEditableObject::Load(IReader& F) if (F.find_chunk (EOBJ_CHUNK_LODS)) F.r_stringZ (m_LODs); - // surfaces +// surfaces if (F.find_chunk(EOBJ_CHUNK_SURFACES3)) { u32 cnt = F.r_u32(); @@ -280,14 +282,14 @@ bool CEditableObject::Load(IReader& F) (*s_it)->SetShaderXRLC ("default"); } - // surfaces xrlc part +// surfaces xrlc part if(F.find_chunk(EOBJ_CHUNK_SURFACES_XRLC)) for (s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ F.r_stringZ(buf); (*s_it)->SetShaderXRLC(buf.c_str()); } } - // Load meshes +// Load meshes IReader* OBJ = F.open_chunk(EOBJ_CHUNK_EDITMESHES); if(OBJ) { @@ -309,7 +311,7 @@ bool CEditableObject::Load(IReader& F) OBJ->close(); } - // bones +// bones if (bRes){ IReader* B_CHUNK = F.open_chunk(EOBJ_CHUNK_BONES2); if (B_CHUNK) @@ -333,7 +335,7 @@ bool CEditableObject::Load(IReader& F) PrepareBones(); } - // skeleton motions +// skeleton motions if (F.find_chunk(EOBJ_CHUNK_SMOTIONS)) { m_SMotions.resize(F.r_u32()); @@ -347,7 +349,7 @@ bool CEditableObject::Load(IReader& F) m_SMotions.clear(); break; } - // resort bone_mots +// resort bone_mots (*s_it)->SortBonesBySkeleton(m_Bones); } } @@ -377,7 +379,7 @@ bool CEditableObject::Load(IReader& F) } } - // bone parts +// bone parts if (bRes){ if (F.find_chunk(EOBJ_CHUNK_BONEPARTS)){ m_BoneParts.resize(F.r_u32()); @@ -477,4 +479,3 @@ bool CEditableObject::ExportOBJ(LPCSTR fn) //------------------------------------------------------------------------------ #endif - diff --git a/src/editors/ECore/Editor/EditObjectImport.cpp b/src/editors/ECore/Editor/EditObjectImport.cpp index 5cd92aa64ad..b55cdb923cd 100644 --- a/src/editors/ECore/Editor/EditObjectImport.cpp +++ b/src/editors/ECore/Editor/EditObjectImport.cpp @@ -10,15 +10,16 @@ #include "LW_SHADERDEF.h" #include "EditMesh.h" -extern "C" { -#include "utils/LWO/lwo2.h" -}; +extern "C" +{ +#include "utils/LWO/lwo2.h" }; #ifdef _EDITOR - #include "ResourceManager.h" - - extern "C" __declspec(dllimport) lwObject* LWOImportObject(char* filename); - extern "C" __declspec(dllimport) void LWOCloseFile(lwObject* object); +#include "Layers/xrRender/ResourceManager.h" + +#include "xrCore/Platform.h" +extern "C" XR_IMPORT lwObject* LWOImportObject(char* filename); +extern "C" XR_IMPORT void LWOCloseFile(lwObject* object); #endif #ifdef _LW_EXPORT @@ -81,7 +82,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) gmName = "default"; } #endif - // fill texture layers + // fill texture layers u32 textureCount = 0; for (st_lwTexture* Itx = lwSurf->color.tex; Itx; Itx = Itx->next) { @@ -97,7 +98,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) } if (cidx != -1) { - // get textures + // get textures for (st_lwClip* lwClip = lwObj->clip; lwClip; lwClip = lwClip->next) { if (cidx == lwClip->index && lwClip->type == ID_STIL) @@ -115,7 +116,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) string256 textureName; _splitpath(tname, nullptr, nullptr, textureName, nullptr); surf->SetTexture(EFS.AppendFolderToName(textureName, 256, 1, true)); - // get vmap refs + // get vmap refs surf->SetVMap(Itx->param.imap.vmap_name); } } @@ -148,13 +149,13 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) mesh->SetName(lwLayer->name ? lwLayer->name : ""); auto bbox = lwLayer->bbox; mesh->m_Box.set(bbox[0], bbox[1], bbox[2], bbox[3], bbox[4], bbox[5]); - // parse mesh(lwo-layer) data + // parse mesh(lwo-layer) data if (lwLayer->nvmaps == 0) { ELog.DlgMsg(mtError, "Import LWO: Mesh layer must contain UV map!"); goto importFailed; } - // XXX nitrocaster: incompatible with multithreaded import + // XXX nitrocaster: incompatible with multithreaded import static xr_map vmIndices; vmIndices.clear(); int vmIndex = 0; @@ -172,7 +173,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) mesh->m_VMaps.push_back(new st_VMap(lwVmap->name, vmtUV, !!lwVmap->perpoly)); st_VMap* vmap = mesh->m_VMaps.back(); vmap->copyfrom(*lwVmap->val, lwVmap->nverts); - // flip uv + // flip uv for (int uvIndex = 0; uvIndex < vmap->size(); uvIndex++) { Fvector2& uv = vmap->getUV(uvIndex); @@ -202,7 +203,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) case ID_RGBA: ELog.Msg(mtError, "Found 'RGBA' VMAP. Import failed."); goto importFailed; } } - // points + // points mesh->m_VertCount = lwLayer->point.count; mesh->m_Vertices = xr_alloc(mesh->m_VertCount); for (int i = 0; i < lwLayer->point.count; i++) @@ -211,7 +212,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) Fvector& vertex = mesh->m_Vertices[i]; vertex.set(lwPoint.pos); } - // polygons + // polygons mesh->m_FaceCount = lwLayer->polygon.count; mesh->m_Faces = xr_alloc(mesh->m_FaceCount); mesh->m_SmoothGroups = xr_alloc(mesh->m_FaceCount); @@ -235,7 +236,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) mesh->m_VMRefs.push_back(st_VMapPtLst()); st_VMapPtLst& vmPointList = mesh->m_VMRefs.back(); faceVert.vmref = mesh->m_VMRefs.size()-1; - // parse uv-map + // parse uv-map st_lwPoint& lwPoint = lwLayer->point.pt[faceVert.pindex]; if (lwFaceVert.nvmaps == 0 && lwPoint.nvmaps == 0) { @@ -244,7 +245,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) } xr_vector vmPoints; AStringVec names; - // process polys + // process polys for (int j = 0; j < lwFaceVert.nvmaps; j++) { if (lwFaceVert.vm[j].vmap->type != ID_TXUV) @@ -255,7 +256,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) names.push_back(lwFaceVert.vm[j].vmap->name); pt.index = lwFaceVert.vm[j].index; } - // process points + // process points for (int j = 0; j < lwPoint.nvmaps; j++) { if (lwPoint.vm[j].vmap->type != ID_TXUV) @@ -270,7 +271,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) auto cmpFunc = [](const st_VMapPt& a, const st_VMapPt& b) { return a.vmap_index < b.vmap_index; }; std::sort(vmPoints.begin(), vmPoints.end(), cmpFunc); - // parse weight-map + // parse weight-map for (int j = 0; j < lwPoint.nvmaps; j++) { if (lwPoint.vm[j].vmap->type != ID_WGHT) @@ -284,7 +285,7 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) vmPointList.pts = xr_alloc(vmPointList.count); memcpy(vmPointList.pts, &*vmPoints.begin(), vmPointList.count*sizeof(st_VMapPt)); } - // lwPoly.surf->alpha_mode stores reviously saved surface id + // lwPoly.surf->alpha_mode stores reviously saved surface id surfIds[i] = lwPoly.surf->alpha_mode; } for (u32 polyId = 0; polyId < mesh->GetFCount(); polyId++) @@ -311,3 +312,4 @@ bool CEditableObject::ImportLWO(const char* fn, bool optimize) return result; } #endif + diff --git a/src/editors/ECore/Editor/EditObjectMotions.cpp b/src/editors/ECore/Editor/EditObjectMotions.cpp index 7e5b56f1d4f..1777e155997 100644 --- a/src/editors/ECore/Editor/EditObjectMotions.cpp +++ b/src/editors/ECore/Editor/EditObjectMotions.cpp @@ -7,7 +7,7 @@ #include "EditObject.h" #ifdef _EDITOR - #include "ui_main.h" +#include "ui_main.h" #endif #include "xrCore/Animation/Motion.hpp" @@ -16,27 +16,46 @@ #ifdef _EDITOR - #include "SkeletonAnimated.h" - #include "AnimationKeyCalculate.h" +#include "Layers/xrRender/SkeletonAnimated.h" +#include "Layers/xrRender/AnimationKeyCalculate.h" #endif #ifndef _EDITOR - bool check_scale( Fmatrix F ){ return true;} +bool check_scale(Fmatrix F) +{ + return true; +} #endif //---------------------------------------------------- -class fBoneNameEQ { - shared_str name; +class fBoneNameEQ +{ + shared_str name; public: - fBoneNameEQ(shared_str N) : name(N) {}; - IC bool operator() (CBone* B) { return (xr_strcmp(B->Name(),name)==0); } + fBoneNameEQ(shared_str N) : name(N) {}; + + IC + + bool operator()(CBone *B) + { + return (xr_strcmp(B->Name(), name)==0); + } }; -class fBoneWMNameEQ { - shared_str wm_name; + +class fBoneWMNameEQ +{ + shared_str wm_name; public: - fBoneWMNameEQ(shared_str N) : wm_name(N) {}; - IC bool operator() (CBone* B) { return (xr_strcmp(B->WMap(),wm_name)==0); } + fBoneWMNameEQ(shared_str N) : wm_name(N) {}; + + IC + + bool operator()(CBone *B) + { + return (xr_strcmp(B->WMap(), wm_name)==0); + } }; + //---------------------------------------------------- #ifdef _EDITOR extern CBone* bone_to_delete; @@ -55,7 +74,7 @@ void CEditableObject::OnFrame() } m_SMParam.Update(EDevice.fTimeDelta,m_ActiveSMotion->fSpeed,!m_ActiveSMotion->m_Flags.is(esmStopAtEnd)); }else{ - //for (BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++) (*b_it)->Reset(); +//for (BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++) (*b_it)->Reset(); } CalculateAnimation(m_ActiveSMotion); } @@ -69,8 +88,9 @@ void CEditableObject::OnFrame() void CEditableObject::OnBindTransformChange() { - for(EditMeshIt mesh_it=FirstMesh();mesh_it!=LastMesh();mesh_it++){ - CEditableMesh* MESH = *mesh_it; + for (EditMeshIt mesh_it = FirstMesh(); mesh_it!=LastMesh(); mesh_it++) + { + CEditableMesh*MESH = *mesh_it; MESH->UnloadSVertices(true); } GotoBindPose(); @@ -78,134 +98,142 @@ void CEditableObject::OnBindTransformChange() void CEditableObject::GotoBindPose() { - BoneVec& lst = m_Bones; - for (BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++) (*b_it)->Reset(); + BoneVec &lst = m_Bones; + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); b_it++) + (*b_it)->Reset(); CalculateAnimation(0); #ifdef _EDITOR UI->RedrawScene(); #endif } -CSMotion* CEditableObject::ResetSAnimation(bool bGotoBindPose) +CSMotion *CEditableObject::ResetSAnimation(bool bGotoBindPose) { - CSMotion* M=m_ActiveSMotion; - SetActiveSMotion(0); + CSMotion *M = m_ActiveSMotion; + SetActiveSMotion(0); if (bGotoBindPose) - GotoBindPose(); + GotoBindPose(); return M; } //---------------------------------------------------- // Skeletal motion //---------------------------------------------------- -static void CalculateAnimBone(CBone* bone, CSMotion* motion, Fmatrix& parent) +static void CalculateAnimBone(CBone *bone, CSMotion *motion, Fmatrix &parent) { - Flags8 flags; flags.zero(); + Flags8 flags; + flags.zero(); if (motion) - flags = motion->GetMotionFlags(bone->SelfID); + flags = motion->GetMotionFlags(bone->SelfID); + + Fmatrix &M = bone->_MTransform(); + Fmatrix &L = bone->_LTransform(); - Fmatrix& M = bone->_MTransform(); - Fmatrix& L = bone->_LTransform(); - - const Fvector& r = bone->_Rotate(); - if( ! bone->callback_overwrite() ) + const Fvector &r = bone->_Rotate(); + if (! bone->callback_overwrite()) { - if ( flags.is(st_BoneMotion::flWorldOrient)){ - M.setXYZi (r.x,r.y,r.z); - M.c.set (bone->_Offset()); - L.mul (parent,M); - L.i.set (M.i); - L.j.set (M.j); - L.k.set (M.k); - - Fmatrix LI; LI.invert(parent); - M.mulA_43 (LI); - }else{ - M.setXYZi (r.x,r.y,r.z); - M.c.set (bone->_Offset()); - L.mul (parent,M); + if (flags.is(st_BoneMotion::flWorldOrient)) + { + M.setXYZi(r.x, r.y, r.z); + M.c.set(bone->_Offset()); + L.mul(parent, M); + L.i.set(M.i); + L.j.set(M.j); + L.k.set(M.k); + + Fmatrix LI; + LI.invert(parent); + M.mulA_43(LI); } - } - if( bone->callback() ) + else + { + M.setXYZi(r.x, r.y, r.z); + M.c.set(bone->_Offset()); + L.mul(parent, M); + } + } + if (bone->callback()) { - bone->callback()( bone ); - M.mul_43( Fmatrix().invert(parent), L ); - // bone->_Offset().set( M.c ); + bone->callback()(bone); + M.mul_43(Fmatrix().invert(parent), L); + // bone->_Offset().set( M.c ); } - bone->_RenderTransform().mul_43(bone->_LTransform(),bone->_RITransform()); + bone->_RenderTransform().mul_43(bone->_LTransform(), bone->_RITransform()); } -static void CalculateAnim(CBone* bone, CSMotion* motion, Fmatrix& parent) -{ - CalculateAnimBone( bone, motion, parent ); +static void CalculateAnim(CBone *bone, CSMotion *motion, Fmatrix &parent) +{ + CalculateAnimBone(bone, motion, parent); // Calculate children - for (BoneIt b_it=bone->children.begin(); b_it!=bone->children.end(); b_it++) - CalculateAnim (*b_it,motion,bone->_LTransform()); + for (BoneIt b_it = bone->children.begin(); b_it!=bone->children.end(); b_it++) + CalculateAnim(*b_it, motion, bone->_LTransform()); } - -static void CalculateRest(CBone* bone, Fmatrix& parent) +static void CalculateRest(CBone *bone, Fmatrix &parent) { - Fmatrix& R = bone->_RTransform(); - R.setXYZi (bone->_RestRotate()); - R.c.set (bone->_RestOffset()); + Fmatrix &R = bone->_RTransform(); + R.setXYZi(bone->_RestRotate()); + R.c.set(bone->_RestOffset()); bone->_LRTransform() = R; - R.mulA_43 (parent); + R.mulA_43(parent); bone->_RITransform().invert(bone->_RTransform()); // Calculate children - for (BoneIt b_it=bone->children.begin(); b_it!=bone->children.end(); b_it++) - CalculateRest (*b_it,bone->_RTransform()); + for (BoneIt b_it = bone->children.begin(); b_it!=bone->children.end(); b_it++) + CalculateRest(*b_it, bone->_RTransform()); } -void CEditableObject::CalculateAnimation(CSMotion* motion) +void CEditableObject::CalculateAnimation(CSMotion *motion) { - if (!m_Bones.empty()) - CalculateAnim(m_Bones.front(),motion,Fidentity); + if (!m_Bones.empty()) + CalculateAnim(m_Bones.front(), motion, Fidentity); } - float CEditableObject::GetBonesBottom() - { - float bottom = FLT_MAX; + +float CEditableObject::GetBonesBottom() +{ + float bottom = FLT_MAX; VERIFY(!m_Bones.empty()); - for (BoneIt b_it=m_Bones.begin()+1; b_it!=m_Bones.end(); b_it++) - if( !(*b_it)->IsRoot() && (*b_it)->_LTransform().c.y < bottom ) - bottom = (*b_it)->_LTransform().c.y; + for (BoneIt b_it = m_Bones.begin()+1; b_it!=m_Bones.end(); b_it++) + if (!(*b_it)->IsRoot()&&(*b_it)->_LTransform().c.y_LTransform().c.y; return bottom; - } +} - static void SetBoneTransform( CBone &bone, const Fmatrix &T, const Fmatrix & parent ) +static void SetBoneTransform(CBone &bone, const Fmatrix &T, const Fmatrix &parent) { - - bone._LTransform() = T; - Fmatrix LI; LI.invert(parent); - bone._MTransform().mul_43( LI, T ); - bone._RenderTransform().mul_43(bone._LTransform(),bone._RITransform()); + bone._LTransform() = T; + Fmatrix LI; + LI.invert(parent); + bone._MTransform().mul_43(LI, T); + bone._RenderTransform().mul_43(bone._LTransform(), bone._RITransform()); } -bool CEditableObject::AnimateRootObject( CSMotion* motion ) -{ - VERIFY( motion ); - if( !motion->m_Flags.test(esmRootMover) ) - return false; - CBone &root_bone = *m_Bones[GetRootBoneID()]; - if( root_bone.children.size() != 1 ) - return false; - return true; +bool CEditableObject::AnimateRootObject(CSMotion *motion) +{ + VERIFY(motion); + if (!motion->m_Flags.test(esmRootMover)) + return false; + CBone &root_bone = *m_Bones[GetRootBoneID()]; + if (root_bone.children.size()!=1) + return false; + return true; } -void CEditableObject::GetAnchorForRootObjectAnimation( Fmatrix &anchor ) + +void CEditableObject::GetAnchorForRootObjectAnimation(Fmatrix &anchor) { - CBone &root_bone = *m_Bones[GetRootBoneID()]; - VERIFY( root_bone .children.size() == 1 ); - CBone &anchor_bone = *root_bone .children[0]; - anchor = anchor_bone._LTransform(); - anchor.invert(); + CBone &root_bone = *m_Bones[GetRootBoneID()]; + VERIFY(root_bone.children.size()==1); + CBone &anchor_bone = *root_bone.children[0]; + anchor = anchor_bone._LTransform(); + anchor.invert(); } + static void AlineYtoGlobalFrame(Fmatrix &in_out_m) { - Fmatrix &m = in_out_m; - + Fmatrix &m = in_out_m; + m.i.y = 0; m.k.y = 0; @@ -213,87 +241,94 @@ static void AlineYtoGlobalFrame(Fmatrix &in_out_m) m.j.y = 1; m.j.z = 0; - float smi = m.i.x * m.i.x + m.i.z * m.i.z; - float smk = m.k.x * m.k.x + m.k.z * m.k.z; - bool bi = smi > EPS_S; - bool bk = smk > EPS_S; - if( smk > smi && bk ) + float smi = m.i.x*m.i.x+m.i.z*m.i.z; + float smk = m.k.x*m.k.x+m.k.z*m.k.z; + bool bi = smi>EPS_S; + bool bk = smk>EPS_S; + if (smk>smi&&bk) { - m.k.mul( 1.f/_sqrt( smk ) ); - m.i.crossproduct( m.j, m.k ); - } else if( bi ) + m.k.mul(1.f/_sqrt(smk)); + m.i.crossproduct(m.j, m.k); + } + else if (bi) { - m.i.mul( 1.f/_sqrt( smi ) ); - m.k.crossproduct( m.i, m.j ); - }else //if( !bi && !bk ) + m.i.mul(1.f/_sqrt(smi)); + m.k.crossproduct(m.i, m.j); + } + else //if( !bi && !bk ) { - //unreal indeed + //unreal indeed m = Fidentity; } -// if ( bi && bk ) - // { - // m.i.mul( 1.f/_sqrt( smi ) ); - // m.k.mul( 1.f/_sqrt( smk ) ); - // } - - if(!check_scale( in_out_m )) - VERIFY( check_scale( in_out_m ) ); + // if ( bi && bk ) + // { + // m.i.mul( 1.f/_sqrt( smi ) ); + // m.k.mul( 1.f/_sqrt( smk ) ); + // } + + if (!check_scale(in_out_m)) + VERIFY(check_scale(in_out_m)); } + void CEditableObject::CalculateRootObjectAnimation(const Fmatrix &anchor) { - float bottom = GetBonesBottom(); - CBone &root_bone = *m_Bones[GetRootBoneID()]; - VERIFY( root_bone .children.size() == 1 ); - CBone &anchor_bone = *root_bone .children[0]; - const Fmatrix gl_anchor = Fmatrix().mul_43( anchor_bone._LTransform(), anchor ); + float bottom = GetBonesBottom(); + CBone &root_bone = *m_Bones[GetRootBoneID()]; + VERIFY(root_bone.children.size()==1); + CBone &anchor_bone = *root_bone.children[0]; + const Fmatrix gl_anchor = Fmatrix().mul_43(anchor_bone._LTransform(), anchor); + + Fmatrix root_transform = gl_anchor;//gl_anchor; + AlineYtoGlobalFrame(root_transform); + + root_transform.c = gl_anchor.c; + root_transform.c.y = bottom; + SetBoneTransform(root_bone, root_transform, Fidentity); - Fmatrix root_transform = gl_anchor;//gl_anchor; - AlineYtoGlobalFrame( root_transform ); + SetBoneTransform(anchor_bone, anchor_bone._LTransform(), root_transform); - root_transform.c = gl_anchor.c; - root_transform.c.y=bottom; - SetBoneTransform( root_bone, root_transform, Fidentity ); - - SetBoneTransform( anchor_bone, anchor_bone._LTransform(), root_transform ); - - // for (BoneIt b_it=root_bone .children.begin(); b_it!=root_bone .children.end(); b_it++) - // SetBoneTransform( *(*b_it), (*(*b_it))._LTransform(), root_transform ); + // for (BoneIt b_it=root_bone .children.begin(); b_it!=root_bone .children.end(); b_it++) + // SetBoneTransform( *(*b_it), (*(*b_it))._LTransform(), root_transform ); } + void CEditableObject::CalculateBindPose() { - if (!m_Bones.empty()) - CalculateRest(m_Bones.front(),Fidentity); + if (!m_Bones.empty()) + CalculateRest(m_Bones.front(), Fidentity); } -void CEditableObject::SetActiveSMotion(CSMotion* mot) +void CEditableObject::SetActiveSMotion(CSMotion *mot) { - m_ActiveSMotion=mot; - if (m_ActiveSMotion) m_SMParam.Set(m_ActiveSMotion); + m_ActiveSMotion = mot; + if (m_ActiveSMotion) + m_SMParam.Set(m_ActiveSMotion); } -bool CEditableObject::RemoveSMotion(const char* name) +bool CEditableObject::RemoveSMotion(const char *name) { - SMotionVec& lst = m_SMotions; - for(SMotionIt m=lst.begin(); m!=lst.end(); m++) - if ((stricmp((*m)->Name(),name)==0)){ - if (m_ActiveSMotion==*m) SetActiveSMotion(0); + SMotionVec &lst = m_SMotions; + for (SMotionIt m = lst.begin(); m!=lst.end(); m++) + if ((stricmp((*m)->Name(), name)==0)) + { + if (m_ActiveSMotion==*m) + SetActiveSMotion(0); xr_delete(*m); - lst.erase(m); + lst.erase(m); return true; } return false; -} +} //--------------------------------------------------------------------------- /* bool CEditableObject::LoadSMotions(const char* fname) { - IReader* F = FS.r_open(fname); + IReader* F = FS.r_open(fname); ClearSMotions(); // object motions m_SMotions.resize(F->r_u32()); - SetActiveSMotion(0); + SetActiveSMotion(0); for (SMotionIt m_it=m_SMotions.begin(); m_it!=m_SMotions.end(); m_it++){ *m_it = xr_new(); if (!(*m_it)->Load(*F)){ @@ -303,80 +338,97 @@ bool CEditableObject::LoadSMotions(const char* fname) FS.r_close(F); return false; } - if (!CheckBoneCompliance(*m_it)){ - ClearSMotions(); + if (!CheckBoneCompliance(*m_it)){ + ClearSMotions(); ELog.DlgMsg(mtError,"Load failed.",fname); xr_delete(&*m_it); FS.r_close(F); return false; } } - FS.r_close(F); - return true; + FS.r_close(F); + return true; } */ -bool CEditableObject::AppendSMotion(LPCSTR fname, SMotionVec* inserted) +bool CEditableObject::AppendSMotion(LPCSTR fname, SMotionVec *inserted) { - VERIFY(IsSkeleton()); + VERIFY(IsSkeleton()); - bool bRes = true; - - LPCSTR ext = strext(fname); - if (0==stricmp(ext,".skl")){ - CSMotion* M = xr_new(); - if (!M->LoadMotion(fname)){ - ELog.Msg(mtError,"Motion '%s' can't load. Append failed.",fname); + bool bRes = true; + + LPCSTR ext = strext(fname); + if (0==stricmp(ext, ".skl")) + { + CSMotion *M = xr_new(); + if (!M->LoadMotion(fname)) + { + ELog.Msg(mtError, "Motion '%s' can't load. Append failed.", fname); xr_delete(M); bRes = false; - }else{ - string256 name; - _splitpath(fname,0,0,name,0); - if (CheckBoneCompliance(M)){ + } + else + { + string256 name; + _splitpath(fname, 0, 0, name, 0); + if (CheckBoneCompliance(M)) + { M->SortBonesBySkeleton(m_Bones); - string256 m_name; - GenerateSMotionName (m_name,name,M); - M->SetName (m_name); + string256 m_name; + GenerateSMotionName(m_name, name, M); + M->SetName(m_name); m_SMotions.push_back(M); - if (inserted) inserted->push_back(M); + if (inserted) + inserted->push_back(M); // optimize - M->Optimize (); - }else{ - ELog.Msg(mtError,"Append failed.",fname); + M->Optimize(); + } + else + { + ELog.Msg(mtError, "Append failed.", fname); xr_delete(M); - bRes = false; + bRes = false; } } - }else if (0==stricmp(ext,".skls")){ - IReader* F = FS.r_open(fname); - if (!F){ - ELog.Msg(mtError,"Can't open file '%s'.",fname); + } + else if (0==stricmp(ext, ".skls")) + { + IReader *F = FS.r_open(fname); + if (!F) + { + ELog.Msg(mtError, "Can't open file '%s'.", fname); bRes = false; - } - if (bRes){ + } + if (bRes) + { // object motions - int cnt = F->r_u32(); - for (int k=0; k(); - if (!M->Load(*F)){ - ELog.Msg(mtError,"Motion '%s' has different version. Load failed.",M->Name()); + int cnt = F->r_u32(); + for (int k = 0; k(); + if (!M->Load(*F)) + { + ELog.Msg(mtError, "Motion '%s' has different version. Load failed.", M->Name()); + xr_delete(M); + bRes = false; + break; + } + if (!CheckBoneCompliance(M)) + { xr_delete(M); bRes = false; break; } - if (!CheckBoneCompliance(M)){ - xr_delete(M); - bRes = false; - break; - } - if (bRes){ + if (bRes) + { M->SortBonesBySkeleton(m_Bones); - string256 m_name; - GenerateSMotionName (m_name,M->Name(),M); - M->SetName (m_name); + string256 m_name; + GenerateSMotionName(m_name, M->Name(), M); + M->SetName(m_name); m_SMotions.push_back(M); - if (inserted) inserted->push_back(M); + if (inserted) + inserted->push_back(M); // optimize - M->Optimize (); + M->Optimize(); } } } @@ -387,172 +439,201 @@ bool CEditableObject::AppendSMotion(LPCSTR fname, SMotionVec* inserted) void CEditableObject::ClearSMotions() { - SetActiveSMotion(0); - for(SMotionIt m_it=m_SMotions.begin(); m_it!=m_SMotions.end();m_it++)xr_delete(*m_it); + SetActiveSMotion(0); + for (SMotionIt m_it = m_SMotions.begin(); m_it!=m_SMotions.end(); m_it++) + xr_delete(*m_it); m_SMotions.clear(); } -bool CEditableObject::SaveSMotions(const char* fname) +bool CEditableObject::SaveSMotions(const char *fname) { - CMemoryWriter F; - F.w_u32 (m_SMotions.size()); - for (SMotionIt m_it=m_SMotions.begin(); m_it!=m_SMotions.end(); m_it++) (*m_it)->Save(F); - return F.save_to(fname); + CMemoryWriter F; + F.w_u32(m_SMotions.size()); + for (SMotionIt m_it = m_SMotions.begin(); m_it!=m_SMotions.end(); m_it++) + (*m_it)->Save(F); + return F.save_to(fname); } -bool CEditableObject::RenameSMotion(const char* old_name, const char* new_name) +bool CEditableObject::RenameSMotion(const char *old_name, const char *new_name) { - if (stricmp(old_name,new_name)==0) return true; - if (FindSMotionByName(new_name)) return false; - CSMotion* M = FindSMotionByName(old_name); VERIFY(M); + if (stricmp(old_name, new_name)==0) + return true; + if (FindSMotionByName(new_name)) + return false; + CSMotion *M = FindSMotionByName(old_name); + VERIFY(M); M->SetName(new_name); return true; } -CSMotion* CEditableObject::FindSMotionByName (const char* name, const CSMotion* Ignore) +CSMotion *CEditableObject::FindSMotionByName(const char *name, const CSMotion *Ignore) { - if (name&&name[0]){ - SMotionVec& lst = m_SMotions; - for(SMotionIt m=lst.begin(); m!=lst.end(); m++) - if ((Ignore!=(*m))&&(stricmp((*m)->Name(),name)==0)) return (*m); + if (name&&name[0]) + { + SMotionVec &lst = m_SMotions; + for (SMotionIt m = lst.begin(); m!=lst.end(); m++) + if ((Ignore!=(*m))&&(stricmp((*m)->Name(), name)==0)) + return (*m); } return 0; } -void CEditableObject::GenerateSMotionName(char* buffer, const char* start_name, const CSMotion* M) +void CEditableObject::GenerateSMotionName(char *buffer, const char *start_name, const CSMotion *M) { - strcpy(buffer,start_name); + strcpy(buffer, start_name); int idx = 0; - while(FindSMotionByName(buffer,M)){ - sprintf( buffer, "%s_%2d", start_name, idx ); - idx++; + while (FindSMotionByName(buffer, M)) + { + sprintf(buffer, "%s_%2d", start_name, idx); + idx++; } strlwr(buffer); } -ICF bool pred_sort_B(CBone* A, CBone* B) +ICF + +bool pred_sort_B(CBone *A, CBone *B) { - return (xr_strcmp(A->Name().c_str(),B->Name().c_str())<0); + return (xr_strcmp(A->Name().c_str(), B->Name().c_str())<0); } -ICF void fill_bones_by_parent(BoneVec& bones,CBone* start) + +ICF + +void fill_bones_by_parent(BoneVec &bones, CBone *start) { - bones.push_back (start); - for (BoneIt b_it=start->children.begin(); b_it!=start->children.end(); b_it++) - fill_bones_by_parent(bones,*b_it); + bones.push_back(start); + for (BoneIt b_it = start->children.begin(); b_it!=start->children.end(); b_it++) + fill_bones_by_parent(bones, *b_it); } + void CEditableObject::PrepareBones() { - if (m_Bones.empty())return; - CBone* PARENT = 0; + if (m_Bones.empty()) + return; + CBone *PARENT = 0; // clear empty parent - BoneIt b_it; - for (b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++) + BoneIt b_it; + for (b_it = m_Bones.begin(); b_it!=m_Bones.end(); b_it++) { - (*b_it)->children.clear (); - (*b_it)->parent = NULL; - BoneIt parent = std::find_if(m_Bones.begin(),m_Bones.end(),fBoneNameEQ((*b_it)->ParentName())); - if (parent==m_Bones.end()){ - (*b_it)->SetParentName(""); - VERIFY2 (0==PARENT,"Invalid object. Have more than 1 parent."); - PARENT = *b_it; - }else{ - BoneIt parent = std::find_if(m_Bones.begin(),m_Bones.end(),fBoneNameEQ((*b_it)->ParentName())); - CBone* tmp = (parent==m_Bones.end())?0:*parent; - (*b_it)->parent = tmp; + (*b_it)->children.clear(); + (*b_it)->parent = NULL; + BoneIt parent = std::find_if(m_Bones.begin(), m_Bones.end(), fBoneNameEQ((*b_it)->ParentName())); + if (parent==m_Bones.end()) + { + (*b_it)->SetParentName(""); + VERIFY2(0==PARENT, "Invalid object. Have more than 1 parent."); + PARENT = *b_it; + } + else + { + BoneIt parent = std::find_if(m_Bones.begin(), m_Bones.end(), fBoneNameEQ((*b_it)->ParentName())); + CBone *tmp = (parent==m_Bones.end()) ? 0 : *parent; + (*b_it)->parent = tmp; } } // sort by name - std::sort(m_Bones.begin(),m_Bones.end(),pred_sort_B); + std::sort(m_Bones.begin(), m_Bones.end(), pred_sort_B); // fill children - for (b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++){ - BoneIt parent = std::find_if(m_Bones.begin(),m_Bones.end(),fBoneNameEQ((*b_it)->ParentName())); - if (parent!=m_Bones.end()) (*parent)->children.push_back(*b_it); + for (b_it = m_Bones.begin(); b_it!=m_Bones.end(); b_it++) + { + BoneIt parent = std::find_if(m_Bones.begin(), m_Bones.end(), fBoneNameEQ((*b_it)->ParentName())); + if (parent!=m_Bones.end()) + (*parent)->children.push_back(*b_it); } // manual sort - u32 b_cnt = m_Bones.size(); - m_Bones.clear (); - fill_bones_by_parent(m_Bones,PARENT); + u32 b_cnt = m_Bones.size(); + m_Bones.clear(); + fill_bones_by_parent(m_Bones, PARENT); - u32 cnt_new = m_Bones.size(); - VERIFY (b_cnt==cnt_new); + u32 cnt_new = m_Bones.size(); + VERIFY(b_cnt==cnt_new); // update SelfID - for (b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++) - (*b_it)->SelfID = b_it-m_Bones.begin(); + for (b_it = m_Bones.begin(); b_it!=m_Bones.end(); b_it++) + (*b_it)->SelfID = b_it-m_Bones.begin(); VERIFY(0==m_Bones.front()->parent); -/* - for (b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++) - Msg("%20s - %20s",(*b_it)->Name().c_str(),(*b_it)->ParentName().c_str()); -*/ - CalculateBindPose (); + /* + for (b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++) + Msg("%20s - %20s",(*b_it)->Name().c_str(),(*b_it)->ParentName().c_str()); + */ + CalculateBindPose(); } -BoneIt CEditableObject::FindBoneByNameIt(const char* name) +BoneIt CEditableObject::FindBoneByNameIt(const char *name) { - return std::find_if(m_Bones.begin(),m_Bones.end(),fBoneNameEQ(name)); + return std::find_if(m_Bones.begin(), m_Bones.end(), fBoneNameEQ(name)); } int CEditableObject::FindBoneByNameIdx(LPCSTR name) { - BoneIt b_it = FindBoneByNameIt(name); - return (b_it==m_Bones.end())?-1:b_it-m_Bones.begin(); + BoneIt b_it = FindBoneByNameIt(name); + return (b_it==m_Bones.end()) ? -1 : b_it-m_Bones.begin(); } -CBone* CEditableObject::FindBoneByName(const char* name) +CBone *CEditableObject::FindBoneByName(const char *name) { - BoneIt b_it = FindBoneByNameIt(name); - return (b_it==m_Bones.end())?0:*b_it; + BoneIt b_it = FindBoneByNameIt(name); + return (b_it==m_Bones.end()) ? 0 : *b_it; } int CEditableObject::GetRootBoneID() { - for (BoneIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++) - if ((*b_it)->IsRoot()) return b_it-m_Bones.begin(); + for (BoneIt b_it = m_Bones.begin(); b_it!=m_Bones.end(); b_it++) + if ((*b_it)->IsRoot()) + return b_it-m_Bones.begin(); THROW; return -1; } int CEditableObject::PartIDByName(LPCSTR name) { - for (BPIt it=m_BoneParts.begin(); it!=m_BoneParts.end(); it++) - if (it->alias==name) return it-m_BoneParts.begin(); + for (BPIt it = m_BoneParts.begin(); it!=m_BoneParts.end(); it++) + if (it->alias==name) + return it-m_BoneParts.begin(); return -1; -} +} shared_str CEditableObject::BoneNameByID(int id) { - VERIFY((id>=0)&&(id<(int)m_Bones.size())); + VERIFY((id>=0)&&(id<(int)m_Bones.size())); return m_Bones[id]->Name(); } -u16 CEditableObject::GetBoneIndexByWMap(const char* wm_name) +u16 CEditableObject::GetBoneIndexByWMap(const char *wm_name) { - BoneIt bone = std::find_if(m_Bones.begin(),m_Bones.end(),fBoneWMNameEQ(wm_name)); - return (bone==m_Bones.end())?BI_NONE:(u16)(bone-m_Bones.begin()); + BoneIt bone = std::find_if(m_Bones.begin(), m_Bones.end(), fBoneWMNameEQ(wm_name)); + return (bone==m_Bones.end()) ? BI_NONE : (u16)(bone-m_Bones.begin()); } -void CEditableObject::GetBoneWorldTransform(u32 bone_idx, float t, CSMotion* motion, Fmatrix& matrix) +void CEditableObject::GetBoneWorldTransform(u32 bone_idx, float t, CSMotion *motion, Fmatrix &matrix) { - VERIFY(bone_idxParent()?m_Bones[idx]->Parent()->SelfID:-1)>-1); - for (int i=lst.size()-1; i>=0; i--){ - idx = lst[i]; - Flags8 flags = motion->GetMotionFlags(idx); - Fvector T,R; + do + { + lst.push_back(idx); + } while ((idx = m_Bones[idx]->Parent() ? m_Bones[idx]->Parent()->SelfID : -1)>-1); + for (int i = lst.size()-1; i>=0; i--) + { + idx = lst[i]; + Flags8 flags = motion->GetMotionFlags(idx); + Fvector T, R; Fmatrix rot, mat; - motion->_Evaluate(idx,t,T,R); - if (flags.is(st_BoneMotion::flWorldOrient)){ - rot.setXYZi(R.x,R.y,R.z); + motion->_Evaluate(idx, t, T, R); + if (flags.is(st_BoneMotion::flWorldOrient)) + { + rot.setXYZi(R.x, R.y, R.z); mat.identity(); mat.c.set(T); mat.mulA_43(matrix); mat.i.set(rot.i); mat.j.set(rot.j); mat.k.set(rot.k); - }else{ - mat.setXYZi(R.x,R.y,R.z); + } + else + { + mat.setXYZi(R.x, R.y, R.z); mat.c.set(T); mat.mulA_43(matrix); } @@ -560,27 +641,28 @@ void CEditableObject::GetBoneWorldTransform(u32 bone_idx, float t, CSMotion* mot } } -bool CEditableObject::CheckBoneCompliance(CSMotion* M) +bool CEditableObject::CheckBoneCompliance(CSMotion *M) { - VERIFY(M); -/* - BoneMotionVec& lst = M->BoneMotions(); - if (m_Bones.size()!=lst.size()){ - Log ("!Different bone count.\nObject has '%d' bones. Motion has '%d' bones.",m_Bones.size(),lst.size()); - return false; - } - for(BoneMotionIt bm_it=lst.begin(); bm_it!=lst.end(); bm_it++) - if (!FindBoneByName(*bm_it->name)){ - Msg ("!Can't find bone '%s' in object.",bm_it->name); - return false; + VERIFY(M); + /* + BoneMotionVec& lst = M->BoneMotions(); + if (m_Bones.size()!=lst.size()){ + Log ("!Different bone count.\nObject has '%d' bones. Motion has '%d' bones.",m_Bones.size(),lst.size()); + return false; } -*/ - for(BoneIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++) - if (!M->FindBoneMotion((*b_it)->Name())) { -// Msg ("!Can't find bone '%s' in motion.",*(*b_it)->Name()); -// return false; - M->add_empty_motion ((*b_it)->Name()); - continue; + for(BoneMotionIt bm_it=lst.begin(); bm_it!=lst.end(); bm_it++) + if (!FindBoneByName(*bm_it->name)){ + Msg ("!Can't find bone '%s' in object.",bm_it->name); + return false; + } + */ + for (BoneIt b_it = m_Bones.begin(); b_it!=m_Bones.end(); b_it++) + if (!M->FindBoneMotion((*b_it)->Name())) + { + // Msg ("!Can't find bone '%s' in motion.",*(*b_it)->Name()); + // return false; + M->add_empty_motion((*b_it)->Name()); + continue; } return true; } @@ -590,13 +672,15 @@ void CEditableObject::OptimizeSMotions() #ifdef _EDITOR SPBItem* pb = UI->ProgressStart(m_SMotions.size(),"Motions optimizing..."); #endif - for (SMotionIt s_it=m_SMotions.begin(); s_it!=m_SMotions.end(); s_it++){ - (*s_it)->Optimize (); + for (SMotionIt s_it = m_SMotions.begin(); s_it!=m_SMotions.end(); s_it++) + { + (*s_it)->Optimize(); #ifdef _EDITOR pb->Inc (); #endif - } + } #ifdef _EDITOR UI->ProgressEnd (pb); #endif } + diff --git a/src/editors/ECore/Editor/EditObjectProps.cpp b/src/editors/ECore/Editor/EditObjectProps.cpp index 085725fe8c0..dea0e3cb862 100644 --- a/src/editors/ECore/Editor/EditObjectProps.cpp +++ b/src/editors/ECore/Editor/EditObjectProps.cpp @@ -4,120 +4,140 @@ #include "EditObject.h" #include "EditMesh.h" #include "ui_main.h" -#include "../../xrServerEntities/PropertiesListHelper.h" -#include "ItemListHelper.h" -#include "motion.h" -#include "bone.h" +#include "xrServerEntities/PropertiesListHelper.h" +#include "editors/xrEProps/ItemListHelper.h" +#include "xrCore/Animation/Motion.hpp" +#include "xrCore/Animation/Bone.hpp" -void CEditableObject::OnChangeShader(PropValue*) +void CEditableObject::OnChangeShader(PropValue *) { - OnDeviceDestroy (); - UI->RedrawScene (); + OnDeviceDestroy(); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- -void CEditableObject::FillSurfaceProps(CSurface* SURF, LPCSTR pref, PropItemVec& items) +void CEditableObject::FillSurfaceProps(CSurface *SURF, LPCSTR pref, PropItemVec &items) { - PropValue* V; - V=PHelper().CreateChoose (items, PrepareKey(pref,"Texture"), &SURF->m_Texture, smTexture); V->OnChangeEvent.bind(this,&CEditableObject::OnChangeShader); - V=PHelper().CreateChoose (items, PrepareKey(pref,"Shader"), &SURF->m_ShaderName,smEShader); V->OnChangeEvent.bind(this,&CEditableObject::OnChangeShader); - V=PHelper().CreateChoose (items, PrepareKey(pref,"Compile"), &SURF->m_ShaderXRLCName,smCShader); - PHelper().CreateChoose (items, PrepareKey(pref,"Game Mtl"), &SURF->m_GameMtlName, smGameMaterial); - V=PHelper().CreateFlag32 (items, PrepareKey(pref,"2 Sided"), &SURF->m_Flags, CSurface::sf2Sided);V->OnChangeEvent.bind(this,&CEditableObject::OnChangeShader); - PHelper().CreateCaption (items, PrepareKey(pref,"Face Count"), shared_str().printf("%d",GetSurfFaceCount(SURF->_Name()))); + PropValue *V; + V = PHelper().CreateChoose(items, PrepareKey(pref, "Texture"), &SURF->m_Texture, smTexture); + V->OnChangeEvent.bind(this, &CEditableObject::OnChangeShader); + V = PHelper().CreateChoose(items, PrepareKey(pref, "Shader"), &SURF->m_ShaderName, smEShader); + V->OnChangeEvent.bind(this, &CEditableObject::OnChangeShader); + V = PHelper().CreateChoose(items, PrepareKey(pref, "Compile"), &SURF->m_ShaderXRLCName, smCShader); + PHelper().CreateChoose(items, PrepareKey(pref, "Game Mtl"), &SURF->m_GameMtlName, smGameMaterial); + V = PHelper().CreateFlag32(items, PrepareKey(pref, "2 Sided"), &SURF->m_Flags, CSurface::sf2Sided); + V->OnChangeEvent.bind(this, &CEditableObject::OnChangeShader); + PHelper().CreateCaption(items, PrepareKey(pref, "Face Count"), shared_str().printf("%d", GetSurfFaceCount(SURF->_Name()))); } + //--------------------------------------------------------------------------- -xr_token ECORE_API eo_type_token[]={ - { "Static", 0}, - { "Dynamic", CEditableObject::eoDynamic}, - { "Progressive Dynamic", CEditableObject::eoDynamic|CEditableObject::eoProgressive}, - { "HOM", CEditableObject::eoHOM}, - { "Multiple Usage", CEditableObject::eoMultipleUsage|CEditableObject::eoUsingLOD}, - { "Sound Occluder", CEditableObject::eoSoundOccluder}, - { 0, 0} +xr_token ECORE_API eo_type_token[] = { + {"Static", 0}, + {"Dynamic", CEditableObject::eoDynamic}, + {"Progressive Dynamic", CEditableObject::eoDynamic|CEditableObject::eoProgressive}, + {"HOM", CEditableObject::eoHOM}, + {"Multiple Usage", CEditableObject::eoMultipleUsage|CEditableObject::eoUsingLOD}, + {"Sound Occluder", CEditableObject::eoSoundOccluder}, + {0, 0} }; -void CEditableObject::FillBasicProps(LPCSTR pref, PropItemVec& items) +void CEditableObject::FillBasicProps(LPCSTR pref, PropItemVec &items) { - PropValue* V=0; - PHelper().CreateCaption (items, PrepareKey(pref,"Reference Name"), m_LibName.c_str()); - PHelper().CreateToken32 (items, PrepareKey(pref,"Object Type"), &m_objectFlags.flags, eo_type_token); - PHelper().CreateCaption (items, PrepareKey(pref,"Version\\Owner Name"), m_CreateName.c_str()); - PHelper().CreateCaption (items, PrepareKey(pref,"Version\\Modif Name"), m_ModifName.c_str()); - PHelper().CreateCaption (items, PrepareKey(pref,"Version\\Creation Time"),Trim(AnsiString(ctime(&m_CreateTime))).c_str()); - PHelper().CreateCaption (items, PrepareKey(pref,"Version\\Modified Time"),Trim(AnsiString(ctime(&m_ModifTime))).c_str()); - V=PHelper().CreateVector (items, PrepareKey(pref,"Transform\\Position"), &t_vPosition, -10000, 10000,0.01,2); V->OnChangeEvent.bind(this,&CEditableObject::OnChangeTransform); - V=PHelper().CreateAngle3 (items, PrepareKey(pref,"Transform\\Rotation"), &t_vRotate, -10000, 10000,0.1,1); V->OnChangeEvent.bind(this,&CEditableObject::OnChangeTransform); - V=PHelper().CreateVector (items, PrepareKey(pref,"Transform\\Scale"), &t_vScale, 0.01, 10000,0.01,2); V->OnChangeEvent.bind(this,&CEditableObject::OnChangeTransform); - V=PHelper().CreateCaption (items, PrepareKey(pref,"Transform\\BBox Min"), shared_str().printf("{%3.2f, %3.2f, %3.2f}",VPUSH(GetBox().min))); - V=PHelper().CreateCaption (items, PrepareKey(pref,"Transform\\BBox Max"), shared_str().printf("{%3.2f, %3.2f, %3.2f}",VPUSH(GetBox().max))); -//. PHelper().CreateChoose (items, PrepareKey(pref,"LOD\\Reference"), &m_LODs, smObject); - PHelper().CreateChoose (items, PrepareKey(pref,"LOD\\Reference"), &m_LODs, smVisual); - - FillSummaryProps (pref,items); + PropValue *V = 0; + PHelper().CreateCaption(items, PrepareKey(pref, "Reference Name"), m_LibName.c_str()); + PHelper().CreateToken32(items, PrepareKey(pref, "Object Type"), &m_objectFlags.flags, eo_type_token); + PHelper().CreateCaption(items, PrepareKey(pref, "Version\\Owner Name"), m_CreateName.c_str()); + PHelper().CreateCaption(items, PrepareKey(pref, "Version\\Modif Name"), m_ModifName.c_str()); + PHelper().CreateCaption(items, PrepareKey(pref, "Version\\Creation Time"), Trim(AnsiString(ctime(&m_CreateTime))).c_str()); + PHelper().CreateCaption(items, PrepareKey(pref, "Version\\Modified Time"), Trim(AnsiString(ctime(&m_ModifTime))).c_str()); + V = PHelper().CreateVector(items, PrepareKey(pref, "Transform\\Position"), &t_vPosition, -10000, 10000, 0.01, 2); + V->OnChangeEvent.bind(this, &CEditableObject::OnChangeTransform); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Transform\\Rotation"), &t_vRotate, -10000, 10000, 0.1, 1); + V->OnChangeEvent.bind(this, &CEditableObject::OnChangeTransform); + V = PHelper().CreateVector(items, PrepareKey(pref, "Transform\\Scale"), &t_vScale, 0.01, 10000, 0.01, 2); + V->OnChangeEvent.bind(this, &CEditableObject::OnChangeTransform); + V = PHelper().CreateCaption(items, PrepareKey(pref, "Transform\\BBox Min"), shared_str().printf("{%3.2f, %3.2f, %3.2f}", VPUSH(GetBox().min))); + V = PHelper().CreateCaption(items, PrepareKey(pref, "Transform\\BBox Max"), shared_str().printf("{%3.2f, %3.2f, %3.2f}", VPUSH(GetBox().max))); + //. PHelper().CreateChoose (items, PrepareKey(pref,"LOD\\Reference"), &m_LODs, smObject); + PHelper().CreateChoose(items, PrepareKey(pref, "LOD\\Reference"), &m_LODs, smVisual); + + FillSummaryProps(pref, items); } + //--------------------------------------------------------------------------- -void CEditableObject::FillSummaryProps(LPCSTR pref, PropItemVec& items) +void CEditableObject::FillSummaryProps(LPCSTR pref, PropItemVec &items) { - AnsiString t; t.sprintf("V: %d, F: %d", GetVertexCount(),GetFaceCount()); - PHelper().CreateCaption(items,PrepareKey(pref,"Geometry\\Object"),t.c_str()); - for (EditMeshIt m_it=FirstMesh(); m_it!=LastMesh(); m_it++){ - CEditableMesh* MESH=*m_it; - t.sprintf("V: %d, F: %d",MESH->GetVertexCount(),MESH->GetFaceCount()); - PHelper().CreateCaption(items,PrepareKey(pref,AnsiString(AnsiString("Geometry\\Meshes\\")+MESH->Name().c_str()).c_str()),t.c_str()); + AnsiString t; + t.sprintf("V: %d, F: %d", GetVertexCount(), GetFaceCount()); + PHelper().CreateCaption(items, PrepareKey(pref, "Geometry\\Object"), t.c_str()); + for (EditMeshIt m_it = FirstMesh(); m_it!=LastMesh(); m_it++) + { + CEditableMesh*MESH = *m_it; + t.sprintf("V: %d, F: %d", MESH->GetVertexCount(), MESH->GetFaceCount()); + PHelper().CreateCaption(items, PrepareKey(pref, AnsiString(AnsiString("Geometry\\Meshes\\")+MESH->Name().c_str()).c_str()), t.c_str()); } - PHelper().CreateSText(items,PrepareKey(pref, "Game options\\User Data"),&m_ClassScript); + PHelper().CreateSText(items, PrepareKey(pref, "Game options\\User Data"), &m_ClassScript); } + //--------------------------------------------------------------------------- -ECORE_API AnsiString MakeFullBoneName(CBone* bone) +ECORE_API AnsiString MakeFullBoneName(CBone *bone) { - if (bone->Parent()){ - return MakeFullBoneName(bone->Parent())+"\\"+bone->Name().c_str(); - }else{ - return bone->Name().c_str(); + if (bone->Parent()) + { + return MakeFullBoneName(bone->Parent())+"\\"+bone->Name().c_str(); + } + else + { + return bone->Name().c_str(); } } -AnsiString MakeFullBonePath(CBone* bone) +AnsiString MakeFullBonePath(CBone *bone) { - if (bone->Parent()){ - return MakeFullBoneName(bone->Parent()); - }else{ - return ""; - } + if (bone->Parent()) + { + return MakeFullBoneName(bone->Parent()); + } + else + { + return ""; + } } -void CEditableObject::FillSurfaceList(LPCSTR pref, ListItemsVec& items, int modeID) +void CEditableObject::FillSurfaceList(LPCSTR pref, ListItemsVec &items, int modeID) { - SurfaceVec& s_lst = Surfaces(); - if (pref) LHelper().CreateItem(items, pref, modeID, ListItem::flSorted); - for (SurfaceIt s_it=s_lst.begin(); s_it!=s_lst.end(); s_it++) + SurfaceVec &s_lst = Surfaces(); + if (pref) + LHelper().CreateItem(items, pref, modeID, ListItem::flSorted); + for (SurfaceIt s_it = s_lst.begin(); s_it!=s_lst.end(); s_it++) LHelper().CreateItem(items, PrepareKey(pref, (*s_it)->_Name()).c_str(), modeID, 0, *s_it); } + //--------------------------------------------------------------------------- -void CEditableObject::FillBoneList(LPCSTR pref, ListItemsVec& items, int modeID) +void CEditableObject::FillBoneList(LPCSTR pref, ListItemsVec &items, int modeID) { - BoneVec& b_lst = Bones(); - if (pref) LHelper().CreateItem(items, pref, modeID, ListItem::flSorted); - for(BoneIt b_it=b_lst.begin(); b_it!=b_lst.end(); b_it++){ - AnsiString pt = MakeFullBonePath(*b_it); - AnsiString path = pt.IsEmpty()?pref:PrepareKey(pref, pt.c_str()).c_str(); - LHelper().CreateItem(items, PrepareKey(path.c_str(), (*b_it)->Name().c_str()).c_str(), modeID, 0, *b_it); + BoneVec &b_lst = Bones(); + if (pref) + LHelper().CreateItem(items, pref, modeID, ListItem::flSorted); + for (BoneIt b_it = b_lst.begin(); b_it!=b_lst.end(); b_it++) + { + AnsiString pt = MakeFullBonePath(*b_it); + AnsiString path = pt.IsEmpty() ? pref : PrepareKey(pref, pt.c_str()).c_str(); + LHelper().CreateItem(items, PrepareKey(path.c_str(), (*b_it)->Name().c_str()).c_str(), modeID, 0, *b_it); } } -void CEditableObject::FillMotionList(LPCSTR pref, ListItemsVec& items, int modeID) +void CEditableObject::FillMotionList(LPCSTR pref, ListItemsVec &items, int modeID) { - SMotionVec& m_lst = SMotions(); - if (pref) LHelper().CreateItem(items, pref, modeID, ListItem::flSorted); - for (SMotionIt m_it=m_lst.begin(); m_it!=m_lst.end(); m_it++) + SMotionVec &m_lst = SMotions(); + if (pref) + LHelper().CreateItem(items, pref, modeID, ListItem::flSorted); + for (SMotionIt m_it = m_lst.begin(); m_it!=m_lst.end(); m_it++) LHelper().CreateItem(items, PrepareKey(pref, (*m_it)->Name()).c_str(), modeID, 0, *m_it); } - - - \ No newline at end of file diff --git a/src/editors/ECore/Editor/EditObjectSkin.cpp b/src/editors/ECore/Editor/EditObjectSkin.cpp index 4fb3c1dc10d..8de1f1aad7b 100644 --- a/src/editors/ECore/Editor/EditObjectSkin.cpp +++ b/src/editors/ECore/Editor/EditObjectSkin.cpp @@ -7,202 +7,241 @@ #include "EditObject.h" #include "EditMesh.h" -#include "d3dutils.h" -#include "../../xrServerEntities/PropertiesListHelper.h" +#include "D3DUtils.h" +#include "xrServerEntities/PropertiesListHelper.h" -const u32 color_bone_sel_color =0xFFFFFFFF; -const u32 color_bone_norm_color =0xFFFFFF00; -const u32 color_bone_link_color =0xFFA0A000; -const u32 color_bone_sel_cm =0xFFFF0000; -const u32 color_bone_norm_cm =0xFF700000; -const float joint_size =0.025f; +const u32 color_bone_sel_color = 0xFFFFFFFF; +const u32 color_bone_norm_color = 0xFFFFFF00; +const u32 color_bone_link_color = 0xFFA0A000; +const u32 color_bone_sel_cm = 0xFFFF0000; +const u32 color_bone_norm_cm = 0xFF700000; +const float joint_size = 0.025f; void CEditableObject::ResetBones() { - BoneVec& lst = m_Bones; - for(BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++) - (*b_it)->ResetData(); + BoneVec &lst = m_Bones; + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); b_it++) + (*b_it)->ResetData(); } -class fBoneNameEQ { - shared_str name; +class fBoneNameEQ +{ + shared_str name; public: - fBoneNameEQ(shared_str N) : name(N) {}; - IC bool operator() (CBone* B) { return (xr_strcmp(B->Name(),name)==0); } + fBoneNameEQ(shared_str N) : name(N) {}; + + IC + + bool operator()(CBone *B) + { + return (xr_strcmp(B->Name(), name)==0); + } }; -bool CEditableObject::LoadBoneData(IReader& F) +bool CEditableObject::LoadBoneData(IReader &F) { - BoneVec load_bones; - int count=0; - IReader* R; - while(0!=(R=F.open_chunk(count++))) + BoneVec load_bones; + int count = 0; + IReader *R; + while (0!=(R = F.open_chunk(count++))) { - CBone* nBone = xr_new(); - load_bones.push_back(nBone); + CBone *nBone = xr_new(); + load_bones.push_back(nBone); nBone->LoadData(*R); Msg("loaded bone [%s]", nBone->Name().c_str()); } - bool bRes = true; + bool bRes = true; // load bones - if (!load_bones.empty()){ - for (BoneIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++){ - CBone* B = *b_it; - BoneIt n_it = std::find_if(load_bones.begin(),load_bones.end(),fBoneNameEQ(B->Name())); + if (!load_bones.empty()) + { + for (BoneIt b_it = m_Bones.begin(); b_it!=m_Bones.end(); b_it++) + { + CBone *B = *b_it; + BoneIt n_it = std::find_if(load_bones.begin(), load_bones.end(), fBoneNameEQ(B->Name())); if (n_it!=load_bones.end()) { - B->CopyData (*n_it); - }else{ - ELog.Msg (mtError,"Can't find bone: '%s'.",*(*b_it)->Name()); - bRes = false; -// break; + B->CopyData(*n_it); + } + else + { + ELog.Msg(mtError, "Can't find bone: '%s'.", *(*b_it)->Name()); + bRes = false; + // break; } } - - for (BoneIt n_it=load_bones.begin(); n_it!=load_bones.end(); n_it++) + + for (BoneIt n_it = load_bones.begin(); n_it!=load_bones.end(); n_it++) xr_delete(*n_it); load_bones.clear(); - }else{ - ELog.Msg (mtError,"Empty bone list."); - bRes = false; + } + else + { + ELog.Msg(mtError, "Empty bone list."); + bRes = false; } // load bone part - if (F.find_chunk(EOBJ_CHUNK_BONEPARTS2)){ - shared_str buf; + if (F.find_chunk(EOBJ_CHUNK_BONEPARTS2)) + { + shared_str buf; m_BoneParts.resize(F.r_u32()); - for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++){ - F.r_stringZ (buf); bp_it->alias=buf; - bp_it->bones.resize (F.r_u32()); - for (RStringVecIt s_it=bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++) - F.r_stringZ (*s_it); + for (BPIt bp_it = m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++) + { + F.r_stringZ(buf); + bp_it->alias = buf; + bp_it->bones.resize(F.r_u32()); + for (RStringVecIt s_it = bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++) + F.r_stringZ(*s_it); } if (!m_BoneParts.empty()&&!VerifyBoneParts()) - ELog.Msg (mtError,"Invalid bone parts. Found missing or duplicate bone."); - }else{ - ELog.Msg (mtError,"Can't load bone parts. Invalid version."); + ELog.Msg(mtError, "Invalid bone parts. Found missing or duplicate bone."); + } + else + { + ELog.Msg(mtError, "Can't load bone parts. Invalid version."); } return bRes; } -void CEditableObject::SaveBoneData(IWriter& F) +void CEditableObject::SaveBoneData(IWriter &F) { - for (BoneIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++){ - F.open_chunk (b_it-m_Bones.begin()); - (*b_it)->SaveData (F); - F.close_chunk (); + for (BoneIt b_it = m_Bones.begin(); b_it!=m_Bones.end(); b_it++) + { + F.open_chunk(b_it-m_Bones.begin()); + (*b_it)->SaveData(F); + F.close_chunk(); } // save bone part - F.open_chunk (EOBJ_CHUNK_BONEPARTS2); - F.w_u32 (m_BoneParts.size()); - for (BPIt bp_it=m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++){ - F.w_stringZ (bp_it->alias.c_str()); - F.w_u32 (bp_it->bones.size()); - for (RStringVecIt s_it=bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++) + F.open_chunk(EOBJ_CHUNK_BONEPARTS2); + F.w_u32(m_BoneParts.size()); + for (BPIt bp_it = m_BoneParts.begin(); bp_it!=m_BoneParts.end(); bp_it++) + { + F.w_stringZ(bp_it->alias.c_str()); + F.w_u32(bp_it->bones.size()); + for (RStringVecIt s_it = bp_it->bones.begin(); s_it!=bp_it->bones.end(); s_it++) F.w_stringZ(*s_it); } - F.close_chunk (); + F.close_chunk(); } -void CEditableObject::RenderSkeletonSingle(const Fmatrix& parent) +void CEditableObject::RenderSkeletonSingle(const Fmatrix &parent) { - RenderSingle(parent); + RenderSingle(parent); RenderBones(parent); } -void CEditableObject::RenderBones(const Fmatrix& parent) +void CEditableObject::RenderBones(const Fmatrix &parent) { - if (IsSkeleton()){ + if (IsSkeleton()) + { // render - BoneVec& lst = m_Bones; - for(BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++){ - EDevice.SetShader(EDevice.m_WireShader); - RCache.set_xform_world(parent); - Fmatrix& M = (*b_it)->_LTransform(); - Fvector p1 = M.c; - u32 c_joint = (*b_it)->flags.is(CBone::flSelected)?color_bone_sel_color:color_bone_norm_color; + BoneVec &lst = m_Bones; + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); b_it++) + { + EDevice.SetShader(EDevice.m_WireShader); + RCache.set_xform_world(parent); + Fmatrix &M = (*b_it)->_LTransform(); + Fvector p1 = M.c; + u32 c_joint = (*b_it)->flags.is(CBone::flSelected) ? color_bone_sel_color : color_bone_norm_color; if (EPrefs->object_flags.is(epoDrawJoints)) - DU_impl.DrawJoint (p1,joint_size,c_joint); + DU_impl.DrawJoint(p1, joint_size, c_joint); // center of mass - if ((*b_it)->shape.type!=SBoneShape::stNone){ + if ((*b_it)->shape.type!=SBoneShape::stNone) + { Fvector cm; - M.transform_tiny(cm,(*b_it)->center_of_mass); - if ((*b_it)->flags.is(CBone::flSelected)){ - float sz = joint_size*2.f; - DU_impl.DrawCross (cm, sz,sz,sz, sz,sz,sz, 0xFFFFFFFF, false); - DU_impl.DrawRomboid (cm,joint_size*0.7f,color_bone_sel_cm); - }else{ - DU_impl.DrawRomboid (cm,joint_size*0.7f,color_bone_norm_cm); + M.transform_tiny(cm, (*b_it)->center_of_mass); + if ((*b_it)->flags.is(CBone::flSelected)) + { + float sz = joint_size*2.f; + DU_impl.DrawCross(cm, sz, sz, sz, sz, sz, sz, 0xFFFFFFFF, false); + DU_impl.DrawRomboid(cm, joint_size*0.7f, color_bone_sel_cm); + } + else + { + DU_impl.DrawRomboid(cm, joint_size*0.7f, color_bone_norm_cm); } } -/* - if (0){ - M.transform_dir (d); - p2.mad (p1,d,(*b_it)->_Length()); - DU.DrawLine (p1,p2,c_joint); + /* + if (0){ + M.transform_dir (d); + p2.mad (p1,d,(*b_it)->_Length()); + DU.DrawLine (p1,p2,c_joint); + } + */ + if ((*b_it)->Parent()) + { + EDevice.SetShader(EDevice.m_SelectionShader); + Fvector &p2 = (*b_it)->Parent()->_LTransform().c; + DU_impl.DrawLine(p1, p2, color_bone_link_color); } -*/ - if ((*b_it)->Parent()){ - EDevice.SetShader(EDevice.m_SelectionShader); - Fvector& p2 = (*b_it)->Parent()->_LTransform().c; - DU_impl.DrawLine (p1,p2,color_bone_link_color); - } - if (EPrefs->object_flags.is(epoDrawBoneAxis)){ - Fmatrix mat; mat.mul(parent,M); - DU_impl.DrawObjectAxis(mat,0.03f,(*b_it)->flags.is(CBone::flSelected)); + if (EPrefs->object_flags.is(epoDrawBoneAxis)) + { + Fmatrix mat; + mat.mul(parent, M); + DU_impl.DrawObjectAxis(mat, 0.03f, (*b_it)->flags.is(CBone::flSelected)); } - if (EPrefs->object_flags.is(epoDrawBoneNames)){ - parent.transform_tiny(p1); - u32 c = (*b_it)->flags.is(CBone::flSelected)?0xFFFFFFFF:0xFF000000; - u32 s = (*b_it)->flags.is(CBone::flSelected)?0xFF000000:0xFF909090; - DU_impl.OutText(p1,(*b_it)->Name().c_str(),c,s); + if (EPrefs->object_flags.is(epoDrawBoneNames)) + { + parent.transform_tiny(p1); + u32 c = (*b_it)->flags.is(CBone::flSelected) ? 0xFFFFFFFF : 0xFF000000; + u32 s = (*b_it)->flags.is(CBone::flSelected) ? 0xFF000000 : 0xFF909090; + DU_impl.OutText(p1, (*b_it)->Name().c_str(), c, s); } - if (EPrefs->object_flags.is(epoDrawBoneShapes)){ - EDevice.SetShader(EDevice.m_SelectionShader); - Fmatrix mat = M; - mat.mulA_43 (parent); - u32 c = (*b_it)->flags.is(CBone::flSelected)?0x80ffffff:0x300000ff; - if ((*b_it)->shape.Valid()){ - switch ((*b_it)->shape.type){ - case SBoneShape::stBox: DU_impl.DrawOBB (mat,(*b_it)->shape.box,c,c); break; - case SBoneShape::stSphere: DU_impl.DrawSphere (mat,(*b_it)->shape.sphere,c,c,TRUE,TRUE);break; - case SBoneShape::stCylinder:DU_impl.DrawCylinder (mat,(*b_it)->shape.cylinder.m_center,(*b_it)->shape.cylinder.m_direction,(*b_it)->shape.cylinder.m_height,(*b_it)->shape.cylinder.m_radius,c,c,TRUE,TRUE);break; - } + if (EPrefs->object_flags.is(epoDrawBoneShapes)) + { + EDevice.SetShader(EDevice.m_SelectionShader); + Fmatrix mat = M; + mat.mulA_43(parent); + u32 c = (*b_it)->flags.is(CBone::flSelected) ? 0x80ffffff : 0x300000ff; + if ((*b_it)->shape.Valid()) + { + switch ((*b_it)->shape.type) + { + case SBoneShape::stBox: DU_impl.DrawOBB(mat, (*b_it)->shape.box, c, c); + break; + case SBoneShape::stSphere: DU_impl.DrawSphere(mat, (*b_it)->shape.sphere, c, c, TRUE, TRUE); + break; + case SBoneShape::stCylinder: DU_impl.DrawCylinder(mat, (*b_it)->shape.cylinder.m_center, (*b_it)->shape.cylinder.m_direction, (*b_it)->shape.cylinder.m_height, (*b_it)->shape.cylinder.m_radius, c, c, TRUE, TRUE); + break; + } } } } } } -CBone* CEditableObject::PickBone(const Fvector& S, const Fvector& D, const Fmatrix& parent) +CBone *CEditableObject::PickBone(const Fvector &S, const Fvector &D, const Fmatrix &parent) { - BoneVec& lst = m_Bones; - float dist = 10000.f; - CBone* sel = 0; - for(BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++){ - if ((*b_it)->Pick(dist,S,D,parent)) - sel = *b_it; + BoneVec &lst = m_Bones; + float dist = 10000.f; + CBone *sel = 0; + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); b_it++) + { + if ((*b_it)->Pick(dist, S, D, parent)) + sel = *b_it; } return sel; } void CEditableObject::SelectBones(bool bVal) { - BoneVec& lst = m_Bones; - for(BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++) + BoneVec &lst = m_Bones; + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); b_it++) (*b_it)->Select(bVal); } -void CEditableObject::SelectBone(CBone* b, bool bVal) +void CEditableObject::SelectBone(CBone *b, bool bVal) { - if (b) b->Select(bVal); + if (b) + b->Select(bVal); } - -int CEditableObject::GetSelectedBones(BoneVec& sel_bones) + +int CEditableObject::GetSelectedBones(BoneVec &sel_bones) { - BoneVec& lst = m_Bones; - for(BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++) - if ((*b_it)->flags.is(CBone::flSelected)) sel_bones.push_back(*b_it); + BoneVec &lst = m_Bones; + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); b_it++) + if ((*b_it)->flags.is(CBone::flSelected)) + sel_bones.push_back(*b_it); return sel_bones.size(); } @@ -210,213 +249,260 @@ int CEditableObject::GetSelectedBones(BoneVec& sel_bones) #include "MgcCont3DMinSphere.h" #include "ExportSkeleton.h" -BOOL f_valid (float f) + +BOOL f_valid(float f) { - return _finite(f) && !_isnan(f); + return _finite(f)&&!_isnan(f); } -BOOL SphereValid (FvectorVec& geom, Fsphere& test) + +BOOL SphereValid(FvectorVec &geom, Fsphere &test) { - if (!f_valid(test.P.x) || !f_valid(test.R)) { - Msg ("*** Attention ***: invalid sphere: %f,%f,%f - %f",test.P.x,test.P.y,test.P.z,test.R); - } - - Fsphere S = test; - S.R += EPS_L; - for (FvectorIt I = geom.begin(); I!=geom.end(); I++) - if (!S.contains(*I)) return FALSE; - return TRUE; + if (!f_valid(test.P.x)||!f_valid(test.R)) + { + Msg("*** Attention ***: invalid sphere: %f,%f,%f - %f", test.P.x, test.P.y, test.P.z, test.R); + } + + Fsphere S = test; + S.R += EPS_L; + for (FvectorIt I = geom.begin(); I!=geom.end(); I++) + if (!S.contains(*I)) + return FALSE; + return TRUE; } -void ComputeSphere(Fsphere &B, FvectorVec& V) + +void ComputeSphere(Fsphere &B, FvectorVec &V) { - if (V.size()<3) { B.P.set(0,0,0); B.R=0.f; return; } - - // 1: calc first variation - Fsphere S1; - Fsphere_compute (S1,V.begin(),V.size()); - BOOL B1 = SphereValid(V,S1); - - // 2: calc ordinary algorithm (2nd) - Fsphere S2; - Fbox bbox; - bbox.invalidate (); - for (FvectorIt I=V.begin(); I!=V.end(); I++) bbox.modify(*I); - bbox.grow (EPS_L); - bbox.getsphere (S2.P,S2.R); - S2.R = -1; - for (I=V.begin(); I!=V.end(); I++) { - float d = S2.P.distance_to_sqr(*I); - if (d>S2.R) S2.R=d; - } - S2.R = _sqrt (_abs(S2.R)); - BOOL B2 = SphereValid(V,S2); - - // 3: calc magic-fm - Mgc::Sphere _S3 = Mgc::MinSphere(V.size(), (const Mgc::Vector3*) V.begin()); - Fsphere S3; - S3.P.set (_S3.Center().x,_S3.Center().y,_S3.Center().z); - S3.R = _S3.Radius(); - BOOL B3 = SphereValid(V,S3); - - // select best one - if (B1 && (S1.RS2.R) + S2.R = d; + } + S2.R = _sqrt(_abs(S2.R)); + BOOL B2 = SphereValid(V, S2); + + // 3: calc magic-fm + Mgc::Sphere _S3 = Mgc::MinSphere(V.size(), (const Mgc::Vector3*) V.begin()); + Fsphere S3; + S3.P.set(_S3.Center().x, _S3.Center().y, _S3.Center().z); + S3.R = _S3.Radius(); + BOOL B3 = SphereValid(V, S3); + + // select best one + if (B1&&(S1.R bone_points; - bone_points.resize (m_Bones.size()); - for(EditMeshIt mesh_it=FirstMesh();mesh_it!=LastMesh();mesh_it++){ - CEditableMesh* MESH = *mesh_it; + R_ASSERT(IsSkeleton()); + xr_vector bone_points; + bone_points.resize(m_Bones.size()); + for (EditMeshIt mesh_it = FirstMesh(); mesh_it!=LastMesh(); mesh_it++) + { + CEditableMesh*MESH = *mesh_it; // generate vertex offset - MESH->GenerateSVertices (1); - for (u32 f_id=0; f_id!=MESH->GetFCount(); f_id++){ - for (int k=0; k<3; k++){ - st_SVert& sv = MESH->m_SVertices[f_id*3+k]; - VERIFY (sv.bones.size()==1); - u16 b_id = sv.bones[0].id;//(sv.bones.size()>1)?(sv.bones[0].w>sv.bones[1].w?sv.bones[0].id:sv.bones[1].id):sv.bones[0].id; - FvectorVec& P = bone_points[b_id]; - bool bFound = false; + MESH->GenerateSVertices(1); + for (u32 f_id = 0; f_id!=MESH->GetFCount(); f_id++) + { + for (int k = 0; k<3; k++) + { + st_SVert&sv = MESH->m_SVertices[f_id*3+k]; + VERIFY(sv.bones.size()==1); + u16 b_id = sv.bones[0].id;//(sv.bones.size()>1)?(sv.bones[0].w>sv.bones[1].w?sv.bones[0].id:sv.bones[1].id):sv.bones[0].id; + FvectorVec &P = bone_points[b_id]; + bool bFound = false; Fvector p; - m_Bones[b_id]->_RITransform().transform_tiny(p,sv.offs); - for (FvectorIt p_it=P.begin(); p_it!=P.end(); p_it++) - if (p_it->similar(p)){ - bFound=true; - break; - } - if (!bFound) P.push_back(p); -// if (sv.bone1!=BI_NONE) bone_points[sv.bone1].push_back(sv.offs1); + m_Bones[b_id]->_RITransform().transform_tiny(p, sv.offs); + for (FvectorIt p_it = P.begin(); p_it!=P.end(); p_it++) + if (p_it->similar(p)) + { + bFound = true; + break; + } + if (!bFound) + P.push_back(p); + // if (sv.bone1!=BI_NONE) bone_points[sv.bone1].push_back(sv.offs1); } } MESH->UnloadSVertices(); } - BoneVec& lst = m_Bones; - for(BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++){ - if (bSelOnly&&!(*b_it)->flags.is(CBone::flSelected)) continue; - FvectorVec& positions = bone_points[b_it-lst.begin()]; - ComputeOBB_WML ((*b_it)->shape.box,positions); - ComputeSphere ((*b_it)->shape.sphere,positions); - ComputeCylinder ((*b_it)->shape.cylinder,(*b_it)->shape.box,positions); + BoneVec &lst = m_Bones; + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); b_it++) + { + if (bSelOnly&&!(*b_it)->flags.is(CBone::flSelected)) + continue; + FvectorVec &positions = bone_points[b_it-lst.begin()]; + ComputeOBB_WML((*b_it)->shape.box, positions); + ComputeSphere((*b_it)->shape.sphere, positions); + ComputeCylinder((*b_it)->shape.cylinder, (*b_it)->shape.box, positions); (*b_it)->center_of_mass.set((*b_it)->shape.sphere.P); } return true; } - + void CEditableObject::ClampByLimits(bool bSelOnly) { - BoneVec& lst = m_Bones; - for(BoneIt b_it=lst.begin(); b_it!=lst.end(); b_it++) - if (!bSelOnly||(bSelOnly&&(*b_it)->Selected())) (*b_it)->ClampByLimits(); + BoneVec &lst = m_Bones; + for (BoneIt b_it = lst.begin(); b_it!=lst.end(); b_it++) + if (!bSelOnly||(bSelOnly&&(*b_it)->Selected())) + (*b_it)->ClampByLimits(); } diff --git a/src/editors/ECore/Editor/EditorPreferences.cpp b/src/editors/ECore/Editor/EditorPreferences.cpp index fe8c2ffc323..1be2bac09d4 100644 --- a/src/editors/ECore/Editor/EditorPreferences.cpp +++ b/src/editors/ECore/Editor/EditorPreferences.cpp @@ -2,177 +2,193 @@ #include "stdafx.h" #pragma hdrstop -#include "PropertiesList.h" +#include "editors/xrEProps/PropertiesList.h" #include "ui_main.h" -#include "ui_toolscustom.h" +#include "UI_ToolsCustom.h" //--------------------------------------------------------------------------- -CCustomPreferences* EPrefs=0; +CCustomPreferences *EPrefs = 0; + //--------------------------------------------------------------------------- CCustomPreferences::CCustomPreferences() { - // view - view_np = 0.1f; - view_fp = 1500.f; - view_fov = deg2rad(60.f); - // fog - fog_color = 0x00555555; - fog_fogness = 0.9; + // view + view_np = 0.1f; + view_fp = 1500.f; + view_fov = deg2rad(60.f); + // fog + fog_color = 0x00555555; + fog_fogness = 0.9; // camera - cam_fly_speed = 5.0f; - cam_fly_alt = 1.8f; - cam_sens_rot = 0.6f; - cam_sens_move = 0.6f; - // tools mouse - tools_sens_move = 0.3f; - tools_sens_rot = 0.3f; - tools_sens_scale = 0.3f; - tools_show_move_axis =false; + cam_fly_speed = 5.0f; + cam_fly_alt = 1.8f; + cam_sens_rot = 0.6f; + cam_sens_move = 0.6f; + // tools mouse + tools_sens_move = 0.3f; + tools_sens_rot = 0.3f; + tools_sens_scale = 0.3f; + tools_show_move_axis = false; // box pick - bp_lim_depth = TRUE; - bp_cull = TRUE; - bp_depth_tolerance = 0.1f; + bp_lim_depth = TRUE; + bp_cull = TRUE; + bp_depth_tolerance = 0.1f; // snap - snap_angle = deg2rad(5.f); - snap_move = 0.1f; - snap_moveto = 0.5f; + snap_angle = deg2rad(5.f); + snap_move = 0.1f; + snap_moveto = 0.5f; // grid - grid_cell_size = 1.f; - grid_cell_count = 100; + grid_cell_size = 1.f; + grid_cell_count = 100; // scene - scene_undo_level = 125; - scene_recent_count = 10; - scene_clear_color = DEFAULT_CLEARCOLOR; + scene_undo_level = 125; + scene_recent_count = 10; + scene_clear_color = DEFAULT_CLEARCOLOR; // objects - object_flags.zero (); + object_flags.zero(); } + //--------------------------------------------------------------------------- -CCustomPreferences::~CCustomPreferences() -{ -} +CCustomPreferences::~CCustomPreferences() {} void CCustomPreferences::ApplyValues() { - Tools->m_MoveSnap = snap_move; - Tools->m_MoveSnapTo = snap_moveto; - Tools->m_RotateSnapAngle= snap_angle; + Tools->m_MoveSnap = snap_move; + Tools->m_MoveSnapTo = snap_moveto; + Tools->m_RotateSnapAngle = snap_angle; EDevice.m_Camera.SetViewport(view_np, view_fp, rad2deg(view_fov)); - Tools->SetFog (fog_color,fog_fogness); + Tools->SetFog(fog_color, fog_fogness); - UI->m_MouseSM = 0.2f*tools_sens_move*tools_sens_move; - UI->m_MouseSR = 0.02f*tools_sens_rot*tools_sens_rot; - UI->m_MouseSS = 0.02f*tools_sens_scale*tools_sens_scale; + UI->m_MouseSM = 0.2f*tools_sens_move*tools_sens_move; + UI->m_MouseSR = 0.02f*tools_sens_rot*tools_sens_rot; + UI->m_MouseSS = 0.02f*tools_sens_scale*tools_sens_scale; - EDevice.m_Camera.SetSensitivity (cam_sens_move, cam_sens_rot); - EDevice.m_Camera.SetFlyParams (cam_fly_speed, cam_fly_alt); + EDevice.m_Camera.SetSensitivity(cam_sens_move, cam_sens_rot); + EDevice.m_Camera.SetFlyParams(cam_fly_speed, cam_fly_alt); - ExecCommand (COMMAND_UPDATE_GRID); + ExecCommand(COMMAND_UPDATE_GRID); } + //--------------------------------------------------------------------------- -void __stdcall CCustomPreferences::OnClose () +void __stdcall CCustomPreferences::OnClose() { - ApplyValues (); + ApplyValues(); } + //--------------------------------------------------------------------------- -void CheckValidate(ShortcutValue*, const xr_shortcut& new_val, bool& result) +void CheckValidate(ShortcutValue *, const xr_shortcut &new_val, bool &result) { - result = true; - ECommandVec& cmds = GetEditorCommands(); - for (u32 cmd_idx=0; cmd_idxeditable){ - VERIFY(!CMD->sub_commands.empty()); - for (u32 sub_cmd_idx=0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++){ - SESubCommand*& SUB_CMD = CMD->sub_commands[sub_cmd_idx]; - if (SUB_CMD->shortcut.similar(new_val)){ result = false; return;} + result = true; + ECommandVec&cmds = GetEditorCommands(); + for (u32 cmd_idx = 0; cmd_idxeditable) + { + VERIFY(!CMD->sub_commands.empty()); + for (u32 sub_cmd_idx = 0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++) + { + SESubCommand*& SUB_CMD = CMD->sub_commands[sub_cmd_idx]; + if (SUB_CMD->shortcut.similar(new_val)) + { + result = false; + return; + } } } } } -void CCustomPreferences::OnKeyboardCommonFileClick(ButtonValue* B, bool& bModif, bool&) +void CCustomPreferences::OnKeyboardCommonFileClick(ButtonValue *B, bool &bModif, bool &) { bModif = false; xr_string fn; - switch(B->btn_num){ - case 0: - if(EFS.GetOpenName("$import$", fn, false, NULL, 6)){ - CInifile* I = xr_new(fn.c_str(), TRUE, TRUE, TRUE); - LoadShortcuts (I); - xr_delete (I); - m_ItemProps->RefreshForm(); - } - break; - case 1: - if(EFS.GetSaveName("$import$", fn, NULL, 6)){ - CInifile* I = xr_new(fn.c_str(), FALSE, TRUE, TRUE); - SaveShortcuts (I); - xr_delete (I); - } - break; - } + switch (B->btn_num) + { + case 0: + if (EFS.GetOpenName("$import$", fn, false, NULL, 6)) + { + CInifile *I = xr_new(fn.c_str(), TRUE, TRUE, TRUE); + LoadShortcuts(I); + xr_delete(I); + m_ItemProps->RefreshForm(); + } + break; + case 1: + if (EFS.GetSaveName("$import$", fn, NULL, 6)) + { + CInifile *I = xr_new(fn.c_str(), FALSE, TRUE, TRUE); + SaveShortcuts(I); + xr_delete(I); + } + break; + } } -void CCustomPreferences::FillProp(PropItemVec& props) +void CCustomPreferences::FillProp(PropItemVec &props) { - PHelper().CreateFlag32 (props,"Objects\\Library\\Discard Instance", &object_flags, epoDiscardInstance); - PHelper().CreateFlag32 (props,"Objects\\Skeleton\\Draw Joints", &object_flags, epoDrawJoints); - PHelper().CreateFlag32 (props,"Objects\\Skeleton\\Draw Bone Axis", &object_flags, epoDrawBoneAxis); - PHelper().CreateFlag32 (props,"Objects\\Skeleton\\Draw Bone Names", &object_flags, epoDrawBoneNames); - PHelper().CreateFlag32 (props,"Objects\\Skeleton\\Draw Bone Shapes", &object_flags, epoDrawBoneShapes); - PHelper().CreateFlag32 (props,"Objects\\Show\\Hint", &object_flags, epoShowHint); - PHelper().CreateFlag32 (props,"Objects\\Show\\Pivot", &object_flags, epoDrawPivot); - PHelper().CreateFlag32 (props,"Objects\\Show\\Animation Path", &object_flags, epoDrawAnimPath); - PHelper().CreateFlag32 (props,"Objects\\Show\\LOD", &object_flags, epoDrawLOD); - PHelper().CreateFlag32 (props,"Objects\\Loading\\Deffered Loading RB", &object_flags, epoDeffLoadRB); - PHelper().CreateFlag32 (props,"Objects\\Loading\\Deffered Loading CF", &object_flags, epoDeffLoadCF); - PHelper().CreateFlag32 (props,"Objects\\GroupObject\\Select ingroup", &object_flags, epoSelectInGroup); - - PHelper().CreateU32 (props,"Scene\\Common\\Recent Count", &scene_recent_count,0, 25); - PHelper().CreateU32 (props,"Scene\\Common\\Undo Level", &scene_undo_level, 0, 125); - PHelper().CreateFloat (props,"Scene\\Grid\\Cell Size", &grid_cell_size, 0.1f, 10.f); - PHelper().CreateU32 (props,"Scene\\Grid\\Cell Count", &grid_cell_count, 10, 1000); - - PHelper().CreateBOOL (props,"Tools\\Box Pick\\Limited Depth", &bp_lim_depth); - PHelper().CreateBOOL (props,"Tools\\Box Pick\\Back Face Culling", &bp_cull); - PHelper().CreateFloat (props,"Tools\\Box Pick\\Depth Tolerance", &bp_depth_tolerance,0.f, 10000.f); - PHelper().CreateFloat (props,"Tools\\Sens\\Move", &tools_sens_move); - PHelper().CreateBOOL (props,"Tools\\Sens\\ShowMoveAxis", &tools_show_move_axis); - - PHelper().CreateFloat (props,"Tools\\Sens\\Rotate", &tools_sens_rot); - PHelper().CreateFloat (props,"Tools\\Sens\\Scale", &tools_sens_scale); - PHelper().CreateAngle (props,"Tools\\Snap\\Angle", &snap_angle, 0, PI_MUL_2); - PHelper().CreateFloat (props,"Tools\\Snap\\Move", &snap_move, 0.01f, 1000.f); - PHelper().CreateFloat (props,"Tools\\Snap\\Move To", &snap_moveto, 0.01f, 1000.f); - - - PHelper().CreateFloat (props,"Viewport\\Camera\\Move Sens", &cam_sens_move); - PHelper().CreateFloat (props,"Viewport\\Camera\\Rotate Sens", &cam_sens_rot); - PHelper().CreateFloat (props,"Viewport\\Camera\\Fly Speed", &cam_fly_speed, 0.01f, 100.f); - PHelper().CreateFloat (props,"Viewport\\Camera\\Fly Altitude", &cam_fly_alt, 0.f, 1000.f); - PHelper().CreateColor (props,"Viewport\\Fog\\Color", &fog_color ); - PHelper().CreateFloat (props,"Viewport\\Fog\\Fogness", &fog_fogness, 0.f, 100.f); - PHelper().CreateFloat (props,"Viewport\\Near Plane", &view_np, 0.01f, 10.f); - PHelper().CreateFloat (props,"Viewport\\Far Plane", &view_fp, 10.f, 10000.f); - PHelper().CreateAngle (props,"Viewport\\FOV", &view_fov, deg2rad(0.1f), deg2rad(170.f)); - PHelper().CreateColor (props,"Viewport\\Clear Color", &scene_clear_color ); - - ButtonValue* B = PHelper().CreateButton (props,"Keyboard\\Common\\File","Load,Save", 0); - B->OnBtnClickEvent.bind (this,&CCustomPreferences::OnKeyboardCommonFileClick); - ECommandVec& cmds = GetEditorCommands(); - for (u32 cmd_idx=0; cmd_idxeditable){ - VERIFY(!CMD->sub_commands.empty()); - for (u32 sub_cmd_idx=0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++){ - SESubCommand*& SUB_CMD = CMD->sub_commands[sub_cmd_idx]; - string128 nm; sprintf(nm,"%s%s%s",CMD->Desc(),!SUB_CMD->desc.empty()?"\\":"",SUB_CMD->desc.c_str()); - ShortcutValue* V = PHelper().CreateShortcut(props,PrepareKey("Keyboard\\Shortcuts",nm), &SUB_CMD->shortcut); + PHelper().CreateFlag32(props, "Objects\\Library\\Discard Instance", &object_flags, epoDiscardInstance); + PHelper().CreateFlag32(props, "Objects\\Skeleton\\Draw Joints", &object_flags, epoDrawJoints); + PHelper().CreateFlag32(props, "Objects\\Skeleton\\Draw Bone Axis", &object_flags, epoDrawBoneAxis); + PHelper().CreateFlag32(props, "Objects\\Skeleton\\Draw Bone Names", &object_flags, epoDrawBoneNames); + PHelper().CreateFlag32(props, "Objects\\Skeleton\\Draw Bone Shapes", &object_flags, epoDrawBoneShapes); + PHelper().CreateFlag32(props, "Objects\\Show\\Hint", &object_flags, epoShowHint); + PHelper().CreateFlag32(props, "Objects\\Show\\Pivot", &object_flags, epoDrawPivot); + PHelper().CreateFlag32(props, "Objects\\Show\\Animation Path", &object_flags, epoDrawAnimPath); + PHelper().CreateFlag32(props, "Objects\\Show\\LOD", &object_flags, epoDrawLOD); + PHelper().CreateFlag32(props, "Objects\\Loading\\Deffered Loading RB", &object_flags, epoDeffLoadRB); + PHelper().CreateFlag32(props, "Objects\\Loading\\Deffered Loading CF", &object_flags, epoDeffLoadCF); + PHelper().CreateFlag32(props, "Objects\\GroupObject\\Select ingroup", &object_flags, epoSelectInGroup); + + PHelper().CreateU32(props, "Scene\\Common\\Recent Count", &scene_recent_count, 0, 25); + PHelper().CreateU32(props, "Scene\\Common\\Undo Level", &scene_undo_level, 0, 125); + PHelper().CreateFloat(props, "Scene\\Grid\\Cell Size", &grid_cell_size, 0.1f, 10.f); + PHelper().CreateU32(props, "Scene\\Grid\\Cell Count", &grid_cell_count, 10, 1000); + + PHelper().CreateBOOL(props, "Tools\\Box Pick\\Limited Depth", &bp_lim_depth); + PHelper().CreateBOOL(props, "Tools\\Box Pick\\Back Face Culling", &bp_cull); + PHelper().CreateFloat(props, "Tools\\Box Pick\\Depth Tolerance", &bp_depth_tolerance, 0.f, 10000.f); + PHelper().CreateFloat(props, "Tools\\Sens\\Move", &tools_sens_move); + PHelper().CreateBOOL(props, "Tools\\Sens\\ShowMoveAxis", &tools_show_move_axis); + + PHelper().CreateFloat(props, "Tools\\Sens\\Rotate", &tools_sens_rot); + PHelper().CreateFloat(props, "Tools\\Sens\\Scale", &tools_sens_scale); + PHelper().CreateAngle(props, "Tools\\Snap\\Angle", &snap_angle, 0, PI_MUL_2); + PHelper().CreateFloat(props, "Tools\\Snap\\Move", &snap_move, 0.01f, 1000.f); + PHelper().CreateFloat(props, "Tools\\Snap\\Move To", &snap_moveto, 0.01f, 1000.f); + + + PHelper().CreateFloat(props, "Viewport\\Camera\\Move Sens", &cam_sens_move); + PHelper().CreateFloat(props, "Viewport\\Camera\\Rotate Sens", &cam_sens_rot); + PHelper().CreateFloat(props, "Viewport\\Camera\\Fly Speed", &cam_fly_speed, 0.01f, 100.f); + PHelper().CreateFloat(props, "Viewport\\Camera\\Fly Altitude", &cam_fly_alt, 0.f, 1000.f); + PHelper().CreateColor(props, "Viewport\\Fog\\Color", &fog_color); + PHelper().CreateFloat(props, "Viewport\\Fog\\Fogness", &fog_fogness, 0.f, 100.f); + PHelper().CreateFloat(props, "Viewport\\Near Plane", &view_np, 0.01f, 10.f); + PHelper().CreateFloat(props, "Viewport\\Far Plane", &view_fp, 10.f, 10000.f); + PHelper().CreateAngle(props, "Viewport\\FOV", &view_fov, deg2rad(0.1f), deg2rad(170.f)); + PHelper().CreateColor(props, "Viewport\\Clear Color", &scene_clear_color); + + ButtonValue *B = PHelper().CreateButton(props, "Keyboard\\Common\\File", "Load,Save", 0); + B->OnBtnClickEvent.bind(this, &CCustomPreferences::OnKeyboardCommonFileClick); + ECommandVec&cmds = GetEditorCommands(); + for (u32 cmd_idx = 0; cmd_idxeditable) + { + VERIFY(!CMD->sub_commands.empty()); + for (u32 sub_cmd_idx = 0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++) + { + SESubCommand*& SUB_CMD = CMD->sub_commands[sub_cmd_idx]; + string128 nm; + sprintf(nm, "%s%s%s", CMD->Desc(), !SUB_CMD->desc.empty() ? "\\" : "", SUB_CMD->desc.c_str()); + ShortcutValue *V = PHelper().CreateShortcut(props, PrepareKey("Keyboard\\Shortcuts", nm), &SUB_CMD->shortcut); V->OnValidateResultEvent.bind(CheckValidate); } } @@ -182,174 +198,186 @@ void CCustomPreferences::FillProp(PropItemVec& props) void CCustomPreferences::Edit() { // fill prop - PropItemVec props; + PropItemVec props; - FillProp (props); + FillProp(props); - m_ItemProps->AssignItems (props); + m_ItemProps->AssignItems(props); m_ItemProps->ShowPropertiesModal(); // save changed options - Save (); + Save(); } + //--------------------------------------------------------------------------- -void CCustomPreferences::Load(CInifile* I) +void CCustomPreferences::Load(CInifile *I) { - psDeviceFlags.flags = R_U32_SAFE ("editor_prefs","device_flags", psDeviceFlags.flags); - psSoundFlags.flags = R_U32_SAFE ("editor_prefs","sound_flags", psSoundFlags.flags) - - Tools->m_Settings.flags = R_U32_SAFE ("editor_prefs","tools_settings",Tools->m_Settings.flags); - - view_np = R_FLOAT_SAFE ("editor_prefs","view_np" ,view_np ); - view_fp = R_FLOAT_SAFE ("editor_prefs","view_fp" ,view_fp ); - view_fov = R_FLOAT_SAFE ("editor_prefs","view_fov" ,view_fov ); - - fog_color = R_U32_SAFE ("editor_prefs","fog_color" ,fog_color ); - fog_fogness = R_FLOAT_SAFE ("editor_prefs","fog_fogness" ,fog_fogness ); - - cam_fly_speed = R_FLOAT_SAFE ("editor_prefs","cam_fly_speed" ,cam_fly_speed ); - cam_fly_alt = R_FLOAT_SAFE ("editor_prefs","cam_fly_alt" ,cam_fly_alt ); - cam_sens_rot = R_FLOAT_SAFE ("editor_prefs","cam_sens_rot" ,cam_sens_rot ); - cam_sens_move = R_FLOAT_SAFE ("editor_prefs","cam_sens_move" ,cam_sens_move ); - - tools_sens_move = R_FLOAT_SAFE ("editor_prefs","tools_sens_move" ,tools_sens_move ); - tools_sens_rot = R_FLOAT_SAFE ("editor_prefs","tools_sens_rot" ,tools_sens_rot ); - tools_sens_scale = R_FLOAT_SAFE ("editor_prefs","tools_sens_scale" ,tools_sens_scale ); - tools_show_move_axis= R_BOOL_SAFE ("editor_prefs","tools_show_move_axis" ,tools_show_move_axis); - - bp_lim_depth = R_BOOL_SAFE ("editor_prefs","bp_lim_depth" ,bp_lim_depth ); - bp_cull = R_BOOL_SAFE ("editor_prefs","bp_lim_depth" ,bp_cull ); - bp_depth_tolerance = R_FLOAT_SAFE ("editor_prefs","tools_sens_rot" ,bp_depth_tolerance ); - - snap_angle = R_FLOAT_SAFE ("editor_prefs","snap_angle" ,snap_angle ); - snap_move = R_FLOAT_SAFE ("editor_prefs","snap_move" ,snap_move ); - snap_moveto = R_FLOAT_SAFE ("editor_prefs","snap_moveto" ,snap_moveto ); - - grid_cell_size = R_FLOAT_SAFE ("editor_prefs","grid_cell_size" ,grid_cell_size ); - grid_cell_count = R_U32_SAFE ("editor_prefs","grid_cell_count" ,grid_cell_count ); - - scene_undo_level = R_U32_SAFE ("editor_prefs","scene_undo_level" ,scene_undo_level ); - scene_recent_count = R_U32_SAFE ("editor_prefs","scene_recent_count",scene_recent_count ); - scene_clear_color = R_U32_SAFE ("editor_prefs","scene_clear_color" ,scene_clear_color ); - - object_flags.flags = R_U32_SAFE ("editor_prefs","object_flags" ,object_flags.flags ); - - // read recent list - for (u32 i=0; im_Settings.flags = R_U32_SAFE("editor_prefs", "tools_settings", Tools->m_Settings.flags); + + view_np = R_FLOAT_SAFE("editor_prefs", "view_np", view_np); + view_fp = R_FLOAT_SAFE("editor_prefs", "view_fp", view_fp); + view_fov = R_FLOAT_SAFE("editor_prefs", "view_fov", view_fov); + + fog_color = R_U32_SAFE("editor_prefs", "fog_color", fog_color); + fog_fogness = R_FLOAT_SAFE("editor_prefs", "fog_fogness", fog_fogness); + + cam_fly_speed = R_FLOAT_SAFE("editor_prefs", "cam_fly_speed", cam_fly_speed); + cam_fly_alt = R_FLOAT_SAFE("editor_prefs", "cam_fly_alt", cam_fly_alt); + cam_sens_rot = R_FLOAT_SAFE("editor_prefs", "cam_sens_rot", cam_sens_rot); + cam_sens_move = R_FLOAT_SAFE("editor_prefs", "cam_sens_move", cam_sens_move); + + tools_sens_move = R_FLOAT_SAFE("editor_prefs", "tools_sens_move", tools_sens_move); + tools_sens_rot = R_FLOAT_SAFE("editor_prefs", "tools_sens_rot", tools_sens_rot); + tools_sens_scale = R_FLOAT_SAFE("editor_prefs", "tools_sens_scale", tools_sens_scale); + tools_show_move_axis = R_BOOL_SAFE("editor_prefs", "tools_show_move_axis", tools_show_move_axis); + + bp_lim_depth = R_BOOL_SAFE("editor_prefs", "bp_lim_depth", bp_lim_depth); + bp_cull = R_BOOL_SAFE("editor_prefs", "bp_lim_depth", bp_cull); + bp_depth_tolerance = R_FLOAT_SAFE("editor_prefs", "tools_sens_rot", bp_depth_tolerance); + + snap_angle = R_FLOAT_SAFE("editor_prefs", "snap_angle", snap_angle); + snap_move = R_FLOAT_SAFE("editor_prefs", "snap_move", snap_move); + snap_moveto = R_FLOAT_SAFE("editor_prefs", "snap_moveto", snap_moveto); + + grid_cell_size = R_FLOAT_SAFE("editor_prefs", "grid_cell_size", grid_cell_size); + grid_cell_count = R_U32_SAFE("editor_prefs", "grid_cell_count", grid_cell_count); + + scene_undo_level = R_U32_SAFE("editor_prefs", "scene_undo_level", scene_undo_level); + scene_recent_count = R_U32_SAFE("editor_prefs", "scene_recent_count", scene_recent_count); + scene_clear_color = R_U32_SAFE("editor_prefs", "scene_clear_color", scene_clear_color); + + object_flags.flags = R_U32_SAFE("editor_prefs", "object_flags", object_flags.flags); + + // read recent list + for (u32 i = 0; iLoadSettings (I); + UI->LoadSettings(I); } -void CCustomPreferences::Save(CInifile* I) +void CCustomPreferences::Save(CInifile *I) { - I->w_u32 ("editor_prefs","device_flags", psDeviceFlags.flags ); - I->w_u32 ("editor_prefs","sound_flags", psSoundFlags.flags ); + I->w_u32("editor_prefs", "device_flags", psDeviceFlags.flags); + I->w_u32("editor_prefs", "sound_flags", psSoundFlags.flags); + + I->w_u32("editor_prefs", "tools_settings", Tools->m_Settings.flags); - I->w_u32 ("editor_prefs","tools_settings", Tools->m_Settings.flags ); + I->w_float("editor_prefs", "view_np", view_np); + I->w_float("editor_prefs", "view_fp", view_fp); + I->w_float("editor_prefs", "view_fov", view_fov); - I->w_float ("editor_prefs","view_np", view_np ); - I->w_float ("editor_prefs","view_fp", view_fp ); - I->w_float ("editor_prefs","view_fov", view_fov ); + I->w_u32("editor_prefs", "fog_color", fog_color); + I->w_float("editor_prefs", "fog_fogness", fog_fogness); - I->w_u32 ("editor_prefs","fog_color", fog_color ); - I->w_float ("editor_prefs","fog_fogness", fog_fogness ); + I->w_float("editor_prefs", "cam_fly_speed", cam_fly_speed); + I->w_float("editor_prefs", "cam_fly_alt", cam_fly_alt); + I->w_float("editor_prefs", "cam_sens_rot", cam_sens_rot); + I->w_float("editor_prefs", "cam_sens_move", cam_sens_move); - I->w_float ("editor_prefs","cam_fly_speed", cam_fly_speed ); - I->w_float ("editor_prefs","cam_fly_alt", cam_fly_alt ); - I->w_float ("editor_prefs","cam_sens_rot", cam_sens_rot ); - I->w_float ("editor_prefs","cam_sens_move", cam_sens_move ); + I->w_float("editor_prefs", "tools_sens_rot", tools_sens_rot); + I->w_float("editor_prefs", "tools_sens_move", tools_sens_move); + I->w_float("editor_prefs", "tools_sens_scale", tools_sens_scale); + I->w_bool("editor_prefs", "tools_show_move_axis", tools_show_move_axis); - I->w_float ("editor_prefs","tools_sens_rot", tools_sens_rot ); - I->w_float ("editor_prefs","tools_sens_move", tools_sens_move ); - I->w_float ("editor_prefs","tools_sens_scale", tools_sens_scale); - I->w_bool ("editor_prefs","tools_show_move_axis",tools_show_move_axis); - - I->w_bool ("editor_prefs","bp_lim_depth", bp_lim_depth ); - I->w_bool ("editor_prefs","bp_lim_depth", bp_cull ); - I->w_float ("editor_prefs","bp_depth_tolerance",bp_depth_tolerance ); + I->w_bool("editor_prefs", "bp_lim_depth", bp_lim_depth); + I->w_bool("editor_prefs", "bp_lim_depth", bp_cull); + I->w_float("editor_prefs", "bp_depth_tolerance", bp_depth_tolerance); - I->w_float ("editor_prefs","snap_angle", snap_angle ); - I->w_float ("editor_prefs","snap_move", snap_move ); - I->w_float ("editor_prefs","snap_moveto", snap_moveto ); + I->w_float("editor_prefs", "snap_angle", snap_angle); + I->w_float("editor_prefs", "snap_move", snap_move); + I->w_float("editor_prefs", "snap_moveto", snap_moveto); - I->w_float ("editor_prefs","grid_cell_size", grid_cell_size ); - I->w_u32 ("editor_prefs","grid_cell_count", grid_cell_count ); + I->w_float("editor_prefs", "grid_cell_size", grid_cell_size); + I->w_u32("editor_prefs", "grid_cell_count", grid_cell_count); - I->w_u32 ("editor_prefs","scene_undo_level", scene_undo_level ); - I->w_u32 ("editor_prefs","scene_recent_count", scene_recent_count ); - I->w_u32 ("editor_prefs","scene_clear_color", scene_clear_color ); + I->w_u32("editor_prefs", "scene_undo_level", scene_undo_level); + I->w_u32("editor_prefs", "scene_recent_count", scene_recent_count); + I->w_u32("editor_prefs", "scene_clear_color", scene_clear_color); - I->w_u32 ("editor_prefs","object_flags", object_flags.flags); + I->w_u32("editor_prefs", "object_flags", object_flags.flags); - for (AStringIt it=scene_recent_list.begin(); it!=scene_recent_list.end(); it++){ - AnsiString L; L.sprintf("recent_files_%d",it-scene_recent_list.begin()); - AnsiString V; V.sprintf("\"%s\"",it->c_str()); - I->w_string("editor_prefs",L.c_str(),V.c_str()); + for (AStringIt it = scene_recent_list.begin(); it!=scene_recent_list.end(); it++) + { + AnsiString L; + L.sprintf("recent_files_%d", it-scene_recent_list.begin()); + AnsiString V; + V.sprintf("\"%s\"", it->c_str()); + I->w_string("editor_prefs", L.c_str(), V.c_str()); } - I->w_string("editor_prefs","weather", sWeather.c_str() ); + I->w_string("editor_prefs", "weather", sWeather.c_str()); // load shortcuts - SaveShortcuts (I); - UI->SaveSettings (I); + SaveShortcuts(I); + UI->SaveSettings(I); } void CCustomPreferences::Load() { - string_path fn; - INI_NAME (fn); - CInifile* I = xr_new(fn, TRUE, TRUE, TRUE); - Load (I); - xr_delete (I); - ApplyValues (); + string_path fn; + INI_NAME(fn); + CInifile *I = xr_new(fn, TRUE, TRUE, TRUE); + Load(I); + xr_delete(I); + ApplyValues(); } + void CCustomPreferences::Save() { - string_path fn; - INI_NAME (fn); - CInifile* I = xr_new(fn, FALSE, TRUE, TRUE); + string_path fn; + INI_NAME(fn); + CInifile *I = xr_new(fn, FALSE, TRUE, TRUE); I->set_override_names(TRUE); - Save (I); - xr_delete (I); + Save(I); + xr_delete(I); } void CCustomPreferences::AppendRecentFile(LPCSTR name) { - for (AStringIt it=scene_recent_list.begin(); it!=scene_recent_list.end(); it++){ - if (*it==name){ - scene_recent_list.erase (it); + for (AStringIt it = scene_recent_list.begin(); it!=scene_recent_list.end(); it++) + { + if (*it==name) + { + scene_recent_list.erase(it); break; } } - scene_recent_list.insert(scene_recent_list.begin(),name); - while (scene_recent_list.size()>=EPrefs->scene_recent_count) - scene_recent_list.pop_back(); + scene_recent_list.insert(scene_recent_list.begin(), name); + while (scene_recent_list.size()>=EPrefs->scene_recent_count) + scene_recent_list.pop_back(); - ExecCommand (COMMAND_REFRESH_UI_BAR); + ExecCommand(COMMAND_REFRESH_UI_BAR); } + //--------------------------------------------------------------------------- void CCustomPreferences::OnCreate() { - Load (); - m_ItemProps = TProperties::CreateModalForm("Editor Preferences",false,0,0,TOnCloseEvent(this,&CCustomPreferences::OnClose),TProperties::plItemFolders|TProperties::plFullSort); //TProperties::plFullExpand TProperties::plFullSort TProperties::plNoClearStore|TProperties::plFolderStore| + Load(); + m_ItemProps = TProperties::CreateModalForm("Editor Preferences", false, 0, 0, TOnCloseEvent(this, &CCustomPreferences::OnClose), TProperties::plItemFolders|TProperties::plFullSort); //TProperties::plFullExpand TProperties::plFullSort TProperties::plNoClearStore|TProperties::plFolderStore| } + //--------------------------------------------------------------------------- void CCustomPreferences::OnDestroy() { TProperties::DestroyForm(m_ItemProps); - Save (); + Save(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ECore/Editor/EditorPreferences.h b/src/editors/ECore/Editor/EditorPreferences.h index 97a78dece98..a5ea05598d3 100644 --- a/src/editors/ECore/Editor/EditorPreferences.h +++ b/src/editors/ECore/Editor/EditorPreferences.h @@ -7,84 +7,86 @@ class TProperties; //--------------------------------------------------------------------------- -enum{ - epoDrawPivot = (1<<0), - epoDrawAnimPath = (1<<1), - epoDrawJoints = (1<<2), - epoDrawBoneAxis = (1<<3), - epoDrawBoneNames = (1<<4), - epoDrawBoneShapes = (1<<5), - epoShowHint = (1<<6), - epoDrawLOD = (1<<7), - epoDiscardInstance = (1<<8), - epoDeffLoadRB = (1<<9), - epoDeffLoadCF = (1<<10), - epoSelectInGroup = (1<<11), +enum +{ + epoDrawPivot = (1<<0), + epoDrawAnimPath = (1<<1), + epoDrawJoints = (1<<2), + epoDrawBoneAxis = (1<<3), + epoDrawBoneNames = (1<<4), + epoDrawBoneShapes = (1<<5), + epoShowHint = (1<<6), + epoDrawLOD = (1<<7), + epoDiscardInstance = (1<<8), + epoDeffLoadRB = (1<<9), + epoDeffLoadCF = (1<<10), + epoSelectInGroup = (1<<11), }; + class ECORE_API CCustomPreferences { -private: // User declarations - TProperties* m_ItemProps; -public: - // view - float view_np; - float view_fp; - float view_fov; - // fog - u32 fog_color; - float fog_fogness; + private: // User declarations + TProperties*m_ItemProps; + public: + // view + float view_np; + float view_fp; + float view_fov; + // fog + u32 fog_color; + float fog_fogness; // camera - float cam_fly_speed; - float cam_fly_alt; - float cam_sens_rot; - float cam_sens_move; - // tools mouse - float tools_sens_rot; - float tools_sens_move; - float tools_sens_scale; - BOOL tools_show_move_axis; + float cam_fly_speed; + float cam_fly_alt; + float cam_sens_rot; + float cam_sens_move; + // tools mouse + float tools_sens_rot; + float tools_sens_move; + float tools_sens_scale; + BOOL tools_show_move_axis; // box pick - BOOL bp_lim_depth; - BOOL bp_cull; - float bp_depth_tolerance; + BOOL bp_lim_depth; + BOOL bp_cull; + float bp_depth_tolerance; // snap - float snap_angle; - float snap_move; - float snap_moveto; + float snap_angle; + float snap_move; + float snap_moveto; // grid - float grid_cell_size; - u32 grid_cell_count; + float grid_cell_size; + u32 grid_cell_count; // scene - u32 scene_undo_level; - u32 scene_recent_count; - u32 scene_clear_color; - AStringVec scene_recent_list; + u32 scene_undo_level; + u32 scene_recent_count; + u32 scene_clear_color; + AStringVec scene_recent_list; // objects - Flags32 object_flags; - shared_str sWeather; -protected: - void OnKeyboardCommonFileClick (ButtonValue* value, bool& bModif, bool& bSafe); - void __stdcall OnClose (); - void ApplyValues (); + Flags32 object_flags; + shared_str sWeather; + protected: + void OnKeyboardCommonFileClick(ButtonValue*value, bool& bModif, bool& bSafe); + void__stdcall OnClose(); + void ApplyValues(); - virtual void Load (CInifile*); - virtual void Save (CInifile*); -public: // User declarations - CCustomPreferences (); - virtual ~CCustomPreferences (); + virtual void Load(CInifile*); + virtual void Save(CInifile*); + public: // User declarations + CCustomPreferences(); + virtual ~CCustomPreferences(); - void OnCreate (); - void OnDestroy (); + void OnCreate(); + void OnDestroy(); - virtual void FillProp (PropItemVec& items); + virtual void FillProp(PropItemVec&items); - void Edit (); + void Edit(); - void Load (); - void Save (); - - void AppendRecentFile (LPCSTR name); - LPCSTR FirstRecentFile (){return scene_recent_list.empty()?"":scene_recent_list.front().c_str();} + void Load(); + void Save(); + + void AppendRecentFile(LPCSTR name); + LPCSTR FirstRecentFile(){return scene_recent_list.empty() ? "" : scene_recent_list.front().c_str();} }; //--------------------------------------------------------------------------- #define R_FLOAT_SAFE(S,L,D) I->line_exist(S,L)?I->r_float(S,L):D; @@ -92,7 +94,8 @@ class ECORE_API CCustomPreferences #define R_BOOL_SAFE(S,L,D) I->line_exist(S,L)?I->r_bool(S,L):D; #define R_STRING_SAFE(S,L,D)I->line_exist(S,L)?I->r_string_wb(S,L):D; //--------------------------------------------------------------------------- -extern ECORE_API CCustomPreferences* EPrefs; +extern ECORE_API CCustomPreferences* EPrefs; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ECore/Editor/Engine.cpp b/src/editors/ECore/Editor/Engine.cpp index ee07b2321f9..52f264db5dc 100644 --- a/src/editors/ECore/Editor/Engine.cpp +++ b/src/editors/ECore/Editor/Engine.cpp @@ -8,8 +8,7 @@ #include "Engine.h" #include "ui_main.h" -xrDispatchTable PSGP; -CEngine Engine; +CEngine Engine; ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -17,39 +16,37 @@ CEngine Engine; CEngine::CEngine() { - pSettings = 0; + pSettings = 0; } -CEngine::~CEngine() -{ - -} +CEngine::~CEngine() {} LPCSTR CEngine::LastWindowsError() { - static string1024 errmsg_buf; - LPCSTR err=0; + static string1024 errmsg_buf; + LPCSTR err = 0; - u32 hr=GetLastError(); - if (hr!=0) { - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,hr,0,errmsg_buf,1024,0); + u32 hr = GetLastError(); + if (hr!=0) + { + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, hr, 0, errmsg_buf, 1024, 0); err = errmsg_buf; - } + } return err; } -extern void __stdcall xrSkin1W_x86 (vertRender* D, vertBoned1W* S, u32 vCount, CBoneInstance* Bones); -extern void __stdcall xrSkin2W_x86 (vertRender* D, vertBoned2W* S, u32 vCount, CBoneInstance* Bones); +extern void __stdcall xrSkin1W_x86(vertRender *D, vertBoned1W *S, u32 vCount, CBoneInstance *Bones); +extern void __stdcall xrSkin2W_x86(vertRender *D, vertBoned2W *S, u32 vCount, CBoneInstance *Bones); void CEngine::Initialize(void) { - // Other stuff - string_path fn; - strconcat (sizeof(fn),fn,UI->EditorName(),".log"); - FS.update_path (fn,_local_root_,fn); + // Other stuff + string_path fn; + strconcat(sizeof(fn), fn, UI->EditorName(), ".log"); + FS.update_path(fn, _local_root_, fn); #ifdef _EDITOR - // Bind PSGP + // Bind PSGP ZeroMemory (&PSGP,sizeof(PSGP)); hPSGP = LoadLibrary("xrCPU_Pipe"); R_ASSERT2 (hPSGP,"Can't find 'xrCPU_Pipe'"); @@ -61,20 +58,25 @@ void CEngine::Initialize(void) PSGP.skin2W = xrSkin2W_x86; #endif - ReloadSettings (); + ReloadSettings(); } void CEngine::ReloadSettings() { - xr_delete (pSettings); + xr_delete(pSettings); // game configure - string_path si_name; - FS.update_path (si_name,"$game_config$","system.ltx"); - pSettings = xr_new(si_name,TRUE);// FALSE,TRUE,TRUE); + string_path si_name; + FS.update_path(si_name, "$game_config$", "system.ltx"); + pSettings = xr_new(si_name, TRUE);// FALSE,TRUE,TRUE); } void CEngine::Destroy() { - xr_delete (pSettings); - if (hPSGP) { FreeLibrary(hPSGP); hPSGP=0; } + xr_delete(pSettings); + if (hPSGP) + { + FreeLibrary(hPSGP); + hPSGP = 0; + } } + diff --git a/src/editors/ECore/Editor/ExportObjectOGF.cpp b/src/editors/ECore/Editor/ExportObjectOGF.cpp index 54276f0cca8..5896bd4a81e 100644 --- a/src/editors/ECore/Editor/ExportObjectOGF.cpp +++ b/src/editors/ECore/Editor/ExportObjectOGF.cpp @@ -16,72 +16,84 @@ CObjectOGFCollectorPacked::CObjectOGFCollectorPacked(const Fbox &bb, int apx_vertices, int apx_faces) { // Params - m_VMscale.set (bb.max.x-bb.min.x+EPS, bb.max.y-bb.min.y+EPS, bb.max.z-bb.min.z+EPS); - m_VMmin.set (bb.min).sub(EPS); - m_VMeps.set (m_VMscale.x/clpOGFMX/2,m_VMscale.y/clpOGFMY/2,m_VMscale.z/clpOGFMZ/2); - m_VMeps.x = (m_VMeps.x=0) V.P.set(m_Verts[similar_pos].P); + if (similar_pos>=0) + V.P.set(m_Verts[similar_pos].P); P = m_Verts.size(); - if (P>=0xFFFF) return 0xffff; + if (P>=0xFFFF) + return 0xffff; m_Verts.push_back(V); m_VM[ix][iy][iz].push_back(P); - u32 ixE,iyE,izE; + u32 ixE, iyE, izE; ixE = iFloor(float(V.P.x+m_VMeps.x-m_VMmin.x)/m_VMscale.x*clpOGFMX); iyE = iFloor(float(V.P.y+m_VMeps.y-m_VMmin.y)/m_VMscale.y*clpOGFMY); izE = iFloor(float(V.P.z+m_VMeps.z-m_VMmin.z)/m_VMscale.z*clpOGFMZ); - R_ASSERT(ixE<=clpOGFMX && iyE<=clpOGFMY && izE<=clpOGFMZ); - - if (ixE!=ix) m_VM[ixE][iy][iz].push_back (P); - if (iyE!=iy) m_VM[ix][iyE][iz].push_back (P); - if (izE!=iz) m_VM[ix][iy][izE].push_back (P); - if ((ixE!=ix)&&(iyE!=iy)) m_VM[ixE][iyE][iz].push_back(P); - if ((ixE!=ix)&&(izE!=iz)) m_VM[ixE][iy][izE].push_back(P); - if ((iyE!=iy)&&(izE!=iz)) m_VM[ix][iyE][izE].push_back(P); - if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) m_VM[ixE][iyE][izE].push_back(P); + R_ASSERT(ixE<=clpOGFMX&&iyE<=clpOGFMY&&izE<=clpOGFMZ); + + if (ixE!=ix) + m_VM[ixE][iy][iz].push_back(P); + if (iyE!=iy) + m_VM[ix][iyE][iz].push_back(P); + if (izE!=iz) + m_VM[ix][iy][izE].push_back(P); + if ((ixE!=ix)&&(iyE!=iy)) + m_VM[ixE][iyE][iz].push_back(P); + if ((ixE!=ix)&&(izE!=iz)) + m_VM[ixE][iy][izE].push_back(P); + if ((iyE!=iy)&&(izE!=iz)) + m_VM[ix][iyE][izE].push_back(P); + if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) + m_VM[ixE][iyE][izE].push_back(P); } VERIFY(PP); + m_Box.invalidate(); + for (OGFVertIt v_it = m_Verts.begin(); v_it!=m_Verts.end(); ++v_it) + m_Box.modify(v_it->P); } -CExportObjectOGF::SSplit::SSplit(CSurface* surf, const Fbox& bb) +CExportObjectOGF::SSplit::SSplit(CSurface *surf, const Fbox &bb) { - apx_box = bb; - m_Surf = surf; - m_CurrentPart = NULL; + apx_box = bb; + m_Surf = surf; + m_CurrentPart = NULL; } CExportObjectOGF::SSplit::~SSplit() { - for (COGFCPIt it=m_Parts.begin(); it!=m_Parts.end(); ++it) - xr_delete(*it); + for (COGFCPIt it = m_Parts.begin(); it!=m_Parts.end(); ++it) + xr_delete(*it); } void CExportObjectOGF::SSplit::AppendPart(int apx_vertices, int apx_faces) { - m_Parts.push_back (xr_new(apx_box,apx_vertices, apx_faces)); - m_CurrentPart = m_Parts.back(); + m_Parts.push_back(xr_new(apx_box, apx_vertices, apx_faces)); + m_CurrentPart = m_Parts.back(); } -void CExportObjectOGF::SSplit::SavePart(IWriter& F, CObjectOGFCollectorPacked* part) +void CExportObjectOGF::SSplit::SavePart(IWriter &F, CObjectOGFCollectorPacked *part) { // Header - F.open_chunk (OGF_HEADER); - ogf_header H; - H.format_version = xrOGF_FormatVersion; - H.type = (part->m_SWR.size())?MT_PROGRESSIVE:MT_NORMAL; - H.shader_id = 0; - H.bb.min = part->m_Box.min; - H.bb.max = part->m_Box.max; - part->m_Box.getsphere(H.bs.c,H.bs.r); - F.w (&H, sizeof(H)); - F.close_chunk (); + F.open_chunk(OGF_HEADER); + ogf_header H; + H.format_version = xrOGF_FormatVersion; + H.type = (part->m_SWR.size()) ? MT_PROGRESSIVE : MT_NORMAL; + H.shader_id = 0; + H.bb.min = part->m_Box.min; + H.bb.max = part->m_Box.max; + part->m_Box.getsphere(H.bs.c, H.bs.r); + F.w(&H, sizeof(H)); + F.close_chunk(); // Texture - F.open_chunk (OGF_TEXTURE); - F.w_stringZ (m_Surf->_Texture()); - F.w_stringZ (m_Surf->_ShaderName()); - F.close_chunk (); + F.open_chunk(OGF_TEXTURE); + F.w_stringZ(m_Surf->_Texture()); + F.w_stringZ(m_Surf->_ShaderName()); + F.close_chunk(); // Vertices - u32 dwFVF = D3DFVF_XYZ|D3DFVF_NORMAL|(1<m_Verts.size()); - for (OGFVertIt v_it=part->m_Verts.begin(); v_it!=part->m_Verts.end(); ++v_it) - { - SOGFVert const& pV = *v_it; - F.w (&(pV.P), sizeof(float)*3); // position (offset) - F.w (&(pV.N), sizeof(float)*3); // normal - F.w_float (pV.UV.x); - F.w_float (pV.UV.y); // tu,tv + u32 dwFVF = D3DFVF_XYZ|D3DFVF_NORMAL|(1<m_Verts.size()); + for (OGFVertIt v_it = part->m_Verts.begin(); v_it!=part->m_Verts.end(); ++v_it) + { + SOGFVert const &pV = *v_it; + F.w(&(pV.P), sizeof(float)*3); // position (offset) + F.w(&(pV.N), sizeof(float)*3); // normal + F.w_float(pV.UV.x); + F.w_float(pV.UV.y); // tu,tv } - F.close_chunk (); + F.close_chunk(); // Faces - F.open_chunk (OGF_INDICES); - F.w_u32 (part->m_Faces.size()*3); - F.w (&part->m_Faces.front(), part->m_Faces.size()*3*sizeof(u16)); - F.close_chunk (); + F.open_chunk(OGF_INDICES); + F.w_u32(part->m_Faces.size()*3); + F.w(&part->m_Faces.front(), part->m_Faces.size()*3*sizeof(u16)); + F.close_chunk(); // PMap - if (part->m_SWR.size()) - { + if (part->m_SWR.size()) + { F.open_chunk(OGF_SWIDATA); - F.w_u32 (0); // reserved space 16 bytes - F.w_u32 (0); - F.w_u32 (0); - F.w_u32 (0); - F.w_u32 (part->m_SWR.size()); // num collapses - for (u32 swr_idx=0; swr_idxm_SWR.size(); ++swr_idx) - F.w (&part->m_SWR[swr_idx],sizeof(VIPM_SWR)); + F.w_u32(0); // reserved space 16 bytes + F.w_u32(0); + F.w_u32(0); + F.w_u32(0); + F.w_u32(part->m_SWR.size()); // num collapses + for (u32 swr_idx = 0; swr_idxm_SWR.size(); ++swr_idx) + F.w(&part->m_SWR[swr_idx], sizeof(VIPM_SWR)); F.close_chunk(); } } -void CExportObjectOGF::SSplit::Save(IWriter& F, int& chunk_id) +void CExportObjectOGF::SSplit::Save(IWriter &F, int &chunk_id) { - for (COGFCPIt it=m_Parts.begin(); it!=m_Parts.end(); ++it) - { - CObjectOGFCollectorPacked* part = *it; - F.open_chunk (chunk_id); - SavePart (F, part); - F.close_chunk (); + for (COGFCPIt it = m_Parts.begin(); it!=m_Parts.end(); ++it) + { + CObjectOGFCollectorPacked *part = *it; + F.open_chunk(chunk_id); + SavePart(F, part); + F.close_chunk(); ++chunk_id; } } void CObjectOGFCollectorPacked::MakeProgressive() { - VIPM_Init (); + VIPM_Init(); - for (OGFVertIt vert_it=m_Verts.begin(); vert_it!=m_Verts.end(); ++vert_it) - VIPM_AppendVertex(vert_it->P,vert_it->UV); + for (OGFVertIt vert_it = m_Verts.begin(); vert_it!=m_Verts.end(); ++vert_it) + VIPM_AppendVertex(vert_it->P, vert_it->UV); - for (OGFFaceIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); ++f_it) - VIPM_AppendFace(f_it->v[0],f_it->v[1],f_it->v[2]); + for (OGFFaceIt f_it = m_Faces.begin(); f_it!=m_Faces.end(); ++f_it) + VIPM_AppendFace(f_it->v[0], f_it->v[1], f_it->v[2]); - VIPM_Result* R = VIPM_Convert(u32(-1),1.f,1); + VIPM_Result *R = VIPM_Convert(u32(-1), 1.f, 1); if (R) - { + { // Permute vertices - OGFVertVec const temp_list = m_Verts; - for(u32 i=0; ipermute_verts[i]]=temp_list[i]; - + OGFVertVec const temp_list = m_Verts; + for (u32 i = 0; ipermute_verts[i]] = temp_list[i]; + // Fill indices - m_Faces.resize (R->indices.size()/3); - for (u32 f_idx=0; f_idxindices[f_idx*3+0]; - F.v[1] = R->indices[f_idx*3+1]; - F.v[2] = R->indices[f_idx*3+2]; + m_Faces.resize(R->indices.size()/3); + for (u32 f_idx = 0; f_idxindices[f_idx*3+0]; + F.v[1] = R->indices[f_idx*3+1]; + F.v[2] = R->indices[f_idx*3+2]; } // Fill SWR - m_SWR.resize (R->swr_records.size()); - for (u32 swr_idx=0; swr_idx!=m_SWR.size(); ++swr_idx) - m_SWR[swr_idx] = R->swr_records[swr_idx]; - - }else{ - Log("!..Can't make progressive."); + m_SWR.resize(R->swr_records.size()); + for (u32 swr_idx = 0; swr_idx!=m_SWR.size(); ++swr_idx) + m_SWR[swr_idx] = R->swr_records[swr_idx]; + } + else + { + Log("!..Can't make progressive."); } - + // cleanup - VIPM_Destroy (); + VIPM_Destroy(); } -void CObjectOGFCollectorPacked:: OptimizeTextureCoordinates() +void CObjectOGFCollectorPacked::OptimizeTextureCoordinates() { // Optimize texture coordinates // 1. Calc bounds - Fvector2 Tdelta; - Fvector2 Tmin, Tmax; - Tmin.set (flt_max, flt_max); - Tmax.set (flt_min, flt_min); - const u32 v_cnt = m_Verts.size(); + Fvector2 Tdelta; + Fvector2 Tmin, Tmax; + Tmin.set(flt_max, flt_max); + Tmax.set(flt_min, flt_min); + const u32 v_cnt = m_Verts.size(); { - for (u32 v_idx=0; v_idx!=v_cnt; v_idx++) - { - SOGFVert const& iV = m_Verts[v_idx]; - Tmin.min (iV.UV); - Tmax.max (iV.UV); - } + for (u32 v_idx = 0; v_idx!=v_cnt; v_idx++) + { + SOGFVert const &iV = m_Verts[v_idx]; + Tmin.min(iV.UV); + Tmax.max(iV.UV); + } } - Tdelta.x = floorf((Tmax.x-Tmin.x)/2+Tmin.x); - Tdelta.y = floorf((Tmax.y-Tmin.y)/2+Tmin.y); - - Fvector2 Tsize; - Tsize.sub (Tmax,Tmin); - { - // 2. Recalc UV mapping - for (u32 v_idx=0; v_idx!=v_cnt; ++v_idx) - { - SOGFVert &iV = m_Verts[v_idx]; - iV.UV.sub (Tdelta); - } + Tdelta.x = floorf((Tmax.x-Tmin.x)/2+Tmin.x); + Tdelta.y = floorf((Tmax.y-Tmin.y)/2+Tmin.y); + + Fvector2 Tsize; + Tsize.sub(Tmax, Tmin); + { + // 2. Recalc UV mapping + for (u32 v_idx = 0; v_idx!=v_cnt; ++v_idx) + { + SOGFVert&iV = m_Verts[v_idx]; + iV.UV.sub(Tdelta); + } } } void CExportObjectOGF::SSplit::MakeProgressive() { - for (COGFCPIt it=m_Parts.begin(); it!=m_Parts.end(); ++it) - (*it)->MakeProgressive(); + for (COGFCPIt it = m_Parts.begin(); it!=m_Parts.end(); ++it) + (*it)->MakeProgressive(); } -CExportObjectOGF::CExportObjectOGF(CEditableObject* object) +CExportObjectOGF::CExportObjectOGF(CEditableObject *object) { - m_Source = object; + m_Source = object; } CExportObjectOGF::~CExportObjectOGF() { - for (SplitIt it=m_Splits.begin(); it!=m_Splits.end(); ++it) - xr_delete(*it); + for (SplitIt it = m_Splits.begin(); it!=m_Splits.end(); ++it) + xr_delete(*it); } -CExportObjectOGF::SSplit* CExportObjectOGF::FindSplit(CSurface* surf) +CExportObjectOGF::SSplit *CExportObjectOGF::FindSplit(CSurface *surf) { - for (SplitIt it=m_Splits.begin(); it!=m_Splits.end(); ++it) - if ((*it)->m_Surf==surf) - return *it; + for (SplitIt it = m_Splits.begin(); it!=m_Splits.end(); ++it) + if ((*it)->m_Surf==surf) + return *it; return 0; } -bool CExportObjectOGF::PrepareMESH(CEditableMesh* MESH) +bool CExportObjectOGF::PrepareMESH(CEditableMesh *MESH) { -// // generate normals - bool bResult = true; + // // generate normals + bool bResult = true; MESH->GenerateVNormals(0); // fill faces - for (SurfFacesPairIt sp_it=MESH->m_SurfFaces.begin(); sp_it!=MESH->m_SurfFaces.end(); ++sp_it) - { - IntVec& face_lst= sp_it->second; - CSurface* surf = sp_it->first; - u32 dwTexCnt = ((surf->_FVF()&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT); - R_ASSERT (dwTexCnt==1); - SSplit* split = FindSplit(surf); + for (SurfFacesPairIt sp_it = MESH->m_SurfFaces.begin(); sp_it!=MESH->m_SurfFaces.end(); ++sp_it) + { + IntVec &face_lst = sp_it->second; + CSurface*surf = sp_it->first; + u32 dwTexCnt = ((surf->_FVF()&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT); + R_ASSERT(dwTexCnt==1); + SSplit*split = FindSplit(surf); if (0==split) - { + { #ifdef _EDITOR SGameMtl* M = GMLib.GetMaterialByID(surf->_GameMtl()); if (0==M) @@ -306,354 +319,359 @@ bool CExportObjectOGF::PrepareMESH(CEditableMesh* MESH) break; } #endif - m_Splits.push_back (xr_new(surf,m_Source->GetBox())); - split = m_Splits.back(); + m_Splits.push_back(xr_new(surf,m_Source->GetBox())); + split = m_Splits.back(); } - int elapsed_faces = surf->m_Flags.is(CSurface::sf2Sided) ?face_lst.size()*2 : face_lst.size(); - const bool b2sided = !!surf->m_Flags.is(CSurface::sf2Sided); - - if (0==split->m_CurrentPart) - split->AppendPart( (elapsed_faces>0xffff) ? 0xffff : elapsed_faces, - (elapsed_faces>0xffff) ? 0xffff : elapsed_faces); - - do{ - for (IntIt f_it=face_lst.begin(); f_it!=face_lst.end(); ++f_it) - { - bool bNewPart = false; - st_Face& face = MESH->m_Faces[*f_it]; + int elapsed_faces = surf->m_Flags.is(CSurface::sf2Sided) ? face_lst.size()*2 : face_lst.size(); + const bool b2sided = !!surf->m_Flags.is(CSurface::sf2Sided); + + if (0==split->m_CurrentPart) + split->AppendPart((elapsed_faces>0xffff) ? 0xffff : elapsed_faces, + (elapsed_faces>0xffff) ? 0xffff : elapsed_faces); + + do + { + for (IntIt f_it = face_lst.begin(); f_it!=face_lst.end(); ++f_it) + { + bool bNewPart = false; + st_Face&face = MESH->m_Faces[*f_it]; { SOGFVert v[3]; - for (int k=0; k<3; ++k) - { - st_FaceVert& fv = face.pv[k]; - int offs = 0; - const Fvector2* uv = 0; - for (u32 t=0; tm_VMRefs[fv.vmref].pts[t+offs]; - st_VMap& vmap = *MESH->m_VMaps[vm_pt.vmap_index]; + st_VMapPt&vm_pt = MESH->m_VMRefs[fv.vmref].pts[t+offs]; + st_VMap&vmap = *MESH->m_VMaps[vm_pt.vmap_index]; if (vmap.type!=vmtUV) { - ++offs; + ++offs; --t; continue; } - uv = &vmap.getUV(vm_pt.index); + uv = &vmap.getUV(vm_pt.index); } - R_ASSERT2 (uv,"uv empty"); - u32 norm_id = (*f_it)*3+k; - R_ASSERT2 (norm_idGetFCount()*3,"Normal index out of range."); - v[k].set (MESH->m_Vertices[fv.pindex],MESH->m_VertexNormals[norm_id],*uv); - } + R_ASSERT2(uv, "uv empty"); + u32 norm_id = (*f_it)*3+k; + R_ASSERT2(norm_idGetFCount()*3, "Normal index out of range."); + v[k].set(MESH->m_Vertices[fv.pindex], MESH->m_VertexNormals[norm_id], *uv); + } --elapsed_faces; - if (!split->m_CurrentPart->add_face(v[0], v[1], v[2])) - bNewPart = true; + if (!split->m_CurrentPart->add_face(v[0], v[1], v[2])) + bNewPart = true; if (b2sided) - { - v[0].N.invert(); v[1].N.invert(); v[2].N.invert(); - if (!split->m_CurrentPart->add_face(v[2], v[1], v[0])) - bNewPart = true; + { + v[0].N.invert(); + v[1].N.invert(); + v[2].N.invert(); + if (!split->m_CurrentPart->add_face(v[2], v[1], v[0])) + bNewPart = true; } } - if (bNewPart && (elapsed_faces>0)) - split->AppendPart( (elapsed_faces>0xffff) ? 0xffff : elapsed_faces, - (elapsed_faces>0xffff) ? 0xffff : elapsed_faces); + if (bNewPart&&(elapsed_faces>0)) + split->AppendPart((elapsed_faces>0xffff) ? 0xffff : elapsed_faces, + (elapsed_faces>0xffff) ? 0xffff : elapsed_faces); } - }while(elapsed_faces>0); + } while (elapsed_faces>0); } // mesh fin - MESH->UnloadVNormals (); - return bResult; + MESH->UnloadVNormals(); + return bResult; } -bool CExportObjectOGF::Prepare(bool gen_tb, CEditableMesh* mesh) +bool CExportObjectOGF::Prepare(bool gen_tb, CEditableMesh *mesh) { - if( (m_Source->MeshCount() == 0) ) return false; + if ((m_Source->MeshCount()==0)) + return false; - bool bResult = true; - if (mesh) - bResult = PrepareMESH(mesh); + bool bResult = true; + if (mesh) + bResult = PrepareMESH(mesh); else - { - for(EditMeshIt mesh_it=m_Source->FirstMesh();mesh_it!=m_Source->LastMesh();++mesh_it) - if (!PrepareMESH(*mesh_it)) - { - bResult = false; - break; - } + { + for (EditMeshIt mesh_it = m_Source->FirstMesh(); mesh_it!=m_Source->LastMesh(); ++mesh_it) + if (!PrepareMESH(*mesh_it)) + { + bResult = false; + break; + } } - if (!bResult) - return false; + if (!bResult) + return false; // calculate TB if (gen_tb) - { - for (SplitIt split_it=m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) + { + for (SplitIt split_it = m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) (*split_it)->CalculateTB(); -// Log ("Time B: ",T.GetElapsed_sec()); + // Log ("Time B: ",T.GetElapsed_sec()); } // fill per bone vertices - if (m_Source->m_objectFlags.is(CEditableObject::eoProgressive)) - { - for (SplitIt split_it=m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) + if (m_Source->m_objectFlags.is(CEditableObject::eoProgressive)) + { + for (SplitIt split_it = m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) (*split_it)->MakeProgressive(); } - // Compute bounding... - ComputeBounding (); -// Log ("Time C: ",T.GetElapsed_sec()); - return bResult; + // Compute bounding... + ComputeBounding(); + // Log ("Time C: ",T.GetElapsed_sec()); + return bResult; } -bool CExportObjectOGF::Export(IWriter& F, bool gen_tb, CEditableMesh* mesh) +bool CExportObjectOGF::Export(IWriter &F, bool gen_tb, CEditableMesh *mesh) { - if( !Prepare(gen_tb,mesh) ) - return false; + if (!Prepare(gen_tb, mesh)) + return false; - // Saving geometry... + // Saving geometry... if ((m_Splits.size()==1)&&(m_Splits[0]->m_Parts.size()==1)) - { - // export as single mesh - m_Splits[0]->SavePart(F,m_Splits[0]->m_Parts[0]); - }else - { - // export as hierrarhy mesh + { + // export as single mesh + m_Splits[0]->SavePart(F, m_Splits[0]->m_Parts[0]); + } + else + { + // export as hierrarhy mesh // Header - ogf_header H; - H.format_version= xrOGF_FormatVersion; - H.type = MT_HIERRARHY; - H.shader_id = 0; - H.bb.min = m_Box.min; - H.bb.max = m_Box.max; - m_Box.getsphere(H.bs.c,H.bs.r); - F.w_chunk (OGF_HEADER,&H,sizeof(H)); + ogf_header H; + H.format_version = xrOGF_FormatVersion; + H.type = MT_HIERRARHY; + H.shader_id = 0; + H.bb.min = m_Box.min; + H.bb.max = m_Box.max; + m_Box.getsphere(H.bs.c, H.bs.r); + F.w_chunk(OGF_HEADER, &H, sizeof(H)); // Desc - ogf_desc desc; + ogf_desc desc; m_Source->PrepareOGFDesc(desc); - F.open_chunk (OGF_S_DESC); - desc.Save (F); - F.close_chunk (); + F.open_chunk(OGF_S_DESC); + desc.Save(F); + F.close_chunk(); // OGF_CHILDREN - F.open_chunk (OGF_CHILDREN); - int chunk = 0; - for (SplitIt split_it=m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) - (*split_it)->Save(F,chunk); + F.open_chunk(OGF_CHILDREN); + int chunk = 0; + for (SplitIt split_it = m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) + (*split_it)->Save(F, chunk); - F.close_chunk (); + F.close_chunk(); } - SplitIt split_it; - F.open_chunk (OGF_COLLISION_VERTICES); - for (split_it=m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) - { - SSplit* split = *split_it; - COGFCPIt it = split->m_Parts.begin(); + SplitIt split_it; + F.open_chunk(OGF_COLLISION_VERTICES); + for (split_it = m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) + { + SSplit*split = *split_it; + COGFCPIt it = split->m_Parts.begin(); for (; it!=split->m_Parts.end(); ++it) { - CObjectOGFCollectorPacked* part = *it; + CObjectOGFCollectorPacked *part = *it; // vertices - OGFVertVec& VERTS = part->getV_Verts(); - OGFVertIt v_it = VERTS.begin(); - for(; v_it!=VERTS.end(); ++v_it) + OGFVertVec &VERTS = part->getV_Verts(); + OGFVertIt v_it = VERTS.begin(); + for (; v_it!=VERTS.end(); ++v_it) { - SOGFVert& V = *v_it; - F.w (&V.P, sizeof(V.P)); - } - }//parts - }//splits - F.close_chunk (); - - F.open_chunk (OGF_COLLISION_INDICES); - u32 v_offs = 0; - for (split_it=m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) - { - SSplit* split = *split_it; - COGFCPIt it = split->m_Parts.begin(); - - for(; it!=split->m_Parts.end(); ++it) - { - CObjectOGFCollectorPacked* part = *it; - OGFFaceVec& FACES = part->getV_Faces(); - OGFFaceIt f_it = FACES.begin(); - for(; f_it!=FACES.end(); ++f_it) - { - SOGFFace& Face = *f_it; - F.w_u32 (v_offs + Face.v[0]); - F.w_u32 (v_offs + Face.v[1]); - F.w_u32 (v_offs + Face.v[2]); - } - v_offs += part->getV_Verts().size(); - }//parts - }//splits - F.close_chunk (); + SOGFVert &V = *v_it; + F.w(&V.P, sizeof(V.P)); + } + }//parts + }//splits + F.close_chunk(); + + F.open_chunk(OGF_COLLISION_INDICES); + u32 v_offs = 0; + for (split_it = m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) + { + SSplit*split = *split_it; + COGFCPIt it = split->m_Parts.begin(); + + for (; it!=split->m_Parts.end(); ++it) + { + CObjectOGFCollectorPacked *part = *it; + OGFFaceVec &FACES = part->getV_Faces(); + OGFFaceIt f_it = FACES.begin(); + for (; f_it!=FACES.end(); ++f_it) + { + SOGFFace &Face = *f_it; + F.w_u32(v_offs+Face.v[0]); + F.w_u32(v_offs+Face.v[1]); + F.w_u32(v_offs+Face.v[2]); + } + v_offs += part->getV_Verts().size(); + }//parts + }//splits + F.close_chunk(); return true; } -bool CExportObjectOGF::ExportAsSimple(IWriter& F) +bool CExportObjectOGF::ExportAsSimple(IWriter &F) { - if( Prepare(true,NULL) ) + if (Prepare(true, NULL)) { // Saving geometry... if ((m_Splits.size()==1)&&(m_Splits[0]->m_Parts.size()==1)) - { + { // export as single mesh m_Splits[0]->SavePart(F, m_Splits[0]->m_Parts[0]); - return true; + return true; } } return false; } -bool CExportObjectOGF::ExportAsWavefrontOBJ(IWriter& F, LPCSTR fn) +bool CExportObjectOGF::ExportAsWavefrontOBJ(IWriter &F, LPCSTR fn) { - if (!Prepare(false,NULL)) - return false; + if (!Prepare(false, NULL)) + return false; - string_path tmp, tex_path, tex_name; - string_path name, ext; - _splitpath (fn, 0, 0, name, ext ); - strcat (name,ext); + string_path tmp, tex_path, tex_name; + string_path name, ext; + _splitpath(fn, 0, 0, name, ext); + strcat(name, ext); - xr_string fn_material = EFS.ChangeFileExt(fn,".mtl"); - IWriter* Fm = FS.w_open(fn_material.c_str()); + xr_string fn_material = EFS.ChangeFileExt(fn, ".mtl"); + IWriter *Fm = FS.w_open(fn_material.c_str()); // write material file - for (SplitIt split_it=m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) + for (SplitIt split_it = m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) { - _splitpath ((*split_it)->m_Surf->_Texture(), 0, tex_path, tex_name, 0 ); - - sprintf (tmp,"newmtl %s", tex_name); - Fm->w_string (tmp); - Fm->w_string ("Ka 0 0 0"); - Fm->w_string ("Kd 1 1 1"); - Fm->w_string ("Ks 0 0 0"); - - sprintf (tmp,"map_Kd %s\\\\%s\\%s%s\n", - "T:", - tex_path, - tex_name, - ".tga"); - Fm->w_string (tmp); + _splitpath((*split_it)->m_Surf->_Texture(), 0, tex_path, tex_name, 0); + + sprintf(tmp, "newmtl %s", tex_name); + Fm->w_string(tmp); + Fm->w_string("Ka 0 0 0"); + Fm->w_string("Kd 1 1 1"); + Fm->w_string("Ks 0 0 0"); + + sprintf(tmp, "map_Kd %s\\\\%s\\%s%s\n", + "T:", + tex_path, + tex_name, + ".tga"); + Fm->w_string(tmp); } - FS.w_close (Fm); + FS.w_close(Fm); - // writ comment - F.w_string ("# This file uses meters as units for non-parametric coordinates."); + // writ comment + F.w_string("# This file uses meters as units for non-parametric coordinates."); - _splitpath (fn, 0, 0, tex_name, 0 ); - sprintf (tmp,"mtllib %s.mtl", tex_name); - F.w_string (tmp); + _splitpath(fn, 0, 0, tex_name, 0); + sprintf(tmp, "mtllib %s.mtl", tex_name); + F.w_string(tmp); - u32 v_offs = 0; - for (split_it=m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) + u32 v_offs = 0; + for (split_it = m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) { - _splitpath ((*split_it)->m_Surf->_Texture(), 0, 0, tex_name, 0 ); - sprintf (tmp,"g %d",split_it-m_Splits.begin()); - F.w_string (tmp); - sprintf (tmp,"usemtl %s",tex_name); - F.w_string (tmp); - Fvector mV; - Fmatrix mZ; - mZ.mirrorZ (); - for (COGFCPIt it=(*split_it)->m_Parts.begin(); it!=(*split_it)->m_Parts.end(); ++it) + _splitpath((*split_it)->m_Surf->_Texture(), 0, 0, tex_name, 0); + sprintf(tmp, "g %d", split_it-m_Splits.begin()); + F.w_string(tmp); + sprintf(tmp, "usemtl %s", tex_name); + F.w_string(tmp); + Fvector mV; + Fmatrix mZ; + mZ.mirrorZ(); + for (COGFCPIt it = (*split_it)->m_Parts.begin(); it!=(*split_it)->m_Parts.end(); ++it) { - CObjectOGFCollectorPacked* part = *it; + CObjectOGFCollectorPacked *part = *it; // vertices - OGFVertVec& VERTS = part->getV_Verts(); - OGFVertIt v_it; - for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++) + OGFVertVec &VERTS = part->getV_Verts(); + OGFVertIt v_it; + for (v_it = VERTS.begin(); v_it!=VERTS.end(); v_it++) { - mZ.transform_tiny (mV,v_it->P); - sprintf (tmp,"v %f %f %f",mV.x,mV.y,mV.z); - F.w_string (tmp); + mZ.transform_tiny(mV, v_it->P); + sprintf(tmp, "v %f %f %f", mV.x, mV.y, mV.z); + F.w_string(tmp); } - for (v_it=VERTS.begin(); v_it!=VERTS.end(); ++v_it) + for (v_it = VERTS.begin(); v_it!=VERTS.end(); ++v_it) { - sprintf (tmp,"vt %f %f",v_it->UV.x,_abs(1.f-v_it->UV.y)); - F.w_string (tmp); + sprintf(tmp, "vt %f %f", v_it->UV.x, _abs(1.f-v_it->UV.y)); + F.w_string(tmp); } - for (v_it=VERTS.begin(); v_it!=VERTS.end(); ++v_it) + for (v_it = VERTS.begin(); v_it!=VERTS.end(); ++v_it) { - mZ.transform_dir (mV,v_it->N); - sprintf (tmp,"vn %f %f %f",mV.x,mV.y,mV.z); - F.w_string (tmp); + mZ.transform_dir(mV, v_it->N); + sprintf(tmp, "vn %f %f %f", mV.x, mV.y, mV.z); + F.w_string(tmp); } - for (v_it=VERTS.begin(); v_it!=VERTS.end(); ++v_it) + for (v_it = VERTS.begin(); v_it!=VERTS.end(); ++v_it) { - mZ.transform_dir (mV,v_it->T); - sprintf (tmp,"vg %f %f %f",mV.x,mV.y,mV.z); - F.w_string (tmp); + mZ.transform_dir(mV, v_it->T); + sprintf(tmp, "vg %f %f %f", mV.x, mV.y, mV.z); + F.w_string(tmp); } - for (v_it=VERTS.begin(); v_it!=VERTS.end(); ++v_it) + for (v_it = VERTS.begin(); v_it!=VERTS.end(); ++v_it) { - mZ.transform_dir (mV,v_it->B); - sprintf (tmp,"vb %f %f %f",mV.x,mV.y,mV.z); - F.w_string (tmp); + mZ.transform_dir(mV, v_it->B); + sprintf(tmp, "vb %f %f %f", mV.x, mV.y, mV.z); + F.w_string(tmp); } // faces - OGFFaceVec& FACES = part->getV_Faces(); - OGFFaceIt f_it; - for (f_it=FACES.begin(); f_it!=FACES.end(); ++f_it) + OGFFaceVec &FACES = part->getV_Faces(); + OGFFaceIt f_it; + for (f_it = FACES.begin(); f_it!=FACES.end(); ++f_it) { - sprintf (tmp,"f %d/%d/%d %d/%d/%d %d/%d/%d",v_offs+f_it->v[2]+1,v_offs+f_it->v[2]+1,v_offs+f_it->v[2]+1, - v_offs+f_it->v[1]+1,v_offs+f_it->v[1]+1,v_offs+f_it->v[1]+1, - v_offs+f_it->v[0]+1,v_offs+f_it->v[0]+1,v_offs+f_it->v[0]+1); - F.w_string (tmp); + sprintf(tmp, "f %d/%d/%d %d/%d/%d %d/%d/%d", v_offs+f_it->v[2]+1, v_offs+f_it->v[2]+1, v_offs+f_it->v[2]+1, + v_offs+f_it->v[1]+1, v_offs+f_it->v[1]+1, v_offs+f_it->v[1]+1, + v_offs+f_it->v[0]+1, v_offs+f_it->v[0]+1, v_offs+f_it->v[0]+1); + F.w_string(tmp); } - v_offs += VERTS.size(); + v_offs += VERTS.size(); } } - return true; + return true; } -bool CEditableObject::PrepareOGF(IWriter& F, u8 infl, bool gen_tb, CEditableMesh* mesh) +bool CEditableObject::PrepareOGF(IWriter &F, u8 infl, bool gen_tb, CEditableMesh *mesh) { - return IsSkeleton()?PrepareSkeletonOGF(F,infl):PrepareRigidOGF(F,gen_tb,mesh); + return IsSkeleton() ? PrepareSkeletonOGF(F, infl) : PrepareRigidOGF(F, gen_tb, mesh); } #include "ExportSkeleton.h" -bool CEditableObject::PrepareSkeletonOGF(IWriter& F, u8 infl) +bool CEditableObject::PrepareSkeletonOGF(IWriter &F, u8 infl) { CExportSkeleton E(this); float prev = g_EpsSkelPositionDelta; - if(m_objectFlags.test(eoHQExport)) + if (m_objectFlags.test(eoHQExport)) g_EpsSkelPositionDelta = EPS; - bool res = E.Export(F,infl); + bool res = E.Export(F, infl); g_EpsSkelPositionDelta = prev; return res; } -bool CEditableObject::PrepareRigidOGF(IWriter& F, bool gen_tb, CEditableMesh* mesh) +bool CEditableObject::PrepareRigidOGF(IWriter &F, bool gen_tb, CEditableMesh *mesh) { CExportObjectOGF E(this); float prev = g_EpsSkelPositionDelta; - if(m_objectFlags.test(eoHQExport)) + if (m_objectFlags.test(eoHQExport)) g_EpsSkelPositionDelta = EPS; g_EpsSkelPositionDelta = prev; - bool res = E.Export(F,gen_tb,mesh); + bool res = E.Export(F, gen_tb, mesh); return res; } -bool CEditableObject::PrepareSVGeometry(IWriter& F, u8 infl) +bool CEditableObject::PrepareSVGeometry(IWriter &F, u8 infl) { CExportSkeleton E(this); float prev = g_EpsSkelPositionDelta; - if(m_objectFlags.test(eoHQExport)) + if (m_objectFlags.test(eoHQExport)) g_EpsSkelPositionDelta = EPS; bool res = E.ExportGeometry(F, infl); @@ -664,20 +682,21 @@ bool CEditableObject::PrepareSVGeometry(IWriter& F, u8 infl) } -bool CEditableObject::PrepareSVKeys(IWriter& F) +bool CEditableObject::PrepareSVKeys(IWriter &F) { CExportSkeleton E(this); return E.ExportMotionKeys(F); } -bool CEditableObject::PrepareSVDefs(IWriter& F) +bool CEditableObject::PrepareSVDefs(IWriter &F) { CExportSkeleton E(this); return E.ExportMotionDefs(F); } -bool CEditableObject::PrepareOMF(IWriter& F) +bool CEditableObject::PrepareOMF(IWriter &F) { CExportSkeleton E(this); return E.ExportMotions(F); } + diff --git a/src/editors/ECore/Editor/ExportObjectOGF.h b/src/editors/ECore/Editor/ExportObjectOGF.h index 90a3d41b35b..de528f163c4 100644 --- a/src/editors/ECore/Editor/ExportObjectOGF.h +++ b/src/editors/ECore/Editor/ExportObjectOGF.h @@ -5,7 +5,7 @@ #include "utils/ETools/PropSlimTools.h" //--------------------------------------------------------------------------- -const int clpOGFMX = 48, clpOGFMY=16, clpOGFMZ=48; +const int clpOGFMX = 48, clpOGFMY = 16, clpOGFMZ = 48; //--------------------------------------------------------------------------- // refs class CEditableObject; @@ -13,165 +13,210 @@ class CEditableMesh; class CSurface; class CInifile; -struct SOGFVert{ - Fvector P; - Fvector N; - Fvector2 UV; - Fvector T; - Fvector B; - SOGFVert() - { - P.set (0,0,0); - N.set (0,1,0); - UV.set (0.f,0.f); - T.set (0,0,0); - B.set (0,0,0); - } - void set(Fvector const& p, Fvector const& n, Fvector2 const& uv) - { - P.set (p); - N.set (n); - UV.set (uv); - } - BOOL similar_pos(SOGFVert& V) - { - return P.similar(V.P,EPS_L); +struct SOGFVert +{ + Fvector P; + Fvector N; + Fvector2 UV; + Fvector T; + Fvector B; + + SOGFVert() + { + P.set(0, 0, 0); + N.set(0, 1, 0); + UV.set(0.f, 0.f); + T.set(0, 0, 0); + B.set(0, 0, 0); + } + + void set(Fvector const &p, Fvector const &n, Fvector2 const &uv) + { + P.set(p); + N.set(n); + UV.set(uv); + } + + BOOL similar_pos(SOGFVert &V) + { + return P.similar(V.P, EPS_L); + } + + BOOL similar(SOGFVert &V) + { + if (!P.similar(V.P, EPS_L)) + return FALSE; + if (!UV.similar(V.UV, EPS_S)) + return FALSE; + if (!N.similar(V.N, EPS_L)) + return FALSE; + return TRUE; } - BOOL similar(SOGFVert& V) - { - if (!P.similar (V.P,EPS_L)) return FALSE; - if (!UV.similar (V.UV,EPS_S)) return FALSE; - if (!N.similar (V.N,EPS_L)) return FALSE; - return TRUE; - } }; -struct SOGFFace{ - WORD v[3]; +struct SOGFFace +{ + WORD v[3]; }; -DEFINE_VECTOR(SOGFVert,OGFVertVec,OGFVertIt); -DEFINE_VECTOR(SOGFFace,OGFFaceVec,OGFFaceIt); +DEFINE_VECTOR(SOGFVert, OGFVertVec, OGFVertIt); +DEFINE_VECTOR(SOGFFace, OGFFaceVec, OGFFaceIt); class CObjectOGFCollectorPacked { public: -// Fobb m_OBB; - Fbox m_Box; - - OGFVertVec m_Verts; - OGFFaceVec m_Faces; + // Fobb m_OBB; + Fbox m_Box; + + OGFVertVec m_Verts; + OGFFaceVec m_Faces; // Progressive - ArbitraryList m_SWR;// The records of the collapses. + ArbitraryList m_SWR;// The records of the collapses. - Fvector m_VMmin, m_VMscale; - U32Vec m_VM[clpOGFMX+1][clpOGFMY+1][clpOGFMZ+1]; - Fvector m_VMeps; + Fvector m_VMmin, m_VMscale; + U32Vec m_VM[clpOGFMX+1][clpOGFMY+1][clpOGFMZ+1]; + Fvector m_VMeps; - u16 VPack (SOGFVert& V); - void ComputeBounding (); - void OptimizeTextureCoordinates(); + u16 VPack(SOGFVert &V); + void ComputeBounding(); + void OptimizeTextureCoordinates(); public: - CObjectOGFCollectorPacked (const Fbox &bb, int apx_vertices, int apx_faces); - void CalculateTB (); - void MakeProgressive (); - IC bool check (SOGFFace& F) - { - if ((F.v[0]==F.v[1]) || (F.v[0]==F.v[2]) || (F.v[1]==F.v[2])) - return false; - else - return true; + CObjectOGFCollectorPacked(const Fbox &bb, int apx_vertices, int apx_faces); + void CalculateTB(); + void MakeProgressive(); + IC + + bool check(SOGFFace &F) + { + if ((F.v[0]==F.v[1])||(F.v[0]==F.v[2])||(F.v[1]==F.v[2])) + return false; + else + return true; } - IC bool add_face (SOGFVert& v0, SOGFVert& v1, SOGFVert& v2) - { - if (v0.P.similar(v1.P,EPS) || v0.P.similar(v2.P,EPS) || v1.P.similar(v2.P,EPS)) - { - ELog.Msg(mtError,"Degenerate face found. Removed."); + + IC + + bool add_face(SOGFVert &v0, SOGFVert &v1, SOGFVert &v2) + { + if (v0.P.similar(v1.P, EPS)||v0.P.similar(v2.P, EPS)||v1.P.similar(v2.P, EPS)) + { + ELog.Msg(mtError, "Degenerate face found. Removed."); return true; } SOGFFace F; u16 v; - v = VPack(v0); if (0xffff==v) return false; F.v[0] = v; - v = VPack(v1); if (0xffff==v) return false; F.v[1] = v; - v = VPack(v2); if (0xffff==v) return false; F.v[2] = v; - - if (check(F)) - m_Faces.push_back(F); + v = VPack(v0); + if (0xffff==v) + return false; + F.v[0] = v; + v = VPack(v1); + if (0xffff==v) + return false; + F.v[1] = v; + v = VPack(v2); + if (0xffff==v) + return false; + F.v[2] = v; + + if (check(F)) + m_Faces.push_back(F); else - { - ELog.Msg(mtError,"Duplicate(degenerate) face found. Removed."); + { + ELog.Msg(mtError, "Duplicate(degenerate) face found. Removed."); return true; } return true; } - IC OGFVertVec& getV_Verts () {return m_Verts;} - IC OGFFaceVec& getV_Faces () {return m_Faces;} - IC SOGFVert* getVert () {return &m_Verts.front();} - IC u32 getVS () {return m_Verts.size();} - IC u32 getTS () {return m_Faces.size();} + + IC OGFVertVec&getV_Verts() + { + return m_Verts; + } + + IC OGFFaceVec&getV_Faces() + { + return m_Faces; + } + + IC SOGFVert*getVert() + { + return &m_Verts.front(); + } + + IC u32 getVS() + { + return m_Verts.size(); + } + + IC u32 getTS() + { + return m_Faces.size(); + } }; + //---------------------------------------------------- -DEFINE_VECTOR(CObjectOGFCollectorPacked*,COGFCPVec,COGFCPIt) +DEFINE_VECTOR(CObjectOGFCollectorPacked *, COGFCPVec, COGFCPIt) class ECORE_API CExportObjectOGF { struct SSplit { - Fbox apx_box; - - COGFCPVec m_Parts; - CObjectOGFCollectorPacked* m_CurrentPart; - - Fbox m_Box; - CSurface* m_Surf; + Fbox apx_box; + + COGFCPVec m_Parts; + CObjectOGFCollectorPacked*m_CurrentPart; + + Fbox m_Box; + CSurface*m_Surf; // Progressive - void AppendPart (int apx_vertices, int apx_faces); - void SavePart (IWriter& F, CObjectOGFCollectorPacked* part); - void Save (IWriter& F, int& chunk_id); + void AppendPart(int apx_vertices, int apx_faces); + void SavePart(IWriter&F, CObjectOGFCollectorPacked*part); + void Save(IWriter&F, int& chunk_id); - void CalculateTB () + void CalculateTB() { - for (COGFCPIt it=m_Parts.begin(); it!=m_Parts.end(); it++) - (*it)->CalculateTB (); + for (COGFCPIt it = m_Parts.begin(); it!=m_Parts.end(); it++) + (*it)->CalculateTB(); } - void MakeProgressive (); - SSplit (CSurface* surf, const Fbox& bb); - ~SSplit (); - void ComputeBounding () + void MakeProgressive(); + SSplit(CSurface*surf, const Fbox&bb); + ~SSplit(); + void ComputeBounding() { m_Box.invalidate(); - for (COGFCPIt it=m_Parts.begin(); it!=m_Parts.end(); it++){ - CObjectOGFCollectorPacked* part = *it; - part->ComputeBounding (); - m_Box.merge (part->m_Box); + for (COGFCPIt it = m_Parts.begin(); it!=m_Parts.end(); it++){ + CObjectOGFCollectorPacked*part = *it; + part->ComputeBounding(); + m_Box.merge(part->m_Box); } } }; - DEFINE_VECTOR (SSplit*,SplitVec,SplitIt); - SplitVec m_Splits; - CEditableObject* m_Source; - Fbox m_Box; -//---------------------------------------------------- -// void ComputeOBB (Fobb &B, FvectorVec& V); - SSplit* FindSplit (CSurface* surf); - void ComputeBounding () + DEFINE_VECTOR(SSplit*, SplitVec, SplitIt); + SplitVec m_Splits; + CEditableObject*m_Source; + Fbox m_Box; + //---------------------------------------------------- + // void ComputeOBB (Fobb &B, FvectorVec& V); + SSplit*FindSplit(CSurface*surf); + void ComputeBounding() { m_Box.invalidate(); - for (SplitIt it=m_Splits.begin(); it!=m_Splits.end(); it++){ - (*it)->ComputeBounding (); - m_Box.merge ((*it)->m_Box); + for (SplitIt it = m_Splits.begin(); it!=m_Splits.end(); it++){ + (*it)->ComputeBounding(); + m_Box.merge((*it)->m_Box); } } - bool PrepareMESH (CEditableMesh* mesh); - bool Prepare (bool gen_tb, CEditableMesh* mesh); -public: - CExportObjectOGF (CEditableObject* object); - ~CExportObjectOGF (); - bool Export (IWriter& F, bool gen_tb=true, CEditableMesh* mesh=NULL); - bool ExportAsSimple (IWriter& F); - bool ExportAsWavefrontOBJ(IWriter& F, LPCSTR fn); + bool PrepareMESH(CEditableMesh*mesh); + bool Prepare(bool gen_tb, CEditableMesh*mesh); + public: + CExportObjectOGF(CEditableObject*object); + ~CExportObjectOGF(); + bool Export(IWriter&F, bool gen_tb = true, CEditableMesh*mesh = NULL); + bool ExportAsSimple(IWriter&F); + bool ExportAsWavefrontOBJ(IWriter&F, LPCSTR fn); }; #endif + diff --git a/src/editors/ECore/Editor/ExportObjectOGFCalculateTB.cpp b/src/editors/ECore/Editor/ExportObjectOGFCalculateTB.cpp index af2b43a3469..d8a5233a529 100644 --- a/src/editors/ECore/Editor/ExportObjectOGFCalculateTB.cpp +++ b/src/editors/ECore/Editor/ExportObjectOGFCalculateTB.cpp @@ -2,10 +2,10 @@ #pragma hdrstop #include "ExportObjectOGF.h" -#include "common/nvMender2003/nvmeshmender.h" -#include "common/NvMender2003/nvMeshMender.h" -#include "common/NvMender2003/mender_input_output.h" -#include "common/NvMender2003/remove_isolated_verts.h" +#include "Common/NvMender2003/NVMeshMender.h" +#include "Common/NvMender2003/NVMeshMender.h" +#include "Common/NvMender2003/mender_input_output.h" +#include "Common/NvMender2003/remove_isolated_verts.h" IC void set_vertex( MeshMender::Vertex &out_vertex, const SOGFVert& in_vertex ) { diff --git a/src/editors/ECore/Editor/ExportSkeleton.cpp b/src/editors/ECore/Editor/ExportSkeleton.cpp index c9494c08cc4..0baba0d5219 100644 --- a/src/editors/ECore/Editor/ExportSkeleton.cpp +++ b/src/editors/ECore/Editor/ExportSkeleton.cpp @@ -14,546 +14,584 @@ #include "MgcCont3DMinBox.h" #ifdef _EDITOR #include "ui_main.h" -#include "ui_toolscustom.h" +#include "UI_ToolsCustom.h" #endif ECORE_API BOOL g_force16BitTransformQuant = FALSE; -ECORE_API float g_EpsSkelPositionDelta = EPS_L; +ECORE_API +float g_EpsSkelPositionDelta = EPS_L; -u16 CSkeletonCollectorPacked::VPack(SSkelVert& V) +u16 CSkeletonCollectorPacked::VPack(SSkelVert &V) { - u32 P = 0xffffffff; + u32 P = 0xffffffff; - u32 ix,iy,iz; + u32 ix, iy, iz; ix = iFloor(float(V.offs.x-m_VMmin.x)/m_VMscale.x*clpSMX); iy = iFloor(float(V.offs.y-m_VMmin.y)/m_VMscale.y*clpSMY); iz = iFloor(float(V.offs.z-m_VMmin.z)/m_VMscale.z*clpSMZ); - R_ASSERT(ix<=clpSMX && iy<=clpSMY && iz<=clpSMZ); + R_ASSERT(ix<=clpSMX&&iy<=clpSMY&&iz<=clpSMZ); - int similar_pos=-1; + int similar_pos = -1; { - U32Vec& vl=m_VM[ix][iy][iz]; - for(U32It it=vl.begin();it!=vl.end(); it++){ - SSkelVert& src=m_Verts[*it]; - if(src.similar_pos(V)){ - if(src.similar(V)){ + U32Vec &vl = m_VM[ix][iy][iz]; + for (U32It it = vl.begin(); it!=vl.end(); it++) + { + SSkelVert&src = m_Verts[*it]; + if (src.similar_pos(V)) + { + if (src.similar(V)) + { P = *it; break; - } - similar_pos=*it; + } + similar_pos = *it; } } } if (0xffffffff==P) { - if (similar_pos>=0) V.offs.set(m_Verts[similar_pos].offs); + if (similar_pos>=0) + V.offs.set(m_Verts[similar_pos].offs); P = m_Verts.size(); m_Verts.push_back(V); m_VM[ix][iy][iz].push_back(P); - u32 ixE,iyE,izE; + u32 ixE, iyE, izE; ixE = iFloor(float(V.offs.x+m_VMeps.x-m_VMmin.x)/m_VMscale.x*clpSMX); iyE = iFloor(float(V.offs.y+m_VMeps.y-m_VMmin.y)/m_VMscale.y*clpSMY); izE = iFloor(float(V.offs.z+m_VMeps.z-m_VMmin.z)/m_VMscale.z*clpSMZ); - R_ASSERT(ixE<=clpSMX && iyE<=clpSMY && izE<=clpSMZ); - - if (ixE!=ix) m_VM[ixE][iy][iz].push_back (P); - if (iyE!=iy) m_VM[ix][iyE][iz].push_back (P); - if (izE!=iz) m_VM[ix][iy][izE].push_back (P); - if ((ixE!=ix)&&(iyE!=iy)) m_VM[ixE][iyE][iz].push_back(P); - if ((ixE!=ix)&&(izE!=iz)) m_VM[ixE][iy][izE].push_back(P); - if ((iyE!=iy)&&(izE!=iz)) m_VM[ix][iyE][izE].push_back(P); - if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) m_VM[ixE][iyE][izE].push_back(P); + R_ASSERT(ixE<=clpSMX&&iyE<=clpSMY&&izE<=clpSMZ); + + if (ixE!=ix) + m_VM[ixE][iy][iz].push_back(P); + if (iyE!=iy) + m_VM[ix][iyE][iz].push_back(P); + if (izE!=iz) + m_VM[ix][iy][izE].push_back(P); + if ((ixE!=ix)&&(iyE!=iy)) + m_VM[ixE][iyE][iz].push_back(P); + if ((ixE!=ix)&&(izE!=iz)) + m_VM[ixE][iy][izE].push_back(P); + if ((iyE!=iy)&&(izE!=iz)) + m_VM[ix][iyE][izE].push_back(P); + if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) + m_VM[ixE][iyE][izE].push_back(P); } - VERIFY (Pm_ShaderName; - m_Texture = surf->m_Texture; - m_PartID = part; + //. m_b2Link = FALSE; + m_SkeletonLinkType = 1; + m_Shader = surf->m_ShaderName; + m_Texture = surf->m_Texture; + m_PartID = part; } -//---------------------------------------------------- - +//---------------------------------------------------- class VertexCache { - public: - VertexCache (int size); - VertexCache (); - ~VertexCache (); + VertexCache(int size); + VertexCache(); + ~VertexCache(); - bool InCache (int entry); - int AddEntry(int entry); - void Clear (); + bool InCache(int entry); + int AddEntry(int entry); + void Clear(); - void Copy (VertexCache* inVcache); - int At (int index); - void Set (int index, int value); + void Copy(VertexCache *inVcache); + int At(int index); + void Set(int index, int value); private: - xr_vector entries; + xr_vector entries; }; -IC bool VertexCache::InCache(int entry) +IC + +bool VertexCache::InCache(int entry) { - bool returnVal = false; - - for(u32 i = 0; i < entries.size(); i++) - { - if(entries[i] == entry) - { - returnVal = true; - break; - } - } - - return returnVal; + bool returnVal = false; + + for (u32 i = 0; i= 0; i--) - { - entries[i + 1] = entries[i]; - } + //push everything right one + for (int i = (u32)entries.size()-2; i>=0; i--) + { + entries[i+1] = entries[i]; + } - entries[0] = entry; + entries[0] = entry; - return removed; + return removed; } VertexCache::VertexCache() { - VertexCache(24); + VertexCache(24); } VertexCache::VertexCache(int size) { - entries.assign (size,-1); + entries.assign(size, -1); } VertexCache::~VertexCache() { - entries.clear (); + entries.clear(); } -int VertexCache::At (int index) +int VertexCache::At(int index) { - return entries[index]; + return entries[index]; } void VertexCache::Set(int index, int value) { - entries[index] = value; + entries[index] = value; } void VertexCache::Clear() { - for(u32 i = 0; i < entries.size(); i++) - entries[i] = -1; + for (u32 i = 0; iSet(i, entries[i]); - } + for (u32 i = 0; iSet(i, entries[i]); + } } -int xrSimulate (u16* indices, u32 i_cnt, int iCacheSize ) +int xrSimulate(u16 *indices, u32 i_cnt, int iCacheSize) { - VertexCache C(iCacheSize); - - int count=0; - for (u32 i=0; i= pV.bones.size() ); - for(i=0; i=pV.bones.size()); + for (i = 0; iw_string (tmp.c_str()); - } - // face - for (SkelFaceIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++){ - SSkelFace& pF = *f_it; - AnsiString tmp; - tmp.sprintf ("f %d %d %d",pF.v[0]+1,pF.v[2]+1,pF.v[1]+1); - W->w_string (tmp.c_str()); - } - // normals - W->w_string ("bind n vertex"); - for (v_it=m_Verts.begin(); v_it!=m_Verts.end(); v_it++){ - SSkelVert& pV = *v_it; - AnsiString tmp; - tmp.sprintf ("n %f %f %f",pV.N.x,pV.N.y,-pV.N.z); - W->w_string (tmp.c_str()); + // SMF + /* + if (0){ + static u32 chunk_id = 0; chunk_id++; + AnsiString r=AnsiString("x:\\import\\test")+chunk_id+".smf"; + IWriter* W = FS._w_open(r.c_str()); + for (SkelVertIt v_it=m_Verts.begin(); v_it!=m_Verts.end(); v_it++){ + SSkelVert& pV = *v_it; + // vertices + AnsiString tmp; + tmp.sprintf ("v %f %f %f",pV.O.x,pV.O.y,-pV.O.z); + W->w_string (tmp.c_str()); + } + // face + for (SkelFaceIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++){ + SSkelFace& pF = *f_it; + AnsiString tmp; + tmp.sprintf ("f %d %d %d",pF.v[0]+1,pF.v[2]+1,pF.v[1]+1); + W->w_string (tmp.c_str()); + } + // normals + W->w_string ("bind n vertex"); + for (v_it=m_Verts.begin(); v_it!=m_Verts.end(); v_it++){ + SSkelVert& pV = *v_it; + AnsiString tmp; + tmp.sprintf ("n %f %f %f",pV.N.x,pV.N.y,-pV.N.z); + W->w_string (tmp.c_str()); + } + FS.w_close (W); } - FS.w_close (W); - } -*/ + */ } - void CExportSkeleton::SSplit::MakeProgressive() { - VIPM_Init (); - for (SkelVertIt vert_it=m_Verts.begin(); vert_it!=m_Verts.end(); vert_it++) - VIPM_AppendVertex(vert_it->offs,vert_it->uv); - for (SkelFaceIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++) - VIPM_AppendFace(f_it->v[0],f_it->v[1],f_it->v[2]); + VIPM_Init(); + for (SkelVertIt vert_it = m_Verts.begin(); vert_it!=m_Verts.end(); vert_it++) + VIPM_AppendVertex(vert_it->offs, vert_it->uv); + for (SkelFaceIt f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++) + VIPM_AppendFace(f_it->v[0], f_it->v[1], f_it->v[2]); - VIPM_Result* R = VIPM_Convert(u32(-1),1.f,1); + VIPM_Result *R = VIPM_Convert(u32(-1), 1.f, 1); - if (R){ + if (R) + { // Permute vertices SkelVertVec temp_list = m_Verts; - for(u32 i=0; ipermute_verts[i]]=temp_list[i]; - + for (u32 i = 0; ipermute_verts[i]] = temp_list[i]; + // Fill indices - m_Faces.resize (R->indices.size()/3); - for (u32 f_idx=0; f_idxindices[f_idx*3+0]; - F.v[1] = R->indices[f_idx*3+1]; - F.v[2] = R->indices[f_idx*3+2]; + m_Faces.resize(R->indices.size()/3); + for (u32 f_idx = 0; f_idxindices[f_idx*3+0]; + F.v[1] = R->indices[f_idx*3+1]; + F.v[2] = R->indices[f_idx*3+2]; } // Fill SWR - m_SWR.resize (R->swr_records.size()); - for (u32 swr_idx=0; swr_idx!=m_SWR.size(); swr_idx++) - m_SWR[swr_idx] = R->swr_records[swr_idx]; - }else{ - Log("!..Can't make progressive."); + m_SWR.resize(R->swr_records.size()); + for (u32 swr_idx = 0; swr_idx!=m_SWR.size(); swr_idx++) + m_SWR[swr_idx] = R->swr_records[swr_idx]; } - + else + { + Log("!..Can't make progressive."); + } + // cleanup - VIPM_Destroy (); + VIPM_Destroy(); } void CExportSkeleton::SSplit::MakeStripify() { -// int ccc = xrSimulate ((u16*)&m_Faces.front(),m_Faces.size()*3,24); -// Log("SRC:",ccc); - // alternative stripification - faces + // int ccc = xrSimulate ((u16*)&m_Faces.front(),m_Faces.size()*3,24); + // Log("SRC:",ccc); + // alternative stripification - faces { - DWORD* remap = xr_alloc (m_Faces.size()); - HRESULT rhr = D3DXOptimizeFaces (&m_Faces.front(),m_Faces.size(),m_Verts.size(),FALSE,remap); - R_CHK (rhr); - SkelFaceVec _source = m_Faces; - for (u32 it=0; it<_source.size(); it++) + DWORD *remap = xr_alloc(m_Faces.size()); + HRESULT rhr = D3DXOptimizeFaces(&m_Faces.front(), m_Faces.size(), m_Verts.size(), FALSE, remap); + R_CHK(rhr); + SkelFaceVec _source = m_Faces; + for (u32 it = 0; it<_source.size(); it++) m_Faces[it] = _source[remap[it]]; - xr_free (remap); + xr_free(remap); -// int ccc = xrSimulate ((u16*)&m_Faces.front(),m_Faces.size()*3,24); -// Log("X:",ccc); + // int ccc = xrSimulate ((u16*)&m_Faces.front(),m_Faces.size()*3,24); + // Log("X:",ccc); } // alternative stripification - vertices { - DWORD* remap = xr_alloc (m_Verts.size()); - HRESULT rhr = D3DXOptimizeVertices (&m_Faces.front(),m_Faces.size(),m_Verts.size(),FALSE,remap); - R_CHK (rhr); - SkelVertVec _source = m_Verts; - - for(u32 vit=0; vit<_source.size(); vit++) - m_Verts[remap[vit]] = _source[vit]; - - for(u32 fit=0; fit<(u32)m_Faces.size(); ++fit) - for (u32 j=0; j<3; j++) - m_Faces[fit].v[j]= remap[m_Faces[fit].v[j]]; - - xr_free (remap); - -// int ccc = xrSimulate ((u16*)&m_Faces.front(),m_Faces.size()*3,24); -// Log("Y:",ccc); + DWORD *remap = xr_alloc(m_Verts.size()); + HRESULT rhr = D3DXOptimizeVertices(&m_Faces.front(), m_Faces.size(), m_Verts.size(), FALSE, remap); + R_CHK(rhr); + SkelVertVec _source = m_Verts; + + for (u32 vit = 0; vit<_source.size(); vit++) + m_Verts[remap[vit]] = _source[vit]; + + for (u32 fit = 0; fit<(u32)m_Faces.size(); ++fit) + for (u32 j = 0; j<3; j++) + m_Faces[fit].v[j] = remap[m_Faces[fit].v[j]]; + + xr_free(remap); + + // int ccc = xrSimulate ((u16*)&m_Faces.front(),m_Faces.size()*3,24); + // Log("Y:",ccc); } } -CExportSkeleton::CExportSkeleton(CEditableObject* object) +CExportSkeleton::CExportSkeleton(CEditableObject *object) { - m_Source=object; + m_Source = object; } + //---------------------------------------------------- #include "editors/ECore/WildMagic/WmlMath.h" #include "editors/ECore/WildMagic/WmlContMinBox3.h" #include "editors/ECore/WildMagic/WmlContBox3.h" -extern BOOL RAPIDMinBox(Fobb& B, Fvector* vertices, u32 v_count); -void ComputeOBB_RAPID (Fobb &B, FvectorVec& V, u32 t_cnt) +extern BOOL RAPIDMinBox(Fobb &B, Fvector *vertices, u32 v_count); + +void ComputeOBB_RAPID(Fobb &B, FvectorVec &V, u32 t_cnt) { - VERIFY (t_cnt==(V.size()/3)); - if ((t_cnt<1)||(V.size()<3)) - { - B.invalidate(); - return; - } - RAPIDMinBox (B, &V.front(), V.size()); + VERIFY(t_cnt==(V.size()/3)); + if ((t_cnt<1)||(V.size()<3)) + { + B.invalidate(); + return; + } + RAPIDMinBox(B, &V.front(), V.size()); // Normalize rotation matrix (???? ???????? ContOrientedBox - ?????? ????? ???????) - B.m_rotate.i.crossproduct(B.m_rotate.j,B.m_rotate.k); - B.m_rotate.j.crossproduct(B.m_rotate.k,B.m_rotate.i); + B.m_rotate.i.crossproduct(B.m_rotate.j, B.m_rotate.k); + B.m_rotate.j.crossproduct(B.m_rotate.k, B.m_rotate.i); - VERIFY (_valid(B.m_rotate)&&_valid(B.m_translate)&&_valid(B.m_halfsize)); + VERIFY(_valid(B.m_rotate)&&_valid(B.m_translate)&&_valid(B.m_halfsize)); } -void ComputeOBB_WML (Fobb &B, FvectorVec& V) +void ComputeOBB_WML(Fobb &B, FvectorVec &V) { - if (V.size()<3) { B.invalidate(); return; } - float HV = flt_max; + if (V.size()<3) + { + B.invalidate(); + return; + } + float HV = flt_max; { - Wml::Box3 BOX; + Wml::Box3 BOX; Wml::MinBox3 mb(V.size(), (const Wml::Vector3*) &V.front(), BOX); - float hv = BOX.Extents()[0]*BOX.Extents()[1]*BOX.Extents()[2]; - if (hvm_Shader.equal(shader) && - it->m_Texture.equal(texture) && - (it->m_PartID==part_id) ) + for (SplitIt it = m_Splits.begin(); it!=m_Splits.end(); it++) + if (it->m_Shader.equal(shader)&& + it->m_Texture.equal(texture)&& + (it->m_PartID==part_id)) - return it-m_Splits.begin(); + return it-m_Splits.begin(); return -1; } -IC void BuildGroups(CBone* B, U16Vec& tgt, u16 id, u16& last_id) +IC + +void BuildGroups(CBone *B, U16Vec &tgt, u16 id, u16 &last_id) { - if (B->IK_data.ik_flags.is(SJointIKData::flBreakable)) id = ++last_id; - tgt[B->SelfID] = id; - for (BoneIt bone_it=B->children.begin(); bone_it!=B->children.end(); bone_it++) - BuildGroups (*bone_it,tgt,id,last_id); + if (B->IK_data.ik_flags.is(SJointIKData::flBreakable)) + id = ++last_id; + tgt[B->SelfID] = id; + for (BoneIt bone_it = B->children.begin(); bone_it!=B->children.end(); bone_it++) + BuildGroups(*bone_it, tgt, id, last_id); } bool CExportSkeleton::PrepareGeometry(u8 influence) { - if( m_Source->MeshCount() == 0 ) return false; + if (m_Source->MeshCount()==0) + return false; - if (m_Source->BoneCount()<1){ - ELog.Msg(mtError,"There are no bones in the object."); - return false; + if (m_Source->BoneCount()<1) + { + ELog.Msg(mtError, "There are no bones in the object."); + return false; } - if (m_Source->BoneCount()>64){ - ELog.Msg(mtError,"Object cannot handle more than 64 bones."); - return false; + if (m_Source->BoneCount()>64) + { + ELog.Msg(mtError, "Object cannot handle more than 64 bones."); + return false; } // mem active motion - CSMotion* active_motion=m_Source->ResetSAnimation(); + CSMotion *active_motion = m_Source->ResetSAnimation(); R_ASSERT(m_Source->IsDynamic()&&m_Source->IsSkeleton()); @@ -562,140 +600,148 @@ bool CExportSkeleton::PrepareGeometry(u8 influence) pb->Inc (); #endif - bool bBreakable = false; - U16Vec bone_brk_parts(m_Source->BoneCount()); - CBone* root = 0; - for (BoneIt bone_it=m_Source->FirstBone(); bone_it!=m_Source->LastBone(); bone_it++){ - CBone* B = *bone_it; - if (B->IK_data.ik_flags.is(SJointIKData::flBreakable)) bBreakable = true; - if (B->IsRoot()) root = B; + bool bBreakable = false; + U16Vec bone_brk_parts(m_Source->BoneCount()); + CBone *root = 0; + for (BoneIt bone_it = m_Source->FirstBone(); bone_it!=m_Source->LastBone(); bone_it++) + { + CBone *B = *bone_it; + if (B->IK_data.ik_flags.is(SJointIKData::flBreakable)) + bBreakable = true; + if (B->IsRoot()) + root = B; } - if (bBreakable){ - VERIFY (root); - u16 last_id = 0; - BuildGroups (root,bone_brk_parts,0,last_id); + if (bBreakable) + { + VERIFY(root); + u16 last_id = 0; + BuildGroups(root, bone_brk_parts, 0, last_id); } - for (U16It uit=bone_brk_parts.begin(); uit!=bone_brk_parts.end(); uit++){ - Msg ("Bone: %s - Part: %d",*m_Source->GetBone(uit-bone_brk_parts.begin())->Name(),*uit); + for (U16It uit = bone_brk_parts.begin(); uit!=bone_brk_parts.end(); uit++) + { + Msg("Bone: %s - Part: %d", *m_Source->GetBone(uit-bone_brk_parts.begin())->Name(), *uit); } - - bool bRes = true; + + bool bRes = true; #ifdef _EDITOR UI->SetStatus ("..Split meshes"); #endif - U16Vec tmp_bone_lst; + U16Vec tmp_bone_lst; - for(EditMeshIt mesh_it=m_Source->FirstMesh();mesh_it!=m_Source->LastMesh();mesh_it++) + for (EditMeshIt mesh_it = m_Source->FirstMesh(); mesh_it!=m_Source->LastMesh(); mesh_it++) { - if (!bRes) break; + if (!bRes) + break; - CEditableMesh* MESH = *mesh_it; + CEditableMesh*MESH = *mesh_it; // generate vertex offset - MESH->GenerateVNormals (0); - MESH->GenerateFNormals (); - MESH->GenerateSVertices (influence); + MESH->GenerateVNormals(0); + MESH->GenerateFNormals(); + MESH->GenerateSVertices(influence); #ifdef _EDITOR pb->Inc (); #endif - // fill faces - for (SurfFacesPairIt sp_it=MESH->m_SurfFaces.begin(); sp_it!=MESH->m_SurfFaces.end(); sp_it++) + // fill faces + for (SurfFacesPairIt sp_it = MESH->m_SurfFaces.begin(); sp_it!=MESH->m_SurfFaces.end(); sp_it++) { - if (!bRes) break; - IntVec& face_lst = sp_it->second; - CSurface* surf = sp_it->first; - u32 dwTexCnt = ((surf->_FVF()&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT); - R_ASSERT (dwTexCnt==1); - - for (IntIt f_it=face_lst.begin(); f_it!=face_lst.end(); f_it++) + if (!bRes) + break; + IntVec &face_lst = sp_it->second; + CSurface*surf = sp_it->first; + u32 dwTexCnt = ((surf->_FVF()&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT); + R_ASSERT(dwTexCnt==1); + + for (IntIt f_it = face_lst.begin(); f_it!=face_lst.end(); f_it++) { - if (!bRes) break; - int f_idx = *f_it; + if (!bRes) + break; + int f_idx = *f_it; { - SSkelVert v[3]; - tmp_bone_lst.clear_not_free (); - u32 link_type = _max(MESH->m_SVertices[f_idx*3+0].bones.size(),MESH->m_SVertices[f_idx*3+1].bones.size()); - link_type = _max(link_type,MESH->m_SVertices[f_idx*3+2].bones.size()); - VERIFY (link_type>0 && link_type<=(u32)influence); + SSkelVert v[3]; + tmp_bone_lst.clear_not_free(); + u32 link_type = _max(MESH->m_SVertices[f_idx*3+0].bones.size(), MESH->m_SVertices[f_idx*3+1].bones.size()); + link_type = _max(link_type, MESH->m_SVertices[f_idx*3+2].bones.size()); + VERIFY(link_type>0&&link_type<=(u32)influence); - for (int k=0; k<3; k++) + for (int k = 0; k<3; k++) { - st_SVert& sv = MESH->m_SVertices[f_idx*3+k]; - VERIFY (sv.bones.size()>0 && (u8)sv.bones.size()<=influence); + st_SVert&sv = MESH->m_SVertices[f_idx*3+k]; + VERIFY(sv.bones.size()>0&&(u8)sv.bones.size()<=influence); if (link_type==1) { - st_SVert::bone b[2]; - b[0].id = sv.bones[0].id; - b[1].id = sv.bones[0].id; - b[0].w = 1.f; - b[1].w = 0.f; - v[k].set (sv.offs,sv.norm,sv.uv,2,b); - tmp_bone_lst.push_back (sv.bones[0].id); - }else - if(link_type==2) + st_SVert::bone b[2]; + b[0].id = sv.bones[0].id; + b[1].id = sv.bones[0].id; + b[0].w = 1.f; + b[1].w = 0.f; + v[k].set(sv.offs, sv.norm, sv.uv, 2, b); + tmp_bone_lst.push_back(sv.bones[0].id); + } + else if (link_type==2) { { - v[k].set (sv.offs,sv.norm,sv.uv,(u8)sv.bones.size(),sv.bones.begin()); + v[k].set(sv.offs, sv.norm, sv.uv, (u8)sv.bones.size(), sv.bones.begin()); - for(u32 i=0; im_ShaderName,surf->m_Texture,bone_brk_part); + int mtl_idx = FindSplit(surf->m_ShaderName, surf->m_Texture, bone_brk_part); if (mtl_idx<0) { - m_Splits.push_back (SSplit(surf,m_Source->GetBox(),bone_brk_part)); - mtl_idx = m_Splits.size()-1; + m_Splits.push_back(SSplit(surf, m_Source->GetBox(), bone_brk_part)); + mtl_idx = m_Splits.size()-1; m_Splits[mtl_idx].m_SkeletonLinkType = 0; } - SSplit& cur_split = m_Splits[mtl_idx]; - cur_split.m_SkeletonLinkType = _max(link_type, cur_split.m_SkeletonLinkType); + SSplit&cur_split = m_Splits[mtl_idx]; + cur_split.m_SkeletonLinkType = _max(link_type, cur_split.m_SkeletonLinkType); - cur_split.m_UsedBones.insert (cur_split.m_UsedBones.end(),tmp_bone_lst.begin(),tmp_bone_lst.end()); + cur_split.m_UsedBones.insert(cur_split.m_UsedBones.end(), tmp_bone_lst.begin(), tmp_bone_lst.end()); // append face - cur_split.add_face (v[0], v[1], v[2]); + cur_split.add_face(v[0], v[1], v[2]); - if (surf->m_Flags.is(CSurface::sf2Sided)) + if (surf->m_Flags.is(CSurface::sf2Sided)) { - v[0].norm.invert (); - v[1].norm.invert (); - v[2].norm.invert (); - cur_split.add_face (v[0], v[2], v[1]); + v[0].norm.invert(); + v[1].norm.invert(); + v[2].norm.invert(); + cur_split.add_face(v[0], v[2], v[1]); } } } @@ -707,45 +753,47 @@ bool CExportSkeleton::PrepareGeometry(u8 influence) #ifdef _EDITOR pb->Inc (); #endif - } + } #ifdef _EDITOR UI->SetStatus ("..Calculate TB"); #endif - Msg ("Split statistic:"); - for (int k=0; k<(int)m_Splits.size(); k++) - { - // check splits - if (bRes) - { - if (!m_Splits[k].valid()) - { - ELog.Msg (mtError,"Empty split found (Shader/Texture: %s/%s). Removed.",*m_Splits[k].m_Shader,*m_Splits[k].m_Texture); - m_Splits.erase (m_Splits.begin()+k); k--; - }else - { - SSplit& split = m_Splits[k]; - std::sort (split.m_UsedBones.begin(),split.m_UsedBones.end()); - U16It ne = std::unique(split.m_UsedBones.begin(),split.m_UsedBones.end()); - split.m_UsedBones.erase (ne,split.m_UsedBones.end()); - Msg (" - Split %d: [Bones: %d, Links: %d, Faces: %d, Verts: %d, BrPart: %d, Shader/Texture: '%s'/'%s']",k,split.m_UsedBones.size(),split.m_SkeletonLinkType,split.getTS(),split.getVS(),split.m_PartID,*m_Splits[k].m_Shader,*m_Splits[k].m_Texture); - } - } - } - // calculate TB - for (SplitIt split_it=m_Splits.begin(); split_it!=m_Splits.end(); split_it++) + Msg("Split statistic:"); + for (int k = 0; k<(int)m_Splits.size(); k++) + { + // check splits + if (bRes) { - split_it->CalculateTB(); - + if (!m_Splits[k].valid()) + { + ELog.Msg(mtError, "Empty split found (Shader/Texture: %s/%s). Removed.", *m_Splits[k].m_Shader, *m_Splits[k].m_Texture); + m_Splits.erase(m_Splits.begin()+k); + k--; + } + else + { + SSplit&split = m_Splits[k]; + std::sort(split.m_UsedBones.begin(), split.m_UsedBones.end()); + U16It ne = std::unique(split.m_UsedBones.begin(), split.m_UsedBones.end()); + split.m_UsedBones.erase(ne, split.m_UsedBones.end()); + Msg(" - Split %d: [Bones: %d, Links: %d, Faces: %d, Verts: %d, BrPart: %d, Shader/Texture: '%s'/'%s']", k, split.m_UsedBones.size(), split.m_SkeletonLinkType, split.getTS(), split.getVS(), split.m_PartID, *m_Splits[k].m_Shader, *m_Splits[k].m_Texture); + } + } + } + // calculate TB + for (SplitIt split_it = m_Splits.begin(); split_it!=m_Splits.end(); split_it++) + { + split_it->CalculateTB(); + #ifdef _EDITOR pb->Inc (); #endif - } + } #ifdef _EDITOR pb->Inc (); #endif - // compute bounding - ComputeBounding (); + // compute bounding + ComputeBounding(); #ifdef _EDITOR UI->ProgressEnd(pb); @@ -756,80 +804,83 @@ bool CExportSkeleton::PrepareGeometry(u8 influence) return bRes; } -bool CExportSkeleton::ExportAsSimple(IWriter& F) +bool CExportSkeleton::ExportAsSimple(IWriter &F) { - if (!PrepareGeometry(2)) return false; + if (!PrepareGeometry(2)) + return false; { // Saving geometry... - if ( m_Splits.size()==1 ) + if (m_Splits.size()==1) { // export as single mesh m_Splits[0].Save(F); return true; - } else - return false; + } + else + return false; } - } #define _string_lod -bool CExportSkeleton::ExportGeometry(IWriter& F, u8 infl) +bool CExportSkeleton::ExportGeometry(IWriter &F, u8 infl) { - if (!PrepareGeometry(infl)) return false; + if (!PrepareGeometry(infl)) + return false; #ifdef _EDITOR SPBItem* pb = UI->ProgressStart(3+m_Splits.size(),"..Export skeleton geometry"); pb->Inc ("Make Progressive..."); #endif - // fill per bone vertices - BoneVec& bones = m_Source->Bones(); - xr_vector bone_points; - bone_points.resize (m_Source->BoneCount()); - - for (SplitIt split_it=m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) - { - if (m_Source->m_objectFlags.is(CEditableObject::eoProgressive)) - split_it->MakeProgressive(); + // fill per bone vertices + BoneVec &bones = m_Source->Bones(); + xr_vector bone_points; + bone_points.resize(m_Source->BoneCount()); + + for (SplitIt split_it = m_Splits.begin(); split_it!=m_Splits.end(); ++split_it) + { + if (m_Source->m_objectFlags.is(CEditableObject::eoProgressive)) + split_it->MakeProgressive(); else - split_it->MakeStripify(); + split_it->MakeStripify(); - SkelVertVec& lst = split_it->getV_Verts(); - for (SkelVertIt sv_it=lst.begin(); sv_it!=lst.end(); sv_it++) + SkelVertVec &lst = split_it->getV_Verts(); + for (SkelVertIt sv_it = lst.begin(); sv_it!=lst.end(); sv_it++) { - bone_points [sv_it->bones[0].id].push_back (sv_it->offs); - bones [sv_it->bones[0].id]->_RITransform().transform_tiny(bone_points[sv_it->bones[0].id].back()); + bone_points[sv_it->bones[0].id].push_back(sv_it->offs); + bones[sv_it->bones[0].id]->_RITransform().transform_tiny(bone_points[sv_it->bones[0].id].back()); } #ifdef _EDITOR pb->Inc (); #endif - } + } - // create OGF + // create OGF // Header - ogf_header H; - H.format_version= xrOGF_FormatVersion; - H.type = m_Source->IsAnimated()?MT_SKELETON_ANIM:MT_SKELETON_RIGID; - H.shader_id = 0; - H.bb.min = m_Box.min; - H.bb.max = m_Box.max; - m_Box.getsphere (H.bs.c,H.bs.r); - F.w_chunk (OGF_HEADER,&H,sizeof(H)); + ogf_header H; + H.format_version = xrOGF_FormatVersion; + H.type = m_Source->IsAnimated() ? MT_SKELETON_ANIM : MT_SKELETON_RIGID; + H.shader_id = 0; + H.bb.min = m_Box.min; + H.bb.max = m_Box.max; + m_Box.getsphere(H.bs.c, H.bs.r); + F.w_chunk(OGF_HEADER, &H, sizeof(H)); // Desc - ogf_desc desc; + ogf_desc desc; m_Source->PrepareOGFDesc(desc); - F.open_chunk (OGF_S_DESC); - desc.Save (F); - F.close_chunk (); + F.open_chunk(OGF_S_DESC); + desc.Save(F); + F.close_chunk(); // OGF_CHILDREN - F.open_chunk (OGF_CHILDREN); - int chield=0; - for (split_it=m_Splits.begin(); split_it!=m_Splits.end(); split_it++){ - F.open_chunk(chield++); + F.open_chunk(OGF_CHILDREN); + int chield = 0; + for (split_it = m_Splits.begin(); split_it!=m_Splits.end(); split_it++) + { + F.open_chunk(chield++); split_it->Save(F); - F.close_chunk(); + F.close_chunk(); } F.close_chunk(); @@ -840,38 +891,39 @@ bool CExportSkeleton::ExportGeometry(IWriter& F, u8 infl) // BoneNames F.open_chunk(OGF_S_BONE_NAMES); F.w_u32(m_Source->BoneCount()); - int bone_idx=0; - for (BoneIt bone_it=m_Source->FirstBone(); bone_it!=m_Source->LastBone(); bone_it++,bone_idx++){ - F.w_stringZ ((*bone_it)->Name()); - F.w_stringZ ((*bone_it)->Parent()?(*bone_it)->ParentName().c_str():""); - Fobb obb; - ComputeOBB_WML (obb,bone_points[bone_idx]); - F.w (&obb,sizeof(Fobb)); + int bone_idx = 0; + for (BoneIt bone_it = m_Source->FirstBone(); bone_it!=m_Source->LastBone(); bone_it++,bone_idx++) + { + F.w_stringZ((*bone_it)->Name()); + F.w_stringZ((*bone_it)->Parent() ? (*bone_it)->ParentName().c_str() : ""); + Fobb obb; + ComputeOBB_WML(obb, bone_points[bone_idx]); + F.w(&obb, sizeof(Fobb)); } F.close_chunk(); bool bRes = true; - + F.open_chunk(OGF_S_IKDATA); - for (bone_it=m_Source->FirstBone(); bone_it!=m_Source->LastBone(); ++bone_it,++bone_idx) - if (!(*bone_it)->ExportOGF(F)) - bRes=false; + for (bone_it = m_Source->FirstBone(); bone_it!=m_Source->LastBone(); ++bone_it,++bone_idx) + if (!(*bone_it)->ExportOGF(F)) + bRes = false; F.close_chunk(); if (m_Source->GetClassScript().size()) - { - F.open_chunk (OGF_S_USERDATA); - F.w_stringZ (m_Source->GetClassScript()); - F.close_chunk (); + { + F.open_chunk(OGF_S_USERDATA); + F.w_stringZ(m_Source->GetClassScript()); + F.close_chunk(); } #ifdef _EDITOR pb->Inc (); #endif - if (m_Source->GetLODs() && xr_strlen(m_Source->GetLODs())>0 && bRes) + if (m_Source->GetLODs()&&xr_strlen(m_Source->GetLODs())>0&&bRes) { - F.open_chunk (OGF_S_LODS); + F.open_chunk(OGF_S_LODS); #ifndef _string_lod CEditableObject* lod_src = Lib.CreateEditObject( m_Source->GetLODs() ); if (0==lod_src) @@ -883,7 +935,7 @@ bool CExportSkeleton::ExportGeometry(IWriter& F, u8 infl) CExportSkeleton E(lod_src); #else - F.w_string ( m_Source->GetLODs() ); + F.w_string(m_Source->GetLODs()); #endif #ifndef _string_lod @@ -896,7 +948,7 @@ bool CExportSkeleton::ExportGeometry(IWriter& F, u8 infl) Lib.RemoveEditObject(lod_src); } #endif - F.close_chunk (); + F.close_chunk(); } #ifdef _EDITOR @@ -904,33 +956,38 @@ bool CExportSkeleton::ExportGeometry(IWriter& F, u8 infl) #endif return bRes; } + //---------------------------------------------------- -struct bm_item{ - CKeyQR* _keysQR; - CKeyQT8* _keysQT8; - CKeyQT16* _keysQT16; - Fvector* _keysT; +struct bm_item +{ + CKeyQR *_keysQR; + CKeyQT8 *_keysQT8; + CKeyQT16 *_keysQT16; + Fvector *_keysT; + void create(u32 len) { - _keysQR = xr_alloc(len); - _keysQT8 = xr_alloc(len); - _keysQT16 = xr_alloc(len); - _keysT = xr_alloc(len); + _keysQR = xr_alloc(len); + _keysQT8 = xr_alloc(len); + _keysQT16 = xr_alloc(len); + _keysT = xr_alloc(len); } + void destroy() { - xr_free (_keysQR); - xr_free (_keysQT8); - xr_free (_keysQT16); - xr_free (_keysT); + xr_free(_keysQR); + xr_free(_keysQT8); + xr_free(_keysQT16); + xr_free(_keysT); } }; -bool CExportSkeleton::ExportMotionKeys(IWriter& F) +bool CExportSkeleton::ExportMotionKeys(IWriter &F) { - if (!!m_Source->m_SMotionRefs.size()||(m_Source->SMotionCount()<1)){ - Msg("!..Object doesn't have own motion"); - return !!m_Source->m_SMotionRefs.size(); + if (!!m_Source->m_SMotionRefs.size()||(m_Source->SMotionCount()<1)) + { + Msg("!..Object doesn't have own motion"); + return !!m_Source->m_SMotionRefs.size(); } #ifdef _EDITOR @@ -938,229 +995,243 @@ bool CExportSkeleton::ExportMotionKeys(IWriter& F) pb->Inc (); #endif // mem active motion - CSMotion* active_motion=m_Source->ResetSAnimation(); + CSMotion *active_motion = m_Source->ResetSAnimation(); // Motions - F.open_chunk (OGF_S_MOTIONS); - F.open_chunk (0); - F.w_u32 (m_Source->SMotionCount()); - F.close_chunk (); - int smot = 1; + F.open_chunk(OGF_S_MOTIONS); + F.open_chunk(0); + F.w_u32(m_Source->SMotionCount()); + F.close_chunk(); + int smot = 1; // use global transform - Fmatrix mGT,mTranslate,mRotate; - mRotate.setHPB (m_Source->a_vRotate.y, m_Source->a_vRotate.x, m_Source->a_vRotate.z); - mTranslate.translate (m_Source->a_vPosition); - mGT.mul (mTranslate,mRotate); + Fmatrix mGT, mTranslate, mRotate; + mRotate.setHPB(m_Source->a_vRotate.y, m_Source->a_vRotate.x, m_Source->a_vRotate.z); + mTranslate.translate(m_Source->a_vPosition); + mGT.mul(mTranslate, mRotate); - for (SMotionIt motion_it=m_Source->FirstSMotion(); motion_it!=m_Source->LastSMotion(); motion_it++, smot++) + for (SMotionIt motion_it = m_Source->FirstSMotion(); motion_it!=m_Source->LastSMotion(); motion_it++,smot++) { - CSMotion* cur_motion = *motion_it; - - if( cur_motion->m_Flags.test(esmRootMover) && !m_Source->AnimateRootObject(cur_motion) ) + CSMotion *cur_motion = *motion_it; + + if (cur_motion->m_Flags.test(esmRootMover)&&!m_Source->AnimateRootObject(cur_motion)) { - Msg("! %s has moveXform flag - but skeleton root has more than one child or has mesh! add special root bone please!", cur_motion->Name() ); - return false; + Msg("! %s has moveXform flag - but skeleton root has more than one child or has mesh! add special root bone please!", cur_motion->Name()); + return false; } -// if (motion->m_Flags.is(esmStopAtEnd)) Msg("%s - %d",motion->Name(),motion->m_Flags.is(esmStopAtEnd)); + // if (motion->m_Flags.is(esmStopAtEnd)) Msg("%s - %d",motion->Name(),motion->m_Flags.is(esmStopAtEnd)); - F.open_chunk (smot); - F.w_stringZ (cur_motion->Name()); - F.w_u32 (cur_motion->Length()); + F.open_chunk(smot); + F.w_stringZ(cur_motion->Name()); + F.w_u32(cur_motion->Length()); - u32 dwLen = cur_motion->Length(); - BoneVec& b_lst = m_Source->Bones(); + u32 dwLen = cur_motion->Length(); + BoneVec &b_lst = m_Source->Bones(); - bm_item* items = xr_alloc(b_lst.size()); - for (u32 itm_idx=0; itm_idx(b_lst.size()); + for (u32 itm_idx = 0; itm_idxFrameStart(); frame<=cur_motion->FrameEnd(); ++frame) + for (int frame = cur_motion->FrameStart(); frame<=cur_motion->FrameEnd(); ++frame) { + float t = (float)frame/cur_motion->FPS(); + int bone_id = 0; - - float t = (float)frame/cur_motion->FPS(); - int bone_id = 0; - - for(BoneIt b_it=b_lst.begin(); b_it!=b_lst.end(); ++b_it, ++bone_id) + for (BoneIt b_it = b_lst.begin(); b_it!=b_lst.end(); ++b_it,++bone_id) { - Fvector T,R; - if(cur_motion->BoneMotions().size()>bone_id) - cur_motion->_Evaluate (bone_id,t,T,R); - else - { - T = (*b_it)->_Offset(); - R = (*b_it)->_Rotate(); - } - (*b_it)->_Update (T,R); - - if(bone_id==0 && frame==(cur_motion->FrameEnd()) ) + Fvector T, R; + if (cur_motion->BoneMotions().size()>bone_id) + cur_motion->_Evaluate(bone_id, t, T, R); + else + { + T = (*b_it)->_Offset(); + R = (*b_it)->_Rotate(); + } + (*b_it)->_Update(T, R); + + if (bone_id==0&&frame==(cur_motion->FrameEnd())) { - Msg("motion [%s] end frame %f,%f,%f",cur_motion->Name(),T.x,T.y,T.z); + Msg("motion [%s] end frame %f,%f,%f", cur_motion->Name(), T.x, T.y, T.z); } } - m_Source->CalculateAnimation( cur_motion ); - if(cur_motion->m_Flags.test(esmRootMover)) + m_Source->CalculateAnimation(cur_motion); + if (cur_motion->m_Flags.test(esmRootMover)) { - if( frame == cur_motion->FrameStart() ) - m_Source->GetAnchorForRootObjectAnimation( ro_anchor ); - - m_Source->CalculateRootObjectAnimation( ro_anchor ); + if (frame==cur_motion->FrameStart()) + m_Source->GetAnchorForRootObjectAnimation(ro_anchor); + + m_Source->CalculateRootObjectAnimation(ro_anchor); } - bone_id = 0; - for(b_it=b_lst.begin(); b_it!=b_lst.end(); b_it++, bone_id++) + bone_id = 0; + for (b_it = b_lst.begin(); b_it!=b_lst.end(); b_it++,bone_id++) { - CBone* B = *b_it; - Fmatrix mat = B->_MTransform(); - if (B->IsRoot()) mat.mulA_43(mGT); - Fquaternion q; - q.set (mat); - CKeyQR& Kr = items[bone_id]._keysQR[frame-cur_motion->FrameStart()]; - Fvector&Kt = items[bone_id]._keysT [frame-cur_motion->FrameStart()]; + CBone *B = *b_it; + Fmatrix mat = B->_MTransform(); + if (B->IsRoot()) + mat.mulA_43(mGT); + Fquaternion q; + q.set(mat); + CKeyQR &Kr = items[bone_id]._keysQR[frame-cur_motion->FrameStart()]; + Fvector &Kt = items[bone_id]._keysT[frame-cur_motion->FrameStart()]; // Quantize quaternion - int _x = int(q.x*KEY_Quant); clamp(_x,-32767,32767); Kr.x = (s16)_x; - int _y = int(q.y*KEY_Quant); clamp(_y,-32767,32767); Kr.y = (s16)_y; - int _z = int(q.z*KEY_Quant); clamp(_z,-32767,32767); Kr.z = (s16)_z; - int _w = int(q.w*KEY_Quant); clamp(_w,-32767,32767); Kr.w = (s16)_w; - Kt.set (mat.c);//B->_Offset()); + int _x = int(q.x*KEY_Quant); + clamp(_x, -32767, 32767); + Kr.x = (s16)_x; + int _y = int(q.y*KEY_Quant); + clamp(_y, -32767, 32767); + Kr.y = (s16)_y; + int _z = int(q.z*KEY_Quant); + clamp(_z, -32767, 32767); + Kr.z = (s16)_z; + int _w = int(q.w*KEY_Quant); + clamp(_w, -32767, 32767); + Kr.w = (s16)_w; + Kt.set(mat.c);//B->_Offset()); } } // free temp storage - for (itm_idx=0; itm_idx1.5f) + if (g_force16BitTransformQuant||St.magnitude()>1.5f) { - bTransform16Bit = true; + bTransform16Bit = true; Msg("animation [%s] is 16bit-transform (%f)m", cur_motion->Name(), St.magnitude()); } - - for (t_idx=0; t_idxInc (); #endif } - F.close_chunk (); + F.close_chunk(); #ifdef _EDITOR UI->ProgressEnd (pb); #endif // restore active motion - m_Source->SetActiveSMotion (active_motion); - return true; + m_Source->SetActiveSMotion(active_motion); + return true; } -bool CExportSkeleton::ExportMotionDefs(IWriter& F) +bool CExportSkeleton::ExportMotionDefs(IWriter &F) { - if (!m_Source->IsAnimated()){ - ELog.Msg(mtError,"Object doesn't have any motion or motion refs."); - return false; + if (!m_Source->IsAnimated()) + { + ELog.Msg(mtError, "Object doesn't have any motion or motion refs."); + return false; } - bool bRes=true; + bool bRes = true; #ifdef _EDITOR SPBItem* pb = UI->ProgressStart(3,"..Export skeleton motions defs"); @@ -1169,84 +1240,88 @@ bool CExportSkeleton::ExportMotionDefs(IWriter& F) if (m_Source->m_SMotionRefs.size()) { - F.open_chunk (OGF_S_MOTION_REFS2); - F.w_u32 (m_Source->m_SMotionRefs.size()); - for(u32 i=0; im_SMotionRefs.size(); ++i) - F.w_stringZ (m_Source->m_SMotionRefs[i].c_str()); + F.open_chunk(OGF_S_MOTION_REFS2); + F.w_u32(m_Source->m_SMotionRefs.size()); + for (u32 i = 0; im_SMotionRefs.size(); ++i) + F.w_stringZ(m_Source->m_SMotionRefs[i].c_str()); - F.close_chunk (); + F.close_chunk(); #ifdef _EDITOR pb->Inc (); #endif - }else{ + } + else + { // save smparams - F.open_chunk (OGF_S_SMPARAMS); - F.w_u16 (xrOGF_SMParamsVersion); + F.open_chunk(OGF_S_SMPARAMS); + F.w_u16(xrOGF_SMParamsVersion); // bone parts - BPVec& bp_lst = m_Source->BoneParts(); + BPVec &bp_lst = m_Source->BoneParts(); if (bp_lst.size()) - { + { if (m_Source->VerifyBoneParts()) - { + { F.w_u16((u16)bp_lst.size()); - for (BPIt bp_it=bp_lst.begin(); bp_it!=bp_lst.end(); ++bp_it) - { - string512 buff; - strcpy (buff, bp_it->alias.c_str()); - strlwr (buff); - F.w_stringZ (buff); - F.w_u16 ((u16)bp_it->bones.size()); - for (int i=0; ibones.size()); ++i) - { - F.w_stringZ (bp_it->bones[i].c_str()); - int idx = m_Source->FindBoneByNameIdx(bp_it->bones[i].c_str()); - VERIFY(idx>=0); - F.w_u32 (idx); + for (BPIt bp_it = bp_lst.begin(); bp_it!=bp_lst.end(); ++bp_it) + { + string512 buff; + strcpy(buff, bp_it->alias.c_str()); + strlwr(buff); + F.w_stringZ(buff); + F.w_u16((u16)bp_it->bones.size()); + for (int i = 0; ibones.size()); ++i) + { + F.w_stringZ(bp_it->bones[i].c_str()); + int idx = m_Source->FindBoneByNameIdx(bp_it->bones[i].c_str()); + VERIFY(idx>=0); + F.w_u32(idx); } } - }else - { - ELog.Msg(mtError,"Invalid bone parts (missing or duplicate bones)."); - bRes = false; } - }else - { + else + { + ELog.Msg(mtError, "Invalid bone parts (missing or duplicate bones)."); + bRes = false; + } + } + else + { F.w_u16(1); F.w_stringZ("default"); F.w_u16((u16)m_Source->BoneCount()); - for (int i=0; iBoneCount(); i++) - F.w_u32(i); + for (int i = 0; iBoneCount(); i++) + F.w_u32(i); } #ifdef _EDITOR pb->Inc (); #endif // motion defs - SMotionVec& sm_lst = m_Source->SMotions(); + SMotionVec &sm_lst = m_Source->SMotions(); F.w_u16((u16)sm_lst.size()); - for (SMotionIt motion_it=m_Source->FirstSMotion(); motion_it!=m_Source->LastSMotion(); ++motion_it) - { - CSMotion* motion = *motion_it; + for (SMotionIt motion_it = m_Source->FirstSMotion(); motion_it!=m_Source->LastSMotion(); ++motion_it) + { + CSMotion *motion = *motion_it; // verify if (!motion->m_Flags.is(esmFX)) - { + { if (!((motion->m_BoneOrPart==BI_NONE)||(motion->m_BoneOrPart<(int)bp_lst.size()))) - { - ELog.Msg(mtError,"Invalid Bone Part of motion: '%s'.",motion->Name()); - bRes=false; + { + ELog.Msg(mtError, "Invalid Bone Part of motion: '%s'.", motion->Name()); + bRes = false; continue; } } if (bRes) - { + { // export - F.w_stringZ (motion->Name()); - F.w_u32 (motion->m_Flags.get()); - F.w_u16 (motion->m_BoneOrPart); - F.w_u16 (u16(motion_it-sm_lst.begin())); - F.w_float (motion->fSpeed); - F.w_float (motion->fPower); - F.w_float (motion->fAccrue); - F.w_float (motion->fFalloff); + F.w_stringZ(motion->Name()); + F.w_u32(motion->m_Flags.get()); + F.w_u16(motion->m_BoneOrPart); + F.w_u16(u16(motion_it-sm_lst.begin())); + F.w_float(motion->fSpeed); + F.w_float(motion->fPower); + F.w_float(motion->fAccrue); + F.w_float(motion->fFalloff); #ifdef _EDITOR u32 sz = motion->marks.size(); @@ -1256,45 +1331,50 @@ bool CExportSkeleton::ExportMotionDefs(IWriter& F) motion->marks[i].Save(&F); } #else - F.w_u32 (0); + F.w_u32(0); #endif } } #ifdef _EDITOR pb->Inc (); #endif - F.close_chunk(); + F.close_chunk(); } - + #ifdef _EDITOR UI->ProgressEnd(pb); #endif return bRes; } -bool CExportSkeleton::ExportMotions(IWriter& F) +bool CExportSkeleton::ExportMotions(IWriter &F) { - if (!ExportMotionKeys(F)) return false; - if (!ExportMotionDefs(F)) return false; + if (!ExportMotionKeys(F)) + return false; + if (!ExportMotionDefs(F)) + return false; return true; } + //---------------------------------------------------- -bool CExportSkeleton::Export(IWriter& F, u8 infl) +bool CExportSkeleton::Export(IWriter &F, u8 infl) { - if (!ExportGeometry(F,infl)) return false; - if (m_Source->IsAnimated()&&!ExportMotions(F)) return false; + if (!ExportGeometry(F, infl)) + return false; + if (m_Source->IsAnimated()&&!ExportMotions(F)) + return false; return true; }; -//---------------------------------------------------- +//---------------------------------------------------- #if defined _EDITOR || defined _MAYA_EXPORT bool CBone::ExportOGF(IWriter& F) { - // check valid +// check valid if (!shape.Valid()){ ELog.Msg(mtError,"Bone '%s' has invalid shape.",*Name()); return false; @@ -1329,4 +1409,5 @@ bool CBone::ExportOGF(IWriter& F) return true; } -#endif \ No newline at end of file +#endif + diff --git a/src/editors/ECore/Editor/ExportSkeleton.h b/src/editors/ECore/Editor/ExportSkeleton.h index d4e4a8978c5..c8d601d666e 100644 --- a/src/editors/ECore/Editor/ExportSkeleton.h +++ b/src/editors/ECore/Editor/ExportSkeleton.h @@ -5,199 +5,209 @@ #include "EditMesh.h" //--------------------------------------------------------------------------- -const int clpSMX = 28, clpSMY=16, clpSMZ=28; +const int clpSMX = 28, clpSMY = 16, clpSMZ = 28; //--------------------------------------------------------------------------- // refs class CEditableObject; class CSurface; class CInifile; extern ECORE_API BOOL g_force16BitTransformQuant; -extern ECORE_API float g_EpsSkelPositionDelta; - -struct ECORE_API SSkelVert: public st_SVert{ - Fvector tang; - Fvector binorm; - SSkelVert(){ - uv.set (0.f,0.f); - offs.set (0,0,0); - norm.set (0,1,0); - tang.set (1,0,0); - binorm.set (0,0,1); - } - void set(const Fvector& _o, const Fvector& _n, const Fvector2& _uv, u8 _w_cnt, const st_SVert::bone* b) - { - offs.set (_o); - norm.set (_n); - uv.set (_uv); - VERIFY (_w_cnt>0 && _w_cnt<=4); - bones.resize(_w_cnt); +extern ECORE_API +float g_EpsSkelPositionDelta; - for (u8 k=0; k<_w_cnt; k++) - { - bones[k]=b[k]; - } - sort_by_bone(); // need to similar - } - BOOL similar_pos(SSkelVert& V) +struct ECORE_API SSkelVert: + +public +st_SVert +{ + Fvector tang; + Fvector binorm; + SSkelVert(){ + uv.set (0.f,0.f); + offs.set (0,0,0); + norm.set (0,1,0); + tang.set (1,0,0); + binorm.set (0,0,1); +} +void set(const Fvector& _o, const Fvector& _n, const Fvector2& _uv, u8 _w_cnt, const st_SVert::bone* b) +{ + offs.set (_o); + norm.set (_n); + uv.set (_uv); + VERIFY (_w_cnt>0 && _w_cnt<=4); + bones.resize(_w_cnt); + + for (u8 k=0; k<_w_cnt; k++) { - return offs.similar(V.offs,g_EpsSkelPositionDelta); - } - BOOL similar(SSkelVert& V) + bones[k]=b[k]; +} +sort_by_bone(); // need to similar +} +BOOL similar_pos(SSkelVert& V) +{ + return offs.similar(V.offs,g_EpsSkelPositionDelta); +} +BOOL similar(SSkelVert& V) +{ + if (bones.size()!=V.bones.size()) return FALSE; + for (u8 k=0; k<(u8)bones.size(); k++) { - if (bones.size()!=V.bones.size()) return FALSE; - for (u8 k=0; k<(u8)bones.size(); k++) - { - if (!bones[k].similar(V.bones[k])) - return FALSE; - } - if (!uv.similar (V.uv,EPS_S)) - return FALSE; + if (!bones[k].similar(V.bones[k])) + return FALSE; +} +if (!uv.similar (V.uv,EPS_S)) +return FALSE; - if (!offs.similar(V.offs,g_EpsSkelPositionDelta)) - return FALSE; +if (!offs.similar(V.offs,g_EpsSkelPositionDelta)) +return FALSE; - if (!norm.similar(V.norm,g_EpsSkelPositionDelta)) - return FALSE; +if (!norm.similar(V.norm,g_EpsSkelPositionDelta)) +return FALSE; - return TRUE; - } +return TRUE; +} }; struct ECORE_API SSkelFace{ - WORD v[3]; + WORD v[3]; }; -DEFINE_VECTOR(SSkelVert,SkelVertVec,SkelVertIt); -DEFINE_VECTOR(SSkelFace,SkelFaceVec,SkelFaceIt); +DEFINE_VECTOR(SSkelVert, SkelVertVec, SkelVertIt); +DEFINE_VECTOR(SSkelFace, SkelFaceVec, SkelFaceIt); class ECORE_API CSkeletonCollectorPacked { -protected: - SkelVertVec m_Verts; - SkelFaceVec m_Faces; - - Fvector m_VMmin, m_VMscale; - U32Vec m_VM[clpSMX+1][clpSMY+1][clpSMZ+1]; - Fvector m_VMeps; - - u16 VPack(SSkelVert& V); -public: - u32 invalid_faces; -public: - CSkeletonCollectorPacked (const Fbox &bb, int apx_vertices=5000, int apx_faces=5000); - bool check (SSkelFace& F){ - if ((F.v[0]==F.v[1]) || (F.v[0]==F.v[2]) || (F.v[1]==F.v[2])) return false; - for (SkelFaceIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++){ + protected: + SkelVertVec m_Verts; + SkelFaceVec m_Faces; + + Fvector m_VMmin, m_VMscale; + U32Vec m_VM[clpSMX+1][clpSMY+1][clpSMZ+1]; + Fvector m_VMeps; + + u16 VPack(SSkelVert&V); + public: + u32 invalid_faces; + public: + CSkeletonCollectorPacked(const Fbox&bb, int apx_vertices = 5000, int apx_faces = 5000); + bool check(SSkelFace&F){ + if ((F.v[0]==F.v[1])||(F.v[0]==F.v[2])||(F.v[1]==F.v[2]))return false; + for (SkelFaceIt f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++){ // Test for 6 variations - if ((f_it->v[0]==F.v[0]) && (f_it->v[1]==F.v[1]) && (f_it->v[2]==F.v[2])) return false; - if ((f_it->v[0]==F.v[0]) && (f_it->v[2]==F.v[1]) && (f_it->v[1]==F.v[2])) return false; - if ((f_it->v[2]==F.v[0]) && (f_it->v[0]==F.v[1]) && (f_it->v[1]==F.v[2])) return false; - if ((f_it->v[2]==F.v[0]) && (f_it->v[1]==F.v[1]) && (f_it->v[0]==F.v[2])) return false; - if ((f_it->v[1]==F.v[0]) && (f_it->v[0]==F.v[1]) && (f_it->v[2]==F.v[2])) return false; - if ((f_it->v[1]==F.v[0]) && (f_it->v[2]==F.v[1]) && (f_it->v[0]==F.v[2])) return false; + if ((f_it->v[0]==F.v[0])&&(f_it->v[1]==F.v[1])&&(f_it->v[2]==F.v[2]))return false; + if ((f_it->v[0]==F.v[0])&&(f_it->v[2]==F.v[1])&&(f_it->v[1]==F.v[2]))return false; + if ((f_it->v[2]==F.v[0])&&(f_it->v[0]==F.v[1])&&(f_it->v[1]==F.v[2]))return false; + if ((f_it->v[2]==F.v[0])&&(f_it->v[1]==F.v[1])&&(f_it->v[0]==F.v[2]))return false; + if ((f_it->v[1]==F.v[0])&&(f_it->v[0]==F.v[1])&&(f_it->v[2]==F.v[2]))return false; + if ((f_it->v[1]==F.v[0])&&(f_it->v[2]==F.v[1])&&(f_it->v[0]==F.v[2]))return false; } return true; } - bool add_face (SSkelVert& v0, SSkelVert& v1, SSkelVert& v2) + bool add_face(SSkelVert&v0, SSkelVert&v1, SSkelVert&v2) { - if (v0.offs.similar(v1.offs,EPS) || v0.offs.similar(v2.offs,EPS) || v1.offs.similar(v2.offs,EPS)){ - ELog.Msg(mtError,"Degenerate face found. Removed."); + if (v0.offs.similar(v1.offs, EPS)||v0.offs.similar(v2.offs, EPS)||v1.offs.similar(v2.offs, EPS)){ + ELog.Msg(mtError, "Degenerate face found. Removed."); invalid_faces++; return false; } SSkelFace F; - F.v[0] = VPack(v0); - F.v[1] = VPack(v1); - F.v[2] = VPack(v2); - if (check(F)){ - m_Faces.push_back (F); - return true; - }else{ - ELog.Msg(mtError,"Duplicate face found. Removed."); + F.v[0] = VPack(v0); + F.v[1] = VPack(v1); + F.v[2] = VPack(v2); + if (check(F)){ + m_Faces.push_back(F); + return true; + }else{ + ELog.Msg(mtError, "Duplicate face found. Removed."); invalid_faces++; return false; } } - SkelVertVec& getV_Verts() {return m_Verts;} - SkelFaceVec& getV_Faces() {return m_Faces;} - SSkelVert* getVert() { return &m_Verts[0];/*.begin();*/ } - int getVS() { return m_Verts.size(); } -// SSkelFace& getFace(int id) { return VERIFY(id m_SWR;// The records of the collapses. - u32 m_SkeletonLinkType; - public: - SSplit (CSurface* surf, const Fbox& bb, u16 part); + ArbitraryListm_SWR;// The records of the collapses. + u32 m_SkeletonLinkType; + public: + SSplit(CSurface*surf, const Fbox&bb, u16 part); - bool valid() + bool valid() { - if (m_Verts.empty()) return false; - if (m_Faces.empty()) return false; + if (m_Verts.empty())return false; + if (m_Faces.empty())return false; return true; } - void MakeProgressive (); - void MakeStripify (); - void CalculateTB (); - void OptimizeTextureCoordinates (); + void MakeProgressive(); + void MakeStripify(); + void CalculateTB(); + void OptimizeTextureCoordinates(); - void Save (IWriter& F); + void Save(IWriter&F); - void ComputeBounding () + void ComputeBounding() { // calculate BBox - m_Box.invalidate (); - for (SkelVertIt v_it=m_Verts.begin(); v_it!=m_Verts.end(); v_it++){ - SSkelVert& pV = *v_it; + m_Box.invalidate(); + for (SkelVertIt v_it = m_Verts.begin(); v_it!=m_Verts.end(); v_it++){ + SSkelVert&pV = *v_it; m_Box.modify(pV.offs); } } }; - DEFINE_VECTOR (SSplit,SplitVec,SplitIt); - SplitVec m_Splits; - Fbox m_Box; -//---------------------------------------------------- - int FindSplit (shared_str shader, shared_str texture, u16 part_id); - void ComputeBounding () + DEFINE_VECTOR(SSplit, SplitVec, SplitIt); + SplitVec m_Splits; + Fbox m_Box; + //---------------------------------------------------- + int FindSplit(shared_str shader, shared_str texture, u16 part_id); + void ComputeBounding() { m_Box.invalidate(); - for (SplitIt it=m_Splits.begin(); it!=m_Splits.end(); it++){ - it->ComputeBounding (); - m_Box.merge (it->m_Box); + for (SplitIt it = m_Splits.begin(); it!=m_Splits.end(); it++){ + it->ComputeBounding(); + m_Box.merge(it->m_Box); } } -public: - virtual bool Export (IWriter& F, u8 infl)=0; + public: + virtual bool Export(IWriter&F, u8 infl) = 0; }; -class ECORE_API CExportSkeleton: public CExportSkeletonCustom{ - CEditableObject* m_Source; - bool PrepareGeometry (u8 influence); -public: - CExportSkeleton (CEditableObject* object); - virtual bool Export (IWriter& F, u8 infl); - virtual bool ExportGeometry (IWriter& F, u8 infl); - virtual bool ExportMotions (IWriter& F); +class ECORE_API CExportSkeleton: - virtual bool ExportMotionKeys (IWriter& F); - virtual bool ExportMotionDefs (IWriter& F); - bool ExportAsSimple (IWriter& F); +public +CExportSkeletonCustom +{ + CEditableObject* m_Source; + bool PrepareGeometry (u8 influence); + public: + CExportSkeleton (CEditableObject* object); + virtual bool Export (IWriter& F, u8 infl); + virtual bool ExportGeometry (IWriter& F, u8 infl); + virtual bool ExportMotions (IWriter& F); + + virtual bool ExportMotionKeys (IWriter& F); + virtual bool ExportMotionDefs (IWriter& F); + bool ExportAsSimple (IWriter& F); }; -void ECORE_API ComputeOBB_RAPID (Fobb &B, FvectorVec& V, u32 t_cnt); -void ECORE_API ComputeOBB_WML (Fobb &B, FvectorVec& V); +void ECORE_API ComputeOBB_RAPID(Fobb &B, FvectorVec &V, u32 t_cnt); +void ECORE_API ComputeOBB_WML(Fobb&B, FvectorVec&V); #endif + diff --git a/src/editors/ECore/Editor/ExportSkeletonCalculateTB.cpp b/src/editors/ECore/Editor/ExportSkeletonCalculateTB.cpp index 5971093b68b..42815bc4b12 100644 --- a/src/editors/ECore/Editor/ExportSkeletonCalculateTB.cpp +++ b/src/editors/ECore/Editor/ExportSkeletonCalculateTB.cpp @@ -4,8 +4,8 @@ #ifndef _EDITOR #include "xrEngine/defines.h" #include "xrCore/xrCore.h" -#include "Layers/xrRender/hwcaps.h" -#include "Layers/xrRender/hw.h" +#include "Layers/xrRender/HWCaps.h" +#include "Layers/xrRender/HW.h" #include "xrEngine/pure.h" class CGameFont; #include "Include/xrRender/drawutils.h" @@ -171,10 +171,10 @@ void CExportSkeleton::SSplit::CalculateTB() ///////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////// -#include "common/nvMender2003/nvmeshmender.h" -#include "common/NvMender2003/nvMeshMender.h" -#include "common/NvMender2003/mender_input_output.h" -#include "common/NvMender2003/remove_isolated_verts.h" +#include "Common/NvMender2003/NVMeshMender.h" +#include "Common/NvMender2003/NVMeshMender.h" +#include "Common/NvMender2003/mender_input_output.h" +#include "Common/NvMender2003/remove_isolated_verts.h" void CExportSkeleton::SSplit::OptimizeTextureCoordinates() { diff --git a/src/editors/ECore/Editor/GeometryCollector.cpp b/src/editors/ECore/Editor/GeometryCollector.cpp index 515f8841c64..c0e188741c2 100644 --- a/src/editors/ECore/Editor/GeometryCollector.cpp +++ b/src/editors/ECore/Editor/GeometryCollector.cpp @@ -11,49 +11,50 @@ //------------------------------------------------------------------------------ VCPacked::VCPacked(const Fbox &bb, float _eps, u32 _sx, u32 _sy, u32 _sz, int apx_vertices) { - eps = _eps; - sx = _max(_sx,1); - sy = _max(_sy,1); - sz = _max(_sz,1); - // prepare hash table - VM.resize (sx*sy*sz); - + eps = _eps; + sx = _max(_sx, 1); + sy = _max(_sy, 1); + sz = _max(_sz, 1); + // prepare hash table + VM.resize(sx*sy*sz); + // Params - VMscale.set (bb.max.x-bb.min.x, bb.max.y-bb.min.y, bb.max.z-bb.min.z); - VMmin.set (bb.min); - VMeps.set (VMscale.x/(sx-1)/2,VMscale.y/(sy-1)/2,VMscale.z/(sz-1)/2); - VMeps.x = (VMeps.xreserve (_average); + int _size = VM.size(); + int _average = (apx_vertices/_size)/2; + for (GCHashIt it = VM.begin(); it!=VM.end(); it++) + it->reserve(_average); } -u32 VCPacked::add_vert(const Fvector& V) +u32 VCPacked::add_vert(const Fvector &V) { u32 P = 0xffffffff; - u32 clpX=sx-1, clpY=sy-1, clpZ=sz-1; + u32 clpX = sx-1, clpY = sy-1, clpZ = sz-1; - u32 ix,iy,iz; + u32 ix, iy, iz; ix = iFloor(float(V.x-VMmin.x)/VMscale.x*clpX); iy = iFloor(float(V.y-VMmin.y)/VMscale.y*clpY); iz = iFloor(float(V.z-VMmin.z)/VMscale.z*clpZ); - clamp(ix,(u32)0,clpX); - clamp(iy,(u32)0,clpY); - clamp(iz,(u32)0,clpZ); + clamp(ix, (u32)0, clpX); + clamp(iy, (u32)0, clpY); + clamp(iz, (u32)0, clpZ); { - U32Vec& vl = get_element(ix,iy,iz); - for(U32It it=vl.begin();it!=vl.end(); it++) - if( verts[*it].similar(V,eps) ) { + U32Vec &vl = get_element(ix, iy, iz); + for (U32It it = vl.begin(); it!=vl.end(); it++) + if (verts[*it].similar(V, eps)) + { P = *it; verts[*it].refs++; break; @@ -64,80 +65,92 @@ u32 VCPacked::add_vert(const Fvector& V) P = verts.size(); verts.push_back(GCVertex(V)); - get_element(ix,iy,iz).push_back(P); + get_element(ix, iy, iz).push_back(P); - u32 ixE,iyE,izE; + u32 ixE, iyE, izE; ixE = iFloor(float(V.x+VMeps.x-VMmin.x)/VMscale.x*clpX); iyE = iFloor(float(V.y+VMeps.y-VMmin.y)/VMscale.y*clpY); izE = iFloor(float(V.z+VMeps.z-VMmin.z)/VMscale.z*clpZ); // R_ASSERT(ixE<=clpMX && iyE<=clpMY && izE<=clpMZ); - clamp(ixE,(u32)0,clpX); clamp(iyE,(u32)0,clpY); clamp(izE,(u32)0,clpZ); - - if (ixE!=ix) get_element(ixE,iy,iz).push_back (P); - if (iyE!=iy) get_element(ix,iyE,iz).push_back (P); - if (izE!=iz) get_element(ix,iy,izE).push_back (P); - if ((ixE!=ix)&&(iyE!=iy)) get_element(ixE,iyE,iz).push_back (P); - if ((ixE!=ix)&&(izE!=iz)) get_element(ixE,iy,izE).push_back (P); - if ((iyE!=iy)&&(izE!=iz)) get_element(ix,iyE,izE).push_back (P); - if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) get_element(ixE,iyE,izE).push_back (P); + clamp(ixE, (u32)0, clpX); + clamp(iyE, (u32)0, clpY); + clamp(izE, (u32)0, clpZ); + + if (ixE!=ix) + get_element(ixE, iy, iz).push_back(P); + if (iyE!=iy) + get_element(ix, iyE, iz).push_back(P); + if (izE!=iz) + get_element(ix, iy, izE).push_back(P); + if ((ixE!=ix)&&(iyE!=iy)) + get_element(ixE, iyE, iz).push_back(P); + if ((ixE!=ix)&&(izE!=iz)) + get_element(ixE, iy, izE).push_back(P); + if ((iyE!=iy)&&(izE!=iz)) + get_element(ix, iyE, izE).push_back(P); + if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) + get_element(ixE, iyE, izE).push_back(P); } return P; } -void VCPacked::clear() +void VCPacked::clear() { - verts.clear_and_free (); - for (GCHashIt it=VM.begin(); it!=VM.end(); it++) - it->clear_and_free (); + verts.clear_and_free(); + for (GCHashIt it = VM.begin(); it!=VM.end(); it++) + it->clear_and_free(); } //------------------------------------------------------------------------------ // GCPacked //------------------------------------------------------------------------------ -void GCPacked::add_face(const Fvector& v0, const Fvector& v1, const Fvector& v2, u32 dummy) +void GCPacked::add_face(const Fvector &v0, const Fvector &v1, const Fvector &v2, u32 dummy) { - GCFace T; - T.verts [0] = add_vert(v0); - T.verts [1] = add_vert(v1); - T.verts [2] = add_vert(v2); - T.dummy = dummy; - faces.push_back (T); - validate (T); + GCFace T; + T.verts[0] = add_vert(v0); + T.verts[1] = add_vert(v1); + T.verts[2] = add_vert(v2); + T.dummy = dummy; + faces.push_back(T); + validate(T); } -void GCPacked::clear() +void GCPacked::clear() { - GCPacked::clear (); - faces.clear_and_free (); + GCPacked::clear(); + faces.clear_and_free(); } -void GCPacked::calc_adjacency (U32Vec& dest) +void GCPacked::calc_adjacency(U32Vec &dest) { - dest.assign (faces.size()*3,0xffffffff); + dest.assign(faces.size()*3, 0xffffffff); // Dumb algorithm O(N^2) :) - for (u32 f=0; ff2) std::swap(f1,f2); + u32 f1 = faces[f].verts[(f_e+0)%3]; + u32 f2 = faces[f].verts[(f_e+1)%3]; + if (f1>f2) + std::swap(f1, f2); - for (u32 t_e=0; t_e<3; t_e++) + for (u32 t_e = 0; t_e<3; t_e++) { - u32 t1 = faces[t].verts[(t_e+0)%3]; - u32 t2 = faces[t].verts[(t_e+1)%3]; - if (t1>t2) std::swap(t1,t2); + u32 t1 = faces[t].verts[(t_e+0)%3]; + u32 t2 = faces[t].verts[(t_e+1)%3]; + if (t1>t2) + std::swap(t1, t2); - if (f1==t1 && f2==t2) + if (f1==t1&&f2==t2) { // f.edge[f_e] linked to t.edge[t_e] - dest[f*3+f_e] = t; + dest[f*3+f_e] = t; break; } } diff --git a/src/editors/ECore/Editor/GeometryCollector.h b/src/editors/ECore/Editor/GeometryCollector.h index b29e3f21ecc..7fd2bfdce36 100644 --- a/src/editors/ECore/Editor/GeometryCollector.h +++ b/src/editors/ECore/Editor/GeometryCollector.h @@ -3,69 +3,73 @@ //--------------------------------------------------------------------------- struct ECORE_API GCVertex{ - Fvector pos; - u32 refs; - GCVertex (const Fvector& p){pos=p;refs=1;} - bool similar (const GCVertex& v, float eps=EPS){return pos.similar(v.pos);} + Fvector pos; + u32 refs; + GCVertex(const Fvector&p){pos = p;refs = 1;} + bool similar(const GCVertex&v, float eps = EPS){return pos.similar(v.pos);} }; struct ECORE_API GCFace{ - u32 verts[3]; - bool valid; - u32 dummy; + u32 verts[3]; + bool valid; + u32 dummy; }; class ECORE_API VCPacked { -protected: - DEFINE_VECTOR(U32Vec,GCHash,GCHashIt); + protected: + DEFINE_VECTOR(U32Vec, GCHash, GCHashIt); - xr_vector verts; + xr_vectorverts; - GCHash VM; - Fvector VMmin, VMscale; - Fvector VMeps; - float eps; - u32 sx,sy,sz; + GCHash VM; + Fvector VMmin, VMscale; + Fvector VMeps; + float eps; + u32 sx,sy,sz; - IC U32Vec& get_element (u32 ix, u32 iy, u32 iz) {VERIFY((ix&Vertices () { return verts; } + GCVertex*getV(){return &*verts.begin();} + size_t getVS(){return verts.size();} + xr_vector&Vertices(){return verts;} - void getHASH_size(u32& x, u32& y, u32& z){x=sx;y=sy;z=sz;} - U32Vec& getHASH_elem(u32 ix, u32 iy, u32 iz){return get_element(ix,iy,iz);} + void getHASH_size(u32&x, u32&y, u32&z){x = sx;y = sy;z = sz;} + U32Vec&getHASH_elem(u32 ix, u32 iy, u32 iz){return get_element(ix, iy, iz);} }; -class ECORE_API GCPacked: public VCPacked +class ECORE_API GCPacked: + +public +VCPacked { - xr_vector faces; - void validate (GCFace& F) + xr_vector faces; + void validate (GCFace& F) { - if ((F.verts[0]==F.verts[1])||(F.verts[0]==F.verts[2])||(F.verts[1]==F.verts[2])) F.valid=false; - else F.valid=true; - } + if ((F.verts[0]==F.verts[1])||(F.verts[0]==F.verts[2])||(F.verts[1]==F.verts[2])) F.valid=false; + else F.valid=true; +} public: - GCPacked (const Fbox &bb, float eps=EPS, u32 clpMX=24, u32 clpMY=16, u32 clpMZ=24, int apx_vertices=5000, int apx_faces=5000): - VCPacked(bb,eps,clpMX,clpMY,clpMZ,apx_vertices){faces.reserve(apx_faces);} - virtual ~GCPacked () { clear(); } - virtual void clear (); +GCPacked (const Fbox &bb, float eps=EPS, u32 clpMX=24, u32 clpMY=16, u32 clpMZ=24, int apx_vertices=5000, int apx_faces=5000): +VCPacked(bb,eps,clpMX,clpMY,clpMZ,apx_vertices){faces.reserve(apx_faces);} +virtual ~GCPacked () { clear(); } +virtual void clear (); - xr_vector& Faces () { return faces; } +xr_vector& Faces () { return faces; } - void add_face (const Fvector& v0, const Fvector& v1, const Fvector& v2, u32 dummy=0); +void add_face (const Fvector& v0, const Fvector& v1, const Fvector& v2, u32 dummy=0); - GCFace* getF () { return &*faces.begin(); } - size_t getFS () { return faces.size(); } +GCFace* getF () { return &*faces.begin(); } +size_t getFS () { return faces.size(); } - void calc_adjacency(U32Vec& dest); +void calc_adjacency(U32Vec& dest); }; #endif + diff --git a/src/editors/ECore/Editor/ImageEditor.cpp b/src/editors/ECore/Editor/ImageEditor.cpp index 3047b6f34b9..39dc158cc07 100644 --- a/src/editors/ECore/Editor/ImageEditor.cpp +++ b/src/editors/ECore/Editor/ImageEditor.cpp @@ -5,10 +5,10 @@ #include "ImageEditor.h" #include "EThumbnail.h" #include "ImageManager.h" -#include "PropertiesList.h" -#include "FolderLib.h" +#include "editors/xrEProps/PropertiesList.h" +#include "editors/xrEProps/FolderLib.h" #include "ui_main.h" -#include "ItemList.h" +#include "editors/xrEProps/ItemList.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "ElTree" @@ -17,154 +17,168 @@ #pragma link "mxPlacemnt" #pragma link "MXCtrls" #pragma resource "*.dfm" -TfrmImageLib* TfrmImageLib::form = 0; -FS_FileSet TfrmImageLib::texture_map; -FS_FileSet TfrmImageLib::modif_map; -bool TfrmImageLib::bFormLocked=false; -Flags32 TfrmImageLib::m_Flags={0}; +TfrmImageLib *TfrmImageLib::form = 0; +FS_FileSet TfrmImageLib::texture_map; +FS_FileSet TfrmImageLib::modif_map; +bool TfrmImageLib::bFormLocked = false; +Flags32 TfrmImageLib::m_Flags = {0}; + //--------------------------------------------------------------------------- -__fastcall TfrmImageLib::TfrmImageLib(TComponent* Owner) +__fastcall TfrmImageLib::TfrmImageLib(TComponent *Owner) : TForm(Owner) { DEFINE_INI(fsStorage); - bImportMode = false; - ttImage->Tag = STextureParams::ttImage; - ttCubeMap->Tag = STextureParams::ttCubeMap; - ttBumpMap->Tag = STextureParams::ttBumpMap; - ttNormalMap->Tag= STextureParams::ttNormalMap; - ttTerrain->Tag = STextureParams::ttTerrain; + bImportMode = false; + ttImage->Tag = STextureParams::ttImage; + ttCubeMap->Tag = STextureParams::ttCubeMap; + ttBumpMap->Tag = STextureParams::ttBumpMap; + ttNormalMap->Tag = STextureParams::ttNormalMap; + ttTerrain->Tag = STextureParams::ttTerrain; } + //--------------------------------------------------------------------------- -void __fastcall TfrmImageLib::FormCreate(TObject*) +void __fastcall TfrmImageLib::FormCreate(TObject *) { - m_ItemProps = TProperties::CreateForm ("",paProperties,alClient); - m_ItemList = TItemList::CreateForm ("Items",paItems,alClient); - m_ItemList->SetOnItemsFocusedEvent (fastdelegate::bind(this,&TfrmImageLib::OnItemsFocused)); - m_ItemList->SetOnItemRemoveEvent (fastdelegate::bind(&ImageLib,&CImageManager::RemoveTexture)); - m_ItemList->SetImages (ImageList); + m_ItemProps = TProperties::CreateForm("", paProperties, alClient); + m_ItemList = TItemList::CreateForm("Items", paItems, alClient); + m_ItemList->SetOnItemsFocusedEvent(fastdelegate::bind(this, &TfrmImageLib::OnItemsFocused)); + m_ItemList->SetOnItemRemoveEvent(fastdelegate::bind(&ImageLib, &CImageManager::RemoveTexture)); + m_ItemList->SetImages(ImageList); } + //--------------------------------------------------------------------------- void __fastcall TfrmImageLib::FormDestroy(TObject *) { TProperties::DestroyForm(m_ItemProps); - TItemList::DestroyForm (m_ItemList); + TItemList::DestroyForm(m_ItemList); } + //--------------------------------------------------------------------------- -void __fastcall TfrmImageLib::EditLib(AnsiString& title, bool bImport) +void __fastcall TfrmImageLib::EditLib(AnsiString &title, bool bImport) { - if (!form){ - form = xr_new((TComponent*)0); - form->Caption = title; - form->bImportMode = bImport; - form->ebRemoveTexture->Enabled = !bImport; -//. form->ebRebuildAssociation->Enabled = !bImport; - form->bReadonlyMode = !FS.can_write_to_alias(_textures_); - if (form->bReadonlyMode){ - Log ("#!You don't have permisions to modify textures."); - form->ebOk->Enabled = false; - form->ebRemoveTexture->Enabled = false; -//. form->ebRebuildAssociation->Enabled = false; - form->m_ItemProps->SetReadOnly (TRUE); + if (!form) + { + form = xr_new((TComponent*)0); + form->Caption = title; + form->bImportMode = bImport; + form->ebRemoveTexture->Enabled = !bImport; + //. form->ebRebuildAssociation->Enabled = !bImport; + form->bReadonlyMode = !FS.can_write_to_alias(_textures_); + if (form->bReadonlyMode) + { + Log("#!You don't have permisions to modify textures."); + form->ebOk->Enabled = false; + form->ebRemoveTexture->Enabled = false; + //. form->ebRebuildAssociation->Enabled = false; + form->m_ItemProps->SetReadOnly(TRUE); } - form->modif_map.clear (); - form->paFilter->Enabled = !bImport; - m_Flags.zero (); + form->modif_map.clear(); + form->paFilter->Enabled = !bImport; + m_Flags.zero(); } form->ShowModal(); UI->RedrawScene(); } + //--------------------------------------------------------------------------- -ETextureThumbnail* TfrmImageLib::FindUsedTHM(const shared_str& name) +ETextureThumbnail *TfrmImageLib::FindUsedTHM(const shared_str &name) { THMMapIt it = m_THM_Used.find(name); - if (it!=m_THM_Used.end()) - return it->second; + if (it!=m_THM_Used.end()) + return it->second; - ETextureThumbnail* thm = xr_new(name.c_str(), false); - m_THM_Used[name] = thm; + ETextureThumbnail*thm = xr_new(name.c_str(),false); + m_THM_Used[name] = thm; - if(bImportMode) + if (bImportMode) { - xr_string fn = name.c_str(); - ImageLib.UpdateFileName (fn); + xr_string fn = name.c_str(); + ImageLib.UpdateFileName(fn); if (!thm->Load(name.c_str(), _import_)) { - bool bLoad = thm->Load(fn.c_str(),_game_textures_); - ImageLib.CreateTextureThumbnail (thm, name.c_str(), _import_, !bLoad); + bool bLoad = thm->Load(fn.c_str(), _game_textures_); + ImageLib.CreateTextureThumbnail(thm, name.c_str(), _import_, !bLoad); } - }else + } + else { - thm->Load(); + thm->Load(); } return thm; } + //--------------------------------------------------------------------------- void TfrmImageLib::SaveUsedTHM() { - for(THMMapIt t_it=m_THM_Used.begin(); t_it!=m_THM_Used.end(); ++t_it) - { - if (modif_map.find(FS_File(t_it->second->SrcName()))!=modif_map.end()) - t_it->second->Save(); + for (THMMapIt t_it = m_THM_Used.begin(); t_it!=m_THM_Used.end(); ++t_it) + { + if (modif_map.find(FS_File(t_it->second->SrcName()))!=modif_map.end()) + t_it->second->Save(); } } + //--------------------------------------------------------------------------- void __fastcall TfrmImageLib::ImportTextures() { - texture_map.clear(); + texture_map.clear(); int new_cnt = ImageLib.GetLocalNewTextures(texture_map); - if (new_cnt){ - if (ELog.DlgMsg(mtInformation,"Found %d new texture(s)",new_cnt)) - EditLib(AnsiString("Update images"),true); - }else{ - ELog.DlgMsg(mtInformation,"Can't find new textures."); + if (new_cnt) + { + if (ELog.DlgMsg(mtInformation, "Found %d new texture(s)", new_cnt)) + EditLib(AnsiString("Update images"), true); + } + else + { + ELog.DlgMsg(mtInformation, "Can't find new textures."); } } void __fastcall TfrmImageLib::UpdateLib() { - VERIFY (!bReadonlyMode); - RegisterModifiedTHM (); - SaveUsedTHM (); - if (bImportMode && !texture_map.empty()) + VERIFY(!bReadonlyMode); + RegisterModifiedTHM(); + SaveUsedTHM(); + if (bImportMode&&!texture_map.empty()) { - AStringVec modif; + AStringVec modif; LockForm(); ImageLib.SafeCopyLocalToServer(texture_map); - // rename with folder - FS_FileSet files = texture_map; - texture_map.clear (); - xr_string fn; - FS_FileSetIt it = files.begin(); - FS_FileSetIt _E = files.end(); - - for (;it!=_E; it++) + // rename with folder + FS_FileSet files = texture_map; + texture_map.clear(); + xr_string fn; + FS_FileSetIt it = files.begin(); + FS_FileSetIt _E = files.end(); + + for (; it!=_E; it++) { - fn = EFS.ChangeFileExt(it->name.c_str(),""); + fn = EFS.ChangeFileExt(it->name.c_str(), ""); ImageLib.UpdateFileName(fn); - FS_File F(*it); - F.name = fn; - texture_map.insert (F); + FS_File F(*it); + F.name = fn; + texture_map.insert(F); } // sync - ImageLib.SynchronizeTextures(true,true,true,&texture_map,&modif); - UnlockForm (); - ImageLib.RefreshTextures(&modif); - }else + ImageLib.SynchronizeTextures(true, true, true, &texture_map, &modif); + UnlockForm(); + ImageLib.RefreshTextures(&modif); + } + else { - // save game textures + // save game textures if (modif_map.size()) { AStringVec modif; - LockForm(); - ImageLib.SynchronizeTextures(true,true,true,&modif_map,&modif); + LockForm(); + ImageLib.SynchronizeTextures(true, true, true, &modif_map, &modif); UnlockForm(); ImageLib.RefreshTextures(&modif); } @@ -173,182 +187,208 @@ void __fastcall TfrmImageLib::UpdateLib() bool __fastcall TfrmImageLib::HideLib() { - if (form){ - form->Close(); - texture_map.clear(); - modif_map.clear(); + if (form) + { + form->Close(); + texture_map.clear(); + modif_map.clear(); } return true; } + //--------------------------------------------------------------------------- void __fastcall TfrmImageLib::FormShow(TObject *) { - InitItemsList (); - // check window position - UI->CheckWindowPos (this); + InitItemsList(); + // check window position + UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- void __fastcall TfrmImageLib::FormClose(TObject *, TCloseAction &Action) { - if (!form) return; - form->Enabled = false; - DestroyUsedTHM (); - form = 0; - Action = caFree; + if (!form) + return; + form->Enabled = false; + DestroyUsedTHM(); + form = 0; + Action = caFree; } + //--------------------------------------------------------------------------- void fix_texture_thm_name(LPSTR fn); -#include "ResourceManager.h" +#include "Layers/xrRender/ResourceManager.h" + void TfrmImageLib::InitItemsList() { - R_ASSERT (m_THM_Used.empty()); - if(!form->bImportMode) - ImageLib.GetTexturesRaw(texture_map); -/* - FS_FileSet flist; - FS.file_list (flist,"$game_textures$",FS_ListFiles|FS_ClampExt,"*.thm"); - Msg ("TfrmImageLib::InitItemsList count of .thm files=%d", flist.size()); - FS_FileSetIt It = flist.begin(); - FS_FileSetIt It_e = flist.end(); - string256 tex_name; - for(;It!=It_e;++It) - { - shared_str sn =(*It).name.c_str(); - FindUsedTHM (sn); - } -*/ - - ListItemsVec items; - SPBItem* pb = UI->ProgressStart (texture_map.size(),"Fill list..."); + R_ASSERT(m_THM_Used.empty()); + if (!form->bImportMode) + ImageLib.GetTexturesRaw(texture_map); + /* + FS_FileSet flist; + FS.file_list (flist,"$game_textures$",FS_ListFiles|FS_ClampExt,"*.thm"); + Msg ("TfrmImageLib::InitItemsList count of .thm files=%d", flist.size()); + FS_FileSetIt It = flist.begin(); + FS_FileSetIt It_e = flist.end(); + string256 tex_name; + for(;It!=It_e;++It) + { + shared_str sn =(*It).name.c_str(); + FindUsedTHM (sn); + } + */ + + ListItemsVec items; + SPBItem*pb = UI->ProgressStart(texture_map.size(), "Fill list..."); // fill - FS_FileSetIt it = texture_map.begin(); - FS_FileSetIt _E = texture_map.end(); + FS_FileSetIt it = texture_map.begin(); + FS_FileSetIt _E = texture_map.end(); for (; it!=_E; it++) { - pb->Inc (); - ListItem* I = LHelper().CreateItem(items,it->name.c_str(),0); - I->m_Object = (void*)(FindUsedTHM(it->name.c_str())); - R_ASSERT2 (I->m_Object, it->name.c_str()); + pb->Inc(); + ListItem *I = LHelper().CreateItem(items, it->name.c_str(), 0); + I->m_Object = (void*)(FindUsedTHM(it->name.c_str())); + R_ASSERT2(I->m_Object, it->name.c_str()); } - UI->ProgressEnd (pb); - m_ItemList->AssignItems (items,false,true); + UI->ProgressEnd(pb); + m_ItemList->AssignItems(items, false, true); } - //--------------------------------------------------------------------------- -void __fastcall TfrmImageLib::FormKeyDown(TObject*, WORD &Key, - TShiftState Shift) +void __fastcall TfrmImageLib::FormKeyDown(TObject *, WORD &Key, + TShiftState Shift) { - if (Shift.Contains(ssCtrl)){ - if (Key==VK_CANCEL) ExecCommand(COMMAND_BREAK_LAST_OPERATION); - }else{ - if (Key==VK_ESCAPE){ - if (bFormLocked) ExecCommand(COMMAND_BREAK_LAST_OPERATION); + if (Shift.Contains(ssCtrl)) + { + if (Key==VK_CANCEL) + ExecCommand(COMMAND_BREAK_LAST_OPERATION); + } + else + { + if (Key==VK_ESCAPE) + { + if (bFormLocked) + ExecCommand(COMMAND_BREAK_LAST_OPERATION); Key = 0; // :-) íóæíî äëÿ òîãî ÷òîáû AccessVoilation íå âûëàçèë ïî ESCAPE } } } + //--------------------------------------------------------------------------- -void __fastcall TfrmImageLib::ebOkClick(TObject*) +void __fastcall TfrmImageLib::ebOkClick(TObject *) { - if (bFormLocked) return; + if (bFormLocked) + return; - UpdateLib (); - HideLib (); + UpdateLib(); + HideLib(); } + //--------------------------------------------------------------------------- void __fastcall TfrmImageLib::ebCancelClick(TObject *) { - if (bFormLocked){ - ExecCommand(COMMAND_BREAK_LAST_OPERATION); - return; + if (bFormLocked) + { + ExecCommand(COMMAND_BREAK_LAST_OPERATION); + return; } HideLib(); } + //--------------------------------------------------------------------------- void __fastcall TfrmImageLib::RegisterModifiedTHM() { - if (m_ItemProps->IsModified()||bImportMode) + if (m_ItemProps->IsModified()||bImportMode) { - for (THMIt t_it=m_THM_Current.begin(); t_it!=m_THM_Current.end(); ++t_it) + for (THMIt t_it = m_THM_Current.begin(); t_it!=m_THM_Current.end(); ++t_it) { - FS_FileSetIt it = texture_map.find(FS_File((*t_it)->SrcName())); - R_ASSERT (it!=texture_map.end()); - modif_map.insert (*it); + FS_FileSetIt it = texture_map.find(FS_File((*t_it)->SrcName())); + R_ASSERT(it!=texture_map.end()); + modif_map.insert(*it); } } } void __fastcall TfrmImageLib::fsStorageRestorePlacement(TObject *) -{ - m_ItemProps->RestoreParams(fsStorage); +{ + m_ItemProps->RestoreParams(fsStorage); m_ItemList->LoadParams(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfrmImageLib::fsStorageSavePlacement(TObject *) { - m_ItemProps->SaveParams(fsStorage); + m_ItemProps->SaveParams(fsStorage); m_ItemList->SaveParams(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfrmImageLib::ebRemoveTextureClick(TObject *) { - m_ItemList->RemoveSelItems(0); + m_ItemList->RemoveSelItems(0); } + //--------------------------------------------------------------------------- void TfrmImageLib::DestroyUsedTHM() { for (THMMapIt it = m_THM_Used.begin(); it!=m_THM_Used.end(); ++it) - xr_delete(it->second); + xr_delete(it->second); m_THM_Used.clear(); } -void TfrmImageLib::OnTypeChange(PropValue* ) +void TfrmImageLib::OnTypeChange(PropValue *) { - UpdateProperties(); + UpdateProperties(); } -void TfrmImageLib::OnCubeMapBtnClick(ButtonValue* value, bool& bModif, bool& ) +void TfrmImageLib::OnCubeMapBtnClick(ButtonValue *value, bool &bModif, bool &) { - ButtonValue* B = dynamic_cast(value); R_ASSERT(B); + ButtonValue *B = dynamic_cast(value); + R_ASSERT(B); bModif = false; - switch(B->btn_num){ - case 0:{ - RStringVec items; - if (0!=m_ItemList->GetSelected(items)){ - for (RStringVecIt it=items.begin(); it!=items.end(); it++){ - AnsiString new_name = AnsiString(it->c_str())+"#small"; - ImageLib.CreateSmallerCubeMap(it->c_str(),new_name.c_str()); + switch (B->btn_num) + { + case 0: + { + RStringVec items; + if (0!=m_ItemList->GetSelected(items)) + { + for (RStringVecIt it = items.begin(); it!=items.end(); it++) + { + AnsiString new_name = AnsiString(it->c_str())+"#small"; + ImageLib.CreateSmallerCubeMap(it->c_str(), new_name.c_str()); + } } } - }break; - } + break; + } } -void TfrmImageLib::OnItemsFocused(ListItemsVec& items) +void TfrmImageLib::OnItemsFocused(ListItemsVec &items) { - PropItemVec props; + PropItemVec props; + + RegisterModifiedTHM(); + m_THM_Current.clear(); - RegisterModifiedTHM (); - m_THM_Current.clear (); - - if (!items.empty()) + if (!items.empty()) { - for (ListItemsIt it=items.begin(); it!=items.end(); it++) + for (ListItemsIt it = items.begin(); it!=items.end(); it++) { - ListItem* prop = *it; - if (prop){ - ETextureThumbnail* thm=0; + ListItem *prop = *it; + if (prop) + { + ETextureThumbnail*thm = 0; thm = FindUsedTHM(prop->Key()); /* @@ -357,134 +397,142 @@ void TfrmImageLib::OnItemsFocused(ListItemsVec& items) thm = FindUsedTHM(prop->Key()); if (!thm) { - m_THM_Used.push_back (thm=xr_new(prop->Key(),false)); - xr_string fn = prop->Key(); - ImageLib.UpdateFileName (fn); + m_THM_Used.push_back (thm=xr_new(prop->Key(),false)); + xr_string fn = prop->Key(); + ImageLib.UpdateFileName (fn); - if (!thm->Load(prop->Key(),_import_)) + if (!thm->Load(prop->Key(),_import_)) { - bool bLoad = thm->Load(fn.c_str(),_game_textures_); + bool bLoad = thm->Load(fn.c_str(),_game_textures_); ImageLib.CreateTextureThumbnail (thm, prop->Key(), _import_, !bLoad); - } + } } }else { thm = FindUsedTHM(prop->Key()); if (!thm) - m_THM_Used.push_back(thm=xr_new(prop->Key())); + m_THM_Used.push_back(thm=xr_new(prop->Key())); } */ - m_THM_Current.push_back (thm); + m_THM_Current.push_back(thm); //prop->tag = thm->_Format().type; - + // fill prop - thm->FillProp (props,PropValue::TOnChange(this,&TfrmImageLib::OnTypeChange)); - - if (thm->_Format().type==STextureParams::ttCubeMap) + thm->FillProp(props, PropValue::TOnChange(this, &TfrmImageLib::OnTypeChange)); + + if (thm->_Format().type==STextureParams::ttCubeMap) { - ButtonValue* B = PHelper().CreateButton (props, "CubeMap\\Edit", "Make Small", 0); - B->OnBtnClickEvent.bind(this,&TfrmImageLib::OnCubeMapBtnClick); + ButtonValue *B = PHelper().CreateButton(props, "CubeMap\\Edit", "Make Small", 0); + B->OnBtnClickEvent.bind(this, &TfrmImageLib::OnCubeMapBtnClick); } } } } - paImage->Repaint (); + paImage->Repaint(); m_ItemProps->tvProperties->MultiSelect = true; - m_ItemProps->AssignItems (props); + m_ItemProps->AssignItems(props); } void __fastcall TfrmImageLib::btFilterClick(TObject *Sender) { - if(m_THM_Current.size()!=1 ) return; + if (m_THM_Current.size()!=1) + return; - ETextureThumbnail* thm = m_THM_Current.back(); - xr_vector sel_str_vec; - - for ( TElTreeItem* node = m_ItemProps->tvProperties->Items->GetFirstNode(); node; node = node->GetNext()) + ETextureThumbnail*thm = m_THM_Current.back(); + xr_vector sel_str_vec; + + for (TElTreeItem *node = m_ItemProps->tvProperties->Items->GetFirstNode(); node; node = node->GetNext()) { - if (node && node->Selected && node->ChildrenCount==0) + if (node&&node->Selected&&node->ChildrenCount==0) { AnsiString str = node->Text; - if(node->Parent) - str = node->Parent->Text + "\\" + str; - - sel_str_vec.push_back(str); + if (node->Parent) + str = node->Parent->Text+"\\"+str; + + sel_str_vec.push_back(str); } } - SortList(thm, sel_str_vec); + SortList(thm, sel_str_vec); } //--------------------------------------------------------------------------- void __fastcall TfrmImageLib::paImagePaint(TObject *) { - if (m_THM_Current.size()==1) m_THM_Current.back()->Draw(paImage); + if (m_THM_Current.size()==1) + m_THM_Current.back()->Draw(paImage); } + //--------------------------------------------------------------------------- void TfrmImageLib::OnFrame() { - if (form){ - if (m_Flags.is(flUpdateProperties)){ - form->m_ItemList->FireOnItemFocused(); - m_Flags.set(flUpdateProperties,FALSE); + if (form) + { + if (m_Flags.is(flUpdateProperties)) + { + form->m_ItemList->FireOnItemFocused(); + m_Flags.set(flUpdateProperties, FALSE); } } } void __fastcall TfrmImageLib::ttImageClick(TObject *Sender) { - const ListItemsVec& items = m_ItemList->GetItems(); + const ListItemsVec &items = m_ItemList->GetItems(); u32 cnt = items.size(); - for (u32 k=0; km_Object; + ETextureThumbnail*thm = (ETextureThumbnail*)I->m_Object; BOOL bVis = FALSE; - int type = thm->_Format().type; - - if (ttImage->Down && ttImage->Tag==type) - bVis = TRUE; - else if (ttCubeMap->Down && ttCubeMap->Tag==type) - bVis = TRUE; - else if (ttBumpMap->Down && ttBumpMap->Tag==type) - bVis = TRUE; - else if (ttNormalMap->Down && ttNormalMap->Tag==type) - bVis = TRUE; - else if (ttTerrain->Down && ttTerrain->Tag==type) - bVis = TRUE; - - I->Visible(bVis); + int type = thm->_Format().type; + + if (ttImage->Down&&ttImage->Tag==type) + bVis = TRUE; + else if (ttCubeMap->Down&&ttCubeMap->Tag==type) + bVis = TRUE; + else if (ttBumpMap->Down&&ttBumpMap->Tag==type) + bVis = TRUE; + else if (ttNormalMap->Down&&ttNormalMap->Tag==type) + bVis = TRUE; + else if (ttTerrain->Down&&ttTerrain->Tag==type) + bVis = TRUE; + + I->Visible(bVis); } - m_ItemList->RefreshForm (); + m_ItemList->RefreshForm(); } -void TfrmImageLib::SortList(ETextureThumbnail* thm0, xr_vector& sel_params) +void TfrmImageLib::SortList(ETextureThumbnail *thm0, xr_vector &sel_params) { - ttImageClick (NULL); - const ListItemsVec& items = m_ItemList->GetItems(); + ttImageClick(NULL); + const ListItemsVec &items = m_ItemList->GetItems(); u32 cnt = items.size(); - for (u32 k=0; kVisible()) continue; - ETextureThumbnail* thm1 = (ETextureThumbnail*)I->m_Object; - - BOOL bVis = thm0->similar(thm1, sel_params); - I->Visible (bVis); - } - m_ItemList->RefreshForm (); - m_ItemList->ExpandAll1Click (NULL); + ListItem *I = items[k]; + if (!I->Visible()) + continue; + ETextureThumbnail*thm1 = (ETextureThumbnail*)I->m_Object; + + BOOL bVis = thm0->similar(thm1, sel_params); + I->Visible(bVis); + } + m_ItemList->RefreshForm(); + m_ItemList->ExpandAll1Click(NULL); } void __fastcall TfrmImageLib::ExtBtn1Click(TObject *Sender) { - ttImageClick(Sender); - m_ItemList->CollapseAll1Click(Sender); + ttImageClick(Sender); + m_ItemList->CollapseAll1Click(Sender); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ECore/Editor/ImageEditor.h b/src/editors/ECore/Editor/ImageEditor.h index 8b37ff28871..e0a07cd9ad5 100644 --- a/src/editors/ECore/Editor/ImageEditor.h +++ b/src/editors/ECore/Editor/ImageEditor.h @@ -19,100 +19,126 @@ // refs class ETextureThumbnail; class TProperties; + //--------------------------------------------------------------------------- class TfrmImageLib : public TForm { -__published: // IDE-managed Components - TPanel *paRight; - TFormStorage *fsStorage; - TPanel *paCommand; - TExtBtn *ebOk; - TBevel *Bevel1; - TPanel *paProperties; - TPanel *paItems; - TSplitter *Splitter1; - TBevel *Bevel2; - TImageList *ImageList; - TExtBtn *ebCancel; - TExtBtn *ebRemoveTexture; - TBevel *Bevel5; - TPanel *Panel1; - TMxPanel *paImage; - TPanel *paFilter; - TExtBtn *ttImage; - TExtBtn *ttBumpMap; - TExtBtn *ttNormalMap; - TExtBtn *ttCubeMap; - TExtBtn *ttTerrain; - TPanel *Panel2; - TExtBtn *btFilter; - TExtBtn *ExtBtn1; + __published: // IDE-managed Components + TPanel*paRight; + TFormStorage *fsStorage; + TPanel *paCommand; + TExtBtn *ebOk; + TBevel *Bevel1; + TPanel *paProperties; + TPanel *paItems; + TSplitter *Splitter1; + TBevel *Bevel2; + TImageList *ImageList; + TExtBtn *ebCancel; + TExtBtn *ebRemoveTexture; + TBevel *Bevel5; + TPanel *Panel1; + TMxPanel *paImage; + TPanel *paFilter; + TExtBtn *ttImage; + TExtBtn *ttBumpMap; + TExtBtn *ttNormalMap; + TExtBtn *ttCubeMap; + TExtBtn *ttTerrain; + TPanel *Panel2; + TExtBtn *btFilter; + TExtBtn *ExtBtn1; void __fastcall ebOkClick(TObject *Sender); void __fastcall FormShow(TObject *Sender); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); - void __fastcall FormCreate(TObject *Sender); - void __fastcall ebCancelClick(TObject *Sender); - void __fastcall ebRemoveTextureClick(TObject *Sender); - void __fastcall FormDestroy(TObject *Sender); - void __fastcall paImagePaint(TObject *Sender); - void __fastcall ttImageClick(TObject *Sender); - void __fastcall btFilterClick(TObject *Sender); - void __fastcall ExtBtn1Click(TObject *Sender); + TShiftState Shift); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); + void __fastcall FormCreate(TObject *Sender); + void __fastcall ebCancelClick(TObject *Sender); + void __fastcall ebRemoveTextureClick(TObject *Sender); + void __fastcall FormDestroy(TObject *Sender); + void __fastcall paImagePaint(TObject *Sender); + void __fastcall ttImageClick(TObject *Sender); + void __fastcall btFilterClick(TObject *Sender); + void __fastcall ExtBtn1Click(TObject *Sender); private: -// list functions - void __stdcall RemoveTexture (LPCSTR fname, EItemType type, bool& res); - - void InitItemsList (); - void __stdcall OnItemsFocused (ListItemsVec& items); - - void __stdcall OnCubeMapBtnClick (ButtonValue* value, bool& bModif, bool& bSafe); - - enum{ - flUpdateProperties = (1<<0), - }; - static Flags32 m_Flags; -private: // User declarations - static TfrmImageLib* form; - - DEFINE_VECTOR (ETextureThumbnail*,THMVec,THMIt); - DEFINE_MAP (shared_str,ETextureThumbnail*,THMMap,THMMapIt); - THMMap m_THM_Used; - THMVec m_THM_Current; - TItemList* m_ItemList; - TProperties* m_ItemProps; - - ETextureThumbnail* FindUsedTHM (const shared_str& name); - void SaveUsedTHM (); - void DestroyUsedTHM (); - - void __fastcall RegisterModifiedTHM (); - - void OnModified (); - static FS_FileSet texture_map; - static FS_FileSet modif_map; - bool bImportMode; - bool bReadonlyMode; - void __fastcall UpdateLib (); - static bool bFormLocked; - static void LockForm (){ bFormLocked = true; form->paProperties->Enabled = false; form->paItems->Enabled = false; } - static void UnlockForm (){ bFormLocked = false;form->paProperties->Enabled = true; form->paItems->Enabled = true; } - - void __stdcall OnTypeChange (PropValue* prop); - void SortList (ETextureThumbnail* thm, xr_vector& sel_str_vec); -public: // User declarations - __fastcall TfrmImageLib (TComponent* Owner); -// static function - static void __fastcall ImportTextures (); - static void __fastcall EditLib (AnsiString& title, bool bImport=false); - static bool __fastcall HideLib (); - static bool __fastcall Visible (){return !!form;} - static void OnFrame (); - static void UpdateProperties (){m_Flags.set(flUpdateProperties,TRUE);} + // list functions + void __stdcall RemoveTexture(LPCSTR fname, EItemType type, bool &res); + + void InitItemsList(); + void __stdcall OnItemsFocused(ListItemsVec &items); + + void __stdcall OnCubeMapBtnClick(ButtonValue *value, bool &bModif, bool &bSafe); + + enum + { + flUpdateProperties = (1<<0), + }; + + static Flags32 m_Flags; +private: // User declarations + static TfrmImageLib *form; + + DEFINE_VECTOR(ETextureThumbnail *, THMVec, THMIt); + DEFINE_MAP(shared_str, ETextureThumbnail *, THMMap, THMMapIt); + THMMap m_THM_Used; + THMVec m_THM_Current; + TItemList *m_ItemList; + TProperties *m_ItemProps; + + ETextureThumbnail *FindUsedTHM(const shared_str &name); + void SaveUsedTHM(); + void DestroyUsedTHM(); + + void __fastcall RegisterModifiedTHM(); + + void OnModified(); + static FS_FileSet texture_map; + static FS_FileSet modif_map; + bool bImportMode; + bool bReadonlyMode; + void __fastcall UpdateLib(); + static bool bFormLocked; + + static void LockForm() + { + bFormLocked = true; + form->paProperties->Enabled = false; + form->paItems->Enabled = false; + } + + static void UnlockForm() + { + bFormLocked = false; + form->paProperties->Enabled = true; + form->paItems->Enabled = true; + } + + void __stdcall OnTypeChange(PropValue *prop); + void SortList(ETextureThumbnail *thm, xr_vector &sel_str_vec); +public: // User declarations + __fastcall TfrmImageLib(TComponent *Owner); + // static function + static void __fastcall ImportTextures(); + static void __fastcall EditLib(AnsiString &title, bool bImport = false); + static bool __fastcall HideLib(); + + static bool __fastcall Visible() + { + return !!form; + } + + static void OnFrame(); + + static void UpdateProperties() + { + m_Flags.set(flUpdateProperties, TRUE); + } }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ECore/Editor/ImageManager.cpp b/src/editors/ECore/Editor/ImageManager.cpp index c560fe73c41..0077ad31a30 100644 --- a/src/editors/ECore/Editor/ImageManager.cpp +++ b/src/editors/ECore/Editor/ImageManager.cpp @@ -7,215 +7,251 @@ #include "Image.h" #include "ui_main.h" #include "EditObject.h" -#include "ResourceManager.h" +#include "Layers/xrRender/ResourceManager.h" CImageManager ImageLib; //--------------------------------------------------------------------------- #pragma package(smart_init) extern bool IsFormatRegister(LPCSTR ext); -extern FIBITMAP* Surface_Load(char* full_name); +extern FIBITMAP *Surface_Load(char *full_name); extern "C" __declspec(dllimport) -int DXTCompress (LPCSTR out_name, u8* raw_data, u8* ext_data, u32 w, u32 h, u32 pitch, - STextureParams* options, u32 depth); +int DXTCompress(LPCSTR out_name, u8 *raw_data, u8 *ext_data, u32 w, u32 h, u32 pitch, + STextureParams *options, u32 depth); -bool IsValidSize(u32 w, u32 h){ - if (!btwIsPow2(h)) return false; - if (h*6==w) return true; - if (!btwIsPow2(w)) return false; +bool IsValidSize(u32 w, u32 h) +{ + if (!btwIsPow2(h)) + return false; + if (h*6==w) + return true; + if (!btwIsPow2(w)) + return false; return true; } -bool Surface_Load(LPCSTR full_name, U32Vec& data, u32& w, u32& h, u32& a) +bool Surface_Load(LPCSTR full_name, U32Vec &data, u32 &w, u32 &h, u32 &a) { - if (!FS.exist(full_name)){ - ELog.Msg(mtError,"Can't find file: '%s'",full_name); - return false; + if (!FS.exist(full_name)) + { + ELog.Msg(mtError, "Can't find file: '%s'", full_name); + return false; } - AnsiString ext = ExtractFileExt(full_name).LowerCase(); - if (ext==".tga"){ - CImage img; - if (!img.LoadTGA (full_name)) return false; - w = img.dwWidth; - h = img.dwHeight; - a = img.bAlpha; - data.resize (w*h); - CopyMemory (data.begin(),img.pData,sizeof(u32)*data.size()); - if (!IsValidSize(w,h)) ELog.Msg(mtError,"Texture (%s) - invalid size: [%d, %d]",full_name,w,h); + AnsiString ext = ExtractFileExt(full_name).LowerCase(); + if (ext==".tga") + { + CImage img; + if (!img.LoadTGA(full_name)) + return false; + w = img.dwWidth; + h = img.dwHeight; + a = img.bAlpha; + data.resize(w*h); + CopyMemory(data.begin(), img.pData, sizeof(u32)*data.size()); + if (!IsValidSize(w, h)) + ELog.Msg(mtError, "Texture (%s) - invalid size: [%d, %d]", full_name, w, h); return true; - }else{ - FIBITMAP* bm = Surface_Load((LPSTR)full_name); - if (bm){ - w = FreeImage_GetWidth (bm); - h = FreeImage_GetHeight(bm); - u32 w4 = w*4; - data.resize (w*h); - for (int y=h-1; y>=0; y--) CopyMemory(data.begin()+(h-y-1)*w,FreeImage_GetScanLine(bm,y),w4); - a = FIC_RGBALPHA==FreeImage_GetColorType(bm); - FreeImage_Unload (bm); - if (!IsValidSize(w,h)) ELog.Msg(mtError,"Texture (%s) - invalid size: [%d, %d]",full_name,w,h); + } + else + { + FIBITMAP *bm = Surface_Load((LPSTR)full_name); + if (bm) + { + w = FreeImage_GetWidth(bm); + h = FreeImage_GetHeight(bm); + u32 w4 = w*4; + data.resize(w*h); + for (int y = h-1; y>=0; y--) + CopyMemory(data.begin()+(h-y-1)*w, FreeImage_GetScanLine(bm, y), w4); + a = FIC_RGBALPHA==FreeImage_GetColorType(bm); + FreeImage_Unload(bm); + if (!IsValidSize(w, h)) + ELog.Msg(mtError, "Texture (%s) - invalid size: [%d, %d]", full_name, w, h); return true; } } - return false; + return false; } + //------------------------------------------------------------------------------ -xr_string CImageManager::UpdateFileName(xr_string& fn) +xr_string CImageManager::UpdateFileName(xr_string &fn) { - return EFS.AppendFolderToName(fn,1,TRUE); + return EFS.AppendFolderToName(fn, 1, TRUE); } //------------------------------------------------------------------------------ // ñîçäàåò òõì //------------------------------------------------------------------------------ -void CImageManager::MakeThumbnailImage(ETextureThumbnail* THM, u32* data, u32 w, u32 h, u32 a) +void CImageManager::MakeThumbnailImage(ETextureThumbnail *THM, u32 *data, u32 w, u32 h, u32 a) { - R_ASSERT(THM); - // create thumbnail - if (THM->m_Pixels.empty()) THM->m_Pixels.resize(THUMB_SIZE); - THM->m_TexParams.width = w; - THM->m_TexParams.height= h; - THM->m_TexParams.flags.set(STextureParams::flHasAlpha,a); - imf_Process(THM->m_Pixels.begin(),THUMB_WIDTH,THUMB_HEIGHT,data,THM->_Width(),THM->_Height(),imf_box); + R_ASSERT(THM); + // create thumbnail + if (THM->m_Pixels.empty()) + THM->m_Pixels.resize(THUMB_SIZE); + THM->m_TexParams.width = w; + THM->m_TexParams.height = h; + THM->m_TexParams.flags.set(STextureParams::flHasAlpha, a); + imf_Process(THM->m_Pixels.begin(), THUMB_WIDTH, THUMB_HEIGHT, data, THM->_Width(), THM->_Height(), imf_box); THM->VFlip(); } //------------------------------------------------------------------------------ // ñîçäàåò òõì //------------------------------------------------------------------------------ -void CImageManager::CreateTextureThumbnail(ETextureThumbnail* THM, const AnsiString& src_name, LPCSTR initial, bool bSetDefParam) +void CImageManager::CreateTextureThumbnail(ETextureThumbnail *THM, const AnsiString &src_name, LPCSTR initial, bool bSetDefParam) { - R_ASSERT(src_name.Length()); - string_path base_name; + R_ASSERT(src_name.Length()); + string_path base_name; if (initial) - FS.update_path(base_name,initial,src_name.c_str()); + FS.update_path(base_name, initial, src_name.c_str()); else - FS.update_path(base_name,_textures_,src_name.c_str()); + FS.update_path(base_name, _textures_, src_name.c_str()); U32Vec data; u32 w, h, a; - xr_string fn = EFS.ChangeFileExt(base_name,".tga"); - if (!Surface_Load(fn.c_str(),data,w,h,a)) + xr_string fn = EFS.ChangeFileExt(base_name, ".tga"); + if (!Surface_Load(fn.c_str(), data, w, h, a)) { - ELog.Msg(mtError,"Can't load texture '%s'.\nCheck file existence",fn.c_str()); - return; + ELog.Msg(mtError, "Can't load texture '%s'.\nCheck file existence", fn.c_str()); + return; } - MakeThumbnailImage(THM,data.begin(),w,h,a); + MakeThumbnailImage(THM, data.begin(), w, h, a); // âûñòàâèòü íà÷àëüíûå ïàðàìåòðû - if (bSetDefParam){ - THM->m_Age = FS.get_file_age(fn.c_str()); - THM->m_TexParams.fmt = (a)?STextureParams::tfDXT3:STextureParams::tfDXT1; - if ((h*6)==w){ - THM->m_TexParams.type = STextureParams::ttCubeMap; - THM->m_TexParams.flags.set (STextureParams::flGenerateMipMaps,FALSE); + if (bSetDefParam) + { + THM->m_Age = FS.get_file_age(fn.c_str()); + THM->m_TexParams.fmt = (a) ? STextureParams::tfDXT3 : STextureParams::tfDXT1; + if ((h*6)==w) + { + THM->m_TexParams.type = STextureParams::ttCubeMap; + THM->m_TexParams.flags.set(STextureParams::flGenerateMipMaps, FALSE); } } THM->SetValid(); } + //------------------------------------------------------------------------------ // ñîçäàåò íîâóþ òåêñòóðó //------------------------------------------------------------------------------ -void CImageManager::CreateGameTexture(LPCSTR src_name, ETextureThumbnail* thumb) +void CImageManager::CreateGameTexture(LPCSTR src_name, ETextureThumbnail *thumb) { - R_ASSERT(src_name&&src_name[0]); - ETextureThumbnail* THM = thumb?thumb:xr_new(src_name); - string_path base_name; - strcpy (base_name,src_name); + R_ASSERT(src_name&&src_name[0]); + ETextureThumbnail *THM = thumb ? thumb : xr_new(src_name); + string_path base_name; + strcpy(base_name, src_name); - string_path game_name; - strcpy (game_name,EFS.ChangeFileExt(src_name,".dds").c_str()); - FS.update_path (base_name,_textures_,base_name); - FS.update_path (game_name,_game_textures_,game_name); - int base_age = FS.get_file_age(base_name); + string_path game_name; + strcpy(game_name, EFS.ChangeFileExt(src_name, ".dds").c_str()); + FS.update_path(base_name, _textures_, base_name); + FS.update_path(game_name, _game_textures_, game_name); + int base_age = FS.get_file_age(base_name); U32Vec data; u32 w, h, a; - if (!Surface_Load(base_name,data,w,h,a)) return; - MakeGameTexture(THM,game_name,data.begin()); + if (!Surface_Load(base_name, data, w, h, a)) + return; + MakeGameTexture(THM, game_name, data.begin()); FS.set_file_age(game_name, base_age); - if (!thumb) xr_delete(THM); + if (!thumb) + xr_delete(THM); } //------------------------------------------------------------------------------ // ñîçäàåò èãðîâóþ òåêñòóðó //------------------------------------------------------------------------------ -bool CImageManager::MakeGameTexture(LPCSTR game_name, u32* data, const STextureParams& tp) +bool CImageManager::MakeGameTexture(LPCSTR game_name, u32 *data, const STextureParams &tp) { - VerifyPath(game_name); + VerifyPath(game_name); // fill texture params - // compress - u32 w4= tp.width*4; - int res = DXTCompress(game_name, (u8*)data, 0, tp.width, tp.height, w4, (STextureParams*)&tp, 4); - if (1!=res){ - FS.file_delete(game_name); - switch(res){ - case 0: ELog.DlgMsg (mtError,"Can't make game texture '%s'.",game_name); break; - case -1000: ELog.Msg (mtError,"Invalid gloss mask '%s'.",game_name); return true; + // compress + u32 w4 = tp.width*4; + int res = DXTCompress(game_name, (u8*)data, 0, tp.width, tp.height, w4, (STextureParams*)&tp, 4); + if (1!=res) + { + FS.file_delete(game_name); + switch (res) + { + case 0: ELog.DlgMsg(mtError, "Can't make game texture '%s'.", game_name); + break; + case -1000: ELog.Msg(mtError, "Invalid gloss mask '%s'.", game_name); + return true; } - return false; + return false; } R_ASSERT((res==1)&&FS.file_length(game_name)); return res==1; } -bool CImageManager::MakeGameTexture(ETextureThumbnail* THM, LPCSTR game_name, u32* load_data) + +bool CImageManager::MakeGameTexture(ETextureThumbnail *THM, LPCSTR game_name, u32 *load_data) { - VerifyPath(game_name); + VerifyPath(game_name); // flip u32 w = THM->_Width(); u32 h = THM->_Height(); - u32 w4= w*4; - // remove old - FS.file_delete (game_name); - AnsiString game_name2 = ChangeFileExt(game_name,"#.dds"); - FS.file_delete (game_name2.c_str()); + u32 w4 = w*4; + // remove old + FS.file_delete(game_name); + AnsiString game_name2 = ChangeFileExt(game_name, "#.dds"); + FS.file_delete(game_name2.c_str()); - U32Vec ext_data; + U32Vec ext_data; if ((THM->m_TexParams.type==STextureParams::ttBumpMap)&&(THM->m_TexParams.ext_normal_map_name.size())) { - bool e_res = true; - LPCSTR e_name = THM->m_TexParams.ext_normal_map_name.c_str(); - ETextureThumbnail* NM_THM = xr_new(e_name); + bool e_res = true; + LPCSTR e_name = THM->m_TexParams.ext_normal_map_name.c_str(); + ETextureThumbnail *NM_THM = xr_new(e_name); if (NM_THM->_Format().type==STextureParams::ttNormalMap) { - if (NM_THM->_Format().fmt==STextureParams::tfRGBA) + if (NM_THM->_Format().fmt==STextureParams::tfRGBA) { - u32 _w,_h; - if (!LoadTextureData(e_name,ext_data,_w,_h)) + u32 _w, _h; + if (!LoadTextureData(e_name, ext_data, _w, _h)) { - ELog.DlgMsg (mtError,"Can't load special normal map texture '%s'.",e_name); - e_res = false; - }else if ((_w!=w)||(_h!=h)) + ELog.DlgMsg(mtError, "Can't load special normal map texture '%s'.", e_name); + e_res = false; + } + else if ((_w!=w)||(_h!=h)) { - ELog.DlgMsg (mtError,"Invalid load special normal map size '%s'. It should be [%dx%d]",e_name,w,h); - e_res = false; + ELog.DlgMsg(mtError, "Invalid load special normal map size '%s'. It should be [%dx%d]", e_name, w, h); + e_res = false; } - }else{ - ELog.DlgMsg (mtError,"Invalid special normal map format '%s'. It should be '32 bit (8:8:8:8)'",e_name); - e_res = false; } - }else{ - ELog.DlgMsg (mtError,"Invalid special normal map type '%s'. It should be 'NormalMap'",e_name); - e_res = false; + else + { + ELog.DlgMsg(mtError, "Invalid special normal map format '%s'. It should be '32 bit (8:8:8:8)'", e_name); + e_res = false; + } + } + else + { + ELog.DlgMsg(mtError, "Invalid special normal map type '%s'. It should be 'NormalMap'", e_name); + e_res = false; } - xr_delete (NM_THM); - if (false==e_res) return false; + xr_delete(NM_THM); + if (false==e_res) + return false; } // compress - - int res = DXTCompress(game_name, (u8*)load_data, (u8*)(ext_data.empty()?0:ext_data.begin()), w, h, w4, &THM->m_TexParams, 4); - if (1!=res){ - if (-1000!=res){ //. Special for Oles (glos<10%) - FS.file_delete (game_name); - FS.file_delete (game_name2.c_str()); + + int res = DXTCompress(game_name, (u8*)load_data, (u8*)(ext_data.empty() ? 0 : ext_data.begin()), w, h, w4, &THM->m_TexParams, 4); + if (1!=res) + { + if (-1000!=res) + { //. Special for Oles (glos<10%) + FS.file_delete(game_name); + FS.file_delete(game_name2.c_str()); } - switch(res){ - case 0: ELog.DlgMsg (mtError,"Can't make game texture '%s'.",THM->m_SrcName.c_str()); break; - case -1000: ELog.Msg (mtError,"Invalid gloss mask '%s'.",THM->m_SrcName.c_str()); return true; + switch (res) + { + case 0: ELog.DlgMsg(mtError, "Can't make game texture '%s'.", THM->m_SrcName.c_str()); + break; + case -1000: ELog.Msg(mtError, "Invalid gloss mask '%s'.", THM->m_SrcName.c_str()); + return true; } - return false; + return false; } R_ASSERT((res==1)&&FS.file_length(game_name)); return res==1; @@ -224,14 +260,16 @@ bool CImageManager::MakeGameTexture(ETextureThumbnail* THM, LPCSTR game_name, u3 //------------------------------------------------------------------------------ // çàãðóæàåò 32-bit äàííûå //------------------------------------------------------------------------------ -bool CImageManager::LoadTextureData(LPCSTR src_name, U32Vec& data, u32& w, u32& h, int* age) +bool CImageManager::LoadTextureData(LPCSTR src_name, U32Vec &data, u32 &w, u32 &h, int *age) { - string_path fn; -//. FS.update_path (fn,_textures_,ChangeFileExt(src_name,".tga").c_str()); - FS.update_path (fn,_game_textures_,ChangeFileExt(src_name,".dds").c_str()); + string_path fn; + //. FS.update_path (fn,_textures_,ChangeFileExt(src_name,".tga").c_str()); + FS.update_path(fn, _game_textures_, ChangeFileExt(src_name, ".dds").c_str()); u32 a; - if (!Surface_Load(fn,data,w,h,a)) return false; - if (age) *age = FS.get_file_age(fn); + if (!Surface_Load(fn, data, w, h, a)) + return false; + if (age) + *age = FS.get_file_age(fn); return true; } @@ -239,156 +277,193 @@ bool CImageManager::LoadTextureData(LPCSTR src_name, U32Vec& data, u32& w, u32& // êîïèðóåò îáíîâëåííûå òåêñòóðû ñ Import'a â Textures // files - ñïèñîê ôàéëîâ äëÿ êîïèðîâàíèå //------------------------------------------------------------------------------ -void CImageManager::SafeCopyLocalToServer(FS_FileSet& files) +void CImageManager::SafeCopyLocalToServer(FS_FileSet &files) { - string_path p_import, p_textures; - string_path src_name, dest_name; - FS.update_path (p_import,_import_,""); - FS.update_path (p_textures,_textures_,""); - - FS_FileSetIt it = files.begin(); - FS_FileSetIt _E = files.end(); - for (; it!=_E; it++){ - xr_string fn; - - // copy sources - fn = it->name; - strconcat (sizeof(src_name),src_name, p_import, fn.c_str()); - UpdateFileName (fn); - - strconcat(sizeof(dest_name),dest_name, p_textures, EFS.ChangeFileExt(fn,".tga").c_str() ); - - if (0==strcmp(strext(src_name),".tga")){ - FS.file_copy(src_name,dest_name); - }else{ - // convert to TGA + string_path p_import, p_textures; + string_path src_name, dest_name; + FS.update_path(p_import, _import_, ""); + FS.update_path(p_textures, _textures_, ""); + + FS_FileSetIt it = files.begin(); + FS_FileSetIt _E = files.end(); + for (; it!=_E; it++) + { + xr_string fn; + + // copy sources + fn = it->name; + strconcat(sizeof(src_name), src_name, p_import, fn.c_str()); + UpdateFileName(fn); + + strconcat(sizeof(dest_name), dest_name, p_textures, EFS.ChangeFileExt(fn, ".tga").c_str()); + + if (0==strcmp(strext(src_name), ".tga")) + { + FS.file_copy(src_name, dest_name); + } + else + { + // convert to TGA U32Vec data; - u32 w,h,a; - R_ASSERT (Surface_Load(src_name,data,w,h,a)); - CImage* I = xr_new(); - I->Create (w,h,data.begin()); - I->Vflip (); - I->SaveTGA (dest_name); - xr_delete (I); + u32 w, h, a; + R_ASSERT(Surface_Load(src_name, data, w, h, a)); + CImage *I = xr_new(); + I->Create(w, h, data.begin()); + I->Vflip(); + I->SaveTGA(dest_name); + xr_delete(I); } - FS.set_file_age (dest_name, FS.get_file_age(src_name)); - EFS.MarkFile (src_name,true); + FS.set_file_age(dest_name, FS.get_file_age(src_name)); + EFS.MarkFile(src_name, true); } -} +} + //------------------------------------------------------------------------------ // âîçâðàùàåò ñïèñîê íå ñèíõðîíèçèðîâàííûõ (ìîäèôèöèðîâàííûõ) òåêñòóð // source_list - ñîäåðæèò ñïèñîê òåêñòóð ñ ðàñøèðåíèÿìè // sync_list - ðåàëüíî ñîõðàíåííûå ôàéëû (ïîñëå èñïîëüçîâàíèÿ îñâîáîäèòü) //------------------------------------------------------------------------------ -void CImageManager::SynchronizeTextures(bool sync_thm, bool sync_game, bool bForceGame, FS_FileSet* source_list, AStringVec* sync_list, FS_FileSet* modif_map, bool bForceBaseAge) -{ +void CImageManager::SynchronizeTextures(bool sync_thm, bool sync_game, bool bForceGame, FS_FileSet *source_list, AStringVec *sync_list, FS_FileSet *modif_map, bool bForceBaseAge) +{ FS_FileSet M_BASE; FS_FileSet M_THUM; FS_FileSet M_GAME; - if (source_list) M_BASE = *source_list; - else FS.file_list(M_BASE,_textures_,FS_ListFiles|FS_ClampExt,"*.tga"); - if (M_BASE.empty()) return; - if (sync_thm) FS.file_list(M_THUM,_textures_,FS_ListFiles|FS_ClampExt,"*.thm"); - if (sync_game) FS.file_list(M_GAME,_game_textures_,FS_ListFiles|FS_ClampExt,"*.dds"); + if (source_list) + M_BASE = *source_list; + else + FS.file_list(M_BASE, _textures_, FS_ListFiles|FS_ClampExt, "*.tga"); + if (M_BASE.empty()) + return; + if (sync_thm) + FS.file_list(M_THUM, _textures_, FS_ListFiles|FS_ClampExt, "*.thm"); + if (sync_game) + FS.file_list(M_GAME, _game_textures_, FS_ListFiles|FS_ClampExt, "*.dds"); + + bool bProgress = M_BASE.size()>1; - bool bProgress = M_BASE.size()>1; - // lock rescanning - int m_age = time(NULL); + int m_age = time(NULL); // sync assoc - SPBItem* pb=0; - if (bProgress) pb = UI->ProgressStart(M_BASE.size(),"Synchronize textures..."); - FS_FileSetIt it=M_BASE.begin(); - FS_FileSetIt _E = M_BASE.end(); - for (; it!=_E; it++){ - U32Vec data; - u32 w, h, a; - - xr_string base_name = EFS.ChangeFileExt(it->name,""); xr_strlwr(base_name); - string_path fn; - FS.update_path (fn,_textures_,EFS.ChangeFileExt(base_name,".tga").c_str()); - if (!FS.exist(fn)) continue; - - FS_FileSetIt th = M_THUM.find(base_name); - bool bThm = ((th==M_THUM.end()) || ((th!=M_THUM.end())&&(th->time_write!=it->time_write))); - FS_FileSetIt gm = M_GAME.find(base_name); - bool bGame= bThm || ((gm==M_GAME.end()) || ((gm!=M_GAME.end())&&(gm->time_write!=it->time_write))); - - ETextureThumbnail* THM=0; - - BOOL bUpdated = FALSE; - BOOL bFailed = FALSE; - // check thumbnail - if (sync_thm&&bThm){ - THM = xr_new(it->name.c_str()); - bool bRes = Surface_Load(fn,data,w,h,a); R_ASSERT(bRes); -//. MakeThumbnailImage(THM,data.begin(),w,h,a); - THM->Save (it->time_write); + SPBItem*pb = 0; + if (bProgress) + pb = UI->ProgressStart(M_BASE.size(), "Synchronize textures..."); + FS_FileSetIt it = M_BASE.begin(); + FS_FileSetIt _E = M_BASE.end(); + for (; it!=_E; it++) + { + U32Vec data; + u32 w, h, a; + + xr_string base_name = EFS.ChangeFileExt(it->name, ""); + xr_strlwr(base_name); + string_path fn; + FS.update_path(fn, _textures_, EFS.ChangeFileExt(base_name, ".tga").c_str()); + if (!FS.exist(fn)) + continue; + + FS_FileSetIt th = M_THUM.find(base_name); + bool bThm = ((th==M_THUM.end())||((th!=M_THUM.end())&&(th->time_write!=it->time_write))); + FS_FileSetIt gm = M_GAME.find(base_name); + bool bGame = bThm||((gm==M_GAME.end())||((gm!=M_GAME.end())&&(gm->time_write!=it->time_write))); + + ETextureThumbnail *THM = 0; + + BOOL bUpdated = FALSE; + BOOL bFailed = FALSE; + // check thumbnail + if (sync_thm&&bThm) + { + THM = xr_new(it->name.c_str()); + bool bRes = Surface_Load(fn, data, w, h, a); + R_ASSERT(bRes); + //. MakeThumbnailImage(THM,data.begin(),w,h,a); + THM->Save(it->time_write); bUpdated = TRUE; } // check game textures - if (bForceGame||(sync_game&&bGame)){ - if (!THM) THM = xr_new(it->name.c_str()); + if (bForceGame||(sync_game&&bGame)) + { + if (!THM) + THM = xr_new(it->name.c_str()); R_ASSERT(THM); - if (data.empty()){ bool bRes = Surface_Load(fn,data,w,h,a); R_ASSERT(bRes);} - if (IsValidSize(w,h)){ - string_path game_name; - strconcat (sizeof(game_name), game_name, base_name.c_str(), ".dds"); + if (data.empty()) + { + bool bRes = Surface_Load(fn, data, w, h, a); + R_ASSERT(bRes); + } + if (IsValidSize(w, h)) + { + string_path game_name; + strconcat(sizeof(game_name), game_name, base_name.c_str(), ".dds"); - FS.update_path (game_name,_game_textures_,game_name); - if (MakeGameTexture(THM,game_name,data.begin())) + FS.update_path(game_name, _game_textures_, game_name); + if (MakeGameTexture(THM, game_name, data.begin())) { - if (sync_list) sync_list->push_back(base_name.c_str()); - if (modif_map) modif_map->insert(*it); - }else{ - bFailed = TRUE; + if (sync_list) + sync_list->push_back(base_name.c_str()); + if (modif_map) + modif_map->insert(*it); } - bUpdated = TRUE; - }else{ - ELog.DlgMsg(mtError,"Can't make game texture '%s'.\nInvalid size (%dx%d).",base_name.c_str(),w,h); + else + { + bFailed = TRUE; + } + bUpdated = TRUE; } - } - if (THM) xr_delete(THM); - if (UI->NeedAbort()) break; - - if (bProgress) - pb->Inc(bUpdated?xr_string(base_name+(bFailed?" - FAILED":" - UPDATED.")).c_str():base_name.c_str(),bUpdated); - - if (bUpdated){ - string_path tga_fn,thm_fn,dds_fn; - FS.update_path (tga_fn,_textures_, EFS.ChangeFileExt(base_name,".tga").c_str()); - FS.update_path (thm_fn,_game_textures_, EFS.ChangeFileExt(base_name,".thm").c_str()); - FS.update_path (dds_fn,_game_textures_, EFS.ChangeFileExt(base_name,".dds").c_str()); - if (bForceBaseAge){ - int age = it->time_write; - FS.set_file_age (tga_fn,age); - FS.set_file_age (thm_fn,age); - FS.set_file_age (dds_fn,age); - }else{ - FS.set_file_age (tga_fn,m_age); - FS.set_file_age (thm_fn,m_age); - FS.set_file_age (dds_fn,m_age); + else + { + ELog.DlgMsg(mtError, "Can't make game texture '%s'.\nInvalid size (%dx%d).", base_name.c_str(), w, h); + } + } + if (THM) + xr_delete(THM); + if (UI->NeedAbort()) + break; + + if (bProgress) + pb->Inc(bUpdated ? xr_string(base_name+(bFailed ? " - FAILED" : " - UPDATED.")).c_str() : base_name.c_str(), bUpdated); + + if (bUpdated) + { + string_path tga_fn, thm_fn, dds_fn; + FS.update_path(tga_fn, _textures_, EFS.ChangeFileExt(base_name, ".tga").c_str()); + FS.update_path(thm_fn, _game_textures_, EFS.ChangeFileExt(base_name, ".thm").c_str()); + FS.update_path(dds_fn, _game_textures_, EFS.ChangeFileExt(base_name, ".dds").c_str()); + if (bForceBaseAge) + { + int age = it->time_write; + FS.set_file_age(tga_fn, age); + FS.set_file_age(thm_fn, age); + FS.set_file_age(dds_fn, age); + } + else + { + FS.set_file_age(tga_fn, m_age); + FS.set_file_age(thm_fn, m_age); + FS.set_file_age(dds_fn, m_age); } } } - if (bProgress) UI->ProgressEnd(pb); + if (bProgress) + UI->ProgressEnd(pb); } + /* void CImageManager::ChangeFileAgeTo(FS_FileSet* tgt_map, int age) { - VERIFY(tgt_map); - FS_FileSet* M_BASE = tgt_map; + VERIFY(tgt_map); + FS_FileSet* M_BASE = tgt_map; // lock rescanning FS.lock_rescan (); // change - SPBItem* pb=0; + SPBItem* pb=0; if (M_BASE->size()>1) pb = UI->ProgressStart(M_BASE->size(),"Change textures age..."); FS_FileSetIt it = M_BASE->begin(); - FS_FileSetIt _E = M_BASE->end(); - for (; it!=_E; it++){ + FS_FileSetIt _E = M_BASE->end(); + for (; it!=_E; it++){ xr_string base_name = EFS.ChangeFileExt(it->name,""); xr_strlwr(base_name); xr_string tga_fn,thm_fn,dds_fn; FS.update_path (tga_fn,_textures_, EFS.ChangeFileExt(base_name,".tga").c_str()); @@ -404,164 +479,188 @@ void CImageManager::ChangeFileAgeTo(FS_FileSet* tgt_map, int age) FS.unlock_rescan (); } */ -void CImageManager::WriteAssociation(CInifile* ltx_ini, LPCSTR base_name, const STextureParams& fmt) +void CImageManager::WriteAssociation(CInifile *ltx_ini, LPCSTR base_name, const STextureParams &fmt) { - ltx_ini->w_u32 ("types", base_name,fmt.type); + ltx_ini->w_u32("types", base_name, fmt.type); } void CImageManager::SynchronizeTexture(LPCSTR tex_name, int age) { AStringVec modif; FS_FileSet t_map; - FS_File F(tex_name); F.time_write = age; - t_map.insert (F); - SynchronizeTextures (true,true,true,&t_map,&modif,0,age); - RefreshTextures (&modif); + FS_File F(tex_name); + F.time_write = age; + t_map.insert(F); + SynchronizeTextures(true, true, true, &t_map, &modif, 0, age); + RefreshTextures(&modif); } + //------------------------------------------------------------------------------ // âîçâðàùàåò ñïèñîê âñåõ òåêñòóð //------------------------------------------------------------------------------ -int CImageManager::GetTextures(FS_FileSet& files, BOOL bFolders) -{ - return FS.file_list(files,_game_textures_,(bFolders?FS_ListFolders:0)|FS_ListFiles|FS_ClampExt,"*.dds"); +int CImageManager::GetTextures(FS_FileSet &files, BOOL bFolders) +{ + return FS.file_list(files, _game_textures_, (bFolders ? FS_ListFolders : 0)|FS_ListFiles|FS_ClampExt, "*.dds"); } -int CImageManager::GetTexturesRaw(FS_FileSet& files, BOOL bFolders) +int CImageManager::GetTexturesRaw(FS_FileSet &files, BOOL bFolders) { - return FS.file_list(files,_textures_,(bFolders?FS_ListFolders:0)|FS_ListFiles|FS_ClampExt,"*.tga"); + return FS.file_list(files, _textures_, (bFolders ? FS_ListFolders : 0)|FS_ListFiles|FS_ClampExt, "*.tga"); } + //------------------------------------------------------------------------------ // âîçâðàùàåò ñïèñîê òåêñòóð, êîòîðûå íóæíî îáíîâèòü //------------------------------------------------------------------------------ -int CImageManager::GetLocalNewTextures(FS_FileSet& files) +int CImageManager::GetLocalNewTextures(FS_FileSet &files) { - return FS.file_list(files,_import_,FS_ListFiles|FS_RootOnly,"*.tga,*.bmp"); + return FS.file_list(files, _import_, FS_ListFiles|FS_RootOnly, "*.tga,*.bmp"); } + //------------------------------------------------------------------------------ // ïðîâåðÿåò ñîîòâåòñòâèå ðàçìåðà òåêñòóð // input: ñïèñîê ôàéëîâ äëÿ òåñòèðîâàíèÿ // output: ñîîòâåòñòâèå //------------------------------------------------------------------------------ #define SQR(a) ((a)*(a)) -BOOL CImageManager::CheckCompliance(LPCSTR fname, int& compl) + +BOOL CImageManager::CheckCompliance(LPCSTR fname, int &compl) { - compl = 0; + compl = 0; U32Vec data; u32 w, h, a; - if (!Surface_Load(fname,data,w,h,a)) return FALSE; - if ((1==w) || (1==h)) return TRUE; + if (!Surface_Load(fname, data, w, h, a)) + return FALSE; + if ((1==w)||(1==h)) + return TRUE; - u32 w_2 = (1==w)?w:w/2; - u32 h_2 = (1==h)?h:h/2; + u32 w_2 = (1==w) ? w : w/2; + u32 h_2 = (1==h) ? h : h/2; // scale down(lanczos3) and up (bilinear, as video board) - u32* pScaled = (u32*)(xr_malloc((w_2)*(h_2)*4)); - u32* pRestored = (u32*)(xr_malloc(w*h*4)); - try { - imf_Process (pScaled, w_2,h_2,data.begin(),w,h,imf_lanczos3 ); - imf_Process (pRestored, w,h,pScaled,w_2,h_2,imf_filter ); + u32 *pScaled = (u32*)(xr_malloc((w_2)*(h_2)*4)); + u32 *pRestored = (u32*)(xr_malloc(w*h*4)); + try + { + imf_Process(pScaled, w_2, h_2, data.begin(), w, h, imf_lanczos3); + imf_Process(pRestored, w, h, pScaled, w_2, h_2, imf_filter); } catch (...) { - Msg ("* ERROR: imf_Process"); - xr_free (pScaled); - xr_free (pRestored); - return FALSE; + Msg("* ERROR: imf_Process"); + xr_free(pScaled); + xr_free(pRestored); + return FALSE; } // Analyze - float difference = 0; - float maximal = 0; - for (u32 p=0; pProgressStart(files.size(),"Check texture compliance: "); - FS_FileSetIt it = files.begin(); - FS_FileSetIt _E = files.end(); - for (; it!=_E; it++){ - int val = 0; - string_path fname; - FS.update_path (fname,_textures_,it->name.c_str()); - if (!CheckCompliance(fname,val)) - ELog.Msg(mtError,"Bad texture: '%s'",it->name.c_str()); - FS_File F(*it); F.attrib = val; - compl.insert (F); - pb->Inc (); - if (UI->NeedAbort()) break; + SPBItem*pb = UI->ProgressStart(files.size(), "Check texture compliance: "); + FS_FileSetIt it = files.begin(); + FS_FileSetIt _E = files.end(); + for (; it!=_E; it++) + { + int val = 0; + string_path fname; + FS.update_path(fname, _textures_, it->name.c_str()); + if (!CheckCompliance(fname, val)) + ELog.Msg(mtError, "Bad texture: '%s'", it->name.c_str()); + FS_File F(*it); + F.attrib = val; + compl.insert(F); + pb->Inc(); + if (UI->NeedAbort()) + break; } - UI->ProgressEnd(pb); + UI->ProgressEnd(pb); } -IC void GET(U32Vec& pixels, u32 w, u32 h, u32 x, u32 y, u32 ref, u32 &count, u32 &r, u32 &g, u32 &b) +IC + +void GET(U32Vec &pixels, u32 w, u32 h, u32 x, u32 y, u32 ref, u32 &count, u32 &r, u32 &g, u32 &b) { // wrap pixels - if (x>=w) return; - if (y>=h) return; + if (x>=w) + return; + if (y>=h) + return; // summarize - u32 pixel = pixels[y*w + x]; - if (color_get_A(pixel)<=ref) return; + u32 pixel = pixels[y*w+x]; + if (color_get_A(pixel)<=ref) + return; - r+=color_get_R (pixel); - g+=color_get_G (pixel); - b+=color_get_B (pixel); + r += color_get_R(pixel); + g += color_get_G(pixel); + b += color_get_B(pixel); count++; } -BOOL _ApplyBorders(U32Vec& pixels, u32 w, u32 h, u32 ref) +BOOL _ApplyBorders(U32Vec &pixels, u32 w, u32 h, u32 ref) { - BOOL bNeedContinue = FALSE; + BOOL bNeedContinue = FALSE; - try { + try + { U32Vec result; result.resize(w*h); - CopyMemory(result.begin(),pixels.begin(),w*h*4); - for (u32 y=0; y200)?subst_alpha(*it,0xFF):subst_alpha(*it,0x00); - for (u32 ref=254; ref>0; ref--) - _ApplyBorders(tgt_data,w,h,ref); - for (int t=0; t200) ? subst_alpha(*it, 0xFF) : subst_alpha(*it, 0x00); + for (u32 ref = 254; ref>0; ref--) + _ApplyBorders(tgt_data, w, h, ref); + for (int t = 0; tGetFaceCount(),obj->GetVertexCount()); + psDeviceFlags.set(rsStatistic|rsDrawGrid, FALSE); + // u32 cc = EPrefs.scene_clear_color; + // EPrefs.scene_clear_color = 0x00333333; + + U32Vec pixels; + u32 w = 512, h = 512; + if (EDevice.MakeScreenshot(pixels, w, h)) + { + EObjectThumbnail tex(tex_name, false); + tex.CreateFromData(pixels.begin(), w, h, obj->GetFaceCount(), obj->GetVertexCount()); tex.Save(age); - }else{ - bResult = FALSE; - ELog.DlgMsg(mtError,"Can't make screenshot."); + } + else + { + bResult = FALSE; + ELog.DlgMsg(mtError, "Can't make screenshot."); } // restore render params - psDeviceFlags = old_flag; -// EPrefs.scene_clear_color = cc; + psDeviceFlags = old_flag; + // EPrefs.scene_clear_color = cc; return bResult; } -void CImageManager::RemoveTexture(LPCSTR fname, EItemType type, bool& res) +void CImageManager::RemoveTexture(LPCSTR fname, EItemType type, bool &res) { - if (TYPE_FOLDER==type){ - FS.dir_delete (_textures_,fname,FALSE); - FS.dir_delete (_game_textures_,fname,FALSE); - res = true; + if (TYPE_FOLDER==type) + { + FS.dir_delete(_textures_, fname, FALSE); + FS.dir_delete(_game_textures_, fname, FALSE); + res = true; return; - }else if (TYPE_OBJECT==type) + } + else if (TYPE_OBJECT==type) { xr_string src_name; - src_name = EFS.ChangeFileExt(fname,".tga"); - if (FS.exist(_textures_,src_name.c_str())) + src_name = EFS.ChangeFileExt(fname, ".tga"); + if (FS.exist(_textures_, src_name.c_str())) { - xr_string base_name= EFS.ChangeFileExt(fname,""); - xr_string thm_name = EFS.ChangeFileExt(fname,".thm"); - xr_string game_name= EFS.ChangeFileExt(fname,".dds"); - xr_string game_name2=EFS.ChangeFileExt(fname,"#.dds"); + xr_string base_name = EFS.ChangeFileExt(fname, ""); + xr_string thm_name = EFS.ChangeFileExt(fname, ".thm"); + xr_string game_name = EFS.ChangeFileExt(fname, ".dds"); + xr_string game_name2 = EFS.ChangeFileExt(fname, "#.dds"); // source - FS.file_delete (_textures_,src_name.c_str()); + FS.file_delete(_textures_, src_name.c_str()); // thumbnail - FS.file_delete (_textures_,thm_name.c_str()); + FS.file_delete(_textures_, thm_name.c_str()); // game - FS.file_delete (_game_textures_,game_name.c_str()); + FS.file_delete(_game_textures_, game_name.c_str()); // game 2 - FS.file_delete (_game_textures_,game_name2.c_str()); + FS.file_delete(_game_textures_, game_name2.c_str()); return; } } - res = false; + res = false; } -EImageThumbnail* CImageManager::CreateThumbnail(LPCSTR src_name, ECustomThumbnail::THMType type, bool bLoad) +EImageThumbnail *CImageManager::CreateThumbnail(LPCSTR src_name, ECustomThumbnail::THMType type, bool bLoad) { - switch (type){ - case ECustomThumbnail::ETObject: return xr_new (src_name,bLoad); - case ECustomThumbnail::ETTexture: return xr_new(src_name,bLoad); - default: NODEFAULT; + switch (type) + { + case ECustomThumbnail::ETObject: return xr_new(src_name, bLoad); + case ECustomThumbnail::ETTexture: return xr_new(src_name, bLoad); + default: NODEFAULT; } return 0; } @@ -652,68 +757,79 @@ EImageThumbnail* CImageManager::CreateThumbnail(LPCSTR src_name, ECustomThumbnai // åñëè ïåðåäàí ïàðàìåòð modif - îáíîâëÿåì DX-Surface only è òîëüêî èç ñïèñêà // èíà÷å ïîëíàÿ ñèíõðîíèçàöèÿ //------------------------------------------------------------------------------ -void CImageManager::RefreshTextures(AStringVec* modif) +void CImageManager::RefreshTextures(AStringVec *modif) { - if (FS.can_write_to_alias(_textures_)){ - if (modif) EDevice.Resources->ED_UpdateTextures(modif); - else{ + if (FS.can_write_to_alias(_textures_)) + { + if (modif) + EDevice.Resources->ED_UpdateTextures(modif); + else + { UI->SetStatus("Refresh textures..."); AStringVec modif_files; - ImageLib.SynchronizeTextures(true,true,false,0,&modif_files); + ImageLib.SynchronizeTextures(true, true, false, 0, &modif_files); EDevice.Resources->ED_UpdateTextures(&modif_files); UI->SetStatus(""); } - }else{ + } + else + { Log("#!You don't have permisions to modify textures."); } } -void __stdcall pb_callback(void* data, float& v) +void __stdcall pb_callback(void *data, float &v) { - SPBItem* PB = (SPBItem*)(data); - PB->Update(v); + SPBItem*PB = (SPBItem*)(data); + PB->Update(v); } -#include "ETools.h" +#include "utils/ETools/ETools.h" + BOOL CImageManager::CreateSmallerCubeMap(LPCSTR src_name, LPCSTR dst_name) { U32Vec data; u32 w, wf, h, a; - string_path full_name; - FS.update_path (full_name,_textures_,src_name); - strcat (full_name,".tga"); - - if (Surface_Load(full_name,data,wf,h,a)){ - w = wf/6; - u32 sm_w=32, sm_wf=6*sm_w, sm_h=32; - if (!btwIsPow2(h)||(h*6!=wf)||(wfProgressStart(1.f,"Cube Map: scale image..."); - CTimer T; T.Start(); - ETOOLS::SimplifyCubeMap (data.begin(),w,h,sm_data.begin(),sm_w,sm_h,16.f,pb_callback,PB); - float tm_scm = T.GetElapsed_sec(); - UI->ProgressEnd (PB); + U32Vec sm_data(sm_wf*sm_h, 0); + SPBItem*PB = UI->ProgressStart(1.f, "Cube Map: scale image..."); + CTimer T; + T.Start(); + ETOOLS::SimplifyCubeMap(data.begin(), w, h, sm_data.begin(), sm_w, sm_h, 16.f, pb_callback, PB); + float tm_scm = T.GetElapsed_sec(); + UI->ProgressEnd(PB); // write texture string_path out_name; - FS.update_path (out_name,_game_textures_,dst_name); + FS.update_path(out_name, _game_textures_, dst_name); strcat(out_name, ".dds"); - STextureParams tp; - tp.width = sm_wf; - tp.height = sm_h; - tp.fmt = STextureParams::tfRGBA; - tp.type = STextureParams::ttCubeMap; - tp.flags.zero (); - if (!MakeGameTexture(out_name,&*sm_data.begin(),tp)) - return FALSE; - ELog.DlgMsg(mtInformation,"Smaller cubemap successfylly created [%3.2f sec].",tm_scm); + STextureParams tp; + tp.width = sm_wf; + tp.height = sm_h; + tp.fmt = STextureParams::tfRGBA; + tp.type = STextureParams::ttCubeMap; + tp.flags.zero(); + if (!MakeGameTexture(out_name, &*sm_data.begin(), tp)) + return FALSE; + ELog.DlgMsg(mtInformation, "Smaller cubemap successfylly created [%3.2f sec].", tm_scm); return TRUE; - }else{ - ELog.Msg(mtError,"Can't load texture '%s'.",src_name); + } + else + { + ELog.Msg(mtError, "Can't load texture '%s'.", src_name); } return FALSE; } diff --git a/src/editors/ECore/Editor/ImageManager.h b/src/editors/ECore/Editor/ImageManager.h index f4ddee2118d..25b54f2584c 100644 --- a/src/editors/ECore/Editor/ImageManager.h +++ b/src/editors/ECore/Editor/ImageManager.h @@ -2,72 +2,95 @@ #ifndef ImageManagerH #define ImageManagerH -#include "../xrEProps/folderlib.h" -#include "../Layers/xrRender/etextureparams.h" -#include "../ECore/Editor/EThumbnail.h" +#include "editors/xrEProps/FolderLib.h" +#include "Layers/xrRender/ETextureParams.h" +#include "editors/ECore/Editor/EThumbnail.h" class CEditableObject; -struct SSimpleImage{ - shared_str name; - DEFINE_VECTOR(U32Vec,DATAVec,DATAIt); - DATAVec layers; - u32 w,h,a; - u32 tag; - int LongestEdge()const {return (w>h)?w:h;} - int Area()const {return w*h;} +struct SSimpleImage +{ + shared_str name; + DEFINE_VECTOR(U32Vec, DATAVec, DATAIt); + DATAVec layers; + u32 w, h, a; + u32 tag; + + int LongestEdge() const + { + return (w>h) ? w : h; + } + + int Area() const + { + return w*h; + } }; -IC bool operator == (const SSimpleImage& a, shared_str nm){return a.name==nm;} -IC bool operator < (const SSimpleImage& a, const SSimpleImage& b){return a.name=(ss_x+px)); R_ASSERT(ds_y>=(ss_y+py)); - for (u32 y=0; y=(ss_y+px)); R_ASSERT(ds_y>=(ss_x+py)); - for (u32 y=0; y=dest_width) return false; - if (R.rb.y>=dest_height) return false; + if (R.rb.x>=dest_width) + return false; + if (R.rb.y>=dest_height) + return false; // Normal (and fastest way) - for (u32 y=0; yitem1.Area())||(item0.LongestEdge()>item1.LongestEdge()));} -extern bool Surface_Load(LPCSTR full_name, U32Vec& data, u32& w, u32& h, u32& a); - -int CImageManager::CreateMergedTexture(u32 layer_cnt, SSimpleImageVec& src_images, SSimpleImage& dst_image, int dest_width, int dest_height, Fvector2Vec& dest_offset, Fvector2Vec& dest_scale, boolVec& dest_rotate, U32Vec& dest_remap) +bool item_area_sort_pred(const SSimpleImage &item0, const SSimpleImage &item1) { - if (src_images.empty()) return -1; + return ((item0.Area()>item1.Area())||(item0.LongestEdge()>item1.LongestEdge())); +} - dest_offset.clear (); - dest_scale.clear (); - dest_rotate.clear (); - dest_remap.resize (src_images.size()); +extern bool Surface_Load(LPCSTR full_name, U32Vec &data, u32 &w, u32 &h, u32 &a); - SSimpleImage::DATAVec dest_layers(layer_cnt); - for (SSimpleImage::DATAIt layer_it=dest_layers.begin(); layer_it!=dest_layers.end(); layer_it++) - layer_it->resize(dest_width*dest_height,0); - U8Vec dest_mask (dest_width*dest_height,0); +int CImageManager::CreateMergedTexture(u32 layer_cnt, SSimpleImageVec &src_images, SSimpleImage &dst_image, int dest_width, int dest_height, Fvector2Vec &dest_offset, Fvector2Vec &dest_scale, boolVec &dest_rotate, U32Vec &dest_remap) +{ + if (src_images.empty()) + return -1; - int max_area = dest_width*dest_height; - int calc_area = 0; + dest_offset.clear(); + dest_scale.clear(); + dest_rotate.clear(); + dest_remap.resize(src_images.size()); - for (SSimpleImageVecIt s_it=src_images.begin(); s_it!=src_images.end(); s_it++){ - s_it->tag = s_it-src_images.begin(); - calc_area += (s_it->w*s_it->h); - if (calc_area>max_area) return 0; + SSimpleImage::DATAVec dest_layers(layer_cnt); + for (SSimpleImage::DATAIt layer_it = dest_layers.begin(); layer_it!=dest_layers.end(); layer_it++) + layer_it->resize(dest_width*dest_height, 0); + U8Vec dest_mask(dest_width*dest_height, 0); + + int max_area = dest_width*dest_height; + int calc_area = 0; + + for (SSimpleImageVecIt s_it = src_images.begin(); s_it!=src_images.end(); s_it++) + { + s_it->tag = s_it-src_images.begin(); + calc_area += (s_it->w*s_it->h); + if (calc_area>max_area) + return 0; } - std::sort (src_images.begin(),src_images.end(),item_area_sort_pred); + std::sort(src_images.begin(), src_images.end(), item_area_sort_pred); - for (s_it=src_images.begin(); s_it!=src_images.end(); s_it++) - dest_remap[s_it->tag] = s_it-src_images.begin(); + for (s_it = src_images.begin(); s_it!=src_images.end(); s_it++) + dest_remap[s_it->tag] = s_it-src_images.begin(); - for (s_it = src_images.begin(); s_it!=src_images.end(); s_it++){ - Irect R; R.set(0,0, s_it->w-1,s_it->h-1); + for (s_it = src_images.begin(); s_it!=src_images.end(); s_it++) + { + Irect R; + R.set(0, 0, s_it->w-1, s_it->h-1); BOOL bRotated; - if (!_rect_place(dest_mask,dest_width,dest_height,R,bRotated)) return 0; - Fvector2 offs,scale; - offs.x = float(R.lt.x)/float(dest_width); - offs.y = float(R.lt.y)/float(dest_height); - scale.x = float(R.width()+1)/float(dest_width); - scale.y = float(R.height()+1)/float(dest_height); - dest_offset.push_back (offs); - dest_scale.push_back (scale); - dest_rotate.push_back (bRotated); + if (!_rect_place(dest_mask, dest_width, dest_height, R, bRotated)) + return 0; + Fvector2 offs, scale; + offs.x = float(R.lt.x)/float(dest_width); + offs.y = float(R.lt.y)/float(dest_height); + scale.x = float(R.width()+1)/float(dest_width); + scale.y = float(R.height()+1)/float(dest_height); + dest_offset.push_back(offs); + dest_scale.push_back(scale); + dest_rotate.push_back(bRotated); // Perform BLIT - VERIFY (s_it->layers.size()==layer_cnt); - for (u32 k=0; klayers[k].begin(),s_it->w,s_it->h,R.lt.x,R.lt.y); - else blit_r (dest_layers[k].begin(),dest_width,dest_height,s_it->layers[k].begin(),s_it->w,s_it->h,R.lt.x,R.lt.y); + VERIFY(s_it->layers.size()==layer_cnt); + for (u32 k = 0; klayers[k].begin(), s_it->w, s_it->h, R.lt.x, R.lt.y); + else + blit_r(dest_layers[k].begin(), dest_width, dest_height, s_it->layers[k].begin(), s_it->w, s_it->h, R.lt.x, R.lt.y); } } - dst_image.w = dest_width; - dst_image.h = dest_height; - dst_image.a = TRUE; - dst_image.layers = dest_layers; + dst_image.w = dest_width; + dst_image.h = dest_height; + dst_image.a = TRUE; + dst_image.layers = dest_layers; return 1; } -int CImageManager::CreateMergedTexture (u32 layer_cnt, SSimpleImageVec& src_images, SSimpleImage& dst_image, int dest_width_min, int dest_width_max, int dest_height_min, int dest_height_max, Fvector2Vec& dest_offset, Fvector2Vec& dest_scale, boolVec& dest_rotate, U32Vec& dest_remap) +int CImageManager::CreateMergedTexture(u32 layer_cnt, SSimpleImageVec &src_images, SSimpleImage &dst_image, int dest_width_min, int dest_width_max, int dest_height_min, int dest_height_max, Fvector2Vec &dest_offset, Fvector2Vec &dest_scale, boolVec &dest_rotate, U32Vec &dest_remap) { - int res = 0; - int w = dest_width_min; - int h = dest_height_min; - do{ - res = ImageLib.CreateMergedTexture(layer_cnt, src_images,dst_image,w,h,dest_offset,dest_scale,dest_rotate,dest_remap); - if (0==res){ - if ((w<=h)&&(wlayers.resize(1); - string_path t_name; -//. FS.update_path (t_name,_textures_,**n_it); - FS.update_path (t_name,_game_textures_,**n_it); - if (!Surface_Load(EFS.ChangeFileExt(t_name,".dds"/*".tga"*/).c_str(),s_it->layers.back(),s_it->w,s_it->h,s_it->a)){ - ELog.DlgMsg (mtError,"Can't load texture '%s'. Check file existence.",**n_it); + if (_names.empty()) + return -1; + + dest_offset.clear(); + dest_scale.clear(); + dest_rotate.clear(); + + RStringVec src_names = _names; + dest_remap.resize(src_names.size()); + std::sort(src_names.begin(), src_names.end()); + src_names.erase(std::unique(src_names.begin(), src_names.end()), src_names.end()); + + U32Vec dest_pixels(dest_width*dest_height, 0); + U8Vec dest_mask(dest_width*dest_height, 0); + + int max_area = dest_width*dest_height; + int calc_area = 0; + + SSimpleImageVec src_items(src_names.size()); + SSimpleImageVecIt s_it = src_items.begin(); + for (RStringVecIt n_it = src_names.begin(); n_it!=src_names.end(); n_it++,s_it++) + { + s_it->layers.resize(1); + string_path t_name; + //. FS.update_path (t_name,_textures_,**n_it); + FS.update_path(t_name, _game_textures_, **n_it); + if (!Surface_Load(EFS.ChangeFileExt(t_name, ".dds"/*".tga"*/).c_str(), s_it->layers.back(), s_it->w, s_it->h, s_it->a)) + { + ELog.DlgMsg(mtError, "Can't load texture '%s'. Check file existence.", **n_it); return -1; } - calc_area += (s_it->w*s_it->h); - if (calc_area>max_area) - return 0; - s_it->name = *n_it; + calc_area += (s_it->w*s_it->h); + if (calc_area>max_area) + return 0; + s_it->name = *n_it; } - std::sort (src_items.begin(),src_items.end(),item_area_sort_pred); + std::sort(src_items.begin(), src_items.end(), item_area_sort_pred); - for (u32 k=0; k<_names.size(); k++){ - shared_str nm = _names[k]; - s_it = std::find(src_items.begin(),src_items.end(),nm); VERIFY(s_it!=src_items.end()); - dest_remap[k] = s_it-src_items.begin(); + for (u32 k = 0; k<_names.size(); k++) + { + shared_str nm = _names[k]; + s_it = std::find(src_items.begin(), src_items.end(), nm); + VERIFY(s_it!=src_items.end()); + dest_remap[k] = s_it-src_items.begin(); } - - for (s_it = src_items.begin(); s_it!=src_items.end(); s_it++){ - Irect R; R.set(0,0, s_it->w-1,s_it->h-1); + + for (s_it = src_items.begin(); s_it!=src_items.end(); s_it++) + { + Irect R; + R.set(0, 0, s_it->w-1, s_it->h-1); BOOL bRotated; - if (!_rect_place(dest_mask,dest_width,dest_height,R,bRotated)) return 0; - Fvector2 offs,scale; - offs.x = float(R.lt.x)/float(dest_width); - offs.y = float(R.lt.y)/float(dest_height); - scale.x = float(R.width()+1)/float(dest_width); - scale.y = float(R.height()+1)/float(dest_height); - dest_offset.push_back (offs); - dest_scale.push_back (scale); - dest_rotate.push_back (bRotated); + if (!_rect_place(dest_mask, dest_width, dest_height, R, bRotated)) + return 0; + Fvector2 offs, scale; + offs.x = float(R.lt.x)/float(dest_width); + offs.y = float(R.lt.y)/float(dest_height); + scale.x = float(R.width()+1)/float(dest_width); + scale.y = float(R.height()+1)/float(dest_height); + dest_offset.push_back(offs); + dest_scale.push_back(scale); + dest_rotate.push_back(bRotated); // Perform BLIT - if (!bRotated) blit (dest_pixels.begin(),dest_width,dest_height,s_it->layers.back().begin(),s_it->w,s_it->h,R.lt.x,R.lt.y); - else blit_r (dest_pixels.begin(),dest_width,dest_height,s_it->layers.back().begin(),s_it->w,s_it->h,R.lt.x,R.lt.y); + if (!bRotated) + blit(dest_pixels.begin(), dest_width, dest_height, s_it->layers.back().begin(), s_it->w, s_it->h, R.lt.x, R.lt.y); + else + blit_r(dest_pixels.begin(), dest_width, dest_height, s_it->layers.back().begin(), s_it->w, s_it->h, R.lt.x, R.lt.y); } // all right. make texture. - AnsiString fn = ChangeFileExt (dest_name,".dds"); - STextureParams tp; - tp.width = dest_width; - tp.height = dest_height; - tp.fmt = fmt; - tp.type = STextureParams::ttImage; - tp.mip_filter = STextureParams::kMIPFilterAdvanced; - tp.flags.assign (STextureParams::flDitherColor|STextureParams::flGenerateMipMaps); - MakeGameTexture (fn.c_str(),dest_pixels.begin(),tp); + AnsiString fn = ChangeFileExt(dest_name, ".dds"); + STextureParams tp; + tp.width = dest_width; + tp.height = dest_height; + tp.fmt = fmt; + tp.type = STextureParams::ttImage; + tp.mip_filter = STextureParams::kMIPFilterAdvanced; + tp.flags.assign(STextureParams::flDitherColor|STextureParams::flGenerateMipMaps); + MakeGameTexture(fn.c_str(), dest_pixels.begin(), tp); return 1; } -int CImageManager::CreateMergedTexture (const RStringVec& src_names, LPCSTR dest_name, STextureParams::ETFormat fmt, int dest_width_min, int dest_width_max, int dest_height_min, int dest_height_max, Fvector2Vec& dest_offset, Fvector2Vec& dest_scale, boolVec& dest_rotate, U32Vec& remap) +int CImageManager::CreateMergedTexture(const RStringVec &src_names, LPCSTR dest_name, STextureParams::ETFormat fmt, int dest_width_min, int dest_width_max, int dest_height_min, int dest_height_max, Fvector2Vec &dest_offset, Fvector2Vec &dest_scale, boolVec &dest_rotate, U32Vec &remap) { - int res = 0; - int w = dest_width_min; - int h = dest_height_min; - do{ - res = ImageLib.CreateMergedTexture(src_names,dest_name,fmt,w,h,dest_offset,dest_scale,dest_rotate,remap); - if (0==res){ - if ((w<=h)&&(wscene_clear_color; EPrefs.scene_clear_color = 0x0000000; psDeviceFlags.zero (); - psDeviceFlags.set (rsFilterLinear,TRUE); - EDevice.dwFillMode = D3DFILL_SOLID; + psDeviceFlags.set (rsFilterLinear,TRUE); + EDevice.dwFillMode = D3DFILL_SOLID; EDevice.dwShadeMode = D3DSHADE_GOURAUD; SetCamera(0,C,S.y,R,D); for (int frame=0; framee_mesh->GetSurfaceByFaceID(R->tag); VERIFY(surf); - Shader_xrLC* c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); - if (!c_sh->flags.bRendering) return FALSE; - const Fvector2* cuv[3]; - R->e_mesh->GetFaceTC (R->tag,cuv); + CSurface*surf = R->e_mesh->GetSurfaceByFaceID(R->tag); + VERIFY(surf); + Shader_xrLC *c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); + if (!c_sh->flags.bRendering) + return FALSE; + const Fvector2 *cuv[3]; + R->e_mesh->GetFaceTC(R->tag, cuv); // barycentric coords // note: W,U,V order Fvector B; - B.set (1.0f - R->u - R->v,R->u,R->v); + B.set(1.0f-R->u-R->v, R->u, R->v); // calc UV - Fvector2 uv; - uv.x = cuv[0]->x*B.x + cuv[1]->x*B.y + cuv[2]->x*B.z; - uv.y = cuv[0]->y*B.x + cuv[1]->y*B.y + cuv[2]->y*B.z; - - int U = iFloor(uv.x*float(surf->m_ImageData->w) + .5f); - int V = iFloor(uv.y*float(surf->m_ImageData->h)+ .5f); - U %= surf->m_ImageData->w; if (U<0) U+=surf->m_ImageData->w; - V %= surf->m_ImageData->h; if (V<0) V+=surf->m_ImageData->h; - -/* -// float filter_core[3][3]={{0.0125,0.0125,0.0125},{0.0125,0.9,0.0125},{0.0125,0.0125,0.0125}}; -// float filter_core[3][3]={{0.0625,0.0625,0.0625},{0.0625,0.5,0.0625},{0.0625,0.0625,0.0625}}; -// float filter_core[3][3]={{0,0,0},{0,1,0},{0,0,0}}; - Fvector4 C={0,0,0,0}; - u32 cnt=0; - for (int y=-1; y<=1; y++){ - int v = V+y; - if (v<0||v>=(int)surf->m_ImageData->h) continue; - for (int x=-1; x<=1; x++){ - int u = U+x; - if (u<0||u>=(int)surf->m_ImageData->w) continue; - Fvector4 c; - color = surf->m_ImageData->layers.back()[v*surf->m_ImageData->w+u]; - float f = filter_core[x+1][y+1]; - c.set (f*color_get_R(color),f*color_get_G(color),f*color_get_B(color),f*color_get_A(color)); - C.add (c); - cnt++; + Fvector2 uv; + uv.x = cuv[0]->x*B.x+cuv[1]->x*B.y+cuv[2]->x*B.z; + uv.y = cuv[0]->y*B.x+cuv[1]->y*B.y+cuv[2]->y*B.z; + + int U = iFloor(uv.x*float(surf->m_ImageData->w)+.5f); + int V = iFloor(uv.y*float(surf->m_ImageData->h)+.5f); + U %= surf->m_ImageData->w; + if (U<0) + U += surf->m_ImageData->w; + V %= surf->m_ImageData->h; + if (V<0) + V += surf->m_ImageData->h; + + /* + // float filter_core[3][3]={{0.0125,0.0125,0.0125},{0.0125,0.9,0.0125},{0.0125,0.0125,0.0125}}; + // float filter_core[3][3]={{0.0625,0.0625,0.0625},{0.0625,0.5,0.0625},{0.0625,0.0625,0.0625}}; + // float filter_core[3][3]={{0,0,0},{0,1,0},{0,0,0}}; + Fvector4 C={0,0,0,0}; + u32 cnt=0; + for (int y=-1; y<=1; y++){ + int v = V+y; + if (v<0||v>=(int)surf->m_ImageData->h) continue; + for (int x=-1; x<=1; x++){ + int u = U+x; + if (u<0||u>=(int)surf->m_ImageData->w) continue; + Fvector4 c; + color = surf->m_ImageData->layers.back()[v*surf->m_ImageData->w+u]; + float f = filter_core[x+1][y+1]; + c.set (f*color_get_R(color),f*color_get_G(color),f*color_get_B(color),f*color_get_A(color)); + C.add (c); + cnt++; + } } - } -// if (0!=cnt) C.div(cnt); - color = color_rgba(C.x,C.y,C.z,C.w); -*/ - color = surf->m_ImageData->layers.back()[V*surf->m_ImageData->w+U]; + // if (0!=cnt) C.div(cnt); + color = color_rgba(C.x,C.y,C.z,C.w); + */ + color = surf->m_ImageData->layers.back()[V*surf->m_ImageData->w+U]; alpha = color_get_A(color); return TRUE; } -struct SBuildLight{ - Flight light; - float energy; +struct SBuildLight +{ + Flight light; + float energy; }; -DEFINE_VECTOR (SBuildLight,BLVec,BLIt); -ICF static void simple_hemi_callback(float x, float y, float z, float E, LPVOID P) + +DEFINE_VECTOR(SBuildLight, BLVec, BLIt); +ICF static + +void simple_hemi_callback(float x, float y, float z, float E, LPVOID P) { - BLVec* dst = (BLVec*)P; - SBuildLight T; - T.energy = E; - T.light.direction.set (x,y,z); - dst->push_back (T); + BLVec *dst = (BLVec*)P; + SBuildLight T; + T.energy = E; + T.light.direction.set(x, y, z); + dst->push_back(T); } -const u32 lod_ss_quality = 8; +const u32 lod_ss_quality = 8; -void CreateLODSamples(const Fbox& bbox, U32Vec& tgt_data, u32 tgt_w, u32 tgt_h) +void CreateLODSamples(const Fbox &bbox, U32Vec &tgt_data, u32 tgt_w, u32 tgt_h) { - U32Vec s_pixels,d_pixels; - Fmatrix save_projection = EDevice.mProject; - Fmatrix save_view = EDevice.mView; + U32Vec s_pixels, d_pixels; + Fmatrix save_projection = EDevice.mProject; + Fmatrix save_view = EDevice.mView; // save render params - Flags32 old_flag = psDeviceFlags; - u32 old_dwFillMode = EDevice.dwFillMode; - u32 old_dwShadeMode = EDevice.dwShadeMode; + Flags32 old_flag = psDeviceFlags; + u32 old_dwFillMode = EDevice.dwFillMode; + u32 old_dwShadeMode = EDevice.dwShadeMode; // set render params - u32 cc = EPrefs->scene_clear_color; - EPrefs->scene_clear_color = 0x0000000; - psDeviceFlags.zero (); - psDeviceFlags.set (rsFilterLinear,TRUE); - EDevice.dwFillMode = D3DFILL_SOLID; - EDevice.dwShadeMode = D3DSHADE_GOURAUD; + u32 cc = EPrefs->scene_clear_color; + EPrefs->scene_clear_color = 0x0000000; + psDeviceFlags.zero(); + psDeviceFlags.set(rsFilterLinear, TRUE); + EDevice.dwFillMode = D3DFILL_SOLID; + EDevice.dwShadeMode = D3DSHADE_GOURAUD; + + Fvector vP, vD, vN, vR; + Fmatrix mV, mP; - Fvector vP,vD,vN,vR; - Fmatrix mV,mP; - Fvector S; - bbox.getradius (S); - float R = 2.f*_max(S.x,S.z); + bbox.getradius(S); + float R = 2.f*_max(S.x, S.z); - u32 pitch = tgt_w*LOD_SAMPLE_COUNT; - tgt_data.resize (pitch*tgt_h); - for (int frame=0; framescene_clear_color = cc; + EDevice.dwFillMode = old_dwFillMode; + EDevice.dwShadeMode = old_dwShadeMode; + psDeviceFlags = old_flag; + EPrefs->scene_clear_color = cc; - RCache.set_xform_view (save_view); - RCache.set_xform_project (save_projection); + RCache.set_xform_view(save_view); + RCache.set_xform_project(save_projection); } -void CImageManager::CreateLODTexture(CEditableObject* OBJECT, U32Vec& lod_pixels, U32Vec& nm_pixels, u32 tgt_w, u32 tgt_h, int _samples, int quality) +void CImageManager::CreateLODTexture(CEditableObject *OBJECT, U32Vec &lod_pixels, U32Vec &nm_pixels, u32 tgt_w, u32 tgt_h, int _samples, int quality) { - // build hemi light - BLVec simple_hemi; + // build hemi light + BLVec simple_hemi; // fill simple hemi - simple_hemi.clear (); - xrHemisphereBuild (1,2.f,simple_hemi_callback,&simple_hemi); + simple_hemi.clear(); + xrHemisphereBuild(1, 2.f, simple_hemi_callback, &simple_hemi); - Fbox bb = OBJECT->GetBox(); + Fbox bb = OBJECT->GetBox(); // build lod normals - lod_pixels.resize (LOD_IMAGE_SIZE*LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,0); - nm_pixels.resize (LOD_IMAGE_SIZE*LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,0); - U32Vec hemi_tmp (LOD_IMAGE_SIZE*LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,0); - Fvector o_center, o_size; - Fmatrix M, Mi; - bb.getradius (o_size); - bb.getcenter (o_center); - SPBItem* PB = UI->ProgressStart(LOD_SAMPLE_COUNT*LOD_IMAGE_SIZE,OBJECT->GetName()); - float dW = _max(o_size.x,o_size.z)/(LOD_IMAGE_SIZE/2); - float dH = o_size.y/(LOD_IMAGE_SIZE/2); - float dR = bb.getradius(); - float d2R = dR*2.f; - ETOOLS::ray_options (CDB::OPT_CULL); - - CreateLODSamples (bb,lod_pixels,LOD_IMAGE_SIZE,LOD_IMAGE_SIZE); - - float tN=0.f,tH=0.f,tT=0.f,tR=0.f; - - float LOD_CALC_SAMPLES = quality; - s32 LOD_CALC_SAMPLES_LIM= LOD_CALC_SAMPLES/2; + lod_pixels.resize(LOD_IMAGE_SIZE*LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT, 0); + nm_pixels.resize(LOD_IMAGE_SIZE*LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT, 0); + U32Vec hemi_tmp(LOD_IMAGE_SIZE*LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT, 0); + Fvector o_center, o_size; + Fmatrix M, Mi; + bb.getradius(o_size); + bb.getcenter(o_center); + SPBItem*PB = UI->ProgressStart(LOD_SAMPLE_COUNT*LOD_IMAGE_SIZE, OBJECT->GetName()); + float dW = _max(o_size.x, o_size.z)/(LOD_IMAGE_SIZE/2); + float dH = o_size.y/(LOD_IMAGE_SIZE/2); + float dR = bb.getradius(); + float d2R = dR*2.f; + ETOOLS::ray_options(CDB::OPT_CULL); + + CreateLODSamples(bb, lod_pixels,LOD_IMAGE_SIZE,LOD_IMAGE_SIZE); + + float tN = 0.f, tH = 0.f, tT = 0.f, tR = 0.f; + + float LOD_CALC_SAMPLES = quality; + s32 LOD_CALC_SAMPLES_LIM = LOD_CALC_SAMPLES/2; // preload textures - for (SurfaceIt surf_it=OBJECT->Surfaces().begin(); surf_it!=OBJECT->Surfaces().end(); surf_it++){ - CSurface* surf = *surf_it; - Shader_xrLC* c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); - if (!c_sh->flags.bRendering) continue; - if (0==surf->m_ImageData)surf->CreateImageData(); - } + for (SurfaceIt surf_it = OBJECT->Surfaces().begin(); surf_it!=OBJECT->Surfaces().end(); surf_it++) + { + CSurface*surf = *surf_it; + Shader_xrLC *c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); + if (!c_sh->flags.bRendering) + continue; + if (0==surf->m_ImageData) + surf->CreateImageData(); + } // calculate - for (u32 sample_idx=0; sample_idxInc (); - float Y = (iH-(LOD_IMAGE_SIZE-1)/2)*dH; - for (s32 iW=0; iWInc(); + float Y = (iH-(LOD_IMAGE_SIZE-1)/2)*dH; + for (s32 iW = 0; iWRayQuery (PQ); - if (PQ.r_count()){ + start.mad(M.k, -dR); + PQ.prepare_rq(start, M.k, d2R, CDB::OPT_CULL); + OBJECT->RayQuery(PQ); + if (PQ.r_count()) + { PQ.r_sort(); - Fvector N = {0,0,0}; -///. Fcolor C = {0,0,0,0}; - for (s32 k=PQ.r_count()-1; k>=0; k--){ - SPickQuery::SResult* R = PQ.r_begin()+k; - u32 uA, uC; - if (!GetPointColor(R,uA,uC)) continue; - float fA = float(uA)/255.f; - if (uA){ - Fvector pt; pt.mad(PQ.m_Start,PQ.m_Direction,R->range-EPS_L); - Fvector4 ptt; ptt.set(pt.x,pt.y,pt.z,fA); + Fvector N = {0,0,0}; + ///. Fcolor C = {0,0,0,0}; + for (s32 k = PQ.r_count()-1; k>=0; k--) + { + SPickQuery::SResult *R = PQ.r_begin()+k; + u32 uA, uC; + if (!GetPointColor(R, uA, uC)) + continue; + float fA = float(uA)/255.f; + if (uA) + { + Fvector pt; + pt.mad(PQ.m_Start, PQ.m_Direction, R->range-EPS_L); + Fvector4 ptt; + ptt.set(pt.x, pt.y, pt.z, fA); sample_pt_vec.push_back(ptt); } // normal Fvector Nn; - Nn.mknormal (R->verts[0],R->verts[1],R->verts[2]); - Nn.mul (fA); + Nn.mknormal(R->verts[0], R->verts[1], R->verts[2]); + Nn.mul(fA); - N.mul (1.f-fA); - N.add (Nn); + N.mul(1.f-fA); + N.add(Nn); // color -///. Fcolor Cn; -///. Cn.set (uC); -///. if (Cn.a>=(200.f/255.f)) C.lerp(C,Cn,Cn.a); + ///. Fcolor Cn; + ///. Cn.set (uC); + ///. if (Cn.a>=(200.f/255.f)) C.lerp(C,Cn,Cn.a); } - float n_mag = N.magnitude(); - if (!fis_zero(n_mag,EPS)) - n_vec.push_back (N.div(n_mag)); -///. c_vec.push_back (Fvector4().set(C.r,C.g,C.b,C.a)); + float n_mag = N.magnitude(); + if (!fis_zero(n_mag, EPS)) + n_vec.push_back(N.div(n_mag)); + ///. c_vec.push_back (Fvector4().set(C.r,C.g,C.b,C.a)); } } } -tN+=TT.GetElapsed_sec(); -///. Fvector4 cC = {0,0,0,0}; -///. for (Fvector4It c_it=c_vec.begin(); c_it!=c_vec.end(); c_it++) -///. cC.add (*c_it); -///. cC.div (c_vec.size()); -///. cC.mul (255.f); -///. tgt_c = color_rgba(iFloor(cC.x),iFloor(cC.y),iFloor(cC.z),iFloor(cC.w)>200.f?255:0); - - Fvector N={0,0,0}; - if (!n_vec.empty()){ - for (FvectorIt it=n_vec.begin(); it!=n_vec.end(); it++) N.add(*it); - N.div (n_vec.size()); - N.normalize_safe(); - Mi.transform_dir(N); + tN += TT.GetElapsed_sec(); + ///. Fvector4 cC = {0,0,0,0}; + ///. for (Fvector4It c_it=c_vec.begin(); c_it!=c_vec.end(); c_it++) + ///. cC.add (*c_it); + ///. cC.div (c_vec.size()); + ///. cC.mul (255.f); + ///. tgt_c = color_rgba(iFloor(cC.x),iFloor(cC.y),iFloor(cC.z),iFloor(cC.w)>200.f?255:0); + + Fvector N = {0,0,0}; + if (!n_vec.empty()) + { + for (FvectorIt it = n_vec.begin(); it!=n_vec.end(); it++) + N.add(*it); + N.div(n_vec.size()); + N.normalize_safe(); + Mi.transform_dir(N); } - N.mul (0.5f); - N.add (0.5f); - N.mul (255.f); - tgt_n = color_rgba(iFloor(N.x),iFloor(N.y),iFloor(N.z),color_get_A(tgt_c)); - - if (0==color_get_A(tgt_c)) continue; -TT.Start(); + N.mul(0.5f); + N.add(0.5f); + N.mul(255.f); + tgt_n = color_rgba(iFloor(N.x), iFloor(N.y), iFloor(N.z), color_get_A(tgt_c)); + + if (0==color_get_A(tgt_c)) + continue; + TT.Start(); // light points - float res_transp = 0.f; - for (Fvector4It pt_it=sample_pt_vec.begin(); pt_it!=sample_pt_vec.end(); pt_it++){ - float avg_transp = 0.f; - for (BLIt it=simple_hemi.begin(); it!=simple_hemi.end(); it++){ -TT1.Start(); - Fvector start; - start.mad (Fvector().set(pt_it->x,pt_it->y,pt_it->z),it->light.direction,-dR); - PQ.prepare_rq (start,it->light.direction,dR,CDB::OPT_CULL); - OBJECT->RayQuery (PQ); -tR+=TT1.GetElapsed_sec(); - float ray_transp= 1.f; - if (PQ.r_count()){ - for (s32 k=0; kx, pt_it->y, pt_it->z), it->light.direction, -dR); + PQ.prepare_rq(start, it->light.direction, dR, CDB::OPT_CULL); + OBJECT->RayQuery(PQ); + tR += TT1.GetElapsed_sec(); + float ray_transp = 1.f; + if (PQ.r_count()) + { + for (s32 k = 0; kw)+avg_transp*pt_it->w; + avg_transp /= simple_hemi.size(); + res_transp = res_transp*(1.f-pt_it->w)+avg_transp*pt_it->w; } -tH+=TT.GetElapsed_sec(); - u8 h = (u8)iFloor (res_transp*255.f); - tgt_h = color_rgba(h,h,h,color_get_A(tgt_c)); + tH += TT.GetElapsed_sec(); + u8 h = (u8)iFloor(res_transp*255.f); + tgt_h = color_rgba(h, h, h, color_get_A(tgt_c)); } } } - Msg("Normal: %3.2fsec, Hemi: %3.2f, PC: %3.2f, RP: %3.2f",tN,tH,tT,tR); - ImageLib.ApplyBorders (lod_pixels,LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,LOD_IMAGE_SIZE); - ImageLib.ApplyBorders (nm_pixels, LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,LOD_IMAGE_SIZE); - ImageLib.ApplyBorders (hemi_tmp, LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,LOD_IMAGE_SIZE); + Msg("Normal: %3.2fsec, Hemi: %3.2f, PC: %3.2f, RP: %3.2f", tN, tH, tT, tR); + ImageLib.ApplyBorders(lod_pixels,LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,LOD_IMAGE_SIZE); + ImageLib.ApplyBorders(nm_pixels, LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,LOD_IMAGE_SIZE); + ImageLib.ApplyBorders(hemi_tmp, LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,LOD_IMAGE_SIZE); // fill alpha to N-channel (HEMI) - for (int px_idx=0; px_idxProgressEnd(PB); } //------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ -void CImageManager::CreateLODTexture(CEditableObject* OBJECT, LPCSTR tex_name, u32 tgt_w, u32 tgt_h, int samples, int age, int quality) +void CImageManager::CreateLODTexture(CEditableObject *OBJECT, LPCSTR tex_name, u32 tgt_w, u32 tgt_h, int samples, int age, int quality) { - U32Vec lod_pixels, nm_pixels; + U32Vec lod_pixels, nm_pixels; - CreateLODTexture (OBJECT,lod_pixels,nm_pixels,tgt_w,tgt_h,samples,quality); + CreateLODTexture(OBJECT, lod_pixels, nm_pixels, tgt_w, tgt_h, samples, quality); - string_path out_name,src_name; - CImage* I = xr_new(); + string_path out_name, src_name; + CImage *I = xr_new(); // save lod - strcpy (src_name,tex_name); + strcpy(src_name, tex_name); - strcpy (src_name, EFS.ChangeFileExt(src_name,".thm").c_str()); - FS.file_delete (_textures_,src_name); + strcpy(src_name, EFS.ChangeFileExt(src_name, ".thm").c_str()); + FS.file_delete(_textures_, src_name); - strcpy (src_name, EFS.ChangeFileExt(src_name,".tga").c_str()); - FS.update_path (out_name,_textures_,src_name); - I->Create (tgt_w*samples,tgt_h,lod_pixels.begin()); -// I->Vflip (); - I->SaveTGA (out_name); - FS.set_file_age (out_name,age); - SynchronizeTexture (src_name,age); + strcpy(src_name, EFS.ChangeFileExt(src_name, ".tga").c_str()); + FS.update_path(out_name, _textures_, src_name); + I->Create(tgt_w*samples, tgt_h, lod_pixels.begin()); + // I->Vflip (); + I->SaveTGA(out_name); + FS.set_file_age(out_name, age); + SynchronizeTexture(src_name, age); // save normal map - strconcat (sizeof(src_name),src_name, tex_name, "_nm"); - strcpy (src_name,EFS.ChangeFileExt(src_name,".thm").c_str()); - FS.file_delete (_textures_,src_name); - - strcpy (src_name, EFS.ChangeFileExt(src_name,".tga").c_str()); - FS.update_path (out_name,_textures_,src_name); - I->Create (tgt_w*samples,tgt_h,nm_pixels.begin()); -// I->Vflip (); - I->SaveTGA (out_name); - FS.set_file_age (out_name,age); - SynchronizeTexture (src_name,age); - - xr_delete (I); + strconcat(sizeof(src_name), src_name, tex_name, "_nm"); + strcpy(src_name, EFS.ChangeFileExt(src_name, ".thm").c_str()); + FS.file_delete(_textures_, src_name); + + strcpy(src_name, EFS.ChangeFileExt(src_name, ".tga").c_str()); + FS.update_path(out_name, _textures_, src_name); + I->Create(tgt_w*samples, tgt_h, nm_pixels.begin()); + // I->Vflip (); + I->SaveTGA(out_name); + FS.set_file_age(out_name, age); + SynchronizeTexture(src_name, age); + + xr_delete(I); } - diff --git a/src/editors/ECore/Editor/LW_ShaderDef.h b/src/editors/ECore/Editor/LW_ShaderDef.h index ee0ce7586c3..aed53555b47 100644 --- a/src/editors/ECore/Editor/LW_ShaderDef.h +++ b/src/editors/ECore/Editor/LW_ShaderDef.h @@ -4,17 +4,19 @@ /* our instance data */ #pragma pack(push,1) -typedef struct st_XRShader{ - char en_name[64]; - int en_idx; - char lc_name[64]; - int lc_idx; - char gm_name[64]; - int gm_idx; - char* desc; +typedef struct st_XRShader +{ + char en_name[64]; + int en_idx; + char lc_name[64]; + int lc_idx; + char gm_name[64]; + int gm_idx; + char *desc; } XRShader; #pragma pack(pop) #define SH_PLUGIN_NAME "!XRayShader" #endif + diff --git a/src/editors/ECore/Editor/Library.cpp b/src/editors/ECore/Editor/Library.cpp index c289ebc34f2..bcb50b8caaf 100644 --- a/src/editors/ECore/Editor/Library.cpp +++ b/src/editors/ECore/Editor/Library.cpp @@ -5,267 +5,316 @@ #include "stdafx.h" #pragma hdrstop -#include "Log.h" +#include "xrCore/Log.h" #include "Library.h" #include "EditObject.h" #include "ui_main.h" //---------------------------------------------------- ELibrary Lib; + //---------------------------------------------------- ELibrary::ELibrary() { - m_bReady = false; + m_bReady = false; } + //---------------------------------------------------- -ELibrary::~ELibrary() -{ -} +ELibrary::~ELibrary() {} + //---------------------------------------------------- void ELibrary::OnCreate() { -// EDevice.seqDevCreate.Add (this,REG_PRIORITY_NORMAL); -// EDevice.seqDevDestroy.Add(this,REG_PRIORITY_NORMAL); + // EDevice.seqDevCreate.Add (this,REG_PRIORITY_NORMAL); + // EDevice.seqDevDestroy.Add(this,REG_PRIORITY_NORMAL); m_bReady = true; } + //---------------------------------------------------- void ELibrary::OnDestroy() { - VERIFY(m_bReady); + VERIFY(m_bReady); m_bReady = false; -// EDevice.seqDevCreate.Remove(this); -// EDevice.seqDevDestroy.Remove(this); + // EDevice.seqDevCreate.Remove(this); + // EDevice.seqDevDestroy.Remove(this); // remove all instance CEditableObject - EditObjPairIt O = m_EditObjects.begin(); - EditObjPairIt E = m_EditObjects.end(); - for(; O!=E; O++){ - if (0!=O->second->m_RefCount){ -//. ELog.DlgMsg(mtError,"Object '%s' still referenced.",O->first.c_str()); -//. R_ASSERT(0==O->second->m_RefCount); + EditObjPairIt O = m_EditObjects.begin(); + EditObjPairIt E = m_EditObjects.end(); + for (; O!=E; O++) + { + if (0!=O->second->m_RefCount) + { + //. ELog.DlgMsg(mtError,"Object '%s' still referenced.",O->first.c_str()); + //. R_ASSERT(0==O->second->m_RefCount); } - xr_delete(O->second); + xr_delete(O->second); } - m_EditObjects.clear(); + m_EditObjects.clear(); } + //---------------------------------------------------- void ELibrary::CleanLibrary() { - VERIFY(m_bReady); + VERIFY(m_bReady); // remove all unused instance CEditableObject - for(EditObjPairIt O = m_EditObjects.begin(); O!=m_EditObjects.end(); ){ - if (0==O->second->m_RefCount){ - EditObjPairIt D = O; O++; - xr_delete (D->second); - m_EditObjects.erase (D); - }else O++; + for (EditObjPairIt O = m_EditObjects.begin(); O!=m_EditObjects.end();) + { + if (0==O->second->m_RefCount) + { + EditObjPairIt D = O; + O++; + xr_delete(D->second); + m_EditObjects.erase(D); + } + else + O++; } } + //---------------------------------------------------- void ELibrary::ReloadObject(LPCSTR nm) { - VERIFY(m_bReady); - R_ASSERT(nm&&nm[0]); - string512 name; strcpy(name,nm); strlwr(name); - EditObjPairIt it = m_EditObjects.find(name); + VERIFY(m_bReady); + R_ASSERT(nm&&nm[0]); + string512 name; + strcpy(name, nm); + strlwr(name); + EditObjPairIt it = m_EditObjects.find(name); if (it!=m_EditObjects.end()) - it->second->Reload(); + it->second->Reload(); } + //--------------------------------------------------------------------------- -void ELibrary::ReloadObjects(){ - VERIFY(m_bReady); - EditObjPairIt O = m_EditObjects.begin(); - EditObjPairIt E = m_EditObjects.end(); - for(; O!=E; O++) - O->second->Reload(); +void ELibrary::ReloadObjects() +{ + VERIFY(m_bReady); + EditObjPairIt O = m_EditObjects.begin(); + EditObjPairIt E = m_EditObjects.end(); + for (; O!=E; O++) + O->second->Reload(); } + //---------------------------------------------------- -void ELibrary::OnDeviceCreate(){ - VERIFY(m_bReady); - EditObjPairIt O = m_EditObjects.begin(); - EditObjPairIt E = m_EditObjects.end(); - for(; O!=E; O++) - O->second->OnDeviceCreate(); +void ELibrary::OnDeviceCreate() +{ + VERIFY(m_bReady); + EditObjPairIt O = m_EditObjects.begin(); + EditObjPairIt E = m_EditObjects.end(); + for (; O!=E; O++) + O->second->OnDeviceCreate(); } + //--------------------------------------------------------------------------- -void ELibrary::OnDeviceDestroy(){ - VERIFY(m_bReady); - EditObjPairIt O = m_EditObjects.begin(); - EditObjPairIt E = m_EditObjects.end(); - for(; O!=E; O++) - O->second->OnDeviceDestroy(); +void ELibrary::OnDeviceDestroy() +{ + VERIFY(m_bReady); + EditObjPairIt O = m_EditObjects.begin(); + EditObjPairIt E = m_EditObjects.end(); + for (; O!=E; O++) + O->second->OnDeviceDestroy(); } + //--------------------------------------------------------------------------- void ELibrary::EvictObjects() { - EditObjPairIt O = m_EditObjects.begin(); - EditObjPairIt E = m_EditObjects.end(); - for(; O!=E; O++) - O->second->EvictObject(); + EditObjPairIt O = m_EditObjects.begin(); + EditObjPairIt E = m_EditObjects.end(); + for (; O!=E; O++) + O->second->EvictObject(); } + //---------------------------------------------------- -CEditableObject* ELibrary::LoadEditObject(LPCSTR name) +CEditableObject *ELibrary::LoadEditObject(LPCSTR name) { - VERIFY(m_bReady); - CEditableObject* m_EditObject = xr_new(name); + VERIFY(m_bReady); + CEditableObject*m_EditObject = xr_new(name); string_path fn; - FS.update_path(fn,_objects_,EFS.ChangeFileExt(name,".object").c_str()); + FS.update_path(fn, _objects_, EFS.ChangeFileExt(name, ".object").c_str()); if (FS.exist(fn)) { - if (m_EditObject->Load(fn)) return m_EditObject; - }else{ - ELog.Msg(mtError,"Can't find file '%s'",fn); + if (m_EditObject->Load(fn)) + return m_EditObject; + } + else + { + ELog.Msg(mtError, "Can't find file '%s'", fn); } xr_delete(m_EditObject); - return 0; + return 0; } + //--------------------------------------------------------------------------- -CEditableObject* ELibrary::CreateEditObject(LPCSTR nm) +CEditableObject *ELibrary::CreateEditObject(LPCSTR nm) { - VERIFY(m_bReady); + VERIFY(m_bReady); R_ASSERT(nm&&nm[0]); -//. UI->ProgressInfo (nm); - AnsiString name = AnsiString(nm).LowerCase(); + //. UI->ProgressInfo (nm); + AnsiString name = AnsiString(nm).LowerCase(); // file exist - find in already loaded - CEditableObject* m_EditObject = 0; - EditObjPairIt it = m_EditObjects.find(name); - if (it!=m_EditObjects.end()) m_EditObject = it->second; - else if (0!=(m_EditObject=LoadEditObject(name.c_str()))) - m_EditObjects[name] = m_EditObject; - if (m_EditObject) m_EditObject->m_RefCount++; - return m_EditObject; + CEditableObject*m_EditObject = 0; + EditObjPairIt it = m_EditObjects.find(name); + if (it!=m_EditObjects.end()) + m_EditObject = it->second; + else if (0!=(m_EditObject = LoadEditObject(name.c_str()))) + m_EditObjects[name] = m_EditObject; + if (m_EditObject) + m_EditObject->m_RefCount++; + return m_EditObject; } + //--------------------------------------------------------------------------- -void ELibrary::RemoveEditObject(CEditableObject*& object) +void ELibrary::RemoveEditObject(CEditableObject *&object) { - if (object){ - object->m_RefCount--; - R_ASSERT(object->m_RefCount>=0); - if ((object->m_RefCount==0)&&EPrefs->object_flags.is(epoDiscardInstance)) - if (!object->IsModified()) UnloadEditObject(object->GetName()); - object=0; - } + if (object) + { + object->m_RefCount--; + R_ASSERT(object->m_RefCount>=0); + if ((object->m_RefCount==0)&&EPrefs->object_flags.is(epoDiscardInstance)) + if (!object->IsModified()) + UnloadEditObject(object->GetName()); + object = 0; + } } + //--------------------------------------------------------------------------- -void ELibrary::Save(FS_FileSet* modif_map) +void ELibrary::Save(FS_FileSet *modif_map) { - VERIFY(m_bReady); - EditObjPairIt O = m_EditObjects.begin(); - EditObjPairIt E = m_EditObjects.end(); + VERIFY(m_bReady); + EditObjPairIt O = m_EditObjects.begin(); + EditObjPairIt E = m_EditObjects.end(); if (modif_map) { - for(; O!=E; O++) - if (modif_map->end()!=modif_map->find(FS_File(O->second->GetName()))) + for (; O!=E; O++) + if (modif_map->end()!=modif_map->find(FS_File(O->second->GetName()))) { - string_path nm; - FS.update_path (nm,_objects_,O->second->GetName()); - strcpy(nm, EFS.ChangeFileExt(nm,".object").c_str()); + string_path nm; + FS.update_path(nm, _objects_, O->second->GetName()); + strcpy(nm, EFS.ChangeFileExt(nm, ".object").c_str()); if (!O->second->Save(nm)) - Log ("!Can't save object:",nm); + Log("!Can't save object:", nm); } - }else + } + else { - for(; O!=E; O++) + for (; O!=E; O++) if (O->second->IsModified()) { - string_path nm; - FS.update_path (nm,_objects_,O->second->GetName()); - strcpy (nm, EFS.ChangeFileExt(nm,".object").c_str()); + string_path nm; + FS.update_path(nm, _objects_, O->second->GetName()); + strcpy(nm, EFS.ChangeFileExt(nm, ".object").c_str()); if (!O->second->Save(nm)) - Log ("!Can't save object:",nm); + Log("!Can't save object:", nm); } } } + //--------------------------------------------------------------------------- -int ELibrary::GetObjects(FS_FileSet& files) +int ELibrary::GetObjects(FS_FileSet &files) { - return FS.file_list(files,_objects_,FS_ListFiles|FS_ClampExt,"*.object"); + return FS.file_list(files, _objects_, FS_ListFiles|FS_ClampExt, "*.object"); } + //--------------------------------------------------------------------------- -void ELibrary::RemoveObject(LPCSTR _fname, EItemType type, bool& res) +void ELibrary::RemoveObject(LPCSTR _fname, EItemType type, bool &res) { - if (TYPE_FOLDER==type){ - FS.dir_delete (_objects_,_fname,FALSE); - res = true; - return; - }else if (TYPE_OBJECT==type){ - string_path fname,src_name; - strcpy(fname,EFS.ChangeFileExt(_fname,".object").c_str()); - FS.update_path (src_name,_objects_,fname); + if (TYPE_FOLDER==type) + { + FS.dir_delete(_objects_, _fname, FALSE); + res = true; + return; + } + else if (TYPE_OBJECT==type) + { + string_path fname, src_name; + strcpy(fname, EFS.ChangeFileExt(_fname, ".object").c_str()); + FS.update_path(src_name, _objects_, fname); if (FS.exist(src_name)) { - xr_string thm_name = EFS.ChangeFileExt(fname,".thm"); + xr_string thm_name = EFS.ChangeFileExt(fname, ".thm"); // source - FS.file_delete (src_name); + FS.file_delete(src_name); // thumbnail - FS.file_delete (_objects_,thm_name.c_str()); + FS.file_delete(_objects_, thm_name.c_str()); + + UnloadEditObject(_fname); - UnloadEditObject (_fname); - res = true; return; } - }else THROW; + } + else + THROW; res = false; } + //--------------------------------------------------------------------------- void ELibrary::RenameObject(LPCSTR nm0, LPCSTR nm1, EItemType type) { - if (TYPE_FOLDER==type){ - FS.dir_delete (_objects_,nm0,FALSE); - }else if (TYPE_OBJECT==type){ - string_path fn0,fn1,temp; + if (TYPE_FOLDER==type) + { + FS.dir_delete(_objects_, nm0, FALSE); + } + else if (TYPE_OBJECT==type) + { + string_path fn0, fn1, temp; // rename base file - FS.update_path(fn0,_objects_,nm0); - strcat(fn0,".object"); - FS.update_path(fn1,_objects_,nm1); - strcat(fn1,".object"); - FS.file_rename(fn0,fn1,false); + FS.update_path(fn0, _objects_, nm0); + strcat(fn0, ".object"); + FS.update_path(fn1, _objects_, nm1); + strcat(fn1, ".object"); + FS.file_rename(fn0, fn1, false); // rename thm - FS.update_path(fn0,_objects_,nm0); - strcat(fn0,".thm"); - FS.update_path(fn1,_objects_,nm1); - strcat(fn1,".thm"); - FS.file_rename(fn0,fn1,false); + FS.update_path(fn0, _objects_, nm0); + strcat(fn0, ".thm"); + FS.update_path(fn1, _objects_, nm1); + strcat(fn1, ".thm"); + FS.file_rename(fn0, fn1, false); // rename in cache - EditObjPairIt it = m_EditObjects.find(nm0); - if (it!=m_EditObjects.end()){ - m_EditObjects[nm1] = it->second; - m_EditObjects.erase (it); + EditObjPairIt it = m_EditObjects.find(nm0); + if (it!=m_EditObjects.end()) + { + m_EditObjects[nm1] = it->second; + m_EditObjects.erase(it); } - } + } } + //--------------------------------------------------------------------------- void ELibrary::UnloadEditObject(LPCSTR full_name) { - EditObjPairIt it = m_EditObjects.find(full_name); - if (it!=m_EditObjects.end()){ - if (0!=it->second->m_RefCount){ - ELog.DlgMsg(mtError,"Object '%s' still referenced.",it->first.c_str()); + EditObjPairIt it = m_EditObjects.find(full_name); + if (it!=m_EditObjects.end()) + { + if (0!=it->second->m_RefCount) + { + ELog.DlgMsg(mtError, "Object '%s' still referenced.", it->first.c_str()); THROW; } - m_EditObjects.erase(it); - xr_delete (it->second); + m_EditObjects.erase(it); + xr_delete(it->second); } } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ECore/Editor/Library.h b/src/editors/ECore/Editor/Library.h index 56f5ee93b18..3df38d789c7 100644 --- a/src/editors/ECore/Editor/Library.h +++ b/src/editors/ECore/Editor/Library.h @@ -6,45 +6,45 @@ #define LibraryH #include "pure.h" -#include "../xrEProps/FolderLib.h" +#include "editors/xrEProps/FolderLib.h" //---------------------------------------------------- class CEditableObject; -DEFINE_MAP_PRED(AnsiString,CEditableObject*,EditObjMap,EditObjPairIt,astr_pred); +DEFINE_MAP_PRED(AnsiString, CEditableObject *, EditObjMap, EditObjPairIt, astr_pred); //---------------------------------------------------- class ECORE_API ELibrary//: public pureDeviceCreate, public pureDeviceDestroy { - bool m_bReady; - friend class TfrmChoseObject; - EditObjMap m_EditObjects; + bool m_bReady; + friendclass TfrmChoseObject; + EditObjMap m_EditObjects; - CEditableObject* LoadEditObject (LPCSTR full_name); - void UnloadEditObject (LPCSTR full_name); -public: - ELibrary (); - virtual ~ELibrary (); - - void __stdcall RemoveObject (LPCSTR fname, EItemType type, bool& res); - void __stdcall RenameObject (LPCSTR fn0, LPCSTR fn1, EItemType type); + CEditableObject*LoadEditObject(LPCSTR full_name); + void UnloadEditObject(LPCSTR full_name); + public: + ELibrary(); + virtual ~ELibrary(); - void OnCreate (); - void OnDestroy (); - void Save (FS_FileSet* modif_map=0); + void__stdcall RemoveObject(LPCSTR fname, EItemType type, bool& res); + void__stdcall RenameObject(LPCSTR fn0, LPCSTR fn1, EItemType type); - void ReloadObjects (); - void CleanLibrary (); - void ReloadObject (LPCSTR name); + void OnCreate(); + void OnDestroy(); + void Save(FS_FileSet*modif_map = 0); - CEditableObject* CreateEditObject (LPCSTR name); - void RemoveEditObject (CEditableObject*& object); + void ReloadObjects(); + void CleanLibrary(); + void ReloadObject(LPCSTR name); - int GetObjects (FS_FileSet& files); - int ObjectCount (){return m_EditObjects.size();} + CEditableObject*CreateEditObject(LPCSTR name); + void RemoveEditObject(CEditableObject*& object); - void EvictObjects (); + int GetObjects(FS_FileSet&files); + int ObjectCount(){return m_EditObjects.size();} - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); + void EvictObjects(); + + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); }; extern ECORE_API ELibrary Lib; diff --git a/src/editors/ECore/Editor/LogForm.cpp b/src/editors/ECore/Editor/LogForm.cpp index 3861031c6c9..f1e7271514d 100644 --- a/src/editors/ECore/Editor/LogForm.cpp +++ b/src/editors/ECore/Editor/LogForm.cpp @@ -8,57 +8,75 @@ #pragma link "mxPlacemnt" #pragma link "MxMenus" #pragma resource "*.dfm" -TfrmLog *TfrmLog::form=0; +TfrmLog *TfrmLog::form = 0; + //--------------------------------------------------------------------------- -__fastcall TfrmLog::TfrmLog(TComponent* Owner) +__fastcall TfrmLog::TfrmLog(TComponent *Owner) : TForm(Owner) { - DEFINE_INI(fsStorage); + DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- -void __fastcall TfrmLog::CreateLog(){ - VERIFY(!form); - form = xr_new((TComponent*)0); +void __fastcall TfrmLog::CreateLog() +{ + VERIFY(!form); + form = xr_new((TComponent*)0); } -void __fastcall TfrmLog::DestroyLog(){ - xr_delete(form); + +void __fastcall TfrmLog::DestroyLog() +{ + xr_delete(form); } -void __fastcall TfrmLog::ShowLog(){ - VERIFY(form); - form->Show(); + +void __fastcall TfrmLog::ShowLog() +{ + VERIFY(form); + form->Show(); } -void __fastcall TfrmLog::HideLog(){ - VERIFY(form); - form->Close(); + +void __fastcall TfrmLog::HideLog() +{ + VERIFY(form); + form->Close(); } void __fastcall TfrmLog::ebClearClick(TObject *Sender) { - lbLog->Items->Clear(); + lbLog->Items->Clear(); } + //--------------------------------------------------------------------------- -void __fastcall TfrmLog::AddDlgMessage(TMsgDlgType mt, const AnsiString& msg) -{ +void __fastcall TfrmLog::AddDlgMessage(TMsgDlgType mt, const AnsiString &msg) +{ ExecCommand(COMMAND_RENDER_FOCUS); - MessageDlg(msg, mt, TMsgDlgButtons() << mbOK, 0); - AddMessage(mt,msg); + MessageDlg(msg, mt, TMsgDlgButtons()<lbLog->Items->AddObject(M,(TObject*)mt); + form->lbLog->Items->AddObject(M, (TObject*)mt); form->lbLog->ItemIndex = form->lbLog->Items->Count-1; - if ((mt==mtError)&&!form->Visible) form->Show(); + if ((mt==mtError)&&!form->Visible) + form->Show(); } + //--------------------------------------------------------------------------- #define MSG_ERROR 0x00C4C4FF @@ -67,99 +85,122 @@ void __fastcall TfrmLog::AddMessage(TMsgDlgType mt, const AnsiString& msg) #define MSG_DEF 0x00E8E8E8 void __fastcall TfrmLog::lbLogDrawItem(TWinControl *Control, int Index, - TRect &Rect, TOwnerDrawState State) -{ - TListBox* lb = ((TListBox *)Control); - TCanvas *pCanvas = lb->Canvas; - if (!State.Contains(odSelected)){ - pCanvas->Brush->Color = TColor(MSG_DEF); - TMsgDlgType mt = (TMsgDlgType)lb->Items->Objects[Index]; - switch(mt){ - case mtError: pCanvas->Brush->Color=TColor(MSG_ERROR);break; - case mtInformation: pCanvas->Brush->Color=TColor(MSG_INFO); break; - case mtConfirmation: pCanvas->Brush->Color=TColor(MSG_CONF); break; - } + TRect &Rect, TOwnerDrawState State) +{ + TListBox *lb = ((TListBox *)Control); + TCanvas *pCanvas = lb->Canvas; + if (!State.Contains(odSelected)) + { + pCanvas->Brush->Color = TColor(MSG_DEF); + TMsgDlgType mt = (TMsgDlgType)lb->Items->Objects[Index]; + switch (mt) + { + case mtError: pCanvas->Brush->Color = TColor(MSG_ERROR); + break; + case mtInformation: pCanvas->Brush->Color = TColor(MSG_INFO); + break; + case mtConfirmation: pCanvas->Brush->Color = TColor(MSG_CONF); + break; + } } - pCanvas->FillRect(Rect); - int Offset = 2; // default text offset width - pCanvas->TextOut(Rect.Left + Offset, Rect.Top, lb->Items->Strings[Index]); + pCanvas->FillRect(Rect); + int Offset = 2; // default text offset width + pCanvas->TextOut(Rect.Left+Offset, Rect.Top, lb->Items->Strings[Index]); } + //--------------------------------------------------------------------------- void __fastcall TfrmLog::FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if (Key==VK_ESCAPE) Close(); - else{ - UI->ApplyGlobalShortCut(Key, Shift); + if (Key==VK_ESCAPE) + Close(); + else + { + UI->ApplyGlobalShortCut(Key, Shift); } } + //--------------------------------------------------------------------------- void __fastcall TfrmLog::ebClearSelectedClick(TObject *Sender) { - for (int i = 0; i < lbLog->Items->Count; i++){ - if (lbLog->Selected[i]){ - lbLog->Items->Delete(i); + for (int i = 0; iItems->Count; i++) + { + if (lbLog->Selected[i]) + { + lbLog->Items->Delete(i); i--; } } } + //--------------------------------------------------------------------------- void __fastcall TfrmLog::ebCloseClick(TObject *Sender) { - Close(); + Close(); } + //--------------------------------------------------------------------------- void __fastcall TfrmLog::FormShow(TObject *Sender) { - // check window position - UI->CheckWindowPos(this); + // check window position + UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- void __fastcall TfrmLog::ebFlushClick(TObject *Sender) { - FlushLog(); + FlushLog(); } + //--------------------------------------------------------------------------- void __fastcall TfrmLog::lbLogKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if (Shift.Contains(ssCtrl)&&(Key=='C')){ - imCopyClick (Sender); - }else if (Shift.Contains(ssCtrl)&&(Key=='A')){ - imSelectAllClick(Sender); + if (Shift.Contains(ssCtrl)&&(Key=='C')) + { + imCopyClick(Sender); + } + else if (Shift.Contains(ssCtrl)&&(Key=='A')) + { + imSelectAllClick(Sender); } } + //--------------------------------------------------------------------------- void __fastcall TfrmLog::imCopyClick(TObject *Sender) { - TClipboard* clp = Clipboard(); - clp->Clear (); - xr_string tmp; - for (int i = 0; i < lbLog->Items->Count; i++) - if (lbLog->Selected[i]){ - tmp = tmp+lbLog->Items->Strings[i].c_str()+"\r\n"; + TClipboard *clp = Clipboard(); + clp->Clear(); + xr_string tmp; + for (int i = 0; iItems->Count; i++) + if (lbLog->Selected[i]) + { + tmp = tmp+lbLog->Items->Strings[i].c_str()+"\r\n"; } - clp->SetTextBuf ((LPSTR)tmp.c_str()); + clp->SetTextBuf((LPSTR)tmp.c_str()); } + //--------------------------------------------------------------------------- void __fastcall TfrmLog::imSelectAllClick(TObject *Sender) { - lbLog->SelectAll(); + lbLog->SelectAll(); } + //--------------------------------------------------------------------------- void __fastcall TfrmLog::lbLogKeyPress(TObject *Sender, char &Key) { - Key = 0; + Key = 0; } + //--------------------------------------------------------------------------- diff --git a/src/editors/ECore/Editor/LogForm.h b/src/editors/ECore/Editor/LogForm.h index a7b9278f19a..fab80cf6e1b 100644 --- a/src/editors/ECore/Editor/LogForm.h +++ b/src/editors/ECore/Editor/LogForm.h @@ -12,51 +12,55 @@ #include "MxMenus.hpp" #include -class ECORE_API TfrmLog : public TForm +class ECORE_API TfrmLog : + +public +TForm { -__published: // IDE-managed Components + __published: // IDE-managed Components TPanel *Panel1; - TPanel *Panel2; - TListBox *lbLog; - TExtBtn *ebClear; - TExtBtn *ebClearSelected; - TExtBtn *ebClose; - TFormStorage *fsStorage; - TExtBtn *ebFlush; - TMxPopupMenu *MxPopupMenu1; - TMenuItem *imCopy; - TMenuItem *imSelectAll; - TMenuItem *ClearAll1; - TMenuItem *ClearSelected1; - TMenuItem *N1; - void __fastcall ebClearClick(TObject *Sender); - void __fastcall lbLogDrawItem(TWinControl *Control, int Index, - TRect &Rect, TOwnerDrawState State); - void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall ebClearSelectedClick(TObject *Sender); - void __fastcall ebCloseClick(TObject *Sender); - void __fastcall FormShow(TObject *Sender); - void __fastcall ebFlushClick(TObject *Sender); - void __fastcall lbLogKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall imCopyClick(TObject *Sender); - void __fastcall imSelectAllClick(TObject *Sender); - void __fastcall lbLogKeyPress(TObject *Sender, char &Key); -private: // User declarations - static TfrmLog *form; -public: // User declarations + TPanel *Panel2; + TListBox *lbLog; + TExtBtn *ebClear; + TExtBtn *ebClearSelected; + TExtBtn *ebClose; + TFormStorage *fsStorage; + TExtBtn *ebFlush; + TMxPopupMenu *MxPopupMenu1; + TMenuItem *imCopy; + TMenuItem *imSelectAll; + TMenuItem *ClearAll1; + TMenuItem *ClearSelected1; + TMenuItem *N1; + void __fastcall ebClearClick(TObject *Sender); + void __fastcall lbLogDrawItem(TWinControl *Control, int Index, + TRect &Rect, TOwnerDrawState State); + void __fastcall FormKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall ebClearSelectedClick(TObject *Sender); + void __fastcall ebCloseClick(TObject *Sender); + void __fastcall FormShow(TObject *Sender); + void __fastcall ebFlushClick(TObject *Sender); + void __fastcall lbLogKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall imCopyClick(TObject *Sender); + void __fastcall imSelectAllClick(TObject *Sender); + void __fastcall lbLogKeyPress(TObject *Sender, char &Key); + private: // User declarations + static TfrmLog *form; + public: // User declarations __fastcall TfrmLog(TComponent* Owner); - static void __fastcall AddMessage (TMsgDlgType mt, const AnsiString& msg); - static void __fastcall AddMessage (const AnsiString& msg){AddMessage(mtCustom,msg);} - static void __fastcall AddDlgMessage(TMsgDlgType mt, const AnsiString& msg); - static void __fastcall AddDlgMessage(const AnsiString& msg){AddDlgMessage(mtCustom,msg);} - static void __fastcall ShowLog (); - static void __fastcall HideLog (); - static void __fastcall CreateLog (); - static void __fastcall DestroyLog (); - static void __fastcall ChangeVisible(){if (form->Visible) HideLog(); else ShowLog();} - static bool __fastcall IsVisible (){return form->Visible;} + static void __fastcall AddMessage (TMsgDlgType mt, const AnsiString& msg); + static void __fastcall AddMessage (const AnsiString& msg){AddMessage(mtCustom,msg);} +static void __fastcall AddDlgMessage(TMsgDlgType mt, const AnsiString& msg); +static void __fastcall AddDlgMessage(const AnsiString& msg){AddDlgMessage(mtCustom,msg);} +static void __fastcall ShowLog (); +static void __fastcall HideLog (); +static void __fastcall CreateLog (); +static void __fastcall DestroyLog (); +static void __fastcall ChangeVisible(){if (form->Visible) HideLog(); else ShowLog();} +static bool __fastcall IsVisible (){return form->Visible;} }; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ECore/Editor/MinimapEditor.cpp b/src/editors/ECore/Editor/MinimapEditor.cpp index a2df63d690f..e3fc190f700 100644 --- a/src/editors/ECore/Editor/MinimapEditor.cpp +++ b/src/editors/ECore/Editor/MinimapEditor.cpp @@ -13,20 +13,21 @@ #pragma link "ElACtrls" #pragma resource "*.dfm" -TTMinimapEditor* TTMinimapEditor::form = NULL; +TTMinimapEditor *TTMinimapEditor::form = NULL; + //.TTMinimapEditor *TMinimapEditor; //--------------------------------------------------------------------------- -__fastcall TTMinimapEditor::TTMinimapEditor(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TTMinimapEditor::TTMinimapEditor(TComponent *Owner) + : TForm(Owner) {} + #include "ui_main.h" void __fastcall TTMinimapEditor::Show() { - if (!form){ - form = xr_new((TComponent*)0); -//. form->Caption = title; + if (!form) + { + form = xr_new((TComponent*)0); + //. form->Caption = title; } form->ShowModal(); @@ -35,158 +36,169 @@ void __fastcall TTMinimapEditor::Show() void __fastcall TTMinimapEditor::Hide() { - if (form){ - form->Close(); + if (form) + { + form->Close(); } } + //--------------------------------------------------------------------------- #include "freeimage/freeimage.h" #include "Image.h" -bool Surface_Load(LPCSTR full_name, U32Vec& data, u32& w, u32& h, u32& a); +bool Surface_Load(LPCSTR full_name, U32Vec &data, u32 &w, u32 &h, u32 &a); void __fastcall TTMinimapEditor::btnLoadClick(TObject *Sender) { - xr_string fn; - image_data.clear (); - - if(EFS.GetOpenName("$app_root$", fn, false, NULL, 0)) + xr_string fn; + image_data.clear(); + + if (EFS.GetOpenName("$app_root$", fn, false, NULL, 0)) { - if (Surface_Load(fn.c_str(),image_data,image_w,image_h,image_a)) + if (Surface_Load(fn.c_str(), image_data, image_w, image_h, image_a)) { - - u32* line = xr_alloc(image_w); - u32 sz_ln=sizeof(u32)*image_w; - u32 y2 = image_w-1; - for (int y=0; y(image_w); + u32 sz_ln = sizeof(u32)*image_w; + u32 y2 = image_w-1; + for (int y = 0; yValue = map_bb.min.x; + ElFloatSpinEditZ1->Value = map_bb.min.y; + + ElFloatSpinEditX2->Value = map_bb.max.x; + ElFloatSpinEditZ2->Value = map_bb.max.y; + b_block = false; + } + else { - b_block = true; - ElFloatSpinEditX1->Value = map_bb.min.x; - ElFloatSpinEditZ1->Value = map_bb.min.y; - - ElFloatSpinEditX2->Value = map_bb.max.x; - ElFloatSpinEditZ2->Value = map_bb.max.y; - b_block = false; - }else - { - map_bb.min.x = ElFloatSpinEditX1->Value; - map_bb.min.y = ElFloatSpinEditZ1->Value; - - map_bb.max.x = ElFloatSpinEditX2->Value; - map_bb.max.y = ElFloatSpinEditZ2->Value; - } - - string512 buff; - sprintf(buff,"bound_rect = %3.3f, %3.3f, %3.3f, %3.3f",map_bb.min.x,map_bb.min.y,map_bb.max.x,map_bb.max.y); - result_edit->ReadOnly = false; - result_edit->Text = buff; - result_edit->ReadOnly = true; - imgPanel->Repaint (); + map_bb.min.x = ElFloatSpinEditX1->Value; + map_bb.min.y = ElFloatSpinEditZ1->Value; + + map_bb.max.x = ElFloatSpinEditX2->Value; + map_bb.max.y = ElFloatSpinEditZ2->Value; + } + + string512 buff; + sprintf(buff, "bound_rect = %3.3f, %3.3f, %3.3f, %3.3f", map_bb.min.x, map_bb.min.y, map_bb.max.x, map_bb.max.y); + result_edit->ReadOnly = false; + result_edit->Text = buff; + result_edit->ReadOnly = true; + imgPanel->Repaint(); } -#include "FolderLib.h" -void DrawThumbnail(TCanvas* pCanvas, TRect& r, U32Vec& data, bool bDrawWithAlpha, int _w, int _h) +#include "editors/xrEProps/FolderLib.h" + +void DrawThumbnail(TCanvas *pCanvas, TRect &r, U32Vec &data, bool bDrawWithAlpha, int _w, int _h) { - pCanvas->CopyMode = cmSrcCopy; + pCanvas->CopyMode = cmSrcCopy; Graphics::TBitmap *pBitmap = xr_new(); - pBitmap->PixelFormat = pf24bit; //pf32bit; - pBitmap->Height = _h; - pBitmap->Width = _w; - + pBitmap->PixelFormat = pf24bit; //pf32bit; + pBitmap->Height = _h; + pBitmap->Width = _w; + if (bDrawWithAlpha) { - Fcolor back; - back.set (bgr2rgb(pCanvas->Brush->Color)); back.mul_rgb(255.f); - for (int y = 0; y < pBitmap->Height; y++) + Fcolor back; + back.set(bgr2rgb(pCanvas->Brush->Color)); + back.mul_rgb(255.f); + for (int y = 0; yHeight; y++) { - u32* ptr = (u32*)pBitmap->ScanLine[y]; - for (int x = 0; x < pBitmap->Width; x++){ - u32 src = data[(_h-1-y)*_w+x]; - float a = float(color_get_A(src))/255.f; - float inv_a = 1.f-a;; - u32 r = iFloor(float(color_get_R(src))*a+back.r*inv_a); - u32 g = iFloor(float(color_get_G(src))*a+back.g*inv_a); - u32 b = iFloor(float(color_get_B(src))*a+back.b*inv_a); - ptr[x] = color_rgba(r,g,b,0); + u32 *ptr = (u32*)pBitmap->ScanLine[y]; + for (int x = 0; xWidth; x++) + { + u32 src = data[(_h-1-y)*_w+x]; + float a = float(color_get_A(src))/255.f; + float inv_a = 1.f-a;; + u32 r = iFloor(float(color_get_R(src))*a+back.r*inv_a); + u32 g = iFloor(float(color_get_G(src))*a+back.g*inv_a); + u32 b = iFloor(float(color_get_B(src))*a+back.b*inv_a); + ptr[x] = color_rgba(r, g, b, 0); } } - }else{ - for (int y = 0; y < pBitmap->Height; y++) + } + else + { + for (int y = 0; yHeight; y++) { - u32* ptr = (u32*)pBitmap->ScanLine[y]; - Memory.mem_copy (ptr,&data[(_h-1-y)*_w],_w*4); + u32 *ptr = (u32*)pBitmap->ScanLine[y]; + Memory.mem_copy(ptr, &data[(_h-1-y)*_w], _w*4); } } - pCanvas->StretchDraw(r,pBitmap); + pCanvas->StretchDraw(r, pBitmap); xr_delete(pBitmap); } void __fastcall TTMinimapEditor::imgPanelPaint(TObject *Sender) { - if(image_data.size()==0) return; - - Irect R; - R.x1 = 0; - R.y1 = 0; - R.x2 = image_draw_size.x; - R.y2 = image_draw_size.y; -//. FHelper.DrawThumbnail(imgPanel->Canvas->Handle, R, &*image_data.begin(), image_w, image_h); - -/* - RECT R1; - R1.left = 0; - R1.top = 0; - R1.right = image_draw_size.x; - R1.bottom = image_draw_size.y; - DrawThumbnail(imgPanel->Canvas, R1, image_data, false, image_w, image_h); -*/ - float kw = (map_bb_loaded.max.x-map_bb_loaded.min.x) / (float)image_draw_size.x; - float kh = (map_bb_loaded.max.y-map_bb_loaded.min.y) / (float)image_draw_size.y; - - TRect R2; - R2.Left = iFloor((map_bb.min.x-map_bb_loaded.min.x)/kw); - R2.Top = iFloor((map_bb.min.y-map_bb_loaded.min.y)/kh); - R2.Right = R2.Left + iFloor((map_bb.max.x-map_bb.min.x)/kw); - R2.Bottom = R2.Top + iFloor((map_bb.max.y-map_bb.min.y)/kh); + if (image_data.size()==0) + return; + + Irect R; + R.x1 = 0; + R.y1 = 0; + R.x2 = image_draw_size.x; + R.y2 = image_draw_size.y; + //. FHelper.DrawThumbnail(imgPanel->Canvas->Handle, R, &*image_data.begin(), image_w, image_h); + + /* + RECT R1; + R1.left = 0; + R1.top = 0; + R1.right = image_draw_size.x; + R1.bottom = image_draw_size.y; + DrawThumbnail(imgPanel->Canvas, R1, image_data, false, image_w, image_h); + */ + float kw = (map_bb_loaded.max.x-map_bb_loaded.min.x)/(float)image_draw_size.x; + float kh = (map_bb_loaded.max.y-map_bb_loaded.min.y)/(float)image_draw_size.y; + + TRect R2; + R2.Left = iFloor((map_bb.min.x-map_bb_loaded.min.x)/kw); + R2.Top = iFloor((map_bb.min.y-map_bb_loaded.min.y)/kh); + R2.Right = R2.Left+iFloor((map_bb.max.x-map_bb.min.x)/kw); + R2.Bottom = R2.Top+iFloor((map_bb.max.y-map_bb.min.y)/kh); FHelper.DrawThumbnail(imgPanel->Canvas->Handle, R, &*image_data.begin(), image_w, image_h); @@ -194,50 +206,58 @@ void __fastcall TTMinimapEditor::imgPanelPaint(TObject *Sender) imgPanel->Canvas->Pen->Style = psSolid; imgPanel->Canvas->Rectangle(R2); } + //--------------------------------------------------------------------------- void __fastcall TTMinimapEditor::imgPanelResize(TObject *Sender) { - if(image_data.size()==0) return; - float _k_img = (float)image_w/(float)image_h; - float _k_panel = (float)imgPanel->Width/(float)imgPanel->Height; - - if(_k_img>_k_panel) - { //align to width - image_draw_size.set (imgPanel->Width, iFloor(imgPanel->Width/_k_img) ); - }else - { //align to height - image_draw_size.set (iFloor(imgPanel->Height*_k_img), imgPanel->Height); + if (image_data.size()==0) + return; + float _k_img = (float)image_w/(float)image_h; + float _k_panel = (float)imgPanel->Width/(float)imgPanel->Height; + + if (_k_img>_k_panel) + { //align to width + image_draw_size.set(imgPanel->Width, iFloor(imgPanel->Width/_k_img)); } - VERIFY (image_draw_size.x<=imgPanel->Width && image_draw_size.y<=imgPanel->Height); + else + { //align to height + image_draw_size.set(iFloor(imgPanel->Height*_k_img), imgPanel->Height); + } + VERIFY(image_draw_size.x<=imgPanel->Width&&image_draw_size.y<=imgPanel->Height); } + //--------------------------------------------------------------------------- void __fastcall TTMinimapEditor::imgPanelMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - if(X>image_draw_size.x || Y>image_draw_size.y) return; - float kw = (map_bb_loaded.max.x-map_bb_loaded.min.x) / (float)image_draw_size.x; - float kh = (map_bb_loaded.max.y-map_bb_loaded.min.y) / (float)image_draw_size.y; - - if( X<(image_draw_size.x/2) && Y<(image_draw_size.y/2) ) - { //LT - map_bb.min.x = map_bb_loaded.min.x + X*kw; - map_bb.min.y = map_bb_loaded.min.y + Y*kh; - } - - if( X>(image_draw_size.x/2) && Y>(image_draw_size.y/2) ) - { //RB - map_bb.max.x = map_bb_loaded.min.x + X*kw; - map_bb.max.y = map_bb_loaded.min.y + Y*kh; - } - ApplyPoints (true); + if (X>image_draw_size.x||Y>image_draw_size.y) + return; + float kw = (map_bb_loaded.max.x-map_bb_loaded.min.x)/(float)image_draw_size.x; + float kh = (map_bb_loaded.max.y-map_bb_loaded.min.y)/(float)image_draw_size.y; + + if (X<(image_draw_size.x/2)&&Y<(image_draw_size.y/2)) + { //LT + map_bb.min.x = map_bb_loaded.min.x+X*kw; + map_bb.min.y = map_bb_loaded.min.y+Y*kh; + } + + if (X>(image_draw_size.x/2)&&Y>(image_draw_size.y/2)) + { //RB + map_bb.max.x = map_bb_loaded.min.x+X*kw; + map_bb.max.y = map_bb_loaded.min.y+Y*kh; + } + ApplyPoints(true); } + //--------------------------------------------------------------------------- void __fastcall TTMinimapEditor::ElFloatSpinEditX1Change(TObject *Sender) { - ApplyPoints (false); + ApplyPoints(false); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/ECore/Editor/MinimapEditor.h b/src/editors/ECore/Editor/MinimapEditor.h index cadb55296a8..6d61cb93184 100644 --- a/src/editors/ECore/Editor/MinimapEditor.h +++ b/src/editors/ECore/Editor/MinimapEditor.h @@ -18,8 +18,8 @@ //--------------------------------------------------------------------------- class TTMinimapEditor : public TForm { -__published: // IDE-managed Components - TPanel *Panel1; + __published: // IDE-managed Components + TPanel*Panel1; TExtBtn *btnLoad; TMxPanel *imgPanel; TMxLabel *MxLabel1; @@ -34,26 +34,32 @@ class TTMinimapEditor : public TForm void __fastcall imgPanelPaint(TObject *Sender); void __fastcall imgPanelResize(TObject *Sender); void __fastcall imgPanelMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); + TShiftState Shift, int X, int Y); void __fastcall ElFloatSpinEditX1Change(TObject *Sender); -private: // User declarations -static TTMinimapEditor* form; - U32Vec image_data; - u32 image_w; - u32 image_h; - u32 image_a; - Fbox2 map_bb; - Fbox2 map_bb_loaded; - Ivector2 image_draw_size; - void ApplyPoints(bool to_controls); -public: // User declarations - __fastcall TTMinimapEditor(TComponent* Owner); +private: // User declarations + static TTMinimapEditor *form; + U32Vec image_data; + u32 image_w; + u32 image_h; + u32 image_a; + Fbox2 map_bb; + Fbox2 map_bb_loaded; + Ivector2 image_draw_size; + void ApplyPoints(bool to_controls); +public: // User declarations + __fastcall TTMinimapEditor(TComponent *Owner); - static void __fastcall Show (); - static void __fastcall Hide (); - static bool __fastcall Visible (){return !!form;} + static void __fastcall Show(); + static void __fastcall Hide(); + + static bool __fastcall Visible() + { + return !!form; + } }; + //--------------------------------------------------------------------------- //. extern PACKAGE TTMinimapEditor *TMinimapEditor; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ECore/Editor/ParticleEffectActions.cpp b/src/editors/ECore/Editor/ParticleEffectActions.cpp index c9f82b14300..4fd270bf581 100644 --- a/src/editors/ECore/Editor/ParticleEffectActions.cpp +++ b/src/editors/ECore/Editor/ParticleEffectActions.cpp @@ -4,5 +4,5 @@ #include "ParticleEffectActions.h" -_CreateEAction pCreateEAction=0; +_CreateEAction pCreateEAction = 0; diff --git a/src/editors/ECore/Editor/ParticleEffectActions.h b/src/editors/ECore/Editor/ParticleEffectActions.h index a1b7ae9b499..b9733612ccc 100644 --- a/src/editors/ECore/Editor/ParticleEffectActions.h +++ b/src/editors/ECore/Editor/ParticleEffectActions.h @@ -2,358 +2,465 @@ #ifndef ParticleEffectActionsH #define ParticleEffectActionsH -struct PBool{ - BOOL val; - PBool ():val(FALSE){} - PBool (BOOL _val):val(_val){} - void set(BOOL v){val=v;} -}; -struct PFloat{ - float val; - float mn; - float mx; - PFloat () {val=0.f;mn=0.f;mx=0.f;} - PFloat (float _val, float _mn, float _mx):val(_val),mn(_mn),mx(_mx){} - void set(float v){val=v;} -}; -struct PInt{ - int val; - int mn; - int mx; - PInt () {val=0;mn=0;mx=0;} - PInt (int _val, int _mn, int _mx):val(_val),mn(_mn),mx(_mx){} - void set(int v){val=v;} -}; -struct PVector{ - Fvector val; - float mn; - float mx; - enum EType{ +struct PBool +{ + BOOL val; + + PBool(): val(FALSE) {} + + PBool(BOOL _val): val(_val) {} + + void set(BOOL v) + { + val = v; + } +}; + +struct PFloat +{ + float val; + float mn; + float mx; + + PFloat() + { + val = 0.f; + mn = 0.f; + mx = 0.f; + } + + PFloat(float _val, float _mn, float _mx): val(_val), mn(_mn), mx(_mx) {} + + void set(float v) + { + val = v; + } +}; + +struct PInt +{ + int val; + int mn; + int mx; + + PInt() + { + val = 0; + mn = 0; + mx = 0; + } + + PInt(int _val, int _mn, int _mx): val(_val), mn(_mn), mx(_mx) {} + + void set(int v) + { + val = v; + } +}; + +struct PVector +{ + Fvector val; + float mn; + float mx; + + enum EType + { vNum, vAngle, vColor, _force_u32 = u32(-1), }; - EType type; - PVector (){val.set(0,0,0);mn=0.f;mx=0.f;} - PVector (EType t, Fvector _val, float _mn, float _mx):type(t),val(_val),mn(_mn),mx(_mx){} - void set(const Fvector& v){val.set(v);} - void set(float x, float y, float z){val.set(x,y,z);} + + EType type; + + PVector() + { + val.set(0, 0, 0); + mn = 0.f; + mx = 0.f; + } + + PVector(EType t, Fvector _val, float _mn, float _mx): type(t), val(_val), mn(_mn), mx(_mx) {} + + void set(const Fvector &v) + { + val.set(v); + } + + void set(float x, float y, float z) + { + val.set(x, y, z); + } }; + struct PDomain { public: - PAPI::PDomainEnum type; - union{ - float f[9]; - Fvector v[3]; + PAPI::PDomainEnum type; + + union + { + float f[9]; + Fvector v[3]; }; - enum EType{ + + enum EType + { vNum, vAngle, vColor, _force_u32 = u32(-1), }; - enum { - flRenderable = (1<<0) + + enum + { + flRenderable = (1<<0) }; - EType e_type; - Flags32 flags; - u32 clr; + + EType e_type; + Flags32 flags; + u32 clr; protected: - void __stdcall PDomain::OnTypeChange(PropValue* sender); + void __stdcall PDomain::OnTypeChange(PropValue *sender); public: - PDomain (){} - PDomain (EType et, BOOL renderable, u32 color=0x00000000, PAPI::PDomainEnum type = PAPI::PDPoint, - float inA0 = 0.0f, float inA1 = 0.0f, float inA2 = 0.0f, - float inA3 = 0.0f, float inA4 = 0.0f, float inA5 = 0.0f, - float inA6 = 0.0f, float inA7 = 0.0f, float inA8 = 0.0f ); - ~PDomain (); - PDomain (const PDomain &in); - - void MoveXYZ (float x, float y, float z); - void RotateXYZ (float x, float y, float z); - void ScaleXYZ (float x, float y, float z); - - Fvector& GetCenter(); - - void Load (IReader& F); - void Save (IWriter& F); - - void Load2 (CInifile& ini, const shared_str& sect); - void Save2 (CInifile& ini, const shared_str& sect); - - void Render (u32 color, const Fmatrix& parent); - void FillProp (PropItemVec& items, LPCSTR pref, u32 clr); + PDomain() {} + + PDomain(EType et, BOOL renderable, u32 color = 0x00000000, PAPI::PDomainEnum type = PAPI::PDPoint, + float inA0 = 0.0f, float inA1 = 0.0f, float inA2 = 0.0f, + float inA3 = 0.0f, float inA4 = 0.0f, float inA5 = 0.0f, + float inA6 = 0.0f, float inA7 = 0.0f, float inA8 = 0.0f); + ~PDomain(); + PDomain(const PDomain &in); + + void MoveXYZ(float x, float y, float z); + void RotateXYZ(float x, float y, float z); + void ScaleXYZ(float x, float y, float z); + + Fvector &GetCenter(); + + void Load(IReader &F); + void Save(IWriter &F); + + void Load2(CInifile &ini, const shared_str §); + void Save2(CInifile &ini, const shared_str §); + + void Render(u32 color, const Fmatrix &parent); + void FillProp(PropItemVec &items, LPCSTR pref, u32 clr); }; + struct EParticleAction { - DEFINE_MAP(AnsiString,PDomain, PDomainMap, PDomainMapIt); - DEFINE_MAP(AnsiString,PBool, PBoolMap, PBoolMapIt); - DEFINE_MAP(AnsiString,PFloat, PFloatMap, PFloatMapIt); - DEFINE_MAP(AnsiString,PInt, PIntMap, PIntMapIt); - DEFINE_MAP(AnsiString,PVector, PVectorMap, PVectorMapIt); - - shared_str actionName; - shared_str actionType; - shared_str hint; - enum{ - flEnabled = (1<<0), - flDraw = (1<<1), + DEFINE_MAP(AnsiString, PDomain, PDomainMap, PDomainMapIt); + DEFINE_MAP(AnsiString, PBool, PBoolMap, PBoolMapIt); + DEFINE_MAP(AnsiString, PFloat, PFloatMap, PFloatMapIt); + DEFINE_MAP(AnsiString, PInt, PIntMap, PIntMapIt); + DEFINE_MAP(AnsiString, PVector, PVectorMap, PVectorMapIt); + + shared_str actionName; + shared_str actionType; + shared_str hint; + + enum + { + flEnabled = (1<<0), + flDraw = (1<<1), }; - Flags32 flags; - PAPI::PActionEnum type; - PDomainMap domains; - PBoolMap bools; - PFloatMap floats; - PIntMap ints; - PVectorMap vectors; + Flags32 flags; + PAPI::PActionEnum type; + + PDomainMap domains; + PBoolMap bools; + PFloatMap floats; + PIntMap ints; + PVectorMap vectors; - enum EValType{ - tpDomain, + enum EValType + { + tpDomain, tpVector, tpFloat, tpBool, tpInt, }; - struct SOrder{ - EValType type; - AnsiString name; - SOrder(EValType _type, AnsiString _name):type(_type),name(_name){} + + struct SOrder + { + EValType type; + AnsiString name; + + SOrder(EValType _type, AnsiString _name): type(_type), name(_name) {} }; - DEFINE_VECTOR (SOrder, OrderVec, OrderVecIt); - OrderVec orders; - - EParticleAction (PAPI::PActionEnum _type) + + DEFINE_VECTOR(SOrder, OrderVec, OrderVecIt); + OrderVec orders; + + EParticleAction(PAPI::PActionEnum _type) + { + flags.assign(flEnabled); + type = _type; + } + +public: + void appendFloat(LPCSTR name, float v, float mn, float mx); + void appendInt(LPCSTR name, int v, int mn = -P_MAXINT, int mx = P_MAXINT); + void appendVector(LPCSTR name, PVector::EType type, float vx, float vy, float vz, float mn = -P_MAXFLOAT, float mx = P_MAXFLOAT); + void appendDomain(LPCSTR name, PDomain v); + void appendBool(LPCSTR name, BOOL b); + + PFloat &_float(LPCSTR name) + { + PFloatMapIt it = floats.find(name); + R_ASSERT2(it!=floats.end(), name); + return it->second; + } + + PInt &_int(LPCSTR name) + { + PIntMapIt it = ints.find(name); + R_ASSERT2(it!=ints.end(), name); + return it->second; + } + + PVector &_vector(LPCSTR name) + { + PVectorMapIt it = vectors.find(name); + R_ASSERT2(it!=vectors.end(), name); + return it->second; + } + + PDomain &_domain(LPCSTR name) { - flags.assign(flEnabled); - type = _type; + PDomainMapIt it = domains.find(name); + R_ASSERT2(it!=domains.end(), name); + return it->second; } + + PBool &_bool(LPCSTR name) + { + PBoolMapIt it = bools.find(name); + R_ASSERT2(it!=bools.end(), name); + return it->second; + } + + PBool *_bool_safe(LPCSTR name) + { + PBoolMapIt it = bools.find(name); + return (it!=bools.end()) ? &it->second : 0; + } + public: - void appendFloat (LPCSTR name, float v, float mn, float mx); - void appendInt (LPCSTR name, int v, int mn=-P_MAXINT, int mx=P_MAXINT); - void appendVector(LPCSTR name, PVector::EType type, float vx, float vy, float vz, float mn=-P_MAXFLOAT, float mx=P_MAXFLOAT); - void appendDomain(LPCSTR name, PDomain v); - void appendBool (LPCSTR name, BOOL b); - PFloat& _float (LPCSTR name){PFloatMapIt it=floats.find(name); R_ASSERT2(it!=floats.end(),name); return it->second;} - PInt& _int (LPCSTR name){PIntMapIt it=ints.find(name); R_ASSERT2(it!=ints.end(),name); return it->second;} - PVector& _vector (LPCSTR name){PVectorMapIt it=vectors.find(name); R_ASSERT2(it!=vectors.end(),name); return it->second;} - PDomain& _domain (LPCSTR name){PDomainMapIt it=domains.find(name); R_ASSERT2(it!=domains.end(),name); return it->second;} - PBool& _bool (LPCSTR name){PBoolMapIt it=bools.find(name); R_ASSERT2(it!=bools.end(),name); return it->second;} - PBool* _bool_safe (LPCSTR name){PBoolMapIt it=bools.find(name); return (it!=bools.end())?&it->second:0;} -public: - virtual void Compile (IWriter& F)=0; - virtual void FillProp (PropItemVec& items, LPCSTR pref, u32 clr); - - virtual void Load (IReader& F); - virtual void Save (IWriter& F); - virtual void Load2 (CInifile& ini, const shared_str& sect); - virtual void Save2 (CInifile& ini, const shared_str& sect); - virtual void Render (const Fmatrix& parent); + virtual void Compile(IWriter &F) =0; + virtual void FillProp(PropItemVec &items, LPCSTR pref, u32 clr); + + virtual void Load(IReader &F); + virtual void Save(IWriter &F); + virtual void Load2(CInifile &ini, const shared_str §); + virtual void Save2(CInifile &ini, const shared_str §); + virtual void Render(const Fmatrix &parent); }; struct EPAAvoid : public EParticleAction { - EPAAvoid (); - virtual void Compile (IWriter& F); + EPAAvoid(); + virtual void Compile(IWriter &F); }; - + struct EPABounce : public EParticleAction { - EPABounce (); - virtual void Compile (IWriter& F); + EPABounce(); + virtual void Compile(IWriter &F); }; struct EPACopyVertexB : public EParticleAction { - EPACopyVertexB(); - virtual void Compile (IWriter& F); + EPACopyVertexB(); + virtual void Compile(IWriter &F); }; struct EPADamping : public EParticleAction { - EPADamping (); - virtual void Compile (IWriter& F); + EPADamping(); + virtual void Compile(IWriter &F); }; struct EPAExplosion : public EParticleAction { - EPAExplosion(); - virtual void Compile (IWriter& F); + EPAExplosion(); + virtual void Compile(IWriter &F); }; struct EPAFollow : public EParticleAction { - EPAFollow (); - virtual void Compile (IWriter& F); + EPAFollow(); + virtual void Compile(IWriter &F); }; struct EPAGravitate : public EParticleAction { - EPAGravitate(); - virtual void Compile (IWriter& F); + EPAGravitate(); + virtual void Compile(IWriter &F); }; struct EPAGravity : public EParticleAction { - EPAGravity (); - virtual void Compile (IWriter& F); + EPAGravity(); + virtual void Compile(IWriter &F); }; struct EPAJet : public EParticleAction { - EPAJet (); - virtual void Compile (IWriter& F); - virtual void Render (const Fmatrix& parent); + EPAJet(); + virtual void Compile(IWriter &F); + virtual void Render(const Fmatrix &parent); }; struct EPAKillOld : public EParticleAction { - EPAKillOld (); - virtual void Compile (IWriter& F); + EPAKillOld(); + virtual void Compile(IWriter &F); }; struct EPAMatchVelocity : public EParticleAction { - EPAMatchVelocity(); - virtual void Compile (IWriter& F); + EPAMatchVelocity(); + virtual void Compile(IWriter &F); }; struct EPAMove : public EParticleAction { - EPAMove (); - virtual void Compile (IWriter& F); + EPAMove(); + virtual void Compile(IWriter &F); }; struct EPAOrbitLine : public EParticleAction { - EPAOrbitLine(); - virtual void Compile (IWriter& F); - virtual void Render (const Fmatrix& parent); + EPAOrbitLine(); + virtual void Compile(IWriter &F); + virtual void Render(const Fmatrix &parent); }; struct EPAOrbitPoint : public EParticleAction { - EPAOrbitPoint(); - virtual void Compile (IWriter& F); - virtual void Render (const Fmatrix& parent); + EPAOrbitPoint(); + virtual void Compile(IWriter &F); + virtual void Render(const Fmatrix &parent); }; struct EPARandomAccel : public EParticleAction { - EPARandomAccel(); - virtual void Compile (IWriter& F); + EPARandomAccel(); + virtual void Compile(IWriter &F); }; struct EPARandomDisplace : public EParticleAction { - EPARandomDisplace(); - virtual void Compile (IWriter& F); + EPARandomDisplace(); + virtual void Compile(IWriter &F); }; struct EPARandomVelocity : public EParticleAction { - EPARandomVelocity(); - virtual void Compile (IWriter& F); + EPARandomVelocity(); + virtual void Compile(IWriter &F); }; struct EPARestore : public EParticleAction { - EPARestore (); - virtual void Compile (IWriter& F); + EPARestore(); + virtual void Compile(IWriter &F); }; struct EPAScatter : public EParticleAction { - EPAScatter (); - virtual void Compile (IWriter& F); - virtual void Render (const Fmatrix& parent); + EPAScatter(); + virtual void Compile(IWriter &F); + virtual void Render(const Fmatrix &parent); }; struct EPASink : public EParticleAction { - EPASink (); - virtual void Compile (IWriter& F); + EPASink(); + virtual void Compile(IWriter &F); }; struct EPASinkVelocity : public EParticleAction { - EPASinkVelocity(); - virtual void Compile (IWriter& F); + EPASinkVelocity(); + virtual void Compile(IWriter &F); }; struct EPASpeedLimit : public EParticleAction { - EPASpeedLimit(); - virtual void Compile (IWriter& F); + EPASpeedLimit(); + virtual void Compile(IWriter &F); }; struct EPASource : public EParticleAction { - EPASource (); - virtual void Compile (IWriter& F); + EPASource(); + virtual void Compile(IWriter &F); }; struct EPATargetColor : public EParticleAction { - EPATargetColor(); - virtual void Compile (IWriter& F); + EPATargetColor(); + virtual void Compile(IWriter &F); }; struct EPATargetSize : public EParticleAction { - EPATargetSize(); - virtual void Compile (IWriter& F); + EPATargetSize(); + virtual void Compile(IWriter &F); }; struct EPATargetRotate : public EParticleAction { - EPATargetRotate(); - virtual void Compile (IWriter& F); + EPATargetRotate(); + virtual void Compile(IWriter &F); }; struct EPATargetVelocity : public EParticleAction { - EPATargetVelocity(); - virtual void Compile (IWriter& F); + EPATargetVelocity(); + virtual void Compile(IWriter &F); }; struct EPAVortex : public EParticleAction { - EPAVortex (); - virtual void Compile (IWriter& F); - virtual void Render (const Fmatrix& parent); + EPAVortex(); + virtual void Compile(IWriter &F); + virtual void Render(const Fmatrix &parent); }; struct EPATurbulence : public EParticleAction { - float ***nval; - float age; + float ***nval; + float age; public: - EPATurbulence(); - - virtual void Compile (IWriter& F); - virtual void Render (const Fmatrix& parent); + EPATurbulence(); + + virtual void Compile(IWriter &F); + virtual void Render(const Fmatrix &parent); }; -extern xr_token2 actions_token[]; +extern xr_token2 actions_token[]; -typedef EParticleAction* (*_CreateEAction)(PAPI::PActionEnum type); -extern ECORE_API _CreateEAction pCreateEAction; +typedef EParticleAction * (*_CreateEAction)(PAPI::PActionEnum type); +extern ECORE_API _CreateEAction pCreateEAction; //--------------------------------------------------------------------------- #endif /* - void pTargetVelocityD(float scale, PDomainEnum dtype, - float a0 = 0.0f, float a1 = 0.0f, float a2 = 0.0f, - float a3 = 0.0f, float a4 = 0.0f, float a5 = 0.0f, - float a6 = 0.0f, float a7 = 0.0f, float a8 = 0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE); + void pTargetVelocityD(float scale, PDomainEnum dtype, + float a0 = 0.0f, float a1 = 0.0f, float a2 = 0.0f, + float a3 = 0.0f, float a4 = 0.0f, float a5 = 0.0f, + float a6 = 0.0f, float a7 = 0.0f, float a8 = 0.0f, BOOL allow_translate=TRUE, BOOL allow_rotate=TRUE); - void pVertex(float x, float y, float z); + void pVertex(float x, float y, float z); } */ - diff --git a/src/editors/ECore/Editor/PhysicsShellHolderEditorBase.cpp b/src/editors/ECore/Editor/PhysicsShellHolderEditorBase.cpp index 7e5724eff74..79ffa6d52a6 100644 --- a/src/editors/ECore/Editor/PhysicsShellHolderEditorBase.cpp +++ b/src/editors/ECore/Editor/PhysicsShellHolderEditorBase.cpp @@ -2,8 +2,9 @@ #pragma hdrstop #include "PhysicsShellHolderEditorBase.h" -#include "../../xrphysics/physicsshell.h" -# include "GameMtlLib.h" +#include "xrPhysics/PhysicsShell.h" +#include "xrEngine/GameMtlLib.h" + //CObjectList Objects; static void SetBoneMaterials( IKinematics &K ) { diff --git a/src/editors/ECore/Editor/PhysicsShellHolderEditorBase.h b/src/editors/ECore/Editor/PhysicsShellHolderEditorBase.h index b75d67e1ca1..383c4e3ee27 100644 --- a/src/editors/ECore/Editor/PhysicsShellHolderEditorBase.h +++ b/src/editors/ECore/Editor/PhysicsShellHolderEditorBase.h @@ -1,7 +1,7 @@ #ifndef _PHYSICS_SHELL_HOLDER_EDITOR_BASE_ #define _PHYSICS_SHELL_HOLDER_EDITOR_BASE_ -#include "../../../xrphysics/iphysicsshellholder.h" +#include "xrPhysics/IPhysicsShellHolder.h" class ECORE_API CPhysicsShellHolderEditorBase: public IPhysicsShellHolder { diff --git a/src/editors/ECore/Editor/PropSlimTools.h b/src/editors/ECore/Editor/PropSlimTools.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Editor/PropSlimTools.h @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Editor/SkeletonFace.h b/src/editors/ECore/Editor/SkeletonFace.h index 90260758b90..127f5af58e1 100644 --- a/src/editors/ECore/Editor/SkeletonFace.h +++ b/src/editors/ECore/Editor/SkeletonFace.h @@ -5,30 +5,42 @@ #include "SkeletonVert.h" struct st_SFACE; -void RegisterSFACE(st_SFACE* f); - -struct st_SFACE { - st_SVERT* v[3]; - DWORD m; - - st_SFACE(){ - RegisterSFACE(this); - } - void VSet(int id, st_SVERT* V){ - v[id]=V; - } - void SetVerts(st_SVERT* v1, st_SVERT* v2, st_SVERT* v3) - { - VSet(0,v1); - VSet(1,v2); - VSet(2,v3); - } - void ReplaceVert(st_SVERT* from, st_SVERT* to) - { - if (v[0]==from) VSet(0,to); - if (v[1]==from) VSet(1,to); - if (v[2]==from) VSet(2,to); - } +void RegisterSFACE(st_SFACE *f); + +struct st_SFACE +{ + st_SVERT *v[3]; + DWORD m; + + st_SFACE() + { + RegisterSFACE(this); + } + + void VSet(int id, st_SVERT *V) + { + v[id] = V; + } + + void SetVerts(st_SVERT *v1, st_SVERT *v2, st_SVERT *v3) + { + VSet(0, v1); + VSet(1, v2); + VSet(2, v3); + } + + void ReplaceVert(st_SVERT *from, st_SVERT *to) + { + if (v[0]==from) + VSet(0, to); + if (v[1]==from) + VSet(1, to); + if (v[2]==from) + VSet(2, to); + } }; -DEFINE_VECTOR(st_SFACE*,vSFACE,SFACEIt); + +DEFINE_VECTOR(st_SFACE *, vSFACE, SFACEIt); #endif // _SkeletonFace_H_ + + diff --git a/src/editors/ECore/Editor/SkeletonVert.h b/src/editors/ECore/Editor/SkeletonVert.h index 9fb07157660..6e97fad9cfa 100644 --- a/src/editors/ECore/Editor/SkeletonVert.h +++ b/src/editors/ECore/Editor/SkeletonVert.h @@ -3,45 +3,66 @@ #pragma once struct st_SVERT; -void RegisterSVERT(st_SVERT* v); +void RegisterSVERT(st_SVERT *v); -const DWORD BONE_NONE = 0xffffffff; +const DWORD BONE_NONE = 0xffffffff; -struct st_SVERT { - Fvector P; - Fvector O; - Fvector N; - DWORD sm_group; +struct st_SVERT +{ + Fvector P; + Fvector O; + Fvector N; + DWORD sm_group; Fvector2Vec uv; - DWORD bone; + DWORD bone; - st_SVERT(){ - P.set (0,0,0); - N.set (0,1,0); + st_SVERT() + { + P.set(0, 0, 0); + N.set(0, 1, 0); uv.clear(); - bone = BONE_NONE; - RegisterSVERT(this); - } - void AppendUV(float _u, float _v){ - uv.push_back(Fvector2()); - uv.back().set(_u,_v); - } - void SetBone(DWORD B){ - if (bone==BONE_NONE){ - bone = B; - } else R_ASSERT(bone==B); - } - BOOL similar(st_SVERT& V){ - if (bone!=V.bone) return FALSE; - if (uv.size()!=V.uv.size()) return FALSE; - for(DWORD i=0; iSetModifiedEvent (fastdelegate::bind(this,&TfrmSoundLib::OnModified)); - m_ItemList = TItemList::CreateForm ("Items",paItems,alClient,TItemList::ilMultiSelect/*|TItemList::ilEditMenu|TItemList::ilDragAllowed*/); - m_ItemList->SetOnItemsFocusedEvent (fastdelegate::bind(this,&TfrmSoundLib::OnItemsFocused)); - TOnItemRemove on_remove; on_remove.bind (this,&TfrmSoundLib::RemoveSound); - TOnItemRename on_rename; on_rename.bind (this,&TfrmSoundLib::RenameSound); - m_ItemList->SetOnItemRemoveEvent (on_remove); - m_ItemList->SetOnItemRenameEvent (on_rename); - m_ItemList->SetImages (ImageList); - bAutoPlay = FALSE; + m_ItemProps = TProperties::CreateForm("SoundED", paProperties, alClient); + m_ItemProps->SetModifiedEvent(fastdelegate::bind(this, &TfrmSoundLib::OnModified)); + m_ItemList = TItemList::CreateForm("Items", paItems, alClient, TItemList::ilMultiSelect/*|TItemList::ilEditMenu|TItemList::ilDragAllowed*/); + m_ItemList->SetOnItemsFocusedEvent(fastdelegate::bind(this, &TfrmSoundLib::OnItemsFocused)); + TOnItemRemove on_remove; + on_remove.bind(this, &TfrmSoundLib::RemoveSound); + TOnItemRename on_rename; + on_rename.bind(this, &TfrmSoundLib::RenameSound); + m_ItemList->SetOnItemRemoveEvent(on_remove); + m_ItemList->SetOnItemRenameEvent(on_rename); + m_ItemList->SetImages(ImageList); + bAutoPlay = FALSE; } + //--------------------------------------------------------------------------- void __fastcall TfrmSoundLib::FormDestroy(TObject *Sender) { TProperties::DestroyForm(m_ItemProps); - TItemList::DestroyForm (m_ItemList); - m_Snd.destroy (); + TItemList::DestroyForm(m_ItemList); + m_Snd.destroy(); } + //--------------------------------------------------------------------------- -void __fastcall TfrmSoundLib::EditLib(AnsiString& title) +void __fastcall TfrmSoundLib::EditLib(AnsiString &title) { - if (!form){ - form = xr_new((TComponent*)0); - form->Caption = title; - form->modif_map.clear(); - m_Flags.zero (); - form->InitItemsList (); - if (!FS.can_write_to_alias(_sounds_)){ - Log ("#!You don't have permisions to modify sounds."); - form->ebOk->Enabled = false; - form->m_ItemProps->SetReadOnly (TRUE); - m_Flags.set (flReadOnly,TRUE); - form->bAutoPlay = TRUE; + if (!form) + { + form = xr_new((TComponent*)0); + form->Caption = title; + form->modif_map.clear(); + m_Flags.zero(); + form->InitItemsList(); + if (!FS.can_write_to_alias(_sounds_)) + { + Log("#!You don't have permisions to modify sounds."); + form->ebOk->Enabled = false; + form->m_ItemProps->SetReadOnly(TRUE); + m_Flags.set(flReadOnly, TRUE); + form->bAutoPlay = TRUE; } } - form->ShowModal (); - UI->RedrawScene (); + form->ShowModal(); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- void TfrmSoundLib::OnModified() { - m_ItemProps->RefreshForm(); + m_ItemProps->RefreshForm(); } + //--------------------------------------------------------------------------- void __fastcall TfrmSoundLib::UpdateLib() { - RegisterModifiedTHM (); - SaveUsedTHM (); + RegisterModifiedTHM(); + SaveUsedTHM(); // save game sounds - if (modif_map.size()){ - AStringVec modif; - LockForm (); - SndLib->SynchronizeSounds (true,true,true,&modif_map,0); -// SndLib->ChangeFileAgeTo (&modif_map,time(NULL)); - UnlockForm (); + if (modif_map.size()) + { + AStringVec modif; + LockForm(); + SndLib->SynchronizeSounds(true, true, true, &modif_map, 0); + // SndLib->ChangeFileAgeTo (&modif_map,time(NULL)); + UnlockForm(); SndLib->RefreshSounds(false); - modif_map.clear (); + modif_map.clear(); } } bool __fastcall TfrmSoundLib::HideLib() { - if (form){ - form->Close(); - modif_map.clear(); + if (form) + { + form->Close(); + modif_map.clear(); } return true; } + //--------------------------------------------------------------------------- void TfrmSoundLib::AppendModif(LPCSTR nm) { - FS_File dest; - string_path fname; - FS.update_path (fname,_sounds_,ChangeFileExt(nm,".wav").c_str()); - BOOL bFind = FS.file_find(fname,dest); R_ASSERT(bFind); + FS_File dest; + string_path fname; + FS.update_path(fname, _sounds_, ChangeFileExt(nm, ".wav").c_str()); + BOOL bFind = FS.file_find(fname, dest); + R_ASSERT(bFind); modif_map.insert(dest); } + //--------------------------------------------------------------------------- -void TfrmSoundLib::RemoveSound(LPCSTR fname, EItemType type, bool& res) +void TfrmSoundLib::RemoveSound(LPCSTR fname, EItemType type, bool &res) { - // delete it from modif map - FS_FileSetIt it=modif_map.find(FS_File(fname)); - if (it!=modif_map.end()) modif_map.erase(it); - // remove sound source - res = SndLib->RemoveSound(fname,type); + // delete it from modif map + FS_FileSetIt it = modif_map.find(FS_File(fname)); + if (it!=modif_map.end()) + modif_map.erase(it); + // remove sound source + res = SndLib->RemoveSound(fname, type); } + //--------------------------------------------------------------------------- void TfrmSoundLib::RenameSound(LPCSTR p0, LPCSTR p1, EItemType type) { // rename sound source - SndLib->RenameSound(p0,p1,type); - // delete old from map - FS_FileSetIt old_it=modif_map.find(FS_File(p0)); - if (old_it!=modif_map.end()){ - modif_map.erase (old_it); - AppendModif (p1); - } + SndLib->RenameSound(p0, p1, type); + // delete old from map + FS_FileSetIt old_it = modif_map.find(FS_File(p0)); + if (old_it!=modif_map.end()) + { + modif_map.erase(old_it); + AppendModif(p1); + } } + //--------------------------------------------------------------------------- void __fastcall TfrmSoundLib::FormShow(TObject *Sender) { - // check window position - UI->CheckWindowPos (this); + // check window position + UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- void __fastcall TfrmSoundLib::FormClose(TObject *Sender, TCloseAction &Action) { - if (!form) return; - form->Enabled = false; - DestroyUsedTHM (); - form = 0; - Action = caFree; + if (!form) + return; + form->Enabled = false; + DestroyUsedTHM(); + form = 0; + Action = caFree; } + //--------------------------------------------------------------------------- void TfrmSoundLib::InitItemsList() { - FS_FileSet sound_map; - SndLib->GetSounds(sound_map,TRUE); + FS_FileSet sound_map; + SndLib->GetSounds(sound_map, TRUE); - ListItemsVec items; + ListItemsVec items; // fill items - FS_FileSetIt it = sound_map.begin(); - FS_FileSetIt _E = sound_map.end(); + FS_FileSetIt it = sound_map.begin(); + FS_FileSetIt _E = sound_map.end(); for (; it!=_E; it++) - LHelper().CreateItem(items,it->name.c_str(),0); + LHelper().CreateItem(items, it->name.c_str(), 0); - m_ItemList->AssignItems(items,false,true); + m_ItemList->AssignItems(items, false, true); } //--------------------------------------------------------------------------- void __fastcall TfrmSoundLib::FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) -{ - if (Shift.Contains(ssCtrl)){ - if (Key==VK_CANCEL) ExecCommand(COMMAND_BREAK_LAST_OPERATION); - }else{ - if (Key==VK_ESCAPE){ - if (bFormLocked) ExecCommand(COMMAND_BREAK_LAST_OPERATION); + TShiftState Shift) +{ + if (Shift.Contains(ssCtrl)) + { + if (Key==VK_CANCEL) + ExecCommand(COMMAND_BREAK_LAST_OPERATION); + } + else + { + if (Key==VK_ESCAPE) + { + if (bFormLocked) + ExecCommand(COMMAND_BREAK_LAST_OPERATION); Key = 0; // :-) íóæíî äëÿ òîãî ÷òîáû AccessVoilation íå âûëàçèë ïî ESCAPE } } } + //--------------------------------------------------------------------------- void __fastcall TfrmSoundLib::ebOkClick(TObject *Sender) { - if (bFormLocked) return; - m_Snd.destroy (); - - UpdateLib (); - HideLib (); + if (bFormLocked) + return; + m_Snd.destroy(); + + UpdateLib(); + HideLib(); } + //--------------------------------------------------------------------------- void __fastcall TfrmSoundLib::ebCancelClick(TObject *Sender) { - if (bFormLocked){ - ExecCommand(COMMAND_BREAK_LAST_OPERATION); - return; + if (bFormLocked) + { + ExecCommand(COMMAND_BREAK_LAST_OPERATION); + return; } - HideLib (); + HideLib(); } + //--------------------------------------------------------------------------- -ESoundThumbnail* TfrmSoundLib::FindUsedTHM(LPCSTR name) +ESoundThumbnail *TfrmSoundLib::FindUsedTHM(LPCSTR name) { - for (THMIt it=m_THM_Used.begin(); it!=m_THM_Used.end(); it++) - if (0==strcmp((*it)->SrcName(),name)) return *it; + for (THMIt it = m_THM_Used.begin(); it!=m_THM_Used.end(); it++) + if (0==strcmp((*it)->SrcName(), name)) + return *it; return 0; } + //--------------------------------------------------------------------------- void TfrmSoundLib::SaveUsedTHM() { - int m_age = time(NULL); - for (THMIt t_it=m_THM_Used.begin(); t_it!=m_THM_Used.end(); t_it++) - (*t_it)->Save(m_age,0); + int m_age = time(NULL); + for (THMIt t_it = m_THM_Used.begin(); t_it!=m_THM_Used.end(); t_it++) + (*t_it)->Save(m_age, 0); } + //--------------------------------------------------------------------------- void __fastcall TfrmSoundLib::RegisterModifiedTHM() { - if (m_ItemProps->IsModified()){ - for (THMIt t_it=m_THM_Current.begin(); t_it!=m_THM_Current.end(); t_it++){ -//. (*t_it)->Save (0,0); - AppendModif ((*t_it)->SrcName()); + if (m_ItemProps->IsModified()) + { + for (THMIt t_it = m_THM_Current.begin(); t_it!=m_THM_Current.end(); t_it++) + { + //. (*t_it)->Save (0,0); + AppendModif((*t_it)->SrcName()); } } } void __fastcall TfrmSoundLib::fsStorageRestorePlacement(TObject *Sender) { - m_ItemProps->RestoreParams(fsStorage); + m_ItemProps->RestoreParams(fsStorage); m_ItemList->LoadParams(fsStorage); - if (!m_Flags.is(flReadOnly)){ - bAutoPlay = fsStorage->ReadInteger("auto_play",FALSE); + if (!m_Flags.is(flReadOnly)) + { + bAutoPlay = fsStorage->ReadInteger("auto_play", FALSE); } } + //--------------------------------------------------------------------------- void __fastcall TfrmSoundLib::fsStorageSavePlacement(TObject *Sender) { - m_ItemProps->SaveParams(fsStorage); + m_ItemProps->SaveParams(fsStorage); m_ItemList->SaveParams(fsStorage); - if (!m_Flags.is(flReadOnly)){ - fsStorage->WriteInteger("auto_play",bAutoPlay); + if (!m_Flags.is(flReadOnly)) + { + fsStorage->WriteInteger("auto_play", bAutoPlay); } } + //--------------------------------------------------------------------------- -void __fastcall TfrmSoundLib::OnControlClick(ButtonValue* V, bool& bModif, bool& bSafe) +void __fastcall TfrmSoundLib::OnControlClick(ButtonValue *V, bool &bModif, bool &bSafe) { - switch (V->btn_num){ - case 0: m_Snd.play(0,sm_2D); break; - case 1: m_Snd.stop(); break; - case 2:{ - bAutoPlay=!bAutoPlay; - V->value[V->btn_num] = shared_str().printf("Auto (%s)",bAutoPlay?"on":"off"); - }break; - } + switch (V->btn_num) + { + case 0: m_Snd.play(0, sm_2D); + break; + case 1: m_Snd.stop(); + break; + case 2: + { + bAutoPlay = !bAutoPlay; + V->value[V->btn_num] = shared_str().printf("Auto (%s)", bAutoPlay ? "on" : "off"); + } + break; + } bModif = false; } + //------------------------------------------------------------------------------ -void __fastcall TfrmSoundLib::OnControl2Click(ButtonValue* V, bool& bModif, bool& bSafe) +void __fastcall TfrmSoundLib::OnControl2Click(ButtonValue *V, bool &bModif, bool &bSafe) { - switch (V->btn_num){ - case 0:{ - bAutoPlay=!bAutoPlay; - V->value[V->btn_num] = bAutoPlay?"on":"off"; - }break; - } + switch (V->btn_num) + { + case 0: + { + bAutoPlay = !bAutoPlay; + V->value[V->btn_num] = bAutoPlay ? "on" : "off"; + } + break; + } bModif = false; } + //------------------------------------------------------------------------------ void TfrmSoundLib::DestroyUsedTHM() { - for (THMIt it=m_THM_Used.begin(); it!=m_THM_Used.end(); it++) - xr_delete(*it); + for (THMIt it = m_THM_Used.begin(); it!=m_THM_Used.end(); it++) + xr_delete(*it); m_THM_Used.clear(); } + //------------------------------------------------------------------------------ #define X_GRID 10 #define Y_GRID 5 -void TfrmSoundLib::OnAttenuationDraw(CanvasValue* sender, void* _canvas, const Irect& _rect) + +void TfrmSoundLib::OnAttenuationDraw(CanvasValue *sender, void *_canvas, const Irect &_rect) { - TCanvas* canvas = (TCanvas*)_canvas; - const TRect& rect = *((TRect*)&_rect); -// canvas + TCanvas *canvas = (TCanvas*)_canvas; + const TRect &rect = *((TRect*)&_rect); + // canvas int w = rect.Width(); int h = rect.Height(); - int x0= rect.left; - int y0= rect.top; + int x0 = rect.left; + int y0 = rect.top; canvas->Brush->Color = clBlack; canvas->FillRect(rect); canvas->Pen->Color = TColor(0x00006600); - canvas->MoveTo(x0,y0); - for (int i=0; iLineTo(x0+i*w/X_GRID,y0+h); - canvas->MoveTo(x0+(i+1)*w/X_GRID,y0+0); + canvas->MoveTo(x0, y0); + for (int i = 0; iLineTo(x0+i*w/X_GRID, y0+h); + canvas->MoveTo(x0+(i+1)*w/X_GRID, y0+0); } - canvas->MoveTo(x0+0,y0+0); - for (int j=0; jLineTo(x0+w,y0+j*h/Y_GRID); - canvas->MoveTo(x0+0,y0+(j+1)*h/Y_GRID); + canvas->MoveTo(x0+0, y0+0); + for (int j = 0; jLineTo(x0+w, y0+j*h/Y_GRID); + canvas->MoveTo(x0+0, y0+(j+1)*h/Y_GRID); } canvas->Pen->Color = clYellow; - canvas->MoveTo(x0+0,y0+iFloor(float(h)-float(h)*0.01f)); // snd cull = 0.01f - canvas->LineTo(x0+w,y0+iFloor(float(h)-float(h)*0.01f)); + canvas->MoveTo(x0+0, y0+iFloor(float(h)-float(h)*0.01f)); // snd cull = 0.01f + canvas->LineTo(x0+w, y0+iFloor(float(h)-float(h)*0.01f)); - ESoundThumbnail* thm = m_THM_Current.back(); - float d_cost = thm->MaxDist()/w; + ESoundThumbnail*thm = m_THM_Current.back(); + float d_cost = thm->MaxDist()/w; AnsiString temp; -// float v = m_D3D.range; -// temp.sprintf("Range = %.2f",v); lbRange->Caption = temp; + // float v = m_D3D.range; + // temp.sprintf("Range = %.2f",v); lbRange->Caption = temp; canvas->Pen->Color = clLime; - for (int d=1; dMinDist()/(psSoundRolloff*R); -// float b = m_Brightness/(m_Attenuation0+m_Attenuation1*R+m_Attenuation2*R*R); + float b = thm->MinDist()/(psSoundRolloff*R); + // float b = m_Brightness/(m_Attenuation0+m_Attenuation1*R+m_Attenuation2*R*R); float bb = h-(h*b); - int y = iFloor(y0+bb); clamp(y,int(rect.Top),int(rect.Bottom)); - if (1==d) canvas->MoveTo(x0+d,y); - else canvas->LineTo(x0+d,y); + int y = iFloor(y0+bb); + clamp(y, int(rect.Top), int(rect.Bottom)); + if (1==d) + canvas->MoveTo(x0+d, y); + else + canvas->LineTo(x0+d, y); } } -void __stdcall TfrmSoundLib::OnAttClick(ButtonValue* V, bool& bModif, bool& bSafe) +void __stdcall TfrmSoundLib::OnAttClick(ButtonValue *V, bool &bModif, bool &bSafe) { bModif = true; - ESoundThumbnail* thm = m_THM_Current.back(); - switch (V->btn_num){ - case 0:{ - float dist = thm->MinDist()/(0.01f*psSoundRolloff); - thm->SetMaxDist (dist+0.1f*dist); - }break; - case 1:{ - float dist = psSoundRolloff*(thm->MaxDist()-(0.1f/1.1f)*thm->MaxDist())*0.01f; - thm->SetMinDist (dist); - }break; - } + ESoundThumbnail*thm = m_THM_Current.back(); + switch (V->btn_num) + { + case 0: + { + float dist = thm->MinDist()/(0.01f*psSoundRolloff); + thm->SetMaxDist(dist+0.1f*dist); + } + break; + case 1: + { + float dist = psSoundRolloff*(thm->MaxDist()-(0.1f/1.1f)*thm->MaxDist())*0.01f; + thm->SetMinDist(dist); + } + break; + } } -void __fastcall TfrmSoundLib::OnItemsFocused(ListItemsVec& items) +void __fastcall TfrmSoundLib::OnItemsFocused(ListItemsVec &items) { - PropItemVec props; - - RegisterModifiedTHM (); - m_Snd.destroy (); - m_THM_Current.clear (); - - if (!items.empty()){ - for (ListItemsIt it=items.begin(); it!=items.end(); it++){ - ListItem* prop = *it; - if (prop){ - ESoundThumbnail* thm=FindUsedTHM(prop->Key()); - if (!thm) m_THM_Used.push_back(thm=xr_new(prop->Key())); + PropItemVec props; + + RegisterModifiedTHM(); + m_Snd.destroy(); + m_THM_Current.clear(); + + if (!items.empty()) + { + for (ListItemsIt it = items.begin(); it!=items.end(); it++) + { + ListItem *prop = *it; + if (prop) + { + ESoundThumbnail*thm = FindUsedTHM(prop->Key()); + if (!thm) + m_THM_Used.push_back(thm = xr_new(prop->Key())); m_THM_Current.push_back(thm); - thm->FillProp (props); + thm->FillProp(props); } } } - ButtonValue* B=0; + ButtonValue *B = 0; if (m_THM_Current.size()==1) { - ESoundThumbnail* thm=m_THM_Current.back(); - u32 size=0; - u32 time=0; + ESoundThumbnail*thm = m_THM_Current.back(); + u32 size = 0; + u32 time = 0; PlaySound(thm->SrcName(), size, time); - CanvasValue* C=0; - C=PHelper().CreateCanvas (props,"Attenuation", "", 64); - C->tag = (int)this; - C->OnDrawCanvasEvent.bind (this,&TfrmSoundLib::OnAttenuationDraw); -// C->OnTestEqual.bind (this,&TfrmSoundLib::OnPointDataTestEqual); - B=PHelper().CreateButton (props,"Auto Att", "By Min,By Max",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&TfrmSoundLib::OnAttClick); - - PHelper().CreateCaption (props,"File Length", shared_str().printf("%.2f Kb",float(size)/1024.f)); - PHelper().CreateCaption (props,"Total Time", shared_str().printf("%.2f sec",float(time)/1000.f)); - if (!m_Flags.is(flReadOnly)){ - B=PHelper().CreateButton(props,"Control", "Play,Stop",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&TfrmSoundLib::OnControlClick); + CanvasValue *C = 0; + C = PHelper().CreateCanvas(props, "Attenuation", "", 64); + C->tag = (int)this; + C->OnDrawCanvasEvent.bind(this, &TfrmSoundLib::OnAttenuationDraw); + // C->OnTestEqual.bind (this,&TfrmSoundLib::OnPointDataTestEqual); + B = PHelper().CreateButton(props, "Auto Att", "By Min,By Max", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &TfrmSoundLib::OnAttClick); + + PHelper().CreateCaption(props, "File Length", shared_str().printf("%.2f Kb", float(size)/1024.f)); + PHelper().CreateCaption(props, "Total Time", shared_str().printf("%.2f sec", float(time)/1000.f)); + if (!m_Flags.is(flReadOnly)) + { + B = PHelper().CreateButton(props, "Control", "Play,Stop", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &TfrmSoundLib::OnControlClick); } } if (!m_Flags.is(flReadOnly)) { - B=PHelper().CreateButton (props,"Auto Play", bAutoPlay?"on":"off",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&TfrmSoundLib::OnControl2Click); + B = PHelper().CreateButton(props, "Auto Play", bAutoPlay ? "on" : "off", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &TfrmSoundLib::OnControl2Click); } - if (!m_Flags.is(flReadOnly) && m_THM_Current.size()) + if (!m_Flags.is(flReadOnly)&&m_THM_Current.size()) { - B=PHelper().CreateButton(props,"MANAGE", "SyncCurrent", ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&TfrmSoundLib::OnSyncCurrentClick); + B = PHelper().CreateButton(props, "MANAGE", "SyncCurrent", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &TfrmSoundLib::OnSyncCurrentClick); } - m_ItemProps->AssignItems (props); + m_ItemProps->AssignItems(props); } + //--------------------------------------------------------------------------- -void TfrmSoundLib::PlaySound(LPCSTR name, u32& size, u32& time) +void TfrmSoundLib::PlaySound(LPCSTR name, u32 &size, u32 &time) { - string_path fname; - FS.update_path (fname,_game_sounds_,ChangeFileExt(name,".ogg").c_str()); + string_path fname; + FS.update_path(fname, _game_sounds_, ChangeFileExt(name, ".ogg").c_str()); FS_File F; - if (FS.file_find(fname,F)) + if (FS.file_find(fname, F)) { - m_Snd.create (name,st_Effect,sg_Undefined); - m_Snd.play (0,sm_2D); - CSoundRender_Source* src= (CSoundRender_Source*)m_Snd._handle(); VERIFY(src); - size = F.size; - time = iFloor(src->fTimeTotal/1000.0f); - if (!bAutoPlay) m_Snd.stop(); + m_Snd.create(name, st_Effect, sg_Undefined); + m_Snd.play(0, sm_2D); + CSoundRender_Source *src = (CSoundRender_Source*)m_Snd._handle(); + VERIFY(src); + size = F.size; + time = iFloor(src->fTimeTotal/1000.0f); + if (!bAutoPlay) + m_Snd.stop(); } } void TfrmSoundLib::OnFrame() { - if (form){ - if (m_Flags.is(flUpdateProperties)){ - form->m_ItemList->FireOnItemFocused(); - m_Flags.set(flUpdateProperties,FALSE); + if (form) + { + if (m_Flags.is(flUpdateProperties)) + { + form->m_ItemList->FireOnItemFocused(); + m_Flags.set(flUpdateProperties, FALSE); } } } -void __fastcall TfrmSoundLib::OnSyncCurrentClick(ButtonValue* V, bool& bModif, bool& bSafe) +void __fastcall TfrmSoundLib::OnSyncCurrentClick(ButtonValue *V, bool &bModif, bool &bSafe) { -//. - THMIt it = m_THM_Current.begin(); - THMIt it_e = m_THM_Current.end(); + //. + THMIt it = m_THM_Current.begin(); + THMIt it_e = m_THM_Current.end(); - for(;it!=it_e; ++it) + for (; it!=it_e; ++it) { - ESoundThumbnail* pTHM = *it; + ESoundThumbnail*pTHM = *it; - string_path src_name, game_name; - FS.update_path (src_name,_sounds_,pTHM->SrcName()); - strconcat (sizeof(src_name),src_name,src_name,".wav"); + string_path src_name, game_name; + FS.update_path(src_name, _sounds_, pTHM->SrcName()); + strconcat(sizeof(src_name), src_name, src_name, ".wav"); - FS.update_path (game_name,_game_sounds_,pTHM->SrcName()); - strconcat (sizeof(game_name),game_name,game_name,".ogg"); + FS.update_path(game_name, _game_sounds_, pTHM->SrcName()); + strconcat(sizeof(game_name), game_name, game_name, ".ogg"); - Msg ("synchronizing [%s]", game_name); - SndLib->MakeGameSound (pTHM, src_name, game_name); + Msg("synchronizing [%s]", game_name); + SndLib->MakeGameSound(pTHM, src_name, game_name); } - Msg ("Done."); + Msg("Done."); } diff --git a/src/editors/ECore/Editor/SoundEditor.h b/src/editors/ECore/Editor/SoundEditor.h index 05222f0a136..4a1ef30baa7 100644 --- a/src/editors/ECore/Editor/SoundEditor.h +++ b/src/editors/ECore/Editor/SoundEditor.h @@ -19,87 +19,112 @@ // refs class ESoundThumbnail; class TProperties; + //--------------------------------------------------------------------------- class TfrmSoundLib : public TForm { -__published: // IDE-managed Components - TPanel *paRight; - TFormStorage *fsStorage; - TPanel *paCommand; - TExtBtn *ebOk; - TPanel *paProperties; - TPanel *paItems; - TSplitter *Splitter1; - TImageList *ImageList; - TExtBtn *ebCancel; - TPanel *Panel1; - TPanel *Panel3; + __published: // IDE-managed Components + TPanel*paRight; + TFormStorage *fsStorage; + TPanel *paCommand; + TExtBtn *ebOk; + TPanel *paProperties; + TPanel *paItems; + TSplitter *Splitter1; + TImageList *ImageList; + TExtBtn *ebCancel; + TPanel *Panel1; + TPanel *Panel3; void __fastcall ebOkClick(TObject *Sender); void __fastcall FormShow(TObject *Sender); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); - void __fastcall FormCreate(TObject *Sender); - void __fastcall ebCancelClick(TObject *Sender); - void __fastcall FormDestroy(TObject *Sender); + TShiftState Shift); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); + void __fastcall FormCreate(TObject *Sender); + void __fastcall ebCancelClick(TObject *Sender); + void __fastcall FormDestroy(TObject *Sender); private: -// list functions - void InitItemsList (); - void __stdcall OnItemsFocused (ListItemsVec& items); - - void __stdcall RemoveSound (LPCSTR fname, EItemType type, bool& res); - void __stdcall RenameSound (LPCSTR p0, LPCSTR p1, EItemType type); - - enum{ - flUpdateProperties = (1<<0), - flReadOnly = (1<<1), - }; - static Flags32 m_Flags; -private: // User declarations - static TfrmSoundLib* form; - - DEFINE_VECTOR (ESoundThumbnail*,THMVec,THMIt); - THMVec m_THM_Used; - THMVec m_THM_Current; - TItemList* m_ItemList; - TProperties* m_ItemProps; - - ESoundThumbnail* FindUsedTHM (LPCSTR name); - void SaveUsedTHM (); - void DestroyUsedTHM (); - - void __fastcall RegisterModifiedTHM (); - - void OnModified (); - void __fastcall UpdateLib (); - - bool bFormLocked; - BOOL bAutoPlay; - - void LockForm (){ bFormLocked = true; form->paProperties->Enabled = false; form->paItems->Enabled = false; } - void UnlockForm (){ bFormLocked = false; form->paProperties->Enabled = true; form->paItems->Enabled = true; } - - static FS_FileSet modif_map; - ref_sound m_Snd; - void PlaySound (LPCSTR name, u32& size, u32& time); - void __stdcall OnControlClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnControl2Click (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnSyncCurrentClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnAttClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnAttenuationDraw (CanvasValue* sender, void* _canvas, const Irect& _rect); - - void AppendModif (LPCSTR nm); -public: // User declarations - __fastcall TfrmSoundLib (TComponent* Owner); -// static function - static void __fastcall EditLib (AnsiString& title); - static bool __fastcall HideLib (); - static bool __fastcall Visible (){return !!form;} - static void OnFrame (); - static void UpdateProperties (){m_Flags.set(flUpdateProperties,TRUE);} + // list functions + void InitItemsList(); + void __stdcall OnItemsFocused(ListItemsVec &items); + + void __stdcall RemoveSound(LPCSTR fname, EItemType type, bool &res); + void __stdcall RenameSound(LPCSTR p0, LPCSTR p1, EItemType type); + + enum + { + flUpdateProperties = (1<<0), + flReadOnly = (1<<1), + }; + + static Flags32 m_Flags; +private: // User declarations + static TfrmSoundLib *form; + + DEFINE_VECTOR(ESoundThumbnail *, THMVec, THMIt); + THMVec m_THM_Used; + THMVec m_THM_Current; + TItemList *m_ItemList; + TProperties *m_ItemProps; + + ESoundThumbnail *FindUsedTHM(LPCSTR name); + void SaveUsedTHM(); + void DestroyUsedTHM(); + + void __fastcall RegisterModifiedTHM(); + + void OnModified(); + void __fastcall UpdateLib(); + + bool bFormLocked; + BOOL bAutoPlay; + + void LockForm() + { + bFormLocked = true; + form->paProperties->Enabled = false; + form->paItems->Enabled = false; + } + + void UnlockForm() + { + bFormLocked = false; + form->paProperties->Enabled = true; + form->paItems->Enabled = true; + } + + static FS_FileSet modif_map; + ref_sound m_Snd; + void PlaySound(LPCSTR name, u32 &size, u32 &time); + void __stdcall OnControlClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnControl2Click(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnSyncCurrentClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnAttClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnAttenuationDraw(CanvasValue *sender, void *_canvas, const Irect &_rect); + + void AppendModif(LPCSTR nm); +public: // User declarations + __fastcall TfrmSoundLib(TComponent *Owner); + // static function + static void __fastcall EditLib(AnsiString &title); + static bool __fastcall HideLib(); + + static bool __fastcall Visible() + { + return !!form; + } + + static void OnFrame(); + + static void UpdateProperties() + { + m_Flags.set(flUpdateProperties, TRUE); + } }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ECore/Editor/SoundManager.cpp b/src/editors/ECore/Editor/SoundManager.cpp index 5a6929d3a80..534b86cf8f6 100644 --- a/src/editors/ECore/Editor/SoundManager.cpp +++ b/src/editors/ECore/Editor/SoundManager.cpp @@ -2,118 +2,134 @@ #pragma hdrstop #include "SoundManager.h" -#include "../../../xrSound/soundrender_environment.h" +#include "xrSound/SoundRender_Environment.h" #include "EThumbnail.h" #include "ui_main.h" -CSoundManager* SndLib=0; +CSoundManager *SndLib = 0; //--------------------------------------------------------------------------- #pragma package(smart_init) -extern "C" int ogg_enc(const char* in_fn, const char* out_fn, float quality, void* comment, int size); +extern "C" int ogg_enc(const char *in_fn, const char *out_fn, float quality, void *comment, int size); + //------------------------------------------------------------------------------ -xr_string CSoundManager::UpdateFileName(xr_string& fn) +xr_string CSoundManager::UpdateFileName(xr_string &fn) { - return EFS.AppendFolderToName(fn,-1,FALSE); + return EFS.AppendFolderToName(fn, -1, FALSE); } //------------------------------------------------------------------------------ // âîçâðàùàåò ñïèñîê âñåõ çâóêîâ //------------------------------------------------------------------------------ -int CSoundManager::GetSounds(FS_FileSet& files, BOOL bFolders) +int CSoundManager::GetSounds(FS_FileSet &files, BOOL bFolders) { - return FS.file_list(files,_sounds_,(bFolders?FS_ListFolders:0)|FS_ListFiles|FS_ClampExt,"*.wav"); + return FS.file_list(files, _sounds_, (bFolders ? FS_ListFolders : 0)|FS_ListFiles|FS_ClampExt, "*.wav"); } -int CSoundManager::GetGameSounds(FS_FileSet& files) +int CSoundManager::GetGameSounds(FS_FileSet &files) { - return FS.file_list(files,_game_sounds_,FS_ListFiles|FS_ClampExt,"*.ogg"); + return FS.file_list(files, _game_sounds_, FS_ListFiles|FS_ClampExt, "*.ogg"); } -int CSoundManager::GetSoundEnvs(AStringVec& items) +int CSoundManager::GetSoundEnvs(AStringVec &items) { -/* - SoundEnvironment_LIB* Lib = Sound->get_env_library(); - if (Lib){ - for (SoundEnvironment_LIB::SE_IT it=Lib->Library().begin(); it!=Lib->Library().end(); it++) - items.push_back(*(*it)->name); - } - return items.size(); -*/ -return 0; + /* + SoundEnvironment_LIB* Lib = Sound->get_env_library(); + if (Lib){ + for (SoundEnvironment_LIB::SE_IT it=Lib->Library().begin(); it!=Lib->Library().end(); it++) + items.push_back(*(*it)->name); + } + return items.size(); + */ + return 0; } bool CSoundManager::OnCreate() { -//. psSoundFreq = sf_44K; -// psSoundFlags.set (ssHardware,FALSE); - CSound_manager_interface::_create (0); - CSound_manager_interface::_create (1); + //. psSoundFreq = sf_44K; + // psSoundFlags.set (ssHardware,FALSE); + CSound_manager_interface::_create(0); + CSound_manager_interface::_create(1); return true; } void CSoundManager::OnDestroy() { - CSound_manager_interface::_destroy (); + CSound_manager_interface::_destroy(); } void CSoundManager::OnFrame() { - ::psSoundVEffects = psDeviceFlags.is(rsMuteSounds)?0.f:1.f; - Sound->update (EDevice.m_Camera.GetPosition(), EDevice.m_Camera.GetDirection(), EDevice.m_Camera.GetNormal()); + ::psSoundVEffects = psDeviceFlags.is(rsMuteSounds) ? 0.f : 1.f; + Sound->update(EDevice.m_Camera.GetPosition(), EDevice.m_Camera.GetDirection(), EDevice.m_Camera.GetNormal()); } void CSoundManager::MuteSounds(BOOL bVal) { - if (bVal) ::psSoundVEffects = 0.f; - else ::psSoundVEffects = psDeviceFlags.is(rsMuteSounds)?0.f:1.f; + if (bVal) + ::psSoundVEffects = 0.f; + else + ::psSoundVEffects = psDeviceFlags.is(rsMuteSounds) ? 0.f : 1.f; } void CSoundManager::RenameSound(LPCSTR nm0, LPCSTR nm1, EItemType type) { - if (TYPE_FOLDER==type){ - FS.dir_delete (_sounds_,nm0,FALSE); - FS.dir_delete (_game_sounds_,nm0,FALSE); - }else if (TYPE_OBJECT==type){ - string_path fn0,fn1,temp; + if (TYPE_FOLDER==type) + { + FS.dir_delete(_sounds_, nm0, FALSE); + FS.dir_delete(_game_sounds_, nm0, FALSE); + } + else if (TYPE_OBJECT==type) + { + string_path fn0, fn1, temp; // rename base file - FS.update_path(fn0,_sounds_,nm0); strcat(fn0,".wav"); - FS.update_path(fn1,_sounds_,nm1); strcat(fn1,".wav"); - FS.file_rename(fn0,fn1,false); + FS.update_path(fn0, _sounds_, nm0); + strcat(fn0, ".wav"); + FS.update_path(fn1, _sounds_, nm1); + strcat(fn1, ".wav"); + FS.file_rename(fn0, fn1, false); // rename thm - FS.update_path(fn0,_sounds_,nm0); strcat(fn0,".thm"); - FS.update_path(fn1,_sounds_,nm1); strcat(fn1,".thm"); - FS.file_rename(fn0,fn1,false); + FS.update_path(fn0, _sounds_, nm0); + strcat(fn0, ".thm"); + FS.update_path(fn1, _sounds_, nm1); + strcat(fn1, ".thm"); + FS.file_rename(fn0, fn1, false); // rename ogg - FS.update_path(fn0,_game_sounds_,nm0); strcat(fn0,".ogg"); - FS.update_path(fn1,_game_sounds_,nm1); strcat(fn1,".ogg"); - FS.file_rename(fn0,fn1,false); + FS.update_path(fn0, _game_sounds_, nm0); + strcat(fn0, ".ogg"); + FS.update_path(fn1, _game_sounds_, nm1); + strcat(fn1, ".ogg"); + FS.file_rename(fn0, fn1, false); - Sound->refresh_sources(); - } + Sound->refresh_sources(); + } } BOOL CSoundManager::RemoveSound(LPCSTR fname, EItemType type) { - if (TYPE_FOLDER==type){ - FS.dir_delete (_sounds_,fname,FALSE); - FS.dir_delete (_game_sounds_,fname,FALSE); - return TRUE; - }else if (TYPE_OBJECT==type){ + if (TYPE_FOLDER==type) + { + FS.dir_delete(_sounds_, fname, FALSE); + FS.dir_delete(_game_sounds_, fname, FALSE); + return TRUE; + } + else if (TYPE_OBJECT==type) + { xr_string src_name; - src_name = EFS.ChangeFileExt(fname,".wav"); - if (FS.exist(_sounds_,src_name.c_str())){ - xr_string thm_name = EFS.ChangeFileExt(fname,".thm"); - xr_string game_name= EFS.ChangeFileExt(fname,".ogg"); + src_name = EFS.ChangeFileExt(fname, ".wav"); + if (FS.exist(_sounds_, src_name.c_str())) + { + xr_string thm_name = EFS.ChangeFileExt(fname, ".thm"); + xr_string game_name = EFS.ChangeFileExt(fname, ".ogg"); // source - FS.file_delete (_sounds_,src_name.c_str()); + FS.file_delete(_sounds_, src_name.c_str()); // thumbnail - FS.file_delete (_sounds_,thm_name.c_str()); + FS.file_delete(_sounds_, thm_name.c_str()); // game - FS.file_delete (_game_sounds_,game_name.c_str()); - Sound->refresh_sources(); + FS.file_delete(_game_sounds_, game_name.c_str()); + Sound->refresh_sources(); return TRUE; } } @@ -123,9 +139,9 @@ BOOL CSoundManager::RemoveSound(LPCSTR fname, EItemType type) //------------------------------------------------------------------------------ // âîçâðàùàåò ñïèñîê íîâûõ çâóêîâ //------------------------------------------------------------------------------ -int CSoundManager::GetLocalNewSounds(FS_FileSet& files) +int CSoundManager::GetLocalNewSounds(FS_FileSet &files) { - return FS.file_list (files,_import_,FS_ListFiles|FS_RootOnly|FS_ClampExt,"*.wav"); + return FS.file_list(files, _import_, FS_ListFiles|FS_RootOnly|FS_ClampExt, "*.wav"); } //------------------------------------------------------------------------------ @@ -141,22 +157,22 @@ void CSoundManager::SafeCopyLocalToServer(FS_FileSet& files) FS.update_path (p_sounds,_sounds_,""); FS_FileSetIt it = files.begin(); - FS_FileSetIt _E = files.end(); - for (; it!=_E; it++){ + FS_FileSetIt _E = files.end(); + for (; it!=_E; it++){ // copy thm - xr_string fn = EFS.ChangeFileExt(it->first,".thm"); - src_name = p_import + fn; - UpdateFileName (fn); - dest_name = p_sounds + fn; - FS.file_rename (src_name.c_str(),dest_name.c_str(),true); - // copy sources - fn = EFS.ChangeFileExt(it->first,".wav"); - src_name = p_import + fn; - UpdateFileName (fn); - dest_name = p_sounds + fn; + xr_string fn = EFS.ChangeFileExt(it->first,".thm"); + src_name = p_import + fn; + UpdateFileName (fn); + dest_name = p_sounds + fn; + FS.file_rename (src_name.c_str(),dest_name.c_str(),true); + // copy sources + fn = EFS.ChangeFileExt(it->first,".wav"); + src_name = p_import + fn; + UpdateFileName (fn); + dest_name = p_sounds + fn; if (FS.exist(dest_name.c_str())){ - EFS.BackupFile (_sounds_,EFS.ChangeFileExt(fn,".wav").c_str()); - EFS.BackupFile (_sounds_,EFS.ChangeFileExt(fn,".thm").c_str()); + EFS.BackupFile (_sounds_,EFS.ChangeFileExt(fn,".wav").c_str()); + EFS.BackupFile (_sounds_,EFS.ChangeFileExt(fn,".thm").c_str()); } FS.file_copy (src_name.c_str(),dest_name.c_str()); FS.set_file_age (dest_name.c_str(),FS.get_file_age(src_name.c_str())); @@ -168,38 +184,41 @@ void CSoundManager::SafeCopyLocalToServer(FS_FileSet& files) //------------------------------------------------------------------------------ // ñîçäàåò òõì //------------------------------------------------------------------------------ -void CSoundManager::CreateSoundThumbnail(ESoundThumbnail* THM, const AnsiString& src_name, LPCSTR initial, bool bSetDefParam) +void CSoundManager::CreateSoundThumbnail(ESoundThumbnail *THM, const AnsiString &src_name, LPCSTR initial, bool bSetDefParam) { - R_ASSERT(src_name.Length()); - string_path base_name; - if (initial) FS.update_path(base_name,initial,src_name.c_str()); - else FS.update_path(base_name,_sounds_,src_name.c_str()); - strcpy (base_name, EFS.ChangeFileExt(base_name,".wav").c_str()); + R_ASSERT(src_name.Length()); + string_path base_name; + if (initial) + FS.update_path(base_name, initial, src_name.c_str()); + else + FS.update_path(base_name, _sounds_, src_name.c_str()); + strcpy(base_name, EFS.ChangeFileExt(base_name, ".wav").c_str()); // âûñòàâèòü íà÷àëüíûå ïàðàìåòðû - if (bSetDefParam){ - THM->m_Age = FS.get_file_age(base_name); - THM->m_fQuality = 0.f; - THM->m_fMinDist = 1.f; - THM->m_uGameType = 0; + if (bSetDefParam) + { + THM->m_Age = FS.get_file_age(base_name); + THM->m_fQuality = 0.f; + THM->m_fMinDist = 1.f; + THM->m_uGameType = 0; } -} +} -void CSoundManager::MakeGameSound(ESoundThumbnail* THM, LPCSTR src_name, LPCSTR game_name) +void CSoundManager::MakeGameSound(ESoundThumbnail *THM, LPCSTR src_name, LPCSTR game_name) { - VerifyPath (game_name); - CMemoryWriter F; - F.w_u32 (OGG_COMMENT_VERSION); - F.w_float (THM->m_fMinDist); - F.w_float (THM->m_fMaxDist); - F.w_float (THM->m_fBaseVolume); - F.w_u32 (THM->m_uGameType); - F.w_float (THM->m_fMaxAIDist); - - if (!ogg_enc(src_name, game_name, THM->m_fQuality, F.pointer(), F.size())) + VerifyPath(game_name); + CMemoryWriter F; + F.w_u32(OGG_COMMENT_VERSION); + F.w_float(THM->m_fMinDist); + F.w_float(THM->m_fMaxDist); + F.w_float(THM->m_fBaseVolume); + F.w_u32(THM->m_uGameType); + F.w_float(THM->m_fMaxAIDist); + + if (!ogg_enc(src_name, game_name, THM->m_fQuality, F.pointer(), F.size())) { - FS.file_delete(game_name); - ELog.DlgMsg(mtError,"Can't make game sound '%s'.",game_name); + FS.file_delete(game_name); + ELog.DlgMsg(mtError, "Can't make game sound '%s'.", game_name); } } @@ -208,190 +227,192 @@ void CSoundManager::MakeGameSound(ESoundThumbnail* THM, LPCSTR src_name, LPCSTR // source_list - ñîäåðæèò ñïèñîê òåêñòóð ñ ðàñøèðåíèÿìè // sync_list - ðåàëüíî ñîõðàíåííûå ôàéëû (ïîñëå èñïîëüçîâàíèÿ îñâîáîäèòü) //------------------------------------------------------------------------------ -void CSoundManager::SynchronizeSounds(bool sync_thm, bool sync_game, bool bForceGame, FS_FileSet* source_list, AStringVec* sync_list, FS_FileSet* modif_map) -{ - FS_FileSet M_BASE; - FS_FileSet M_THUM; +void CSoundManager::SynchronizeSounds(bool sync_thm, bool sync_game, bool bForceGame, FS_FileSet *source_list, AStringVec *sync_list, FS_FileSet *modif_map) +{ + FS_FileSet M_BASE; + FS_FileSet M_THUM; FS_FileSet M_GAME; if (source_list) - M_BASE = *source_list; + M_BASE = *source_list; else - FS.file_list(M_BASE,_sounds_,FS_ListFiles|FS_ClampExt,"*.wav"); + FS.file_list(M_BASE, _sounds_, FS_ListFiles|FS_ClampExt, "*.wav"); if (M_BASE.empty()) - return; + return; if (sync_thm) - FS.file_list(M_THUM,_sounds_,FS_ListFiles|FS_ClampExt,"*.thm"); - + FS.file_list(M_THUM, _sounds_, FS_ListFiles|FS_ClampExt, "*.thm"); + if (sync_game) - FS.file_list(M_GAME,_game_sounds_,FS_ListFiles|FS_ClampExt,"*.ogg"); + FS.file_list(M_GAME, _game_sounds_, FS_ListFiles|FS_ClampExt, "*.ogg"); - bool bProgress = (M_BASE.size()>1); + bool bProgress = (M_BASE.size()>1); - int m_age = time(NULL); + int m_age = time(NULL); - SPBItem* pb = 0; + SPBItem*pb = 0; if (bProgress) - pb = UI->ProgressStart(M_BASE.size(),"Synchronize sounds..."); + pb = UI->ProgressStart(M_BASE.size(), "Synchronize sounds..."); - FS_FileSetIt it = M_BASE.begin(); - FS_FileSetIt it_e = M_BASE.end(); - for (; it!=it_e; ++it) + FS_FileSetIt it = M_BASE.begin(); + FS_FileSetIt it_e = M_BASE.end(); + for (; it!=it_e; ++it) { - BOOL bUpdated = FALSE; - xr_string base_name = EFS.ChangeFileExt(it->name,""); - xr_strlwr (base_name); - string_path fn; - FS.update_path (fn,_sounds_,EFS.ChangeFileExt(base_name,".wav").c_str()); - if (!FS.exist(fn)) - continue; + BOOL bUpdated = FALSE; + xr_string base_name = EFS.ChangeFileExt(it->name, ""); + xr_strlwr(base_name); + string_path fn; + FS.update_path(fn, _sounds_, EFS.ChangeFileExt(base_name, ".wav").c_str()); + if (!FS.exist(fn)) + continue; - FS_FileSetIt th = M_THUM.find(base_name); - bool bThm = ((th==M_THUM.end()) || ((th!=M_THUM.end())&&(th->time_write!=it->time_write))); - FS_FileSetIt gm = M_GAME.find(base_name); - bool bGame = bThm || ((gm==M_GAME.end()) || ((gm!=M_GAME.end())&&(gm->time_write!=it->time_write))); + FS_FileSetIt th = M_THUM.find(base_name); + bool bThm = ((th==M_THUM.end())||((th!=M_THUM.end())&&(th->time_write!=it->time_write))); + FS_FileSetIt gm = M_GAME.find(base_name); + bool bGame = bThm||((gm==M_GAME.end())||((gm!=M_GAME.end())&&(gm->time_write!=it->time_write))); - ESoundThumbnail* THM = 0; + ESoundThumbnail*THM = 0; // backup base sound - // check thumbnail - if (sync_thm&&bThm){ - THM = xr_new(it->name.c_str()); - THM->Save (m_age); - bUpdated = TRUE; + // check thumbnail + if (sync_thm&&bThm) + { + THM = xr_new(it->name.c_str()); + THM->Save(m_age); + bUpdated = TRUE; } // check game sounds - if (bForceGame||(sync_game&&bGame)) + if (bForceGame||(sync_game&&bGame)) { - if (!THM) THM = xr_new(it->name.c_str()); + if (!THM) + THM = xr_new(it->name.c_str()); R_ASSERT(THM); - string_path src_name; - strconcat (sizeof(src_name),src_name, base_name.c_str(), ".wav"); + string_path src_name; + strconcat(sizeof(src_name), src_name, base_name.c_str(), ".wav"); - FS.update_path (src_name,_sounds_,src_name); - string_path game_name; - strconcat (sizeof(game_name),game_name, base_name.c_str(), ".ogg"); - FS.update_path (game_name,_game_sounds_,game_name); - MakeGameSound (THM,src_name,game_name); + FS.update_path(src_name, _sounds_, src_name); + string_path game_name; + strconcat(sizeof(game_name), game_name, base_name.c_str(), ".ogg"); + FS.update_path(game_name, _game_sounds_, game_name); + MakeGameSound(THM, src_name, game_name); if (sync_list) - sync_list->push_back(base_name.c_str()); + sync_list->push_back(base_name.c_str()); if (modif_map) - modif_map->insert(*it); + modif_map->insert(*it); bUpdated = TRUE; - } + } - if (THM) - xr_delete(THM); + if (THM) + xr_delete(THM); - if (UI->NeedAbort()) - break; + if (UI->NeedAbort()) + break; if (bProgress) - pb->Inc (bUpdated?xr_string(base_name+" - UPDATED.").c_str():"",bUpdated); + pb->Inc(bUpdated ? xr_string(base_name+" - UPDATED.").c_str() : "", bUpdated); if (bUpdated) { - string_path wav_fn,thm_fn,ogg_fn; - FS.update_path (wav_fn,_sounds_, EFS.ChangeFileExt(base_name,".wav").c_str()); - FS.update_path (thm_fn,_sounds_, EFS.ChangeFileExt(base_name,".thm").c_str()); - FS.update_path (ogg_fn,_game_sounds_, EFS.ChangeFileExt(base_name,".ogg").c_str()); - FS.set_file_age (wav_fn,m_age); - FS.set_file_age (thm_fn,m_age); - FS.set_file_age (ogg_fn,m_age); + string_path wav_fn, thm_fn, ogg_fn; + FS.update_path(wav_fn, _sounds_, EFS.ChangeFileExt(base_name, ".wav").c_str()); + FS.update_path(thm_fn, _sounds_, EFS.ChangeFileExt(base_name, ".thm").c_str()); + FS.update_path(ogg_fn, _game_sounds_, EFS.ChangeFileExt(base_name, ".ogg").c_str()); + FS.set_file_age(wav_fn, m_age); + FS.set_file_age(thm_fn, m_age); + FS.set_file_age(ogg_fn, m_age); } } if (bProgress) - UI->ProgressEnd(pb); + UI->ProgressEnd(pb); } void CSoundManager::CleanupSounds() { - FS_FileSet M_BASE; - FS_FileSet M_THUM; - FS_FileSet M_GAME; - FS_FileSet M_GAME_DEL; - FS_FileSet M_THM_DEL; + FS_FileSet M_BASE; + FS_FileSet M_THUM; + FS_FileSet M_GAME; + FS_FileSet M_GAME_DEL; + FS_FileSet M_THM_DEL; - FS.file_list (M_BASE,_sounds_, FS_ListFiles|FS_ClampExt,"*.wav"); - FS.file_list (M_THUM,_sounds_, FS_ListFiles|FS_ClampExt,"*.thm"); - FS.file_list (M_GAME,_game_sounds_, FS_ListFiles|FS_ClampExt,"*.ogg"); + FS.file_list(M_BASE, _sounds_, FS_ListFiles|FS_ClampExt, "*.wav"); + FS.file_list(M_THUM, _sounds_, FS_ListFiles|FS_ClampExt, "*.thm"); + FS.file_list(M_GAME, _game_sounds_, FS_ListFiles|FS_ClampExt, "*.ogg"); - FS_FileSetIt it; - FS_FileSetIt it_e; + FS_FileSetIt it; + FS_FileSetIt it_e; // check source exist - it = M_GAME.begin(); - it_e = M_GAME.end(); + it = M_GAME.begin(); + it_e = M_GAME.end(); - for (; it!=it_e; ++it) + for (; it!=it_e; ++it) { - xr_string base_name = EFS.ChangeFileExt(it->name,""); - xr_strlwr (base_name); - FS_FileSetIt bs = M_BASE.find(base_name); + xr_string base_name = EFS.ChangeFileExt(it->name, ""); + xr_strlwr(base_name); + FS_FileSetIt bs = M_BASE.find(base_name); - if (bs==M_BASE.end()) - M_GAME_DEL.insert (*it); + if (bs==M_BASE.end()) + M_GAME_DEL.insert(*it); } - it = M_THUM.begin(); - it_e = M_THUM.end(); + it = M_THUM.begin(); + it_e = M_THUM.end(); - for (; it!=it_e; ++it) + for (; it!=it_e; ++it) { - xr_string base_name = EFS.ChangeFileExt(it->name,""); - xr_strlwr (base_name); - FS_FileSetIt bs = M_BASE.find(base_name); - if (bs==M_BASE.end()) - M_THM_DEL.insert (*it); + xr_string base_name = EFS.ChangeFileExt(it->name, ""); + xr_strlwr(base_name); + FS_FileSetIt bs = M_BASE.find(base_name); + if (bs==M_BASE.end()) + M_THM_DEL.insert(*it); } - SPBItem* pb = UI->ProgressStart(M_GAME_DEL.size()+M_THM_DEL.size(),"Cleanup sounds..."); + SPBItem*pb = UI->ProgressStart(M_GAME_DEL.size()+M_THM_DEL.size(), "Cleanup sounds..."); // mark game del sounds - it = M_GAME_DEL.begin(); - it_e = M_GAME_DEL.end(); + it = M_GAME_DEL.begin(); + it_e = M_GAME_DEL.end(); - for (; it!=it_e; ++it) + for (; it!=it_e; ++it) { - xr_string base_name = EFS.ChangeFileExt(it->name,""); - xr_strlwr (base_name); - string_path fn; - FS.update_path (fn,_game_sounds_,EFS.ChangeFileExt(base_name,".ogg").c_str()); - EFS.MarkFile (fn,true); - pb->Inc (); + xr_string base_name = EFS.ChangeFileExt(it->name, ""); + xr_strlwr(base_name); + string_path fn; + FS.update_path(fn, _game_sounds_, EFS.ChangeFileExt(base_name, ".ogg").c_str()); + EFS.MarkFile(fn, true); + pb->Inc(); } // mark thm sounds - it = M_THM_DEL.begin(); - it_e = M_THM_DEL.end(); - for (; it!=it_e; ++it) + it = M_THM_DEL.begin(); + it_e = M_THM_DEL.end(); + for (; it!=it_e; ++it) { - xr_string base_name = EFS.ChangeFileExt(it->name,""); - xr_strlwr (base_name); - string_path fn; - FS.update_path (fn,_sounds_,EFS.ChangeFileExt(base_name,".thm").c_str()); - EFS.MarkFile (fn,true); - pb->Inc (); + xr_string base_name = EFS.ChangeFileExt(it->name, ""); + xr_strlwr(base_name); + string_path fn; + FS.update_path(fn, _sounds_, EFS.ChangeFileExt(base_name, ".thm").c_str()); + EFS.MarkFile(fn, true); + pb->Inc(); } - UI->ProgressEnd (pb); + UI->ProgressEnd(pb); } /* void CSoundManager::ChangeFileAgeTo(FS_FileSet* tgt_map, int age) { - VERIFY(tgt_map); - FS_FileSet* M_BASE = tgt_map; + VERIFY(tgt_map); + FS_FileSet* M_BASE = tgt_map; // lock rescanning FS.lock_rescan (); // change - SPBItem* pb=0; + SPBItem* pb=0; if (M_BASE->size()>1) pb = UI->ProgressStart(M_BASE->size(),"Change sounds age..."); FS_FileSetIt it = M_BASE->begin(); - FS_FileSetIt _E = M_BASE->end(); - for (; it!=_E; it++){ + FS_FileSetIt _E = M_BASE->end(); + for (; it!=_E; it++){ xr_string base_name = EFS.ChangeFileExt(it->first,""); xr_strlwr(base_name); xr_string wav_fn,thm_fn,ogg_fn; FS.update_path (wav_fn,_sounds_, EFS.ChangeFileExt(base_name,".wav").c_str()); @@ -413,15 +434,19 @@ void CSoundManager::ChangeFileAgeTo(FS_FileSet* tgt_map, int age) //------------------------------------------------------------------------------ void CSoundManager::RefreshSounds(bool bSync) { - if (FS.can_write_to_alias(_sounds_)){ + if (FS.can_write_to_alias(_sounds_)) + { UI->SetStatus("Refresh sounds..."); - if (bSync){ - SynchronizeSounds (true,true,false,0,0); - CleanupSounds (); + if (bSync) + { + SynchronizeSounds(true, true, false, 0, 0); + CleanupSounds(); } Sound->refresh_sources(); UI->SetStatus(""); - }else{ + } + else + { Log("#!You don't have permisions to modify sounds."); } } diff --git a/src/editors/ECore/Editor/SoundManager.h b/src/editors/ECore/Editor/SoundManager.h index 918d391867a..d7671d12409 100644 --- a/src/editors/ECore/Editor/SoundManager.h +++ b/src/editors/ECore/Editor/SoundManager.h @@ -2,47 +2,48 @@ #ifndef SoundManagerH #define SoundManagerH -#include "../xrEProps/folderlib.h" +#include "editors/xrEProps/FolderLib.h" // refs class ESoundThumbnail; class ECORE_API CSoundManager { -public: - void MakeGameSound (ESoundThumbnail* THM, LPCSTR src_name, LPCSTR game_name); - CSoundManager (){} - virtual ~CSoundManager (){;} - - BOOL __stdcall RemoveSound (LPCSTR fname, EItemType type); - void __stdcall RenameSound (LPCSTR p0, LPCSTR p1, EItemType type); + public: + void MakeGameSound(ESoundThumbnail*THM, LPCSTR src_name, LPCSTR game_name); + CSoundManager(){} + virtual ~CSoundManager(){;} - // texture routines - int GetSounds (FS_FileSet& files, BOOL bFolders=FALSE); - int GetGameSounds (FS_FileSet& files); - int GetSoundEnvs (AStringVec& items); + BOOL__stdcall RemoveSound(LPCSTR fname, EItemType type); + void__stdcall RenameSound(LPCSTR p0, LPCSTR p1, EItemType type); - int GetLocalNewSounds (FS_FileSet& files); -// void SafeCopyLocalToServer(FS_FileSet& files); - void SynchronizeSounds (bool sync_thm, bool sync_game, bool bForceGame, FS_FileSet* source_map, AStringVec* sync_list_without_extention, FS_FileSet* modif_map=0); -// void ChangeFileAgeTo (FS_FileSet* tgt_map, int age); - void CreateSoundThumbnail(ESoundThumbnail* THM, const AnsiString& src_name, LPCSTR path=0, bool bSetDefParam=true); - void CleanupSounds (); + // texture routines + int GetSounds(FS_FileSet&files, BOOL bFolders = FALSE); + int GetGameSounds(FS_FileSet&files); + int GetSoundEnvs(AStringVec&items); - bool OnCreate (); - void OnDestroy (); + int GetLocalNewSounds(FS_FileSet&files); + // void SafeCopyLocalToServer(FS_FileSet& files); + void SynchronizeSounds(bool sync_thm, bool sync_game, bool bForceGame, FS_FileSet*source_map, AStringVec*sync_list_without_extention, FS_FileSet*modif_map = 0); + // void ChangeFileAgeTo (FS_FileSet* tgt_map, int age); + void CreateSoundThumbnail(ESoundThumbnail*THM, const AnsiString&src_name, LPCSTR path = 0, bool bSetDefParam = true); + void CleanupSounds(); - virtual void OnFrame (); + bool OnCreate(); + void OnDestroy(); - virtual bool Validate (){return true;} + virtual void OnFrame(); - void MuteSounds (BOOL bVal); + virtual bool Validate(){return true;} - void RefreshSounds (bool bSync); + void MuteSounds(BOOL bVal); - xr_string UpdateFileName (xr_string& fn); + void RefreshSounds(bool bSync); + + xr_string UpdateFileName(xr_string&fn); }; extern ECORE_API CSoundManager* SndLib; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ECore/Editor/TLSPRITE.CPP b/src/editors/ECore/Editor/TLSPRITE.CPP index f7e6e69447b..81ca90909fe 100644 --- a/src/editors/ECore/Editor/TLSPRITE.CPP +++ b/src/editors/ECore/Editor/TLSPRITE.CPP @@ -1,163 +1,187 @@ #include "stdafx.h" #pragma hdrstop -#include "tlsprite.h" -#include "texture.h" +#include "TLSprite.h" +#include "editors/ECore/Engine/Texture.h" #include "ui_main.h" -#include "d3dutils.h" +#include "D3DUtils.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// -CTLSprite::CTLSprite ( ) +CTLSprite::CTLSprite() { - mesh.setcolor (0xFFFFFFFF); - mesh.setdepth ( ); - mesh.settex (0,0,1,1); + mesh.setcolor(0xFFFFFFFF); + mesh.setdepth(); + mesh.settex(0, 0, 1, 1); } -CTLSprite::~CTLSprite( ) -{ -} +CTLSprite::~CTLSprite() {} void CTLSprite::Render(Fvector &pos, float radius, bool bFixedSize, u32 clr) { - FVF::TL P; - float cx,cy,sz; - - P.transform ( pos, EDevice.mFullTransform ); - cx = EDevice._x2real(P.p.x); - cy = EDevice._y2real(P.p.y); - if (bFixedSize) sz = EDevice._x2real(radius)-EDevice._x2real(0); - else sz = UI->GetRenderWidth()*radius/P.p.w; - mesh.m[0].p.x = cx-sz; mesh.m[0].p.y = cy+sz; - mesh.m[1].p.x = cx-sz; mesh.m[1].p.y = cy-sz; - mesh.m[3].p.x = cx+sz; mesh.m[3].p.y = cy-sz; - mesh.m[2].p.x = cx+sz; mesh.m[2].p.y = cy+sz; - mesh.setdepth ( P.p.z, P.p.w ); - mesh.setcolor ( clr ); - - DU_impl.DrawPrimitiveTL(D3DPT_TRIANGLESTRIP,2,(FVF::TL*)&mesh,4,false,false); + FVF::TL P; + float cx, cy, sz; + + P.transform(pos, EDevice.mFullTransform); + cx = EDevice._x2real(P.p.x); + cy = EDevice._y2real(P.p.y); + if (bFixedSize) + sz = EDevice._x2real(radius)-EDevice._x2real(0); + else + sz = UI->GetRenderWidth()*radius/P.p.w; + mesh.m[0].p.x = cx-sz; + mesh.m[0].p.y = cy+sz; + mesh.m[1].p.x = cx-sz; + mesh.m[1].p.y = cy-sz; + mesh.m[3].p.x = cx+sz; + mesh.m[3].p.y = cy-sz; + mesh.m[2].p.x = cx+sz; + mesh.m[2].p.y = cy+sz; + mesh.setdepth(P.p.z, P.p.w); + mesh.setcolor(clr); + + DU_impl.DrawPrimitiveTL(D3DPT_TRIANGLESTRIP, 2, (FVF::TL*)&mesh, 4, false, false); } void CTLSprite::Render(Fvector &pos, u32 color, float radius, float angle) { - FVF::TL P; + FVF::TL P; - P.transform (pos, EDevice.mFullTransform); - if (P.p.w<=0) return; + P.transform(pos, EDevice.mFullTransform); + if (P.p.w<=0) + return; - float cx = EDevice._x2real(P.p.x); - float cy = EDevice._y2real(P.p.y); + float cx = EDevice._x2real(P.p.x); + float cy = EDevice._y2real(P.p.y); - float sz = (UI->GetRenderWidth()*radius)/P.p.w; - if (sz<1.5f) return; + float sz = (UI->GetRenderWidth()*radius)/P.p.w; + if (sz<1.5f) + return; - // Rotation - float _sin1=_sin(angle),_cos1=_cos(angle); - float _sin2=_sin(angle+PI_DIV_2),_cos2=_cos(angle+PI_DIV_2); + // Rotation + float _sin1 = _sin(angle), _cos1 = _cos(angle); + float _sin2 = _sin(angle+PI_DIV_2), _cos2 = _cos(angle+PI_DIV_2); - mesh.m[0].p.x = cx+sz*_sin1; mesh.m[0].p.y = cy+sz*_cos1; - mesh.m[1].p.x = cx-sz*_sin2; mesh.m[1].p.y = cy-sz*_cos2; - mesh.m[2].p.x = cx+sz*_sin2; mesh.m[2].p.y = cy+sz*_cos2; - mesh.m[3].p.x = cx-sz*_sin1; mesh.m[3].p.y = cy-sz*_cos1; + mesh.m[0].p.x = cx+sz*_sin1; + mesh.m[0].p.y = cy+sz*_cos1; + mesh.m[1].p.x = cx-sz*_sin2; + mesh.m[1].p.y = cy-sz*_cos2; + mesh.m[2].p.x = cx+sz*_sin2; + mesh.m[2].p.y = cy+sz*_cos2; + mesh.m[3].p.x = cx-sz*_sin1; + mesh.m[3].p.y = cy-sz*_cos1; - mesh.setdepth (P.p.z, P.p.w); - mesh.setcolor (color); + mesh.setdepth(P.p.z, P.p.w); + mesh.setcolor(color); - DU_impl.DrawPrimitiveTL(D3DPT_TRIANGLESTRIP,2,(FVF::TL*)&mesh,4,false,false); + DU_impl.DrawPrimitiveTL(D3DPT_TRIANGLESTRIP, 2, (FVF::TL*)&mesh, 4, false, false); } -void CTLSprite::Render( Fvector &pos, u32 color, float radius, const Fvector& D ){ - Fvector P1,P2; - P1.mad (pos,D,-radius); - P2.mad (pos,D,radius); - - FVF::TL s1,s2; - s1.transform (P1,EDevice.mFullTransform); - s2.transform (P2,EDevice.mFullTransform); - - if ((s1.p.w<=0)||(s2.p.w<=0)) return; - - float l1 = radius/s1.p.w*1.4142f; - float l2 = radius/s2.p.w*1.4142f; - - Fvector2 dir,R; - dir.set (s2.p.x-s1.p.x,s2.p.y-s1.p.y); - dir.norm (); - R.cross (dir); - - mesh.m[0].p.x = EDevice._x2real(s1.p.x+l1*R.x); mesh.m[0].p.y = EDevice._y2real(s1.p.y+l1*R.y); mesh.m[0].p.z = s2.p.z; mesh.m[0].p.w = s2.p.w; - mesh.m[1].p.x = EDevice._x2real(s2.p.x+l2*R.x); mesh.m[1].p.y = EDevice._y2real(s2.p.y+l2*R.y); mesh.m[1].p.z = s2.p.z; mesh.m[1].p.w = s2.p.w; - mesh.m[2].p.x = EDevice._x2real(s1.p.x-l1*R.x); mesh.m[2].p.y = EDevice._y2real(s1.p.y-l1*R.y); mesh.m[2].p.z = s2.p.z; mesh.m[2].p.w = s2.p.w; - mesh.m[3].p.x = EDevice._x2real(s2.p.x-l2*R.x); mesh.m[3].p.y = EDevice._y2real(s2.p.y-l2*R.y); mesh.m[3].p.z = s2.p.z; mesh.m[3].p.w = s2.p.w; - - mesh.setcolor (color); - - DU_impl.DrawPrimitiveTL(D3DPT_TRIANGLESTRIP,2,(FVF::TL*)&mesh,4,false,false); -/* - float radius = size*0.5f; - - Fvector P1,P2; - P1.direct (pos,D,radius); - P2.direct (pos,D,-radius); +void CTLSprite::Render(Fvector &pos, u32 color, float radius, const Fvector &D) +{ + Fvector P1, P2; + P1.mad(pos, D, -radius); + P2.mad(pos, D, radius); - FVF::TL s1,s2; - s1.transform (P1,EDevice.m_FullTransform); - s2.transform (P2,EDevice.m_FullTransform); + FVF::TL s1, s2; + s1.transform(P1, EDevice.mFullTransform); + s2.transform(P2, EDevice.mFullTransform); - if ((s1.p.w<=0)||(s2.p.w<=0)) return; + if ((s1.p.w<=0)||(s2.p.w<=0)) + return; - float l1 = radius/s1.p.w*1.4142f; + float l1 = radius/s1.p.w*1.4142f; float l2 = radius/s2.p.w*1.4142f; - Fvector2 dir,R; - dir.set (s2.p.x-s1.p.x,s2.p.y-s1.p.y); - dir.norm (); - R.cross (dir); - - mesh.m[0].p.x = X_TO_REAL(s1.p.x+l1*R.x); mesh.m[0].p.y = Y_TO_REAL(s1.p.y+l1*R.y); mesh.m[0].p.z = s1.p.z; mesh.m[0].p.w = s1.p.w; - mesh.m[1].p.x = X_TO_REAL(s2.p.x+l2*R.x); mesh.m[1].p.y = Y_TO_REAL(s2.p.y+l2*R.y); mesh.m[1].p.z = s2.p.z; mesh.m[1].p.w = s2.p.w; - mesh.m[2].p.x = X_TO_REAL(s1.p.x-l1*R.x); mesh.m[2].p.y = Y_TO_REAL(s1.p.y-l1*R.y); mesh.m[2].p.z = s1.p.z; mesh.m[2].p.w = s1.p.w; - mesh.m[3].p.x = X_TO_REAL(s2.p.x-l2*R.x); mesh.m[3].p.y = Y_TO_REAL(s2.p.y-l2*R.y); mesh.m[3].p.z = s2.p.z; mesh.m[3].p.w = s2.p.w; -// mesh.m[1].p.x = X_TO_REAL(s2.p.x); mesh.m[1].p.y = Y_TO_REAL(s2.p.y); mesh.m[1].p.z = s2.p.z; mesh.m[1].p.w = s2.p.w; -// mesh.m[1].tu = 0.5f; mesh.m[1].tv = 0.f; - - mesh.setcolor (RGBA_MAKE(iFloor(color.r),iFloor(color.g),iFloor(color.b),iFloor(color.a))); - - EDevice.DP (D3DPT_TRIANGLESTRIP, FVF::F_TL, &mesh, 4); -*/ -/* Fvector2 dir; - dir.x = p1.x-p0.x; - dir.y = p1.y-p0.y; - dir.norm_safe (); - - Fvector P0,P1; - P0.direct (pos,); - - FVF::TL P; - P.transform (pos,EDevice.m_FullTransform); - float sz = UI->GetRenderWidth()*radius/P.p.w; - float sz0 = radius/P.p.w;//(radius/p0.w)/2; - float sz1 = radius/P.p.w;//radius/p1.w; - Fvector2 D,R; - D.x = (dir.x-dir.y)*0.7071f; - D.y = (dir.x+dir.y)*0.7071f; - R.cross (D); - - float cx = X_TO_REAL(P.p.x); - float cy = Y_TO_REAL(P.p.y); - - mesh.m[0].p.x = X_TO_REAL(p0.x+sz0*R.x); mesh.m[0].p.y = Y_TO_REAL(p0.y+sz0*R.y); - mesh.m[1].p.x = X_TO_REAL(p1.x+sz1*R.x); mesh.m[1].p.y = Y_TO_REAL(p1.y+sz1*R.y); - mesh.m[2].p.x = X_TO_REAL(p0.x-sz0*R.x); mesh.m[2].p.y = Y_TO_REAL(p0.y-sz0*R.y); - mesh.m[3].p.x = X_TO_REAL(p1.x-sz1*R.x); mesh.m[3].p.y = Y_TO_REAL(p1.y-sz1*R.y); - - mesh.setdepth (P.p.z, P.p.w); - mesh.setcolor (RGBA_MAKE(iFloor(color.r),iFloor(color.g),iFloor(color.b),iFloor(color.a))); - - EDevice.DP (D3DPT_TRIANGLESTRIP, FVF::F_TL, &mesh, 4); -*/ + Fvector2 dir, R; + dir.set(s2.p.x-s1.p.x, s2.p.y-s1.p.y); + dir.norm(); + R.cross(dir); + + mesh.m[0].p.x = EDevice._x2real(s1.p.x+l1*R.x); + mesh.m[0].p.y = EDevice._y2real(s1.p.y+l1*R.y); + mesh.m[0].p.z = s2.p.z; + mesh.m[0].p.w = s2.p.w; + mesh.m[1].p.x = EDevice._x2real(s2.p.x+l2*R.x); + mesh.m[1].p.y = EDevice._y2real(s2.p.y+l2*R.y); + mesh.m[1].p.z = s2.p.z; + mesh.m[1].p.w = s2.p.w; + mesh.m[2].p.x = EDevice._x2real(s1.p.x-l1*R.x); + mesh.m[2].p.y = EDevice._y2real(s1.p.y-l1*R.y); + mesh.m[2].p.z = s2.p.z; + mesh.m[2].p.w = s2.p.w; + mesh.m[3].p.x = EDevice._x2real(s2.p.x-l2*R.x); + mesh.m[3].p.y = EDevice._y2real(s2.p.y-l2*R.y); + mesh.m[3].p.z = s2.p.z; + mesh.m[3].p.w = s2.p.w; + + mesh.setcolor(color); + + DU_impl.DrawPrimitiveTL(D3DPT_TRIANGLESTRIP, 2, (FVF::TL*)&mesh, 4, false, false); + /* + float radius = size*0.5f; + + Fvector P1,P2; + P1.direct (pos,D,radius); + P2.direct (pos,D,-radius); + + FVF::TL s1,s2; + s1.transform (P1,EDevice.m_FullTransform); + s2.transform (P2,EDevice.m_FullTransform); + + if ((s1.p.w<=0)||(s2.p.w<=0)) return; + + float l1 = radius/s1.p.w*1.4142f; + float l2 = radius/s2.p.w*1.4142f; + + Fvector2 dir,R; + dir.set (s2.p.x-s1.p.x,s2.p.y-s1.p.y); + dir.norm (); + R.cross (dir); + + mesh.m[0].p.x = X_TO_REAL(s1.p.x+l1*R.x); mesh.m[0].p.y = Y_TO_REAL(s1.p.y+l1*R.y); mesh.m[0].p.z = s1.p.z; mesh.m[0].p.w = s1.p.w; + mesh.m[1].p.x = X_TO_REAL(s2.p.x+l2*R.x); mesh.m[1].p.y = Y_TO_REAL(s2.p.y+l2*R.y); mesh.m[1].p.z = s2.p.z; mesh.m[1].p.w = s2.p.w; + mesh.m[2].p.x = X_TO_REAL(s1.p.x-l1*R.x); mesh.m[2].p.y = Y_TO_REAL(s1.p.y-l1*R.y); mesh.m[2].p.z = s1.p.z; mesh.m[2].p.w = s1.p.w; + mesh.m[3].p.x = X_TO_REAL(s2.p.x-l2*R.x); mesh.m[3].p.y = Y_TO_REAL(s2.p.y-l2*R.y); mesh.m[3].p.z = s2.p.z; mesh.m[3].p.w = s2.p.w; + // mesh.m[1].p.x = X_TO_REAL(s2.p.x); mesh.m[1].p.y = Y_TO_REAL(s2.p.y); mesh.m[1].p.z = s2.p.z; mesh.m[1].p.w = s2.p.w; + // mesh.m[1].tu = 0.5f; mesh.m[1].tv = 0.f; + + mesh.setcolor (RGBA_MAKE(iFloor(color.r),iFloor(color.g),iFloor(color.b),iFloor(color.a))); + + EDevice.DP (D3DPT_TRIANGLESTRIP, FVF::F_TL, &mesh, 4); + */ + /* Fvector2 dir; + dir.x = p1.x-p0.x; + dir.y = p1.y-p0.y; + dir.norm_safe (); + + Fvector P0,P1; + P0.direct (pos,); + + FVF::TL P; + P.transform (pos,EDevice.m_FullTransform); + float sz = UI->GetRenderWidth()*radius/P.p.w; + float sz0 = radius/P.p.w;//(radius/p0.w)/2; + float sz1 = radius/P.p.w;//radius/p1.w; + Fvector2 D,R; + D.x = (dir.x-dir.y)*0.7071f; + D.y = (dir.x+dir.y)*0.7071f; + R.cross (D); + + float cx = X_TO_REAL(P.p.x); + float cy = Y_TO_REAL(P.p.y); + + mesh.m[0].p.x = X_TO_REAL(p0.x+sz0*R.x); mesh.m[0].p.y = Y_TO_REAL(p0.y+sz0*R.y); + mesh.m[1].p.x = X_TO_REAL(p1.x+sz1*R.x); mesh.m[1].p.y = Y_TO_REAL(p1.y+sz1*R.y); + mesh.m[2].p.x = X_TO_REAL(p0.x-sz0*R.x); mesh.m[2].p.y = Y_TO_REAL(p0.y-sz0*R.y); + mesh.m[3].p.x = X_TO_REAL(p1.x-sz1*R.x); mesh.m[3].p.y = Y_TO_REAL(p1.y-sz1*R.y); + + mesh.setdepth (P.p.z, P.p.w); + mesh.setcolor (RGBA_MAKE(iFloor(color.r),iFloor(color.g),iFloor(color.b),iFloor(color.a))); + + EDevice.DP (D3DPT_TRIANGLESTRIP, FVF::F_TL, &mesh, 4); + */ } /* @@ -165,13 +189,13 @@ void CTLSprite::UpdateTC(){ float tu,tv; int frame; - float fSPF = fPlayTime/float(iCount); - fLocalTime +=EDevice.fTimeDelta; - if (fLocalTime>=fPlayTime) fLocalTime-=fPlayTime; - frame = iFloor( fLocalTime/fSPF ); + float fSPF = fPlayTime/float(iCount); + fLocalTime +=EDevice.fTimeDelta; + if (fLocalTime>=fPlayTime) fLocalTime-=fPlayTime; + frame = iFloor( fLocalTime/fSPF ); - tu =(frame%iFrameDim)*fTexSize; - tv =(frame/iFrameDim)*fTexSize; + tu =(frame%iFrameDim)*fTexSize; + tv =(frame/iFrameDim)*fTexSize; mesh.m[0].tu=tu+fTexSize; mesh.m[0].tv=tv+fTexSize; mesh.m[1].tu=tu; mesh.m[1].tv=tv+fTexSize; @@ -181,32 +205,33 @@ void CTLSprite::UpdateTC(){ void CTLSprite::Render( Fvector &pos, float alpha, float size, float scale ) { - FTLvertex P; - FPcolor cur; - float s_da, s_da2, c_da, c_da2; - uchar cc; + FTLvertex P; + FPcolor cur; + float s_da, s_da2, c_da, c_da2; + uchar cc; - P.s_transform ( pos, UI->m_FullTransform ); - float cx = X_TO_REAL(P.sx); - float cy = Y_TO_REAL(P.sy); + P.s_transform ( pos, UI->m_FullTransform ); + float cx = X_TO_REAL(P.sx); + float cy = Y_TO_REAL(P.sy); - float dx = size/P.rhw * scale * UI->GetRenderWidth() / 2; - float dy = size/P.rhw / scale * UI->GetRenderWidth() / 2; + float dx = size/P.rhw * scale * UI->GetRenderWidth() / 2; + float dy = size/P.rhw / scale * UI->GetRenderWidth() / 2; - cc = uchar(255.f*alpha); - cur.set (cc,cc,cc,255); + cc = uchar(255.f*alpha); + cur.set (cc,cc,cc,255); - c_da = dy*0.707106f; - s_da = -dx*0.707106f; + c_da = dy*0.707106f; + s_da = -dx*0.707106f; - mesh.m[0].sx = cx + s_da; mesh.m[0].sy = cy + c_da; - mesh.m[1].sx = cx + s_da; mesh.m[1].sy = cy - c_da; - mesh.m[3].sx = cx - s_da; mesh.m[3].sy = cy - c_da; - mesh.m[2].sx = cx - s_da; mesh.m[2].sy = cy + c_da; + mesh.m[0].sx = cx + s_da; mesh.m[0].sy = cy + c_da; + mesh.m[1].sx = cx + s_da; mesh.m[1].sy = cy - c_da; + mesh.m[3].sx = cx - s_da; mesh.m[3].sy = cy - c_da; + mesh.m[2].sx = cx - s_da; mesh.m[2].sy = cy + c_da; - mesh.setdepth ( P.sz, P.rhw ); - mesh.setcolor ( cur ); + mesh.setdepth ( P.sz, P.rhw ); + mesh.setcolor ( cur ); CDX( UI->d3d()->DrawPrimitive( D3DPT_TRIANGLESTRIP, FTLVERTEX, &mesh, 4, 0 )); UI->stat->lRenderPolyCount += 2; }*/ + diff --git a/src/editors/ECore/Editor/TLSPRITE.h b/src/editors/ECore/Editor/TLSPRITE.h index 0057f4d38b3..c360da08e27 100644 --- a/src/editors/ECore/Editor/TLSPRITE.h +++ b/src/editors/ECore/Editor/TLSPRITE.h @@ -3,77 +3,202 @@ #define TO_REAL(_X_, _S_) ((_X_)+1.f)*float(_S_/2) -typedef struct _TLpolygon { +typedef struct _TLpolygon +{ public: - union{ - struct{ - FVF::TL lb, lt, rb, rt; - }; - FVF::TL m[4]; - }; - - IC void* d3d (void) { return this; } - IC void setpos (Frect &r) { lb.p.x=r.x1; lb.p.y=r.y2;lt.p.x=r.x1;lt.p.y=r.y1;rb.p.x=r.x2;rb.p.y=r.y2;rt.p.x=r.x2;rt.p.y=r.y1;} - IC void setpos (float x1, float y1, float x2, float y2){ lb.p.x=x1; lb.p.y=y2; lt.p.x=x1; lt.p.y=y1; rb.p.x=x2; rb.p.y=y2; rt.p.x=x2; rt.p.y=y1;} - IC void setdepth(float z = 0.f, float rhw = 1.f) { lb.p.z=z; rb.p.z= z; lt.p.z = z; rt.p.z = z; lb.p.w = rhw; rb.p.w = rhw; lt.p.w = rhw; rt.p.w = rhw;}; - IC void setcolor(u32 c) { lb.color=c; rb.color=c; lt.color=c; rt.color=c; }; - IC void settex (Frect &r) { lb.uv.x = r.x1; lb.uv.y = r.y2; lt.uv.x = r.x1; lt.uv.y = r.y1; rb.uv.x = r.x2; rb.uv.y = r.y2; rt.uv.x = r.x2; rt.uv.y = r.y1; } - IC void settex (float x1, float y1, float x2, float y2){ lb.uv.x=x1; lb.uv.y=y2; lt.uv.x=x1; lt.uv.y=y1; rb.uv.x=x2; rb.uv.y=y2; rt.uv.x=x2; rt.uv.y=y1;} - - IC void to_real (int w, int h) - { - lt.p.x=lb.p.x=TO_REAL(lb.p.x, w); rb.p.x=rt.p.x=TO_REAL(rb.p.x, w); - lt.p.y=rt.p.y=TO_REAL(lt.p.y, h); lb.p.y=rb.p.y=TO_REAL(lb.p.y, h); - } - - IC void to_real (Frect &r, int w, int h) - { - lt.p.x=lb.p.x=TO_REAL(r.x1, w); lt.p.y=rt.p.y=TO_REAL(r.y1, h); - rb.p.x=rt.p.x=TO_REAL(r.x2, w); lb.p.y=rb.p.y=TO_REAL(r.y2, h); - } - - IC void add (float dx, float dy) - { - lb.p.x+=dx; lb.p.y+=dy; lt.p.x+=dx; lt.p.y+=dy; - rb.p.x+=dx; rb.p.y+=dy; rt.p.x+=dx; rt.p.y+=dy; - } - - IC void add (Frect &r, float dx, float dy) - { - lb.p.x=r.x1+dx; lb.p.y=r.y2+dy; lt.p.x=r.x1+dx; lt.p.y=r.y1+dy; - rb.p.x=r.x2+dx; rb.p.y=r.y2+dy; rt.p.x=r.x2+dx; rt.p.y=r.y1+dy; - } - - IC void sub (float dx, float dy) - { - lb.p.x-=dx; lb.p.y-=dy; lt.p.x-=dx; lt.p.y-=dy; - rb.p.x-=dx; rb.p.y-=dy; rt.p.x-=dx; rt.p.y-=dy; - } - - IC void sub (Frect &r, float dx, float dy) - { - lb.p.x=r.x1-dx; lb.p.y=r.y2-dy; lt.p.x=r.x1-dx; lt.p.y=r.y1-dy; - rb.p.x=r.x2-dx; rb.p.y=r.y2-dy; rt.p.x=r.x2-dx; rt.p.y=r.y1-dy; - } + union + { + struct + { + FVF::TL lb, lt, rb, rt; + }; + + FVF::TL m[4]; + }; + + IC + + void *d3d(void) + { + return this; + } + + IC + + void setpos(Frect &r) + { + lb.p.x = r.x1; + lb.p.y = r.y2; + lt.p.x = r.x1; + lt.p.y = r.y1; + rb.p.x = r.x2; + rb.p.y = r.y2; + rt.p.x = r.x2; + rt.p.y = r.y1; + } + + IC + + void setpos(float x1, float y1, float x2, float y2) + { + lb.p.x = x1; + lb.p.y = y2; + lt.p.x = x1; + lt.p.y = y1; + rb.p.x = x2; + rb.p.y = y2; + rt.p.x = x2; + rt.p.y = y1; + } + + IC + + void setdepth(float z = 0.f, float rhw = 1.f) + { + lb.p.z = z; + rb.p.z = z; + lt.p.z = z; + rt.p.z = z; + lb.p.w = rhw; + rb.p.w = rhw; + lt.p.w = rhw; + rt.p.w = rhw; + }; + + IC + + void setcolor(u32 c) + { + lb.color = c; + rb.color = c; + lt.color = c; + rt.color = c; + }; + + IC + + void settex(Frect &r) + { + lb.uv.x = r.x1; + lb.uv.y = r.y2; + lt.uv.x = r.x1; + lt.uv.y = r.y1; + rb.uv.x = r.x2; + rb.uv.y = r.y2; + rt.uv.x = r.x2; + rt.uv.y = r.y1; + } + + IC + + void settex(float x1, float y1, float x2, float y2) + { + lb.uv.x = x1; + lb.uv.y = y2; + lt.uv.x = x1; + lt.uv.y = y1; + rb.uv.x = x2; + rb.uv.y = y2; + rt.uv.x = x2; + rt.uv.y = y1; + } + + IC + + void to_real(int w, int h) + { + lt.p.x = lb.p.x = TO_REAL(lb.p.x, w); + rb.p.x = rt.p.x = TO_REAL(rb.p.x, w); + lt.p.y = rt.p.y = TO_REAL(lt.p.y, h); + lb.p.y = rb.p.y = TO_REAL(lb.p.y, h); + } + + IC + + void to_real(Frect &r, int w, int h) + { + lt.p.x = lb.p.x = TO_REAL(r.x1, w); + lt.p.y = rt.p.y = TO_REAL(r.y1, h); + rb.p.x = rt.p.x = TO_REAL(r.x2, w); + lb.p.y = rb.p.y = TO_REAL(r.y2, h); + } + + IC + + void add(float dx, float dy) + { + lb.p.x += dx; + lb.p.y += dy; + lt.p.x += dx; + lt.p.y += dy; + rb.p.x += dx; + rb.p.y += dy; + rt.p.x += dx; + rt.p.y += dy; + } + + IC + + void add(Frect &r, float dx, float dy) + { + lb.p.x = r.x1+dx; + lb.p.y = r.y2+dy; + lt.p.x = r.x1+dx; + lt.p.y = r.y1+dy; + rb.p.x = r.x2+dx; + rb.p.y = r.y2+dy; + rt.p.x = r.x2+dx; + rt.p.y = r.y1+dy; + } + + IC + + void sub(float dx, float dy) + { + lb.p.x -= dx; + lb.p.y -= dy; + lt.p.x -= dx; + lt.p.y -= dy; + rb.p.x -= dx; + rb.p.y -= dy; + rt.p.x -= dx; + rt.p.y -= dy; + } + + IC + + void sub(Frect &r, float dx, float dy) + { + lb.p.x = r.x1-dx; + lb.p.y = r.y2-dy; + lt.p.x = r.x1-dx; + lt.p.y = r.y1-dy; + rb.p.x = r.x2-dx; + rb.p.y = r.y2-dy; + rt.p.x = r.x2-dx; + rt.p.y = r.y1-dy; + } } FTLpolygon; -class ECORE_API CTLSprite +class ECORE_API CTLSprite { - FTLpolygon mesh; -public: - CTLSprite ( ); - virtual ~CTLSprite ( ); - void Render ( Fvector &pos, u32 color, float radius, float angle ); - IC void Render ( Fvector &pos, u32 color, float radius, float angle, const Fvector2& lt, const Fvector2& rb ){ - mesh.settex (lt.x,lt.y,rb.x,rb.y); - Render (pos,color,radius,angle); + FTLpolygon mesh; + public: + CTLSprite(); + virtual ~CTLSprite(); + void Render(Fvector&pos, u32 color, float radius, float angle); + IC void Render(Fvector&pos, u32 color, float radius, float angle, const Fvector2<, const Fvector2&rb){ + mesh.settex(lt.x, lt.y, rb.x, rb.y); + Render(pos, color, radius, angle); } - void Render ( Fvector &pos, u32 color, float radius, const Fvector& D ); - IC void Render ( Fvector &pos, u32 color, float radius, const Fvector& D, const Fvector2& lt, const Fvector2& rb){ - mesh.settex (lt.x,lt.y,rb.x,rb.y); - Render (pos,color,radius,D); + void Render(Fvector&pos, u32 color, float radius, const Fvector&D); + IC void Render(Fvector&pos, u32 color, float radius, const Fvector&D, const Fvector2<, const Fvector2&rb){ + mesh.settex(lt.x, lt.y, rb.x, rb.y); + Render(pos, color, radius, D); } - void Render ( Fvector &pos, float radius, bool bFixedSize, u32 clr=0xffffffff ); + void Render(Fvector&pos, float radius, bool bFixedSize, u32 clr = 0xffffffff); }; #endif //__TLSPRITE_H__ + + diff --git a/src/editors/ECore/Editor/UI_Camera.cpp b/src/editors/ECore/Editor/UI_Camera.cpp index 699059a0b01..bfe6726c8f3 100644 --- a/src/editors/ECore/Editor/UI_Camera.cpp +++ b/src/editors/ECore/Editor/UI_Camera.cpp @@ -3,104 +3,133 @@ #include "UI_Camera.h" #include "ui_main.h" -#include "ui_toolscustom.h" +#include "UI_ToolsCustom.h" CUI_Camera::CUI_Camera() { - m_Style = csPlaneMove; + m_Style = csPlaneMove; - m_Znear = 0.2f; - m_Zfar = 1500.f; - m_HPB.set(0,0,0); - m_Position.set(0,0,0); - m_Target.set(0,0,0); + m_Znear = 0.2f; + m_Zfar = 1500.f; + m_HPB.set(0, 0, 0); + m_Position.set(0, 0, 0); + m_Target.set(0, 0, 0); m_CamMat.identity(); - m_FlySpeed = 5.f; + m_FlySpeed = 5.f; m_FlyAltitude = 1.8f; - m_bMoving=false; + m_bMoving = false; } -CUI_Camera::~CUI_Camera() -{ -} +CUI_Camera::~CUI_Camera() {} void CUI_Camera::SetStyle(ECameraStyle new_style) { - if (new_style==cs3DArcBall){ - Fvector dir; - dir.sub (m_Target,m_Position); + if (new_style==cs3DArcBall) + { + Fvector dir; + dir.sub(m_Target, m_Position); // parse heading - Fvector DYaw; DYaw.set(dir.x,0.f,dir.z); DYaw.normalize_safe(); - if (DYaw.x<0) m_HPB.x = acosf(DYaw.z); - else m_HPB.x = 2*PI-acosf(DYaw.z); + Fvector DYaw; + DYaw.set(dir.x, 0.f, dir.z); + DYaw.normalize_safe(); + if (DYaw.x<0) + m_HPB.x = acosf(DYaw.z); + else + m_HPB.x = 2*PI-acosf(DYaw.z); // parse pitch - dir.normalize_safe (); - m_HPB.y = asinf(dir.y); + dir.normalize_safe(); + m_HPB.y = asinf(dir.y); - BuildCamera (); + BuildCamera(); } - m_Style = new_style; + m_Style = new_style; UI->RedrawScene(); } void CUI_Camera::Reset() { - m_HPB.set(0,0,0); - m_Position.set(0,3,-10); - SetStyle(m_Style); + m_HPB.set(0, 0, 0); + m_Position.set(0, 3, -10); + SetStyle(m_Style); BuildCamera(); } void CUI_Camera::Set(float h, float p, float b, float x, float y, float z) { - m_HPB.set(h,p,b); - m_Position.set(x,y,z); + m_HPB.set(h, p, b); + m_Position.set(x, y, z); BuildCamera(); } -void CUI_Camera::Set(const Fvector& hpb, const Fvector& pos) +void CUI_Camera::Set(const Fvector &hpb, const Fvector &pos) { - m_HPB.set(hpb); + m_HPB.set(hpb); m_Position.set(pos); BuildCamera(); } void CUI_Camera::BuildCamera() { - if (m_HPB.x>PI_MUL_2) m_HPB.x-=PI_MUL_2; if (m_HPB.x<-PI_MUL_2) m_HPB.x+=PI_MUL_2; - if (m_HPB.y>PI_MUL_2) m_HPB.y-=PI_MUL_2; if (m_HPB.y<-PI_MUL_2) m_HPB.y+=PI_MUL_2; - if (m_HPB.z>PI_MUL_2) m_HPB.z-=PI_MUL_2; if (m_HPB.z<-PI_MUL_2) m_HPB.z+=PI_MUL_2; - - if (m_Style==cs3DArcBall){ - Fvector D; - D.setHP (m_HPB.x,m_HPB.y); - float dist = m_Position.distance_to(m_Target); - m_Position.mul (D,-dist); - m_Position.add (m_Target); + if (m_HPB.x>PI_MUL_2) + m_HPB.x -= PI_MUL_2; + if (m_HPB.x<-PI_MUL_2) + m_HPB.x += PI_MUL_2; + if (m_HPB.y>PI_MUL_2) + m_HPB.y -= PI_MUL_2; + if (m_HPB.y<-PI_MUL_2) + m_HPB.y += PI_MUL_2; + if (m_HPB.z>PI_MUL_2) + m_HPB.z -= PI_MUL_2; + if (m_HPB.z<-PI_MUL_2) + m_HPB.z += PI_MUL_2; + + if (m_Style==cs3DArcBall) + { + Fvector D; + D.setHP(m_HPB.x, m_HPB.y); + float dist = m_Position.distance_to(m_Target); + m_Position.mul(D, -dist); + m_Position.add(m_Target); } - m_CamMat.setHPB(m_HPB.x,m_HPB.y,m_HPB.z); + m_CamMat.setHPB(m_HPB.x, m_HPB.y, m_HPB.z); m_CamMat.translate_over(m_Position); UI->OutCameraPos(); - - EDevice.vCameraPosition.set (m_CamMat.c); - EDevice.vCameraDirection.set (m_CamMat.k); - EDevice.vCameraTop.set (m_CamMat.j); - EDevice.vCameraRight.set (m_CamMat.i); + + EDevice.vCameraPosition.set(m_CamMat.c); + EDevice.vCameraDirection.set(m_CamMat.k); + EDevice.vCameraTop.set(m_CamMat.j); + EDevice.vCameraRight.set(m_CamMat.i); } void CUI_Camera::SetDepth(float _far, bool bForcedUpdate) { - if (m_Zfar!=_far) {m_Zfar=_far; UI->Resize(bForcedUpdate);} + if (m_Zfar!=_far) + { + m_Zfar = _far; + UI->Resize(bForcedUpdate); + } } void CUI_Camera::SetViewport(float _near, float _far, float _fov) { - if (m_Znear!=_near) {m_Znear=_near; UI->Resize();} - if (m_Zfar!=_far) {m_Zfar=_far; UI->Resize();} - if (EDevice.fFOV!=_fov) {EDevice.fFOV=_fov; UI->Resize();} + if (m_Znear!=_near) + { + m_Znear = _near; + UI->Resize(); + } + if (m_Zfar!=_far) + { + m_Zfar = _far; + UI->Resize(); + } + if (EDevice.fFOV!=_fov) + { + EDevice.fFOV = _fov; + UI->Resize(); + } } void CUI_Camera::SetSensitivity(float sm, float sr) @@ -109,31 +138,35 @@ void CUI_Camera::SetSensitivity(float sm, float sr) m_SR = 0.02f*(sr*sr); } -static const Fvector down_dir={0.f,-1.f,0.f}; +static const Fvector down_dir = {0.f,-1.f,0.f}; void CUI_Camera::Update(float dt) { - if (m_bMoving){ - BOOL bLeftDn = m_Shift.Contains(ssLeft); - BOOL bRightDn = m_Shift.Contains(ssRight); - if ((m_Style==csFreeFly)&&(bLeftDn||bRightDn)&&!(bLeftDn&&bRightDn)){ - Fvector vmove; - vmove.set( m_CamMat.k ); - vmove.mul( m_FlySpeed*dt ); - if (bLeftDn) m_Position.add( vmove ); - else if (bRightDn) m_Position.sub( vmove ); - - if (m_Shift.Contains(ssCtrl)){ + if (m_bMoving) + { + BOOL bLeftDn = m_Shift.Contains(ssLeft); + BOOL bRightDn = m_Shift.Contains(ssRight); + if ((m_Style==csFreeFly)&&(bLeftDn||bRightDn)&&!(bLeftDn&&bRightDn)) + { + Fvector vmove; + vmove.set(m_CamMat.k); + vmove.mul(m_FlySpeed*dt); + if (bLeftDn) + m_Position.add(vmove); + else if (bRightDn) + m_Position.sub(vmove); + + if (m_Shift.Contains(ssCtrl)) + { float dist = UI->ZFar(); - if (Tools->RayPick(m_Position,down_dir,dist))//UI->R PickGround(pos,m_Position,dir,-1)) - m_Position.y = m_Position.y+down_dir.y*dist+m_FlyAltitude; + if (Tools->RayPick(m_Position, down_dir, dist))//UI->R PickGround(pos,m_Position,dir,-1)) + m_Position.y = m_Position.y+down_dir.y*dist+m_FlyAltitude; else - m_Position.y = m_FlyAltitude; - + m_Position.y = m_FlyAltitude; } - UI->RedrawScene(); - } + UI->RedrawScene(); + } BuildCamera(); } } @@ -141,15 +174,17 @@ void CUI_Camera::Update(float dt) void CUI_Camera::Pan(float dx, float dz) { Fvector vmove; - vmove.set( m_CamMat.k ); vmove.y = 0; + vmove.set(m_CamMat.k); + vmove.y = 0; vmove.normalize_safe(); - vmove.mul( dz*-m_SM ); - m_Position.add( vmove ); + vmove.mul(dz*-m_SM); + m_Position.add(vmove); - vmove.set( m_CamMat.i ); vmove.y = 0; + vmove.set(m_CamMat.i); + vmove.y = 0; vmove.normalize_safe(); - vmove.mul( dx*m_SM ); - m_Position.add( vmove ); + vmove.mul(dx*m_SM); + m_Position.add(vmove); BuildCamera(); } @@ -157,43 +192,46 @@ void CUI_Camera::Pan(float dx, float dz) void CUI_Camera::Scale(float dy) { Fvector vmove; - vmove.set( 0.f, dy, 0.f ); + vmove.set(0.f, dy, 0.f); vmove.y *= -m_SM; - m_Position.add( vmove ); + m_Position.add(vmove); BuildCamera(); } void CUI_Camera::Rotate(float dx, float dy) { - m_HPB.x-=m_SR*dx; - m_HPB.y-=m_SR*dy*EDevice.fASPECT; + m_HPB.x -= m_SR*dx; + m_HPB.y -= m_SR*dy*EDevice.fASPECT; BuildCamera(); } bool CUI_Camera::MoveStart(TShiftState Shift) { - if (Shift.Contains(ssShift)){ - if (!m_bMoving){ - ShowCursor (FALSE); - UI->IR_GetMousePosScreen(m_StartPos); - m_bMoving = true; + if (Shift.Contains(ssShift)) + { + if (!m_bMoving) + { + ShowCursor(FALSE); + UI->IR_GetMousePosScreen(m_StartPos); + m_bMoving = true; } - m_Shift = Shift; + m_Shift = Shift; return true; } - m_Shift = Shift; + m_Shift = Shift; return false; } bool CUI_Camera::MoveEnd(TShiftState Shift) { - m_Shift = Shift; - if (!Shift.Contains(ssLeft)||!Shift.Contains(ssShift)){ - SetCursorPos(m_StartPos.x, m_StartPos.y); - ShowCursor (TRUE); - m_bMoving = false; + m_Shift = Shift; + if (!Shift.Contains(ssLeft)||!Shift.Contains(ssShift)) + { + SetCursorPos(m_StartPos.x, m_StartPos.y); + ShowCursor(TRUE); + m_bMoving = false; return true; } return false; @@ -201,143 +239,169 @@ bool CUI_Camera::MoveEnd(TShiftState Shift) bool CUI_Camera::Process(TShiftState Shift, int dx, int dy) { - if (m_bMoving){ + if (m_bMoving) + { m_Shift = Shift; -// camera move - if( dx || dy ){ - SetCursorPos(m_StartPos.x,m_StartPos.y); - switch (m_Style){ - case csPlaneMove: - if (m_Shift.Contains(ssLeft) && m_Shift.Contains(ssRight)) Rotate (dx,dy); - else if (m_Shift.Contains(ssLeft)) Pan (dx,dy); - else if(m_Shift.Contains(ssRight)) Scale (dy); - break; - case csFreeFly: - if (m_Shift.Contains(ssLeft)||m_Shift.Contains(ssRight)) Rotate (dx,dy); -// if (Shift.Contains(ssLeft)) Rotate (d.x,d.y); -// else if (Shift.Contains(ssRight)) Scale(d.y); - break; - case cs3DArcBall: - ArcBall(m_Shift,dx,dy); - break; + // camera move + if (dx||dy) + { + SetCursorPos(m_StartPos.x, m_StartPos.y); + switch (m_Style) + { + case csPlaneMove: + if (m_Shift.Contains(ssLeft)&&m_Shift.Contains(ssRight)) + Rotate(dx, dy); + else if (m_Shift.Contains(ssLeft)) + Pan(dx, dy); + else if (m_Shift.Contains(ssRight)) + Scale(dy); + break; + case csFreeFly: + if (m_Shift.Contains(ssLeft)||m_Shift.Contains(ssRight)) + Rotate(dx, dy); + // if (Shift.Contains(ssLeft)) Rotate (d.x,d.y); + // else if (Shift.Contains(ssRight)) Scale(d.y); + break; + case cs3DArcBall: + ArcBall(m_Shift, dx, dy); + break; } - UI->RedrawScene(); + UI->RedrawScene(); } return true; - } + } return false; } bool CUI_Camera::KeyDown(WORD Key, TShiftState Shift) { - if (m_bMoving){ - switch (Key){ - case VK_CONTROL: m_Shift<>ssShift; MoveEnd(m_Shift); break; - case VK_CONTROL: m_Shift>>ssCtrl; break; - default: return false; + if (m_bMoving) + { + switch (Key) + { + case VK_SHIFT: m_Shift>>ssShift; + MoveEnd(m_Shift); + break; + case VK_CONTROL: m_Shift>>ssCtrl; + break; + default: return false; } - return true; + return true; } - return false; + return false; } -void CUI_Camera::MouseRayFromPoint( Fvector& start, Fvector& direction, const Ivector2& point ) +void CUI_Camera::MouseRayFromPoint(Fvector &start, Fvector &direction, const Ivector2 &point) { - int halfwidth = UI->GetRealWidth()*0.5f; - int halfheight = UI->GetRealHeight()*0.5f; + int halfwidth = UI->GetRealWidth()*0.5f; + int halfheight = UI->GetRealHeight()*0.5f; - if (!halfwidth||!halfheight) return; + if (!halfwidth||!halfheight) + return; Ivector2 point2; point2.set(point.x-halfwidth, halfheight-point.y); - start.set( m_Position ); + start.set(m_Position); - float size_y = m_Znear * tan( deg2rad(EDevice.fFOV) * 0.5f ); - float size_x = size_y / EDevice.fASPECT; + float size_y = m_Znear*tan(deg2rad(EDevice.fFOV)*0.5f); + float size_x = size_y/EDevice.fASPECT; - float r_pt = float(point2.x) * size_x / (float) halfwidth; - float u_pt = float(point2.y) * size_y / (float) halfheight; + float r_pt = float(point2.x)*size_x/(float) halfwidth; + float u_pt = float(point2.y)*size_y/(float) halfheight; - direction.mul( m_CamMat.k, m_Znear ); - direction.mad( direction, m_CamMat.j, u_pt ); - direction.mad( direction, m_CamMat.i, r_pt ); - direction.normalize(); + direction.mul(m_CamMat.k, m_Znear); + direction.mad(direction, m_CamMat.j, u_pt); + direction.mad(direction, m_CamMat.i, r_pt); + direction.normalize(); } -void CUI_Camera::ZoomExtents(const Fbox& bb) +void CUI_Camera::ZoomExtents(const Fbox &bb) { - Fvector C,D; - float R,H1,H2; - bb.getsphere(C,R); - D.mul(m_CamMat.k,-1); + Fvector C, D; + float R, H1, H2; + bb.getsphere(C, R); + D.mul(m_CamMat.k, -1); H1 = R/sinf(deg2rad(EDevice.fFOV)*0.5f); H2 = R/sinf(deg2rad(EDevice.fFOV)*0.5f/EDevice.fASPECT); - m_Position.mad(C,D,_max(H1,H2)); - m_Target.set(C); - - BuildCamera(); -/* - eye_k - ôîêóñíîå ðàññòîÿíèå, eye_k=eye_width/2 - camera.alfa:=0; - camera.beta:=-30*pi/180; - camera.gama:=0; - s:=(maxx-minx)*eye_k/eye_width*0.5*0.5; - camera.posx:=(maxx+minx)/2; - camera.posy:=maxy+s*tan(30*pi/180); - camera.posz:=minz-s; -*/ + m_Position.mad(C, D, _max(H1, H2)); + m_Target.set(C); + + BuildCamera(); + /* + eye_k - ôîêóñíîå ðàññòîÿíèå, eye_k=eye_width/2 + camera.alfa:=0; + camera.beta:=-30*pi/180; + camera.gama:=0; + s:=(maxx-minx)*eye_k/eye_width*0.5*0.5; + camera.posx:=(maxx+minx)/2; + camera.posy:=maxy+s*tan(30*pi/180); + camera.posz:=minz-s; + */ } void CUI_Camera::ArcBall(TShiftState Shift, float dx, float dy) { - float dist = m_Position.distance_to(m_Target); - if (Shift.Contains(ssAlt)){ - if (Shift.Contains(ssLeft)){ + float dist = m_Position.distance_to(m_Target); + if (Shift.Contains(ssAlt)) + { + if (Shift.Contains(ssLeft)) + { Fvector vmove; - vmove.set( m_CamMat.k ); vmove.y = 0; + vmove.set(m_CamMat.k); + vmove.y = 0; vmove.normalize_safe(); - vmove.mul( dy*-m_SM ); - m_Target.add( vmove ); + vmove.mul(dy*-m_SM); + m_Target.add(vmove); - vmove.set( m_CamMat.i ); vmove.y = 0; + vmove.set(m_CamMat.i); + vmove.y = 0; vmove.normalize_safe(); - vmove.mul( dx*m_SM ); - m_Target.add( vmove ); - }else if(Shift.Contains(ssRight)){ + vmove.mul(dx*m_SM); + m_Target.add(vmove); + } + else if (Shift.Contains(ssRight)) + { Fvector vmove; - vmove.set( 0.f, dy, 0.f ); + vmove.set(0.f, dy, 0.f); vmove.y *= -m_SM; - m_Target.add( vmove ); + m_Target.add(vmove); + } + } + else + { + if (Shift.Contains(ssRight)) + { + dist -= dx*m_SM; + } + else if (Shift.Contains(ssLeft)) + { + m_HPB.x -= m_SR*dx; + m_HPB.y -= m_SR*dy*EDevice.fASPECT; } - }else{ - if (Shift.Contains(ssRight)){ - dist -= dx*m_SM; - }else if (Shift.Contains(ssLeft)){ - m_HPB.x-=m_SR*dx; - m_HPB.y-=m_SR*dy*EDevice.fASPECT; - } } Fvector D; - D.setHP (m_HPB.x,m_HPB.y); + D.setHP(m_HPB.x, m_HPB.y); - m_Position.mul (D,-dist); - m_Position.add (m_Target); + m_Position.mul(D, -dist); + m_Position.add(m_Target); - BuildCamera (); + BuildCamera(); } - diff --git a/src/editors/ECore/Editor/UI_Camera.h b/src/editors/ECore/Editor/UI_Camera.h index cf005042cb1..1ee4d587c0d 100644 --- a/src/editors/ECore/Editor/UI_Camera.h +++ b/src/editors/ECore/Editor/UI_Camera.h @@ -2,80 +2,82 @@ #ifndef UI_CameraH #define UI_CameraH -enum ECameraStyle{ - csPlaneMove=0, - cs3DArcBall, +enum ECameraStyle +{ + csPlaneMove=0, + cs3DArcBall, csFreeFly }; class ECORE_API CUI_Camera{ - ECameraStyle m_Style; - bool m_bMoving; - TShiftState m_Shift; - Ivector2 m_StartPos; - float m_FlySpeed; - float m_FlyAltitude; + ECameraStyle m_Style; + bool m_bMoving; + TShiftState m_Shift; + Ivector2 m_StartPos; + float m_FlySpeed; + float m_FlyAltitude; - Fmatrix m_CamMat; - Fvector m_HPB; - Fvector m_Position; - Fvector m_Target; -protected: - friend class CEditorRenderDevice; - friend class TUI; + Fmatrix m_CamMat; + Fvector m_HPB; + Fvector m_Position; + Fvector m_Target; + protected: + friendclass CEditorRenderDevice; + friendclass TUI; - float m_Znear; - float m_Zfar; - float m_SR, m_SM; + float m_Znear; + float m_Zfar; + float m_SR, m_SM; - void Pan (float X, float Z); - void Scale (float Y); - void Rotate (float X, float Y); - void ArcBall (TShiftState Shift, float X, float Y); -public: - CUI_Camera (); - virtual ~CUI_Camera (); + void Pan(float X, float Z); + void Scale(float Y); + void Rotate(float X, float Y); + void ArcBall(TShiftState Shift, float X, float Y); + public: + CUI_Camera(); + virtual ~CUI_Camera(); - IC float _Znear (){return m_Znear;} - IC float _Zfar (){return m_Zfar;} + IC float _Znear(){return m_Znear;} + IC float _Zfar(){return m_Zfar;} - void BuildCamera (); - void Reset (); - void Update (float dt); - void SetStyle (ECameraStyle style); - ECameraStyle GetStyle (){return m_Style;} + void BuildCamera(); + void Reset(); + void Update(float dt); + void SetStyle(ECameraStyle style); + ECameraStyle GetStyle(){return m_Style;} - bool MoveStart (TShiftState Shift); - bool MoveEnd (TShiftState Shift); - bool IsMoving (){return m_bMoving;} - bool Process (TShiftState Shift, int dx, int dy); - bool KeyDown (WORD Key, TShiftState Shift); - bool KeyUp (WORD Key, TShiftState Shift); + bool MoveStart(TShiftState Shift); + bool MoveEnd(TShiftState Shift); + bool IsMoving(){return m_bMoving;} + bool Process(TShiftState Shift, int dx, int dy); + bool KeyDown(WORD Key, TShiftState Shift); + bool KeyUp(WORD Key, TShiftState Shift); - void ViewFront (){m_HPB.set(0.f,0.f,0.f); BuildCamera();} - void ViewBack (){m_HPB.set(M_PI,0.f,0.f); BuildCamera();} - void ViewLeft (){m_HPB.set(-PI_DIV_2,0.f,0.f); BuildCamera();} - void ViewRight (){m_HPB.set(PI_DIV_2,0.f,0.f); BuildCamera();} - void ViewTop (){m_HPB.set(0.f,-PI_DIV_2,0.f); BuildCamera();} - void ViewBottom (){m_HPB.set(0.f,PI_DIV_2,0.f); BuildCamera();} - void ViewReset (){m_HPB.set(0.f,0,0.f); m_Position.set(0,0,0); m_Target.set(0,0,0); BuildCamera();} + void ViewFront(){m_HPB.set(0.f, 0.f, 0.f); BuildCamera();} + void ViewBack(){m_HPB.set(M_PI, 0.f, 0.f); BuildCamera();} + void ViewLeft(){m_HPB.set(-PI_DIV_2, 0.f, 0.f); BuildCamera();} + void ViewRight(){m_HPB.set(PI_DIV_2, 0.f, 0.f); BuildCamera();} + void ViewTop(){m_HPB.set(0.f, -PI_DIV_2, 0.f); BuildCamera();} + void ViewBottom(){m_HPB.set(0.f, PI_DIV_2, 0.f); BuildCamera();} + void ViewReset(){m_HPB.set(0.f, 0, 0.f); m_Position.set(0, 0, 0); m_Target.set(0, 0, 0); BuildCamera();} - const Fmatrix& GetTransform() const {return m_CamMat;} - const Fmatrix& GetView (Fmatrix& V) const {return V.invert(m_CamMat);} - const Fvector& GetHPB () const {return m_HPB;} - const Fvector& GetPosition () const {return m_Position;} - const Fvector& GetRight () const {return m_CamMat.i;} - const Fvector& GetNormal () const {return m_CamMat.j;} - const Fvector& GetDirection() const {return m_CamMat.k;} - void Set (float h, float p, float b, float x, float y, float z); - void Set (const Fvector& hpb, const Fvector& pos); - void SetSensitivity(float sm, float sr); - void SetViewport (float _near, float _far, float _fov); - void SetDepth (float _far, bool bForcedUpdate); - void SetFlyParams(float speed, float fAltitude){ m_FlySpeed=speed; m_FlyAltitude=fAltitude; } + const Fmatrix&GetTransform() const{return m_CamMat;} + const Fmatrix&GetView(Fmatrix&V) const{return V.invert(m_CamMat);} + const Fvector&GetHPB() const{return m_HPB;} + const Fvector&GetPosition() const{return m_Position;} + const Fvector&GetRight() const{return m_CamMat.i;} + const Fvector&GetNormal() const{return m_CamMat.j;} + const Fvector&GetDirection() const{return m_CamMat.k;} + void Set(float h, float p, float b, float x, float y, float z); + void Set(const Fvector&hpb, const Fvector&pos); + void SetSensitivity(float sm, float sr); + void SetViewport(float _near, float _far, float _fov); + void SetDepth(float _far, bool bForcedUpdate); + void SetFlyParams(float speed, float fAltitude){m_FlySpeed = speed; m_FlyAltitude = fAltitude;} - void ZoomExtents (const Fbox& bb); + void ZoomExtents(const Fbox&bb); - void MouseRayFromPoint(Fvector& start, Fvector& direction, const Ivector2& point); + void MouseRayFromPoint(Fvector&start, Fvector&direction, const Ivector2&point); }; #endif + diff --git a/src/editors/ECore/Editor/UI_MainCommand.cpp b/src/editors/ECore/Editor/UI_MainCommand.cpp index 3ff83c0c548..69807abb6c2 100644 --- a/src/editors/ECore/Editor/UI_MainCommand.cpp +++ b/src/editors/ECore/Editor/UI_MainCommand.cpp @@ -9,228 +9,289 @@ #include "ImageEditor.h" #include "MinimapEditor.h" #include "SoundEditor.h" -#include "d3dutils.h" +#include "D3DUtils.h" -#include "PSLibrary.h" +#include "Layers/xrRender/PSLibrary.h" #include "Library.h" -#include "LightAnimLibrary.h" +#include "xrEngine/LightAnimLibrary.h" #include "ImageManager.h" #include "SoundManager.h" -#include "ResourceManager.h" -#include "igame_persistent.h" -#include "NumericVector.h" +#include "Layers/xrRender/ResourceManager.h" +#include "xrEngine/IGame_Persistent.h" +#include "editors/xrEProps/NumericVector.h" -#include "TextForm.h" +#include "editors/xrEProps/TextForm.h" -ECommandVec ECommands; -BOOL bAllowReceiveCommand = FALSE; -BOOL bAllowLogCommands = FALSE; -TfrmText* frmEditCommandList = 0; -AnsiString sCommandListText; +ECommandVec ECommands; +BOOL bAllowReceiveCommand = FALSE; +BOOL bAllowLogCommands = FALSE; +TfrmText *frmEditCommandList = 0; +AnsiString sCommandListText; BOOL AllowLogCommands() { - return bAllowLogCommands; + return bAllowLogCommands; } -ECommandVec& GetEditorCommands() +ECommandVec &GetEditorCommands() { - return ECommands; + return ECommands; } -void EnableReceiveCommands() + +void EnableReceiveCommands() { - bAllowReceiveCommand = TRUE; + bAllowReceiveCommand = TRUE; } -SESubCommand* FindCommandByShortcut(const xr_shortcut& val) + +SESubCommand *FindCommandByShortcut(const xr_shortcut &val) { - ECommandVec& cmds = GetEditorCommands(); - for (u32 cmd_idx=0; cmd_idxeditable){ - VERIFY(!CMD->sub_commands.empty()); - for (u32 sub_cmd_idx=0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++){ - SESubCommand*& SUB_CMD = CMD->sub_commands[sub_cmd_idx]; - if (SUB_CMD->shortcut.similar(val)) return SUB_CMD; + ECommandVec&cmds = GetEditorCommands(); + for (u32 cmd_idx = 0; cmd_idxeditable) + { + VERIFY(!CMD->sub_commands.empty()); + for (u32 sub_cmd_idx = 0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++) + { + SESubCommand*& SUB_CMD = CMD->sub_commands[sub_cmd_idx]; + if (SUB_CMD->shortcut.similar(val)) + return SUB_CMD; } } } return 0; } -SECommand* FindCommandByName(LPCSTR nm) + +SECommand *FindCommandByName(LPCSTR nm) { - ECommandVec& cmds = GetEditorCommands(); - for (u32 cmd_idx=0; cmd_idxname,nm))) return CMD; + ECommandVec&cmds = GetEditorCommands(); + for (u32 cmd_idx = 0; cmd_idxname, nm))) + return CMD; } return 0; } -SESubCommand* FindSubCommandByName(SECommand* CMD, LPCSTR nm) + +SESubCommand *FindSubCommandByName(SECommand *CMD, LPCSTR nm) { - VERIFY(CMD && !CMD->sub_commands.empty()); - for (u32 sub_cmd_idx=0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++){ - SESubCommand* SUB_CMD = CMD->sub_commands[sub_cmd_idx]; - if (0==stricmp(SUB_CMD->desc.c_str(),nm)) return SUB_CMD; + VERIFY(CMD&&!CMD->sub_commands.empty()); + for (u32 sub_cmd_idx = 0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++) + { + SESubCommand*SUB_CMD = CMD->sub_commands[sub_cmd_idx]; + if (0==stricmp(SUB_CMD->desc.c_str(), nm)) + return SUB_CMD; } return 0; } -void ParseParam(xr_string sp, CCommandVar& res) + +void ParseParam(xr_string sp, CCommandVar &res) { - if (!sp.empty()){ - u32 rs=0,ip=0; - if (0==strstr(sp.c_str(),"\"")) - rs = sscanf(sp.c_str(),"%d",&ip); - if (1!=rs){ - _GetItem(sp.c_str(),1,sp,'\"'); - if (!sp.empty()) res = sp; - }else res = ip; + if (!sp.empty()) + { + u32 rs = 0, ip = 0; + if (0==strstr(sp.c_str(), "\"")) + rs = sscanf(sp.c_str(), "%d", &ip); + if (1!=rs) + { + _GetItem(sp.c_str(), 1, sp, '\"'); + if (!sp.empty()) + res = sp; + } + else + res = ip; } } -CCommandVar ExecCommand (const xr_shortcut& val) + +CCommandVar ExecCommand(const xr_shortcut &val) { - SESubCommand* SUB = FindCommandByShortcut(val); - CCommandVar res = CCommandVar(u32(0)); + SESubCommand*SUB = FindCommandByShortcut(val); + CCommandVar res = CCommandVar(u32(0)); if (SUB) - res = ExecCommand(SUB->parent->idx,SUB->p0,SUB->p1); + res = ExecCommand(SUB->parent->idx, SUB->p0, SUB->p1); return res; } -CCommandVar ExecCommand (u32 cmd, CCommandVar p1, CCommandVar p2) -{ - if (!bAllowReceiveCommand) return 0; - - VERIFY (cmdcommand.empty()); - static int exec_level= 0; - if (bAllowLogCommands){ - string128 level;strcpy(level,exec_level==0?"":";"); - for(int k=0; kName(),sp1.c_str(),sp2.c_str()); - else if (p1.IsInteger()&&p2.IsInteger())Msg("%s%s (%d,%d)", level,CMD->Name(),u32(p1),u32(p2)); - else if (p1.IsInteger()&&p2.IsString()) Msg("%s%s (%d,\"%s\")", level,CMD->Name(),u32(p1),sp2.c_str()); - else if (p1.IsString()&&p2.IsInteger()) Msg("%s%s (\"%s\",%d)", level,CMD->Name(),sp1.c_str(),u32(p2)); + +CCommandVar ExecCommand(u32 cmd, CCommandVar p1, CCommandVar p2) +{ + if (!bAllowReceiveCommand) + return 0; + + VERIFY(cmdcommand.empty()); + static int exec_level = 0; + if (bAllowLogCommands) + { + string128 level; + strcpy(level, exec_level==0 ? "" : ";"); + for (int k = 0; kName(), sp1.c_str(), sp2.c_str()); + else if (p1.IsInteger()&&p2.IsInteger()) + Msg("%s%s (%d,%d)", level, CMD->Name(), u32(p1), u32(p2)); + else if (p1.IsInteger()&&p2.IsString()) + Msg("%s%s (%d,\"%s\")", level, CMD->Name(), u32(p1), sp2.c_str()); + else if (p1.IsString()&&p2.IsInteger()) + Msg("%s%s (\"%s\",%d)", level, CMD->Name(), sp1.c_str(), u32(p2)); } exec_level++; - res = CMD->command(p1,p2); - exec_level--; VERIFY(exec_level>=0); + res = CMD->command(p1, p2); + exec_level--; + VERIFY(exec_level>=0); return res; } -void RegisterCommand (u32 cmd, SECommand* cmd_impl) + +void RegisterCommand(u32 cmd, SECommand *cmd_impl) { - if (cmd>=ECommands.size()) - ECommands.resize(cmd+1,0); - SECommand*& CMD = ECommands[cmd]; - if (CMD){ - Msg ("RegisterCommand: command '%s' overridden by command '%s'.",*CMD->desc,*cmd_impl->desc); - xr_delete (CMD); + if (cmd>=ECommands.size()) + ECommands.resize(cmd+1, 0); + SECommand*& CMD = ECommands[cmd]; + if (CMD) + { + Msg("RegisterCommand: command '%s' overridden by command '%s'.", *CMD->desc, *cmd_impl->desc); + xr_delete(CMD); } - CMD = cmd_impl; -} -void RegisterSubCommand(SECommand* cmd_impl, LPCSTR desc, CCommandVar p0, CCommandVar p1) -{ - VERIFY (cmd_impl); - cmd_impl->AppendSubCommand(desc,p0,p1); -} -BOOL LoadShortcuts(CInifile* ini) -{ - for (u32 cmd_idx=0; cmd_idxeditable){ - for (u32 sub_cmd_idx=0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++){ - SESubCommand*& SUB = CMD->sub_commands[sub_cmd_idx]; - string256 nm,tmp; - if (SUB->desc.size()) sprintf(nm,"%s.\"%s\"",CMD->Name(),SUB->desc.c_str()); - else sprintf(nm,"%s",CMD->Name()); - if (ini->line_exist("shortcuts",nm)){ - LPCSTR val = ini->r_string("shortcuts",nm); - int res = sscanf(val,"%d,%s",&SUB->shortcut.hotkey,tmp); - if (2==res){ - xr_string sp; - _GetItem (tmp,0,sp); - ParseParam (sp,SUB->p0); - _GetItem (tmp,1,sp); - ParseParam (sp,SUB->p1); + CMD = cmd_impl; +} + +void RegisterSubCommand(SECommand *cmd_impl, LPCSTR desc, CCommandVar p0, CCommandVar p1) +{ + VERIFY(cmd_impl); + cmd_impl->AppendSubCommand(desc, p0, p1); +} + +BOOL LoadShortcuts(CInifile *ini) +{ + for (u32 cmd_idx = 0; cmd_idxeditable) + { + for (u32 sub_cmd_idx = 0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++) + { + SESubCommand*& SUB = CMD->sub_commands[sub_cmd_idx]; + string256 nm, tmp; + if (SUB->desc.size()) + sprintf(nm, "%s.\"%s\"", CMD->Name(), SUB->desc.c_str()); + else + sprintf(nm, "%s", CMD->Name()); + if (ini->line_exist("shortcuts", nm)) + { + LPCSTR val = ini->r_string("shortcuts", nm); + int res = sscanf(val, "%d,%s", &SUB->shortcut.hotkey, tmp); + if (2==res) + { + xr_string sp; + _GetItem(tmp, 0, sp); + ParseParam(sp, SUB->p0); + _GetItem(tmp, 1, sp); + ParseParam(sp, SUB->p1); } } } } } - return TRUE; -} -BOOL SaveShortcuts(CInifile* ini) -{ - for (u32 cmd_idx=0; cmd_idxeditable){ - for (u32 sub_cmd_idx=0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++){ - SESubCommand*& SUB = CMD->sub_commands[sub_cmd_idx]; - string256 nm,tmp; - if (SUB->desc.size()) sprintf(nm,"%s.\"%s\"",CMD->Name(),SUB->desc.c_str()); - else sprintf(nm,"%s",CMD->Name()); - if (SUB->p0.IsString()&&SUB->p1.IsString()) sprintf(tmp,"%d, \"%s\",\"%s\"",SUB->shortcut.hotkey,xr_string(SUB->p0).c_str(),xr_string(SUB->p1).c_str()); - else if (SUB->p0.IsInteger()&&SUB->p1.IsInteger()) sprintf(tmp,"%d, %d,%d", SUB->shortcut.hotkey,u32(SUB->p0),u32(SUB->p1)); - else if (SUB->p0.IsInteger()&&SUB->p1.IsString()) sprintf(tmp,"%d, %d,\"%s\"", SUB->shortcut.hotkey,u32(SUB->p0),xr_string(SUB->p1).c_str()); - else if (SUB->p0.IsString()&&SUB->p1.IsInteger()) sprintf(tmp,"%d, \"%s\",%d", SUB->shortcut.hotkey,xr_string(SUB->p0).c_str(),u32(SUB->p1)); - ini->w_string ("shortcuts",nm,tmp); + return TRUE; +} + +BOOL SaveShortcuts(CInifile *ini) +{ + for (u32 cmd_idx = 0; cmd_idxeditable) + { + for (u32 sub_cmd_idx = 0; sub_cmd_idxsub_commands.size(); sub_cmd_idx++) + { + SESubCommand*& SUB = CMD->sub_commands[sub_cmd_idx]; + string256 nm, tmp; + if (SUB->desc.size()) + sprintf(nm, "%s.\"%s\"", CMD->Name(), SUB->desc.c_str()); + else + sprintf(nm, "%s", CMD->Name()); + if (SUB->p0.IsString()&&SUB->p1.IsString()) + sprintf(tmp, "%d, \"%s\",\"%s\"", SUB->shortcut.hotkey, xr_string(SUB->p0).c_str(), xr_string(SUB->p1).c_str()); + else if (SUB->p0.IsInteger()&&SUB->p1.IsInteger()) + sprintf(tmp, "%d, %d,%d", SUB->shortcut.hotkey, u32(SUB->p0), u32(SUB->p1)); + else if (SUB->p0.IsInteger()&&SUB->p1.IsString()) + sprintf(tmp, "%d, %d,\"%s\"", SUB->shortcut.hotkey, u32(SUB->p0), xr_string(SUB->p1).c_str()); + else if (SUB->p0.IsString()&&SUB->p1.IsInteger()) + sprintf(tmp, "%d, \"%s\",%d", SUB->shortcut.hotkey, xr_string(SUB->p0).c_str(), u32(SUB->p1)); + ini->w_string("shortcuts", nm, tmp); } } } - return TRUE; + return TRUE; } -void ClearCommands() + +void ClearCommands() { - for (ECommandVecIt it=ECommands.begin(); it!=ECommands.end(); it++) - xr_delete (*it); - ECommands.clear (); + for (ECommandVecIt it = ECommands.begin(); it!=ECommands.end(); it++) + xr_delete(*it); + ECommands.clear(); } -void TUI::ClearCommands () +void TUI::ClearCommands() { - ::ClearCommands (); + ::ClearCommands(); } //------------------------------------------------------------------------------ // UI Commands //------------------------------------------------------------------------------ -CCommandVar TUI::CommandRenderFocus(CCommandVar p1, CCommandVar p2) +CCommandVar TUI::CommandRenderFocus(CCommandVar p1, CCommandVar p2) { if (((TForm*)m_D3DWindow->Owner)->Visible&&m_bReady) m_D3DWindow->SetFocus(); return 1; } -CCommandVar TUI::CommandBreakLastOperation(CCommandVar p1, CCommandVar p2) + +CCommandVar TUI::CommandBreakLastOperation(CCommandVar p1, CCommandVar p2) { - if (mrYes==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Are you sure to break current action?")){ - NeedBreak (); - ELog.Msg (mtInformation,"Execution canceled."); + if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<Width,h=m_D3DPanel->Height,w_2=w/2,h_2=h/2; + if (psDeviceFlags.is(rsDrawSafeRect)) + { + int w = m_D3DPanel->Width, h = m_D3DPanel->Height, w_2 = w/2, h_2 = h/2; Irect rect; - if ((0.75f*float(w))>float(h)) rect.set(w_2-1.33f*float(h_2),0,1.33f*h,h); - else rect.set(0,h_2-0.75f*float(w_2),w,0.75f*w); - m_D3DWindow->Left = rect.x1; - m_D3DWindow->Top = rect.y1; - m_D3DWindow->Width = rect.x2; - m_D3DWindow->Height = rect.y2; - }else{ - m_D3DWindow->Left = 0; - m_D3DWindow->Top = 0; - m_D3DWindow->Width = m_D3DPanel->Width; - m_D3DWindow->Height = m_D3DPanel->Height; + if ((0.75f*float(w))>float(h)) + rect.set(w_2-1.33f*float(h_2), 0, 1.33f*h, h); + else + rect.set(0, h_2-0.75f*float(w_2), w, 0.75f*w); + m_D3DWindow->Left = rect.x1; + m_D3DWindow->Top = rect.y1; + m_D3DWindow->Width = rect.x2; + m_D3DWindow->Height = rect.y2; + } + else + { + m_D3DWindow->Left = 0; + m_D3DWindow->Top = 0; + m_D3DWindow->Width = m_D3DPanel->Width; + m_D3DWindow->Height = m_D3DPanel->Height; } - UI->RedrawScene (); + UI->RedrawScene(); return 1; } @@ -239,504 +300,581 @@ CCommandVar TUI::CommandRenderResize(CCommandVar p1, CCommandVar p2) //------------------------------------------------------------------------------ CCommandVar CommandInitialize(CCommandVar p1, CCommandVar p2) { - CCommandVar res = TRUE; - Engine.Initialize (); + CCommandVar res = TRUE; + Engine.Initialize(); // make interface //---------------- - EPrefs->OnCreate (); - if (UI->OnCreate((TD3DWindow*)(u32)p1,(TPanel*)(u32)p2)) + EPrefs->OnCreate(); + if (UI->OnCreate((TD3DWindow*)(u32)p1, (TPanel*)(u32)p2)) { - ExecCommand (COMMAND_CREATE_SOUND_LIB); R_ASSERT(SndLib); + ExecCommand(COMMAND_CREATE_SOUND_LIB); + R_ASSERT(SndLib); SndLib->OnCreate(); - LALib.OnCreate (); - Lib.OnCreate (); + LALib.OnCreate(); + Lib.OnCreate(); BOOL bWeather = psDeviceFlags.is(rsEnvironment); psDeviceFlags.set(rsEnvironment, FALSE); - g_pGamePersistent= xr_new(); + g_pGamePersistent = xr_new(); if (Tools->OnCreate()) { - EPrefs->Load(); + EPrefs->Load(); EDevice.seqAppStart.Process(rp_AppStart); - ExecCommand (COMMAND_RESTORE_UI_BAR); - ExecCommand (COMMAND_REFRESH_UI_BAR); - ExecCommand (COMMAND_CLEAR); - ExecCommand (COMMAND_RENDER_FOCUS); - ExecCommand (COMMAND_CHANGE_ACTION, etaSelect); - ExecCommand (COMMAND_RENDER_RESIZE); -/* - if(bWeather && EPrefs->sWeather.size() ) - { - psDeviceFlags.set(rsEnvironment, TRUE); - g_pGamePersistent->Environment().SetWeather(EPrefs->sWeather, true); - - } -*/ - }else{ - res = FALSE; + ExecCommand(COMMAND_RESTORE_UI_BAR); + ExecCommand(COMMAND_REFRESH_UI_BAR); + ExecCommand(COMMAND_CLEAR); + ExecCommand(COMMAND_RENDER_FOCUS); + ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); + ExecCommand(COMMAND_RENDER_RESIZE); + /* + if(bWeather && EPrefs->sWeather.size() ) + { + psDeviceFlags.set(rsEnvironment, TRUE); + g_pGamePersistent->Environment().SetWeather(EPrefs->sWeather, true); + + } + */ } - }else{ - res = FALSE; + else + { + res = FALSE; + } + } + else + { + res = FALSE; } return res; -} -CCommandVar CommandDestroy(CCommandVar p1, CCommandVar p2) +} + +CCommandVar CommandDestroy(CCommandVar p1, CCommandVar p2) { - ExecCommand (COMMAND_SAVE_UI_BAR); - EPrefs->OnDestroy (); - ExecCommand (COMMAND_CLEAR); + ExecCommand(COMMAND_SAVE_UI_BAR); + EPrefs->OnDestroy(); + ExecCommand(COMMAND_CLEAR); EDevice.seqAppEnd.Process(rp_AppEnd); - xr_delete (g_pGamePersistent); - LALib.OnDestroy (); - Tools->OnDestroy (); - SndLib->OnDestroy (); - xr_delete (SndLib); - Lib.OnDestroy (); - UI->OnDestroy (); - Engine.Destroy (); - return TRUE; -} -CCommandVar CommandQuit(CCommandVar p1, CCommandVar p2) + xr_delete(g_pGamePersistent); + LALib.OnDestroy(); + Tools->OnDestroy(); + SndLib->OnDestroy(); + xr_delete(SndLib); + Lib.OnDestroy(); + UI->OnDestroy(); + Engine.Destroy(); + return TRUE; +} + +CCommandVar CommandQuit(CCommandVar p1, CCommandVar p2) { - UI->Quit (); - return TRUE; -} -CCommandVar CommandEditorPrefs(CCommandVar p1, CCommandVar p2) + UI->Quit(); + return TRUE; +} + +CCommandVar CommandEditorPrefs(CCommandVar p1, CCommandVar p2) { - EPrefs->Edit (); - return TRUE; -} -CCommandVar CommandChangeAction(CCommandVar p1, CCommandVar p2) + EPrefs->Edit(); + return TRUE; +} + +CCommandVar CommandChangeAction(CCommandVar p1, CCommandVar p2) { - Tools->SetAction (ETAction(u32(p1))); - return TRUE; -} -CCommandVar CommandChangeAxis(CCommandVar p1, CCommandVar p2) + Tools->SetAction(ETAction(u32(p1))); + return TRUE; +} + +CCommandVar CommandChangeAxis(CCommandVar p1, CCommandVar p2) { - Tools->SetAxis (ETAxis(u32(p1))); - return TRUE; + Tools->SetAxis(ETAxis(u32(p1))); + return TRUE; } -CCommandVar CommandSimulate(CCommandVar p1, CCommandVar p2) +CCommandVar CommandSimulate(CCommandVar p1, CCommandVar p2) { + Tools->Simulate(); - Tools->Simulate(); - - return TRUE; + return TRUE; } -CCommandVar CommandUseSimulatePositions(CCommandVar p1, CCommandVar p2) +CCommandVar CommandUseSimulatePositions(CCommandVar p1, CCommandVar p2) { + Tools->UseSimulatePositions(); - Tools->UseSimulatePositions(); - - return TRUE; + return TRUE; } - -CCommandVar CommandSetSettings(CCommandVar p1, CCommandVar p2) +CCommandVar CommandSetSettings(CCommandVar p1, CCommandVar p2) { - Tools->SetSettings(p1,p2); - return TRUE; -} -CCommandVar CommandSoundEditor(CCommandVar p1, CCommandVar p2) + Tools->SetSettings(p1, p2); + return TRUE; +} + +CCommandVar CommandSoundEditor(CCommandVar p1, CCommandVar p2) { TfrmSoundLib::EditLib(AnsiString("Sound Editor")); - return TRUE; + return TRUE; } -CCommandVar CommandSyncSounds(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandSyncSounds(CCommandVar p1, CCommandVar p2) { - if (ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Are you sure to synchronize sounds?")==mrYes) + if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<RefreshSounds(true); - return TRUE; + return TRUE; } -CCommandVar CommandImageEditor(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandImageEditor(CCommandVar p1, CCommandVar p2) { TfrmImageLib::EditLib(AnsiString("Image Editor")); - return TRUE; + return TRUE; } -CCommandVar CommandMinimapEditor(CCommandVar p1, CCommandVar p2) +CCommandVar CommandMinimapEditor(CCommandVar p1, CCommandVar p2) { - TTMinimapEditor::Show (); - return TRUE; + TTMinimapEditor::Show(); + return TRUE; } -CCommandVar CommandCheckTextures(CCommandVar p1, CCommandVar p2) +CCommandVar CommandCheckTextures(CCommandVar p1, CCommandVar p2) { TfrmImageLib::ImportTextures(); - return TRUE; + return TRUE; } -CCommandVar CommandRefreshTextures(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandRefreshTextures(CCommandVar p1, CCommandVar p2) { - if (ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Are you sure to synchronize textures?")==mrYes) + if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<RedrawScene (); - return TRUE; + UI->RedrawScene(); + return TRUE; } -CCommandVar CommandChangeSnap(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandChangeSnap(CCommandVar p1, CCommandVar p2) { ((TExtBtn*)(u32)p1)->Down = !((TExtBtn*)(u32)p1)->Down; - return TRUE; + return TRUE; } -CCommandVar CommandUnloadTextures(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandUnloadTextures(CCommandVar p1, CCommandVar p2) { EDevice.UnloadTextures(); - return TRUE; + return TRUE; } -CCommandVar CommandEvictObjects(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandEvictObjects(CCommandVar p1, CCommandVar p2) { - Lib.EvictObjects (); - return TRUE; + Lib.EvictObjects(); + return TRUE; } -CCommandVar CommandEvictTextures(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandEvictTextures(CCommandVar p1, CCommandVar p2) { EDevice.Resources->Evict(); - return TRUE; + return TRUE; } -CCommandVar CommandCheckModified(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandCheckModified(CCommandVar p1, CCommandVar p2) { - return Tools->IsModified(); + return Tools->IsModified(); } -CCommandVar CommandExit(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandExit(CCommandVar p1, CCommandVar p2) { - return Tools->IfModified(); + return Tools->IfModified(); } -CCommandVar CommandShowProperties(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandShowProperties(CCommandVar p1, CCommandVar p2) { - if(p1.IsString()) + if (p1.IsString()) { - xr_string SSS = p1; - Tools->ShowProperties(SSS.c_str()); - }else - Tools->ShowProperties(NULL); - return TRUE; + xr_string SSS = p1; + Tools->ShowProperties(SSS.c_str()); + } + else + Tools->ShowProperties(NULL); + return TRUE; } -CCommandVar CommandUpdateProperties(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandUpdateProperties(CCommandVar p1, CCommandVar p2) { Tools->UpdateProperties(p1); - return TRUE; + return TRUE; } -CCommandVar CommandRefreshProperties(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandRefreshProperties(CCommandVar p1, CCommandVar p2) { Tools->RefreshProperties(); - return TRUE; + return TRUE; } -CCommandVar CommandZoomExtents(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandZoomExtents(CCommandVar p1, CCommandVar p2) { - Tools->ZoomObject (p1); - UI->RedrawScene (); - return TRUE; + Tools->ZoomObject(p1); + UI->RedrawScene(); + return TRUE; } -CCommandVar CommandToggleRenderWire(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandToggleRenderWire(CCommandVar p1, CCommandVar p2) { - if (EDevice.dwFillMode!=D3DFILL_WIREFRAME) EDevice.dwFillMode = D3DFILL_WIREFRAME; - else EDevice.dwFillMode = D3DFILL_SOLID; - UI->RedrawScene (); - return TRUE; + if (EDevice.dwFillMode!=D3DFILL_WIREFRAME) + EDevice.dwFillMode = D3DFILL_WIREFRAME; + else + EDevice.dwFillMode = D3DFILL_SOLID; + UI->RedrawScene(); + return TRUE; } -CCommandVar CommandToggleSafeRect(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandToggleSafeRect(CCommandVar p1, CCommandVar p2) { - psDeviceFlags.set (rsDrawSafeRect,!psDeviceFlags.is(rsDrawSafeRect)); - ExecCommand (COMMAND_RENDER_RESIZE); - UI->RedrawScene (); - return TRUE; + psDeviceFlags.set(rsDrawSafeRect, !psDeviceFlags.is(rsDrawSafeRect)); + ExecCommand(COMMAND_RENDER_RESIZE); + UI->RedrawScene(); + return TRUE; } -CCommandVar CommandToggleGrid(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandToggleGrid(CCommandVar p1, CCommandVar p2) { - psDeviceFlags.set(rsDrawGrid,!psDeviceFlags.is(rsDrawGrid)); - UI->RedrawScene (); - return TRUE; + psDeviceFlags.set(rsDrawGrid, !psDeviceFlags.is(rsDrawGrid)); + UI->RedrawScene(); + return TRUE; } -CCommandVar CommandUpdateGrid(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandUpdateGrid(CCommandVar p1, CCommandVar p2) { - DU_impl.UpdateGrid (EPrefs->grid_cell_count,EPrefs->grid_cell_size); - UI->OutGridSize (); - UI->RedrawScene (); - return TRUE; + DU_impl.UpdateGrid(EPrefs->grid_cell_count, EPrefs->grid_cell_size); + UI->OutGridSize(); + UI->RedrawScene(); + return TRUE; } -CCommandVar CommandGridNumberOfSlots(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandGridNumberOfSlots(CCommandVar p1, CCommandVar p2) { - if (p1) EPrefs->grid_cell_count += 2; - else EPrefs->grid_cell_count -= 2; - ExecCommand (COMMAND_UPDATE_GRID); - UI->RedrawScene (); - return TRUE; + if (p1) + EPrefs->grid_cell_count += 2; + else + EPrefs->grid_cell_count -= 2; + ExecCommand(COMMAND_UPDATE_GRID); + UI->RedrawScene(); + return TRUE; } -CCommandVar CommandGridSlotSize(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandGridSlotSize(CCommandVar p1, CCommandVar p2) { float step = 1.f; float val = EPrefs->grid_cell_size; - if (p1){ - if (val<1) step/=10.f; + if (p1) + { + if (val<1) + step /= 10.f; EPrefs->grid_cell_size += step; - }else{ - if (fsimilar(val,1.f)||(val<1)) step/=10.f; + } + else + { + if (fsimilar(val, 1.f)||(val<1)) + step /= 10.f; EPrefs->grid_cell_size -= step; } - ExecCommand (COMMAND_UPDATE_GRID); - UI->RedrawScene (); - return TRUE; + ExecCommand(COMMAND_UPDATE_GRID); + UI->RedrawScene(); + return TRUE; } -CCommandVar CommandCreateSoundLib(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandCreateSoundLib(CCommandVar p1, CCommandVar p2) { - SndLib = xr_new(); - return TRUE; + SndLib = xr_new(); + return TRUE; } -CCommandVar CommandMuteSound(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandMuteSound(CCommandVar p1, CCommandVar p2) { - SndLib->MuteSounds (p1); - return TRUE; + SndLib->MuteSounds(p1); + return TRUE; } + CCommandVar CommandMoveCameraTo(CCommandVar p1, CCommandVar p2) { - Fvector pos = EDevice.m_Camera.GetPosition(); - if (NumericVectorRun ("Move to",&pos,3)) - EDevice.m_Camera.Set (EDevice.m_Camera.GetHPB(),pos); - return TRUE; -} - -CCommandVar ExecuteCommandList(LPCSTR text) -{ - CCommandVar res = TRUE; - IReader F ((void*)text,xr_strlen(text)); - while (!F.eof()){ - xr_string line, cmd, params, sp1, sp2; - F.r_string (line); - line = _Trim(line); - if (!line.empty()){ - if (line[0]==';' || (line[0]=='/'&&line[1]=='/')) continue; - _GetItem (line.c_str(),0,cmd,'('); - _GetItem (line.c_str(),1,params,'('); - _GetItem (params.c_str(),0,params,')'); - _GetItem (params.c_str(),0,sp1,','); - _GetItem (params.c_str(),1,sp2,','); + Fvector pos = EDevice.m_Camera.GetPosition(); + if (NumericVectorRun("Move to", &pos, 3)) + EDevice.m_Camera.Set(EDevice.m_Camera.GetHPB(), pos); + return TRUE; +} + +CCommandVar ExecuteCommandList(LPCSTR text) +{ + CCommandVar res = TRUE; + IReader F((void*)text, xr_strlen(text)); + while (!F.eof()) + { + xr_string line, cmd, params, sp1, sp2; + F.r_string(line); + line = _Trim(line); + if (!line.empty()) + { + if (line[0]==';'||(line[0]=='/'&&line[1]=='/')) + continue; + _GetItem(line.c_str(), 0, cmd, '('); + _GetItem(line.c_str(), 1, params, '('); + _GetItem(params.c_str(), 0, params, ')'); + _GetItem(params.c_str(), 0, sp1, ','); + _GetItem(params.c_str(), 1, sp2, ','); // parse cmd - xr_string cmd_name, sub_cmd_name; - _GetItem (cmd.c_str(),0,cmd_name,'.'); - _GetItem (cmd.c_str(),1,sub_cmd_name,'.'); - - SECommand* CMD = FindCommandByName(cmd_name.c_str()); - if (CMD){ - SESubCommand* SUB= FindSubCommandByName(CMD,sub_cmd_name.c_str()); - if (!sub_cmd_name.empty()&&!SUB){ - ELog.DlgMsg (mtError,"Can't find sub-command: '%s'",sub_cmd_name.c_str()); - res = FALSE; + xr_string cmd_name, sub_cmd_name; + _GetItem(cmd.c_str(), 0, cmd_name, '.'); + _GetItem(cmd.c_str(), 1, sub_cmd_name, '.'); + + SECommand*CMD = FindCommandByName(cmd_name.c_str()); + if (CMD) + { + SESubCommand*SUB = FindSubCommandByName(CMD, sub_cmd_name.c_str()); + if (!sub_cmd_name.empty()&&!SUB) + { + ELog.DlgMsg(mtError, "Can't find sub-command: '%s'", sub_cmd_name.c_str()); + res = FALSE; break; } // parse params - CCommandVar p1,p2; - if (SUB){ - p1 = SUB->p0; - p2 = SUB->p1; + CCommandVar p1, p2; + if (SUB) + { + p1 = SUB->p0; + p2 = SUB->p1; } - ParseParam (sp1,p1); - ParseParam (sp2,p2); + ParseParam(sp1, p1); + ParseParam(sp2, p2); // execute command - if (FALSE==ExecCommand(CMD->idx,p1,p2)){ - ELog.DlgMsg (mtError,"Can't execute command: '%s'",cmd.c_str()); - res = FALSE; + if (FALSE==ExecCommand(CMD->idx, p1, p2)) + { + ELog.DlgMsg(mtError, "Can't execute command: '%s'", cmd.c_str()); + res = FALSE; break; } - }else{ - ELog.DlgMsg (mtError,"Can't find command: '%s'",cmd.c_str()); - res = FALSE; + } + else + { + ELog.DlgMsg(mtError, "Can't find command: '%s'", cmd.c_str()); + res = FALSE; break; } } } - return res; + return res; } -bool OnRunExecuteListClick(LPCSTR txt) +bool OnRunExecuteListClick(LPCSTR txt) { - ExecuteCommandList (txt); + ExecuteCommandList(txt); return true; } -CCommandVar CommandExecuteCommandList(CCommandVar _p1, CCommandVar _p2) +CCommandVar CommandExecuteCommandList(CCommandVar _p1, CCommandVar _p2) { - xr_string cmds_text = _p1; - return ExecuteCommandList (cmds_text.c_str()); + xr_string cmds_text = _p1; + return ExecuteCommandList(cmds_text.c_str()); } bool __stdcall OnCloseCommandListEditor() { - frmEditCommandList = 0; - return true; + frmEditCommandList = 0; + return true; } -CCommandVar CommandEditCommandList(CCommandVar _p1, CCommandVar _p2) +CCommandVar CommandEditCommandList(CCommandVar _p1, CCommandVar _p2) { - if (NULL==frmEditCommandList){ - frmEditCommandList = TfrmText::CreateForm(sCommandListText,"Execute command list",0,0,"Run",OnRunExecuteListClick,OnCloseCommandListEditor); + if (NULL==frmEditCommandList) + { + frmEditCommandList = TfrmText::CreateForm(sCommandListText, "Execute command list", 0, 0, "Run", OnRunExecuteListClick, OnCloseCommandListEditor); return TRUE; } return FALSE; } -CCommandVar CommandLogCommands(CCommandVar _p1, CCommandVar _p2) +CCommandVar CommandLogCommands(CCommandVar _p1, CCommandVar _p2) { - bAllowLogCommands = _p1; - return TRUE; + bAllowLogCommands = _p1; + return TRUE; } -CCommandVar CommandRunMacro(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandRunMacro(CCommandVar p1, CCommandVar p2) { - xr_string fn; - if (p1.IsString()){ - fn = xr_string(p1); - IReader* F = FS.r_open(fn.c_str()); - if (NULL==F) F = FS.r_open(_import_,fn.c_str()); - if (F){ - ExecCommand (COMMAND_EXECUTE_COMMAND_LIST,xr_string((LPCSTR)F->pointer())); - FS.r_close (F); - return TRUE; + xr_string fn; + if (p1.IsString()) + { + fn = xr_string(p1); + IReader *F = FS.r_open(fn.c_str()); + if (NULL==F) + F = FS.r_open(_import_, fn.c_str()); + if (F) + { + ExecCommand(COMMAND_EXECUTE_COMMAND_LIST, xr_string((LPCSTR)F->pointer())); + FS.r_close(F); + return TRUE; } - }else{ - SECommand* CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; VERIFY(CMD); - u32 num = p1; VERIFY(numsub_commands.size()); - SESubCommand* SUB=CMD->sub_commands[num]; - fn = xr_string(SUB->p0); - return ExecCommand(COMMAND_RUN_MACRO,fn,p2); } - return FALSE; + else + { + SECommand*CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; + VERIFY(CMD); + u32 num = p1; + VERIFY(numsub_commands.size()); + SESubCommand*SUB = CMD->sub_commands[num]; + fn = xr_string(SUB->p0); + return ExecCommand(COMMAND_RUN_MACRO, fn, p2); + } + return FALSE; } -CCommandVar CommandAssignMacro(CCommandVar p1, CCommandVar p2) + +CCommandVar CommandAssignMacro(CCommandVar p1, CCommandVar p2) { - xr_string fn = p2.IsString()?xr_string(p2):xr_string(""); - if (p2.IsString()){ + xr_string fn = p2.IsString() ? xr_string(p2) : xr_string(""); + if (p2.IsString()) + { if (0==fn.find(FS.get_path(_import_)->m_Path)) - fn = xr_string(fn.c_str()+xr_strlen(FS.get_path(_import_)->m_Path)); - ECommands[COMMAND_RUN_MACRO]->sub_commands[p1]->p0 = fn; - return TRUE; - }else{ - if (EFS.GetOpenName(_import_,fn,false,NULL,2)) - return ExecCommand (COMMAND_ASSIGN_MACRO,p1,fn); + fn = xr_string(fn.c_str()+xr_strlen(FS.get_path(_import_)->m_Path)); + ECommands[COMMAND_RUN_MACRO]->sub_commands[p1]->p0 = fn; + return TRUE; + } + else + { + if (EFS.GetOpenName(_import_, fn, false, NULL, 2)) + return ExecCommand(COMMAND_ASSIGN_MACRO, p1, fn); } return FALSE; } void TUI::RegisterCommands() { - REGISTER_CMD_S (COMMAND_INITIALIZE, CommandInitialize); - REGISTER_CMD_S (COMMAND_DESTROY, CommandDestroy); - REGISTER_CMD_SE (COMMAND_EXIT, "Exit", CommandExit, true); - REGISTER_CMD_S (COMMAND_QUIT, CommandQuit); - REGISTER_CMD_SE (COMMAND_EDITOR_PREF, "Editor Preference", CommandEditorPrefs, false); - - - REGISTER_CMD_SE (COMMAND_SIMULATE, "Simulate", CommandSimulate, true); - REGISTER_CMD_SE (COMMAND_USE_SIMULATE_POSITIONS,"Use Simulate Positions",CommandUseSimulatePositions, true); - - REGISTER_SUB_CMD_SE (COMMAND_CHANGE_ACTION, "Change Action", CommandChangeAction,false); - APPEND_SUB_CMD ("Select", etaSelect, 0); - APPEND_SUB_CMD ("Add", etaAdd, 0); - APPEND_SUB_CMD ("Move", etaMove, 0); - APPEND_SUB_CMD ("Rotate", etaRotate, 0); - APPEND_SUB_CMD ("Scale", etaScale, 0); - REGISTER_SUB_CMD_END; - REGISTER_SUB_CMD_SE (COMMAND_CHANGE_AXIS, "Change Axis", CommandChangeAxis, false); - APPEND_SUB_CMD ("X", etAxisX, 0); - APPEND_SUB_CMD ("Y", etAxisY, 0); - APPEND_SUB_CMD ("Z", etAxisZ, 0); - APPEND_SUB_CMD ("ZX", etAxisZX, 0); - REGISTER_SUB_CMD_END; - REGISTER_CMD_S (COMMAND_SET_SETTINGS, CommandSetSettings); - REGISTER_CMD_S (COMMAND_SOUND_EDITOR, CommandSoundEditor); - REGISTER_CMD_S (COMMAND_SYNC_SOUNDS, CommandSyncSounds); - REGISTER_CMD_S (COMMAND_IMAGE_EDITOR, CommandImageEditor); REGISTER_CMD_S (COMMAND_MINIMAP_EDITOR, CommandMinimapEditor); - REGISTER_CMD_S (COMMAND_CHECK_TEXTURES, CommandCheckTextures); - REGISTER_CMD_S (COMMAND_REFRESH_TEXTURES, CommandRefreshTextures); - REGISTER_CMD_S (COMMAND_RELOAD_TEXTURES, CommandReloadTextures); - REGISTER_CMD_S (COMMAND_CHANGE_SNAP, CommandChangeSnap); - REGISTER_CMD_S (COMMAND_UNLOAD_TEXTURES, CommandUnloadTextures); - REGISTER_CMD_S (COMMAND_EVICT_OBJECTS, CommandEvictObjects); - REGISTER_CMD_S (COMMAND_EVICT_TEXTURES, CommandEvictTextures); - REGISTER_CMD_S (COMMAND_CHECK_MODIFIED, CommandCheckModified); - REGISTER_CMD_SE (COMMAND_SHOW_PROPERTIES, "Show Properties", CommandShowProperties, false); - REGISTER_CMD_S (COMMAND_UPDATE_PROPERTIES, CommandUpdateProperties); - REGISTER_CMD_S (COMMAND_REFRESH_PROPERTIES, CommandRefreshProperties); - REGISTER_SUB_CMD_SE (COMMAND_ZOOM_EXTENTS, "Zoom", CommandZoomExtents,false); - APPEND_SUB_CMD ("Extent", 0,0); - APPEND_SUB_CMD ("Selected", 1,0); - REGISTER_SUB_CMD_END; - REGISTER_CMD_SE (COMMAND_MOVE_CAMERA_TO, "Scene\\Move Camera To",CommandMoveCameraTo,false); - REGISTER_CMD_SE (COMMAND_TOGGLE_RENDER_WIRE, "Toggle Wireframe", CommandToggleRenderWire, false); - REGISTER_CMD_C (COMMAND_RENDER_FOCUS, this,TUI::CommandRenderFocus); - REGISTER_CMD_CE (COMMAND_BREAK_LAST_OPERATION, "Break Last Operation", this,TUI::CommandBreakLastOperation,false); - REGISTER_CMD_SE (COMMAND_TOGGLE_SAFE_RECT, "Toggle Safe Rect", CommandToggleSafeRect,false); - REGISTER_CMD_C (COMMAND_RENDER_RESIZE, this,TUI::CommandRenderResize); - REGISTER_CMD_SE (COMMAND_TOGGLE_GRID, "Toggle Grid", CommandToggleGrid,false); - REGISTER_CMD_S (COMMAND_UPDATE_GRID, CommandUpdateGrid); - REGISTER_CMD_S (COMMAND_GRID_NUMBER_OF_SLOTS, CommandGridNumberOfSlots); - REGISTER_SUB_CMD_SE (COMMAND_GRID_SLOT_SIZE, "Change Grid Size", CommandGridSlotSize,false); - APPEND_SUB_CMD ("Decrease", 0,0); - APPEND_SUB_CMD ("Increase", 1,0); - REGISTER_SUB_CMD_END; - REGISTER_CMD_S (COMMAND_CREATE_SOUND_LIB, CommandCreateSoundLib); - REGISTER_CMD_S (COMMAND_MUTE_SOUND, CommandMuteSound); - REGISTER_CMD_S (COMMAND_EDIT_COMMAND_LIST, CommandEditCommandList); - REGISTER_CMD_S (COMMAND_EXECUTE_COMMAND_LIST, CommandExecuteCommandList); - REGISTER_CMD_S (COMMAND_LOG_COMMANDS, CommandLogCommands); - REGISTER_SUB_CMD_SE (COMMAND_RUN_MACRO, "Run Macro", CommandRunMacro,false); - APPEND_SUB_CMD ("Slot #1", xr_string(""),0); - APPEND_SUB_CMD ("Slot #2", xr_string(""),0); - APPEND_SUB_CMD ("Slot #3", xr_string(""),0); - APPEND_SUB_CMD ("Slot #4", xr_string(""),0); - APPEND_SUB_CMD ("Slot #5", xr_string(""),0); - APPEND_SUB_CMD ("Slot #6", xr_string(""),0); - APPEND_SUB_CMD ("Slot #7", xr_string(""),0); - APPEND_SUB_CMD ("Slot #8", xr_string(""),0); - REGISTER_SUB_CMD_END; - REGISTER_CMD_S (COMMAND_ASSIGN_MACRO, CommandAssignMacro); -} + REGISTER_CMD_S (COMMAND_INITIALIZE, CommandInitialize); + REGISTER_CMD_S (COMMAND_DESTROY, CommandDestroy); + REGISTER_CMD_SE (COMMAND_EXIT, "Exit", CommandExit, true); + REGISTER_CMD_S (COMMAND_QUIT, CommandQuit); + REGISTER_CMD_SE (COMMAND_EDITOR_PREF, "Editor Preference", CommandEditorPrefs, false); + + + REGISTER_CMD_SE (COMMAND_SIMULATE, "Simulate", CommandSimulate, true); + REGISTER_CMD_SE (COMMAND_USE_SIMULATE_POSITIONS,"Use Simulate Positions",CommandUseSimulatePositions, true); + + REGISTER_SUB_CMD_SE (COMMAND_CHANGE_ACTION, "Change Action", CommandChangeAction,false); + APPEND_SUB_CMD ("Select", etaSelect, 0); + APPEND_SUB_CMD ("Add", etaAdd, 0); + APPEND_SUB_CMD ("Move", etaMove, 0); + APPEND_SUB_CMD ("Rotate", etaRotate, 0); + APPEND_SUB_CMD ("Scale", etaScale, 0); + REGISTER_SUB_CMD_END; + REGISTER_SUB_CMD_SE (COMMAND_CHANGE_AXIS, "Change Axis", CommandChangeAxis, false); + APPEND_SUB_CMD ("X", etAxisX, 0); + APPEND_SUB_CMD ("Y", etAxisY, 0); + APPEND_SUB_CMD ("Z", etAxisZ, 0); + APPEND_SUB_CMD ("ZX", etAxisZX, 0); + REGISTER_SUB_CMD_END; + REGISTER_CMD_S (COMMAND_SET_SETTINGS, CommandSetSettings); + REGISTER_CMD_S (COMMAND_SOUND_EDITOR, CommandSoundEditor); + REGISTER_CMD_S (COMMAND_SYNC_SOUNDS, CommandSyncSounds); + REGISTER_CMD_S (COMMAND_IMAGE_EDITOR, CommandImageEditor); + REGISTER_CMD_S (COMMAND_MINIMAP_EDITOR, CommandMinimapEditor); + REGISTER_CMD_S (COMMAND_CHECK_TEXTURES, CommandCheckTextures); + REGISTER_CMD_S (COMMAND_REFRESH_TEXTURES, CommandRefreshTextures); + REGISTER_CMD_S (COMMAND_RELOAD_TEXTURES, CommandReloadTextures); + REGISTER_CMD_S (COMMAND_CHANGE_SNAP, CommandChangeSnap); + REGISTER_CMD_S (COMMAND_UNLOAD_TEXTURES, CommandUnloadTextures); + REGISTER_CMD_S (COMMAND_EVICT_OBJECTS, CommandEvictObjects); + REGISTER_CMD_S (COMMAND_EVICT_TEXTURES, CommandEvictTextures); + REGISTER_CMD_S (COMMAND_CHECK_MODIFIED, CommandCheckModified); + REGISTER_CMD_SE (COMMAND_SHOW_PROPERTIES, "Show Properties", CommandShowProperties, false); + REGISTER_CMD_S (COMMAND_UPDATE_PROPERTIES, CommandUpdateProperties); + REGISTER_CMD_S (COMMAND_REFRESH_PROPERTIES, CommandRefreshProperties); + REGISTER_SUB_CMD_SE (COMMAND_ZOOM_EXTENTS, "Zoom", CommandZoomExtents,false); + APPEND_SUB_CMD ("Extent", 0,0); + APPEND_SUB_CMD ("Selected", 1,0); + REGISTER_SUB_CMD_END; + REGISTER_CMD_SE (COMMAND_MOVE_CAMERA_TO, "Scene\\Move Camera To",CommandMoveCameraTo,false); + REGISTER_CMD_SE (COMMAND_TOGGLE_RENDER_WIRE, "Toggle Wireframe", CommandToggleRenderWire, false); + REGISTER_CMD_C (COMMAND_RENDER_FOCUS, this,TUI::CommandRenderFocus); + REGISTER_CMD_CE (COMMAND_BREAK_LAST_OPERATION, "Break Last Operation", this,TUI::CommandBreakLastOperation,false); + REGISTER_CMD_SE (COMMAND_TOGGLE_SAFE_RECT, "Toggle Safe Rect", CommandToggleSafeRect,false); + REGISTER_CMD_C (COMMAND_RENDER_RESIZE, this,TUI::CommandRenderResize); + REGISTER_CMD_SE (COMMAND_TOGGLE_GRID, "Toggle Grid", CommandToggleGrid,false); + REGISTER_CMD_S (COMMAND_UPDATE_GRID, CommandUpdateGrid); + REGISTER_CMD_S (COMMAND_GRID_NUMBER_OF_SLOTS, CommandGridNumberOfSlots); + REGISTER_SUB_CMD_SE (COMMAND_GRID_SLOT_SIZE, "Change Grid Size", CommandGridSlotSize,false); + APPEND_SUB_CMD ("Decrease", 0,0); + APPEND_SUB_CMD ("Increase", 1,0); + REGISTER_SUB_CMD_END; + REGISTER_CMD_S (COMMAND_CREATE_SOUND_LIB, CommandCreateSoundLib); + REGISTER_CMD_S (COMMAND_MUTE_SOUND, CommandMuteSound); + REGISTER_CMD_S (COMMAND_EDIT_COMMAND_LIST, CommandEditCommandList); + REGISTER_CMD_S (COMMAND_EXECUTE_COMMAND_LIST, CommandExecuteCommandList); + REGISTER_CMD_S (COMMAND_LOG_COMMANDS, CommandLogCommands); + REGISTER_SUB_CMD_SE (COMMAND_RUN_MACRO, "Run Macro", CommandRunMacro,false); + APPEND_SUB_CMD ("Slot #1", xr_string(""),0); + APPEND_SUB_CMD ("Slot #2", xr_string(""),0); + APPEND_SUB_CMD ("Slot #3", xr_string(""),0); + APPEND_SUB_CMD ("Slot #4", xr_string(""),0); + APPEND_SUB_CMD ("Slot #5", xr_string(""),0); + APPEND_SUB_CMD ("Slot #6", xr_string(""),0); + APPEND_SUB_CMD ("Slot #7", xr_string(""),0); + APPEND_SUB_CMD ("Slot #8", xr_string(""),0); + REGISTER_SUB_CMD_END; + REGISTER_CMD_S (COMMAND_ASSIGN_MACRO, CommandAssignMacro); +} //--------------------------------------------------------------------------- bool TUI::ApplyShortCut(WORD Key, TShiftState Shift) { - VERIFY(m_bReady); + VERIFY(m_bReady); - if (ApplyGlobalShortCut(Key,Shift)) return true; + if (ApplyGlobalShortCut(Key, Shift)) + return true; - if (Key==VK_ESCAPE){ ExecCommand (COMMAND_CHANGE_ACTION, etaSelect); return true;} + if (Key==VK_ESCAPE) + { + ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); + return true; + } - xr_shortcut SC; - SC.key = Key; - SC.ext.assign (u8((Shift.Contains(ssShift)?xr_shortcut::flShift:0)| - (Shift.Contains(ssCtrl) ?xr_shortcut::flCtrl:0)| - (Shift.Contains(ssAlt) ?xr_shortcut::flAlt:0))); - SESubCommand* SUB = FindCommandByShortcut(SC); + xr_shortcut SC; + SC.key = Key; + SC.ext.assign(u8((Shift.Contains(ssShift) ? xr_shortcut::flShift : 0)| + (Shift.Contains(ssCtrl) ? xr_shortcut::flCtrl : 0)| + (Shift.Contains(ssAlt) ? xr_shortcut::flAlt : 0))); + SESubCommand*SUB = FindCommandByShortcut(SC); - if (!SUB||SUB->parent->global_shortcut) return false; + if (!SUB||SUB->parent->global_shortcut) + return false; - return ExecCommand(SC); + return ExecCommand(SC); } + //--------------------------------------------------------------------------- bool TUI::ApplyGlobalShortCut(WORD Key, TShiftState Shift) { - VERIFY(m_bReady); + VERIFY(m_bReady); - if (Key==VK_OEM_3){ ExecCommand (COMMAND_RENDER_FOCUS); return true;} + if (Key==VK_OEM_3) + { + ExecCommand(COMMAND_RENDER_FOCUS); + return true; + } - xr_shortcut SC; - SC.key = Key; - SC.ext.assign (u8((Shift.Contains(ssShift)?xr_shortcut::flShift:0)| - (Shift.Contains(ssCtrl) ?xr_shortcut::flCtrl:0)| - (Shift.Contains(ssAlt) ?xr_shortcut::flAlt:0))); - SESubCommand* SUB = FindCommandByShortcut(SC); + xr_shortcut SC; + SC.key = Key; + SC.ext.assign(u8((Shift.Contains(ssShift) ? xr_shortcut::flShift : 0)| + (Shift.Contains(ssCtrl) ? xr_shortcut::flCtrl : 0)| + (Shift.Contains(ssAlt) ? xr_shortcut::flAlt : 0))); + SESubCommand*SUB = FindCommandByShortcut(SC); - if (!SUB||!SUB->parent->global_shortcut) return false; + if (!SUB||!SUB->parent->global_shortcut) + return false; - return ExecCommand(SUB->parent->idx,SUB->p0,SUB->p1); + return ExecCommand(SUB->parent->idx, SUB->p0, SUB->p1); } + //--------------------------------------------------------------------------- diff --git a/src/editors/ECore/Editor/UI_MainCommand.h b/src/editors/ECore/Editor/UI_MainCommand.h index 520d7817c13..0b9e3e2e036 100644 --- a/src/editors/ECore/Editor/UI_MainCommand.h +++ b/src/editors/ECore/Editor/UI_MainCommand.h @@ -1,42 +1,43 @@ #ifndef UI_MainCommandH #define UI_MainCommandH -enum{ - COMMAND_INITIALIZE=0, // p1 - D3DWindow, p2 - TPanel - COMMAND_DESTROY, - COMMAND_QUIT, - COMMAND_EDITOR_PREF, - COMMAND_CHANGE_ACTION, +enum +{ + COMMAND_INITIALIZE=0, // p1 - D3DWindow, p2 - TPanel + COMMAND_DESTROY, + COMMAND_QUIT, + COMMAND_EDITOR_PREF, + COMMAND_CHANGE_ACTION, COMMAND_IMAGE_EDITOR, COMMAND_MINIMAP_EDITOR, - COMMAND_CHECK_TEXTURES, - COMMAND_REFRESH_TEXTURES, - COMMAND_RELOAD_TEXTURES, - COMMAND_CHANGE_AXIS, - COMMAND_CHANGE_SNAP, + COMMAND_CHECK_TEXTURES, + COMMAND_REFRESH_TEXTURES, + COMMAND_RELOAD_TEXTURES, + COMMAND_CHANGE_AXIS, + COMMAND_CHANGE_SNAP, COMMAND_SET_SETTINGS, COMMAND_UNLOAD_TEXTURES, COMMAND_EVICT_OBJECTS, COMMAND_EVICT_TEXTURES, COMMAND_CHECK_MODIFIED, - COMMAND_EXIT, - COMMAND_SHOW_PROPERTIES, - COMMAND_UPDATE_PROPERTIES, // p1 - forced update if needed + COMMAND_EXIT, + COMMAND_SHOW_PROPERTIES, + COMMAND_UPDATE_PROPERTIES, // p1 - forced update if needed COMMAND_REFRESH_PROPERTIES, COMMAND_MOVE_CAMERA_TO, - COMMAND_ZOOM_EXTENTS, + COMMAND_ZOOM_EXTENTS, COMMAND_RENDER_FOCUS, - COMMAND_RENDER_RESIZE, + COMMAND_RENDER_RESIZE, COMMAND_TOGGLE_RENDER_WIRE, COMMAND_UPDATE_CAPTION, - COMMAND_BREAK_LAST_OPERATION, - COMMAND_UPDATE_TOOLBAR, + COMMAND_BREAK_LAST_OPERATION, + COMMAND_UPDATE_TOOLBAR, COMMAND_TOGGLE_SAFE_RECT, COMMAND_TOGGLE_GRID, - COMMAND_UPDATE_GRID, + COMMAND_UPDATE_GRID, COMMAND_GRID_NUMBER_OF_SLOTS, COMMAND_GRID_SLOT_SIZE, - + COMMAND_REFRESH_UI_BAR, COMMAND_RESTORE_UI_BAR, COMMAND_SAVE_UI_BAR, @@ -50,93 +51,131 @@ enum{ COMMAND_SAVE_BACKUP, COMMAND_CREATE_SOUND_LIB, - COMMAND_TOGGLE_AIMAP_VISIBILITY, - + COMMAND_TOGGLE_AIMAP_VISIBILITY, + // sound - COMMAND_SOUND_EDITOR, - COMMAND_SYNC_SOUNDS, - - COMMAND_UNDO, - COMMAND_REDO, - + COMMAND_SOUND_EDITOR, + COMMAND_SYNC_SOUNDS, + + COMMAND_UNDO, + COMMAND_REDO, + COMMAND_EDIT_COMMAND_LIST, COMMAND_EXECUTE_COMMAND_LIST, COMMAND_LOG_COMMANDS, - COMMAND_RUN_MACRO, // p1 - file name - COMMAND_ASSIGN_MACRO, // p1 - slot, p2 - file_name + COMMAND_RUN_MACRO, // p1 - file name + COMMAND_ASSIGN_MACRO, // p1 - slot, p2 - file_name COMMAND_SIMULATE, COMMAND_USE_SIMULATE_POSITIONS, COMMAND_MAIN_LAST }; + //------------------------------------------------------------------------------ -class CCommandVar{ - enum EType{ +class CCommandVar +{ + enum EType + { tpStr, tpInt }; - u32 i; - xr_string s; - EType type; + + u32 i; + xr_string s; + EType type; public: - CCommandVar ():i(0),type(tpInt) {} - CCommandVar (xr_string str) :type(tpStr){s=str;} - CCommandVar (u32 val) :type(tpInt){i=val;} - IC operator u32 () {VERIFY(type==tpInt);return i;} - IC operator xr_string () {VERIFY(type==tpStr);return s;} - IC bool IsString () {return type==tpStr;} - IC bool IsInteger () {return type==tpInt;} -// IC operator LPCSTR () {VERIFY(type==tpStr);return s.c_str();} + CCommandVar(): i(0), type(tpInt) {} + + CCommandVar(xr_string str) : type(tpStr) + { + s = str; + } + + CCommandVar(u32 val) : type(tpInt) + { + i = val; + } + + IC operator u32() + { + VERIFY(type==tpInt); + return i; + } + + IC operator xr_string() + { + VERIFY(type==tpStr); + return s; + } + + IC + + bool IsString() + { + return type==tpStr; + } + + IC + + bool IsInteger() + { + return type==tpInt; + } + + // IC operator LPCSTR () {VERIFY(type==tpStr);return s.c_str();} }; -typedef fastdelegate::FastDelegate2 TECommandEvent; +typedef fastdelegate::FastDelegate2 TECommandEvent; class SECommand; struct ECORE_API SESubCommand{ - SECommand* parent; - xr_string desc; - CCommandVar p0; - CCommandVar p1; - xr_shortcut shortcut; -public: - SESubCommand (LPCSTR d, SECommand* p, CCommandVar _p0, CCommandVar _p1){desc=d;parent=p;p0=_p0;p1=_p1;} + SECommand*parent; + xr_string desc; + CCommandVar p0; + CCommandVar p1; + xr_shortcut shortcut; + public: + SESubCommand(LPCSTR d, SECommand*p, CCommandVar _p0, CCommandVar _p1){desc = d;parent = p;p0 = _p0;p1 = _p1;} }; -DEFINE_VECTOR (SESubCommand*,ESubCommandVec,ESubCommandVecIt); +DEFINE_VECTOR(SESubCommand *, ESubCommandVec, ESubCommandVecIt); struct ECORE_API SECommand{ - bool editable; - LPSTR name; - LPSTR desc; - ESubCommandVec sub_commands; - TECommandEvent command; - u32 idx; - bool global_shortcut; -public: - SECommand (LPCSTR n, LPCSTR d, bool edit, bool multi, TECommandEvent cmd, u32 i, bool _gs):editable(edit),command(cmd),idx(i),global_shortcut(_gs) - { - name = xr_strdup(n); - desc = xr_strdup(d); - if (!multi) AppendSubCommand("",u32(0),u32(0)); - } - ~SECommand (){xr_free(name);xr_free(desc); for (ESubCommandVecIt it=sub_commands.begin(); it!=sub_commands.end(); it++) xr_delete(*it);} - IC LPCSTR Name (){return name&&name[0]?name:"";} - IC LPCSTR Desc (){return desc&&desc[0]?desc:"";} - void AppendSubCommand(LPCSTR desc, CCommandVar p0, CCommandVar p1){sub_commands.push_back(xr_new(desc,this,p0,p1));} + bool editable; + LPSTR name; + LPSTR desc; + ESubCommandVec sub_commands; + TECommandEvent command; + u32 idx; + bool global_shortcut; + public: + SECommand(LPCSTR n, LPCSTR d, bool edit, bool multi, TECommandEvent cmd, u32 i, bool _gs):editable(edit),command(cmd),idx(i),global_shortcut(_gs) + { + name = xr_strdup(n); + desc = xr_strdup(d); + if (!multi) AppendSubCommand("", u32(0), u32(0)); + } + ~SECommand(){xr_free(name);xr_free(desc);for (ESubCommandVecIt it = sub_commands.begin(); it!=sub_commands.end(); it++) xr_delete(*it);} + IC LPCSTR Name(){return name&&name[0] ? name : "";} + IC LPCSTR Desc(){return desc&&desc[0] ? desc : "";} + void AppendSubCommand(LPCSTR desc, CCommandVar p0, CCommandVar p1){sub_commands.push_back(xr_new(desc,this,p0,p1));} }; -DEFINE_VECTOR(SECommand*,ECommandVec,ECommandVecIt); - -ECORE_API CCommandVar ExecCommand (u32 cmd, CCommandVar p1=u32(0), CCommandVar p2=u32(0)); -ECORE_API CCommandVar ExecCommand (const xr_shortcut& val); -ECORE_API void RegisterCommand (u32 cmd, SECommand* cmd_impl); -ECORE_API void RegisterSubCommand (SECommand* cmd_impl, LPCSTR desc, CCommandVar p0, CCommandVar p1); -ECORE_API void EnableReceiveCommands (); -ECORE_API ECommandVec& GetEditorCommands (); -ECORE_API SESubCommand* FindCommandByShortcut (const xr_shortcut& val); -ECORE_API BOOL LoadShortcuts (CInifile* ini); -ECORE_API BOOL SaveShortcuts (CInifile* ini); -ECORE_API BOOL AllowLogCommands (); +DEFINE_VECTOR(SECommand *, ECommandVec, ECommandVecIt); + +ECORE_API CCommandVar ExecCommand(u32 cmd, CCommandVar p1 = u32(0), CCommandVar p2 = u32(0)); +ECORE_API CCommandVar ExecCommand(const xr_shortcut &val); +ECORE_API +void RegisterCommand(u32 cmd, SECommand *cmd_impl); +ECORE_API +void RegisterSubCommand(SECommand *cmd_impl, LPCSTR desc, CCommandVar p0, CCommandVar p1); +ECORE_API +void EnableReceiveCommands(); +ECORE_API ECommandVec&GetEditorCommands(); +ECORE_API SESubCommand*FindCommandByShortcut(const xr_shortcut &val); +ECORE_API BOOL LoadShortcuts(CInifile*ini); +ECORE_API BOOL SaveShortcuts(CInifile*ini); +ECORE_API BOOL AllowLogCommands(); #define BIND_CMD_EVENT_S(a) fastdelegate::bind(a) #define BIND_CMD_EVENT_C(a,b) fastdelegate::bind(a,&b) @@ -153,4 +192,3 @@ ECORE_API BOOL AllowLogCommands (); #endif //UI_MainCommandH - diff --git a/src/editors/ECore/Editor/UI_MainMail.cpp b/src/editors/ECore/Editor/UI_MainMail.cpp index 48a34991b5e..69a9e8808e8 100644 --- a/src/editors/ECore/Editor/UI_MainMail.cpp +++ b/src/editors/ECore/Editor/UI_MainMail.cpp @@ -3,111 +3,134 @@ #pragma hdrstop #include "ui_main.h" + //--------------------------------------------------------------------------- bool TUI::CreateMailslot() { - AnsiString slot_name = AnsiString("\\\\.\\mailslot\\")+AnsiString(UI->EditorName()); + AnsiString slot_name = AnsiString("\\\\.\\mailslot\\")+AnsiString(UI->EditorName()); hMailSlot = ::CreateMailslot(slot_name.c_str(), - 0, // no maximum message size - MAILSLOT_WAIT_FOREVER, // no time-out for operations + 0, // no maximum message size + MAILSLOT_WAIT_FOREVER, // no time-out for operations (LPSECURITY_ATTRIBUTES) NULL); // no security attributes - return (hMailSlot != INVALID_HANDLE_VALUE); + return (hMailSlot!=INVALID_HANDLE_VALUE); } + //--------------------------------------------------------------------------- void TUI::CheckMailslot() { DWORD cbMessage, cMessage, cbRead; - BOOL fResult; - LPSTR lpszBuffer; + BOOL fResult; + LPSTR lpszBuffer; cbMessage = cMessage = cbRead = 0; - fResult = GetMailslotInfo(hMailSlot, // mailslot handle - (LPDWORD) NULL, // no maximum message size - &cbMessage, // size of next message - &cMessage, // number of messages - (LPDWORD) NULL); // no read time-out - R_ASSERT2(fResult,"Can't get mailslot info"); - if (cbMessage == MAILSLOT_NO_MESSAGE) return; - while (cMessage != 0) // retrieve all messages - { - // Allocate memory for the message. - lpszBuffer = (LPSTR) GlobalAlloc(GPTR, cbMessage); - lpszBuffer[0] = '\0'; - fResult = ReadFile(hMailSlot, lpszBuffer, cbMessage, &cbRead, (LPOVERLAPPED) NULL); - if (!fResult) { - GlobalFree((HGLOBAL) lpszBuffer); - throw Exception("Can't ReadFile"); - } - OnReceiveMail(lpszBuffer); - GlobalFree((HGLOBAL) lpszBuffer); - fResult = GetMailslotInfo(hMailSlot, // mailslot handle - (LPDWORD) NULL, // no maximum message size - &cbMessage, // size of next message - &cMessage, // number of messages - (LPDWORD) NULL); // no read time-out - R_ASSERT2(fResult,"Can't get mailslot info"); + fResult = GetMailslotInfo(hMailSlot, // mailslot handle + (LPDWORD) NULL, // no maximum message size + &cbMessage, // size of next message + &cMessage, // number of messages + (LPDWORD) NULL); // no read time-out + R_ASSERT2(fResult, "Can't get mailslot info"); + if (cbMessage==MAILSLOT_NO_MESSAGE) + return; + while (cMessage!=0) // retrieve all messages + { + // Allocate memory for the message. + lpszBuffer = (LPSTR) GlobalAlloc(GPTR, cbMessage); + lpszBuffer[0] = '\0'; + fResult = ReadFile(hMailSlot, lpszBuffer, cbMessage, &cbRead, (LPOVERLAPPED) NULL); + if (!fResult) + { + GlobalFree((HGLOBAL) lpszBuffer); + throw Exception("Can't ReadFile"); + } + OnReceiveMail(lpszBuffer); + GlobalFree((HGLOBAL) lpszBuffer); + fResult = GetMailslotInfo(hMailSlot, // mailslot handle + (LPDWORD) NULL, // no maximum message size + &cbMessage, // size of next message + &cMessage, // number of messages + (LPDWORD) NULL); // no read time-out + R_ASSERT2(fResult, "Can't get mailslot info"); } } + //--------------------------------------------------------------------------- void TUI::OnReceiveMail(LPCSTR msg) { - int cnt = _GetItemCount(msg,' '); - if (cnt){ - AnsiString M=AnsiString(msg).LowerCase(); + int cnt = _GetItemCount(msg, ' '); + if (cnt) + { + AnsiString M = AnsiString(msg).LowerCase(); AnsiString p[2]; - _GetItem(msg,0,p[0],' ',"",false); - if (cnt>1) _GetItems(msg,1,cnt,p[1],' '); - if (p[0]=="exit"){ - ELog.DlgMsg(mtInformation,"'%s EDITOR': Critical update!",AnsiString(UI->EditorName()).UpperCase().c_str()); - while (1){ - if (ExecCommand(COMMAND_EXIT)){ - ExecCommand(COMMAND_QUIT); + _GetItem(msg, 0, p[0], ' ', "", false); + if (cnt>1) + _GetItems(msg, 1, cnt, p[1], ' '); + if (p[0]=="exit") + { + ELog.DlgMsg(mtInformation, "'%s EDITOR': Critical update!", AnsiString(UI->EditorName()).UpperCase().c_str()); + while (1) + { + if (ExecCommand(COMMAND_EXIT)) + { + ExecCommand(COMMAND_QUIT); break; } } - }else if (p[0]=="quit"){ - ELog.Msg(mtInformation,"'%s EDITOR': Super critical update!",AnsiString(UI->EditorName()).UpperCase().c_str()); - ExecCommand(COMMAND_SAVE_BACKUP); - ExecCommand(COMMAND_QUIT); - }else if (p[0]=="info"){ - if (cnt>1) ELog.DlgMsg(mtInformation,"'%s EDITOR': %s",AnsiString(UI->EditorName()).UpperCase().c_str(),p[1].c_str()); - }else if (p[0]=="error"){ - if (cnt>1) ELog.DlgMsg(mtError,"'%s EDITOR': %s",AnsiString(UI->EditorName()).UpperCase().c_str(),p[1].c_str()); + } + else if (p[0]=="quit") + { + ELog.Msg(mtInformation, "'%s EDITOR': Super critical update!", AnsiString(UI->EditorName()).UpperCase().c_str()); + ExecCommand(COMMAND_SAVE_BACKUP); + ExecCommand(COMMAND_QUIT); + } + else if (p[0]=="info") + { + if (cnt>1) + ELog.DlgMsg(mtInformation, "'%s EDITOR': %s", AnsiString(UI->EditorName()).UpperCase().c_str(), p[1].c_str()); + } + else if (p[0]=="error") + { + if (cnt>1) + ELog.DlgMsg(mtError, "'%s EDITOR': %s", AnsiString(UI->EditorName()).UpperCase().c_str(), p[1].c_str()); } } } + //--------------------------------------------------------------------------- void TUI::SendMail(LPCSTR name, LPCSTR dest, LPCSTR msg) { - HANDLE hFile; - DWORD cbWritten; - BOOL fResult; - char cName[256]; + HANDLE hFile; + DWORD cbWritten; + BOOL fResult; + char cName[256]; - sprintf(cName,"\\\\%s\\mailslot\\%s",name,dest); - hFile = CreateFile( - cName, - GENERIC_WRITE, - FILE_SHARE_READ, // required to write to a mailslot - (LPSECURITY_ATTRIBUTES) NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - (HANDLE) NULL); - if (hFile == INVALID_HANDLE_VALUE) return; - fResult = WriteFile( - hFile, - msg, - (u32) lstrlen(msg) + 1, - &cbWritten, - (LPOVERLAPPED) NULL); - if (!fResult) return; - fResult = CloseHandle(hFile); - if (!fResult) return; + sprintf(cName, "\\\\%s\\mailslot\\%s", name, dest); + hFile = CreateFile( + cName, + GENERIC_WRITE, + FILE_SHARE_READ, // required to write to a mailslot + (LPSECURITY_ATTRIBUTES) NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + (HANDLE) NULL); + if (hFile==INVALID_HANDLE_VALUE) + return; + fResult = WriteFile( + hFile, + msg, + (u32) lstrlen(msg)+1, + &cbWritten, + (LPOVERLAPPED) NULL); + if (!fResult) + return; + fResult = CloseHandle(hFile); + if (!fResult) + return; } + //--------------------------------------------------------------------------- diff --git a/src/editors/ECore/Editor/UI_ToolsCustom.cpp b/src/editors/ECore/Editor/UI_ToolsCustom.cpp index 83b5119f499..17973cffc11 100644 --- a/src/editors/ECore/Editor/UI_ToolsCustom.cpp +++ b/src/editors/ECore/Editor/UI_ToolsCustom.cpp @@ -8,106 +8,108 @@ #include "EditMesh.h" #include "ChoseForm.h" #include "ui_main.h" -#include "PropertiesList.h" -#include "motion.h" -#include "bone.h" -#include "library.h" -#include "fmesh.h" -#include "folderlib.h" -#include "d3dutils.h" +#include "PropertiesList.h" +#include "xrCore/Animation/Motion.hpp" +#include "xrCore/Animation/Bone.hpp" +#include "Library.h" +#include "xrCore/FMesh.hpp" +#include "editors/xrEProps/FolderLib.h" +#include "D3DUtils.h" //------------------------------------------------------------------------------ -CToolCustom* Tools=0; +CToolCustom *Tools = 0; //------------------------------------------------------------------------------ #define CHECK_SNAP(R,A,C){ R+=A; if(fabsf(R)>=C){ A=snapto(R,C); R=0; }else{A=0;}} CToolCustom::CToolCustom() { - m_bReady = false; - m_Action = etaSelect; - m_Settings.assign (etfNormalAlign|etfGSnap|etfOSnap|etfMTSnap|etfVSnap|etfASnap|etfMSnap); - m_Axis = etAxisZX; - fFogness = 0.9f; - dwFogColor = 0xffffffff; - m_pAxisMoveObject = NULL; - m_axis_xform = Fidentity; + m_bReady = false; + m_Action = etaSelect; + m_Settings.assign(etfNormalAlign|etfGSnap|etfOSnap|etfMTSnap|etfVSnap|etfASnap|etfMSnap); + m_Axis = etAxisZX; + fFogness = 0.9f; + dwFogColor = 0xffffffff; + m_pAxisMoveObject = NULL; + m_axis_xform = Fidentity; } + //--------------------------------------------------------------------------- -CToolCustom::~CToolCustom() -{ -} +CToolCustom::~CToolCustom() {} + //--------------------------------------------------------------------------- bool CToolCustom::OnCreate() { - m_bReady = true; + m_bReady = true; - SetAction (etaSelect); + SetAction(etaSelect); return true; } void CToolCustom::OnDestroy() { - Lib.RemoveEditObject (m_pAxisMoveObject); - VERIFY (m_bReady); - m_bReady = false; + Lib.RemoveEditObject(m_pAxisMoveObject); + VERIFY(m_bReady); + m_bReady = false; } + //--------------------------------------------------------------------------- void CToolCustom::SetAction(ETAction action) { - switch(action) + switch (action) { - case etaSelect: - m_bHiddenMode = false; - break; - case etaAdd: - case etaMove: - case etaRotate: - case etaScale: - m_bHiddenMode = true; - break; + case etaSelect: + m_bHiddenMode = false; + break; + case etaAdd: + case etaMove: + case etaRotate: + case etaScale: + m_bHiddenMode = true; + break; } m_Action = action; - switch(m_Action) + switch (m_Action) { - case etaSelect: - UI->GetD3DWindow()->Cursor = crCross; - break; - case etaAdd: - UI->GetD3DWindow()->Cursor = crArrow; - break; - case etaMove: - if(!EPrefs->tools_show_move_axis) - UI->GetD3DWindow()->Cursor = crSizeAll; - else - UI->GetD3DWindow()->Cursor = crHandPoint; - - break; - case etaRotate: - UI->GetD3DWindow()->Cursor = crSizeWE; - break; - case etaScale: - UI->GetD3DWindow()->Cursor = crVSplit; - break; - default: - UI->GetD3DWindow()->Cursor = crHelp; + case etaSelect: + UI->GetD3DWindow()->Cursor = crCross; + break; + case etaAdd: + UI->GetD3DWindow()->Cursor = crArrow; + break; + case etaMove: + if (!EPrefs->tools_show_move_axis) + UI->GetD3DWindow()->Cursor = crSizeAll; + else + UI->GetD3DWindow()->Cursor = crHandPoint; + + break; + case etaRotate: + UI->GetD3DWindow()->Cursor = crSizeWE; + break; + case etaScale: + UI->GetD3DWindow()->Cursor = crVSplit; + break; + default: + UI->GetD3DWindow()->Cursor = crHelp; } - if(m_Action==etaMove) + if (m_Action==etaMove) { - if(!m_pAxisMoveObject && EPrefs->tools_show_move_axis) + if (!m_pAxisMoveObject&&EPrefs->tools_show_move_axis) { m_pAxisMoveObject = Lib.CreateEditObject("editor\\axis"); m_Axis = etAxisUndefined; - } - }else + } + } + else { - if(m_pAxisMoveObject) - Lib.RemoveEditObject (m_pAxisMoveObject); - } + if (m_pAxisMoveObject) + Lib.RemoveEditObject(m_pAxisMoveObject); + } UI->RedrawScene(); ExecCommand(COMMAND_REFRESH_UI_BAR); } @@ -115,14 +117,14 @@ void CToolCustom::SetAction(ETAction action) void CToolCustom::SetAxis(ETAxis axis) { - m_Axis=axis; + m_Axis = axis; UI->RedrawScene(); ExecCommand(COMMAND_REFRESH_UI_BAR); } void CToolCustom::SetSettings(u32 mask, BOOL val) { - m_Settings.set(mask,val); + m_Settings.set(mask, val); UI->RedrawScene(); ExecCommand(COMMAND_REFRESH_UI_BAR); } @@ -130,238 +132,263 @@ void CToolCustom::SetSettings(u32 mask, BOOL val) bool __fastcall CToolCustom::MouseStart(TShiftState Shift) { - switch(m_Action) + switch (m_Action) { - case etaSelect: break; - case etaAdd: break; - case etaMove: - if (etAxisY==m_Axis){ - m_MoveXVector.set(0,0,0); - m_MoveYVector.set(0,1,0); - }else{ - m_MoveXVector.set( EDevice.m_Camera.GetRight() ); - m_MoveXVector.y = 0; - m_MoveYVector.set( EDevice.m_Camera.GetDirection() ); - m_MoveYVector.y = 0; - m_MoveXVector.normalize_safe(); - m_MoveYVector.normalize_safe(); - } - m_MoveReminder.set(0,0,0); - m_MovedAmount.set(0,0,0); - break; - case etaRotate: - m_RotateCenter.set(0,0,0); - m_RotateVector.set(0,0,0); - if (etAxisX==m_Axis) m_RotateVector.set(1,0,0); - else if (etAxisY==m_Axis) m_RotateVector.set(0,1,0); - else if (etAxisZ==m_Axis) m_RotateVector.set(0,0,1); - m_fRotateSnapValue = 0; - m_RotateAmount = 0; - break; - case etaScale: - m_ScaleAmount.set (0,0,0); - break; + case etaSelect: break; + case etaAdd: break; + case etaMove: + if (etAxisY==m_Axis) + { + m_MoveXVector.set(0, 0, 0); + m_MoveYVector.set(0, 1, 0); + } + else + { + m_MoveXVector.set(EDevice.m_Camera.GetRight()); + m_MoveXVector.y = 0; + m_MoveYVector.set(EDevice.m_Camera.GetDirection()); + m_MoveYVector.y = 0; + m_MoveXVector.normalize_safe(); + m_MoveYVector.normalize_safe(); + } + m_MoveReminder.set(0, 0, 0); + m_MovedAmount.set(0, 0, 0); + break; + case etaRotate: + m_RotateCenter.set(0, 0, 0); + m_RotateVector.set(0, 0, 0); + if (etAxisX==m_Axis) + m_RotateVector.set(1, 0, 0); + else if (etAxisY==m_Axis) + m_RotateVector.set(0, 1, 0); + else if (etAxisZ==m_Axis) + m_RotateVector.set(0, 0, 1); + m_fRotateSnapValue = 0; + m_RotateAmount = 0; + break; + case etaScale: + m_ScaleAmount.set(0, 0, 0); + break; } - if(m_Action==etaMove && m_pAxisMoveObject) + if (m_Action==etaMove&&m_pAxisMoveObject) { - Fmatrix inv_parent; - inv_parent.invert (m_axis_xform); - Fvector start_point, start_dir; - float dist; - SRayPickInfo pinfo; - - start_point = UI->m_CurrentRStart; - start_dir = UI->m_CurrentRDir; - dist = 10000; - m_pAxisMoveObject->RayPick(dist, start_point, start_dir,inv_parent,&pinfo); - if(pinfo.e_mesh) + Fmatrix inv_parent; + inv_parent.invert(m_axis_xform); + Fvector start_point, start_dir; + float dist; + SRayPickInfo pinfo; + + start_point = UI->m_CurrentRStart; + start_dir = UI->m_CurrentRDir; + dist = 10000; + m_pAxisMoveObject->RayPick(dist, start_point, start_dir, inv_parent, &pinfo); + if (pinfo.e_mesh) { - LPCSTR mn = pinfo.e_mesh->Name().c_str(); - if(0==stricmp(mn,"axis_x")) - SetAxis(etAxisX); - else - if(0==stricmp(mn,"axis_y")) - SetAxis(etAxisY); - else - if(0==stricmp(mn,"axis_z")) - SetAxis(etAxisZ); + LPCSTR mn = pinfo.e_mesh->Name().c_str(); + if (0==stricmp(mn, "axis_x")) + SetAxis(etAxisX); + else if (0==stricmp(mn, "axis_y")) + SetAxis(etAxisY); + else if (0==stricmp(mn, "axis_z")) + SetAxis(etAxisZ); + else if (0==stricmp(mn, "center")) + SetAxis(etAxisZX); else - if(0==stricmp(mn,"center")) - SetAxis(etAxisZX); - else - R_ASSERT2(0, "fix axis name"); + R_ASSERT2(0, "fix axis name"); }; } - - return m_bHiddenMode; + + return m_bHiddenMode; } bool __fastcall CToolCustom::MouseEnd(TShiftState Shift) { - switch(m_Action){ - case etaSelect: break; - case etaAdd: break; - case etaMove: - if(EPrefs->tools_show_move_axis) - m_Axis = etAxisUndefined; - break; - case etaRotate: break; - case etaScale: break; + switch (m_Action) + { + case etaSelect: break; + case etaAdd: break; + case etaMove: + if (EPrefs->tools_show_move_axis) + m_Axis = etAxisUndefined; + break; + case etaRotate: break; + case etaScale: break; } - return true; + return true; } void __fastcall CToolCustom::MouseMove(TShiftState Shift) { - switch(m_Action){ - case etaSelect: break; - case etaAdd: break; - case etaMove: - { - m_MovedAmount.mul( m_MoveXVector, UI->m_MouseSM * UI->m_DeltaCpH.x ); - m_MovedAmount.mad( m_MoveYVector, -UI->m_MouseSM * UI->m_DeltaCpH.y ); - - if( m_Settings.is(etfMSnap) ){ - CHECK_SNAP(m_MoveReminder.x,m_MovedAmount.x,m_MoveSnap); - CHECK_SNAP(m_MoveReminder.y,m_MovedAmount.y,m_MoveSnap); - CHECK_SNAP(m_MoveReminder.z,m_MovedAmount.z,m_MoveSnap); + switch (m_Action) + { + case etaSelect: break; + case etaAdd: break; + case etaMove: + { + m_MovedAmount.mul(m_MoveXVector, UI->m_MouseSM*UI->m_DeltaCpH.x); + m_MovedAmount.mad(m_MoveYVector, -UI->m_MouseSM*UI->m_DeltaCpH.y); + + if (m_Settings.is(etfMSnap)) + { + CHECK_SNAP(m_MoveReminder.x,m_MovedAmount.x,m_MoveSnap); + CHECK_SNAP(m_MoveReminder.y,m_MovedAmount.y,m_MoveSnap); + CHECK_SNAP(m_MoveReminder.z,m_MovedAmount.z,m_MoveSnap); + } + + if (!(etAxisX==m_Axis)&&!(etAxisZX==m_Axis)) + m_MovedAmount.x = 0.f; + if (!(etAxisZ==m_Axis)&&!(etAxisZX==m_Axis)) + m_MovedAmount.z = 0.f; + if (!(etAxisY==m_Axis)) + m_MovedAmount.y = 0.f; + } + break; + case etaRotate: + { + m_RotateAmount = -UI->m_DeltaCpH.x*UI->m_MouseSR; + if (m_Settings.is(etfASnap)) + CHECK_SNAP(m_fRotateSnapValue,m_RotateAmount,m_RotateSnapAngle); } + break; + case etaScale: + { + float dy = UI->m_DeltaCpH.x*UI->m_MouseSS; + if (dy>1.f) + dy = 1.f; else if (dy<-1.f) + dy = -1.f; + + m_ScaleAmount.set(dy, dy, dy); - if (!(etAxisX==m_Axis)&&!(etAxisZX==m_Axis)) m_MovedAmount.x = 0.f; - if (!(etAxisZ==m_Axis)&&!(etAxisZX==m_Axis)) m_MovedAmount.z = 0.f; - if (!(etAxisY==m_Axis)) m_MovedAmount.y = 0.f; - - }break; - case etaRotate:{ - m_RotateAmount = -UI->m_DeltaCpH.x * UI->m_MouseSR; - if( m_Settings.is(etfASnap) ) CHECK_SNAP(m_fRotateSnapValue,m_RotateAmount,m_RotateSnapAngle); - }break; - case etaScale:{ - float dy = UI->m_DeltaCpH.x * UI->m_MouseSS; - if (dy>1.f) dy=1.f; else if (dy<-1.f) dy=-1.f; - - m_ScaleAmount.set( dy, dy, dy ); - - if (m_Settings.is(etfNUScale)){ - if (!(etAxisX==m_Axis)&&!(etAxisZX==m_Axis)) m_ScaleAmount.x = 0.f; - if (!(etAxisZ==m_Axis)&&!(etAxisZX==m_Axis)) m_ScaleAmount.z = 0.f; - if (!(etAxisY==m_Axis)) m_ScaleAmount.y = 0.f; + if (m_Settings.is(etfNUScale)) + { + if (!(etAxisX==m_Axis)&&!(etAxisZX==m_Axis)) + m_ScaleAmount.x = 0.f; + if (!(etAxisZ==m_Axis)&&!(etAxisZX==m_Axis)) + m_ScaleAmount.z = 0.f; + if (!(etAxisY==m_Axis)) + m_ScaleAmount.y = 0.f; + } } - }break; + break; } } -void CToolCustom::GetCurrentFog(u32& fog_color, float& s_fog, float& e_fog) +void CToolCustom::GetCurrentFog(u32 &fog_color, float &s_fog, float &e_fog) { - s_fog = psDeviceFlags.is(rsFog)?(1.0f - fFogness)* 0.85f * UI->ZFar():0.99f*UI->ZFar(); - e_fog = psDeviceFlags.is(rsFog)?0.91f * UI->ZFar():UI->ZFar(); - fog_color = dwFogColor; + s_fog = psDeviceFlags.is(rsFog) ? (1.0f-fFogness)*0.85f*UI->ZFar() : 0.99f*UI->ZFar(); + e_fog = psDeviceFlags.is(rsFog) ? 0.91f*UI->ZFar() : UI->ZFar(); + fog_color = dwFogColor; } -void CToolCustom::RenderEnvironment() -{ -} +void CToolCustom::RenderEnvironment() {} void CToolCustom::Clear() { - ClearDebugDraw (); + ClearDebugDraw(); } void CToolCustom::Render() { - // render errors - EDevice.SetShader (EDevice.m_SelectionShader); - RCache.set_xform_world (Fidentity); - EDevice.RenderNearer (0.0003f); - EDevice.SetRS (D3DRS_CULLMODE,D3DCULL_NONE); + // render errors + EDevice.SetShader(EDevice.m_SelectionShader); + RCache.set_xform_world(Fidentity); + EDevice.RenderNearer(0.0003f); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_NONE); AnsiString temp; - int cnt=0; - for (SDebugDraw::PointIt vit=m_DebugDraw.m_Points.begin(); vit!=m_DebugDraw.m_Points.end(); ++vit) + int cnt = 0; + for (SDebugDraw::PointIt vit = m_DebugDraw.m_Points.begin(); vit!=m_DebugDraw.m_Points.end(); ++vit) { LPCSTR s = NULL; if (vit->i) { - temp.sprintf ("P: %d",cnt++); + temp.sprintf("P: %d", cnt++); s = temp.c_str(); } - if(vit->descr.size()) + if (vit->descr.size()) { s = vit->descr.c_str(); } - DU_impl.dbgDrawVert(vit->p[0], vit->c, s?s:""); + DU_impl.dbgDrawVert(vit->p[0], vit->c, s ? s : ""); } - EDevice.SetShader (EDevice.m_SelectionShader); - cnt=0; - for (SDebugDraw::LineIt eit=m_DebugDraw.m_Lines.begin(); eit!=m_DebugDraw.m_Lines.end(); eit++){ - if (eit->i) temp.sprintf ("L: %d",cnt++); - DU_impl.dbgDrawEdge (eit->p[0],eit->p[1], eit->c, eit->i?temp.c_str():""); + EDevice.SetShader(EDevice.m_SelectionShader); + cnt = 0; + for (SDebugDraw::LineIt eit = m_DebugDraw.m_Lines.begin(); eit!=m_DebugDraw.m_Lines.end(); eit++) + { + if (eit->i) + temp.sprintf("L: %d", cnt++); + DU_impl.dbgDrawEdge(eit->p[0], eit->p[1], eit->c, eit->i ? temp.c_str() : ""); } - EDevice.SetShader (EDevice.m_SelectionShader); - cnt=0; - for (SDebugDraw::FaceIt fwit=m_DebugDraw.m_WireFaces.begin(); fwit!=m_DebugDraw.m_WireFaces.end(); fwit++){ - if (fwit->i) temp.sprintf ("F: %d",cnt++); - DU_impl.dbgDrawFace (fwit->p[0],fwit->p[1],fwit->p[2],fwit->c, fwit->i?temp.c_str():""); + EDevice.SetShader(EDevice.m_SelectionShader); + cnt = 0; + for (SDebugDraw::FaceIt fwit = m_DebugDraw.m_WireFaces.begin(); fwit!=m_DebugDraw.m_WireFaces.end(); fwit++) + { + if (fwit->i) + temp.sprintf("F: %d", cnt++); + DU_impl.dbgDrawFace(fwit->p[0], fwit->p[1], fwit->p[2], fwit->c, fwit->i ? temp.c_str() : ""); } - cnt=0; - if (!m_DebugDraw.m_SolidFaces.empty()){ - EDevice.SetShader (EDevice.m_SelectionShader); - DU_impl.DD_DrawFace_begin (FALSE); - for (SDebugDraw::FaceIt fsit=m_DebugDraw.m_SolidFaces.begin(); fsit!=m_DebugDraw.m_SolidFaces.end(); fsit++) - DU_impl.DD_DrawFace_push (fsit->p[0],fsit->p[1],fsit->p[2], fsit->c); - DU_impl.DD_DrawFace_end (); + cnt = 0; + if (!m_DebugDraw.m_SolidFaces.empty()) + { + EDevice.SetShader(EDevice.m_SelectionShader); + DU_impl.DD_DrawFace_begin(FALSE); + for (SDebugDraw::FaceIt fsit = m_DebugDraw.m_SolidFaces.begin(); fsit!=m_DebugDraw.m_SolidFaces.end(); fsit++) + DU_impl.DD_DrawFace_push(fsit->p[0], fsit->p[1], fsit->p[2], fsit->c); + DU_impl.DD_DrawFace_end(); } - EDevice.SetShader (EDevice.m_SelectionShader); - cnt=0; - for (SDebugDraw::OBBVecIt oit=m_DebugDraw.m_OBB.begin(); oit!=m_DebugDraw.m_OBB.end(); oit++) + EDevice.SetShader(EDevice.m_SelectionShader); + cnt = 0; + for (SDebugDraw::OBBVecIt oit = m_DebugDraw.m_OBB.begin(); oit!=m_DebugDraw.m_OBB.end(); oit++) { - temp.sprintf ("OBB: %d",cnt++); - DU_impl.DrawOBB (Fidentity,*oit,0x2F00FF00,0xFF00FF00); - DU_impl.OutText (oit->m_translate,temp.c_str(),0xffff0000,0x0000000); + temp.sprintf("OBB: %d", cnt++); + DU_impl.DrawOBB(Fidentity, *oit, 0x2F00FF00, 0xFF00FF00); + DU_impl.OutText(oit->m_translate, temp.c_str(), 0xffff0000, 0x0000000); } - EDevice.SetRS (D3DRS_CULLMODE,D3DCULL_CCW); - EDevice.ResetNearer (); - - if(m_pAxisMoveObject && GetSelectionPosition(m_axis_xform) ) + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CCW); + EDevice.ResetNearer(); + + if (m_pAxisMoveObject&&GetSelectionPosition(m_axis_xform)) { - for(SurfaceIt s_it = m_pAxisMoveObject->Surfaces().begin(); s_it != m_pAxisMoveObject->Surfaces().end(); ++s_it) + for (SurfaceIt s_it = m_pAxisMoveObject->Surfaces().begin(); s_it!=m_pAxisMoveObject->Surfaces().end(); ++s_it) { - EDevice.SetShader ((*s_it)->_Shader()); - RCache.set_xform_world (m_axis_xform); - - for(int idx=0; idx< m_pAxisMoveObject->Meshes().size(); ++idx) + EDevice.SetShader((*s_it)->_Shader()); + RCache.set_xform_world(m_axis_xform); + + for (int idx = 0; idxMeshes().size(); ++idx) { - CEditableMesh* M = m_pAxisMoveObject->Meshes()[idx]; - if( (m_Axis==idx) || - (idx==etAxisZX) || - (m_Axis==etAxisZX && (idx==etAxisX || idx==etAxisZ) ) || - (m_Axis==etAxisUndefined) - ) - M->Render (m_axis_xform, *s_it); - } + CEditableMesh*M = m_pAxisMoveObject->Meshes()[idx]; + if ((m_Axis==idx)|| + (idx==etAxisZX)|| + (m_Axis==etAxisZX&&(idx==etAxisX||idx==etAxisZ))|| + (m_Axis==etAxisUndefined) + ) + M->Render(m_axis_xform, *s_it); + } } - } - - if(m_pAxisMoveObject && GetSelectionPosition(m_axis_xform) ) + } + + if (m_pAxisMoveObject&&GetSelectionPosition(m_axis_xform)) { - for(SurfaceIt s_it = m_pAxisMoveObject->Surfaces().begin(); s_it != m_pAxisMoveObject->Surfaces().end(); ++s_it) + for (SurfaceIt s_it = m_pAxisMoveObject->Surfaces().begin(); s_it!=m_pAxisMoveObject->Surfaces().end(); ++s_it) { - EDevice.SetShader ((*s_it)->_Shader()); - RCache.set_xform_world (m_axis_xform); - - for(int idx=0; idx< m_pAxisMoveObject->Meshes().size(); ++idx) + EDevice.SetShader((*s_it)->_Shader()); + RCache.set_xform_world(m_axis_xform); + + for (int idx = 0; idxMeshes().size(); ++idx) { - CEditableMesh* M = m_pAxisMoveObject->Meshes()[idx]; - if( (m_Axis==idx) || - (idx==etAxisZX) || - (m_Axis==etAxisZX && (idx==etAxisX || idx==etAxisZ) ) || - (m_Axis==etAxisUndefined) - ) - M->Render (m_axis_xform, *s_it); - } + CEditableMesh*M = m_pAxisMoveObject->Meshes()[idx]; + if ((m_Axis==idx)|| + (idx==etAxisZX)|| + (m_Axis==etAxisZX&&(idx==etAxisX||idx==etAxisZ))|| + (m_Axis==etAxisUndefined) + ) + M->Render(m_axis_xform, *s_it); + } } - } + } } + //------------------------------------------------------------------------------ + diff --git a/src/editors/ECore/Editor/UI_ToolsCustom.h b/src/editors/ECore/Editor/UI_ToolsCustom.h index e85ddec0686..94de0fd2f32 100644 --- a/src/editors/ECore/Editor/UI_ToolsCustom.h +++ b/src/editors/ECore/Editor/UI_ToolsCustom.h @@ -4,7 +4,7 @@ #include "eltree.hpp" #include "mxplacemnt.hpp" -#include "../xrEProps/ItemListHelper.h" +#include "editors/xrEProps/ItemListHelper.h" #include "EditObject.h" // refs @@ -14,7 +14,8 @@ class PropValue; class TfrmKeyBar; class CBlend; -enum ETAction{ +enum ETAction +{ etaSelect=0, etaAdd, etaMove, @@ -23,211 +24,213 @@ enum ETAction{ etaMaxActions }; -enum ETAxis{ - etAxisY, +enum ETAxis +{ + etAxisY, etAxisX, etAxisZ, etAxisZX, - etAxisUndefined, + etAxisUndefined, }; -enum ETFlags{ - etfCSParent = (1<<0), - etfNUScale = (1<<1), - etfNormalAlign = (1<<2), - etfGSnap = (1<<3), - etfOSnap = (1<<4), - etfMTSnap = (1<<5), - etfVSnap = (1<<6), - etfASnap = (1<<7), - etfMSnap = (1<<8), +enum ETFlags +{ + etfCSParent = (1<<0), + etfNUScale = (1<<1), + etfNormalAlign = (1<<2), + etfGSnap = (1<<3), + etfOSnap = (1<<4), + etfMTSnap = (1<<5), + etfVSnap = (1<<6), + etfASnap = (1<<7), + etfMSnap = (1<<8), }; class ECORE_API CToolCustom { - friend class CCustomPreferences; -protected: - bool m_bReady; - - ETAction m_Action; - ETAxis m_Axis; - Flags32 m_Settings; - - bool m_bHiddenMode; - // move - Fvector m_MoveXVector; - Fvector m_MoveYVector; - Fvector m_MoveReminder; - Fvector m_MovedAmount; - // scale - Fvector m_ScaleCenter; - Fvector m_ScaleAmount; + friendclass CCustomPreferences; + protected: + bool m_bReady; + + ETAction m_Action; + ETAxis m_Axis; + Flags32 m_Settings; + + bool m_bHiddenMode; + // move + Fvector m_MoveXVector; + Fvector m_MoveYVector; + Fvector m_MoveReminder; + Fvector m_MovedAmount; + // scale + Fvector m_ScaleCenter; + Fvector m_ScaleAmount; // rotate - Fvector m_RotateCenter; - Fvector m_RotateVector; - float m_fRotateSnapValue; - float m_RotateAmount; -public: - float m_MoveSnap; - float m_MoveSnapTo; - float m_RotateSnapAngle; -public: - float fFogness; - u32 dwFogColor; -public: - AnsiString m_LastFileName; -public: + Fvector m_RotateCenter; + Fvector m_RotateVector; + float m_fRotateSnapValue; + float m_RotateAmount; + public: + float m_MoveSnap; + float m_MoveSnapTo; + float m_RotateSnapAngle; + public: + float fFogness; + u32 dwFogColor; + public: + AnsiString m_LastFileName; + public: struct SDebugDraw{ - struct Face{ - Fvector p[3]; - u32 c; - bool i; - bool m; - }; - struct Line{ - Fvector p[2]; - u32 c; - bool i; - bool m; - }; - struct Point{ - Fvector p[1]; - u32 c; - bool i; - bool m; - xr_string descr; - }; - DEFINE_VECTOR(Face,FaceVec,FaceIt); - DEFINE_VECTOR(Line,LineVec,LineIt); - DEFINE_VECTOR(Point,PointVec,PointIt); - DEFINE_VECTOR(Fobb,OBBVec,OBBVecIt); - FaceVec m_WireFaces; - FaceVec m_SolidFaces; - LineVec m_Lines; - PointVec m_Points; - OBBVec m_OBB; - void Clear() + struct Face{ + Fvector p[3]; + u32 c; + bool i; + bool m; + }; + struct Line{ + Fvector p[2]; + u32 c; + bool i; + bool m; + }; + struct Point{ + Fvector p[1]; + u32 c; + bool i; + bool m; + xr_string descr; + }; + DEFINE_VECTOR(Face, FaceVec, FaceIt); + DEFINE_VECTOR(Line, LineVec, LineIt); + DEFINE_VECTOR(Point, PointVec, PointIt); + DEFINE_VECTOR(Fobb, OBBVec, OBBVecIt); + FaceVec m_WireFaces; + FaceVec m_SolidFaces; + LineVec m_Lines; + PointVec m_Points; + OBBVec m_OBB; + void Clear() { - m_WireFaces.clear (); - m_SolidFaces.clear (); - m_Lines.clear (); - m_Points.clear (); - m_OBB.clear (); + m_WireFaces.clear(); + m_SolidFaces.clear(); + m_Lines.clear(); + m_Points.clear(); + m_OBB.clear(); } - void AppendPoint(const Fvector& p0, u32 c=0xff0000ff, bool i=true, bool m=true, LPCSTR descr = NULL) + void AppendPoint(const Fvector&p0, u32 c = 0xff0000ff, bool i = true, bool m = true, LPCSTR descr = NULL) { - m_Points.push_back(Point()); + m_Points.push_back(Point()); m_Points.back().p[0].set(p0); - m_Points.back().c = c; - m_Points.back().i = i; - m_Points.back().m = m; + m_Points.back().c = c; + m_Points.back().i = i; + m_Points.back().m = m; if(descr) - m_Points.back().descr = descr; + m_Points.back().descr = descr; } - void AppendLine (const Fvector& p0, const Fvector& p1, u32 c=0xff00ff00, bool i=true, bool m=true) + void AppendLine(const Fvector&p0, const Fvector&p1, u32 c = 0xff00ff00, bool i = true, bool m = true) { - m_Lines.push_back(Line()); - m_Lines.back().p[0].set(p0); - m_Lines.back().p[1].set(p1); - m_Lines.back().c = c; - m_Lines.back().i = i; - m_Lines.back().m = m; + m_Lines.push_back(Line()); + m_Lines.back().p[0].set(p0); + m_Lines.back().p[1].set(p1); + m_Lines.back().c = c; + m_Lines.back().i = i; + m_Lines.back().m = m; } - void AppendWireFace (const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 c=0xffff0000, bool i=true, bool m=true) + void AppendWireFace(const Fvector&p0, const Fvector&p1, const Fvector&p2, u32 c = 0xffff0000, bool i = true, bool m = true) { - m_WireFaces.push_back(Face()); - m_WireFaces.back().p[0].set(p0); - m_WireFaces.back().p[1].set(p1); - m_WireFaces.back().p[2].set(p2); - m_WireFaces.back().c = c; - m_WireFaces.back().i = i; - m_WireFaces.back().m = m; + m_WireFaces.push_back(Face()); + m_WireFaces.back().p[0].set(p0); + m_WireFaces.back().p[1].set(p1); + m_WireFaces.back().p[2].set(p2); + m_WireFaces.back().c = c; + m_WireFaces.back().i = i; + m_WireFaces.back().m = m; } - void AppendSolidFace(const Fvector& p0, const Fvector& p1, const Fvector& p2, u32 c=0xffff0000, bool i=true, bool m=true) + void AppendSolidFace(const Fvector&p0, const Fvector&p1, const Fvector&p2, u32 c = 0xffff0000, bool i = true, bool m = true) { - m_SolidFaces.push_back(Face()); - m_SolidFaces.back().p[0].set(p0); - m_SolidFaces.back().p[1].set(p1); - m_SolidFaces.back().p[2].set(p2); - m_SolidFaces.back().c = c; - m_SolidFaces.back().i = i; - m_SolidFaces.back().m = m; + m_SolidFaces.push_back(Face()); + m_SolidFaces.back().p[0].set(p0); + m_SolidFaces.back().p[1].set(p1); + m_SolidFaces.back().p[2].set(p2); + m_SolidFaces.back().c = c; + m_SolidFaces.back().i = i; + m_SolidFaces.back().m = m; } - void AppendOBB (const Fobb& obb) + void AppendOBB(const Fobb&obb) { - m_OBB.push_back(obb); + m_OBB.push_back(obb); } }; - SDebugDraw m_DebugDraw; -public: - void ClearDebugDraw (){m_DebugDraw.Clear();} -public: - CToolCustom (); - virtual ~CToolCustom (); - - ETAction GetAction () {return m_Action;} - ETAxis GetAxis () {return m_Axis;} - BOOL GetSettings (u32 mask) {return m_Settings.is(mask);} - virtual void SetAction (ETAction act); - virtual void SetAxis (ETAxis axis); - virtual void SetSettings (u32 mask, BOOL val); - - virtual void Simulate (){}; - virtual void UseSimulatePositions(){}; - - - virtual void SetFog (u32 fog_color, float fogness){dwFogColor=fog_color;fFogness=fogness;} - virtual void GetCurrentFog (u32& fog_color, float& s_fog, float& e_fog); - - virtual void Render ()=0; - virtual void RenderEnvironment ()=0; - virtual void OnFrame ()=0; - - virtual bool OnCreate ()=0; - virtual void OnDestroy ()=0; - - virtual bool IfModified ()=0; - virtual bool IsModified ()=0; - virtual void Modified ()=0; - - virtual LPCSTR GetInfo ()=0; - - virtual void ZoomObject (BOOL bSelOnly)=0; - - virtual bool Load (LPCSTR name)=0; - virtual bool Save (LPCSTR name, bool bInternal=false)=0; - virtual void Reload ()=0; - - virtual void OnDeviceCreate ()=0; - virtual void OnDeviceDestroy ()=0; - - virtual void Clear ()=0; - - virtual void OnShowHint (AStringVec& SS)=0; - - virtual bool __fastcall MouseStart (TShiftState Shift)=0; - virtual bool __fastcall MouseEnd (TShiftState Shift)=0; - virtual void __fastcall MouseMove (TShiftState Shift)=0; - virtual bool __fastcall HiddenMode (){return m_bHiddenMode;} - virtual bool __fastcall KeyDown (WORD Key, TShiftState Shift){return false;} - virtual bool __fastcall KeyUp (WORD Key, TShiftState Shift){return false;} - virtual bool __fastcall KeyPress (WORD Key, TShiftState Shift){return false;} - - virtual bool Pick (TShiftState Shift)=0; - virtual bool RayPick (const Fvector& start, const Fvector& dir, float& dist, Fvector* pt=0, Fvector* n=0)=0; - - virtual void ShowProperties (LPCSTR focused_item)=0; - virtual void UpdateProperties (BOOL bForced=FALSE)=0; - virtual void RefreshProperties ()=0; - - const AnsiString& GetEditFileName () { return m_LastFileName; } - - CEditableObject* m_pAxisMoveObject; - Fmatrix m_axis_xform; - - virtual bool GetSelectionPosition (Fmatrix& result) =0; + SDebugDraw m_DebugDraw; + public: + void ClearDebugDraw(){m_DebugDraw.Clear();} + public: + CToolCustom(); + virtual ~CToolCustom(); + + ETAction GetAction(){return m_Action;} + ETAxis GetAxis(){return m_Axis;} + BOOL GetSettings(u32 mask){return m_Settings.is(mask);} + virtual void SetAction(ETAction act); + virtual void SetAxis(ETAxis axis); + virtual void SetSettings(u32 mask, BOOL val); + + virtual void Simulate(){}; + virtual void UseSimulatePositions(){}; + + + virtual void SetFog(u32 fog_color, float fogness){dwFogColor = fog_color;fFogness = fogness;} + virtual void GetCurrentFog(u32&fog_color, float& s_fog, float& e_fog); + + virtual void Render() = 0; + virtual void RenderEnvironment() = 0; + virtual void OnFrame() = 0; + + virtual bool OnCreate() = 0; + virtual void OnDestroy() = 0; + + virtual bool IfModified() = 0; + virtual bool IsModified() = 0; + virtual void Modified() = 0; + + virtual LPCSTR GetInfo() = 0; + + virtual void ZoomObject(BOOL bSelOnly) = 0; + + virtual bool Load(LPCSTR name) = 0; + virtual bool Save(LPCSTR name, bool bInternal = false) = 0; + virtual void Reload() = 0; + + virtual void OnDeviceCreate() = 0; + virtual void OnDeviceDestroy() = 0; + + virtual void Clear() = 0; + + virtual void OnShowHint(AStringVec&SS) = 0; + + virtual bool__fastcall MouseStart(TShiftState Shift) = 0; + virtual bool__fastcall MouseEnd(TShiftState Shift) = 0; + virtual void__fastcall MouseMove(TShiftState Shift) = 0; + virtual bool__fastcall HiddenMode(){return m_bHiddenMode;} + virtual bool__fastcall KeyDown(WORD Key, TShiftState Shift){return false;} + virtual bool__fastcall KeyUp(WORD Key, TShiftState Shift){return false;} + virtual bool__fastcall KeyPress(WORD Key, TShiftState Shift){return false;} + + virtual bool Pick(TShiftState Shift) = 0; + virtual bool RayPick(const Fvector&start, const Fvector&dir, float& dist, Fvector*pt = 0, Fvector*n = 0) = 0; + + virtual void ShowProperties(LPCSTR focused_item) = 0; + virtual void UpdateProperties(BOOL bForced = FALSE) = 0; + virtual void RefreshProperties() = 0; + + const AnsiString&GetEditFileName(){return m_LastFileName;} + + CEditableObject*m_pAxisMoveObject; + Fmatrix m_axis_xform; + + virtual bool GetSelectionPosition(Fmatrix&result) = 0; }; -extern ECORE_API CToolCustom* Tools; +extern ECORE_API CToolCustom* Tools; #define SURFACES_PREFIX "Surfaces" #define BONES_PREFIX "Bones" @@ -235,3 +238,4 @@ extern ECORE_API CToolCustom* Tools; #define OBJECT_PREFIX "Object" //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ECore/Editor/c_dinput.cpp b/src/editors/ECore/Editor/c_dinput.cpp index d348dca2180..abee3df1ec7 100644 --- a/src/editors/ECore/Editor/c_dinput.cpp +++ b/src/editors/ECore/Editor/c_dinput.cpp @@ -10,262 +10,262 @@ #pragma hdrstop static DIOBJECTDATAFORMAT rgodfDIKeyboard[] = { - { &GUID_Key, 0, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(0) | 0x80000000, 0 }, - { &GUID_Key, 1, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(1) | 0x80000000, 0 }, - { &GUID_Key, 2, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(2) | 0x80000000, 0 }, - { &GUID_Key, 3, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(3) | 0x80000000, 0 }, - { &GUID_Key, 4, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(4) | 0x80000000, 0 }, - { &GUID_Key, 5, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(5) | 0x80000000, 0 }, - { &GUID_Key, 6, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(6) | 0x80000000, 0 }, - { &GUID_Key, 7, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(7) | 0x80000000, 0 }, - { &GUID_Key, 8, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(8) | 0x80000000, 0 }, - { &GUID_Key, 9, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(9) | 0x80000000, 0 }, - { &GUID_Key, 10, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(10) | 0x80000000, 0 }, - { &GUID_Key, 11, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(11) | 0x80000000, 0 }, - { &GUID_Key, 12, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(12) | 0x80000000, 0 }, - { &GUID_Key, 13, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(13) | 0x80000000, 0 }, - { &GUID_Key, 14, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(14) | 0x80000000, 0 }, - { &GUID_Key, 15, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(15) | 0x80000000, 0 }, - { &GUID_Key, 16, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(16) | 0x80000000, 0 }, - { &GUID_Key, 17, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(17) | 0x80000000, 0 }, - { &GUID_Key, 18, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(18) | 0x80000000, 0 }, - { &GUID_Key, 19, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(19) | 0x80000000, 0 }, - { &GUID_Key, 20, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(20) | 0x80000000, 0 }, - { &GUID_Key, 21, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(21) | 0x80000000, 0 }, - { &GUID_Key, 22, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(22) | 0x80000000, 0 }, - { &GUID_Key, 23, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(23) | 0x80000000, 0 }, - { &GUID_Key, 24, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(24) | 0x80000000, 0 }, - { &GUID_Key, 25, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(25) | 0x80000000, 0 }, - { &GUID_Key, 26, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(26) | 0x80000000, 0 }, - { &GUID_Key, 27, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(27) | 0x80000000, 0 }, - { &GUID_Key, 28, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(28) | 0x80000000, 0 }, - { &GUID_Key, 29, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(29) | 0x80000000, 0 }, - { &GUID_Key, 30, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(30) | 0x80000000, 0 }, - { &GUID_Key, 31, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(31) | 0x80000000, 0 }, - { &GUID_Key, 32, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(32) | 0x80000000, 0 }, - { &GUID_Key, 33, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(33) | 0x80000000, 0 }, - { &GUID_Key, 34, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(34) | 0x80000000, 0 }, - { &GUID_Key, 35, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(35) | 0x80000000, 0 }, - { &GUID_Key, 36, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(36) | 0x80000000, 0 }, - { &GUID_Key, 37, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(37) | 0x80000000, 0 }, - { &GUID_Key, 38, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(38) | 0x80000000, 0 }, - { &GUID_Key, 39, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(39) | 0x80000000, 0 }, - { &GUID_Key, 40, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(40) | 0x80000000, 0 }, - { &GUID_Key, 41, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(41) | 0x80000000, 0 }, - { &GUID_Key, 42, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(42) | 0x80000000, 0 }, - { &GUID_Key, 43, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(43) | 0x80000000, 0 }, - { &GUID_Key, 44, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(44) | 0x80000000, 0 }, - { &GUID_Key, 45, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(45) | 0x80000000, 0 }, - { &GUID_Key, 46, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(46) | 0x80000000, 0 }, - { &GUID_Key, 47, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(47) | 0x80000000, 0 }, - { &GUID_Key, 48, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(48) | 0x80000000, 0 }, - { &GUID_Key, 49, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(49) | 0x80000000, 0 }, - { &GUID_Key, 50, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(50) | 0x80000000, 0 }, - { &GUID_Key, 51, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(51) | 0x80000000, 0 }, - { &GUID_Key, 52, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(52) | 0x80000000, 0 }, - { &GUID_Key, 53, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(53) | 0x80000000, 0 }, - { &GUID_Key, 54, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(54) | 0x80000000, 0 }, - { &GUID_Key, 55, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(55) | 0x80000000, 0 }, - { &GUID_Key, 56, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(56) | 0x80000000, 0 }, - { &GUID_Key, 57, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(57) | 0x80000000, 0 }, - { &GUID_Key, 58, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(58) | 0x80000000, 0 }, - { &GUID_Key, 59, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(59) | 0x80000000, 0 }, - { &GUID_Key, 60, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(60) | 0x80000000, 0 }, - { &GUID_Key, 61, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(61) | 0x80000000, 0 }, - { &GUID_Key, 62, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(62) | 0x80000000, 0 }, - { &GUID_Key, 63, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(63) | 0x80000000, 0 }, - { &GUID_Key, 64, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(64) | 0x80000000, 0 }, - { &GUID_Key, 65, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(65) | 0x80000000, 0 }, - { &GUID_Key, 66, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(66) | 0x80000000, 0 }, - { &GUID_Key, 67, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(67) | 0x80000000, 0 }, - { &GUID_Key, 68, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(68) | 0x80000000, 0 }, - { &GUID_Key, 69, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(69) | 0x80000000, 0 }, - { &GUID_Key, 70, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(70) | 0x80000000, 0 }, - { &GUID_Key, 71, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(71) | 0x80000000, 0 }, - { &GUID_Key, 72, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(72) | 0x80000000, 0 }, - { &GUID_Key, 73, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(73) | 0x80000000, 0 }, - { &GUID_Key, 74, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(74) | 0x80000000, 0 }, - { &GUID_Key, 75, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(75) | 0x80000000, 0 }, - { &GUID_Key, 76, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(76) | 0x80000000, 0 }, - { &GUID_Key, 77, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(77) | 0x80000000, 0 }, - { &GUID_Key, 78, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(78) | 0x80000000, 0 }, - { &GUID_Key, 79, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(79) | 0x80000000, 0 }, - { &GUID_Key, 80, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(80) | 0x80000000, 0 }, - { &GUID_Key, 81, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(81) | 0x80000000, 0 }, - { &GUID_Key, 82, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(82) | 0x80000000, 0 }, - { &GUID_Key, 83, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(83) | 0x80000000, 0 }, - { &GUID_Key, 84, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(84) | 0x80000000, 0 }, - { &GUID_Key, 85, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(85) | 0x80000000, 0 }, - { &GUID_Key, 86, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(86) | 0x80000000, 0 }, - { &GUID_Key, 87, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(87) | 0x80000000, 0 }, - { &GUID_Key, 88, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(88) | 0x80000000, 0 }, - { &GUID_Key, 89, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(89) | 0x80000000, 0 }, - { &GUID_Key, 90, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(90) | 0x80000000, 0 }, - { &GUID_Key, 91, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(91) | 0x80000000, 0 }, - { &GUID_Key, 92, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(92) | 0x80000000, 0 }, - { &GUID_Key, 93, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(93) | 0x80000000, 0 }, - { &GUID_Key, 94, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(94) | 0x80000000, 0 }, - { &GUID_Key, 95, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(95) | 0x80000000, 0 }, - { &GUID_Key, 96, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(96) | 0x80000000, 0 }, - { &GUID_Key, 97, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(97) | 0x80000000, 0 }, - { &GUID_Key, 98, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(98) | 0x80000000, 0 }, - { &GUID_Key, 99, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(99) | 0x80000000, 0 }, - { &GUID_Key, 100, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(100) | 0x80000000, 0 }, - { &GUID_Key, 101, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(101) | 0x80000000, 0 }, - { &GUID_Key, 102, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(102) | 0x80000000, 0 }, - { &GUID_Key, 103, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(103) | 0x80000000, 0 }, - { &GUID_Key, 104, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(104) | 0x80000000, 0 }, - { &GUID_Key, 105, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(105) | 0x80000000, 0 }, - { &GUID_Key, 106, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(106) | 0x80000000, 0 }, - { &GUID_Key, 107, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(107) | 0x80000000, 0 }, - { &GUID_Key, 108, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(108) | 0x80000000, 0 }, - { &GUID_Key, 109, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(109) | 0x80000000, 0 }, - { &GUID_Key, 110, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(110) | 0x80000000, 0 }, - { &GUID_Key, 111, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(111) | 0x80000000, 0 }, - { &GUID_Key, 112, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(112) | 0x80000000, 0 }, - { &GUID_Key, 113, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(113) | 0x80000000, 0 }, - { &GUID_Key, 114, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(114) | 0x80000000, 0 }, - { &GUID_Key, 115, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(115) | 0x80000000, 0 }, - { &GUID_Key, 116, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(116) | 0x80000000, 0 }, - { &GUID_Key, 117, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(117) | 0x80000000, 0 }, - { &GUID_Key, 118, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(118) | 0x80000000, 0 }, - { &GUID_Key, 119, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(119) | 0x80000000, 0 }, - { &GUID_Key, 120, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(120) | 0x80000000, 0 }, - { &GUID_Key, 121, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(121) | 0x80000000, 0 }, - { &GUID_Key, 122, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(122) | 0x80000000, 0 }, - { &GUID_Key, 123, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(123) | 0x80000000, 0 }, - { &GUID_Key, 124, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(124) | 0x80000000, 0 }, - { &GUID_Key, 125, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(125) | 0x80000000, 0 }, - { &GUID_Key, 126, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(126) | 0x80000000, 0 }, - { &GUID_Key, 127, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(127) | 0x80000000, 0 }, - { &GUID_Key, 128, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(128) | 0x80000000, 0 }, - { &GUID_Key, 129, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(129) | 0x80000000, 0 }, - { &GUID_Key, 130, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(130) | 0x80000000, 0 }, - { &GUID_Key, 131, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(131) | 0x80000000, 0 }, - { &GUID_Key, 132, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(132) | 0x80000000, 0 }, - { &GUID_Key, 133, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(133) | 0x80000000, 0 }, - { &GUID_Key, 134, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(134) | 0x80000000, 0 }, - { &GUID_Key, 135, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(135) | 0x80000000, 0 }, - { &GUID_Key, 136, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(136) | 0x80000000, 0 }, - { &GUID_Key, 137, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(137) | 0x80000000, 0 }, - { &GUID_Key, 138, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(138) | 0x80000000, 0 }, - { &GUID_Key, 139, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(139) | 0x80000000, 0 }, - { &GUID_Key, 140, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(140) | 0x80000000, 0 }, - { &GUID_Key, 141, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(141) | 0x80000000, 0 }, - { &GUID_Key, 142, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(142) | 0x80000000, 0 }, - { &GUID_Key, 143, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(143) | 0x80000000, 0 }, - { &GUID_Key, 144, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(144) | 0x80000000, 0 }, - { &GUID_Key, 145, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(145) | 0x80000000, 0 }, - { &GUID_Key, 146, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(146) | 0x80000000, 0 }, - { &GUID_Key, 147, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(147) | 0x80000000, 0 }, - { &GUID_Key, 148, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(148) | 0x80000000, 0 }, - { &GUID_Key, 149, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(149) | 0x80000000, 0 }, - { &GUID_Key, 150, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(150) | 0x80000000, 0 }, - { &GUID_Key, 151, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(151) | 0x80000000, 0 }, - { &GUID_Key, 152, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(152) | 0x80000000, 0 }, - { &GUID_Key, 153, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(153) | 0x80000000, 0 }, - { &GUID_Key, 154, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(154) | 0x80000000, 0 }, - { &GUID_Key, 155, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(155) | 0x80000000, 0 }, - { &GUID_Key, 156, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(156) | 0x80000000, 0 }, - { &GUID_Key, 157, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(157) | 0x80000000, 0 }, - { &GUID_Key, 158, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(158) | 0x80000000, 0 }, - { &GUID_Key, 159, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(159) | 0x80000000, 0 }, - { &GUID_Key, 160, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(160) | 0x80000000, 0 }, - { &GUID_Key, 161, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(161) | 0x80000000, 0 }, - { &GUID_Key, 162, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(162) | 0x80000000, 0 }, - { &GUID_Key, 163, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(163) | 0x80000000, 0 }, - { &GUID_Key, 164, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(164) | 0x80000000, 0 }, - { &GUID_Key, 165, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(165) | 0x80000000, 0 }, - { &GUID_Key, 166, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(166) | 0x80000000, 0 }, - { &GUID_Key, 167, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(167) | 0x80000000, 0 }, - { &GUID_Key, 168, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(168) | 0x80000000, 0 }, - { &GUID_Key, 169, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(169) | 0x80000000, 0 }, - { &GUID_Key, 170, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(170) | 0x80000000, 0 }, - { &GUID_Key, 171, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(171) | 0x80000000, 0 }, - { &GUID_Key, 172, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(172) | 0x80000000, 0 }, - { &GUID_Key, 173, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(173) | 0x80000000, 0 }, - { &GUID_Key, 174, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(174) | 0x80000000, 0 }, - { &GUID_Key, 175, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(175) | 0x80000000, 0 }, - { &GUID_Key, 176, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(176) | 0x80000000, 0 }, - { &GUID_Key, 177, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(177) | 0x80000000, 0 }, - { &GUID_Key, 178, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(178) | 0x80000000, 0 }, - { &GUID_Key, 179, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(179) | 0x80000000, 0 }, - { &GUID_Key, 180, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(180) | 0x80000000, 0 }, - { &GUID_Key, 181, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(181) | 0x80000000, 0 }, - { &GUID_Key, 182, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(182) | 0x80000000, 0 }, - { &GUID_Key, 183, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(183) | 0x80000000, 0 }, - { &GUID_Key, 184, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(184) | 0x80000000, 0 }, - { &GUID_Key, 185, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(185) | 0x80000000, 0 }, - { &GUID_Key, 186, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(186) | 0x80000000, 0 }, - { &GUID_Key, 187, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(187) | 0x80000000, 0 }, - { &GUID_Key, 188, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(188) | 0x80000000, 0 }, - { &GUID_Key, 189, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(189) | 0x80000000, 0 }, - { &GUID_Key, 190, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(190) | 0x80000000, 0 }, - { &GUID_Key, 191, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(191) | 0x80000000, 0 }, - { &GUID_Key, 192, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(192) | 0x80000000, 0 }, - { &GUID_Key, 193, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(193) | 0x80000000, 0 }, - { &GUID_Key, 194, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(194) | 0x80000000, 0 }, - { &GUID_Key, 195, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(195) | 0x80000000, 0 }, - { &GUID_Key, 196, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(196) | 0x80000000, 0 }, - { &GUID_Key, 197, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(197) | 0x80000000, 0 }, - { &GUID_Key, 198, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(198) | 0x80000000, 0 }, - { &GUID_Key, 199, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(199) | 0x80000000, 0 }, - { &GUID_Key, 200, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(200) | 0x80000000, 0 }, - { &GUID_Key, 201, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(201) | 0x80000000, 0 }, - { &GUID_Key, 202, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(202) | 0x80000000, 0 }, - { &GUID_Key, 203, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(203) | 0x80000000, 0 }, - { &GUID_Key, 204, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(204) | 0x80000000, 0 }, - { &GUID_Key, 205, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(205) | 0x80000000, 0 }, - { &GUID_Key, 206, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(206) | 0x80000000, 0 }, - { &GUID_Key, 207, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(207) | 0x80000000, 0 }, - { &GUID_Key, 208, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(208) | 0x80000000, 0 }, - { &GUID_Key, 209, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(209) | 0x80000000, 0 }, - { &GUID_Key, 210, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(210) | 0x80000000, 0 }, - { &GUID_Key, 211, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(211) | 0x80000000, 0 }, - { &GUID_Key, 212, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(212) | 0x80000000, 0 }, - { &GUID_Key, 213, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(213) | 0x80000000, 0 }, - { &GUID_Key, 214, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(214) | 0x80000000, 0 }, - { &GUID_Key, 215, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(215) | 0x80000000, 0 }, - { &GUID_Key, 216, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(216) | 0x80000000, 0 }, - { &GUID_Key, 217, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(217) | 0x80000000, 0 }, - { &GUID_Key, 218, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(218) | 0x80000000, 0 }, - { &GUID_Key, 219, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(219) | 0x80000000, 0 }, - { &GUID_Key, 220, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(220) | 0x80000000, 0 }, - { &GUID_Key, 221, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(221) | 0x80000000, 0 }, - { &GUID_Key, 222, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(222) | 0x80000000, 0 }, - { &GUID_Key, 223, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(223) | 0x80000000, 0 }, - { &GUID_Key, 224, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(224) | 0x80000000, 0 }, - { &GUID_Key, 225, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(225) | 0x80000000, 0 }, - { &GUID_Key, 226, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(226) | 0x80000000, 0 }, - { &GUID_Key, 227, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(227) | 0x80000000, 0 }, - { &GUID_Key, 228, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(228) | 0x80000000, 0 }, - { &GUID_Key, 229, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(229) | 0x80000000, 0 }, - { &GUID_Key, 230, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(230) | 0x80000000, 0 }, - { &GUID_Key, 231, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(231) | 0x80000000, 0 }, - { &GUID_Key, 232, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(232) | 0x80000000, 0 }, - { &GUID_Key, 233, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(233) | 0x80000000, 0 }, - { &GUID_Key, 234, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(234) | 0x80000000, 0 }, - { &GUID_Key, 235, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(235) | 0x80000000, 0 }, - { &GUID_Key, 236, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(236) | 0x80000000, 0 }, - { &GUID_Key, 237, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(237) | 0x80000000, 0 }, - { &GUID_Key, 238, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(238) | 0x80000000, 0 }, - { &GUID_Key, 239, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(239) | 0x80000000, 0 }, - { &GUID_Key, 240, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(240) | 0x80000000, 0 }, - { &GUID_Key, 241, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(241) | 0x80000000, 0 }, - { &GUID_Key, 242, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(242) | 0x80000000, 0 }, - { &GUID_Key, 243, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(243) | 0x80000000, 0 }, - { &GUID_Key, 244, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(244) | 0x80000000, 0 }, - { &GUID_Key, 245, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(245) | 0x80000000, 0 }, - { &GUID_Key, 246, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(246) | 0x80000000, 0 }, - { &GUID_Key, 247, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(247) | 0x80000000, 0 }, - { &GUID_Key, 248, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(248) | 0x80000000, 0 }, - { &GUID_Key, 249, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(249) | 0x80000000, 0 }, - { &GUID_Key, 250, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(250) | 0x80000000, 0 }, - { &GUID_Key, 251, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(251) | 0x80000000, 0 }, - { &GUID_Key, 252, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(252) | 0x80000000, 0 }, - { &GUID_Key, 253, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(253) | 0x80000000, 0 }, - { &GUID_Key, 254, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(254) | 0x80000000, 0 }, - { &GUID_Key, 255, DIDFT_BUTTON | DIDFT_MAKEINSTANCE(255) | 0x80000000, 0 } + {&GUID_Key, 0, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(0)|0x80000000, 0}, + {&GUID_Key, 1, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(1)|0x80000000, 0}, + {&GUID_Key, 2, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(2)|0x80000000, 0}, + {&GUID_Key, 3, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(3)|0x80000000, 0}, + {&GUID_Key, 4, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(4)|0x80000000, 0}, + {&GUID_Key, 5, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(5)|0x80000000, 0}, + {&GUID_Key, 6, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(6)|0x80000000, 0}, + {&GUID_Key, 7, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(7)|0x80000000, 0}, + {&GUID_Key, 8, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(8)|0x80000000, 0}, + {&GUID_Key, 9, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(9)|0x80000000, 0}, + {&GUID_Key, 10, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(10)|0x80000000, 0}, + {&GUID_Key, 11, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(11)|0x80000000, 0}, + {&GUID_Key, 12, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(12)|0x80000000, 0}, + {&GUID_Key, 13, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(13)|0x80000000, 0}, + {&GUID_Key, 14, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(14)|0x80000000, 0}, + {&GUID_Key, 15, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(15)|0x80000000, 0}, + {&GUID_Key, 16, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(16)|0x80000000, 0}, + {&GUID_Key, 17, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(17)|0x80000000, 0}, + {&GUID_Key, 18, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(18)|0x80000000, 0}, + {&GUID_Key, 19, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(19)|0x80000000, 0}, + {&GUID_Key, 20, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(20)|0x80000000, 0}, + {&GUID_Key, 21, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(21)|0x80000000, 0}, + {&GUID_Key, 22, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(22)|0x80000000, 0}, + {&GUID_Key, 23, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(23)|0x80000000, 0}, + {&GUID_Key, 24, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(24)|0x80000000, 0}, + {&GUID_Key, 25, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(25)|0x80000000, 0}, + {&GUID_Key, 26, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(26)|0x80000000, 0}, + {&GUID_Key, 27, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(27)|0x80000000, 0}, + {&GUID_Key, 28, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(28)|0x80000000, 0}, + {&GUID_Key, 29, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(29)|0x80000000, 0}, + {&GUID_Key, 30, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(30)|0x80000000, 0}, + {&GUID_Key, 31, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(31)|0x80000000, 0}, + {&GUID_Key, 32, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(32)|0x80000000, 0}, + {&GUID_Key, 33, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(33)|0x80000000, 0}, + {&GUID_Key, 34, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(34)|0x80000000, 0}, + {&GUID_Key, 35, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(35)|0x80000000, 0}, + {&GUID_Key, 36, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(36)|0x80000000, 0}, + {&GUID_Key, 37, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(37)|0x80000000, 0}, + {&GUID_Key, 38, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(38)|0x80000000, 0}, + {&GUID_Key, 39, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(39)|0x80000000, 0}, + {&GUID_Key, 40, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(40)|0x80000000, 0}, + {&GUID_Key, 41, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(41)|0x80000000, 0}, + {&GUID_Key, 42, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(42)|0x80000000, 0}, + {&GUID_Key, 43, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(43)|0x80000000, 0}, + {&GUID_Key, 44, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(44)|0x80000000, 0}, + {&GUID_Key, 45, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(45)|0x80000000, 0}, + {&GUID_Key, 46, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(46)|0x80000000, 0}, + {&GUID_Key, 47, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(47)|0x80000000, 0}, + {&GUID_Key, 48, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(48)|0x80000000, 0}, + {&GUID_Key, 49, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(49)|0x80000000, 0}, + {&GUID_Key, 50, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(50)|0x80000000, 0}, + {&GUID_Key, 51, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(51)|0x80000000, 0}, + {&GUID_Key, 52, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(52)|0x80000000, 0}, + {&GUID_Key, 53, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(53)|0x80000000, 0}, + {&GUID_Key, 54, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(54)|0x80000000, 0}, + {&GUID_Key, 55, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(55)|0x80000000, 0}, + {&GUID_Key, 56, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(56)|0x80000000, 0}, + {&GUID_Key, 57, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(57)|0x80000000, 0}, + {&GUID_Key, 58, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(58)|0x80000000, 0}, + {&GUID_Key, 59, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(59)|0x80000000, 0}, + {&GUID_Key, 60, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(60)|0x80000000, 0}, + {&GUID_Key, 61, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(61)|0x80000000, 0}, + {&GUID_Key, 62, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(62)|0x80000000, 0}, + {&GUID_Key, 63, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(63)|0x80000000, 0}, + {&GUID_Key, 64, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(64)|0x80000000, 0}, + {&GUID_Key, 65, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(65)|0x80000000, 0}, + {&GUID_Key, 66, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(66)|0x80000000, 0}, + {&GUID_Key, 67, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(67)|0x80000000, 0}, + {&GUID_Key, 68, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(68)|0x80000000, 0}, + {&GUID_Key, 69, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(69)|0x80000000, 0}, + {&GUID_Key, 70, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(70)|0x80000000, 0}, + {&GUID_Key, 71, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(71)|0x80000000, 0}, + {&GUID_Key, 72, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(72)|0x80000000, 0}, + {&GUID_Key, 73, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(73)|0x80000000, 0}, + {&GUID_Key, 74, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(74)|0x80000000, 0}, + {&GUID_Key, 75, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(75)|0x80000000, 0}, + {&GUID_Key, 76, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(76)|0x80000000, 0}, + {&GUID_Key, 77, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(77)|0x80000000, 0}, + {&GUID_Key, 78, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(78)|0x80000000, 0}, + {&GUID_Key, 79, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(79)|0x80000000, 0}, + {&GUID_Key, 80, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(80)|0x80000000, 0}, + {&GUID_Key, 81, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(81)|0x80000000, 0}, + {&GUID_Key, 82, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(82)|0x80000000, 0}, + {&GUID_Key, 83, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(83)|0x80000000, 0}, + {&GUID_Key, 84, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(84)|0x80000000, 0}, + {&GUID_Key, 85, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(85)|0x80000000, 0}, + {&GUID_Key, 86, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(86)|0x80000000, 0}, + {&GUID_Key, 87, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(87)|0x80000000, 0}, + {&GUID_Key, 88, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(88)|0x80000000, 0}, + {&GUID_Key, 89, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(89)|0x80000000, 0}, + {&GUID_Key, 90, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(90)|0x80000000, 0}, + {&GUID_Key, 91, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(91)|0x80000000, 0}, + {&GUID_Key, 92, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(92)|0x80000000, 0}, + {&GUID_Key, 93, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(93)|0x80000000, 0}, + {&GUID_Key, 94, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(94)|0x80000000, 0}, + {&GUID_Key, 95, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(95)|0x80000000, 0}, + {&GUID_Key, 96, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(96)|0x80000000, 0}, + {&GUID_Key, 97, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(97)|0x80000000, 0}, + {&GUID_Key, 98, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(98)|0x80000000, 0}, + {&GUID_Key, 99, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(99)|0x80000000, 0}, + {&GUID_Key, 100, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(100)|0x80000000, 0}, + {&GUID_Key, 101, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(101)|0x80000000, 0}, + {&GUID_Key, 102, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(102)|0x80000000, 0}, + {&GUID_Key, 103, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(103)|0x80000000, 0}, + {&GUID_Key, 104, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(104)|0x80000000, 0}, + {&GUID_Key, 105, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(105)|0x80000000, 0}, + {&GUID_Key, 106, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(106)|0x80000000, 0}, + {&GUID_Key, 107, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(107)|0x80000000, 0}, + {&GUID_Key, 108, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(108)|0x80000000, 0}, + {&GUID_Key, 109, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(109)|0x80000000, 0}, + {&GUID_Key, 110, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(110)|0x80000000, 0}, + {&GUID_Key, 111, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(111)|0x80000000, 0}, + {&GUID_Key, 112, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(112)|0x80000000, 0}, + {&GUID_Key, 113, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(113)|0x80000000, 0}, + {&GUID_Key, 114, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(114)|0x80000000, 0}, + {&GUID_Key, 115, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(115)|0x80000000, 0}, + {&GUID_Key, 116, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(116)|0x80000000, 0}, + {&GUID_Key, 117, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(117)|0x80000000, 0}, + {&GUID_Key, 118, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(118)|0x80000000, 0}, + {&GUID_Key, 119, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(119)|0x80000000, 0}, + {&GUID_Key, 120, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(120)|0x80000000, 0}, + {&GUID_Key, 121, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(121)|0x80000000, 0}, + {&GUID_Key, 122, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(122)|0x80000000, 0}, + {&GUID_Key, 123, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(123)|0x80000000, 0}, + {&GUID_Key, 124, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(124)|0x80000000, 0}, + {&GUID_Key, 125, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(125)|0x80000000, 0}, + {&GUID_Key, 126, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(126)|0x80000000, 0}, + {&GUID_Key, 127, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(127)|0x80000000, 0}, + {&GUID_Key, 128, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(128)|0x80000000, 0}, + {&GUID_Key, 129, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(129)|0x80000000, 0}, + {&GUID_Key, 130, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(130)|0x80000000, 0}, + {&GUID_Key, 131, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(131)|0x80000000, 0}, + {&GUID_Key, 132, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(132)|0x80000000, 0}, + {&GUID_Key, 133, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(133)|0x80000000, 0}, + {&GUID_Key, 134, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(134)|0x80000000, 0}, + {&GUID_Key, 135, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(135)|0x80000000, 0}, + {&GUID_Key, 136, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(136)|0x80000000, 0}, + {&GUID_Key, 137, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(137)|0x80000000, 0}, + {&GUID_Key, 138, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(138)|0x80000000, 0}, + {&GUID_Key, 139, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(139)|0x80000000, 0}, + {&GUID_Key, 140, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(140)|0x80000000, 0}, + {&GUID_Key, 141, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(141)|0x80000000, 0}, + {&GUID_Key, 142, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(142)|0x80000000, 0}, + {&GUID_Key, 143, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(143)|0x80000000, 0}, + {&GUID_Key, 144, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(144)|0x80000000, 0}, + {&GUID_Key, 145, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(145)|0x80000000, 0}, + {&GUID_Key, 146, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(146)|0x80000000, 0}, + {&GUID_Key, 147, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(147)|0x80000000, 0}, + {&GUID_Key, 148, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(148)|0x80000000, 0}, + {&GUID_Key, 149, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(149)|0x80000000, 0}, + {&GUID_Key, 150, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(150)|0x80000000, 0}, + {&GUID_Key, 151, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(151)|0x80000000, 0}, + {&GUID_Key, 152, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(152)|0x80000000, 0}, + {&GUID_Key, 153, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(153)|0x80000000, 0}, + {&GUID_Key, 154, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(154)|0x80000000, 0}, + {&GUID_Key, 155, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(155)|0x80000000, 0}, + {&GUID_Key, 156, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(156)|0x80000000, 0}, + {&GUID_Key, 157, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(157)|0x80000000, 0}, + {&GUID_Key, 158, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(158)|0x80000000, 0}, + {&GUID_Key, 159, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(159)|0x80000000, 0}, + {&GUID_Key, 160, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(160)|0x80000000, 0}, + {&GUID_Key, 161, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(161)|0x80000000, 0}, + {&GUID_Key, 162, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(162)|0x80000000, 0}, + {&GUID_Key, 163, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(163)|0x80000000, 0}, + {&GUID_Key, 164, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(164)|0x80000000, 0}, + {&GUID_Key, 165, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(165)|0x80000000, 0}, + {&GUID_Key, 166, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(166)|0x80000000, 0}, + {&GUID_Key, 167, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(167)|0x80000000, 0}, + {&GUID_Key, 168, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(168)|0x80000000, 0}, + {&GUID_Key, 169, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(169)|0x80000000, 0}, + {&GUID_Key, 170, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(170)|0x80000000, 0}, + {&GUID_Key, 171, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(171)|0x80000000, 0}, + {&GUID_Key, 172, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(172)|0x80000000, 0}, + {&GUID_Key, 173, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(173)|0x80000000, 0}, + {&GUID_Key, 174, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(174)|0x80000000, 0}, + {&GUID_Key, 175, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(175)|0x80000000, 0}, + {&GUID_Key, 176, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(176)|0x80000000, 0}, + {&GUID_Key, 177, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(177)|0x80000000, 0}, + {&GUID_Key, 178, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(178)|0x80000000, 0}, + {&GUID_Key, 179, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(179)|0x80000000, 0}, + {&GUID_Key, 180, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(180)|0x80000000, 0}, + {&GUID_Key, 181, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(181)|0x80000000, 0}, + {&GUID_Key, 182, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(182)|0x80000000, 0}, + {&GUID_Key, 183, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(183)|0x80000000, 0}, + {&GUID_Key, 184, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(184)|0x80000000, 0}, + {&GUID_Key, 185, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(185)|0x80000000, 0}, + {&GUID_Key, 186, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(186)|0x80000000, 0}, + {&GUID_Key, 187, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(187)|0x80000000, 0}, + {&GUID_Key, 188, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(188)|0x80000000, 0}, + {&GUID_Key, 189, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(189)|0x80000000, 0}, + {&GUID_Key, 190, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(190)|0x80000000, 0}, + {&GUID_Key, 191, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(191)|0x80000000, 0}, + {&GUID_Key, 192, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(192)|0x80000000, 0}, + {&GUID_Key, 193, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(193)|0x80000000, 0}, + {&GUID_Key, 194, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(194)|0x80000000, 0}, + {&GUID_Key, 195, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(195)|0x80000000, 0}, + {&GUID_Key, 196, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(196)|0x80000000, 0}, + {&GUID_Key, 197, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(197)|0x80000000, 0}, + {&GUID_Key, 198, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(198)|0x80000000, 0}, + {&GUID_Key, 199, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(199)|0x80000000, 0}, + {&GUID_Key, 200, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(200)|0x80000000, 0}, + {&GUID_Key, 201, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(201)|0x80000000, 0}, + {&GUID_Key, 202, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(202)|0x80000000, 0}, + {&GUID_Key, 203, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(203)|0x80000000, 0}, + {&GUID_Key, 204, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(204)|0x80000000, 0}, + {&GUID_Key, 205, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(205)|0x80000000, 0}, + {&GUID_Key, 206, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(206)|0x80000000, 0}, + {&GUID_Key, 207, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(207)|0x80000000, 0}, + {&GUID_Key, 208, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(208)|0x80000000, 0}, + {&GUID_Key, 209, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(209)|0x80000000, 0}, + {&GUID_Key, 210, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(210)|0x80000000, 0}, + {&GUID_Key, 211, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(211)|0x80000000, 0}, + {&GUID_Key, 212, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(212)|0x80000000, 0}, + {&GUID_Key, 213, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(213)|0x80000000, 0}, + {&GUID_Key, 214, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(214)|0x80000000, 0}, + {&GUID_Key, 215, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(215)|0x80000000, 0}, + {&GUID_Key, 216, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(216)|0x80000000, 0}, + {&GUID_Key, 217, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(217)|0x80000000, 0}, + {&GUID_Key, 218, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(218)|0x80000000, 0}, + {&GUID_Key, 219, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(219)|0x80000000, 0}, + {&GUID_Key, 220, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(220)|0x80000000, 0}, + {&GUID_Key, 221, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(221)|0x80000000, 0}, + {&GUID_Key, 222, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(222)|0x80000000, 0}, + {&GUID_Key, 223, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(223)|0x80000000, 0}, + {&GUID_Key, 224, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(224)|0x80000000, 0}, + {&GUID_Key, 225, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(225)|0x80000000, 0}, + {&GUID_Key, 226, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(226)|0x80000000, 0}, + {&GUID_Key, 227, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(227)|0x80000000, 0}, + {&GUID_Key, 228, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(228)|0x80000000, 0}, + {&GUID_Key, 229, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(229)|0x80000000, 0}, + {&GUID_Key, 230, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(230)|0x80000000, 0}, + {&GUID_Key, 231, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(231)|0x80000000, 0}, + {&GUID_Key, 232, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(232)|0x80000000, 0}, + {&GUID_Key, 233, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(233)|0x80000000, 0}, + {&GUID_Key, 234, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(234)|0x80000000, 0}, + {&GUID_Key, 235, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(235)|0x80000000, 0}, + {&GUID_Key, 236, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(236)|0x80000000, 0}, + {&GUID_Key, 237, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(237)|0x80000000, 0}, + {&GUID_Key, 238, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(238)|0x80000000, 0}, + {&GUID_Key, 239, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(239)|0x80000000, 0}, + {&GUID_Key, 240, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(240)|0x80000000, 0}, + {&GUID_Key, 241, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(241)|0x80000000, 0}, + {&GUID_Key, 242, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(242)|0x80000000, 0}, + {&GUID_Key, 243, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(243)|0x80000000, 0}, + {&GUID_Key, 244, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(244)|0x80000000, 0}, + {&GUID_Key, 245, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(245)|0x80000000, 0}, + {&GUID_Key, 246, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(246)|0x80000000, 0}, + {&GUID_Key, 247, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(247)|0x80000000, 0}, + {&GUID_Key, 248, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(248)|0x80000000, 0}, + {&GUID_Key, 249, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(249)|0x80000000, 0}, + {&GUID_Key, 250, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(250)|0x80000000, 0}, + {&GUID_Key, 251, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(251)|0x80000000, 0}, + {&GUID_Key, 252, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(252)|0x80000000, 0}, + {&GUID_Key, 253, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(253)|0x80000000, 0}, + {&GUID_Key, 254, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(254)|0x80000000, 0}, + {&GUID_Key, 255, DIDFT_BUTTON|DIDFT_MAKEINSTANCE(255)|0x80000000, 0} }; extern const DIDATAFORMAT c_dfDIKeyboard = { @@ -278,13 +278,13 @@ extern const DIDATAFORMAT c_dfDIKeyboard = { }; static DIOBJECTDATAFORMAT rgodfDIMouse[] = { - { &GUID_XAxis, 0, DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_YAxis, 4, DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_ZAxis, 8, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 12, DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0 }, - { NULL, 13, DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0 }, - { NULL, 14, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 15, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 } + {&GUID_XAxis, 0, DIDFT_AXIS|DIDFT_ANYINSTANCE, 0}, + {&GUID_YAxis, 4, DIDFT_AXIS|DIDFT_ANYINSTANCE, 0}, + {&GUID_ZAxis, 8, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 12, DIDFT_BUTTON|DIDFT_ANYINSTANCE, 0}, + {NULL, 13, DIDFT_BUTTON|DIDFT_ANYINSTANCE, 0}, + {NULL, 14, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 15, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0} }; extern const DIDATAFORMAT c_dfDIMouse = { @@ -297,17 +297,17 @@ extern const DIDATAFORMAT c_dfDIMouse = { }; static DIOBJECTDATAFORMAT rgodfDIMouse2[] = { - { &GUID_XAxis, 0, DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_YAxis, 4, DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_ZAxis, 8, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 12, DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0 }, - { NULL, 13, DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0 }, - { NULL, 14, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 15, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 16, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 17, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 18, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 19, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 } + {&GUID_XAxis, 0, DIDFT_AXIS|DIDFT_ANYINSTANCE, 0}, + {&GUID_YAxis, 4, DIDFT_AXIS|DIDFT_ANYINSTANCE, 0}, + {&GUID_ZAxis, 8, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 12, DIDFT_BUTTON|DIDFT_ANYINSTANCE, 0}, + {NULL, 13, DIDFT_BUTTON|DIDFT_ANYINSTANCE, 0}, + {NULL, 14, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 15, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 16, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 17, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 18, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 19, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0} }; extern const DIDATAFORMAT c_dfDIMouse2 = { @@ -320,50 +320,50 @@ extern const DIDATAFORMAT c_dfDIMouse2 = { }; static DIOBJECTDATAFORMAT rgodfDIJoystick[] = { - { &GUID_XAxis, 0, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_YAxis, 4, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_ZAxis, 8, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_RxAxis, 12, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_RyAxis, 16, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_RzAxis, 20, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_Slider, 24, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_Slider, 28, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_POV, 32, DIDFT_POV | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { &GUID_POV, 36, DIDFT_POV | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { &GUID_POV, 40, DIDFT_POV | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { &GUID_POV, 44, DIDFT_POV | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 48, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 49, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 50, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 51, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 52, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 53, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 54, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 55, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 56, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 57, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 58, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 59, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 60, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 61, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 62, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 63, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 64, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 65, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 66, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 67, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 68, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 69, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 70, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 71, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 72, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 73, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 74, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 75, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 76, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 77, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 78, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 79, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 } + {&GUID_XAxis, 0, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_YAxis, 4, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_ZAxis, 8, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_RxAxis, 12, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_RyAxis, 16, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_RzAxis, 20, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_Slider, 24, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_Slider, 28, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_POV, 32, DIDFT_POV|DIDFT_ANYINSTANCE|0x80000000, 0}, + {&GUID_POV, 36, DIDFT_POV|DIDFT_ANYINSTANCE|0x80000000, 0}, + {&GUID_POV, 40, DIDFT_POV|DIDFT_ANYINSTANCE|0x80000000, 0}, + {&GUID_POV, 44, DIDFT_POV|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 48, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 49, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 50, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 51, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 52, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 53, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 54, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 55, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 56, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 57, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 58, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 59, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 60, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 61, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 62, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 63, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 64, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 65, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 66, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 67, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 68, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 69, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 70, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 71, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 72, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 73, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 74, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 75, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 76, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 77, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 78, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 79, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0} }; extern const DIDATAFORMAT c_dfDIJoystick = { @@ -376,170 +376,170 @@ extern const DIDATAFORMAT c_dfDIJoystick = { }; static DIOBJECTDATAFORMAT rgodfDIJoystick2[] = { - { &GUID_XAxis, 0, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_YAxis, 4, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_ZAxis, 8, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_RxAxis, 12, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_RyAxis, 16, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_RzAxis, 20, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_Slider, 24, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_Slider, 28, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTPOSITION }, - { &GUID_POV, 32, DIDFT_POV | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { &GUID_POV, 36, DIDFT_POV | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { &GUID_POV, 40, DIDFT_POV | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { &GUID_POV, 44, DIDFT_POV | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 48, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 49, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 50, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 51, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 52, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 53, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 54, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 55, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 56, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 57, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 58, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 59, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 60, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 61, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 62, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 63, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 64, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 65, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 66, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 67, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 68, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 69, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 70, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 71, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 72, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 73, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 74, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 75, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 76, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 77, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 78, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 79, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 80, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 81, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 82, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 83, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 84, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 85, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 86, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 87, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 88, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 89, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 90, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 91, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 92, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 93, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 94, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 95, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 96, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 97, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 98, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 99, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 100, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 101, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 102, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 103, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 104, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 105, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 106, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 107, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 108, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 109, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 110, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 111, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 112, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 113, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 114, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 115, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 116, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 117, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 118, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 119, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 120, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 121, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 122, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 123, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 124, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 125, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 126, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 127, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 128, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 129, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 130, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 131, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 132, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 133, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 134, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 135, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 136, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 137, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 138, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 139, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 140, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 141, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 142, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 143, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 144, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 145, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 146, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 147, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 148, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 149, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 150, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 151, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 152, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 153, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 154, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 155, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 156, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 157, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 158, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 159, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 160, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 161, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 162, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 163, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 164, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 165, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 166, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 167, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 168, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 169, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 170, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 171, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 172, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 173, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 174, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { NULL, 175, DIDFT_BUTTON | DIDFT_ANYINSTANCE | 0x80000000, 0 }, - { &GUID_XAxis, 176, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTVELOCITY }, - { &GUID_YAxis, 180, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTVELOCITY }, - { &GUID_ZAxis, 184, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTVELOCITY }, - { &GUID_RxAxis, 188, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTVELOCITY }, - { &GUID_RyAxis, 192, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTVELOCITY }, - { &GUID_RzAxis, 196, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTVELOCITY }, - { &GUID_Slider, 24, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTVELOCITY }, - { &GUID_Slider, 28, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTVELOCITY }, - { &GUID_XAxis, 208, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTACCEL }, - { &GUID_YAxis, 212, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTACCEL }, - { &GUID_ZAxis, 216, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTACCEL }, - { &GUID_RxAxis, 220, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTACCEL }, - { &GUID_RyAxis, 224, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTACCEL }, - { &GUID_RzAxis, 228, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTACCEL }, - { &GUID_Slider, 24, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTACCEL }, - { &GUID_Slider, 28, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTACCEL }, - { &GUID_XAxis, 240, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTFORCE }, - { &GUID_YAxis, 244, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTFORCE }, - { &GUID_ZAxis, 248, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTFORCE }, - { &GUID_RxAxis, 252, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTFORCE }, - { &GUID_RyAxis, 256, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTFORCE }, - { &GUID_RzAxis, 260, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTFORCE }, - { &GUID_Slider, 24, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTFORCE }, - { &GUID_Slider, 28, DIDFT_AXIS | DIDFT_ANYINSTANCE | 0x80000000, DIDOI_ASPECTFORCE } + {&GUID_XAxis, 0, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_YAxis, 4, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_ZAxis, 8, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_RxAxis, 12, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_RyAxis, 16, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_RzAxis, 20, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_Slider, 24, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_Slider, 28, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTPOSITION}, + {&GUID_POV, 32, DIDFT_POV|DIDFT_ANYINSTANCE|0x80000000, 0}, + {&GUID_POV, 36, DIDFT_POV|DIDFT_ANYINSTANCE|0x80000000, 0}, + {&GUID_POV, 40, DIDFT_POV|DIDFT_ANYINSTANCE|0x80000000, 0}, + {&GUID_POV, 44, DIDFT_POV|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 48, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 49, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 50, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 51, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 52, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 53, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 54, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 55, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 56, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 57, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 58, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 59, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 60, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 61, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 62, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 63, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 64, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 65, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 66, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 67, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 68, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 69, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 70, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 71, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 72, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 73, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 74, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 75, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 76, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 77, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 78, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 79, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 80, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 81, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 82, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 83, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 84, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 85, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 86, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 87, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 88, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 89, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 90, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 91, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 92, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 93, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 94, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 95, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 96, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 97, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 98, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 99, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 100, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 101, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 102, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 103, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 104, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 105, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 106, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 107, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 108, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 109, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 110, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 111, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 112, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 113, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 114, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 115, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 116, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 117, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 118, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 119, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 120, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 121, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 122, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 123, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 124, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 125, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 126, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 127, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 128, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 129, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 130, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 131, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 132, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 133, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 134, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 135, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 136, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 137, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 138, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 139, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 140, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 141, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 142, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 143, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 144, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 145, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 146, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 147, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 148, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 149, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 150, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 151, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 152, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 153, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 154, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 155, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 156, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 157, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 158, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 159, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 160, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 161, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 162, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 163, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 164, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 165, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 166, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 167, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 168, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 169, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 170, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 171, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 172, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 173, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 174, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {NULL, 175, DIDFT_BUTTON|DIDFT_ANYINSTANCE|0x80000000, 0}, + {&GUID_XAxis, 176, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTVELOCITY}, + {&GUID_YAxis, 180, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTVELOCITY}, + {&GUID_ZAxis, 184, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTVELOCITY}, + {&GUID_RxAxis, 188, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTVELOCITY}, + {&GUID_RyAxis, 192, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTVELOCITY}, + {&GUID_RzAxis, 196, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTVELOCITY}, + {&GUID_Slider, 24, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTVELOCITY}, + {&GUID_Slider, 28, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTVELOCITY}, + {&GUID_XAxis, 208, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTACCEL}, + {&GUID_YAxis, 212, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTACCEL}, + {&GUID_ZAxis, 216, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTACCEL}, + {&GUID_RxAxis, 220, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTACCEL}, + {&GUID_RyAxis, 224, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTACCEL}, + {&GUID_RzAxis, 228, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTACCEL}, + {&GUID_Slider, 24, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTACCEL}, + {&GUID_Slider, 28, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTACCEL}, + {&GUID_XAxis, 240, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTFORCE}, + {&GUID_YAxis, 244, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTFORCE}, + {&GUID_ZAxis, 248, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTFORCE}, + {&GUID_RxAxis, 252, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTFORCE}, + {&GUID_RyAxis, 256, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTFORCE}, + {&GUID_RzAxis, 260, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTFORCE}, + {&GUID_Slider, 24, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTFORCE}, + {&GUID_Slider, 28, DIDFT_AXIS|DIDFT_ANYINSTANCE|0x80000000, DIDOI_ASPECTFORCE} }; extern const DIDATAFORMAT c_dfDIJoystick2 = { diff --git a/src/editors/ECore/Editor/device.cpp b/src/editors/ECore/Editor/device.cpp index bcdf03d87fd..17215d7c387 100644 --- a/src/editors/ECore/Editor/device.cpp +++ b/src/editors/ECore/Editor/device.cpp @@ -1,429 +1,451 @@ //--------------------------------------------------------------------------- #include "stdafx.h" #pragma hdrstop -#include "gamefont.h" +#include "xrEngine/GameFont.h" #include #include "xrCore/Debug/dxerr.h" #include "ImageManager.h" #include "ui_main.h" #include "render.h" -#include "GameMtlLib.h" -#include "ResourceManager.h" +#include "xrEngine/GameMtlLib.h" +#include "Layers/xrRender/ResourceManager.h" #pragma package(smart_init) -CEditorRenderDevice EDevice; +CEditorRenderDevice EDevice; -extern int rsDVB_Size; -extern int rsDIB_Size; +extern int rsDVB_Size; +extern int rsDIB_Size; -ENGINE_API BOOL g_bRendering = FALSE; +ENGINE_API BOOL g_bRendering = FALSE; //--------------------------------------------------------------------------- CEditorRenderDevice::CEditorRenderDevice() { - psDeviceFlags.assign(rsStatistic|rsFilterLinear|rsFog|rsDrawGrid); -// dynamic buffer size - rsDVB_Size = 2048; - rsDIB_Size = 2048; -// default initialization + psDeviceFlags.assign(rsStatistic|rsFilterLinear|rsFog|rsDrawGrid); + // dynamic buffer size + rsDVB_Size = 2048; + rsDIB_Size = 2048; + // default initialization m_ScreenQuality = 1.f; - dwWidth = dwHeight = 256; - m_RealWidth = m_RealHeight = 256; - m_RenderWidth_2 = m_RenderHeight_2 = 128; - mProject.identity(); + dwWidth = dwHeight = 256; + m_RealWidth = m_RealHeight = 256; + m_RenderWidth_2 = m_RenderHeight_2 = 128; + mProject.identity(); mFullTransform.identity(); - mView.identity (); - m_WireShader = 0; - m_SelectionShader = 0; + mView.identity(); + m_WireShader = 0; + m_SelectionShader = 0; - b_is_Ready = FALSE; - b_is_Active = FALSE; + b_is_Ready = FALSE; + b_is_Active = FALSE; - // Engine flow-control - fTimeDelta = 0; - fTimeGlobal = 0; - dwTimeDelta = 0; - dwTimeGlobal = 0; + // Engine flow-control + fTimeDelta = 0; + fTimeGlobal = 0; + dwTimeDelta = 0; + dwTimeGlobal = 0; - dwFillMode = D3DFILL_SOLID; - dwShadeMode = D3DSHADE_GOURAUD; + dwFillMode = D3DFILL_SOLID; + dwShadeMode = D3DSHADE_GOURAUD; - m_CurrentShader = 0; - pSystemFont = 0; + m_CurrentShader = 0; + pSystemFont = 0; - fASPECT = 1.f; - fFOV = 60.f; + fASPECT = 1.f; + fFOV = 60.f; dwPrecacheFrame = 0; } -CEditorRenderDevice::~CEditorRenderDevice(){ - VERIFY(!b_is_Ready); +CEditorRenderDevice::~CEditorRenderDevice() +{ + VERIFY(!b_is_Ready); } extern void Surface_Init(); -#include "../../Include/xrAPI/xrAPI.h" +#include "Include/xrAPI/xrAPI.h" #include "../../Layers/xrRender/dxRenderFactory.h" + void CEditorRenderDevice::Initialize() { -// m_Camera.Reset(); + // m_Camera.Reset(); - m_DefaultMat.set(1,1,1); - Surface_Init(); + m_DefaultMat.set(1, 1, 1); + Surface_Init(); - // game materials - GMLib.Load (); + // game materials + GMLib.Load(); - // compiler shader + // compiler shader string_path fn; - FS.update_path(fn,_game_data_,"shaders_xrlc.xr"); - if (FS.exist(fn)){ - ShaderXRLC.Load(fn); - }else{ - ELog.DlgMsg(mtInformation,"Can't find file '%s'",fn); + FS.update_path(fn, _game_data_, "shaders_xrlc.xr"); + if (FS.exist(fn)) + { + ShaderXRLC.Load(fn); + } + else + { + ELog.DlgMsg(mtInformation, "Can't find file '%s'", fn); } - RenderFactory = &RenderFactoryImpl; + RenderFactory = &RenderFactoryImpl; - // Startup shaders - Create (); + // Startup shaders + Create(); ::Render->Initialize(); } void CEditorRenderDevice::ShutDown() { - ::Render->ShutDown (); + ::Render->ShutDown(); - ShaderXRLC.Unload (); - GMLib.Unload (); + ShaderXRLC.Unload(); + GMLib.Unload(); - // destroy context - Destroy (); - xr_delete (pSystemFont); + // destroy context + Destroy(); + xr_delete(pSystemFont); - // destroy shaders -// PSLib.xrShutDown (); + // destroy shaders + // PSLib.xrShutDown (); } -void CEditorRenderDevice::InitTimer(){ - Timer_MM_Delta = 0; - { - u32 time_mm = timeGetTime (); - while (timeGetTime()==time_mm); // wait for next tick - u32 time_system = timeGetTime (); - u32 time_local = TimerAsync (); - Timer_MM_Delta = time_system-time_local; - } +void CEditorRenderDevice::InitTimer() +{ + Timer_MM_Delta = 0; + { + u32 time_mm = timeGetTime(); + while (timeGetTime()==time_mm); // wait for next tick + u32 time_system = timeGetTime(); + u32 time_local = TimerAsync(); + Timer_MM_Delta = time_system-time_local; + } } + //--------------------------------------------------------------------------- -void CEditorRenderDevice::RenderNearer(float n){ - mProject._43=m_fNearer-n; +void CEditorRenderDevice::RenderNearer(float n) +{ + mProject._43 = m_fNearer-n; RCache.set_xform_project(mProject); } -void CEditorRenderDevice::ResetNearer(){ - mProject._43=m_fNearer; + +void CEditorRenderDevice::ResetNearer() +{ + mProject._43 = m_fNearer; RCache.set_xform_project(mProject); } + //--------------------------------------------------------------------------- bool CEditorRenderDevice::Create() { - if (b_is_Ready) return false; - Statistic = xr_new(); - ELog.Msg(mtInformation,"Starting RENDER device..."); + if (b_is_Ready) + return false; + Statistic = xr_new(); + ELog.Msg(mtInformation, "Starting RENDER device..."); - HW.CreateDevice (m_hRenderWnd, false); + HW.CreateDevice(m_hRenderWnd, false); - // after creation - dwFrame = 0; + // after creation + dwFrame = 0; - string_path sh; - FS.update_path (sh,_game_data_,"shaders.xr"); + string_path sh; + FS.update_path(sh, _game_data_, "shaders.xr"); - IReader* F = 0; - if (FS.exist(sh)) - F = FS.r_open(0,sh); - Resources = xr_new (); + IReader *F = 0; + if (FS.exist(sh)) + F = FS.r_open(0, sh); + Resources = xr_new(); // if build options - load textures immediately - if (strstr(Core.Params,"-build")||strstr(Core.Params,"-ebuild")) + if (strstr(Core.Params, "-build")||strstr(Core.Params, "-ebuild")) EDevice.Resources->DeferredLoad(FALSE); - _Create (F); - FS.r_close (F); + _Create(F); + FS.r_close(F); - ELog.Msg (mtInformation, "D3D: initialized"); + ELog.Msg(mtInformation, "D3D: initialized"); - return true; + return true; } //--------------------------------------------------------------------------- -void CEditorRenderDevice::Destroy(){ - if (!b_is_Ready) return; +void CEditorRenderDevice::Destroy() +{ + if (!b_is_Ready) + return; - ELog.Msg( mtInformation, "Destroying Direct3D..."); + ELog.Msg(mtInformation, "Destroying Direct3D..."); - HW.Validate (); + HW.Validate(); - // before destroy - _Destroy (FALSE); - xr_delete (Resources); + // before destroy + _Destroy(FALSE); + xr_delete(Resources); - // real destroy - HW.DestroyDevice (); + // real destroy + HW.DestroyDevice(); - ELog.Msg( mtInformation, "D3D: device cleared" ); - xr_delete (Statistic); + ELog.Msg(mtInformation, "D3D: device cleared"); + xr_delete(Statistic); } + //--------------------------------------------------------------------------- void CEditorRenderDevice::_SetupStates() { - HW.Caps.Update(); - for (u32 i=0; iSetSamplerState( i, D3DSAMP_MIPMAPLODBIAS, *((LPDWORD) (&fBias)))); - } - EDevice.SetRS(D3DRS_DITHERENABLE, TRUE ); - EDevice.SetRS(D3DRS_COLORVERTEX, TRUE ); - EDevice.SetRS(D3DRS_STENCILENABLE, FALSE ); - EDevice.SetRS(D3DRS_ZENABLE, TRUE ); - EDevice.SetRS(D3DRS_SHADEMODE, D3DSHADE_GOURAUD ); - EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CCW ); - EDevice.SetRS(D3DRS_ALPHAFUNC, D3DCMP_GREATER ); - EDevice.SetRS(D3DRS_LOCALVIEWER, TRUE ); - EDevice.SetRS(D3DRS_NORMALIZENORMALS,TRUE ); - - EDevice.SetRS(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); - EDevice.SetRS(D3DRS_SPECULARMATERIALSOURCE,D3DMCS_MATERIAL); - EDevice.SetRS(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL); - EDevice.SetRS(D3DRS_EMISSIVEMATERIALSOURCE,D3DMCS_COLOR1 ); + HW.Caps.Update(); + for (u32 i = 0; iSetSamplerState(i, D3DSAMP_MIPMAPLODBIAS, *((LPDWORD)(&fBias)))); + } + EDevice.SetRS(D3DRS_DITHERENABLE, TRUE); + EDevice.SetRS(D3DRS_COLORVERTEX, TRUE); + EDevice.SetRS(D3DRS_STENCILENABLE, FALSE); + EDevice.SetRS(D3DRS_ZENABLE, TRUE); + EDevice.SetRS(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CCW); + EDevice.SetRS(D3DRS_ALPHAFUNC, D3DCMP_GREATER); + EDevice.SetRS(D3DRS_LOCALVIEWER, TRUE); + EDevice.SetRS(D3DRS_NORMALIZENORMALS, TRUE); + + EDevice.SetRS(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); + EDevice.SetRS(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); + EDevice.SetRS(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL); + EDevice.SetRS(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1); ResetMaterial(); } + //--------------------------------------------------------------------------- -void CEditorRenderDevice::_Create(IReader* F) +void CEditorRenderDevice::_Create(IReader *F) { - b_is_Ready = TRUE; + b_is_Ready = TRUE; - // General Render States - _SetupStates (); - - RCache.OnDeviceCreate (); - Resources->OnDeviceCreate (F); - ::Render->OnDeviceCreate (); + // General Render States + _SetupStates(); - m_WireShader.create ("editor\\wire"); - m_SelectionShader.create ("editor\\selection"); + RCache.OnDeviceCreate(); + Resources->OnDeviceCreate(F); + ::Render->OnDeviceCreate(); - // signal another objects - UI->OnDeviceCreate (); -//. seqDevCreate.Process (rp_DeviceCreate); + m_WireShader.create("editor\\wire"); + m_SelectionShader.create("editor\\selection"); - pSystemFont = xr_new("hud_font_small"); -// pSystemFont = xr_new("hud_font_medium"); + // signal another objects + UI->OnDeviceCreate(); + //. seqDevCreate.Process (rp_DeviceCreate); + + pSystemFont = xr_new("hud_font_small"); + // pSystemFont = xr_new("hud_font_medium"); } -void CEditorRenderDevice::_Destroy(BOOL bKeepTextures) +void CEditorRenderDevice::_Destroy(BOOL bKeepTextures) { - xr_delete (pSystemFont); + xr_delete(pSystemFont); - b_is_Ready = FALSE; - m_CurrentShader = 0; + b_is_Ready = FALSE; + m_CurrentShader = 0; - UI->OnDeviceDestroy (); + UI->OnDeviceDestroy(); - m_WireShader.destroy (); - m_SelectionShader.destroy (); + m_WireShader.destroy(); + m_SelectionShader.destroy(); -//. seqDevDestroy.Process (rp_DeviceDestroy); + //. seqDevDestroy.Process (rp_DeviceDestroy); - ::Render->Models->OnDeviceDestroy (); + ::Render->Models->OnDeviceDestroy(); - Resources->OnDeviceDestroy (bKeepTextures); + Resources->OnDeviceDestroy(bKeepTextures); - RCache.OnDeviceDestroy (); - ::Render->OnDeviceDestroy (); + RCache.OnDeviceDestroy(); + ::Render->OnDeviceDestroy(); } //--------------------------------------------------------------------------- void __fastcall CEditorRenderDevice::Resize(int w, int h) { - m_RealWidth = w; - m_RealHeight = h; - m_RenderArea = w*h; + m_RealWidth = w; + m_RealHeight = h; + m_RenderArea = w*h; - dwWidth = m_RealWidth * m_ScreenQuality; - dwHeight = m_RealHeight * m_ScreenQuality; - m_RenderWidth_2 = dwWidth * 0.5f; - m_RenderHeight_2= dwHeight * 0.5f; + dwWidth = m_RealWidth*m_ScreenQuality; + dwHeight = m_RealHeight*m_ScreenQuality; + m_RenderWidth_2 = dwWidth*0.5f; + m_RenderHeight_2 = dwHeight*0.5f; - fASPECT = (float)dwHeight / (float)dwWidth; - mProject.build_projection( deg2rad(fFOV), fASPECT, m_Camera.m_Znear, m_Camera.m_Zfar ); - m_fNearer = mProject._43; + fASPECT = (float)dwHeight/(float)dwWidth; + mProject.build_projection(deg2rad(fFOV), fASPECT, m_Camera.m_Znear, m_Camera.m_Zfar); + m_fNearer = mProject._43; - Reset (); + Reset(); RCache.set_xform_project(mProject); - RCache.set_xform_world (Fidentity); + RCache.set_xform_world(Fidentity); - UI->RedrawScene (); + UI->RedrawScene(); } -void CEditorRenderDevice::Reset () +void CEditorRenderDevice::Reset() { - u32 tm_start = TimerAsync(); - Resources->reset_begin (); - Memory.mem_compact (); - HW.DevPP.BackBufferWidth= dwWidth; - HW.DevPP.BackBufferHeight= dwHeight; - HW.Reset (m_hRenderWnd); - dwWidth = HW.DevPP.BackBufferWidth; - dwHeight = HW.DevPP.BackBufferHeight; - m_RenderWidth_2 = dwWidth * 0.5f; - m_RenderHeight_2 = dwHeight * 0.5f; -// fWidth_2 = float(dwWidth/2); -// fHeight_2 = float(dwHeight/2); - Resources->reset_end (); - _SetupStates (); - u32 tm_end = TimerAsync(); - Msg ("*** RESET [%d ms]",tm_end-tm_start); + u32 tm_start = TimerAsync(); + Resources->reset_begin(); + Memory.mem_compact(); + HW.DevPP.BackBufferWidth = dwWidth; + HW.DevPP.BackBufferHeight = dwHeight; + HW.Reset(m_hRenderWnd); + dwWidth = HW.DevPP.BackBufferWidth; + dwHeight = HW.DevPP.BackBufferHeight; + m_RenderWidth_2 = dwWidth*0.5f; + m_RenderHeight_2 = dwHeight*0.5f; + // fWidth_2 = float(dwWidth/2); + // fHeight_2 = float(dwHeight/2); + Resources->reset_end(); + _SetupStates(); + u32 tm_end = TimerAsync(); + Msg("*** RESET [%d ms]", tm_end-tm_start); } -BOOL CEditorRenderDevice::Begin () +BOOL CEditorRenderDevice::Begin() { - VERIFY(b_is_Ready); - HW.Validate (); - HRESULT _hr = HW.pDevice->TestCooperativeLevel(); + VERIFY(b_is_Ready); + HW.Validate(); + HRESULT _hr = HW.pDevice->TestCooperativeLevel(); if (FAILED(_hr)) - { - // If the device was lost, do not render until we get it back - if (D3DERR_DEVICELOST==_hr) { - Sleep (33); - return FALSE; - } - - // Check if the device is ready to be reset - if (D3DERR_DEVICENOTRESET==_hr) - { - Reset (); - } - } - - VERIFY (FALSE==g_bRendering); - CHK_DX (HW.pDevice->BeginScene()); - CHK_DX(HW.pDevice->Clear(0,0, - D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET| - (HW.Caps.bStencil?D3DCLEAR_STENCIL:0), - EPrefs->scene_clear_color,1,0 - )); - RCache.OnFrameBegin (); - g_bRendering = TRUE; - return TRUE; + { + // If the device was lost, do not render until we get it back + if (D3DERR_DEVICELOST==_hr) + { + Sleep(33); + return FALSE; + } + + // Check if the device is ready to be reset + if (D3DERR_DEVICENOTRESET==_hr) + { + Reset(); + } + } + + VERIFY(FALSE==g_bRendering); + CHK_DX(HW.pDevice->BeginScene()); + CHK_DX(HW.pDevice->Clear(0, 0, + D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET| + (HW.Caps.bStencil ? D3DCLEAR_STENCIL : 0), + EPrefs->scene_clear_color, 1, 0 + )); + RCache.OnFrameBegin(); + g_bRendering = TRUE; + return TRUE; } //--------------------------------------------------------------------------- void CEditorRenderDevice::End() { - VERIFY(HW.pDevice); - VERIFY(b_is_Ready); + VERIFY(HW.pDevice); + VERIFY(b_is_Ready); + + seqRender.Process(rp_Render); - seqRender.Process (rp_Render); - - Statistic->Show(pSystemFont); - EDevice.SetRS (D3DRS_FILLMODE,D3DFILL_SOLID); - pSystemFont->OnRender(); - EDevice.SetRS (D3DRS_FILLMODE,EDevice.dwFillMode); + Statistic->Show(pSystemFont); + EDevice.SetRS(D3DRS_FILLMODE, D3DFILL_SOLID); + pSystemFont->OnRender(); + EDevice.SetRS(D3DRS_FILLMODE, EDevice.dwFillMode); - g_bRendering = FALSE; + g_bRendering = FALSE; - // end scene - RCache.OnFrameEnd(); + // end scene + RCache.OnFrameEnd(); CHK_DX(HW.pDevice->EndScene()); - CHK_DX(HW.pDevice->Present( NULL, NULL, NULL, NULL )); + CHK_DX(HW.pDevice->Present(NULL, NULL, NULL, NULL)); } void CEditorRenderDevice::UpdateView() { -// set camera matrix - m_Camera.GetView(mView); + // set camera matrix + m_Camera.GetView(mView); RCache.set_xform_view(mView); - mFullTransform.mul(mProject,mView); + mFullTransform.mul(mProject, mView); -// frustum culling sets - ::Render->ViewBase.CreateFromMatrix(mFullTransform,FRUSTUM_P_ALL); + // frustum culling sets + ::Render->ViewBase.CreateFromMatrix(mFullTransform, FRUSTUM_P_ALL); } void CEditorRenderDevice::FrameMove() { - dwFrame++; + dwFrame++; - // Timer - float fPreviousFrameTime = Timer.GetElapsed_sec(); Timer.Start(); // previous frame - fTimeDelta = 0.1f * fTimeDelta + 0.9f*fPreviousFrameTime; // smooth random system activity - worst case ~7% error - if (fTimeDelta>.1f) fTimeDelta=.1f; // limit to 15fps minimum + // Timer + float fPreviousFrameTime = Timer.GetElapsed_sec(); + Timer.Start(); // previous frame + fTimeDelta = 0.1f*fTimeDelta+0.9f*fPreviousFrameTime; // smooth random system activity - worst case ~7% error + if (fTimeDelta>.1f) + fTimeDelta = .1f; // limit to 15fps minimum - fTimeGlobal = TimerGlobal.GetElapsed_sec(); //float(qTime)*CPU::cycles2seconds; - dwTimeGlobal = TimerGlobal.GetElapsed_ms (); //u32((qTime*u64(1000))/CPU::cycles_per_second); - dwTimeDelta = iFloor(fTimeDelta*1000.f+0.5f); - dwTimeContinual = dwTimeGlobal; + fTimeGlobal = TimerGlobal.GetElapsed_sec(); //float(qTime)*CPU::cycles2seconds; + dwTimeGlobal = TimerGlobal.GetElapsed_ms(); //u32((qTime*u64(1000))/CPU::cycles_per_second); + dwTimeDelta = iFloor(fTimeDelta*1000.f+0.5f); + dwTimeContinual = dwTimeGlobal; m_Camera.Update(fTimeDelta); // process objects - seqFrame.Process(rp_Frame); + seqFrame.Process(rp_Frame); } void CEditorRenderDevice::DP(D3DPRIMITIVETYPE pt, ref_geom geom, u32 vBase, u32 pc) { - ref_shader S = m_CurrentShader?m_CurrentShader:m_WireShader; - u32 dwRequired = S->E[0]->passes.size(); - RCache.set_Geometry (geom); - for (u32 dwPass = 0; dwPassE[0]->passes.size(); + RCache.set_Geometry(geom); + for (u32 dwPass = 0; dwPassE[0]->passes.size(); - RCache.set_Geometry (geom); - for (u32 dwPass = 0; dwPassE[0]->passes.size(); + RCache.set_Geometry(geom); + for (u32 dwPass = 0; dwPassSetStatus("Reload textures..."); - Resources->ED_UpdateTextures(0); - UI->SetStatus(""); + UI->SetStatus("Reload textures..."); + Resources->ED_UpdateTextures(0); + UI->SetStatus(""); } void CEditorRenderDevice::UnloadTextures() { #ifndef _EDITOR Resources->DeferredUnload(); -#endif +#endif } -void CEditorRenderDevice::Reset(IReader* F, BOOL bKeepTextures) +void CEditorRenderDevice::Reset(IReader *F, BOOL bKeepTextures) { - CTimer tm; + CTimer tm; tm.Start(); - _Destroy (bKeepTextures); - _Create (F); - Msg ("*** RESET [%d ms]",tm.GetElapsed_ms()); + _Destroy(bKeepTextures); + _Create(F); + Msg("*** RESET [%d ms]", tm.GetElapsed_ms()); } void CEditorRenderDevice::time_factor(float v) { - Timer.time_factor(v); - TimerGlobal.time_factor(v); + Timer.time_factor(v); + TimerGlobal.time_factor(v); } diff --git a/src/editors/ECore/Editor/device.h b/src/editors/ECore/Editor/device.h index 4bd932469f6..6543913defb 100644 --- a/src/editors/ECore/Editor/device.h +++ b/src/editors/ECore/Editor/device.h @@ -1,16 +1,16 @@ #ifndef DeviceH #define DeviceH -#include "../../../xrengine/device.h" -#include "ui_camera.h" -#include "../../../Layers/xrRender/hwcaps.h" -#include "../../../Layers/xrRender/hw.h" -#include "../../../xrEngine/pure.h" -#include "../../../xrCore/ftimer.h" -#include "estats.h" -#include "../../../xrEngine/shader_xrlc.h" -#include "../../../Layers/xrRender/shader.h" -#include "../../../Layers/xrRender/R_Backend.h" +#include "xrEngine/device.h" +#include "UI_Camera.h" +#include "Layers/xrRender/HWCaps.h" +#include "Layers/xrRender/HW.h" +#include "xrEngine/pure.h" +#include "xrCore/FTimer.h" +#include "EStats.h" +#include "utils/Shader_xrLC.h" +#include "Layers/xrRender/Shader.h" +#include "Layers/xrRender/R_Backend.h" //--------------------------------------------------------------------------- @@ -21,42 +21,44 @@ class CResourceManager; //------------------------------------------------------------------------------ class ECORE_API CEditorRenderDevice : - public CRenderDeviceBase + +public +CRenderDeviceBase { - friend class CUI_Camera; - friend class TUI; + friend class CUI_Camera; + friend class TUI; - float m_fNearer; + float m_fNearer; - //u32 Timer_MM_Delta; - //CTimer Timer; - //CTimer TimerGlobal; + //u32 Timer_MM_Delta; + //CTimer Timer; + //CTimer TimerGlobal; - ref_shader m_CurrentShader; + ref_shader m_CurrentShader; - void _SetupStates(); - void _Create (IReader* F); - void _Destroy (BOOL bKeepTextures); - void Reset (); -public: - ref_shader m_WireShader; - ref_shader m_SelectionShader; + void _SetupStates(); + void _Create (IReader* F); + void _Destroy (BOOL bKeepTextures); + void Reset (); + public: + ref_shader m_WireShader; + ref_shader m_SelectionShader; - Fmaterial m_DefaultMat; -public: - // u32 dwWidth, dwHeight; - u32 m_RenderWidth_2, m_RenderHeight_2; - u32 m_RealWidth, m_RealHeight; - float m_RenderArea; - float m_ScreenQuality; - - u32 dwFillMode; - u32 dwShadeMode; -public: -// HWND m_hWnd; - HWND m_hRenderWnd; + Fmaterial m_DefaultMat; + public: + // u32 dwWidth, dwHeight; + u32 m_RenderWidth_2, m_RenderHeight_2; + u32 m_RealWidth, m_RealHeight; + float m_RenderArea; + float m_ScreenQuality; - IC void SetHandle(HWND main_hwnd, HWND render_hwnd){m_hWnd=main_hwnd; m_hRenderWnd=render_hwnd;} + u32 dwFillMode; + u32 dwShadeMode; + public: + // HWND m_hWnd; + HWND m_hRenderWnd; + + IC void SetHandle(HWND main_hwnd, HWND render_hwnd){m_hWnd=main_hwnd; m_hRenderWnd=render_hwnd;} // u32 dwFrame; // u32 dwPrecacheFrame; @@ -64,140 +66,139 @@ class ECORE_API CEditorRenderDevice : // BOOL b_is_Ready; // BOOL b_is_Active; - // Engine flow-control - //float fTimeDelta; - //float fTimeGlobal; - //u32 dwTimeDelta; - //u32 dwTimeGlobal; - // u32 dwTimeContinual; +// Engine flow-control +//float fTimeDelta; +//float fTimeGlobal; +//u32 dwTimeDelta; +//u32 dwTimeGlobal; +// u32 dwTimeContinual; - // camera - CUI_Camera m_Camera; +// camera +CUI_Camera m_Camera; - // Fvector vCameraPosition; - // Fvector vCameraDirection; - // Fvector vCameraTop; - // Fvector vCameraRight; - // - //Fmatrix mView; - //Fmatrix mProjection; - //Fmatrix mFullTransform; +// Fvector vCameraPosition; +// Fvector vCameraDirection; +// Fvector vCameraTop; +// Fvector vCameraRight; +// +//Fmatrix mView; +//Fmatrix mProjection; +//Fmatrix mFullTransform; - // float fFOV; - //float fASPECT; +// float fFOV; +//float fASPECT; - // Dependent classes - CResourceManager* Resources; - CEStats* Statistic; +// Dependent classes +CResourceManager* Resources; +CEStats* Statistic; - CGameFont* pSystemFont; +CGameFont* pSystemFont; - // registrators +// registrators // CRegistrator seqDevDestroy; // CRegistrator seqDevCreate; - //CRegistrator seqFrame; - //CRegistrator seqRender; - //CRegistrator seqAppStart; - //CRegistrator seqAppEnd; - //CRegistrator seqAppActivate; - //CRegistrator seqAppDeactivate; +//CRegistrator seqFrame; +//CRegistrator seqRender; +//CRegistrator seqAppStart; +//CRegistrator seqAppEnd; +//CRegistrator seqAppActivate; +//CRegistrator seqAppDeactivate; public: - CEditorRenderDevice (); - virtual ~CEditorRenderDevice (); - - void Pause (BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason){}; - BOOL Paused (){return FALSE;}; - void time_factor (float); - bool Create (); - void Destroy (); - void Resize (int w, int h); - void ReloadTextures (); - void UnloadTextures (); - - void RenderNearer (float f_Near); - void ResetNearer (); - - BOOL Begin (); - void End (); - - void Initialize (void); - void ShutDown (void); - void Reset (IReader* F, BOOL bKeepTextures); - - IC CTimer* GetTimerGlobal (){return &TimerGlobal;} - - IC float GetRenderArea (){return m_RenderArea;} - // Sprite rendering - IC float _x2real (float x) - { return (x+1)*m_RenderWidth_2; } - IC float _y2real (float y) - { return (y+1)*m_RenderHeight_2;} - - // draw - void SetShader (ref_shader sh){m_CurrentShader = sh;} - void DP (D3DPRIMITIVETYPE pt, ref_geom geom, u32 startV, u32 pc); - void DIP (D3DPRIMITIVETYPE pt, ref_geom geom, u32 baseV, u32 startV, u32 countV, u32 startI, u32 PC); - - IC void SetRS (D3DRENDERSTATETYPE p1, u32 p2) - { VERIFY(b_is_Ready); CHK_DX(HW.pDevice->SetRenderState(p1,p2)); } - IC void SetSS (u32 sampler, D3DSAMPLERSTATETYPE type, u32 value) - { VERIFY(b_is_Ready); CHK_DX(HW.pDevice->SetSamplerState(sampler,type,value)); } - - // light&material - IC void LightEnable (u32 dwLightIndex, BOOL bEnable) - { CHK_DX(HW.pDevice->LightEnable(dwLightIndex, bEnable));} - IC void SetLight (u32 dwLightIndex, Flight& lpLight) - { CHK_DX(HW.pDevice->SetLight(dwLightIndex, (D3DLIGHT9*)&lpLight));} - IC void SetMaterial (Fmaterial& mat) - { CHK_DX(HW.pDevice->SetMaterial((D3DMATERIAL9*)&mat));} - IC void ResetMaterial () - { CHK_DX(HW.pDevice->SetMaterial((D3DMATERIAL9*)&m_DefaultMat));} - - // update - void UpdateView (); - void FrameMove (); - - bool MakeScreenshot (U32Vec& pixels, u32 width, u32 height); - - void InitTimer (); - // Mode control - IC u32 TimerAsync (void) - { return TimerGlobal.GetElapsed_ms();} - IC u32 TimerAsync_MMT (void) - { return TimerAsync()+Timer_MM_Delta; } +CEditorRenderDevice (); +virtual ~CEditorRenderDevice (); + +void Pause (BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason){}; +BOOL Paused (){return FALSE;}; +void time_factor (float); +bool Create (); +void Destroy (); +void Resize (int w, int h); +void ReloadTextures (); +void UnloadTextures (); + +void RenderNearer (float f_Near); +void ResetNearer (); + +BOOL Begin (); +void End (); + +void Initialize (void); +void ShutDown (void); +void Reset (IReader* F, BOOL bKeepTextures); + +IC CTimer* GetTimerGlobal (){return &TimerGlobal;} + +IC float GetRenderArea (){return m_RenderArea;} +// Sprite rendering +IC float _x2real (float x) +{ return (x+1)*m_RenderWidth_2; } +IC float _y2real (float y) +{ return (y+1)*m_RenderHeight_2;} + +// draw +void SetShader (ref_shader sh){m_CurrentShader = sh;} +void DP (D3DPRIMITIVETYPE pt, ref_geom geom, u32 startV, u32 pc); +void DIP (D3DPRIMITIVETYPE pt, ref_geom geom, u32 baseV, u32 startV, u32 countV, u32 startI, u32 PC); + +IC void SetRS (D3DRENDERSTATETYPE p1, u32 p2) +{ VERIFY(b_is_Ready); CHK_DX(HW.pDevice->SetRenderState(p1,p2)); } +IC void SetSS (u32 sampler, D3DSAMPLERSTATETYPE type, u32 value) +{ VERIFY(b_is_Ready); CHK_DX(HW.pDevice->SetSamplerState(sampler,type,value)); } + +// light&material +IC void LightEnable (u32 dwLightIndex, BOOL bEnable) +{ CHK_DX(HW.pDevice->LightEnable(dwLightIndex, bEnable));} +IC void SetLight (u32 dwLightIndex, Flight& lpLight) +{ CHK_DX(HW.pDevice->SetLight(dwLightIndex, (D3DLIGHT9*)&lpLight));} +IC void SetMaterial (Fmaterial& mat) +{ CHK_DX(HW.pDevice->SetMaterial((D3DMATERIAL9*)&mat));} +IC void ResetMaterial () +{ CHK_DX(HW.pDevice->SetMaterial((D3DMATERIAL9*)&m_DefaultMat));} + +// update +void UpdateView (); +void FrameMove (); + +bool MakeScreenshot (U32Vec& pixels, u32 width, u32 height); + +void InitTimer (); +// Mode control +IC u32 TimerAsync (void) +{ return TimerGlobal.GetElapsed_ms();} +IC u32 TimerAsync_MMT (void) +{ return TimerAsync()+Timer_MM_Delta; } public: - Shader_xrLC_LIB ShaderXRLC; +Shader_xrLC_LIB ShaderXRLC; private: - virtual CStatsPhysics* _BCL StatPhysics () { return Statistic; } - virtual void _BCL AddSeqFrame ( pureFrame* f, bool mt ) { seqFrame.Add (f,REG_PRIORITY_LOW); } - virtual void _BCL RemoveSeqFrame ( pureFrame* f ) { seqFrame.Remove ( f );} +virtual CStatsPhysics* _BCL StatPhysics () { return Statistic; } +virtual void _BCL AddSeqFrame ( pureFrame* f, bool mt ) { seqFrame.Add (f,REG_PRIORITY_LOW); } +virtual void _BCL RemoveSeqFrame ( pureFrame* f ) { seqFrame.Remove ( f );} }; extern ECORE_API CEditorRenderDevice EDevice; // video -enum { - rsFilterLinear = (1ul<<20ul), - rsEdgedFaces = (1ul<<21ul), - rsRenderTextures = (1ul<<22ul), - rsLighting = (1ul<<23ul), - rsFog = (1ul<<24ul), - rsRenderRealTime = (1ul<<25ul), - rsDrawGrid = (1ul<<26ul), - rsDrawSafeRect = (1ul<<27ul), - rsMuteSounds = (1ul<<28ul), - rsEnvironment = (1ul<<29ul), +enum +{ + rsFilterLinear = (1ul<<20ul), + rsEdgedFaces = (1ul<<21ul), + rsRenderTextures = (1ul<<22ul), + rsLighting = (1ul<<23ul), + rsFog = (1ul<<24ul), + rsRenderRealTime = (1ul<<25ul), + rsDrawGrid = (1ul<<26ul), + rsDrawSafeRect = (1ul<<27ul), + rsMuteSounds = (1ul<<28ul), + rsEnvironment = (1ul<<29ul), }; #define DEFAULT_CLEARCOLOR 0x00555555 -#define REQ_CREATE() if (!EDevice.bReady) return; -#define REQ_DESTROY() if (EDevice.bReady) return; +#define REQ_CREATE() if (!EDevice.bReady) return; +#define REQ_DESTROY() if (EDevice.bReady) return; -#include "../xrCPU_Pipe/xrCPU_Pipe.h" -ENGINE_API extern xrDispatchTable PSGP; - -#include "../../Layers/xrRender/R_Backend_Runtime.h" +#include "Layers/xrRender/R_Backend_Runtime.h" #endif + diff --git a/src/editors/ECore/Editor/du_box.cpp b/src/editors/ECore/Editor/du_box.cpp index 9b146a94360..8bb0a05f855 100644 --- a/src/editors/ECore/Editor/du_box.cpp +++ b/src/editors/ECore/Editor/du_box.cpp @@ -6,43 +6,43 @@ //--------------------------------------------------------------------------- //#pragma package(smart_init) Fvector du_box_vertices2[DU_BOX_NUMVERTEX2] = { - {-0.5f, -0.5f, -0.5f}, {-0.5f, +0.5f, -0.5f}, {+0.5f, +0.5f, -0.5f}, - {+0.5f, +0.5f, -0.5f}, {+0.5f, -0.5f, -0.5f}, {-0.5f, -0.5f, -0.5f}, - {+0.5f, -0.5f, -0.5f}, {+0.5f, +0.5f, -0.5f}, {+0.5f, +0.5f, +0.5f}, - {+0.5f, +0.5f, +0.5f}, {+0.5f, -0.5f, +0.5f}, {+0.5f, -0.5f, -0.5f}, - {+0.5f, +0.5f, +0.5f}, {-0.5f, +0.5f, +0.5f}, {-0.5f, -0.5f, +0.5f}, - {+0.5f, +0.5f, +0.5f}, {-0.5f, -0.5f, +0.5f}, {+0.5f, -0.5f, +0.5f}, - {-0.5f, +0.5f, +0.5f}, {-0.5f, +0.5f, -0.5f}, {-0.5f, -0.5f, +0.5f}, - {-0.5f, +0.5f, -0.5f}, {-0.5f, -0.5f, -0.5f}, {-0.5f, -0.5f, +0.5f}, - {+0.5f, -0.5f, -0.5f}, {-0.5f, -0.5f, +0.5f}, {-0.5f, -0.5f, -0.5f}, - {+0.5f, -0.5f, -0.5f}, {+0.5f, -0.5f, +0.5f}, {-0.5f, -0.5f, +0.5f}, - {-0.5f, +0.5f, -0.5f}, {-0.5f, +0.5f, +0.5f}, {+0.5f, +0.5f, +0.5f}, - {-0.5f, +0.5f, -0.5f}, {+0.5f, +0.5f, +0.5f}, {+0.5f, +0.5f, -0.5f} + {-0.5f, -0.5f, -0.5f},{-0.5f, +0.5f, -0.5f},{+0.5f, +0.5f, -0.5f}, + {+0.5f, +0.5f, -0.5f},{+0.5f, -0.5f, -0.5f},{-0.5f, -0.5f, -0.5f}, + {+0.5f, -0.5f, -0.5f},{+0.5f, +0.5f, -0.5f},{+0.5f, +0.5f, +0.5f}, + {+0.5f, +0.5f, +0.5f},{+0.5f, -0.5f, +0.5f},{+0.5f, -0.5f, -0.5f}, + {+0.5f, +0.5f, +0.5f},{-0.5f, +0.5f, +0.5f},{-0.5f, -0.5f, +0.5f}, + {+0.5f, +0.5f, +0.5f},{-0.5f, -0.5f, +0.5f},{+0.5f, -0.5f, +0.5f}, + {-0.5f, +0.5f, +0.5f},{-0.5f, +0.5f, -0.5f},{-0.5f, -0.5f, +0.5f}, + {-0.5f, +0.5f, -0.5f},{-0.5f, -0.5f, -0.5f},{-0.5f, -0.5f, +0.5f}, + {+0.5f, -0.5f, -0.5f},{-0.5f, -0.5f, +0.5f},{-0.5f, -0.5f, -0.5f}, + {+0.5f, -0.5f, -0.5f},{+0.5f, -0.5f, +0.5f},{-0.5f, -0.5f, +0.5f}, + {-0.5f, +0.5f, -0.5f},{-0.5f, +0.5f, +0.5f},{+0.5f, +0.5f, +0.5f}, + {-0.5f, +0.5f, -0.5f},{+0.5f, +0.5f, +0.5f},{+0.5f, +0.5f, -0.5f} }; Fvector du_box_vertices[DU_BOX_NUMVERTEX] = { - {-0.5f, -0.5f, -0.5f}, - {-0.5f, +0.5f, -0.5f}, - {+0.5f, +0.5f, -0.5f}, - {+0.5f, -0.5f, -0.5f}, - {-0.5f, +0.5f, +0.5f}, - {-0.5f, -0.5f, +0.5f}, - {+0.5f, +0.5f, +0.5f}, - {+0.5f, -0.5f, +0.5f}, + {-0.5f, -0.5f, -0.5f}, + {-0.5f, +0.5f, -0.5f}, + {+0.5f, +0.5f, -0.5f}, + {+0.5f, -0.5f, -0.5f}, + {-0.5f, +0.5f, +0.5f}, + {-0.5f, -0.5f, +0.5f}, + {+0.5f, +0.5f, +0.5f}, + {+0.5f, -0.5f, +0.5f}, }; WORD du_box_faces[DU_BOX_NUMFACES*3] = { - 0, 1, 2, 2, 3, 0, - 3, 2, 6, 6, 7, 3, - 6, 4, 5, 6, 5, 7, - 4, 1, 5, 1, 0, 5, - 3, 5, 0, 3, 7, 5, // bottom - 1, 4, 6, 1, 6, 2 // top + 0, 1, 2, 2, 3, 0, + 3, 2, 6, 6, 7, 3, + 6, 4, 5, 6, 5, 7, + 4, 1, 5, 1, 0, 5, + 3, 5, 0, 3, 7, 5, // bottom + 1, 4, 6, 1, 6, 2 // top }; WORD du_box_lines[DU_BOX_NUMLINES*2] = { - 0, 1, 1, 2, 2, 3, 3, 0, - 4, 5, 5, 7, 6, 7, 6, 4, - 0, 5, 1, 4, 2, 6, 3, 7 + 0, 1, 1, 2, 2, 3, 3, 0, + 4, 5, 5, 7, 6, 7, 6, 4, + 0, 5, 1, 4, 2, 6, 3, 7 }; diff --git a/src/editors/ECore/Editor/du_box.h b/src/editors/ECore/Editor/du_box.h index b4cc4f21591..4f99ffb4c1b 100644 --- a/src/editors/ECore/Editor/du_box.h +++ b/src/editors/ECore/Editor/du_box.h @@ -14,3 +14,4 @@ extern ECORE_API WORD du_box_lines[]; extern ECORE_API Fvector du_box_vertices2[]; #endif + diff --git a/src/editors/ECore/Editor/du_cone.cpp b/src/editors/ECore/Editor/du_cone.cpp index cc25a8262c2..0adadc01f1b 100644 --- a/src/editors/ECore/Editor/du_cone.cpp +++ b/src/editors/ECore/Editor/du_cone.cpp @@ -5,45 +5,45 @@ #include "du_cone.h" //--------------------------------------------------------------------------- //#pragma package(smart_init) -Fvector du_cone_vertices[DU_CONE_NUMVERTEX]= +Fvector du_cone_vertices[DU_CONE_NUMVERTEX] = { - {0.0000f, 0.0000f, 0.0000f}, - {0.5000f, 0.0000f, 1.0000f}, - {0.4619f, 0.1913f, 1.0000f}, - {0.3536f, 0.3536f, 1.0000f}, - {0.1913f, 0.4619f, 1.0000f}, - {-0.0000f, 0.5000f, 1.0000f}, - {-0.1913f, 0.4619f, 1.0000f}, - {-0.3536f, 0.3536f, 1.0000f}, - {-0.4619f, 0.1913f, 1.0000f}, - {-0.5000f, -0.0000f, 1.0000f}, - {-0.4619f, -0.1913f, 1.0000f}, - {-0.3536f, -0.3536f, 1.0000f}, - {-0.1913f, -0.4619f, 1.0000f}, - {0.0000f, -0.5000f, 1.0000f}, - {0.1913f, -0.4619f, 1.0000f}, - {0.3536f, -0.3536f, 1.0000f}, - {0.4619f, -0.1913f, 1.0000f}, - {0.0000f, 0.0000f, 1.0000f} + {0.0000f, 0.0000f, 0.0000f}, + {0.5000f, 0.0000f, 1.0000f}, + {0.4619f, 0.1913f, 1.0000f}, + {0.3536f, 0.3536f, 1.0000f}, + {0.1913f, 0.4619f, 1.0000f}, + {-0.0000f, 0.5000f, 1.0000f}, + {-0.1913f, 0.4619f, 1.0000f}, + {-0.3536f, 0.3536f, 1.0000f}, + {-0.4619f, 0.1913f, 1.0000f}, + {-0.5000f, -0.0000f, 1.0000f}, + {-0.4619f, -0.1913f, 1.0000f}, + {-0.3536f, -0.3536f, 1.0000f}, + {-0.1913f, -0.4619f, 1.0000f}, + {0.0000f, -0.5000f, 1.0000f}, + {0.1913f, -0.4619f, 1.0000f}, + {0.3536f, -0.3536f, 1.0000f}, + {0.4619f, -0.1913f, 1.0000f}, + {0.0000f, 0.0000f, 1.0000f} }; -WORD du_cone_faces[DU_CONE_NUMFACES*3]= +WORD du_cone_faces[DU_CONE_NUMFACES*3] = { - 0, 2, 1, - 0, 3, 2, - 0, 4, 3, - 0, 5, 4, - 0, 6, 5, - 0, 7, 6, - 0, 8, 7, - 0, 9, 8, - 0, 10, 9, + 0, 2, 1, + 0, 3, 2, + 0, 4, 3, + 0, 5, 4, + 0, 6, 5, + 0, 7, 6, + 0, 8, 7, + 0, 9, 8, + 0, 10, 9, 0, 11, 10, 0, 12, 11, 0, 13, 12, 0, 14, 13, 0, 15, 14, 0, 16, 15, - 0, 1, 16, + 0, 1, 16, 17, 1, 2, 17, 2, 3, 17, 3, 4, @@ -62,41 +62,42 @@ WORD du_cone_faces[DU_CONE_NUMFACES*3]= 17,16, 1 }; -WORD du_cone_lines[DU_CONE_NUMLINES*2]= +WORD du_cone_lines[DU_CONE_NUMLINES*2] = { - // tile - 0, 1, -// 0, 2, - 0, 3, -// 0, 4, - 0, 5, -// 0, 6, - 0, 7, -// 0, 8, - 0, 9, -// 0, 10, - 0, 11, -// 0, 12, - 0, 13, -// 0, 14, - 0, 15, -// 0, 16, - - // cape - 1, 2, - 2, 3, - 3, 4, - 4, 5, - 5, 6, - 6, 7, - 7, 8, - 8, 9, - 9, 10, - 10, 11, - 11, 12, - 12, 13, - 13, 14, - 14, 15, - 15, 16, - 16, 1, + // tile + 0, 1, + // 0, 2, + 0, 3, + // 0, 4, + 0, 5, + // 0, 6, + 0, 7, + // 0, 8, + 0, 9, + // 0, 10, + 0, 11, + // 0, 12, + 0, 13, + // 0, 14, + 0, 15, + // 0, 16, + + // cape + 1, 2, + 2, 3, + 3, 4, + 4, 5, + 5, 6, + 6, 7, + 7, 8, + 8, 9, + 9, 10, + 10, 11, + 11, 12, + 12, 13, + 13, 14, + 14, 15, + 15, 16, + 16, 1, }; + diff --git a/src/editors/ECore/Editor/du_cone.h b/src/editors/ECore/Editor/du_cone.h index 705024211f8..d0e87765928 100644 --- a/src/editors/ECore/Editor/du_cone.h +++ b/src/editors/ECore/Editor/du_cone.h @@ -11,3 +11,4 @@ extern ECORE_API Fvector du_cone_vertices[]; extern ECORE_API WORD du_cone_faces[]; extern ECORE_API WORD du_cone_lines[]; #endif + diff --git a/src/editors/ECore/Editor/du_cylinder.cpp b/src/editors/ECore/Editor/du_cylinder.cpp index ab2a9012c26..be2703a3cc0 100644 --- a/src/editors/ECore/Editor/du_cylinder.cpp +++ b/src/editors/ECore/Editor/du_cylinder.cpp @@ -5,125 +5,125 @@ #include "du_cylinder.h" //--------------------------------------------------------------------------- //#pragma package(smart_init) -Fvector du_cylinder_vertices[DU_CYLINDER_NUMVERTEX]={ - {0.5000f, 0.0000f, 0.5000f }, // 0 - {0.5000f, -0.0000f, -0.5000f}, // 1 - {0.4330f, -0.2500f, -0.5000f}, // 2 - {0.4330f, -0.2500f, 0.5000f }, // 3 - {0.2500f, -0.4330f, -0.5000f}, // 4 - {0.2500f, -0.4330f, 0.5000f }, // 5 - {0.0000f, -0.5000f, -0.5000f}, // 6 - {-0.0000f, -0.5000f, 0.5000f }, // 7 - {-0.2500f, -0.4330f, -0.5000f}, // 8 - {-0.2500f, -0.4330f, 0.5000f }, // 9 - {-0.4330f, -0.2500f, -0.5000f}, // 10 - {-0.4330f, -0.2500f, 0.5000f }, // 11 - {-0.5000f, -0.0000f, -0.5000f}, // 12 - {-0.5000f, 0.0000f, 0.5000f }, // 13 - {-0.4330f, 0.2500f, -0.5000f}, // 14 - {-0.4330f, 0.2500f, 0.5000f }, // 15 - {-0.2500f, 0.4330f, -0.5000f}, // 16 - {-0.2500f, 0.4330f, 0.5000f }, // 17 - {0.0000f, 0.5000f, -0.5000f}, // 18 - {-0.0000f, 0.5000f, 0.5000f }, // 19 - {0.2500f, 0.4330f, -0.5000f}, // 20 - {0.2500f, 0.4330f, 0.5000f }, // 21 - {0.4330f, 0.2500f, -0.5000f}, // 22 - {0.4330f, 0.2500f, 0.5000f }, // 23 - {-0.0000f, 0.0000f, 0.5000f }, // 24 - {0.0000f, -0.0000f, -0.5000f}, // 25 +Fvector du_cylinder_vertices[DU_CYLINDER_NUMVERTEX] = { + {0.5000f, 0.0000f, 0.5000f}, // 0 + {0.5000f, -0.0000f, -0.5000f}, // 1 + {0.4330f, -0.2500f, -0.5000f}, // 2 + {0.4330f, -0.2500f, 0.5000f}, // 3 + {0.2500f, -0.4330f, -0.5000f}, // 4 + {0.2500f, -0.4330f, 0.5000f}, // 5 + {0.0000f, -0.5000f, -0.5000f}, // 6 + {-0.0000f, -0.5000f, 0.5000f}, // 7 + {-0.2500f, -0.4330f, -0.5000f}, // 8 + {-0.2500f, -0.4330f, 0.5000f}, // 9 + {-0.4330f, -0.2500f, -0.5000f}, // 10 + {-0.4330f, -0.2500f, 0.5000f}, // 11 + {-0.5000f, -0.0000f, -0.5000f}, // 12 + {-0.5000f, 0.0000f, 0.5000f}, // 13 + {-0.4330f, 0.2500f, -0.5000f}, // 14 + {-0.4330f, 0.2500f, 0.5000f}, // 15 + {-0.2500f, 0.4330f, -0.5000f}, // 16 + {-0.2500f, 0.4330f, 0.5000f}, // 17 + {0.0000f, 0.5000f, -0.5000f}, // 18 + {-0.0000f, 0.5000f, 0.5000f}, // 19 + {0.2500f, 0.4330f, -0.5000f}, // 20 + {0.2500f, 0.4330f, 0.5000f}, // 21 + {0.4330f, 0.2500f, -0.5000f}, // 22 + {0.4330f, 0.2500f, 0.5000f}, // 23 + {-0.0000f, 0.0000f, 0.5000f}, // 24 + {0.0000f, -0.0000f, -0.5000f}, // 25 }; -u16 du_cylinder_faces[DU_CYLINDER_NUMFACES*3]={ - 0, 2, 1, - 3, 2, 0, - 3, 4, 2, - 5, 4, 3, - 5, 6, 4, - 7, 6, 5, - 8, 6, 9, - 9, 6, 7, - 10, 8, 11, - 11, 8, 9, - 12, 10, 13, - 13, 10, 11, - 14, 12, 15, - 12, 13, 15, - 16, 14, 17, - 17, 14, 15, - 18, 16, 19, - 19, 16, 17, - 19, 20, 18, - 21, 20, 19, - 21, 22, 20, - 23, 22, 21, - 23, 1, 22, - 23, 0, 1, - 23, 24, 0, - 21, 24, 23, - 19, 24, 21, - 17, 24, 19, - 15, 24, 17, - 13, 24, 15, - 11, 24, 13, - 9, 24, 11, - 7, 24, 9, - 5, 24, 7, - 3, 24, 5, - 0, 24, 3, - 8, 25, 6, - 10, 25, 8, - 12, 25, 10, - 14, 25, 12, - 16, 25, 14, - 18, 25, 16, - 20, 25, 18, - 22, 25, 20, - 1, 25, 22, - 2, 25, 1, - 4, 25, 2, - 6, 25, 4, +u16 du_cylinder_faces[DU_CYLINDER_NUMFACES*3] = { + 0, 2, 1, + 3, 2, 0, + 3, 4, 2, + 5, 4, 3, + 5, 6, 4, + 7, 6, 5, + 8, 6, 9, + 9, 6, 7, + 10, 8, 11, + 11, 8, 9, + 12, 10, 13, + 13, 10, 11, + 14, 12, 15, + 12, 13, 15, + 16, 14, 17, + 17, 14, 15, + 18, 16, 19, + 19, 16, 17, + 19, 20, 18, + 21, 20, 19, + 21, 22, 20, + 23, 22, 21, + 23, 1, 22, + 23, 0, 1, + 23, 24, 0, + 21, 24, 23, + 19, 24, 21, + 17, 24, 19, + 15, 24, 17, + 13, 24, 15, + 11, 24, 13, + 9, 24, 11, + 7, 24, 9, + 5, 24, 7, + 3, 24, 5, + 0, 24, 3, + 8, 25, 6, + 10, 25, 8, + 12, 25, 10, + 14, 25, 12, + 16, 25, 14, + 18, 25, 16, + 20, 25, 18, + 22, 25, 20, + 1, 25, 22, + 2, 25, 1, + 4, 25, 2, + 6, 25, 4, }; -u16 du_cylinder_lines[DU_CYLINDER_NUMLINES*2]={ -// tile - 0, 1, -// 2, 3, - 4, 5, -// 6, 7, - 8, 9, -// 10, 11, - 12, 13, -// 14, 15, - 16, 17, -// 18, 19, - 20, 21, -// 22, 23, -// cape 0 - 1, 2, - 2, 4, - 4, 6, - 6, 8, - 8, 10, - 10, 12, - 12, 14, - 14, 16, - 16, 18, - 18, 20, - 20, 22, - 22, 1, -// cape1 - 0, 3, - 3, 5, - 5, 7, - 7, 9, - 9, 11, - 11, 13, - 13, 15, - 15, 17, - 17, 19, - 19, 21, - 21, 23, - 23, 0, +u16 du_cylinder_lines[DU_CYLINDER_NUMLINES*2] = { + // tile + 0, 1, + // 2, 3, + 4, 5, + // 6, 7, + 8, 9, + // 10, 11, + 12, 13, + // 14, 15, + 16, 17, + // 18, 19, + 20, 21, + // 22, 23, + // cape 0 + 1, 2, + 2, 4, + 4, 6, + 6, 8, + 8, 10, + 10, 12, + 12, 14, + 14, 16, + 16, 18, + 18, 20, + 20, 22, + 22, 1, + // cape1 + 0, 3, + 3, 5, + 5, 7, + 7, 9, + 9, 11, + 11, 13, + 13, 15, + 15, 17, + 17, 19, + 19, 21, + 21, 23, + 23, 0, }; diff --git a/src/editors/ECore/Editor/du_cylinder.h b/src/editors/ECore/Editor/du_cylinder.h index 5ef010b6b2d..dce40eae8cd 100644 --- a/src/editors/ECore/Editor/du_cylinder.h +++ b/src/editors/ECore/Editor/du_cylinder.h @@ -11,3 +11,4 @@ extern ECORE_API u16 du_cylinder_faces[]; extern ECORE_API u16 du_cylinder_lines[]; #endif + diff --git a/src/editors/ECore/Editor/du_sphere.cpp b/src/editors/ECore/Editor/du_sphere.cpp index 082ae993288..3f5b675d6be 100644 --- a/src/editors/ECore/Editor/du_sphere.cpp +++ b/src/editors/ECore/Editor/du_sphere.cpp @@ -5,409 +5,409 @@ #include "du_sphere.h" //--------------------------------------------------------------------------- //#pragma package(smart_init) -Fvector du_sphere_vertices[DU_SPHERE_NUMVERTEX]={ - {0.0000f, 1.0000f, 0.0000f }, - {0.8944f, 0.4472f, 0.0000f }, - {0.2764f, 0.4472f, 0.8507f }, - {-0.7236f, 0.4472f, 0.5257f }, - {-0.7236f, 0.4472f, -0.5257f}, - {0.2764f, 0.4472f, -0.8507f}, - {0.7236f, -0.4472f, 0.5257f }, - {-0.2764f, -0.4472f, 0.8507f }, - {-0.8944f, -0.4472f, -0.0000f}, - {-0.2764f, -0.4472f, -0.8507f}, - {0.7236f, -0.4472f, -0.5257f}, - {0.0000f, -1.0000f, 0.0000f }, - {0.3607f, 0.9327f, 0.0000f }, - {0.6729f, 0.7397f, 0.0000f }, - {0.1115f, 0.9327f, 0.3431f }, - {0.2079f, 0.7397f, 0.6399f }, - {-0.2918f, 0.9327f, 0.2120f }, - {-0.5444f, 0.7397f, 0.3955f }, - {-0.2918f, 0.9327f, -0.2120f}, - {-0.5444f, 0.7397f, -0.3955f}, - {0.1115f, 0.9327f, -0.3431f}, - {0.2079f, 0.7397f, -0.6399f}, - {0.7844f, 0.5168f, 0.3431f }, - {0.5687f, 0.5168f, 0.6399f }, - {-0.0839f, 0.5168f, 0.8520f }, - {-0.4329f, 0.5168f, 0.7386f }, - {-0.8362f, 0.5168f, 0.1835f }, - {-0.8362f, 0.5168f, -0.1835f}, - {-0.4329f, 0.5168f, -0.7386f}, - {-0.0839f, 0.5168f, -0.8520f}, - {0.5687f, 0.5168f, -0.6399f}, - {0.7844f, 0.5168f, -0.3431f}, - {0.9647f, 0.1561f, 0.2120f }, - {0.9051f, -0.1561f, 0.3955f }, - {0.0965f, 0.1561f, 0.9830f }, - {-0.0965f, -0.1561f, 0.9830f }, - {-0.9051f, 0.1561f, 0.3955f }, - {-0.9647f, -0.1561f, 0.2120f }, - {-0.6558f, 0.1561f, -0.7386f}, - {-0.4998f, -0.1561f, -0.8520f}, - {0.4998f, 0.1561f, -0.8520f}, - {0.6558f, -0.1561f, -0.7386f}, - {0.9647f, 0.1561f, -0.2120f}, - {0.9051f, -0.1561f, -0.3955f}, - {0.4998f, 0.1561f, 0.8520f }, - {0.6558f, -0.1561f, 0.7386f }, - {-0.6558f, 0.1561f, 0.7386f }, - {-0.4998f, -0.1561f, 0.8520f }, - {-0.9051f, 0.1561f, -0.3955f}, - {-0.9647f, -0.1561f, -0.2120f}, - {0.0965f, 0.1561f, -0.9830f}, - {-0.0965f, -0.1561f, -0.9830f}, - {0.4329f, -0.5168f, 0.7386f }, - {0.0839f, -0.5168f, 0.8520f }, - {-0.5687f, -0.5168f, 0.6399f }, - {-0.7844f, -0.5168f, 0.3431f }, - {-0.7844f, -0.5168f, -0.3431f}, - {-0.5687f, -0.5168f, -0.6399f}, - {0.0839f, -0.5168f, -0.8520f}, - {0.4329f, -0.5168f, -0.7386f}, - {0.8362f, -0.5168f, -0.1835f}, - {0.8362f, -0.5168f, 0.1835f }, - {0.2918f, -0.9327f, 0.2120f }, - {0.5444f, -0.7397f, 0.3955f }, - {-0.1115f, -0.9327f, 0.3431f }, - {-0.2079f, -0.7397f, 0.6399f }, - {-0.3607f, -0.9327f, -0.0000f}, - {-0.6729f, -0.7397f, -0.0000f}, - {-0.1115f, -0.9327f, -0.3431f}, - {-0.2079f, -0.7397f, -0.6399f}, - {0.2918f, -0.9327f, -0.2120f}, - {0.5444f, -0.7397f, -0.3955f}, - {0.4795f, 0.8054f, 0.3484f }, - {-0.1832f, 0.8054f, 0.5637f }, - {-0.5927f, 0.8054f, -0.0000f}, - {-0.1832f, 0.8054f, -0.5637f}, - {0.4795f, 0.8054f, -0.3484f}, - {0.9855f, -0.1699f, 0.0000f }, - {0.3045f, -0.1699f, 0.9372f }, - {-0.7973f, -0.1699f, 0.5792f }, - {-0.7973f, -0.1699f, -0.5792f}, - {0.3045f, -0.1699f, -0.9372f}, - {0.7973f, 0.1699f, 0.5792f }, - {-0.3045f, 0.1699f, 0.9372f }, - {-0.9855f, 0.1699f, -0.0000f}, - {-0.3045f, 0.1699f, -0.9372f}, - {0.7973f, 0.1699f, -0.5792f}, - {0.1832f, -0.8054f, 0.5637f }, - {-0.4795f, -0.8054f, 0.3484f }, - {-0.4795f, -0.8054f, -0.3484f}, - {0.1832f, -0.8054f, -0.5637f}, - {0.5927f, -0.8054f, 0.0000 } +Fvector du_sphere_vertices[DU_SPHERE_NUMVERTEX] = { + {0.0000f, 1.0000f, 0.0000f}, + {0.8944f, 0.4472f, 0.0000f}, + {0.2764f, 0.4472f, 0.8507f}, + {-0.7236f, 0.4472f, 0.5257f}, + {-0.7236f, 0.4472f, -0.5257f}, + {0.2764f, 0.4472f, -0.8507f}, + {0.7236f, -0.4472f, 0.5257f}, + {-0.2764f, -0.4472f, 0.8507f}, + {-0.8944f, -0.4472f, -0.0000f}, + {-0.2764f, -0.4472f, -0.8507f}, + {0.7236f, -0.4472f, -0.5257f}, + {0.0000f, -1.0000f, 0.0000f}, + {0.3607f, 0.9327f, 0.0000f}, + {0.6729f, 0.7397f, 0.0000f}, + {0.1115f, 0.9327f, 0.3431f}, + {0.2079f, 0.7397f, 0.6399f}, + {-0.2918f, 0.9327f, 0.2120f}, + {-0.5444f, 0.7397f, 0.3955f}, + {-0.2918f, 0.9327f, -0.2120f}, + {-0.5444f, 0.7397f, -0.3955f}, + {0.1115f, 0.9327f, -0.3431f}, + {0.2079f, 0.7397f, -0.6399f}, + {0.7844f, 0.5168f, 0.3431f}, + {0.5687f, 0.5168f, 0.6399f}, + {-0.0839f, 0.5168f, 0.8520f}, + {-0.4329f, 0.5168f, 0.7386f}, + {-0.8362f, 0.5168f, 0.1835f}, + {-0.8362f, 0.5168f, -0.1835f}, + {-0.4329f, 0.5168f, -0.7386f}, + {-0.0839f, 0.5168f, -0.8520f}, + {0.5687f, 0.5168f, -0.6399f}, + {0.7844f, 0.5168f, -0.3431f}, + {0.9647f, 0.1561f, 0.2120f}, + {0.9051f, -0.1561f, 0.3955f}, + {0.0965f, 0.1561f, 0.9830f}, + {-0.0965f, -0.1561f, 0.9830f}, + {-0.9051f, 0.1561f, 0.3955f}, + {-0.9647f, -0.1561f, 0.2120f}, + {-0.6558f, 0.1561f, -0.7386f}, + {-0.4998f, -0.1561f, -0.8520f}, + {0.4998f, 0.1561f, -0.8520f}, + {0.6558f, -0.1561f, -0.7386f}, + {0.9647f, 0.1561f, -0.2120f}, + {0.9051f, -0.1561f, -0.3955f}, + {0.4998f, 0.1561f, 0.8520f}, + {0.6558f, -0.1561f, 0.7386f}, + {-0.6558f, 0.1561f, 0.7386f}, + {-0.4998f, -0.1561f, 0.8520f}, + {-0.9051f, 0.1561f, -0.3955f}, + {-0.9647f, -0.1561f, -0.2120f}, + {0.0965f, 0.1561f, -0.9830f}, + {-0.0965f, -0.1561f, -0.9830f}, + {0.4329f, -0.5168f, 0.7386f}, + {0.0839f, -0.5168f, 0.8520f}, + {-0.5687f, -0.5168f, 0.6399f}, + {-0.7844f, -0.5168f, 0.3431f}, + {-0.7844f, -0.5168f, -0.3431f}, + {-0.5687f, -0.5168f, -0.6399f}, + {0.0839f, -0.5168f, -0.8520f}, + {0.4329f, -0.5168f, -0.7386f}, + {0.8362f, -0.5168f, -0.1835f}, + {0.8362f, -0.5168f, 0.1835f}, + {0.2918f, -0.9327f, 0.2120f}, + {0.5444f, -0.7397f, 0.3955f}, + {-0.1115f, -0.9327f, 0.3431f}, + {-0.2079f, -0.7397f, 0.6399f}, + {-0.3607f, -0.9327f, -0.0000f}, + {-0.6729f, -0.7397f, -0.0000f}, + {-0.1115f, -0.9327f, -0.3431f}, + {-0.2079f, -0.7397f, -0.6399f}, + {0.2918f, -0.9327f, -0.2120f}, + {0.5444f, -0.7397f, -0.3955f}, + {0.4795f, 0.8054f, 0.3484f}, + {-0.1832f, 0.8054f, 0.5637f}, + {-0.5927f, 0.8054f, -0.0000f}, + {-0.1832f, 0.8054f, -0.5637f}, + {0.4795f, 0.8054f, -0.3484f}, + {0.9855f, -0.1699f, 0.0000f}, + {0.3045f, -0.1699f, 0.9372f}, + {-0.7973f, -0.1699f, 0.5792f}, + {-0.7973f, -0.1699f, -0.5792f}, + {0.3045f, -0.1699f, -0.9372f}, + {0.7973f, 0.1699f, 0.5792f}, + {-0.3045f, 0.1699f, 0.9372f}, + {-0.9855f, 0.1699f, -0.0000f}, + {-0.3045f, 0.1699f, -0.9372f}, + {0.7973f, 0.1699f, -0.5792f}, + {0.1832f, -0.8054f, 0.5637f}, + {-0.4795f, -0.8054f, 0.3484f}, + {-0.4795f, -0.8054f, -0.3484f}, + {0.1832f, -0.8054f, -0.5637f}, + {0.5927f, -0.8054f, 0.0000} }; -WORD du_sphere_faces[DU_SPHERE_NUMFACES*3]={ - 14, 12, 0, - 72, 13, 12, - 14, 72, 12, - 15, 72, 14, - 22, 1, 13, - 72, 22, 13, - 23, 22, 72, - 15, 23, 72, - 2, 23, 15, - 16, 14, 0, - 73, 15, 14, - 16, 73, 14, - 17, 73, 16, - 24, 2, 15, - 73, 24, 15, - 25, 24, 73, - 17, 25, 73, - 3, 25, 17, - 18, 16, 0, - 74, 17, 16, - 18, 74, 16, - 19, 74, 18, - 26, 3, 17, - 74, 26, 17, - 27, 26, 74, - 19, 27, 74, - 4, 27, 19, - 20, 18, 0, - 75, 19, 18, - 20, 75, 18, - 21, 75, 20, - 28, 4, 19, - 75, 28, 19, - 29, 28, 75, - 21, 29, 75, - 5, 29, 21, - 12, 20, 0, - 76, 21, 20, - 12, 76, 20, - 13, 76, 12, - 30, 5, 21, - 76, 30, 21, - 31, 30, 76, - 13, 31, 76, - 1, 31, 13, - 32, 42, 1, - 77, 43, 42, - 32, 77, 42, - 33, 77, 32, - 60, 10, 43, - 77, 60, 43, - 61, 60, 77, - 33, 61, 77, - 6, 61, 33, - 34, 44, 2, - 78, 45, 44, - 34, 78, 44, - 35, 78, 34, - 52, 6, 45, - 78, 52, 45, - 53, 52, 78, - 35, 53, 78, - 7, 53, 35, - 36, 46, 3, - 79, 47, 46, - 36, 79, 46, - 37, 79, 36, - 54, 7, 47, - 79, 54, 47, - 55, 54, 79, - 37, 55, 79, - 8, 55, 37, - 38, 48, 4, - 80, 49, 48, - 38, 80, 48, - 39, 80, 38, - 56, 8, 49, - 80, 56, 49, - 57, 56, 80, - 39, 57, 80, - 9, 57, 39, - 40, 50, 5, - 81, 51, 50, - 40, 81, 50, - 41, 81, 40, - 58, 9, 51, - 81, 58, 51, - 59, 58, 81, - 41, 59, 81, - 10, 59, 41, - 33, 45, 6, - 82, 44, 45, - 33, 82, 45, - 32, 82, 33, - 23, 2, 44, - 82, 23, 44, - 22, 23, 82, - 32, 22, 82, - 1, 22, 32, - 35, 47, 7, - 83, 46, 47, - 35, 83, 47, - 34, 83, 35, - 25, 3, 46, - 83, 25, 46, - 24, 25, 83, - 34, 24, 83, - 2, 24, 34, - 37, 49, 8, - 84, 48, 49, - 37, 84, 49, - 36, 84, 37, - 27, 4, 48, - 84, 27, 48, - 26, 27, 84, - 36, 26, 84, - 3, 26, 36, - 39, 51, 9, - 85, 50, 51, - 39, 85, 51, - 38, 85, 39, - 29, 5, 50, - 85, 29, 50, - 28, 29, 85, - 38, 28, 85, - 4, 28, 38, - 41, 43, 10, - 86, 42, 43, - 41, 86, 43, - 40, 86, 41, - 31, 1, 42, - 86, 31, 42, - 30, 31, 86, - 40, 30, 86, - 5, 30, 40, - 62, 64, 11, - 87, 65, 64, - 62, 87, 64, - 63, 87, 62, - 53, 7, 65, - 87, 53, 65, - 52, 53, 87, - 63, 52, 87, - 6, 52, 63, - 64, 66, 11, - 88, 67, 66, - 64, 88, 66, - 65, 88, 64, - 55, 8, 67, - 88, 55, 67, - 54, 55, 88, - 65, 54, 88, - 7, 54, 65, - 66, 68, 11, - 89, 69, 68, - 66, 89, 68, - 67, 89, 66, - 57, 9, 69, - 89, 57, 69, - 56, 57, 89, - 67, 56, 89, - 8, 56, 67, - 68, 70, 11, - 90, 71, 70, - 68, 90, 70, - 69, 90, 68, - 59, 10, 71, - 90, 59, 71, - 58, 59, 90, - 69, 58, 90, - 9, 58, 69, - 70, 62, 11, - 91, 63, 62, - 70, 91, 62, - 71, 91, 70, - 61, 6, 63, - 91, 61, 63, - 60, 61, 91, - 71, 60, 91, - 10, 60, 71, +WORD du_sphere_faces[DU_SPHERE_NUMFACES*3] = { + 14, 12, 0, + 72, 13, 12, + 14, 72, 12, + 15, 72, 14, + 22, 1, 13, + 72, 22, 13, + 23, 22, 72, + 15, 23, 72, + 2, 23, 15, + 16, 14, 0, + 73, 15, 14, + 16, 73, 14, + 17, 73, 16, + 24, 2, 15, + 73, 24, 15, + 25, 24, 73, + 17, 25, 73, + 3, 25, 17, + 18, 16, 0, + 74, 17, 16, + 18, 74, 16, + 19, 74, 18, + 26, 3, 17, + 74, 26, 17, + 27, 26, 74, + 19, 27, 74, + 4, 27, 19, + 20, 18, 0, + 75, 19, 18, + 20, 75, 18, + 21, 75, 20, + 28, 4, 19, + 75, 28, 19, + 29, 28, 75, + 21, 29, 75, + 5, 29, 21, + 12, 20, 0, + 76, 21, 20, + 12, 76, 20, + 13, 76, 12, + 30, 5, 21, + 76, 30, 21, + 31, 30, 76, + 13, 31, 76, + 1, 31, 13, + 32, 42, 1, + 77, 43, 42, + 32, 77, 42, + 33, 77, 32, + 60, 10, 43, + 77, 60, 43, + 61, 60, 77, + 33, 61, 77, + 6, 61, 33, + 34, 44, 2, + 78, 45, 44, + 34, 78, 44, + 35, 78, 34, + 52, 6, 45, + 78, 52, 45, + 53, 52, 78, + 35, 53, 78, + 7, 53, 35, + 36, 46, 3, + 79, 47, 46, + 36, 79, 46, + 37, 79, 36, + 54, 7, 47, + 79, 54, 47, + 55, 54, 79, + 37, 55, 79, + 8, 55, 37, + 38, 48, 4, + 80, 49, 48, + 38, 80, 48, + 39, 80, 38, + 56, 8, 49, + 80, 56, 49, + 57, 56, 80, + 39, 57, 80, + 9, 57, 39, + 40, 50, 5, + 81, 51, 50, + 40, 81, 50, + 41, 81, 40, + 58, 9, 51, + 81, 58, 51, + 59, 58, 81, + 41, 59, 81, + 10, 59, 41, + 33, 45, 6, + 82, 44, 45, + 33, 82, 45, + 32, 82, 33, + 23, 2, 44, + 82, 23, 44, + 22, 23, 82, + 32, 22, 82, + 1, 22, 32, + 35, 47, 7, + 83, 46, 47, + 35, 83, 47, + 34, 83, 35, + 25, 3, 46, + 83, 25, 46, + 24, 25, 83, + 34, 24, 83, + 2, 24, 34, + 37, 49, 8, + 84, 48, 49, + 37, 84, 49, + 36, 84, 37, + 27, 4, 48, + 84, 27, 48, + 26, 27, 84, + 36, 26, 84, + 3, 26, 36, + 39, 51, 9, + 85, 50, 51, + 39, 85, 51, + 38, 85, 39, + 29, 5, 50, + 85, 29, 50, + 28, 29, 85, + 38, 28, 85, + 4, 28, 38, + 41, 43, 10, + 86, 42, 43, + 41, 86, 43, + 40, 86, 41, + 31, 1, 42, + 86, 31, 42, + 30, 31, 86, + 40, 30, 86, + 5, 30, 40, + 62, 64, 11, + 87, 65, 64, + 62, 87, 64, + 63, 87, 62, + 53, 7, 65, + 87, 53, 65, + 52, 53, 87, + 63, 52, 87, + 6, 52, 63, + 64, 66, 11, + 88, 67, 66, + 64, 88, 66, + 65, 88, 64, + 55, 8, 67, + 88, 55, 67, + 54, 55, 88, + 65, 54, 88, + 7, 54, 65, + 66, 68, 11, + 89, 69, 68, + 66, 89, 68, + 67, 89, 66, + 57, 9, 69, + 89, 57, 69, + 56, 57, 89, + 67, 56, 89, + 8, 56, 67, + 68, 70, 11, + 90, 71, 70, + 68, 90, 70, + 69, 90, 68, + 59, 10, 71, + 90, 59, 71, + 58, 59, 90, + 69, 58, 90, + 9, 58, 69, + 70, 62, 11, + 91, 63, 62, + 70, 91, 62, + 71, 91, 70, + 61, 6, 63, + 91, 61, 63, + 60, 61, 91, + 71, 60, 91, + 10, 60, 71, }; -Fvector du_sphere_verticesl[DU_SPHERE_NUMVERTEXL]={ - {0, -1.0, 0 }, - {0.309018f, -0.951056f, 0 }, - {0.587786f, -0.809018f, 0 }, - {0.809018f, -0.587786f, 0 }, - {0.951056f, -0.309018f, 0 }, - {1.0, 0, 0 }, - {0.951056f, 0.309018f, 0 }, - {0.809018f, 0.587786f, 0 }, - {0.587786f, 0.809018f, 0 }, - {0.309018f, 0.951056f, 0 }, - {0, 1.0, 0 }, - {-0.309018f, 0.951056f, 0 }, - {-0.587786f, 0.809018f, 0 }, - {-0.809018f, 0.587786f, 0 }, - {-0.951056f, 0.309018f, 0 }, - {-1.0, 0, 0 }, - {-0.951056f, -0.309018f,0 }, - {-0.809018f, -0.587786f,0 }, - {-0.587786f, -0.809018f,0 }, - {-0.309018f, -0.951056f,0 }, - {1.0, 0, 0 }, - {0.951056f, 0, -0.309018f}, - {0.809018f, 0, -0.587786f}, - {0.587786f, 0, -0.809018f}, - {0.309018f, 0, -0.951056f}, - {0, 0, -1.0 }, - {-0.309018f, 0, -0.951056f}, - {-0.587786f, 0, -0.809018f}, - {-0.809018f, 0, -0.587786f}, - {-0.951056f, 0, -0.309018f}, - {-1.0, 0, 0 }, - {-0.951056f, 0, 0.309018f }, - {-0.809018f, 0, 0.587786f }, - {-0.587786f, 0, 0.809018f }, - {-0.309018f, 0, 0.951056f }, - {0, 0, 1.0 }, - {0.309018f, 0, 0.951056f }, - {0.587786f, 0, 0.809018f }, - {0.809018f, 0, 0.587786f }, - {0.951056f, 0, 0.309018f }, - {0, -1.0, 0 }, - {0, -0.951056f, -0.309018f}, - {0, -0.809018f, -0.587786f}, - {0, -0.587786f, -0.809018f}, - {0, -0.309018f, -0.951056f}, - {0, 0, -1.0 }, - {0, 0.309018f, -0.951056f}, - {0, 0.587786f, -0.809018f}, - {0, 0.809018f, -0.587786f}, - {0, 0.951056f, -0.309018f}, - {0, 1.0, 0 }, - {0, 0.951056f, 0.309018f }, - {0, 0.809018f, 0.587786f }, - {0, 0.587786f, 0.809018f }, - {0, 0.309018f, 0.951056f }, - {0, 0, 1.0 }, - {0, -0.309018f, 0.951056f }, - {0, -0.587786f, 0.809018f }, - {0, -0.809018f, 0.587786f }, - {0, -0.951056f, 0.309018f }, +Fvector du_sphere_verticesl[DU_SPHERE_NUMVERTEXL] = { + {0, -1.0, 0}, + {0.309018f, -0.951056f, 0}, + {0.587786f, -0.809018f, 0}, + {0.809018f, -0.587786f, 0}, + {0.951056f, -0.309018f, 0}, + {1.0, 0, 0}, + {0.951056f, 0.309018f, 0}, + {0.809018f, 0.587786f, 0}, + {0.587786f, 0.809018f, 0}, + {0.309018f, 0.951056f, 0}, + {0, 1.0, 0}, + {-0.309018f, 0.951056f, 0}, + {-0.587786f, 0.809018f, 0}, + {-0.809018f, 0.587786f, 0}, + {-0.951056f, 0.309018f, 0}, + {-1.0, 0, 0}, + {-0.951056f, -0.309018f,0}, + {-0.809018f, -0.587786f,0}, + {-0.587786f, -0.809018f,0}, + {-0.309018f, -0.951056f,0}, + {1.0, 0, 0}, + {0.951056f, 0, -0.309018f}, + {0.809018f, 0, -0.587786f}, + {0.587786f, 0, -0.809018f}, + {0.309018f, 0, -0.951056f}, + {0, 0, -1.0}, + {-0.309018f, 0, -0.951056f}, + {-0.587786f, 0, -0.809018f}, + {-0.809018f, 0, -0.587786f}, + {-0.951056f, 0, -0.309018f}, + {-1.0, 0, 0}, + {-0.951056f, 0, 0.309018f}, + {-0.809018f, 0, 0.587786f}, + {-0.587786f, 0, 0.809018f}, + {-0.309018f, 0, 0.951056f}, + {0, 0, 1.0}, + {0.309018f, 0, 0.951056f}, + {0.587786f, 0, 0.809018f}, + {0.809018f, 0, 0.587786f}, + {0.951056f, 0, 0.309018f}, + {0, -1.0, 0}, + {0, -0.951056f, -0.309018f}, + {0, -0.809018f, -0.587786f}, + {0, -0.587786f, -0.809018f}, + {0, -0.309018f, -0.951056f}, + {0, 0, -1.0}, + {0, 0.309018f, -0.951056f}, + {0, 0.587786f, -0.809018f}, + {0, 0.809018f, -0.587786f}, + {0, 0.951056f, -0.309018f}, + {0, 1.0, 0}, + {0, 0.951056f, 0.309018f}, + {0, 0.809018f, 0.587786f}, + {0, 0.587786f, 0.809018f}, + {0, 0.309018f, 0.951056f}, + {0, 0, 1.0}, + {0, -0.309018f, 0.951056f}, + {0, -0.587786f, 0.809018f}, + {0, -0.809018f, 0.587786f}, + {0, -0.951056f, 0.309018f}, }; -WORD du_sphere_lines[DU_SPHERE_NUMLINES*2]={ - 0, 1, - 1, 2, - 2, 3, - 3, 4, - 4, 5, - 5, 6, - 6, 7, - 7, 8, - 8, 9, - 9, 10, - 10, 11, - 11, 12, - 12, 13, - 13, 14, - 14, 15, - 15, 16, - 16, 17, - 17, 18, - 18, 19, - 19, 0, +WORD du_sphere_lines[DU_SPHERE_NUMLINES*2] = { + 0, 1, + 1, 2, + 2, 3, + 3, 4, + 4, 5, + 5, 6, + 6, 7, + 7, 8, + 8, 9, + 9, 10, + 10, 11, + 11, 12, + 12, 13, + 13, 14, + 14, 15, + 15, 16, + 16, 17, + 17, 18, + 18, 19, + 19, 0, - 20, 21, - 21, 22, - 22, 23, - 23, 24, - 24, 25, - 25, 26, - 26, 27, - 27, 28, - 28, 29, - 29, 30, - 30, 31, - 31, 32, - 32, 33, - 33, 34, - 34, 35, - 35, 36, - 36, 37, - 37, 38, - 38, 39, - 39, 20, - - 40, 41, - 41, 42, - 42, 43, - 43, 44, - 44, 45, - 45, 46, - 46, 47, - 47, 48, - 48, 49, - 49, 50, - 50, 51, - 51, 52, - 52, 53, - 53, 54, - 54, 55, - 55, 56, - 56, 57, - 57, 58, - 58, 59, - 59, 40, + 20, 21, + 21, 22, + 22, 23, + 23, 24, + 24, 25, + 25, 26, + 26, 27, + 27, 28, + 28, 29, + 29, 30, + 30, 31, + 31, 32, + 32, 33, + 33, 34, + 34, 35, + 35, 36, + 36, 37, + 37, 38, + 38, 39, + 39, 20, + + 40, 41, + 41, 42, + 42, 43, + 43, 44, + 44, 45, + 45, 46, + 46, 47, + 47, 48, + 48, 49, + 49, 50, + 50, 51, + 51, 52, + 52, 53, + 53, 54, + 54, 55, + 55, 56, + 56, 57, + 57, 58, + 58, 59, + 59, 40, }; diff --git a/src/editors/ECore/Editor/du_sphere.h b/src/editors/ECore/Editor/du_sphere.h index 39c7eb4af1c..799f513a29b 100644 --- a/src/editors/ECore/Editor/du_sphere.h +++ b/src/editors/ECore/Editor/du_sphere.h @@ -13,3 +13,4 @@ extern ECORE_API Fvector du_sphere_verticesl[]; extern ECORE_API WORD du_sphere_lines[]; #endif + diff --git a/src/editors/ECore/Editor/du_sphere_part.cpp b/src/editors/ECore/Editor/du_sphere_part.cpp new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Editor/du_sphere_part.cpp @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Editor/du_sphere_part.h b/src/editors/ECore/Editor/du_sphere_part.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Editor/du_sphere_part.h @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Editor/engine.h b/src/editors/ECore/Editor/engine.h index 491a4f4dd84..5f0e3c53268 100644 --- a/src/editors/ECore/Editor/engine.h +++ b/src/editors/ECore/Editor/engine.h @@ -7,24 +7,24 @@ #pragma once #include "ELog.h" -#include "../../../xrCPU_Pipe/xrCPU_Pipe.h" class ENGINE_API CEngine { - HMODULE hPSGP; -public: - CEngine (); - ~CEngine (); + HMODULE hPSGP; + public: + CEngine(); + ~CEngine(); - void Initialize (); - void Destroy (); - LPCSTR LastWindowsError(); + void Initialize(); + void Destroy(); + LPCSTR LastWindowsError(); - void ReloadSettings (); + void ReloadSettings(); }; -ENGINE_API extern xrDispatchTable PSGP; -ENGINE_API extern CEngine Engine; +ENGINE_API extern CEngine Engine; #endif // !defined(AFX_ENGINE_H__22802DD7_D7EB_4234_9781_E237657471AC__INCLUDED_) + + diff --git a/src/editors/ECore/Editor/itterate_adjacents_dynamic.h b/src/editors/ECore/Editor/itterate_adjacents_dynamic.h index 7c7c2886a27..ff00538cb48 100644 --- a/src/editors/ECore/Editor/itterate_adjacents_dynamic.h +++ b/src/editors/ECore/Editor/itterate_adjacents_dynamic.h @@ -1,7 +1,7 @@ #ifndef _ITTERATE_ADJACENTS_DYNAMIC_H_ #define _ITTERATE_ADJACENTS_DYNAMIC_H_ -#include "common/face_smoth_flags.h" +#include "Common/face_smoth_flags.h" template struct itterate_adjacents_params_dynamic diff --git a/src/editors/ECore/Editor/lwo2.h b/src/editors/ECore/Editor/lwo2.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Editor/lwo2.h @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Editor/pDomain.cpp b/src/editors/ECore/Editor/pDomain.cpp index 8924972f83e..e18e01e0039 100644 --- a/src/editors/ECore/Editor/pDomain.cpp +++ b/src/editors/ECore/Editor/pDomain.cpp @@ -1,84 +1,82 @@ #include "stdafx.h" #pragma hdrstop -#include "d3dutils.h" +#include "D3DUtils.h" #include "ui_main.h" -#include "../../xrServerEntities/PropertiesListHelper.h" +#include "xrServerEntities/PropertiesListHelper.h" #include "ParticleEffectActions.h" using namespace PAPI; -PDomain::PDomain(EType et, BOOL ra, u32 color, PDomainEnum t, - float inA0, float inA1, float inA2, - float inA3, float inA4, float inA5, - float inA6, float inA7, float inA8 ) +PDomain::PDomain(EType et, BOOL ra, u32 color, PDomainEnum t, + float inA0, float inA1, float inA2, + float inA3, float inA4, float inA5, + float inA6, float inA7, float inA8) { - flags.set(flRenderable,ra); - e_type = et; - type = t; - clr = color; - f[0] = inA0; - f[1] = inA1; - f[2] = inA2; - f[3] = inA3; - f[4] = inA4; - f[5] = inA5; - f[6] = inA6; - f[7] = inA7; - f[8] = inA8; + flags.set(flRenderable, ra); + e_type = et; + type = t; + clr = color; + f[0] = inA0; + f[1] = inA1; + f[2] = inA2; + f[3] = inA3; + f[4] = inA4; + f[5] = inA5; + f[6] = inA6; + f[7] = inA7; + f[8] = inA8; } -PDomain::PDomain(const PDomain& inDomain) +PDomain::PDomain(const PDomain &inDomain) { - e_type = inDomain.e_type; - flags = inDomain.flags; - type = inDomain.type; - clr = inDomain.clr; - f[0] = inDomain.f[0]; - f[1] = inDomain.f[1]; - f[2] = inDomain.f[2]; - f[3] = inDomain.f[3]; - f[4] = inDomain.f[4]; - f[5] = inDomain.f[5]; - f[6] = inDomain.f[6]; - f[7] = inDomain.f[7]; - f[8] = inDomain.f[8]; + e_type = inDomain.e_type; + flags = inDomain.flags; + type = inDomain.type; + clr = inDomain.clr; + f[0] = inDomain.f[0]; + f[1] = inDomain.f[1]; + f[2] = inDomain.f[2]; + f[3] = inDomain.f[3]; + f[4] = inDomain.f[4]; + f[5] = inDomain.f[5]; + f[6] = inDomain.f[6]; + f[7] = inDomain.f[7]; + f[8] = inDomain.f[8]; } -PDomain::~PDomain() -{ -} +PDomain::~PDomain() {} -void PDomain::Load(IReader& F) +void PDomain::Load(IReader &F) { - type = PDomainEnum(F.r_u32()); - F.r_fvector3(v[0]); - F.r_fvector3(v[1]); - F.r_fvector3(v[2]); + type = PDomainEnum(F.r_u32()); + F.r_fvector3(v[0]); + F.r_fvector3(v[1]); + F.r_fvector3(v[2]); } -void PDomain::Load2(CInifile& ini, const shared_str& sect) +void PDomain::Load2(CInifile &ini, const shared_str §) { - type = PDomainEnum(ini.r_u32(sect,"type")); - v[0] = ini.r_fvector3(sect,"v0"); - v[1] = ini.r_fvector3(sect,"v1"); - v[2] = ini.r_fvector3(sect,"v2"); + type = PDomainEnum(ini.r_u32(sect, "type")); + v[0] = ini.r_fvector3(sect, "v0"); + v[1] = ini.r_fvector3(sect, "v1"); + v[2] = ini.r_fvector3(sect, "v2"); } -void PDomain::Save(IWriter& F) +void PDomain::Save(IWriter &F) { - F.w_u32 (type); - F.w_fvector3(v[0]); - F.w_fvector3(v[1]); - F.w_fvector3(v[2]); + F.w_u32(type); + F.w_fvector3(v[0]); + F.w_fvector3(v[1]); + F.w_fvector3(v[2]); } -void PDomain::Save2(CInifile& ini, const shared_str& sect) +void PDomain::Save2(CInifile &ini, const shared_str §) { - ini.w_u32 (sect.c_str(), "type", type); - ini.w_fvector3 (sect.c_str(), "v0", v[0]); - ini.w_fvector3 (sect.c_str(), "v1", v[1]); - ini.w_fvector3 (sect.c_str(), "v2", v[2]); + ini.w_u32(sect.c_str(), "type", type); + ini.w_fvector3(sect.c_str(), "v0", v[0]); + ini.w_fvector3(sect.c_str(), "v1", v[1]); + ini.w_fvector3(sect.c_str(), "v2", v[2]); } /* @@ -86,298 +84,411 @@ void PDomain::set(PAPI::PDomainEnum t, float inA0, float inA1, float inA2, float inA3, float inA4, float inA5, float inA6, float inA7, float inA8 ) { - type = t; - f[0] = inA0; - f[1] = inA1; - f[2] = inA2; - f[3] = inA3; - f[4] = inA4; - f[5] = inA5; - f[6] = inA6; - f[7] = inA7; - f[8] = inA8; + type = t; + f[0] = inA0; + f[1] = inA1; + f[2] = inA2; + f[3] = inA3; + f[4] = inA4; + f[5] = inA5; + f[6] = inA6; + f[7] = inA7; + f[8] = inA8; } */ //-------------------------------------------------------------------- -void PDomain::Render (u32 clr, const Fmatrix& parent) +void PDomain::Render(u32 clr, const Fmatrix &parent) { - if (!flags.is(flRenderable)) return; - u32 clr_s = subst_alpha (clr,0x60); - u32 clr_w = subst_alpha (clr,0xff); - RCache.set_xform_world (parent); - switch(type){ - case PDPoint: - EDevice.SetShader (EDevice.m_WireShader); - DU_impl.DrawCross (v[0], 0.05f,0.05f,0.05f, 0.05f,0.05f,0.05f, clr_w); - break; - case PDLine: - EDevice.SetShader (EDevice.m_WireShader); - DU_impl.DrawCross (v[0], 0.05f,0.05f,0.05f, 0.05f,0.05f,0.05f, clr_w); - DU_impl.DrawCross (v[1], 0.05f,0.05f,0.05f, 0.05f,0.05f,0.05f, clr_w); - DU_impl.DrawLine (v[0], v[1], clr_w); - break; - case PDTriangle: - EDevice.SetShader (EDevice.m_SelectionShader); - DU_impl.DrawFace (v[0], v[1], v[2], clr_s, clr_w, true, true); - break; - case PDPlane:{ - EDevice.SetShader (EDevice.m_SelectionShader); - Fvector2 sz = {100.f,100.f}; - DU_impl.DrawPlane (v[0],v[1],sz,clr_s,clr_w,true,true,true); - }break; - case PDBox: - EDevice.SetShader (EDevice.m_SelectionShader); - DU_impl.DrawAABB (v[0], v[1], clr_s, clr_w, true, true); - break; - case PDSphere: - DU_impl.DrawSphere (parent, v[0], f[4], clr_s, clr_w, true, true); - DU_impl.DrawSphere (parent, v[0], f[3], clr_s, clr_w, true, true); - break; - case PDCylinder:{ - Fvector c,d; - float h = d.sub(v[1],v[0]).magnitude(); - c.add (v[0],v[1]).div(2.f); - if (!fis_zero(h)){ - d.div (h); - DU_impl.DrawCylinder (parent, c, d, h, f[6], clr_s, clr_w, true, true); - DU_impl.DrawCylinder (parent, c, d, h, f[7], clr_s, clr_w, true, true); + if (!flags.is(flRenderable)) + return; + u32 clr_s = subst_alpha(clr, 0x60); + u32 clr_w = subst_alpha(clr, 0xff); + RCache.set_xform_world(parent); + switch (type) + { + case PDPoint: + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawCross(v[0], 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, clr_w); + break; + case PDLine: + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawCross(v[0], 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, clr_w); + DU_impl.DrawCross(v[1], 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, clr_w); + DU_impl.DrawLine(v[0], v[1], clr_w); + break; + case PDTriangle: + EDevice.SetShader(EDevice.m_SelectionShader); + DU_impl.DrawFace(v[0], v[1], v[2], clr_s, clr_w, true, true); + break; + case PDPlane: + { + EDevice.SetShader(EDevice.m_SelectionShader); + Fvector2 sz = {100.f,100.f}; + DU_impl.DrawPlane(v[0], v[1], sz, clr_s, clr_w, true, true, true); + } + break; + case PDBox: + EDevice.SetShader(EDevice.m_SelectionShader); + DU_impl.DrawAABB(v[0], v[1], clr_s, clr_w, true, true); + break; + case PDSphere: + DU_impl.DrawSphere(parent, v[0], f[4], clr_s, clr_w, true, true); + DU_impl.DrawSphere(parent, v[0], f[3], clr_s, clr_w, true, true); + break; + case PDCylinder: + { + Fvector c, d; + float h = d.sub(v[1], v[0]).magnitude(); + c.add(v[0], v[1]).div(2.f); + if (!fis_zero(h)) + { + d.div(h); + DU_impl.DrawCylinder(parent, c, d, h, f[6], clr_s, clr_w, true, true); + DU_impl.DrawCylinder(parent, c, d, h, f[7], clr_s, clr_w, true, true); + } } - }break; - case PDCone:{ - Fvector d; - float h = d.sub(v[1],v[0]).magnitude(); - if (!fis_zero(h)){ - d.div (h); - DU_impl.DrawCone (parent, v[0], d, h, f[6], clr_s, clr_w, true, true); - DU_impl.DrawCone (parent, v[0], d, h, f[7], clr_s, clr_w, true, true); + break; + case PDCone: + { + Fvector d; + float h = d.sub(v[1], v[0]).magnitude(); + if (!fis_zero(h)) + { + d.div(h); + DU_impl.DrawCone(parent, v[0], d, h, f[6], clr_s, clr_w, true, true); + DU_impl.DrawCone(parent, v[0], d, h, f[7], clr_s, clr_w, true, true); + } } - }break; - case PDBlob: - EDevice.SetShader (EDevice.m_WireShader); - DU_impl.DrawCross (v[0], f[3],f[3],f[3], f[3],f[3],f[3], clr); - break; - case PDDisc: - DU_impl.DrawCylinder (parent, v[0], v[1], 0.f, f[6], clr_s, clr_w, true, true); - DU_impl.DrawCylinder (parent, v[0], v[1], 0.f, f[7], clr_s, clr_w, true, true); - break; - case PDRectangle: - DU_impl.DrawRectangle (v[0], v[1], v[2], clr_s, clr_w, true, true); - break; - } + break; + case PDBlob: + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawCross(v[0], f[3], f[3], f[3], f[3], f[3], f[3], clr); + break; + case PDDisc: + DU_impl.DrawCylinder(parent, v[0], v[1], 0.f, f[6], clr_s, clr_w, true, true); + DU_impl.DrawCylinder(parent, v[0], v[1], 0.f, f[7], clr_s, clr_w, true, true); + break; + case PDRectangle: + DU_impl.DrawRectangle(v[0], v[1], v[2], clr_s, clr_w, true, true); + break; + } } -xr_token domain_token [ ]={ - { "Point", PDPoint }, - { "Line", PDLine }, - { "Triangle", PDTriangle }, - { "Plane", PDPlane }, - { "Box", PDBox }, - { "Sphere", PDSphere }, - { "Cylinder", PDCylinder }, - { "Cone", PDCone }, - { "Blob", PDBlob }, - { "Disc", PDDisc }, - { "Rectangle", PDRectangle }, - { 0, 0 } +xr_token domain_token [ ] = { + {"Point", PDPoint}, + {"Line", PDLine}, + {"Triangle", PDTriangle}, + {"Plane", PDPlane}, + {"Box", PDBox}, + {"Sphere", PDSphere}, + {"Cylinder", PDCylinder}, + {"Cone", PDCone}, + {"Blob", PDBlob}, + {"Disc", PDDisc}, + {"Rectangle", PDRectangle}, + {0, 0} }; -void PDomain::OnTypeChange(PropValue* sender) -{ - ExecCommand (COMMAND_UPDATE_PROPERTIES); +void PDomain::OnTypeChange(PropValue *sender) +{ + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void PDomain::FillProp (PropItemVec& items, LPCSTR pref, u32 clr) +void PDomain::FillProp(PropItemVec &items, LPCSTR pref, u32 clr) { - PropValue* V; - V=PHelper().CreateToken32(items,pref,(u32*)&type,domain_token); - V->OnChangeEvent.bind (this,&PDomain::OnTypeChange); - V->Owner()->prop_color = TColor(clr); - - switch(e_type){ - case vNum: - switch(type){ - case PDPoint: - V=PHelper().CreateVector (items,PrepareKey(pref,"Center"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDLine: - V=PHelper().CreateVector (items,PrepareKey(pref,"Point 1"), &v[0],flt_min,flt_max,0.001f,3); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Point 2"), &v[1],flt_min,flt_max,0.001f,3); V->Owner()->prop_color = TColor(clr); - break; - case PDTriangle: - V=PHelper().CreateVector (items,PrepareKey(pref,"Vertex 1"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Vertex 2"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Vertex 3"), &v[2],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDPlane: - V=PHelper().CreateVector (items,PrepareKey(pref,"Origin"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Normal"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDBox: - V=PHelper().CreateVector (items,PrepareKey(pref,"Min"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Max"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDSphere: - V=PHelper().CreateVector (items,PrepareKey(pref,"Center"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[3],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[4],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDCylinder: - V=PHelper().CreateVector (items,PrepareKey(pref,"Point 1"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Point 2"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[6],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[7],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDCone: - V=PHelper().CreateVector (items,PrepareKey(pref,"Apex"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"End Point"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[6],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[7],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDBlob: - V=PHelper().CreateVector (items,PrepareKey(pref,"Center"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[3],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDDisc: - V=PHelper().CreateVector (items,PrepareKey(pref,"Center"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Normal"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[6],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[7],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDRectangle: - V=PHelper().CreateVector (items,PrepareKey(pref,"Origin"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Basis U"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Basis V"), &v[2],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - default: - V=PHelper().CreateVector (items,PrepareKey(pref,"Translate"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Rotate"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVector (items,PrepareKey(pref,"Scale"), &v[2],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - } - break; - case vAngle: - switch(type){ - case PDPoint: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Center"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDLine: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Point 1"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Point 2"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDTriangle: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Vertex 1"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Vertex 2"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Vertex 3"), &v[2],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDPlane: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Origin"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Normal"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDBox: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Min"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Max"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDSphere: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Center"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[3],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[4],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDCylinder: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Point 1"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Point 2"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[6],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[7],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDCone: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Apex"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"End Point"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[6],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[7],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDBlob: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Center"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[3],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDDisc: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Center"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Normal"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[6],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[7],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - case PDRectangle: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Origin"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Basis U"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Basis V"), &v[2],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - default: - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Translate"), &v[0],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Rotate"), &v[1],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateAngle3 (items,PrepareKey(pref,"Scale"), &v[2],flt_min,flt_max,0.001f,3);V->Owner()->prop_color = TColor(clr); - break; - } - break; - case vColor: - switch(type){ - case PDPoint: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Center"), &v[0]); V->Owner()->prop_color = TColor(clr); - break; - case PDLine: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Point 1"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Point 2"), &v[1]); V->Owner()->prop_color = TColor(clr); - break; - case PDTriangle: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Vertex 1"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Vertex 2"), &v[1]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Vertex 3"), &v[2]); V->Owner()->prop_color = TColor(clr); - break; - case PDPlane: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Origin"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Normal"), &v[1]); V->Owner()->prop_color = TColor(clr); - break; - case PDBox: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Min"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Max"), &v[1]); V->Owner()->prop_color = TColor(clr); - break; - case PDSphere: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Center"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[3]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[4]); V->Owner()->prop_color = TColor(clr); - break; - case PDCylinder: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Point 1"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Point 2"), &v[1]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[6]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[7]); V->Owner()->prop_color = TColor(clr); - break; - case PDCone: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Apex"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"End Point"), &v[1]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[6]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[7]); V->Owner()->prop_color = TColor(clr); - break; - case PDBlob: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Center"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[3]); V->Owner()->prop_color = TColor(clr); - break; - case PDDisc: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Center"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Normal"), &v[1]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Inner"), &f[6]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Radius Outer"), &f[7]); V->Owner()->prop_color = TColor(clr); - break; - case PDRectangle: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Origin"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Basis U"), &v[1]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Basis V"), &v[2]); V->Owner()->prop_color = TColor(clr); - break; - default: - V=PHelper().CreateVColor (items,PrepareKey(pref,"Translate"), &v[0]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Rotate"), &v[1]); V->Owner()->prop_color = TColor(clr); - V=PHelper().CreateVColor (items,PrepareKey(pref,"Scale"), &v[2]); V->Owner()->prop_color = TColor(clr); - break; - } - break; + PropValue *V; + V = PHelper().CreateToken32(items, pref, (u32*)&type, domain_token); + V->OnChangeEvent.bind(this, &PDomain::OnTypeChange); + V->Owner()->prop_color = TColor(clr); + + switch (e_type) + { + case vNum: + switch (type) + { + case PDPoint: + V = PHelper().CreateVector(items, PrepareKey(pref, "Center"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDLine: + V = PHelper().CreateVector(items, PrepareKey(pref, "Point 1"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Point 2"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDTriangle: + V = PHelper().CreateVector(items, PrepareKey(pref, "Vertex 1"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Vertex 2"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Vertex 3"), &v[2], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDPlane: + V = PHelper().CreateVector(items, PrepareKey(pref, "Origin"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Normal"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDBox: + V = PHelper().CreateVector(items, PrepareKey(pref, "Min"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Max"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDSphere: + V = PHelper().CreateVector(items, PrepareKey(pref, "Center"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[3], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[4], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDCylinder: + V = PHelper().CreateVector(items, PrepareKey(pref, "Point 1"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Point 2"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[6], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[7], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDCone: + V = PHelper().CreateVector(items, PrepareKey(pref, "Apex"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "End Point"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[6], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[7], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDBlob: + V = PHelper().CreateVector(items, PrepareKey(pref, "Center"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[3], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDDisc: + V = PHelper().CreateVector(items, PrepareKey(pref, "Center"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Normal"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[6], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[7], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDRectangle: + V = PHelper().CreateVector(items, PrepareKey(pref, "Origin"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Basis U"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Basis V"), &v[2], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + default: + V = PHelper().CreateVector(items, PrepareKey(pref, "Translate"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Rotate"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVector(items, PrepareKey(pref, "Scale"), &v[2], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + } + break; + case vAngle: + switch (type) + { + case PDPoint: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Center"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDLine: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Point 1"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Point 2"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDTriangle: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Vertex 1"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Vertex 2"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Vertex 3"), &v[2], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDPlane: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Origin"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Normal"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDBox: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Min"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Max"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDSphere: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Center"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[3], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[4], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDCylinder: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Point 1"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Point 2"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[6], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[7], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDCone: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Apex"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "End Point"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[6], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[7], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDBlob: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Center"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[3], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDDisc: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Center"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Normal"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[6], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[7], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + case PDRectangle: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Origin"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Basis U"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Basis V"), &v[2], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + default: + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Translate"), &v[0], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Rotate"), &v[1], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Scale"), &v[2], flt_min, flt_max, 0.001f, 3); + V->Owner()->prop_color = TColor(clr); + break; + } + break; + case vColor: + switch (type) + { + case PDPoint: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Center"), &v[0]); + V->Owner()->prop_color = TColor(clr); + break; + case PDLine: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Point 1"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Point 2"), &v[1]); + V->Owner()->prop_color = TColor(clr); + break; + case PDTriangle: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Vertex 1"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Vertex 2"), &v[1]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Vertex 3"), &v[2]); + V->Owner()->prop_color = TColor(clr); + break; + case PDPlane: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Origin"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Normal"), &v[1]); + V->Owner()->prop_color = TColor(clr); + break; + case PDBox: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Min"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Max"), &v[1]); + V->Owner()->prop_color = TColor(clr); + break; + case PDSphere: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Center"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[3]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[4]); + V->Owner()->prop_color = TColor(clr); + break; + case PDCylinder: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Point 1"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Point 2"), &v[1]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[6]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[7]); + V->Owner()->prop_color = TColor(clr); + break; + case PDCone: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Apex"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "End Point"), &v[1]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[6]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[7]); + V->Owner()->prop_color = TColor(clr); + break; + case PDBlob: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Center"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[3]); + V->Owner()->prop_color = TColor(clr); + break; + case PDDisc: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Center"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Normal"), &v[1]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Inner"), &f[6]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Radius Outer"), &f[7]); + V->Owner()->prop_color = TColor(clr); + break; + case PDRectangle: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Origin"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Basis U"), &v[1]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Basis V"), &v[2]); + V->Owner()->prop_color = TColor(clr); + break; + default: + V = PHelper().CreateVColor(items, PrepareKey(pref, "Translate"), &v[0]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Rotate"), &v[1]); + V->Owner()->prop_color = TColor(clr); + V = PHelper().CreateVColor(items, PrepareKey(pref, "Scale"), &v[2]); + V->Owner()->prop_color = TColor(clr); + break; + } + break; } } @@ -385,212 +496,213 @@ void PDomain::FillProp (PropItemVec& items, LPCSTR pref, u32 clr) /* void PDomain::MoveXYZ(float x, float y, float z) { - switch(type) - { - case PDPoint: - a0+=x; a1+=y; a2+=z; - break; - case PDLine: - a0+=x; a1+=y; a2+=z; - a3+=x; a4+=y; a5+=z; - break; - case PDTriangle: - a0+=x; a1+=y; a2+=z; - a3+=x; a4+=y; a5+=z; - a6+=x; a7+=y; a8+=z; - break; - case PDPlane: - a0+=x; a1+=y; a2+=z; - break; - case PDBox: - a0+=x; a1+=y; a2+=z; - a3+=x; a4+=y; a5+=z; - break; - case PDSphere: - a0+=x; a1+=y; a2+=z; - break; - case PDCylinder: - a0+=x; a1+=y; a2+=z; - a3+=x; a4+=y; a5+=z; - break; - case PDCone: - a0+=x; a1+=y; a2+=z; - a3+=x; a4+=y; a5+=z; - break; - case PDBlob: - a0+=x; a1+=y; a2+=z; - break; - case PDDisc: - a0+=x; a1+=y; a2+=z; - break; - } - + switch(type) + { + case PDPoint: + a0+=x; a1+=y; a2+=z; + break; + case PDLine: + a0+=x; a1+=y; a2+=z; + a3+=x; a4+=y; a5+=z; + break; + case PDTriangle: + a0+=x; a1+=y; a2+=z; + a3+=x; a4+=y; a5+=z; + a6+=x; a7+=y; a8+=z; + break; + case PDPlane: + a0+=x; a1+=y; a2+=z; + break; + case PDBox: + a0+=x; a1+=y; a2+=z; + a3+=x; a4+=y; a5+=z; + break; + case PDSphere: + a0+=x; a1+=y; a2+=z; + break; + case PDCylinder: + a0+=x; a1+=y; a2+=z; + a3+=x; a4+=y; a5+=z; + break; + case PDCone: + a0+=x; a1+=y; a2+=z; + a3+=x; a4+=y; a5+=z; + break; + case PDBlob: + a0+=x; a1+=y; a2+=z; + break; + case PDDisc: + a0+=x; a1+=y; a2+=z; + break; + } + } //---------------------------------------------------------- void PDomain::RotateXYZ (float x, float y, float z) { - MVertex v1; - MVertex v2; - MVertex v3; - MVertex r1; - MVertex r2; - MVertex r3; + MVertex v1; + MVertex v2; + MVertex v3; + MVertex r1; + MVertex r2; + MVertex r3; // MVertex tmpV; - MMatrix trans; - - MVertex c; - - trans.setIdentity(); - trans.rotateX(x); - trans.rotateZ(z); - trans.rotateY(y); + MMatrix trans; + + MVertex c; + + trans.setIdentity(); + trans.rotateX(x); + trans.rotateZ(z); + trans.rotateY(y); // float xloc; // float yloc; // float zloc; - switch(type) - { - case PDPoint: - break; - case PDLine: - r1 = trans*(v1.set( a0, a1, a2 )); - r2 = trans*(v2.set( a3, a4, a5 )); - a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); - break; - case PDTriangle: - c = GetCenter(); - r1 = trans*(v1.set( (float)a0-c.X(), (float)a1-c.Y(), (float)a2-c.Z() )); - r2 = trans*(v2.set( (float)a3-c.X(), (float)a4-c.Y(), (float)a5-c.Z() )); - r3 = trans*(v3.set( (float)a6-c.X(), (float)a7-c.Y(), (float)a8-c.Z() )); - a0 = r1.X()+c.X(); a1 = r1.Y()+c.Y(); a2 = r1.Z()+c.Z(); - a3 = r2.X()+c.X(); a4 = r2.Y()+c.Y(); a5 = r2.Z()+c.Z(); - a6 = r3.X()+c.X(); a7 = r3.Y()+c.Y(); a8 = r3.Z()+c.Z(); - break; - case PDPlane: + switch(type) + { + case PDPoint: + break; + case PDLine: + r1 = trans*(v1.set( a0, a1, a2 )); + r2 = trans*(v2.set( a3, a4, a5 )); + a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); + break; + case PDTriangle: + c = GetCenter(); + r1 = trans*(v1.set( (float)a0-c.X(), (float)a1-c.Y(), (float)a2-c.Z() )); + r2 = trans*(v2.set( (float)a3-c.X(), (float)a4-c.Y(), (float)a5-c.Z() )); + r3 = trans*(v3.set( (float)a6-c.X(), (float)a7-c.Y(), (float)a8-c.Z() )); + a0 = r1.X()+c.X(); a1 = r1.Y()+c.Y(); a2 = r1.Z()+c.Z(); + a3 = r2.X()+c.X(); a4 = r2.Y()+c.Y(); a5 = r2.Z()+c.Z(); + a6 = r3.X()+c.X(); a7 = r3.Y()+c.Y(); a8 = r3.Z()+c.Z(); + break; + case PDPlane: // r2 = trans*(v2.set( a3, a4, a5 )); // r3 = trans*(v3.set( a6, a7, a8 )); // a3 = r2.X(); a4 = r2.Y(); a5 = r2.Z(); // a6 = r3.X(); a7 = r3.Y(); a8 = r3.Z(); - - c = GetCenter(); - v1.set(a0-c.X(), a1-c.Y(), a2-c.Z()); - v2.set((float)a0+((float)a3/2.0), (float)a1+((float)a4/2.0), (float)a2+((float)a5/2.0)); - v3.set((float)a0+((float)a6/2.0), (float)a1+((float)a7/2.0), (float)a2+((float)a8/2.0)); - - r1 = trans*v1; - r2 = trans*v2; - r3 = trans*v3; - - a0 = r1.X()+c.X(); a1 = r1.Y()+c.Y(); a2 = r1.Z()+c.Z(); - - - break; - case PDBox: - r1 = trans*(v1.set( a0, a1, a2 )); - r2 = trans*(v2.set( a3, a4, a5 )); - a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); - a3 = r2.X(); a4 = r2.Y(); a5 = r2.Z(); - break; - case PDSphere: - r1 = trans*(v1.set( a0, a1, a2 )); - a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); - break; - case PDCylinder: - r1 = trans*(v1.set( a0, a1, a2 )); - r2 = trans*(v2.set( a3, a4, a5 )); - a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); - a3 = r2.X(); a4 = r2.Y(); a5 = r2.Z(); - break; - case PDCone: - r1 = trans*(v1.set( a0, a1, a2 )); - r2 = trans*(v2.set( a3, a4, a5 )); - a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); - a3 = r2.X(); a4 = r2.Y(); a5 = r2.Z(); - break; - case PDBlob: - r1 = trans*(v1.set( a0, a1, a2 )); - a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); - break; - case PDDisc: - break; - } + + c = GetCenter(); + v1.set(a0-c.X(), a1-c.Y(), a2-c.Z()); + v2.set((float)a0+((float)a3/2.0), (float)a1+((float)a4/2.0), (float)a2+((float)a5/2.0)); + v3.set((float)a0+((float)a6/2.0), (float)a1+((float)a7/2.0), (float)a2+((float)a8/2.0)); + + r1 = trans*v1; + r2 = trans*v2; + r3 = trans*v3; + + a0 = r1.X()+c.X(); a1 = r1.Y()+c.Y(); a2 = r1.Z()+c.Z(); + + + break; + case PDBox: + r1 = trans*(v1.set( a0, a1, a2 )); + r2 = trans*(v2.set( a3, a4, a5 )); + a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); + a3 = r2.X(); a4 = r2.Y(); a5 = r2.Z(); + break; + case PDSphere: + r1 = trans*(v1.set( a0, a1, a2 )); + a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); + break; + case PDCylinder: + r1 = trans*(v1.set( a0, a1, a2 )); + r2 = trans*(v2.set( a3, a4, a5 )); + a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); + a3 = r2.X(); a4 = r2.Y(); a5 = r2.Z(); + break; + case PDCone: + r1 = trans*(v1.set( a0, a1, a2 )); + r2 = trans*(v2.set( a3, a4, a5 )); + a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); + a3 = r2.X(); a4 = r2.Y(); a5 = r2.Z(); + break; + case PDBlob: + r1 = trans*(v1.set( a0, a1, a2 )); + a0 = r1.X(); a1 = r1.Y(); a2 = r1.Z(); + break; + case PDDisc: + break; + } } //---------------------------------------------------------- void PDomain::ScaleXYZ (float x, float y, float z) { - x = x; - y = y; - z = z; - - switch(type) - { - case PDPoint: - break; - case PDLine: - break; - case PDTriangle: - break; - case PDPlane: - break; - case PDBox: - break; - case PDSphere: - break; - case PDCylinder: - break; - case PDCone: - break; - case PDBlob: - break; - case PDDisc: - break; - } + x = x; + y = y; + z = z; + + switch(type) + { + case PDPoint: + break; + case PDLine: + break; + case PDTriangle: + break; + case PDPlane: + break; + case PDBox: + break; + case PDSphere: + break; + case PDCylinder: + break; + case PDCone: + break; + case PDBlob: + break; + case PDDisc: + break; + } } //---------------------------------------------------------- MVertex& PDomain::GetCenter() { - static MVertex center; - MVertex v1; - MVertex v2; - MVertex v3; - MVertex v4; - - switch(type) - { - case PDPoint: - center.set(a0, a1, a2); - break; - case PDLine: - break; - case PDTriangle: - center.set( ((float)a0+(float)a3+(float)a6)/3.0, - ((float)a1+(float)a4+(float)a7)/3.0, - ((float)a2+(float)a5+(float)a8)/3.0 ); - break; - case PDPlane: - v1.set(a0, a1, a2); - v2.set(a0+(a3/2.0f), a1+(a4/2.0f), a2+(a5/2.0f)); - v3.set(a0+(a6/2.0f), a1+(a7/2.0f), a2+(a8/2.0f)); - v4.set(a0+(a6/2.0f)+(a3/2.0f), a1+(a7/2.0f)+(a4/2.0f), a2+(a8/2.0f)+(a5/2.0f)); - center.set( (v1.X()+v2.X()+v3.X()+v4.X())/4.0, - (v1.Y()+v2.Y()+v3.Y()+v4.Y())/4.0, - (v1.Z()+v2.Z()+v3.Z()+v4.Z())/4.0 ); - break; - case PDBox: - break; - case PDSphere: - break; - case PDCylinder: - break; - case PDCone: - break; - case PDBlob: - break; - case PDDisc: - center.set(a0, a1, a2); - break; - } - return center; + static MVertex center; + MVertex v1; + MVertex v2; + MVertex v3; + MVertex v4; + + switch(type) + { + case PDPoint: + center.set(a0, a1, a2); + break; + case PDLine: + break; + case PDTriangle: + center.set( ((float)a0+(float)a3+(float)a6)/3.0, + ((float)a1+(float)a4+(float)a7)/3.0, + ((float)a2+(float)a5+(float)a8)/3.0 ); + break; + case PDPlane: + v1.set(a0, a1, a2); + v2.set(a0+(a3/2.0f), a1+(a4/2.0f), a2+(a5/2.0f)); + v3.set(a0+(a6/2.0f), a1+(a7/2.0f), a2+(a8/2.0f)); + v4.set(a0+(a6/2.0f)+(a3/2.0f), a1+(a7/2.0f)+(a4/2.0f), a2+(a8/2.0f)+(a5/2.0f)); + center.set( (v1.X()+v2.X()+v3.X()+v4.X())/4.0, + (v1.Y()+v2.Y()+v3.Y()+v4.Y())/4.0, + (v1.Z()+v2.Z()+v3.Z()+v4.Z())/4.0 ); + break; + case PDBox: + break; + case PDSphere: + break; + case PDCylinder: + break; + case PDCone: + break; + case PDBlob: + break; + case PDDisc: + center.set(a0, a1, a2); + break; + } + return center; } */ + diff --git a/src/editors/ECore/Editor/pick_definition.h b/src/editors/ECore/Editor/pick_definition.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Editor/pick_definition.h @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Editor/render.cpp b/src/editors/ECore/Editor/render.cpp index a1b0fb42758..974298d71df 100644 --- a/src/editors/ECore/Editor/render.cpp +++ b/src/editors/ECore/Editor/render.cpp @@ -2,230 +2,284 @@ #pragma hdrstop #include "render.h" -#include "ResourceManager.h" -#include "../../Include/xrAPI/xrAPI.h" +#include "Layers/xrRender/ResourceManager.h" +#include "Include/xrAPI/xrAPI.h" //--------------------------------------------------------------------------- -float ssaDISCARD = 4.f; -float ssaDONTSORT = 32.f; +float ssaDISCARD = 4.f; +float ssaDONTSORT = 32.f; -ECORE_API float r_ssaDISCARD; -ECORE_API float g_fSCREEN; +ECORE_API +float r_ssaDISCARD; +ECORE_API +float g_fSCREEN; -CRender RImplementation; -ECORE_API CRender* Render = &RImplementation; +CRender RImplementation; +ECORE_API CRender* Render = &RImplementation; //--------------------- -IRenderFactory* RenderFactory = NULL; +IRenderFactory *RenderFactory = NULL; + //--------------------------------------------------------------------------- -CRender::CRender () +CRender::CRender() { - m_skinning = 0; + m_skinning = 0; } -CRender::~CRender () +CRender::~CRender() { - xr_delete (Target); + xr_delete(Target); } -void CRender::Initialize () +void CRender::Initialize() { - PSLibrary.OnCreate (); + PSLibrary.OnCreate(); } -void CRender::ShutDown () + +void CRender::ShutDown() { - PSLibrary.OnDestroy (); + PSLibrary.OnDestroy(); } -void CRender::OnDeviceCreate () +void CRender::OnDeviceCreate() { - Models = xr_new (); - Models->Logging (FALSE); + Models = xr_new(); + Models->Logging(FALSE); } -void CRender::OnDeviceDestroy () + +void CRender::OnDeviceDestroy() { - xr_delete (Models); + xr_delete(Models); } -ref_shader CRender::getShader (int id){ return 0; }//VERIFY(id(); + D->Load(F); + return D; +} + +IRenderVisual *CRender::model_CreatePE(LPCSTR name) +{ + PS::CPEDef *source = PSLibrary.FindPED(name); + return Models->CreatePE(source); +} + +IRenderVisual *CRender::model_CreateParticles(LPCSTR name) +{ + PS::CPEDef *SE = PSLibrary.FindPED(name); + if (SE) + return Models->CreatePE(SE); + else + { + PS::CPGDef *SG = PSLibrary.FindPGD(name); + return SG ? Models->CreatePG(SG) : 0; + } +} + +void CRender::rmNear() +{ + CRenderTarget *T = getTarget(); + D3DVIEWPORT9 VP = {0,0,T->get_width(),T->get_height(),0,0.02f}; + CHK_DX(HW.pDevice->SetViewport(&VP)); +} + +void CRender::rmFar() +{ + CRenderTarget *T = getTarget(); + D3DVIEWPORT9 VP = {0,0,T->get_width(),T->get_height(),0.99999f,1.f}; + CHK_DX(HW.pDevice->SetViewport(&VP)); +} + +void CRender::rmNormal() { + CRenderTarget *T = getTarget(); + D3DVIEWPORT9 VP = {0,0,T->get_width(),T->get_height(),0,1.f}; + CHK_DX(HW.pDevice->SetViewport(&VP)); } -IRender_DetailModel* CRender::model_CreateDM(IReader* F) +void CRender::set_Transform(Fmatrix *M) { - VERIFY (F); - CDetail* D = xr_new (); - D->Load (F); - return D; + current_matrix.set(*M); } -IRenderVisual* CRender::model_CreatePE(LPCSTR name) +void CRender::add_Visual(IRenderVisual *visual) { - PS::CPEDef* source = PSLibrary.FindPED (name); - return Models->CreatePE (source); + Models->RenderSingle(dynamic_cast(visual), current_matrix, 1.f); } -IRenderVisual* CRender::model_CreateParticles (LPCSTR name) +IRenderVisual *CRender::model_Create(LPCSTR name, IReader *data) { - PS::CPEDef* SE = PSLibrary.FindPED (name); - if (SE) return Models->CreatePE (SE); - else{ - PS::CPGDef* SG = PSLibrary.FindPGD (name); - return SG?Models->CreatePG (SG):0; - } + return Models->Create(name, data); } -void CRender::rmNear () +IRenderVisual *CRender::model_CreateChild(LPCSTR name, IReader *data) { - CRenderTarget* T = getTarget (); - D3DVIEWPORT9 VP = {0,0,T->get_width(),T->get_height(),0,0.02f }; - CHK_DX (HW.pDevice->SetViewport(&VP)); + return Models->CreateChild(name, data); } -void CRender::rmFar () + +void CRender::model_Delete(IRenderVisual * &V, BOOL bDiscard) { - CRenderTarget* T = getTarget (); - D3DVIEWPORT9 VP = {0,0,T->get_width(),T->get_height(),0.99999f,1.f }; - CHK_DX (HW.pDevice->SetViewport(&VP)); + Models->Delete(dynamic_cast(V), bDiscard); } -void CRender::rmNormal () + +IRenderVisual *CRender::model_Duplicate(IRenderVisual *V) { - CRenderTarget* T = getTarget (); - D3DVIEWPORT9 VP = {0,0,T->get_width(),T->get_height(),0,1.f }; - CHK_DX (HW.pDevice->SetViewport(&VP)); + return Models->Instance_Duplicate(dynamic_cast(V)); } -void CRender::set_Transform (Fmatrix* M) +void CRender::model_Render(IRenderVisual *m_pVisual, const Fmatrix &mTransform, int priority, bool strictB2F, float m_fLOD) { - current_matrix.set(*M); + Models->Render(dynamic_cast(m_pVisual), mTransform, priority, strictB2F, m_fLOD); } -void CRender::add_Visual (IRenderVisual* visual) { Models->RenderSingle (dynamic_cast(visual),current_matrix,1.f);} -IRenderVisual* CRender::model_Create (LPCSTR name, IReader* data) { return Models->Create(name,data); } -IRenderVisual* CRender::model_CreateChild (LPCSTR name, IReader* data) { return Models->CreateChild(name,data);} -void CRender::model_Delete (IRenderVisual* &V, BOOL bDiscard) { Models->Delete(dynamic_cast(V),bDiscard); } -IRenderVisual* CRender::model_Duplicate (IRenderVisual* V) { return Models->Instance_Duplicate(dynamic_cast(V)); } -void CRender::model_Render (IRenderVisual* m_pVisual, const Fmatrix& mTransform, int priority, bool strictB2F, float m_fLOD){Models->Render(dynamic_cast(m_pVisual), mTransform, priority, strictB2F, m_fLOD);} -void CRender::model_RenderSingle (IRenderVisual* m_pVisual, const Fmatrix& mTransform, float m_fLOD){Models->RenderSingle(dynamic_cast(m_pVisual), mTransform, m_fLOD);} +void CRender::model_RenderSingle(IRenderVisual *m_pVisual, const Fmatrix &mTransform, float m_fLOD) +{ + Models->RenderSingle(dynamic_cast(m_pVisual), mTransform, m_fLOD); +} //#pragma comment(lib,"d3dx_r1") -HRESULT CRender::CompileShader ( - LPCSTR pSrcData, - UINT SrcDataLen, - void* _pDefines, - void* _pInclude, - LPCSTR pFunctionName, - LPCSTR pTarget, - DWORD Flags, - void* _ppShader, - void* _ppErrorMsgs, - void* _ppConstantTable) -{ - CONST D3DXMACRO* pDefines = (CONST D3DXMACRO*) _pDefines; - LPD3DXINCLUDE pInclude = (LPD3DXINCLUDE) _pInclude; - LPD3DXBUFFER* ppShader = (LPD3DXBUFFER*) _ppShader; - LPD3DXBUFFER* ppErrorMsgs = (LPD3DXBUFFER*) _ppErrorMsgs; - LPD3DXCONSTANTTABLE* ppConstantTable = (LPD3DXCONSTANTTABLE*)_ppConstantTable; - return D3DXCompileShader (pSrcData,SrcDataLen,pDefines,pInclude,pFunctionName,pTarget,Flags,ppShader,ppErrorMsgs,ppConstantTable); -} -HRESULT CRender::shader_compile ( - LPCSTR name, - LPCSTR pSrcData, - UINT SrcDataLen, - void* _pDefines, - void* _pInclude, - LPCSTR pFunctionName, - LPCSTR pTarget, - DWORD Flags, - void* _ppShader, - void* _ppErrorMsgs, - void* _ppConstantTable) -{ - D3DXMACRO defines [128]; - int def_it = 0; - CONST D3DXMACRO* pDefines = (CONST D3DXMACRO*) _pDefines; - if (pDefines) { - // transfer existing defines - for (;;def_it++) { - if (0==pDefines[def_it].Name) break; - defines[def_it] = pDefines[def_it]; - } - } - // options - if (m_skinning<0) { - defines[def_it].Name = "SKIN_NONE"; - defines[def_it].Definition = "1"; - def_it ++; - } - if (0==m_skinning) { - defines[def_it].Name = "SKIN_0"; - defines[def_it].Definition = "1"; - def_it ++; - } - if (1==m_skinning) { - defines[def_it].Name = "SKIN_1"; - defines[def_it].Definition = "1"; - def_it ++; - } - if (2==m_skinning) { - defines[def_it].Name = "SKIN_2"; - defines[def_it].Definition = "1"; - def_it ++; - } - // finish - defines[def_it].Name = 0; - defines[def_it].Definition = 0; - def_it ++; - - LPD3DXINCLUDE pInclude = (LPD3DXINCLUDE) _pInclude; - LPD3DXBUFFER* ppShader = (LPD3DXBUFFER*) _ppShader; - LPD3DXBUFFER* ppErrorMsgs = (LPD3DXBUFFER*) _ppErrorMsgs; - LPD3DXCONSTANTTABLE* ppConstantTable = (LPD3DXCONSTANTTABLE*)_ppConstantTable; -//. return D3DXCompileShader (pSrcData,SrcDataLen,defines,pInclude,pFunctionName,pTarget,Flags,ppShader,ppErrorMsgs,ppConstantTable); +HRESULT CRender::CompileShader( + LPCSTR pSrcData, + UINT SrcDataLen, + void *_pDefines, + void *_pInclude, + LPCSTR pFunctionName, + LPCSTR pTarget, + DWORD Flags, + void *_ppShader, + void *_ppErrorMsgs, + void *_ppConstantTable) +{ + CONST D3DXMACRO* pDefines = (CONST + D3DXMACRO* + ) + _pDefines; + LPD3DXINCLUDE pInclude = (LPD3DXINCLUDE) _pInclude; + LPD3DXBUFFER *ppShader = (LPD3DXBUFFER*) _ppShader; + LPD3DXBUFFER *ppErrorMsgs = (LPD3DXBUFFER*) _ppErrorMsgs; + LPD3DXCONSTANTTABLE *ppConstantTable = (LPD3DXCONSTANTTABLE*)_ppConstantTable; + return D3DXCompileShader(pSrcData, SrcDataLen, pDefines, pInclude, pFunctionName, pTarget, Flags, ppShader, ppErrorMsgs, ppConstantTable); +} + +HRESULT CRender::shader_compile( + LPCSTR name, + LPCSTR pSrcData, + UINT SrcDataLen, + void *_pDefines, + void *_pInclude, + LPCSTR pFunctionName, + LPCSTR pTarget, + DWORD Flags, + void *_ppShader, + void *_ppErrorMsgs, + void *_ppConstantTable) +{ + D3DXMACRO defines [128]; + int def_it = 0; + CONST D3DXMACRO* pDefines = (CONST + D3DXMACRO* + ) + _pDefines; + if (pDefines) + { + // transfer existing defines + for (;; def_it++) + { + if (0==pDefines[def_it].Name) + break; + defines[def_it] = pDefines[def_it]; + } + } + // options + if (m_skinning<0) + { + defines[def_it].Name = "SKIN_NONE"; + defines[def_it].Definition = "1"; + def_it ++; + } + if (0==m_skinning) + { + defines[def_it].Name = "SKIN_0"; + defines[def_it].Definition = "1"; + def_it ++; + } + if (1==m_skinning) + { + defines[def_it].Name = "SKIN_1"; + defines[def_it].Definition = "1"; + def_it ++; + } + if (2==m_skinning) + { + defines[def_it].Name = "SKIN_2"; + defines[def_it].Definition = "1"; + def_it ++; + } + // finish + defines[def_it].Name = 0; + defines[def_it].Definition = 0; + def_it ++; + + LPD3DXINCLUDE pInclude = (LPD3DXINCLUDE) _pInclude; + LPD3DXBUFFER *ppShader = (LPD3DXBUFFER*) _ppShader; + LPD3DXBUFFER *ppErrorMsgs = (LPD3DXBUFFER*) _ppErrorMsgs; + LPD3DXCONSTANTTABLE *ppConstantTable = (LPD3DXCONSTANTTABLE*)_ppConstantTable; + //. return D3DXCompileShader (pSrcData,SrcDataLen,defines,pInclude,pFunctionName,pTarget,Flags,ppShader,ppErrorMsgs,ppConstantTable); #ifdef D3DXSHADER_USE_LEGACY_D3DX9_31_DLL // December 2006 and later + HRESULT _result = D3DXCompileShader(pSrcData,SrcDataLen,defines,pInclude,pFunctionName,pTarget,Flags|D3DXSHADER_USE_LEGACY_D3DX9_31_DLL,ppShader,ppErrorMsgs,ppConstantTable); #else - HRESULT _result = D3DXCompileShader(pSrcData,SrcDataLen,defines,pInclude,pFunctionName,pTarget,Flags,ppShader,ppErrorMsgs,ppConstantTable); + HRESULT _result = D3DXCompileShader(pSrcData, SrcDataLen, defines, pInclude, pFunctionName, pTarget, Flags, ppShader, ppErrorMsgs, ppConstantTable); #endif - return _result; + return _result; } -void CRender::reset_begin () +void CRender::reset_begin() { - xr_delete (Target); + xr_delete(Target); } -void CRender::reset_end () + +void CRender::reset_end() { - Target = xr_new (); + Target = xr_new(); } diff --git a/src/editors/ECore/Editor/render.h b/src/editors/ECore/Editor/render.h index 16daaaccb5f..f19eaf4d337 100644 --- a/src/editors/ECore/Editor/render.h +++ b/src/editors/ECore/Editor/render.h @@ -2,156 +2,171 @@ #ifndef renderH #define renderH -#include "..\..\xrCDB\frustum.h" +#include "xrCDB\Frustum.h" #include "vis_common.h" -#include "..\..\Layers\xrRender\blenders\blender.h" -#include "..\..\Layers\xrRender\blenders\blender_clsid.h" -#include "..\..\Layers\xrRender\xrRender_console.h" -#include "..\..\Layers\xrRender\PSLibrary.h" -#include "..\..\Layers\xrRender\IRenderDetailModel.H" -#include "..\..\Layers\xrRender\DetailModel.H" -#include "..\..\Layers\xrRender\ModelPool.h" -#include "..\..\Layers\xrRender\SkeletonCustom.h" -#include "..\..\Include/xrAPI/xrAPI.h" +#include "Layers/xrRender/blenders/Blender.h" +#include "Layers/xrRender/blenders/Blender_CLSID.h" +#include "Layers/xrRender/xrRender_console.h" +#include "Layers/xrRender/PSLibrary.h" +#include "Layers/xrRender/IRenderDetailModel.H" +#include "Layers/xrRender/DetailModel.H" +#include "Layers/xrRender/ModelPool.h" +#include "Layers/xrRender/SkeletonCustom.h" +#include "Include/xrAPI/xrAPI.h" // definition (Renderer) class CRenderTarget /*:public IRender_Target*/ { public: - virtual u32 get_width () { return EDevice.dwWidth; } - virtual u32 get_height () { return EDevice.dwHeight; } + virtual u32 get_width() + { + return EDevice.dwWidth; + } + + virtual u32 get_height() + { + return EDevice.dwHeight; + } }; class IRender { public: - enum GenerationLevel - { - GENERATION_R1 = 81, - GENERATION_DX81 = 81, - GENERATION_R2 = 90, - GENERATION_DX90 = 90, - GENERATION_forcedword = u32(-1) - }; - // feature level - virtual GenerationLevel get_generation ()=0; + enum GenerationLevel + { + GENERATION_R1 = 81, + GENERATION_DX81 = 81, + GENERATION_R2 = 90, + GENERATION_DX90 = 90, + GENERATION_forcedword = u32(-1) + }; + + // feature level + virtual GenerationLevel get_generation() =0; }; -class ECORE_API CRender: public IRender +class ECORE_API CRender: + +public +IRender { - CRenderTarget* Target; - Fmatrix current_matrix; + CRenderTarget* Target; + Fmatrix current_matrix; -public: - // options - s32 m_skinning; + public: + // options + s32 m_skinning; - // Data - CFrustum ViewBase; - CPSLibrary PSLibrary; + // Data + CFrustum ViewBase; + CPSLibrary PSLibrary; - CModelPool* Models; -public: - // Occlusion culling - virtual BOOL occ_visible (Fbox& B); - virtual BOOL occ_visible (sPoly& P); - virtual BOOL occ_visible (vis_data& P); + CModelPool* Models; + public: + // Occlusion culling + virtual BOOL occ_visible (Fbox& B); + virtual BOOL occ_visible (sPoly& P); + virtual BOOL occ_visible (vis_data& P); - // Constructor/destructor - CRender (); - virtual ~CRender (); + // Constructor/destructor + CRender (); + virtual ~CRender (); - void shader_option_skinning (u32 mode) { m_skinning=mode; } + void shader_option_skinning (u32 mode) { m_skinning=mode; } - void Initialize (); - void ShutDown (); +void Initialize (); +void ShutDown (); - void OnDeviceCreate (); - void OnDeviceDestroy (); +void OnDeviceCreate (); +void OnDeviceDestroy (); - void Calculate (); - void Render (); +void Calculate (); +void Render (); - void set_Transform (Fmatrix* M); - void add_Visual (IRenderVisual* visual); +void set_Transform (Fmatrix* M); +void add_Visual (IRenderVisual* visual); - virtual ref_shader getShader (int id); - CRenderTarget* getTarget (){return Target;} +virtual ref_shader getShader (int id); +CRenderTarget* getTarget (){return Target;} //. virtual IRender_Target* getTarget (){return Target;} - void reset_begin (); - void reset_end (); - virtual IRenderVisual* model_Create (LPCSTR name, IReader* data=0); - virtual IRenderVisual* model_CreateChild (LPCSTR name, IReader* data); - virtual IRenderVisual* model_CreatePE (LPCSTR name); - virtual IRenderVisual* model_CreateParticles (LPCSTR name); +void reset_begin (); +void reset_end (); +virtual IRenderVisual* model_Create (LPCSTR name, IReader* data=0); +virtual IRenderVisual* model_CreateChild (LPCSTR name, IReader* data); +virtual IRenderVisual* model_CreatePE (LPCSTR name); +virtual IRenderVisual* model_CreateParticles (LPCSTR name); - virtual IRender_DetailModel* model_CreateDM (IReader* R); - virtual IRenderVisual* model_Duplicate (IRenderVisual* V); - virtual void model_Delete (IRenderVisual* & V, BOOL bDiscard=TRUE); - virtual void model_Delete (IRender_DetailModel* & F) +virtual IRender_DetailModel* model_CreateDM (IReader* R); +virtual IRenderVisual* model_Duplicate (IRenderVisual* V); +virtual void model_Delete (IRenderVisual* & V, BOOL bDiscard=TRUE); +virtual void model_Delete (IRender_DetailModel* & F) +{ + if (F) { - if (F) - { - CDetail* D = (CDetail*)F; - D->Unload (); - xr_delete (D); - F = NULL; - } - } - void model_Render (IRenderVisual* m_pVisual, const Fmatrix& mTransform, int priority, bool strictB2F, float m_fLOD); - void model_RenderSingle (IRenderVisual* m_pVisual, const Fmatrix& mTransform, float m_fLOD); - virtual GenerationLevel get_generation (){return GENERATION_R1;} - virtual bool is_sun_static () {return true;}; - - virtual void add_SkeletonWallmark (intrusive_ptr wm){}; - virtual void add_SkeletonWallmark (const Fmatrix* xf, CKinematics* obj, ref_shader& sh, const Fvector& start, const Fvector& dir, float size){}; - - // Render mode - virtual void rmNear (); - virtual void rmFar (); - virtual void rmNormal (); - - void apply_lmaterial (){} - - virtual LPCSTR getShaderPath (){return "R1\\";} - - virtual HRESULT CompileShader ( - LPCSTR pSrcData, - UINT SrcDataLen, - void* pDefines, - void* pInclude, - LPCSTR pFunctionName, - LPCSTR pTarget, - DWORD Flags, - void* ppShader, - void* ppErrorMsgs, - void* ppConstantTable); - - virtual IDirect3DBaseTexture9* texture_load (LPCSTR fname, u32& mem_size); - virtual HRESULT shader_compile ( - LPCSTR name, - LPCSTR pSrcData, - UINT SrcDataLen, - void* pDefines, - void* pInclude, - LPCSTR pFunctionName, - LPCSTR pTarget, - DWORD Flags, - void* ppShader, - void* ppErrorMsgs, - void* ppConstantTable); + CDetail* D = (CDetail*)F; + D->Unload (); + xr_delete (D); + F = NULL; +} +} +void model_Render (IRenderVisual* m_pVisual, const Fmatrix& mTransform, int priority, bool strictB2F, float m_fLOD); +void model_RenderSingle (IRenderVisual* m_pVisual, const Fmatrix& mTransform, float m_fLOD); +virtual GenerationLevel get_generation (){return GENERATION_R1;} +virtual bool is_sun_static () {return true;}; + +virtual void add_SkeletonWallmark (intrusive_ptr wm){}; +virtual void add_SkeletonWallmark (const Fmatrix* xf, CKinematics* obj, ref_shader& sh, const Fvector& start, const Fvector& dir, float size){}; + +// Render mode +virtual void rmNear (); +virtual void rmFar (); +virtual void rmNormal (); + +void apply_lmaterial (){} + +virtual LPCSTR getShaderPath (){return "R1\\";} + +virtual HRESULT CompileShader ( + LPCSTR pSrcData, + UINT SrcDataLen, + void* pDefines, + void* pInclude, + LPCSTR pFunctionName, + LPCSTR pTarget, + DWORD Flags, + void* ppShader, + void* ppErrorMsgs, + void* ppConstantTable); + +virtual IDirect3DBaseTexture9* texture_load (LPCSTR fname, u32& mem_size); +virtual HRESULT shader_compile ( + LPCSTR name, + LPCSTR pSrcData, + UINT SrcDataLen, + void* pDefines, + void* pInclude, + LPCSTR pFunctionName, + LPCSTR pTarget, + DWORD Flags, + void* ppShader, + void* ppErrorMsgs, + void* ppConstantTable); }; -IC float CalcSSA(Fvector& C, float R) +IC + +float CalcSSA(Fvector &C, float R) { - float distSQ = EDevice.m_Camera.GetPosition().distance_to_sqr(C); - return R*R/distSQ; + float distSQ = EDevice.m_Camera.GetPosition().distance_to_sqr(C); + return R*R/distSQ; } -extern ECORE_API CRender RImplementation; + +extern ECORE_API CRender RImplementation; //.extern ECORE_API CRender* Render; #endif + diff --git a/src/editors/ECore/Editor/ui_main.cpp b/src/editors/ECore/Editor/ui_main.cpp index 4b66e1a6572..5ed1da1d872 100644 --- a/src/editors/ECore/Editor/ui_main.cpp +++ b/src/editors/ECore/Editor/ui_main.cpp @@ -3,128 +3,148 @@ #include "stdafx.h" #pragma hdrstop -#include "xr_input.h" +#include "xrEngine/xr_input.h" #include "UI_ToolsCustom.h" #include "UI_Main.h" -#include "d3dutils.h" +#include "D3DUtils.h" #include "SoundManager.h" -#include "PSLibrary.h" +#include "Layers/xrRender/PSLibrary.h" #include "ImageEditor.h" #include "SoundEditor.h" -#include "ChoseForm.h" -#include "ETools.h" +#include "editors/xrEProps/ChoseForm.h" +#include "utils/ETools/ETools.h" -TUI* UI = 0; +TUI *UI = 0; TUI::TUI() { - UI = this; - m_bAppActive = false; - m_bReady = false; - m_D3DWindow = 0; - m_D3DPanel = 0; - bNeedAbort = false; + UI = this; + m_bAppActive = false; + m_bReady = false; + m_D3DWindow = 0; + m_D3DPanel = 0; + bNeedAbort = false; - m_CurrentRStart.set(0,0,0); - m_CurrentRDir.set(0,0,0); + m_CurrentRStart.set(0, 0, 0); + m_CurrentRDir.set(0, 0, 0); - m_Flags.assign (flResize); + m_Flags.assign(flResize); - m_Pivot.set ( 0, 0, 0 ); + m_Pivot.set(0, 0, 0); - m_MouseCaptured = false; + m_MouseCaptured = false; m_MouseMultiClickCaptured = false; - m_SelectionRect = false; - bMouseInUse = false; + m_SelectionRect = false; + bMouseInUse = false; - m_bHintShowing = false; - m_pHintWindow = 0; - m_LastHint = ""; + m_bHintShowing = false; + m_pHintWindow = 0; + m_LastHint = ""; } + //--------------------------------------------------------------------------- TUI::~TUI() { - VERIFY(m_ProgressItems.size()==0); + VERIFY(m_ProgressItems.size()==0); VERIFY(m_EditorState.size()==0); } void TUI::OnDeviceCreate() { - DU_impl.OnDeviceCreate(); + DU_impl.OnDeviceCreate(); } void TUI::OnDeviceDestroy() { - DU_impl.OnDeviceDestroy(); + DU_impl.OnDeviceDestroy(); } bool TUI::IsModified() { - return ExecCommand(COMMAND_CHECK_MODIFIED); + return ExecCommand(COMMAND_CHECK_MODIFIED); } + //--------------------------------------------------------------------------- -void TUI::EnableSelectionRect( bool flag ){ - m_SelectionRect = flag; - m_SelEnd.x = m_SelStart.x = 0; - m_SelEnd.y = m_SelStart.y = 0; +void TUI::EnableSelectionRect(bool flag) +{ + m_SelectionRect = flag; + m_SelEnd.x = m_SelStart.x = 0; + m_SelEnd.y = m_SelStart.y = 0; } -void TUI::UpdateSelectionRect( const Ivector2& from, const Ivector2& to ){ - m_SelStart.set(from); - m_SelEnd.set(to); +void TUI::UpdateSelectionRect(const Ivector2 &from, const Ivector2 &to) +{ + m_SelStart.set(from); + m_SelEnd.set(to); } -bool __fastcall TUI::KeyDown (WORD Key, TShiftState Shift) +bool __fastcall TUI::KeyDown(WORD Key, TShiftState Shift) { - if (!m_bReady) return false; -// m_ShiftState = Shift; -// Log("Dn ",Shift.Contains(ssShift)?"1":"0"); - if (EDevice.m_Camera.KeyDown(Key,Shift)) return true; + if (!m_bReady) + return false; + // m_ShiftState = Shift; + // Log("Dn ",Shift.Contains(ssShift)?"1":"0"); + if (EDevice.m_Camera.KeyDown(Key, Shift)) + return true; return Tools->KeyDown(Key, Shift); } -bool __fastcall TUI::KeyUp (WORD Key, TShiftState Shift) +bool __fastcall TUI::KeyUp(WORD Key, TShiftState Shift) { - if (!m_bReady) return false; -// m_ShiftState = Shift; - if (EDevice.m_Camera.KeyUp(Key,Shift)) return true; + if (!m_bReady) + return false; + // m_ShiftState = Shift; + if (EDevice.m_Camera.KeyUp(Key, Shift)) + return true; return Tools->KeyUp(Key, Shift); } bool __fastcall TUI::KeyPress(WORD Key, TShiftState Shift) { - if (!m_bReady) return false; + if (!m_bReady) + return false; return Tools->KeyPress(Key, Shift); } + //---------------------------------------------------- void TUI::MousePress(TShiftState Shift, int X, int Y) { - if (!m_bReady) return; - if (m_MouseCaptured) return; + if (!m_bReady) + return; + if (m_MouseCaptured) + return; bMouseInUse = true; m_ShiftState = Shift; // camera activate - if(!EDevice.m_Camera.MoveStart(m_ShiftState)){ - if (Tools->Pick(Shift)) return; - if( !m_MouseCaptured ){ - if( Tools->HiddenMode() ){ - IR_GetMousePosScreen(m_StartCpH); - m_DeltaCpH.set(0,0); - }else{ + if (!EDevice.m_Camera.MoveStart(m_ShiftState)) + { + if (Tools->Pick(Shift)) + return; + if (!m_MouseCaptured) + { + if (Tools->HiddenMode()) + { + IR_GetMousePosScreen(m_StartCpH); + m_DeltaCpH.set(0, 0); + } + else + { IR_GetMousePosReal(EDevice.m_hRenderWnd, m_CurrentCp); m_StartCp = m_CurrentCp; - EDevice.m_Camera.MouseRayFromPoint(m_CurrentRStart, m_CurrentRDir, m_CurrentCp ); + EDevice.m_Camera.MouseRayFromPoint(m_CurrentRStart, m_CurrentRDir, m_CurrentCp); } - if(Tools->MouseStart(m_ShiftState)){ - if(Tools->HiddenMode()) ShowCursor( FALSE ); + if (Tools->MouseStart(m_ShiftState)) + { + if (Tools->HiddenMode()) + ShowCursor(FALSE); m_MouseCaptured = true; } } @@ -134,475 +154,583 @@ void TUI::MousePress(TShiftState Shift, int X, int Y) void TUI::MouseRelease(TShiftState Shift, int X, int Y) { - if (!m_bReady) return; + if (!m_bReady) + return; m_ShiftState = Shift; - if( EDevice.m_Camera.IsMoving() ){ - if (EDevice.m_Camera.MoveEnd(m_ShiftState)) bMouseInUse = false; - }else{ - bMouseInUse = false; - if( m_MouseCaptured ){ - if( !Tools->HiddenMode() ){ + if (EDevice.m_Camera.IsMoving()) + { + if (EDevice.m_Camera.MoveEnd(m_ShiftState)) + bMouseInUse = false; + } + else + { + bMouseInUse = false; + if (m_MouseCaptured) + { + if (!Tools->HiddenMode()) + { IR_GetMousePosReal(EDevice.m_hRenderWnd, m_CurrentCp); - EDevice.m_Camera.MouseRayFromPoint(m_CurrentRStart,m_CurrentRDir,m_CurrentCp ); + EDevice.m_Camera.MouseRayFromPoint(m_CurrentRStart, m_CurrentRDir, m_CurrentCp); } - if( Tools->MouseEnd(m_ShiftState) ){ - if( Tools->HiddenMode() ){ - SetCursorPos(m_StartCpH.x,m_StartCpH.y); - ShowCursor( TRUE ); + if (Tools->MouseEnd(m_ShiftState)) + { + if (Tools->HiddenMode()) + { + SetCursorPos(m_StartCpH.x, m_StartCpH.y); + ShowCursor(TRUE); } m_MouseCaptured = false; } } } // update tools (change action) - Tools->OnFrame (); - RedrawScene (); + Tools->OnFrame(); + RedrawScene(); } + //---------------------------------------------------- void TUI::MouseMove(TShiftState Shift, int X, int Y) { - if (!m_bReady) return; + if (!m_bReady) + return; m_ShiftState = Shift; } + //---------------------------------------------------- -void TUI::IR_OnMouseMove(int x, int y){ - if (!m_bReady) return; +void TUI::IR_OnMouseMove(int x, int y) +{ + if (!m_bReady) + return; bool bRayUpdated = false; - if (!EDevice.m_Camera.Process(m_ShiftState,x,y)){ - if( m_MouseCaptured || m_MouseMultiClickCaptured ){ - if( Tools->HiddenMode() ){ - m_DeltaCpH.set(x,y); - if( m_DeltaCpH.x || m_DeltaCpH.y ){ - Tools->MouseMove(m_ShiftState); + if (!EDevice.m_Camera.Process(m_ShiftState, x, y)) + { + if (m_MouseCaptured||m_MouseMultiClickCaptured) + { + if (Tools->HiddenMode()) + { + m_DeltaCpH.set(x, y); + if (m_DeltaCpH.x||m_DeltaCpH.y) + { + Tools->MouseMove(m_ShiftState); } - }else{ + } + else + { IR_GetMousePosReal(EDevice.m_hRenderWnd, m_CurrentCp); - EDevice.m_Camera.MouseRayFromPoint(m_CurrentRStart,m_CurrentRDir,m_CurrentCp); + EDevice.m_Camera.MouseRayFromPoint(m_CurrentRStart, m_CurrentRDir, m_CurrentCp); Tools->MouseMove(m_ShiftState); } - RedrawScene(); + RedrawScene(); bRayUpdated = true; } } - if (!bRayUpdated){ - IR_GetMousePosReal(EDevice.m_hRenderWnd, m_CurrentCp); - EDevice.m_Camera.MouseRayFromPoint(m_CurrentRStart,m_CurrentRDir,m_CurrentCp); + if (!bRayUpdated) + { + IR_GetMousePosReal(EDevice.m_hRenderWnd, m_CurrentCp); + EDevice.m_Camera.MouseRayFromPoint(m_CurrentRStart, m_CurrentRDir, m_CurrentCp); } // Out cursor pos - OutUICursorPos (); + OutUICursorPos(); } + //--------------------------------------------------------------------------- void TUI::OnAppActivate() { - VERIFY(m_bReady); - if (pInput){ + VERIFY(m_bReady); + if (pInput) + { m_ShiftState.Clear(); - pInput->OnAppActivate(); - EDevice.seqAppActivate.Process (rp_AppActivate); + pInput->OnAppActivate(); + EDevice.seqAppActivate.Process(rp_AppActivate); } - m_bAppActive = true; + m_bAppActive = true; } + //--------------------------------------------------------------------------- void TUI::OnAppDeactivate() { - VERIFY(m_bReady); - if (pInput){ - pInput->OnAppDeactivate(); + VERIFY(m_bReady); + if (pInput) + { + pInput->OnAppDeactivate(); m_ShiftState.Clear(); EDevice.seqAppDeactivate.Process(rp_AppDeactivate); } HideHint(); - m_bAppActive = false; + m_bAppActive = false; } + //--------------------------------------------------------------------------- -bool TUI::ShowHint(const AStringVec& SS) +bool TUI::ShowHint(const AStringVec &SS) { - VERIFY(m_bReady); - if (SS.size()){ - AnsiString S=_ListToSequence2(SS); - if (m_bHintShowing&&(S==m_LastHint)) return true; + VERIFY(m_bReady); + if (SS.size()) + { + AnsiString S = _ListToSequence2(SS); + if (m_bHintShowing&&(S==m_LastHint)) + return true; m_LastHint = S; m_bHintShowing = true; - if (!m_pHintWindow){ + if (!m_pHintWindow) + { m_pHintWindow = xr_new((TComponent*)0); m_pHintWindow->Brush->Color = (TColor)0x0d9F2FF; } - TRect rect = m_pHintWindow->CalcHintRect(320,S,0); - rect.Left+=m_HintPoint.x; rect.Top+=m_HintPoint.y; - rect.Right+=m_HintPoint.x; rect.Bottom+=m_HintPoint.y; - m_pHintWindow->ActivateHint(rect,S); - }else{ - m_bHintShowing = false; + TRect rect = m_pHintWindow->CalcHintRect(320, S, 0); + rect.Left += m_HintPoint.x; + rect.Top += m_HintPoint.y; + rect.Right += m_HintPoint.x; + rect.Bottom += m_HintPoint.y; + m_pHintWindow->ActivateHint(rect, S); + } + else + { + m_bHintShowing = false; m_LastHint = ""; } return m_bHintShowing; } + //--------------------------------------------------------------------------- void TUI::HideHint() { - VERIFY(m_bReady); + VERIFY(m_bReady); m_bHintShowing = false; xr_delete(m_pHintWindow); } + //--------------------------------------------------------------------------- -void TUI::ShowHint(const AnsiString& s) +void TUI::ShowHint(const AnsiString &s) { - VERIFY (m_bReady); - GetCursorPos (&m_HintPoint); - AStringVec SS; - SS.push_back (s); - Tools->OnShowHint(SS); - if (!ShowHint(SS)&&m_pHintWindow) HideHint(); + VERIFY(m_bReady); + GetCursorPos(&m_HintPoint); + AStringVec SS; + SS.push_back(s); + Tools->OnShowHint(SS); + if (!ShowHint(SS)&&m_pHintWindow) + HideHint(); } + //--------------------------------------------------------------------------- void TUI::ShowObjectHint() { - VERIFY(m_bReady); - if (!EPrefs->object_flags.is(epoShowHint)){ -// if (m_bHintShowing) HideHint(); - return; + VERIFY(m_bReady); + if (!EPrefs->object_flags.is(epoShowHint)) + { + // if (m_bHintShowing) HideHint(); + return; } - if (EDevice.m_Camera.IsMoving()||m_MouseCaptured) return; - if (!m_bAppActive) return; + if (EDevice.m_Camera.IsMoving()||m_MouseCaptured) + return; + if (!m_bAppActive) + return; GetCursorPos(&m_HintPoint); - TWinControl* ctr = FindVCLWindow(m_HintPoint); - if (ctr!=m_D3DWindow) return; + TWinControl *ctr = FindVCLWindow(m_HintPoint); + if (ctr!=m_D3DWindow) + return; - AStringVec SS; - Tools->OnShowHint(SS); - if (!ShowHint(SS)&&m_pHintWindow) HideHint(); + AStringVec SS; + Tools->OnShowHint(SS); + if (!ShowHint(SS)&&m_pHintWindow) + HideHint(); } + //--------------------------------------------------------------------------- -void TUI::CheckWindowPos(TForm* form) +void TUI::CheckWindowPos(TForm *form) { - if (form->Left+form->Width>Screen->Width) form->Left = Screen->Width-form->Width; - if (form->Top+form->Height>Screen->Height) form->Top = Screen->Height-form->Height; - if (form->Left<0) form->Left = 0; - if (form->Top<0) form->Top = 0; + if (form->Left+form->Width>Screen->Width) + form->Left = Screen->Width-form->Width; + if (form->Top+form->Height>Screen->Height) + form->Top = Screen->Height-form->Height; + if (form->Left<0) + form->Left = 0; + if (form->Top<0) + form->Top = 0; } + //--------------------------------------------------------------------------- -#include "igame_persistent.h" +#include "xrEngine/IGame_Persistent.h" #include "environment.h" void TUI::PrepareRedraw() { - VERIFY(m_bReady); - if (m_Flags.is(flResize)) RealResize(); -// set render state - EDevice.SetRS(D3DRS_TEXTUREFACTOR, 0xffffffff); + VERIFY(m_bReady); + if (m_Flags.is(flResize)) + RealResize(); + // set render state + EDevice.SetRS(D3DRS_TEXTUREFACTOR, 0xffffffff); // fog u32 fog_color; - float fog_start, fog_end; - Tools->GetCurrentFog (fog_color, fog_start, fog_end); -/* - if (0==g_pGamePersistent->Environment().GetWeather().size()) + float fog_start, fog_end; + Tools->GetCurrentFog(fog_color, fog_start, fog_end); + /* + if (0==g_pGamePersistent->Environment().GetWeather().size()) + { + g_pGamePersistent->Environment().CurrentEnv->fog_color.set (color_get_R(fog_color),color_get_G(fog_color),color_get_B(fog_color)); + g_pGamePersistent->Environment().CurrentEnv->fog_far = fog_end; + g_pGamePersistent->Environment().CurrentEnv->fog_near = fog_start; + } + */ + EDevice.SetRS(D3DRS_FOGCOLOR, fog_color); + EDevice.SetRS(D3DRS_RANGEFOGENABLE, FALSE); + if (HW.Caps.bTableFog) + { + EDevice.SetRS(D3DRS_FOGTABLEMODE, D3DFOG_LINEAR); + EDevice.SetRS(D3DRS_FOGVERTEXMODE, D3DFOG_NONE); + } + else { - g_pGamePersistent->Environment().CurrentEnv->fog_color.set (color_get_R(fog_color),color_get_G(fog_color),color_get_B(fog_color)); - g_pGamePersistent->Environment().CurrentEnv->fog_far = fog_end; - g_pGamePersistent->Environment().CurrentEnv->fog_near = fog_start; + EDevice.SetRS(D3DRS_FOGTABLEMODE, D3DFOG_NONE); + EDevice.SetRS(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR); } -*/ - EDevice.SetRS( D3DRS_FOGCOLOR, fog_color ); - EDevice.SetRS( D3DRS_RANGEFOGENABLE, FALSE ); - if (HW.Caps.bTableFog) { - EDevice.SetRS( D3DRS_FOGTABLEMODE, D3DFOG_LINEAR ); - EDevice.SetRS( D3DRS_FOGVERTEXMODE, D3DFOG_NONE ); - } else { - EDevice.SetRS( D3DRS_FOGTABLEMODE, D3DFOG_NONE ); - EDevice.SetRS( D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR ); - } - EDevice.SetRS( D3DRS_FOGSTART, *(DWORD *)(&fog_start) ); - EDevice.SetRS( D3DRS_FOGEND, *(DWORD *)(&fog_end) ); + EDevice.SetRS(D3DRS_FOGSTART, *(DWORD *)(&fog_start)); + EDevice.SetRS(D3DRS_FOGEND, *(DWORD *)(&fog_end)); // filter - for (u32 k=0; kRenderDUMP_RT.Begin(); - if (EDevice.Begin()){ - EDevice.UpdateView (); - EDevice.ResetMaterial (); + PrepareRedraw(); + try + { + EDevice.Statistic->RenderDUMP_RT.Begin(); + if (EDevice.Begin()) + { + EDevice.UpdateView(); + EDevice.ResetMaterial(); - Tools->RenderEnvironment (); + Tools->RenderEnvironment(); //. temporary reset filter ( ) - for (u32 k=0; kRender (); - }catch(...){ - ELog.DlgMsg(mtError, "Please notify AlexMX!!! Critical error has occured in render routine!!! [Type B]"); + try + { + Tools->Render(); + } catch (...) + { + ELog.DlgMsg(mtError, "Please notify AlexMX!!! Critical error has occured in render routine!!! [Type B]"); } // draw selection rect - if(m_SelectionRect) DU_impl.DrawSelectionRect(m_SelStart,m_SelEnd); + if (m_SelectionRect) + DU_impl.DrawSelectionRect(m_SelStart, m_SelEnd); // draw axis DU_impl.DrawAxis(EDevice.m_Camera.GetTransform()); - try{ - // end draw - EDevice.End(); - }catch(...){ - ELog.DlgMsg(mtError, "Please notify AlexMX!!! Critical error has occured in render routine!!! [Type C]"); + try + { + // end draw + EDevice.End(); + } catch (...) + { + ELog.DlgMsg(mtError, "Please notify AlexMX!!! Critical error has occured in render routine!!! [Type C]"); } } - EDevice.Statistic->RenderDUMP_RT.End(); - }catch(...){ - ELog.DlgMsg(mtError, "Please notify AlexMX!!! Critical error has occured in render routine!!! [Type A]"); -// _clear87(); -// FPU::m24r(); -// ELog.DlgMsg(mtError, "Critical error has occured in render routine.\nEditor may work incorrectly."); + EDevice.Statistic->RenderDUMP_RT.End(); + } catch (...) + { + ELog.DlgMsg(mtError, "Please notify AlexMX!!! Critical error has occured in render routine!!! [Type A]"); + // _clear87(); + // FPU::m24r(); + // ELog.DlgMsg(mtError, "Critical error has occured in render routine.\nEditor may work incorrectly."); EDevice.End(); -// EDevice.Resize(m_D3DWindow->Width,m_D3DWindow->Height); + // EDevice.Resize(m_D3DWindow->Width,m_D3DWindow->Height); } - OutInfo(); + OutInfo(); } + //--------------------------------------------------------------------------- void TUI::RealResize() { - EDevice.Resize (m_D3DWindow->Width,m_D3DWindow->Height); - m_Flags.set (flResize,FALSE); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + EDevice.Resize(m_D3DWindow->Width, m_D3DWindow->Height); + m_Flags.set(flResize, FALSE); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } + void TUI::RealUpdateScene() { - Tools->UpdateProperties (false); - m_Flags.set (flUpdateScene,FALSE); + Tools->UpdateProperties(false); + m_Flags.set(flUpdateScene, FALSE); } + void TUI::RealRedrawScene() { - if (!psDeviceFlags.is(rsRenderRealTime)) - m_Flags.set (flRedraw,FALSE); - Redraw (); + if (!psDeviceFlags.is(rsRenderRealTime)) + m_Flags.set(flRedraw, FALSE); + Redraw(); } + void TUI::OnFrame() { - EDevice.FrameMove (); - SndLib->OnFrame (); + EDevice.FrameMove(); + SndLib->OnFrame(); // tools on frame - if (m_Flags.is(flUpdateScene)) RealUpdateScene(); - Tools->OnFrame (); - // show hint - ShowObjectHint (); - ResetBreak (); - // check mail - CheckMailslot (); + if (m_Flags.is(flUpdateScene)) + RealUpdateScene(); + Tools->OnFrame(); + // show hint + ShowObjectHint(); + ResetBreak(); + // check mail + CheckMailslot(); // OnFrame TfrmImageLib::OnFrame(); TfrmSoundLib::OnFrame(); TfrmChoseItem::OnFrame(); // Progress - ProgressDraw (); + ProgressDraw(); } -void TUI::Idle() + +void TUI::Idle() { - VERIFY(m_bReady); - EDevice.b_is_Active = Application->Active; - // input + VERIFY(m_bReady); + EDevice.b_is_Active = Application->Active; + // input pInput->OnFrame(); Sleep(1); - if (ELog.in_use) return; + if (ELog.in_use) + return; - OnFrame (); - if (m_Flags.is(flRedraw)) RealRedrawScene(); + OnFrame(); + if (m_Flags.is(flRedraw)) + RealRedrawScene(); // test quit - if (m_Flags.is(flNeedQuit)) RealQuit(); + if (m_Flags.is(flNeedQuit)) + RealQuit(); } + //--------------------------------------------------------------------------- void ResetActionToSelect() { ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); } + //--------------------------------------------------------------------------- #define MIN_PANEL_HEIGHT 15 + void __fastcall PanelMinMax(TPanel *pa) { - if (pa&&(pa->Align!=alClient)){ - if (pa->Tag > 0){ + if (pa&&(pa->Align!=alClient)) + { + if (pa->Tag>0) + { pa->Height = pa->Tag; - pa->Tag = 0; - }else{ - pa->Tag = pa->Height; + pa->Tag = 0; + } + else + { + pa->Tag = pa->Height; pa->Height = MIN_PANEL_HEIGHT; } ExecCommand(COMMAND_UPDATE_TOOLBAR); } } + void __fastcall PanelMinimize(TPanel *pa) { - if (pa&&(pa->Align!=alClient)){ - if (pa->Tag <= 0){ - pa->Tag = pa->Height; + if (pa&&(pa->Align!=alClient)) + { + if (pa->Tag<=0) + { + pa->Tag = pa->Height; pa->Height = MIN_PANEL_HEIGHT; } ExecCommand(COMMAND_UPDATE_TOOLBAR); } } + void __fastcall PanelMaximize(TPanel *pa) { - if (pa&&(pa->Align!=alClient)){ - if (pa->Tag > 0){ + if (pa&&(pa->Align!=alClient)) + { + if (pa->Tag>0) + { pa->Height = pa->Tag; - pa->Tag = 0; + pa->Tag = 0; } ExecCommand(COMMAND_UPDATE_TOOLBAR); } } -void __fastcall PanelMinMaxClick(TObject* Sender) + +void __fastcall PanelMinMaxClick(TObject *Sender) { PanelMinMax(((TPanel*)((TControl*)Sender)->Parent)); } -void __fastcall PanelMinimizeClick(TObject* Sender) + +void __fastcall PanelMinimizeClick(TObject *Sender) { PanelMinimize(((TPanel*)((TControl*)Sender)->Parent)); } -void __fastcall PanelMaximizeClick(TObject* Sender) + +void __fastcall PanelMaximizeClick(TObject *Sender) { PanelMaximize(((TPanel*)((TControl*)Sender)->Parent)); } + //--------------------------------------------------------------------------- -bool TUI::OnCreate(TD3DWindow* w, TPanel* p) +bool TUI::OnCreate(TD3DWindow *w, TPanel *p) { -// create base class - EDevice.InitTimer(); + // create base class + EDevice.InitTimer(); - m_D3DWindow = w; - m_D3DPanel = p; + m_D3DWindow = w; + m_D3DPanel = p; VERIFY(m_D3DWindow); EDevice.Initialize(); - - // Creation - ETOOLS::ray_options (CDB::OPT_ONLYNEAREST | CDB::OPT_CULL); - pInput = xr_new(FALSE,mouse_device_key); - UI->IR_Capture (); + // Creation + ETOOLS::ray_options(CDB::OPT_ONLYNEAREST|CDB::OPT_CULL); - m_bReady = true; + pInput = xr_new(FALSE, mouse_device_key); + UI->IR_Capture(); - if (!CreateMailslot()){ - ELog.DlgMsg (mtError,"Can't create mail slot.\nIt's possible two Editors started."); - return false; + m_bReady = true; + + if (!CreateMailslot()) + { + ELog.DlgMsg(mtError, "Can't create mail slot.\nIt's possible two Editors started."); + return false; } - if (!FS.path_exist(_local_root_)){ - ELog.DlgMsg (mtError,"Undefined Editor local directory."); - return false; + if (!FS.path_exist(_local_root_)) + { + ELog.DlgMsg(mtError, "Undefined Editor local directory."); + return false; } - BeginEState (esEditScene); + BeginEState(esEditScene); return true; } void TUI::OnDestroy() { - VERIFY(m_bReady); - m_bReady = false; - UI->IR_Release (); - xr_delete (pInput); - EndEState (); + VERIFY(m_bReady); + m_bReady = false; + UI->IR_Release(); + xr_delete(pInput); + EndEState(); - EDevice.ShutDown (); - + EDevice.ShutDown(); } -SPBItem* TUI::ProgressStart (float max_val, LPCSTR text) +SPBItem *TUI::ProgressStart(float max_val, LPCSTR text) { - VERIFY(m_bReady); - SPBItem* item = xr_new(text,"",max_val); - m_ProgressItems.push_back (item); - ELog.Msg (mtInformation,text); - ProgressDraw (); - return item; + VERIFY(m_bReady); + SPBItem*item = xr_new(text,"",max_val); + m_ProgressItems.push_back(item); + ELog.Msg(mtInformation, text); + ProgressDraw(); + return item; } -void TUI::ProgressEnd (SPBItem*& pbi) + +void TUI::ProgressEnd(SPBItem *&pbi) { - VERIFY(m_bReady); - if (pbi){ - PBVecIt it=std::find(m_ProgressItems.begin(),m_ProgressItems.end(),pbi); VERIFY(it!=m_ProgressItems.end()); - m_ProgressItems.erase (it); - xr_delete (pbi); - ProgressDraw (); + VERIFY(m_bReady); + if (pbi) + { + PBVecIt it = std::find(m_ProgressItems.begin(), m_ProgressItems.end(), pbi); + VERIFY(it!=m_ProgressItems.end()); + m_ProgressItems.erase(it); + xr_delete(pbi); + ProgressDraw(); } } -void SPBItem::GetInfo (AnsiString& txt, float& p, float& m) +void SPBItem::GetInfo(AnsiString &txt, float &p, float &m) { - if (info.size())txt.sprintf("%s (%s)",text.c_str(),info.c_str()); - else txt.sprintf("%s",text.c_str()); - p = progress; - m = max; -} -void SPBItem::Inc (LPCSTR info, bool bWarn) + if (info.size()) + txt.sprintf("%s (%s)", text.c_str(), info.c_str()); + else + txt.sprintf("%s", text.c_str()); + p = progress; + m = max; +} + +void SPBItem::Inc(LPCSTR info, bool bWarn) { - Info (info,bWarn); - Update (progress+1.f); + Info(info, bWarn); + Update(progress+1.f); } -void SPBItem::Update (float val) + +void SPBItem::Update(float val) { - progress = val; - UI->ProgressDraw (); + progress = val; + UI->ProgressDraw(); } -void SPBItem::Info (LPCSTR text, bool bWarn) + +void SPBItem::Info(LPCSTR text, bool bWarn) { - if (text&&text[0]){ - info = text; - AnsiString txt; - float p,m; - GetInfo (txt,p,m); - ELog.Msg (bWarn?mtError:mtInformation,txt.c_str()); - UI->ProgressDraw (); + if (text&&text[0]) + { + info = text; + AnsiString txt; + float p, m; + GetInfo(txt, p, m); + ELog.Msg(bWarn ? mtError : mtInformation, txt.c_str()); + UI->ProgressDraw(); } } diff --git a/src/editors/ECore/Editor/ui_main.h b/src/editors/ECore/Editor/ui_main.h index 39ccf48cb5a..e7928b16b5c 100644 --- a/src/editors/ECore/Editor/ui_main.h +++ b/src/editors/ECore/Editor/ui_main.h @@ -11,10 +11,12 @@ class CCustomObject; class TUI_Tools; class TUI_Tools; class C3DCursor; + //------------------------------------------------------------------------------ -enum EEditorState{ - esNone, +enum EEditorState +{ + esNone, esEditScene, esEditLibrary, esEditLightAnim, @@ -22,223 +24,234 @@ enum EEditorState{ }; struct ECORE_API SPBItem{ - shared_str text; - shared_str info; - float max; - float progress; -public: - SPBItem (LPCSTR txt, LPCSTR inf, float mx):text(txt),info(inf),max(mx),progress(0.f){} - void GetInfo (AnsiString& txt, float& p, float& m); - void Inc (LPCSTR info=0, bool bWarn=false); - void Update (float val); - void Info (LPCSTR text, bool bWarn=false); + shared_str text; + shared_str info; + float max; + float progress; + public: + SPBItem(LPCSTR txt, LPCSTR inf, float mx):text(txt),info(inf),max(mx),progress(0.f){} + void GetInfo(AnsiString&txt, float& p, float& m); + void Inc(LPCSTR info = 0, bool bWarn = false); + void Update(float val); + void Info(LPCSTR text, bool bWarn = false); }; typedef xr_vector EStateList; typedef EStateList::iterator EStateIt; -class ECORE_API TUI: public IInputReceiver{ -protected: +class ECORE_API TUI: + +public +IInputReceiver +{ + protected: friend class CCustomPreferences; friend class CEditorRenderDevice; TD3DWindow* m_D3DWindow; - TPanel* m_D3DPanel; + TPanel* m_D3DPanel; TShiftState m_ShiftState; bool m_bAppActive; -protected: + protected: EStateList m_EditorState; bool bNeedAbort; -public: - bool m_bReady; + public: + bool m_bReady; TD3DWindow* GetD3DWindow(){return m_D3DWindow;} protected: - Fvector m_Pivot; +Fvector m_Pivot; protected: - bool m_SelectionRect; - Ivector2 m_SelStart; - Ivector2 m_SelEnd; +bool m_SelectionRect; +Ivector2 m_SelStart; +Ivector2 m_SelEnd; protected: - enum{ - flRedraw = (1<<0), - flUpdateScene = (1<<1), - flResize = (1<<2), - flNeedQuit = (1<<3), - }; - Flags32 m_Flags; +enum{ + flRedraw = (1<<0), + flUpdateScene = (1<<1), + flResize = (1<<2), + flNeedQuit = (1<<3), +}; +Flags32 m_Flags; protected: - long m_StartTime; +long m_StartTime; - void PrepareRedraw (); - void Redraw (); +void PrepareRedraw (); +void Redraw (); protected: - void D3D_CreateStateBlocks(); - void D3D_DestroyStateBlocks(); +void D3D_CreateStateBlocks(); +void D3D_DestroyStateBlocks(); public: - virtual void OutUICursorPos ()=0; - virtual void OutGridSize ()=0; - virtual void OutInfo ()=0; +virtual void OutUICursorPos ()=0; +virtual void OutGridSize ()=0; +virtual void OutInfo ()=0; public: - // non-hidden ops - Ivector2 m_StartCp; - Ivector2 m_CurrentCp; +// non-hidden ops +Ivector2 m_StartCp; +Ivector2 m_CurrentCp; - Fvector m_CurrentRStart; - Fvector m_CurrentRDir; +Fvector m_CurrentRStart; +Fvector m_CurrentRDir; - // hidden ops - Ivector2 m_StartCpH; - Ivector2 m_DeltaCpH; +// hidden ops +Ivector2 m_StartCpH; +Ivector2 m_DeltaCpH; protected: - bool m_MouseCaptured; - bool m_MouseMultiClickCaptured; - bool bMouseInUse; +bool m_MouseCaptured; +bool m_MouseMultiClickCaptured; +bool bMouseInUse; - THintWindow* m_pHintWindow; - AnsiString m_LastHint; - bool m_bHintShowing; - POINT m_HintPoint; +THintWindow* m_pHintWindow; +AnsiString m_LastHint; +bool m_bHintShowing; +POINT m_HintPoint; - // mailslot - HANDLE hMailSlot; +// mailslot +HANDLE hMailSlot; public: - void ShowObjectHint(); - void ShowHint(const AnsiString& s); - bool ShowHint(const AStringVec& SS); - void HideHint(); +void ShowObjectHint(); +void ShowHint(const AnsiString& s); +bool ShowHint(const AStringVec& SS); +void HideHint(); public: - // mouse sensetive - float m_MouseSM, m_MouseSS, m_MouseSR; +// mouse sensetive +float m_MouseSM, m_MouseSS, m_MouseSR; protected: - virtual void RealQuit ()=0; - virtual void RealUpdateScene ()=0; - void RealRedrawScene (); - void RealResize (); - void OnFrame (); +virtual void RealQuit ()=0; +virtual void RealUpdateScene ()=0; +void RealRedrawScene (); +void RealResize (); +void OnFrame (); public: - TUI (); - virtual ~TUI (); +TUI (); +virtual ~TUI (); - void Quit () { m_Flags.set(flNeedQuit,TRUE); } +void Quit () { m_Flags.set(flNeedQuit,TRUE); } - IC HANDLE GetHWND () { return m_D3DWindow->Handle; } - int GetRenderWidth () { return EDevice.dwWidth; } - int GetRenderHeight () { return EDevice.dwHeight; } - int GetRealWidth () { return EDevice.m_RealWidth; } - int GetRealHeight () { return EDevice.m_RealHeight; } +IC HANDLE GetHWND () { return m_D3DWindow->Handle; } +int GetRenderWidth () { return EDevice.dwWidth; } +int GetRenderHeight () { return EDevice.dwHeight; } +int GetRealWidth () { return EDevice.m_RealWidth; } +int GetRealHeight () { return EDevice.m_RealHeight; } - IC float ZFar () { return EDevice.m_Camera.m_Zfar; } - IC TShiftState GetShiftState () { return m_ShiftState; } +IC float ZFar () { return EDevice.m_Camera.m_Zfar; } +IC TShiftState GetShiftState () { return m_ShiftState; } - virtual bool OnCreate (TD3DWindow* w, TPanel* p); - virtual void OnDestroy (); +virtual bool OnCreate (TD3DWindow* w, TPanel* p); +virtual void OnDestroy (); - virtual char* GetCaption ()=0; +virtual char* GetCaption ()=0; - bool IsModified (); +bool IsModified (); - void __fastcall Idle (); - void Resize (bool bForced=false){ m_Flags.set(flResize|flRedraw,TRUE);if (bForced) RealResize(); } - // add, remove, changing objects/scene - void UpdateScene (bool bForced=false){ m_Flags.set(flUpdateScene,TRUE); if (bForced) RealUpdateScene();} - // only redraw scene - void RedrawScene (bool bForced=false){ m_Flags.set(flRedraw,TRUE); if (bForced) RealRedrawScene();} +void __fastcall Idle (); +void Resize (bool bForced=false){ m_Flags.set(flResize|flRedraw,TRUE);if (bForced) RealResize(); } +// add, remove, changing objects/scene +void UpdateScene (bool bForced=false){ m_Flags.set(flUpdateScene,TRUE); if (bForced) RealUpdateScene();} +// only redraw scene +void RedrawScene (bool bForced=false){ m_Flags.set(flRedraw,TRUE); if (bForced) RealRedrawScene();} - void SetRenderQuality (float q) { EDevice.m_ScreenQuality = q;} +void SetRenderQuality (float q) { EDevice.m_ScreenQuality = q;} // mouse action - void EnableSelectionRect (bool flag ); - void UpdateSelectionRect (const Ivector2& from, const Ivector2& to ); - - void MouseMultiClickCapture(bool b){m_MouseMultiClickCaptured = b;} - - bool __fastcall IsMouseCaptured () { return m_MouseCaptured|m_MouseMultiClickCaptured;} - bool __fastcall IsMouseInUse () { return bMouseInUse;} - - bool __fastcall KeyDown (WORD Key, TShiftState Shift); - bool __fastcall KeyUp (WORD Key, TShiftState Shift); - bool __fastcall KeyPress (WORD Key, TShiftState Shift); - void __fastcall MousePress (TShiftState Shift, int X, int Y); - void __fastcall MouseRelease (TShiftState Shift, int X, int Y); - void __fastcall MouseMove (TShiftState Shift, int X, int Y); - - void BeginEState (EEditorState st){ m_EditorState.push_back(st); } - void EndEState (){ m_EditorState.pop_back(); } - void EndEState (EEditorState st){ - VERIFY(std::find(m_EditorState.begin(),m_EditorState.end(),st)!=m_EditorState.end()); - for (EStateIt it=m_EditorState.end()-1; it>=m_EditorState.begin(); it--) - if (*it==st){ - m_EditorState.erase(it,m_EditorState.end()); - break; - } - } - EEditorState GetEState (){ return m_EditorState.back(); } - bool ContainEState (EEditorState st){ return std::find(m_EditorState.begin(),m_EditorState.end(),st)!=m_EditorState.end(); } - - virtual void OutCameraPos ()=0; - virtual void SetStatus (LPSTR s, bool bOutLog=true)=0; - virtual void ResetStatus ()=0; - - // direct input - virtual void IR_OnMouseMove (int x, int y); - - void OnAppActivate (); - void OnAppDeactivate (); - - bool NeedAbort (){Application->ProcessMessages(); return bNeedAbort;} - void NeedBreak (){bNeedAbort = true;} - void ResetBreak (){bNeedAbort = false;} - - virtual bool ApplyShortCut (WORD Key, TShiftState Shift)=0; - virtual bool ApplyGlobalShortCut (WORD Key, TShiftState Shift)=0; - - void SetGradient (u32 color){;} - - void OnDeviceCreate (); - void OnDeviceDestroy (); - - // mailslot - bool CreateMailslot (); - void CheckMailslot (); - void OnReceiveMail (LPCSTR msg); - void SendMail (LPCSTR name, LPCSTR dest, LPCSTR msg); - - void CheckWindowPos (TForm* form); - - virtual LPCSTR EditorName ()=0; - virtual LPCSTR EditorDesc ()=0; +void EnableSelectionRect (bool flag ); +void UpdateSelectionRect (const Ivector2& from, const Ivector2& to ); + +void MouseMultiClickCapture(bool b){m_MouseMultiClickCaptured = b;} + +bool __fastcall IsMouseCaptured () { return m_MouseCaptured|m_MouseMultiClickCaptured;} +bool __fastcall IsMouseInUse () { return bMouseInUse;} + +bool __fastcall KeyDown (WORD Key, TShiftState Shift); +bool __fastcall KeyUp (WORD Key, TShiftState Shift); +bool __fastcall KeyPress (WORD Key, TShiftState Shift); +void __fastcall MousePress (TShiftState Shift, int X, int Y); +void __fastcall MouseRelease (TShiftState Shift, int X, int Y); +void __fastcall MouseMove (TShiftState Shift, int X, int Y); + +void BeginEState (EEditorState st){ m_EditorState.push_back(st); } +void EndEState (){ m_EditorState.pop_back(); } +void EndEState (EEditorState st){ + VERIFY(std::find(m_EditorState.begin(),m_EditorState.end(),st)!=m_EditorState.end()); + for (EStateIt it=m_EditorState.end()-1; it>=m_EditorState.begin(); it--) + if (*it==st){ + m_EditorState.erase(it,m_EditorState.end()); + break; +} +} +EEditorState GetEState (){ return m_EditorState.back(); } +bool ContainEState (EEditorState st){ return std::find(m_EditorState.begin(),m_EditorState.end(),st)!=m_EditorState.end(); } + +virtual void OutCameraPos ()=0; +virtual void SetStatus (LPSTR s, bool bOutLog=true)=0; +virtual void ResetStatus ()=0; + +// direct input +virtual void IR_OnMouseMove (int x, int y); + +void OnAppActivate (); +void OnAppDeactivate (); + +bool NeedAbort (){Application->ProcessMessages(); return bNeedAbort;} +void NeedBreak (){bNeedAbort = true;} +void ResetBreak (){bNeedAbort = false;} + +virtual bool ApplyShortCut (WORD Key, TShiftState Shift)=0; +virtual bool ApplyGlobalShortCut (WORD Key, TShiftState Shift)=0; + +void SetGradient (u32 color){;} + +void OnDeviceCreate (); +void OnDeviceDestroy (); + +// mailslot +bool CreateMailslot (); +void CheckMailslot (); +void OnReceiveMail (LPCSTR msg); +void SendMail (LPCSTR name, LPCSTR dest, LPCSTR msg); + +void CheckWindowPos (TForm* form); + +virtual LPCSTR EditorName ()=0; +virtual LPCSTR EditorDesc ()=0; // commands - virtual void RegisterCommands ()=0; - void ClearCommands (); - - CCommandVar CommandRenderFocus (CCommandVar p1, CCommandVar p2); - CCommandVar CommandBreakLastOperation (CCommandVar p1, CCommandVar p2); - CCommandVar CommandRenderResize (CCommandVar p1, CCommandVar p2); - - virtual void SaveSettings (CInifile*){} - virtual void LoadSettings (CInifile*){} -protected: +virtual void RegisterCommands ()=0; +void ClearCommands (); + +CCommandVar CommandRenderFocus (CCommandVar p1, CCommandVar p2); +CCommandVar CommandBreakLastOperation (CCommandVar p1, CCommandVar p2); +CCommandVar CommandRenderResize (CCommandVar p1, CCommandVar p2); + +virtual void SaveSettings (CInifile*){} +virtual void LoadSettings (CInifile*){} +protected: // progress bar - DEFINE_VECTOR (SPBItem*,PBVec,PBVecIt); - PBVec m_ProgressItems; +DEFINE_VECTOR (SPBItem*,PBVec,PBVecIt); +PBVec m_ProgressItems; public: - SPBItem* ProgressStart (float max_val, LPCSTR text); - void ProgressEnd (SPBItem*&); - virtual void ProgressDraw ()=0; - SPBItem* ProgressLast (){return m_ProgressItems.empty()?0:m_ProgressItems.back();} +SPBItem* ProgressStart (float max_val, LPCSTR text); +void ProgressEnd (SPBItem*&); +virtual void ProgressDraw ()=0; +SPBItem* ProgressLast (){return m_ProgressItems.empty()?0:m_ProgressItems.back();} }; //--------------------------------------------------------------------------- -extern ECORE_API TUI* UI; +extern ECORE_API TUI* UI; //--------------------------------------------------------------------------- void ECORE_API ResetActionToSelect(); #define COMMAND0(cmd) {ExecCommand(cmd);bExec=true;} #define COMMAND1(cmd,p0) {ExecCommand(cmd,p0);bExec=true;} -extern ECORE_API void __fastcall PanelMinMax (TPanel *pa); -extern ECORE_API void __fastcall PanelMinimize (TPanel *pa); -extern ECORE_API void __fastcall PanelMaximize (TPanel *pa); -extern ECORE_API void __fastcall PanelMinMaxClick (TObject *sender); -extern ECORE_API void __fastcall PanelMinimizeClick (TObject *sender); -extern ECORE_API void __fastcall PanelMaximizeClick (TObject *sender); +extern ECORE_API +void __fastcall PanelMinMax(TPanel*pa); +extern ECORE_API +void __fastcall PanelMinimize(TPanel*pa); +extern ECORE_API +void __fastcall PanelMaximize(TPanel*pa); +extern ECORE_API +void __fastcall PanelMinMaxClick(TObject*sender); +extern ECORE_API +void __fastcall PanelMinimizeClick(TObject*sender); +extern ECORE_API +void __fastcall PanelMaximizeClick(TObject*sender); //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/ECore/Editor/xrLoadSurface.cpp b/src/editors/ECore/Editor/xrLoadSurface.cpp index 706ba64c4bc..5d72387349a 100644 --- a/src/editors/ECore/Editor/xrLoadSurface.cpp +++ b/src/editors/ECore/Editor/xrLoadSurface.cpp @@ -3,125 +3,152 @@ #include "freeimage/freeimage.h" -struct SExts{ - xr_vector exts; +struct SExts +{ + xr_vector exts; + void format_register(LPCSTR ext) { - if (ext&&ext[0]){ - for (u32 i=0; i0) { - _close(h); - return TRUE; - } - } - return FALSE; + for (u32 i = 0; i0) + { + _close(h); + return TRUE; + } + } + return FALSE; } -FIBITMAP* Surface_Load(char* full_name) +FIBITMAP *Surface_Load(char *full_name) { - // load - FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(full_name); - FIBITMAP* map = FreeImage_Load(fif,full_name); - if (0==map) return NULL; + // load + FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(full_name); + FIBITMAP *map = FreeImage_Load(fif, full_name); + if (0==map) + return NULL; - // check if already 32bpp - if (32==FreeImage_GetBPP(map)) return map; + // check if already 32bpp + if (32==FreeImage_GetBPP(map)) + return map; - // convert - FIBITMAP* map32 = FreeImage_ConvertTo32Bits(map); - if (0==map32) map32 = map; - else FreeImage_Unload(map); + // convert + FIBITMAP *map32 = FreeImage_ConvertTo32Bits(map); + if (0==map32) + map32 = map; + else + FreeImage_Unload(map); - return map32; + return map32; } -u32* Surface_Load(char* name, u32& w, u32& h) +u32 *Surface_Load(char *name, u32 &w, u32 &h) { - if (strchr(name,'.')) *(strchr(name,'.')) = 0; + if (strchr(name, '.')) + *(strchr(name, '.')) = 0; - // detect format - string_path full; - if (!Surface_Detect(full,name)) return NULL; + // detect format + string_path full; + if (!Surface_Detect(full, name)) + return NULL; - FIBITMAP* map32 = Surface_Load(full); + FIBITMAP *map32 = Surface_Load(full); - h = FreeImage_GetHeight (map32); - w = FreeImage_GetWidth (map32); + h = FreeImage_GetHeight(map32); + w = FreeImage_GetWidth(map32); - u32 memSize = w*h*4; - u32* memPTR = (u32*)(xr_malloc(memSize)); - u32* memDATA = (u32*)(FreeImage_GetScanLine(map32,0)); - CopyMemory (memPTR,memDATA,memSize); - FreeImage_Unload (map32); - return memPTR; + u32 memSize = w*h*4; + u32 *memPTR = (u32*)(xr_malloc(memSize)); + u32 *memDATA = (u32*)(FreeImage_GetScanLine(map32, 0)); + CopyMemory(memPTR, memDATA, memSize); + FreeImage_Unload(map32); + return memPTR; } + diff --git a/src/editors/ECore/Engine/GameMtlLib.cpp b/src/editors/ECore/Engine/GameMtlLib.cpp new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Engine/GameMtlLib.cpp @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Engine/GameMtlLib.h b/src/editors/ECore/Engine/GameMtlLib.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Engine/GameMtlLib.h @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Engine/GameMtlLib_Engine.cpp b/src/editors/ECore/Engine/GameMtlLib_Engine.cpp new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Engine/GameMtlLib_Engine.cpp @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Engine/Image.cpp b/src/editors/ECore/Engine/Image.cpp index 8c3a4c047b9..0a340bd82f0 100644 --- a/src/editors/ECore/Engine/Image.cpp +++ b/src/editors/ECore/Engine/Image.cpp @@ -8,103 +8,116 @@ #include "Image.h" #include "../../../Layers/xrRender/tga.h" -void CImage::Create(u32 w, u32 h, u32* data) +void CImage::Create(u32 w, u32 h, u32 *data) { - Create(w,h); - CopyMemory(pData,data,w*h*sizeof(u32)); + Create(w, h); + CopyMemory(pData, data, w*h*sizeof(u32)); } void CImage::Create(u32 w, u32 h) { - xr_free (pData); - dwWidth = w; - dwHeight = h; - pData = (u32*)(xr_malloc(w*h*sizeof(u32))); + xr_free(pData); + dwWidth = w; + dwHeight = h; + pData = (u32*)(xr_malloc(w*h*sizeof(u32))); } void CImage::SaveTGA(LPCSTR name, BOOL b24) { - // Save - TGAdesc tga; - tga.data = pData; - tga.format = b24?IMG_24B:IMG_32B; - tga.height = dwHeight; - tga.width = dwWidth; - tga.scanlenght=dwWidth*4; - - IWriter* F = FS.w_open(name); - if (F){ - tga.maketga (*F); - FS.w_close (F); - }else{ - Log ("!Can't save tga:",name); + // Save + TGAdesc tga; + tga.data = pData; + tga.format = b24 ? IMG_24B : IMG_32B; + tga.height = dwHeight; + tga.width = dwWidth; + tga.scanlenght = dwWidth*4; + + IWriter *F = FS.w_open(name); + if (F) + { + tga.maketga(*F); + FS.w_close(F); + } + else + { + Log("!Can't save tga:", name); } } void CImage::Vflip() { - R_ASSERT(pData); - for (u32 y=0; y255) c=255; + int c = iFloor(a); + if (c<0) + c = 0; else if (c>255) + c = 255; return BYTE(c); } void CImage::Contrast(float _fc) { - R_ASSERT(pData); + R_ASSERT(pData); // Apply contrast correction - char *ptr = (char *)pData; - float fc = _fc*2.f; - for (u32 i=0; idwWidth; - dwHeight= hdr->dwHeight; - bAlpha = TUisAlphaPresents(hdr->fmt); + void* data = DownloadFile(name); + _fileT* hdr = (_fileT*)data; + u32* pixels = (u32 *) ((char *)data + sizeof(_fileT)); + dwWidth = hdr->dwWidth; + dwHeight= hdr->dwHeight; + bAlpha = TUisAlphaPresents(hdr->fmt); - pData = (u32*)xr_malloc(dwWidth*dwHeight*4); - // CopyMemory(pData,pixels,dwWidth*dwHeight*4); + pData = (u32*)xr_malloc(dwWidth*dwHeight*4); + // CopyMemory(pData,pixels,dwWidth*dwHeight*4); - xr_free(data); + xr_free(data); } */ @@ -162,137 +175,165 @@ void CImage::LoadT(char *name) #define RGBA_GETBLUE(rgb) u32((rgb) & 0xff) #endif -#pragma pack(push,1) // Gotta pack these structures! +#pragma pack(push,1) // Gotta pack these structures! + struct TGAHeader { - BYTE idlen; - BYTE cmtype; - BYTE imgtype; - - u16 cmorg; - u16 cmlen; - BYTE cmes; - - short xorg; - short yorg; - short width; - short height; - BYTE pixsize; - BYTE desc; + BYTE idlen; + BYTE cmtype; + BYTE imgtype; + + u16 cmorg; + u16 cmlen; + BYTE cmes; + + short xorg; + short yorg; + short width; + short height; + BYTE pixsize; + BYTE desc; }; #pragma pack(pop) -extern u32 *Surface_Load(char*,u32&,u32&); +extern u32 *Surface_Load(char *, u32 &, u32 &); -void CImage::Load (LPCSTR name) +void CImage::Load(LPCSTR name) { - VERIFY (!pData); - pData = Surface_Load((LPSTR)name,dwWidth,dwHeight); + VERIFY(!pData); + pData = Surface_Load((LPSTR)name, dwWidth, dwHeight); } bool CImage::LoadTGA(LPCSTR name) { - destructor TGA(FS.r_open(name)); + destructor TGA(FS.r_open(name)); - TGAHeader hdr; - BOOL hflip, vflip; + TGAHeader hdr; + BOOL hflip, vflip; - TGA().r(&hdr,sizeof(TGAHeader)); + TGA().r(&hdr, sizeof(TGAHeader)); - if (!((hdr.imgtype==2)||(hdr.imgtype==10))){ - Msg("Unsupported texture format (%s)",name); + if (!((hdr.imgtype==2)||(hdr.imgtype==10))) + { + Msg("Unsupported texture format (%s)", name); return false; } - if (!((hdr.pixsize==24)||(hdr.pixsize==32))){ - Msg("Texture (%s) - invalid pixsize: %d",name,hdr.pixsize); + if (!((hdr.pixsize==24)||(hdr.pixsize==32))) + { + Msg("Texture (%s) - invalid pixsize: %d", name, hdr.pixsize); return false; } #ifndef _EDITOR - if (!btwIsPow2(hdr.width)){ - Msg("Texture (%s) - invalid width: %d",name,hdr.width); + if (!btwIsPow2(hdr.width)) + { + Msg("Texture (%s) - invalid width: %d", name, hdr.width); return false; } - if (!btwIsPow2(hdr.height)){ - Msg("Texture (%s) - invalid height: %d",name,hdr.height); + if (!btwIsPow2(hdr.height)) + { + Msg("Texture (%s) - invalid height: %d", name, hdr.height); return false; } #endif - // Skip funky stuff - if (hdr.idlen) TGA().advance(hdr.idlen); - if (hdr.cmlen) TGA().advance(hdr.cmlen*((hdr.cmes+7)/8)); + // Skip funky stuff + if (hdr.idlen) + TGA().advance(hdr.idlen); + if (hdr.cmlen) + TGA().advance(hdr.cmlen*((hdr.cmes+7)/8)); - hflip = (hdr.desc & 0x10) ? TRUE : FALSE; // Need hflip - vflip = (hdr.desc & 0x20) ? TRUE : FALSE; // Need vflip + hflip = (hdr.desc&0x10) ? TRUE : FALSE; // Need hflip + vflip = (hdr.desc&0x20) ? TRUE : FALSE; // Need vflip - dwWidth = hdr.width; - dwHeight = hdr.height; - bAlpha = (hdr.pixsize==32); + dwWidth = hdr.width; + dwHeight = hdr.height; + bAlpha = (hdr.pixsize==32); - // Alloc memory - pData = (u32*)xr_malloc(dwWidth*dwHeight*4); + // Alloc memory + pData = (u32*)xr_malloc(dwWidth*dwHeight*4); u32 pixel; - u32* ptr = pData; - for( int y=0; y Mapping; - typedef xr_set< Edge > EdgeSet; - typedef xr_vector< xr_set< unsigned int > > IdenticalVertices; + typedef xr_map Mapping; + typedef xr_set EdgeSet; + typedef xr_vector> IdenticalVertices; IdenticalVertices IdenticalVertices_; // make room for potential tex coords, normals, binormals and tangents - output.resize( input.size() + 4 ); + output.resize(input.size()+4); Mapping inmap; Mapping outmap; - for ( unsigned int a = 0; a < input.size(); ++a ) + for (unsigned int a = 0; a EmptySet; + xr_set EmptySet; - for ( unsigned int i = 0; i < positions.size(); i += 3 ) + for (unsigned int i = 0; i(positions.size() / 3.0f); - - for ( unsigned int i = 0; i < theCount; ++i ) - { - maxPosition.x = nv_max( maxPosition.x, pPositions[ i ].x ); - maxPosition.y = nv_max( maxPosition.y, pPositions[ i ].y ); - maxPosition.z = nv_max( maxPosition.z, pPositions[ i ].z ); - - minPosition.x = nv_min( minPosition.x, pPositions[ i ].x ); - minPosition.y = nv_min( minPosition.y, pPositions[ i ].y ); - minPosition.z = nv_min( minPosition.z, pPositions[ i ].z ); - } - - // Find major, minor and other axis for cylindrical texgen - - vec3 delta = maxPosition - minPosition; - - delta.x = _abs( delta.x ); - delta.y = _abs( delta.y ); - delta.z = _abs( delta.z ); - - bool maxx,maxy,maxz; - maxx = maxy = maxz = false; - bool minz,miny,minx; - minx = miny = minz = false; - - nv_scalar deltaMajor; - - if ( ( delta.x >= delta.y ) && ( delta.x >= delta.z ) ) - { - maxx = true; - deltaMajor = delta.x; - if ( delta.y > delta.z ) - { - minz = true; - } - else - { - miny = true; - } - } - else - if ( ( delta.z >= delta.y ) && ( delta.z >= delta.x ) ) - { - maxz = true; - deltaMajor = delta.z; - if ( delta.y > delta.x ) - { - minx = true; - } - else - { - miny = true; - } - } - else - if ( ( delta.y >= delta.z ) && ( delta.y >= delta.x ) ) - { - maxy = true; - deltaMajor = delta.y; - if ( delta.x > delta.z ) - { - minz = true; - } - else - { - minx = true; - } - } - - for ( unsigned int p = 0; p < theCount; ++p ) - { - // Find position relative to center of bounding box - - vec3 texCoords = ( ( maxPosition + minPosition ) / 2.0f ) - pPositions[ p ]; - - nv_scalar Major, Minor, Other = nv_zero; - - if ( maxx ) - { - Major = texCoords.x; - if ( miny ) - { - Minor = texCoords.y; - Other = texCoords.z; - } else { - Minor = texCoords.z; - Other = texCoords.y; - } - } - else - if ( maxy ) - { - Major = texCoords.y; - if ( minx ) - { - Minor = texCoords.x; - Other = texCoords.z; - } else { - Minor = texCoords.z; - Other = texCoords.x; - } - } - else - if ( maxz ) - { - Major = texCoords.z; - if ( miny ) - { - Minor = texCoords.y; - Other = texCoords.x; - } else { - Minor = texCoords.x; - Other = texCoords.y; - } - } - - nv_scalar longitude = nv_zero; - - // Prevent zero or near-zero from being passed into atan2 - if ( _abs( Other ) < 0.0001f ) - { - if ( Other >= nv_zero ) - { - Other = 0.0001f; - } else { - Other = -0.0001f; - } - } - - // perform cylindrical mapping onto object, and remap from -pi,pi to -1,1 - - longitude = (( atan2( Minor, Other ) ) / nv_scalar(3.141592654)); - - texCoords.x = 0.5f * longitude + 0.5f; - texCoords.y = (Major/deltaMajor) + 0.5f; - - texCoords.x = nv_max( texCoords.x, nv_zero ); - texCoords.y = nv_max( texCoords.y, nv_zero ); - - texCoords.x = nv_min( texCoords.x, 1.0f ); - texCoords.y = nv_min( texCoords.y, 1.0f ); - - pTex0[ p ].x = texCoords.x-0.25f; - if ( pTex0[ p ].x < nv_zero ) pTex0[ p ].x += 1.0; - pTex0[ p ].y = 1.0f-texCoords.y; - pTex0[ p ].z = 1.0f; - } - } - - if ( _FixCylindricalTexGen == FixCylindricalTexGen ) - { - Mapping::iterator texIter = outmap.find( "tex0" ); - - VertexAttribute::FloatVector& texcoords = ( output[ (*texIter).second ].floatVector_ ); - - const unsigned int theSize = indices.size(); - - for ( unsigned int f = 0; f < theSize; f += 3 ) - { - for ( int v = 0; v < 3; ++v ) - { - int start = f + v; - int end = start + 1; - - if ( v == 2 ) - { - end = f; - } - - nv_scalar dS = texcoords[ indices[ end ] * 3 + 0 ] - texcoords[ indices[ start ] * 3 + 0 ]; - - nv_scalar newS = nv_zero; - - bool bDoS = false; - - unsigned int theOneToChange = start; - - if ( _abs( dS ) >= 0.5f ) - { - bDoS = true; - if ( texcoords[ indices[ start ] * 3 + 0 ] < texcoords[ indices[ end ] * 3 + 0 ] ) - { - newS = texcoords[ indices[ start ]* 3 + 0 ] + 1.0f; - } - else - { - theOneToChange = end; - newS = texcoords[ indices[ end ] * 3 + 0 ] + 1.0f; - } - } - - if ( bDoS == true ) - { - unsigned int theNewIndex = texcoords.size() / 3; - // Duplicate every part of the vertex - for ( unsigned int att = 0; att < output.size(); ++att ) - { - // No new indices are created, just vertex attributes - if ( output[ att ].Name_ != "indices" ) - { - if ( output[ att ].Name_ == "tex0" ) - { - output[ att ].floatVector_.push_back( (float)newS ); // y - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 1 ] ); // x - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 2 ] ); // z - } - else - { - // *3 b/c we are looking up 3vectors in an array of floats - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 0 ] ); // x - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 1 ] ); // y - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 2 ] ); // z - } - } - } - - IdenticalVertices_.push_back( EmptySet ); - - IdenticalVertices_[ indices[ theOneToChange ] ].insert( theNewIndex ); - IdenticalVertices_[ theNewIndex ].insert( indices[ theOneToChange ] ); - - // point to where the new vertices will go - indices[ theOneToChange ] = theNewIndex; - } - - } // for v - - { - - for ( int v = 0; v < 3; ++v ) - { - int start = f + v; - int end = start + 1; - - if ( v == 2 ) - { - end = f; - } - - nv_scalar dT = texcoords[ indices[ end ] * 3 + 1 ] - texcoords[ indices[ start ] * 3 + 1 ]; - - nv_scalar newT = nv_zero; - - bool bDoT = false; - - unsigned int theOneToChange = start; - - if ( _abs( dT ) >= 0.5f ) - { - bDoT = true; - if ( texcoords[ indices[ start ] * 3 + 1 ] < texcoords[ indices[ end ] * 3 + 1 ] ) - { - newT = texcoords[ indices[ start ] * 3 + 1 ] + 1.0f; - } - else - { - theOneToChange = end; - newT = texcoords[ indices[ end ] * 3 + 1 ] + 1.0f; - } - } - - if ( bDoT == true ) - { - unsigned int theNewIndex = texcoords.size() / 3; - // Duplicate every part of the vertex - for ( unsigned int att = 0; att < output.size(); ++att ) - { - // No new indices are created, just vertex attributes - if ( output[ att ].Name_ != "indices" ) - { - if ( output[ att ].Name_ == "tex0" ) - { - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 0 ] ); // x - output[ att ].floatVector_.push_back( (float) newT ); // y - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 2 ] ); // z - } - else - { - // *3 b/c we are looking up 3vectors in an array of floats - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 0 ] ); // x - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 1 ] ); // y - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ theOneToChange ] * 3 + 2 ] ); // z - } - } - } - - IdenticalVertices_.push_back( EmptySet ); - - IdenticalVertices_[ theNewIndex ].insert( indices[ theOneToChange ] ); - IdenticalVertices_[ indices[ theOneToChange ] ].insert( theNewIndex ); - - // point to where the new vertices will go - indices[ theOneToChange ] = theNewIndex; - } - } - - } // for v - - } // for f - } // if fix texgen - if (pTextureMatrix) { - const mat4 M( pTextureMatrix[0], pTextureMatrix[1], pTextureMatrix[2], pTextureMatrix[3], - pTextureMatrix[4], pTextureMatrix[5], pTextureMatrix[6], pTextureMatrix[7], - pTextureMatrix[8], pTextureMatrix[9], pTextureMatrix[10], pTextureMatrix[11], - pTextureMatrix[12], pTextureMatrix[13], pTextureMatrix[14], pTextureMatrix[15]); - Mapping::iterator texIter = outmap.find("tex0"); - VertexAttribute::FloatVector& texcoords = output[(*texIter).second].floatVector_; - - // now apply matrix - for (unsigned int v = 0; v < texcoords.size(); v += 3) { - vec3& V = *reinterpret_cast(&texcoords[v]); - V = V * M; - } - } + if (have_texcoords) + output[(*want).second].floatVector_ = input[(*have).second].floatVector_; + else + { + // just initialize array so it's the correct size + output[(*want).second].floatVector_ = positions; + + pTex0 = (vec3*)(&(output[(*want).second].floatVector_[0])); + + // Generate cylindrical coordinates + + // Find min and max positions for object bounding box + + vec3 maxPosition(-flt_max, -flt_max, -flt_max); + vec3 minPosition(flt_max, flt_max, flt_max); + + // there are 1/3 as many vectors as floats + const unsigned int theCount = static_cast(positions.size()/3.0f); + + for (unsigned int i = 0; i=delta.y)&&(delta.x>=delta.z)) + { + maxx = true; + deltaMajor = delta.x; + if (delta.y>delta.z) + { + minz = true; + } + else + { + miny = true; + } + } + else if ((delta.z>=delta.y)&&(delta.z>=delta.x)) + { + maxz = true; + deltaMajor = delta.z; + if (delta.y>delta.x) + { + minx = true; + } + else + { + miny = true; + } + } + else if ((delta.y>=delta.z)&&(delta.y>=delta.x)) + { + maxy = true; + deltaMajor = delta.y; + if (delta.x>delta.z) + { + minz = true; + } + else + { + minx = true; + } + } + + for (unsigned int p = 0; p=nv_zero) + { + Other = 0.0001f; + } + else + { + Other = -0.0001f; + } + } + + // perform cylindrical mapping onto object, and remap from -pi,pi to -1,1 + + longitude = ((atan2(Minor, Other))/nv_scalar(3.141592654)); + + texCoords.x = 0.5f*longitude+0.5f; + texCoords.y = (Major/deltaMajor)+0.5f; + + texCoords.x = nv_max(texCoords.x, nv_zero); + texCoords.y = nv_max(texCoords.y, nv_zero); + + texCoords.x = nv_min(texCoords.x, 1.0f); + texCoords.y = nv_min(texCoords.y, 1.0f); + + pTex0[p].x = texCoords.x-0.25f; + if (pTex0[p].x=0.5f) + { + bDoS = true; + if (texcoords[indices[start]*3+0]=0.5f) + { + bDoT = true; + if (texcoords[indices[start]*3+1](&texcoords[v]); + V = V*M; + } + } } - if ( bComputeTangentSpace ) - { + if (bComputeTangentSpace) + { EdgeSet Edges; - Mapping::iterator texIter = outmap.find( "tex0" ); + Mapping::iterator texIter = outmap.find("tex0"); - vec3* tex = (vec3*)&( output[ (*texIter).second ].floatVector_[ 0 ] ); + vec3 *tex = (vec3*)&(output[(*texIter).second].floatVector_[0]); - typedef xr_vector< vec3 > VecVector; + typedef xr_vector VecVector; // create tangents - want = outmap.find( "tangent" ); - if ( want == outmap.end() ) - { - VertexAttribute tanAtt; - tanAtt.Name_ = "tangent"; - output.push_back( tanAtt ); - outmap[ "tangent" ] = output.size() - 1; - want = outmap.find( "tangent" ); + want = outmap.find("tangent"); + if (want==outmap.end()) + { + VertexAttribute tanAtt; + tanAtt.Name_ = "tangent"; + output.push_back(tanAtt); + outmap["tangent"] = output.size()-1; + want = outmap.find("tangent"); } - // just initialize array so it's the correct size - output[ (*want).second ].floatVector_ = positions; + // just initialize array so it's the correct size + output[(*want).second].floatVector_ = positions; // create binormals - want = outmap.find( "binormal" ); - if ( want == outmap.end() ) - { - VertexAttribute binAtt; - binAtt.Name_ = "binormal"; - output.push_back( binAtt ); - outmap[ "binormal" ] = output.size() - 1; - want = outmap.find( "binormal" ); + want = outmap.find("binormal"); + if (want==outmap.end()) + { + VertexAttribute binAtt; + binAtt.Name_ = "binormal"; + output.push_back(binAtt); + outmap["binormal"] = output.size()-1; + want = outmap.find("binormal"); } - // just initialize array so it's the correct size - output[ (*want).second ].floatVector_ = positions; + // just initialize array so it's the correct size + output[(*want).second].floatVector_ = positions; // Create a vector of s,t and sxt for each face of the model VecVector sVector; @@ -679,210 +682,227 @@ bool NVMeshMender::Munge( const NVMeshMender::VAVector& input, VecVector sxtVector; const unsigned int theSize = indices.size(); - // for each face, calculate its S,T & SxT vector, & store its edges - for ( unsigned int f = 0; f < theSize; f += 3 ) - { - vec3d edge0; - vec3d edge1; + // for each face, calculate its S,T & SxT vector, & store its edges + for (unsigned int f = 0; f _eps ) ds_dx = - b / a; - double dt_dx = nv_zero; if ( _abs( a ) > _eps ) dt_dx = - c / a; - - // create an edge out of y, s and t - edge0.x = pPositions[ indices[ f + 1 ] ].y - pPositions[ indices[ f ] ].y; - edge1.x = pPositions[ indices[ f + 2 ] ].y - pPositions[ indices[ f ] ].y; - sxt = edge0 ^ edge1; - - a=sxt.x;b=sxt.y;c= sxt.z; - double ds_dy = nv_zero; if ( _abs( a ) > _eps ) ds_dy = -b / a; - double dt_dy = nv_zero; if ( _abs( a ) > _eps ) dt_dy = -c / a; - - // create an edge out of z, s and t - edge0.x = pPositions[ indices[ f + 1 ] ].z - pPositions[ indices[ f ] ].z; - edge1.x = pPositions[ indices[ f + 2 ] ].z - pPositions[ indices[ f ] ].z; - sxt = edge0 ^ edge1; - - a=sxt.x;b=sxt.y;c= sxt.z; - double ds_dz = nv_zero; if ( _abs( a ) > _eps ) ds_dz = -b / a; - double dt_dz = nv_zero; if ( _abs( a ) > _eps ) dt_dz = -c / a; + pPositions = (vec3*) (&(positions[0])); + tex = (vec3*) (&(output[(*texIter).second].floatVector_[0])); + + double _eps = type_epsilon(double)*10; + double a, b, c; + vec3d sxt; + + // create an edge(s) out of s and t + edge0.y = tex[indices[f+1]].x-tex[indices[f]].x; + edge0.z = tex[indices[f+1]].y-tex[indices[f]].y; + edge1.y = tex[indices[f+2]].x-tex[indices[f]].x; + edge1.z = tex[indices[f+2]].y-tex[indices[f]].y; + + // create an edge out of x, s and t + edge0.x = pPositions[indices[f+1]].x-pPositions[indices[f]].x; + edge1.x = pPositions[indices[f+2]].x-pPositions[indices[f]].x; + sxt = edge0^edge1; + + a = sxt.x; + b = sxt.y; + c = sxt.z; + double ds_dx = nv_zero; + if (_abs(a)>_eps) + ds_dx = - b/a; + double dt_dx = nv_zero; + if (_abs(a)>_eps) + dt_dx = - c/a; + + // create an edge out of y, s and t + edge0.x = pPositions[indices[f+1]].y-pPositions[indices[f]].y; + edge1.x = pPositions[indices[f+2]].y-pPositions[indices[f]].y; + sxt = edge0^edge1; + + a = sxt.x; + b = sxt.y; + c = sxt.z; + double ds_dy = nv_zero; + if (_abs(a)>_eps) + ds_dy = -b/a; + double dt_dy = nv_zero; + if (_abs(a)>_eps) + dt_dy = -c/a; + + // create an edge out of z, s and t + edge0.x = pPositions[indices[f+1]].z-pPositions[indices[f]].z; + edge1.x = pPositions[indices[f+2]].z-pPositions[indices[f]].z; + sxt = edge0^edge1; + + a = sxt.x; + b = sxt.y; + c = sxt.z; + double ds_dz = nv_zero; + if (_abs(a)>_eps) + ds_dz = -b/a; + double dt_dz = nv_zero; + if (_abs(a)>_eps) + dt_dz = -c/a; // generate coordinate frame from the gradients - s = vec3d( ds_dx, ds_dy, ds_dz ); - t = vec3d( dt_dx, dt_dy, dt_dz ); + s = vec3d(ds_dx, ds_dy, ds_dz); + t = vec3d(dt_dx, dt_dy, dt_dz); - s.normalize (); - t.normalize (); - sxt = s ^ t; - sxt.normalize (); + s.normalize(); + t.normalize(); + sxt = s^t; + sxt.normalize(); // save vectors for this face - sVector.push_back ( vec3(s) ); - tVector.push_back ( vec3(t) ); - sxtVector.push_back ( vec3(sxt) ); - - if ( _FixTangents == FixTangents ) - { - // Look for each edge of the triangle in the edge map, in order to find - // a neighboring face along the edge - - for ( int e = 0; e < 3; ++e ) - { - Edge edge; - - int start = f + e; - int end = start + 1; - - if ( e == 2 ) - { - end = f; - } - // order vertex indices ( low, high ) - edge.v0 = (unsigned int)nv_min( (nv_scalar)indices[ start ], (nv_scalar)indices[ end ] ); - edge.v1 = (unsigned int)nv_max( (nv_scalar)indices[ start ], (nv_scalar)indices[ end ] ); - - EdgeSet::iterator iter = Edges.find( edge ); - - // if we are the only triangle with this edge... - if ( iter == Edges.end() ) - { - // ...then add us to the set of edges - edge.face = f / 3; - Edges.insert( edge ); - } - else - { - // otherwise, check our neighbor's s,t & sxt vectors vs our own - const nv_scalar sAgreement = dot(s, sVector[(*iter).face]); - const nv_scalar tAgreement = dot(t, tVector[(*iter).face]); - const nv_scalar sxtAgreement = dot(sxt, sxtVector[(*iter).face]); - - // Check Radian angle split limit - const nv_scalar epsilon = _cos( bSmoothCreaseAngleRadians ); - - // if the discontinuity in s, t, or sxt is greater than some epsilon, - // duplicate the vertex so it won't smooth with its neighbor anymore - - if ( ( _abs( sAgreement ) < epsilon ) || - ( _abs( tAgreement ) < epsilon ) || - ( _abs( sxtAgreement ) < epsilon ) ) - { - // Duplicate two vertices of this edge for this triangle only. - // This way the faces won't smooth with each other, thus - // preventing the tangent basis from becoming degenerate - - // divide by 3 b/c vector is of floats and not vectors - const unsigned int theNewIndex = positions.size() / 3; - - // Duplicate every part of the vertex - for ( unsigned int att = 0; att < output.size(); ++att ) - { - // No new indices are created, just vertex attributes - if ( output[ att ].Name_ != "indices" ) - { - // *3 b/c we are looking up 3vectors in an array of floats - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ start ] * 3 + 0 ] ); // x - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ start ] * 3 + 1 ] ); // y - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ start ] * 3 + 2 ] ); // z - - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ end ] * 3 + 0 ] ); // x - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ end ] * 3 + 1 ] ); // y - output[ att ].floatVector_.push_back( output[ att ].floatVector_[ indices[ end ] * 3 + 2 ] ); // z - } - } - - IdenticalVertices_.push_back( EmptySet ); - IdenticalVertices_.push_back( EmptySet ); - - // point to where the new vertices will go - indices[ start ] = theNewIndex; - indices[ end ] = theNewIndex + 1; - - } - - // Now that the vertices are duplicated, smoothing won't occur over this edge, - // because the two faces will sum their tangent basis vectors into separate indices - } - } - } // if fixtangents - } + sVector.push_back(vec3(s)); + tVector.push_back(vec3(t)); + sxtVector.push_back(vec3(sxt)); + + if (_FixTangents==FixTangents) + { + // Look for each edge of the triangle in the edge map, in order to find + // a neighboring face along the edge + + for (int e = 0; e<3; ++e) + { + Edge edge; + + int start = f+e; + int end = start+1; + + if (e==2) + { + end = f; + } + // order vertex indices ( low, high ) + edge.v0 = (unsigned int)nv_min((nv_scalar)indices[start], (nv_scalar)indices[end]); + edge.v1 = (unsigned int)nv_max((nv_scalar)indices[start], (nv_scalar)indices[end]); + + EdgeSet::iterator iter = Edges.find(edge); + + // if we are the only triangle with this edge... + if (iter==Edges.end()) + { + // ...then add us to the set of edges + edge.face = f/3; + Edges.insert(edge); + } + else + { + // otherwise, check our neighbor's s,t & sxt vectors vs our own + const nv_scalar sAgreement = dot(s, sVector[(*iter).face]); + const nv_scalar tAgreement = dot(t, tVector[(*iter).face]); + const nv_scalar sxtAgreement = dot(sxt, sxtVector[(*iter).face]); + + // Check Radian angle split limit + const nv_scalar epsilon = _cos(bSmoothCreaseAngleRadians); + + // if the discontinuity in s, t, or sxt is greater than some epsilon, + // duplicate the vertex so it won't smooth with its neighbor anymore + + if ((_abs(sAgreement)::iterator iter = IdenticalVertices_[ v ].begin(); - iter != IdenticalVertices_[ v ].end(); - ++iter ) + for (xr_set::iterator iter = IdenticalVertices_[v].begin(); + iter!=IdenticalVertices_[v].end(); + ++iter) { - avgS[ v ] += avgS[ *iter ]; - avgT[ v ] += avgT[ *iter ]; + avgS[v] += avgS[*iter]; + avgT[v] += avgT[*iter]; } } } - Mapping::iterator tangent = outmap.find( "tangent" ); - Mapping::iterator binormal = outmap.find( "binormal" ); + Mapping::iterator tangent = outmap.find("tangent"); + Mapping::iterator binormal = outmap.find("binormal"); // now renormalize - for ( unsigned int b = 0; b < positions.size(); b += 3 ) + for (unsigned int b = 0; b(&output[(*tangent).second].floatVector_[b]) = normalize(avgS[b / 3]); // s - *reinterpret_cast(&output[(*binormal).second].floatVector_[b]) = normalize(avgT[b / 3]); // T + *reinterpret_cast(&output[(*tangent).second].floatVector_[b]) = normalize(avgS[b/3]); // s + *reinterpret_cast(&output[(*binormal).second].floatVector_[b]) = normalize(avgT[b/3]); // T } - } + } - // At this point, tex coords, normals, binormals and tangents should be generated if necessary, - // and other attributes are simply copied as available + // At this point, tex coords, normals, binormals and tangents should be generated if necessary, + // and other attributes are simply copied as available return true; } diff --git a/src/editors/ECore/Engine/NVMeshMender.h b/src/editors/ECore/Engine/NVMeshMender.h index d2680b5aeda..d6dc2930344 100644 --- a/src/editors/ECore/Engine/NVMeshMender.h +++ b/src/editors/ECore/Engine/NVMeshMender.h @@ -129,127 +129,130 @@ Questions to sim.dietrich@nvidia.com class NVMeshMender { - private : +private : - mutable xr_vector< xr_string > LastErrors_; + mutable xr_vector LastErrors_; - struct Edge - { - unsigned int v0; - unsigned int v1; + struct Edge + { + unsigned int v0; + unsigned int v1; - unsigned int face; - unsigned int face2; + unsigned int face; + unsigned int face2; - bool operator==( const Edge& rhs ) const - { - return ( ( v0 == rhs.v0 ) && ( v1 == rhs.v1 ) ); - } - - bool operator<( const Edge& rhs ) const - { - if ( v0 < rhs.v0 ) - { - return true; - } - - if ( v0 > rhs.v0 ) - { - return false; - } - - return ( v1 < rhs.v1 ); - } - }; - - public : - - void SetLastError( const xr_string& rhs ) const + bool operator==(const Edge &rhs) const { - LastErrors_.push_back( rhs ); + return ((v0==rhs.v0)&&(v1==rhs.v1)); } - xr_string GetLastError() const + bool operator<(const Edge &rhs) const { - xr_string aString; + if (v0 0 ) + if (v0>rhs.v0) { - aString = LastErrors_.back(); + return false; } - return aString; + + return (v10) { - xr_string Name_; + aString = LastErrors_.back(); + } + return aString; + } - typedef xr_vector< int > IntVector; - IntVector intVector_; + struct VertexAttribute + { + xr_string Name_; + typedef xr_vector IntVector; + IntVector intVector_; - typedef xr_vector< float > FloatVector; - FloatVector floatVector_; - VertexAttribute& operator=( const VertexAttribute& rhs ) - { - Name_ = rhs.Name_; - intVector_ = rhs.intVector_; - floatVector_ = rhs.floatVector_; - return *this; - } + typedef xr_vector FloatVector; + FloatVector floatVector_; - VertexAttribute( const char* pName = "" ) : Name_(pName) {;} + VertexAttribute &operator=(const VertexAttribute &rhs) + { + Name_ = rhs.Name_; + intVector_ = rhs.intVector_; + floatVector_ = rhs.floatVector_; + return *this; + } - VertexAttribute( const VertexAttribute& rhs ) - { - *this = rhs; - } + VertexAttribute(const char *pName = "") : Name_(pName) + { + ; + } - bool operator==( const VertexAttribute& rhs ) - { - return ( Name_ == rhs.Name_ ); - } + VertexAttribute(const VertexAttribute &rhs) + { + *this = rhs; + } - bool operator<( const VertexAttribute& rhs ) - { - return ( Name_ < rhs.Name_ ); - } + bool operator==(const VertexAttribute &rhs) + { + return (Name_==rhs.Name_); + } - }; - - typedef xr_vector< VertexAttribute > VAVector; - - enum Option - { - FixTangents, - DontFixTangents, - - FixCylindricalTexGen, - DontFixCylindricalTexGen, - - WeightNormalsByFaceSize, - DontWeightNormalsByFaceSize - }; - - bool NVMeshMender::Munge( const NVMeshMender::VAVector& input, - NVMeshMender::VAVector& output, - const float bSmoothCreaseAngleRadians = 3.141592654f / 3.0f, - const float* pTextureMatrix = 0, - const Option _FixTangents = FixTangents, - const Option _FixCylindricalTexGen = FixCylindricalTexGen, - const Option _WeightNormalsByFaceSize = WeightNormalsByFaceSize - ); - bool NVMeshMender::MungeD3DX( const NVMeshMender::VAVector& input, - NVMeshMender::VAVector& output, - const float bSmoothCreaseAngleRadians = 3.141592654f / 3.0f, - const float* pTextureMatrix = 0, - const Option _FixTangents = FixTangents, - const Option _FixCylindricalTexGen = FixCylindricalTexGen, - const Option _WeightNormalsByFaceSize = WeightNormalsByFaceSize - ); + bool operator<(const VertexAttribute &rhs) + { + return (Name_ VAVector; + + enum Option + { + FixTangents, + DontFixTangents, + + FixCylindricalTexGen, + DontFixCylindricalTexGen, + + WeightNormalsByFaceSize, + DontWeightNormalsByFaceSize + }; + + bool NVMeshMender::Munge(const NVMeshMender::VAVector &input, + NVMeshMender::VAVector &output, + const float bSmoothCreaseAngleRadians = 3.141592654f/3.0f, + const float *pTextureMatrix = 0, + const Option _FixTangents = FixTangents, + const Option _FixCylindricalTexGen = FixCylindricalTexGen, + const Option _WeightNormalsByFaceSize = WeightNormalsByFaceSize + ); + bool NVMeshMender::MungeD3DX(const NVMeshMender::VAVector &input, + NVMeshMender::VAVector &output, + const float bSmoothCreaseAngleRadians = 3.141592654f/3.0f, + const float *pTextureMatrix = 0, + const Option _FixTangents = FixTangents, + const Option _FixCylindricalTexGen = FixCylindricalTexGen, + const Option _WeightNormalsByFaceSize = WeightNormalsByFaceSize + ); }; -#endif //_NVMeshMender_H_ +#endif //_NVMeshMender_H_ + diff --git a/src/editors/ECore/Engine/Texture.h b/src/editors/ECore/Engine/Texture.h index 66e2b112d34..62f6c8cdd9c 100644 --- a/src/editors/ECore/Engine/Texture.h +++ b/src/editors/ECore/Engine/Texture.h @@ -7,6 +7,8 @@ #pragma once // Wizzard pack -extern ENGINE_API IDirect3DBaseTexture9* TWLoader2D (LPCSTR fname); +extern ENGINE_API IDirect3DBaseTexture9 *TWLoader2D(LPCSTR fname); #endif // !defined(AFX_TEXTURE_H__0E25CF47_FFEC_11D3_B4E3_4854E82A090D__INCLUDED_) + + diff --git a/src/editors/ECore/Engine/ai_sounds.cpp b/src/editors/ECore/Engine/ai_sounds.cpp index 5f60eeb15a4..40e4e32725b 100644 --- a/src/editors/ECore/Engine/ai_sounds.cpp +++ b/src/editors/ECore/Engine/ai_sounds.cpp @@ -3,27 +3,28 @@ #include "ai_sounds.h" -xr_token anomaly_type_token[]={ - { "undefined", sg_Undefined }, - { "Item picking up", SOUND_TYPE_ITEM_PICKING_UP }, - { "Item dropping", SOUND_TYPE_ITEM_DROPPING }, - { "Item taking", SOUND_TYPE_ITEM_TAKING }, - { "Item hiding", SOUND_TYPE_ITEM_HIDING }, - { "Item using", SOUND_TYPE_ITEM_USING }, - { "Weapon shooting", SOUND_TYPE_WEAPON_SHOOTING }, - { "Weapon empty clicking", SOUND_TYPE_WEAPON_EMPTY_CLICKING }, - { "Weapon bullet hit", SOUND_TYPE_WEAPON_BULLET_HIT }, - { "Weapon recharging", SOUND_TYPE_WEAPON_RECHARGING }, - { "NPC dying", SOUND_TYPE_MONSTER_DYING }, - { "NPC injuring", SOUND_TYPE_MONSTER_INJURING }, - { "NPC step", SOUND_TYPE_MONSTER_STEP }, - { "NPC talking", SOUND_TYPE_MONSTER_TALKING }, - { "NPC attacking", SOUND_TYPE_MONSTER_ATTACKING }, - { "NPC eating", SOUND_TYPE_MONSTER_EATING }, - { "Anomaly idle", SOUND_TYPE_ANOMALY_IDLE }, - { "Object breaking", SOUND_TYPE_WORLD_OBJECT_BREAKING }, - { "Object colliding", SOUND_TYPE_WORLD_OBJECT_COLLIDING }, - { "Object exploding", SOUND_TYPE_WORLD_OBJECT_EXPLODING }, - { "World ambient", SOUND_TYPE_WORLD_AMBIENT }, - { 0, 0} +xr_token anomaly_type_token[] = { + {"undefined", sg_Undefined}, + {"Item picking up", SOUND_TYPE_ITEM_PICKING_UP}, + {"Item dropping", SOUND_TYPE_ITEM_DROPPING}, + {"Item taking", SOUND_TYPE_ITEM_TAKING}, + {"Item hiding", SOUND_TYPE_ITEM_HIDING}, + {"Item using", SOUND_TYPE_ITEM_USING}, + {"Weapon shooting", SOUND_TYPE_WEAPON_SHOOTING}, + {"Weapon empty clicking", SOUND_TYPE_WEAPON_EMPTY_CLICKING}, + {"Weapon bullet hit", SOUND_TYPE_WEAPON_BULLET_HIT}, + {"Weapon recharging", SOUND_TYPE_WEAPON_RECHARGING}, + {"NPC dying", SOUND_TYPE_MONSTER_DYING}, + {"NPC injuring", SOUND_TYPE_MONSTER_INJURING}, + {"NPC step", SOUND_TYPE_MONSTER_STEP}, + {"NPC talking", SOUND_TYPE_MONSTER_TALKING}, + {"NPC attacking", SOUND_TYPE_MONSTER_ATTACKING}, + {"NPC eating", SOUND_TYPE_MONSTER_EATING}, + {"Anomaly idle", SOUND_TYPE_ANOMALY_IDLE}, + {"Object breaking", SOUND_TYPE_WORLD_OBJECT_BREAKING}, + {"Object colliding", SOUND_TYPE_WORLD_OBJECT_COLLIDING}, + {"Object exploding", SOUND_TYPE_WORLD_OBJECT_EXPLODING}, + {"World ambient", SOUND_TYPE_WORLD_AMBIENT}, + {0, 0} }; + diff --git a/src/editors/ECore/Engine/ai_sounds.h b/src/editors/ECore/Engine/ai_sounds.h index 66ef42b72d5..ff37c065e2d 100644 --- a/src/editors/ECore/Engine/ai_sounds.h +++ b/src/editors/ECore/Engine/ai_sounds.h @@ -9,72 +9,73 @@ #ifndef ai_soundsH #define ai_soundsH -enum ESoundTypes { - SOUND_TYPE_NO_SOUND = 0x00000000ui32, - - SOUND_TYPE_WEAPON = 0x80000000ui32, - SOUND_TYPE_ITEM = 0x40000000ui32, - SOUND_TYPE_MONSTER = 0x20000000ui32, - SOUND_TYPE_ANOMALY = 0x10000000ui32, - SOUND_TYPE_WORLD = 0x08000000ui32, - - SOUND_TYPE_PICKING_UP = 0x04000000ui32, - SOUND_TYPE_DROPPING = 0x02000000ui32, - SOUND_TYPE_HIDING = 0x01000000ui32, - SOUND_TYPE_TAKING = 0x00800000ui32, - SOUND_TYPE_USING = 0x00400000ui32, - - SOUND_TYPE_SHOOTING = 0x00200000ui32, - SOUND_TYPE_EMPTY_CLICKING = 0x00100000ui32, - SOUND_TYPE_BULLET_HIT = 0x00080000ui32, - SOUND_TYPE_RECHARGING = 0x00040000ui32, - - SOUND_TYPE_DYING = 0x00020000ui32, - SOUND_TYPE_INJURING = 0x00010000ui32, - SOUND_TYPE_STEP = 0x00008000ui32, - SOUND_TYPE_TALKING = 0x00004000ui32, - SOUND_TYPE_ATTACKING = 0x00002000ui32, - SOUND_TYPE_EATING = 0x00001000ui32, - - SOUND_TYPE_IDLE = 0x00000800ui32, - - SOUND_TYPE_OBJECT_BREAKING = 0x00000400ui32, - SOUND_TYPE_OBJECT_COLLIDING = 0x00000200ui32, - SOUND_TYPE_OBJECT_EXPLODING = 0x00000100ui32, - SOUND_TYPE_AMBIENT = 0x00000080ui32, - - SOUND_TYPE_ITEM_PICKING_UP = SOUND_TYPE_ITEM | SOUND_TYPE_PICKING_UP, - SOUND_TYPE_ITEM_DROPPING = SOUND_TYPE_ITEM | SOUND_TYPE_DROPPING, - SOUND_TYPE_ITEM_HIDING = SOUND_TYPE_ITEM | SOUND_TYPE_HIDING, - SOUND_TYPE_ITEM_TAKING = SOUND_TYPE_ITEM | SOUND_TYPE_TAKING, - SOUND_TYPE_ITEM_USING = SOUND_TYPE_ITEM | SOUND_TYPE_USING, - - SOUND_TYPE_WEAPON_SHOOTING = SOUND_TYPE_WEAPON | SOUND_TYPE_SHOOTING, - SOUND_TYPE_WEAPON_EMPTY_CLICKING = SOUND_TYPE_WEAPON | SOUND_TYPE_EMPTY_CLICKING, - SOUND_TYPE_WEAPON_BULLET_HIT = SOUND_TYPE_WEAPON | SOUND_TYPE_BULLET_HIT, - SOUND_TYPE_WEAPON_RECHARGING = SOUND_TYPE_WEAPON | SOUND_TYPE_RECHARGING, - - SOUND_TYPE_MONSTER_DYING = SOUND_TYPE_MONSTER | SOUND_TYPE_DYING, - SOUND_TYPE_MONSTER_INJURING = SOUND_TYPE_MONSTER | SOUND_TYPE_INJURING, - SOUND_TYPE_MONSTER_STEP = SOUND_TYPE_MONSTER | SOUND_TYPE_STEP, - SOUND_TYPE_MONSTER_TALKING = SOUND_TYPE_MONSTER | SOUND_TYPE_TALKING, - SOUND_TYPE_MONSTER_ATTACKING = SOUND_TYPE_MONSTER | SOUND_TYPE_ATTACKING, - SOUND_TYPE_MONSTER_EATING = SOUND_TYPE_MONSTER | SOUND_TYPE_EATING, - - SOUND_TYPE_ANOMALY_IDLE = SOUND_TYPE_ANOMALY | SOUND_TYPE_IDLE, - - SOUND_TYPE_WORLD_OBJECT_BREAKING = SOUND_TYPE_WORLD | SOUND_TYPE_OBJECT_BREAKING, - SOUND_TYPE_WORLD_OBJECT_COLLIDING = SOUND_TYPE_WORLD | SOUND_TYPE_OBJECT_COLLIDING, - SOUND_TYPE_WORLD_OBJECT_EXPLODING = SOUND_TYPE_WORLD | SOUND_TYPE_OBJECT_EXPLODING, - SOUND_TYPE_WORLD_AMBIENT = SOUND_TYPE_WORLD | SOUND_TYPE_AMBIENT, - - SOUND_TYPE_WEAPON_PISTOL = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_GUN = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_SUBMACHINEGUN = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_MACHINEGUN = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_SNIPERRIFLE = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_GRENADELAUNCHER = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_ROCKETLAUNCHER = SOUND_TYPE_WEAPON, +enum ESoundTypes +{ + SOUND_TYPE_NO_SOUND = 0x00000000ui32, + + SOUND_TYPE_WEAPON = 0x80000000ui32, + SOUND_TYPE_ITEM = 0x40000000ui32, + SOUND_TYPE_MONSTER = 0x20000000ui32, + SOUND_TYPE_ANOMALY = 0x10000000ui32, + SOUND_TYPE_WORLD = 0x08000000ui32, + + SOUND_TYPE_PICKING_UP = 0x04000000ui32, + SOUND_TYPE_DROPPING = 0x02000000ui32, + SOUND_TYPE_HIDING = 0x01000000ui32, + SOUND_TYPE_TAKING = 0x00800000ui32, + SOUND_TYPE_USING = 0x00400000ui32, + + SOUND_TYPE_SHOOTING = 0x00200000ui32, + SOUND_TYPE_EMPTY_CLICKING = 0x00100000ui32, + SOUND_TYPE_BULLET_HIT = 0x00080000ui32, + SOUND_TYPE_RECHARGING = 0x00040000ui32, + + SOUND_TYPE_DYING = 0x00020000ui32, + SOUND_TYPE_INJURING = 0x00010000ui32, + SOUND_TYPE_STEP = 0x00008000ui32, + SOUND_TYPE_TALKING = 0x00004000ui32, + SOUND_TYPE_ATTACKING = 0x00002000ui32, + SOUND_TYPE_EATING = 0x00001000ui32, + + SOUND_TYPE_IDLE = 0x00000800ui32, + + SOUND_TYPE_OBJECT_BREAKING = 0x00000400ui32, + SOUND_TYPE_OBJECT_COLLIDING = 0x00000200ui32, + SOUND_TYPE_OBJECT_EXPLODING = 0x00000100ui32, + SOUND_TYPE_AMBIENT = 0x00000080ui32, + + SOUND_TYPE_ITEM_PICKING_UP = SOUND_TYPE_ITEM|SOUND_TYPE_PICKING_UP, + SOUND_TYPE_ITEM_DROPPING = SOUND_TYPE_ITEM|SOUND_TYPE_DROPPING, + SOUND_TYPE_ITEM_HIDING = SOUND_TYPE_ITEM|SOUND_TYPE_HIDING, + SOUND_TYPE_ITEM_TAKING = SOUND_TYPE_ITEM|SOUND_TYPE_TAKING, + SOUND_TYPE_ITEM_USING = SOUND_TYPE_ITEM|SOUND_TYPE_USING, + + SOUND_TYPE_WEAPON_SHOOTING = SOUND_TYPE_WEAPON|SOUND_TYPE_SHOOTING, + SOUND_TYPE_WEAPON_EMPTY_CLICKING = SOUND_TYPE_WEAPON|SOUND_TYPE_EMPTY_CLICKING, + SOUND_TYPE_WEAPON_BULLET_HIT = SOUND_TYPE_WEAPON|SOUND_TYPE_BULLET_HIT, + SOUND_TYPE_WEAPON_RECHARGING = SOUND_TYPE_WEAPON|SOUND_TYPE_RECHARGING, + + SOUND_TYPE_MONSTER_DYING = SOUND_TYPE_MONSTER|SOUND_TYPE_DYING, + SOUND_TYPE_MONSTER_INJURING = SOUND_TYPE_MONSTER|SOUND_TYPE_INJURING, + SOUND_TYPE_MONSTER_STEP = SOUND_TYPE_MONSTER|SOUND_TYPE_STEP, + SOUND_TYPE_MONSTER_TALKING = SOUND_TYPE_MONSTER|SOUND_TYPE_TALKING, + SOUND_TYPE_MONSTER_ATTACKING = SOUND_TYPE_MONSTER|SOUND_TYPE_ATTACKING, + SOUND_TYPE_MONSTER_EATING = SOUND_TYPE_MONSTER|SOUND_TYPE_EATING, + + SOUND_TYPE_ANOMALY_IDLE = SOUND_TYPE_ANOMALY|SOUND_TYPE_IDLE, + + SOUND_TYPE_WORLD_OBJECT_BREAKING = SOUND_TYPE_WORLD|SOUND_TYPE_OBJECT_BREAKING, + SOUND_TYPE_WORLD_OBJECT_COLLIDING = SOUND_TYPE_WORLD|SOUND_TYPE_OBJECT_COLLIDING, + SOUND_TYPE_WORLD_OBJECT_EXPLODING = SOUND_TYPE_WORLD|SOUND_TYPE_OBJECT_EXPLODING, + SOUND_TYPE_WORLD_AMBIENT = SOUND_TYPE_WORLD|SOUND_TYPE_AMBIENT, + + SOUND_TYPE_WEAPON_PISTOL = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_GUN = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_SUBMACHINEGUN = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_MACHINEGUN = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_SNIPERRIFLE = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_GRENADELAUNCHER = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_ROCKETLAUNCHER = SOUND_TYPE_WEAPON, }; #define CROUCH_SOUND_FACTOR .3f @@ -83,3 +84,4 @@ enum ESoundTypes { extern xr_token anomaly_type_token[]; #endif + diff --git a/src/editors/ECore/Engine/bone.cpp b/src/editors/ECore/Engine/bone.cpp new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Engine/bone.cpp @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Engine/cl_collector.cpp b/src/editors/ECore/Engine/cl_collector.cpp index 69966916e73..c448f94b574 100644 --- a/src/editors/ECore/Engine/cl_collector.cpp +++ b/src/editors/ECore/Engine/cl_collector.cpp @@ -10,3 +10,5 @@ ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// + + diff --git a/src/editors/ECore/Engine/cl_collector.h b/src/editors/ECore/Engine/cl_collector.h index 85b72fbac85..59b9094bd24 100644 --- a/src/editors/ECore/Engine/cl_collector.h +++ b/src/editors/ECore/Engine/cl_collector.h @@ -7,3 +7,5 @@ #pragma once #endif // !defined(AFX_CL_COLLECTOR_H__F107ABA0_E877_4C5A_8EFF_DAB3A86ABDB6__INCLUDED_) + + diff --git a/src/editors/ECore/Engine/cl_intersect.h b/src/editors/ECore/Engine/cl_intersect.h new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/editors/ECore/Engine/cl_intersect.h @@ -0,0 +1 @@ + diff --git a/src/editors/ECore/Engine/guid_generator.cpp b/src/editors/ECore/Engine/guid_generator.cpp index b34dd1871c8..a1c874a270e 100644 --- a/src/editors/ECore/Engine/guid_generator.cpp +++ b/src/editors/ECore/Engine/guid_generator.cpp @@ -18,7 +18,7 @@ xrGUID generate_guid() { - xrGUID result; + xrGUID result; #ifdef WINVER STATIC_CHECK (sizeof(xrGUID) == sizeof(GUID),Different_GUID_types); GUID _result; @@ -31,9 +31,10 @@ xrGUID generate_guid() default : break; } #endif - STATIC_CHECK (sizeof(result) >= sizeof(u64),GUID_must_have_size_greater_or_equal_to_the_long_long); - ZeroMemory (&result,sizeof(result)); - u64 temp = CPU::GetCLK(); - Memory.mem_copy (&result,&temp,sizeof(temp)); - return (result); + STATIC_CHECK(sizeof(result)>=sizeof(u64), GUID_must_have_size_greater_or_equal_to_the_long_long); + ZeroMemory(&result, sizeof(result)); + u64 temp = CPU::GetCLK(); + Memory.mem_copy(&result, &temp, sizeof(temp)); + return (result); } + diff --git a/src/editors/ECore/Engine/guid_generator.h b/src/editors/ECore/Engine/guid_generator.h index fdeb24f0171..a02eb660eaa 100644 --- a/src/editors/ECore/Engine/guid_generator.h +++ b/src/editors/ECore/Engine/guid_generator.h @@ -15,3 +15,5 @@ ENGINE_API extern xrGUID generate_guid(); #endif //guid_generatorH + + diff --git a/src/editors/ECore/Engine/nv_algebra.cpp b/src/editors/ECore/Engine/nv_algebra.cpp index 0e254e6a1d6..55c857c2c43 100644 --- a/src/editors/ECore/Engine/nv_algebra.cpp +++ b/src/editors/ECore/Engine/nv_algebra.cpp @@ -24,96 +24,92 @@ from the use or inability to use this file or items derived from it. #define _finite finite #endif -mat3::mat3() -{ -} +mat3::mat3() {} -mat3::mat3(const nv_scalar* array) +mat3::mat3(const nv_scalar *array) { - Memory.mem_copy(mat_array, array, sizeof(nv_scalar) * 9); + Memory.mem_copy(mat_array, array, sizeof(nv_scalar)*9); } -mat3::mat3(const mat3 & M) +mat3::mat3(const mat3 &M) { - Memory.mem_copy(mat_array, M.mat_array, sizeof(nv_scalar) * 9); + Memory.mem_copy(mat_array, M.mat_array, sizeof(nv_scalar)*9); } -mat4::mat4() -{ -} +mat4::mat4() {} -mat4::mat4(const nv_scalar* array) +mat4::mat4(const nv_scalar *array) { - Memory.mem_copy(mat_array, array, sizeof(nv_scalar) * 16); + Memory.mem_copy(mat_array, array, sizeof(nv_scalar)*16); } -mat4::mat4(const mat4& M) +mat4::mat4(const mat4 &M) { - Memory.mem_copy(mat_array, M.mat_array, sizeof(nv_scalar) * 16); + Memory.mem_copy(mat_array, M.mat_array, sizeof(nv_scalar)*16); } -vec3 & cross(vec3 & u, const vec3 & v, const vec3 & w) +vec3 &cross(vec3 &u, const vec3 &v, const vec3 &w) { - u.x = v.y*w.z - v.z*w.y; - u.y = v.z*w.x - v.x*w.z; - u.z = v.x*w.y - v.y*w.x; + u.x = v.y*w.z-v.z*w.y; + u.y = v.z*w.x-v.x*w.z; + u.z = v.x*w.y-v.y*w.x; return u; } -nv_scalar & dot(nv_scalar& u, const vec3& v, const vec3& w) +nv_scalar &dot(nv_scalar &u, const vec3 &v, const vec3 &w) { - u = v.x*w.x + v.y*w.y + v.z*w.z; + u = v.x*w.x+v.y*w.y+v.z*w.z; return u; } -nv_scalar dot(const vec3& v, const vec3& w) +nv_scalar dot(const vec3 &v, const vec3 &w) { - return v.x*w.x + v.y*w.y + v.z*w.z; + return v.x*w.x+v.y*w.y+v.z*w.z; } -nv_scalar & dot(nv_scalar& u, const vec4& v, const vec4& w) +nv_scalar &dot(nv_scalar &u, const vec4 &v, const vec4 &w) { - u = v.x*w.x + v.y*w.y + v.z*w.z + v.w*w.w; + u = v.x*w.x+v.y*w.y+v.z*w.z+v.w*w.w; return u; } -nv_scalar dot(const vec4& v, const vec4& w) +nv_scalar dot(const vec4 &v, const vec4 &w) { - return v.x*w.x + v.y*w.y + v.z*w.z + v.w*w.w; + return v.x*w.x+v.y*w.y+v.z*w.z+v.w*w.w; } -nv_scalar & dot(nv_scalar& u, const vec3& v, const vec4& w) +nv_scalar &dot(nv_scalar &u, const vec3 &v, const vec4 &w) { - u = v.x*w.x + v.y*w.y + v.z*w.z; + u = v.x*w.x+v.y*w.y+v.z*w.z; return u; } -nv_scalar dot(const vec3& v, const vec4& w) +nv_scalar dot(const vec3 &v, const vec4 &w) { - return v.x*w.x + v.y*w.y + v.z*w.z; + return v.x*w.x+v.y*w.y+v.z*w.z; } -nv_scalar & dot(nv_scalar& u, const vec4& v, const vec3& w) +nv_scalar &dot(nv_scalar &u, const vec4 &v, const vec3 &w) { - u = v.x*w.x + v.y*w.y + v.z*w.z; + u = v.x*w.x+v.y*w.y+v.z*w.z; return u; } -nv_scalar dot(const vec4& v, const vec3& w) +nv_scalar dot(const vec4 &v, const vec3 &w) { - return v.x*w.x + v.y*w.y + v.z*w.z; + return v.x*w.x+v.y*w.y+v.z*w.z; } -vec3 & reflect(vec3& r, const vec3& n, const vec3& l) +vec3 &reflect(vec3 &r, const vec3 &n, const vec3 &l) { nv_scalar n_dot_l; - n_dot_l = nv_two * dot(n_dot_l,n,l); - mult(r,l,-nv_one); - madd(r,n,n_dot_l); + n_dot_l = nv_two*dot(n_dot_l, n, l); + mult(r, l, -nv_one); + madd(r, n, n_dot_l); return r; } -vec3 & madd(vec3 & u, const vec3& v, const nv_scalar& lambda) +vec3 &madd(vec3 &u, const vec3 &v, const nv_scalar &lambda) { u.x += v.x*lambda; u.y += v.y*lambda; @@ -121,7 +117,7 @@ vec3 & madd(vec3 & u, const vec3& v, const nv_scalar& lambda) return u; } -vec3 & mult(vec3 & u, const vec3& v, const nv_scalar& lambda) +vec3 &mult(vec3 &u, const vec3 &v, const nv_scalar &lambda) { u.x = v.x*lambda; u.y = v.y*lambda; @@ -129,7 +125,7 @@ vec3 & mult(vec3 & u, const vec3& v, const nv_scalar& lambda) return u; } -vec3 & mult(vec3 & u, const vec3& v, const vec3& w) +vec3 &mult(vec3 &u, const vec3 &v, const vec3 &w) { u.x = v.x*w.x; u.y = v.y*w.y; @@ -137,23 +133,23 @@ vec3 & mult(vec3 & u, const vec3& v, const vec3& w) return u; } -vec3 & sub(vec3 & u, const vec3& v, const vec3& w) +vec3 &sub(vec3 &u, const vec3 &v, const vec3 &w) { - u.x = v.x - w.x; - u.y = v.y - w.y; - u.z = v.z - w.z; + u.x = v.x-w.x; + u.y = v.y-w.y; + u.z = v.z-w.z; return u; } -vec3 & add(vec3 & u, const vec3& v, const vec3& w) +vec3 &add(vec3 &u, const vec3 &v, const vec3 &w) { - u.x = v.x + w.x; - u.y = v.y + w.y; - u.z = v.z + w.z; + u.x = v.x+w.x; + u.y = v.y+w.y; + u.z = v.z+w.z; return u; } -vec3 & scale(vec3& u, const nv_scalar s) +vec3 &scale(vec3 &u, const nv_scalar s) { u.x *= s; u.y *= s; @@ -161,7 +157,7 @@ vec3 & scale(vec3& u, const nv_scalar s) return u; } -vec4 & scale(vec4& u, const nv_scalar s) +vec4 &scale(vec4 &u, const nv_scalar s) { u.x *= s; u.y *= s; @@ -170,129 +166,129 @@ vec4 & scale(vec4& u, const nv_scalar s) return u; } -vec3 & mult(vec3& u, const mat3& M, const vec3& v) +vec3 &mult(vec3 &u, const mat3 &M, const vec3 &v) { - u.x = M.a00 * v.x + M.a01 * v.y + M.a02 * v.z; - u.y = M.a10 * v.x + M.a11 * v.y + M.a12 * v.z; - u.z = M.a20 * v.x + M.a21 * v.y + M.a22 * v.z; + u.x = M.a00*v.x+M.a01*v.y+M.a02*v.z; + u.y = M.a10*v.x+M.a11*v.y+M.a12*v.z; + u.z = M.a20*v.x+M.a21*v.y+M.a22*v.z; return u; } -vec3 & mult(vec3& u, const vec3& v, const mat3& M) +vec3 &mult(vec3 &u, const vec3 &v, const mat3 &M) { - u.x = M.a00 * v.x + M.a10 * v.y + M.a20 * v.z; - u.y = M.a01 * v.x + M.a11 * v.y + M.a21 * v.z; - u.z = M.a02 * v.x + M.a12 * v.y + M.a22 * v.z; + u.x = M.a00*v.x+M.a10*v.y+M.a20*v.z; + u.y = M.a01*v.x+M.a11*v.y+M.a21*v.z; + u.z = M.a02*v.x+M.a12*v.y+M.a22*v.z; return u; } -const vec3 operator*(const mat3& M, const vec3& v) +const vec3 operator*(const mat3 &M, const vec3 &v) { - vec3 u; - u.x = M.a00 * v.x + M.a01 * v.y + M.a02 * v.z; - u.y = M.a10 * v.x + M.a11 * v.y + M.a12 * v.z; - u.z = M.a20 * v.x + M.a21 * v.y + M.a22 * v.z; + vec3 u; + u.x = M.a00*v.x+M.a01*v.y+M.a02*v.z; + u.y = M.a10*v.x+M.a11*v.y+M.a12*v.z; + u.z = M.a20*v.x+M.a21*v.y+M.a22*v.z; return u; } -const vec3 operator*(const vec3& v, const mat3& M) +const vec3 operator*(const vec3 &v, const mat3 &M) { - vec3 u; - u.x = M.a00 * v.x + M.a10 * v.y + M.a20 * v.z; - u.y = M.a01 * v.x + M.a11 * v.y + M.a21 * v.z; - u.z = M.a02 * v.x + M.a12 * v.y + M.a22 * v.z; + vec3 u; + u.x = M.a00*v.x+M.a10*v.y+M.a20*v.z; + u.y = M.a01*v.x+M.a11*v.y+M.a21*v.z; + u.z = M.a02*v.x+M.a12*v.y+M.a22*v.z; return u; } -vec4 & mult(vec4& u, const mat4& M, const vec4& v) +vec4 &mult(vec4 &u, const mat4 &M, const vec4 &v) { - u.x = M.a00 * v.x + M.a01 * v.y + M.a02 * v.z + M.a03 * v.w; - u.y = M.a10 * v.x + M.a11 * v.y + M.a12 * v.z + M.a13 * v.w; - u.z = M.a20 * v.x + M.a21 * v.y + M.a22 * v.z + M.a23 * v.w; - u.w = M.a30 * v.x + M.a31 * v.y + M.a32 * v.z + M.a33 * v.w; + u.x = M.a00*v.x+M.a01*v.y+M.a02*v.z+M.a03*v.w; + u.y = M.a10*v.x+M.a11*v.y+M.a12*v.z+M.a13*v.w; + u.z = M.a20*v.x+M.a21*v.y+M.a22*v.z+M.a23*v.w; + u.w = M.a30*v.x+M.a31*v.y+M.a32*v.z+M.a33*v.w; return u; } -vec4 & mult(vec4& u, const vec4& v, const mat4& M) +vec4 &mult(vec4 &u, const vec4 &v, const mat4 &M) { - u.x = M.a00 * v.x + M.a10 * v.y + M.a20 * v.z + M.a30 * v.w; - u.y = M.a01 * v.x + M.a11 * v.y + M.a21 * v.z + M.a31 * v.w; - u.z = M.a02 * v.x + M.a12 * v.y + M.a22 * v.z + M.a32 * v.w; - u.w = M.a03 * v.x + M.a13 * v.y + M.a23 * v.z + M.a33 * v.w; + u.x = M.a00*v.x+M.a10*v.y+M.a20*v.z+M.a30*v.w; + u.y = M.a01*v.x+M.a11*v.y+M.a21*v.z+M.a31*v.w; + u.z = M.a02*v.x+M.a12*v.y+M.a22*v.z+M.a32*v.w; + u.w = M.a03*v.x+M.a13*v.y+M.a23*v.z+M.a33*v.w; return u; } -const vec4 operator*(const mat4& M, const vec4& v) +const vec4 operator*(const mat4 &M, const vec4 &v) { - vec4 u; - u.x = M.a00 * v.x + M.a01 * v.y + M.a02 * v.z + M.a03 * v.w; - u.y = M.a10 * v.x + M.a11 * v.y + M.a12 * v.z + M.a13 * v.w; - u.z = M.a20 * v.x + M.a21 * v.y + M.a22 * v.z + M.a23 * v.w; - u.w = M.a30 * v.x + M.a31 * v.y + M.a32 * v.z + M.a33 * v.w; + vec4 u; + u.x = M.a00*v.x+M.a01*v.y+M.a02*v.z+M.a03*v.w; + u.y = M.a10*v.x+M.a11*v.y+M.a12*v.z+M.a13*v.w; + u.z = M.a20*v.x+M.a21*v.y+M.a22*v.z+M.a23*v.w; + u.w = M.a30*v.x+M.a31*v.y+M.a32*v.z+M.a33*v.w; return u; } -const vec4 operator*(const vec4& v, const mat4& M) +const vec4 operator*(const vec4 &v, const mat4 &M) { - vec4 u; - u.x = M.a00 * v.x + M.a10 * v.y + M.a20 * v.z + M.a30 * v.w; - u.y = M.a01 * v.x + M.a11 * v.y + M.a21 * v.z + M.a31 * v.w; - u.z = M.a02 * v.x + M.a12 * v.y + M.a22 * v.z + M.a32 * v.w; - u.w = M.a03 * v.x + M.a13 * v.y + M.a23 * v.z + M.a33 * v.w; + vec4 u; + u.x = M.a00*v.x+M.a10*v.y+M.a20*v.z+M.a30*v.w; + u.y = M.a01*v.x+M.a11*v.y+M.a21*v.z+M.a31*v.w; + u.z = M.a02*v.x+M.a12*v.y+M.a22*v.z+M.a32*v.w; + u.w = M.a03*v.x+M.a13*v.y+M.a23*v.z+M.a33*v.w; return u; } -vec3 & mult_pos(vec3& u, const mat4& M, const vec3& v) +vec3 &mult_pos(vec3 &u, const mat4 &M, const vec3 &v) { - nv_scalar oow = nv_one / (v.x * M.a30 + v.y * M.a31 + v.z * M.a32 + M.a33); - u.x = (M.a00 * v.x + M.a01 * v.y + M.a02 * v.z + M.a03) * oow; - u.y = (M.a10 * v.x + M.a11 * v.y + M.a12 * v.z + M.a13) * oow; - u.z = (M.a20 * v.x + M.a21 * v.y + M.a22 * v.z + M.a23) * oow; + nv_scalar oow = nv_one/(v.x*M.a30+v.y*M.a31+v.z*M.a32+M.a33); + u.x = (M.a00*v.x+M.a01*v.y+M.a02*v.z+M.a03)*oow; + u.y = (M.a10*v.x+M.a11*v.y+M.a12*v.z+M.a13)*oow; + u.z = (M.a20*v.x+M.a21*v.y+M.a22*v.z+M.a23)*oow; return u; } -vec3 & mult_pos(vec3& u, const vec3& v, const mat4& M) +vec3 &mult_pos(vec3 &u, const vec3 &v, const mat4 &M) { - nv_scalar oow = nv_one / (v.x * M.a03 + v.y * M.a13 + v.z * M.a23 + M.a33); - u.x = (M.a00 * v.x + M.a10 * v.y + M.a20 * v.z + M.a30) * oow; - u.y = (M.a01 * v.x + M.a11 * v.y + M.a21 * v.z + M.a31) * oow; - u.z = (M.a02 * v.x + M.a12 * v.y + M.a22 * v.z + M.a32) * oow; + nv_scalar oow = nv_one/(v.x*M.a03+v.y*M.a13+v.z*M.a23+M.a33); + u.x = (M.a00*v.x+M.a10*v.y+M.a20*v.z+M.a30)*oow; + u.y = (M.a01*v.x+M.a11*v.y+M.a21*v.z+M.a31)*oow; + u.z = (M.a02*v.x+M.a12*v.y+M.a22*v.z+M.a32)*oow; return u; } -vec3 & mult_dir(vec3& u, const mat4& M, const vec3& v) +vec3 &mult_dir(vec3 &u, const mat4 &M, const vec3 &v) { - u.x = M.a00 * v.x + M.a01 * v.y + M.a02 * v.z; - u.y = M.a10 * v.x + M.a11 * v.y + M.a12 * v.z; - u.z = M.a20 * v.x + M.a21 * v.y + M.a22 * v.z; + u.x = M.a00*v.x+M.a01*v.y+M.a02*v.z; + u.y = M.a10*v.x+M.a11*v.y+M.a12*v.z; + u.z = M.a20*v.x+M.a21*v.y+M.a22*v.z; return u; } -vec3 & mult_dir(vec3& u, const vec3& v, const mat4& M) +vec3 &mult_dir(vec3 &u, const vec3 &v, const mat4 &M) { - u.x = M.a00 * v.x + M.a10 * v.y + M.a20 * v.z; - u.y = M.a01 * v.x + M.a11 * v.y + M.a21 * v.z; - u.z = M.a02 * v.x + M.a12 * v.y + M.a22 * v.z; + u.x = M.a00*v.x+M.a10*v.y+M.a20*v.z; + u.y = M.a01*v.x+M.a11*v.y+M.a21*v.z; + u.z = M.a02*v.x+M.a12*v.y+M.a22*v.z; return u; } -vec3 & mult(vec3& u, const mat4& M, const vec3& v) +vec3 &mult(vec3 &u, const mat4 &M, const vec3 &v) { - u.x = M.a00 * v.x + M.a01 * v.y + M.a02 * v.z + M.a03; - u.y = M.a10 * v.x + M.a11 * v.y + M.a12 * v.z + M.a13; - u.z = M.a20 * v.x + M.a21 * v.y + M.a22 * v.z + M.a23; + u.x = M.a00*v.x+M.a01*v.y+M.a02*v.z+M.a03; + u.y = M.a10*v.x+M.a11*v.y+M.a12*v.z+M.a13; + u.z = M.a20*v.x+M.a21*v.y+M.a22*v.z+M.a23; return u; } -vec3 & mult(vec3& u, const vec3& v, const mat4& M) +vec3 &mult(vec3 &u, const vec3 &v, const mat4 &M) { - u.x = M.a00 * v.x + M.a10 * v.y + M.a20 * v.z + M.a30; - u.y = M.a01 * v.x + M.a11 * v.y + M.a21 * v.z + M.a31; - u.z = M.a02 * v.x + M.a12 * v.y + M.a22 * v.z + M.a32; + u.x = M.a00*v.x+M.a10*v.y+M.a20*v.z+M.a30; + u.y = M.a01*v.x+M.a11*v.y+M.a21*v.z+M.a31; + u.z = M.a02*v.x+M.a12*v.y+M.a22*v.z+M.a32; return u; } -mat4 & add(mat4& A, const mat4& B) +mat4 &add(mat4 &A, const mat4 &B) { A.a00 += B.a00; A.a10 += B.a10; @@ -313,7 +309,7 @@ mat4 & add(mat4& A, const mat4& B) return A; } -mat3 & add(mat3& A, const mat3& B) +mat3 &add(mat3 &A, const mat3 &B) { A.a00 += B.a00; A.a10 += B.a10; @@ -337,46 +333,46 @@ mat3 & add(mat3& A, const mat3& B) // // C.a30 C.a31 C.a32 C.a33 = A.a30 A.a31 A.a32 A.a33 * B.a30 B.a31 B.a32 B.a33 -mat4 & mult(mat4& C, const mat4& A, const mat4& B) -{ - C.a00 = A.a00 * B.a00 + A.a01 * B.a10 + A.a02 * B.a20 + A.a03 * B.a30; - C.a10 = A.a10 * B.a00 + A.a11 * B.a10 + A.a12 * B.a20 + A.a13 * B.a30; - C.a20 = A.a20 * B.a00 + A.a21 * B.a10 + A.a22 * B.a20 + A.a23 * B.a30; - C.a30 = A.a30 * B.a00 + A.a31 * B.a10 + A.a32 * B.a20 + A.a33 * B.a30; - C.a01 = A.a00 * B.a01 + A.a01 * B.a11 + A.a02 * B.a21 + A.a03 * B.a31; - C.a11 = A.a10 * B.a01 + A.a11 * B.a11 + A.a12 * B.a21 + A.a13 * B.a31; - C.a21 = A.a20 * B.a01 + A.a21 * B.a11 + A.a22 * B.a21 + A.a23 * B.a31; - C.a31 = A.a30 * B.a01 + A.a31 * B.a11 + A.a32 * B.a21 + A.a33 * B.a31; - C.a02 = A.a00 * B.a02 + A.a01 * B.a12 + A.a02 * B.a22 + A.a03 * B.a32; - C.a12 = A.a10 * B.a02 + A.a11 * B.a12 + A.a12 * B.a22 + A.a13 * B.a32; - C.a22 = A.a20 * B.a02 + A.a21 * B.a12 + A.a22 * B.a22 + A.a23 * B.a32; - C.a32 = A.a30 * B.a02 + A.a31 * B.a12 + A.a32 * B.a22 + A.a33 * B.a32; - C.a03 = A.a00 * B.a03 + A.a01 * B.a13 + A.a02 * B.a23 + A.a03 * B.a33; - C.a13 = A.a10 * B.a03 + A.a11 * B.a13 + A.a12 * B.a23 + A.a13 * B.a33; - C.a23 = A.a20 * B.a03 + A.a21 * B.a13 + A.a22 * B.a23 + A.a23 * B.a33; - C.a33 = A.a30 * B.a03 + A.a31 * B.a13 + A.a32 * B.a23 + A.a33 * B.a33; +mat4 &mult(mat4 &C, const mat4 &A, const mat4 &B) +{ + C.a00 = A.a00*B.a00+A.a01*B.a10+A.a02*B.a20+A.a03*B.a30; + C.a10 = A.a10*B.a00+A.a11*B.a10+A.a12*B.a20+A.a13*B.a30; + C.a20 = A.a20*B.a00+A.a21*B.a10+A.a22*B.a20+A.a23*B.a30; + C.a30 = A.a30*B.a00+A.a31*B.a10+A.a32*B.a20+A.a33*B.a30; + C.a01 = A.a00*B.a01+A.a01*B.a11+A.a02*B.a21+A.a03*B.a31; + C.a11 = A.a10*B.a01+A.a11*B.a11+A.a12*B.a21+A.a13*B.a31; + C.a21 = A.a20*B.a01+A.a21*B.a11+A.a22*B.a21+A.a23*B.a31; + C.a31 = A.a30*B.a01+A.a31*B.a11+A.a32*B.a21+A.a33*B.a31; + C.a02 = A.a00*B.a02+A.a01*B.a12+A.a02*B.a22+A.a03*B.a32; + C.a12 = A.a10*B.a02+A.a11*B.a12+A.a12*B.a22+A.a13*B.a32; + C.a22 = A.a20*B.a02+A.a21*B.a12+A.a22*B.a22+A.a23*B.a32; + C.a32 = A.a30*B.a02+A.a31*B.a12+A.a32*B.a22+A.a33*B.a32; + C.a03 = A.a00*B.a03+A.a01*B.a13+A.a02*B.a23+A.a03*B.a33; + C.a13 = A.a10*B.a03+A.a11*B.a13+A.a12*B.a23+A.a13*B.a33; + C.a23 = A.a20*B.a03+A.a21*B.a13+A.a22*B.a23+A.a23*B.a33; + C.a33 = A.a30*B.a03+A.a31*B.a13+A.a32*B.a23+A.a33*B.a33; return C; } -mat4 mat4::operator*(const mat4& B) const +mat4 mat4::operator*(const mat4 &B) const { mat4 C; - C.a00 = a00 * B.a00 + a01 * B.a10 + a02 * B.a20 + a03 * B.a30; - C.a10 = a10 * B.a00 + a11 * B.a10 + a12 * B.a20 + a13 * B.a30; - C.a20 = a20 * B.a00 + a21 * B.a10 + a22 * B.a20 + a23 * B.a30; - C.a30 = a30 * B.a00 + a31 * B.a10 + a32 * B.a20 + a33 * B.a30; - C.a01 = a00 * B.a01 + a01 * B.a11 + a02 * B.a21 + a03 * B.a31; - C.a11 = a10 * B.a01 + a11 * B.a11 + a12 * B.a21 + a13 * B.a31; - C.a21 = a20 * B.a01 + a21 * B.a11 + a22 * B.a21 + a23 * B.a31; - C.a31 = a30 * B.a01 + a31 * B.a11 + a32 * B.a21 + a33 * B.a31; - C.a02 = a00 * B.a02 + a01 * B.a12 + a02 * B.a22 + a03 * B.a32; - C.a12 = a10 * B.a02 + a11 * B.a12 + a12 * B.a22 + a13 * B.a32; - C.a22 = a20 * B.a02 + a21 * B.a12 + a22 * B.a22 + a23 * B.a32; - C.a32 = a30 * B.a02 + a31 * B.a12 + a32 * B.a22 + a33 * B.a32; - C.a03 = a00 * B.a03 + a01 * B.a13 + a02 * B.a23 + a03 * B.a33; - C.a13 = a10 * B.a03 + a11 * B.a13 + a12 * B.a23 + a13 * B.a33; - C.a23 = a20 * B.a03 + a21 * B.a13 + a22 * B.a23 + a23 * B.a33; - C.a33 = a30 * B.a03 + a31 * B.a13 + a32 * B.a23 + a33 * B.a33; + C.a00 = a00*B.a00+a01*B.a10+a02*B.a20+a03*B.a30; + C.a10 = a10*B.a00+a11*B.a10+a12*B.a20+a13*B.a30; + C.a20 = a20*B.a00+a21*B.a10+a22*B.a20+a23*B.a30; + C.a30 = a30*B.a00+a31*B.a10+a32*B.a20+a33*B.a30; + C.a01 = a00*B.a01+a01*B.a11+a02*B.a21+a03*B.a31; + C.a11 = a10*B.a01+a11*B.a11+a12*B.a21+a13*B.a31; + C.a21 = a20*B.a01+a21*B.a11+a22*B.a21+a23*B.a31; + C.a31 = a30*B.a01+a31*B.a11+a32*B.a21+a33*B.a31; + C.a02 = a00*B.a02+a01*B.a12+a02*B.a22+a03*B.a32; + C.a12 = a10*B.a02+a11*B.a12+a12*B.a22+a13*B.a32; + C.a22 = a20*B.a02+a21*B.a12+a22*B.a22+a23*B.a32; + C.a32 = a30*B.a02+a31*B.a12+a32*B.a22+a33*B.a32; + C.a03 = a00*B.a03+a01*B.a13+a02*B.a23+a03*B.a33; + C.a13 = a10*B.a03+a11*B.a13+a12*B.a23+a13*B.a33; + C.a23 = a20*B.a03+a21*B.a13+a22*B.a23+a23*B.a33; + C.a33 = a30*B.a03+a31*B.a13+a32*B.a23+a33*B.a33; return C; } @@ -388,22 +384,22 @@ mat4 mat4::operator*(const mat4& B) const // // C.a20 C.a21 C.a22 = A.a20 A.a21 A.a22 * B.a20 B.a21 B.a22 -mat3 & mult(mat3& C, const mat3& A, const mat3& B) -{ - C.a00 = A.a00 * B.a00 + A.a01 * B.a10 + A.a02 * B.a20; - C.a10 = A.a10 * B.a00 + A.a11 * B.a10 + A.a12 * B.a20; - C.a20 = A.a20 * B.a00 + A.a21 * B.a10 + A.a22 * B.a20; - C.a01 = A.a00 * B.a01 + A.a01 * B.a11 + A.a02 * B.a21; - C.a11 = A.a10 * B.a01 + A.a11 * B.a11 + A.a12 * B.a21; - C.a21 = A.a20 * B.a01 + A.a21 * B.a11 + A.a22 * B.a21; - C.a02 = A.a00 * B.a02 + A.a01 * B.a12 + A.a02 * B.a22; - C.a12 = A.a10 * B.a02 + A.a11 * B.a12 + A.a12 * B.a22; - C.a22 = A.a20 * B.a02 + A.a21 * B.a12 + A.a22 * B.a22; +mat3 &mult(mat3 &C, const mat3 &A, const mat3 &B) +{ + C.a00 = A.a00*B.a00+A.a01*B.a10+A.a02*B.a20; + C.a10 = A.a10*B.a00+A.a11*B.a10+A.a12*B.a20; + C.a20 = A.a20*B.a00+A.a21*B.a10+A.a22*B.a20; + C.a01 = A.a00*B.a01+A.a01*B.a11+A.a02*B.a21; + C.a11 = A.a10*B.a01+A.a11*B.a11+A.a12*B.a21; + C.a21 = A.a20*B.a01+A.a21*B.a11+A.a22*B.a21; + C.a02 = A.a00*B.a02+A.a01*B.a12+A.a02*B.a22; + C.a12 = A.a10*B.a02+A.a11*B.a12+A.a12*B.a22; + C.a22 = A.a20*B.a02+A.a21*B.a12+A.a22*B.a22; return C; } -mat3 & transpose(mat3& A) +mat3 &transpose(mat3 &A) { nv_scalar tmp; tmp = A.a01; @@ -420,7 +416,7 @@ mat3 & transpose(mat3& A) return A; } -mat4 & transpose(mat4& A) +mat4 &transpose(mat4 &A) { nv_scalar tmp; tmp = A.a01; @@ -449,7 +445,7 @@ mat4 & transpose(mat4& A) return A; } -mat4 & transpose(mat4& B, const mat4& A) +mat4 &transpose(mat4 &B, const mat4 &A) { B.a00 = A.a00; B.a01 = A.a10; @@ -470,7 +466,7 @@ mat4 & transpose(mat4& B, const mat4& A) return B; } -mat3 & transpose(mat3& B, const mat3& A) +mat3 &transpose(mat3 &B, const mat3 &A) { B.a00 = A.a00; B.a01 = A.a10; @@ -493,7 +489,7 @@ mat3 & transpose(mat3& B, const mat3& A) */ nv_scalar det2x2(nv_scalar a1, nv_scalar a2, nv_scalar b1, nv_scalar b2) { - return a1 * b2 - b1 * a2; + return a1*b2-b1*a2; } /* @@ -504,40 +500,40 @@ nv_scalar det2x2(nv_scalar a1, nv_scalar a2, nv_scalar b1, nv_scalar b2) | c1 c2 c3 | */ -nv_scalar det3x3(nv_scalar a1, nv_scalar a2, nv_scalar a3, - nv_scalar b1, nv_scalar b2, nv_scalar b3, - nv_scalar c1, nv_scalar c2, nv_scalar c3) +nv_scalar det3x3(nv_scalar a1, nv_scalar a2, nv_scalar a3, + nv_scalar b1, nv_scalar b2, nv_scalar b3, + nv_scalar c1, nv_scalar c2, nv_scalar c3) { - return a1 * det2x2(b2, b3, c2, c3) - b1 * det2x2(a2, a3, c2, c3) + c1 * det2x2(a2, a3, b2, b3); + return a1*det2x2(b2, b3, c2, c3)-b1*det2x2(a2, a3, c2, c3)+c1*det2x2(a2, a3, b2, b3); } -mat4 & invert(mat4& B, const mat4& A) +mat4 &invert(mat4 &B, const mat4 &A) { - nv_scalar det,oodet; + nv_scalar det, oodet; - B.a00 = det3x3(A.a11, A.a21, A.a31, A.a12, A.a22, A.a32, A.a13, A.a23, A.a33); + B.a00 = det3x3(A.a11, A.a21, A.a31, A.a12, A.a22, A.a32, A.a13, A.a23, A.a33); B.a10 = -det3x3(A.a10, A.a20, A.a30, A.a12, A.a22, A.a32, A.a13, A.a23, A.a33); - B.a20 = det3x3(A.a10, A.a20, A.a30, A.a11, A.a21, A.a31, A.a13, A.a23, A.a33); + B.a20 = det3x3(A.a10, A.a20, A.a30, A.a11, A.a21, A.a31, A.a13, A.a23, A.a33); B.a30 = -det3x3(A.a10, A.a20, A.a30, A.a11, A.a21, A.a31, A.a12, A.a22, A.a32); B.a01 = -det3x3(A.a01, A.a21, A.a31, A.a02, A.a22, A.a32, A.a03, A.a23, A.a33); - B.a11 = det3x3(A.a00, A.a20, A.a30, A.a02, A.a22, A.a32, A.a03, A.a23, A.a33); + B.a11 = det3x3(A.a00, A.a20, A.a30, A.a02, A.a22, A.a32, A.a03, A.a23, A.a33); B.a21 = -det3x3(A.a00, A.a20, A.a30, A.a01, A.a21, A.a31, A.a03, A.a23, A.a33); - B.a31 = det3x3(A.a00, A.a20, A.a30, A.a01, A.a21, A.a31, A.a02, A.a22, A.a32); + B.a31 = det3x3(A.a00, A.a20, A.a30, A.a01, A.a21, A.a31, A.a02, A.a22, A.a32); - B.a02 = det3x3(A.a01, A.a11, A.a31, A.a02, A.a12, A.a32, A.a03, A.a13, A.a33); + B.a02 = det3x3(A.a01, A.a11, A.a31, A.a02, A.a12, A.a32, A.a03, A.a13, A.a33); B.a12 = -det3x3(A.a00, A.a10, A.a30, A.a02, A.a12, A.a32, A.a03, A.a13, A.a33); - B.a22 = det3x3(A.a00, A.a10, A.a30, A.a01, A.a11, A.a31, A.a03, A.a13, A.a33); + B.a22 = det3x3(A.a00, A.a10, A.a30, A.a01, A.a11, A.a31, A.a03, A.a13, A.a33); B.a32 = -det3x3(A.a00, A.a10, A.a30, A.a01, A.a11, A.a31, A.a02, A.a12, A.a32); B.a03 = -det3x3(A.a01, A.a11, A.a21, A.a02, A.a12, A.a22, A.a03, A.a13, A.a23); - B.a13 = det3x3(A.a00, A.a10, A.a20, A.a02, A.a12, A.a22, A.a03, A.a13, A.a23); + B.a13 = det3x3(A.a00, A.a10, A.a20, A.a02, A.a12, A.a22, A.a03, A.a13, A.a23); B.a23 = -det3x3(A.a00, A.a10, A.a20, A.a01, A.a11, A.a21, A.a03, A.a13, A.a23); - B.a33 = det3x3(A.a00, A.a10, A.a20, A.a01, A.a11, A.a21, A.a02, A.a12, A.a22); + B.a33 = det3x3(A.a00, A.a10, A.a20, A.a01, A.a11, A.a21, A.a02, A.a12, A.a22); - det = (A.a00 * B.a00) + (A.a01 * B.a10) + (A.a02 * B.a20) + (A.a03 * B.a30); + det = (A.a00*B.a00)+(A.a01*B.a10)+(A.a02*B.a20)+(A.a03*B.a30); - oodet = nv_one / det; + oodet = nv_one/det; B.a00 *= oodet; B.a10 *= oodet; @@ -562,7 +558,7 @@ mat4 & invert(mat4& B, const mat4& A) return B; } -mat4 & invert_rot_trans(mat4& B, const mat4& A) +mat4 &invert_rot_trans(mat4 &B, const mat4 &A) { B.a00 = A.a00; B.a10 = A.a01; @@ -576,88 +572,94 @@ mat4 & invert_rot_trans(mat4& B, const mat4& A) B.a12 = A.a21; B.a22 = A.a22; B.a32 = A.a32; - B.a03 = - (A.a00 * A.a03 + A.a10 * A.a13 + A.a20 * A.a23); - B.a13 = - (A.a01 * A.a03 + A.a11 * A.a13 + A.a21 * A.a23); - B.a23 = - (A.a02 * A.a03 + A.a12 * A.a13 + A.a22 * A.a23); + B.a03 = - (A.a00*A.a03+A.a10*A.a13+A.a20*A.a23); + B.a13 = - (A.a01*A.a03+A.a11*A.a13+A.a21*A.a23); + B.a23 = - (A.a02*A.a03+A.a12*A.a13+A.a22*A.a23); B.a33 = A.a33; return B; } -nv_scalar det(const mat3& A) +nv_scalar det(const mat3 &A) { - return det3x3(A.a00, A.a01, A.a02, - A.a10, A.a11, A.a12, - A.a20, A.a21, A.a22); + return det3x3(A.a00, A.a01, A.a02, + A.a10, A.a11, A.a12, + A.a20, A.a21, A.a22); } -mat3 & invert(mat3& B, const mat3& A) +mat3 &invert(mat3 &B, const mat3 &A) { - nv_scalar det,oodet; + nv_scalar det, oodet; - B.a00 = (A.a11 * A.a22 - A.a21 * A.a12); - B.a10 = -(A.a10 * A.a22 - A.a20 * A.a12); - B.a20 = (A.a10 * A.a21 - A.a20 * A.a11); - B.a01 = -(A.a01 * A.a22 - A.a21 * A.a02); - B.a11 = (A.a00 * A.a22 - A.a20 * A.a02); - B.a21 = -(A.a00 * A.a21 - A.a20 * A.a01); - B.a02 = (A.a01 * A.a12 - A.a11 * A.a02); - B.a12 = -(A.a00 * A.a12 - A.a10 * A.a02); - B.a22 = (A.a00 * A.a11 - A.a10 * A.a01); + B.a00 = (A.a11*A.a22-A.a21*A.a12); + B.a10 = -(A.a10*A.a22-A.a20*A.a12); + B.a20 = (A.a10*A.a21-A.a20*A.a11); + B.a01 = -(A.a01*A.a22-A.a21*A.a02); + B.a11 = (A.a00*A.a22-A.a20*A.a02); + B.a21 = -(A.a00*A.a21-A.a20*A.a01); + B.a02 = (A.a01*A.a12-A.a11*A.a02); + B.a12 = -(A.a00*A.a12-A.a10*A.a02); + B.a22 = (A.a00*A.a11-A.a10*A.a01); - det = (A.a00 * B.a00) + (A.a01 * B.a10) + (A.a02 * B.a20); - - oodet = nv_one / det; + det = (A.a00*B.a00)+(A.a01*B.a10)+(A.a02*B.a20); - B.a00 *= oodet; B.a01 *= oodet; B.a02 *= oodet; - B.a10 *= oodet; B.a11 *= oodet; B.a12 *= oodet; - B.a20 *= oodet; B.a21 *= oodet; B.a22 *= oodet; + oodet = nv_one/det; + + B.a00 *= oodet; + B.a01 *= oodet; + B.a02 *= oodet; + B.a10 *= oodet; + B.a11 *= oodet; + B.a12 *= oodet; + B.a20 *= oodet; + B.a21 *= oodet; + B.a22 *= oodet; return B; } -vec3 & normalize(vec3& u) +vec3 &normalize(vec3 &u) { - nv_scalar norm = _sqrt(u.x * u.x + u.y * u.y + u.z * u.z); - if (norm > nv_eps) - norm = nv_one / norm; + nv_scalar norm = _sqrt(u.x*u.x+u.y*u.y+u.z*u.z); + if (norm>nv_eps) + norm = nv_one/norm; else norm = nv_zero; - return scale(u,norm); + return scale(u, norm); } -vec4 & normalize(vec4& u) +vec4 &normalize(vec4 &u) { - nv_scalar norm = _sqrt(u.x * u.x + u.y * u.y + u.z * u.z + u.w * u.w); - if (norm > nv_eps) - norm = nv_one / norm; + nv_scalar norm = _sqrt(u.x*u.x+u.y*u.y+u.z*u.z+u.w*u.w); + if (norm>nv_eps) + norm = nv_one/norm; else norm = nv_zero; - return scale(u,norm); + return scale(u, norm); } -quat & normalize(quat & p) +quat &normalize(quat &p) { - nv_scalar norm = _sqrt(p.x * p.x + p.y * p.y + p.z * p.z + p.w * p.w); - if (norm > nv_eps) - norm = nv_one / norm; + nv_scalar norm = _sqrt(p.x*p.x+p.y*p.y+p.z*p.z+p.w*p.w); + if (norm>nv_eps) + norm = nv_one/norm; else norm = nv_zero; p.x *= norm; p.y *= norm; p.z *= norm; p.w *= norm; - return p; + return p; } -mat4 & look_at(mat4& M, const vec3& eye, const vec3& center, const vec3& up) +mat4 &look_at(mat4 &M, const vec3 &eye, const vec3 ¢er, const vec3 &up) { vec3 x, y, z; // make rotation matrix // Z vector - z.x = eye.x - center.x; - z.y = eye.y - center.y; - z.z = eye.z - center.z; + z.x = eye.x-center.x; + z.y = eye.y-center.y; + z.z = eye.z-center.z; normalize(z); // Y vector @@ -666,228 +668,242 @@ mat4 & look_at(mat4& M, const vec3& eye, const vec3& center, const vec3& up) y.z = up.z; // X vector = Y cross Z - cross(x,y,z); + cross(x, y, z); // Recompute Y = Z cross X - cross(y,z,x); + cross(y, z, x); // cross product gives area of parallelogram, which is < 1.0 for // non-perpendicular unit-length vectors; so normalize x, y here normalize(x); normalize(y); - M.a00 = x.x; M.a01 = x.y; M.a02 = x.z; M.a03 = -x.x * eye.x - x.y * eye.y - x.z*eye.z; - M.a10 = y.x; M.a11 = y.y; M.a12 = y.z; M.a13 = -y.x * eye.x - y.y * eye.y - y.z*eye.z; - M.a20 = z.x; M.a21 = z.y; M.a22 = z.z; M.a23 = -z.x * eye.x - z.y * eye.y - z.z*eye.z; - M.a30 = nv_zero; M.a31 = nv_zero; M.a32 = nv_zero; M.a33 = nv_one; + M.a00 = x.x; + M.a01 = x.y; + M.a02 = x.z; + M.a03 = -x.x*eye.x-x.y*eye.y-x.z*eye.z; + M.a10 = y.x; + M.a11 = y.y; + M.a12 = y.z; + M.a13 = -y.x*eye.x-y.y*eye.y-y.z*eye.z; + M.a20 = z.x; + M.a21 = z.y; + M.a22 = z.z; + M.a23 = -z.x*eye.x-z.y*eye.y-z.z*eye.z; + M.a30 = nv_zero; + M.a31 = nv_zero; + M.a32 = nv_zero; + M.a33 = nv_one; return M; } -mat4 & frustum(mat4& M, const nv_scalar l, const nv_scalar r, const nv_scalar b, - const nv_scalar t, const nv_scalar n, const nv_scalar f) +mat4 &frustum(mat4 &M, const nv_scalar l, const nv_scalar r, const nv_scalar b, + const nv_scalar t, const nv_scalar n, const nv_scalar f) { - M.a00 = (nv_two*n) / (r-l); + M.a00 = (nv_two*n)/(r-l); M.a10 = 0.0; M.a20 = 0.0; M.a30 = 0.0; M.a01 = 0.0; - M.a11 = (nv_two*n) / (t-b); + M.a11 = (nv_two*n)/(t-b); M.a21 = 0.0; M.a31 = 0.0; - M.a02 = (r+l) / (r-l); - M.a12 = (t+b) / (t-b); - M.a22 = -(f+n) / (f-n); + M.a02 = (r+l)/(r-l); + M.a12 = (t+b)/(t-b); + M.a22 = -(f+n)/(f-n); M.a32 = -nv_one; M.a03 = 0.0; M.a13 = 0.0; - M.a23 = -(nv_two*f*n) / (f-n); + M.a23 = -(nv_two*f*n)/(f-n); M.a33 = 0.0; return M; } -mat4 & perspective(mat4& M, const nv_scalar fovy, const nv_scalar aspect, const nv_scalar n, const nv_scalar f) +mat4 &perspective(mat4 &M, const nv_scalar fovy, const nv_scalar aspect, const nv_scalar n, const nv_scalar f) { nv_scalar xmin, xmax, ymin, ymax; - ymax = n * tan(fovy * nv_to_rad * nv_zero_5); + ymax = n*tan(fovy*nv_to_rad*nv_zero_5); ymin = -ymax; - xmin = ymin * aspect; - xmax = ymax * aspect; + xmin = ymin*aspect; + xmax = ymax*aspect; return frustum(M, xmin, xmax, ymin, ymax, n, f); } const quat quat::Identity(0, 0, 0, 1); -quat::quat(nv_scalar x, nv_scalar y, nv_scalar z, nv_scalar w) : x(x), y(y), z(z), w(w) -{ -} +quat::quat(nv_scalar x, nv_scalar y, nv_scalar z, nv_scalar w) : x(x), y(y), z(z), w(w) {} -quat::quat(const quat& quat) +quat::quat(const quat &quat) { - x = quat.x; - y = quat.y; - z = quat.z; - w = quat.w; + x = quat.x; + y = quat.y; + z = quat.z; + w = quat.w; } -quat::quat(const vec3& axis, nv_scalar angle) +quat::quat(const vec3 &axis, nv_scalar angle) { - nv_scalar len = axis.norm(); - if (len) { - nv_scalar invLen = 1 / len; - nv_scalar angle2 = angle / 2; - nv_scalar scale = _sin(angle2) * invLen; - x = scale * axis[0]; - y = scale * axis[1]; - z = scale * axis[2]; - w = _cos(angle2); - } + nv_scalar len = axis.norm(); + if (len) + { + nv_scalar invLen = 1/len; + nv_scalar angle2 = angle/2; + nv_scalar scale = _sin(angle2)*invLen; + x = scale*axis[0]; + y = scale*axis[1]; + z = scale*axis[2]; + w = _cos(angle2); + } } -quat::quat(const mat3& rot) +quat::quat(const mat3 &rot) { - FromMatrix(rot); + FromMatrix(rot); } -quat& quat::operator=(const quat& quat) +quat &quat::operator=(const quat &quat) { - x = quat.x; - y = quat.y; - z = quat.z; - w = quat.w; - return *this; + x = quat.x; + y = quat.y; + z = quat.z; + w = quat.w; + return *this; } quat quat::Inverse() { - return quat(- x, - y, - z, w); + return quat(- x, - y, - z, w); } void quat::Normalize() { - nv_scalar len = _sqrt(x * x + y * y + z * z + w * w); - if (len > 0) { - nv_scalar invLen = 1 / len; - x *= invLen; - y *= invLen; - z *= invLen; - w *= invLen; - } -} - -void quat::FromMatrix(const mat3& mat) -{ - nv_scalar trace = mat(0, 0) + mat(1, 1) + mat(2, 2); - if (trace > 0) { - nv_scalar scale = _sqrt(trace + 1.0f); - w = 0.5f * scale; - scale = 0.5f / scale; - x = scale * (mat(2, 1) - mat(1, 2)); - y = scale * (mat(0, 2) - mat(2, 0)); - z = scale * (mat(1, 0) - mat(0, 1)); - } - else { - static int next[] = { 1, 2, 0 }; - int i = 0; - if (mat(1, 1) > mat(0, 0)) - i = 1; - if (mat(2, 2) > mat(i, i)) - i = 2; - int j = next[i]; - int k = next[j]; - nv_scalar scale = _sqrt(mat(i, i) - mat(j, j) - mat(k, k) + 1); - nv_scalar* q[] = { &x, &y, &z }; - *q[i] = 0.5f * scale; - scale = 0.5f / scale; - w = scale * (mat(k, j) - mat(j, k)); - *q[j] = scale * (mat(j, i) + mat(i, j)); - *q[k] = scale * (mat(k, i) + mat(i, k)); - } -} - -void quat::ToMatrix(mat3& mat) const -{ - nv_scalar x2 = x * 2; - nv_scalar y2 = y * 2; - nv_scalar z2 = z * 2; - nv_scalar wx = x2 * w; - nv_scalar wy = y2 * w; - nv_scalar wz = z2 * w; - nv_scalar xx = x2 * x; - nv_scalar xy = y2 * x; - nv_scalar xz = z2 * x; - nv_scalar yy = y2 * y; - nv_scalar yz = z2 * y; - nv_scalar zz = z2 * z; - mat(0, 0) = 1 - (yy + zz); - mat(0, 1) = xy - wz; - mat(0, 2) = xz + wy; - mat(1, 0) = xy + wz; - mat(1, 1) = 1 - (xx + zz); - mat(1, 2) = yz - wx; - mat(2, 0) = xz - wy; - mat(2, 1) = yz + wx; - mat(2, 2) = 1 - (xx + yy); -} - -const quat operator*(const quat& p, const quat& q) -{ - return quat( - p.w * q.x + p.x * q.w + p.y * q.z - p.z * q.y, - p.w * q.y + p.y * q.w + p.z * q.x - p.x * q.z, - p.w * q.z + p.z * q.w + p.x * q.y - p.y * q.x, - p.w * q.w - p.x * q.x - p.y * q.y - p.z * q.z - ); -} - -quat& quat::operator*=(const quat& quat) -{ - *this = *this * quat; - return *this; -} - -mat3 & quat_2_mat(mat3& M, const quat& q) -{ - q.ToMatrix(M); + nv_scalar len = _sqrt(x*x+y*y+z*z+w*w); + if (len>0) + { + nv_scalar invLen = 1/len; + x *= invLen; + y *= invLen; + z *= invLen; + w *= invLen; + } +} + +void quat::FromMatrix(const mat3 &mat) +{ + nv_scalar trace = mat(0, 0)+mat(1, 1)+mat(2, 2); + if (trace>0) + { + nv_scalar scale = _sqrt(trace+1.0f); + w = 0.5f*scale; + scale = 0.5f/scale; + x = scale*(mat(2, 1)-mat(1, 2)); + y = scale*(mat(0, 2)-mat(2, 0)); + z = scale*(mat(1, 0)-mat(0, 1)); + } + else + { + static int next[] = {1, 2, 0}; + int i = 0; + if (mat(1, 1)>mat(0, 0)) + i = 1; + if (mat(2, 2)>mat(i, i)) + i = 2; + int j = next[i]; + int k = next[j]; + nv_scalar scale = _sqrt(mat(i, i)-mat(j, j)-mat(k, k)+1); + nv_scalar *q[] = {&x, &y, &z}; + *q[i] = 0.5f*scale; + scale = 0.5f/scale; + w = scale*(mat(k, j)-mat(j, k)); + *q[j] = scale*(mat(j, i)+mat(i, j)); + *q[k] = scale*(mat(k, i)+mat(i, k)); + } +} + +void quat::ToMatrix(mat3 &mat) const +{ + nv_scalar x2 = x*2; + nv_scalar y2 = y*2; + nv_scalar z2 = z*2; + nv_scalar wx = x2*w; + nv_scalar wy = y2*w; + nv_scalar wz = z2*w; + nv_scalar xx = x2*x; + nv_scalar xy = y2*x; + nv_scalar xz = z2*x; + nv_scalar yy = y2*y; + nv_scalar yz = z2*y; + nv_scalar zz = z2*z; + mat(0, 0) = 1-(yy+zz); + mat(0, 1) = xy-wz; + mat(0, 2) = xz+wy; + mat(1, 0) = xy+wz; + mat(1, 1) = 1-(xx+zz); + mat(1, 2) = yz-wx; + mat(2, 0) = xz-wy; + mat(2, 1) = yz+wx; + mat(2, 2) = 1-(xx+yy); +} + +const quat operator*(const quat &p, const quat &q) +{ + return quat( + p.w*q.x+p.x*q.w+p.y*q.z-p.z*q.y, + p.w*q.y+p.y*q.w+p.z*q.x-p.x*q.z, + p.w*q.z+p.z*q.w+p.x*q.y-p.y*q.x, + p.w*q.w-p.x*q.x-p.y*q.y-p.z*q.z + ); +} + +quat &quat::operator*=(const quat &quat) +{ + *this = *this*quat; + return *this; +} + +mat3 &quat_2_mat(mat3 &M, const quat &q) +{ + q.ToMatrix(M); return M; } -quat & mat_2_quat(quat& q, const mat3& M) +quat &mat_2_quat(quat &q, const mat3 &M) { - q.FromMatrix(M); + q.FromMatrix(M); return q; -} +} -quat & mat_2_quat(quat& q, const mat4& M) +quat &mat_2_quat(quat &q, const mat4 &M) { - mat3 m; - M.get_rot(m); - q.FromMatrix(m); + mat3 m; + M.get_rot(m); + q.FromMatrix(m); return q; -} +} /* Given an axis and angle, compute quaternion. */ -quat & axis_to_quat(quat& q, const vec3& a, const nv_scalar phi) +quat &axis_to_quat(quat &q, const vec3 &a, const nv_scalar phi) { vec3 tmp(a.x, a.y, a.z); normalize(tmp); - nv_scalar s = _sin(phi/nv_two); - q.x = s * tmp.x; - q.y = s * tmp.y; - q.z = s * tmp.z; + nv_scalar s = _sin(phi/nv_two); + q.x = s*tmp.x; + q.y = s*tmp.y; + q.z = s*tmp.z; q.w = _cos(phi/nv_two); return q; } -quat & conj(quat & p) +quat &conj(quat &p) { p.x = -p.x; p.y = -p.y; @@ -895,7 +911,7 @@ quat & conj(quat & p) return p; } - quat & conj(quat& p, const quat& q) +quat &conj(quat &p, const quat &q) { p.x = -q.x; p.y = -q.y; @@ -904,7 +920,7 @@ quat & conj(quat & p) return p; } - quat & add_quats(quat& p, const quat& q1, const quat& q2) +quat &add_quats(quat &p, const quat &q1, const quat &q2) { quat t1, t2; @@ -918,200 +934,207 @@ quat & conj(quat & p) t2.y *= q1.w; t2.z *= q1.w; - p.x = (q2.y * q1.z) - (q2.z * q1.y) + t1.x + t2.x; - p.y = (q2.z * q1.x) - (q2.x * q1.z) + t1.y + t2.y; - p.z = (q2.x * q1.y) - (q2.y * q1.x) + t1.z + t2.z; - p.w = q1.w * q2.w - (q1.x * q2.x + q1.y * q2.y + q1.z * q2.z); + p.x = (q2.y*q1.z)-(q2.z*q1.y)+t1.x+t2.x; + p.y = (q2.z*q1.x)-(q2.x*q1.z)+t1.y+t2.y; + p.z = (q2.x*q1.y)-(q2.y*q1.x)+t1.z+t2.z; + p.w = q1.w*q2.w-(q1.x*q2.x+q1.y*q2.y+q1.z*q2.z); return p; } -nv_scalar & dot(nv_scalar& s, const quat& q1, const quat& q2) +nv_scalar &dot(nv_scalar &s, const quat &q1, const quat &q2) { - s = q1.x*q2.x + q1.y*q2.y + q1.z*q2.z + q1.w*q2.w; + s = q1.x*q2.x+q1.y*q2.y+q1.z*q2.z+q1.w*q2.w; return s; } -nv_scalar dot(const quat& q1, const quat& q2) +nv_scalar dot(const quat &q1, const quat &q2) { - return q1.x*q2.x + q1.y*q2.y + q1.z*q2.z + q1.w*q2.w; + return q1.x*q2.x+q1.y*q2.y+q1.z*q2.z+q1.w*q2.w; } #ifndef acosf #define acosf acos #endif -quat & slerp_quats(quat & p, nv_scalar s, const quat & q1, const quat & q2) +quat &slerp_quats(quat &p, nv_scalar s, const quat &q1, const quat &q2) { nv_scalar cosine = dot(q1, q2); - if (cosine < -1) - cosine = -1; - else if (cosine > 1) - cosine = 1; + if (cosine<-1) + cosine = -1; + else if (cosine>1) + cosine = 1; nv_scalar angle = (nv_scalar)acosf(cosine); - if (_abs(angle) < nv_eps) { - p = q1; + if (_abs(angle) nv_eps) - h = (nv_one - phi) / lambda; + cross(w, u, v); + dot(phi, u, v); + dot(lambda, w, w); + if (lambda>nv_eps) + h = (nv_one-phi)/lambda; else h = lambda; - - nv_scalar hxy = w.x * w.y * h; - nv_scalar hxz = w.x * w.z * h; - nv_scalar hyz = w.y * w.z * h; - a00 = phi + w.x * w.x * h; - a01 = hxy - w.z; - a02 = hxz + w.y; + nv_scalar hxy = w.x*w.y*h; + nv_scalar hxz = w.x*w.z*h; + nv_scalar hyz = w.y*w.z*h; + + a00 = phi+w.x*w.x*h; + a01 = hxy-w.z; + a02 = hxz+w.y; - a10 = hxy + w.z; - a11 = phi + w.y * w.y * h; - a12 = hyz - w.x; + a10 = hxy+w.z; + a11 = phi+w.y*w.y*h; + a12 = hyz-w.x; - a20 = hxz - w.y; - a21 = hyz + w.x; - a22 = phi + w.z * w.z * h; + a20 = hxz-w.y; + a21 = hyz+w.x; + a22 = phi+w.z*w.z*h; } -void mat4::set_rot(const quat& q) +void mat4::set_rot(const quat &q) { - mat3 m; - q.ToMatrix(m); - set_rot(m); + mat3 m; + q.ToMatrix(m); + set_rot(m); } // v is normalized // theta in radians -void mat4::set_rot(const nv_scalar& theta, const vec3& v) +void mat4::set_rot(const nv_scalar &theta, const vec3 &v) { nv_scalar ct = nv_scalar(_cos(theta)); nv_scalar st = nv_scalar(_sin(theta)); - nv_scalar xx = v.x * v.x; - nv_scalar yy = v.y * v.y; - nv_scalar zz = v.z * v.z; - nv_scalar xy = v.x * v.y; - nv_scalar xz = v.x * v.z; - nv_scalar yz = v.y * v.z; + nv_scalar xx = v.x*v.x; + nv_scalar yy = v.y*v.y; + nv_scalar zz = v.z*v.z; + nv_scalar xy = v.x*v.y; + nv_scalar xz = v.x*v.z; + nv_scalar yz = v.y*v.z; - a00 = xx + ct*(1-xx); - a01 = xy + ct*(-xy) + st*-v.z; - a02 = xz + ct*(-xz) + st*v.y; + a00 = xx+ct*(1-xx); + a01 = xy+ct*(-xy)+st*-v.z; + a02 = xz+ct*(-xz)+st*v.y; - a10 = xy + ct*(-xy) + st*v.z; - a11 = yy + ct*(1-yy); - a12 = yz + ct*(-yz) + st*-v.x; + a10 = xy+ct*(-xy)+st*v.z; + a11 = yy+ct*(1-yy); + a12 = yz+ct*(-yz)+st*-v.x; - a20 = xz + ct*(-xz) + st*-v.y; - a21 = yz + ct*(-yz) + st*v.x; - a22 = zz + ct*(1-zz); + a20 = xz+ct*(-xz)+st*-v.y; + a21 = yz+ct*(-yz)+st*v.x; + a22 = zz+ct*(1-zz); } -void mat4::set_rot(const vec3& u, const vec3& v) +void mat4::set_rot(const vec3 &u, const vec3 &v) { nv_scalar phi; nv_scalar h; nv_scalar lambda; vec3 w; - cross(w,u,v); - dot(phi,u,v); - dot(lambda,w,w); - if (lambda > nv_eps) - h = (nv_one - phi) / lambda; + cross(w, u, v); + dot(phi, u, v); + dot(lambda, w, w); + if (lambda>nv_eps) + h = (nv_one-phi)/lambda; else h = lambda; - - nv_scalar hxy = w.x * w.y * h; - nv_scalar hxz = w.x * w.z * h; - nv_scalar hyz = w.y * w.z * h; - a00 = phi + w.x * w.x * h; - a01 = hxy - w.z; - a02 = hxz + w.y; + nv_scalar hxy = w.x*w.y*h; + nv_scalar hxz = w.x*w.z*h; + nv_scalar hyz = w.y*w.z*h; - a10 = hxy + w.z; - a11 = phi + w.y * w.y * h; - a12 = hyz - w.x; + a00 = phi+w.x*w.x*h; + a01 = hxy-w.z; + a02 = hxz+w.y; - a20 = hxz - w.y; - a21 = hyz + w.x; - a22 = phi + w.z * w.z * h; + a10 = hxy+w.z; + a11 = phi+w.y*w.y*h; + a12 = hyz-w.x; + + a20 = hxz-w.y; + a21 = hyz+w.x; + a22 = phi+w.z*w.z*h; } -void mat4::set_rot(const mat3& M) +void mat4::set_rot(const mat3 &M) { // copy the 3x3 rotation block - a00 = M.a00; a10 = M.a10; a20 = M.a20; - a01 = M.a01; a11 = M.a11; a21 = M.a21; - a02 = M.a02; a12 = M.a12; a22 = M.a22; + a00 = M.a00; + a10 = M.a10; + a20 = M.a20; + a01 = M.a01; + a11 = M.a11; + a21 = M.a21; + a02 = M.a02; + a12 = M.a12; + a22 = M.a22; } -void mat4::set_translation(const vec3& t) +void mat4::set_translation(const vec3 &t) { a03 = t.x; a13 = t.y; a23 = t.z; } -vec3 & mat4::get_translation(vec3& t) const +vec3 &mat4::get_translation(vec3 &t) const { t.x = a03; t.y = a13; @@ -1119,75 +1142,81 @@ vec3 & mat4::get_translation(vec3& t) const return t; } -mat3 & mat4::get_rot(mat3& M) const +mat3 &mat4::get_rot(mat3 &M) const { // assign the 3x3 rotation block - M.a00 = a00; M.a10 = a10; M.a20 = a20; - M.a01 = a01; M.a11 = a11; M.a21 = a21; - M.a02 = a02; M.a12 = a12; M.a22 = a22; + M.a00 = a00; + M.a10 = a10; + M.a20 = a20; + M.a01 = a01; + M.a11 = a11; + M.a21 = a21; + M.a02 = a02; + M.a12 = a12; + M.a22 = a22; return M; } -quat & mat4::get_rot(quat& q) const +quat &mat4::get_rot(quat &q) const { - mat3 m; - get_rot(m); - q.FromMatrix(m); + mat3 m; + get_rot(m); + q.FromMatrix(m); return q; } -mat3& tangent_basis(mat3& basis, const vec3& v0, const vec3& v1, const vec3& v2, const vec2& t0, const vec2& t1, const vec2& t2, const vec3 & n) +mat3 &tangent_basis(mat3 &basis, const vec3 &v0, const vec3 &v1, const vec3 &v2, const vec2 &t0, const vec2 &t1, const vec2 &t2, const vec3 &n) { vec3 cp; - vec3 e0(v1.x - v0.x, t1.s - t0.s, t1.t - t0.t); - vec3 e1(v2.x - v0.x, t2.s - t0.s, t2.t - t0.t); + vec3 e0(v1.x-v0.x, t1.s-t0.s, t1.t-t0.t); + vec3 e1(v2.x-v0.x, t2.s-t0.s, t2.t-t0.t); - cross(cp,e0,e1); - if ( _abs(cp.x) > nv_eps) + cross(cp, e0, e1); + if (_abs(cp.x)>nv_eps) { - basis.a00 = -cp.y / cp.x; - basis.a10 = -cp.z / cp.x; + basis.a00 = -cp.y/cp.x; + basis.a10 = -cp.z/cp.x; } - e0.x = v1.y - v0.y; - e1.x = v2.y - v0.y; + e0.x = v1.y-v0.y; + e1.x = v2.y-v0.y; - cross(cp,e0,e1); - if ( _abs(cp.x) > nv_eps) + cross(cp, e0, e1); + if (_abs(cp.x)>nv_eps) { - basis.a01 = -cp.y / cp.x; - basis.a11 = -cp.z / cp.x; + basis.a01 = -cp.y/cp.x; + basis.a11 = -cp.z/cp.x; } - e0.x = v1.z - v0.z; - e1.x = v2.z - v0.z; + e0.x = v1.z-v0.z; + e1.x = v2.z-v0.z; - cross(cp,e0,e1); - if ( _abs(cp.x) > nv_eps) + cross(cp, e0, e1); + if (_abs(cp.x)>nv_eps) { - basis.a02 = -cp.y / cp.x; - basis.a12 = -cp.z / cp.x; + basis.a02 = -cp.y/cp.x; + basis.a12 = -cp.z/cp.x; } // tangent... - nv_scalar oonorm = nv_one / _sqrt(basis.a00 * basis.a00 + basis.a01 * basis.a01 + basis.a02 * basis.a02); + nv_scalar oonorm = nv_one/_sqrt(basis.a00*basis.a00+basis.a01*basis.a01+basis.a02*basis.a02); basis.a00 *= oonorm; basis.a01 *= oonorm; basis.a02 *= oonorm; // binormal... - oonorm = nv_one / _sqrt(basis.a10 * basis.a10 + basis.a11 * basis.a11 + basis.a12 * basis.a12); + oonorm = nv_one/_sqrt(basis.a10*basis.a10+basis.a11*basis.a11+basis.a12*basis.a12); basis.a10 *= oonorm; basis.a11 *= oonorm; basis.a12 *= oonorm; // normal... // compute the cross product TxB - basis.a20 = basis.a01*basis.a12 - basis.a02*basis.a11; - basis.a21 = basis.a02*basis.a10 - basis.a00*basis.a12; - basis.a22 = basis.a00*basis.a11 - basis.a01*basis.a10; + basis.a20 = basis.a01*basis.a12-basis.a02*basis.a11; + basis.a21 = basis.a02*basis.a10-basis.a00*basis.a12; + basis.a22 = basis.a00*basis.a11-basis.a01*basis.a10; - oonorm = nv_one / _sqrt(basis.a20 * basis.a20 + basis.a21 * basis.a21 + basis.a22 * basis.a22); + oonorm = nv_one/_sqrt(basis.a20*basis.a20+basis.a21*basis.a21+basis.a22*basis.a22); basis.a20 *= oonorm; basis.a21 *= oonorm; basis.a22 *= oonorm; @@ -1195,11 +1224,11 @@ mat3& tangent_basis(mat3& basis, const vec3& v0, const vec3& v1, const vec3& v2, // Gram-Schmidt orthogonalization process for B // compute the cross product B=NxT to obtain // an orthogonal basis - basis.a10 = basis.a21*basis.a02 - basis.a22*basis.a01; - basis.a11 = basis.a22*basis.a00 - basis.a20*basis.a02; - basis.a12 = basis.a20*basis.a01 - basis.a21*basis.a00; + basis.a10 = basis.a21*basis.a02-basis.a22*basis.a01; + basis.a11 = basis.a22*basis.a00-basis.a20*basis.a02; + basis.a12 = basis.a20*basis.a01-basis.a21*basis.a00; - if (basis.a20 * n.x + basis.a21 * n.y + basis.a22 * n.z < nv_zero) + if (basis.a20*n.x+basis.a21*n.y+basis.a22*n.z nv_one) + if (t>nv_one) t = nv_one; - if (t < -nv_one) + if (t<-nv_one) t = -nv_one; - phi = nv_two * nv_scalar(asin(t)); - axis_to_quat(q,a,phi); + phi = nv_two*nv_scalar(asin(t)); + axis_to_quat(q, a, phi); return q; } -vec3& cube_map_normal(int i, int x, int y, int cubesize, vec3& v) +vec3 &cube_map_normal(int i, int x, int y, int cubesize, vec3 &v) { nv_scalar s, t, sc, tc; - s = (nv_scalar(x) + nv_zero_5) / nv_scalar(cubesize); - t = (nv_scalar(y) + nv_zero_5) / nv_scalar(cubesize); - sc = s * nv_two - nv_one; - tc = t * nv_two - nv_one; + s = (nv_scalar(x)+nv_zero_5)/nv_scalar(cubesize); + t = (nv_scalar(y)+nv_zero_5)/nv_scalar(cubesize); + sc = s*nv_two-nv_one; + tc = t*nv_two-nv_one; - switch (i) + switch (i) { case 0: v.x = nv_one; @@ -1323,18 +1355,18 @@ vec3& cube_map_normal(int i, int x, int y, int cubesize, vec3& v) } // computes the area of a triangle -nv_scalar nv_area(const vec3& v1, const vec3& v2, const vec3& v3) +nv_scalar nv_area(const vec3 &v1, const vec3 &v2, const vec3 &v3) { vec3 cp_sum; vec3 cp; cross(cp_sum, v1, v2); cp_sum += cross(cp, v2, v3); cp_sum += cross(cp, v3, v1); - return nv_norm(cp_sum) * nv_zero_5; + return nv_norm(cp_sum)*nv_zero_5; } // computes the perimeter of a triangle -nv_scalar nv_perimeter(const vec3& v1, const vec3& v2, const vec3& v3) +nv_scalar nv_perimeter(const vec3 &v1, const vec3 &v2, const vec3 &v3) { nv_scalar perim; vec3 diff; @@ -1348,17 +1380,17 @@ nv_scalar nv_perimeter(const vec3& v1, const vec3& v2, const vec3& v3) } // compute the center and radius of the inscribed circle defined by the three vertices -nv_scalar nv_find_in_circle(vec3& center, const vec3& v1, const vec3& v2, const vec3& v3) +nv_scalar nv_find_in_circle(vec3 ¢er, const vec3 &v1, const vec3 &v2, const vec3 &v3) { nv_scalar area = nv_area(v1, v2, v3); // if the area is null - if (area < nv_eps) + if (area&); - bool operator==(const vec2 & u) const + vec2(const nv_scalar *xy) : x(xy[0]), y(xy[1]) { } + + vec2(const vec2 &u) : x(u.x), y(u.y) { } + + vec2(const vec3t &); + + bool operator==(const vec2 &u) const { - return (u.x == x && u.y == y) ? true : false; + return (u.x==x&&u.y==y) ? true : false; } - bool operator!=(const vec2 & u) const + bool operator!=(const vec2 &u) const { - return !(*this == u ); + return !(*this==u); } - vec2 & operator*=(const nv_scalar & lambda) + vec2 &operator*=(const nv_scalar &lambda) { - x*= lambda; - y*= lambda; + x *= lambda; + y *= lambda; return *this; } - vec2 & operator-=(const vec2 & u) + vec2 &operator-=(const vec2 &u) { - x-= u.x; - y-= u.y; + x -= u.x; + y -= u.y; return *this; } - vec2 & operator+=(const vec2 & u) + vec2 &operator+=(const vec2 &u) { - x+= u.x; - y+= u.y; + x += u.x; + y += u.y; return *this; } - nv_scalar & operator[](int i) + nv_scalar &operator[](int i) { return vec_array[i]; } @@ -65,194 +69,256 @@ struct DECLSPEC_NV_MATH vec2 return vec_array[i]; } - union { - struct { - nv_scalar x,y; // standard names for components + union + { + struct + { + nv_scalar x, y; // standard names for components }; - struct { - nv_scalar s,t; // standard names for components + + struct + { + nv_scalar s, t; // standard names for components }; - nv_scalar vec_array[2]; // array access + + nv_scalar vec_array[2]; // array access }; }; -inline const vec2 operator+(const vec2& u, const vec2& v) +inline const vec2 operator+(const vec2 &u, const vec2 &v) { - return vec2(u.x + v.x, u.y + v.y); + return vec2(u.x+v.x, u.y+v.y); } -inline const vec2 operator-(const vec2& u, const vec2& v) +inline const vec2 operator-(const vec2 &u, const vec2 &v) { - return vec2(u.x - v.x, u.y - v.y); + return vec2(u.x-v.x, u.y-v.y); } -inline const vec2 operator*(const nv_scalar s, const vec2& u) +inline const vec2 operator*(const nv_scalar s, const vec2 &u) { - return vec2(s * u.x, s * u.y); + return vec2(s*u.x, s*u.y); } -inline const vec2 operator/(const vec2& u, const nv_scalar s) +inline const vec2 operator/(const vec2 &u, const nv_scalar s) { - return vec2(u.x / s, u.y / s); + return vec2(u.x/s, u.y/s); } -inline const vec2 operator*(const vec2&u, const vec2&v) +inline const vec2 operator*(const vec2 &u, const vec2 &v) { - return vec2(u.x * v.x, u.y * v.y); + return vec2(u.x*v.x, u.y*v.y); } template struct vec3t { - vec3t() { } - vec3t(_T x, _T y, _T z) : x(x), y(y), z(z) { } - vec3t(const _T* xyz) : x(xyz[0]), y(xyz[1]), z(xyz[2]) { } - vec3t(const vec2& u) : x(u.x), y(u.y), z(1.0f) { } - vec3t(const vec3t& u) : x(_T(u.x)), y(_T(u.y)), z(_T(u.z)) { } - vec3t(const vec3t& u) : x(_T(u.x)), y(_T(u.y)), z(_T(u.z)) { } - vec3t(const vec4&); + vec3t() { } + + vec3t(_T x, _T y, _T z) : x(x), y(y), z(z) { } - bool operator==(const vec3t<_T> & u) const { - return (u.x == x && u.y == y && u.z == z) ? true : false; + vec3t(const _T *xyz) : x(xyz[0]), y(xyz[1]), z(xyz[2]) { } + + vec3t(const vec2 &u) : x(u.x), y(u.y), z(1.0f) { } + + vec3t(const vec3t &u) : x(_T(u.x)), y(_T(u.y)), z(_T(u.z)) { } + + vec3t(const vec3t &u) : x(_T(u.x)), y(_T(u.y)), z(_T(u.z)) { } + + vec3t(const vec4 &); + + bool operator==(const vec3t<_T> &u) const + { + return (u.x==x&&u.y==y&&u.z==z) ? true : false; } - bool operator!=( const vec3t<_T>& rhs ) const { - return !(*this == rhs ); + + bool operator!=(const vec3t<_T> &rhs) const + { + return !(*this==rhs); } - vec3t<_T> & operator*=(const _T & lambda) { - x*= lambda; - y*= lambda; - z*= lambda; + + vec3t<_T> &operator*=(const _T &lambda) + { + x *= lambda; + y *= lambda; + z *= lambda; return *this; } - vec3t<_T> operator - () const { - return vec3t<_T>(-x, -y, -z); - } - vec3t<_T> & operator-=(const vec3t<_T> & u) { - x-= u.x; - y-= u.y; - z-= u.z; + + vec3t<_T> operator -() const + { + return vec3t<_T>(-x, -y, -z); + } + + vec3t<_T> &operator-=(const vec3t<_T> &u) + { + x -= u.x; + y -= u.y; + z -= u.z; return *this; } - vec3t<_T> & operator+=(const vec3t<_T> & u) { - x+= u.x; - y+= u.y; - z+= u.z; + + vec3t<_T> &operator+=(const vec3t<_T> &u) + { + x += u.x; + y += u.y; + z += u.z; return *this; } - _T sq_norm() const { return x * x + y * y + z * z; } - _T norm() const { return _sqrt(sq_norm()); } - _T normalize () { - _T _norm = norm(); - if (_norm > nv_eps) _norm = nv_one / _norm; - else _norm = nv_zero; - x *= _norm; - y *= _norm; - z *= _norm; - return _norm; - } - - _T & operator[](int i) { + + _T sq_norm() const + { + return x*x+y*y+z*z; + } + + _T norm() const + { + return _sqrt(sq_norm()); + } + + _T normalize() + { + _T _norm = norm(); + if (_norm>nv_eps) + _norm = nv_one/_norm; + else + _norm = nv_zero; + x *= _norm; + y *= _norm; + z *= _norm; + return _norm; + } + + _T &operator[](int i) + { return vec_array[i]; } - union { - struct { - _T x,y,z; // standard names for components + union + { + struct + { + _T x, y, z; // standard names for components }; - struct { - _T s,t,r; // standard names for components + + struct + { + _T s, t, r; // standard names for components }; - _T vec_array[3]; // array access + + _T vec_array[3]; // array access }; - const _T operator[](int i) const { + const _T operator[](int i) const + { return vec_array[i]; } }; -template inline const vec3t<_T> operator+(const vec3t<_T>& u, const vec3t<_T>& v) { - return vec3t<_T>(u.x + v.x, u.y + v.y, u.z + v.z); +template +inline const vec3t<_T> operator+(const vec3t<_T> &u, const vec3t<_T> &v) +{ + return vec3t<_T>(u.x+v.x, u.y+v.y, u.z+v.z); } -template inline const vec3t<_T> operator-(const vec3t<_T>& u, const vec3t<_T>& v) { - return vec3t<_T>(u.x - v.x, u.y - v.y, u.z - v.z); + +template +inline const vec3t<_T> operator-(const vec3t<_T> &u, const vec3t<_T> &v) +{ + return vec3t<_T>(u.x-v.x, u.y-v.y, u.z-v.z); } -template inline const vec3t<_T> operator^(const vec3t<_T>& u, const vec3t<_T>& v) { - return vec3t<_T>(u.y * v.z - u.z * v.y, u.z * v.x - u.x * v.z, u.x * v.y - u.y * v.x); + +template +inline const vec3t<_T> operator^(const vec3t<_T> &u, const vec3t<_T> &v) +{ + return vec3t<_T>(u.y*v.z-u.z*v.y, u.z*v.x-u.x*v.z, u.x*v.y-u.y*v.x); } -template inline const vec3t<_T> operator*(const _T s, const vec3t<_T>& u) { - return vec3t<_T>(s * u.x, s * u.y, s * u.z); + +template +inline const vec3t<_T> operator*(const _T s, const vec3t<_T> &u) +{ + return vec3t<_T>(s*u.x, s*u.y, s*u.z); } -template inline const vec3t<_T> operator/(const vec3t<_T>& u, const _T s) { - return vec3t<_T>(u.x / s, u.y / s, u.z / s); + +template +inline const vec3t<_T> operator/(const vec3t<_T> &u, const _T s) +{ + return vec3t<_T>(u.x/s, u.y/s, u.z/s); } -template inline const vec3t<_T> operator*(const vec3t<_T>& u, const vec3t<_T>& v) { - return vec3t<_T>(u.x * v.x, u.y * v.y, u.z * v.z); + +template +inline const vec3t<_T> operator*(const vec3t<_T> &u, const vec3t<_T> &v) +{ + return vec3t<_T>(u.x*v.x, u.y*v.y, u.z*v.z); } // -typedef vec3t vec3; -typedef vec3t vec3f; -typedef vec3t vec3d; +typedef vec3t vec3; +typedef vec3t vec3f; +typedef vec3t vec3d; -inline vec2::vec2(const vec3& u) +inline vec2::vec2(const vec3 &u) { - nv_scalar k = 1 / u.z; - x = k * u.x; - y = k * u.y; + nv_scalar k = 1/u.z; + x = k*u.x; + y = k*u.y; } struct DECLSPEC_NV_MATH vec4 { - vec4() { } + vec4() { } + vec4(nv_scalar x, nv_scalar y, nv_scalar z, nv_scalar w) : x(x), y(y), z(z), w(w) { } - vec4(const nv_scalar* xyzw) : x(xyzw[0]), y(xyzw[1]), z(xyzw[2]), w(xyzw[3]) { } - vec4(const vec3& u) : x(u.x), y(u.y), z(u.z), w(1.0f) { } - vec4(const vec4& u) : x(u.x), y(u.y), z(u.z), w(u.w) { } - bool operator==(const vec4 & u) const + vec4(const nv_scalar *xyzw) : x(xyzw[0]), y(xyzw[1]), z(xyzw[2]), w(xyzw[3]) { } + + vec4(const vec3 &u) : x(u.x), y(u.y), z(u.z), w(1.0f) { } + + vec4(const vec4 &u) : x(u.x), y(u.y), z(u.z), w(u.w) { } + + bool operator==(const vec4 &u) const { - return (u.x == x && u.y == y && u.z == z && u.w == w) ? true : false; + return (u.x==x&&u.y==y&&u.z==z&&u.w==w) ? true : false; } - bool operator!=( const vec4& rhs ) const + bool operator!=(const vec4 &rhs) const { - return !(*this == rhs ); + return !(*this==rhs); } - vec4 & operator*=(const nv_scalar & lambda) + vec4 &operator*=(const nv_scalar &lambda) { - x*= lambda; - y*= lambda; - z*= lambda; - w*= lambda; + x *= lambda; + y *= lambda; + z *= lambda; + w *= lambda; return *this; } - vec4 & operator-=(const vec4 & u) + vec4 &operator-=(const vec4 &u) { - x-= u.x; - y-= u.y; - z-= u.z; - w-= u.w; + x -= u.x; + y -= u.y; + z -= u.z; + w -= u.w; return *this; } - vec4 & operator+=(const vec4 & u) + vec4 &operator+=(const vec4 &u) { - x+= u.x; - y+= u.y; - z+= u.z; - w+= u.w; + x += u.x; + y += u.y; + z += u.z; + w += u.w; return *this; } - vec4 operator - () const - { - return vec4(-x, -y, -z, -w); - } + vec4 operator -() const + { + return vec4(-x, -y, -z, -w); + } - nv_scalar & operator[](int i) + nv_scalar &operator[](int i) { return vec_array[i]; } @@ -262,50 +328,57 @@ struct DECLSPEC_NV_MATH vec4 return vec_array[i]; } - union { - struct { - nv_scalar x,y,z,w; // standard names for components + union + { + struct + { + nv_scalar x, y, z, w; // standard names for components }; - struct { - nv_scalar s,t,r,q; // standard names for components + + struct + { + nv_scalar s, t, r, q; // standard names for components }; - nv_scalar vec_array[4]; // array access + + nv_scalar vec_array[4]; // array access }; }; -inline const vec4 operator+(const vec4& u, const vec4& v) +inline const vec4 operator+(const vec4 &u, const vec4 &v) { - return vec4(u.x + v.x, u.y + v.y, u.z + v.z, u.w + v.w); + return vec4(u.x+v.x, u.y+v.y, u.z+v.z, u.w+v.w); } -inline const vec4 operator-(const vec4& u, const vec4& v) +inline const vec4 operator-(const vec4 &u, const vec4 &v) { - return vec4(u.x - v.x, u.y - v.y, u.z - v.z, u.w - v.w); + return vec4(u.x-v.x, u.y-v.y, u.z-v.z, u.w-v.w); } -inline const vec4 operator*(const nv_scalar s, const vec4& u) +inline const vec4 operator*(const nv_scalar s, const vec4 &u) { - return vec4(s * u.x, s * u.y, s * u.z, s * u.w); + return vec4(s*u.x, s*u.y, s*u.z, s*u.w); } -inline const vec4 operator/(const vec4& u, const nv_scalar s) +inline const vec4 operator/(const vec4 &u, const nv_scalar s) { - return vec4(u.x / s, u.y / s, u.z / s, u.w / s); + return vec4(u.x/s, u.y/s, u.z/s, u.w/s); } -inline const vec4 operator*(const vec4& u, const vec4& v) +inline const vec4 operator*(const vec4 &u, const vec4 &v) { - return vec4(u.x * v.x, u.y * v.y, u.z * v.z, u.w * v.w); + return vec4(u.x*v.x, u.y*v.y, u.z*v.z, u.w*v.w); } -template inline vec3t<_T>::vec3t(const vec4& u) { - x = u.x; - y = u.y; - z = u.z; +template +inline vec3t<_T>::vec3t(const vec4 &u) +{ + x = u.x; + y = u.y; + z = u.z; } // quaternion -struct quat; +struct quat; /* for all the matrices...a indicates the element at row x, col y @@ -317,271 +390,307 @@ struct quat; struct DECLSPEC_NV_MATH mat3 { mat3(); - mat3(const nv_scalar * array); - mat3(const mat3 & M); - mat3( const nv_scalar& f0, const nv_scalar& f1, const nv_scalar& f2, - const nv_scalar& f3, const nv_scalar& f4, const nv_scalar& f5, - const nv_scalar& f6, const nv_scalar& f7, const nv_scalar& f8 ) - : a00( f0 ), a10( f1 ), a20( f2 ), - a01( f3 ), a11( f4 ), a21( f5 ), - a02( f6 ), a12( f7 ), a22( f8) { } + mat3(const nv_scalar *array); + mat3(const mat3 &M); + + mat3(const nv_scalar &f0, const nv_scalar &f1, const nv_scalar &f2, + const nv_scalar &f3, const nv_scalar &f4, const nv_scalar &f5, + const nv_scalar &f6, const nv_scalar &f7, const nv_scalar &f8) + : a00(f0), a10(f1), a20(f2), + a01(f3), a11(f4), a21(f5), + a02(f6), a12(f7), a22(f8) { } const vec3 col(const int i) const { - return vec3(&mat_array[i * 3]); + return vec3(&mat_array[i*3]); } const vec3 operator[](int i) const { - return vec3(mat_array[i], mat_array[i + 3], mat_array[i + 6]); + return vec3(mat_array[i], mat_array[i+3], mat_array[i+6]); } - const nv_scalar& operator()(const int& i, const int& j) const + const nv_scalar &operator()(const int &i, const int &j) const { - return mat_array[ j * 3 + i ]; + return mat_array[j*3+i]; } - nv_scalar& operator()(const int& i, const int& j) + nv_scalar &operator()(const int &i, const int &j) { - return mat_array[ j * 3 + i ]; + return mat_array[j*3+i]; } - void set_row(int i, const vec3 & v) + void set_row(int i, const vec3 &v) { mat_array[i] = v.x; - mat_array[i + 3] = v.y; - mat_array[i + 6] = v.z; + mat_array[i+3] = v.y; + mat_array[i+6] = v.z; } - void set_col(int i, const vec3 & v) - { - mat_array[i * 3] = v.x; - mat_array[i * 3 + 1] = v.y; - mat_array[i * 3 + 2] = v.z; - } + void set_col(int i, const vec3 &v) + { + mat_array[i*3] = v.x; + mat_array[i*3+1] = v.y; + mat_array[i*3+2] = v.z; + } - void set_rot(const nv_scalar & theta, const vec3 & v); - void set_rot(const vec3 & u, const vec3 & v); + void set_rot(const nv_scalar &theta, const vec3 &v); + void set_rot(const vec3 &u, const vec3 &v); - union { - struct { - nv_scalar a00, a10, a20; // standard names for components - nv_scalar a01, a11, a21; // standard names for components - nv_scalar a02, a12, a22; // standard names for components + union + { + struct + { + nv_scalar a00, a10, a20; // standard names for components + nv_scalar a01, a11, a21; // standard names for components + nv_scalar a02, a12, a22; // standard names for components }; - nv_scalar mat_array[9]; // array access + + nv_scalar mat_array[9]; // array access }; }; -const vec3 operator*(const mat3&, const vec3&); -const vec3 operator*(const vec3&, const mat3&); +const vec3 operator*(const mat3 &, const vec3 &); +const vec3 operator*(const vec3 &, const mat3 &); struct DECLSPEC_NV_MATH mat4 { mat4(); - mat4(const nv_scalar * array); - mat4(const mat4 & M); - - mat4( const nv_scalar& f0, const nv_scalar& f1, const nv_scalar& f2, const nv_scalar& f3, - const nv_scalar& f4, const nv_scalar& f5, const nv_scalar& f6, const nv_scalar& f7, - const nv_scalar& f8, const nv_scalar& f9, const nv_scalar& f10, const nv_scalar& f11, - const nv_scalar& f12, const nv_scalar& f13, const nv_scalar& f14, const nv_scalar& f15 ) - : a00( f0 ), a10( f1 ), a20( f2 ), a30( f3 ), - a01( f4 ), a11( f5 ), a21( f6 ), a31( f7 ), - a02( f8 ), a12( f9 ), a22( f10), a32( f11), - a03( f12), a13( f13), a23( f14), a33( f15) { } - + mat4(const nv_scalar *array); + mat4(const mat4 &M); + + mat4(const nv_scalar &f0, const nv_scalar &f1, const nv_scalar &f2, const nv_scalar &f3, + const nv_scalar &f4, const nv_scalar &f5, const nv_scalar &f6, const nv_scalar &f7, + const nv_scalar &f8, const nv_scalar &f9, const nv_scalar &f10, const nv_scalar &f11, + const nv_scalar &f12, const nv_scalar &f13, const nv_scalar &f14, const nv_scalar &f15) + : a00(f0), a10(f1), a20(f2), a30(f3), + a01(f4), a11(f5), a21(f6), a31(f7), + a02(f8), a12(f9), a22(f10), a32(f11), + a03(f12), a13(f13), a23(f14), a33(f15) { } + const vec4 col(const int i) const { - return vec4(&mat_array[i * 4]); + return vec4(&mat_array[i*4]); } - - const vec4 operator[](const int& i) const + + const vec4 operator[](const int &i) const { - return vec4(mat_array[i], mat_array[i + 4], mat_array[i + 8], mat_array[i + 12]); + return vec4(mat_array[i], mat_array[i+4], mat_array[i+8], mat_array[i+12]); } - - const nv_scalar& operator()(const int& i, const int& j) const + + const nv_scalar &operator()(const int &i, const int &j) const { - return mat_array[ j * 4 + i ]; + return mat_array[j*4+i]; } - nv_scalar& operator()(const int& i, const int& j) + nv_scalar &operator()(const int &i, const int &j) { - return mat_array[ j * 4 + i ]; + return mat_array[j*4+i]; } - void set_col(int i, const vec4 & v) + void set_col(int i, const vec4 &v) { - mat_array[i * 4] = v.x; - mat_array[i * 4 + 1] = v.y; - mat_array[i * 4 + 2] = v.z; - mat_array[i * 4 + 3] = v.w; + mat_array[i*4] = v.x; + mat_array[i*4+1] = v.y; + mat_array[i*4+2] = v.z; + mat_array[i*4+3] = v.w; } - void set_row(int i, const vec4 & v) + void set_row(int i, const vec4 &v) { mat_array[i] = v.x; - mat_array[i + 4] = v.y; - mat_array[i + 8] = v.z; - mat_array[i + 12] = v.w; + mat_array[i+4] = v.y; + mat_array[i+8] = v.z; + mat_array[i+12] = v.w; } - mat3 & get_rot(mat3 & M) const; - quat & get_rot(quat & q) const; - void set_rot(const quat & q); - void set_rot(const mat3 & M); - void set_rot(const nv_scalar & theta, const vec3 & v); - void set_rot(const vec3 & u, const vec3 & v); + mat3 &get_rot(mat3 &M) const; + quat &get_rot(quat &q) const; + void set_rot(const quat &q); + void set_rot(const mat3 &M); + void set_rot(const nv_scalar &theta, const vec3 &v); + void set_rot(const vec3 &u, const vec3 &v); - void set_translation(const vec3 & t); - vec3 & get_translation(vec3 & t) const; + void set_translation(const vec3 &t); + vec3 &get_translation(vec3 &t) const; - mat4 operator*(const mat4&) const; + mat4 operator*(const mat4 &) const; - union { - struct { - nv_scalar a00, a10, a20, a30; // standard names for components - nv_scalar a01, a11, a21, a31; // standard names for components - nv_scalar a02, a12, a22, a32; // standard names for components - nv_scalar a03, a13, a23, a33; // standard names for components + union + { + struct + { + nv_scalar a00, a10, a20, a30; // standard names for components + nv_scalar a01, a11, a21, a31; // standard names for components + nv_scalar a02, a12, a22, a32; // standard names for components + nv_scalar a03, a13, a23, a33; // standard names for components }; - struct { - nv_scalar _11, _12, _13, _14; // standard names for components - nv_scalar _21, _22, _23, _24; // standard names for components - nv_scalar _31, _32, _33, _34; // standard names for components - nv_scalar _41, _42, _43, _44; // standard names for components + + struct + { + nv_scalar _11, _12, _13, _14; // standard names for components + nv_scalar _21, _22, _23, _24; // standard names for components + nv_scalar _31, _32, _33, _34; // standard names for components + nv_scalar _41, _42, _43, _44; // standard names for components }; - union { - struct { + + union + { + struct + { nv_scalar b00, b10, b20, p; // standard names for components nv_scalar b01, b11, b21, q; // standard names for components nv_scalar b02, b12, b22, r; // standard names for components - nv_scalar x, y, z, w; // standard names for components + nv_scalar x, y, z, w; // standard names for components }; }; - nv_scalar mat_array[16]; // array access + + nv_scalar mat_array[16]; // array access }; }; -const vec4 operator*(const mat4&, const vec4&); -const vec4 operator*(const vec4&, const mat4&); +const vec4 operator*(const mat4 &, const vec4 &); +const vec4 operator*(const vec4 &, const mat4 &); // quaternion -struct DECLSPEC_NV_MATH quat { +struct DECLSPEC_NV_MATH quat +{ public: - quat(nv_scalar x = 0, nv_scalar y = 0, nv_scalar z = 0, nv_scalar w = 1); - quat(const quat& quat); - quat(const vec3& axis, nv_scalar angle); - quat(const mat3& rot); - quat& operator=(const quat& quat); - quat operator-() - { - return quat(-x, -y, -z, -w); - } - quat Inverse(); - void Normalize(); - void FromMatrix(const mat3& mat); - void ToMatrix(mat3& mat) const; - quat& operator*=(const quat& quat); - static const quat Identity; - nv_scalar& operator[](int i) { return comp[i]; } - const nv_scalar operator[](int i) const { return comp[i]; } - union { - struct { - nv_scalar x, y, z, w; - }; - nv_scalar comp[4]; - }; + quat(nv_scalar x = 0, nv_scalar y = 0, nv_scalar z = 0, nv_scalar w = 1); + quat(const quat &quat); + quat(const vec3 &axis, nv_scalar angle); + quat(const mat3 &rot); + quat &operator=(const quat &quat); + + quat operator-() + { + return quat(-x, -y, -z, -w); + } + + quat Inverse(); + void Normalize(); + void FromMatrix(const mat3 &mat); + void ToMatrix(mat3 &mat) const; + quat &operator*=(const quat &quat); + static const quat Identity; + + nv_scalar &operator[](int i) + { + return comp[i]; + } + + const nv_scalar operator[](int i) const + { + return comp[i]; + } + + union + { + struct + { + nv_scalar x, y, z, w; + }; + + nv_scalar comp[4]; + }; }; -const quat operator*(const quat&, const quat&); -extern quat & conj(quat & p, const quat & q); -extern quat & add_quats(quat & p, const quat & q1, const quat & q2); -extern nv_scalar dot(const quat & p, const quat & q); -extern quat & dot(nv_scalar s, const quat & p, const quat & q); -extern quat & slerp_quats(quat & p, nv_scalar s, const quat & q1, const quat & q2); -extern quat & axis_to_quat(quat & q, const vec3 & a, const nv_scalar phi); -extern mat3 & quat_2_mat(mat3 &M, const quat &q ); -extern quat & mat_2_quat(quat &q,const mat3 &M); + +const quat operator*(const quat &, const quat &); +extern quat &conj(quat &p, const quat &q); +extern quat &add_quats(quat &p, const quat &q1, const quat &q2); +extern nv_scalar dot(const quat &p, const quat &q); +extern quat &dot(nv_scalar s, const quat &p, const quat &q); +extern quat &slerp_quats(quat &p, nv_scalar s, const quat &q1, const quat &q2); +extern quat &axis_to_quat(quat &q, const vec3 &a, const nv_scalar phi); +extern mat3 &quat_2_mat(mat3 &M, const quat &q); +extern quat &mat_2_quat(quat &q, const mat3 &M); // constant algebraic values -const nv_scalar array16_id[] = { nv_one, nv_zero, nv_zero, nv_zero, - nv_zero, nv_one, nv_zero, nv_zero, - nv_zero, nv_zero, nv_one, nv_zero, - nv_zero, nv_zero, nv_zero, nv_one}; - -const nv_scalar array16_null[] = { nv_zero, nv_zero, nv_zero, nv_zero, - nv_zero, nv_zero, nv_zero, nv_zero, - nv_zero, nv_zero, nv_zero, nv_zero, - nv_zero, nv_zero, nv_zero, nv_zero}; - -const nv_scalar array16_scale_bias[] = { nv_zero_5, nv_zero, nv_zero, nv_zero, - nv_zero, nv_zero_5, nv_zero, nv_zero, - nv_zero, nv_zero, nv_zero_5, nv_zero, - nv_zero_5, nv_zero_5, nv_zero_5, nv_one}; - -const nv_scalar array9_id[] = { nv_one, nv_zero, nv_zero, - nv_zero, nv_one, nv_zero, - nv_zero, nv_zero, nv_one}; - - -const vec2 vec2_null(nv_zero,nv_zero); -const vec4 vec4_one(nv_one,nv_one,nv_one,nv_one); -const vec3 vec3_one(nv_one,nv_one,nv_one); -const vec3 vec3_null(nv_zero,nv_zero,nv_zero); -const vec3 vec3_x(nv_one,nv_zero,nv_zero); -const vec3 vec3_y(nv_zero,nv_one,nv_zero); -const vec3 vec3_z(nv_zero,nv_zero,nv_one); -const vec3 vec3_neg_x(-nv_one,nv_zero,nv_zero); -const vec3 vec3_neg_y(nv_zero,-nv_one,nv_zero); -const vec3 vec3_neg_z(nv_zero,nv_zero,-nv_one); -const vec4 vec4_null(nv_zero,nv_zero,nv_zero,nv_zero); -const vec4 vec4_x(nv_one,nv_zero,nv_zero,nv_zero); -const vec4 vec4_neg_x(-nv_one,nv_zero,nv_zero,nv_zero); -const vec4 vec4_y(nv_zero,nv_one,nv_zero,nv_zero); -const vec4 vec4_neg_y(nv_zero,-nv_one,nv_zero,nv_zero); -const vec4 vec4_z(nv_zero,nv_zero,nv_one,nv_zero); -const vec4 vec4_neg_z(nv_zero,nv_zero,-nv_one,nv_zero); -const vec4 vec4_w(nv_zero,nv_zero,nv_zero,nv_one); -const vec4 vec4_neg_w(nv_zero,nv_zero,nv_zero,-nv_one); -const quat quat_id(nv_zero,nv_zero,nv_zero,nv_one); -const mat4 mat4_id(array16_id); -const mat3 mat3_id(array9_id); -const mat4 mat4_null(array16_null); -const mat4 mat4_scale_bias(array16_scale_bias); +const nv_scalar array16_id[] = {nv_one, nv_zero, nv_zero, nv_zero, + nv_zero, nv_one, nv_zero, nv_zero, + nv_zero, nv_zero, nv_one, nv_zero, + nv_zero, nv_zero, nv_zero, nv_one}; + +const nv_scalar array16_null[] = {nv_zero, nv_zero, nv_zero, nv_zero, + nv_zero, nv_zero, nv_zero, nv_zero, + nv_zero, nv_zero, nv_zero, nv_zero, + nv_zero, nv_zero, nv_zero, nv_zero}; + +const nv_scalar array16_scale_bias[] = {nv_zero_5, nv_zero, nv_zero, nv_zero, + nv_zero, nv_zero_5, nv_zero, nv_zero, + nv_zero, nv_zero, nv_zero_5, nv_zero, + nv_zero_5, nv_zero_5, nv_zero_5, nv_one}; + +const nv_scalar array9_id[] = {nv_one, nv_zero, nv_zero, + nv_zero, nv_one, nv_zero, + nv_zero, nv_zero, nv_one}; + + +const vec2 vec2_null(nv_zero,nv_zero); +const vec4 vec4_one(nv_one,nv_one,nv_one,nv_one); +const vec3 vec3_one(nv_one,nv_one,nv_one); +const vec3 vec3_null(nv_zero,nv_zero,nv_zero); +const vec3 vec3_x(nv_one,nv_zero,nv_zero); +const vec3 vec3_y(nv_zero,nv_one,nv_zero); +const vec3 vec3_z(nv_zero,nv_zero,nv_one); +const vec3 vec3_neg_x(-nv_one,nv_zero,nv_zero); +const vec3 vec3_neg_y(nv_zero, -nv_one,nv_zero); +const vec3 vec3_neg_z(nv_zero,nv_zero, -nv_one); +const vec4 vec4_null(nv_zero,nv_zero,nv_zero,nv_zero); +const vec4 vec4_x(nv_one,nv_zero,nv_zero,nv_zero); +const vec4 vec4_neg_x(-nv_one,nv_zero,nv_zero,nv_zero); +const vec4 vec4_y(nv_zero,nv_one,nv_zero,nv_zero); +const vec4 vec4_neg_y(nv_zero, -nv_one,nv_zero,nv_zero); +const vec4 vec4_z(nv_zero,nv_zero,nv_one,nv_zero); +const vec4 vec4_neg_z(nv_zero,nv_zero, -nv_one,nv_zero); +const vec4 vec4_w(nv_zero,nv_zero,nv_zero,nv_one); +const vec4 vec4_neg_w(nv_zero,nv_zero,nv_zero, -nv_one); +const quat quat_id(nv_zero,nv_zero,nv_zero,nv_one); +const mat4 mat4_id(array16_id); +const mat3 mat3_id(array9_id); +const mat4 mat4_null(array16_null); +const mat4 mat4_scale_bias(array16_scale_bias); // normalizes a vector and return a reference of itself -extern vec3 & normalize(vec3 & u); -extern vec4 & normalize(vec4 & u); +extern vec3 &normalize(vec3 &u); +extern vec4 &normalize(vec4 &u); // Computes the squared magnitude -inline nv_scalar nv_sq_norm(const vec3 & n) -{ return n.x * n.x + n.y * n.y + n.z * n.z; } +inline nv_scalar nv_sq_norm(const vec3 &n) +{ + return n.x*n.x+n.y*n.y+n.z*n.z; +} -inline nv_scalar nv_sq_norm(const vec4 & n) -{ return n.x * n.x + n.y * n.y + n.z * n.z + n.w * n.w; } +inline nv_scalar nv_sq_norm(const vec4 &n) +{ + return n.x*n.x+n.y*n.y+n.z*n.z+n.w*n.w; +} // Computes the magnitude -inline nv_scalar nv_norm(const vec3 & n) -{ return _sqrt(nv_sq_norm(n)); } +inline nv_scalar nv_norm(const vec3 &n) +{ + return _sqrt(nv_sq_norm(n)); +} -inline nv_scalar nv_norm(const vec4 & n) -{ return _sqrt(nv_sq_norm(n)); } +inline nv_scalar nv_norm(const vec4 &n) +{ + return _sqrt(nv_sq_norm(n)); +} // computes the cross product ( v cross w) and stores the result in u // i.e. u = v cross w -extern vec3 & cross(vec3 & u, const vec3 & v, const vec3 & w); +extern vec3 &cross(vec3 &u, const vec3 &v, const vec3 &w); // computes the dot product ( v dot w) and stores the result in u // i.e. u = v dot w -extern nv_scalar & dot(nv_scalar & u, const vec3 & v, const vec3 & w); -extern nv_scalar dot(const vec3 & v, const vec3 & w); -extern nv_scalar & dot(nv_scalar & u, const vec4 & v, const vec4 & w); -extern nv_scalar dot(const vec4 & v, const vec4 & w); -extern nv_scalar & dot(nv_scalar & u, const vec3 & v, const vec4 & w); -extern nv_scalar dot(const vec3 & v, const vec4 & w); -extern nv_scalar & dot(nv_scalar & u, const vec4 & v, const vec3 & w); -extern nv_scalar dot(const vec4 & v, const vec3 & w); +extern nv_scalar &dot(nv_scalar &u, const vec3 &v, const vec3 &w); +extern nv_scalar dot(const vec3 &v, const vec3 &w); +extern nv_scalar &dot(nv_scalar &u, const vec4 &v, const vec4 &w); +extern nv_scalar dot(const vec4 &v, const vec4 &w); +extern nv_scalar &dot(nv_scalar &u, const vec3 &v, const vec4 &w); +extern nv_scalar dot(const vec3 &v, const vec4 &w); +extern nv_scalar &dot(nv_scalar &u, const vec4 &v, const vec3 &w); +extern nv_scalar dot(const vec4 &v, const vec3 &w); // compute the reflected vector R of L w.r.t N - vectors need to be // normalized @@ -593,134 +702,151 @@ extern nv_scalar dot(const vec4 & v, const vec3 & w); // \ | / // \|/ // + -extern vec3 & reflect(vec3 & r, const vec3 & n, const vec3 & l); +extern vec3 &reflect(vec3 &r, const vec3 &n, const vec3 &l); // Computes u = v * lambda + u -extern vec3 & madd(vec3 & u, const vec3 & v, const nv_scalar & lambda); +extern vec3 &madd(vec3 &u, const vec3 &v, const nv_scalar &lambda); // Computes u = v * lambda -extern vec3 & mult(vec3 & u, const vec3 & v, const nv_scalar & lambda); +extern vec3 &mult(vec3 &u, const vec3 &v, const nv_scalar &lambda); // Computes u = v * w -extern vec3 & mult(vec3 & u, const vec3 & v, const vec3 & w); +extern vec3 &mult(vec3 &u, const vec3 &v, const vec3 &w); // Computes u = v + w -extern vec3 & add(vec3 & u, const vec3 & v, const vec3 & w); +extern vec3 &add(vec3 &u, const vec3 &v, const vec3 &w); // Computes u = v - w -extern vec3 & sub(vec3 & u, const vec3 & v, const vec3 & w); +extern vec3 &sub(vec3 &u, const vec3 &v, const vec3 &w); // Computes u = u * s -extern vec3 & scale(vec3 & u, const nv_scalar s); -extern vec4 & scale(vec4 & u, const nv_scalar s); +extern vec3 &scale(vec3 &u, const nv_scalar s); +extern vec4 &scale(vec4 &u, const nv_scalar s); // Computes u = M * v -extern vec3 & mult(vec3 & u, const mat3 & M, const vec3 & v); -extern vec4 & mult(vec4 & u, const mat4 & M, const vec4 & v); +extern vec3 &mult(vec3 &u, const mat3 &M, const vec3 &v); +extern vec4 &mult(vec4 &u, const mat4 &M, const vec4 &v); // Computes u = v * M -extern vec3 & mult(vec3 & u, const vec3 & v, const mat3 & M); -extern vec4 & mult(vec4 & u, const vec4 & v, const mat4 & M); +extern vec3 &mult(vec3 &u, const vec3 &v, const mat3 &M); +extern vec4 &mult(vec4 &u, const vec4 &v, const mat4 &M); // Computes u = M(4x4) * v and divides by w -extern vec3 & mult_pos(vec3 & u, const mat4 & M, const vec3 & v); +extern vec3 &mult_pos(vec3 &u, const mat4 &M, const vec3 &v); // Computes u = M(4x4) * v -extern vec3 & mult_dir(vec3 & u, const mat4 & M, const vec3 & v); +extern vec3 &mult_dir(vec3 &u, const mat4 &M, const vec3 &v); // Computes u = M(4x4) * v and does not divide by w (assumed to be 1) -extern vec3 & mult(vec3& u, const mat4& M, const vec3& v); +extern vec3 &mult(vec3 &u, const mat4 &M, const vec3 &v); // Computes u = v * M(4x4) and divides by w -extern vec3 & mult_pos(vec3 & u, const vec3 & v, const mat4 & M); +extern vec3 &mult_pos(vec3 &u, const vec3 &v, const mat4 &M); // Computes u = v * M(4x4) -extern vec3 & mult_dir(vec3 & u, const vec3 & v, const mat4 & M); +extern vec3 &mult_dir(vec3 &u, const vec3 &v, const mat4 &M); // Computes u = v * M(4x4) and does not divide by w (assumed to be 1) -extern vec3 & mult(vec3& u, const vec3& v, const mat4& M); +extern vec3 &mult(vec3 &u, const vec3 &v, const mat4 &M); // Computes A += B -extern mat4 & add(mat4 & A, const mat4 & B); -extern mat3 & add(mat3 & A, const mat3 & B); +extern mat4 &add(mat4 &A, const mat4 &B); +extern mat3 &add(mat3 &A, const mat3 &B); // Computes C = A * B -extern mat4 & mult(mat4 & C, const mat4 & A, const mat4 & B); -extern mat3 & mult(mat3 & C, const mat3 & A, const mat3 & B); +extern mat4 &mult(mat4 &C, const mat4 &A, const mat4 &B); +extern mat3 &mult(mat3 &C, const mat3 &A, const mat3 &B); // Computes B = Transpose(A) // T // B = A -extern mat3 & transpose(mat3 & B, const mat3 & A); -extern mat4 & transpose(mat4 & B, const mat4 & A); -extern mat3 & transpose(mat3 & B); -extern mat4 & transpose(mat4 & B); +extern mat3 &transpose(mat3 &B, const mat3 &A); +extern mat4 &transpose(mat4 &B, const mat4 &A); +extern mat3 &transpose(mat3 &B); +extern mat4 &transpose(mat4 &B); // Computes B = inverse(A) // -1 // B = A -extern mat4 & invert(mat4 & B, const mat4 & A); -extern mat3 & invert(mat3 & B, const mat3 & A); +extern mat4 &invert(mat4 &B, const mat4 &A); +extern mat3 &invert(mat3 &B, const mat3 &A); // Computes B = inverse(A) // T T // (R t) (R -R t) // assuming that A = (0 1) so that B = (0 1) // B = A -extern mat4 & invert_rot_trans(mat4 & B, const mat4 & A); +extern mat4 &invert_rot_trans(mat4 &B, const mat4 &A); -extern mat4 & look_at(mat4 & M, const vec3 & eye, const vec3 & center, const vec3 & up); -extern mat4 & frustum(mat4 & M, const nv_scalar l, const nv_scalar r, const nv_scalar b, - const nv_scalar t, const nv_scalar n, const nv_scalar f); +extern mat4 &look_at(mat4 &M, const vec3 &eye, const vec3 ¢er, const vec3 &up); +extern mat4 &frustum(mat4 &M, const nv_scalar l, const nv_scalar r, const nv_scalar b, + const nv_scalar t, const nv_scalar n, const nv_scalar f); -extern mat4 & perspective(mat4 & M, const nv_scalar fovy, const nv_scalar aspect, const nv_scalar n, const nv_scalar f); +extern mat4 &perspective(mat4 &M, const nv_scalar fovy, const nv_scalar aspect, const nv_scalar n, const nv_scalar f); // quaternion -extern quat & normalize(quat & p); -extern quat & conj(quat & p); -extern quat & conj(quat & p, const quat & q); -extern quat & add_quats(quat & p, const quat & q1, const quat & q2); -extern quat & axis_to_quat(quat & q, const vec3 & a, const nv_scalar phi); -extern mat3 & quat_2_mat(mat3 &M, const quat &q ); -extern quat & mat_2_quat(quat &q,const mat3 &M); -extern quat & mat_2_quat(quat &q,const mat4 &M); +extern quat &normalize(quat &p); +extern quat &conj(quat &p); +extern quat &conj(quat &p, const quat &q); +extern quat &add_quats(quat &p, const quat &q1, const quat &q2); +extern quat &axis_to_quat(quat &q, const vec3 &a, const nv_scalar phi); +extern mat3 &quat_2_mat(mat3 &M, const quat &q); +extern quat &mat_2_quat(quat &q, const mat3 &M); +extern quat &mat_2_quat(quat &q, const mat4 &M); // surface properties -extern mat3 & tangent_basis(mat3 & basis,const vec3 & v0,const vec3 & v1,const vec3 & v2,const vec2 & t0,const vec2 & t1,const vec2 & t2, const vec3 & n); +extern mat3 &tangent_basis(mat3 &basis, const vec3 &v0, const vec3 &v1, const vec3 &v2, const vec2 &t0, const vec2 &t1, const vec2 &t2, const vec3 &n); // linear interpolation inline nv_scalar lerp(nv_scalar t, nv_scalar a, nv_scalar b) -{ return a * (nv_one - t) + t * b; } +{ + return a*(nv_one-t)+t*b; +} -inline vec3 & lerp(vec3 & w, const nv_scalar & t, const vec3 & u, const vec3 & v) -{ w.x = lerp(t, u.x, v.x); w.y = lerp(t, u.y, v.y); w.z = lerp(t, u.z, v.z); return w; } +inline vec3 &lerp(vec3 &w, const nv_scalar &t, const vec3 &u, const vec3 &v) +{ + w.x = lerp(t, u.x, v.x); + w.y = lerp(t, u.y, v.y); + w.z = lerp(t, u.z, v.z); + return w; +} // utilities -inline nv_scalar nv_min(const nv_scalar & lambda, const nv_scalar & n) -{ return (lambda < n ) ? lambda : n; } +inline nv_scalar nv_min(const nv_scalar &lambda, const nv_scalar &n) +{ + return (lambda n ) ? lambda : n; } +inline nv_scalar nv_max(const nv_scalar &lambda, const nv_scalar &n) +{ + return (lambda>n) ? lambda : n; +} inline nv_scalar nv_clamp(nv_scalar u, const nv_scalar min, const nv_scalar max) -{ u = (u < min) ? min : u; u = (u > max) ? max : u; return u; } +{ + u = (umax) ? max : u; + return u; +} extern nv_scalar nv_random(); -extern quat & trackball(quat & q, vec2 & pt1, vec2 & pt2, nv_scalar trackballsize); +extern quat &trackball(quat &q, vec2 &pt1, vec2 &pt2, nv_scalar trackballsize); -extern vec3 & cube_map_normal(int i, int x, int y, int cubesize, vec3 & v); +extern vec3 &cube_map_normal(int i, int x, int y, int cubesize, vec3 &v); // geometry // computes the area of a triangle -extern nv_scalar nv_area(const vec3 & v1, const vec3 & v2, const vec3 &v3); +extern nv_scalar nv_area(const vec3 &v1, const vec3 &v2, const vec3 &v3); // computes the perimeter of a triangle -extern nv_scalar nv_perimeter(const vec3 & v1, const vec3 & v2, const vec3 &v3); +extern nv_scalar nv_perimeter(const vec3 &v1, const vec3 &v2, const vec3 &v3); // find the inscribed circle -extern nv_scalar nv_find_in_circle( vec3 & center, const vec3 & v1, const vec3 & v2, const vec3 &v3); +extern nv_scalar nv_find_in_circle(vec3 ¢er, const vec3 &v1, const vec3 &v2, const vec3 &v3); // find the circumscribed circle -extern nv_scalar nv_find_circ_circle( vec3 & center, const vec3 & v1, const vec3 & v2, const vec3 &v3); +extern nv_scalar nv_find_circ_circle(vec3 ¢er, const vec3 &v1, const vec3 &v2, const vec3 &v3); // fast cosine functions extern nv_scalar fast_cos(const nv_scalar x); extern nv_scalar ffast_cos(const nv_scalar x); // determinant -nv_scalar det(const mat3 & A); +nv_scalar det(const mat3 &A); -extern void nv_is_valid(const vec3& v); +extern void nv_is_valid(const vec3 &v); extern void nv_is_valid(nv_scalar lambda); #endif //nv_algebraH + + diff --git a/src/editors/ECore/Engine/nv_math.h b/src/editors/ECore/Engine/nv_math.h index 014a87ca986..7f6f297f8c8 100644 --- a/src/editors/ECore/Engine/nv_math.h +++ b/src/editors/ECore/Engine/nv_math.h @@ -19,9 +19,10 @@ from the use or inability to use this file or items derived from it. #include "nv_mathdecl.h" #endif // _nv_mathdecl_h_ + #include -typedef f32 nv_scalar; +typedef f32 nv_scalar; #define nv_zero nv_scalar(0) #define nv_zero_5 nv_scalar(0.5) @@ -42,7 +43,8 @@ typedef f32 nv_scalar; #define nv_big_eps nv_scalar(10e-6) #define nv_small_eps nv_scalar(10e-2) -template struct vec3t; +template +struct vec3t; struct vec2; struct vec4; @@ -50,4 +52,7 @@ struct vec4; #include "nv_algebra.h" #endif // _nv_algebra_h_ + #endif //_nv_math_h_ + + diff --git a/src/editors/ECore/Engine/nv_mathdecl.h b/src/editors/ECore/Engine/nv_mathdecl.h index 0587cb4b945..ef1ee3fc965 100644 --- a/src/editors/ECore/Engine/nv_mathdecl.h +++ b/src/editors/ECore/Engine/nv_mathdecl.h @@ -17,15 +17,17 @@ from the use or inability to use this file or items derived from it. #define _nv_mathdecl_h_ #ifdef NV_MATH_DLL - - #ifdef NV_MATH_EXPORTS - #define DECLSPEC_NV_MATH __declspec(dllexport) - #else - #define DECLSPEC_NV_MATH __declspec(dllimport) - #endif +#include "xrCore/Platform.h" +#ifdef NV_MATH_EXPORTS + #define DECLSPEC_NV_MATH XR_EXPORT +#else + #define DECLSPEC_NV_MATH XR_IMPORT +#endif #else - #define DECLSPEC_NV_MATH +#define DECLSPEC_NV_MATH #endif -#endif // _nv_mathdecl_h_ +#endif // _nv_mathdecl_h_ + + diff --git a/src/editors/ECore/stdafx.h b/src/editors/ECore/stdafx.h index f04d86f87fb..da8af0b2f15 100644 --- a/src/editors/ECore/stdafx.h +++ b/src/editors/ECore/stdafx.h @@ -17,9 +17,9 @@ #define DIRECTINPUT_VERSION 0x0800 -#define R_R1 1 -#define R_R2 2 -#define RENDER R_R1 +#define R_R1 1 +#define R_R2 2 +#define RENDER R_R1 // Std C++ headers #include @@ -34,11 +34,11 @@ #ifdef _eof #undef _eof #endif -__inline int _eof (int _a) { return ::eof(_a); } +__inline int _eof(int _a) { return ::eof(_a); } #ifdef _access #undef _access #endif -__inline int _access(const char *_a, int _b) { return ::access(_a,_b); } +__inline int _access(const char *_a, int _b) { return ::access(_a, _b); } #ifdef _lseek #undef _lseek #endif @@ -47,34 +47,37 @@ __inline long _lseek(int handle, long offset, int fromwhere){ return ::lseek(han #undef _dup #endif #define fmodf fmod -__inline int _dup (int handle) { return ::dup(handle);} -__inline float modff(float a, float *b){ - double x,y; - y = modf(double(a),&x); - *b = x; - return float(y); +__inline int _dup (int handle) { return ::dup(handle); } +__inline float modff(float a, float *b) +{ + double x, y; + + y = modf(double(a), &x); + *b = x; + return float(y); } -__inline float expf (float val) { return ::exp(val);} +__inline float expf (float val) { return ::exp(val);} +#include "xrCore/Platform.h" -#ifdef _ECOREB - #define ECORE_API __declspec(dllexport) - #define ENGINE_API __declspec(dllexport) +#ifdef _ECOREB +#define ECORE_API XR_EXPORT +#define ENGINE_API XR_EXPORT #else - #define ECORE_API __declspec(dllimport) - #define ENGINE_API __declspec(dllimport) +#define ECORE_API XR_IMPORT +#define ENGINE_API XR_IMPORT #endif -#define DLL_API __declspec(dllimport) -#define PropertyGP(a,b) __declspec( property( get=a, put=b ) ) -#define THROW FATAL("THROW"); -#define THROW2(a) FATAL(a); +#define DLL_API XR_IMPORT +#define PropertyGP(a,b) __declspec( property( get=a, put=b ) ) +#define THROW FATAL("THROW"); +#define THROW2(a) FATAL(a); #define NO_XRC_STATS -#define clMsg Msg +#define clMsg Msg // core -#include +#include #ifdef _EDITOR class PropValue; @@ -85,59 +88,59 @@ __inline float expf (float val) { return ::exp(val);} DEFINE_VECTOR(ListItem*,ListItemsVec,ListItemsIt); #endif -#include "..\..\xrCDB\xrCDB.h" -#include "..\..\xrSound\Sound.h" -#include "..\..\xrEngine\PSystem.h" +#include "xrCDB/xrCDB.h" +#include "xrSound/Sound.h" +#include "xrEngine/PSystem.h" // DirectX headers #include #include -#include "..\..\Layers\xrRender\xrD3dDefs.h" +#include "Layers/xrRender/xrD3dDefs.h" #include //#include // some user components -#include "..\..\xrEngine\fmesh.h" -#include "..\..\xrEngine\_d3d_extensions.h" +#include "xrCore/FMesh.hpp" +#include "Common/_d3d_extensions.h" #include "D3DX_Wrapper.h" -DEFINE_VECTOR (AnsiString,AStringVec,AStringIt); -DEFINE_VECTOR (AnsiString*,LPAStringVec,LPAStringIt); +DEFINE_VECTOR (AnsiString, AStringVec, AStringIt); +DEFINE_VECTOR (AnsiString*, LPAStringVec, LPAStringIt); -#include "..\..\..\xrServerEntities\xrEProps.h" -#include "..\..\xrCore\Log.h" -#include "editor\engine.h" -#include "..\..\xrEngine\defines.h" +#include "xrServerEntities\xrEProps.h" +#include "xrCore/Log.h" +#include "Editor/engine.h" +#include "xrEngine/defines.h" -#include "../../xrphysics/xrphysics.h" +#include "xrPhysics/xrPhysics.h" struct str_pred : public std::binary_function { IC bool operator()(LPCSTR x, LPCSTR y) const - { return strcmp(x,y)<0; } + { return strcmp(x, y)<0; } }; struct astr_pred : public std::binary_function { IC bool operator()(const AnsiString& x, const AnsiString& y) const - { return xEditorName(),".ini").c_str());} @@ -163,8 +166,7 @@ struct astr_pred : public std::binary_function Date: Fri, 4 Dec 2015 07:16:36 +0500 Subject: [PATCH 09/10] LevelEditor: fixed includes and formatted code --- src/editors/LevelEditor/BottomBar.cpp | 468 ++-- src/editors/LevelEditor/DOOneColor.cpp | 100 +- src/editors/LevelEditor/DOShuffle.cpp | 388 +-- src/editors/LevelEditor/DOShuffle.h | 171 +- .../LevelEditor/Edit/AppendObjectInfoForm.h | 26 +- src/editors/LevelEditor/Edit/Builder.cpp | 350 +-- src/editors/LevelEditor/Edit/Builder.h | 239 +- src/editors/LevelEditor/Edit/BuilderCore.cpp | 75 +- src/editors/LevelEditor/Edit/BuilderGame.cpp | 183 +- src/editors/LevelEditor/Edit/BuilderLODs.cpp | 424 ++-- src/editors/LevelEditor/Edit/BuilderLTX.cpp | 127 +- src/editors/LevelEditor/Edit/BuilderOGF.cpp | 176 +- .../LevelEditor/Edit/BuilderRemote.cpp | 2111 +++++++++-------- src/editors/LevelEditor/Edit/Cursor3D.cpp | 189 +- src/editors/LevelEditor/Edit/Cursor3D.h | 70 +- .../LevelEditor/Edit/Custom2DProjector.cpp | 118 +- .../LevelEditor/Edit/Custom2DProjector.h | 114 +- src/editors/LevelEditor/Edit/CustomObject.cpp | 308 +-- src/editors/LevelEditor/Edit/CustomObject.h | 399 ++-- .../Edit/CustomObjectAnimation.cpp | 447 ++-- .../LevelEditor/Edit/CustomObjectLE.cpp | 303 +-- src/editors/LevelEditor/Edit/ELight.cpp | 309 +-- src/editors/LevelEditor/Edit/ELight.h | 193 +- src/editors/LevelEditor/Edit/ELight_IO.cpp | 351 +-- src/editors/LevelEditor/Edit/ELight_props.cpp | 365 +-- .../LevelEditor/Edit/EParticlesObject.cpp | 314 +-- .../LevelEditor/Edit/EParticlesObject.h | 87 +- .../LevelEditor/Edit/ESceneAIMapControls.cpp | 152 +- .../LevelEditor/Edit/ESceneAIMapTools.cpp | 773 +++--- .../LevelEditor/Edit/ESceneAIMapTools.h | 411 ++-- .../Edit/ESceneAIMapTools_Controls.cpp | 23 +- .../Edit/ESceneAIMapTools_Export.cpp | 139 +- .../Edit/ESceneAIMapTools_Export.h | 24 +- .../Edit/ESceneAIMapTools_Generate.cpp | 1663 +++++++------ .../Edit/ESceneAIMapTools_MotionSimulator.cpp | 989 ++++---- .../Edit/ESceneAIMapTools_Pick.cpp | 150 +- .../Edit/ESceneAIMapTools_Render.cpp | 231 +- .../LevelEditor/Edit/ESceneControlsCustom.cpp | 420 ++-- .../LevelEditor/Edit/ESceneControlsCustom.h | 145 +- .../LevelEditor/Edit/ESceneCustomMTools.cpp | 92 +- .../LevelEditor/Edit/ESceneCustomMTools.h | 288 ++- .../Edit/ESceneCustomMToolsControls.cpp | 62 +- .../LevelEditor/Edit/ESceneCustomOTools.cpp | 376 +-- .../LevelEditor/Edit/ESceneCustomOTools.h | 139 +- .../LevelEditor/Edit/ESceneCustomOToolsIO.cpp | 216 +- .../LevelEditor/Edit/ESceneDOTools.cpp | 826 ++++--- src/editors/LevelEditor/Edit/ESceneDOTools.h | 311 ++- .../Edit/ESceneDOTools_Controls.cpp | 14 +- .../Edit/ESceneDOTools_Generate.cpp | 691 +++--- .../LevelEditor/Edit/ESceneDOTools_Pick.cpp | 145 +- .../LevelEditor/Edit/ESceneDummyTools.h | 54 +- .../LevelEditor/Edit/ESceneFogVolumeTools.cpp | 70 +- .../LevelEditor/Edit/ESceneFogVolumeTools.h | 64 +- .../LevelEditor/Edit/ESceneGlowTools.cpp | 25 +- .../LevelEditor/Edit/ESceneGlowTools.h | 79 +- .../LevelEditor/Edit/ESceneGlowToolsIO.cpp | 85 +- .../LevelEditor/Edit/ESceneGroupControls.cpp | 34 +- .../LevelEditor/Edit/ESceneGroupTools.cpp | 322 +-- .../LevelEditor/Edit/ESceneGroupTools.h | 96 +- .../LevelEditor/Edit/ESceneGroupToolsIO.cpp | 74 +- .../LevelEditor/Edit/ESceneLightTools.cpp | 572 +++-- .../LevelEditor/Edit/ESceneLightTools.h | 141 +- .../LevelEditor/Edit/ESceneLightToolsIO.cpp | 186 +- .../LevelEditor/Edit/ESceneObjectControls.cpp | 121 +- .../LevelEditor/Edit/ESceneObjectTools.cpp | 312 +-- .../LevelEditor/Edit/ESceneObjectTools.h | 142 +- .../Edit/ESceneObjectToolsExportBreakable.cpp | 394 +-- .../LevelEditor/Edit/ESceneObjectToolsIO.cpp | 206 +- .../LevelEditor/Edit/ESceneObjectTools_.cpp | 276 ++- .../LevelEditor/Edit/ESceneObjectTools__.cpp | 295 ++- .../LevelEditor/Edit/EScenePSControls.cpp | 34 +- .../LevelEditor/Edit/EScenePSTools.cpp | 25 +- src/editors/LevelEditor/Edit/EScenePSTools.h | 65 +- .../LevelEditor/Edit/EScenePSToolsIO.cpp | 74 +- .../LevelEditor/Edit/EScenePortalTools.cpp | 146 +- .../LevelEditor/Edit/EScenePortalTools.h | 76 +- .../LevelEditor/Edit/EScenePortalToolsIO.cpp | 88 +- .../LevelEditor/Edit/ESceneSectorControls.cpp | 283 ++- .../LevelEditor/Edit/ESceneSectorTools.cpp | 92 +- .../LevelEditor/Edit/ESceneSectorTools.h | 82 +- .../LevelEditor/Edit/ESceneSectorToolsIO.cpp | 88 +- .../LevelEditor/Edit/ESceneShapeControls.cpp | 85 +- .../LevelEditor/Edit/ESceneShapeTools.cpp | 82 +- .../LevelEditor/Edit/ESceneShapeTools.h | 71 +- .../LevelEditor/Edit/ESceneShapeToolsIO.cpp | 73 +- .../LevelEditor/Edit/ESceneSoundEnvTools.cpp | 19 +- .../LevelEditor/Edit/ESceneSoundEnvTools.h | 60 +- .../Edit/ESceneSoundEnvToolsIO.cpp | 74 +- .../LevelEditor/Edit/ESceneSoundSrcTools.h | 63 +- .../Edit/ESceneSoundSrcToolsIO.cpp | 74 +- .../LevelEditor/Edit/ESceneSpawnControls.cpp | 80 +- .../LevelEditor/Edit/ESceneSpawnTools.cpp | 311 +-- .../LevelEditor/Edit/ESceneSpawnToolsIO.cpp | 87 +- .../Edit/ESceneWallmarkControls.cpp | 64 +- .../LevelEditor/Edit/ESceneWallmarkTools.cpp | 1365 ++++++----- .../LevelEditor/Edit/ESceneWallmarkTools.h | 256 +- .../LevelEditor/Edit/ESceneWayControls.cpp | 60 +- .../LevelEditor/Edit/ESceneWayControls.h | 21 +- .../LevelEditor/Edit/ESceneWayTools.cpp | 8 +- src/editors/LevelEditor/Edit/ESceneWayTools.h | 63 +- .../LevelEditor/Edit/ESceneWayToolsIO.cpp | 72 +- src/editors/LevelEditor/Edit/EShape.cpp | 742 +++--- .../LevelEditor/Edit/ESound_Environment.cpp | 141 +- .../LevelEditor/Edit/ESound_Environment.h | 46 +- .../LevelEditor/Edit/ESound_Source.cpp | 660 +++--- .../LevelEditor/Edit/EditObjectExportLWO.cpp | 171 +- src/editors/LevelEditor/Edit/FS2.cpp | 27 +- src/editors/LevelEditor/Edit/FS2.h | 499 ++-- .../Edit/GeometryPartExtractor.cpp | 609 +++-- .../LevelEditor/Edit/GeometryPartExtractor.h | 186 +- src/editors/LevelEditor/Edit/GroupObject.cpp | 578 ++--- .../LevelEditor/Edit/GroupObjectUtils.cpp | 2 +- .../LevelEditor/Edit/LevelPreferences.cpp | 66 +- .../LevelEditor/Edit/LevelPreferences.h | 16 +- src/editors/LevelEditor/Edit/SceneIO.cpp | 1682 ++++++------- src/editors/LevelEditor/Edit/SceneObject.cpp | 363 +-- src/editors/LevelEditor/Edit/SceneObject.h | 189 +- .../LevelEditor/Edit/SceneObjectIO.cpp | 160 +- src/editors/LevelEditor/Edit/ScenePick.cpp | 252 +- src/editors/LevelEditor/Edit/SceneRender.cpp | 193 +- .../LevelEditor/Edit/SceneSelection.cpp | 181 +- src/editors/LevelEditor/Edit/SceneSnap.cpp | 210 +- .../LevelEditor/Edit/SceneSummaryInfo.cpp | 718 +++--- .../LevelEditor/Edit/SceneSummaryInfo.h | 335 +-- src/editors/LevelEditor/Edit/SceneUndo.cpp | 105 +- src/editors/LevelEditor/Edit/SceneUtil.cpp | 69 +- src/editors/LevelEditor/Edit/Scene_Tools.cpp | 48 +- .../LevelEditor/Edit/SoundManager_LE.cpp | 91 +- .../LevelEditor/Edit/SoundManager_LE.h | 44 +- src/editors/LevelEditor/Edit/SpawnPoint.cpp | 1727 +++++++------- src/editors/LevelEditor/Edit/SpawnPoint.h | 254 +- src/editors/LevelEditor/Edit/UI_LevelMain.cpp | 1595 +++++++------ src/editors/LevelEditor/Edit/UI_LevelMain.h | 150 +- .../LevelEditor/Edit/UI_LevelTools.cpp | 571 +++-- src/editors/LevelEditor/Edit/UI_LevelTools.h | 246 +- src/editors/LevelEditor/Edit/WayPoint.cpp | 1115 +++++---- src/editors/LevelEditor/Edit/WayPoint.h | 221 +- src/editors/LevelEditor/Edit/glow.cpp | 272 ++- src/editors/LevelEditor/Edit/glow.h | 94 +- src/editors/LevelEditor/Edit/portal.cpp | 717 +++--- src/editors/LevelEditor/Edit/portalutils.cpp | 704 +++--- src/editors/LevelEditor/Edit/scene.cpp | 666 +++--- src/editors/LevelEditor/Edit/scene.h | 498 ++-- src/editors/LevelEditor/Edit/sector.cpp | 755 +++--- src/editors/LevelEditor/Edit/sector.h | 178 +- src/editors/LevelEditor/EditLibrary.cpp | 1068 +++++---- src/editors/LevelEditor/EditLibrary.h | 156 +- src/editors/LevelEditor/EditLightAnim.cpp | 626 +++-- src/editors/LevelEditor/EditLightAnim.h | 183 +- src/editors/LevelEditor/FrameAIMap.cpp | 123 +- src/editors/LevelEditor/FrameDetObj.cpp | 61 +- src/editors/LevelEditor/FrameEmitter.cpp | 119 +- src/editors/LevelEditor/FrameEmitter.h | 100 +- src/editors/LevelEditor/FrameGroup.cpp | 135 +- src/editors/LevelEditor/FrameGroup.h | 115 +- src/editors/LevelEditor/FrameLight.cpp | 45 +- src/editors/LevelEditor/FrameObject.cpp | 247 +- src/editors/LevelEditor/FrameObject.h | 129 +- src/editors/LevelEditor/FramePS.cpp | 95 +- src/editors/LevelEditor/FramePS.h | 63 +- src/editors/LevelEditor/FramePortal.cpp | 44 +- src/editors/LevelEditor/FrameSector.cpp | 54 +- src/editors/LevelEditor/FrameShape.cpp | 38 +- src/editors/LevelEditor/FrameSpawn.cpp | 182 +- src/editors/LevelEditor/FrameSpawn.h | 95 +- src/editors/LevelEditor/FrameWayPoint.cpp | 107 +- src/editors/LevelEditor/FrmDBXpacker.cpp | 171 +- src/editors/LevelEditor/FrmDBXpacker.h | 77 +- src/editors/LevelEditor/LEClipEditor.cpp | 254 +- src/editors/LevelEditor/LEClipEditor.h | 86 +- src/editors/LevelEditor/LEPhysics.cpp | 40 +- src/editors/LevelEditor/LeftBar.cpp | 587 +++-- src/editors/LevelEditor/LevelEditor.cpp | 253 +- src/editors/LevelEditor/ObjectList.cpp | 573 ++--- src/editors/LevelEditor/ObjectList.h | 130 +- src/editors/LevelEditor/PropertiesEObject.cpp | 193 +- src/editors/LevelEditor/PropertiesEObject.h | 107 +- src/editors/LevelEditor/ShaderFunction.cpp | 219 +- src/editors/LevelEditor/ShaderFunction.h | 98 +- src/editors/LevelEditor/TopBar.cpp | 223 +- src/editors/LevelEditor/iniStreamImpl.h | 54 +- src/editors/LevelEditor/lephysics.h | 22 +- src/editors/LevelEditor/main.cpp | 232 +- src/editors/LevelEditor/previewimage.cpp | 79 +- src/editors/LevelEditor/stdafx.h | 123 +- 185 files changed, 27929 insertions(+), 21797 deletions(-) diff --git a/src/editors/LevelEditor/BottomBar.cpp b/src/editors/LevelEditor/BottomBar.cpp index c42b7e7615c..f7044de2d1c 100644 --- a/src/editors/LevelEditor/BottomBar.cpp +++ b/src/editors/LevelEditor/BottomBar.cpp @@ -3,50 +3,72 @@ #pragma hdrstop #include "BottomBar.h" -#include "../ECore/Editor/LogForm.h" -#include "../ECore/Editor/ui_main.h" -#include "igame_persistent.h" +#include "editors/ECore/Editor/LogForm.h" +#include "editors/ECore/Editor/ui_main.h" +#include "xrEngine/IGame_Persistent.h" #include "environment.h" //--------------------------------------------------------------------------- #pragma package(smart_init) -#pragma link "ExtBtn" +#pragma link "ExtBtn" #pragma link "MxMenus" #pragma link "mxPlacemnt" -#pragma resource "*.dfm" -TfraBottomBar *fraBottomBar=0; +#pragma resource "*.dfm" +TfraBottomBar *fraBottomBar = 0; + //--------------------------------------------------------------------------- -__fastcall TfraBottomBar::TfraBottomBar(TComponent* Owner) +__fastcall TfraBottomBar::TfraBottomBar(TComponent *Owner) : TFrame(Owner) { DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ClickOptionsMenuItem(TObject *Sender) { - TMenuItem* mi = dynamic_cast(Sender); - if (mi){ + TMenuItem *mi = dynamic_cast(Sender); + if (mi) + { mi->Checked = !mi->Checked; - if (mi==miDrawGrid) ExecCommand(COMMAND_TOGGLE_GRID); - else if (mi==miRenderWithTextures) psDeviceFlags.set(rsRenderTextures,mi->Checked); - else if (mi==miMuteSounds) psDeviceFlags.set(rsMuteSounds,mi->Checked); - else if (mi==miLightScene) psDeviceFlags.set(rsLighting,mi->Checked); - else if (mi==miRenderLinearFilter) psDeviceFlags.set(rsFilterLinear,mi->Checked); - else if (mi==miRenderEdgedFaces) psDeviceFlags.set(rsEdgedFaces,mi->Checked); - else if (mi==miFog) psDeviceFlags.set(rsFog,mi->Checked); - else if (mi==miRealTime) psDeviceFlags.set(rsRenderRealTime,mi->Checked); - else if (mi==miDrawSafeRect) ExecCommand(COMMAND_TOGGLE_SAFE_RECT); - else if (mi==miRenderFillPoint) EDevice.dwFillMode = D3DFILL_POINT; - else if (mi==miRenderFillWireframe) EDevice.dwFillMode = D3DFILL_WIREFRAME; - else if (mi==miRenderFillSolid) EDevice.dwFillMode = D3DFILL_SOLID; - else if (mi==miRenderShadeFlat) EDevice.dwShadeMode = D3DSHADE_FLAT; - else if (mi==miRenderShadeGouraud) EDevice.dwShadeMode = D3DSHADE_GOURAUD; - else if (mi==miRenderHWTransform){ HW.Caps.bForceGPU_SW = !mi->Checked; UI->Resize(); } + if (mi==miDrawGrid) + ExecCommand(COMMAND_TOGGLE_GRID); + else if (mi==miRenderWithTextures) + psDeviceFlags.set(rsRenderTextures, mi->Checked); + else if (mi==miMuteSounds) + psDeviceFlags.set(rsMuteSounds, mi->Checked); + else if (mi==miLightScene) + psDeviceFlags.set(rsLighting, mi->Checked); + else if (mi==miRenderLinearFilter) + psDeviceFlags.set(rsFilterLinear, mi->Checked); + else if (mi==miRenderEdgedFaces) + psDeviceFlags.set(rsEdgedFaces, mi->Checked); + else if (mi==miFog) + psDeviceFlags.set(rsFog, mi->Checked); + else if (mi==miRealTime) + psDeviceFlags.set(rsRenderRealTime, mi->Checked); + else if (mi==miDrawSafeRect) + ExecCommand(COMMAND_TOGGLE_SAFE_RECT); + else if (mi==miRenderFillPoint) + EDevice.dwFillMode = D3DFILL_POINT; + else if (mi==miRenderFillWireframe) + EDevice.dwFillMode = D3DFILL_WIREFRAME; + else if (mi==miRenderFillSolid) + EDevice.dwFillMode = D3DFILL_SOLID; + else if (mi==miRenderShadeFlat) + EDevice.dwShadeMode = D3DSHADE_FLAT; + else if (mi==miRenderShadeGouraud) + EDevice.dwShadeMode = D3DSHADE_GOURAUD; + else if (mi==miRenderHWTransform) + { + HW.Caps.bForceGPU_SW = !mi->Checked; + UI->Resize(); + } } UI->RedrawScene(); ExecCommand(COMMAND_UPDATE_TOOLBAR); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::QualityClick(TObject *Sender) { @@ -54,287 +76,329 @@ void __fastcall TfraBottomBar::QualityClick(TObject *Sender) ((TMenuItem*)Sender)->Checked = true; UI->Resize(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::fsStorageRestorePlacement(TObject *Sender) { // fill mode - if (miRenderFillPoint->Checked) EDevice.dwFillMode=D3DFILL_POINT; - else if (miRenderFillWireframe->Checked)EDevice.dwFillMode=D3DFILL_WIREFRAME; - else if (miRenderFillSolid->Checked) EDevice.dwFillMode=D3DFILL_SOLID; + if (miRenderFillPoint->Checked) + EDevice.dwFillMode = D3DFILL_POINT; + else if (miRenderFillWireframe->Checked) + EDevice.dwFillMode = D3DFILL_WIREFRAME; + else if (miRenderFillSolid->Checked) + EDevice.dwFillMode = D3DFILL_SOLID; // shade mode - if (miRenderShadeFlat->Checked) EDevice.dwShadeMode=D3DSHADE_FLAT; - else if (miRenderShadeGouraud->Checked) EDevice.dwShadeMode=D3DSHADE_GOURAUD; + if (miRenderShadeFlat->Checked) + EDevice.dwShadeMode = D3DSHADE_FLAT; + else if (miRenderShadeGouraud->Checked) + EDevice.dwShadeMode = D3DSHADE_GOURAUD; // hw transform - HW.Caps.bForceGPU_SW = !miRenderHWTransform->Checked; + HW.Caps.bForceGPU_SW = !miRenderHWTransform->Checked; // quality - if (N200->Checked) QualityClick(N200); - else if (N150->Checked) QualityClick(N150); - else if (N125->Checked) QualityClick(N125); - else if (N100->Checked) QualityClick(N100); - else if (N75->Checked) QualityClick(N75); - else if (N50->Checked) QualityClick(N50); - else if (N25->Checked) QualityClick(N25); + if (N200->Checked) + QualityClick(N200); + else if (N150->Checked) + QualityClick(N150); + else if (N125->Checked) + QualityClick(N125); + else if (N100->Checked) + QualityClick(N100); + else if (N75->Checked) + QualityClick(N75); + else if (N50->Checked) + QualityClick(N50); + else if (N25->Checked) + QualityClick(N25); // setup menu miWeather->Clear(); - TMenuItem* mi = xr_new((TComponent*)0); - mi->Caption = "none"; - mi->OnClick = miWeatherClick; - mi->Tag = -1; - mi->Checked = true; - mi->RadioItem = true; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); -/* - // append weathers - CEnvironment::EnvsMapIt _I=g_pGamePersistent->Environment().WeatherCycles.begin(); - CEnvironment::EnvsMapIt _E=g_pGamePersistent->Environment().WeatherCycles.end(); - for (; _I!=_E; _I++){ - mi = xr_new((TComponent*)0); - mi->Caption = *_I->first; - mi->OnClick = miWeatherClick; - mi->RadioItem = true; - miWeather->Add (mi); - } -*/ - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Reload"; - mi->OnClick = miWeatherClick; - mi->Tag = -2; - miWeather->Add (mi); - - mi = xr_new((TComponent*)0); - mi->Caption = "-"; - miWeather->Add (mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Properties..."; - mi->OnClick = miWeatherClick; - mi->Tag = -3; - miWeather->Add (mi); - - psDeviceFlags.set (rsEnvironment,FALSE); + TMenuItem *mi = xr_new((TComponent*)0); + mi->Caption = "none"; + mi->OnClick = miWeatherClick; + mi->Tag = -1; + mi->Checked = true; + mi->RadioItem = true; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + /* + // append weathers + CEnvironment::EnvsMapIt _I=g_pGamePersistent->Environment().WeatherCycles.begin(); + CEnvironment::EnvsMapIt _E=g_pGamePersistent->Environment().WeatherCycles.end(); + for (; _I!=_E; _I++){ + mi = xr_new((TComponent*)0); + mi->Caption = *_I->first; + mi->OnClick = miWeatherClick; + mi->RadioItem = true; + miWeather->Add(mi); + } + */ + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "Reload"; + mi->OnClick = miWeatherClick; + mi->Tag = -2; + miWeather->Add(mi); + + mi = xr_new((TComponent*)0); + mi->Caption = "-"; + miWeather->Add(mi); + mi = xr_new((TComponent*)0); + mi->Caption = "Properties..."; + mi->OnClick = miWeatherClick; + mi->Tag = -3; + miWeather->Add(mi); + + psDeviceFlags.set(rsEnvironment, FALSE); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebLogClick(TObject *Sender) { - TfrmLog::ChangeVisible(); + TfrmLog::ChangeVisible(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebStopClick(TObject *Sender) { - ExecCommand(COMMAND_BREAK_LAST_OPERATION); + ExecCommand(COMMAND_BREAK_LAST_OPERATION); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebStatClick(TObject *Sender) { - psDeviceFlags.set(rsStatistic,!psDeviceFlags.is(rsStatistic)); + psDeviceFlags.set(rsStatistic, !psDeviceFlags.is(rsStatistic)); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebOptionsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { POINT pt; GetCursorPos(&pt); - pmOptions->Popup(pt.x,pt.y); - TExtBtn* btn = dynamic_cast(Sender); VERIFY(btn); btn->MouseManualUp(); + pmOptions->Popup(pt.x, pt.y); + TExtBtn *btn = dynamic_cast(Sender); + VERIFY(btn); + btn->MouseManualUp(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::pmOptionsPopup(TObject *Sender) { - miRenderWithTextures->Checked = psDeviceFlags.is(rsRenderTextures); - miLightScene->Checked = psDeviceFlags.is(rsLighting); - miMuteSounds->Checked = psDeviceFlags.is(rsMuteSounds); - miRenderLinearFilter->Checked = psDeviceFlags.is(rsFilterLinear); - miRenderEdgedFaces->Checked = psDeviceFlags.is(rsEdgedFaces); - miRealTime->Checked = psDeviceFlags.is(rsRenderRealTime); - miFog->Checked = psDeviceFlags.is(rsFog); - miDrawGrid->Checked = psDeviceFlags.is(rsDrawGrid); - miDrawSafeRect->Checked = psDeviceFlags.is(rsDrawSafeRect); - - for(int i=0; i < miWeather->Count; ++i) + miRenderWithTextures->Checked = psDeviceFlags.is(rsRenderTextures); + miLightScene->Checked = psDeviceFlags.is(rsLighting); + miMuteSounds->Checked = psDeviceFlags.is(rsMuteSounds); + miRenderLinearFilter->Checked = psDeviceFlags.is(rsFilterLinear); + miRenderEdgedFaces->Checked = psDeviceFlags.is(rsEdgedFaces); + miRealTime->Checked = psDeviceFlags.is(rsRenderRealTime); + miFog->Checked = psDeviceFlags.is(rsFog); + miDrawGrid->Checked = psDeviceFlags.is(rsDrawGrid); + miDrawSafeRect->Checked = psDeviceFlags.is(rsDrawSafeRect); + + for (int i = 0; iCount; ++i) { - TMenuItem* mi = miWeather->Items[i]; + TMenuItem *mi = miWeather->Items[i]; BOOL bch; - bch = ((EPrefs->sWeather.size()) && (0==stricmp(mi->Caption.c_str(), EPrefs->sWeather.c_str()))) || - (mi->Caption=="none" && EPrefs->sWeather.size()==0) ; - mi->Checked = bch; + bch = ((EPrefs->sWeather.size())&&(0==stricmp(mi->Caption.c_str(), EPrefs->sWeather.c_str())))|| + (mi->Caption=="none"&&EPrefs->sWeather.size()==0) ; + mi->Checked = bch; } } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::miWeatherClick(TObject *Sender) { -/* - TMenuItem* mi = dynamic_cast(Sender); - if (mi){ - if (mi->Tag==0){ - psDeviceFlags.set (rsEnvironment,TRUE); - g_pGamePersistent->Environment().SetWeather(mi->Caption.c_str()); - EPrefs->sWeather = mi->Caption.c_str(); - mi->Checked = !mi->Checked; - }else if (mi->Tag==-1){ - psDeviceFlags.set (rsEnvironment,FALSE); - g_pGamePersistent->Environment().SetWeather(0); - EPrefs->sWeather = ""; - mi->Checked = !mi->Checked; - }else if (mi->Tag==-2){ - Engine.ReloadSettings(); - g_pGamePersistent->Environment().ED_Reload(); - }else if (mi->Tag==-3){ - TProperties* P = TProperties::CreateModalForm("Weather properties"); - CEnvironment& env = g_pGamePersistent->Environment(); - PropItemVec items; - float ft=env.ed_from_time,tt=env.ed_to_time,sp=env.fTimeFactor; - PHelper().CreateTime (items,"From Time", &ft); - PHelper().CreateTime (items,"To Time", &tt); - PHelper().CreateFloat (items,"Speed", &sp, 1.f,10000.f,1.f,1); - - P->AssignItems (items); - if (mrOk==P->ShowPropertiesModal()){ - env.ed_from_time = ft; - env.ed_to_time = tt; - env.fTimeFactor = sp; + /* + TMenuItem* mi = dynamic_cast(Sender); + if (mi){ + if (mi->Tag==0){ + psDeviceFlags.set(rsEnvironment,TRUE); + g_pGamePersistent->Environment().SetWeather(mi->Caption.c_str()); + EPrefs->sWeather = mi->Caption.c_str(); + mi->Checked = !mi->Checked; + }else if (mi->Tag==-1){ + psDeviceFlags.set(rsEnvironment,FALSE); + g_pGamePersistent->Environment().SetWeather(0); + EPrefs->sWeather = ""; + mi->Checked = !mi->Checked; + }else if (mi->Tag==-2){ + Engine.ReloadSettings(); + g_pGamePersistent->Environment().ED_Reload(); + }else if (mi->Tag==-3){ + TProperties* P = TProperties::CreateModalForm("Weather properties"); + CEnvironment& env = g_pGamePersistent->Environment(); + PropItemVec items; + float ft=env.ed_from_time,tt=env.ed_to_time,sp=env.fTimeFactor; + PHelper().CreateTime(items,"From Time", &ft); + PHelper().CreateTime(items,"To Time", &tt); + PHelper().CreateFloat(items,"Speed", &sp, 1.f,10000.f,1.f,1); + + P->AssignItems (items); + if (mrOk==P->ShowPropertiesModal()){ + env.ed_from_time = ft; + env.ed_to_time = tt; + env.fTimeFactor = sp; + } + TProperties::DestroyForm(P); } - TProperties::DestroyForm(P); } - } -*/ + */ } + //--------------------------------------------------------------------------- void TfraBottomBar::RedrawBar() { - SPBItem* pbi = UI->ProgressLast(); - if (pbi){ - AnsiString txt; - float p,m; - pbi->GetInfo(txt,p,m); + SPBItem *pbi = UI->ProgressLast(); + if (pbi) + { + AnsiString txt; + float p, m; + pbi->GetInfo(txt, p, m); // status line - if (paStatus->Caption!=txt){ - paStatus->Caption = txt; - paStatus->Repaint (); + if (paStatus->Caption!=txt) + { + paStatus->Caption = txt; + paStatus->Repaint(); } // progress - int val = fis_zero(m)?0:(int)((p/m)*100); - if (val!=cgProgress->Progress){ - cgProgress->Progress = val; - cgProgress->Repaint (); + int val = fis_zero(m) ? 0 : (int)((p/m)*100); + if (val!=cgProgress->Progress) + { + cgProgress->Progress = val; + cgProgress->Repaint(); } - if (false==cgProgress->Visible) - cgProgress->Visible = true; - }else{ - if (cgProgress->Visible){ + + if (false==cgProgress->Visible) + cgProgress->Visible = true; + } + else + { + if (cgProgress->Visible) + { // status line - paStatus->Caption = ""; - paStatus->Repaint (); - // progress - cgProgress->Visible = false; - cgProgress->Progress = 0; + paStatus->Caption = ""; + paStatus->Repaint(); + // progress + cgProgress->Visible = false; + cgProgress->Progress = 0; } } } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroAssignClick(TObject *Sender) { - ExecCommand(COMMAND_ASSIGN_MACRO,((TMenuItem*)Sender)->Tag,0); + ExecCommand(COMMAND_ASSIGN_MACRO, ((TMenuItem*)Sender)->Tag, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroClearClick(TObject *Sender) { - ExecCommand(COMMAND_ASSIGN_MACRO,((TMenuItem*)Sender)->Tag,xr_string("")); + ExecCommand(COMMAND_ASSIGN_MACRO, ((TMenuItem*)Sender)->Tag, xr_string("")); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroExecuteClick(TObject *Sender) { - ExecCommand(COMMAND_RUN_MACRO,((TMenuItem*)Sender)->Tag,0); + ExecCommand(COMMAND_RUN_MACRO, ((TMenuItem*)Sender)->Tag, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroLogCommandsClick(TObject *Sender) { - ExecCommand(COMMAND_LOG_COMMANDS,((TMenuItem*)Sender)->Checked,0); + ExecCommand(COMMAND_LOG_COMMANDS, ((TMenuItem*)Sender)->Checked, 0); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::MacroEditCommandListClick(TObject *Sender) { - ExecCommand(COMMAND_EDIT_COMMAND_LIST); + ExecCommand(COMMAND_EDIT_COMMAND_LIST); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::ebMacroMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - SECommand* CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; VERIFY(CMD); + SECommand *CMD = GetEditorCommands()[COMMAND_RUN_MACRO]; + VERIFY(CMD); // fill macroses - pmMacro->Items->Clear(); - TMenuItem* mi; - for (u32 k=0; ksub_commands.size(); ++k){ - SESubCommand* SUB = CMD->sub_commands[k]; - BOOL bValid = !xr_string(SUB->p0).empty(); - mi = xr_new((TComponent*)0); - mi->Caption = AnsiString().sprintf("%d: %s",k+1,bValid?xr_string(SUB->p0).c_str():""); - TMenuItem* e = xr_new((TComponent*)0); - e->Caption = "Execute"; - e->OnClick = MacroExecuteClick; - e->Enabled = bValid; - e->Tag = k; - e->ShortCut = SUB->shortcut.hotkey; - TMenuItem* a = xr_new((TComponent*)0); - a->Caption = "Assign"; - a->OnClick = MacroAssignClick; - a->Tag = k; - TMenuItem* c = xr_new((TComponent*)0); - c->Caption = "Clear"; - c->OnClick = MacroClearClick; - c->Tag = k; - mi->Add (e); - mi->Add (a); - mi->Add (c); + pmMacro->Items->Clear(); + TMenuItem *mi; + for (u32 k = 0; ksub_commands.size(); ++k) + { + SESubCommand *SUB = CMD->sub_commands[k]; + BOOL bValid = !xr_string(SUB->p0).empty(); + mi = xr_new((TComponent*)0); + mi->Caption = AnsiString().sprintf("%d: %s", k+1, bValid ? xr_string(SUB->p0).c_str() : ""); + TMenuItem *e = xr_new((TComponent*)0); + e->Caption = "Execute"; + e->OnClick = MacroExecuteClick; + e->Enabled = bValid; + e->Tag = k; + e->ShortCut = SUB->shortcut.hotkey; + TMenuItem *a = xr_new((TComponent*)0); + a->Caption = "Assign"; + a->OnClick = MacroAssignClick; + a->Tag = k; + TMenuItem *c = xr_new((TComponent*)0); + c->Caption = "Clear"; + c->OnClick = MacroClearClick; + c->Tag = k; + mi->Add(e); + mi->Add(a); + mi->Add(c); pmMacro->Items->Add(mi); } - mi = xr_new((TComponent*)0); - mi->Caption = "-"; + mi = xr_new((TComponent*)0); + mi->Caption = "-"; pmMacro->Items->Add(mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Edit Command List..."; - mi->OnClick = MacroEditCommandListClick; + mi = xr_new((TComponent*)0); + mi->Caption = "Edit Command List..."; + mi->OnClick = MacroEditCommandListClick; pmMacro->Items->Add(mi); - mi = xr_new((TComponent*)0); - mi->Caption = "Log Commands"; - mi->AutoCheck = true; - mi->Checked = AllowLogCommands(); - mi->OnClick = MacroLogCommandsClick; + mi = xr_new((TComponent*)0); + mi->Caption = "Log Commands"; + mi->AutoCheck = true; + mi->Checked = AllowLogCommands(); + mi->OnClick = MacroLogCommandsClick; pmMacro->Items->Add(mi); - // popup menu + // popup menu POINT pt; - GetCursorPos (&pt); - pmMacro->Popup (pt.x,pt.y); - TExtBtn* btn = dynamic_cast(Sender); VERIFY(btn); btn->MouseManualUp(); + GetCursorPos(&pt); + pmMacro->Popup(pt.x, pt.y); + TExtBtn *btn = dynamic_cast(Sender); + VERIFY(btn); + btn->MouseManualUp(); } + //--------------------------------------------------------------------------- void __fastcall TfraBottomBar::N501Click(TObject *Sender) { - TMenuItem* mi = dynamic_cast(Sender); - float val = ((float)mi->Tag / 100.0f); - EDevice.time_factor (val); - mi->Checked = true; + TMenuItem *mi = dynamic_cast(Sender); + float val = ((float)mi->Tag/100.0f); + EDevice.time_factor(val); + mi->Checked = true; } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/DOOneColor.cpp b/src/editors/LevelEditor/DOOneColor.cpp index b60fd951f62..02444114582 100644 --- a/src/editors/LevelEditor/DOOneColor.cpp +++ b/src/editors/LevelEditor/DOOneColor.cpp @@ -3,109 +3,125 @@ #include "DOOneColor.h" #include "DOShuffle.h" -#include "../ECore/Editor/ColorPicker.h" +#include "editors/ECore/Editor/ColorPicker.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "ElXPThemedControl" #pragma link "ExtBtn" #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfrmOneColor::TfrmOneColor(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfrmOneColor::TfrmOneColor(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- -void __fastcall TfrmOneColor::ShowIndex(TfrmDOShuffle* parent) +void __fastcall TfrmOneColor::ShowIndex(TfrmDOShuffle *parent) { - m_Parent = parent; -// VERIFY(stage); -// m_CurStage = stage; + m_Parent = parent; + // VERIFY(stage); + // m_CurStage = stage; bLoadMode = true; -// if (m_CurStage){ -// } + // if (m_CurStage){ + // } bLoadMode = false; - Visible=true; + Visible = true; } + //--------------------------------------------------------------------------- -void __fastcall TfrmOneColor::HideIndex(){ - Visible=false; +void __fastcall TfrmOneColor::HideIndex() +{ + Visible = false; } + //--------------------------------------------------------------------------- void __fastcall TfrmOneColor::mcColorMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - u32 color = ((TMultiObjColor*)Sender)->Brush->Color; - if (SelectColorWin(&color)){ - ((TMultiObjColor*)Sender)->_Set(color); - m_Parent->bColorIndModif = true; + u32 color = ((TMultiObjColor*)Sender)->Brush->Color; + if (SelectColorWin(&color)) + { + ((TMultiObjColor*)Sender)->_Set(color); + m_Parent->bColorIndModif = true; } } + //--------------------------------------------------------------------------- void __fastcall TfrmOneColor::FormClose(TObject *Sender, - TCloseAction &Action) + TCloseAction &Action) { - Action = caFree; + Action = caFree; m_Parent->RemoveColorIndex(this); } + //--------------------------------------------------------------------------- void __fastcall TfrmOneColor::ebMultiRemoveClick(TObject *Sender) { - Close(); + Close(); } + //--------------------------------------------------------------------------- void __fastcall TfrmOneColor::tvDOListDragOver(TObject *Sender, - TObject *Source, int X, int Y, TDragState State, bool &Accept) + TObject *Source, int X, int Y, TDragState State, bool &Accept) { Accept = false; - if (Source == tvDOList) return; - if (Source != m_Parent->tvItems) return; - for ( TElTreeItem* node = tvDOList->Items->GetFirstNode(); node; node = node->GetNext()) - if (node->Text == m_Parent->FDragItem->Text) return; - Accept = true; + if (Source==tvDOList) + return; + if (Source!=m_Parent->tvItems) + return; + for (TElTreeItem *node = tvDOList->Items->GetFirstNode(); node; node = node->GetNext()) + if (node->Text==m_Parent->FDragItem->Text) + return; + Accept = true; } + //--------------------------------------------------------------------------- void __fastcall TfrmOneColor::tvDOListDragDrop(TObject *Sender, - TObject *Source, int X, int Y) + TObject *Source, int X, int Y) { - tvDOList->Items->AddObject(0,m_Parent->FDragItem->Text,m_Parent->FDragItem->Data); - m_Parent->bColorIndModif = true; + tvDOList->Items->AddObject(0, m_Parent->FDragItem->Text, m_Parent->FDragItem->Data); + m_Parent->bColorIndModif = true; } + //--------------------------------------------------------------------------- void __fastcall TfrmOneColor::tvDOListStartDrag(TObject *Sender, - TDragObject *&DragObject) + TDragObject *&DragObject) { - FDragItem = tvDOList->ItemFocused; + FDragItem = tvDOList->ItemFocused; } + //--------------------------------------------------------------------------- -void __fastcall TfrmOneColor::RemoveObject(LPCSTR text){ - for ( TElTreeItem* node = tvDOList->Items->GetFirstNode(); node; node = node->GetNext()) - if (node->Text == (WideString)text){ - node->Delete(); - return; +void __fastcall TfrmOneColor::RemoveObject(LPCSTR text) +{ + for (TElTreeItem *node = tvDOList->Items->GetFirstNode(); node; node = node->GetNext()) + if (node->Text==(WideString)text) + { + node->Delete(); + return; } } void __fastcall TfrmOneColor::AppendObject(LPCSTR text, LPVOID data) { - for ( TElTreeItem* node = tvDOList->Items->GetFirstNode(); node; node = node->GetNext()) - if (node->Text == (WideString)text) return; - tvDOList->Items->AddObject(0,text,data); + for (TElTreeItem *node = tvDOList->Items->GetFirstNode(); node; node = node->GetNext()) + if (node->Text==(WideString)text) + return; + tvDOList->Items->AddObject(0, text, data); } void __fastcall TfrmOneColor::tvDOListItemFocused(TObject *Sender) { - m_Parent->OnItemFocused (tvDOList); + m_Parent->OnItemFocused(tvDOList); } + //--------------------------------------------------------------------------- diff --git a/src/editors/LevelEditor/DOShuffle.cpp b/src/editors/LevelEditor/DOShuffle.cpp index 937b966723d..899d6d4f709 100644 --- a/src/editors/LevelEditor/DOShuffle.cpp +++ b/src/editors/LevelEditor/DOShuffle.cpp @@ -4,25 +4,26 @@ #pragma hdrstop #include "DOShuffle.h" -#include "../ECore/Editor/EThumbnail.h" -#include "xr_trims.h" -#include "../ECore/Editor/Library.h" +#include "editors/ECore/Editor/EThumbnail.h" +#include "xrCore/xr_trims.h" +#include "editors/ECore/Editor/Library.h" #include "DOOneColor.h" -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditObject.h" #include "Scene.h" -#include "../xrEProps/folderlib.h" +#include "editors/xrEProps/FolderLib.h" #include "ESceneDOTools.h" -#include "../ECore/Editor/ui_main.h" -#include "../ECore/Editor/ImageManager.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ImageManager.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" -TfrmDOShuffle *TfrmDOShuffle::form=0; +TfrmDOShuffle *TfrmDOShuffle::form = 0; //static DDVec DOData; /* -SDOData::SDOData(){ - DOData.push_back(this); +SDOData::SDOData() +{ + DOData.push_back(this); } */ //--------------------------------------------------------------------------- @@ -30,376 +31,441 @@ SDOData::SDOData(){ //--------------------------------------------------------------------------- bool __fastcall TfrmDOShuffle::Run() { - VERIFY(!form); - form = xr_new((TComponent*)0,dynamic_cast(Scene->GetTool(OBJCLASS_DO))); - // show + VERIFY(!form); + form = xr_new((TComponent*)0, dynamic_cast(Scene->GetTool(OBJCLASS_DO))); + // show return (form->ShowModal()==mrOk); } + //--------------------------------------------------------------------------- void TfrmDOShuffle::OnObjectPropsModified() { - bObjectModif = true; -// TElTreeItem* N = tvItems->Selected; -// tvItems->Selected = 0; -// tvItems->Selected = N; + bObjectModif = true; + // TElTreeItem* N = tvItems->Selected; + // tvItems->Selected = 0; + // tvItems->Selected = N; } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::FormCreate(TObject *Sender) { - m_ObjectProps = TProperties::CreateForm("Objects",paObjectProps,alClient,fastdelegate::bind(this,&TfrmDOShuffle::OnObjectPropsModified)); - bTHMLockRepaint = false; - bLockFocused = false; + m_ObjectProps = TProperties::CreateForm("Objects", paObjectProps, alClient, fastdelegate::bind(this, &TfrmDOShuffle::OnObjectPropsModified)); + bTHMLockRepaint = false; + bLockFocused = false; } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::FormDestroy(TObject *Sender) { - TProperties::DestroyForm(m_ObjectProps); + TProperties::DestroyForm(m_ObjectProps); } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::FormShow(TObject *Sender) { - bColorIndModif = false; - bObjectModif = false; - FillData (); - // check window position - UI->CheckWindowPos (this); + bColorIndModif = false; + bObjectModif = false; + FillData(); + // check window position + UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- void TfrmDOShuffle::FillData() { - // init + // init tvItems->IsUpdating = true; tvItems->Selected = 0; tvItems->Items->Clear(); // objects - for (CDetailManager::DetailIt d_it=DM->objects.begin(); d_it!=DM->objects.end(); d_it++) - AddItem(0,((EDetail*)(*d_it))->GetName(),(void*)(*d_it)); + for (CDetailManager::DetailIt d_it = DM->objects.begin(); d_it!=DM->objects.end(); d_it++) + AddItem(0, ((EDetail*)(*d_it))->GetName(), (void*)(*d_it)); // indices ColorIndexPairIt S = DM->m_ColorIndices.begin(); ColorIndexPairIt E = DM->m_ColorIndices.end(); - ColorIndexPairIt it= S; - for(; it!=E; it++){ - TfrmOneColor* OneColor = xr_new((TComponent*)0); - color_indices.push_back(OneColor); - OneColor->Parent = form->sbDO; - OneColor->ShowIndex(this); + ColorIndexPairIt it = S; + for (; it!=E; it++) + { + TfrmOneColor *OneColor = xr_new((TComponent*)0); + color_indices.push_back(OneColor); + OneColor->Parent = form->sbDO; + OneColor->ShowIndex(this); OneColor->mcColor->Brush->Color = (TColor)rgb2bgr(it->first); - for (DOIt do_it=it->second.begin(); do_it!=it->second.end(); do_it++){ - EDetail* dd = 0; - for (CDetailManager::DetailIt d_it=DM->objects.begin(); d_it!=DM->objects.end(); d_it++) - if (0==strcmp(((EDetail*)(*d_it))->GetName(),(*do_it)->GetName())){ dd = (EDetail*)*d_it; break; } + for (DOIt do_it = it->second.begin(); do_it!=it->second.end(); do_it++) + { + EDetail *dd = 0; + for (CDetailManager::DetailIt d_it = DM->objects.begin(); d_it!=DM->objects.end(); d_it++) + if (0==strcmp(((EDetail*)(*d_it))->GetName(), (*do_it)->GetName())) + { + dd = (EDetail*)*d_it; + break; + } VERIFY(dd); - OneColor->AppendObject(dd->GetName(),dd); + OneColor->AppendObject(dd->GetName(), dd); } } // redraw tvItems->IsUpdating = false; } + //--------------------------------------------------------------------------- bool TfrmDOShuffle::ApplyChanges() { - // update indices - DM->RemoveColorIndices(); - for (u32 k=0; ktvDOList->Items->Count){ - u32 clr = bgr2rgb(OneColor->mcColor->Brush->Color); - for ( TElTreeItem* node = OneColor->tvDOList->Items->GetFirstNode(); node; node = node->GetNext()) - DM->AppendIndexObject(clr,AnsiString(node->Text).c_str(),false); + // update indices + DM->RemoveColorIndices(); + for (u32 k = 0; ktvDOList->Items->Count) + { + u32 clr = bgr2rgb(OneColor->mcColor->Brush->Color); + for (TElTreeItem *node = OneColor->tvDOList->Items->GetFirstNode(); node; node = node->GetNext()) + DM->AppendIndexObject(clr, AnsiString(node->Text).c_str(), false); } } - if (/*bNeedUpdate||*/bColorIndModif||bObjectModif){ - ELog.DlgMsg(mtInformation,"Object or object list changed. Reinitialize needed!"); + if (/*bNeedUpdate||*/bColorIndModif||bObjectModif) + { + ELog.DlgMsg(mtInformation, "Object or object list changed. Reinitialize needed!"); DM->InvalidateSlots(); - return true; + return true; } return false; } + //--------------------------------------------------------------------------- void TfrmDOShuffle::ClearIndexForms() { - for (u32 k=0; kItems->GetFirstNode(); node; node = node->GetNext()) - if (node->Data && (AnsiString(node->Text) == s)) return node; + for (TElTreeItem *node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) + if (node->Data&&(AnsiString(node->Text)==s)) + return node; return 0; } + //--------------------------------------------------------------------------- -TElTreeItem* TfrmDOShuffle::AddItem(TElTreeItem* node, const char* name, void* obj) +TElTreeItem *TfrmDOShuffle::AddItem(TElTreeItem *node, const char *name, void *obj) { - TElTreeItem* obj_node = tvItems->Items->AddChildObject(node, name, obj); + TElTreeItem *obj_node = tvItems->Items->AddChildObject(node, name, obj); obj_node->ParentStyle = false; obj_node->Bold = false; return obj_node; } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { -// if (Key==VK_ESCAPE) ebCancel->Click(); -// if (Key==VK_RETURN) ebOk->Click(); + // if (Key==VK_ESCAPE) ebCancel->Click(); + // if (Key==VK_RETURN) ebOk->Click(); } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::FormClose(TObject *Sender, TCloseAction &Action) { - ModalResult = ApplyChanges()?mrOk:mrCancel; + ModalResult = ApplyChanges() ? mrOk : mrCancel; - ClearIndexForms(); + ClearIndexForms(); if (ModalResult==mrOk) - DM->InvalidateCache(); + DM->InvalidateCache(); - Action = caFree; + Action = caFree; form = 0; } + //--------------------------------------------------------------------------- -void TfrmDOShuffle::OnItemFocused(TElTree* tv) +void TfrmDOShuffle::OnItemFocused(TElTree *tv) { - if (bLockFocused) return; - bLockFocused = true; + if (bLockFocused) + return; + bLockFocused = true; - // unselect before - if (tvItems!=tv) tvItems->Selected = 0; - for (u32 k=0; ktvDOList!=tv){ - OneColor->tvDOList->IsUpdating = true; - OneColor->tvDOList->Selected = 0; - OneColor->tvDOList->IsUpdating = false; + // unselect before + if (tvItems!=tv) + tvItems->Selected = 0; + for (u32 k = 0; ktvDOList!=tv) + { + OneColor->tvDOList->IsUpdating = true; + OneColor->tvDOList->Selected = 0; + OneColor->tvDOList->IsUpdating = false; } } - bLockFocused = false; - + bLockFocused = false; + // select - TElTreeItem* Item = tv->Selected; + TElTreeItem *Item = tv->Selected; xr_delete(m_Thm); PropItemVec items; - if (Item&&Item->Data){ - AnsiString nm = Item->Text; - m_Thm = ImageLib.CreateThumbnail(nm.c_str(),EImageThumbnail::ETObject); - EDetail* dd = (EDetail*)Item->Data; - PHelper().CreateCaption (items,"Ref Name", dd->GetName()); - PHelper().CreateFloat (items,"Density", &dd->m_fDensityFactor, 0.1f, 1.0f); - PHelper().CreateFloat (items,"Min Scale", &dd->m_fMinScale, 0.1f, 100.0f); - PHelper().CreateFloat (items,"Max Scale", &dd->m_fMaxScale, 0.1f, 100.f); - PHelper().CreateFlag32 (items,"No Waving", &dd->m_Flags, DO_NO_WAVING); + if (Item&&Item->Data) + { + AnsiString nm = Item->Text; + m_Thm = ImageLib.CreateThumbnail(nm.c_str(), EImageThumbnail::ETObject); + EDetail *dd = (EDetail*)Item->Data; + PHelper().CreateCaption(items, "Ref Name", dd->GetName()); + PHelper().CreateFloat(items, "Density", &dd->m_fDensityFactor, 0.1f, 1.0f); + PHelper().CreateFloat(items, "Min Scale", &dd->m_fMinScale, 0.1f, 100.0f); + PHelper().CreateFloat(items, "Max Scale", &dd->m_fMaxScale, 0.1f, 100.f); + PHelper().CreateFlag32(items, "No Waving", &dd->m_Flags, DO_NO_WAVING); } - m_ObjectProps->AssignItems (items); - if (!bTHMLockRepaint) paImage->Repaint(); + m_ObjectProps->AssignItems(items); + if (!bTHMLockRepaint) + paImage->Repaint(); } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::tvItemsItemFocused(TObject *Sender) { - OnItemFocused (tvItems); + OnItemFocused(tvItems); } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::paImagePaint(TObject *Sender) { - if (m_Thm) m_Thm->Draw(paImage); + if (m_Thm) + m_Thm->Draw(paImage); } + //--------------------------------------------------------------------------- -bool __fastcall LookupFunc(TElTreeItem* Item, void* SearchDetails){ +bool __fastcall LookupFunc(TElTreeItem *Item, void *SearchDetails) +{ char s1 = *(char*)SearchDetails; char s2 = *AnsiString(Item->Text).c_str(); - return (s1==tolower(s2)); + return (s1==tolower(s2)); } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::tvItemsKeyPress(TObject *Sender, char &Key) { - TElTreeItem* node = tvItems->Items->LookForItemEx(tvItems->Selected,-1,false,false,false,&Key,LookupFunc); - if (!node) node = tvItems->Items->LookForItemEx(0,-1,false,false,false,&Key,LookupFunc); - FHelper.RestoreSelection(tvItems,node,false); + TElTreeItem *node = tvItems->Items->LookForItemEx(tvItems->Selected, -1, false, false, false, &Key, LookupFunc); + if (!node) + node = tvItems->Items->LookForItemEx(0, -1, false, false, false, &Key, LookupFunc); + FHelper.RestoreSelection(tvItems, node, false); } + //--------------------------------------------------------------------------- -static TElTreeItem* DragItem=0; +static TElTreeItem *DragItem = 0; + void __fastcall TfrmDOShuffle::tvMultiDragDrop(TObject *Sender, - TObject *Source, int X, int Y) + TObject *Source, int X, int Y) { - TElTreeItem* node = ((TElTree*)Sender)->GetItemAtY(Y); + TElTreeItem *node = ((TElTree*)Sender)->GetItemAtY(Y); if (node) - DragItem->MoveToIns(0,node->Index); - DragItem = 0; + DragItem->MoveToIns(0, node->Index); + DragItem = 0; } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::tvMultiDragOver(TObject *Sender, - TObject *Source, int X, int Y, TDragState State, bool &Accept) + TObject *Source, int X, int Y, TDragState State, bool &Accept) { - Accept = false; - TElTreeItem* node = ((TElTree*)Sender)->GetItemAtY(Y); - if ((Sender==Source)&&(node!=DragItem)) Accept=true; + Accept = false; + TElTreeItem *node = ((TElTree*)Sender)->GetItemAtY(Y); + if ((Sender==Source)&&(node!=DragItem)) + Accept = true; } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::tvMultiStartDrag(TObject *Sender, - TDragObject *&DragObject) + TDragObject *&DragObject) { - DragItem = ((TElTree*)Sender)->Selected; + DragItem = ((TElTree*)Sender)->Selected; } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::ebAddObjectClick(TObject *Sender) { - LPCSTR S; - if (TfrmChoseItem::SelectItem(smObject,S,8)){ - AStringVec lst; - _SequenceToList(lst, S); - for (AStringIt s_it=lst.begin(); s_it!=lst.end(); s_it++) - if (!FindItem(s_it->c_str())){ - if (tvItems->Items->Count>=dm_max_objects){ - ELog.DlgMsg(mtInformation,"Maximum detail objects in scene '%d'",dm_max_objects); + LPCSTR S; + if (TfrmChoseItem::SelectItem(smObject, S, 8)) + { + AStringVec lst; + _SequenceToList(lst, S); + for (AStringIt s_it = lst.begin(); s_it!=lst.end(); s_it++) + if (!FindItem(s_it->c_str())) + { + if (tvItems->Items->Count>=dm_max_objects) + { + ELog.DlgMsg(mtInformation, "Maximum detail objects in scene '%d'", dm_max_objects); return; } - AddItem(0,s_it->c_str(),(void*)DM->AppendDO(s_it->c_str())); + AddItem(0, s_it->c_str(), (void*)DM->AppendDO(s_it->c_str())); } } } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::ebDelObjectClick(TObject *Sender) { - if (tvItems->Selected){ - LPCSTR name = AnsiString(tvItems->Selected->Text).c_str(); - DM->RemoveDO (name); - bObjectModif = true; - bColorIndModif = true; - for (u32 k=0; kRemoveObject(name); + if (tvItems->Selected) + { + LPCSTR name = AnsiString(tvItems->Selected->Text).c_str(); + DM->RemoveDO(name); + bObjectModif = true; + bColorIndModif = true; + for (u32 k = 0; kRemoveObject(name); tvItems->Selected->Delete(); } } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::ebAppendIndexClick(TObject *Sender) { bColorIndModif = true; - color_indices.push_back(xr_new((TComponent*)0)); - color_indices.back()->Parent = sbDO; + color_indices.push_back(xr_new((TComponent*)0)); + color_indices.back()->Parent = sbDO; color_indices.back()->ShowIndex(this); } + //--------------------------------------------------------------------------- -void __fastcall TfrmDOShuffle::RemoveColorIndex(TfrmOneColor* p) +void __fastcall TfrmDOShuffle::RemoveColorIndex(TfrmOneColor *p) { - form->bColorIndModif = true; - form->color_indices.erase(std::find(form->color_indices.begin(),form->color_indices.end(),p)); + form->bColorIndModif = true; + form->color_indices.erase(std::find(form->color_indices.begin(), form->color_indices.end(), p)); } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::ebMultiClearClick(TObject *Sender) { - bColorIndModif = true; - for (u32 k=0; kParent; - if (OneColor&&OneColor->FDragItem){ - OneColor->FDragItem->Delete(); - bColorIndModif = true; + TfrmOneColor *OneColor = (TfrmOneColor*)((TElTree*)Source)->Parent; + if (OneColor&&OneColor->FDragItem) + { + OneColor->FDragItem->Delete(); + bColorIndModif = true; } } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::tvItemsDragOver(TObject *Sender, - TObject *Source, int X, int Y, TDragState State, bool &Accept) + TObject *Source, int X, int Y, TDragState State, bool &Accept) { Accept = false; - if (Source == tvItems) return; + if (Source==tvItems) + return; Accept = true; } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::tvItemsStartDrag(TObject *Sender, - TDragObject *&DragObject) + TDragObject *&DragObject) { FDragItem = tvItems->ItemFocused; } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::ebSaveListClick(TObject *Sender) { - xr_string fname; - if (EFS.GetSaveName(_detail_objects_,fname)){ - DM->ExportColorIndices(fname.c_str()); + xr_string fname; + if (EFS.GetSaveName(_detail_objects_, fname)) + { + DM->ExportColorIndices(fname.c_str()); } } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::ebLoadListClick(TObject *Sender) { - xr_string fname; - if (EFS.GetOpenName(_detail_objects_,fname)){ - if (DM->ImportColorIndices(fname.c_str())){ - bColorIndModif = true; - DM->InvalidateSlots (); - ClearIndexForms (); - FillData (); + xr_string fname; + if (EFS.GetOpenName(_detail_objects_, fname)) + { + if (DM->ImportColorIndices(fname.c_str())) + { + bColorIndModif = true; + DM->InvalidateSlots(); + ClearIndexForms(); + FillData(); } } } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::ebClearListClick(TObject *Sender) { - DM->InvalidateSlots (); - DM->ClearColorIndices (); - ClearIndexForms (); - FillData (); - bColorIndModif = true; - bObjectModif = true; - UI->RedrawScene (); + DM->InvalidateSlots(); + DM->ClearColorIndices(); + ClearIndexForms(); + FillData(); + bColorIndModif = true; + bObjectModif = true; + UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::fsStorageRestorePlacement(TObject *Sender) { - m_ObjectProps->RestoreParams(fsStorage); + m_ObjectProps->RestoreParams(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfrmDOShuffle::fsStorageSavePlacement(TObject *Sender) { - m_ObjectProps->SaveParams(fsStorage); + m_ObjectProps->SaveParams(fsStorage); } + //--------------------------------------------------------------------------- diff --git a/src/editors/LevelEditor/DOShuffle.h b/src/editors/LevelEditor/DOShuffle.h index f90bfed3f53..eadb4859511 100644 --- a/src/editors/LevelEditor/DOShuffle.h +++ b/src/editors/LevelEditor/DOShuffle.h @@ -12,7 +12,7 @@ #include #include -#include "../ECore/Editor/Library.h" +#include "editors/ECore/Editor/Library.h" #include #include "ElTree.hpp" #include "ElXPThemedControl.hpp" @@ -27,103 +27,114 @@ class EDetailManager; class TfrmDOShuffle : public TForm { -friend class TfrmOneColor; -__published: // IDE-managed Components - TPanel *paTools; - TFormStorage *fsStorage; - TPanel *Panel3; - TScrollBox *sbDO; - TExtBtn *ebAppendIndex; - TExtBtn *ebMultiClear; - TPanel *Panel2; - TElTree *tvItems; - TPanel *paObject; - TPanel *Panel1; - TExtBtn *ebAddObject; - TExtBtn *ebDelObject; - TExtBtn *ebLoadList; - TExtBtn *ebSaveList; - TExtBtn *ebClearList; - TPanel *paObjectProps; - TSplitter *Splitter1; - TMxPanel *paImage; + friend class TfrmOneColor; + __published: // IDE-managed Components + TPanel*paTools; + TFormStorage *fsStorage; + TPanel *Panel3; + TScrollBox *sbDO; + TExtBtn *ebAppendIndex; + TExtBtn *ebMultiClear; + TPanel *Panel2; + TElTree *tvItems; + TPanel *paObject; + TPanel *Panel1; + TExtBtn *ebAddObject; + TExtBtn *ebDelObject; + TExtBtn *ebLoadList; + TExtBtn *ebSaveList; + TExtBtn *ebClearList; + TPanel *paObjectProps; + TSplitter *Splitter1; + TMxPanel *paImage; void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); - void __fastcall paImagePaint(TObject *Sender); - void __fastcall tvItemsKeyPress(TObject *Sender, char &Key); - void __fastcall tvMultiDragDrop(TObject *Sender, TObject *Source, int X, - int Y); - void __fastcall tvMultiDragOver(TObject *Sender, TObject *Source, int X, - int Y, TDragState State, bool &Accept); - void __fastcall tvMultiStartDrag(TObject *Sender, - TDragObject *&DragObject); - void __fastcall ebAddObjectClick(TObject *Sender); - void __fastcall ebDelObjectClick(TObject *Sender); - void __fastcall ebAppendIndexClick(TObject *Sender); - void __fastcall ebMultiClearClick(TObject *Sender); - void __fastcall tvItemsDragDrop(TObject *Sender, TObject *Source, int X, - int Y); - void __fastcall tvItemsDragOver(TObject *Sender, TObject *Source, int X, - int Y, TDragState State, bool &Accept); - void __fastcall tvItemsStartDrag(TObject *Sender, - TDragObject *&DragObject); - void __fastcall FormShow(TObject *Sender); - void __fastcall tvItemsItemFocused(TObject *Sender); - void __fastcall ebSaveListClick(TObject *Sender); - void __fastcall ebLoadListClick(TObject *Sender); - void __fastcall ebClearListClick(TObject *Sender); - void __fastcall FormCreate(TObject *Sender); - void __fastcall FormDestroy(TObject *Sender); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); -private: // User declarations - static TfrmDOShuffle* form; - TElTreeItem* FDragItem; - - EImageThumbnail* m_Thm; - EDetailManager* DM; - - TProperties* m_ObjectProps; - void __stdcall OnObjectPropsModified(); - + void __fastcall paImagePaint(TObject *Sender); + void __fastcall tvItemsKeyPress(TObject *Sender, char &Key); + void __fastcall tvMultiDragDrop(TObject *Sender, TObject *Source, int X, + int Y); + void __fastcall tvMultiDragOver(TObject *Sender, TObject *Source, int X, + int Y, TDragState State, bool &Accept); + void __fastcall tvMultiStartDrag(TObject *Sender, + TDragObject *&DragObject); + void __fastcall ebAddObjectClick(TObject *Sender); + void __fastcall ebDelObjectClick(TObject *Sender); + void __fastcall ebAppendIndexClick(TObject *Sender); + void __fastcall ebMultiClearClick(TObject *Sender); + void __fastcall tvItemsDragDrop(TObject *Sender, TObject *Source, int X, + int Y); + void __fastcall tvItemsDragOver(TObject *Sender, TObject *Source, int X, + int Y, TDragState State, bool &Accept); + void __fastcall tvItemsStartDrag(TObject *Sender, + TDragObject *&DragObject); + void __fastcall FormShow(TObject *Sender); + void __fastcall tvItemsItemFocused(TObject *Sender); + void __fastcall ebSaveListClick(TObject *Sender); + void __fastcall ebLoadListClick(TObject *Sender); + void __fastcall ebClearListClick(TObject *Sender); + void __fastcall FormCreate(TObject *Sender); + void __fastcall FormDestroy(TObject *Sender); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); +private: // User declarations + static TfrmDOShuffle *form; + TElTreeItem *FDragItem; + + EImageThumbnail *m_Thm; + EDetailManager *DM; + + TProperties *m_ObjectProps; + void __stdcall OnObjectPropsModified(); + xr_vector color_indices; - void InitItemsList(const char* nm=0); - TElTreeItem* FindItem(const char* s); - TElTreeItem* AddItem(TElTreeItem* node, const char* name, void* obj=(void*)1); + void InitItemsList(const char *nm = 0); + TElTreeItem *FindItem(const char *s); + TElTreeItem *AddItem(TElTreeItem *node, const char *name, void *obj = (void*)1); - void FillData (); - bool ApplyChanges (); + void FillData(); + bool ApplyChanges(); bool bColorIndModif; bool bObjectModif; - void ClearIndexForms(); + void ClearIndexForms(); bool bTHMLockRepaint; bool bLockFocused; -public: - void OnItemFocused (TElTree* tv); -public: // User declarations - __fastcall TfrmDOShuffle(TComponent* Owner, EDetailManager* dm_tools); -// static function - static bool __fastcall Run (); - static bool __fastcall Visible(){return !!form;} - static void __fastcall RemoveColorIndex(TfrmOneColor* p); - static TfrmDOShuffle* __fastcall Form(){return form;} +public: + void OnItemFocused(TElTree *tv); +public: // User declarations + __fastcall TfrmDOShuffle(TComponent *Owner, EDetailManager *dm_tools); + // static function + static bool __fastcall Run(); + + static bool __fastcall Visible() + { + return !!form; + } + + static void __fastcall RemoveColorIndex(TfrmOneColor *p); + + static TfrmDOShuffle * __fastcall Form() + { + return form; + } }; + //--------------------------------------------------------------------------- /* struct SDOData{ - AnsiString m_RefName; - float m_fMinScale; - float m_fMaxScale; - float m_fDensityFactor; - Flags32 m_Flags; - SDOData (); + AnsiString m_RefName; + float m_fMinScale; + float m_fMaxScale; + float m_fDensityFactor; + Flags32 m_Flags; + SDOData(); }; DEFINE_VECTOR(SDOData*,DDVec,DDIt); */ //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/AppendObjectInfoForm.h b/src/editors/LevelEditor/Edit/AppendObjectInfoForm.h index c98ae36b404..6f72968cf88 100644 --- a/src/editors/LevelEditor/Edit/AppendObjectInfoForm.h +++ b/src/editors/LevelEditor/Edit/AppendObjectInfoForm.h @@ -13,23 +13,23 @@ class CCustomObject; class TfrmAppendObjectInfo : public TForm { __published: // IDE-managed Components - TStaticText *StaticText1; - TButton *btOverwrite; - TButton *btSkip; - TCheckBox *CheckBox1; - TButton *Button1; - TStaticText *StaticText2; - void __fastcall btOverwriteClick(TObject *Sender); + TStaticText *StaticText1; + TButton *btOverwrite; + TButton *btSkip; + TCheckBox *CheckBox1; + TButton *Button1; + TStaticText *StaticText2; + void __fastcall btOverwriteClick(TObject *Sender); private: // User declarations public: // User declarations - __fastcall TfrmAppendObjectInfo(TComponent* Owner); + __fastcall TfrmAppendObjectInfo(TComponent* Owner); - void Prepare (); - CCustomObject* m_existing_object; - CCustomObject* m_new_object; - int m_result; + void Prepare(); + CCustomObject* m_existing_object; + CCustomObject* m_new_object; + int m_result; }; -extern TfrmAppendObjectInfo* g_frmConflictLoadObject; +extern TfrmAppendObjectInfo* g_frmConflictLoadObject; //--------------------------------------------------------------------------- #endif diff --git a/src/editors/LevelEditor/Edit/Builder.cpp b/src/editors/LevelEditor/Edit/Builder.cpp index eca92f364fd..fda35b5dbfb 100644 --- a/src/editors/LevelEditor/Edit/Builder.cpp +++ b/src/editors/LevelEditor/Edit/Builder.cpp @@ -9,244 +9,290 @@ #include "Scene.h" #include "PortalUtils.h" #include "ESceneDOTools.h" -#include "../ECore/Editor/ui_main.h" -#include "../ECore/Editor/ui_toolscustom.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/UI_ToolsCustom.h" #include "xrHemisphere.h" //---------------------------------------------------- SceneBuilder Builder; //---------------------------------------------------- -ICF static void simple_hemi_callback(float x, float y, float z, float E, LPVOID P) +ICF static + +void simple_hemi_callback(float x, float y, float z, float E, LPVOID P) { - SceneBuilder::BLVec* dst = (SceneBuilder::BLVec*)P; - SceneBuilder::SBuildLight T; - T.energy = E; - T.light.direction.set (x,y,z); - dst->push_back (T); + SceneBuilder::BLVec *dst = (SceneBuilder::BLVec*)P; + SceneBuilder::SBuildLight T; + T.energy = E; + T.light.direction.set(x, y, z); + dst->push_back(T); } SceneBuilder::SceneBuilder() { m_iDefaultSectorNum = 0; - l_scene_stat = 0; - l_verts = 0; - l_faces = 0; - l_smgroups = 0; - l_vert_cnt = 0; - l_face_cnt = 0; - l_vert_it = 0; - l_face_it = 0; - object_for_render = 0; - m_save_as_object = false; + l_scene_stat = 0; + l_verts = 0; + l_faces = 0; + l_smgroups = 0; + l_vert_cnt = 0; + l_face_cnt = 0; + l_vert_it = 0; + l_face_it = 0; + object_for_render = 0; + m_save_as_object = false; } -SceneBuilder::~SceneBuilder() -{ -} +SceneBuilder::~SceneBuilder() {} //------------------------------------------------------------------------------ #define CHECK_BREAK if (UI->NeedAbort()) break; #define VERIFY_COMPILE(x,c1,c2) CHECK_BREAK \ if (!x){error_text.sprintf("ERROR: %s %s", c1,c2); break;} + //------------------------------------------------------------------------------ BOOL SceneBuilder::Compile(bool b_selected_only) { - if(m_save_as_object) - { - EvictResource (); - GetBounding (); - CompileStatic (b_selected_only); - EvictResource (); - return TRUE; - } - - AnsiString error_text = ""; - UI->ResetBreak (); - if(UI->ContainEState(esBuildLevel)) return false; - ELog.Msg( mtInformation, "Building started..." ); + if (m_save_as_object) + { + EvictResource(); + GetBounding(); + CompileStatic(b_selected_only); + EvictResource(); + return TRUE; + } + + AnsiString error_text = ""; + UI->ResetBreak(); + if (UI->ContainEState(esBuildLevel)) + return false; + ELog.Msg(mtInformation, "Building started..."); UI->BeginEState(esBuildLevel); - try{ - do{ - // check debug + try + { + do + { + // check debug bool bTestPortal = Scene->ObjCount(OBJCLASS_SECTOR)||Scene->ObjCount(OBJCLASS_PORTAL); - // validate scene - VERIFY_COMPILE(Scene->Validate(false,bTestPortal,true,true,true,true),"Validation failed.","Invalid scene."); - // fill simple hemi - simple_hemi.clear (); - xrHemisphereBuild (1,2.f,simple_hemi_callback,&simple_hemi); - // build - VERIFY_COMPILE (PreparePath(), "Failed to prepare level path",""); - VERIFY_COMPILE (PrepareFolders(), "Failed to prepare level folders",""); - VERIFY_COMPILE (EvictResource(), "Failed to evict resource",""); - VERIFY_COMPILE (GetBounding(), "Failed to acquire level bounding volume",""); - VERIFY_COMPILE (RenumerateSectors(), "Failed to renumerate sectors",""); - VERIFY_COMPILE (CompileStatic(false), "Failed static remote build",""); - VERIFY_COMPILE (EvictResource(), "Failed to evict resource",""); - VERIFY_COMPILE (BuildLTX(), "Failed to build level description",""); - VERIFY_COMPILE (BuildGame(), "Failed to build game",""); - VERIFY_COMPILE (BuildSceneStat(), "Failed to build scene statistic",""); - BuildHOMModel (); - BuildSOMModel (); - // build tools - SceneToolsMapPairIt _I = Scene->FirstTool(); - SceneToolsMapPairIt _E = Scene->LastTool(); + // validate scene + VERIFY_COMPILE(Scene->Validate(false,bTestPortal,true,true,true,true),"Validation failed.","Invalid scene."); + // fill simple hemi + simple_hemi.clear(); + xrHemisphereBuild(1, 2.f, simple_hemi_callback, &simple_hemi); + // build + VERIFY_COMPILE (PreparePath(), "Failed to prepare level path",""); + VERIFY_COMPILE (PrepareFolders(), "Failed to prepare level folders",""); + VERIFY_COMPILE (EvictResource(), "Failed to evict resource",""); + VERIFY_COMPILE (GetBounding(), "Failed to acquire level bounding volume",""); + VERIFY_COMPILE (RenumerateSectors(), "Failed to renumerate sectors",""); + VERIFY_COMPILE (CompileStatic(false), "Failed static remote build",""); + VERIFY_COMPILE (EvictResource(), "Failed to evict resource",""); + VERIFY_COMPILE (BuildLTX(), "Failed to build level description",""); + VERIFY_COMPILE (BuildGame(), "Failed to build game",""); + VERIFY_COMPILE (BuildSceneStat(), "Failed to build scene statistic",""); + BuildHOMModel(); + BuildSOMModel(); + // build tools + SceneToolsMapPairIt _I = Scene->FirstTool(); + SceneToolsMapPairIt _E = Scene->LastTool(); for (; _I!=_E; ++_I) { - if (_I->first!=OBJCLASS_DUMMY) + if (_I->first!=OBJCLASS_DUMMY) { if (_I->second->Valid()) { VERIFY_COMPILE(_I->second->Export(m_LevelPath),_I->second->ClassDesc(),"export failed."); - ELog.Msg(mtInformation,"Process %s - done.",_I->second->ClassDesc()); - }else + ELog.Msg(mtInformation, "Process %s - done.", _I->second->ClassDesc()); + } + else { - ELog.Msg(mtError,"Process %s - failed.",_I->second->ClassDesc()); + ELog.Msg(mtError, "Process %s - failed.", _I->second->ClassDesc()); } } } - Clear (); - } while(0); - - if (!error_text.IsEmpty()) ELog.DlgMsg(mtError,error_text.c_str()); - else if (UI->NeedAbort()) ELog.DlgMsg(mtInformation,"Building terminated."); - else ELog.DlgMsg(mtInformation,"Building OK."); - }catch(...){ - ELog.DlgMsg(mtError,"Error has occured in builder routine. Editor aborted."); + Clear(); + } while (0); + + if (!error_text.IsEmpty()) + ELog.DlgMsg(mtError, error_text.c_str()); + else if (UI->NeedAbort()) + ELog.DlgMsg(mtInformation, "Building terminated."); + else + ELog.DlgMsg(mtInformation, "Building OK."); + } catch (...) + { + ELog.DlgMsg(mtError, "Error has occured in builder routine. Editor aborted."); abort(); } UI->EndEState(); - return error_text.IsEmpty(); + return error_text.IsEmpty(); } + //------------------------------------------------------------------------------ -BOOL SceneBuilder::MakeGame( ) +BOOL SceneBuilder::MakeGame() { - AnsiString error_text=""; - UI->ResetBreak(); - if(UI->ContainEState(esBuildLevel)) return false; - ELog.Msg( mtInformation, "Making started..." ); + AnsiString error_text = ""; + UI->ResetBreak(); + if (UI->ContainEState(esBuildLevel)) + return false; + ELog.Msg(mtInformation, "Making started..."); UI->BeginEState(esBuildLevel); - try{ - do{ - // clear error + try + { + do + { + // clear error Tools->ClearDebugDraw(); - // validate scene - VERIFY_COMPILE(Scene->Validate(false,false,false,false,false,false), "Validation failed.","Invalid scene."); - // build - VERIFY_COMPILE(PreparePath(), "Failed to prepare level path.",""); - VERIFY_COMPILE(GetBounding(), "Failed to acquire level bounding volume.",""); - VERIFY_COMPILE(RenumerateSectors(), "Failed to renumerate sectors",""); - VERIFY_COMPILE(BuildLTX(), "Failed to build level description.",""); - VERIFY_COMPILE(BuildGame(), "Failed to build game.",""); - } while(0); - - if (!error_text.IsEmpty()) ELog.DlgMsg(mtError,error_text.c_str()); - else if (UI->NeedAbort()) ELog.DlgMsg(mtInformation,"Making terminated."); - else ELog.DlgMsg(mtInformation,"Making finished."); - }catch(...){ - ELog.DlgMsg(mtError,"Error has occured in builder routine. Editor aborted."); + // validate scene + VERIFY_COMPILE(Scene->Validate(false,false,false,false,false,false), "Validation failed.","Invalid scene."); + // build + VERIFY_COMPILE(PreparePath(), "Failed to prepare level path.",""); + VERIFY_COMPILE(GetBounding(), "Failed to acquire level bounding volume.",""); + VERIFY_COMPILE(RenumerateSectors(), "Failed to renumerate sectors",""); + VERIFY_COMPILE(BuildLTX(), "Failed to build level description.",""); + VERIFY_COMPILE(BuildGame(), "Failed to build game.",""); + } while (0); + + if (!error_text.IsEmpty()) + ELog.DlgMsg(mtError, error_text.c_str()); + else if (UI->NeedAbort()) + ELog.DlgMsg(mtInformation, "Making terminated."); + else + ELog.DlgMsg(mtInformation, "Making finished."); + } catch (...) + { + ELog.DlgMsg(mtError, "Error has occured in builder routine. Editor aborted."); abort(); } UI->EndEState(); - return error_text.IsEmpty(); + return error_text.IsEmpty(); } + //------------------------------------------------------------------------------ BOOL SceneBuilder::MakeAIMap() { - AnsiString error_text; - do{ - VERIFY_COMPILE(PreparePath(), "Failed to prepare level path.",""); - VERIFY_COMPILE(BuildAIMap(), "Failed to build AI-Map.",""); - }while(0); - if (!error_text.IsEmpty()) ELog.DlgMsg(mtError,error_text.c_str()); - else if (UI->NeedAbort()) ELog.DlgMsg(mtInformation,"Building terminated."); - else ELog.DlgMsg(mtInformation,"AI-Map succesfully exported."); - - return error_text.IsEmpty(); + AnsiString error_text; + do + { + VERIFY_COMPILE(PreparePath(), "Failed to prepare level path.",""); + VERIFY_COMPILE(BuildAIMap(), "Failed to build AI-Map.",""); + } while (0); + if (!error_text.IsEmpty()) + ELog.DlgMsg(mtError, error_text.c_str()); + else if (UI->NeedAbort()) + ELog.DlgMsg(mtInformation, "Building terminated."); + else + ELog.DlgMsg(mtInformation, "AI-Map succesfully exported."); + + return error_text.IsEmpty(); } + //------------------------------------------------------------------------------ BOOL SceneBuilder::MakeDetails() { - AnsiString error_text; - do{ - VERIFY_COMPILE(PreparePath(), "Failed to prepare level path.",""); + AnsiString error_text; + do + { + VERIFY_COMPILE(PreparePath(), "Failed to prepare level path.",""); // save details - VERIFY_COMPILE(Scene->GetTool(OBJCLASS_DO)->Export(m_LevelPath), "Export failed.",""); - }while(0); - if (!error_text.IsEmpty()) ELog.DlgMsg(mtError,error_text.c_str()); - else if (UI->NeedAbort()) ELog.DlgMsg(mtInformation,"Building terminated."); - else ELog.DlgMsg(mtInformation,"Details succesfully exported."); + VERIFY_COMPILE(Scene->GetTool(OBJCLASS_DO)->Export(m_LevelPath), "Export failed.",""); + } while (0); + if (!error_text.IsEmpty()) + ELog.DlgMsg(mtError, error_text.c_str()); + else if (UI->NeedAbort()) + ELog.DlgMsg(mtInformation, "Building terminated."); + else + ELog.DlgMsg(mtInformation, "Details succesfully exported."); - return error_text.IsEmpty(); + return error_text.IsEmpty(); } + //------------------------------------------------------------------------------ -BOOL SceneBuilder::MakeHOM( ) +BOOL SceneBuilder::MakeHOM() { - AnsiString error_text=""; - UI->ResetBreak(); - if(UI->ContainEState(esBuildLevel)) return false; - ELog.Msg( mtInformation, "Making started..." ); + AnsiString error_text = ""; + UI->ResetBreak(); + if (UI->ContainEState(esBuildLevel)) + return false; + ELog.Msg(mtInformation, "Making started..."); UI->BeginEState(esBuildLevel); - try{ - do{ - // build - VERIFY_COMPILE(PreparePath(), "Failed to prepare level path.",""); - VERIFY_COMPILE(BuildHOMModel(), "Failed to build HOM model.",""); - } while(0); - - if (!error_text.IsEmpty()) ELog.DlgMsg(mtError,error_text.c_str()); - else if (UI->NeedAbort()) ELog.DlgMsg(mtInformation,"Building terminated..."); - else ELog.DlgMsg(mtInformation,"Building OK..."); - }catch(...){ - ELog.DlgMsg(mtError,"Error has occured in builder routine. Editor aborted."); + try + { + do + { + // build + VERIFY_COMPILE(PreparePath(), "Failed to prepare level path.",""); + VERIFY_COMPILE(BuildHOMModel(), "Failed to build HOM model.",""); + } while (0); + + if (!error_text.IsEmpty()) + ELog.DlgMsg(mtError, error_text.c_str()); + else if (UI->NeedAbort()) + ELog.DlgMsg(mtInformation, "Building terminated..."); + else + ELog.DlgMsg(mtInformation, "Building OK..."); + } catch (...) + { + ELog.DlgMsg(mtError, "Error has occured in builder routine. Editor aborted."); abort(); } UI->EndEState(); - return error_text.IsEmpty(); + return error_text.IsEmpty(); } + //------------------------------------------------------------------------------ -BOOL SceneBuilder::MakeSOM( ) +BOOL SceneBuilder::MakeSOM() { - AnsiString error_text=""; - UI->ResetBreak(); - if(UI->ContainEState(esBuildLevel)) return false; - ELog.Msg( mtInformation, "Making started..." ); + AnsiString error_text = ""; + UI->ResetBreak(); + if (UI->ContainEState(esBuildLevel)) + return false; + ELog.Msg(mtInformation, "Making started..."); UI->BeginEState(esBuildLevel); - try{ - do{ - // build - VERIFY_COMPILE(PreparePath(), "Failed to prepare level path.",""); - VERIFY_COMPILE(BuildSOMModel(), "Failed to build SOM model.",""); - } while(0); - - if (!error_text.IsEmpty()) ELog.DlgMsg(mtError,error_text.c_str()); - else if (UI->NeedAbort()) ELog.DlgMsg(mtInformation,"Building terminated..."); - else ELog.DlgMsg(mtInformation,"Building OK..."); - }catch(...){ - ELog.DlgMsg(mtError,"Error has occured in builder routine. Editor aborted."); + try + { + do + { + // build + VERIFY_COMPILE(PreparePath(), "Failed to prepare level path.",""); + VERIFY_COMPILE(BuildSOMModel(), "Failed to build SOM model.",""); + } while (0); + + if (!error_text.IsEmpty()) + ELog.DlgMsg(mtError, error_text.c_str()); + else if (UI->NeedAbort()) + ELog.DlgMsg(mtInformation, "Building terminated..."); + else + ELog.DlgMsg(mtInformation, "Building OK..."); + } catch (...) + { + ELog.DlgMsg(mtError, "Error has occured in builder routine. Editor aborted."); abort(); } UI->EndEState(); - return error_text.IsEmpty(); + return error_text.IsEmpty(); } + //------------------------------------------------------------------------------ -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditObject.h" + void SceneBuilder::OnRender() { - if (object_for_render){ + if (object_for_render) + { object_for_render->OnFrame(); object_for_render->RenderSingle(Fidentity); } diff --git a/src/editors/LevelEditor/Edit/Builder.h b/src/editors/LevelEditor/Edit/Builder.h index 00f31846a48..01e56382c86 100644 --- a/src/editors/LevelEditor/Edit/Builder.h +++ b/src/editors/LevelEditor/Edit/Builder.h @@ -6,7 +6,7 @@ #define BuilderH #include "communicate.h" -#include "../ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/EditMesh.h" #include "ESceneClassList.h" //---------------------------------------------------- @@ -25,137 +25,146 @@ class CSceneStat; // some types typedef Fvector b_vnormal; -struct sb_light_control // controller or "layer", 30fps +struct sb_light_control // controller or "layer", 30fps { - string64 name; // empty for base layer - U32Vec data; + string64 name; // empty for base layer + U32Vec data; }; -struct e_b_lod{ - b_lod lod; - U32Vec data; - U32Vec ndata; - shared_str lod_name; +struct e_b_lod +{ + b_lod lod; + U32Vec data; + U32Vec ndata; + shared_str lod_name; }; -class SceneBuilder{ +class SceneBuilder +{ public: - struct SBuildLight{ - Flight light; - float energy; + struct SBuildLight + { + Flight light; + float energy; }; - DEFINE_VECTOR(SBuildLight,BLVec,BLIt); + + DEFINE_VECTOR(SBuildLight, BLVec, BLIt); protected: - BLVec simple_hemi; + BLVec simple_hemi; public: - CEditableObject* object_for_render; - - int l_vert_cnt, l_vert_it; - int l_face_cnt, l_face_it; - b_vertex* l_verts; - b_face* l_faces; - u32* l_smgroups; - - xr_vector l_mu_models; - xr_vector l_mu_refs; - xr_vector l_lods; - xr_vector l_light_control; - xr_vector l_light_static; - xr_vector l_light_dynamic; - xr_vector l_textures; - xr_vector l_shaders; - xr_vector l_shaders_xrlc; - xr_vector l_materials; - xr_vector l_vnormals; - xr_vector l_glows; - xr_vector l_portals; - xr_vector l_light_keys; - - CSceneStat* l_scene_stat; - - void GetBBox (u32 st_fid, u32 cnt, Fbox& box); - - BOOL BuildGlow (CGlow* e); - void BuildPortal (b_portal* b, CPortal* e); - BOOL BuildMesh (const Fmatrix& parent, CEditableObject* object, CEditableMesh* mesh, int sector_num, - b_vertex* verts, int& vert_cnt, int& vert_it, - b_face* faces, int& face_cnt, int& face_it, u32* smooth_groups, const Fmatrix& real_transform); - BOOL BuildObject (CSceneObject* obj); - BOOL BuildMUObject (CSceneObject* obj); - - void Clear (); - - int BuildLightControl(LPCSTR name); - void BuildHemiLights (u8 quality, LPCSTR lcontrol); - void AppendLight (); - BOOL BuildSun (u8 quality, Fvector2 dir); - BOOL BuildPointLight (b_light* b, const Flags32& usage, svector* sectors, FvectorVec* soft_points, const Fmatrix* soft_transform=0); - BOOL BuildLight (CLight* e); - - int FindInLODs (b_lod* s); - int BuildObjectLOD (const Fmatrix& parent, CEditableObject* e, int sector_num); - - int FindInShaders (b_shader* s); - int BuildShader (LPCSTR s); - - int FindInShadersXRLC(b_shader* s); - int BuildShaderXRLC (const char * s); - - int FindInTextures (LPCSTR name); - int BuildTexture (LPCSTR name); - - int FindInMaterials (b_material* m); - int BuildMaterial (CSurface* surf, int sector_num, bool allow_draft); - int BuildMaterial (LPCSTR esh_name, LPCSTR csh_name, LPCSTR tx_name, u32 tx_cnt, int sector_num, bool allow_draft); - - BOOL ParseStaticObjects (ObjectList& lst, LPCSTR prefix, bool b_selected_only); - - int CalculateSector (const Fvector& P, float R); - - void SaveBuild (); - void SaveBuildAsObject (); + CEditableObject *object_for_render; + + int l_vert_cnt, l_vert_it; + int l_face_cnt, l_face_it; + b_vertex *l_verts; + b_face *l_faces; + u32 *l_smgroups; + + xr_vector l_mu_models; + xr_vector l_mu_refs; + xr_vector l_lods; + xr_vector l_light_control; + xr_vector l_light_static; + xr_vector l_light_dynamic; + xr_vector l_textures; + xr_vector l_shaders; + xr_vector l_shaders_xrlc; + xr_vector l_materials; + xr_vector l_vnormals; + xr_vector l_glows; + xr_vector l_portals; + xr_vector l_light_keys; + + CSceneStat *l_scene_stat; + + void GetBBox(u32 st_fid, u32 cnt, Fbox &box); + + BOOL BuildGlow(CGlow *e); + void BuildPortal(b_portal *b, CPortal *e); + BOOL BuildMesh(const Fmatrix &parent, CEditableObject *object, CEditableMesh *mesh, int sector_num, + b_vertex *verts, int &vert_cnt, int &vert_it, + b_face *faces, int &face_cnt, int &face_it, u32 *smooth_groups, const Fmatrix &real_transform); + BOOL BuildObject(CSceneObject *obj); + BOOL BuildMUObject(CSceneObject *obj); + + void Clear(); + + int BuildLightControl(LPCSTR name); + void BuildHemiLights(u8 quality, LPCSTR lcontrol); + void AppendLight(); + BOOL BuildSun(u8 quality, Fvector2 dir); + BOOL BuildPointLight(b_light *b, const Flags32 &usage, svector *sectors, FvectorVec *soft_points, const Fmatrix *soft_transform = 0); + BOOL BuildLight(CLight *e); + + int FindInLODs(b_lod *s); + int BuildObjectLOD(const Fmatrix &parent, CEditableObject *e, int sector_num); + + int FindInShaders(b_shader *s); + int BuildShader(LPCSTR s); + + int FindInShadersXRLC(b_shader *s); + int BuildShaderXRLC(const char *s); + + int FindInTextures(LPCSTR name); + int BuildTexture(LPCSTR name); + + int FindInMaterials(b_material *m); + int BuildMaterial(CSurface *surf, int sector_num, bool allow_draft); + int BuildMaterial(LPCSTR esh_name, LPCSTR csh_name, LPCSTR tx_name, u32 tx_cnt, int sector_num, bool allow_draft); + + BOOL ParseStaticObjects(ObjectList &lst, LPCSTR prefix, bool b_selected_only); + + int CalculateSector(const Fvector &P, float R); + + void SaveBuild(); + void SaveBuildAsObject(); protected: - friend void SaveBuild (); + friend void SaveBuild(); friend class TfrmBuildProgress; - Fbox m_LevelBox; + Fbox m_LevelBox; public: - bool m_save_as_object; - string_path m_LevelPath; - xr_string MakeLevelPath (LPCSTR nm){return xr_string(m_LevelPath)+xr_string(nm);} + bool m_save_as_object; + string_path m_LevelPath; + + xr_string MakeLevelPath(LPCSTR nm) + { + return xr_string(m_LevelPath)+xr_string(nm); + } + protected: - bool EvictResource (); - bool PrepareFolders (); - bool PreparePath (); - - bool GetBounding (); - - BOOL ParseLTX (CInifile* pIni, ObjectList& lst, LPCSTR prefix=0); - BOOL BuildLTX (); - BOOL ParseGAME (IWriter& game, IWriter& spawn, ObjectList& lst, LPCSTR prefix=0); - BOOL BuildGame (); - - BOOL BuildSceneStat (); - bool BuildHOMModel (); - bool BuildSOMModel (); - bool BuildAIMap (); - bool BuildWallmarks (); - BOOL CompileStatic (bool b_selected_only); - - int m_iDefaultSectorNum; - bool RenumerateSectors (); + bool EvictResource(); + bool PrepareFolders(); + bool PreparePath(); + + bool GetBounding(); + + BOOL ParseLTX(CInifile *pIni, ObjectList &lst, LPCSTR prefix = 0); + BOOL BuildLTX(); + BOOL ParseGAME(IWriter &game, IWriter &spawn, ObjectList &lst, LPCSTR prefix = 0); + BOOL BuildGame(); + + BOOL BuildSceneStat(); + bool BuildHOMModel(); + bool BuildSOMModel(); + bool BuildAIMap(); + bool BuildWallmarks(); + BOOL CompileStatic(bool b_selected_only); + + int m_iDefaultSectorNum; + bool RenumerateSectors(); public: - SceneBuilder (); - virtual ~SceneBuilder (); + SceneBuilder(); + virtual ~SceneBuilder(); - BOOL Compile (bool b_selected_only); - BOOL MakeGame (); - BOOL MakeDetails (); - BOOL MakeHOM (); - BOOL MakeSOM (); - BOOL MakeAIMap (); + BOOL Compile(bool b_selected_only); + BOOL MakeGame(); + BOOL MakeDetails(); + BOOL MakeHOM(); + BOOL MakeSOM(); + BOOL MakeAIMap(); - void OnRender (); + void OnRender(); }; extern SceneBuilder Builder; diff --git a/src/editors/LevelEditor/Edit/BuilderCore.cpp b/src/editors/LevelEditor/Edit/BuilderCore.cpp index b719fae99e7..3bb10275fd3 100644 --- a/src/editors/LevelEditor/Edit/BuilderCore.cpp +++ b/src/editors/LevelEditor/Edit/BuilderCore.cpp @@ -9,79 +9,94 @@ #include "Scene.h" #include "SceneObject.h" #include "Sector.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" + //------------------------------------------------------------------------------ bool SceneBuilder::PreparePath() { - if (Scene->m_LevelOp.m_FNLevelPath.size()==0) return false; - FS.update_path (m_LevelPath,_game_levels_,Scene->m_LevelOp.m_FNLevelPath.c_str()); - strcat(m_LevelPath,"\\"); + if (Scene->m_LevelOp.m_FNLevelPath.size()==0) + return false; + FS.update_path(m_LevelPath, _game_levels_, Scene->m_LevelOp.m_FNLevelPath.c_str()); + strcat(m_LevelPath, "\\"); return true; } + //------------------------------------------------------------------------------ bool SceneBuilder::PrepareFolders() { - FS.dir_delete (m_LevelPath,TRUE); - return true; + FS.dir_delete(m_LevelPath, TRUE); + return true; } + //------------------------------------------------------------------------------ bool SceneBuilder::EvictResource() { - ExecCommand(COMMAND_EVICT_OBJECTS); + ExecCommand(COMMAND_EVICT_OBJECTS); ExecCommand(COMMAND_EVICT_TEXTURES); - int objcount = Scene->ObjCount(OBJCLASS_SCENEOBJECT); - if( objcount <= 0 ) return true; + int objcount = Scene->ObjCount(OBJCLASS_SCENEOBJECT); + if (objcount<=0) + return true; - SPBItem* pb = UI->ProgressStart(objcount, "Evict objects..."); + SPBItem *pb = UI->ProgressStart(objcount, "Evict objects..."); // unload cform, point normals ObjectIt _F = Scene->FirstObj(OBJCLASS_SCENEOBJECT); ObjectIt _E = Scene->LastObj(OBJCLASS_SCENEOBJECT); - for(;_F!=_E;_F++){ - CSceneObject* O = (CSceneObject*)(*_F); - if (UI->NeedAbort()) break; // break building + for (; _F!=_E; _F++) + { + CSceneObject *O = (CSceneObject*)(*_F); + if (UI->NeedAbort()) + break; // break building O->EvictObject(); pb->Inc(); - } - UI->ProgressEnd(pb); + } + UI->ProgressEnd(pb); return true; } + //------------------------------------------------------------------------------ bool SceneBuilder::GetBounding() { - Fbox b0; - bool r0 = Scene->GetBox(m_LevelBox,OBJCLASS_SCENEOBJECT); - bool r1 = Scene->GetBox(b0,OBJCLASS_GROUP); - if (r1) m_LevelBox.merge(b0); - return (r0||r1); + Fbox b0; + bool r0 = Scene->GetBox(m_LevelBox, OBJCLASS_SCENEOBJECT); + bool r1 = Scene->GetBox(b0, OBJCLASS_GROUP); + if (r1) + m_LevelBox.merge(b0); + return (r0||r1); } + //------------------------------------------------------------------------------ bool SceneBuilder::RenumerateSectors() { - m_iDefaultSectorNum = -1; + m_iDefaultSectorNum = -1; - SPBItem* pb = UI->ProgressStart(Scene->ObjCount(OBJCLASS_SECTOR), "Renumerate sectors..."); + SPBItem *pb = UI->ProgressStart(Scene->ObjCount(OBJCLASS_SECTOR), "Renumerate sectors..."); - int sector_num = 0; + int sector_num = 0; ObjectIt _F = Scene->FirstObj(OBJCLASS_SECTOR); ObjectIt _E = Scene->LastObj(OBJCLASS_SECTOR); - for(;_F!=_E;_F++,sector_num++){ - CSector* _S=(CSector*)(*_F); + for (; _F!=_E; _F++,sector_num++) + { + CSector *_S = (CSector*)(*_F); _S->m_sector_num = sector_num; - if (_S->IsDefault()) m_iDefaultSectorNum=sector_num; + if (_S->IsDefault()) + m_iDefaultSectorNum = sector_num; pb->Inc(); - } + } - UI->ProgressEnd(pb); + UI->ProgressEnd(pb); - if (m_iDefaultSectorNum<0) m_iDefaultSectorNum=Scene->ObjCount(OBJCLASS_SECTOR); - return true; + if (m_iDefaultSectorNum<0) + m_iDefaultSectorNum = Scene->ObjCount(OBJCLASS_SECTOR); + return true; } + //------------------------------------------------------------------------------ + diff --git a/src/editors/LevelEditor/Edit/BuilderGame.cpp b/src/editors/LevelEditor/Edit/BuilderGame.cpp index f3cab88ba44..7cd4667cf76 100644 --- a/src/editors/LevelEditor/Edit/BuilderGame.cpp +++ b/src/editors/LevelEditor/Edit/BuilderGame.cpp @@ -7,166 +7,171 @@ #include "Builder.h" #include "Scene.h" -#include "../../xrServerEntities/LevelGameDef.h" +#include "xrServerEntities/LevelGameDef.h" #include "SoundManager_LE.h" #include "CustomObject.h" #include "ESceneFogVolumeTools.h" #include "SpawnPoint.h" -bool sort_fog_vol(EFogVolume* fv1, EFogVolume* fv2) +bool sort_fog_vol(EFogVolume *fv1, EFogVolume *fv2) { - return (fv1->m_volumeType < fv2->m_volumeType); + return (fv1->m_volumeTypem_volumeType); } BOOL SceneBuilder::BuildGame() { - SExportStreams F; - F.envmodif.stream.open_chunk (F.envmodif.chunk++); - F.envmodif.stream.w_u32 (u32(SPAWNPOINT_VERSION)); - F.envmodif.stream.close_chunk (); - - if (!Scene->ExportGame(&F)) return FALSE; - - BOOL bRes = TRUE; + SExportStreams F; + F.envmodif.stream.open_chunk(F.envmodif.chunk++); + F.envmodif.stream.w_u32(u32(SPAWNPOINT_VERSION)); + F.envmodif.stream.close_chunk(); + + if (!Scene->ExportGame(&F)) + return FALSE; + + BOOL bRes = TRUE; // save spawn { - xr_string lev_spawn = MakeLevelPath("level.spawn"); - EFS.MarkFile (lev_spawn.c_str(),true); + xr_string lev_spawn = MakeLevelPath("level.spawn"); + EFS.MarkFile(lev_spawn.c_str(), true); if (F.spawn.chunk) - if (!F.spawn.stream.save_to (lev_spawn.c_str())) bRes = FALSE; + if (!F.spawn.stream.save_to(lev_spawn.c_str())) + bRes = FALSE; - lev_spawn = MakeLevelPath("level_rs.spawn"); - EFS.MarkFile (lev_spawn.c_str(),true); + lev_spawn = MakeLevelPath("level_rs.spawn"); + EFS.MarkFile(lev_spawn.c_str(), true); if (F.spawn_rs.chunk) - if (!F.spawn_rs.stream.save_to (lev_spawn.c_str())) bRes = FALSE; + if (!F.spawn_rs.stream.save_to(lev_spawn.c_str())) + bRes = FALSE; } // save game { - CMemoryWriter GAME; - GAME.w_chunk(WAY_PATROLPATH_CHUNK, F.patrolpath.stream.pointer(), F.patrolpath.stream.size()); - GAME.w_chunk(RPOINT_CHUNK, F.rpoint.stream.pointer(), F.rpoint.stream.size()); - xr_string lev_game = MakeLevelPath("level.game"); - EFS.MarkFile (lev_game.c_str(),true); + CMemoryWriter GAME; + GAME.w_chunk(WAY_PATROLPATH_CHUNK, F.patrolpath.stream.pointer(), F.patrolpath.stream.size()); + GAME.w_chunk(RPOINT_CHUNK, F.rpoint.stream.pointer(), F.rpoint.stream.size()); + xr_string lev_game = MakeLevelPath("level.game"); + EFS.MarkFile(lev_game.c_str(), true); if (GAME.size()) - if (!GAME.save_to (lev_game.c_str())) bRes = FALSE; + if (!GAME.save_to(lev_game.c_str())) + bRes = FALSE; } // save weather env modificator { - xr_string lev_env_mod = MakeLevelPath("level.env_mod"); - EFS.MarkFile (lev_env_mod.c_str(),true); + xr_string lev_env_mod = MakeLevelPath("level.env_mod"); + EFS.MarkFile(lev_env_mod.c_str(), true); if (F.envmodif.chunk) - if (!F.envmodif.stream.save_to (lev_env_mod.c_str())) bRes = FALSE; + if (!F.envmodif.stream.save_to(lev_env_mod.c_str())) + bRes = FALSE; } // save static sounds { - xr_string lev_sound_static = MakeLevelPath("level.snd_static"); - EFS.MarkFile (lev_sound_static.c_str(),true); - if (F.sound_static.chunk) - if (!F.sound_static.stream.save_to (lev_sound_static.c_str())) bRes = FALSE; - } -/* - // save sound envs - { - xr_string lev_sound_env = MakeLevelPath("level.snd_env"); - EFS.MarkFile (lev_sound_env.c_str(),true); - if (LSndLib->MakeEnvGeometry (F.sound_env_geom.stream,false)) - if (!F.sound_env_geom.stream.save_to(lev_sound_env.c_str())) bRes = FALSE; + xr_string lev_sound_static = MakeLevelPath("level.snd_static"); + EFS.MarkFile(lev_sound_static.c_str(), true); + if (F.sound_static.chunk) + if (!F.sound_static.stream.save_to(lev_sound_static.c_str())) + bRes = FALSE; } -*/ + /* + // save sound envs + { + xr_string lev_sound_env = MakeLevelPath("level.snd_env"); + EFS.MarkFile (lev_sound_env.c_str(),true); + if (LSndLib->MakeEnvGeometry (F.sound_env_geom.stream,false)) + if (!F.sound_env_geom.stream.save_to(lev_sound_env.c_str())) bRes = FALSE; + } + */ // save static PG { - xr_string lev_pe_static = MakeLevelPath("level.ps_static"); - EFS.MarkFile (lev_pe_static.c_str(),true); - if (F.pe_static.chunk) - if (!F.pe_static.stream.save_to (lev_pe_static.c_str())) bRes = FALSE; + xr_string lev_pe_static = MakeLevelPath("level.ps_static"); + EFS.MarkFile(lev_pe_static.c_str(), true); + if (F.pe_static.chunk) + if (!F.pe_static.stream.save_to(lev_pe_static.c_str())) + bRes = FALSE; } // save fog volumes - if(1) + if (1) { - xr_string lev_fog_vol = MakeLevelPath("level.fog_vol"); - EFS.MarkFile (lev_fog_vol.c_str(),true); + xr_string lev_fog_vol = MakeLevelPath("level.fog_vol"); + EFS.MarkFile(lev_fog_vol.c_str(), true); - F.fog_vol.stream.w_u16 (3); //version + F.fog_vol.stream.w_u16(3); //version - ObjectList& fogs = Scene->ListObj(OBJCLASS_FOG_VOL); + ObjectList &fogs = Scene->ListObj(OBJCLASS_FOG_VOL); - typedef xr_vector tfog_group; - typedef xr_map tfog_groups; + typedef xr_vector tfog_group; + typedef xr_map tfog_groups; - tfog_groups fog_groups; + tfog_groups fog_groups; - for (ObjectIt oit=fogs.begin(); oit!=fogs.end(); ++oit) + for (ObjectIt oit = fogs.begin(); oit!=fogs.end(); ++oit) { - EFogVolume* E = dynamic_cast(*oit); - R_ASSERT (E); - u32 grp_id = E->m_group_id; + EFogVolume *E = dynamic_cast(*oit); + R_ASSERT(E); + u32 grp_id = E->m_group_id; fog_groups[grp_id].push_back(E); } - F.fog_vol.stream.w_u32 (fog_groups.size()); + F.fog_vol.stream.w_u32(fog_groups.size()); - tfog_groups::iterator git = fog_groups.begin(); - tfog_groups::iterator git_e = fog_groups.end(); - for(; git!=git_e; ++git) + tfog_groups::iterator git = fog_groups.begin(); + tfog_groups::iterator git_e = fog_groups.end(); + for (; git!=git_e; ++git) { - tfog_group& one_group = git->second; + tfog_group &one_group = git->second; std::sort(one_group.begin(), one_group.end(), sort_fog_vol); tfog_group::iterator fgit = one_group.begin(); tfog_group::iterator fgit_e = one_group.end(); - for(; fgit!=fgit_e; ++fgit) + for (; fgit!=fgit_e; ++fgit) { - EFogVolume* E = *fgit; - if(fgit==one_group.begin()) + EFogVolume *E = *fgit; + if (fgit==one_group.begin()) { - if(E->m_volumeType!=fvEmitter) + if (E->m_volumeType!=fvEmitter) { - bRes = FALSE; + bRes = FALSE; Msg("! incorrect fog volumes grouping"); - break; + break; } - - F.fog_vol.stream.w_string (E->m_volume_profile.c_str()); - } - Fmatrix M = E->_Transform(); - F.fog_vol.stream.w (&M, sizeof(M)); - if(fgit==one_group.begin()) + F.fog_vol.stream.w_string(E->m_volume_profile.c_str()); + } + Fmatrix M = E->_Transform(); + F.fog_vol.stream.w(&M, sizeof(M)); + + if (fgit==one_group.begin()) { - if(E->m_volumeType!=fvEmitter) + if (E->m_volumeType!=fvEmitter) { - - bRes = FALSE; + bRes = FALSE; Msg("! incorrect fog volumes grouping"); - break; + break; } - - F.fog_vol.stream.w_u32 (one_group.size()-1); - }else + + F.fog_vol.stream.w_u32(one_group.size()-1); + } + else { - - if(E->m_volumeType!=fvOcclusion) + if (E->m_volumeType!=fvOcclusion) { - bRes = FALSE; + bRes = FALSE; Msg("! incorrect fog volumes grouping"); - break; + break; } - - } - if(!bRes) - break; + } + if (!bRes) + break; } - if(!bRes) + if (!bRes) break; } if (!F.fog_vol.stream.save_to(lev_fog_vol.c_str())) - bRes = FALSE; + bRes = FALSE; } return bRes; diff --git a/src/editors/LevelEditor/Edit/BuilderLODs.cpp b/src/editors/LevelEditor/Edit/BuilderLODs.cpp index 9da3cbdf728..b01aafe5646 100644 --- a/src/editors/LevelEditor/Edit/BuilderLODs.cpp +++ b/src/editors/LevelEditor/Edit/BuilderLODs.cpp @@ -1,11 +1,11 @@ -#include "stdafx.h" -#pragma hdrstop - +#include "stdafx.h" +#pragma hdrstop + #include "Builder.h" -#include "../ECore/Editor/ImageManager.h" +#include "editors/ECore/Editor/ImageManager.h" #include "SceneObject.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/ui_main.h" #include "scene.h" //------------------------------------------------------------------------------ @@ -16,246 +16,262 @@ //------------------------------------------------------------------------------ // lod build functions //------------------------------------------------------------------------------ -DEFINE_VECTOR(Fvector4,Fvector4Vec,Fvector4It); -BOOL GetPointColor(SPickQuery::SResult* R, u32& alpha) +DEFINE_VECTOR(Fvector4, Fvector4Vec, Fvector4It); + +BOOL GetPointColor(SPickQuery::SResult *R, u32 &alpha) { - CSurface* surf = R->e_mesh->GetSurfaceByFaceID(R->tag); VERIFY(surf); - Shader_xrLC* c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); - if (!c_sh->flags.bRendering) return FALSE; - const Fvector2* cuv[3]; - R->e_mesh->GetFaceTC (R->tag,cuv); + CSurface *surf = R->e_mesh->GetSurfaceByFaceID(R->tag); + VERIFY(surf); + Shader_xrLC *c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); + if (!c_sh->flags.bRendering) + return FALSE; + const Fvector2 *cuv[3]; + R->e_mesh->GetFaceTC(R->tag, cuv); // barycentric coords // note: W,U,V order Fvector B; - B.set (1.0f - R->u - R->v,R->u,R->v); + B.set(1.0f-R->u-R->v, R->u, R->v); // calc UV - Fvector2 uv; - uv.x = cuv[0]->x*B.x + cuv[1]->x*B.y + cuv[2]->x*B.z; - uv.y = cuv[0]->y*B.x + cuv[1]->y*B.y + cuv[2]->y*B.z; + Fvector2 uv; + uv.x = cuv[0]->x*B.x+cuv[1]->x*B.y+cuv[2]->x*B.z; + uv.y = cuv[0]->y*B.x+cuv[1]->y*B.y+cuv[2]->y*B.z; - int U = iFloor(uv.x*float(surf->m_ImageData->w) + .5f); - int V = iFloor(uv.y*float(surf->m_ImageData->h)+ .5f); - U %= surf->m_ImageData->w; if (U<0) U+=surf->m_ImageData->w; - V %= surf->m_ImageData->h; if (V<0) V+=surf->m_ImageData->h; + int U = iFloor(uv.x*float(surf->m_ImageData->w)+.5f); + int V = iFloor(uv.y*float(surf->m_ImageData->h)+.5f); + U %= surf->m_ImageData->w; + if (U<0) + U += surf->m_ImageData->w; + V %= surf->m_ImageData->h; + if (V<0) + V += surf->m_ImageData->h; alpha = color_get_A(surf->m_ImageData->layers.back()[V*surf->m_ImageData->w+U]); return TRUE; } -int SceneBuilder::BuildObjectLOD(const Fmatrix& parent, CEditableObject* E, int sector_num) +int SceneBuilder::BuildObjectLOD(const Fmatrix &parent, CEditableObject *E, int sector_num) { - if (!E->m_objectFlags.is(CEditableObject::eoUsingLOD)) return -1; + if (!E->m_objectFlags.is(CEditableObject::eoUsingLOD)) + return -1; xr_string lod_name = E->GetLODTextureName(); - b_material mtl; - mtl.surfidx = (u16)BuildTexture (LEVEL_LODS_TEX_NAME); - mtl.shader = (u16)BuildShader (E->GetLODShaderName()); - mtl.sector = (u16)sector_num; - mtl.shader_xrlc = -1; - if ((u16(-1)==mtl.surfidx)||(u16(-1)==mtl.shader)) return -2; + b_material mtl; + mtl.surfidx = (u16)BuildTexture(LEVEL_LODS_TEX_NAME); + mtl.shader = (u16)BuildShader(E->GetLODShaderName()); + mtl.sector = (u16)sector_num; + mtl.shader_xrlc = -1; + if ((u16(-1)==mtl.surfidx)||(u16(-1)==mtl.shader)) + return -2; - int mtl_idx = FindInMaterials(&mtl); - if (mtl_idx<0){ + int mtl_idx = FindInMaterials(&mtl); + if (mtl_idx<0) + { l_materials.push_back(mtl); - mtl_idx = l_materials.size()-1; + mtl_idx = l_materials.size()-1; } l_lods.push_back(e_b_lod()); - e_b_lod& b = l_lods.back(); - Fvector p[4]; - Fvector2 t[4]; - for (int frame=0; frameGetLODFrame(frame,p,t,&parent); - for (int k=0; k<4; k++){ + e_b_lod &b = l_lods.back(); + Fvector p[4]; + Fvector2 t[4]; + for (int frame = 0; frameGetLODFrame(frame, p, t, &parent); + for (int k = 0; k<4; k++) + { b.lod.faces[frame].v[k].set(p[k]); b.lod.faces[frame].t[k].set(t[k]); } } - b.lod.dwMaterial= mtl_idx; - b.lod_name = lod_name.c_str(); - xr_string l_name= lod_name.c_str(); - u32 w,h; + b.lod.dwMaterial = mtl_idx; + b.lod_name = lod_name.c_str(); + xr_string l_name = lod_name.c_str(); + u32 w, h; int age; - if (!ImageLib.LoadTextureData(l_name.c_str(),b.data,w,h,&age)){ - Msg("!Can't find LOD texture: '%s'",l_name.c_str()); - return -2; + if (!ImageLib.LoadTextureData(l_name.c_str(), b.data, w, h, &age)) + { + Msg("!Can't find LOD texture: '%s'", l_name.c_str()); + return -2; } -/* if (age!=E->Version()){ - Msg("!Invalid LOD texture version: '%s'",l_name.c_str()); - return -2; - }*/ - l_name += "_nm"; - if (!ImageLib.LoadTextureData(l_name.c_str(),b.ndata,w,h,&age)){ - Msg("!Can't find LOD texture: '%s'",l_name.c_str()); - return -2; + /* if (age!=E->Version()){ + Msg("!Invalid LOD texture version: '%s'",l_name.c_str()); + return -2; + }*/ + l_name += "_nm"; + if (!ImageLib.LoadTextureData(l_name.c_str(), b.ndata, w, h, &age)) + { + Msg("!Can't find LOD texture: '%s'", l_name.c_str()); + return -2; } -/* if (age!=E->Version()){ - Msg("!Invalid LOD texture version: '%s'",l_name.c_str()); - return -2; - }*/ -// b.data -/* - // make lod - Fbox bb = E->GetBox(); - E->m_Flags.set (CEditableObject::eoUsingLOD,FALSE); - object_for_render = E; - ImageLib.CreateLODTexture (bb, b.data, LOD_IMAGE_SIZE,LOD_IMAGE_SIZE,LOD_SAMPLE_COUNT); - E->m_Flags.set (CEditableObject::eoUsingLOD,TRUE); - - // build lod normals - b.ndata.resize (LOD_IMAGE_SIZE*LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT); - U8Vec hemi_temp (LOD_IMAGE_SIZE*LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,0); - Fvector o_center,o_size; - Fmatrix M,Mi; - bb.getradius (o_size); - bb.getcenter (o_center); - SPBItem* PB = UI->ProgressStart(LOD_SAMPLE_COUNT*LOD_IMAGE_SIZE,lod_name.c_str()); - float dW = _max(o_size.x,o_size.z)/(LOD_IMAGE_SIZE/2); - float dH = o_size.y/(LOD_IMAGE_SIZE/2); - float dR = bb.getradius(); - float d2R = dR*2.f; - XRC.ray_options (CDB::OPT_CULL); - ETOOLS::ray_options (CDB::OPT_CULL); - - float tN=0.f,tH=0.f,tT=0.f,tR=0.f; + /* if (age!=E->Version()){ + Msg("!Invalid LOD texture version: '%s'",l_name.c_str()); + return -2; + }*/ + // b.data + /* + // make lod + Fbox bb = E->GetBox(); + E->m_Flags.set (CEditableObject::eoUsingLOD,FALSE); + object_for_render = E; + ImageLib.CreateLODTexture(bb, b.data, LOD_IMAGE_SIZE,LOD_IMAGE_SIZE,LOD_SAMPLE_COUNT); + E->m_Flags.set (CEditableObject::eoUsingLOD,TRUE); - float LOD_CALC_SAMPLES = Scene->m_LevelOp.m_LOD_Quality; - s32 LOD_CALC_SAMPLES_LIM= LOD_CALC_SAMPLES/2; - - // preload textures - for (SurfaceIt surf_it=E->Surfaces().begin(); surf_it!=E->Surfaces().end(); surf_it++){ - CSurface* surf = *surf_it; - Shader_xrLC* c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); - if (!c_sh->flags.bRendering) continue; - if (0==surf->m_ImageData)surf->CreateImageData(); - } - - // preload CF Model - for (EditMeshIt mesh_it=E->Meshes().begin(); mesh_it!=E->Meshes().end(); mesh_it++) - (*mesh_it)->GenerateCFModel(); + // build lod normals + b.ndata.resize (LOD_IMAGE_SIZE*LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT); + U8Vec hemi_temp (LOD_IMAGE_SIZE*LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,0); + Fvector o_center,o_size; + Fmatrix M,Mi; + bb.getradius (o_size); + bb.getcenter (o_center); + SPBItem* PB = UI->ProgressStart(LOD_SAMPLE_COUNT*LOD_IMAGE_SIZE,lod_name.c_str()); + float dW = _max(o_size.x,o_size.z)/(LOD_IMAGE_SIZE/2); + float dH = o_size.y/(LOD_IMAGE_SIZE/2); + float dR = bb.getradius(); + float d2R = dR*2.f; + XRC.ray_options (CDB::OPT_CULL); + ETOOLS::ray_options (CDB::OPT_CULL); - // calculate - for (u32 sample_idx=0; sample_idxInc (); - float Y = (iH-(LOD_IMAGE_SIZE-1)/2)*dH; - for (s32 iW=0; iWRayQuery (PQ); - if (PQ.r_count()){ - PQ.r_sort(); - Fvector N = {0,0,0}; - for (s32 k=PQ.r_count()-1; k>=0; k--){ - SPickQuery::SResult* R = PQ.r_begin()+k; - u32 uA; - if (!GetPointColor(R,uA)) continue; - float fA = float(uA)/255.f; - if (uA){ - Fvector pt; pt.mad(PQ.m_Start,PQ.m_Direction,R->range-EPS_L); - Fvector4 ptt; ptt.set(pt.x,pt.y,pt.z,fA); - sample_pt_vec.push_back(ptt); + float tN=0.f,tH=0.f,tT=0.f,tR=0.f; + + float LOD_CALC_SAMPLES = Scene->m_LevelOp.m_LOD_Quality; + s32 LOD_CALC_SAMPLES_LIM= LOD_CALC_SAMPLES/2; + + // preload textures + for (SurfaceIt surf_it=E->Surfaces().begin(); surf_it!=E->Surfaces().end(); surf_it++){ + CSurface* surf = *surf_it; + Shader_xrLC* c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); + if (!c_sh->flags.bRendering) continue; + if (0==surf->m_ImageData)surf->CreateImageData(); + } + + // preload CF Model + for (EditMeshIt mesh_it=E->Meshes().begin(); mesh_it!=E->Meshes().end(); mesh_it++) + (*mesh_it)->GenerateCFModel(); + + // calculate + for (u32 sample_idx=0; sample_idxInc (); + float Y = (iH-(LOD_IMAGE_SIZE-1)/2)*dH; + for (s32 iW=0; iWRayQuery (PQ); + if (PQ.r_count()){ + PQ.r_sort(); + Fvector N = {0,0,0}; + for (s32 k=PQ.r_count()-1; k>=0; k--){ + SPickQuery::SResult* R = PQ.r_begin()+k; + u32 uA; + if (!GetPointColor(R,uA)) continue; + float fA = float(uA)/255.f; + if (uA){ + Fvector pt; pt.mad(PQ.m_Start,PQ.m_Direction,R->range-EPS_L); + Fvector4 ptt; ptt.set(pt.x,pt.y,pt.z,fA); + sample_pt_vec.push_back(ptt); + } + // normal + Fvector Nn; + Nn.mknormal (R->verts[0],R->verts[1],R->verts[2]); + Nn.mul (fA); + + N.mul (1.f-fA); + N.add (Nn); } - // normal - Fvector Nn; - Nn.mknormal (R->verts[0],R->verts[1],R->verts[2]); - Nn.mul (fA); - - N.mul (1.f-fA); - N.add (Nn); + float n_mag = N.magnitude(); + if (!fis_zero(n_mag,EPS)) + n_vec.push_back(N.div(n_mag)); } - float n_mag = N.magnitude(); - if (!fis_zero(n_mag,EPS)) - n_vec.push_back (N.div(n_mag)); } } - } -tN+=TT.Stop(); - -TT.Start(); - // light points - float res_transp = 0.f; - for (Fvector4It pt_it=sample_pt_vec.begin(); pt_it!=sample_pt_vec.end(); pt_it++){ - float avg_transp = 0.f; - for (BLIt it=simple_hemi.begin(); it!=simple_hemi.end(); it++){ -TT1.Start(); - Fvector start; - start.mad (Fvector().set(pt_it->x,pt_it->y,pt_it->z),it->light.direction,-dR); - PQ.prepare_rq (start,it->light.direction,dR,CDB::OPT_CULL); - E->RayQuery (PQ); -tR+=TT1.Stop(); - float ray_transp= 1.f; - if (PQ.r_count()){ - for (s32 k=0; kx,pt_it->y,pt_it->z),it->light.direction,-dR); + PQ.prepare_rq(start,it->light.direction,dR,CDB::OPT_CULL); + E->RayQuery (PQ); + tR+=TT1.Stop(); + float ray_transp= 1.f; + if (PQ.r_count()){ + for (s32 k=0; kw)+avg_transp*pt_it->w; } - avg_transp /= simple_hemi.size(); - res_transp = res_transp*(1.f-pt_it->w)+avg_transp*pt_it->w; - } -tH+=TT.Stop(); - - tgt_h = iFloor (res_transp*255.f); - - Fvector N={0,0,0}; - if (!n_vec.empty()){ - for (FvectorIt it=n_vec.begin(); it!=n_vec.end(); it++) N.add(*it); - N.div (n_vec.size()); - N.normalize_safe(); - Mi.transform_dir(N); + tH+=TT.Stop(); + + tgt_h = iFloor(res_transp*255.f); + + Fvector N={0,0,0}; + if (!n_vec.empty()){ + for (FvectorIt it=n_vec.begin(); it!=n_vec.end(); it++) N.add(*it); + N.div (n_vec.size()); + N.normalize_safe(); + Mi.transform_dir(N); + } + N.mul (0.5f); + N.add (0.5f); + N.mul (255.f); + tgt_n = color_rgba(iFloor(N.x),iFloor(N.y),iFloor(N.z),src_a); } - N.mul (0.5f); - N.add (0.5f); - N.mul (255.f); - tgt_n = color_rgba(iFloor(N.x),iFloor(N.y),iFloor(N.z),src_a); } } - } - - Msg("Normal: %3.2fsec, Hemi: %3.2f, PC: %3.2f, RP: %3.2f",tN,tH,tT,tR); - ImageLib.ApplyBorders (b.ndata, LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,LOD_IMAGE_SIZE); - // fill alpha to N-channel - for (int px_idx=0; px_idxProgressEnd(PB); -*/ + Msg("Normal: %3.2fsec, Hemi: %3.2f, PC: %3.2f, RP: %3.2f",tN,tH,tT,tR); + ImageLib.ApplyBorders (b.ndata, LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT,LOD_IMAGE_SIZE); + // fill alpha to N-channel + for (int px_idx=0; px_idxProgressEnd(PB); + */ + return l_lods.size()-1; } + //------------------------------------------------------------------------------ + diff --git a/src/editors/LevelEditor/Edit/BuilderLTX.cpp b/src/editors/LevelEditor/Edit/BuilderLTX.cpp index a0141db655c..6c6e813caec 100644 --- a/src/editors/LevelEditor/Edit/BuilderLTX.cpp +++ b/src/editors/LevelEditor/Edit/BuilderLTX.cpp @@ -7,7 +7,7 @@ #include "Builder.h" #include "Scene.h" -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditObject.h" #include "SceneObject.h" #include "ELight.h" #include "SpawnPoint.h" @@ -19,95 +19,100 @@ #include "sector.h" //---------------------------------------------------- -BOOL SceneBuilder::ParseLTX(CInifile* pIni, ObjectList& lst, LPCSTR prefix) +BOOL SceneBuilder::ParseLTX(CInifile *pIni, ObjectList &lst, LPCSTR prefix) { return TRUE; } + //---------------------------------------------------- BOOL SceneBuilder::BuildLTX() { - bool bResult = true; - int objcount = Scene->ObjCount(); - if( objcount <= 0 ) return true; + bool bResult = true; + int objcount = Scene->ObjCount(); + if (objcount<=0) + return true; - xr_string ltx_filename = MakeLevelPath("level.ltx"); + xr_string ltx_filename = MakeLevelPath("level.ltx"); if (FS.exist(ltx_filename.c_str())) - EFS.MarkFile(ltx_filename.c_str(),true); + EFS.MarkFile(ltx_filename.c_str(), true); - // -- defaults -- - IWriter* F = FS.w_open(ltx_filename.c_str()); + // -- defaults -- + IWriter *F = FS.w_open(ltx_filename.c_str()); if (F) { - string256 buff; - F->w_string("[map_usage]"); - sprintf(buff,"ver=%s",Scene->m_LevelOp.m_map_version.c_str()); - F->w_string(buff); - if(Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDDeathmatch)) - F->w_string("deathmatch"); - if(Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDTeamDeathmatch)) - F->w_string("teamdeathmatch"); - if(Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDArtefactHunt)) - F->w_string("artefacthunt"); - if(Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDCaptureTheArtefact)) - F->w_string("capturetheartefact"); - if(Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDDominationZone)) - F->w_string("dominationzone"); - if(Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDTeamDominationZone)) - F->w_string("teamdominationzone"); - -//---- - F->w_string( ";"); - - Fbox bb; - Fbox bg; - Scene->GetBox(bb,OBJCLASS_SCENEOBJECT); - bool r1 = Scene->GetBox(bg,OBJCLASS_GROUP); - if (r1) bb.merge(bg); - - ObjectList& shapes = Scene->ListObj(OBJCLASS_SHAPE); - for (ObjectIt sit=shapes.begin(); sit!=shapes.end(); ++sit) + string256 buff; + F->w_string("[map_usage]"); + sprintf(buff, "ver=%s", Scene->m_LevelOp.m_map_version.c_str()); + F->w_string(buff); + if (Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDDeathmatch)) + F->w_string("deathmatch"); + if (Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDTeamDeathmatch)) + F->w_string("teamdeathmatch"); + if (Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDArtefactHunt)) + F->w_string("artefacthunt"); + if (Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDCaptureTheArtefact)) + F->w_string("capturetheartefact"); + if (Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDDominationZone)) + F->w_string("dominationzone"); + if (Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDTeamDominationZone)) + F->w_string("teamdominationzone"); + + //---- + F->w_string(";"); + + Fbox bb; + Fbox bg; + Scene->GetBox(bb, OBJCLASS_SCENEOBJECT); + bool r1 = Scene->GetBox(bg, OBJCLASS_GROUP); + if (r1) + bb.merge(bg); + + ObjectList &shapes = Scene->ListObj(OBJCLASS_SHAPE); + for (ObjectIt sit = shapes.begin(); sit!=shapes.end(); ++sit) { - CEditShape* E = dynamic_cast(*sit); - R_ASSERT (E); - if(E->m_shape_type==eShapeLevelBound) + CEditShape *E = dynamic_cast(*sit); + R_ASSERT(E); + if (E->m_shape_type==eShapeLevelBound) { - E->GetBox (bb); + E->GetBox(bb); break; } } - F->w_string ("[level_map]"); - sprintf (buff,"bound_rect = %f,%f,%f,%f", bb.min.x, bb.min.z,bb.max.x, bb.max.z); - F->w_string (buff); - sprintf (buff,"texture = map\\map_%s", Scene->m_LevelOp.m_FNLevelPath.c_str()); - F->w_string (buff); + F->w_string("[level_map]"); + sprintf(buff, "bound_rect = %f,%f,%f,%f", bb.min.x, bb.min.z, bb.max.x, bb.max.z); + F->w_string(buff); + sprintf(buff, "texture = map\\map_%s", Scene->m_LevelOp.m_FNLevelPath.c_str()); + F->w_string(buff); + - - F->w_string( ";"); - if(Scene->m_LevelOp.m_BOPText.size()) - F->w_stringZ( Scene->m_LevelOp.m_BOPText ); + F->w_string(";"); + if (Scene->m_LevelOp.m_BOPText.size()) + F->w_stringZ(Scene->m_LevelOp.m_BOPText); -//---- + //---- ObjectIt _F = Scene->FirstObj(OBJCLASS_SECTOR); ObjectIt _E = Scene->LastObj(OBJCLASS_SECTOR); - F->w_string (";"); - F->w_string ("[sub_level_map]"); - for(;_F!=_E;++_F) + F->w_string(";"); + F->w_string("[sub_level_map]"); + for (; _F!=_E; ++_F) { - CSector* _S = (CSector*)(*_F); - sprintf (buff,"%d = %d", _S->m_sector_num, _S->m_map_idx); - F->w_string (buff); + CSector *_S = (CSector*)(*_F); + sprintf(buff, "%d = %d", _S->m_sector_num, _S->m_map_idx); + F->w_string(buff); } - FS.w_close (F); - }else{ - bResult = false; + FS.w_close(F); + } + else + { + bResult = false; } - return bResult; + return bResult; } diff --git a/src/editors/LevelEditor/Edit/BuilderOGF.cpp b/src/editors/LevelEditor/Edit/BuilderOGF.cpp index 5c69d7178ce..af6a44515ca 100644 --- a/src/editors/LevelEditor/Edit/BuilderOGF.cpp +++ b/src/editors/LevelEditor/Edit/BuilderOGF.cpp @@ -7,128 +7,141 @@ #include "Builder.h" #include "Scene.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditMesh.h" #include "SceneObject.h" #include "ESceneAIMapTools.h" + //---------------------------------------------------- // some types bool SceneBuilder::BuildHOMModel() { - CMemoryWriter F; + CMemoryWriter F; F.open_chunk(0); F.w_u32(0); F.close_chunk(); F.open_chunk(1); - ObjectList& lst = Scene->ListObj(OBJCLASS_SCENEOBJECT); - for (ObjectIt it=lst.begin(); it!=lst.end(); it++) + ObjectList &lst = Scene->ListObj(OBJCLASS_SCENEOBJECT); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) { - CSceneObject* S = (CSceneObject*)(*it); - CEditableObject* E = S->GetReference(); R_ASSERT(E); - if (E->m_objectFlags.is(CEditableObject::eoHOM)) + CSceneObject *S = (CSceneObject*)(*it); + CEditableObject *E = S->GetReference(); + R_ASSERT(E); + if (E->m_objectFlags.is(CEditableObject::eoHOM)) { - Fvector v; - const Fmatrix& parent = S->_Transform(); - for (EditMeshIt m_it=E->FirstMesh(); m_it!=E->LastMesh(); ++m_it) + Fvector v; + const Fmatrix &parent = S->_Transform(); + for (EditMeshIt m_it = E->FirstMesh(); m_it!=E->LastMesh(); ++m_it) { - for (SurfFacesPairIt sf_it=(*m_it)->m_SurfFaces.begin(); sf_it!=(*m_it)->m_SurfFaces.end(); ++sf_it) + for (SurfFacesPairIt sf_it = (*m_it)->m_SurfFaces.begin(); sf_it!=(*m_it)->m_SurfFaces.end(); ++sf_it) { BOOL b2Sided = sf_it->first->m_Flags.is(CSurface::sf2Sided); - IntVec& i_lst= sf_it->second; - for (IntIt i_it=i_lst.begin(); i_it!=i_lst.end(); ++i_it) + IntVec &i_lst = sf_it->second; + for (IntIt i_it = i_lst.begin(); i_it!=i_lst.end(); ++i_it) { - st_Face& face = (*m_it)->m_Faces[*i_it]; - for (int k=0; k<3; ++k) + st_Face &face = (*m_it)->m_Faces[*i_it]; + for (int k = 0; k<3; ++k) { - parent.transform_tiny (v,(*m_it)->m_Vertices[face.pv[k].pindex]); - F.w_fvector3 (v); + parent.transform_tiny(v, (*m_it)->m_Vertices[face.pv[k].pindex]); + F.w_fvector3(v); } - F.w_u32 (b2Sided); + F.w_u32(b2Sided); } } } - }else + } + else { - Fvector v; - const Fmatrix& parent = S->_Transform(); - for (EditMeshIt m_it=E->FirstMesh(); m_it!=E->LastMesh(); ++m_it) + Fvector v; + const Fmatrix &parent = S->_Transform(); + for (EditMeshIt m_it = E->FirstMesh(); m_it!=E->LastMesh(); ++m_it) { - for (SurfFacesPairIt sf_it=(*m_it)->m_SurfFaces.begin(); sf_it!=(*m_it)->m_SurfFaces.end(); ++sf_it) + for (SurfFacesPairIt sf_it = (*m_it)->m_SurfFaces.begin(); sf_it!=(*m_it)->m_SurfFaces.end(); ++sf_it) { - CSurface* S = sf_it->first; - if(S->m_GameMtlName=="materials\\occ") + CSurface *S = sf_it->first; + if (S->m_GameMtlName=="materials\\occ") { - BOOL b2Sided = S->m_Flags.is(CSurface::sf2Sided); - IntVec& i_lst = sf_it->second; - for (IntIt i_it=i_lst.begin(); i_it!=i_lst.end(); ++i_it) + BOOL b2Sided = S->m_Flags.is(CSurface::sf2Sided); + IntVec &i_lst = sf_it->second; + for (IntIt i_it = i_lst.begin(); i_it!=i_lst.end(); ++i_it) { - st_Face& face = (*m_it)->m_Faces[*i_it]; - for (int k=0; k<3; ++k) + st_Face &face = (*m_it)->m_Faces[*i_it]; + for (int k = 0; k<3; ++k) { - parent.transform_tiny (v,(*m_it)->m_Vertices[face.pv[k].pindex]); - F.w_fvector3 (v); + parent.transform_tiny(v, (*m_it)->m_Vertices[face.pv[k].pindex]); + F.w_fvector3(v); } - F.w_u32 (b2Sided); + F.w_u32(b2Sided); } } } } } } - + BOOL bValid = !!F.chunk_size(); F.close_chunk(); - if (bValid){ - xr_string hom_name = MakeLevelPath("level.hom"); - bValid = F.save_to(hom_name.c_str()); + if (bValid) + { + xr_string hom_name = MakeLevelPath("level.hom"); + bValid = F.save_to(hom_name.c_str()); } - return bValid; + return bValid; } bool SceneBuilder::BuildSOMModel() { - BOOL bResult = TRUE; - CMemoryWriter F; + BOOL bResult = TRUE; + CMemoryWriter F; - F.open_chunk (0); - F.w_u32 (0); - F.close_chunk (); + F.open_chunk(0); + F.w_u32(0); + F.close_chunk(); - F.open_chunk (1); - ObjectList& lst = Scene->ListObj(OBJCLASS_SCENEOBJECT); - for (ObjectIt it=lst.begin(); it!=lst.end(); it++){ - CSceneObject* S = (CSceneObject*)(*it); - CEditableObject* E = S->GetReference(); R_ASSERT(E); - if (E->m_objectFlags.is(CEditableObject::eoSoundOccluder)){ - Fvector v; - const Fmatrix& parent = S->_Transform(); - for (EditMeshIt m_it=E->FirstMesh(); m_it!=E->LastMesh(); m_it++){ - for (SurfFacesPairIt sf_it=(*m_it)->m_SurfFaces.begin(); sf_it!=(*m_it)->m_SurfFaces.end(); sf_it++){ - CSurface* surf = sf_it->first; - int gm_id = surf->_GameMtl(); - if (gm_id==GAMEMTL_NONE_ID){ - ELog.DlgMsg (mtError,"Object '%s', surface '%s' contain invalid game material.",(*m_it)->Parent()->m_LibName.c_str(),surf->_Name()); - bResult = FALSE; - break; + F.open_chunk(1); + ObjectList &lst = Scene->ListObj(OBJCLASS_SCENEOBJECT); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + { + CSceneObject *S = (CSceneObject*)(*it); + CEditableObject *E = S->GetReference(); + R_ASSERT(E); + if (E->m_objectFlags.is(CEditableObject::eoSoundOccluder)) + { + Fvector v; + const Fmatrix &parent = S->_Transform(); + for (EditMeshIt m_it = E->FirstMesh(); m_it!=E->LastMesh(); m_it++) + { + for (SurfFacesPairIt sf_it = (*m_it)->m_SurfFaces.begin(); sf_it!=(*m_it)->m_SurfFaces.end(); sf_it++) + { + CSurface *surf = sf_it->first; + int gm_id = surf->_GameMtl(); + if (gm_id==GAMEMTL_NONE_ID) + { + ELog.DlgMsg(mtError, "Object '%s', surface '%s' contain invalid game material.", (*m_it)->Parent()->m_LibName.c_str(), surf->_Name()); + bResult = FALSE; + break; } - SGameMtl* mtl = GMLib.GetMaterialByID(gm_id); - if (0==mtl){ - ELog.DlgMsg (mtError,"Object '%s', surface '%s' contain undefined game material.",(*m_it)->Parent()->m_LibName.c_str(),surf->_Name()); - bResult = FALSE; - break; + SGameMtl *mtl = GMLib.GetMaterialByID(gm_id); + if (0==mtl) + { + ELog.DlgMsg(mtError, "Object '%s', surface '%s' contain undefined game material.", (*m_it)->Parent()->m_LibName.c_str(), surf->_Name()); + bResult = FALSE; + break; } - BOOL b2Sided = surf->m_Flags.is(CSurface::sf2Sided); - IntVec& i_lst = sf_it->second; - for (IntIt i_it=i_lst.begin(); i_it!=i_lst.end(); i_it++){ - st_Face& face = (*m_it)->m_Faces[*i_it]; - for (int k=0; k<3; k++){ - parent.transform_tiny(v,(*m_it)->m_Vertices[face.pv[k].pindex]); + BOOL b2Sided = surf->m_Flags.is(CSurface::sf2Sided); + IntVec &i_lst = sf_it->second; + for (IntIt i_it = i_lst.begin(); i_it!=i_lst.end(); i_it++) + { + st_Face &face = (*m_it)->m_Faces[*i_it]; + for (int k = 0; k<3; k++) + { + parent.transform_tiny(v, (*m_it)->m_Vertices[face.pv[k].pindex]); F.w_fvector3(v); } - F.w_u32 (b2Sided); - F.w_float (mtl->fSndOcclusionFactor); + F.w_u32(b2Sided); + F.w_float(mtl->fSndOcclusionFactor); } } } @@ -136,30 +149,31 @@ bool SceneBuilder::BuildSOMModel() } BOOL bValid = !!F.chunk_size()&&bResult; F.close_chunk(); - if (bValid){ - xr_string som_name = MakeLevelPath("level.som"); - bValid = F.save_to(som_name.c_str()); + if (bValid) + { + xr_string som_name = MakeLevelPath("level.som"); + bValid = F.save_to(som_name.c_str()); } - return bValid; + return bValid; } bool SceneBuilder::BuildAIMap() { - // build sky ogf + // build sky ogf if (Scene->GetTool(OBJCLASS_AIMAP)->Valid()) { return Scene->GetTool(OBJCLASS_AIMAP)->Export(m_LevelPath); } - return false; + return false; } bool SceneBuilder::BuildWallmarks() { - // build sky ogf + // build sky ogf if (Scene->GetTool(OBJCLASS_WM)->Valid()) { return Scene->GetTool(OBJCLASS_WM)->Export(m_LevelPath); } - return false; + return false; } diff --git a/src/editors/LevelEditor/Edit/BuilderRemote.cpp b/src/editors/LevelEditor/Edit/BuilderRemote.cpp index e71bd40c819..e68131de891 100644 --- a/src/editors/LevelEditor/Edit/BuilderRemote.cpp +++ b/src/editors/LevelEditor/Edit/BuilderRemote.cpp @@ -1,25 +1,25 @@ -#include "stdafx.h" -#pragma hdrstop - -#include "Builder.h" +#include "stdafx.h" +#pragma hdrstop + +#include "Builder.h" #include "ELight.h" #include "SceneObject.h" -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditObject.h" #include "Communicate.h" #include "Scene.h" -#include "../ECore/Editor/EditMesh.h" -#include "../ECore/Engine/Texture.h" +#include "editors/ECore/Editor/EditMesh.h" +#include "editors/ECore/Engine/Texture.h" #include "glow.h" #include "sector.h" #include "groupobject.h" #include "portal.h" #include "Common/LevelStructure.hpp" -#include "../ECore/Editor/ui_main.h" -#include "ui_leveltools.h" +#include "editors/ECore/Editor/ui_main.h" +#include "UI_LevelTools.h" #include "xrHemisphere.h" #include "ResourceManager.h" -#include "../ECore/Editor/ImageManager.h" -#include "../ECore/Engine/Image.h" +#include "editors/ECore/Editor/ImageManager.h" +#include "editors/ECore/Engine/Image.h" #include "ESceneLightTools.h" @@ -31,84 +31,106 @@ #define LEVEL_LODS_NRM_NAME "level_lods_nm" #define LEVEL_DI_TEX_NAME "level_stat" -class CSceneStat{ - Fvector bb_min; - u32 bb_sx, bb_sz; +class CSceneStat +{ + Fvector bb_min; + u32 bb_sx, bb_sz; + + u32 max_svert; + U32Vec svertices; + + u32 &svertex(u32 ix, u32 iz) + { + VERIFY((ixmax_svert) max_svert=v; + u32 ix = clampr((u32)iFloor(p.x-bb_min.x), (u32)0, bb_sx-1); + u32 iz = clampr((u32)iFloor(p.z-bb_min.z), (u32)0, bb_sz-1); + u32 &v = svertex(ix, iz); + v++; + if (v>max_svert) + max_svert = v; } - void add_muvert(const Fmatrix& parent, const Fvector& _p) + + void add_muvert(const Fmatrix &parent, const Fvector &_p) { - Fvector p; - parent.transform_tiny(p,_p); - u32 ix = clampr((u32)iFloor(p.x-bb_min.x),(u32)0,bb_sx-1); - u32 iz = clampr((u32)iFloor(p.z-bb_min.z),(u32)0,bb_sz-1); - u32& v = muvertex(ix,iz); v++; - if (v>max_muvert) max_muvert=v; + Fvector p; + parent.transform_tiny(p, _p); + u32 ix = clampr((u32)iFloor(p.x-bb_min.x), (u32)0, bb_sx-1); + u32 iz = clampr((u32)iFloor(p.z-bb_min.z), (u32)0, bb_sz-1); + u32 &v = muvertex(ix, iz); + v++; + if (v>max_muvert) + max_muvert = v; } + bool flush(LPCSTR fn) { - // flush image - u32 sx=bb_sx, sz=bb_sz; - U32Vec data (sx*sz); - // prepare vertex info + // flush image + u32 sx = bb_sx, sz = bb_sz; + U32Vec data(sx*sz); + // prepare vertex info // find max - u32 ix,iz; - u32 total_svert=0; - u32 total_muvert=0; - for (ix=0; ix(); - I->Create (sx,sz,data.begin()); - I->Vflip (); - I->SaveTGA (image_name.c_str()); - xr_delete (I); + CImage *I = xr_new(); + I->Create(sx, sz, data.begin()); + I->Vflip(); + I->SaveTGA(image_name.c_str()); + xr_delete(I); // flush text AnsiString txt_name = AnsiString(fn)+".txt"; - IWriter* F = FS.w_open(txt_name.c_str()); - if (F){ - F->w_string (AnsiString().sprintf("Map size X x Z: [%d x %d]",bb_sx,bb_sz).c_str()); - F->w_string (AnsiString().sprintf("Max static vertex per m^2: %d",max_svert).c_str()); - F->w_string (AnsiString().sprintf("Total static vertices: %d",total_svert).c_str()); - F->w_string (AnsiString().sprintf("Max mu vertex per m^2: %d",max_muvert).c_str()); - F->w_string (AnsiString().sprintf("Total mu vertices: %d",total_muvert).c_str()); - FS.w_close (F); - return true; + IWriter *F = FS.w_open(txt_name.c_str()); + if (F) + { + F->w_string(AnsiString().sprintf("Map size X x Z: [%d x %d]", bb_sx, bb_sz).c_str()); + F->w_string(AnsiString().sprintf("Max static vertex per m^2: %d", max_svert).c_str()); + F->w_string(AnsiString().sprintf("Total static vertices: %d", total_svert).c_str()); + F->w_string(AnsiString().sprintf("Max mu vertex per m^2: %d", max_muvert).c_str()); + F->w_string(AnsiString().sprintf("Total mu vertices: %d", total_muvert).c_str()); + FS.w_close(F); + return true; } return false; } @@ -116,591 +138,589 @@ class CSceneStat{ void SceneBuilder::SaveBuildAsObject() { - string512 tmp, tex_path, tex_name; - xr_string fn, fn_material; + string512 tmp, tex_path, tex_name; + xr_string fn, fn_material; + + if (! EFS.GetSaveName(_import_, fn)) + return; + + fn = EFS.ChangeFileExt(fn, ".obj"); + fn_material = EFS.ChangeFileExt(fn, ".mtl"); + + IWriter *Fm = FS.w_open(fn_material.c_str()); + + for (u32 i = 0; iw_string(tmp); + Fm->w_string("Ka 0 0 0"); + Fm->w_string("Kd 1 1 1"); + Fm->w_string("Ks 0 0 0"); + + sprintf(tmp, "map_Kd %s\\\\%s\\%s%s\n", + "T:", + tex_path, + tex_name, + ".tga"); + Fm->w_string(tmp); + } + FS.w_close(Fm); - if (! EFS.GetSaveName ( _import_, fn )) - return; + IWriter *F = FS.w_open(fn.c_str()); + CMemoryWriter tmpFaces; - fn = EFS.ChangeFileExt(fn,".obj"); - fn_material = EFS.ChangeFileExt(fn,".mtl"); + // writ comment + F->w_string("# This file uses meters as units for non-parametric coordinates."); + _splitpath(fn.c_str(), 0, 0, tex_name, 0); + sprintf(tmp, "mtllib %s.mtl", tex_name); + F->w_string(tmp); - IWriter* Fm = FS.w_open(fn_material.c_str()); + F->w_string("g default"); - for(u32 i=0;iw_string (tmp); - Fm->w_string ("Ka 0 0 0"); - Fm->w_string ("Kd 1 1 1"); - Fm->w_string ("Ks 0 0 0"); - - sprintf (tmp,"map_Kd %s\\\\%s\\%s%s\n", - "T:", - tex_path, - tex_name, - ".tga"); - Fm->w_string (tmp); + const b_vertex &it = l_verts[idx]; + sprintf(tmp, "v %f %f %f", it.x*100.0f, it.y*100.0f, it.z*100.0f); + F->w_string(tmp); } - FS.w_close (Fm); - - IWriter* F = FS.w_open(fn.c_str()); - CMemoryWriter tmpFaces; - - // writ comment - F->w_string ("# This file uses meters as units for non-parametric coordinates."); - _splitpath (fn.c_str(), 0, 0, tex_name, 0 ); - sprintf (tmp,"mtllib %s.mtl", tex_name); - F->w_string (tmp); - - F->w_string ("g default"); - - //vertices - u32 idx; - u32 total_vertices = 0; - u32 total_tcs = 0; - for(idx=0; idxw_string (tmp); - - } - - //TC-s - for(idx=0; idxw_string (tmp); - } + sprintf(tmp, "f %d/%d %d/%d %d/%d", it.v[0]+1, idx*3+1, + it.v[1]+1, idx*3+2, + it.v[2]+1, idx*3+3); + tmpFaces.w_string(tmp); + } + total_vertices += l_vert_it; + + for (idx = 0; idxw_string(tmp); + } //TC-s - for(u32 fi=0; fiw(tmpFaces.pointer(),tmpFaces.size()); - - //uv -// sprintf (tmp,"vt %f %f",v_it->UV.x,_abs(1.f-v_it->UV.y)); F.w_string (tmp); - - //normals -// sprintf (tmp,"vn %f %f %f",mV.x,mV.y,mV.z); F.w_string (tmp); + F->w(tmpFaces.pointer(), tmpFaces.size()); - //g -// sprintf (tmp,"vg %f %f %f",mV.x,mV.y,mV.z); F.w_string (tmp); + //uv + // sprintf (tmp,"vt %f %f",v_it->UV.x,_abs(1.f-v_it->UV.y)); F.w_string(tmp); - //b -// sprintf (tmp,"vb %f %f %f",mV.x,mV.y,mV.z); F.w_string (tmp); + //normals + // sprintf (tmp,"vn %f %f %f",mV.x,mV.y,mV.z); F.w_string(tmp); + //g + // sprintf (tmp,"vg %f %f %f",mV.x,mV.y,mV.z); F.w_string(tmp); + //b + // sprintf (tmp,"vb %f %f %f",mV.x,mV.y,mV.z); F.w_string(tmp); -/* - string512 tmp,tex_path,tex_name; - // write mtl - for (SplitIt split_it=m_Splits.begin(); split_it!=m_Splits.end(); split_it++) - { - _splitpath ((*split_it)->m_Surf->_Texture(), 0, 0, tex_name, 0 ); - sprintf (tmp,"newmtl %s",tex_name); - F.w_string (tmp); - - _splitpath ((*split_it)->m_Surf->_Texture(), 0, tex_path, tex_name, 0 ); - strconcat (sizeof(tex_path),tex_path,tex_path,"\\",tex_name,".tga"); - sprintf (tmp,"map_Kd %s",tex_path); - F.w_string (tmp); - } - sprintf (tmp,"mtllib %s",name); - F.w_string (tmp); - - // write mtl - u32 v_offs = 0; - for (split_it=m_Splits.begin(); split_it!=m_Splits.end(); split_it++){ - _splitpath ((*split_it)->m_Surf->_Texture(), 0, 0, tex_name, 0 ); - sprintf (tmp,"g %d",split_it-m_Splits.begin()); F.w_string (tmp); - sprintf (tmp,"usemtl %s",tex_name); F.w_string (tmp); - Fvector mV; - Fmatrix mZ; - mZ.mirrorZ (); - for (COGFCPIt it=(*split_it)->m_Parts.begin(); it!=(*split_it)->m_Parts.end(); it++){ - CObjectOGFCollectorPacked* part = *it; - // vertices - OGFVertVec& VERTS = part->getV_Verts(); - OGFVertIt v_it; - for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++){ - mZ.transform_tiny(mV,v_it->P); - sprintf (tmp,"v %f %f %f",mV.x,mV.y,mV.z); F.w_string (tmp); - } - for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++){ - sprintf (tmp,"vt %f %f",v_it->UV.x,_abs(1.f-v_it->UV.y)); F.w_string (tmp); - } - for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++){ - mZ.transform_dir(mV,v_it->N); - sprintf (tmp,"vn %f %f %f",mV.x,mV.y,mV.z); F.w_string (tmp); - } - for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++){ - mZ.transform_dir(mV,v_it->T); - sprintf (tmp,"vg %f %f %f",mV.x,mV.y,mV.z); F.w_string (tmp); - } - for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++){ - mZ.transform_dir(mV,v_it->B); - sprintf (tmp,"vb %f %f %f",mV.x,mV.y,mV.z); F.w_string (tmp); - } - // faces - OGFFaceVec& FACES = part->getV_Faces(); - OGFFaceIt f_it; - for (f_it=FACES.begin(); f_it!=FACES.end(); f_it++){ - sprintf (tmp,"f %d/%d/%d %d/%d/%d %d/%d/%d",v_offs+f_it->v[2]+1,v_offs+f_it->v[2]+1,v_offs+f_it->v[2]+1, - v_offs+f_it->v[1]+1,v_offs+f_it->v[1]+1,v_offs+f_it->v[1]+1, - v_offs+f_it->v[0]+1,v_offs+f_it->v[0]+1,v_offs+f_it->v[0]+1); F.w_string (tmp); + /* + string512 tmp,tex_path,tex_name; + // write mtl + for (SplitIt split_it=m_Splits.begin(); split_it!=m_Splits.end(); split_it++) + { + _splitpath ((*split_it)->m_Surf->_Texture(), 0, 0, tex_name, 0 ); + sprintf (tmp,"newmtl %s",tex_name); + F.w_string (tmp); + + _splitpath ((*split_it)->m_Surf->_Texture(), 0, tex_path, tex_name, 0 ); + strconcat (sizeof(tex_path),tex_path,tex_path,"\\",tex_name,".tga"); + sprintf (tmp,"map_Kd %s",tex_path); + F.w_string(tmp); + } + sprintf (tmp,"mtllib %s",name); + F.w_string (tmp); + + // write mtl + u32 v_offs = 0; + for (split_it=m_Splits.begin(); split_it!=m_Splits.end(); split_it++){ + _splitpath ((*split_it)->m_Surf->_Texture(), 0, 0, tex_name, 0 ); + sprintf (tmp,"g %d",split_it-m_Splits.begin()); F.w_string(tmp); + sprintf (tmp,"usemtl %s",tex_name); F.w_string(tmp); + Fvector mV; + Fmatrix mZ; + mZ.mirrorZ (); + for (COGFCPIt it=(*split_it)->m_Parts.begin(); it!=(*split_it)->m_Parts.end(); it++){ + CObjectOGFCollectorPacked* part = *it; + // vertices + OGFVertVec& VERTS = part->getV_Verts(); + OGFVertIt v_it; + for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++){ + mZ.transform_tiny(mV,v_it->P); + sprintf (tmp,"v %f %f %f",mV.x,mV.y,mV.z); F.w_string(tmp); + } + for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++){ + sprintf (tmp,"vt %f %f",v_it->UV.x,_abs(1.f-v_it->UV.y)); F.w_string(tmp); + } + for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++){ + mZ.transform_dir(mV,v_it->N); + sprintf (tmp,"vn %f %f %f",mV.x,mV.y,mV.z); F.w_string(tmp); + } + for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++){ + mZ.transform_dir(mV,v_it->T); + sprintf (tmp,"vg %f %f %f",mV.x,mV.y,mV.z); F.w_string(tmp); + } + for (v_it=VERTS.begin(); v_it!=VERTS.end(); v_it++){ + mZ.transform_dir(mV,v_it->B); + sprintf (tmp,"vb %f %f %f",mV.x,mV.y,mV.z); F.w_string(tmp); + } + // faces + OGFFaceVec& FACES = part->getV_Faces(); + OGFFaceIt f_it; + for (f_it=FACES.begin(); f_it!=FACES.end(); f_it++){ + sprintf (tmp,"f %d/%d/%d %d/%d/%d %d/%d/%d",v_offs+f_it->v[2]+1,v_offs+f_it->v[2]+1,v_offs+f_it->v[2]+1, + v_offs+f_it->v[1]+1,v_offs+f_it->v[1]+1,v_offs+f_it->v[1]+1, + v_offs+f_it->v[0]+1,v_offs+f_it->v[0]+1,v_offs+f_it->v[0]+1); F.w_string(tmp); + } + v_offs += VERTS.size(); } - v_offs += VERTS.size(); } } -} -*/ -//--- - FS.w_close (F); + */ + //--- + FS.w_close(F); } void SceneBuilder::SaveBuild() { - xr_string fn = MakeLevelPath("build.prj"); - IWriter* F = FS.w_open(fn.c_str()); - if (F){ - F->open_chunk (EB_Version); - F->w_u32 (XRCL_CURRENT_VERSION); - F->close_chunk (); - - F->open_chunk (EB_Parameters); - F->w (&Scene->m_LevelOp.m_BuildParams,sizeof(b_params)); - F->close_chunk (); - - F->open_chunk (EB_Vertices); - F->w (l_verts,sizeof(b_vertex)*l_vert_it); //. l_vert_cnt - F->close_chunk (); - - F->open_chunk (EB_Faces); - F->w (l_faces,sizeof(b_face)*l_face_it); //. l_face_cnt - F->close_chunk (); - - F->open_chunk (EB_SmoothGroups); - F->w (l_smgroups, sizeof(u32)*l_face_it); //. l_face_cnt - F->close_chunk (); - - F->open_chunk (EB_Materials); - F->w (l_materials.begin(),sizeof(b_material)*l_materials.size()); - F->close_chunk (); - - F->open_chunk (EB_Shaders_Render); - F->w (l_shaders.begin(),sizeof(b_shader)*l_shaders.size()); - F->close_chunk (); - - F->open_chunk (EB_Shaders_Compile); - F->w (l_shaders_xrlc.begin(),sizeof(b_shader)*l_shaders_xrlc.size()); - F->close_chunk (); - - F->open_chunk (EB_Textures); - F->w (l_textures.begin(),sizeof(b_texture)*l_textures.size()); - F->close_chunk (); - - F->open_chunk (EB_Glows); - F->w (l_glows.begin(),sizeof(b_glow)*l_glows.size()); - F->close_chunk (); - - F->open_chunk (EB_Portals); - F->w (l_portals.begin(),sizeof(b_portal)*l_portals.size()); - F->close_chunk (); - - F->open_chunk (EB_Light_control); - for (xr_vector::iterator lc_it=l_light_control.begin(); lc_it!=l_light_control.end(); lc_it++){ - F->w (lc_it->name,sizeof(lc_it->name)); - F->w_u32 (lc_it->data.size()); - F->w (lc_it->data.begin(),sizeof(u32)*lc_it->data.size()); + xr_string fn = MakeLevelPath("build.prj"); + IWriter *F = FS.w_open(fn.c_str()); + if (F) + { + F->open_chunk(EB_Version); + F->w_u32(XRCL_CURRENT_VERSION); + F->close_chunk(); + + F->open_chunk(EB_Parameters); + F->w(&Scene->m_LevelOp.m_BuildParams, sizeof(b_params)); + F->close_chunk(); + + F->open_chunk(EB_Vertices); + F->w(l_verts, sizeof(b_vertex)*l_vert_it); //. l_vert_cnt + F->close_chunk(); + + F->open_chunk(EB_Faces); + F->w(l_faces, sizeof(b_face)*l_face_it); //. l_face_cnt + F->close_chunk(); + + F->open_chunk(EB_SmoothGroups); + F->w(l_smgroups, sizeof(u32)*l_face_it); //. l_face_cnt + F->close_chunk(); + + F->open_chunk(EB_Materials); + F->w(l_materials.begin(), sizeof(b_material)*l_materials.size()); + F->close_chunk(); + + F->open_chunk(EB_Shaders_Render); + F->w(l_shaders.begin(), sizeof(b_shader)*l_shaders.size()); + F->close_chunk(); + + F->open_chunk(EB_Shaders_Compile); + F->w(l_shaders_xrlc.begin(), sizeof(b_shader)*l_shaders_xrlc.size()); + F->close_chunk(); + + F->open_chunk(EB_Textures); + F->w(l_textures.begin(), sizeof(b_texture)*l_textures.size()); + F->close_chunk(); + + F->open_chunk(EB_Glows); + F->w(l_glows.begin(), sizeof(b_glow)*l_glows.size()); + F->close_chunk(); + + F->open_chunk(EB_Portals); + F->w(l_portals.begin(), sizeof(b_portal)*l_portals.size()); + F->close_chunk(); + + F->open_chunk(EB_Light_control); + for (xr_vector::iterator lc_it = l_light_control.begin(); lc_it!=l_light_control.end(); lc_it++) + { + F->w(lc_it->name, sizeof(lc_it->name)); + F->w_u32(lc_it->data.size()); + F->w(lc_it->data.begin(), sizeof(u32)*lc_it->data.size()); } - F->close_chunk (); + F->close_chunk(); - F->open_chunk (EB_Light_static); - F->w (l_light_static.begin(),sizeof(b_light_static)*l_light_static.size()); - F->close_chunk (); + F->open_chunk(EB_Light_static); + F->w(l_light_static.begin(), sizeof(b_light_static)*l_light_static.size()); + F->close_chunk(); - F->open_chunk (EB_Light_dynamic); - F->w (l_light_dynamic.begin(),sizeof(b_light_dynamic)*l_light_dynamic.size()); - F->close_chunk (); + F->open_chunk(EB_Light_dynamic); + F->w(l_light_dynamic.begin(), sizeof(b_light_dynamic)*l_light_dynamic.size()); + F->close_chunk(); - F->open_chunk (EB_LOD_models); - for (int k=0; k<(int)l_lods.size(); ++k) - F->w (&l_lods[k].lod,sizeof(b_lod)); - F->close_chunk (); + F->open_chunk(EB_LOD_models); + for (int k = 0; k<(int)l_lods.size(); ++k) + F->w(&l_lods[k].lod, sizeof(b_lod)); + F->close_chunk(); - F->open_chunk (EB_MU_models); - for (k=0; k<(int)l_mu_models.size(); ++k) + F->open_chunk(EB_MU_models); + for (k = 0; k<(int)l_mu_models.size(); ++k) { - b_mu_model& m= l_mu_models[k]; + b_mu_model &m = l_mu_models[k]; // name F->w_stringZ(m.name); // vertices - F->w_u32 (m.m_iVertexCount); - F->w (m.m_pVertices,sizeof(b_vertex)*m.m_iVertexCount); + F->w_u32(m.m_iVertexCount); + F->w(m.m_pVertices, sizeof(b_vertex)*m.m_iVertexCount); // faces - F->w_u32 (m.m_iFaceCount); - F->w (m.m_pFaces,sizeof(b_face)*m.m_iFaceCount); + F->w_u32(m.m_iFaceCount); + F->w(m.m_pFaces, sizeof(b_face)*m.m_iFaceCount); // lod_id - F->w_u16 (m.lod_id); - F->w (m.m_smgroups,sizeof(int)*m.m_iFaceCount); + F->w_u16(m.lod_id); + F->w(m.m_smgroups, sizeof(int)*m.m_iFaceCount); } - F->close_chunk (); + F->close_chunk(); - F->open_chunk (EB_MU_refs); - F->w (l_mu_refs.begin(),sizeof(b_mu_reference)*l_mu_refs.size()); - F->close_chunk (); + F->open_chunk(EB_MU_refs); + F->w(l_mu_refs.begin(), sizeof(b_mu_reference)*l_mu_refs.size()); + F->close_chunk(); - FS.w_close (F); + FS.w_close(F); } } -int SceneBuilder::CalculateSector(const Fvector& P, float R) +int SceneBuilder::CalculateSector(const Fvector &P, float R) { ObjectIt _F = Scene->FirstObj(OBJCLASS_SECTOR); ObjectIt _E = Scene->LastObj(OBJCLASS_SECTOR); - for(;_F!=_E;_F++){ - CSector* _S=(CSector*)(*_F); - EVisible vis=_S->Intersect(P,R); + for (; _F!=_E; _F++) + { + CSector *_S = (CSector*)(*_F); + EVisible vis = _S->Intersect(P, R); if ((vis==fvPartialInside)||(vis==fvFully)) - if (_S->m_sector_num!=m_iDefaultSectorNum) - return _S->m_sector_num; - } + if (_S->m_sector_num!=m_iDefaultSectorNum) + return _S->m_sector_num; + } return m_iDefaultSectorNum; // ïî óìîë÷àíèþ } -void SceneBuilder::Clear () +void SceneBuilder::Clear() { - object_for_render = 0; - l_vert_cnt = 0; - l_face_cnt = 0; - l_vert_it = 0; - l_face_it = 0; - xr_free (l_verts); - xr_free (l_faces); - xr_free (l_smgroups); - - for (int k=0; k<(int)l_mu_models.size(); k++){ - b_mu_model& m = l_mu_models[k]; - xr_free (m.m_pVertices); - xr_free (m.m_pFaces); - xr_free (m.m_smgroups); + object_for_render = 0; + l_vert_cnt = 0; + l_face_cnt = 0; + l_vert_it = 0; + l_face_it = 0; + xr_free(l_verts); + xr_free(l_faces); + xr_free(l_smgroups); + + for (int k = 0; k<(int)l_mu_models.size(); k++) + { + b_mu_model &m = l_mu_models[k]; + xr_free(m.m_pVertices); + xr_free(m.m_pFaces); + xr_free(m.m_smgroups); } - l_mu_models.clear (); - l_mu_refs.clear (); - l_lods.clear (); - l_light_static.clear (); - l_light_dynamic.clear (); - l_light_control.clear (); - l_textures.clear (); - l_shaders.clear (); - l_shaders_xrlc.clear (); - l_materials.clear (); - l_vnormals.clear (); - l_glows.clear (); - l_portals.clear (); - l_light_keys.clear (); - xr_delete (l_scene_stat); + l_mu_models.clear(); + l_mu_refs.clear(); + l_lods.clear(); + l_light_static.clear(); + l_light_dynamic.clear(); + l_light_control.clear(); + l_textures.clear(); + l_shaders.clear(); + l_shaders_xrlc.clear(); + l_materials.clear(); + l_vnormals.clear(); + l_glows.clear(); + l_portals.clear(); + l_light_keys.clear(); + xr_delete(l_scene_stat); } //------------------------------------------------------------------------------ // CEditObject build functions //------------------------------------------------------------------------------ -float CalcArea(const Fvector& v0, const Fvector& v1, const Fvector& v2) +float CalcArea(const Fvector &v0, const Fvector &v1, const Fvector &v2) { - float e1 = v0.distance_to(v1); - float e2 = v0.distance_to(v2); - float e3 = v1.distance_to(v2); + float e1 = v0.distance_to(v1); + float e2 = v0.distance_to(v2); + float e3 = v1.distance_to(v2); - float p = (e1+e2+e3)/2.f; - return _sqrt( p*(p-e1)*(p-e2)*(p-e3) ); + float p = (e1+e2+e3)/2.f; + return _sqrt(p*(p-e1)*(p-e2)*(p-e3)); } //const Fmatrix& parent, -BOOL GetStaticCformData( const Fmatrix& parent, CEditableMesh* mesh, CEditableObject* object, Fvector* verts, int& vert_cnt, int& vert_it, CDB::TRI *faces , int& face_cnt, int& face_it ) +BOOL GetStaticCformData(const Fmatrix &parent, CEditableMesh *mesh, CEditableObject *object, Fvector *verts, int &vert_cnt, int &vert_it, CDB::TRI *faces, int &face_cnt, int &face_it) { - - if (object->IsDynamic()) - return FALSE; + if (object->IsDynamic()) + return FALSE; //Fmatrix parent = object->_Transform(); - - BOOL bResult = TRUE; - int point_offs = vert_it; // save offset - // fill vertices - for (u32 pt_id=0; pt_idGetVCount(); pt_id++){ - R_ASSERT(vert_itVertices()[pt_id]); + + BOOL bResult = TRUE; + int point_offs = vert_it; // save offset + // fill vertices + for (u32 pt_id = 0; pt_idGetVCount(); pt_id++) + { + R_ASSERT(vert_itVertices()[pt_id]); } - for (SurfFacesPairIt sp_it=mesh->Surfaces().begin(); sp_it!=mesh->Surfaces().end(); sp_it++) + for (SurfFacesPairIt sp_it = mesh->Surfaces().begin(); sp_it!=mesh->Surfaces().end(); sp_it++) { - IntVec& face_lst = sp_it->second; - CSurface* surf = sp_it->first; - if(surf->m_GameMtlName=="materials\\occ") - continue; + IntVec &face_lst = sp_it->second; + CSurface *surf = sp_it->first; + if (surf->m_GameMtlName=="materials\\occ") + continue; u16 game_material_idx = GMLib.GetMaterialIdx(surf->m_GameMtlName.c_str()); - for (IntIt f_it=face_lst.begin(); f_it!=face_lst.end(); ++f_it) + for (IntIt f_it = face_lst.begin(); f_it!=face_lst.end(); ++f_it) { - st_Face& face = mesh->Faces()[*f_it]; - float _a = CalcArea(mesh->Vertices()[face.pv[0].pindex],mesh->Vertices()[face.pv[1].pindex],mesh->Vertices()[face.pv[2].pindex]); - if (!_valid(_a) || (_aFaces()[*f_it]; + float _a = CalcArea(mesh->Vertices()[face.pv[0].pindex], mesh->Vertices()[face.pv[1].pindex], mesh->Vertices()[face.pv[2].pindex]); + if (!_valid(_a)||(_am_Flags.is(CSurface::sf2Sided)) - { - R_ASSERT (face_itm_Flags.is(CSurface::sf2Sided)) + { + R_ASSERT(face_itGetVCount(); pt_id++){ - R_ASSERT(vert_itm_Vertices[pt_id]); + for (u32 pt_id = 0; pt_idGetVCount(); pt_id++) + { + R_ASSERT(vert_itm_Vertices[pt_id]); } if (object->IsDynamic()) - { - // update mesh - mesh->GenerateFNormals(); - mesh->GenerateAdjacency(); - Fvector N; - for (u32 pt=0; ptGetVCount(); pt++) - { - N.set(0,0,0); - IntVec& a_lst = (*mesh->m_Adjs)[pt]; + { + // update mesh + mesh->GenerateFNormals(); + mesh->GenerateAdjacency(); + Fvector N; + for (u32 pt = 0; ptGetVCount(); pt++) + { + N.set(0, 0, 0); + IntVec &a_lst = (*mesh->m_Adjs)[pt]; VERIFY(a_lst.size()); - for (IntIt i_it=a_lst.begin(); i_it!=a_lst.end(); i_it++) + for (IntIt i_it = a_lst.begin(); i_it!=a_lst.end(); i_it++) N.add((*mesh->m_FaceNormals)[*i_it]); N.normalize_safe(); parent.transform_dir(N); l_vnormals.push_back(N); } - // unload mesh normals - mesh->UnloadAdjacency(); - mesh->UnloadFNormals(); + // unload mesh normals + mesh->UnloadAdjacency(); + mesh->UnloadFNormals(); } // fill faces - for (SurfFacesPairIt sp_it=mesh->m_SurfFaces.begin(); sp_it!=mesh->m_SurfFaces.end(); sp_it++) + for (SurfFacesPairIt sp_it = mesh->m_SurfFaces.begin(); sp_it!=mesh->m_SurfFaces.end(); sp_it++) { - IntVec& face_lst = sp_it->second; - CSurface* surf = sp_it->first; - if(surf->m_GameMtlName=="materials\\occ") - continue; - - int m_id = BuildMaterial(surf,sect_num,!object->IsMUStatic()); - int gm_id = surf->_GameMtl(); - if (m_id<0) { - bResult = FALSE; + IntVec &face_lst = sp_it->second; + CSurface *surf = sp_it->first; + if (surf->m_GameMtlName=="materials\\occ") + continue; + + int m_id = BuildMaterial(surf, sect_num, !object->IsMUStatic()); + int gm_id = surf->_GameMtl(); + if (m_id<0) + { + bResult = FALSE; break; } if (gm_id<0) { - ELog.DlgMsg (mtError,"Surface: '%s' contains bad game material.",surf->_Name()); - bResult = FALSE; + ELog.DlgMsg(mtError, "Surface: '%s' contains bad game material.", surf->_Name()); + bResult = FALSE; break; } - SGameMtl* M = GMLib.GetMaterialByID(gm_id); + SGameMtl *M = GMLib.GetMaterialByID(gm_id); if (0==M) { - ELog.DlgMsg (mtError,"Surface: '%s' contains undefined game material.",surf->_Name()); - bResult = FALSE; + ELog.DlgMsg(mtError, "Surface: '%s' contains undefined game material.", surf->_Name()); + bResult = FALSE; break; } if (M->Flags.is(SGameMtl::flBreakable)) { - ELog.Msg (mtInformation,"Surface: '%s' contains breakable game material.",surf->_Name()); + ELog.Msg(mtInformation, "Surface: '%s' contains breakable game material.", surf->_Name()); continue; } if (M->Flags.is(SGameMtl::flClimable)) { - ELog.Msg (mtInformation,"Surface: '%s' contains climable game material.",surf->_Name()); + ELog.Msg(mtInformation, "Surface: '%s' contains climable game material.", surf->_Name()); continue; } if (M->Flags.is(SGameMtl::flDynamic)) { - ELog.DlgMsg (mtError,"Surface: '%s' contains non-static game material.",surf->_Name()); - bResult = FALSE; + ELog.DlgMsg(mtError, "Surface: '%s' contains non-static game material.", surf->_Name()); + bResult = FALSE; break; } - u32 dwTexCnt = ((surf->_FVF()&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT); + u32 dwTexCnt = ((surf->_FVF()&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT); if (dwTexCnt!=1) { - ELog.DlgMsg (mtError,"Surface: '%s' contains more than 1 texture refs.",surf->_Name()); - bResult = FALSE; - break; + ELog.DlgMsg(mtError, "Surface: '%s' contains more than 1 texture refs.", surf->_Name()); + bResult = FALSE; + break; } - u32 dwInvalidFaces = 0; - for (IntIt f_it=face_lst.begin(); f_it!=face_lst.end(); ++f_it) + u32 dwInvalidFaces = 0; + for (IntIt f_it = face_lst.begin(); f_it!=face_lst.end(); ++f_it) { - st_Face& face = mesh->m_Faces[*f_it]; - float _a = CalcArea(mesh->m_Vertices[face.pv[0].pindex],mesh->m_Vertices[face.pv[1].pindex],mesh->m_Vertices[face.pv[2].pindex]); - if (!_valid(_a) || (_am_Faces[*f_it]; + float _a = CalcArea(mesh->m_Vertices[face.pv[0].pindex], mesh->m_Vertices[face.pv[1].pindex], mesh->m_Vertices[face.pv[2].pindex]); + if (!_valid(_a)||(_am_Vertices[face.pv[0].pindex]); - real_transform.transform_tiny(p1,mesh->m_Vertices[face.pv[1].pindex]); - real_transform.transform_tiny(p2,mesh->m_Vertices[face.pv[2].pindex]); - Tools->m_DebugDraw.AppendWireFace(p0,p1,p2); + real_transform.transform_tiny(p0, mesh->m_Vertices[face.pv[0].pindex]); + real_transform.transform_tiny(p1, mesh->m_Vertices[face.pv[1].pindex]); + real_transform.transform_tiny(p2, mesh->m_Vertices[face.pv[2].pindex]); + Tools->m_DebugDraw.AppendWireFace(p0, p1, p2); - dwInvalidFaces++; + dwInvalidFaces++; continue; } - R_ASSERT (face_itm_SmoothGroups[*f_it]; - smgroups[face_it] &= ~(1<<3); - - first_face.dwMaterial = (u16)m_id; - first_face.dwMaterialGame = gm_id; - for (int k=0; k<3; ++k) + R_ASSERT(face_itm_SmoothGroups[*f_it]; + smgroups[face_it] &= ~(1<<3); + + first_face.dwMaterial = (u16)m_id; + first_face.dwMaterialGame = gm_id; + for (int k = 0; k<3; ++k) { - st_FaceVert& fv = face.pv[k]; + st_FaceVert &fv = face.pv[k]; // vertex index - R_ASSERT2((fv.pindex+point_offs)m_VMRefs[fv.vmref].pts[t]; - st_VMap& vmap = *mesh->m_VMaps[vm_pt.vmap_index]; + st_VMapPt &vm_pt = mesh->m_VMRefs[fv.vmref].pts[t]; + st_VMap &vmap = *mesh->m_VMaps[vm_pt.vmap_index]; if (vmap.type!=vmtUV) { ++offs; @@ -710,29 +730,29 @@ BOOL SceneBuilder::BuildMesh( const Fmatrix& parent, first_face.t[k].set(vmap.getUV(vm_pt.index)); } } - ++face_it; + ++face_it; } - if (surf->m_Flags.is(CSurface::sf2Sided)) + if (surf->m_Flags.is(CSurface::sf2Sided)) { - R_ASSERT (face_itm_SmoothGroups[*f_it]; - smgroups[face_it] |= (1<<3); - - for (int k=0; k<3; ++k) + R_ASSERT(face_itm_SmoothGroups[*f_it]; + smgroups[face_it] |= (1<<3); + + for (int k = 0; k<3; ++k) { - st_FaceVert& fv = face.pv[2-k]; + st_FaceVert &fv = face.pv[2-k]; // vertex index - second_face.v[k] =fv.pindex+point_offs; + second_face.v[k] = fv.pindex+point_offs; // uv maps int offs = 0; - for (u32 t=0; tm_VMRefs[fv.vmref].pts[t]; - st_VMap& vmap = *mesh->m_VMaps[vm_pt.vmap_index]; + st_VMapPt &vm_pt = mesh->m_VMRefs[fv.vmref].pts[t]; + st_VMap &vmap = *mesh->m_VMaps[vm_pt.vmap_index]; if (vmap.type!=vmtUV) { ++offs; @@ -746,430 +766,480 @@ BOOL SceneBuilder::BuildMesh( const Fmatrix& parent, } } if (dwInvalidFaces) - Msg("!Object '%s' - '%s' has %d invalid face(s). Removed.",object->GetName(),mesh->Name().c_str(),dwInvalidFaces); + Msg("!Object '%s' - '%s' has %d invalid face(s). Removed.", object->GetName(), mesh->Name().c_str(), dwInvalidFaces); if (!bResult) - break; + break; } return bResult; } -BOOL SceneBuilder::BuildObject(CSceneObject* obj) +BOOL SceneBuilder::BuildObject(CSceneObject *obj) { - CEditableObject *O = obj->GetReference(); + CEditableObject *O = obj->GetReference(); AnsiString temp; - temp.sprintf("Building object: %s",obj->Name); + temp.sprintf("Building object: %s", obj->Name); UI->SetStatus(temp.c_str()); - Fmatrix T = obj->_Transform(); - - Fmatrix cv = Fidentity; + Fmatrix T = obj->_Transform(); - if(m_save_as_object) - { - cv.k.z = -1.f; + Fmatrix cv = Fidentity; - Fmatrix TM; + if (m_save_as_object) + { + cv.k.z = -1.f; - TM.mul ( Fmatrix().mul(cv,T), cv ); - TM.mulB_44 ( cv ); - T = TM; - } + Fmatrix TM; - // parse mesh data - for(EditMeshIt M=O->FirstMesh();M!=O->LastMesh();M++){ - CSector* S = PortalUtils.FindSector(obj,*M); - int sect_num = S?S->m_sector_num:m_iDefaultSectorNum; - if (!BuildMesh(T,O,*M,sect_num,l_verts,l_vert_cnt,l_vert_it,l_faces,l_face_cnt,l_face_it,l_smgroups,obj->_Transform())) - return FALSE; + TM.mul(Fmatrix().mul(cv, T), cv); + TM.mulB_44(cv); + T = TM; + } + + // parse mesh data + for (EditMeshIt M = O->FirstMesh(); M!=O->LastMesh(); M++) + { + CSector *S = PortalUtils.FindSector(obj, *M); + int sect_num = S ? S->m_sector_num : m_iDefaultSectorNum; + if (!BuildMesh(T, O, *M, sect_num, l_verts, l_vert_cnt, l_vert_it, l_faces, l_face_cnt, l_face_it, l_smgroups, obj->_Transform())) + return FALSE; // fill DI vertices - for (u32 pt_id=0; pt_id<(*M)->GetVCount(); pt_id++) - { - Fvector v_res1, v_res2; - const Fvector& v_src = (*M)->m_Vertices[pt_id]; + for (u32 pt_id = 0; pt_id<(*M)->GetVCount(); pt_id++) + { + Fvector v_res1, v_res2; + const Fvector &v_src = (*M)->m_Vertices[pt_id]; - Fvector tmp; - cv.transform_tiny ( tmp , v_src ); - T.transform_tiny ( v_res1, tmp ); + Fvector tmp; + cv.transform_tiny(tmp, v_src); + T.transform_tiny(v_res1, tmp); - l_scene_stat->add_svert(v_res1); + l_scene_stat->add_svert(v_res1); } } return TRUE; } -int GetModelIdx( LPCSTR model_name ) +int GetModelIdx(LPCSTR model_name) { - int model_idx = -1; + int model_idx = -1; - for (int k=0; k<(int)Builder.l_mu_models.size(); k++){ - b_mu_model& m = Builder.l_mu_models[k]; - if (0==strcmp(m.name,model_name)){ - model_idx = k; + for (int k = 0; k<(int)Builder.l_mu_models.size(); k++) + { + b_mu_model &m = Builder.l_mu_models[k]; + if (0==strcmp(m.name, model_name)) + { + model_idx = k; break; } } - return model_idx; + return model_idx; } //BOOL GetMuStaticCformData( CSceneObject* obj,mesh_build_data &data, bool b_selected_only ) //{ // CEditableObject *O = obj->GetReference(); // int model_idx = GetModelIdx(O->GetName()); - // detect sector +// detect sector // CSector* S = PortalUtils.FindSector(obj,*O->FirstMesh()); // int sect_num = S?S->m_sector_num:Builder.m_iDefaultSectorNum; //} - -BOOL SceneBuilder::BuildMUObject(CSceneObject* obj) +BOOL SceneBuilder::BuildMUObject(CSceneObject *obj) { - CEditableObject *O = obj->GetReference(); - AnsiString temp; temp.sprintf("Building object: %s",obj->Name); + CEditableObject *O = obj->GetReference(); + AnsiString temp; + temp.sprintf("Building object: %s", obj->Name); UI->SetStatus(temp.c_str()); - int model_idx = GetModelIdx( O->GetName() ) ; + int model_idx = GetModelIdx(O->GetName()); // detect sector - CSector* S = PortalUtils.FindSector(obj,*O->FirstMesh()); - int sect_num = S?S->m_sector_num:m_iDefaultSectorNum; + CSector *S = PortalUtils.FindSector(obj, *O->FirstMesh()); + int sect_num = S ? S->m_sector_num : m_iDefaultSectorNum; // build model - if (-1==model_idx || m_save_as_object) + if (-1==model_idx||m_save_as_object) { - // build LOD - int lod_id = BuildObjectLOD(Fidentity,O,sect_num); - if (lod_id==-2) return FALSE; + // build LOD + int lod_id = BuildObjectLOD(Fidentity, O, sect_num); + if (lod_id==-2) + return FALSE; // build model - model_idx = l_mu_models.size(); - l_mu_models.push_back(b_mu_model()); - b_mu_model& M = l_mu_models.back(); - M.lod_id = (u16)lod_id; - int vert_it=0, face_it=0; - - M.m_iFaceCount = obj->GetFaceCount(); - M.m_iVertexCount = obj->GetVertexCount(); - strcpy (M.name,O->GetName()); - - M.m_pFaces = xr_alloc(M.m_iFaceCount); - M.m_pVertices = xr_alloc(M.m_iVertexCount); - M.m_smgroups = xr_alloc(M.m_iFaceCount); - // parse mesh data - Fmatrix T; - T.identity(); - - if(m_save_as_object) - { - T = obj->_Transform(); - - Fmatrix cv = Fidentity; - - cv.k.z = -1.f; - - Fmatrix TM; - - TM.mul ( Fmatrix().mul(cv,T), cv ); - TM.mulB_44 ( cv ); - T = TM; - } - - for(EditMeshIt MESH=O->FirstMesh();MESH!=O->LastMesh();++MESH) - if (!BuildMesh(T, O, *MESH, sect_num, M.m_pVertices, M.m_iVertexCount, vert_it, M.m_pFaces, M.m_iFaceCount, face_it, M.m_smgroups, obj->_Transform())) - return FALSE; - - M.m_iFaceCount = face_it; - M.m_iVertexCount = vert_it; + model_idx = l_mu_models.size(); + l_mu_models.push_back(b_mu_model()); + b_mu_model &M = l_mu_models.back(); + M.lod_id = (u16)lod_id; + int vert_it = 0, face_it = 0; + + M.m_iFaceCount = obj->GetFaceCount(); + M.m_iVertexCount = obj->GetVertexCount(); + strcpy(M.name, O->GetName()); + + M.m_pFaces = xr_alloc(M.m_iFaceCount); + M.m_pVertices = xr_alloc(M.m_iVertexCount); + M.m_smgroups = xr_alloc(M.m_iFaceCount); + // parse mesh data + Fmatrix T; + T.identity(); + + if (m_save_as_object) + { + T = obj->_Transform(); + + Fmatrix cv = Fidentity; + + cv.k.z = -1.f; + + Fmatrix TM; + + TM.mul(Fmatrix().mul(cv, T), cv); + TM.mulB_44(cv); + T = TM; + } + + for (EditMeshIt MESH = O->FirstMesh(); MESH!=O->LastMesh(); ++MESH) + if (!BuildMesh(T, O, *MESH, sect_num, M.m_pVertices, M.m_iVertexCount, vert_it, M.m_pFaces, M.m_iFaceCount, face_it, M.m_smgroups, obj->_Transform())) + return FALSE; + + M.m_iFaceCount = face_it; + M.m_iVertexCount = vert_it; } - l_mu_refs.push_back (b_mu_reference()); - b_mu_reference& R = l_mu_refs.back(); - R.model_index = model_idx; - R.transform = obj->_Transform(); - R.flags.zero (); - R.sector = (u16)sect_num; + l_mu_refs.push_back(b_mu_reference()); + b_mu_reference &R = l_mu_refs.back(); + R.model_index = model_idx; + R.transform = obj->_Transform(); + R.flags.zero(); + R.sector = (u16)sect_num; // scene statssm - b_mu_model& M = l_mu_models[model_idx]; + b_mu_model &M = l_mu_models[model_idx]; + + for (u32 mu_vi = 0; mu_vi<(u32)M.m_iVertexCount; ++mu_vi) + l_scene_stat->add_muvert(obj->_Transform(), M.m_pVertices[mu_vi]); - for (u32 mu_vi=0; mu_vi<(u32)M.m_iVertexCount; ++mu_vi) - l_scene_stat->add_muvert(obj->_Transform(),M.m_pVertices[mu_vi]); - return TRUE; } //------------------------------------------------------------------------------ // light build functions //------------------------------------------------------------------------------ -int SceneBuilder::BuildLightControl(LPCSTR name) +int SceneBuilder::BuildLightControl(LPCSTR name) { - for (u32 k=0; kT.energy = E; - H->T.light.direction.set(x,y,z); - H->dest->push_back (H->T); + SHemiData *H = (SHemiData*)P; + H->T.energy = E; + H->T.light.direction.set(x, y, z); + H->dest->push_back(H->T); } + void SceneBuilder::BuildHemiLights(u8 quality, LPCSTR lcontrol) { - BLVec dest; - Flight RL; + BLVec dest; + Flight RL; // set def params - RL.type = D3DLIGHT_DIRECTIONAL; - RL.diffuse.set (1.f,1.f,1.f,1.f); - if (quality){ - SHemiData h_data; - h_data.dest = &dest; - h_data.T.light = RL; - xrHemisphereBuild(quality,2.f,hemi_callback,&h_data); //. hack - int control_ID = BuildLightControl(lcontrol); - for (BLIt it=dest.begin(); it!=dest.end(); it++){ + RL.type = D3DLIGHT_DIRECTIONAL; + RL.diffuse.set(1.f, 1.f, 1.f, 1.f); + if (quality) + { + SHemiData h_data; + h_data.dest = &dest; + h_data.T.light = RL; + xrHemisphereBuild(quality, 2.f, hemi_callback, &h_data); //. hack + int control_ID = BuildLightControl(lcontrol); + for (BLIt it = dest.begin(); it!=dest.end(); it++) + { l_light_static.push_back(b_light_static()); - b_light_static& sl = l_light_static.back(); - sl.controller_ID = control_ID; - sl.data = it->light; - sl.data.mul (it->energy); + b_light_static &sl = l_light_static.back(); + sl.controller_ID = control_ID; + sl.data = it->light; + sl.data.mul(it->energy); } - }else{ - int control_ID = BuildLightControl(lcontrol); + } + else + { + int control_ID = BuildLightControl(lcontrol); l_light_static.push_back(b_light_static()); - b_light_static& sl = l_light_static.back(); - sl.controller_ID = control_ID; - sl.data.type = D3DLIGHT_DIRECTIONAL; - sl.data.diffuse.set (1.f,1.f,1.f,1.f); - sl.data.direction.set (0.f,-1.f,0.f); + b_light_static &sl = l_light_static.back(); + sl.controller_ID = control_ID; + sl.data.type = D3DLIGHT_DIRECTIONAL; + sl.data.diffuse.set(1.f, 1.f, 1.f, 1.f); + sl.data.direction.set(0.f, -1.f, 0.f); } } + BOOL SceneBuilder::BuildSun(u8 quality, Fvector2 dir) { - int controller_ID = BuildLightControl(LCONTROL_SUN); + int controller_ID = BuildLightControl(LCONTROL_SUN); // static // soft light int samples; - switch(quality){ - case 0: samples = 1; break; - case 1: samples = 3; break; - case 2: samples = 4; break; - case 3: samples = 7; break; - default: - THROW2("Invalid case."); + switch (quality) + { + case 0: samples = 1; + break; + case 1: samples = 3; + break; + case 2: samples = 4; + break; + case 3: samples = 7; + break; + default: + THROW2("Invalid case."); } - Fcolor color; color.set(1.f,1.f,1.f,1.f); - float sample_energy = 1.f/float(samples*samples); - color.mul_rgb (sample_energy); + Fcolor color; + color.set(1.f, 1.f, 1.f, 1.f); + float sample_energy = 1.f/float(samples*samples); + color.mul_rgb(sample_energy); - float disp = deg2rad(3.f); // dispersion of sun - float da = disp/float(samples); - float mn_x = dir.x-disp/2; - float mn_y = dir.y-disp/2; - for (int x=0; x* sectors, FvectorVec* soft_points, const Fmatrix* soft_transform) +BOOL SceneBuilder::BuildPointLight(b_light *b, const Flags32 &usage, svector *sectors, FvectorVec *soft_points, const Fmatrix *soft_transform) { - if (usage.is(ELight::flAffectStatic)){ - if (soft_points&&!soft_points->empty()){ - R_ASSERT(soft_transform); - // make soft light - Fcolor color = b->data.diffuse; - color.normalize_rgb (b->data.diffuse); - float sample_energy = (b->data.diffuse.magnitude_rgb())/float(soft_points->size()); - color.mul_rgb (sample_energy); - - for (u32 k=0; ksize(); k++){ + if (usage.is(ELight::flAffectStatic)) + { + if (soft_points&&!soft_points->empty()) + { + R_ASSERT(soft_transform); + // make soft light + Fcolor color = b->data.diffuse; + color.normalize_rgb(b->data.diffuse); + float sample_energy = (b->data.diffuse.magnitude_rgb())/float(soft_points->size()); + color.mul_rgb(sample_energy); + + for (u32 k = 0; ksize(); k++) + { l_light_static.push_back(b_light_static()); - b_light_static& sl = l_light_static.back(); - sl.controller_ID = b->controller_ID; - sl.data = b->data; - sl.data.diffuse.set (color); - soft_transform->transform_tiny(sl.data.position,(*soft_points)[k]); + b_light_static &sl = l_light_static.back(); + sl.controller_ID = b->controller_ID; + sl.data = b->data; + sl.data.diffuse.set(color); + soft_transform->transform_tiny(sl.data.position, (*soft_points)[k]); } - }else{ - // make single light + } + else + { + // make single light l_light_static.push_back(b_light_static()); - b_light_static& sl = l_light_static.back(); - sl.controller_ID = b->controller_ID; - sl.data = b->data; + b_light_static &sl = l_light_static.back(); + sl.controller_ID = b->controller_ID; + sl.data = b->data; } } - if (usage.is(ELight::flAffectDynamic)){ - R_ASSERT (sectors); - l_light_dynamic.push_back(b_light_dynamic()); - b_light_dynamic& dl = l_light_dynamic.back(); - dl.controller_ID = b->controller_ID; - dl.data = b->data; - dl.sectors = *sectors; + if (usage.is(ELight::flAffectDynamic)) + { + R_ASSERT(sectors); + l_light_dynamic.push_back(b_light_dynamic()); + b_light_dynamic &dl = l_light_dynamic.back(); + dl.controller_ID = b->controller_ID; + dl.data = b->data; + dl.sectors = *sectors; } - return TRUE; + return TRUE; } -BOOL SceneBuilder::BuildLight(CLight* e) +BOOL SceneBuilder::BuildLight(CLight *e) { if (!e->m_Flags.is_any(ELight::flAffectStatic|ELight::flAffectDynamic)) - return FALSE; + return FALSE; - if (!e->GetLControlName()){ - ELog.Msg(mtError,"Invalid light control name: light '%s'.",e->Name); - return FALSE; + if (!e->GetLControlName()) + { + ELog.Msg(mtError, "Invalid light control name: light '%s'.", e->Name); + return FALSE; } - - b_light L; - L.data.type = e->m_Type; - L.data.diffuse.mul_rgb (e->m_Color,e->m_Brightness); - L.data.position.set (e->PPosition); - Fvector dir; dir.setHP (e->PRotation.y,e->PRotation.x); - L.data.direction.set (dir); - L.data.range = e->m_Range; - L.data.attenuation0 = e->m_Attenuation0; - L.data.attenuation1 = e->m_Attenuation1; - L.data.attenuation2 = e->m_Attenuation2; - L.data.phi = e->m_Cone; - - L.controller_ID = BuildLightControl(e->GetLControlName()); //BuildLightControl(LCONTROL_STATIC); - - svector* lpSectors; - if (e->m_Flags.is(ELight::flAffectDynamic)){ - svector sectors; - lpSectors = §ors; - Fvector pos = e->PPosition; - float& range = e->m_Range; - if (Scene->ObjCount(OBJCLASS_SECTOR)){ + + b_light L; + L.data.type = e->m_Type; + L.data.diffuse.mul_rgb(e->m_Color, e->m_Brightness); + L.data.position.set(e->PPosition); + Fvector dir; + dir.setHP(e->PRotation.y, e->PRotation.x); + L.data.direction.set(dir); + L.data.range = e->m_Range; + L.data.attenuation0 = e->m_Attenuation0; + L.data.attenuation1 = e->m_Attenuation1; + L.data.attenuation2 = e->m_Attenuation2; + L.data.phi = e->m_Cone; + + L.controller_ID = BuildLightControl(e->GetLControlName()); //BuildLightControl(LCONTROL_STATIC); + + svector *lpSectors; + if (e->m_Flags.is(ELight::flAffectDynamic)) + { + svector sectors; + lpSectors = §ors; + Fvector pos = e->PPosition; + float &range = e->m_Range; + if (Scene->ObjCount(OBJCLASS_SECTOR)) + { // test fully and partial inside ObjectIt _F = Scene->FirstObj(OBJCLASS_SECTOR); ObjectIt _E = Scene->LastObj(OBJCLASS_SECTOR); - for(;_F!=_E;_F++){ - if (sectors.size()>=16) break; - CSector* _S=(CSector*)(*_F); - EVisible vis=_S->Intersect(pos,range); + for (; _F!=_E; _F++) + { + if (sectors.size()>=16) + break; + CSector *_S = (CSector*)(*_F); + EVisible vis = _S->Intersect(pos, range); if ((vis==fvPartialInside)||(vis==fvFully)) sectors.push_back((u16)_S->m_sector_num); } // test partial outside _F = Scene->FirstObj(OBJCLASS_SECTOR); - for(;_F!=_E;_F++){ - if (sectors.size()>=16) break; - CSector* _S=(CSector*)(*_F); - EVisible vis=_S->Intersect(pos,range); + for (; _F!=_E; _F++) + { + if (sectors.size()>=16) + break; + CSector *_S = (CSector*)(*_F); + EVisible vis = _S->Intersect(pos, range); if (vis==fvPartialOutside) sectors.push_back((u16)_S->m_sector_num); } - if (sectors.empty()) return FALSE; - }else{ + if (sectors.empty()) + return FALSE; + } + else + { sectors.push_back((u16)m_iDefaultSectorNum); } } - switch (e->m_Type){ - case ELight::ltPoint: return BuildPointLight (&L,e->m_Flags,lpSectors,e->m_FuzzyData?&e->m_FuzzyData->m_Positions:0,&e->_Transform()); - default: - THROW2("Invalid light type."); - return FALSE; + switch (e->m_Type) + { + case ELight::ltPoint: return BuildPointLight(&L, e->m_Flags, lpSectors, e->m_FuzzyData ? &e->m_FuzzyData->m_Positions : 0, &e->_Transform()); + default: + THROW2("Invalid light type."); + return FALSE; } } + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // Glow build functions //------------------------------------------------------------------------------ -BOOL SceneBuilder::BuildGlow(CGlow* e) +BOOL SceneBuilder::BuildGlow(CGlow *e) { - l_glows.push_back(b_glow()); - b_glow& b = l_glows.back(); -// material - b_material mtl; ZeroMemory(&mtl,sizeof(mtl)); + l_glows.push_back(b_glow()); + b_glow &b = l_glows.back(); + // material + b_material mtl; + ZeroMemory(&mtl, sizeof(mtl)); int mtl_idx; - VERIFY (e->m_ShaderName.size()); - mtl.surfidx = (u16)BuildTexture (*e->m_TexName); - mtl.shader = (u16)BuildShader (*e->m_ShaderName); - mtl.sector = (u16)CalculateSector (e->PPosition,e->m_fRadius); - mtl.shader_xrlc = -1; - if ((u16(-1)==mtl.surfidx)||(u16(-1)==mtl.shader)) return FALSE; - - mtl_idx = FindInMaterials(&mtl); - if (mtl_idx<0){ + VERIFY(e->m_ShaderName.size()); + mtl.surfidx = (u16)BuildTexture(*e->m_TexName); + mtl.shader = (u16)BuildShader(*e->m_ShaderName); + mtl.sector = (u16)CalculateSector(e->PPosition, e->m_fRadius); + mtl.shader_xrlc = -1; + if ((u16(-1)==mtl.surfidx)||(u16(-1)==mtl.shader)) + return FALSE; + + mtl_idx = FindInMaterials(&mtl); + if (mtl_idx<0) + { l_materials.push_back(mtl); - mtl_idx = l_materials.size()-1; + mtl_idx = l_materials.size()-1; } -// fill params - b.P.set (e->PPosition); - b.size = e->m_fRadius; - b.dwMaterial = mtl_idx; - b.flags = e->m_Flags.is(CGlow::gfFixedSize)?0x01:0x00; // 0x01 - non scalable + // fill params + b.P.set(e->PPosition); + b.size = e->m_fRadius; + b.dwMaterial = mtl_idx; + b.flags = e->m_Flags.is(CGlow::gfFixedSize) ? 0x01 : 0x00; // 0x01 - non scalable return TRUE; } + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // Portal build functions //------------------------------------------------------------------------------ -void SceneBuilder::BuildPortal(b_portal* b, CPortal* e){ - b->sector_front = (u16)e->m_SectorFront->m_sector_num; - b->sector_back = (u16)e->m_SectorBack->m_sector_num; +void SceneBuilder::BuildPortal(b_portal *b, CPortal *e) +{ + b->sector_front = (u16)e->m_SectorFront->m_sector_num; + b->sector_back = (u16)e->m_SectorBack->m_sector_num; b->vertices.resize(e->m_SimplifyVertices.size()); - CopyMemory(b->vertices.begin(),e->m_SimplifyVertices.begin(),e->m_SimplifyVertices.size()*sizeof(Fvector)); + CopyMemory(b->vertices.begin(), e->m_SimplifyVertices.begin(), e->m_SimplifyVertices.size()*sizeof(Fvector)); } //------------------------------------------------------------------------------ // shader build functions //------------------------------------------------------------------------------ -int SceneBuilder::FindInShaders(b_shader* s){ - for (u32 i=0; iname)==0)return i; +int SceneBuilder::FindInShaders(b_shader *s) +{ + for (u32 i = 0; iname)==0) + return i; return -1; } + //------------------------------------------------------------------------------ -int SceneBuilder::BuildShader(const char * s) +int SceneBuilder::BuildShader(const char *s) { b_shader sh; - strcpy(sh.name,s); + strcpy(sh.name, s); int sh_id = FindInShaders(&sh); - if (sh_id<0){ - if (!EDevice.Resources->_FindBlender(sh.name)){ - ELog.DlgMsg(mtError,"Can't find engine shader: %s",sh.name); + if (sh_id<0) + { + if (!EDevice.Resources->_FindBlender(sh.name)) + { + ELog.DlgMsg(mtError, "Can't find engine shader: %s", sh.name); return -1; } l_shaders.push_back(sh); @@ -1177,25 +1247,32 @@ int SceneBuilder::BuildShader(const char * s) } return sh_id; } + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // shader xrlc build functions //------------------------------------------------------------------------------ -int SceneBuilder::FindInShadersXRLC(b_shader* s){ - for (u32 i=0; iname)==0)return i; +int SceneBuilder::FindInShadersXRLC(b_shader *s) +{ + for (u32 i = 0; iname)==0) + return i; return -1; } + //------------------------------------------------------------------------------ -int SceneBuilder::BuildShaderXRLC(const char * s){ +int SceneBuilder::BuildShaderXRLC(const char *s) +{ b_shader sh; - strcpy(sh.name,s); + strcpy(sh.name, s); int sh_id = FindInShadersXRLC(&sh); - if (sh_id<0){ - if (!EDevice.ShaderXRLC.Get(sh.name)){ - ELog.DlgMsg(mtError,"Can't find compiler shader: %s",sh.name); + if (sh_id<0) + { + if (!EDevice.ShaderXRLC.Get(sh.name)) + { + ELog.DlgMsg(mtError, "Can't find compiler shader: %s", sh.name); return -1; } l_shaders_xrlc.push_back(sh); @@ -1203,300 +1280,343 @@ int SceneBuilder::BuildShaderXRLC(const char * s){ } return sh_id; } + //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // texture build functions //------------------------------------------------------------------------------ -int SceneBuilder::FindInTextures(const char* name){ - for (u32 i=0; isurfidx) && - (l_materials[i].shader == m->shader) && - (l_materials[i].shader_xrlc == m->shader_xrlc) && - (l_materials[i].sector == m->sector)) return i; + for (u32 i = 0; isurfidx)&& + (l_materials[i].shader==m->shader)&& + (l_materials[i].shader_xrlc==m->shader_xrlc)&& + (l_materials[i].sector==m->sector)) + return i; } return -1; } + //------------------------------------------------------------------------------ -int SceneBuilder::BuildMaterial(CSurface* surf, int sector_num, bool allow_draft) +int SceneBuilder::BuildMaterial(CSurface *surf, int sector_num, bool allow_draft) { - return BuildMaterial(surf->_ShaderName(),surf->_ShaderXRLCName(),surf->_Texture(),((surf->_FVF()&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT),sector_num,allow_draft); + return BuildMaterial(surf->_ShaderName(), surf->_ShaderXRLCName(), surf->_Texture(), ((surf->_FVF()&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT), sector_num, allow_draft); } + int SceneBuilder::BuildMaterial(LPCSTR esh_name, LPCSTR csh_name, LPCSTR tx_name, u32 tx_cnt, int sector_num, bool allow_draft) { - b_material mtl; ZeroMemory(&mtl,sizeof(mtl)); + b_material mtl; + ZeroMemory(&mtl, sizeof(mtl)); VERIFY(sector_num>=0); int mtl_idx; - VERIFY (tx_cnt==1); - - if (allow_draft&&(Scene->m_LevelOp.m_BuildParams.m_quality==ebqDraft)){ - Shader_xrLC* c_sh = EDevice.ShaderXRLC.Get(csh_name); - if (c_sh->flags.bRendering){ - mtl.shader = (u16)BuildShader ("def_shaders\\def_vertex"); - mtl.shader_xrlc = (u16)BuildShaderXRLC ("def_shaders\\def_vertex"); - }else{ - mtl.shader = (u16)BuildShader (esh_name); - mtl.shader_xrlc = (u16)BuildShaderXRLC (csh_name); + VERIFY(tx_cnt==1); + + if (allow_draft&&(Scene->m_LevelOp.m_BuildParams.m_quality==ebqDraft)) + { + Shader_xrLC *c_sh = EDevice.ShaderXRLC.Get(csh_name); + if (c_sh->flags.bRendering) + { + mtl.shader = (u16)BuildShader("def_shaders\\def_vertex"); + mtl.shader_xrlc = (u16)BuildShaderXRLC("def_shaders\\def_vertex"); + } + else + { + mtl.shader = (u16)BuildShader(esh_name); + mtl.shader_xrlc = (u16)BuildShaderXRLC(csh_name); } - }else{ - mtl.shader = (u16)BuildShader (esh_name); - mtl.shader_xrlc = (u16)BuildShaderXRLC (csh_name); } - mtl.sector = (u16)sector_num; - mtl.surfidx = (u16)BuildTexture (tx_name); - if ((u16(-1)==mtl.shader)||(u16(-1)==mtl.shader_xrlc)||(u16(-1)==mtl.surfidx)) return -1; + else + { + mtl.shader = (u16)BuildShader(esh_name); + mtl.shader_xrlc = (u16)BuildShaderXRLC(csh_name); + } + mtl.sector = (u16)sector_num; + mtl.surfidx = (u16)BuildTexture(tx_name); + if ((u16(-1)==mtl.shader)||(u16(-1)==mtl.shader_xrlc)||(u16(-1)==mtl.surfidx)) + return -1; - mtl_idx = FindInMaterials(&mtl); - if (mtl_idx<0){ + mtl_idx = FindInMaterials(&mtl); + if (mtl_idx<0) + { l_materials.push_back(mtl); - mtl_idx = l_materials.size()-1; + mtl_idx = l_materials.size()-1; } return mtl_idx; } + //------------------------------------------------------------------------------ -BOOL SceneBuilder::ParseStaticObjects(ObjectList& lst, LPCSTR prefix, bool b_selected_only) +BOOL SceneBuilder::ParseStaticObjects(ObjectList &lst, LPCSTR prefix, bool b_selected_only) { - BOOL bResult = TRUE; - SPBItem* pb = UI->ProgressStart(lst.size(),"Parse static objects..."); - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) - { + BOOL bResult = TRUE; + SPBItem *pb = UI->ProgressStart(lst.size(), "Parse static objects..."); + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + { pb->Inc((*_F)->Name); - if (UI->NeedAbort()) break; - if(b_selected_only && !(*_F)->Selected()) - continue; - - switch((*_F)->ClassID){ - case OBJCLASS_LIGHT: - bResult = BuildLight((CLight*)(*_F)); + if (UI->NeedAbort()) break; - case OBJCLASS_GLOW: - bResult = BuildGlow((CGlow*)(*_F)); - break; - case OBJCLASS_PORTAL: - l_portals.push_back(b_portal()); - BuildPortal(&l_portals.back(),(CPortal*)(*_F)); - break; - case OBJCLASS_SCENEOBJECT:{ - CSceneObject *obj = (CSceneObject*)(*_F); - if (obj->IsStatic()) - bResult = BuildObject(obj); - else if (obj->IsMUStatic()) - bResult = BuildMUObject(obj); - }break; -/* case OBJCLASS_GROUP:{ - CGroupObject* group = (CGroupObject*)(*_F); - - ObjectList grp_lst; - group->GetObjects (grp_lst); - - bResult = ParseStaticObjects(grp_lst, group->Name, b_selected_only); - }break; */ + if (b_selected_only&&!(*_F)->Selected()) + continue; + + switch ((*_F)->ClassID) + { + case OBJCLASS_LIGHT: + bResult = BuildLight((CLight*)(*_F)); + break; + case OBJCLASS_GLOW: + bResult = BuildGlow((CGlow*)(*_F)); + break; + case OBJCLASS_PORTAL: + l_portals.push_back(b_portal()); + BuildPortal(&l_portals.back(), (CPortal*)(*_F)); + break; + case OBJCLASS_SCENEOBJECT: + { + CSceneObject *obj = (CSceneObject*)(*_F); + if (obj->IsStatic()) + bResult = BuildObject(obj); + else if (obj->IsMUStatic()) + bResult = BuildMUObject(obj); + } + break; + /* case OBJCLASS_GROUP:{ + CGroupObject* group = (CGroupObject*)(*_F); + + ObjectList grp_lst; + group->GetObjects(grp_lst); + + bResult = ParseStaticObjects(grp_lst, group->Name, b_selected_only); + }break; */ }// end switch if (!bResult) { - ELog.DlgMsg(mtError,"Failed to build object: '%s'",(*_F)->Name); - break; + ELog.DlgMsg(mtError, "Failed to build object: '%s'", (*_F)->Name); + break; } } UI->ProgressEnd(pb); return bResult; } + //------------------------------------------------------------------------------ BOOL SceneBuilder::CompileStatic(bool b_selected_only) { ObjClassID cls = LTools->CurrentClassID(); - if(cls==OBJCLASS_DUMMY) return FALSE; - ESceneToolBase* pCurrentTool = Scene->GetOTool(cls); + if (cls==OBJCLASS_DUMMY) + return FALSE; + ESceneToolBase *pCurrentTool = Scene->GetOTool(cls); - BOOL bResult = TRUE; + BOOL bResult = TRUE; - Clear (); + Clear(); - SceneToolsMapPairIt t_it = Scene->FirstTool(); - SceneToolsMapPairIt t_end = Scene->LastTool(); + SceneToolsMapPairIt t_it = Scene->FirstTool(); + SceneToolsMapPairIt t_end = Scene->LastTool(); - if(b_selected_only) + if (b_selected_only) { - if(pCurrentTool) - pCurrentTool->CompileStaticStart(); - }else + if (pCurrentTool) + pCurrentTool->CompileStaticStart(); + } + else { for (; t_it!=t_end; ++t_it) { - ESceneToolBase* mt = t_it->second; + ESceneToolBase *mt = t_it->second; if (mt) mt->CompileStaticStart(); } - } - int objcount = Scene->ObjCount(); - if( objcount <= 0 ) return FALSE; + } + int objcount = Scene->ObjCount(); + if (objcount<=0) + return FALSE; -// compute vertex/face count - l_vert_cnt = 0; - l_face_cnt = 0; - l_vert_it = 0; - l_face_it = 0; + // compute vertex/face count + l_vert_cnt = 0; + l_face_cnt = 0; + l_vert_it = 0; + l_face_it = 0; - if(b_selected_only) + if (b_selected_only) { - if(pCurrentTool) - pCurrentTool->GetStaticDesc(l_vert_cnt,l_face_cnt, b_selected_only,false); - }else + if (pCurrentTool) + pCurrentTool->GetStaticDesc(l_vert_cnt, l_face_cnt, b_selected_only, false); + } + else { - t_it = Scene->FirstTool(); - t_end = Scene->LastTool(); + t_it = Scene->FirstTool(); + t_end = Scene->LastTool(); for (; t_it!=t_end; ++t_it) { - ESceneToolBase* mt = t_it->second; + ESceneToolBase *mt = t_it->second; if (mt) - mt->GetStaticDesc(l_vert_cnt,l_face_cnt, b_selected_only,false); + mt->GetStaticDesc(l_vert_cnt, l_face_cnt, b_selected_only, false); } } - l_faces = xr_alloc (l_face_cnt); - l_smgroups = xr_alloc (l_face_cnt); - l_verts = xr_alloc(l_vert_cnt); - - l_scene_stat= xr_new(m_LevelBox); - -// make hemisphere - ESceneLightTool* lt = dynamic_cast(Scene->GetOTool(OBJCLASS_LIGHT)); - LPCSTR h_control = *lt->FindLightControl(lt->m_HemiControl)->name; - BuildHemiLights (Scene->m_LevelOp.m_LightHemiQuality,h_control); - if (0!=strcmp(LCONTROL_HEMI,h_control)) - BuildHemiLights (Scene->m_LevelOp.m_LightHemiQuality,LCONTROL_HEMI); -// make sun - BuildSun (Scene->m_LevelOp.m_LightSunQuality,lt->m_SunShadowDir); -// parse scene - SPBItem* pb = UI->ProgressStart(Scene->ObjCount(),"Parse scene objects..."); - - if(b_selected_only) + l_faces = xr_alloc(l_face_cnt); + l_smgroups = xr_alloc(l_face_cnt); + l_verts = xr_alloc(l_vert_cnt); + + l_scene_stat = xr_new(m_LevelBox); + + // make hemisphere + ESceneLightTool *lt = dynamic_cast(Scene->GetOTool(OBJCLASS_LIGHT)); + LPCSTR h_control = *lt->FindLightControl(lt->m_HemiControl)->name; + BuildHemiLights(Scene->m_LevelOp.m_LightHemiQuality, h_control); + if (0!=strcmp(LCONTROL_HEMI, h_control)) + BuildHemiLights(Scene->m_LevelOp.m_LightHemiQuality,LCONTROL_HEMI); + // make sun + BuildSun(Scene->m_LevelOp.m_LightSunQuality, lt->m_SunShadowDir); + // parse scene + SPBItem *pb = UI->ProgressStart(Scene->ObjCount(), "Parse scene objects..."); + + if (b_selected_only) { - if(pCurrentTool) - if (!pCurrentTool->ExportStatic(this,b_selected_only)) - {bResult = FALSE;} - }else + if (pCurrentTool) + if (!pCurrentTool->ExportStatic(this, b_selected_only)) + { + bResult = FALSE; + } + } + else { - t_it = Scene->FirstTool(); - t_end = Scene->LastTool(); + t_it = Scene->FirstTool(); + t_end = Scene->LastTool(); for (; t_it!=t_end; ++t_it) { - ESceneToolBase* mt = t_it->second; + ESceneToolBase *mt = t_it->second; if (mt) - if (!mt->ExportStatic(this,b_selected_only)) - {bResult = FALSE; break;} + if (!mt->ExportStatic(this, b_selected_only)) + { + bResult = FALSE; + break; + } } } - UI->ProgressEnd(pb); -// process lods - if (bResult&&!l_lods.empty()) + UI->ProgressEnd(pb); + // process lods + if (bResult&&!l_lods.empty()) { - SPBItem* pb = UI->ProgressStart(l_lods.size()*2,"Merge LOD textures..."); - Fvector2Vec offsets; - Fvector2Vec scales; - boolVec rotated; - U32Vec remap; - SSimpleImageVec images; - for (int k=0; k<(int)l_lods.size(); ++k) + SPBItem *pb = UI->ProgressStart(l_lods.size()*2, "Merge LOD textures..."); + Fvector2Vec offsets; + Fvector2Vec scales; + boolVec rotated; + U32Vec remap; + SSimpleImageVec images; + for (int k = 0; k<(int)l_lods.size(); ++k) { images.push_back(SSimpleImage()); - SSimpleImage& I = images.back(); - I.name = l_lods[k].lod_name; + SSimpleImage &I = images.back(); + I.name = l_lods[k].lod_name; I.layers.push_back(l_lods[k].data); I.layers.push_back(l_lods[k].ndata); - I.w = LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT; - I.h = LOD_IMAGE_SIZE; - pb->Inc(); + I.w = LOD_IMAGE_SIZE*LOD_SAMPLE_COUNT; + I.h = LOD_IMAGE_SIZE; + pb->Inc(); } SSimpleImage merged_image; - xr_string fn_color = ChangeFileExt (MakeLevelPath(LEVEL_LODS_TEX_NAME).c_str(),".dds").c_str(); - xr_string fn_normal = ChangeFileExt (MakeLevelPath(LEVEL_LODS_NRM_NAME).c_str(),".dds").c_str(); - if (1==ImageLib.CreateMergedTexture (2,images,merged_image,512,2048,64,2048,offsets,scales,rotated,remap)){ + xr_string fn_color = ChangeFileExt(MakeLevelPath(LEVEL_LODS_TEX_NAME).c_str(), ".dds").c_str(); + xr_string fn_normal = ChangeFileExt(MakeLevelPath(LEVEL_LODS_NRM_NAME).c_str(), ".dds").c_str(); + if (1==ImageLib.CreateMergedTexture(2, images, merged_image, 512, 2048, 64, 2048, offsets, scales, rotated, remap)) + { // all right, make texture - STextureParams tp; - tp.width = merged_image.w; - tp.height = merged_image.h; - tp.fmt = STextureParams::tfDXT5; - tp.type = STextureParams::ttImage; - tp.mip_filter = STextureParams::kMIPFilterAdvanced; - tp.flags.assign (STextureParams::flDitherColor|STextureParams::flGenerateMipMaps); - ImageLib.MakeGameTexture (fn_color.c_str(),merged_image.layers[0].begin(), tp); - ImageLib.MakeGameTexture (fn_normal.c_str(),merged_image.layers[1].begin(),tp); - for (k=0; k<(int)l_lods.size(); k++){ - e_b_lod& l = l_lods[k]; - for (u32 f=0; f<8; f++){ - for (u32 t=0; t<4; t++){ - Fvector2& uv = l.lod.faces[f].t[t]; - u32 id = remap[k]; - ImageLib.MergedTextureRemapUV(uv.x,uv.y,uv.x,uv.y,offsets[id],scales[id],rotated[id]); + STextureParams tp; + tp.width = merged_image.w; + tp.height = merged_image.h; + tp.fmt = STextureParams::tfDXT5; + tp.type = STextureParams::ttImage; + tp.mip_filter = STextureParams::kMIPFilterAdvanced; + tp.flags.assign(STextureParams::flDitherColor|STextureParams::flGenerateMipMaps); + ImageLib.MakeGameTexture(fn_color.c_str(), merged_image.layers[0].begin(), tp); + ImageLib.MakeGameTexture(fn_normal.c_str(), merged_image.layers[1].begin(), tp); + for (k = 0; k<(int)l_lods.size(); k++) + { + e_b_lod &l = l_lods[k]; + for (u32 f = 0; f<8; f++) + { + for (u32 t = 0; t<4; t++) + { + Fvector2 &uv = l.lod.faces[f].t[t]; + u32 id = remap[k]; + ImageLib.MergedTextureRemapUV(uv.x, uv.y, uv.x, uv.y, offsets[id], scales[id], rotated[id]); } } - pb->Inc(); - } - }else{ - ELog.DlgMsg (mtError,"Failed to build merged LOD texture. Merged texture more than [2048x2048]."); - bResult = FALSE; + pb->Inc(); + } + } + else + { + ELog.DlgMsg(mtError, "Failed to build merged LOD texture. Merged texture more than [2048x2048]."); + bResult = FALSE; } UI->ProgressEnd(pb); } -// save build - if (bResult && !UI->NeedAbort()) - { - if(m_save_as_object) - SaveBuildAsObject (); - else - SaveBuild (); - } + // save build + if (bResult&&!UI->NeedAbort()) + { + if (m_save_as_object) + SaveBuildAsObject(); + else + SaveBuild(); + } - if(b_selected_only) + if (b_selected_only) { - if(pCurrentTool) - pCurrentTool->CompileStaticEnd(); - }else + if (pCurrentTool) + pCurrentTool->CompileStaticEnd(); + } + else { - t_it = Scene->FirstTool(); - t_end = Scene->LastTool(); + t_it = Scene->FirstTool(); + t_end = Scene->LastTool(); for (; t_it!=t_end; ++t_it) { - ESceneToolBase* mt = t_it->second; + ESceneToolBase *mt = t_it->second; if (mt) mt->CompileStaticEnd(); } - } + } return bResult; } @@ -1505,3 +1625,4 @@ BOOL SceneBuilder::BuildSceneStat() xr_string dest_name = MakeLevelPath(LEVEL_DI_TEX_NAME); return l_scene_stat->flush(dest_name.c_str()); } + diff --git a/src/editors/LevelEditor/Edit/Cursor3D.cpp b/src/editors/LevelEditor/Edit/Cursor3D.cpp index fb9764e6a55..40bcbad9ed7 100644 --- a/src/editors/LevelEditor/Edit/Cursor3D.cpp +++ b/src/editors/LevelEditor/Edit/Cursor3D.cpp @@ -4,16 +4,17 @@ #include "Cursor3D.h" #include "scene.h" -#include "sceneobject.h" -#include "ui_levelmain.h" -#include "../ECore/Editor/d3dUtils.h" +#include "SceneObject.h" +#include "UI_LevelMain.h" +#include "editors/ECore/Editor/d3dUtils.h" //--------------------------------------------------------------------------- -static WORD CrossIndices[4]={0,2,1,3}; +static WORD CrossIndices[4] = {0,2,1,3}; #pragma package(smart_init) -C3DCursor::C3DCursor(){ +C3DCursor::C3DCursor() +{ m_Visible = false; brush_radius = 1.f; brush_up_depth = 1.f; @@ -21,126 +22,159 @@ C3DCursor::C3DCursor(){ SetBrushSegment(); eStyle = csLasso; } + //--------------------------------------------------------------------------- -C3DCursor::~C3DCursor(){ +C3DCursor::~C3DCursor() +{ m_RenderBuffer.clear(); } + //--------------------------------------------------------------------------- -void C3DCursor::SetBrushSegment(float segment){ +void C3DCursor::SetBrushSegment(float segment) +{ m_RenderBuffer.resize(segment); d_angle = float(PI_MUL_2)/float(segment); } + //--------------------------------------------------------------------------- -void C3DCursor::SetColor(Fcolor& c){ - dwColor = c.get(); +void C3DCursor::SetColor(Fcolor &c) +{ + dwColor = c.get(); } + //--------------------------------------------------------------------------- -void C3DCursor::GetPickPoint (Fvector& src, Fvector& dst, Fvector* N) +void C3DCursor::GetPickPoint(Fvector &src, Fvector &dst, Fvector *N) { Fvector start; SRayPickInfo pinf; - start.set(src); start.y+=brush_up_depth; + start.set(src); + start.y += brush_up_depth; pinf.inf.range = brush_up_depth+brush_dn_depth; pinf.pt.set(src); Fvector pick_dir; - pick_dir.set(0,-1,0); - if(Scene->RayPickObject(pinf.inf.range, start, pick_dir, OBJCLASS_SCENEOBJECT, &pinf, Scene->GetSnapList(false))){ + pick_dir.set(0, -1, 0); + if (Scene->RayPickObject(pinf.inf.range, start, pick_dir, OBJCLASS_SCENEOBJECT, &pinf, Scene->GetSnapList(false))) + { dst.set(pinf.pt); - if (N){ - Fvector verts[3]; - pinf.e_obj->GetFaceWorld(pinf.s_obj->_Transform(),pinf.e_mesh,pinf.inf.id,verts); - N->mknormal(verts[0], verts[1], verts[2]); + if (N) + { + Fvector verts[3]; + pinf.e_obj->GetFaceWorld(pinf.s_obj->_Transform(), pinf.e_mesh, pinf.inf.id, verts); + N->mknormal(verts[0], verts[1], verts[2]); } - }else{ + } + else + { dst.set(src); - if (N) N->set(0,1,0); + if (N) + N->set(0, 1, 0); } } + //--------------------------------------------------------------------------- -void C3DCursor::Render(){ - if (m_Visible&&!EDevice.m_Camera.IsMoving()){ +void C3DCursor::Render() +{ + if (m_Visible&&!EDevice.m_Camera.IsMoving()) + { SRayPickInfo pinf; Fvector start, dir, N, D; POINT start_pt; Ivector2 pt; - GetCursorPos(&start_pt); - start_pt=UI->GetD3DWindow()->ScreenToClient(start_pt); - pt.set(float(start_pt.x),float(start_pt.y)); - EDevice.m_Camera.MouseRayFromPoint(start,dir,pt); - if (LUI->PickGround(pinf.pt,start,dir, -1)){ - N.set(0,1,0); - D.set(0,0,1); - - switch (eStyle){ - case csLasso:{ - Fmatrix m_ViewMat; - Fvector at; - at.sub(pinf.pt, N); - m_ViewMat.build_camera (pinf.pt, at, D); - m_ViewMat.invert (); - Fvector p; - float s_a = 0; - for (u32 idx=0; idxGetD3DWindow()->ScreenToClient(start_pt); + pt.set(float(start_pt.x), float(start_pt.y)); + EDevice.m_Camera.MouseRayFromPoint(start, dir, pt); + if (LUI->PickGround(pinf.pt, start, dir, -1)) + { + N.set(0, 1, 0); + D.set(0, 0, 1); + + switch (eStyle) + { + case csLasso: + { + Fmatrix m_ViewMat; + Fvector at; + at.sub(pinf.pt, N); + m_ViewMat.build_camera(pinf.pt, at, D); + m_ViewMat.invert(); + Fvector p; + float s_a = 0; + for (u32 idx = 0; idxD3D_RenderNearer(0.0001); - RCache.set_xform_world(Fidentity); - EDevice.SetShader(EDevice.m_WireShader); - DU_impl.DrawPrimitiveL(D3DPT_LINESTRIP,m_RenderBuffer.size(),m_RenderBuffer.begin(),m_RenderBuffer.size(),dwColor,true,true); -// UI->D3D_ResetNearer(); - }break; - case csPoint:{ - FVF::TL pt[5]; - pt[0].transform(pinf.pt,EDevice.mFullTransform); - pt[0].color = dwColor; - pt[0].p.x = EDevice._x2real(pt[0].p.x); - pt[0].p.y = EDevice._y2real(pt[0].p.y); - pt[1].set(pt[0].p.x-1,pt[0].p.y ,pt[0].p.z,pt[0].p.w,dwColor,0,0); - pt[2].set(pt[0].p.x+1,pt[0].p.y ,pt[0].p.z,pt[0].p.w,dwColor,0,0); - pt[3].set(pt[0].p.x ,pt[0].p.y-1,pt[0].p.z,pt[0].p.w,dwColor,0,0); - pt[4].set(pt[0].p.x ,pt[0].p.y+1,pt[0].p.z,pt[0].p.w,dwColor,0,0); - EDevice.RenderNearer(0.001); - RCache.set_xform_world(Fidentity); - EDevice.SetShader(EDevice.m_WireShader); - DU_impl.DrawPrimitiveTL(D3DPT_POINTLIST,5,pt,5,true,true); - EDevice.ResetNearer(); - }break; + // UI->D3D_RenderNearer(0.0001); + RCache.set_xform_world(Fidentity); + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawPrimitiveL(D3DPT_LINESTRIP, m_RenderBuffer.size(), m_RenderBuffer.begin(), m_RenderBuffer.size(), dwColor, true, true); + // UI->D3D_ResetNearer(); + } + break; + case csPoint: + { + FVF::TL pt[5]; + pt[0].transform(pinf.pt, EDevice.mFullTransform); + pt[0].color = dwColor; + pt[0].p.x = EDevice._x2real(pt[0].p.x); + pt[0].p.y = EDevice._y2real(pt[0].p.y); + pt[1].set(pt[0].p.x-1, pt[0].p.y, pt[0].p.z, pt[0].p.w, dwColor, 0, 0); + pt[2].set(pt[0].p.x+1, pt[0].p.y, pt[0].p.z, pt[0].p.w, dwColor, 0, 0); + pt[3].set(pt[0].p.x, pt[0].p.y-1, pt[0].p.z, pt[0].p.w, dwColor, 0, 0); + pt[4].set(pt[0].p.x, pt[0].p.y+1, pt[0].p.z, pt[0].p.w, dwColor, 0, 0); + EDevice.RenderNearer(0.001); + RCache.set_xform_world(Fidentity); + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawPrimitiveTL(D3DPT_POINTLIST, 5, pt, 5, true, true); + EDevice.ResetNearer(); + } + break; } } } } + //--------------------------------------------------------------------------- -bool C3DCursor::PrepareBrush(){ +bool C3DCursor::PrepareBrush() +{ SRayPickInfo pinf; bool bPickObject, bPickGround; Fvector N, D; POINT start_pt; Ivector2 pt; - GetCursorPos(&start_pt); start_pt=UI->GetD3DWindow()->ScreenToClient(start_pt); - pt.set(iFloor(start_pt.x),iFloor(start_pt.y)); - EDevice.m_Camera.MouseRayFromPoint(brush_start,brush_dir,pt); - bPickObject = !!Scene->RayPickObject(pinf.inf.range,brush_start, brush_dir, OBJCLASS_SCENEOBJECT, &pinf, Scene->GetSnapList(false)); - if (!bPickObject) bPickGround = LUI->PickGround(pinf.pt, brush_start, brush_dir); - if (bPickObject||bPickGround){ - N.set(0,1,0); D.set(0,0,1); - Fvector at; at.sub(pinf.pt, N); - brush_mat.build_camera(pinf.pt, at, D); brush_mat.invert(); + GetCursorPos(&start_pt); + start_pt = UI->GetD3DWindow()->ScreenToClient(start_pt); + pt.set(iFloor(start_pt.x), iFloor(start_pt.y)); + EDevice.m_Camera.MouseRayFromPoint(brush_start, brush_dir, pt); + bPickObject = !!Scene->RayPickObject(pinf.inf.range, brush_start, brush_dir, OBJCLASS_SCENEOBJECT, &pinf, Scene->GetSnapList(false)); + if (!bPickObject) + bPickGround = LUI->PickGround(pinf.pt, brush_start, brush_dir); + if (bPickObject||bPickGround) + { + N.set(0, 1, 0); + D.set(0, 0, 1); + Fvector at; + at.sub(pinf.pt, N); + brush_mat.build_camera(pinf.pt, at, D); + brush_mat.invert(); return true; } return false; } + //--------------------------------------------------------------------------- -void C3DCursor::GetRandomBrushPos(Fvector& pos, Fvector& norm){ +void C3DCursor::GetRandomBrushPos(Fvector &pos, Fvector &norm) +{ Fvector p, start, dir; SRayPickInfo pinf; float s_a = Random.randF(PI_MUL_2); @@ -149,4 +183,7 @@ void C3DCursor::GetRandomBrushPos(Fvector& pos, Fvector& norm){ brush_mat.transform(p); GetPickPoint(p, pos, &norm); } + //--------------------------------------------------------------------------- + + diff --git a/src/editors/LevelEditor/Edit/Cursor3D.h b/src/editors/LevelEditor/Edit/Cursor3D.h index a76665ff60c..35de703edac 100644 --- a/src/editors/LevelEditor/Edit/Cursor3D.h +++ b/src/editors/LevelEditor/Edit/Cursor3D.h @@ -4,38 +4,62 @@ //--------------------------------------------------------------------------- #define CURSOR_PRECISION_SEGMENT 16 -enum ECursorStyle{ - csLasso, +enum ECursorStyle +{ + csLasso, csPoint }; -class C3DCursor{ - float d_angle; - u32 dwColor; +class C3DCursor +{ + float d_angle; + u32 dwColor; FvectorVec m_RenderBuffer; Fvector brush_start, brush_dir; Fmatrix brush_mat; - float brush_radius; - float brush_up_depth, brush_dn_depth; + float brush_radius; + float brush_up_depth, brush_dn_depth; - bool m_Visible; - void GetPickPoint (Fvector& src, Fvector& dst, Fvector* N); + bool m_Visible; + void GetPickPoint(Fvector &src, Fvector &dst, Fvector *N); ECursorStyle eStyle; public: - C3DCursor (); - virtual ~C3DCursor (); - void SetBrushSegment(float segment=CURSOR_PRECISION_SEGMENT); - void Render (); - bool GetVisible (){return m_Visible;} - - float GetBrushSize(){return brush_radius;} - void SetBrushRadius(float r){brush_radius=r;} - void SetBrushDepth(float up_d, float dn_d){brush_up_depth=up_d;brush_dn_depth=dn_d;} - void SetColor (Fcolor& c); - bool PrepareBrush(); - void GetRandomBrushPos(Fvector& pos, Fvector& norm); -//. void Visible (bool b){m_Visible = b;} - void Style (ECursorStyle st){eStyle=st;} + C3DCursor(); + virtual ~C3DCursor(); + void SetBrushSegment(float segment = CURSOR_PRECISION_SEGMENT); + void Render(); + + bool GetVisible() + { + return m_Visible; + } + + float GetBrushSize() + { + return brush_radius; + } + + void SetBrushRadius(float r) + { + brush_radius = r; + } + + void SetBrushDepth(float up_d, float dn_d) + { + brush_up_depth = up_d; + brush_dn_depth = dn_d; + } + + void SetColor(Fcolor &c); + bool PrepareBrush(); + void GetRandomBrushPos(Fvector &pos, Fvector &norm); + + //. void Visible (bool b){m_Visible = b;} + void Style(ECursorStyle st) + { + eStyle = st; + } }; #endif + diff --git a/src/editors/LevelEditor/Edit/Custom2DProjector.cpp b/src/editors/LevelEditor/Edit/Custom2DProjector.cpp index 53ce8cc7f04..0d4a9ef4d2d 100644 --- a/src/editors/LevelEditor/Edit/Custom2DProjector.cpp +++ b/src/editors/LevelEditor/Edit/Custom2DProjector.cpp @@ -3,10 +3,10 @@ #pragma hdrstop #include "Custom2DProjector.h" -#include "../ECore/Editor/ImageManager.h" +#include "editors/ECore/Editor/ImageManager.h" #include "SceneObject.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditMesh.h" //------------------------------------------------------------------------------ // SBase @@ -15,93 +15,103 @@ CCustom2DProjector::CCustom2DProjector() { - name = ""; - shader_overlap = 0; - shader_blended = 0; + name = ""; + shader_overlap = 0; + shader_blended = 0; } bool CCustom2DProjector::LoadImage(LPCSTR nm) { - name = nm; - ImageLib.LoadTextureData(*name,data,w,h); + name = nm; + ImageLib.LoadTextureData(*name, data, w, h); return Valid(); } -void CCustom2DProjector::CreateRMFromObjects(const Fbox& box, ObjectList& lst) +void CCustom2DProjector::CreateRMFromObjects(const Fbox &box, ObjectList &lst) { - geom.destroy(); - mesh.clear (); - for (ObjectIt it=lst.begin(); it!=lst.end(); it++){ - CSceneObject* S = (CSceneObject*)(*it); - CEditableObject* O = S->GetReference(); VERIFY(O); + geom.destroy(); + mesh.clear(); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + { + CSceneObject *S = (CSceneObject*)(*it); + CEditableObject *O = S->GetReference(); + VERIFY(O); - Fmatrix T; S->GetFullTransformToWorld(T); - mesh.reserve (mesh.size()+S->GetFaceCount()*3); - for (EditMeshIt m_it=O->FirstMesh(); m_it!=O->LastMesh(); m_it++){ - for (u32 f_id=0; f_id!=(*m_it)->GetFCount(); f_id++){ - FVF::V v; - for (int k=0; k<3; k++){ - T.transform_tiny(v.p,(*m_it)->GetVertices()[(*m_it)->GetFaces()[f_id].pv[k].pindex]); - v.t.x = GetUFromX(v.p.x,box); - v.t.y = GetVFromZ(v.p.z,box); + Fmatrix T; + S->GetFullTransformToWorld(T); + mesh.reserve(mesh.size()+S->GetFaceCount()*3); + for (EditMeshIt m_it = O->FirstMesh(); m_it!=O->LastMesh(); m_it++) + { + for (u32 f_id = 0; f_id!=(*m_it)->GetFCount(); f_id++) + { + FVF::V v; + for (int k = 0; k<3; k++) + { + T.transform_tiny(v.p, (*m_it)->GetVertices()[(*m_it)->GetFaces()[f_id].pv[k].pindex]); + v.t.x = GetUFromX(v.p.x, box); + v.t.y = GetVFromZ(v.p.z, box); mesh.push_back(v); } } } } - geom.create(FVF::F_V,RCache.Vertex.Buffer(),0); + geom.create(FVF::F_V, RCache.Vertex.Buffer(), 0); } void CCustom2DProjector::Render(bool blended) { - if (!Valid()) return; + if (!Valid()) + return; EDevice.RenderNearer(0.001f); - RCache.set_xform_world(Fidentity); - EDevice.SetShader (blended?shader_blended:shader_overlap); - div_t cnt = div(mesh.size(),MAX_BUF_SIZE); + RCache.set_xform_world(Fidentity); + EDevice.SetShader(blended ? shader_blended : shader_overlap); + div_t cnt = div(mesh.size(),MAX_BUF_SIZE); u32 vBase; - _VertexStream* Stream = &RCache.Vertex; - for (int k=0; kLock(MAX_BUF_SIZE,geom->vb_stride,vBase); - CopyMemory (pv,mesh.begin()+k*MAX_BUF_SIZE,sizeof(FVF::V)*MAX_BUF_SIZE); - Stream->Unlock (MAX_BUF_SIZE,geom->vb_stride); - EDevice.DP (D3DPT_TRIANGLELIST,geom,vBase,MAX_BUF_SIZE/3); + _VertexStream *Stream = &RCache.Vertex; + for (int k = 0; kLock(MAX_BUF_SIZE, geom->vb_stride, vBase); + CopyMemory(pv, mesh.begin()+k*MAX_BUF_SIZE, sizeof(FVF::V)*MAX_BUF_SIZE); + Stream->Unlock(MAX_BUF_SIZE, geom->vb_stride); + EDevice.DP(D3DPT_TRIANGLELIST, geom, vBase,MAX_BUF_SIZE/3); } - if (cnt.rem){ - FVF::V* pv = (FVF::V*)Stream->Lock(cnt.rem,geom->vb_stride,vBase); - CopyMemory (pv,mesh.begin()+cnt.quot*MAX_BUF_SIZE,sizeof(FVF::V)*cnt.rem); - Stream->Unlock (cnt.rem,geom->vb_stride); - EDevice.DP (D3DPT_TRIANGLELIST,geom,vBase,cnt.rem/3); + if (cnt.rem) + { + FVF::V *pv = (FVF::V*)Stream->Lock(cnt.rem, geom->vb_stride, vBase); + CopyMemory(pv, mesh.begin()+cnt.quot*MAX_BUF_SIZE, sizeof(FVF::V)*cnt.rem); + Stream->Unlock(cnt.rem, geom->vb_stride); + EDevice.DP(D3DPT_TRIANGLELIST, geom, vBase, cnt.rem/3); } - EDevice.ResetNearer (); + EDevice.ResetNearer(); } void CCustom2DProjector::CreateShader() { - DestroyShader (); - if (Valid()){ - shader_blended.create ("editor\\do_base",*name); - shader_overlap.create ("default",*name); - geom.create (FVF::F_V,RCache.Vertex.Buffer(),0); - } + DestroyShader(); + if (Valid()) + { + shader_blended.create("editor\\do_base", *name); + shader_overlap.create("default", *name); + geom.create(FVF::F_V, RCache.Vertex.Buffer(), 0); + } } void CCustom2DProjector::DestroyShader() { - geom.destroy(); - shader_blended.destroy(); - shader_overlap.destroy(); + geom.destroy(); + shader_blended.destroy(); + shader_overlap.destroy(); } -void CCustom2DProjector::OnImageChange (PropValue* prop) +void CCustom2DProjector::OnImageChange(PropValue *prop) { - LoadImage (*name); - DestroyShader (); - CreateShader (); + LoadImage(*name); + DestroyShader(); + CreateShader(); } void CCustom2DProjector::ReloadImage() { - LoadImage (*name); + LoadImage(*name); } diff --git a/src/editors/LevelEditor/Edit/Custom2DProjector.h b/src/editors/LevelEditor/Edit/Custom2DProjector.h index 0d3a44a2f08..0d0af395f03 100644 --- a/src/editors/LevelEditor/Edit/Custom2DProjector.h +++ b/src/editors/LevelEditor/Edit/Custom2DProjector.h @@ -4,54 +4,104 @@ #include "ESceneClassList.h" -class CCustom2DProjector{ +class CCustom2DProjector +{ protected: - ref_shader shader_blended; - ref_shader shader_overlap; - u32 w; - u32 h; - U32Vec data; - DEFINE_VECTOR (FVF::V,TVertVec,TVertIt); - TVertVec mesh; - ref_geom geom; + ref_shader shader_blended; + ref_shader shader_overlap; + u32 w; + u32 h; + U32Vec data; + DEFINE_VECTOR(FVF::V, TVertVec, TVertIt); + TVertVec mesh; + ref_geom geom; public: - void __stdcall OnImageChange (PropValue* prop); + void __stdcall OnImageChange(PropValue *prop); public: - shared_str name; + shared_str name; public: - CCustom2DProjector (); - IC bool Valid (){return (w>0)&&(h>0)&&(!!data.size());} - IC void Clear (){name=""; w=0; h=0; geom=0; data.clear(); mesh.clear(); DestroyShader();} - bool LoadImage (LPCSTR nm); - void ReloadImage (); - void CreateRMFromObjects (const Fbox& box, ObjectList& lst); - void Render (bool blended); - void CreateShader (); - void DestroyShader (); - IC LPCSTR GetName (){ return *name; } - IC bool GetColor (u32& color, int U, int V){ - if (Valid()&&(U<(int)w)&&(V<(int)h)){ - color = data[V*w+U]; + CCustom2DProjector(); + IC + + bool Valid() + { + return (w>0)&&(h>0)&&(!!data.size()); + } + + IC + + void Clear() + { + name = ""; + w = 0; + h = 0; + geom = 0; + data.clear(); + mesh.clear(); + DestroyShader(); + } + + bool LoadImage(LPCSTR nm); + void ReloadImage(); + void CreateRMFromObjects(const Fbox &box, ObjectList &lst); + void Render(bool blended); + void CreateShader(); + void DestroyShader(); + + IC LPCSTR GetName() + { + return *name; + } + + IC + + bool GetColor(u32 &color, int U, int V) + { + if (Valid()&&(U<(int)w)&&(V<(int)h)) + { + color = data[V*w+U]; return true; } return false; } - IC float GetUFromX (float x, const Fbox& box){ + + IC + + float GetUFromX(float x, const Fbox &box) + { R_ASSERT(Valid()); - return (x-box.min.x)/(box.max.x-box.min.x); + return (x-box.min.x)/(box.max.x-box.min.x); } - IC int GetPixelUFromX (float x, const Fbox& box){ - int U = iFloor(GetUFromX(x,box)*(w-1)+0.5f); if (U<0) U=0; + + IC + + int GetPixelUFromX(float x, const Fbox &box) + { + int U = iFloor(GetUFromX(x, box)*(w-1)+0.5f); + if (U<0) + U = 0; return U; } - IC float GetVFromZ (float z, const Fbox& box){ + + IC + + float GetVFromZ(float z, const Fbox &box) + { R_ASSERT(Valid()); - return 1.f-(z-box.min.z)/(box.max.z-box.min.z); + return 1.f-(z-box.min.z)/(box.max.z-box.min.z); } - IC int GetPixelVFromZ (float z, const Fbox& box){ - int V = iFloor(GetVFromZ(z,box)*(h-1)+0.5f); if (V<0) V=0; + + IC + + int GetPixelVFromZ(float z, const Fbox &box) + { + int V = iFloor(GetVFromZ(z, box)*(h-1)+0.5f); + if (V<0) + V = 0; return V; } }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/CustomObject.cpp b/src/editors/LevelEditor/Edit/CustomObject.cpp index d71d0394d11..7e881356f72 100644 --- a/src/editors/LevelEditor/Edit/CustomObject.cpp +++ b/src/editors/LevelEditor/Edit/CustomObject.cpp @@ -5,9 +5,9 @@ #include "stdafx.h" #pragma hdrstop -#include "customobject.h" +#include "CustomObject.h" #include "UI_LevelMain.h" -#include "../ECore/Editor/D3DUtils.h" +#include "editors/ECore/Editor/D3DUtils.h" #include "motion.h" #include "ESceneCustomOTools.h" @@ -19,263 +19,279 @@ #define CUSTOMOBJECT_CHUNK_FLAGS 0xF906 #define CUSTOMOBJECT_CHUNK_NAME 0xF907 #define CUSTOMOBJECT_CHUNK_MOTION_PARAM 0xF908 + //---------------------------------------------------- CCustomObject::CCustomObject(LPVOID data, LPCSTR name) { - save_id = 0; - ClassID = OBJCLASS_DUMMY; - ParentTool = 0; - if (name) FName = name; - m_CO_Flags.assign (0); - m_RT_Flags.assign (flRT_Valid|flRT_Visible); - m_pOwnerObject = 0; - ResetTransform (); - m_RT_Flags.set (flRT_UpdateTransform,TRUE); - m_Motion = NULL; - m_MotionParams = NULL; - - FPosition.set (0,0,0); - FScale.set (1,1,1); - FRotation.set (0,0,0); + save_id = 0; + ClassID = OBJCLASS_DUMMY; + ParentTool = 0; + if (name) + FName = name; + m_CO_Flags.assign(0); + m_RT_Flags.assign(flRT_Valid|flRT_Visible); + m_pOwnerObject = 0; + ResetTransform(); + m_RT_Flags.set(flRT_UpdateTransform, TRUE); + m_Motion = NULL; + m_MotionParams = NULL; + + FPosition.set(0, 0, 0); + FScale.set(1, 1, 1); + FRotation.set(0, 0, 0); } CCustomObject::~CCustomObject() { - xr_delete (m_Motion); - xr_delete (m_MotionParams); + xr_delete(m_Motion); + xr_delete(m_MotionParams); } bool CCustomObject::IsRender() { - Fbox bb; GetBox(bb); - return ::Render->occ_visible(bb)||( Selected() && m_CO_Flags.is_any(flRenderAnyWayIfSelected|flMotion) ); + Fbox bb; + GetBox(bb); + return ::Render->occ_visible(bb)||(Selected()&&m_CO_Flags.is_any(flRenderAnyWayIfSelected|flMotion)); } void CCustomObject::OnUpdateTransform() { - - m_RT_Flags.set (flRT_UpdateTransform,FALSE); + m_RT_Flags.set(flRT_UpdateTransform, FALSE); // update transform matrix - FTransformR.setXYZi (-PRotation.x, -PRotation.y, -PRotation.z); - - FTransformS.scale (PScale); - FTransformP.translate (PPosition); - FTransformRP.mul (FTransformP,FTransformR); - FTransform.mul (FTransformRP,FTransformS); - FITransformRP.invert (FTransformRP); - FITransform.invert (FTransform); + FTransformR.setXYZi(-PRotation.x, -PRotation.y, -PRotation.z); - if (Motionable()&&Visible()&&Selected()&&m_CO_Flags.is(flAutoKey)) AnimationCreateKey(m_MotionParams->Frame()); + FTransformS.scale(PScale); + FTransformP.translate(PPosition); + FTransformRP.mul(FTransformP, FTransformR); + FTransform.mul(FTransformRP, FTransformS); + FITransformRP.invert(FTransformRP); + FITransform.invert(FTransform); + + if (Motionable()&&Visible()&&Selected()&&m_CO_Flags.is(flAutoKey)) + AnimationCreateKey(m_MotionParams->Frame()); } -void CCustomObject::Select( int flag ) +void CCustomObject::Select(int flag) { - if (m_RT_Flags.is(flRT_Visible) && (!!m_RT_Flags.is(flRT_Selected)!=flag)) + if (m_RT_Flags.is(flRT_Visible)&&(!!m_RT_Flags.is(flRT_Selected)!=flag)) { - m_RT_Flags.set (flRT_Selected,(flag==-1)?(m_RT_Flags.is(flRT_Selected)?FALSE:TRUE):flag); - UI->RedrawScene (); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - ParentTool->OnSelected(this); + m_RT_Flags.set(flRT_Selected, (flag==-1) ? (m_RT_Flags.is(flRT_Selected) ? FALSE : TRUE) : flag); + UI->RedrawScene(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + ParentTool->OnSelected(this); } } -void CCustomObject::Show( BOOL flag ) +void CCustomObject::Show(BOOL flag) { - m_RT_Flags.set (flRT_Visible,flag); + m_RT_Flags.set(flRT_Visible, flag); + + if (!m_RT_Flags.is(flRT_Visible)) + m_RT_Flags.set(flRT_Selected, FALSE); - if (!m_RT_Flags.is(flRT_Visible)) - m_RT_Flags.set(flRT_Selected, FALSE); - UI->RedrawScene(); }; -BOOL CCustomObject::Editable() const +BOOL CCustomObject::Editable() const { - BOOL b1 = m_CO_Flags.is(flObjectInGroup); + BOOL b1 = m_CO_Flags.is(flObjectInGroup); BOOL b2 = m_CO_Flags.is(flObjectInGroupUnique); - return !b1 || (b1&&b2); + return !b1||(b1&&b2); } -bool CCustomObject::LoadLTX(CInifile& ini, LPCSTR sect_name) +bool CCustomObject::LoadLTX(CInifile &ini, LPCSTR sect_name) { - m_CO_Flags.assign (ini.r_u32(sect_name, "co_flags") ); + m_CO_Flags.assign(ini.r_u32(sect_name, "co_flags")); - FName = ini.r_string(sect_name, "name"); - FPosition = ini.r_fvector3 (sect_name, "position"); - VERIFY2 (_valid(FPosition), sect_name); - FRotation = ini.r_fvector3 (sect_name, "rotation"); - VERIFY2 (_valid(FRotation), sect_name); - FScale = ini.r_fvector3 (sect_name, "scale"); - VERIFY2 (_valid(FScale), sect_name); + FName = ini.r_string(sect_name, "name"); + FPosition = ini.r_fvector3(sect_name, "position"); + VERIFY2(_valid(FPosition), sect_name); + FRotation = ini.r_fvector3(sect_name, "rotation"); + VERIFY2(_valid(FRotation), sect_name); + FScale = ini.r_fvector3(sect_name, "scale"); + VERIFY2(_valid(FScale), sect_name); // object motion if (m_CO_Flags.is(flMotion)) { - m_CO_Flags.set(flMotion, FALSE); -// R_ASSERT (0); -/* - VERIFY (m_Motion); - F.open_chunk (CUSTOMOBJECT_CHUNK_MOTION); - m_Motion->Save (F); - F.close_chunk (); - */ -// m_MotionParams->t_current = ini.r_float (sect_name, "motion_params_t"); + m_CO_Flags.set(flMotion, FALSE); + // R_ASSERT (0); + /* + VERIFY (m_Motion); + F.open_chunk(CUSTOMOBJECT_CHUNK_MOTION); + m_Motion->Save(F); + F.close_chunk(); + */ + // m_MotionParams->t_current = ini.r_float (sect_name, "motion_params_t"); } - LUI->restore_rt_flags (this); - return true; + LUI->restore_rt_flags(this); + return true; } -bool CCustomObject::LoadStream(IReader& F) +bool CCustomObject::LoadStream(IReader &F) { R_ASSERT(F.find_chunk(CUSTOMOBJECT_CHUNK_FLAGS)); { m_CO_Flags.assign(F.r_u32()); - + R_ASSERT(F.find_chunk(CUSTOMOBJECT_CHUNK_NAME)); - F.r_stringZ (FName); + F.r_stringZ(FName); } - if(F.find_chunk(CUSTOMOBJECT_CHUNK_TRANSFORM)) + if (F.find_chunk(CUSTOMOBJECT_CHUNK_TRANSFORM)) { F.r_fvector3(FPosition); F.r_fvector3(FRotation); - VERIFY(_valid(FRotation)); + VERIFY(_valid(FRotation)); F.r_fvector3(FScale); } // object motion if (F.find_chunk(CUSTOMOBJECT_CHUNK_MOTION)) { - m_Motion = xr_new(); - if (!m_Motion->Load(F)){ - ELog.Msg(mtError,"CustomObject: '%s' - motion has different version. Load failed.",Name); + m_Motion = xr_new(); + if (!m_Motion->Load(F)) + { + ELog.Msg(mtError, "CustomObject: '%s' - motion has different version. Load failed.", Name); xr_delete(m_Motion); } m_MotionParams = xr_new(); - m_MotionParams->Set(m_Motion); + m_MotionParams->Set(m_Motion); AnimationUpdate(m_MotionParams->Frame()); } - if (F.find_chunk(CUSTOMOBJECT_CHUNK_MOTION_PARAM)){ - m_MotionParams->t_current = F.r_float(); + if (F.find_chunk(CUSTOMOBJECT_CHUNK_MOTION_PARAM)) + { + m_MotionParams->t_current = F.r_float(); AnimationUpdate(m_MotionParams->Frame()); } - UpdateTransform (); + UpdateTransform(); - LUI->restore_rt_flags (this); - return true; + LUI->restore_rt_flags(this); + return true; } -void CCustomObject::SaveLTX(CInifile& ini, LPCSTR sect_name) +void CCustomObject::SaveLTX(CInifile &ini, LPCSTR sect_name) { - ini.w_u32 (sect_name, "co_flags", m_CO_Flags.get()); - - ini.w_string (sect_name, "name", FName.c_str()); - - ini.w_fvector3 (sect_name, "position", FPosition); - ini.w_fvector3 (sect_name, "rotation", FRotation); - ini.w_fvector3 (sect_name, "scale", FScale); - -/* - // object motion - if (m_CO_Flags.is(flMotion)) - { - R_ASSERT (0); - - VERIFY (m_Motion); - F.open_chunk (CUSTOMOBJECT_CHUNK_MOTION); - m_Motion->Save (F); - F.close_chunk (); - - ini.w_float (sect_name, "motion_params_t", m_MotionParams->t_current); - } -*/ - LUI->store_rt_flags (this); + ini.w_u32(sect_name, "co_flags", m_CO_Flags.get()); + + ini.w_string(sect_name, "name", FName.c_str()); + + ini.w_fvector3(sect_name, "position", FPosition); + ini.w_fvector3(sect_name, "rotation", FRotation); + ini.w_fvector3(sect_name, "scale", FScale); + + /* + // object motion + if (m_CO_Flags.is(flMotion)) + { + R_ASSERT (0); + + VERIFY (m_Motion); + F.open_chunk(CUSTOMOBJECT_CHUNK_MOTION); + m_Motion->Save(F); + F.close_chunk(); + + ini.w_float (sect_name, "motion_params_t", m_MotionParams->t_current); + } + */ + LUI->store_rt_flags(this); } -void CCustomObject::SaveStream(IWriter& F) +void CCustomObject::SaveStream(IWriter &F) { - F.open_chunk (CUSTOMOBJECT_CHUNK_FLAGS); - F.w_u32 (m_CO_Flags.get()); - F.close_chunk (); + F.open_chunk(CUSTOMOBJECT_CHUNK_FLAGS); + F.w_u32(m_CO_Flags.get()); + F.close_chunk(); - F.open_chunk (CUSTOMOBJECT_CHUNK_NAME); - F.w_stringZ (FName); - F.close_chunk (); + F.open_chunk(CUSTOMOBJECT_CHUNK_NAME); + F.w_stringZ(FName); + F.close_chunk(); - F.open_chunk (CUSTOMOBJECT_CHUNK_TRANSFORM); - F.w_fvector3 (FPosition); - F.w_fvector3 (FRotation); - F.w_fvector3 (FScale); - F.close_chunk (); + F.open_chunk(CUSTOMOBJECT_CHUNK_TRANSFORM); + F.w_fvector3(FPosition); + F.w_fvector3(FRotation); + F.w_fvector3(FScale); + F.close_chunk(); // object motion if (m_CO_Flags.is(flMotion)) { - VERIFY (m_Motion); - F.open_chunk (CUSTOMOBJECT_CHUNK_MOTION); - m_Motion->Save (F); - F.close_chunk (); - - F.open_chunk (CUSTOMOBJECT_CHUNK_MOTION_PARAM); - F.w_float (m_MotionParams->t_current); - F.close_chunk (); + VERIFY(m_Motion); + F.open_chunk(CUSTOMOBJECT_CHUNK_MOTION); + m_Motion->Save(F); + F.close_chunk(); + + F.open_chunk(CUSTOMOBJECT_CHUNK_MOTION_PARAM); + F.w_float(m_MotionParams->t_current); + F.close_chunk(); } - LUI->store_rt_flags (this); + LUI->store_rt_flags(this); } + //---------------------------------------------------- #include "ESceneCustomOTools.h" + void CCustomObject::OnFrame() { - if (m_Motion) AnimationOnFrame(); - if (m_RT_Flags.is(flRT_UpdateTransform)) OnUpdateTransform(); - if(m_CO_Flags.test(flObjectInGroup) && m_pOwnerObject==NULL) - m_CO_Flags.set(flObjectInGroup, FALSE); + if (m_Motion) + AnimationOnFrame(); + if (m_RT_Flags.is(flRT_UpdateTransform)) + OnUpdateTransform(); + if (m_CO_Flags.test(flObjectInGroup)&&m_pOwnerObject==NULL) + m_CO_Flags.set(flObjectInGroup, FALSE); } void CCustomObject::RenderRoot(int priority, bool strictB2F) { - if(FParentTools->IsVisible()) - Render(priority, strictB2F); + if (FParentTools->IsVisible()) + Render(priority, strictB2F); } void CCustomObject::Render(int priority, bool strictB2F) { - if ((1==priority)&&(false==strictB2F)){ - if (EPrefs->object_flags.is(epoDrawPivot)&&Selected()){ - DU_impl.DrawObjectAxis(FTransformRP,0.1f,Selected()); + if ((1==priority)&&(false==strictB2F)) + { + if (EPrefs->object_flags.is(epoDrawPivot)&&Selected()) + { + DU_impl.DrawObjectAxis(FTransformRP, 0.1f, Selected()); } if (m_Motion&&Visible()&&Selected()) AnimationDrawPath(); } } -bool CCustomObject::RaySelect(int flag, const Fvector& start, const Fvector& dir, bool bRayTest){ - float dist = UI->ZFar(); - if ((bRayTest&&RayPick(dist,start,dir))||!bRayTest){ - Select(flag); +bool CCustomObject::RaySelect(int flag, const Fvector &start, const Fvector &dir, bool bRayTest) +{ + float dist = UI->ZFar(); + if ((bRayTest&&RayPick(dist, start, dir))||!bRayTest) + { + Select(flag); return true; } return false; }; -bool CCustomObject::FrustumSelect(int flag, const CFrustum& frustum){ - if (FrustumPick(frustum)){ - Select(flag); +bool CCustomObject::FrustumSelect(int flag, const CFrustum &frustum) +{ + if (FrustumPick(frustum)) + { + Select(flag); return true; } - return false; + return false; }; -bool CCustomObject::GetSummaryInfo(SSceneSummary* inf) +bool CCustomObject::GetSummaryInfo(SSceneSummary *inf) { - Fbox bb; - if (GetBox(bb)){ + Fbox bb; + if (GetBox(bb)) + { inf->bbox.modify(bb.min); inf->bbox.modify(bb.max); } @@ -284,6 +300,6 @@ bool CCustomObject::GetSummaryInfo(SSceneSummary* inf) void CCustomObject::OnSynchronize() { - OnFrame (); + OnFrame(); } diff --git a/src/editors/LevelEditor/Edit/CustomObject.h b/src/editors/LevelEditor/Edit/CustomObject.h index ec76d7a6568..a4e222bf504 100644 --- a/src/editors/LevelEditor/Edit/CustomObject.h +++ b/src/editors/LevelEditor/Edit/CustomObject.h @@ -20,219 +20,226 @@ class SAnimParams; struct SSceneSummary; class ESceneCustomOTool; -struct SExportStreamItem{ - int chunk; - CMemoryWriter stream; - SExportStreamItem ():chunk(0){;} +struct SExportStreamItem +{ + int chunk; + CMemoryWriter stream; + + SExportStreamItem(): chunk(0) + { + ; + } }; -struct SExportStreams{ - SExportStreamItem spawn; - SExportStreamItem spawn_rs; - SExportStreamItem patrolpath; - SExportStreamItem rpoint; - SExportStreamItem sound_static; - SExportStreamItem sound_env_geom; - SExportStreamItem pe_static; - SExportStreamItem envmodif; - SExportStreamItem fog_vol; +struct SExportStreams +{ + SExportStreamItem spawn; + SExportStreamItem spawn_rs; + SExportStreamItem patrolpath; + SExportStreamItem rpoint; + SExportStreamItem sound_static; + SExportStreamItem sound_env_geom; + SExportStreamItem pe_static; + SExportStreamItem envmodif; + SExportStreamItem fog_vol; }; -class ECORE_API CCustomObject +class ECORE_API CCustomObject { - ObjClassID FClassID; - ESceneCustomOTool* FParentTools; + ObjClassID FClassID; + ESceneCustomOTool*FParentTools; - SAnimParams* m_MotionParams; - COMotion* m_Motion; + SAnimParams*m_MotionParams; + COMotion*m_Motion; // private animation methods - void AnimationOnFrame (); - void AnimationDrawPath (); - void AnimationCreateKey (float t); - void AnimationDeleteKey (float t); - void AnimationUpdate (float t); -public: - enum{ - flSelected_notused = (1<<0), - flVisible_notused = (1<<1), - flLocked_notused = (1<<2), - flMotion = (1<<3), - flRenderAnyWayIfSelected = (1<<4), - flObjectInGroup = (1<<5), - flObjectInGroupUnique = (1<<6), - - flAutoKey = (1<<30), - flCameraView = (1<<31), + void AnimationOnFrame(); + void AnimationDrawPath(); + void AnimationCreateKey(float t); + void AnimationDeleteKey(float t); + void AnimationUpdate(float t); + public: + enum{ + flSelected_notused = (1<<0), + flVisible_notused = (1<<1), + flLocked_notused = (1<<2), + flMotion = (1<<3), + flRenderAnyWayIfSelected = (1<<4), + flObjectInGroup = (1<<5), + flObjectInGroupUnique = (1<<6), + + flAutoKey = (1<<30), + flCameraView = (1<<31), }; - Flags32 m_CO_Flags; - - enum{ - flRT_Valid = (1<<0), - flRT_UpdateTransform= (1<<1), - flRT_NeedSelfDelete = (1<<2), - flRT_Selected = (1<<3), - flRT_Visible = (1<<4), - flRT_SelectedLast = (1<<5), - + Flags32 m_CO_Flags; + + enum{ + flRT_Valid = (1<<0), + flRT_UpdateTransform = (1<<1), + flRT_NeedSelfDelete = (1<<2), + flRT_Selected = (1<<3), + flRT_Visible = (1<<4), + flRT_SelectedLast = (1<<5), + }; - Flags32 m_RT_Flags; -public: - shared_str FName; - int save_id; + Flags32 m_RT_Flags; + public: + shared_str FName; + int save_id; // orientation - Fvector FPosition; - Fvector FScale; - Fvector FRotation; - Fmatrix FTransformP; - Fmatrix FTransformR; - Fmatrix FTransformS; - Fmatrix FTransformRP; - Fmatrix FTransform; - Fmatrix FITransformRP; - Fmatrix FITransform; - - CCustomObject* m_pOwnerObject; - bool __stdcall OnObjectNameAfterEdit (PropValue* sender, shared_str& edit_val); - void __stdcall OnTransformChange (PropValue* value); - void __stdcall OnMotionableChange (PropValue* sender); - void __stdcall OnMotionCommandsClick (ButtonValue* value, bool& bModif, bool& bSafe); - void __stdcall OnMotionFilesClick (ButtonValue* value, bool& bModif, bool& bSafe); - void __stdcall OnMotionControlClick (ButtonValue* value, bool& bModif, bool& bSafe); - void __stdcall OnMotionFrameChange (PropValue* value); - void __stdcall OnMotionKeyTimeChange (PropValue* value); - - void __stdcall OnMotionCurrentFrameChange(PropValue* value); - void __stdcall OnMotionCameraViewChange(PropValue* value); -protected: - LPCSTR GetName () const {return *FName; } - void SetName (LPCSTR N){string256 tmp; strcpy(tmp,N); strlwr(tmp); FName=tmp;} - - virtual const Fvector& GetPosition () const { return FPosition; } - virtual const Fvector& GetRotation () const { return FRotation; } - virtual const Fvector& GetScale () const { return FScale; } - - virtual void SetPosition (const Fvector& pos) { FPosition.set(pos); UpdateTransform();} - virtual void SetRotation (const Fvector& rot) { FRotation.set(rot); VERIFY(_valid(FRotation)); UpdateTransform();} - virtual void SetScale (const Fvector& scale) { FScale.set(scale); UpdateTransform();} - - void __stdcall OnNameChange (PropValue* sender); - void __stdcall OnChangeIngroupUnique(PropValue* sender); - - void __stdcall OnNumChangePosition (PropValue* sender); - void __stdcall OnNumChangeRotation (PropValue* sender); - void __stdcall OnNumChangeScale (PropValue* sender); - - virtual void DeleteThis (){m_RT_Flags.set(flRT_NeedSelfDelete,TRUE);} -public: - CCustomObject (LPVOID data, LPCSTR name); - virtual ~CCustomObject (); - - BOOL Editable () const ; - - IC BOOL Motionable ()const {return m_CO_Flags.is(flMotion); } - IC BOOL Visible ()const {return m_RT_Flags.is(flRT_Visible); } - IC BOOL Selected ()const {return m_RT_Flags.is(flRT_Selected);} - IC BOOL Valid ()const {return m_RT_Flags.is(flRT_Valid);} - IC BOOL IsDeleted ()const {return m_RT_Flags.is(flRT_NeedSelfDelete);} - - // editor integration - virtual bool Validate (bool bMsg){return true;} - virtual void FillProp (LPCSTR pref, PropItemVec& items); - void AnimationFillProp(LPCSTR pref, PropItemVec& items); - virtual bool GetSummaryInfo (SSceneSummary* inf); - - virtual void Select (int flag); - virtual void Show (BOOL flag); - void SetValid (BOOL flag) {m_RT_Flags.set(flRT_Valid,flag);} - void SetRenderIfSelected(BOOL flag){m_CO_Flags.set(flRenderAnyWayIfSelected,flag);} - - virtual bool IsRender (); - virtual void Render (int priority, bool strictB2F); - void RenderRoot (int priority, bool strictB2F); - virtual void OnFrame (); - virtual void OnUpdateTransform(); - - virtual void OnSceneRemove (){}; - - virtual bool RaySelect (int flag, const Fvector& start, const Fvector& dir, bool bRayTest=false); // flag 1,0,-1 (-1 invert) - virtual bool FrustumSelect (int flag, const CFrustum& frustum); - virtual bool RayPick (float& dist, const Fvector& start, const Fvector& dir, SRayPickInfo* pinf=NULL){ return false; }; - virtual bool FrustumPick (const CFrustum& frustum){ return false; }; - virtual bool SpherePick (const Fvector& center, float radius){ return false; }; - - void ResetTransform (){ - FScale.set (1,1,1); - FRotation.set (0,0,0); - FPosition.set (0,0,0); - FTransform.identity (); - FTransformRP.identity (); - FITransform.identity (); - FITransformRP.identity (); - } - virtual void ResetAnimation (bool upd_t=true){;} - virtual void UpdateTransform (bool bForced=false){m_RT_Flags.set(flRT_UpdateTransform,TRUE);if(bForced)OnUpdateTransform();} + Fvector FPosition; + Fvector FScale; + Fvector FRotation; + Fmatrix FTransformP; + Fmatrix FTransformR; + Fmatrix FTransformS; + Fmatrix FTransformRP; + Fmatrix FTransform; + Fmatrix FITransformRP; + Fmatrix FITransform; + + CCustomObject*m_pOwnerObject; + bool__stdcall OnObjectNameAfterEdit(PropValue*sender, shared_str&edit_val); + void__stdcall OnTransformChange(PropValue*value); + void__stdcall OnMotionableChange(PropValue*sender); + void__stdcall OnMotionCommandsClick(ButtonValue*value, bool& bModif, bool& bSafe); + void__stdcall OnMotionFilesClick(ButtonValue*value, bool& bModif, bool& bSafe); + void__stdcall OnMotionControlClick(ButtonValue*value, bool& bModif, bool& bSafe); + void__stdcall OnMotionFrameChange(PropValue*value); + void__stdcall OnMotionKeyTimeChange(PropValue*value); + + void__stdcall OnMotionCurrentFrameChange(PropValue*value); + void__stdcall OnMotionCameraViewChange(PropValue*value); + protected: + LPCSTR GetName() const{return *FName;} + void SetName(LPCSTR N){string256 tmp; strcpy(tmp, N); strlwr(tmp); FName = tmp;} + + virtual const Fvector&GetPosition() const{return FPosition;} + virtual const Fvector&GetRotation() const{return FRotation;} + virtual const Fvector&GetScale() const{return FScale;} + + virtual void SetPosition(const Fvector&pos){FPosition.set(pos); UpdateTransform();} + virtual void SetRotation(const Fvector&rot){FRotation.set(rot); VERIFY(_valid(FRotation)); UpdateTransform();} + virtual void SetScale(const Fvector&scale){FScale.set(scale); UpdateTransform();} + + void__stdcall OnNameChange(PropValue*sender); + void__stdcall OnChangeIngroupUnique(PropValue*sender); + + void__stdcall OnNumChangePosition(PropValue*sender); + void__stdcall OnNumChangeRotation(PropValue*sender); + void__stdcall OnNumChangeScale(PropValue*sender); + + virtual void DeleteThis(){m_RT_Flags.set(flRT_NeedSelfDelete, TRUE);} + public: + CCustomObject(LPVOID data, LPCSTR name); + virtual ~CCustomObject(); + + BOOL Editable() const; + + IC BOOL Motionable()const{return m_CO_Flags.is(flMotion);} + IC BOOL Visible()const{return m_RT_Flags.is(flRT_Visible);} + IC BOOL Selected()const{return m_RT_Flags.is(flRT_Selected);} + IC BOOL Valid()const{return m_RT_Flags.is(flRT_Valid);} + IC BOOL IsDeleted()const{return m_RT_Flags.is(flRT_NeedSelfDelete);} + + // editor integration + virtual bool Validate(bool bMsg){return true;} + virtual void FillProp(LPCSTR pref, PropItemVec&items); + void AnimationFillProp(LPCSTR pref, PropItemVec&items); + virtual bool GetSummaryInfo(SSceneSummary*inf); + + virtual void Select(int flag); + virtual void Show(BOOL flag); + void SetValid(BOOL flag){m_RT_Flags.set(flRT_Valid, flag);} + void SetRenderIfSelected(BOOL flag){m_CO_Flags.set(flRenderAnyWayIfSelected, flag);} + + virtual bool IsRender(); + virtual void Render(int priority, bool strictB2F); + void RenderRoot(int priority, bool strictB2F); + virtual void OnFrame(); + virtual void OnUpdateTransform(); + + virtual void OnSceneRemove(){}; + + virtual bool RaySelect(int flag, const Fvector&start, const Fvector&dir, bool bRayTest = false); // flag 1,0,-1 (-1 invert) + virtual bool FrustumSelect(int flag, const CFrustum&frustum); + virtual bool RayPick(float& dist, const Fvector&start, const Fvector&dir, SRayPickInfo*pinf = NULL){return false;}; + virtual bool FrustumPick(const CFrustum&frustum){return false;}; + virtual bool SpherePick(const Fvector¢er, float radius){return false;}; + + void ResetTransform(){ + FScale.set(1, 1, 1); + FRotation.set(0, 0, 0); + FPosition.set(0, 0, 0); + FTransform.identity(); + FTransformRP.identity(); + FITransform.identity(); + FITransformRP.identity(); + } + virtual void ResetAnimation(bool upd_t = true){;} + virtual void UpdateTransform(bool bForced = false){m_RT_Flags.set(flRT_UpdateTransform, TRUE);if(bForced)OnUpdateTransform();} // animation methods - + // grouping methods - virtual void OnDetach (); - virtual void OnAttach (CCustomObject* owner); - CCustomObject* GetOwner (){return m_pOwnerObject;} - virtual bool CanAttach ()=0; + virtual void OnDetach(); + virtual void OnAttach(CCustomObject*owner); + CCustomObject*GetOwner(){return m_pOwnerObject;} + virtual bool CanAttach() = 0; + + virtual bool OnChooseQuery(LPCSTR specific){return true;} - virtual bool OnChooseQuery (LPCSTR specific){return true;} - // change position/orientation methods - virtual void NumSetPosition (const Fvector& pos) { SetPosition(pos); } - virtual void NumSetRotation (const Fvector& rot) { SetRotation(rot); } - virtual void NumSetScale (const Fvector& scale) { SetScale(scale); } - virtual void MoveTo (const Fvector& pos, const Fvector& up); - virtual void Move (Fvector& amount); - virtual void RotateParent (Fvector& axis, float angle ); - virtual void RotateLocal (Fvector& axis, float angle ); - virtual void RotatePivot (const Fmatrix& prev_inv, const Fmatrix& current); - virtual void Scale (Fvector& amount); - virtual void ScalePivot (const Fmatrix& prev_inv, const Fmatrix& current, Fvector& amount); - - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); - - virtual bool ExportGame (SExportStreams* data){return true;} - - virtual bool GetBox (Fbox& box) const {return false;} - virtual bool GetUTBox (Fbox& box){return false;} - virtual void OnSceneUpdate (){;} - virtual void OnObjectRemove (const CCustomObject* object){;} - virtual bool OnSelectionRemove(){return true;} // âîçâðàùàåò ìîæíî ëè åãî óäàëÿòü âîîáùå - - virtual void OnDeviceCreate (){;} - virtual void OnDeviceDestroy (){;} - - virtual void OnSynchronize (); - virtual void OnShowHint (AStringVec& dest); - - virtual LPCSTR RefName (){return 0;} - - IC const Fmatrix& _ITransform (){return FITransform;} - IC const Fmatrix& _Transform (){return FTransform;} - IC const Fvector& _Position (){return FPosition;} - IC const Fvector& _Rotation (){return FRotation;} - IC const Fvector& _Scale (){return FScale;} - - PropertyGP(GetPosition,SetPosition) Fvector PPosition; - PropertyGP(GetRotation,SetRotation) Fvector PRotation; - PropertyGP(GetScale,SetScale) Fvector PScale; - - PropertyGP(FParentTools,FParentTools) ESceneCustomOTool* ParentTool; - PropertyGP(FClassID,FClassID) ObjClassID ClassID; - PropertyGP(GetName,SetName) LPCSTR Name; -public: - static void SnapMove (Fvector& pos, Fvector& rot, const Fmatrix& rotRP, const Fvector& amount); - static void NormalAlign (Fvector& rot, const Fvector& up, const Fvector& dir); + virtual void NumSetPosition(const Fvector&pos){SetPosition(pos);} + virtual void NumSetRotation(const Fvector&rot){SetRotation(rot);} + virtual void NumSetScale(const Fvector&scale){SetScale(scale);} + virtual void MoveTo(const Fvector&pos, const Fvector&up); + virtual void Move(Fvector&amount); + virtual void RotateParent(Fvector&axis, float angle); + virtual void RotateLocal(Fvector&axis, float angle); + virtual void RotatePivot(const Fmatrix&prev_inv, const Fmatrix¤t); + virtual void Scale(Fvector&amount); + virtual void ScalePivot(const Fmatrix&prev_inv, const Fmatrix¤t, Fvector&amount); + + virtual bool LoadStream(IReader&); + virtual bool LoadLTX(CInifile&ini, LPCSTR sect_name); + virtual void SaveStream(IWriter&); + virtual void SaveLTX(CInifile&ini, LPCSTR sect_name); + + virtual bool ExportGame(SExportStreams*data){return true;} + + virtual bool GetBox(Fbox&box) const{return false;} + virtual bool GetUTBox(Fbox&box){return false;} + virtual void OnSceneUpdate(){;} + virtual void OnObjectRemove(const CCustomObject*object){;} + virtual bool OnSelectionRemove(){return true;} // âîçâðàùàåò ìîæíî ëè åãî óäàëÿòü âîîáùå + + virtual void OnDeviceCreate(){;} + virtual void OnDeviceDestroy(){;} + + virtual void OnSynchronize(); + virtual void OnShowHint(AStringVec&dest); + + virtual LPCSTR RefName(){return 0;} + + IC const Fmatrix&_ITransform(){return FITransform;} + IC const Fmatrix&_Transform(){return FTransform;} + IC const Fvector&_Position(){return FPosition;} + IC const Fvector&_Rotation(){return FRotation;} + IC const Fvector&_Scale(){return FScale;} + + PropertyGP(GetPosition, SetPosition) Fvector PPosition; + PropertyGP(GetRotation, SetRotation) Fvector PRotation; + PropertyGP(GetScale, SetScale) Fvector PScale; + + PropertyGP(FParentTools, FParentTools) ESceneCustomOTool*ParentTool; + PropertyGP(FClassID, FClassID) ObjClassID ClassID; + PropertyGP(GetName, SetName) LPCSTR Name; + public: + static void SnapMove(Fvector&pos, Fvector&rot, const Fmatrix&rotRP, const Fvector&amount); + static void NormalAlign(Fvector&rot, const Fvector&up, const Fvector&dir); }; //---------------------------------------------------- #endif /* _INCDEF_CustomObject_H_ */ + diff --git a/src/editors/LevelEditor/Edit/CustomObjectAnimation.cpp b/src/editors/LevelEditor/Edit/CustomObjectAnimation.cpp index 9cd00872255..0f510b74805 100644 --- a/src/editors/LevelEditor/Edit/CustomObjectAnimation.cpp +++ b/src/editors/LevelEditor/Edit/CustomObjectAnimation.cpp @@ -1,28 +1,32 @@ #include "stdafx.h" #pragma hdrstop -#include "customobject.h" -#include "motion.h" -#include "envelope.h" -#include "../ECore/Editor/D3DUtils.h" -#include "../ECore/Editor/ui_main.h" +#include "CustomObject.h" +#include "xrCore/Animation/Motion.hpp" +#include "xrCore/Animation/Envelope.hpp" +#include "editors/ECore/Editor/D3DUtils.h" +#include "editors/ECore/Editor/ui_main.h" -void CCustomObject::OnMotionableChange(PropValue* sender) +void CCustomObject::OnMotionableChange(PropValue *sender) { - if (m_CO_Flags.is(flMotion)){ - m_Motion = xr_new(); - m_MotionParams = xr_new(); - }else{ - xr_delete (m_Motion); - xr_delete (m_MotionParams); + if (m_CO_Flags.is(flMotion)) + { + m_Motion = xr_new(); + m_MotionParams = xr_new(); + } + else + { + xr_delete(m_Motion); + xr_delete(m_MotionParams); } - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } void CCustomObject::AnimationCreateKey(float t) { - Fvector R; R.set(-PRotation.x,-PRotation.y,-PRotation.z); - m_Motion->CreateKey(t,PPosition,R); + Fvector R; + R.set(-PRotation.x, -PRotation.y, -PRotation.z); + m_Motion->CreateKey(t, PPosition, R); } void CCustomObject::AnimationDeleteKey(float t) @@ -33,38 +37,39 @@ void CCustomObject::AnimationDeleteKey(float t) //float speed = 0.f; void CCustomObject::AnimationUpdate(float t) { - Fvector R,P,r; - m_Motion->_Evaluate (t,P,r); - R.set (-r.x,-r.y,-r.z); + Fvector R, P, r; + m_Motion->_Evaluate(t, P, r); + R.set(-r.x, -r.y, -r.z); -// speed = speed*0.9f+(P.distance_to(PPosition)/EDevice.fTimeDelta)*0.1f; -// Log("speed: ",speed); - PPosition = P; - PRotation = R; - BOOL bAK = m_CO_Flags.is(flAutoKey); - m_CO_Flags.set (flAutoKey,FALSE); - UpdateTransform (true); - m_CO_Flags.set (flAutoKey,bAK); + // speed = speed*0.9f+(P.distance_to(PPosition)/EDevice.fTimeDelta)*0.1f; + // Log("speed: ",speed); + PPosition = P; + PRotation = R; + BOOL bAK = m_CO_Flags.is(flAutoKey); + m_CO_Flags.set(flAutoKey, FALSE); + UpdateTransform(true); + m_CO_Flags.set(flAutoKey, bAK); if (m_CO_Flags.is(flCameraView)) - EDevice.m_Camera.Set (-r.y,-r.x,-r.z,P.x,P.y,P.z); + EDevice.m_Camera.Set(-r.y, -r.x, -r.z, P.x, P.y, P.z); } void CCustomObject::AnimationOnFrame() { - VERIFY (m_Motion); + VERIFY(m_Motion); if (Selected()&&m_MotionParams->bPlay) { - AnimationUpdate (m_MotionParams->Frame()); - m_MotionParams->Update (EDevice.fTimeDelta,1.f,true); + AnimationUpdate(m_MotionParams->Frame()); + m_MotionParams->Update(EDevice.fTimeDelta, 1.f, true); } } static FvectorVec path_points; + void CCustomObject::AnimationDrawPath() { // motion path - VERIFY (m_Motion); + VERIFY(m_Motion); #ifdef _EDITOR if (EPrefs->object_flags.is(epoDrawAnimPath)){ float fps = m_Motion->FPS(); @@ -73,230 +78,266 @@ void CCustomObject::AnimationDrawPath() Fvector T,r; u32 clr = 0xffffffff; - path_points.clear (); + path_points.clear (); for (float t=min_t; (t_Evaluate (t,T,r); + m_Motion->_Evaluate(t,T,r); path_points.push_back(T); } - EDevice.SetShader (EDevice.m_WireShader); - RCache.set_xform_world (Fidentity); + EDevice.SetShader (EDevice.m_WireShader); + RCache.set_xform_world(Fidentity); if (!path_points.empty()) - DU_impl.DrawPrimitiveL (D3DPT_LINESTRIP,path_points.size()-1,path_points.begin(),path_points.size(),clr,true,false); + DU_impl.DrawPrimitiveL (D3DPT_LINESTRIP,path_points.size()-1,path_points.begin(),path_points.size(),clr,true,false); CEnvelope* E = m_Motion->Envelope(); for (KeyIt k_it=E->keys.begin(); k_it!=E->keys.end(); k_it++){ - m_Motion->_Evaluate ((*k_it)->time,T,r); + m_Motion->_Evaluate((*k_it)->time,T,r); if (EDevice.m_Camera.GetPosition().distance_to_sqr(T)<50.f*50.f){ - DU_impl.DrawCross (T,0.1f,0.1f,0.1f, 0.1f,0.1f,0.1f, clr,false); - DU_impl.OutText (T,AnsiString().sprintf("K: %3.3f",(*k_it)->time).c_str(),0xffffffff,0x00000000); + DU_impl.DrawCross(T,0.1f,0.1f,0.1f, 0.1f,0.1f,0.1f, clr,false); + DU_impl.OutText (T,AnsiString().sprintf("K: %3.3f",(*k_it)->time).c_str(),0xffffffff,0x00000000); } } } -#endif +#endif } -void CCustomObject::OnMotionControlClick(ButtonValue* value, bool& bModif, bool& bSafe) +void CCustomObject::OnMotionControlClick(ButtonValue *value, bool &bModif, bool &bSafe) { - ButtonValue* B = dynamic_cast(value); R_ASSERT(B); - switch(B->btn_num){ - case 0:{ - m_MotionParams->t_current = m_MotionParams->min_t; - m_MotionParams->tmp = m_MotionParams->t_current; + ButtonValue *B = dynamic_cast(value); + R_ASSERT(B); + switch (B->btn_num) + { + case 0: + { + m_MotionParams->t_current = m_MotionParams->min_t; + m_MotionParams->tmp = m_MotionParams->t_current; - m_MotionParams->bPlay= FALSE; - }break; - case 1:{ - float min_k; - float max_k; - m_Motion->FindNearestKey(m_MotionParams->t_current, min_k, max_k); - m_MotionParams->t_current = min_k; - m_MotionParams->tmp = m_MotionParams->t_current; - m_MotionParams->bPlay= FALSE; - }break; - case 2:{ - m_MotionParams->t_current -= 1.f/30.f; - m_MotionParams->tmp = m_MotionParams->t_current; - m_MotionParams->bPlay= FALSE; - }break; - case 3:{ - m_MotionParams->bPlay= TRUE; - }break; - case 4:{ - m_MotionParams->bPlay= FALSE; - }break; - case 5:{ - m_MotionParams->t_current += 1.f/30.f; - m_MotionParams->tmp = m_MotionParams->t_current; - m_MotionParams->bPlay= FALSE; - }break; - case 6:{ - float min_k; - float max_k; - m_Motion->FindNearestKey(m_MotionParams->t_current, min_k, max_k); - m_MotionParams->t_current = max_k; - m_MotionParams->tmp = m_MotionParams->t_current; - m_MotionParams->bPlay= FALSE; - }break; - case 7:{ - m_MotionParams->t_current = m_MotionParams->max_t; - m_MotionParams->tmp = m_MotionParams->t_current; - m_MotionParams->bPlay = FALSE; - }break; + m_MotionParams->bPlay = FALSE; + } + break; + case 1: + { + float min_k; + float max_k; + m_Motion->FindNearestKey(m_MotionParams->t_current, min_k, max_k); + m_MotionParams->t_current = min_k; + m_MotionParams->tmp = m_MotionParams->t_current; + m_MotionParams->bPlay = FALSE; + } + break; + case 2: + { + m_MotionParams->t_current -= 1.f/30.f; + m_MotionParams->tmp = m_MotionParams->t_current; + m_MotionParams->bPlay = FALSE; + } + break; + case 3: + { + m_MotionParams->bPlay = TRUE; + } + break; + case 4: + { + m_MotionParams->bPlay = FALSE; + } + break; + case 5: + { + m_MotionParams->t_current += 1.f/30.f; + m_MotionParams->tmp = m_MotionParams->t_current; + m_MotionParams->bPlay = FALSE; + } + break; + case 6: + { + float min_k; + float max_k; + m_Motion->FindNearestKey(m_MotionParams->t_current, min_k, max_k); + m_MotionParams->t_current = max_k; + m_MotionParams->tmp = m_MotionParams->t_current; + m_MotionParams->bPlay = FALSE; + } + break; + case 7: + { + m_MotionParams->t_current = m_MotionParams->max_t; + m_MotionParams->tmp = m_MotionParams->t_current; + m_MotionParams->bPlay = FALSE; + } + break; } - AnimationUpdate (m_MotionParams->Frame()); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + AnimationUpdate(m_MotionParams->Frame()); + ExecCommand(COMMAND_UPDATE_PROPERTIES); bModif = false; } -void CCustomObject::OnMotionCommandsClick(ButtonValue* value, bool& bModif, bool& bSafe) +void CCustomObject::OnMotionCommandsClick(ButtonValue *value, bool &bModif, bool &bSafe) { - ButtonValue* B = dynamic_cast(value); R_ASSERT(B); - switch(B->btn_num){ - case 0: - AnimationCreateKey (m_MotionParams->t_current); - break; - case 1: - AnimationDeleteKey (m_MotionParams->t_current); - break; - case 2:{ - TProperties* P = TProperties::CreateModalForm("Scale keys"); - PropItemVec items; - float from_time=m_MotionParams->min_t,to_time=m_MotionParams->max_t,scale_factor=1.f; - PHelper().CreateFloat (items,"From Time", &from_time, from_time, to_time, 1.f/30.f, 3); - PHelper().CreateFloat (items,"To Time", &to_time, from_time, to_time, 1.f/30.f, 3); - PHelper().CreateFloat (items,"Scale", &scale_factor, -1000.f, 1000.f); - P->AssignItems (items); - if (mrOk==P->ShowPropertiesModal()){ - m_Motion->ScaleKeys(from_time,to_time,scale_factor); - } - TProperties::DestroyForm(P); - float mx; m_Motion->GetLength(0,&mx); - if (m_MotionParams->max_tmax_t=mx; - m_Motion->SetParam (m_MotionParams->min_t*30.f,m_MotionParams->max_t*30.f,30.f); + ButtonValue *B = dynamic_cast(value); + R_ASSERT(B); + switch (B->btn_num) + { + case 0: + AnimationCreateKey(m_MotionParams->t_current); + break; + case 1: + AnimationDeleteKey(m_MotionParams->t_current); + break; + case 2: + { + TProperties *P = TProperties::CreateModalForm("Scale keys"); + PropItemVec items; + float from_time = m_MotionParams->min_t, to_time = m_MotionParams->max_t, scale_factor = 1.f; + PHelper().CreateFloat(items, "From Time", &from_time, from_time, to_time, 1.f/30.f, 3); + PHelper().CreateFloat(items, "To Time", &to_time, from_time, to_time, 1.f/30.f, 3); + PHelper().CreateFloat(items, "Scale", &scale_factor, -1000.f, 1000.f); + P->AssignItems(items); + if (mrOk==P->ShowPropertiesModal()) + { + m_Motion->ScaleKeys(from_time, to_time, scale_factor); + } + TProperties::DestroyForm(P); + float mx; + m_Motion->GetLength(0, &mx); + if (m_MotionParams->max_tmax_t = mx; + m_Motion->SetParam(m_MotionParams->min_t*30.f, m_MotionParams->max_t*30.f, 30.f); + } } - }break; - case 3:{ - TProperties* P = TProperties::CreateModalForm("Normalize keys"); - PropItemVec items; - float from_time=m_MotionParams->min_t,to_time=m_MotionParams->max_t,speed=5.f; - PHelper().CreateFloat (items,"From Time", &from_time, from_time, to_time, 1.f/30.f, 3); - PHelper().CreateFloat (items,"To Time", &to_time, from_time, to_time, 1.f/30.f, 3); - PHelper().CreateFloat (items,"Speed (m/sec)", &speed, 0.f, 100.f); - P->AssignItems (items); - if (mrOk==P->ShowPropertiesModal()){ - m_Motion->NormalizeKeys(from_time,to_time,speed); + break; + case 3: + { + TProperties *P = TProperties::CreateModalForm("Normalize keys"); + PropItemVec items; + float from_time = m_MotionParams->min_t, to_time = m_MotionParams->max_t, speed = 5.f; + PHelper().CreateFloat(items, "From Time", &from_time, from_time, to_time, 1.f/30.f, 3); + PHelper().CreateFloat(items, "To Time", &to_time, from_time, to_time, 1.f/30.f, 3); + PHelper().CreateFloat(items, "Speed (m/sec)", &speed, 0.f, 100.f); + P->AssignItems(items); + if (mrOk==P->ShowPropertiesModal()) + { + m_Motion->NormalizeKeys(from_time, to_time, speed); + } + TProperties::DestroyForm(P); + float mx; + m_Motion->GetLength(0, &mx); + if (m_MotionParams->max_tmax_t = mx; + m_Motion->SetParam(m_MotionParams->min_t*30.f, m_MotionParams->max_t*30.f, 30.f); + } } - TProperties::DestroyForm(P); - float mx; m_Motion->GetLength(0,&mx); - if (m_MotionParams->max_tmax_t=mx; - m_Motion->SetParam (m_MotionParams->min_t*30.f,m_MotionParams->max_t*30.f,30.f); + break; + case 4: + { + float mn, mx; + m_Motion->GetLength(&mn, &mx); + m_MotionParams->min_t = mn; + m_MotionParams->max_t = mx; + m_Motion->SetParam(mn*30.f, mx*30.f, 30.f); } - }break; - case 4:{ - float mn,mx; - m_Motion->GetLength (&mn,&mx); - m_MotionParams->min_t = mn; - m_MotionParams->max_t = mx; - m_Motion->SetParam (mn*30.f,mx*30.f,30.f); - }break; - } - AnimationUpdate (m_MotionParams->Frame()); - bModif = true; + break; + } + AnimationUpdate(m_MotionParams->Frame()); + bModif = true; } -void CCustomObject::OnMotionFilesClick(ButtonValue* value, bool& bModif, bool& bSafe) +void CCustomObject::OnMotionFilesClick(ButtonValue *value, bool &bModif, bool &bSafe) { - ButtonValue* B = dynamic_cast(value); R_ASSERT(B); + ButtonValue *B = dynamic_cast(value); + R_ASSERT(B); bModif = false; xr_string fn; - switch(B->btn_num){ - case 0: - if(EFS.GetOpenName("$game_anims$", fn)){ - m_Motion->LoadMotion(fn.c_str()); - m_MotionParams->Set (m_Motion); - AnimationUpdate (m_MotionParams->Frame()); - bModif = true; - ExecCommand (COMMAND_UPDATE_PROPERTIES); - } - break; - case 1: - if(EFS.GetSaveName("$game_anims$", fn)) - m_Motion->SaveMotion(fn.c_str()); - break; - } + switch (B->btn_num) + { + case 0: + if (EFS.GetOpenName("$game_anims$", fn)) + { + m_Motion->LoadMotion(fn.c_str()); + m_MotionParams->Set(m_Motion); + AnimationUpdate(m_MotionParams->Frame()); + bModif = true; + ExecCommand(COMMAND_UPDATE_PROPERTIES); + } + break; + case 1: + if (EFS.GetSaveName("$game_anims$", fn)) + m_Motion->SaveMotion(fn.c_str()); + break; + } } -void CCustomObject::OnMotionFrameChange(PropValue* value) +void CCustomObject::OnMotionFrameChange(PropValue *value) { - m_Motion->SetParam (m_MotionParams->min_t*30.f,m_MotionParams->max_t*30.f,30.f); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + m_Motion->SetParam(m_MotionParams->min_t*30.f, m_MotionParams->max_t*30.f, 30.f); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void CCustomObject::OnMotionKeyTimeChange(PropValue* value) +void CCustomObject::OnMotionKeyTimeChange(PropValue *value) { - float t = m_MotionParams->tmp; - Fvector P,R; + float t = m_MotionParams->tmp; + Fvector P, R; - m_Motion->_Evaluate(m_MotionParams->t_current,P, R); + m_Motion->_Evaluate(m_MotionParams->t_current, P, R); m_Motion->DeleteKey(m_MotionParams->t_current); - m_Motion->CreateKey(t,P,R); + m_Motion->CreateKey(t, P, R); } -void CCustomObject::OnMotionCurrentFrameChange(PropValue* value) +void CCustomObject::OnMotionCurrentFrameChange(PropValue *value) { - if (m_MotionParams->t_currentmin_t) - m_MotionParams->min_t = m_MotionParams->t_current; + if (m_MotionParams->t_currentmin_t) + m_MotionParams->min_t = m_MotionParams->t_current; else if (m_MotionParams->t_current>m_MotionParams->max_t) - m_MotionParams->max_t = m_MotionParams->t_current; + m_MotionParams->max_t = m_MotionParams->t_current; - m_Motion->SetParam (m_MotionParams->min_t*30.f,m_MotionParams->max_t*30.f,30.f); - m_MotionParams->bPlay= FALSE; - AnimationUpdate (m_MotionParams->Frame()); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + m_Motion->SetParam(m_MotionParams->min_t*30.f, m_MotionParams->max_t*30.f, 30.f); + m_MotionParams->bPlay = FALSE; + AnimationUpdate(m_MotionParams->Frame()); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void CCustomObject::OnMotionCameraViewChange(PropValue* value) +void CCustomObject::OnMotionCameraViewChange(PropValue *value) { - if (m_CO_Flags.is(flCameraView)) - AnimationUpdate (m_MotionParams->Frame()); + if (m_CO_Flags.is(flCameraView)) + AnimationUpdate(m_MotionParams->Frame()); } -void CCustomObject::OnTransformChange(PropValue* value) +void CCustomObject::OnTransformChange(PropValue *value) { - UpdateTransform(); + UpdateTransform(); } -void CCustomObject::AnimationFillProp(LPCSTR pref, PropItemVec& items) +void CCustomObject::AnimationFillProp(LPCSTR pref, PropItemVec &items) { - PropValue* V = PHelper().CreateFlag32(items,PrepareKey(pref,"Flags\\Motionable"),&m_CO_Flags, flMotion); - V->OnChangeEvent.bind(this,&CCustomObject::OnMotionableChange); - if (Motionable()){ - PHelper().CreateCaption (items,PrepareKey(pref,"Motion\\Hint"), "Make KEY only on Parent CS"); - ButtonValue* B = PHelper().CreateButton (items,PrepareKey(pref,"Motion\\Files"), "Import,Export", 0); - B->OnBtnClickEvent.bind(this,&CCustomObject::OnMotionFilesClick); - B = PHelper().CreateButton (items,PrepareKey(pref,"Motion\\Commands"), "+ K,- K,Scale,Norm,Clamp", 0); - B->OnBtnClickEvent.bind(this,&CCustomObject::OnMotionCommandsClick); - B = PHelper().CreateButton (items,PrepareKey(pref,"Motion\\Controls"), " |<<, +<<, <<, >, ||, >>, >>+, >>|", 0); - B->OnBtnClickEvent.bind(this,&CCustomObject::OnMotionControlClick); - PHelper().CreateFlag32 (items,PrepareKey(pref,"Motion\\Flags\\Auto Key"), &m_CO_Flags, flAutoKey); - V = PHelper().CreateFlag32 (items,PrepareKey(pref,"Motion\\Flags\\Camera View"), &m_CO_Flags, flCameraView); - V->OnChangeEvent.bind(this,&CCustomObject::OnMotionCameraViewChange); - V = PHelper().CreateFloat (items,PrepareKey(pref,"Motion\\Start Frame (sec)"), &m_MotionParams->min_t, -10000.f, m_MotionParams->max_t, 1.f/30.f, 3); - V->OnChangeEvent.bind(this,&CCustomObject::OnMotionFrameChange); - V = PHelper().CreateFloat (items,PrepareKey(pref,"Motion\\End Frame (sec)"), &m_MotionParams->max_t, m_MotionParams->min_t, 10000.f, 1.f/30.f, 3); - V->OnChangeEvent.bind(this,&CCustomObject::OnMotionFrameChange); - V = PHelper().CreateFloat (items,PrepareKey(pref,"Motion\\Current Frame (sec)"), &m_MotionParams->t_current, -10000.f, 10000.f, 1.f/30.f, 3); - V->OnChangeEvent.bind(this,&CCustomObject::OnMotionCurrentFrameChange); + PropValue *V = PHelper().CreateFlag32(items, PrepareKey(pref, "Flags\\Motionable"), &m_CO_Flags, flMotion); + V->OnChangeEvent.bind(this, &CCustomObject::OnMotionableChange); + if (Motionable()) + { + PHelper().CreateCaption(items, PrepareKey(pref, "Motion\\Hint"), "Make KEY only on Parent CS"); + ButtonValue *B = PHelper().CreateButton(items, PrepareKey(pref, "Motion\\Files"), "Import,Export", 0); + B->OnBtnClickEvent.bind(this, &CCustomObject::OnMotionFilesClick); + B = PHelper().CreateButton(items, PrepareKey(pref, "Motion\\Commands"), "+ K,- K,Scale,Norm,Clamp", 0); + B->OnBtnClickEvent.bind(this, &CCustomObject::OnMotionCommandsClick); + B = PHelper().CreateButton(items, PrepareKey(pref, "Motion\\Controls"), " |<<, +<<, <<, >, ||, >>, >>+, >>|", 0); + B->OnBtnClickEvent.bind(this, &CCustomObject::OnMotionControlClick); + PHelper().CreateFlag32(items, PrepareKey(pref, "Motion\\Flags\\Auto Key"), &m_CO_Flags, flAutoKey); + V = PHelper().CreateFlag32(items, PrepareKey(pref, "Motion\\Flags\\Camera View"), &m_CO_Flags, flCameraView); + V->OnChangeEvent.bind(this, &CCustomObject::OnMotionCameraViewChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Motion\\Start Frame (sec)"), &m_MotionParams->min_t, -10000.f, m_MotionParams->max_t, 1.f/30.f, 3); + V->OnChangeEvent.bind(this, &CCustomObject::OnMotionFrameChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Motion\\End Frame (sec)"), &m_MotionParams->max_t, m_MotionParams->min_t, 10000.f, 1.f/30.f, 3); + V->OnChangeEvent.bind(this, &CCustomObject::OnMotionFrameChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Motion\\Current Frame (sec)"), &m_MotionParams->t_current, -10000.f, 10000.f, 1.f/30.f, 3); + V->OnChangeEvent.bind(this, &CCustomObject::OnMotionCurrentFrameChange); - V = PHelper().CreateFloat (items,PrepareKey(pref,"Motion\\ChangeKeyTime(sec)"), &m_MotionParams->tmp, -10000.f, 10000.f, 1.f/30.f, 3); - V->OnChangeEvent.bind(this,&CCustomObject::OnMotionKeyTimeChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Motion\\ChangeKeyTime(sec)"), &m_MotionParams->tmp, -10000.f, 10000.f, 1.f/30.f, 3); + V->OnChangeEvent.bind(this, &CCustomObject::OnMotionKeyTimeChange); - PHelper().CreateCaption (items,PrepareKey(pref,"Motion\\Key Count"), shared_str().printf("%d",m_Motion->KeyCount())); - PHelper().CreateCaption (items,PrepareKey(pref,"Motion\\Length (sec)"), shared_str().printf("%3.2f",m_Motion->GetLength())); - } + PHelper().CreateCaption(items, PrepareKey(pref, "Motion\\Key Count"), shared_str().printf("%d", m_Motion->KeyCount())); + PHelper().CreateCaption(items, PrepareKey(pref, "Motion\\Length (sec)"), shared_str().printf("%3.2f", m_Motion->GetLength())); + } } - + diff --git a/src/editors/LevelEditor/Edit/CustomObjectLE.cpp b/src/editors/LevelEditor/Edit/CustomObjectLE.cpp index 7df7dd9d146..5545d94c710 100644 --- a/src/editors/LevelEditor/Edit/CustomObjectLE.cpp +++ b/src/editors/LevelEditor/Edit/CustomObjectLE.cpp @@ -2,240 +2,265 @@ #pragma hdrstop #include "CustomObject.h" -#include "../ECore/Editor/ui_main.h" -#include "../ECore/Editor/ui_toolscustom.h" -#include "../ECore/Editor/editorpreferences.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/UI_ToolsCustom.h" +#include "editors/ECore/Editor/editorpreferences.h" #include "scene.h" //------------------------------------------------------------------------------ // static part //------------------------------------------------------------------------------ -void CCustomObject::SnapMove(Fvector& pos, Fvector& rot, const Fmatrix& rotRP, const Fvector& amount) +void CCustomObject::SnapMove(Fvector &pos, Fvector &rot, const Fmatrix &rotRP, const Fvector &amount) { -// !!! Hide object before test + // !!! Hide object before test SRayPickInfo pinf; - Fvector up,dn={0,-1,0}; + Fvector up, dn = {0,-1,0}; rotRP.transform_dir(dn); up.invert(dn); - Fvector s2,s1=pos; + Fvector s2, s1 = pos; s1.add(amount); - s2.mad(s1,up,EPrefs->snap_moveto); - - pinf.inf.range=EPrefs->snap_moveto; - if (Scene->RayPickObject( pinf.inf.range, s1, dn, OBJCLASS_SCENEOBJECT, &pinf, Scene->GetSnapList(false))||Scene->RayPickObject( pinf.inf.range, s2, dn, OBJCLASS_SCENEOBJECT, &pinf, Scene->GetSnapList(false))){ - pos.set(pinf.pt); - if (Tools->GetSettings(etfNormalAlign)){ - Fvector verts[3]; - pinf.e_obj->GetFaceWorld(pinf.s_obj->_Transform(),pinf.e_mesh,pinf.inf.id,verts); - Fvector vR,vD,vN; - vN.mknormal(verts[0],verts[1],verts[2]); - - vD.set(rotRP.k); - vR.crossproduct (vN,vD); - vR.normalize(); - vD.crossproduct (vR,vN); - vD.normalize(); - - Fmatrix M; - M.set(vR,vN,vD,vR); - M.getXYZ(rot); - } + s2.mad(s1, up, EPrefs->snap_moveto); + + pinf.inf.range = EPrefs->snap_moveto; + if (Scene->RayPickObject(pinf.inf.range, s1, dn, OBJCLASS_SCENEOBJECT, &pinf, Scene->GetSnapList(false))||Scene->RayPickObject(pinf.inf.range, s2, dn, OBJCLASS_SCENEOBJECT, &pinf, Scene->GetSnapList(false))) + { + pos.set(pinf.pt); + if (Tools->GetSettings(etfNormalAlign)) + { + Fvector verts[3]; + pinf.e_obj->GetFaceWorld(pinf.s_obj->_Transform(), pinf.e_mesh, pinf.inf.id, verts); + Fvector vR, vD, vN; + vN.mknormal(verts[0], verts[1], verts[2]); + + vD.set(rotRP.k); + vR.crossproduct(vN, vD); + vR.normalize(); + vD.crossproduct(vR, vN); + vD.normalize(); + + Fmatrix M; + M.set(vR, vN, vD, vR); + M.getXYZ(rot); } - else pos.add(amount); + } + else + pos.add(amount); } -void CCustomObject::NormalAlign(Fvector& rot, const Fvector& up, const Fvector& dir) + +void CCustomObject::NormalAlign(Fvector &rot, const Fvector &up, const Fvector &dir) { - Fmatrix mR; - Fvector vR,vD,vN; + Fmatrix mR; + Fvector vR, vD, vN; vN.set(up); -// vD.set(0,0,1); + // vD.set(0,0,1); vD.set(dir); - if (fabsf(vN.z)>0.99f) vD.set(1,0,0); - vR.crossproduct(vN,vD); vR.normalize(); - vD.crossproduct(vR,vN); vD.normalize(); - mR.set(vR,vN,vD,vR); + if (fabsf(vN.z)>0.99f) + vD.set(1, 0, 0); + vR.crossproduct(vN, vD); + vR.normalize(); + vD.crossproduct(vR, vN); + vD.normalize(); + mR.set(vR, vN, vD, vR); mR.getXYZ(rot); } + //------------------------------------------------------------------------------ void CCustomObject::OnDetach() { - if (m_pOwnerObject){ - m_pOwnerObject = 0; -//. string64 new_name; -//. Scene->GenObjectName(ClassID,new_name,Name); -//. Name = new_name; -//. Scene->AppendObject (this,false); + if (m_pOwnerObject) + { + m_pOwnerObject = 0; + //. string64 new_name; + //. Scene->GenObjectName(ClassID,new_name,Name); + //. Name = new_name; + //. Scene->AppendObject(this,false); } - m_CO_Flags.set (flObjectInGroup,FALSE); - Select (true); + m_CO_Flags.set(flObjectInGroup, FALSE); + Select(true); FParentTools->SetChanged(TRUE); } -void CCustomObject::OnAttach(CCustomObject* owner) +void CCustomObject::OnAttach(CCustomObject *owner) { - R_ASSERT (owner); - R_ASSERT2 ( ((!m_pOwnerObject) || (m_pOwnerObject==owner) ), "Object already has owner!"); - m_pOwnerObject = owner; -//. Scene->RemoveObject (this,false,false); - if(owner->FClassID==OBJCLASS_GROUP) - m_CO_Flags.set(flObjectInGroup,TRUE); - - Select (false); + R_ASSERT(owner); + R_ASSERT2(((!m_pOwnerObject)||(m_pOwnerObject==owner)), "Object already has owner!"); + m_pOwnerObject = owner; + //. Scene->RemoveObject (this,false,false); + if (owner->FClassID==OBJCLASS_GROUP) + m_CO_Flags.set(flObjectInGroup, TRUE); + + Select(false); FParentTools->SetChanged(TRUE); } -void CCustomObject::Move(Fvector& amount) +void CCustomObject::Move(Fvector &amount) { UI->UpdateScene(); - Fvector v=PPosition; - Fvector r=PRotation; - if (Tools->GetSettings(etfMTSnap)){ - BOOL bVis = Visible(); - BOOL bSel = Selected(); - Show (FALSE); - Select (FALSE); - SnapMove (v,r,FTransformRP,amount); - Show (bVis); - Select (bSel); - }else{ - v.add(amount); + Fvector v = PPosition; + Fvector r = PRotation; + if (Tools->GetSettings(etfMTSnap)) + { + BOOL bVis = Visible(); + BOOL bSel = Selected(); + Show(FALSE); + Select(FALSE); + SnapMove(v, r, FTransformRP, amount); + Show(bVis); + Select(bSel); + } + else + { + v.add(amount); } PPosition = v; PRotation = r; } -void CCustomObject::MoveTo(const Fvector& pos, const Fvector& up) +void CCustomObject::MoveTo(const Fvector &pos, const Fvector &up) { UI->UpdateScene(); - Fvector v=PPosition; + Fvector v = PPosition; v.set(pos); - if (Tools->GetSettings(etfNormalAlign)){ - Fmatrix M; - M.setXYZ (PRotation); + if (Tools->GetSettings(etfNormalAlign)) + { + Fmatrix M; + M.setXYZ(PRotation); Fvector ret_rot = PRotation; - NormalAlign (ret_rot, up, M.k); - PRotation = ret_rot; + NormalAlign(ret_rot, up, M.k); + PRotation = ret_rot; } PPosition = v; } -void CCustomObject::RotatePivot(const Fmatrix& prev_inv, const Fmatrix& current) +void CCustomObject::RotatePivot(const Fmatrix &prev_inv, const Fmatrix ¤t) { - Fmatrix Ol,On; - Ol.mul (prev_inv,FTransformRP); - On.mul (current,Ol); - Fvector xyz; - On.getXYZ (xyz); - PRotation = xyz; - PPosition = On.c; + Fmatrix Ol, On; + Ol.mul(prev_inv, FTransformRP); + On.mul(current, Ol); + Fvector xyz; + On.getXYZ(xyz); + PRotation = xyz; + PPosition = On.c; } -void CCustomObject::RotateParent(Fvector& axis, float angle) +void CCustomObject::RotateParent(Fvector &axis, float angle) { UI->UpdateScene(); - Fvector r = PRotation; - r.mad (axis,angle); - PRotation = r; + Fvector r = PRotation; + r.mad(axis, angle); + PRotation = r; } -void CCustomObject::RotateLocal(Fvector& axis, float angle) +void CCustomObject::RotateLocal(Fvector &axis, float angle) { Fmatrix m; Fvector r; - m.rotation(axis,angle); + m.rotation(axis, angle); FTransformRP.mulB_43(m); FTransformRP.getXYZ(r); - PRotation = r; + PRotation = r; } -void CCustomObject::ScalePivot( const Fmatrix& prev_inv, const Fmatrix& current, Fvector& amount ) +void CCustomObject::ScalePivot(const Fmatrix &prev_inv, const Fmatrix ¤t, Fvector &amount) { UI->UpdateScene(); - Fvector p = PPosition; - Fvector s = PScale; - s.add(amount); - if (s.xUpdateScene(); - Fvector s = PScale; - s.add(amount); - if (s.x(sender); VERIFY(V); - if(0==edit_val.size()) - return false; - - edit_val = (AnsiString(edit_val.c_str()).LowerCase()).c_str(); - return !Scene->FindObjectByName(edit_val.c_str(),(CCustomObject*)0); + RTextValue *V = dynamic_cast(sender); + VERIFY(V); + if (0==edit_val.size()) + return false; + + edit_val = (AnsiString(edit_val.c_str()).LowerCase()).c_str(); + return !Scene->FindObjectByName(edit_val.c_str(), (CCustomObject*)0); } -void CCustomObject::OnNumChangePosition(PropValue* sender) +void CCustomObject::OnNumChangePosition(PropValue *sender) { - NumSetPosition (PPosition); + NumSetPosition(PPosition); } -void CCustomObject::OnNumChangeRotation(PropValue* sender) + +void CCustomObject::OnNumChangeRotation(PropValue *sender) { - NumSetRotation (PRotation); + NumSetRotation(PRotation); } -void CCustomObject::OnNumChangeScale(PropValue* sender) + +void CCustomObject::OnNumChangeScale(PropValue *sender) { - NumSetScale (PScale); + NumSetScale(PScale); } -void CCustomObject::OnNameChange(PropValue* sender) + +void CCustomObject::OnNameChange(PropValue *sender) { - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void CCustomObject::FillProp(LPCSTR pref, PropItemVec& items) +void CCustomObject::FillProp(LPCSTR pref, PropItemVec &items) { - PropValue* V; - V = PHelper().CreateNameCB (items, PrepareKey(pref, "Name"),&FName,NULL,NULL,RTextValue::TOnAfterEditEvent(this,&CCustomObject::OnObjectNameAfterEdit)); - V->OnChangeEvent.bind (this,&CCustomObject::OnNameChange); - V = PHelper().CreateVector (items, PrepareKey(pref,"Transform\\Position"), &PPosition, -10000, 10000,0.01,2); - V->OnChangeEvent.bind (this,&CCustomObject::OnNumChangePosition); - V = PHelper().CreateAngle3 (items, PrepareKey(pref,"Transform\\Rotation"), &PRotation, -10000, 10000,0.1,1); - V->OnChangeEvent.bind (this,&CCustomObject::OnNumChangeRotation); - V = PHelper().CreateVector (items, PrepareKey(pref,"Transform\\Scale"), &PScale, 0.01, 10000,0.01,2); - V->OnChangeEvent.bind (this,&CCustomObject::OnNumChangeScale); + PropValue *V; + V = PHelper().CreateNameCB(items, PrepareKey(pref, "Name"), &FName, NULL, NULL, RTextValue::TOnAfterEditEvent(this, &CCustomObject::OnObjectNameAfterEdit)); + V->OnChangeEvent.bind(this, &CCustomObject::OnNameChange); + V = PHelper().CreateVector(items, PrepareKey(pref, "Transform\\Position"), &PPosition, -10000, 10000, 0.01, 2); + V->OnChangeEvent.bind(this, &CCustomObject::OnNumChangePosition); + V = PHelper().CreateAngle3(items, PrepareKey(pref, "Transform\\Rotation"), &PRotation, -10000, 10000, 0.1, 1); + V->OnChangeEvent.bind(this, &CCustomObject::OnNumChangeRotation); + V = PHelper().CreateVector(items, PrepareKey(pref, "Transform\\Scale"), &PScale, 0.01, 10000, 0.01, 2); + V->OnChangeEvent.bind(this, &CCustomObject::OnNumChangeScale); - if(m_CO_Flags.test(flObjectInGroup)) + if (m_CO_Flags.test(flObjectInGroup)) { - V = PHelper().CreateFlag32 (items, PrepareKey(pref,"In group editable"), &m_CO_Flags, flObjectInGroupUnique); - V->OnChangeEvent.bind (this,&CCustomObject::OnChangeIngroupUnique); + V = PHelper().CreateFlag32(items, PrepareKey(pref, "In group editable"), &m_CO_Flags, flObjectInGroupUnique); + V->OnChangeEvent.bind(this, &CCustomObject::OnChangeIngroupUnique); } } -void CCustomObject::OnChangeIngroupUnique(PropValue* sender) +void CCustomObject::OnChangeIngroupUnique(PropValue *sender) { - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } //---------------------------------------------------- -void CCustomObject::OnShowHint(AStringVec& dest) +void CCustomObject::OnShowHint(AStringVec &dest) { -// dest.push_back(AnsiString("Class: ")+AnsiString(ParentTools->ClassDesc())); + // dest.push_back(AnsiString("Class: ")+AnsiString(ParentTools->ClassDesc())); dest.push_back(AnsiString("Name: ")+AnsiString(Name)); dest.push_back(AnsiString("-------")); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ELight.cpp b/src/editors/LevelEditor/Edit/ELight.cpp index 9c47b078070..8f2d7e3b639 100644 --- a/src/editors/LevelEditor/Edit/ELight.cpp +++ b/src/editors/LevelEditor/Edit/ELight.cpp @@ -5,26 +5,29 @@ #pragma hdrstop #include "ELight.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "../ECORE/Editor/D3DUtils.h" #include "scene.h" #include "escenelighttools.h" -static const u32 LIGHT_VERSION = 0x0011; +static const u32 LIGHT_VERSION = 0x0011; + //---------------------------------------------------- -enum{ - LIGHT_CHUNK_VERSION = 0xB411, - LIGHT_CHUNK_FLAG = 0xB413, - LIGHT_CHUNK_BRIGHTNESS = 0xB425, - LIGHT_CHUNK_D3D_PARAMS = 0xB435, - LIGHT_CHUNK_USE_IN_D3D = 0xB436, - LIGHT_CHUNK_ROTATE = 0xB437, - LIGHT_CHUNK_ANIMREF = 0xB438, - LIGHT_CHUNK_SPOT_TEXTURE = 0xB439, - LIGHT_CHUNK_FUZZY_DATA = 0xB440, - LIGHT_CHUNK_LCONTROL = 0xB441, - LIGHT_CHUNK_PARAMS = 0xB442, +enum +{ + LIGHT_CHUNK_VERSION = 0xB411, + LIGHT_CHUNK_FLAG = 0xB413, + LIGHT_CHUNK_BRIGHTNESS = 0xB425, + LIGHT_CHUNK_D3D_PARAMS = 0xB435, + LIGHT_CHUNK_USE_IN_D3D = 0xB436, + LIGHT_CHUNK_ROTATE = 0xB437, + LIGHT_CHUNK_ANIMREF = 0xB438, + LIGHT_CHUNK_SPOT_TEXTURE = 0xB439, + LIGHT_CHUNK_FUZZY_DATA = 0xB440, + LIGHT_CHUNK_LCONTROL = 0xB441, + LIGHT_CHUNK_PARAMS = 0xB442, }; + //---------------------------------------------------- #define VIS_RADIUS 0.25f @@ -33,207 +36,237 @@ enum{ #define NORM_DYN_COLOR 0x0000FF00 #define LOCK_COLOR 0x00FF0000 -CLight::CLight(LPVOID data, LPCSTR name):CCustomObject(data,name) +CLight::CLight(LPVOID data, LPCSTR name): CCustomObject(data, name) { - Construct(data); + Construct(data); } void CLight::Construct(LPVOID data) { - ClassID = OBJCLASS_LIGHT; + ClassID = OBJCLASS_LIGHT; - m_UseInD3D = TRUE; + m_UseInD3D = TRUE; - m_FuzzyData = 0; - - m_Type = ELight::ltPoint; - m_Color.set (1.f,1.f,1.f,0); - m_Brightness = 1.f; - m_Attenuation0 = 1.f; - m_Attenuation1 = 0.f; - m_Attenuation2 = 0.f; - m_Range = 8.f; - m_Cone = PI_DIV_8; + m_FuzzyData = 0; - m_VirtualSize = 0.f; + m_Type = ELight::ltPoint; + m_Color.set(1.f, 1.f, 1.f, 0); + m_Brightness = 1.f; + m_Attenuation0 = 1.f; + m_Attenuation1 = 0.f; + m_Attenuation2 = 0.f; + m_Range = 8.f; + m_Cone = PI_DIV_8; - m_pAnimRef = 0; - m_LControl = 0; + m_VirtualSize = 0.f; - m_Flags.assign (ELight::flAffectStatic); + m_pAnimRef = 0; + m_LControl = 0; + + m_Flags.assign(ELight::flAffectStatic); } CLight::~CLight() { - xr_delete (m_FuzzyData); + xr_delete(m_FuzzyData); } void CLight::OnUpdateTransform() { - FScale.set (1.f,1.f,1.f); - inherited::OnUpdateTransform(); + FScale.set(1.f, 1.f, 1.f); + inherited::OnUpdateTransform(); } -void CLight::CopyFrom(CLight* src) +void CLight::CopyFrom(CLight *src) { - THROW2("CLight:: Go to AlexMX"); + THROW2("CLight:: Go to AlexMX"); } -void CLight::AffectD3D(BOOL flag){ - m_UseInD3D = flag; +void CLight::AffectD3D(BOOL flag) +{ + m_UseInD3D = flag; UI->UpdateScene(); } + //---------------------------------------------------- -bool CLight::GetBox( Fbox& box ) const +bool CLight::GetBox(Fbox &box) const { - box.set (PPosition, PPosition); - box.min.sub (m_Range); - box.max.add (m_Range); - return true; + box.set(PPosition, PPosition); + box.min.sub(m_Range); + box.max.add(m_Range); + return true; } void CLight::Render(int priority, bool strictB2F) { - inherited::Render(priority,strictB2F); - if ((1==priority)&&(false==strictB2F)){ - EDevice.SetShader (EDevice.m_WireShader); - RCache.set_xform_world (Fidentity); - u32 clr = Selected()?SEL_COLOR:(m_Flags.is(ELight::flAffectDynamic)?NORM_DYN_COLOR:NORM_COLOR); - switch (m_Type){ - case ELight::ltPoint: - if (Selected()) - DU_impl.DrawLineSphere( PPosition, m_Range, clr, true ); - - DU_impl.DrawPointLight(PPosition,VIS_RADIUS, clr); - if (m_Flags.is(ELight::flPointFuzzy)){ - VERIFY(m_FuzzyData); - for (FvectorIt it=m_FuzzyData->m_Positions.begin(); it!=m_FuzzyData->m_Positions.end(); it++){ - Fvector tmp; _Transform().transform_tiny(tmp,*it); - DU_impl.DrawPointLight(tmp,VIS_RADIUS/6, clr); - } - } - break; - case ELight::ltSpot:{ -// Fvector dir; -// dir.setHP (PRotation.y,PRotation.x); -// DU.DrawCone (Fidentity, PPosition, dir, Selected()?m_Range:VIS_RADIUS, radius2, clr, true, false); - if (Selected()) - DU_impl.DrawSpotLight( PPosition, FTransformR.k, m_Range, m_Cone, clr ); - else - DU_impl.DrawSpotLight( PPosition, FTransformR.k, VIS_RADIUS, m_Cone, clr ); - }break; - default: THROW; + inherited::Render(priority, strictB2F); + if ((1==priority)&&(false==strictB2F)) + { + EDevice.SetShader(EDevice.m_WireShader); + RCache.set_xform_world(Fidentity); + u32 clr = Selected() ? SEL_COLOR : (m_Flags.is(ELight::flAffectDynamic) ? NORM_DYN_COLOR : NORM_COLOR); + switch (m_Type) + { + case ELight::ltPoint: + if (Selected()) + DU_impl.DrawLineSphere(PPosition, m_Range, clr, true); + + DU_impl.DrawPointLight(PPosition,VIS_RADIUS, clr); + if (m_Flags.is(ELight::flPointFuzzy)) + { + VERIFY(m_FuzzyData); + for (FvectorIt it = m_FuzzyData->m_Positions.begin(); it!=m_FuzzyData->m_Positions.end(); it++) + { + Fvector tmp; + _Transform().transform_tiny(tmp, *it); + DU_impl.DrawPointLight(tmp,VIS_RADIUS/6, clr); + } + } + break; + case ELight::ltSpot: + { + // Fvector dir; + // dir.setHP (PRotation.y,PRotation.x); + // DU.DrawCone (Fidentity, PPosition, dir, Selected()?m_Range:VIS_RADIUS, radius2, clr, true, false); + if (Selected()) + DU_impl.DrawSpotLight(PPosition, FTransformR.k, m_Range, m_Cone, clr); + else + DU_impl.DrawSpotLight(PPosition, FTransformR.k, VIS_RADIUS, m_Cone, clr); + } + break; + default: THROW; } - ESceneLightTool* lt = dynamic_cast(ParentTool); - VERIFY (lt); - + ESceneLightTool *lt = dynamic_cast(ParentTool); + VERIFY(lt); + if (lt->m_Flags.is(ESceneLightTool::flShowControlName)) { - Fvector D; - D.sub (EDevice.vCameraPosition,PPosition); - float dist = D.normalize_magn(); - if (!Scene->RayPickObject(dist,PPosition,D,OBJCLASS_SCENEOBJECT,0,0)) - DU_impl.OutText (PPosition,AnsiString().sprintf(" %s",GetLControlName()).c_str(),0xffffffff,0xff000000); + Fvector D; + D.sub(EDevice.vCameraPosition, PPosition); + float dist = D.normalize_magn(); + if (!Scene->RayPickObject(dist, PPosition, D, OBJCLASS_SCENEOBJECT, 0, 0)) + DU_impl.OutText(PPosition, AnsiString().sprintf(" %s", GetLControlName()).c_str(), 0xffffffff, 0xff000000); } - }else if ((1==priority)&&(true==strictB2F)) + } + else if ((1==priority)&&(true==strictB2F)) { - EDevice.SetShader (EDevice.m_SelectionShader); - RCache.set_xform_world (Fidentity); - switch (m_Type) + EDevice.SetShader(EDevice.m_SelectionShader); + RCache.set_xform_world(Fidentity); + switch (m_Type) { - case ELight::ltPoint: - if (m_Flags.is(ELight::flPointFuzzy)) - { - u32 clr = Selected()?SEL_COLOR:(m_Flags.is(ELight::flAffectDynamic)?NORM_DYN_COLOR:NORM_COLOR); - clr = subst_alpha(clr,0x40); - const Fvector zero={0.f,0.f,0.f}; - VERIFY(m_FuzzyData); - switch (m_FuzzyData->m_ShapeType) + case ELight::ltPoint: + if (m_Flags.is(ELight::flPointFuzzy)) { - case CLight::SFuzzyData::fstSphere: - DU_impl.DrawSphere (_Transform(),zero,m_FuzzyData->m_SphereRadius,clr,clr,true,true); - break; - case CLight::SFuzzyData::fstBox: - DU_impl.DrawAABB (_Transform(),zero,m_FuzzyData->m_BoxDimension,clr,clr,true,true); - break; + u32 clr = Selected() ? SEL_COLOR : (m_Flags.is(ELight::flAffectDynamic) ? NORM_DYN_COLOR : NORM_COLOR); + clr = subst_alpha(clr, 0x40); + const Fvector zero = {0.f,0.f,0.f}; + VERIFY(m_FuzzyData); + switch (m_FuzzyData->m_ShapeType) + { + case CLight::SFuzzyData::fstSphere: + DU_impl.DrawSphere(_Transform(), zero, m_FuzzyData->m_SphereRadius, clr, clr, true, true); + break; + case CLight::SFuzzyData::fstBox: + DU_impl.DrawAABB(_Transform(), zero, m_FuzzyData->m_BoxDimension, clr, clr, true, true); + break; + } } - } - break; - case ELight::ltSpot: break; - default: THROW; + break; + case ELight::ltSpot: break; + default: THROW; } - } + } } -bool CLight::FrustumPick(const CFrustum& frustum) +bool CLight::FrustumPick(const CFrustum &frustum) { -// return (frustum.testSphere(m_Position,m_Range))?true:false; - return (frustum.testSphere_dirty(PPosition,VIS_RADIUS))?true:false; + // return (frustum.testSphere(m_Position,m_Range))?true:false; + return (frustum.testSphere_dirty(PPosition,VIS_RADIUS)) ? true : false; } -bool CLight::RayPick(float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf) +bool CLight::RayPick(float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf) { - Fvector ray2; - ray2.sub( PPosition, start ); + Fvector ray2; + ray2.sub(PPosition, start); float d = ray2.dotproduct(direction); - if( d > 0 ){ + if (d>0) + { float d2 = ray2.magnitude(); - if( ((d2*d2-d*d) < (VIS_RADIUS*VIS_RADIUS)) && (d>VIS_RADIUS) ){ - if (dVIS_RADIUS)) + { + if (d(ParentTool); VERIFY(lt); - xr_rtoken* lc = lt->FindLightControl(m_LControl); - return lc?*lc->name:0; + ESceneLightTool *lt = dynamic_cast(ParentTool); + VERIFY(lt); + xr_rtoken *lc = lt->FindLightControl(m_LControl); + return lc ? *lc->name : 0; } + //---------------------------------------------------- -void CLight::OnNeedUpdate(PropValue* value) +void CLight::OnNeedUpdate(PropValue *value) { - Update(); + Update(); } + //---------------------------------------------------- -bool CLight::GetSummaryInfo(SSceneSummary* inf) +bool CLight::GetSummaryInfo(SSceneSummary *inf) { - inherited::GetSummaryInfo (inf); - switch (m_Type){ - case ELight::ltPoint: inf->light_point_cnt++; break; - case ELight::ltSpot: inf->light_spot_cnt++; break; + inherited::GetSummaryInfo(inf); + switch (m_Type) + { + case ELight::ltPoint: inf->light_point_cnt++; + break; + case ELight::ltSpot: inf->light_spot_cnt++; + break; } - switch (m_Type){ - case ELight::ltPoint: - case ELight::ltSpot: - if (m_Flags.is(ELight::flAffectStatic)) inf->light_static_cnt++; - if (m_Flags.is(ELight::flAffectDynamic)) inf->light_dynamic_cnt++; - if (m_Flags.is(ELight::flProcedural)) inf->light_procedural_cnt++; - if (m_Flags.is(ELight::flBreaking)) inf->light_breakable_cnt++; - break; + switch (m_Type) + { + case ELight::ltPoint: + case ELight::ltSpot: + if (m_Flags.is(ELight::flAffectStatic)) + inf->light_static_cnt++; + if (m_Flags.is(ELight::flAffectDynamic)) + inf->light_dynamic_cnt++; + if (m_Flags.is(ELight::flProcedural)) + inf->light_procedural_cnt++; + if (m_Flags.is(ELight::flBreaking)) + inf->light_breakable_cnt++; + break; } - return true; + return true; } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ELight.h b/src/editors/LevelEditor/Edit/ELight.h index 37b59c001c6..f659d514ec1 100644 --- a/src/editors/LevelEditor/Edit/ELight.h +++ b/src/editors/LevelEditor/Edit/ELight.h @@ -13,133 +13,148 @@ class CLAItem; class CLight : public CCustomObject { protected: - typedef CCustomObject inherited; + typedef CCustomObject inherited; public: - // flags - Flags32 m_Flags; - + // flags + Flags32 m_Flags; + // light - ELight::EType m_Type; /* Type of light source */ - Fcolor m_Color; /* Diffuse color of light */ - float m_Brightness; - float m_Range; /* Cutoff range */ - float m_Attenuation0; /* Constant attenuation */ - float m_Attenuation1; /* Linear attenuation */ - float m_Attenuation2; /* Quadratic attenuation */ - float m_Cone; /* Outer angle of spotlight cone */ - - float m_VirtualSize; - - CLAItem* m_pAnimRef; + ELight::EType m_Type; /* Type of light source */ + Fcolor m_Color; /* Diffuse color of light */ + float m_Brightness; + float m_Range; /* Cutoff range */ + float m_Attenuation0; /* Constant attenuation */ + float m_Attenuation1; /* Linear attenuation */ + float m_Attenuation2; /* Quadratic attenuation */ + float m_Cone; /* Outer angle of spotlight cone */ + + float m_VirtualSize; + + CLAItem *m_pAnimRef; // spot light - shared_str m_FalloffTex; + shared_str m_FalloffTex; // controller - u32 m_LControl; + u32 m_LControl; - // build options - BOOL m_UseInD3D; + // build options + BOOL m_UseInD3D; // fuzzy - struct SFuzzyData{ - enum EShapeType{ + struct SFuzzyData + { + enum EShapeType + { fstSphere, fstBox, fstForceU8 = u8(-1) }; - EShapeType m_ShapeType; - float m_SphereRadius; - Fvector m_BoxDimension; - s16 m_PointCount; - FvectorVec m_Positions; - SFuzzyData () + + EShapeType m_ShapeType; + float m_SphereRadius; + Fvector m_BoxDimension; + s16 m_PointCount; + FvectorVec m_Positions; + + SFuzzyData() { - m_ShapeType = fstSphere; - m_SphereRadius = 0.1f; - m_BoxDimension.set (0.1f,0.1f,0.1f); - m_PointCount = 1; - m_Positions.resize (m_PointCount,Fvector().set(0,0,0)); + m_ShapeType = fstSphere; + m_SphereRadius = 0.1f; + m_BoxDimension.set(0.1f, 0.1f, 0.1f); + m_PointCount = 1; + m_Positions.resize(m_PointCount, Fvector().set(0, 0, 0)); } - void Generate(Fvector& p) + + void Generate(Fvector &p) { - switch (m_ShapeType){ - case fstSphere: - p.random_point(m_SphereRadius); - break; - case fstBox: - p.random_point(m_BoxDimension); - break; + switch (m_ShapeType) + { + case fstSphere: + p.random_point(m_SphereRadius); + break; + case fstBox: + p.random_point(m_BoxDimension); + break; } } - void SaveStream(IWriter& F); - void LoadStream(IReader& F); - void SaveLTX(CInifile& ini, LPCSTR sect_name); - void LoadLTX(CInifile& ini, LPCSTR sect_name); + + void SaveStream(IWriter &F); + void LoadStream(IReader &F); + void SaveLTX(CInifile &ini, LPCSTR sect_name); + void LoadLTX(CInifile &ini, LPCSTR sect_name); }; - SFuzzyData* m_FuzzyData; - virtual void OnUpdateTransform(); - void __stdcall OnTypeChange (PropValue* value); + SFuzzyData *m_FuzzyData; + + virtual void OnUpdateTransform(); + void __stdcall OnTypeChange(PropValue *value); - void __stdcall OnFuzzyFlagChange (PropValue* value); - void __stdcall OnFuzzyDataChange (PropValue* value); - void __stdcall OnFuzzyTypeChange (PropValue* value); + void __stdcall OnFuzzyFlagChange(PropValue *value); + void __stdcall OnFuzzyDataChange(PropValue *value); + void __stdcall OnFuzzyTypeChange(PropValue *value); - void __stdcall OnFuzzyGenerateClick(ButtonValue* value, bool& bModif, bool& bSafe); - void __stdcall OnAutoClick (ButtonValue* value, bool& bModif, bool& bSafe); - void __stdcall OnNeedUpdate (PropValue* value); + void __stdcall OnFuzzyGenerateClick(ButtonValue *value, bool &bModif, bool &bSafe); + void __stdcall OnAutoClick(ButtonValue *value, bool &bModif, bool &bSafe); + void __stdcall OnNeedUpdate(PropValue *value); - void __stdcall OnPointDataChange(PropValue* value); - void __stdcall OnAttenuationDraw(CanvasValue* sender, void* canvas, const Irect& rect); - void __stdcall OnPointDataTestEqual(CanvasValue* a, CanvasValue* b, bool& res); + void __stdcall OnPointDataChange(PropValue *value); + void __stdcall OnAttenuationDraw(CanvasValue *sender, void *canvas, const Irect &rect); + void __stdcall OnPointDataTestEqual(CanvasValue *a, CanvasValue *b, bool &res); protected: -// virtual Fvector& GetPosition () { return m_D3D.position; } -// virtual void SetPosition (const Fvector& pos) { m_D3D.position.set(pos); UpdateTransform();} + // virtual Fvector& GetPosition() { return m_D3D.position; } + // virtual void SetPosition (const Fvector& pos) { m_D3D.position.set(pos); UpdateTransform();} public: - CLight (LPVOID data, LPCSTR name); - void Construct (LPVOID data); - virtual ~CLight (); - void CopyFrom (CLight* src); - virtual bool CanAttach () {return true;} + CLight(LPVOID data, LPCSTR name); + void Construct(LPVOID data); + virtual ~CLight(); + void CopyFrom(CLight *src); + + virtual bool CanAttach() + { + return true; + } // pick functions - virtual bool RayPick (float& distance, const Fvector& start, const Fvector& direction, - SRayPickInfo* pinf = NULL ); - virtual bool FrustumPick (const CFrustum& frustum); + virtual bool RayPick(float &distance, const Fvector &start, const Fvector &direction, + SRayPickInfo *pinf = NULL); + virtual bool FrustumPick(const CFrustum &frustum); // change position/orientation methods - virtual void Scale (Fvector& amount){;} + virtual void Scale(Fvector &amount) + { + ; + } // placement functions - virtual bool GetBox (Fbox& box) const; + virtual bool GetBox(Fbox &box) const; // file system function - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); - - - virtual void FillProp (LPCSTR pref, PropItemVec& items); - void FillSunProp (LPCSTR pref, PropItemVec& items); - void FillPointProp (LPCSTR pref, PropItemVec& items); - void FillSpotProp (LPCSTR pref, PropItemVec& items); - void FillAttProp (LPCSTR pref, PropItemVec& items); - virtual bool GetSummaryInfo (SSceneSummary* inf); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); + + + virtual void FillProp(LPCSTR pref, PropItemVec &items); + void FillSunProp(LPCSTR pref, PropItemVec &items); + void FillPointProp(LPCSTR pref, PropItemVec &items); + void FillSpotProp(LPCSTR pref, PropItemVec &items); + void FillAttProp(LPCSTR pref, PropItemVec &items); + virtual bool GetSummaryInfo(SSceneSummary *inf); // render utility function - void AffectD3D (BOOL flag); + void AffectD3D(BOOL flag); + + virtual void Render(int priority, bool strictB2F); + virtual void OnFrame(); + void Update(); - virtual void Render (int priority, bool strictB2F); - virtual void OnFrame (); - void Update (); + LPCSTR GetLControlName(); - LPCSTR GetLControlName (); - // events - virtual void OnShowHint (AStringVec& dest); -}; + virtual void OnShowHint(AStringVec &dest); +}; #endif /*_INCDEF_Light_H_*/ diff --git a/src/editors/LevelEditor/Edit/ELight_IO.cpp b/src/editors/LevelEditor/Edit/ELight_IO.cpp index 951fac05e44..13bcbbfcb1b 100644 --- a/src/editors/LevelEditor/Edit/ELight_IO.cpp +++ b/src/editors/LevelEditor/Edit/ELight_IO.cpp @@ -8,276 +8,291 @@ #include "LightAnimLibrary.h" #include "escenelighttools.h" -static const u32 LIGHT_VERSION = 0x0011; +static const u32 LIGHT_VERSION = 0x0011; + //---------------------------------------------------- -enum{ - LIGHT_CHUNK_VERSION = 0xB411, - LIGHT_CHUNK_FLAG = 0xB413, - LIGHT_CHUNK_BRIGHTNESS = 0xB425, - LIGHT_CHUNK_D3D_PARAMS = 0xB435, - LIGHT_CHUNK_USE_IN_D3D = 0xB436, - LIGHT_CHUNK_ROTATE = 0xB437, - LIGHT_CHUNK_ANIMREF = 0xB438, - LIGHT_CHUNK_FALLOFF_TEXTURE = 0xB439, - LIGHT_CHUNK_FUZZY_DATA = 0xB440, - LIGHT_CHUNK_LCONTROL = 0xB441, - LIGHT_CHUNK_PARAMS = 0xB442, +enum +{ + LIGHT_CHUNK_VERSION = 0xB411, + LIGHT_CHUNK_FLAG = 0xB413, + LIGHT_CHUNK_BRIGHTNESS = 0xB425, + LIGHT_CHUNK_D3D_PARAMS = 0xB435, + LIGHT_CHUNK_USE_IN_D3D = 0xB436, + LIGHT_CHUNK_ROTATE = 0xB437, + LIGHT_CHUNK_ANIMREF = 0xB438, + LIGHT_CHUNK_FALLOFF_TEXTURE = 0xB439, + LIGHT_CHUNK_FUZZY_DATA = 0xB440, + LIGHT_CHUNK_LCONTROL = 0xB441, + LIGHT_CHUNK_PARAMS = 0xB442, }; + //---------------------------------------------------- -void CLight::SFuzzyData::SaveLTX(CInifile& ini, LPCSTR sect_name) +void CLight::SFuzzyData::SaveLTX(CInifile &ini, LPCSTR sect_name) { - ini.w_u8 (sect_name, "fuzzy_shape_type", m_ShapeType); - ini.w_float (sect_name, "fuzzy_sphere_radius", m_SphereRadius); - ini.w_fvector3 (sect_name, "fuzzy_box_dim", m_BoxDimension); - ini.w_u32 (sect_name, "fuzzy_point_count", m_PointCount); + ini.w_u8(sect_name, "fuzzy_shape_type", m_ShapeType); + ini.w_float(sect_name, "fuzzy_sphere_radius", m_SphereRadius); + ini.w_fvector3(sect_name, "fuzzy_box_dim", m_BoxDimension); + ini.w_u32(sect_name, "fuzzy_point_count", m_PointCount); - string128 buff; - for(u32 idx=0; idx(); + m_FuzzyData = xr_new(); m_FuzzyData->LoadLTX(ini, sect_name); } - UpdateTransform (); - return true; + UpdateTransform(); + return true; } -void CLight::SaveLTX(CInifile& ini, LPCSTR sect_name) +void CLight::SaveLTX(CInifile &ini, LPCSTR sect_name) { - CCustomObject::SaveLTX(ini, sect_name); + CCustomObject::SaveLTX(ini, sect_name); - ini.w_u16 (sect_name, "version", LIGHT_VERSION); + ini.w_u16(sect_name, "version", LIGHT_VERSION); - ini.w_u32 (sect_name, "type", m_Type); - ini.w_fcolor (sect_name, "color", m_Color); - ini.w_float (sect_name, "brightness", m_Brightness); - ini.w_float (sect_name, "range", m_Range); - ini.w_float (sect_name, "attenuation0", m_Attenuation0); - ini.w_float (sect_name, "attenuation1", m_Attenuation1); - ini.w_float (sect_name, "attenuation2", m_Attenuation2); - ini.w_float (sect_name, "cone", m_Cone); - ini.w_float (sect_name, "virtual_size", m_VirtualSize); + ini.w_u32(sect_name, "type", m_Type); + ini.w_fcolor(sect_name, "color", m_Color); + ini.w_float(sect_name, "brightness", m_Brightness); + ini.w_float(sect_name, "range", m_Range); + ini.w_float(sect_name, "attenuation0", m_Attenuation0); + ini.w_float(sect_name, "attenuation1", m_Attenuation1); + ini.w_float(sect_name, "attenuation2", m_Attenuation2); + ini.w_float(sect_name, "cone", m_Cone); + ini.w_float(sect_name, "virtual_size", m_VirtualSize); - ini.w_bool (sect_name, "use_in_d3d", m_UseInD3D); - ini.w_u32 (sect_name, "light_flags", m_Flags.get()); - ini.w_u32 (sect_name, "light_control", m_LControl); + ini.w_bool(sect_name, "use_in_d3d", m_UseInD3D); + ini.w_u32(sect_name, "light_flags", m_Flags.get()); + ini.w_u32(sect_name, "light_control", m_LControl); - ini.w_string (sect_name,"anim_ref_name", (m_pAnimRef)?m_pAnimRef->cName.c_str():""); + ini.w_string(sect_name, "anim_ref_name", (m_pAnimRef) ? m_pAnimRef->cName.c_str() : ""); - ini.w_string (sect_name, "fallof_texture", m_FalloffTex.c_str()); + ini.w_string(sect_name, "fallof_texture", m_FalloffTex.c_str()); - if (m_Flags.is(ELight::flPointFuzzy)) + if (m_Flags.is(ELight::flPointFuzzy)) { - VERIFY (m_FuzzyData); + VERIFY(m_FuzzyData); m_FuzzyData->SaveLTX(ini, sect_name); } } -bool CLight::LoadStream(IReader& F) +bool CLight::LoadStream(IReader &F) { - u16 version = 0; + u16 version = 0; string1024 buf; - R_ASSERT(F.r_chunk(LIGHT_CHUNK_VERSION,&version)); - if((version!=0x0010)&&(version!=LIGHT_VERSION)){ - ELog.DlgMsg( mtError, "CLight: Unsupported version."); + R_ASSERT(F.r_chunk(LIGHT_CHUNK_VERSION, &version)); + if ((version!=0x0010)&&(version!=LIGHT_VERSION)) + { + ELog.DlgMsg(mtError, "CLight: Unsupported version."); return false; } - CCustomObject::LoadStream(F); + CCustomObject::LoadStream(F); if (F.find_chunk(LIGHT_CHUNK_PARAMS)) { - m_Type = (ELight::EType)F.r_u32(); - F.r_fcolor (m_Color); - m_Brightness = F.r_float(); - m_Range = F.r_float(); - m_Attenuation0 = F.r_float(); - m_Attenuation1 = F.r_float(); - m_Attenuation2 = F.r_float(); - m_Cone = F.r_float(); - m_VirtualSize = F.r_float(); - }else{ - R_ASSERT(F.find_chunk(LIGHT_CHUNK_D3D_PARAMS)); - Flight d3d; - F.r (&d3d,sizeof(d3d)); - m_Type = (ELight::EType)d3d.type; - m_Color.set (d3d.diffuse); - PPosition = d3d.position; - m_Range = d3d.range; - m_Attenuation0 = d3d.attenuation0; - m_Attenuation1 = d3d.attenuation1; - m_Attenuation2 = d3d.attenuation2; - m_Cone = d3d.phi; - R_ASSERT(F.r_chunk(LIGHT_CHUNK_BRIGHTNESS,&m_Brightness)); + m_Type = (ELight::EType)F.r_u32(); + F.r_fcolor(m_Color); + m_Brightness = F.r_float(); + m_Range = F.r_float(); + m_Attenuation0 = F.r_float(); + m_Attenuation1 = F.r_float(); + m_Attenuation2 = F.r_float(); + m_Cone = F.r_float(); + m_VirtualSize = F.r_float(); + } + else + { + R_ASSERT(F.find_chunk(LIGHT_CHUNK_D3D_PARAMS)); + Flight d3d; + F.r(&d3d, sizeof(d3d)); + m_Type = (ELight::EType)d3d.type; + m_Color.set(d3d.diffuse); + PPosition = d3d.position; + m_Range = d3d.range; + m_Attenuation0 = d3d.attenuation0; + m_Attenuation1 = d3d.attenuation1; + m_Attenuation2 = d3d.attenuation2; + m_Cone = d3d.phi; + R_ASSERT(F.r_chunk(LIGHT_CHUNK_BRIGHTNESS, &m_Brightness)); } - - R_ASSERT (F.r_chunk(LIGHT_CHUNK_USE_IN_D3D,&m_UseInD3D)); + + R_ASSERT(F.r_chunk(LIGHT_CHUNK_USE_IN_D3D, &m_UseInD3D)); if (F.find_chunk(LIGHT_CHUNK_FLAG)) - F.r(&m_Flags.flags,sizeof(m_Flags)); + F.r(&m_Flags.flags, sizeof(m_Flags)); if (F.find_chunk(LIGHT_CHUNK_LCONTROL)) - F.r(&m_LControl,sizeof(m_LControl)); + F.r(&m_LControl, sizeof(m_LControl)); - if (D3DLIGHT_DIRECTIONAL==m_Type) + if (D3DLIGHT_DIRECTIONAL==m_Type) { - ESceneLightTool* lt = dynamic_cast(ParentTool); VERIFY(lt); - lt->m_SunShadowDir.set(FRotation.x,FRotation.y); - ELog.DlgMsg( mtError, "CLight: Can't load sun."); - return false; + ESceneLightTool *lt = dynamic_cast(ParentTool); + VERIFY(lt); + lt->m_SunShadowDir.set(FRotation.x, FRotation.y); + ELog.DlgMsg(mtError, "CLight: Can't load sun."); + return false; } if (F.find_chunk(LIGHT_CHUNK_ANIMREF)) { - F.r_stringZ(buf,sizeof(buf)); - m_pAnimRef = LALib.FindItem(buf); - if (!m_pAnimRef) ELog.Msg(mtError, "Can't find light animation: %s",buf); + F.r_stringZ(buf, sizeof(buf)); + m_pAnimRef = LALib.FindItem(buf); + if (!m_pAnimRef) + ELog.Msg(mtError, "Can't find light animation: %s", buf); } if (F.find_chunk(LIGHT_CHUNK_FALLOFF_TEXTURE)) { - F.r_stringZ(m_FalloffTex); + F.r_stringZ(m_FalloffTex); } if (F.find_chunk(LIGHT_CHUNK_FUZZY_DATA)) { - m_FuzzyData = xr_new(); + m_FuzzyData = xr_new(); m_FuzzyData->LoadStream(F); - m_Flags.set(ELight::flPointFuzzy,TRUE); - }else{ - m_Flags.set(ELight::flPointFuzzy,FALSE); + m_Flags.set(ELight::flPointFuzzy, TRUE); + } + else + { + m_Flags.set(ELight::flPointFuzzy, FALSE); } - UpdateTransform (); + UpdateTransform(); return true; } + //---------------------------------------------------- -void CLight::SaveStream(IWriter& F) +void CLight::SaveStream(IWriter &F) { - CCustomObject::SaveStream(F); - - F.open_chunk (LIGHT_CHUNK_VERSION); - F.w_u16 (LIGHT_VERSION); - F.close_chunk (); - - F.open_chunk (LIGHT_CHUNK_PARAMS); - F.w_u32 (m_Type); - F.w_fcolor (m_Color); - F.w_float (m_Brightness); - F.w_float (m_Range); - F.w_float (m_Attenuation0); - F.w_float (m_Attenuation1); - F.w_float (m_Attenuation2); - F.w_float (m_Cone); - F.w_float (m_VirtualSize); - F.close_chunk (); - - F.w_chunk (LIGHT_CHUNK_USE_IN_D3D,&m_UseInD3D,sizeof(m_UseInD3D)); - F.w_chunk (LIGHT_CHUNK_FLAG,&m_Flags,sizeof(m_Flags)); - F.w_chunk (LIGHT_CHUNK_LCONTROL,&m_LControl,sizeof(m_LControl)); - - if (m_pAnimRef){ - F.open_chunk(LIGHT_CHUNK_ANIMREF); - F.w_stringZ (m_pAnimRef->cName); - F.close_chunk(); + CCustomObject::SaveStream(F); + + F.open_chunk(LIGHT_CHUNK_VERSION); + F.w_u16(LIGHT_VERSION); + F.close_chunk(); + + F.open_chunk(LIGHT_CHUNK_PARAMS); + F.w_u32(m_Type); + F.w_fcolor(m_Color); + F.w_float(m_Brightness); + F.w_float(m_Range); + F.w_float(m_Attenuation0); + F.w_float(m_Attenuation1); + F.w_float(m_Attenuation2); + F.w_float(m_Cone); + F.w_float(m_VirtualSize); + F.close_chunk(); + + F.w_chunk(LIGHT_CHUNK_USE_IN_D3D, &m_UseInD3D, sizeof(m_UseInD3D)); + F.w_chunk(LIGHT_CHUNK_FLAG, &m_Flags, sizeof(m_Flags)); + F.w_chunk(LIGHT_CHUNK_LCONTROL, &m_LControl, sizeof(m_LControl)); + + if (m_pAnimRef) + { + F.open_chunk(LIGHT_CHUNK_ANIMREF); + F.w_stringZ(m_pAnimRef->cName); + F.close_chunk(); } - if (m_FalloffTex.size()){ - F.open_chunk(LIGHT_CHUNK_FALLOFF_TEXTURE); - F.w_stringZ (m_FalloffTex); - F.close_chunk(); + if (m_FalloffTex.size()) + { + F.open_chunk(LIGHT_CHUNK_FALLOFF_TEXTURE); + F.w_stringZ(m_FalloffTex); + F.close_chunk(); } - if (m_Flags.is(ELight::flPointFuzzy)){ + if (m_Flags.is(ELight::flPointFuzzy)) + { VERIFY(m_FuzzyData); F.open_chunk(LIGHT_CHUNK_FUZZY_DATA); m_FuzzyData->SaveStream(F); F.close_chunk(); } } + //---------------------------------------------------- diff --git a/src/editors/LevelEditor/Edit/ELight_props.cpp b/src/editors/LevelEditor/Edit/ELight_props.cpp index 715bbc884c6..0d1955a601a 100644 --- a/src/editors/LevelEditor/Edit/ELight_props.cpp +++ b/src/editors/LevelEditor/Edit/ELight_props.cpp @@ -7,260 +7,297 @@ #include "ELight.h" #include "escenelighttools.h" #include "LightAnimLibrary.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" //---------------------------------------------------- -void CLight::OnAutoClick(ButtonValue* value, bool& bModif, bool& bSafe) +void CLight::OnAutoClick(ButtonValue *value, bool &bModif, bool &bSafe) { - ButtonValue* B = dynamic_cast(value); R_ASSERT(B); - switch(B->btn_num){ - case 0:{ - float P = 0.1f; - m_Attenuation0 = 1.f; - m_Attenuation1 = (m_Brightness-P-P*m_Range*m_Range*m_Attenuation2)/(P*m_Range); - clamp(m_Attenuation1,0.f,1.f); - }break; - case 1:{ - float P = 0.1f; - m_Attenuation0 = 1.f; - m_Attenuation2 = (m_Brightness-P-P*m_Range*m_Attenuation1)/(P*m_Range*m_Range); - clamp(m_Attenuation2,0.f,1.f); - } + ButtonValue *B = dynamic_cast(value); + R_ASSERT(B); + switch (B->btn_num) + { + case 0: + { + float P = 0.1f; + m_Attenuation0 = 1.f; + m_Attenuation1 = (m_Brightness-P-P*m_Range*m_Range*m_Attenuation2)/(P*m_Range); + clamp(m_Attenuation1, 0.f, 1.f); + } + break; + case 1: + { + float P = 0.1f; + m_Attenuation0 = 1.f; + m_Attenuation2 = (m_Brightness-P-P*m_Range*m_Attenuation1)/(P*m_Range*m_Range); + clamp(m_Attenuation2, 0.f, 1.f); + } } bModif = true; - OnPointDataChange(value); + OnPointDataChange(value); } -void CLight::OnFuzzyGenerateClick(ButtonValue* value, bool& bModif, bool& bSafe) +void CLight::OnFuzzyGenerateClick(ButtonValue *value, bool &bModif, bool &bSafe) { - ButtonValue* B = dynamic_cast(value); R_ASSERT(B); - switch(B->btn_num){ - case 0:{ - OnFuzzyDataChange(value); - }break; + ButtonValue *B = dynamic_cast(value); + R_ASSERT(B); + switch (B->btn_num) + { + case 0: + { + OnFuzzyDataChange(value); + } + break; } bModif = true; } -void CLight::OnFuzzyFlagChange(PropValue* value) +void CLight::OnFuzzyFlagChange(PropValue *value) { - if (m_Flags.is(ELight::flPointFuzzy)){ - m_FuzzyData = xr_new(); - OnFuzzyTypeChange (value); - }else{ - xr_delete (m_FuzzyData); - OnTypeChange (value); + if (m_Flags.is(ELight::flPointFuzzy)) + { + m_FuzzyData = xr_new(); + OnFuzzyTypeChange(value); + } + else + { + xr_delete(m_FuzzyData); + OnTypeChange(value); } } -void CLight::OnFuzzyTypeChange(PropValue* value) +void CLight::OnFuzzyTypeChange(PropValue *value) { - OnTypeChange (value); - OnFuzzyDataChange (value); + OnTypeChange(value); + OnFuzzyDataChange(value); } -void CLight::OnFuzzyDataChange(PropValue* value) +void CLight::OnFuzzyDataChange(PropValue *value) { VERIFY(m_FuzzyData); - m_FuzzyData->m_Positions.resize (m_FuzzyData->m_PointCount); - for (FvectorIt it=m_FuzzyData->m_Positions.begin(); it!=m_FuzzyData->m_Positions.end(); it++) - m_FuzzyData->Generate(*it); + m_FuzzyData->m_Positions.resize(m_FuzzyData->m_PointCount); + for (FvectorIt it = m_FuzzyData->m_Positions.begin(); it!=m_FuzzyData->m_Positions.end(); it++) + m_FuzzyData->Generate(*it); } #define X_GRID 14 #define Y_GRID 6 -void CLight::OnAttenuationDraw(CanvasValue* sender, void* _canvas, const Irect& _rect) +void CLight::OnAttenuationDraw(CanvasValue *sender, void *_canvas, const Irect &_rect) { - TCanvas* canvas = (TCanvas*)_canvas; - const TRect& rect = *((TRect*)&_rect); -// canvas + TCanvas *canvas = (TCanvas*)_canvas; + const TRect &rect = *((TRect*)&_rect); + // canvas int w = rect.Width(); int h = rect.Height(); - int x0= rect.left; - int y0= rect.top; + int x0 = rect.left; + int y0 = rect.top; canvas->Brush->Color = clBlack; canvas->FillRect(rect); canvas->Pen->Color = TColor(0x00006600); - canvas->MoveTo(x0,y0); - for (int i=0; iLineTo(x0+i*w/X_GRID,y0+h); - canvas->MoveTo(x0+(i+1)*w/X_GRID,y0+0); + canvas->MoveTo(x0, y0); + for (int i = 0; iLineTo(x0+i*w/X_GRID, y0+h); + canvas->MoveTo(x0+(i+1)*w/X_GRID, y0+0); } - canvas->MoveTo(x0+0,y0+0); - for (int j=0; jLineTo(x0+w,y0+j*h/Y_GRID); - canvas->MoveTo(x0+0,y0+(j+1)*h/Y_GRID); + canvas->MoveTo(x0+0, y0+0); + for (int j = 0; jLineTo(x0+w, y0+j*h/Y_GRID); + canvas->MoveTo(x0+0, y0+(j+1)*h/Y_GRID); } canvas->Pen->Color = clYellow; - canvas->MoveTo(x0+0,y0+h/2); - canvas->LineTo(x0+w,y0+h/2); + canvas->MoveTo(x0+0, y0+h/2); + canvas->LineTo(x0+w, y0+h/2); float d_cost = m_Range/w; AnsiString temp; -// float v = m_D3D.range; -// temp.sprintf("Range = %.2f",v); lbRange->Caption = temp; + // float v = m_D3D.range; + // temp.sprintf("Range = %.2f",v); lbRange->Caption = temp; canvas->Pen->Color = clLime; - if (!(fis_zero(m_Attenuation0)&&fis_zero(m_Attenuation1)&&fis_zero(m_Attenuation2))){ - for (int d=1; dMoveTo(x0+d,y); - else canvas->LineTo(x0+d,y); + b -= m_Brightness*R/(m_Range*(m_Attenuation0+m_Attenuation1*m_Range+m_Attenuation2*m_Range*m_Range)); + float bb = h-((h/(/*br_max*/3.f*2))*b+h/2); + int y = iFloor(y0+bb); + clamp(y, int(rect.Top), int(rect.Bottom)); + if (1==d) + canvas->MoveTo(x0+d, y); + else + canvas->LineTo(x0+d, y); } } } -void CLight::OnPointDataChange(PropValue* value) +void CLight::OnPointDataChange(PropValue *value) { - ExecCommand(COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void CLight::OnPointDataTestEqual(CanvasValue* a, CanvasValue* b, bool& res) +void CLight::OnPointDataTestEqual(CanvasValue *a, CanvasValue *b, bool &res) { - CLight* A = (CLight*)(a->tag); VERIFY(A); - CLight* B = (CLight*)(b->tag); VERIFY(B); - res = (fsimilar(A->m_Range,B->m_Range)&& - fsimilar(A->m_Attenuation0,B->m_Attenuation0)&& - fsimilar(A->m_Attenuation1,B->m_Attenuation1)&& - fsimilar(A->m_Attenuation2,B->m_Attenuation2)&& - fsimilar(A->m_Brightness,B->m_Brightness)); + CLight *A = (CLight*)(a->tag); + VERIFY(A); + CLight *B = (CLight*)(b->tag); + VERIFY(B); + res = (fsimilar(A->m_Range, B->m_Range)&& + fsimilar(A->m_Attenuation0, B->m_Attenuation0)&& + fsimilar(A->m_Attenuation1, B->m_Attenuation1)&& + fsimilar(A->m_Attenuation2, B->m_Attenuation2)&& + fsimilar(A->m_Brightness, B->m_Brightness)); } -void CLight::FillAttProp(LPCSTR pref, PropItemVec& items) +void CLight::FillAttProp(LPCSTR pref, PropItemVec &items) { - PropValue* V; - V=PHelper().CreateFloat (items, PrepareKey(pref, "Range"), &m_Range, 0.1f,1000.f); - V->OnChangeEvent.bind (this,&CLight::OnPointDataChange); - V=PHelper().CreateFloat (items, PrepareKey(pref, "Attenuation\\Constant"), &m_Attenuation0,0.f,1.f,0.0001f,6); - V->OnChangeEvent.bind (this,&CLight::OnPointDataChange); - V=PHelper().CreateFloat (items, PrepareKey(pref, "Attenuation\\Linear"), &m_Attenuation1,0.f,1.f,0.0001f,6); - V->OnChangeEvent.bind (this,&CLight::OnPointDataChange); - V=PHelper().CreateFloat (items, PrepareKey(pref, "Attenuation\\Quadratic"), &m_Attenuation2,0.f,1.f,0.0001f,6); - V->OnChangeEvent.bind (this,&CLight::OnPointDataChange); - ButtonValue* B=0; - B=PHelper().CreateButton(items, PrepareKey(pref, "Attenuation\\Auto"),"Linear,Quadratic",0); - B->OnBtnClickEvent.bind (this,&CLight::OnAutoClick); - CanvasValue* C=0; - C=PHelper().CreateCanvas (items, PrepareKey(pref, "Attenuation\\Graphic"), "", 64); - C->tag = (int)this; - C->OnDrawCanvasEvent.bind(this,&CLight::OnAttenuationDraw); - C->OnTestEqual.bind (this,&CLight::OnPointDataTestEqual); + PropValue *V; + V = PHelper().CreateFloat(items, PrepareKey(pref, "Range"), &m_Range, 0.1f, 1000.f); + V->OnChangeEvent.bind(this, &CLight::OnPointDataChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Attenuation\\Constant"), &m_Attenuation0, 0.f, 1.f, 0.0001f, 6); + V->OnChangeEvent.bind(this, &CLight::OnPointDataChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Attenuation\\Linear"), &m_Attenuation1, 0.f, 1.f, 0.0001f, 6); + V->OnChangeEvent.bind(this, &CLight::OnPointDataChange); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Attenuation\\Quadratic"), &m_Attenuation2, 0.f, 1.f, 0.0001f, 6); + V->OnChangeEvent.bind(this, &CLight::OnPointDataChange); + ButtonValue *B = 0; + B = PHelper().CreateButton(items, PrepareKey(pref, "Attenuation\\Auto"), "Linear,Quadratic", 0); + B->OnBtnClickEvent.bind(this, &CLight::OnAutoClick); + CanvasValue *C = 0; + C = PHelper().CreateCanvas(items, PrepareKey(pref, "Attenuation\\Graphic"), "", 64); + C->tag = (int)this; + C->OnDrawCanvasEvent.bind(this, &CLight::OnAttenuationDraw); + C->OnTestEqual.bind(this, &CLight::OnPointDataTestEqual); } -xr_token fuzzy_shape_types[]={ - { "Sphere", CLight::SFuzzyData::fstSphere }, - { "Box", CLight::SFuzzyData::fstBox }, - { 0, 0 } +xr_token fuzzy_shape_types[] = { + {"Sphere", CLight::SFuzzyData::fstSphere}, + {"Box", CLight::SFuzzyData::fstBox}, + {0, 0} }; -void CLight::FillPointProp(LPCSTR pref, PropItemVec& items) + +void CLight::FillPointProp(LPCSTR pref, PropItemVec &items) { - // flags - PHelper().CreateFlag32(items, PrepareKey(pref,"Usage\\LightMap"), &m_Flags, ELight::flAffectStatic); - PHelper().CreateFlag32(items, PrepareKey(pref,"Usage\\Dynamic"), &m_Flags, ELight::flAffectDynamic); - PHelper().CreateFlag32(items, PrepareKey(pref,"Usage\\Animated"), &m_Flags, ELight::flProcedural); -// PHelper().CreateFlag32 (items, PrepareKey(pref,"Flags\\Breakable"),&m_Flags, CLight::flBreaking); + // flags + PHelper().CreateFlag32(items, PrepareKey(pref, "Usage\\LightMap"), &m_Flags, ELight::flAffectStatic); + PHelper().CreateFlag32(items, PrepareKey(pref, "Usage\\Dynamic"), &m_Flags, ELight::flAffectDynamic); + PHelper().CreateFlag32(items, PrepareKey(pref, "Usage\\Animated"), &m_Flags, ELight::flProcedural); + // PHelper().CreateFlag32(items, PrepareKey(pref,"Flags\\Breakable"),&m_Flags, CLight::flBreaking); - FillAttProp (pref,items); - PropValue* P=0; - ButtonValue* B=0; - P=PHelper().CreateFlag32(items, PrepareKey(pref, "Fuzzy"), &m_Flags, ELight::flPointFuzzy); - P->OnChangeEvent.bind (this,&CLight::OnFuzzyFlagChange); - if (m_Flags.is(ELight::flPointFuzzy)){ - VERIFY (m_FuzzyData); - P=PHelper().CreateS16 (items, PrepareKey(pref, "Fuzzy\\Count"), &m_FuzzyData->m_PointCount,1,100); - P->OnChangeEvent.bind (this,&CLight::OnFuzzyDataChange); - B=PHelper().CreateButton (items, PrepareKey(pref, "Fuzzy\\Generate"),"Random",0); - B->OnBtnClickEvent.bind (this,&CLight::OnFuzzyGenerateClick); - P=PHelper().CreateToken8 (items, PrepareKey(pref, "Fuzzy\\Shape"), (u8*)&m_FuzzyData->m_ShapeType, fuzzy_shape_types); - P->OnChangeEvent.bind (this,&CLight::OnFuzzyTypeChange); - switch (m_FuzzyData->m_ShapeType){ - case CLight::SFuzzyData::fstSphere: - P=PHelper().CreateFloat(items, PrepareKey(pref, "Fuzzy\\Radius"), &m_FuzzyData->m_SphereRadius,0.01f,100.f,0.01f,2); - P->OnChangeEvent.bind (this,&CLight::OnFuzzyDataChange); - break; - case CLight::SFuzzyData::fstBox: - P=PHelper().CreateVector(items, PrepareKey(pref, "Fuzzy\\Half Dimension"),&m_FuzzyData->m_BoxDimension,0.01f,100.f,0.01f,2); - P->OnChangeEvent.bind (this,&CLight::OnFuzzyDataChange); - break; + FillAttProp(pref, items); + PropValue *P = 0; + ButtonValue *B = 0; + P = PHelper().CreateFlag32(items, PrepareKey(pref, "Fuzzy"), &m_Flags, ELight::flPointFuzzy); + P->OnChangeEvent.bind(this, &CLight::OnFuzzyFlagChange); + if (m_Flags.is(ELight::flPointFuzzy)) + { + VERIFY(m_FuzzyData); + P = PHelper().CreateS16(items, PrepareKey(pref, "Fuzzy\\Count"), &m_FuzzyData->m_PointCount, 1, 100); + P->OnChangeEvent.bind(this, &CLight::OnFuzzyDataChange); + B = PHelper().CreateButton(items, PrepareKey(pref, "Fuzzy\\Generate"), "Random", 0); + B->OnBtnClickEvent.bind(this, &CLight::OnFuzzyGenerateClick); + P = PHelper().CreateToken8(items, PrepareKey(pref, "Fuzzy\\Shape"), (u8*)&m_FuzzyData->m_ShapeType, fuzzy_shape_types); + P->OnChangeEvent.bind(this, &CLight::OnFuzzyTypeChange); + switch (m_FuzzyData->m_ShapeType) + { + case CLight::SFuzzyData::fstSphere: + P = PHelper().CreateFloat(items, PrepareKey(pref, "Fuzzy\\Radius"), &m_FuzzyData->m_SphereRadius, 0.01f, 100.f, 0.01f, 2); + P->OnChangeEvent.bind(this, &CLight::OnFuzzyDataChange); + break; + case CLight::SFuzzyData::fstBox: + P = PHelper().CreateVector(items, PrepareKey(pref, "Fuzzy\\Half Dimension"), &m_FuzzyData->m_BoxDimension, 0.01f, 100.f, 0.01f, 2); + P->OnChangeEvent.bind(this, &CLight::OnFuzzyDataChange); + break; } } } + //---------------------------------------------------- -void CLight::FillSpotProp(LPCSTR pref, PropItemVec& items) +void CLight::FillSpotProp(LPCSTR pref, PropItemVec &items) { - // flags - PHelper().CreateFlag32(items, PrepareKey(pref,"Usage\\LightMap"), &m_Flags, ELight::flAffectStatic); - PHelper().CreateFlag32(items, PrepareKey(pref,"Usage\\Dynamic"), &m_Flags, ELight::flAffectDynamic); - PHelper().CreateFlag32(items, PrepareKey(pref,"Usage\\Animated"), &m_Flags, ELight::flProcedural); -// PHelper().CreateFlag32 (items, PHelper().PrepareKey(pref,"Flags\\Breakable"),&m_Flags, CLight::flBreaking); + // flags + PHelper().CreateFlag32(items, PrepareKey(pref, "Usage\\LightMap"), &m_Flags, ELight::flAffectStatic); + PHelper().CreateFlag32(items, PrepareKey(pref, "Usage\\Dynamic"), &m_Flags, ELight::flAffectDynamic); + PHelper().CreateFlag32(items, PrepareKey(pref, "Usage\\Animated"), &m_Flags, ELight::flProcedural); + // PHelper().CreateFlag32(items, PHelper().PrepareKey(pref,"Flags\\Breakable"),&m_Flags, CLight::flBreaking); - FillAttProp (pref,items); - PHelper().CreateAngle (items, PrepareKey(pref, "Spot R1\\Cone Angle"), &m_Cone, 0.1f,deg2rad(120.f),0.01f,2); - PHelper().CreateChoose (items, PrepareKey(pref, "Spot R1\\Texture"), &m_FalloffTex, smTexture); + FillAttProp(pref, items); + PHelper().CreateAngle(items, PrepareKey(pref, "Spot R1\\Cone Angle"), &m_Cone, 0.1f, deg2rad(120.f), 0.01f, 2); + PHelper().CreateChoose(items, PrepareKey(pref, "Spot R1\\Texture"), &m_FalloffTex, smTexture); } + //---------------------------------------------------- -xr_token token_light_type[ ] = { - { "Point", ELight::ltPoint }, -//. andy { "Spot", ELight::ltSpot }, - { 0, 0 } +xr_token token_light_type[ ] = { + {"Point", ELight::ltPoint}, + //. andy { "Spot", ELight::ltSpot }, + {0, 0} }; -void CLight::FillProp(LPCSTR pref, PropItemVec& items) +void CLight::FillProp(LPCSTR pref, PropItemVec &items) { - inherited::FillProp(pref,items); + inherited::FillProp(pref, items); - PropValue* V=0; + PropValue *V = 0; - V=PHelper().CreateToken32 (items, PrepareKey(pref,"Type"), (u32*)&m_Type,token_light_type); - V->OnChangeEvent.bind (this,&CLight::OnTypeChange); - V=PHelper().CreateFColor(items, PrepareKey(pref,"Color"), &m_Color); - V->OnChangeEvent.bind (this,&CLight::OnNeedUpdate); - V=PHelper().CreateFloat (items, PrepareKey(pref,"Brightness"), &m_Brightness,-3.f,3.f,0.1f,2); - V->OnChangeEvent.bind (this,&CLight::OnPointDataChange); + V = PHelper().CreateToken32(items, PrepareKey(pref, "Type"), (u32*)&m_Type, token_light_type); + V->OnChangeEvent.bind(this, &CLight::OnTypeChange); + V = PHelper().CreateFColor(items, PrepareKey(pref, "Color"), &m_Color); + V->OnChangeEvent.bind(this, &CLight::OnNeedUpdate); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Brightness"), &m_Brightness, -3.f, 3.f, 0.1f, 2); + V->OnChangeEvent.bind(this, &CLight::OnPointDataChange); - ESceneLightTool* lt = dynamic_cast(ParentTool); VERIFY(lt); - PHelper().CreateRToken32(items,PrepareKey(pref,"Light Control"), &m_LControl, &*lt->lcontrols.begin(), lt->lcontrols.size()); + ESceneLightTool *lt = dynamic_cast(ParentTool); + VERIFY(lt); + PHelper().CreateRToken32(items, PrepareKey(pref, "Light Control"), &m_LControl, &*lt->lcontrols.begin(), lt->lcontrols.size()); - switch(m_Type){ - case ELight::ltPoint: FillPointProp (pref, items); break; - case ELight::ltSpot: FillSpotProp (pref, items); break; - default: THROW; + switch (m_Type) + { + case ELight::ltPoint: FillPointProp(pref, items); + break; + case ELight::ltSpot: FillSpotProp(pref, items); + break; + default: THROW; } - PHelper().CreateBOOL (items, PrepareKey(pref,"Use In D3D"), &m_UseInD3D); + PHelper().CreateBOOL(items, PrepareKey(pref, "Use In D3D"), &m_UseInD3D); } -void CLight::OnTypeChange(PropValue* value) +void CLight::OnTypeChange(PropValue *value) { - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); - Update (); + Update(); } + //---------------------------------------------------- -void CLight::OnShowHint(AStringVec& dest){ +void CLight::OnShowHint(AStringVec &dest) +{ CCustomObject::OnShowHint(dest); AnsiString temp; temp.sprintf("Type: "); - switch(m_Type){ - case ELight::ltPoint: temp+="point"; break; - case ELight::ltSpot: temp+="spot"; break; - default: temp+="undef"; + switch (m_Type) + { + case ELight::ltPoint: temp += "point"; + break; + case ELight::ltSpot: temp += "spot"; + break; + default: temp += "undef"; } dest.push_back(temp); temp = "Flags: "; - if (m_Flags.is(ELight::flAffectStatic)) temp+="Stat "; - if (m_Flags.is(ELight::flAffectDynamic)) temp+="Dyn "; - if (m_Flags.is(ELight::flProcedural)) temp+="Proc "; + if (m_Flags.is(ELight::flAffectStatic)) + temp += "Stat "; + if (m_Flags.is(ELight::flAffectDynamic)) + temp += "Dyn "; + if (m_Flags.is(ELight::flProcedural)) + temp += "Proc "; dest.push_back(temp); - temp.sprintf("Pos: %3.2f, %3.2f, %3.2f",PPosition.x,PPosition.y,PPosition.z); + temp.sprintf("Pos: %3.2f, %3.2f, %3.2f", PPosition.x, PPosition.y, PPosition.z); dest.push_back(temp); } - diff --git a/src/editors/LevelEditor/Edit/EParticlesObject.cpp b/src/editors/LevelEditor/Edit/EParticlesObject.cpp index 6bfecc5c8b5..e80b2ebf67a 100644 --- a/src/editors/LevelEditor/Edit/EParticlesObject.cpp +++ b/src/editors/LevelEditor/Edit/EParticlesObject.cpp @@ -7,7 +7,7 @@ #include "EParticlesObject.h" #include "../ECORE/Editor/D3DUtils.h" #include "..\..\Layers\xrRender\PSLibrary.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #define CPSOBJECT_VERSION 0x0013 //---------------------------------------------------- @@ -21,301 +21,335 @@ //using namespace PS; -EParticlesObject::EParticlesObject(LPVOID data, LPCSTR name):CCustomObject(data,name) +EParticlesObject::EParticlesObject(LPVOID data, LPCSTR name): CCustomObject(data, name) { - Construct(data); + Construct(data); } + //---------------------------------------------------- void EParticlesObject::Construct(LPVOID data) { - ClassID = OBJCLASS_PS; - m_Particles = 0; + ClassID = OBJCLASS_PS; + m_Particles = 0; m_GameType.SetDefaults(); } + //---------------------------------------------------- EParticlesObject::~EParticlesObject() { - ::Render->model_Delete (dynamic_cast(m_Particles) ); + ::Render->model_Delete(dynamic_cast(m_Particles)); } + //---------------------------------------------------- -bool EParticlesObject::GetBox( Fbox& box ) const +bool EParticlesObject::GetBox(Fbox &box) const { - box.set( PPosition, PPosition ); - box.min.x -= PSOBJECT_SIZE; - box.min.y -= PSOBJECT_SIZE; - box.min.z -= PSOBJECT_SIZE; - box.max.x += PSOBJECT_SIZE; - box.max.y += PSOBJECT_SIZE; - box.max.z += PSOBJECT_SIZE; + box.set(PPosition, PPosition); + box.min.x -= PSOBJECT_SIZE; + box.min.y -= PSOBJECT_SIZE; + box.min.z -= PSOBJECT_SIZE; + box.max.x += PSOBJECT_SIZE; + box.max.y += PSOBJECT_SIZE; + box.max.z += PSOBJECT_SIZE; return true; } + //---------------------------------------------------- void EParticlesObject::OnUpdateTransform() { - inherited::OnUpdateTransform (); - Fvector v={0.f,0.f,0.f}; - if (m_Particles) m_Particles->UpdateParent(_Transform(),v,FALSE); + inherited::OnUpdateTransform(); + Fvector v = {0.f,0.f,0.f}; + if (m_Particles) + m_Particles->UpdateParent(_Transform(), v, FALSE); } + //---------------------------------------------------- void EParticlesObject::OnFrame() { - inherited::OnFrame(); - Fbox bb; GetBox(bb); + inherited::OnFrame(); + Fbox bb; + GetBox(bb); if (::Render->occ_visible(bb)) - if (m_Particles) - m_Particles->OnFrame(EDevice.dwTimeDelta); + if (m_Particles) + m_Particles->OnFrame(EDevice.dwTimeDelta); } + //---------------------------------------------------- void EParticlesObject::Render(int priority, bool strictB2F) { - inherited::Render(priority,strictB2F); - Fbox bb; GetBox(bb); - if (::Render->occ_visible(bb)){ + inherited::Render(priority, strictB2F); + Fbox bb; + GetBox(bb); + if (::Render->occ_visible(bb)) + { RCache.set_xform_world(Fidentity); - if (1==priority){ - if (false==strictB2F){ + if (1==priority) + { + if (false==strictB2F) + { // draw emitter - EDevice.SetShader(EDevice.m_WireShader); - if( !Selected() ) - DU_impl.DrawCross (PPosition,0.30f,0.1f,0.3f,0.3f,0.3f,0.3f,0xFFFFEBAA,false); - - Fvector p = PPosition; - DU_impl.DrawRomboid (p,0.1f,0x0AFFEBAA); - if( Selected() ) + EDevice.SetShader(EDevice.m_WireShader); + if (!Selected()) + DU_impl.DrawCross(PPosition, 0.30f, 0.1f, 0.3f, 0.3f, 0.3f, 0.3f, 0xFFFFEBAA, false); + + Fvector p = PPosition; + DU_impl.DrawRomboid(p, 0.1f, 0x0AFFEBAA); + if (Selected()) { - Fbox bb; GetBox(bb); + Fbox bb; + GetBox(bb); u32 clr = 0xFFFFFFFF; - DU_impl.DrawSelectionBoxB(bb,&clr); + DU_impl.DrawSelectionBoxB(bb, &clr); } } } if (m_Particles) - ::Render->model_Render(dynamic_cast(m_Particles), _Transform(),priority,strictB2F,1.f); + ::Render->model_Render(dynamic_cast(m_Particles), _Transform(), priority, strictB2F, 1.f); } } + //---------------------------------------------------- void EParticlesObject::RenderSingle() { - Render(1,false); - Render(1,true); + Render(1, false); + Render(1, true); } + //---------------------------------------------------- -bool EParticlesObject::FrustumPick(const CFrustum& frustum) +bool EParticlesObject::FrustumPick(const CFrustum &frustum) { - return (frustum.testSphere_dirty(PPosition,PSOBJECT_SIZE))?true:false; + return (frustum.testSphere_dirty(PPosition,PSOBJECT_SIZE)) ? true : false; } + //---------------------------------------------------- -bool EParticlesObject::RayPick(float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf) +bool EParticlesObject::RayPick(float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf) { - Fvector pos,ray2; + Fvector pos, ray2; pos.set(PPosition); - ray2.sub( pos, start ); + ray2.sub(pos, start); float d = ray2.dotproduct(direction); - if( d > 0 ){ + if (d>0) + { float d2 = ray2.magnitude(); - if( ((d2*d2-d*d) < (PSOBJECT_SIZE*PSOBJECT_SIZE)) && (d>PSOBJECT_SIZE) ){ - if (dPSOBJECT_SIZE)) + { + if (dPlay(); + if (m_Particles) + m_Particles->Play(); } + //---------------------------------------------------- void EParticlesObject::Stop() { - if (m_Particles) m_Particles->Stop(); + if (m_Particles) + m_Particles->Stop(); } + //---------------------------------------------------- -bool EParticlesObject::LoadLTX(CInifile& ini, LPCSTR sect_name) +bool EParticlesObject::LoadLTX(CInifile &ini, LPCSTR sect_name) { - u32 version = ini.r_u32(sect_name,"version"); + u32 version = ini.r_u32(sect_name, "version"); - inherited::LoadLTX(ini, sect_name); + inherited::LoadLTX(ini, sect_name); - if(version>=0x0012) - m_GameType.LoadLTX(ini, sect_name, false); + if (version>=0x0012) + m_GameType.LoadLTX(ini, sect_name, false); - m_RefName = ini.r_string(sect_name, "ref_name"); + m_RefName = ini.r_string(sect_name, "ref_name"); if (!Compile(*m_RefName)) { - ELog.DlgMsg( mtError, "EParticlesObject: '%s' not found in library", *m_RefName ); + ELog.DlgMsg(mtError, "EParticlesObject: '%s' not found in library", *m_RefName); return false; } return true; } -void EParticlesObject::SaveLTX(CInifile& ini, LPCSTR sect_name) +void EParticlesObject::SaveLTX(CInifile &ini, LPCSTR sect_name) { - CCustomObject::SaveLTX(ini, sect_name); + CCustomObject::SaveLTX(ini, sect_name); - ini.w_u32 (sect_name, "version", CPSOBJECT_VERSION); + ini.w_u32(sect_name, "version", CPSOBJECT_VERSION); - ini.w_string (sect_name, "ref_name", m_RefName.c_str()); - m_GameType.SaveLTX (ini, sect_name); + ini.w_string(sect_name, "ref_name", m_RefName.c_str()); + m_GameType.SaveLTX(ini, sect_name); } -bool EParticlesObject::LoadStream(IReader& F) +bool EParticlesObject::LoadStream(IReader &F) { - u16 version = 0; + u16 version = 0; - R_ASSERT(F.r_chunk(CPSOBJECT_CHUNK_VERSION,&version)); - if(version<0x0011) + R_ASSERT(F.r_chunk(CPSOBJECT_CHUNK_VERSION, &version)); + if (version<0x0011) { - ELog.DlgMsg( mtError, "PSObject: Unsupported version."); + ELog.DlgMsg(mtError, "PSObject: Unsupported version."); return false; } - inherited::LoadStream(F); + inherited::LoadStream(F); R_ASSERT(F.find_chunk(CPSOBJECT_CHUNK_REFERENCE)); F.r_stringZ(m_RefName); - if(version>=0x0013) + if (version>=0x0013) { - R_ASSERT(F.find_chunk(CPSOBJECT_CHUNK_GAMETYPE)); - m_GameType.LoadStream(F); + R_ASSERT(F.find_chunk(CPSOBJECT_CHUNK_GAMETYPE)); + m_GameType.LoadStream(F); } if (!Compile(*m_RefName)) { - ELog.DlgMsg( mtError, "EParticlesObject: '%s' not found in library", *m_RefName ); + ELog.DlgMsg(mtError, "EParticlesObject: '%s' not found in library", *m_RefName); return false; } return true; } + //---------------------------------------------------- -void EParticlesObject::SaveStream(IWriter& F) +void EParticlesObject::SaveStream(IWriter &F) { - inherited::SaveStream(F); + inherited::SaveStream(F); - F.open_chunk (CPSOBJECT_CHUNK_VERSION); - F.w_u16 (CPSOBJECT_VERSION); - F.close_chunk (); + F.open_chunk(CPSOBJECT_CHUNK_VERSION); + F.w_u16(CPSOBJECT_VERSION); + F.close_chunk(); - F.open_chunk (CPSOBJECT_CHUNK_REFERENCE); - F.w_stringZ (m_RefName); - F.close_chunk (); + F.open_chunk(CPSOBJECT_CHUNK_REFERENCE); + F.w_stringZ(m_RefName); + F.close_chunk(); - F.open_chunk (CPSOBJECT_CHUNK_GAMETYPE); - m_GameType.SaveStream(F); - F.close_chunk (); + F.open_chunk(CPSOBJECT_CHUNK_GAMETYPE); + m_GameType.SaveStream(F); + F.close_chunk(); } + //---------------------------------------------------- -void EParticlesObject::OnDeviceCreate() -{ -} +void EParticlesObject::OnDeviceCreate() {} -void EParticlesObject::OnDeviceDestroy() -{ -} +void EParticlesObject::OnDeviceDestroy() {} -bool EParticlesObject::ExportGame(SExportStreams* F) +bool EParticlesObject::ExportGame(SExportStreams *F) { - SExportStreamItem& I = F->pe_static; + SExportStreamItem &I = F->pe_static; - if(I.chunk==0) + if (I.chunk==0) { - I.stream.open_chunk (I.chunk++); - I.stream.w_u32 (1); //version - I.stream.close_chunk (); + I.stream.open_chunk(I.chunk++); + I.stream.w_u32(1); //version + I.stream.close_chunk(); } - - I.stream.open_chunk (I.chunk++); - I.stream.w_u16 (m_GameType.m_GameType.get()); - I.stream.w_stringZ (m_RefName); - I.stream.w (&_Transform(),sizeof(Fmatrix)); - I.stream.close_chunk (); + + I.stream.open_chunk(I.chunk++); + I.stream.w_u16(m_GameType.m_GameType.get()); + I.stream.w_stringZ(m_RefName); + I.stream.w(&_Transform(), sizeof(Fmatrix)); + I.stream.close_chunk(); return true; } + //---------------------------------------------------- bool EParticlesObject::Compile(LPCSTR ref_name) { - ::Render->model_Delete (dynamic_cast(m_Particles) ); + ::Render->model_Delete(dynamic_cast(m_Particles)); if (ref_name) { - IRenderVisual* base = ::Render->model_CreateParticles(ref_name); - m_Particles = dynamic_cast(base); - if (m_Particles){ - UpdateTransform (); - m_RefName = ref_name; + IRenderVisual *base = ::Render->model_CreateParticles(ref_name); + m_Particles = dynamic_cast(base); + if (m_Particles) + { + UpdateTransform(); + m_RefName = ref_name; return true; } } - m_RefName = ""; + m_RefName = ""; return false; } -void EParticlesObject::OnRefChange(PropValue* V) +void EParticlesObject::OnRefChange(PropValue *V) { - if (!Compile(*m_RefName)){ - ELog.Msg( mtError, "Can't compile particle system '%s'", *m_RefName ); - }else{ - ExecCommand(COMMAND_REFRESH_PROPERTIES); + if (!Compile(*m_RefName)) + { + ELog.Msg(mtError, "Can't compile particle system '%s'", *m_RefName); + } + else + { + ExecCommand(COMMAND_REFRESH_PROPERTIES); } } -void EParticlesObject::OnControlClick(ButtonValue* sender, bool& bModif, bool& bSafe) +void EParticlesObject::OnControlClick(ButtonValue *sender, bool &bModif, bool &bSafe) { - ButtonValue* V = dynamic_cast(sender); R_ASSERT(V); - switch (V->btn_num){ - case 0: Play(); break; - case 1: Stop(); break; - } + ButtonValue *V = dynamic_cast(sender); + R_ASSERT(V); + switch (V->btn_num) + { + case 0: Play(); + break; + case 1: Stop(); + break; + } UI->RedrawScene(); bModif = false; } -void EParticlesObject::FillProp(LPCSTR pref, PropItemVec& items) +void EParticlesObject::FillProp(LPCSTR pref, PropItemVec &items) { - inherited::FillProp(pref, items); - PropValue* V; - V=PHelper().CreateChoose (items,PrepareKey(pref, "Reference"),&m_RefName, smParticles); - V->OnChangeEvent.bind (this,&EParticlesObject::OnRefChange); - ButtonValue* B; - B=PHelper().CreateButton (items,PrepareKey(pref,"Controls"), "Play,Stop",0); - B->OnBtnClickEvent.bind (this,&EParticlesObject::OnControlClick); - - m_GameType.FillProp (pref, items); + inherited::FillProp(pref, items); + PropValue *V; + V = PHelper().CreateChoose(items, PrepareKey(pref, "Reference"), &m_RefName, smParticles); + V->OnChangeEvent.bind(this, &EParticlesObject::OnRefChange); + ButtonValue *B; + B = PHelper().CreateButton(items, PrepareKey(pref, "Controls"), "Play,Stop", 0); + B->OnBtnClickEvent.bind(this, &EParticlesObject::OnControlClick); + + m_GameType.FillProp(pref, items); } + //---------------------------------------------------- -bool EParticlesObject::GetSummaryInfo(SSceneSummary* inf) +bool EParticlesObject::GetSummaryInfo(SSceneSummary *inf) { - inherited::GetSummaryInfo (inf); -/* - if (!m_RefName.IsEmpty()&&m_PE.GetDefinition()){ - inf->pe_static.insert(m_PE.GetDefinition()->m_Name); - if (m_PE.GetDefinition()->m_TextureName&&m_PE.GetDefinition()->m_TextureName[0]) inf->textures.insert(ChangeFileExt(m_PE.GetDefinition()->m_TextureName,"").LowerCase()); - } - inf->pe_static_cnt++; -*/ - return true; + inherited::GetSummaryInfo(inf); + /* + if (!m_RefName.IsEmpty()&&m_PE.GetDefinition()){ + inf->pe_static.insert(m_PE.GetDefinition()->m_Name); + if (m_PE.GetDefinition()->m_TextureName&&m_PE.GetDefinition()->m_TextureName[0]) inf->textures.insert(ChangeFileExt(m_PE.GetDefinition()->m_TextureName,"").LowerCase()); + } + inf->pe_static_cnt++; + */ + return true; } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/EParticlesObject.h b/src/editors/LevelEditor/Edit/EParticlesObject.h index 59bfe2f4e5e..2a68cdfb047 100644 --- a/src/editors/LevelEditor/Edit/EParticlesObject.h +++ b/src/editors/LevelEditor/Edit/EParticlesObject.h @@ -12,54 +12,71 @@ class EParticlesObject: public CCustomObject { - typedef CCustomObject inherited; - Fbox m_BBox; - shared_str m_RefName; + typedef CCustomObject inherited; + Fbox m_BBox; + shared_str m_RefName; - IParticleCustom* m_Particles; - GameTypeChooser m_GameType; + IParticleCustom *m_Particles; + GameTypeChooser m_GameType; - void __stdcall OnRefChange (PropValue* V); - void __stdcall OnControlClick (ButtonValue* sender, bool& bModif, bool& bSafe); + void __stdcall OnRefChange(PropValue *V); + void __stdcall OnControlClick(ButtonValue *sender, bool &bModif, bool &bSafe); public: - EParticlesObject (LPVOID data, LPCSTR name); - void Construct (LPVOID data); - virtual ~EParticlesObject (); - virtual bool CanAttach () {return true;} + EParticlesObject(LPVOID data, LPCSTR name); + void Construct(LPVOID data); + virtual ~EParticlesObject(); - IParticleCustom* GetParticles (){return m_Particles;} - LPCSTR GetReferenceName (){return m_Particles?*m_Particles->Name():0;} + virtual bool CanAttach() + { + return true; + } - void RenderSingle (); - virtual void Render (int priority, bool strictB2F); - virtual bool RayPick (float& distance, const Fvector& start, const Fvector& direction, - SRayPickInfo* pinf = NULL ); - virtual bool FrustumPick (const CFrustum& frustum); + IParticleCustom *GetParticles() + { + return m_Particles; + } - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); + LPCSTR GetReferenceName() + { + return m_Particles ? *m_Particles->Name() : 0; + } - virtual bool ExportGame (SExportStreams* data); - virtual bool GetBox (Fbox& box) const; - virtual void OnFrame (); + void RenderSingle(); + virtual void Render(int priority, bool strictB2F); + virtual bool RayPick(float &distance, const Fvector &start, const Fvector &direction, + SRayPickInfo *pinf = NULL); + virtual bool FrustumPick(const CFrustum &frustum); - void Play (); - void Stop (); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); - virtual void OnUpdateTransform (); + virtual bool ExportGame(SExportStreams *data); + virtual bool GetBox(Fbox &box) const; + virtual void OnFrame(); - IC bool RefCompare (LPCSTR ref_name){VERIFY(ref_name&&ref_name[0]); return (0==stricmp(ref_name,GetReferenceName()));} + void Play(); + void Stop(); + + virtual void OnUpdateTransform(); + + IC + + bool RefCompare(LPCSTR ref_name) + { + VERIFY(ref_name&&ref_name[0]); + return (0==stricmp(ref_name, GetReferenceName())); + } + + bool Compile(LPCSTR ref_name); - bool Compile (LPCSTR ref_name); - // device dependent routine - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); - virtual void FillProp (LPCSTR pref, PropItemVec& items); - virtual bool GetSummaryInfo (SSceneSummary* inf); + virtual void FillProp(LPCSTR pref, PropItemVec &items); + virtual bool GetSummaryInfo(SSceneSummary *inf); }; #endif diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapControls.cpp b/src/editors/LevelEditor/Edit/ESceneAIMapControls.cpp index e45b1836ce9..e19af9b974e 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapControls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneAIMapControls.cpp @@ -3,130 +3,154 @@ #include "ESceneAIMapControls.h" #include "ESceneAIMapTools.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "FrameAIMap.h" #include "scene.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" //------------------------------------------------------------------------------ // Node Add //------------------------------------------------------------------------------ -TUI_ControlAIMapNodeAdd::TUI_ControlAIMapNodeAdd(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent){ -} +TUI_ControlAIMapNodeAdd::TUI_ControlAIMapNodeAdd(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} bool __fastcall TUI_ControlAIMapNodeAdd::Start(TShiftState Shift) { - append_nodes = 0; - Fvector p; - ESceneAIMapTool* S = (ESceneAIMapTool*)parent_tool; - if (S->PickObjects(p,UI->m_CurrentRStart,UI->m_CurrentRDir,UI->ZFar())){ - S->SelectObjects (false); - append_nodes = S->AddNode(p,((TfraAIMap*)S->pFrame)->ebIgnoreConstraints->Down,((TfraAIMap*)S->pFrame)->ebAutoLink->Down,S->m_BrushSize); - if (!Shift.Contains(ssAlt)){ - if (append_nodes) Scene->UndoSave(); - ResetActionToSelect(); + append_nodes = 0; + Fvector p; + ESceneAIMapTool *S = (ESceneAIMapTool*)parent_tool; + if (S->PickObjects(p, UI->m_CurrentRStart, UI->m_CurrentRDir, UI->ZFar())) + { + S->SelectObjects(false); + append_nodes = S->AddNode(p, ((TfraAIMap*)S->pFrame)->ebIgnoreConstraints->Down, ((TfraAIMap*)S->pFrame)->ebAutoLink->Down, S->m_BrushSize); + if (!Shift.Contains(ssAlt)) + { + if (append_nodes) + Scene->UndoSave(); + ResetActionToSelect(); return false; - }else return true; + } + else + return true; } return false; } + void TUI_ControlAIMapNodeAdd::Move(TShiftState _Shift) { - Fvector p; - ESceneAIMapTool* S = (ESceneAIMapTool*)parent_tool; - if (S->PickObjects(p,UI->m_CurrentRStart,UI->m_CurrentRDir,UI->ZFar())){ - append_nodes+=S->AddNode(p,((TfraAIMap*)S->pFrame)->ebIgnoreConstraints->Down,((TfraAIMap*)S->pFrame)->ebAutoLink->Down,S->m_BrushSize); + Fvector p; + ESceneAIMapTool *S = (ESceneAIMapTool*)parent_tool; + if (S->PickObjects(p, UI->m_CurrentRStart, UI->m_CurrentRDir, UI->ZFar())) + { + append_nodes += S->AddNode(p, ((TfraAIMap*)S->pFrame)->ebIgnoreConstraints->Down, ((TfraAIMap*)S->pFrame)->ebAutoLink->Down, S->m_BrushSize); } } + bool TUI_ControlAIMapNodeAdd::End(TShiftState _Shift) { - if (!_Shift.Contains(ssAlt)) ResetActionToSelect(); - if (append_nodes) Scene->UndoSave(); - return true; + if (!_Shift.Contains(ssAlt)) + ResetActionToSelect(); + if (append_nodes) + Scene->UndoSave(); + return true; } //------------------------------------------------------------------------------------ // Node Move //------------------------------------------------------------------------------------ -TUI_ControlAIMapNodeMove::TUI_ControlAIMapNodeMove(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent) -{ -} +TUI_ControlAIMapNodeMove::TUI_ControlAIMapNodeMove(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} + bool TUI_ControlAIMapNodeMove::Start(TShiftState Shift) { - if(parent_tool->SelectionCount(true)==0) return false; - - if (etAxisY==Tools->GetAxis()){ - m_MovingXVector.set(0,0,0); - m_MovingYVector.set(0,1,0); - }else{ - m_MovingXVector.set(0,0,0); - m_MovingYVector.set(0,0,0); + if (parent_tool->SelectionCount(true)==0) + return false; + + if (etAxisY==Tools->GetAxis()) + { + m_MovingXVector.set(0, 0, 0); + m_MovingYVector.set(0, 1, 0); + } + else + { + m_MovingXVector.set(0, 0, 0); + m_MovingYVector.set(0, 0, 0); } - m_MovingReminder.set(0,0,0); + m_MovingReminder.set(0, 0, 0); return true; } void __fastcall TUI_ControlAIMapNodeMove::Move(TShiftState _Shift) { - Fvector amount; - if (DefaultMovingProcess(_Shift,amount)){ - AINodeVec& lst = ((ESceneAIMapTool*)parent_tool)->Nodes(); - for(AINodeIt _F = lst.begin();_F!=lst.end();_F++) - if((*_F)->flags.is(SAINode::flSelected)){ - (*_F)->Pos.add(amount); - (*_F)->Plane.build((*_F)->Pos,(*_F)->Plane.n); + Fvector amount; + if (DefaultMovingProcess(_Shift, amount)) + { + AINodeVec &lst = ((ESceneAIMapTool*)parent_tool)->Nodes(); + for (AINodeIt _F = lst.begin(); _F!=lst.end(); _F++) + if ((*_F)->flags.is(SAINode::flSelected)) + { + (*_F)->Pos.add(amount); + (*_F)->Plane.build((*_F)->Pos, (*_F)->Plane.n); } } } bool __fastcall TUI_ControlAIMapNodeMove::End(TShiftState _Shift) { - return MovingEnd(_Shift); + return MovingEnd(_Shift); } //------------------------------------------------------------------------------------ // Rotate Node //------------------------------------------------------------------------------------ -TUI_ControlAIMapNodeRotate::TUI_ControlAIMapNodeRotate(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent) -{ -} +TUI_ControlAIMapNodeRotate::TUI_ControlAIMapNodeRotate(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} + bool __fastcall TUI_ControlAIMapNodeRotate::Start(TShiftState Shift) { - if(parent_tool->SelectionCount(true)==0) return false; + if (parent_tool->SelectionCount(true)==0) + return false; - m_RotateVector.set(0,0,0); - if (etAxisX==Tools->GetAxis()) m_RotateVector.set(1,0,0); - else if (etAxisY==Tools->GetAxis()) m_RotateVector.set(0,0,0); - else if (etAxisZ==Tools->GetAxis()) m_RotateVector.set(0,0,1); - m_fRotateSnapAngle = 0; + m_RotateVector.set(0, 0, 0); + if (etAxisX==Tools->GetAxis()) + m_RotateVector.set(1, 0, 0); + else if (etAxisY==Tools->GetAxis()) + m_RotateVector.set(0, 0, 0); + else if (etAxisZ==Tools->GetAxis()) + m_RotateVector.set(0, 0, 1); + m_fRotateSnapAngle = 0; return true; } void __fastcall TUI_ControlAIMapNodeRotate::Move(TShiftState _Shift) { - if (_Shift.Contains(ssLeft)){ - float amount = -UI->m_DeltaCpH.x * UI->m_MouseSR; + if (_Shift.Contains(ssLeft)) + { + float amount = -UI->m_DeltaCpH.x*UI->m_MouseSR; - if( Tools->GetSettings(etfASnap) ) CHECK_SNAP(m_fRotateSnapAngle,amount,Tools->m_RotateSnapAngle); + if (Tools->GetSettings(etfASnap)) + CHECK_SNAP(m_fRotateSnapAngle,amount,Tools->m_RotateSnapAngle); Fmatrix R; - if (fis_zero(m_RotateVector.x)) R.rotateZ(amount); - else R.rotateX(amount); - - AINodeVec& lst = ((ESceneAIMapTool*)parent_tool)->Nodes(); - for(AINodeIt _F = lst.begin();_F!=lst.end();_F++) - if((*_F)->flags.is(SAINode::flSelected)){ - Fvector new_n; - R.transform_dir(new_n,(*_F)->Plane.n); - if (Fvector().set(0,1,0).dotproduct(new_n)>0.02f){ - (*_F)->Plane.build((*_F)->Pos,new_n); + if (fis_zero(m_RotateVector.x)) + R.rotateZ(amount); + else + R.rotateX(amount); + + AINodeVec &lst = ((ESceneAIMapTool*)parent_tool)->Nodes(); + for (AINodeIt _F = lst.begin(); _F!=lst.end(); _F++) + if ((*_F)->flags.is(SAINode::flSelected)) + { + Fvector new_n; + R.transform_dir(new_n, (*_F)->Plane.n); + if (Fvector().set(0, 1, 0).dotproduct(new_n)>0.02f) + { + (*_F)->Plane.build((*_F)->Pos, new_n); } } } } + bool __fastcall TUI_ControlAIMapNodeRotate::End(TShiftState _Shift) { - return RotateEnd(_Shift); + return RotateEnd(_Shift); } diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapTools.cpp b/src/editors/LevelEditor/Edit/ESceneAIMapTools.cpp index ea60f074066..089885e9164 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneAIMapTools.cpp @@ -4,8 +4,8 @@ #include "ESceneAIMapTools.h" #include "Common/LevelStructure.hpp" #include "Scene.h" -#include "ui_levelmain.h" -#include "ui_leveltools.h" +#include "UI_LevelMain.h" +#include "UI_LevelTools.h" #include "ESceneAIMapControls.h" #include "xrPool.h" @@ -22,559 +22,642 @@ #define AIMAP_CHUNK_INTERNAL_DATA2 0x0009 //---------------------------------------------------- -poolSS g_ainode_pool; +poolSS g_ainode_pool; -void* SAINode::operator new(std::size_t size) +void *SAINode::operator new(std::size_t size) { - return g_ainode_pool.create(); + return g_ainode_pool.create(); } -void* SAINode::operator new(std::size_t size, SAINode* src) +void *SAINode::operator new(std::size_t size, SAINode *src) { - return src; + return src; } -void SAINode::operator delete(void* ptr) +void SAINode::operator delete(void *ptr) { - g_ainode_pool.destroy((SAINode*)ptr); + g_ainode_pool.destroy((SAINode*)ptr); } -void SAINode::PointLF(Fvector& D, float patch_size) +void SAINode::PointLF(Fvector &D, float patch_size) { - Fvector d; d.set(0,-1,0); - Fvector v = Pos; - float s = patch_size/2; - v.x -= s; - v.z += s; - Plane.intersectRayPoint(v,d,D); + Fvector d; + d.set(0, -1, 0); + Fvector v = Pos; + float s = patch_size/2; + v.x -= s; + v.z += s; + Plane.intersectRayPoint(v, d, D); } -void SAINode::PointFR(Fvector& D, float patch_size) +void SAINode::PointFR(Fvector &D, float patch_size) { - Fvector d; d.set(0,-1,0); - Fvector v = Pos; - float s = patch_size/2; - v.x += s; - v.z += s; - Plane.intersectRayPoint(v,d,D); + Fvector d; + d.set(0, -1, 0); + Fvector v = Pos; + float s = patch_size/2; + v.x += s; + v.z += s; + Plane.intersectRayPoint(v, d, D); } -void SAINode::PointRB(Fvector& D, float patch_size) +void SAINode::PointRB(Fvector &D, float patch_size) { - Fvector d; d.set(0,-1,0); - Fvector v = Pos; - float s = patch_size/2; - v.x += s; - v.z -= s; - Plane.intersectRayPoint(v,d,D); + Fvector d; + d.set(0, -1, 0); + Fvector v = Pos; + float s = patch_size/2; + v.x += s; + v.z -= s; + Plane.intersectRayPoint(v, d, D); } -void SAINode::PointBL(Fvector& D, float patch_size) +void SAINode::PointBL(Fvector &D, float patch_size) { - Fvector d; d.set(0,-1,0); - Fvector v = Pos; - float s = patch_size/2; - v.x -= s; - v.z -= s; - Plane.intersectRayPoint(v,d,D); + Fvector d; + d.set(0, -1, 0); + Fvector v = Pos; + float s = patch_size/2; + v.x -= s; + v.z -= s; + Plane.intersectRayPoint(v, d, D); } -void SAINode::LoadLTX(CInifile& ini, LPCSTR sect_name, ESceneAIMapTool* tools) +void SAINode::LoadLTX(CInifile &ini, LPCSTR sect_name, ESceneAIMapTool *tools) { - R_ASSERT(0); + R_ASSERT(0); } -void SAINode::SaveLTX(CInifile& ini, LPCSTR sect_name, ESceneAIMapTool* tools) +void SAINode::SaveLTX(CInifile &ini, LPCSTR sect_name, ESceneAIMapTool *tools) { - R_ASSERT2 (0, "dont use it !!!"); - u32 id; - u16 pl; - NodePosition np; + R_ASSERT2(0, "dont use it !!!"); + u32 id; + u16 pl; + NodePosition np; - id = n1?(u32)n1->idx:InvalidNode; - ini.w_u32 (sect_name,"n1", id); + id = n1 ? (u32)n1->idx : InvalidNode; + ini.w_u32(sect_name, "n1", id); - id = n2?(u32)n2->idx:InvalidNode; - ini.w_u32 (sect_name,"n2", id); + id = n2 ? (u32)n2->idx : InvalidNode; + ini.w_u32(sect_name, "n2", id); - id = n3?(u32)n3->idx:InvalidNode; - ini.w_u32 (sect_name,"n3", id); + id = n3 ? (u32)n3->idx : InvalidNode; + ini.w_u32(sect_name, "n3", id); - id = n4?(u32)n4->idx:InvalidNode; - ini.w_u32 (sect_name,"n4", id); + id = n4 ? (u32)n4->idx : InvalidNode; + ini.w_u32(sect_name, "n4", id); - pl = pvCompress (Plane.n); - ini.w_u16 (sect_name, "plane", pl); + pl = pvCompress(Plane.n); + ini.w_u16(sect_name, "plane", pl); - tools->PackPosition(np,Pos,tools->m_AIBBox,tools->m_Params); - string256 buff; + tools->PackPosition(np, Pos, tools->m_AIBBox, tools->m_Params); + string256 buff; - s16 x; - u16 y; - s16 z; + s16 x; + u16 y; + s16 z; - sprintf (buff,"%i,%u,%i",np.x,np.y,np.z); - ini.w_string (sect_name, "np", buff); - ini.w_u8 (sect_name, "flag", flags.get()); + sprintf(buff, "%i,%u,%i", np.x, np.y, np.z); + ini.w_string(sect_name, "np", buff); + ini.w_u8(sect_name, "flag", flags.get()); } -void SAINode::LoadStream(IReader& F, ESceneAIMapTool* tools) +void SAINode::LoadStream(IReader &F, ESceneAIMapTool *tools) { - u32 id; - u16 pl; - NodePosition np; - F.r (&id,3); n1 = (SAINode*)tools->UnpackLink(id); - F.r (&id,3); n2 = (SAINode*)tools->UnpackLink(id); - F.r (&id,3); n3 = (SAINode*)tools->UnpackLink(id); - F.r (&id,3); n4 = (SAINode*)tools->UnpackLink(id); - pl = F.r_u16(); pvDecompress(Plane.n,pl); - F.r (&np,sizeof(np)); tools->UnpackPosition(Pos,np,tools->m_AIBBox,tools->m_Params); - Plane.build (Pos,Plane.n); - flags.assign (F.r_u8()); + u32 id; + u16 pl; + NodePosition np; + F.r(&id, 3); + n1 = (SAINode*)tools->UnpackLink(id); + F.r(&id, 3); + n2 = (SAINode*)tools->UnpackLink(id); + F.r(&id, 3); + n3 = (SAINode*)tools->UnpackLink(id); + F.r(&id, 3); + n4 = (SAINode*)tools->UnpackLink(id); + pl = F.r_u16(); + pvDecompress(Plane.n, pl); + F.r(&np, sizeof(np)); + tools->UnpackPosition(Pos, np, tools->m_AIBBox, tools->m_Params); + Plane.build(Pos, Plane.n); + flags.assign(F.r_u8()); } -void SAINode::SaveStream(IWriter& F, ESceneAIMapTool* tools) +void SAINode::SaveStream(IWriter &F, ESceneAIMapTool *tools) { - u32 id; - u16 pl; - NodePosition np; + u32 id; + u16 pl; + NodePosition np; - id = n1?(u32)n1->idx:InvalidNode; F.w(&id,3); - id = n2?(u32)n2->idx:InvalidNode; F.w(&id,3); - id = n3?(u32)n3->idx:InvalidNode; F.w(&id,3); - id = n4?(u32)n4->idx:InvalidNode; F.w(&id,3); - pl = pvCompress (Plane.n); F.w_u16(pl); - tools->PackPosition(np,Pos,tools->m_AIBBox,tools->m_Params); F.w(&np,sizeof(np)); - F.w_u8 (flags.get()); + id = n1 ? (u32)n1->idx : InvalidNode; + F.w(&id, 3); + id = n2 ? (u32)n2->idx : InvalidNode; + F.w(&id, 3); + id = n3 ? (u32)n3->idx : InvalidNode; + F.w(&id, 3); + id = n4 ? (u32)n4->idx : InvalidNode; + F.w(&id, 3); + pl = pvCompress(Plane.n); + F.w_u16(pl); + tools->PackPosition(np, Pos, tools->m_AIBBox, tools->m_Params); + F.w(&np, sizeof(np)); + F.w_u8(flags.get()); } -ESceneAIMapTool::ESceneAIMapTool():ESceneToolBase(OBJCLASS_AIMAP) +ESceneAIMapTool::ESceneAIMapTool(): ESceneToolBase(OBJCLASS_AIMAP) { - m_Shader = 0; + m_Shader = 0; m_Flags.zero(); - m_AIBBox.invalidate (); -// m_Header.size_y = m_Header.aabb.max.y-m_Header.aabb.min.y+EPS_L; - hash_Initialize(); - m_VisRadius = 30.f; - m_SmoothHeight = 0.5f; - m_BrushSize = 1; - m_CFModel = 0; + m_AIBBox.invalidate(); + // m_Header.size_y = m_Header.aabb.max.y-m_Header.aabb.min.y+EPS_L; + hash_Initialize(); + m_VisRadius = 30.f; + m_SmoothHeight = 0.5f; + m_BrushSize = 1; + m_CFModel = 0; } + //---------------------------------------------------- -ESceneAIMapTool::~ESceneAIMapTool() -{ -} +ESceneAIMapTool::~ESceneAIMapTool() {} + //---------------------------------------------------- void ESceneAIMapTool::Clear(bool bOnlyNodes) { - inherited::Clear (); - hash_Clear (); - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++) - xr_delete (*it); - m_Nodes.clear_and_free(); - if (!bOnlyNodes){ - m_SnapObjects.clear (); - m_AIBBox.invalidate (); - ExecCommand (COMMAND_REFRESH_SNAP_OBJECTS); - g_ainode_pool.clear (); + inherited::Clear(); + hash_Clear(); + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + xr_delete(*it); + m_Nodes.clear_and_free(); + if (!bOnlyNodes) + { + m_SnapObjects.clear(); + m_AIBBox.invalidate(); + ExecCommand(COMMAND_REFRESH_SNAP_OBJECTS); + g_ainode_pool.clear(); } } + //---------------------------------------------------- -void ESceneAIMapTool::CalculateNodesBBox(Fbox& bb) +void ESceneAIMapTool::CalculateNodesBBox(Fbox &bb) { bb.invalidate(); - for (AINodeIt b_it=m_Nodes.begin(); b_it!=m_Nodes.end(); ++b_it) + for (AINodeIt b_it = m_Nodes.begin(); b_it!=m_Nodes.end(); ++b_it) { - VERIFY(_valid((*b_it)->Pos)); - bb.modify((*b_it)->Pos); + VERIFY(_valid((*b_it)->Pos)); + bb.modify((*b_it)->Pos); } } + //---------------------------------------------------- extern BOOL ai_map_shown; + void ESceneAIMapTool::OnActivate() { - inherited::OnActivate (); - ai_map_shown = TRUE; + inherited::OnActivate(); + ai_map_shown = TRUE; } void ESceneAIMapTool::OnFrame() { - if (m_Flags.is(flUpdateHL)){ - m_Flags.set(flUpdateHL,FALSE); - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++) - (*it)->flags.set(SAINode::flHLSelected,FALSE); - for (it=m_Nodes.begin(); it!=m_Nodes.end(); it++){ - SAINode& N = **it; + if (m_Flags.is(flUpdateHL)) + { + m_Flags.set(flUpdateHL, FALSE); + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + (*it)->flags.set(SAINode::flHLSelected, FALSE); + for (it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + { + SAINode &N = **it; if (N.flags.is(SAINode::flSelected)) - for (int k=0; k<4; k++) - if (N.n[k]) N.n[k]->flags.set(SAINode::flHLSelected,TRUE); + for (int k = 0; k<4; k++) + if (N.n[k]) + N.n[k]->flags.set(SAINode::flHLSelected, TRUE); } } - if (m_Flags.is(flUpdateSnapList)) RealUpdateSnapList(); + if (m_Flags.is(flUpdateSnapList)) + RealUpdateSnapList(); } + //---------------------------------------------------- void ESceneAIMapTool::EnumerateNodes() { - u32 idx = 0; - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++,idx++) - (*it)->idx = idx; + u32 idx = 0; + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++,idx++) + (*it)->idx = idx; } void ESceneAIMapTool::DenumerateNodes() { - u32 cnt=m_Nodes.size(); - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++){ - if (!((((u32)(*it)->n1n1==InvalidNode))&& - (((u32)(*it)->n2n2==InvalidNode))&& - (((u32)(*it)->n3n3==InvalidNode))&& - (((u32)(*it)->n4n4==InvalidNode)))){ - ELog.Msg(mtError,"Node: has wrong link [%3.2f, %3.2f, %3.2f], {%d,%d,%d,%d}",VPUSH((*it)->Pos),(*it)->n1,(*it)->n2,(*it)->n3,(*it)->n4); - (*it)->n1 = 0; - (*it)->n2 = 0; - (*it)->n3 = 0; - (*it)->n4 = 0; - continue; - } -// ,"AINode: Wrong link found."); - (*it)->n1 = ((u32)(*it)->n1==InvalidNode)?0:m_Nodes[(u32)(*it)->n1]; - (*it)->n2 = ((u32)(*it)->n2==InvalidNode)?0:m_Nodes[(u32)(*it)->n2]; - (*it)->n3 = ((u32)(*it)->n3==InvalidNode)?0:m_Nodes[(u32)(*it)->n3]; - (*it)->n4 = ((u32)(*it)->n4==InvalidNode)?0:m_Nodes[(u32)(*it)->n4]; -/* - if (((u32)(*it)->n1n1==InvalidNode)) (*it)->n1 = ((u32)(*it)->n1==InvalidNode)?0:m_Nodes[(u32)(*it)->n1]; - else (*it)->n1=0; - if (((u32)(*it)->n2n2==InvalidNode)) (*it)->n2 = ((u32)(*it)->n2==InvalidNode)?0:m_Nodes[(u32)(*it)->n2]; - else (*it)->n2=0; - if (((u32)(*it)->n3n3==InvalidNode)) (*it)->n3 = ((u32)(*it)->n3==InvalidNode)?0:m_Nodes[(u32)(*it)->n3]; - else (*it)->n3=0; - if (((u32)(*it)->n4n4==InvalidNode)) (*it)->n4 = ((u32)(*it)->n4==InvalidNode)?0:m_Nodes[(u32)(*it)->n4]; - else (*it)->n4=0; -*/ + u32 cnt = m_Nodes.size(); + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + { + if (!((((u32)(*it)->n1n1==InvalidNode))&& + (((u32)(*it)->n2n2==InvalidNode))&& + (((u32)(*it)->n3n3==InvalidNode))&& + (((u32)(*it)->n4n4==InvalidNode)))) + { + ELog.Msg(mtError, "Node: has wrong link [%3.2f, %3.2f, %3.2f], {%d,%d,%d,%d}", VPUSH((*it)->Pos), (*it)->n1, (*it)->n2, (*it)->n3, (*it)->n4); + (*it)->n1 = 0; + (*it)->n2 = 0; + (*it)->n3 = 0; + (*it)->n4 = 0; + continue; + } + // ,"AINode: Wrong link found."); + (*it)->n1 = ((u32)(*it)->n1==InvalidNode) ? 0 : m_Nodes[(u32)(*it)->n1]; + (*it)->n2 = ((u32)(*it)->n2==InvalidNode) ? 0 : m_Nodes[(u32)(*it)->n2]; + (*it)->n3 = ((u32)(*it)->n3==InvalidNode) ? 0 : m_Nodes[(u32)(*it)->n3]; + (*it)->n4 = ((u32)(*it)->n4==InvalidNode) ? 0 : m_Nodes[(u32)(*it)->n4]; + /* + if (((u32)(*it)->n1n1==InvalidNode)) (*it)->n1 = ((u32)(*it)->n1==InvalidNode)?0:m_Nodes[(u32)(*it)->n1]; + else (*it)->n1=0; + if (((u32)(*it)->n2n2==InvalidNode)) (*it)->n2 = ((u32)(*it)->n2==InvalidNode)?0:m_Nodes[(u32)(*it)->n2]; + else (*it)->n2=0; + if (((u32)(*it)->n3n3==InvalidNode)) (*it)->n3 = ((u32)(*it)->n3==InvalidNode)?0:m_Nodes[(u32)(*it)->n3]; + else (*it)->n3=0; + if (((u32)(*it)->n4n4==InvalidNode)) (*it)->n4 = ((u32)(*it)->n4==InvalidNode)?0:m_Nodes[(u32)(*it)->n4]; + else (*it)->n4=0; + */ } } -bool ESceneAIMapTool::LoadLTX(CInifile& ini) + +bool ESceneAIMapTool::LoadLTX(CInifile &ini) { - R_ASSERT(0); - return true; + R_ASSERT(0); + return true; } -void ESceneAIMapTool::SaveLTX(CInifile& ini, int id) +void ESceneAIMapTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); + inherited::SaveLTX(ini, id); - ini.w_u32 ("main", "version", AIMAP_VERSION); - ini.w_u32 ("main", "flags", m_Flags.get()); + ini.w_u32("main", "version", AIMAP_VERSION); + ini.w_u32("main", "flags", m_Flags.get()); - ini.w_fvector3 ("main", "bbox_min", m_AIBBox.min); - ini.w_fvector3 ("main", "bbox_max", m_AIBBox.max); + ini.w_fvector3("main", "bbox_min", m_AIBBox.min); + ini.w_fvector3("main", "bbox_max", m_AIBBox.max); - ini.w_float ("params", "patch_size", m_Params.fPatchSize); - ini.w_float ("params", "test_height", m_Params.fTestHeight); - ini.w_float ("params", "can_up", m_Params.fCanUP); - ini.w_float ("params", "can_down", m_Params.fCanDOWN); + ini.w_float("params", "patch_size", m_Params.fPatchSize); + ini.w_float("params", "test_height", m_Params.fTestHeight); + ini.w_float("params", "can_up", m_Params.fCanUP); + ini.w_float("params", "can_down", m_Params.fCanDOWN); - EnumerateNodes (); - ini.w_u32 ("main", "nodes_count", m_Nodes.size()); + EnumerateNodes(); + ini.w_u32("main", "nodes_count", m_Nodes.size()); - u32 i = 0; - string128 buff; - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); ++it, ++i) + u32 i = 0; + string128 buff; + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); ++it,++i) { - sprintf (buff,"n_%d", i); - (*it)->SaveLTX (ini, buff, this); + sprintf(buff, "n_%d", i); + (*it)->SaveLTX(ini, buff, this); } - ini.w_float ("main", "vis_radius", m_VisRadius); - ini.w_u32 ("main", "brush_size", m_BrushSize); + ini.w_float("main", "vis_radius", m_VisRadius); + ini.w_u32("main", "brush_size", m_BrushSize); - ini.w_float ("main", "smooth_height", m_SmoothHeight); + ini.w_float("main", "smooth_height", m_SmoothHeight); - for (ObjectIt o_it=m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); ++o_it) - ini.w_string ("snap_objects", (*o_it)->Name, NULL); + for (ObjectIt o_it = m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); ++o_it) + ini.w_string("snap_objects", (*o_it)->Name, NULL); } -bool ESceneAIMapTool::LoadStream(IReader& F) +bool ESceneAIMapTool::LoadStream(IReader &F) { - inherited::LoadStream (F); + inherited::LoadStream(F); - u16 version = 0; + u16 version = 0; - R_ASSERT(F.r_chunk(AIMAP_CHUNK_VERSION,&version)); - if( version!=AIMAP_VERSION ){ - ELog.DlgMsg( mtError, "AIMap: Unsupported version."); + R_ASSERT(F.r_chunk(AIMAP_CHUNK_VERSION, &version)); + if (version!=AIMAP_VERSION) + { + ELog.DlgMsg(mtError, "AIMap: Unsupported version."); return false; } R_ASSERT(F.find_chunk(AIMAP_CHUNK_FLAGS)); - F.r (&m_Flags,sizeof(m_Flags)); + F.r(&m_Flags, sizeof(m_Flags)); R_ASSERT(F.find_chunk(AIMAP_CHUNK_BOX)); - F.r (&m_AIBBox,sizeof(m_AIBBox)); + F.r(&m_AIBBox, sizeof(m_AIBBox)); R_ASSERT(F.find_chunk(AIMAP_CHUNK_PARAMS)); - F.r (&m_Params,sizeof(m_Params)); + F.r(&m_Params, sizeof(m_Params)); R_ASSERT(F.find_chunk(AIMAP_CHUNK_NODES)); - m_Nodes.resize (F.r_u32()); - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++){ - *it = xr_new(); - (*it)->LoadStream (F,this); + m_Nodes.resize(F.r_u32()); + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + { + *it = xr_new(); + (*it)->LoadStream(F, this); } - DenumerateNodes (); + DenumerateNodes(); - if (F.find_chunk(AIMAP_CHUNK_INTERNAL_DATA)){ - m_VisRadius = F.r_float(); - m_BrushSize = F.r_u32(); + if (F.find_chunk(AIMAP_CHUNK_INTERNAL_DATA)) + { + m_VisRadius = F.r_float(); + m_BrushSize = F.r_u32(); } - if (F.find_chunk(AIMAP_CHUNK_INTERNAL_DATA2)){ - m_SmoothHeight = F.r_float(); + if (F.find_chunk(AIMAP_CHUNK_INTERNAL_DATA2)) + { + m_SmoothHeight = F.r_float(); } - // snap objects - if (F.find_chunk(AIMAP_CHUNK_SNAP_OBJECTS)){ - shared_str buf; - int cnt = F.r_u32(); - if (cnt){ - for (int i=0; iFindObjectByName(buf.c_str(),OBJCLASS_SCENEOBJECT); - if (!O) ELog.Msg(mtError,"AIMap: Can't find snap object '%s'.",buf.c_str()); - else m_SnapObjects.push_back(O); - } + // snap objects + if (F.find_chunk(AIMAP_CHUNK_SNAP_OBJECTS)) + { + shared_str buf; + int cnt = F.r_u32(); + if (cnt) + { + for (int i = 0; iFindObjectByName(buf.c_str(), OBJCLASS_SCENEOBJECT); + if (!O) + ELog.Msg(mtError, "AIMap: Can't find snap object '%s'.", buf.c_str()); + else + m_SnapObjects.push_back(O); + } } } - hash_FillFromNodes (); + hash_FillFromNodes(); return true; } + //---------------------------------------------------- -bool ESceneAIMapTool::LoadSelection(IReader& F) +bool ESceneAIMapTool::LoadSelection(IReader &F) { - Clear(); - return LoadStream(F); + Clear(); + return LoadStream(F); } void ESceneAIMapTool::OnSynchronize() { - RealUpdateSnapList (); + RealUpdateSnapList(); } + //---------------------------------------------------- -void ESceneAIMapTool::SaveStream(IWriter& F) +void ESceneAIMapTool::SaveStream(IWriter &F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - F.open_chunk (AIMAP_CHUNK_VERSION); - F.w_u16 (AIMAP_VERSION); - F.close_chunk (); + F.open_chunk(AIMAP_CHUNK_VERSION); + F.w_u16(AIMAP_VERSION); + F.close_chunk(); - F.open_chunk (AIMAP_CHUNK_FLAGS); - F.w (&m_Flags,sizeof(m_Flags)); - F.close_chunk (); + F.open_chunk(AIMAP_CHUNK_FLAGS); + F.w(&m_Flags, sizeof(m_Flags)); + F.close_chunk(); - F.open_chunk (AIMAP_CHUNK_BOX); - F.w (&m_AIBBox,sizeof(m_AIBBox)); - F.close_chunk (); + F.open_chunk(AIMAP_CHUNK_BOX); + F.w(&m_AIBBox, sizeof(m_AIBBox)); + F.close_chunk(); - F.open_chunk (AIMAP_CHUNK_PARAMS); - F.w (&m_Params,sizeof(m_Params)); - F.close_chunk (); + F.open_chunk(AIMAP_CHUNK_PARAMS); + F.w(&m_Params, sizeof(m_Params)); + F.close_chunk(); - EnumerateNodes (); - F.open_chunk (AIMAP_CHUNK_NODES); - F.w_u32 (m_Nodes.size()); - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++) - (*it)->SaveStream (F,this); - F.close_chunk (); + EnumerateNodes(); + F.open_chunk(AIMAP_CHUNK_NODES); + F.w_u32(m_Nodes.size()); + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + (*it)->SaveStream(F, this); + F.close_chunk(); - F.open_chunk (AIMAP_CHUNK_INTERNAL_DATA); - F.w_float (m_VisRadius); - F.w_u32 (m_BrushSize); - F.close_chunk (); + F.open_chunk(AIMAP_CHUNK_INTERNAL_DATA); + F.w_float(m_VisRadius); + F.w_u32(m_BrushSize); + F.close_chunk(); - F.open_chunk (AIMAP_CHUNK_INTERNAL_DATA2); - F.w_float (m_SmoothHeight); - F.close_chunk (); + F.open_chunk(AIMAP_CHUNK_INTERNAL_DATA2); + F.w_float(m_SmoothHeight); + F.close_chunk(); - F.open_chunk (AIMAP_CHUNK_SNAP_OBJECTS); - F.w_u32 (m_SnapObjects.size()); - for (ObjectIt o_it=m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); o_it++) - F.w_stringZ ((*o_it)->Name); - F.close_chunk (); + F.open_chunk(AIMAP_CHUNK_SNAP_OBJECTS); + F.w_u32(m_SnapObjects.size()); + for (ObjectIt o_it = m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); o_it++) + F.w_stringZ((*o_it)->Name); + F.close_chunk(); } + //---------------------------------------------------- -void ESceneAIMapTool::SaveSelection(IWriter& F) +void ESceneAIMapTool::SaveSelection(IWriter &F) { - SaveStream(F); + SaveStream(F); } bool ESceneAIMapTool::Valid() { - return !m_Nodes.empty(); + return !m_Nodes.empty(); } bool ESceneAIMapTool::IsNeedSave() { - return (!m_Nodes.empty()||!m_SnapObjects.empty()); + return (!m_Nodes.empty()||!m_SnapObjects.empty()); } -void ESceneAIMapTool::OnObjectRemove(CCustomObject* O, bool bDeleting) +void ESceneAIMapTool::OnObjectRemove(CCustomObject *O, bool bDeleting) { - if (OBJCLASS_SCENEOBJECT==O->ClassID){ - if (find(m_SnapObjects.begin(),m_SnapObjects.end(),O)!=m_SnapObjects.end()){ - m_SnapObjects.remove(O); - RealUpdateSnapList(); + if (OBJCLASS_SCENEOBJECT==O->ClassID) + { + if (find(m_SnapObjects.begin(), m_SnapObjects.end(), O)!=m_SnapObjects.end()) + { + m_SnapObjects.remove(O); + RealUpdateSnapList(); } } } -int ESceneAIMapTool::AddNode(const Fvector& pos, bool bIgnoreConstraints, bool bAutoLink, int sz) +int ESceneAIMapTool::AddNode(const Fvector &pos, bool bIgnoreConstraints, bool bAutoLink, int sz) { - Fvector Pos = pos; - if (1==sz){ - SAINode* N = BuildNode(Pos,Pos,bIgnoreConstraints,true); - if (N){ - N->flags.set (SAINode::flSelected,TRUE); - if (bAutoLink) UpdateLinks(N,bIgnoreConstraints); - return 1; - }else{ - ELog.Msg (mtError,"Can't create node."); - return 0; + Fvector Pos = pos; + if (1==sz) + { + SAINode *N = BuildNode(Pos, Pos, bIgnoreConstraints, true); + if (N) + { + N->flags.set(SAINode::flSelected, TRUE); + if (bAutoLink) + UpdateLinks(N, bIgnoreConstraints); + return 1; + } + else + { + ELog.Msg(mtError, "Can't create node."); + return 0; } - }else{ - return BuildNodes (Pos,sz,bIgnoreConstraints); + } + else + { + return BuildNodes(Pos, sz, bIgnoreConstraints); } } struct invalid_node_pred : public std::unary_function { - int link; - invalid_node_pred(int _link):link(_link){;} - bool operator()(const SAINode*& x){ return x->Links()==link; } + int link; + + invalid_node_pred(int _link): link(_link) + { + ; + } + + bool operator()(const SAINode *&x) + { + return x->Links()==link; + } }; + void ESceneAIMapTool::SelectNodesByLink(int link) { - SelectObjects (false); + SelectObjects(false); // remove link to sel nodes - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++) + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) if ((*it)->Links()==link) -// if (!(*it)->flags.is(SAINode::flHide)) - (*it)->flags.set(SAINode::flSelected,TRUE); - UI->RedrawScene (); + // if (!(*it)->flags.is(SAINode::flHide)) + (*it)->flags.set(SAINode::flSelected, TRUE); + UI->RedrawScene(); } void ESceneAIMapTool::SelectObjects(bool flag) { - switch (LTools->GetSubTarget()){ - case estAIMapNode:{ - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++) -// if (!(*it)->flags.is(SAINode::flHide)) - (*it)->flags.set(SAINode::flSelected,flag); - }break; + switch (LTools->GetSubTarget()) + { + case estAIMapNode: + { + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + // if (!(*it)->flags.is(SAINode::flHide)) + (*it)->flags.set(SAINode::flSelected, flag); + } + break; } - UpdateHLSelected (); - UI->RedrawScene (); + UpdateHLSelected(); + UI->RedrawScene(); } + struct delete_sel_node_pred : public std::unary_function { - bool operator()(SAINode*& x) + bool operator()(SAINode *&x) { - // breaking links - for (int k=0; k<4; k++) + // breaking links + for (int k = 0; k<4; k++) if (x->n[k]&&x->n[k]->flags.is(SAINode::flSelected)) - x->n[k]=0; - // free memory - bool res = x->flags.is(SAINode::flSelected); - if (res) xr_delete(x); - return res; + x->n[k] = 0; + // free memory + bool res = x->flags.is(SAINode::flSelected); + if (res) + xr_delete(x); + return res; } }; + void ESceneAIMapTool::RemoveSelection() { - switch (LTools->GetSubTarget()){ - case estAIMapNode:{ - if (m_Nodes.size()==(u32)SelectionCount(true)){ - Clear (true); - }else{ - SPBItem* pb = UI->ProgressStart(3,"Removing nodes..."); - // remove link to sel nodes - pb->Inc("erasing nodes"); - // remove sel nodes - AINodeIt result = std::remove_if(m_Nodes.begin(), m_Nodes.end(), delete_sel_node_pred()); - m_Nodes.erase (result,m_Nodes.end()); - pb->Inc("updating hash"); - hash_Clear (); - hash_FillFromNodes (); - pb->Inc("end"); - UI->ProgressEnd(pb); + switch (LTools->GetSubTarget()) + { + case estAIMapNode: + { + if (m_Nodes.size()==(u32)SelectionCount(true)) + { + Clear(true); + } + else + { + SPBItem *pb = UI->ProgressStart(3, "Removing nodes..."); + // remove link to sel nodes + pb->Inc("erasing nodes"); + // remove sel nodes + AINodeIt result = std::remove_if(m_Nodes.begin(), m_Nodes.end(), delete_sel_node_pred()); + m_Nodes.erase(result, m_Nodes.end()); + pb->Inc("updating hash"); + hash_Clear(); + hash_FillFromNodes(); + pb->Inc("end"); + UI->ProgressEnd(pb); + } } - }break; + break; } - UpdateHLSelected (); - UI->RedrawScene (); + UpdateHLSelected(); + UI->RedrawScene(); } void ESceneAIMapTool::InvertSelection() { - switch (LTools->GetSubTarget()){ - case estAIMapNode:{ - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++) -// if (!(*it)->flags.is(SAINode::flHide)) - (*it)->flags.invert(SAINode::flSelected); - }break; + switch (LTools->GetSubTarget()) + { + case estAIMapNode: + { + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + // if (!(*it)->flags.is(SAINode::flHide)) + (*it)->flags.invert(SAINode::flSelected); + } + break; } - UpdateHLSelected (); - UI->RedrawScene (); + UpdateHLSelected(); + UI->RedrawScene(); } int ESceneAIMapTool::SelectionCount(bool testflag) { - int count = 0; - switch (LTools->GetSubTarget()){ - case estAIMapNode:{ - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++) - if ((*it)->flags.is(SAINode::flSelected)==testflag) - count++; - }break; + int count = 0; + switch (LTools->GetSubTarget()) + { + case estAIMapNode: + { + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + if ((*it)->flags.is(SAINode::flSelected)==testflag) + count++; + } + break; } return count; } -void ESceneAIMapTool::FillProp(LPCSTR pref, PropItemVec& items) +void ESceneAIMapTool::FillProp(LPCSTR pref, PropItemVec &items) { - PHelper().CreateFlag32 (items, PrepareKey(pref,"Common\\Draw Nodes"), &m_Flags, flHideNodes, 0,0, FlagValueCustom::flInvertedDraw); - PHelper().CreateFlag32 (items, PrepareKey(pref,"Common\\Slow Calculate Mode"), &m_Flags, flSlowCalculate); - PHelper().CreateFloat (items, PrepareKey(pref,"Common\\Visible Radius"), &m_VisRadius, 10.f, 250.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Common\\Smooth Height"), &m_SmoothHeight,0.1f, 100.f); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Draw Nodes"), &m_Flags, flHideNodes, 0, 0, FlagValueCustom::flInvertedDraw); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Slow Calculate Mode"), &m_Flags, flSlowCalculate); + PHelper().CreateFloat(items, PrepareKey(pref, "Common\\Visible Radius"), &m_VisRadius, 10.f, 250.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Common\\Smooth Height"), &m_SmoothHeight, 0.1f, 100.f); - PHelper().CreateU32 (items, PrepareKey(pref,"Params\\Brush Size"), &m_BrushSize, 1, 100); - PHelper().CreateFloat (items, PrepareKey(pref,"Params\\Can Up"), &m_Params.fCanUP, 0.f, 10.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Params\\Can Down"), &m_Params.fCanDOWN, 0.f, 10.f); + PHelper().CreateU32(items, PrepareKey(pref, "Params\\Brush Size"), &m_BrushSize, 1, 100); + PHelper().CreateFloat(items, PrepareKey(pref, "Params\\Can Up"), &m_Params.fCanUP, 0.f, 10.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Params\\Can Down"), &m_Params.fCanDOWN, 0.f, 10.f); } -void ESceneAIMapTool::GetBBox(Fbox& bb, bool bSelOnly) +void ESceneAIMapTool::GetBBox(Fbox &bb, bool bSelOnly) { - switch (LTools->GetSubTarget()){ - case estAIMapNode:{ - if (bSelOnly){ - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++) - if ((*it)->flags.is(SAINode::flSelected)){ - bb.modify(Fvector().add((*it)->Pos,-m_Params.fPatchSize*0.5f)); - bb.modify(Fvector().add((*it)->Pos,m_Params.fPatchSize*0.5f)); - } - }else{ - bb.merge (m_AIBBox); + switch (LTools->GetSubTarget()) + { + case estAIMapNode: + { + if (bSelOnly) + { + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + if ((*it)->flags.is(SAINode::flSelected)) + { + bb.modify(Fvector().add((*it)->Pos, -m_Params.fPatchSize*0.5f)); + bb.modify(Fvector().add((*it)->Pos, m_Params.fPatchSize*0.5f)); + } + } + else + { + bb.merge(m_AIBBox); + } } - }break; + break; } } diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapTools.h b/src/editors/LevelEditor/Edit/ESceneAIMapTools.h index fed6b14611d..ab9f3204438 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapTools.h +++ b/src/editors/LevelEditor/Edit/ESceneAIMapTools.h @@ -12,211 +12,300 @@ class ESceneAIMapTool; struct SAINode; -const DWORD InvalidNode = (1<<24)-1; +const DWORD InvalidNode = (1<<24)-1; #pragma pack(push,1) -struct SAINode // definition of "patch" or "node" +struct SAINode // definition of "patch" or "node" { - union { - struct { - SAINode* n1; // Left - SAINode* n2; // Forward - SAINode* n3; // Right - SAINode* n4; // Backward - }; - SAINode* n[4]; - }; - Fplane Plane; // plane of patch - Fvector Pos; // position of patch center - - enum{ - flSelected = (1<<0), - flHLSelected= (1<<1), -// flHide = (1<<2), // obsolette - - flN1 = (1<<4), - flN2 = (1<<5), - flN3 = (1<<6), - flN4 = (1<<7), + union + { + struct + { + SAINode *n1; // Left + SAINode *n2; // Forward + SAINode *n3; // Right + SAINode *n4; // Backward + }; + + SAINode *n[4]; }; - Flags8 flags; - u32 idx; - - SAINode () {n1=n2=n3=n4=0;idx=0;flags.zero();} - SAINode* nLeft () {return n1;} - SAINode* nForward() {return n2;} - SAINode* nRight () {return n3;} - SAINode* nBack () {return n4;} - - int Links () const {int cnt=0; for (int k=0; k<4; k++) if(n[k]) cnt++; return cnt;} - void PointLF (Fvector& D, float patch_size); - void PointFR (Fvector& D, float patch_size); - void PointRB (Fvector& D, float patch_size); - void PointBL (Fvector& D, float patch_size); - - void LoadStream (IReader&, ESceneAIMapTool*); - void SaveStream (IWriter&, ESceneAIMapTool*); - void LoadLTX (CInifile& ini, LPCSTR sect_name, ESceneAIMapTool*); - void SaveLTX (CInifile& ini, LPCSTR sect_name, ESceneAIMapTool*); - - void* operator new (std::size_t size); - void* operator new (std::size_t size, SAINode*); - void operator delete (void*); + + Fplane Plane; // plane of patch + Fvector Pos; // position of patch center + + enum + { + flSelected = (1<<0), + flHLSelected= (1<<1), + // flHide = (1<<2), // obsolette + + flN1 = (1<<4), + flN2 = (1<<5), + flN3 = (1<<6), + flN4 = (1<<7), + }; + + Flags8 flags; + u32 idx; + + SAINode() + { + n1 = n2 = n3 = n4 = 0; + idx = 0; + flags.zero(); + } + + SAINode *nLeft() + { + return n1; + } + + SAINode *nForward() + { + return n2; + } + + SAINode *nRight() + { + return n3; + } + + SAINode *nBack() + { + return n4; + } + + int Links() const + { + int cnt = 0; + for (int k = 0; k<4; k++) + if (n[k]) + cnt++; + return cnt; + } + + void PointLF(Fvector &D, float patch_size); + void PointFR(Fvector &D, float patch_size); + void PointRB(Fvector &D, float patch_size); + void PointBL(Fvector &D, float patch_size); + + void LoadStream(IReader &, ESceneAIMapTool *); + void SaveStream(IWriter &, ESceneAIMapTool *); + void LoadLTX(CInifile &ini, LPCSTR sect_name, ESceneAIMapTool *); + void SaveLTX(CInifile &ini, LPCSTR sect_name, ESceneAIMapTool *); + + void *operator new(std::size_t size); + void *operator new(std::size_t size, SAINode *); + void operator delete(void *); }; #pragma pack(pop) -DEFINE_VECTOR(SAINode*,AINodeVec,AINodeIt); +DEFINE_VECTOR(SAINode *, AINodeVec, AINodeIt); -const int HDIM_X = 128; -const int HDIM_Z = 128; +const int HDIM_X = 128; +const int HDIM_Z = 128; class ESceneAIMapTool: public ESceneToolBase { - friend class SAINode; - typedef ESceneToolBase inherited; - ObjectList m_SnapObjects; - // hash - AINodeVec m_HASH[HDIM_X+1][HDIM_Z+1]; - AINodeVec m_Nodes; - - SAIParams m_Params; - Fbox m_AIBBox; - - ref_geom m_RGeom; - ref_shader m_Shader; - CDB::MODEL* m_CFModel; + friend class SAINode; + typedef ESceneToolBase inherited; + ObjectList m_SnapObjects; + // hash + AINodeVec m_HASH[HDIM_X+1][HDIM_Z+1]; + AINodeVec m_Nodes; + + SAIParams m_Params; + Fbox m_AIBBox; + + ref_geom m_RGeom; + ref_shader m_Shader; + CDB::MODEL *m_CFModel; protected: - void hash_FillFromNodes (); - void hash_Initialize (); - void hash_Clear (); - void HashRect (const Fvector& v, float radius, Irect& result); - AINodeVec* HashMap (int ix, int iz); - AINodeVec* HashMap (Fvector& V); - SAINode* FindNode (Fvector& vAt, float eps=0.05f); - SAINode* FindNeighbor (SAINode* N, int side, bool bIgnoreConstraints); - void MotionSimulate (Fvector& result, Fvector& start, Fvector& end, float _radius, float _height); + void hash_FillFromNodes(); + void hash_Initialize(); + void hash_Clear(); + void HashRect(const Fvector &v, float radius, Irect &result); + AINodeVec *HashMap(int ix, int iz); + AINodeVec *HashMap(Fvector &V); + SAINode *FindNode(Fvector &vAt, float eps = 0.05f); + SAINode *FindNeighbor(SAINode *N, int side, bool bIgnoreConstraints); + void MotionSimulate(Fvector &result, Fvector &start, Fvector &end, float _radius, float _height); - SAINode* BuildNode (Fvector& vFrom, Fvector& vAt, bool bIgnoreConstraints, bool bSuperIgnoreConstraints=false); - int BuildNodes (const Fvector& pos, int sz, bool bIgnoreConstraints); - void BuildNodes (bool bFromSelectedOnly); - BOOL CreateNode (Fvector& vAt, SAINode& N, bool bIgnoreConstraints); - BOOL CanTravel (Fvector _from, Fvector _at); + SAINode *BuildNode(Fvector &vFrom, Fvector &vAt, bool bIgnoreConstraints, bool bSuperIgnoreConstraints = false); + int BuildNodes(const Fvector &pos, int sz, bool bIgnoreConstraints); + void BuildNodes(bool bFromSelectedOnly); + BOOL CreateNode(Fvector &vAt, SAINode &N, bool bIgnoreConstraints); + BOOL CanTravel(Fvector _from, Fvector _at); - SAINode* GetNode (Fvector vAt, bool bIgnoreConstraints); - void UpdateLinks (SAINode* N, bool bIgnoreConstraints); + SAINode *GetNode(Fvector vAt, bool bIgnoreConstraints); + void UpdateLinks(SAINode *N, bool bIgnoreConstraints); - void UnpackPosition (Fvector& Pdest, const NodePosition& Psrc, Fbox& bb, SAIParams& params); - u32 UnpackLink (u32& L); - void PackPosition (NodePosition& Dest, Fvector& Src, Fbox& bb, SAIParams& params); + void UnpackPosition(Fvector &Pdest, const NodePosition &Psrc, Fbox &bb, SAIParams ¶ms); + u32 UnpackLink(u32 &L); + void PackPosition(NodePosition &Dest, Fvector &Src, Fbox &bb, SAIParams ¶ms); - void EnumerateNodes (); - void DenumerateNodes (); + void EnumerateNodes(); + void DenumerateNodes(); - bool RealUpdateSnapList (); - int RemoveOutOfBoundsNodes (); + bool RealUpdateSnapList(); + int RemoveOutOfBoundsNodes(); - void CalculateNodesBBox (Fbox& bb); + void CalculateNodesBBox(Fbox &bb); // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - enum EMode{ - mdAppend, - mdRemove, - mdInvert, + enum EMode + { + mdAppend, + mdRemove, + mdInvert, }; - enum{ - flUpdateSnapList = (1<<0), - flHideNodes = (1<<1), - flSlowCalculate = (1<<2), - flUpdateHL = (1<<15), - }; - Flags32 m_Flags; - - float m_VisRadius; - float m_SmoothHeight; - u32 m_BrushSize; - xr_vector m_ignored_materials; - bool PickObjects (Fvector& dest, const Fvector& start, const Fvector& dir, float dist); -public: - ESceneAIMapTool (); - virtual ~ESceneAIMapTool (); + enum + { + flUpdateSnapList = (1<<0), + flHideNodes = (1<<1), + flSlowCalculate = (1<<2), + flUpdateHL = (1<<15), + }; - virtual bool AllowEnabling (){return true;} - virtual BOOL AllowMouseStart (){return true;} + Flags32 m_Flags; - virtual void OnObjectRemove (CCustomObject* O, bool bDeleting); - virtual void UpdateSnapList (){m_Flags.set(flUpdateSnapList,TRUE);} - virtual ObjectList* GetSnapList (){return &m_SnapObjects;} + float m_VisRadius; + float m_SmoothHeight; + u32 m_BrushSize; + xr_vector m_ignored_materials; - // selection manipulate - SAINode* PickNode (const Fvector& start, const Fvector& dir, float& dist); - virtual int RaySelect (int flag, float& distance, const Fvector& start, const Fvector& direction, BOOL bDistanceOnly); - virtual int FrustumSelect (int flag, const CFrustum& frustum); - virtual void SelectObjects (bool flag); - virtual void InvertSelection (); - virtual void RemoveSelection (); - virtual int SelectionCount (bool testflag); - virtual void ShowObjects (bool flag, bool bAllowSelectionFlag=false, bool bSelFlag=true){} + bool PickObjects(Fvector &dest, const Fvector &start, const Fvector &dir, float dist); +public: + ESceneAIMapTool(); + virtual ~ESceneAIMapTool(); + + virtual bool AllowEnabling() + { + return true; + } + + virtual BOOL AllowMouseStart() + { + return true; + } + + virtual void OnObjectRemove(CCustomObject *O, bool bDeleting); + + virtual void UpdateSnapList() + { + m_Flags.set(flUpdateSnapList, TRUE); + } + + virtual ObjectList *GetSnapList() + { + return &m_SnapObjects; + } + + // selection manipulate + SAINode *PickNode(const Fvector &start, const Fvector &dir, float &dist); + virtual int RaySelect(int flag, float &distance, const Fvector &start, const Fvector &direction, BOOL bDistanceOnly); + virtual int FrustumSelect(int flag, const CFrustum &frustum); + virtual void SelectObjects(bool flag); + virtual void InvertSelection(); + virtual void RemoveSelection(); + virtual int SelectionCount(bool testflag); + + virtual void ShowObjects(bool flag, bool bAllowSelectionFlag = false, bool bSelFlag = true) {} + + virtual void Clear(bool bOnlyNodes = false); + + // definition + IC LPCSTR ClassName() + { + return "ai_map"; + } + + IC LPCSTR ClassDesc() + { + return "AI Map"; + } + + IC + + int RenderPriority() + { + return 10; + } - virtual void Clear (bool bOnlyNodes=false); + // validation + virtual bool Valid(); - // definition - IC LPCSTR ClassName (){return "ai_map";} - IC LPCSTR ClassDesc (){return "AI Map";} - IC int RenderPriority (){return 10;} + virtual bool Validate(bool) + { + return true; + } - // validation - virtual bool Valid (); - virtual bool Validate (bool){return true;} - virtual bool IsNeedSave (); + virtual bool IsNeedSave(); // events - virtual void OnFrame (); - virtual void OnRender (int priority, bool strictB2F); - virtual void OnActivate (); + virtual void OnFrame(); + virtual void OnRender(int priority, bool strictB2F); + virtual void OnActivate(); // IO - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool can_use_inifile () {return false;} + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + + virtual bool can_use_inifile() + { + return false; + } - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - virtual bool Export (LPCSTR path); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + virtual bool Export(LPCSTR path); - // device dependent funcs - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); + // device dependent funcs + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); - virtual void OnSynchronize (); + virtual void OnSynchronize(); // utils - bool GenerateMap (bool bFromSelectedOnly); - virtual bool GetSummaryInfo (SSceneSummary* inf){return false;} - virtual void GetBBox (Fbox& bb, bool bSelOnly); + bool GenerateMap(bool bFromSelectedOnly); - // properties - virtual void FillProp (LPCSTR pref, PropItemVec& items); + virtual bool GetSummaryInfo(SSceneSummary *inf) + { + return false; + } + + virtual void GetBBox(Fbox &bb, bool bSelOnly); + + // properties + virtual void FillProp(LPCSTR pref, PropItemVec &items); // other - int AddNode (const Fvector& pos, bool bIgnoreConstraints, bool bAutoLink, int cnt); + int AddNode(const Fvector &pos, bool bIgnoreConstraints, bool bAutoLink, int cnt); - AINodeVec& Nodes (){return m_Nodes;} - - void MakeLinks (u8 side_flag, EMode mode, bool bIgnoreConstraints); - void RemoveLinks (); - void InvertLinks (); + AINodeVec &Nodes() + { + return m_Nodes; + } - void UpdateHLSelected (){m_Flags.set(flUpdateHL,TRUE);} + void MakeLinks(u8 side_flag, EMode mode, bool bIgnoreConstraints); + void RemoveLinks(); + void InvertLinks(); - void SmoothNodes (); - void ResetNodes (); - void SelectNodesByLink (int link); + void UpdateHLSelected() + { + m_Flags.set(flUpdateHL, TRUE); + } + + void SmoothNodes(); + void ResetNodes(); + void SelectNodesByLink(int link); }; #endif // ESceneAIMapToolsH + diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Controls.cpp b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Controls.cpp index 6304f645b0b..061fa38bf25 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Controls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Controls.cpp @@ -2,26 +2,29 @@ #pragma hdrstop #include "ESceneAIMapTools.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "ESceneAIMapControls.h" #include "FrameAIMap.h" void ESceneAIMapTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); - // node tools -// AddControl(xr_new (estAIMapNode, etaSelect, this)); - AddControl(xr_new (estAIMapNode, etaAdd, this)); - AddControl(xr_new (estAIMapNode, etaMove, this)); - AddControl(xr_new (estAIMapNode, etaRotate, this)); - // frame - pFrame = xr_new((TComponent*)0,this); + inherited::CreateDefaultControls(estDefault); + // node tools + // AddControl(xr_new(estAIMapNode, etaSelect, this)); + AddControl(xr_new(estAIMapNode, etaAdd, this)); + AddControl(xr_new(estAIMapNode, etaMove, this)); + AddControl(xr_new(estAIMapNode, etaRotate, this)); + // frame + pFrame = xr_new((TComponent*)0, this); } + //---------------------------------------------------- void ESceneAIMapTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Export.cpp b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Export.cpp index edfb81d9fef..29680b1dce1 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Export.cpp +++ b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Export.cpp @@ -1,91 +1,106 @@ #include "stdafx.h" -#pragma hdrstop - +#pragma hdrstop + #include "ESceneAIMapTools_Export.h" #include "ESceneAIMapTools.h" -void ESceneAIMapTool::UnpackPosition(Fvector& Pdest, const NodePosition& Psrc, Fbox& bb, SAIParams& params) +void ESceneAIMapTool::UnpackPosition(Fvector &Pdest, const NodePosition &Psrc, Fbox &bb, SAIParams ¶ms) { Pdest.x = float(Psrc.x)*params.fPatchSize; - Pdest.y = (float(Psrc.y)/65535)*(bb.max.y-bb.min.y) + bb.min.y; + Pdest.y = (float(Psrc.y)/65535)*(bb.max.y-bb.min.y)+bb.min.y; Pdest.z = float(Psrc.z)*params.fPatchSize; } -u32 ESceneAIMapTool::UnpackLink(u32& L) +u32 ESceneAIMapTool::UnpackLink(u32 &L) { - return L&0x00ffffff; + return L&0x00ffffff; } -void ESceneAIMapTool::PackPosition(NodePosition& Dest, Fvector& Src, Fbox& bb, SAIParams& params) +void ESceneAIMapTool::PackPosition(NodePosition &Dest, Fvector &Src, Fbox &bb, SAIParams ¶ms) { - float sp = 1/params.fPatchSize; - int px,py,pz; - px = iFloor(Src.x*sp+EPS_L); - py = iFloor(65535.f*(Src.y-bb.min.y)/(bb.max.y-bb.min.y)+EPS_L); - pz = iFloor(Src.z*sp+EPS_L); - - clamp (px,-32767,32767); Dest.x = s16 (px); - clamp (py,0, 65535); Dest.y = u16 (py); - clamp (pz,-32767,32767); Dest.z = s16 (pz); + float sp = 1/params.fPatchSize; + int px, py, pz; + px = iFloor(Src.x*sp+EPS_L); + py = iFloor(65535.f*(Src.y-bb.min.y)/(bb.max.y-bb.min.y)+EPS_L); + pz = iFloor(Src.z*sp+EPS_L); + + clamp(px, -32767, 32767); + Dest.x = s16(px); + clamp(py, 0, 65535); + Dest.y = u16(py); + clamp(pz, -32767, 32767); + Dest.z = s16(pz); } bool ESceneAIMapTool::Export(LPCSTR path) { -//.? if (!RealUpdateSnapList()) return false; - if (!Valid()) return false; + //.? if (!RealUpdateSnapList()) return false; + if (!Valid()) + return false; // calculate bbox - Fbox bb; CalculateNodesBBox(bb); + Fbox bb; + CalculateNodesBBox(bb); - AnsiString fn = AnsiString(path)+"build.aimap"; + AnsiString fn = AnsiString(path)+"build.aimap"; // export - IWriter* F = FS.w_open(fn.c_str()); - - if (F){ - F->open_chunk (E_AIMAP_CHUNK_VERSION); - F->w_u16 (E_AIMAP_VERSION); - F->close_chunk (); - - F->open_chunk (E_AIMAP_CHUNK_BOX); - F->w (&bb,sizeof(bb)); - F->close_chunk (); - - F->open_chunk (E_AIMAP_CHUNK_PARAMS); - F->w (&m_Params,sizeof(m_Params)); - F->close_chunk (); - - EnumerateNodes (); - F->open_chunk (E_AIMAP_CHUNK_NODES); - F->w_u32 (m_Nodes.size()); - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++){ - u32 id; - u16 pl; - NodePosition np; - - id = (*it)->n1?(u32)(*it)->n1->idx:InvalidNode; F->w(&id,3); - id = (*it)->n2?(u32)(*it)->n2->idx:InvalidNode; F->w(&id,3); - id = (*it)->n3?(u32)(*it)->n3->idx:InvalidNode; F->w(&id,3); - id = (*it)->n4?(u32)(*it)->n4->idx:InvalidNode; F->w(&id,3); - pl = pvCompress ((*it)->Plane.n); F->w_u16(pl); - PackPosition (np,(*it)->Pos,bb,m_Params); F->w(&np,sizeof(np)); + IWriter *F = FS.w_open(fn.c_str()); + + if (F) + { + F->open_chunk(E_AIMAP_CHUNK_VERSION); + F->w_u16(E_AIMAP_VERSION); + F->close_chunk(); + + F->open_chunk(E_AIMAP_CHUNK_BOX); + F->w(&bb, sizeof(bb)); + F->close_chunk(); + + F->open_chunk(E_AIMAP_CHUNK_PARAMS); + F->w(&m_Params, sizeof(m_Params)); + F->close_chunk(); + + EnumerateNodes(); + F->open_chunk(E_AIMAP_CHUNK_NODES); + F->w_u32(m_Nodes.size()); + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + { + u32 id; + u16 pl; + NodePosition np; + + id = (*it)->n1 ? (u32)(*it)->n1->idx : InvalidNode; + F->w(&id, 3); + id = (*it)->n2 ? (u32)(*it)->n2->idx : InvalidNode; + F->w(&id, 3); + id = (*it)->n3 ? (u32)(*it)->n3->idx : InvalidNode; + F->w(&id, 3); + id = (*it)->n4 ? (u32)(*it)->n4->idx : InvalidNode; + F->w(&id, 3); + pl = pvCompress((*it)->Plane.n); + F->w_u16(pl); + PackPosition(np, (*it)->Pos, bb, m_Params); + F->w(&np, sizeof(np)); } - F->close_chunk (); + F->close_chunk(); - FS.w_close (F); - return true; + FS.w_close(F); + return true; } - return false; + return false; } + /* - u32 id; + u32 id; u16 pl; - NodePosition np; - F.r (&id,3); n1 = (SAINode*)tools->UnpackLink(id); - F.r (&id,3); n2 = (SAINode*)tools->UnpackLink(id); - F.r (&id,3); n3 = (SAINode*)tools->UnpackLink(id); - F.r (&id,3); n4 = (SAINode*)tools->UnpackLink(id); - pl = F.r_u16(); pvDecompress(Plane.n,pl); - F.r (&np,sizeof(np)); tools->UnpackPosition(Pos,np,tools->m_BBox,tools->m_Params); - Plane.build (Pos,Plane.n); + NodePosition np; + F.r (&id,3); n1 = (SAINode*)tools->UnpackLink(id); + F.r (&id,3); n2 = (SAINode*)tools->UnpackLink(id); + F.r (&id,3); n3 = (SAINode*)tools->UnpackLink(id); + F.r (&id,3); n4 = (SAINode*)tools->UnpackLink(id); + pl = F.r_u16(); pvDecompress(Plane.n,pl); + F.r (&np,sizeof(np)); tools->UnpackPosition(Pos,np,tools->m_BBox,tools->m_Params); + Plane.build (Pos,Plane.n); */ + diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Export.h b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Export.h index f1bccecb0a9..c50fea41fdd 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Export.h +++ b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Export.h @@ -4,18 +4,18 @@ //---------------------------------------------------- struct SAIParams { - float fPatchSize; // patch size - float fTestHeight; // test height (center of the "tester") - float fCanUP; // can reach point in up (dist) - float fCanDOWN; // can reach point down (dist) - - SAIParams () + float fPatchSize; // patch size + float fTestHeight; // test height (center of the "tester") + float fCanUP; // can reach point in up (dist) + float fCanDOWN; // can reach point down (dist) + + SAIParams() { - fPatchSize = 0.7f; - fTestHeight = 1.0f; - fCanUP = 1.5f; - fCanDOWN = 4.0f; - } + fPatchSize = 0.7f; + fTestHeight = 1.0f; + fCanUP = 1.5f; + fCanDOWN = 4.0f; + } }; // chunks @@ -27,4 +27,4 @@ struct SAIParams #define E_AIMAP_CHUNK_NODES 0x0004 //---------------------------------------------------- #endif - \ No newline at end of file + diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Generate.cpp b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Generate.cpp index df6c29ede8d..d302224825e 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Generate.cpp +++ b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Generate.cpp @@ -4,661 +4,781 @@ #include "ESceneAIMapTools.h" #include "scene.h" -#include "../ECore/Editor/ui_main.h" -#include "ui_leveltools.h" +#include "editors/ECore/Editor/ui_main.h" +#include "UI_LevelTools.h" #include "cl_intersect.h" #include "MgcAppr3DPlaneFit.h" -#include "sceneobject.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EditMesh.h" -#include "leftbar.h" +#include "SceneObject.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditMesh.h" +#include "LeftBar.h" #include "ETools.h" -static SPickQuery PQ; +static SPickQuery PQ; -IC void SnapXZ (Fvector& V, float ps) +IC + +void SnapXZ(Fvector &V, float ps) { - V.x = snapto(V.x,ps); - V.z = snapto(V.z,ps); + V.x = snapto(V.x, ps); + V.z = snapto(V.z, ps); } -struct tri { - Fvector* v[3]; - Fvector N; + +struct tri +{ + Fvector *v[3]; + Fvector N; }; -const int RCAST_MaxTris = (2*1024); -const int RCAST_Count = 4; -const int RCAST_Total = (2*RCAST_Count+1)*(2*RCAST_Count+1); -const float RCAST_Depth = 1.f; -const float RCAST_VALID = 0.55f; +const int RCAST_MaxTris = (2*1024); +const int RCAST_Count = 4; +const int RCAST_Total = (2*RCAST_Count+1)*(2*RCAST_Count+1); +const float RCAST_Depth = 1.f; +const float RCAST_VALID = 0.55f; -BOOL ESceneAIMapTool::CreateNode(Fvector& vAt, SAINode& N, bool bIC) +BOOL ESceneAIMapTool::CreateNode(Fvector &vAt, SAINode &N, bool bIC) { - // *** Query and cache polygons for ray-casting - Fvector PointUp; PointUp.set(vAt); PointUp.y += RCAST_Depth; SnapXZ (PointUp,m_Params.fPatchSize); - Fvector PointDown; PointDown.set(vAt); PointDown.y -= RCAST_Depth; SnapXZ (PointDown,m_Params.fPatchSize); - - Fbox BB; BB.set (PointUp,PointUp); BB.grow(m_Params.fPatchSize/2); // box 1 - Fbox B2; B2.set (PointDown,PointDown); B2.grow(m_Params.fPatchSize/2); // box 2 - BB.merge (B2); + // *** Query and cache polygons for ray-casting + Fvector PointUp; + PointUp.set(vAt); + PointUp.y += RCAST_Depth; + SnapXZ(PointUp, m_Params.fPatchSize); + Fvector PointDown; + PointDown.set(vAt); + PointDown.y -= RCAST_Depth; + SnapXZ(PointDown, m_Params.fPatchSize); + + Fbox BB; + BB.set(PointUp, PointUp); + BB.grow(m_Params.fPatchSize/2); // box 1 + Fbox B2; + B2.set(PointDown, PointDown); + B2.grow(m_Params.fPatchSize/2); // box 2 + BB.merge(B2); if (m_CFModel) { - /* + /* for(u32 i=0; iget_tris_count(); ++i) { CDB::TRI* tri = (m_CFModel->get_tris()+i); if(tri->material!=0) - Msg("non-default material"); + Msg("non-default material"); } */ - Scene->BoxQuery(PQ,BB,CDB::OPT_FULL_TEST,m_CFModel); - }else - Scene->BoxQuery(PQ,BB,CDB::OPT_FULL_TEST,GetSnapList()); - - DWORD dwCount = PQ.r_count(); - if (dwCount==0){ -// Log("chasm1"); - return FALSE; // chasm? - } - - // *** Transfer triangles and compute sector -// R_ASSERT(dwCount tris; tris.reserve(RCAST_MaxTris); tris.clear(); - for (DWORD i=0; iBoxQuery(PQ, BB, CDB::OPT_FULL_TEST, m_CFModel); + } + else + Scene->BoxQuery(PQ, BB, CDB::OPT_FULL_TEST, GetSnapList()); + + DWORD dwCount = PQ.r_count(); + if (dwCount==0) + { + // Log("chasm1"); + return FALSE; // chasm? + } + + // *** Transfer triangles and compute sector + // R_ASSERT(dwCount tris; + tris.reserve(RCAST_MaxTris); + tris.clear(); + for (DWORD i = 0; ie_obj&&R->e_mesh) { - CSurface* surf = R->e_mesh->GetSurfaceByFaceID(R->tag); -//. SGameMtl* mtl = GMLib.GetMaterialByID(surf->_GameMtl()); -//. if (mtl->Flags.is(SGameMtl::flPassable))continue; + CSurface *surf = R->e_mesh->GetSurfaceByFaceID(R->tag); + //. SGameMtl* mtl = GMLib.GetMaterialByID(surf->_GameMtl()); + //. if (mtl->Flags.is(SGameMtl::flPassable))continue; - Shader_xrLC* c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); - if (!c_sh->flags.bCollision) continue; + Shader_xrLC *c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); + if (!c_sh->flags.bCollision) + continue; } - /* - if(m_CFModel) + /* + if(m_CFModel) + { + u16 mtl_id = R->material; + + if(std::find(m_ignored_materials.begin(), m_ignored_materials.end(), mtl_id) != m_ignored_materials.end() ) + { + //. Msg("--ignore"); + continue; + } + } + */ + tris.push_back(tri()); + tri &D = tris.back(); + Fvector *V = R->verts; + + D.v[0] = &V[0]; + D.v[1] = &V[1]; + D.v[2] = &V[2]; + D.N.mknormal(*D.v[0], *D.v[1], *D.v[2]); + if (D.N.y<=0) + tris.pop_back(); + } + if (tris.size()==0) + { + // Log("chasm2"); + return FALSE; // chasm? + } + + static xr_vector points; + points.reserve(RCAST_Total); + points.clear(); + static xr_vector normals; + normals.reserve(RCAST_Total); + normals.clear(); + Fvector P, D; + D.set(0, -1, 0); + + float coeff = 0.5f*m_Params.fPatchSize/float(RCAST_Count); + + for (int x = -RCAST_Count; x<=RCAST_Count; x++) + { + P.x = vAt.x+coeff*float(x); + for (int z = -RCAST_Count; z<=RCAST_Count; z++) { - u16 mtl_id = R->material; + P.z = vAt.z+coeff*float(z); + P.y = vAt.y+10.f; - if(std::find(m_ignored_materials.begin(), m_ignored_materials.end(), mtl_id) != m_ignored_materials.end() ) + float tri_min_range = flt_max; + int tri_selected = -1; + float range, u, v; + for (i = 0; i=0) + { + P.y -= tri_min_range; + points.push_back(P); + normals.push_back(tris[tri_selected].N); + } + } + } + if (points.size()<3) + { + // Msg ("Failed to create node at [%f,%f,%f].",vAt.x,vAt.y,vAt.z); + return FALSE; + } + //. + float rc_lim = bIC ? 0.015f : 0.7f; + if (float(points.size())/float(RCAST_Total)0) + { + vOffs = points[p]; + PL.build(vOffs, vNorm); + } + } + + // *** Create node and register it + N.Plane.build(vOffs, vNorm); // build plane + D.set(0, 1, 0); + N.Plane.intersectRayPoint(PointDown, D, N.Pos); // "project" position + + // *** Validate results + vNorm.set(0, 1, 0); + if (vNorm.dotproduct(N.Plane.n)<_cos(deg2rad(60.f))) + return FALSE; + + float y_old = vAt.y; + float y_new = N.Pos.y; + if (y_old>y_new) + { + // down + if (y_old-y_new>m_Params.fCanDOWN) + return FALSE; + } + else + { + // up + if (y_new-y_old>m_Params.fCanUP) + return FALSE; + } + + // *** Validate plane + { + Fvector PLP; + D.set(0, -1, 0); + int num_successed_rays = 0; + for (int x = -RCAST_Count; x<=RCAST_Count; x++) + { + P.x = N.Pos.x+coeff*float(x); + for (int z = -RCAST_Count; z<=RCAST_Count; z++) + { + P.z = N.Pos.z+coeff*float(z); + P.y = N.Pos.y; + N.Plane.intersectRayPoint(P, D, PLP); // "project" position + P.y = PLP.y+RCAST_VALID*0.01f; + + float tri_min_range = flt_max; + int tri_selected = -1; + float range, u, v; + for (i = 0; i=0) + { + if (tri_min_rangeverts; - - D.v[0] = &V[0]; - D.v[1] = &V[1]; - D.v[2] = &V[2]; - D.N.mknormal(*D.v[0],*D.v[1],*D.v[2]); - if (D.N.y<=0) tris.pop_back (); - } - if (tris.size()==0){ -// Log("chasm2"); - return FALSE; // chasm? - } - - static xr_vector points; points.reserve(RCAST_Total); points.clear(); - static xr_vector normals; normals.reserve(RCAST_Total);normals.clear(); - Fvector P,D; D.set(0,-1,0); - - float coeff = 0.5f*m_Params.fPatchSize/float(RCAST_Count); - - for (int x=-RCAST_Count; x<=RCAST_Count; x++) - { - P.x = vAt.x + coeff*float(x); - for (int z=-RCAST_Count; z<=RCAST_Count; z++) { - P.z = vAt.z + coeff*float(z); - P.y = vAt.y + 10.f; - - float tri_min_range = flt_max; - int tri_selected = -1; - float range,u,v; - for (i=0; i=0) { - P.y -= tri_min_range; - points.push_back(P); - normals.push_back(tris[tri_selected].N); - } - } - } - if (points.size()<3) { -// Msg ("Failed to create node at [%f,%f,%f].",vAt.x,vAt.y,vAt.z); - return FALSE; - } -//. - float rc_lim = bIC?0.015f:0.7f; - if (float(points.size())/float(RCAST_Total) < rc_lim) { -// Msg ("Partial chasm at [%f,%f,%f].",vAt.x,vAt.y,vAt.z); - return FALSE; - } - - // *** Calc normal - Fvector vNorm; - vNorm.set(0,0,0); - for (DWORD n=0; n0) { - vOffs = points[p]; - PL.build(vOffs,vNorm); - } - } - - // *** Create node and register it - N.Plane.build (vOffs,vNorm); // build plane - D.set (0,1,0); - N.Plane.intersectRayPoint(PointDown,D,N.Pos); // "project" position - - // *** Validate results - vNorm.set(0,1,0); - if (vNorm.dotproduct(N.Plane.n)<_cos(deg2rad(60.f))) return FALSE; - - float y_old = vAt.y; - float y_new = N.Pos.y; - if (y_old>y_new) { - // down - if (y_old-y_new > m_Params.fCanDOWN ) return FALSE; - } else { - // up - if (y_new-y_old > m_Params.fCanUP ) return FALSE; - } - - // *** Validate plane - { - Fvector PLP; D.set(0,-1,0); - int num_successed_rays = 0; - for (int x=-RCAST_Count; x<=RCAST_Count; x++) - { - P.x = N.Pos.x + coeff*float(x); - for (int z=-RCAST_Count; z<=RCAST_Count; z++) { - P.z = N.Pos.z + coeff*float(z); - P.y = N.Pos.y; - N.Plane.intersectRayPoint(P,D,PLP); // "project" position - P.y = PLP.y+RCAST_VALID*0.01f; - - float tri_min_range = flt_max; - int tri_selected = -1; - float range,u,v; - for (i=0; i=0){ - if (tri_min_range(); - m_HASH[i][j].clear (); - m_HASH[i][j].reserve (64); - } + for (int i = 0; i<=HDIM_X; i++) + for (int j = 0; j<=HDIM_Z; j++) + { + // m_HASH[i][j] = xr_new(); + m_HASH[i][j].clear(); + m_HASH[i][j].reserve(64); + } } void ESceneAIMapTool::hash_FillFromNodes() { - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++){ - AINodeVec* V = HashMap((*it)->Pos); R_ASSERT2(V,"AINode position out of bounds."); - V->push_back (*it); + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + { + AINodeVec *V = HashMap((*it)->Pos); + R_ASSERT2(V, "AINode position out of bounds."); + V->push_back(*it); } } void ESceneAIMapTool::hash_Clear() { - for (int i=0; i<=HDIM_X; i++) - for (int j=0; j<=HDIM_Z; j++) -// xr_delete (m_HASH[i][j]); - m_HASH[i][j].clear (); + for (int i = 0; i<=HDIM_X; i++) + for (int j = 0; j<=HDIM_Z; j++) + // xr_delete(m_HASH[i][j]); + m_HASH[i][j].clear(); } -void ESceneAIMapTool::HashRect(const Fvector& v, float radius, Irect& result) +void ESceneAIMapTool::HashRect(const Fvector &v, float radius, Irect &result) { - Fvector VMmin, VMscale, VMeps, scale; - - Fbox& bb = m_AIBBox; - VMscale.set (bb.max.x-bb.min.x, bb.max.y-bb.min.y, bb.max.z-bb.min.z); - VMmin.set (bb.min); - VMeps.set (float(VMscale.x/HDIM_X/2.f),float(0),float(VMscale.z/HDIM_Z/2.f)); - VMeps.x = (VMeps.xbegin(); I!=V->end(); I++){ - SAINode* N = *I; - if (vAt.similar(N->Pos,eps)) return N; - } - return 0; + AINodeVec *V = HashMap(vAt); + if (!V) + return 0; + + for (AINodeIt I = V->begin(); I!=V->end(); I++) + { + SAINode *N = *I; + if (vAt.similar(N->Pos, eps)) + return N; + } + return 0; } - + BOOL ESceneAIMapTool::CanTravel(Fvector _from, Fvector _at) { - _at.y = _from.y; - - float eps = 0.1f; - float eps_y = m_Params.fPatchSize*1.5f; // * tan(56) = 1.5 - Fvector Result; float radius = m_Params.fPatchSize/_sqrt(2.f); - - // 1 - MotionSimulate(Result,_from,_at,radius,0.7f); - BOOL b1 = fsimilar(Result.x,_at.x,eps)&&fsimilar(Result.z,_at.z,eps)&&fsimilar(Result.y,_at.y,eps_y); - if (b1) return TRUE; - - // 2 - MotionSimulate(Result,_from,_at,radius,2.f); - BOOL b2 = fsimilar(Result.x,_at.x,eps)&&fsimilar(Result.z,_at.z,eps)&&fsimilar(Result.y,_at.y,eps_y); - if (b2) return TRUE; - - return FALSE; + _at.y = _from.y; + + float eps = 0.1f; + float eps_y = m_Params.fPatchSize*1.5f; // * tan(56) = 1.5 + Fvector Result; + float radius = m_Params.fPatchSize/_sqrt(2.f); + + // 1 + MotionSimulate(Result, _from, _at, radius, 0.7f); + BOOL b1 = fsimilar(Result.x, _at.x, eps)&&fsimilar(Result.z, _at.z, eps)&&fsimilar(Result.y, _at.y, eps_y); + if (b1) + return TRUE; + + // 2 + MotionSimulate(Result, _from, _at, radius, 2.f); + BOOL b2 = fsimilar(Result.x, _at.x, eps)&&fsimilar(Result.z, _at.z, eps)&&fsimilar(Result.y, _at.y, eps_y); + if (b2) + return TRUE; + + return FALSE; } -SAINode* ESceneAIMapTool::BuildNode(Fvector& vFrom, Fvector& vAt, bool bIC, bool bSuperIC) // return node's index +SAINode *ESceneAIMapTool::BuildNode(Fvector &vFrom, Fvector &vAt, bool bIC, bool bSuperIC) // return node's index { - // *** Test if we can travel this path - SnapXZ (vAt,m_Params.fPatchSize); + // *** Test if we can travel this path + SnapXZ(vAt, m_Params.fPatchSize); - if (!(bIC||CanTravel(vFrom, vAt))) return 0; + if (!(bIC||CanTravel(vFrom, vAt))) + return 0; - // *** set up node - SAINode N; + // *** set up node + SAINode N; - BOOL bRes = CreateNode(vAt,N,bIC); - if (!bRes&&bIC&&bSuperIC){ - Fvector D = {0,1,0}; - N.Plane.build(vAt,D); // build plane - N.Plane.intersectRayPoint(vAt,D,N.Pos); // "project" position - bRes = TRUE; + BOOL bRes = CreateNode(vAt, N, bIC); + if (!bRes&&bIC&&bSuperIC) + { + Fvector D = {0,1,0}; + N.Plane.build(vAt, D); // build plane + N.Plane.intersectRayPoint(vAt, D, N.Pos); // "project" position + bRes = TRUE; } - if (bRes) { - //*** check if similar node exists - SAINode* old = FindNode(N.Pos); - if (!old){ - // register xr_new(N)); - V->push_back (m_Nodes.back()); + if (bRes) + { + //*** check if similar node exists + SAINode *old = FindNode(N.Pos); + if (!old) + { + // register xr_new(N)); + V->push_back(m_Nodes.back()); return m_Nodes.back(); - }else return 0; - }else{ - // where already was node - return it - return old; - } - }else{ - return 0; + } + else + return 0; + } + else + { + // where already was node - return it + return old; + } + } + else + { + return 0; } } -int ESceneAIMapTool::BuildNodes(const Fvector& pos, int sz, bool bIC) +int ESceneAIMapTool::BuildNodes(const Fvector &pos, int sz, bool bIC) { // Align emitter - Fvector Pos = pos; - SnapXZ (Pos,m_Params.fPatchSize); - Pos.y += 1; - Fvector Dir; Dir.set(0,-1,0); + Fvector Pos = pos; + SnapXZ(Pos, m_Params.fPatchSize); + Pos.y += 1; + Fvector Dir; + Dir.set(0, -1, 0); - int cnt = 0; + int cnt = 0; if (m_CFModel) - cnt=Scene->RayQuery(PQ,Pos,Dir,3,CDB::OPT_ONLYNEAREST|CDB::OPT_CULL,m_CFModel); + cnt = Scene->RayQuery(PQ, Pos, Dir, 3, CDB::OPT_ONLYNEAREST|CDB::OPT_CULL, m_CFModel); else - cnt=Scene->RayQuery(PQ,Pos,Dir,3,CDB::OPT_ONLYNEAREST|CDB::OPT_CULL,GetSnapList()); + cnt = Scene->RayQuery(PQ, Pos, Dir, 3, CDB::OPT_ONLYNEAREST|CDB::OPT_CULL, GetSnapList()); - if (0==cnt) { - ELog.Msg (mtInformation,"Can't align position."); - return 0; - } else { - Pos.y = Pos.y - PQ.r_begin()->range; + if (0==cnt) + { + ELog.Msg(mtInformation, "Can't align position."); + return 0; + } + else + { + Pos.y = Pos.y-PQ.r_begin()->range; } - + // Build first node - int oldcount = m_Nodes.size(); - SAINode* start = BuildNode(Pos,Pos,bIC); - if (!start) return 0; + int oldcount = m_Nodes.size(); + SAINode *start = BuildNode(Pos, Pos, bIC); + if (!start) + return 0; // Estimate nodes - float estimated_nodes = (2*sz-1)*(2*sz-1); + float estimated_nodes = (2*sz-1)*(2*sz-1); - SPBItem* pb = 0; - if (estimated_nodes>1024) pb = UI->ProgressStart(1, "Building nodes..."); - float radius = sz*m_Params.fPatchSize-EPS_L; + SPBItem *pb = 0; + if (estimated_nodes>1024) + pb = UI->ProgressStart(1, "Building nodes..."); + float radius = sz*m_Params.fPatchSize-EPS_L; // General cycle - for (int k=0; k<(int)m_Nodes.size(); k++){ - SAINode* N = m_Nodes[k]; + for (int k = 0; k<(int)m_Nodes.size(); k++) + { + SAINode *N = m_Nodes[k]; // left - if (0==N->n1){ - Pos.set (N->Pos); - Pos.x -= m_Params.fPatchSize; + if (0==N->n1) + { + Pos.set(N->Pos); + Pos.x -= m_Params.fPatchSize; if (Pos.distance_to(start->Pos)<=radius) - N->n1 = BuildNode(N->Pos,Pos,bIC); + N->n1 = BuildNode(N->Pos, Pos, bIC); } // fwd - if (0==N->n2){ - Pos.set (N->Pos); - Pos.z += m_Params.fPatchSize; + if (0==N->n2) + { + Pos.set(N->Pos); + Pos.z += m_Params.fPatchSize; if (Pos.distance_to(start->Pos)<=radius) - N->n2 = BuildNode(N->Pos,Pos,bIC); + N->n2 = BuildNode(N->Pos, Pos, bIC); } // right - if (0==N->n3){ - Pos.set (N->Pos); - Pos.x += m_Params.fPatchSize; + if (0==N->n3) + { + Pos.set(N->Pos); + Pos.x += m_Params.fPatchSize; if (Pos.distance_to(start->Pos)<=radius) - N->n3 = BuildNode(N->Pos,Pos,bIC); + N->n3 = BuildNode(N->Pos, Pos, bIC); } // back - if (0==N->n4){ - Pos.set (N->Pos); - Pos.z -= m_Params.fPatchSize; + if (0==N->n4) + { + Pos.set(N->Pos); + Pos.z -= m_Params.fPatchSize; if (Pos.distance_to(start->Pos)<=radius) - N->n4 = BuildNode(N->Pos,Pos,bIC); + N->n4 = BuildNode(N->Pos, Pos, bIC); } - if (estimated_nodes>1024){ - if (k%128==0) { - float p1 = float(k)/float(m_Nodes.size()); - float p2 = float(m_Nodes.size())/estimated_nodes; - float p = 0.1f*p1+0.9f*p2; + if (estimated_nodes>1024) + { + if (k%128==0) + { + float p1 = float(k)/float(m_Nodes.size()); + float p2 = float(m_Nodes.size())/estimated_nodes; + float p = 0.1f*p1+0.9f*p2; - clamp (p,0.f,1.f); + clamp(p, 0.f, 1.f); pb->Update(p); // check need abort && redraw - if (UI->NeedAbort()) break; + if (UI->NeedAbort()) + break; } } } - if (estimated_nodes>1024) UI->ProgressEnd(pb); + if (estimated_nodes>1024) + UI->ProgressEnd(pb); return oldcount-m_Nodes.size(); } void ESceneAIMapTool::BuildNodes(bool bFromSelectedOnly) { - // begin - m_Nodes.reserve (1024*1024); + // begin + m_Nodes.reserve(1024*1024); - // Initialize hash -// hash_Initialize (); + // Initialize hash + // hash_Initialize (); R_ASSERT(!m_Nodes.empty()); // Estimate nodes - Fvector Pos,LevelSize; - m_AIBBox.getsize (LevelSize); - float estimated_nodes = (LevelSize.x/m_Params.fPatchSize)*(LevelSize.z/m_Params.fPatchSize); + Fvector Pos, LevelSize; + m_AIBBox.getsize(LevelSize); + float estimated_nodes = (LevelSize.x/m_Params.fPatchSize)*(LevelSize.z/m_Params.fPatchSize); - SPBItem* pb = UI->ProgressStart(1, "Building nodes..."); + SPBItem *pb = UI->ProgressStart(1, "Building nodes..."); // General cycle - for (int k=0; k<(int)m_Nodes.size(); k++){ - SAINode* N = m_Nodes[k]; - if (bFromSelectedOnly && !N->flags.is(SAINode::flSelected)) continue; + for (int k = 0; k<(int)m_Nodes.size(); k++) + { + SAINode *N = m_Nodes[k]; + if (bFromSelectedOnly&&!N->flags.is(SAINode::flSelected)) + continue; // left - if (0==N->n1){ - Pos.set (N->Pos); - Pos.x -= m_Params.fPatchSize; - N->n1 = BuildNode(N->Pos,Pos,false); + if (0==N->n1) + { + Pos.set(N->Pos); + Pos.x -= m_Params.fPatchSize; + N->n1 = BuildNode(N->Pos, Pos, false); } // fwd - if (0==N->n2){ - Pos.set (N->Pos); - Pos.z += m_Params.fPatchSize; - N->n2 = BuildNode(N->Pos,Pos,false); + if (0==N->n2) + { + Pos.set(N->Pos); + Pos.z += m_Params.fPatchSize; + N->n2 = BuildNode(N->Pos, Pos, false); } // right - if (0==N->n3){ - Pos.set (N->Pos); - Pos.x += m_Params.fPatchSize; - N->n3 = BuildNode(N->Pos,Pos,false); + if (0==N->n3) + { + Pos.set(N->Pos); + Pos.x += m_Params.fPatchSize; + N->n3 = BuildNode(N->Pos, Pos, false); } // back - if (0==N->n4){ - Pos.set (N->Pos); - Pos.z -= m_Params.fPatchSize; - N->n4 = BuildNode(N->Pos,Pos,false); + if (0==N->n4) + { + Pos.set(N->Pos); + Pos.z -= m_Params.fPatchSize; + N->n4 = BuildNode(N->Pos, Pos, false); } - if (bFromSelectedOnly){ - // select neighbour nodes - if (N->n1) N->n1->flags.set(SAINode::flSelected,TRUE); - if (N->n2) N->n2->flags.set(SAINode::flSelected,TRUE); - if (N->n3) N->n3->flags.set(SAINode::flSelected,TRUE); - if (N->n4) N->n4->flags.set(SAINode::flSelected,TRUE); + if (bFromSelectedOnly) + { + // select neighbour nodes + if (N->n1) + N->n1->flags.set(SAINode::flSelected, TRUE); + if (N->n2) + N->n2->flags.set(SAINode::flSelected, TRUE); + if (N->n3) + N->n3->flags.set(SAINode::flSelected, TRUE); + if (N->n4) + N->n4->flags.set(SAINode::flSelected, TRUE); } - - if (k%512==0) { - float p1 = float(k)/float(m_Nodes.size()); - float p2 = float(m_Nodes.size())/estimated_nodes; - float p = 0.1f*p1+0.9f*p2; - clamp (p,0.f,1.f); + if (k%512==0) + { + float p1 = float(k)/float(m_Nodes.size()); + float p2 = float(m_Nodes.size())/estimated_nodes; + float p = 0.1f*p1+0.9f*p2; + + clamp(p, 0.f, 1.f); pb->Update(p); // check need abort && redraw - if (k%32768==0) UI->RedrawScene(true); - if (UI->NeedAbort()) break; + if (k%32768==0) + UI->RedrawScene(true); + if (UI->NeedAbort()) + break; } } UI->ProgressEnd(pb); } -SAINode* ESceneAIMapTool::GetNode(Fvector vAt, bool bIC) // return node's index +SAINode *ESceneAIMapTool::GetNode(Fvector vAt, bool bIC) // return node's index { - // *** Test if we can travel this path - SnapXZ (vAt,m_Params.fPatchSize); - - // *** set up xr_new(); - SAINode* R = 0; - if (CreateNode(vAt,*N,bIC)){ - R = FindNode(N->Pos); - xr_delete (N); + // *** Test if we can travel this path + SnapXZ(vAt, m_Params.fPatchSize); + + // *** set up xr_new(); + SAINode *R = 0; + if (CreateNode(vAt, *N, bIC)) + { + R = FindNode(N->Pos); + xr_delete(N); } - xr_delete(N); + xr_delete(N); return R; } -void ESceneAIMapTool::UpdateLinks(SAINode* N, bool bIC) +void ESceneAIMapTool::UpdateLinks(SAINode *N, bool bIC) { - Fvector Pos; - SAINode* D; + Fvector Pos; + SAINode *D; // left { - Pos.set (N->Pos); - Pos.x -= m_Params.fPatchSize; - D = GetNode(Pos,bIC); - if (bIC||CanTravel(N->Pos, Pos)) N->n1 = D; - if (D&&(bIC||CanTravel(D->Pos, N->Pos))) D->n3 = N; + Pos.set(N->Pos); + Pos.x -= m_Params.fPatchSize; + D = GetNode(Pos, bIC); + if (bIC||CanTravel(N->Pos, Pos)) + N->n1 = D; + if (D&&(bIC||CanTravel(D->Pos, N->Pos))) + D->n3 = N; } // fwd { - Pos.set (N->Pos); - Pos.z += m_Params.fPatchSize; - D = GetNode(Pos,bIC); - if (bIC||CanTravel(N->Pos, Pos)) N->n2 = D; - if (D&&(bIC||CanTravel(D->Pos, N->Pos))) D->n4 = N; + Pos.set(N->Pos); + Pos.z += m_Params.fPatchSize; + D = GetNode(Pos, bIC); + if (bIC||CanTravel(N->Pos, Pos)) + N->n2 = D; + if (D&&(bIC||CanTravel(D->Pos, N->Pos))) + D->n4 = N; } // right { - Pos.set (N->Pos); - Pos.x += m_Params.fPatchSize; - D = GetNode(Pos,bIC); - if (bIC||CanTravel(N->Pos, Pos)) N->n3 = D; - if (D&&(bIC||CanTravel(D->Pos, N->Pos))) D->n1 = N; + Pos.set(N->Pos); + Pos.x += m_Params.fPatchSize; + D = GetNode(Pos, bIC); + if (bIC||CanTravel(N->Pos, Pos)) + N->n3 = D; + if (D&&(bIC||CanTravel(D->Pos, N->Pos))) + D->n1 = N; } // back { - Pos.set (N->Pos); - Pos.z -= m_Params.fPatchSize; - D = GetNode(Pos,bIC); - if (bIC||CanTravel(N->Pos, Pos)) N->n4 = D; - if (D&&(bIC||CanTravel(D->Pos, N->Pos))) D->n2 = N; + Pos.set(N->Pos); + Pos.z -= m_Params.fPatchSize; + D = GetNode(Pos, bIC); + if (bIC||CanTravel(N->Pos, Pos)) + N->n4 = D; + if (D&&(bIC||CanTravel(D->Pos, N->Pos))) + D->n2 = N; } } bool ESceneAIMapTool::GenerateMap(bool bFromSelectedOnly) { - std::sort(m_ignored_materials.begin(),m_ignored_materials.end()); - bool bRes = false; - if (!GetSnapList()->empty()){ - if (!RealUpdateSnapList()) return false; - if (m_Nodes.empty()){ - ELog.DlgMsg(mtError,"Append at least one node."); + std::sort(m_ignored_materials.begin(), m_ignored_materials.end()); + bool bRes = false; + if (!GetSnapList()->empty()) + { + if (!RealUpdateSnapList()) + return false; + if (m_Nodes.empty()) + { + ELog.DlgMsg(mtError, "Append at least one node."); return false; } - if (!m_Flags.is(flSlowCalculate)){ + if (!m_Flags.is(flSlowCalculate)) + { // evict resources - ExecCommand (COMMAND_EVICT_OBJECTS); - ExecCommand (COMMAND_EVICT_TEXTURES); - + ExecCommand(COMMAND_EVICT_OBJECTS); + ExecCommand(COMMAND_EVICT_TEXTURES); + // prepare collision model - u32 avg_face_cnt = 0; - u32 avg_vert_cnt = 0; - u32 mesh_cnt = 0; - Fbox snap_bb; + u32 avg_face_cnt = 0; + u32 avg_vert_cnt = 0; + u32 mesh_cnt = 0; + Fbox snap_bb; { - snap_bb.invalidate (); - for (ObjectIt o_it=m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); o_it++){ - CSceneObject* S = dynamic_cast(*o_it); VERIFY(S); - avg_face_cnt += S->GetFaceCount(); - avg_vert_cnt += S->GetVertexCount(); - mesh_cnt += S->Meshes()->size(); - Fbox bb; - S->GetBox (bb); - snap_bb.merge (bb); + snap_bb.invalidate(); + for (ObjectIt o_it = m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); o_it++) + { + CSceneObject *S = dynamic_cast(*o_it); + VERIFY(S); + avg_face_cnt += S->GetFaceCount(); + avg_vert_cnt += S->GetVertexCount(); + mesh_cnt += S->Meshes()->size(); + Fbox bb; + S->GetBox(bb); + snap_bb.merge(bb); } } - SPBItem* pb = UI->ProgressStart(mesh_cnt,"Prepare collision model..."); + SPBItem *pb = UI->ProgressStart(mesh_cnt, "Prepare collision model..."); - CDB::Collector* CL = ETOOLS::create_collector(); + CDB::Collector *CL = ETOOLS::create_collector(); Fvector verts[3]; - for (ObjectIt o_it=m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); o_it++) + for (ObjectIt o_it = m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); o_it++) { - CSceneObject* S = dynamic_cast(*o_it); VERIFY(S); - CEditableObject* E = S->GetReference(); VERIFY(E); - EditMeshVec& _meshes = E->Meshes(); - for (EditMeshIt m_it=_meshes.begin(); m_it!=_meshes.end(); m_it++) + CSceneObject *S = dynamic_cast(*o_it); + VERIFY(S); + CEditableObject *E = S->GetReference(); + VERIFY(E); + EditMeshVec &_meshes = E->Meshes(); + for (EditMeshIt m_it = _meshes.begin(); m_it!=_meshes.end(); m_it++) { - pb->Inc(AnsiString().sprintf("%s [%s]",S->Name,(*m_it)->Name().c_str()).c_str()); - const SurfFaces& _sfaces = (*m_it)->GetSurfFaces(); - for (SurfFaces::const_iterator sp_it=_sfaces.begin(); sp_it!=_sfaces.end(); sp_it++) + pb->Inc(AnsiString().sprintf("%s [%s]", S->Name, (*m_it)->Name().c_str()).c_str()); + const SurfFaces &_sfaces = (*m_it)->GetSurfFaces(); + for (SurfFaces::const_iterator sp_it = _sfaces.begin(); sp_it!=_sfaces.end(); sp_it++) { - CSurface* surf = sp_it->first; + CSurface *surf = sp_it->first; // test passable - //. SGameMtl* mtl = GMLib.GetMaterialByID(surf->_GameMtl()); - //. if (mtl->Flags.is(SGameMtl::flPassable))continue; + //. SGameMtl* mtl = GMLib.GetMaterialByID(surf->_GameMtl()); + //. if (mtl->Flags.is(SGameMtl::flPassable))continue; - Shader_xrLC* c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); - if (!c_sh->flags.bCollision) continue; + Shader_xrLC *c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); + if (!c_sh->flags.bCollision) + continue; // collect tris - const IntVec& face_lst = sp_it->second; - for (IntVec::const_iterator it=face_lst.begin(); it!=face_lst.end(); it++) + const IntVec &face_lst = sp_it->second; + for (IntVec::const_iterator it = face_lst.begin(); it!=face_lst.end(); it++) { - E->GetFaceWorld (S->_Transform(),*m_it,*it,verts); + E->GetFaceWorld(S->_Transform(), *m_it, *it, verts); - ETOOLS::collector_add_face_d(CL,verts[0],verts[1],verts[2], surf->_GameMtl() /* *it */); + ETOOLS::collector_add_face_d(CL, verts[0], verts[1], verts[2], surf->_GameMtl() /* *it */); if (surf->m_Flags.is(CSurface::sf2Sided)) - ETOOLS::collector_add_face_d(CL,verts[2],verts[1],verts[0], surf->_GameMtl() /* *it */); + ETOOLS::collector_add_face_d(CL, verts[2], verts[1], verts[0], surf->_GameMtl() /* *it */); } } } @@ -666,44 +786,48 @@ bool ESceneAIMapTool::GenerateMap(bool bFromSelectedOnly) UI->ProgressEnd(pb); - UI->SetStatus ("Building collision model..."); + UI->SetStatus("Building collision model..."); // create CFModel - m_CFModel = ETOOLS::create_model_cl(CL); + m_CFModel = ETOOLS::create_model_cl(CL); ETOOLS::destroy_collector(CL); - } + } // building - Scene->lock (); -CTimer tm; -tm.Start(); - BuildNodes (bFromSelectedOnly); -tm.GetElapsed_sec(); - Scene->unlock (); -//. Log("-test time: ", g_tm.GetElapsed_sec()); - Log("-building time: ",tm.GetElapsed_sec()); -//. Msg("-Rate: %3.2f Count: %d",(g_tm.GetElapsed_sec()/tm.GetElapsed_sec())*100.f,g_tm.count); + Scene->lock(); + CTimer tm; + tm.Start(); + BuildNodes(bFromSelectedOnly); + tm.GetElapsed_sec(); + Scene->unlock(); + //. Log("-test time: ", g_tm.GetElapsed_sec()); + Log("-building time: ", tm.GetElapsed_sec()); + //. Msg("-Rate: %3.2f Count: %d",(g_tm.GetElapsed_sec()/tm.GetElapsed_sec())*100.f,g_tm.count); // unload CFModel - ETOOLS::destroy_model(m_CFModel); + ETOOLS::destroy_model(m_CFModel); - Scene->UndoSave (); + Scene->UndoSave(); bRes = true; - UI->SetStatus (""); - }else{ - ELog.DlgMsg(mtError,"Fill snap list before generating slots!"); + UI->SetStatus(""); + } + else + { + ELog.DlgMsg(mtError, "Fill snap list before generating slots!"); } return bRes; } int ESceneAIMapTool::RemoveOutOfBoundsNodes() { - int count = 0; - for (int k=0; k<(int)m_Nodes.size(); k++){ - SAINode* N = m_Nodes[k]; - AINodeVec* V = HashMap(N->Pos); - if (!V){ - m_Nodes.erase(m_Nodes.begin()+k); + int count = 0; + for (int k = 0; k<(int)m_Nodes.size(); k++) + { + SAINode *N = m_Nodes[k]; + AINodeVec *V = HashMap(N->Pos); + if (!V) + { + m_Nodes.erase(m_Nodes.begin()+k); k--; count++; } @@ -713,200 +837,275 @@ int ESceneAIMapTool::RemoveOutOfBoundsNodes() bool ESceneAIMapTool::RealUpdateSnapList() { - m_Flags.set (flUpdateSnapList,FALSE); - fraLeftBar->UpdateSnapList (); - Fbox nodes_bb; CalculateNodesBBox(nodes_bb); - if (!GetSnapList()->empty()){ - Fbox bb,snap_bb; Scene->GetBox(snap_bb,*GetSnapList()); - if (nodes_bb.is_valid()) bb.merge(snap_bb,nodes_bb); else bb.set(snap_bb); - if (!m_AIBBox.similar(bb)){ - m_AIBBox.set (bb); - hash_Clear (); - hash_FillFromNodes (); + m_Flags.set(flUpdateSnapList, FALSE); + fraLeftBar->UpdateSnapList(); + Fbox nodes_bb; + CalculateNodesBBox(nodes_bb); + if (!GetSnapList()->empty()) + { + Fbox bb, snap_bb; + Scene->GetBox(snap_bb, *GetSnapList()); + if (nodes_bb.is_valid()) + bb.merge(snap_bb, nodes_bb); else + bb.set(snap_bb); + if (!m_AIBBox.similar(bb)) + { + m_AIBBox.set(bb); + hash_Clear(); + hash_FillFromNodes(); } - return true; - }else{ - m_AIBBox.set (nodes_bb); - hash_Clear (); - hash_FillFromNodes (); + return true; + } + else + { + m_AIBBox.set(nodes_bb); + hash_Clear(); + hash_FillFromNodes(); return false; } } void ESceneAIMapTool::RemoveLinks() { - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++) - if ((*it)->flags.is(SAINode::flSelected)){ - for (int k=0; k<4; k++) - if ((*it)->n[k]&&(*it)->n[k]->flags.is(SAINode::flSelected)) - (*it)->n[k] = 0; + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + if ((*it)->flags.is(SAINode::flSelected)) + { + for (int k = 0; k<4; k++) + if ((*it)->n[k]&&(*it)->n[k]->flags.is(SAINode::flSelected)) + (*it)->n[k] = 0; } - UpdateHLSelected (); + UpdateHLSelected(); } -static const int opposite[4]={2,3,0,1}; -static const u8 fl[4] ={SAINode::flN1,SAINode::flN2,SAINode::flN3,SAINode::flN4}; +static const int opposite[4] = {2,3,0,1}; +static const u8 fl[4] = {SAINode::flN1,SAINode::flN2,SAINode::flN3,SAINode::flN4}; + void ESceneAIMapTool::InvertLinks() { - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++) - if ((*it)->flags.is(SAINode::flSelected)) - for (int k=0; k<4; k++) - if ((*it)->n[k]&&(*it)->n[k]->flags.is(SAINode::flSelected)&&!(*it)->flags.is(fl[k])){ - if (0==(*it)->n[k]->n[opposite[k]]){ - (*it)->n[k]->n[opposite[k]] = (*it); - (*it)->n[k]->flags.set(fl[opposite[k]],TRUE); - (*it)->n[k] = 0; + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + if ((*it)->flags.is(SAINode::flSelected)) + for (int k = 0; k<4; k++) + if ((*it)->n[k]&&(*it)->n[k]->flags.is(SAINode::flSelected)&&!(*it)->flags.is(fl[k])) + { + if (0==(*it)->n[k]->n[opposite[k]]) + { + (*it)->n[k]->n[opposite[k]] = (*it); + (*it)->n[k]->flags.set(fl[opposite[k]], TRUE); + (*it)->n[k] = 0; } } // reset processing flag - for (AINodeIt a_it=m_Nodes.begin(); a_it!=m_Nodes.end(); a_it++) - (*a_it)->flags.set(SAINode::flN1|SAINode::flN2|SAINode::flN3|SAINode::flN4,FALSE); - UpdateHLSelected (); + for (AINodeIt a_it = m_Nodes.begin(); a_it!=m_Nodes.end(); a_it++) + (*a_it)->flags.set(SAINode::flN1|SAINode::flN2|SAINode::flN3|SAINode::flN4, FALSE); + UpdateHLSelected(); } -SAINode* ESceneAIMapTool::FindNeighbor(SAINode* N, int side, bool bIgnoreConstraints) +SAINode *ESceneAIMapTool::FindNeighbor(SAINode *N, int side, bool bIgnoreConstraints) { - Fvector Pos; - Pos.set (N->Pos); - SnapXZ (Pos,m_Params.fPatchSize); - switch (side){ - case 0: Pos.x -= m_Params.fPatchSize; break; - case 1: Pos.z += m_Params.fPatchSize; break; - case 2: Pos.x += m_Params.fPatchSize; break; - case 3: Pos.z -= m_Params.fPatchSize; break; + Fvector Pos; + Pos.set(N->Pos); + SnapXZ(Pos, m_Params.fPatchSize); + switch (side) + { + case 0: Pos.x -= m_Params.fPatchSize; + break; + case 1: Pos.z += m_Params.fPatchSize; + break; + case 2: Pos.x += m_Params.fPatchSize; + break; + case 3: Pos.z -= m_Params.fPatchSize; + break; } - AINodeVec* nodes = HashMap(Pos); - SAINode* R = 0; + AINodeVec *nodes = HashMap(Pos); + SAINode *R = 0; if (nodes) - if (bIgnoreConstraints){ - float dy= flt_max; - for (AINodeIt I=nodes->begin(); I!=nodes->end(); I++) - if (fsimilar((*I)->Pos.x,Pos.x,EPS_L)&&fsimilar((*I)->Pos.z,Pos.z,EPS_L)){ + if (bIgnoreConstraints) + { + float dy = flt_max; + for (AINodeIt I = nodes->begin(); I!=nodes->end(); I++) + if (fsimilar((*I)->Pos.x, Pos.x, EPS_L)&&fsimilar((*I)->Pos.z, Pos.z, EPS_L)) + { float _dy = _abs((*I)->Pos.y-Pos.y); - if (_dybegin(); I!=nodes->end(); I++){ - if (fsimilar((*I)->Pos.x,Pos.x,EPS_L)&&fsimilar((*I)->Pos.z,Pos.z,EPS_L)){ + } + else + { + SAINode *R_up = 0; + SAINode *R_down = 0; + float dy_up = flt_max; + float dy_down = flt_max; + for (AINodeIt I = nodes->begin(); I!=nodes->end(); I++) + { + if (fsimilar((*I)->Pos.x, Pos.x, EPS_L)&&fsimilar((*I)->Pos.z, Pos.z, EPS_L)) + { float _dy = (*I)->Pos.y-Pos.y; - float _ady= _abs(_dy); - if (_dy>=0.f){ - if ((_ady=0.f) + { + if ((_adyflags.is(SAINode::flSelected)){ - for (int k=0; k<4; k++){ - if (!(side_flag&fl[k])) continue; - switch (mode){ - case mdAppend:{ - SAINode* S = FindNeighbor(T,k,bIgnoreConstraints); - if (S&&S->flags.is(SAINode::flSelected)) T->n[k] = S; - }break; - case mdRemove:{ - SAINode* S = FindNeighbor(T,k,bIgnoreConstraints); - if (S&&S->flags.is(SAINode::flSelected)) T->n[k] = 0; - }break; - case mdInvert:{ - SAINode* S = FindNeighbor(T,k,bIgnoreConstraints); - if (S){ - if (!T->flags.is(fl[k])){ - if (T->n[k]&&S->n[opposite[k]]) continue; - SAINode* a = T->n[k]; - T->n[k] = S->n[opposite[k]]; - S->n[opposite[k]] = a; + if (!side_flag) + return; + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + { + SAINode *T = *it; + if ((*it)->flags.is(SAINode::flSelected)) + { + for (int k = 0; k<4; k++) + { + if (!(side_flag&fl[k])) + continue; + switch (mode) + { + case mdAppend: + { + SAINode *S = FindNeighbor(T, k, bIgnoreConstraints); + if (S&&S->flags.is(SAINode::flSelected)) + T->n[k] = S; + } + break; + case mdRemove: + { + SAINode *S = FindNeighbor(T, k, bIgnoreConstraints); + if (S&&S->flags.is(SAINode::flSelected)) + T->n[k] = 0; + } + break; + case mdInvert: + { + SAINode *S = FindNeighbor(T, k, bIgnoreConstraints); + if (S) + { + if (!T->flags.is(fl[k])) + { + if (T->n[k]&&S->n[opposite[k]]) + continue; + SAINode *a = T->n[k]; + T->n[k] = S->n[opposite[k]]; + S->n[opposite[k]] = a; + } + S->flags.set(fl[opposite[k]], TRUE); } - S->flags.set(fl[opposite[k]],TRUE); } - }break; + break; } } } } // reset processing flag - for (AINodeIt a_it=m_Nodes.begin(); a_it!=m_Nodes.end(); a_it++) - (*a_it)->flags.set(SAINode::flN1|SAINode::flN2|SAINode::flN3|SAINode::flN4,FALSE); - UpdateHLSelected (); + for (AINodeIt a_it = m_Nodes.begin(); a_it!=m_Nodes.end(); a_it++) + (*a_it)->flags.set(SAINode::flN1|SAINode::flN2|SAINode::flN3|SAINode::flN4, FALSE); + UpdateHLSelected(); } void ESceneAIMapTool::ResetNodes() { - SPBItem* pb = UI->ProgressStart(m_Nodes.size(), "Smoothing nodes..."); - - int n_cnt = 0; - - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++){ - SAINode& N = **it; - if (N.flags.is(SAINode::flSelected)){ - n_cnt++; - N.Plane.build(N.Pos,Fvector().set(0,1,0)); + SPBItem *pb = UI->ProgressStart(m_Nodes.size(), "Smoothing nodes..."); + + int n_cnt = 0; + + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + { + SAINode &N = **it; + if (N.flags.is(SAINode::flSelected)) + { + n_cnt++; + N.Plane.build(N.Pos, Fvector().set(0, 1, 0)); } } UI->ProgressEnd(pb); - if (n_cnt) Scene->UndoSave(); + if (n_cnt) + Scene->UndoSave(); } #define merge(pt) if (fsimilar(P.y,REF.y,m_SmoothHeight)) { c++; pt.add(P); } + void ESceneAIMapTool::SmoothNodes() { - SPBItem* pb = UI->ProgressStart(m_Nodes.size(), "Smoothing nodes..."); - - AINodeVec smoothed; smoothed.reserve(m_Nodes.size()); - U8Vec mark; mark.assign (m_Nodes.size(),0); - - int sm_nodes=0; - - EnumerateNodes (); - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++){ - SAINode& N = **it; - Fvector P1,P2,P3,P4,P,REF; - int c; - - if (N.flags.is(SAINode::flSelected)){ - sm_nodes++; - + SPBItem *pb = UI->ProgressStart(m_Nodes.size(), "Smoothing nodes..."); + + AINodeVec smoothed; + smoothed.reserve(m_Nodes.size()); + U8Vec mark; + mark.assign(m_Nodes.size(), 0); + + int sm_nodes = 0; + + EnumerateNodes(); + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + { + SAINode &N = **it; + Fvector P1, P2, P3, P4, P, REF; + int c; + + if (N.flags.is(SAINode::flSelected)) + { + sm_nodes++; + // smooth point LF { - bool bCorner = false; + bool bCorner = false; - c=1; N.PointLF(REF,m_Params.fPatchSize); P1.set(REF); - if (N.nLeft()) { - SAINode& L = *N.nLeft(); + c = 1; + N.PointLF(REF, m_Params.fPatchSize); + P1.set(REF); + if (N.nLeft()) + { + SAINode &L = *N.nLeft(); - L.PointFR(P,m_Params.fPatchSize); merge(P1); - if (L.nForward()) { + L.PointFR(P, m_Params.fPatchSize); + merge(P1); + if (L.nForward()) + { bCorner = true; - SAINode& C = *L.nForward(); + SAINode &C = *L.nForward(); - C.PointRB(P,m_Params.fPatchSize); merge(P1); + C.PointRB(P, m_Params.fPatchSize); + merge(P1); } } - if (N.nForward()) { - SAINode& F = *N.nForward(); + if (N.nForward()) + { + SAINode &F = *N.nForward(); - F.PointBL(P,m_Params.fPatchSize); merge(P1); - if ((!bCorner) && F.nLeft()) { + F.PointBL(P, m_Params.fPatchSize); + merge(P1); + if ((!bCorner)&&F.nLeft()) + { bCorner = true; - SAINode& C = *F.nLeft(); - C.PointRB(P,m_Params.fPatchSize); merge(P1); + SAINode &C = *F.nLeft(); + C.PointRB(P, m_Params.fPatchSize); + merge(P1); } } R_ASSERT(c<=4); @@ -915,29 +1114,39 @@ void ESceneAIMapTool::SmoothNodes() // smooth point FR { - bool bCorner = false; + bool bCorner = false; - c=1; N.PointFR(REF,m_Params.fPatchSize); P2.set(REF); - if (N.nForward()) { - SAINode& F = *N.nForward(); + c = 1; + N.PointFR(REF, m_Params.fPatchSize); + P2.set(REF); + if (N.nForward()) + { + SAINode &F = *N.nForward(); - F.PointRB(P,m_Params.fPatchSize); merge(P2); - if (F.nRight()) { + F.PointRB(P, m_Params.fPatchSize); + merge(P2); + if (F.nRight()) + { bCorner = true; - SAINode& C = *F.nRight(); + SAINode &C = *F.nRight(); - C.PointBL(P,m_Params.fPatchSize); merge(P2); + C.PointBL(P, m_Params.fPatchSize); + merge(P2); } } - if (N.nRight()) { - SAINode& R = *N.nRight(); + if (N.nRight()) + { + SAINode &R = *N.nRight(); - R.PointLF(P,m_Params.fPatchSize); merge(P2); - if ((!bCorner) && R.nForward()) { + R.PointLF(P, m_Params.fPatchSize); + merge(P2); + if ((!bCorner)&&R.nForward()) + { bCorner = true; - SAINode& C = *R.nForward(); - C.PointBL(P,m_Params.fPatchSize); merge(P2); + SAINode &C = *R.nForward(); + C.PointBL(P, m_Params.fPatchSize); + merge(P2); } } R_ASSERT(c<=4); @@ -946,29 +1155,39 @@ void ESceneAIMapTool::SmoothNodes() // smooth point RB { - bool bCorner = false; + bool bCorner = false; - c=1; N.PointRB(REF,m_Params.fPatchSize); P3.set(REF); - if (N.nRight()) { - SAINode& R = *N.nRight(); + c = 1; + N.PointRB(REF, m_Params.fPatchSize); + P3.set(REF); + if (N.nRight()) + { + SAINode &R = *N.nRight(); - R.PointBL(P,m_Params.fPatchSize); merge(P3); - if (R.nBack()) { + R.PointBL(P, m_Params.fPatchSize); + merge(P3); + if (R.nBack()) + { bCorner = true; - SAINode& C = *R.nBack(); + SAINode &C = *R.nBack(); - C.PointLF(P,m_Params.fPatchSize); merge(P3); + C.PointLF(P, m_Params.fPatchSize); + merge(P3); } } - if (N.nBack()) { - SAINode& B = *N.nBack(); + if (N.nBack()) + { + SAINode &B = *N.nBack(); - B.PointFR(P,m_Params.fPatchSize); merge(P3); - if ((!bCorner) && B.nRight()) { + B.PointFR(P, m_Params.fPatchSize); + merge(P3); + if ((!bCorner)&&B.nRight()) + { bCorner = true; - SAINode& C = *B.nRight(); - C.PointLF(P,m_Params.fPatchSize); merge(P3); + SAINode &C = *B.nRight(); + C.PointLF(P, m_Params.fPatchSize); + merge(P3); } } R_ASSERT(c<=4); @@ -977,29 +1196,39 @@ void ESceneAIMapTool::SmoothNodes() // smooth point BL { - bool bCorner = false; + bool bCorner = false; - c=1; N.PointBL(REF,m_Params.fPatchSize); P4.set(REF); - if (N.nBack()) { - SAINode& B = *N.nBack(); + c = 1; + N.PointBL(REF, m_Params.fPatchSize); + P4.set(REF); + if (N.nBack()) + { + SAINode &B = *N.nBack(); - B.PointLF(P,m_Params.fPatchSize); merge(P4); - if (B.nLeft()) { + B.PointLF(P, m_Params.fPatchSize); + merge(P4); + if (B.nLeft()) + { bCorner = true; - SAINode& C = *B.nLeft(); + SAINode &C = *B.nLeft(); - C.PointFR(P,m_Params.fPatchSize); merge(P4); + C.PointFR(P, m_Params.fPatchSize); + merge(P4); } } - if (N.nLeft()) { - SAINode& L = *N.nLeft(); + if (N.nLeft()) + { + SAINode &L = *N.nLeft(); - L.PointRB(P,m_Params.fPatchSize); merge(P4); - if ((!bCorner) && L.nBack()) { + L.PointRB(P, m_Params.fPatchSize); + merge(P4); + if ((!bCorner)&&L.nBack()) + { bCorner = true; - SAINode& C = *L.nBack(); - C.PointFR(P,m_Params.fPatchSize); merge(P4); + SAINode &C = *L.nBack(); + C.PointFR(P, m_Params.fPatchSize); + merge(P4); } } R_ASSERT(c<=4); @@ -1007,50 +1236,60 @@ void ESceneAIMapTool::SmoothNodes() } // align plane - Fvector data[4]; data[0]=P1; data[1]=P2; data[2]=P3; data[3]=P4; - Fvector vOffs,vNorm,D; + Fvector data[4]; + data[0] = P1; + data[1] = P2; + data[2] = P3; + data[3] = P4; + Fvector vOffs, vNorm, D; vNorm.set(N.Plane.n); vOffs.set(N.Pos); Mgc::OrthogonalPlaneFit( - 4,(Mgc::Vector3*)data, + 4, (Mgc::Vector3*)data, *((Mgc::Vector3*)&vOffs), *((Mgc::Vector3*)&vNorm) ); - if (vNorm.y<0) vNorm.invert(); + if (vNorm.y<0) + vNorm.invert(); // create _new node - SAINode* NEW = xr_new(N); - NEW->n1 = (SAINode*)(N.n1?N.n1->idx:InvalidNode); - NEW->n2 = (SAINode*)(N.n2?N.n2->idx:InvalidNode); - NEW->n3 = (SAINode*)(N.n3?N.n3->idx:InvalidNode); - NEW->n4 = (SAINode*)(N.n4?N.n4->idx:InvalidNode); - NEW->Plane.build(vOffs,vNorm); - D.set (0,1,0); - N.Plane.intersectRayPoint(N.Pos,D,NEW->Pos); // "project" position - smoothed.push_back (NEW); - }else{ + SAINode *NEW = xr_new(N); + NEW->n1 = (SAINode*)(N.n1 ? N.n1->idx : InvalidNode); + NEW->n2 = (SAINode*)(N.n2 ? N.n2->idx : InvalidNode); + NEW->n3 = (SAINode*)(N.n3 ? N.n3->idx : InvalidNode); + NEW->n4 = (SAINode*)(N.n4 ? N.n4->idx : InvalidNode); + NEW->Plane.build(vOffs, vNorm); + D.set(0, 1, 0); + N.Plane.intersectRayPoint(N.Pos, D, NEW->Pos); // "project" position + smoothed.push_back(NEW); + } + else + { // create _new node - SAINode* NEW = xr_new(N); - NEW->n1 = (SAINode*)(N.n1?N.n1->idx:InvalidNode); - NEW->n2 = (SAINode*)(N.n2?N.n2->idx:InvalidNode); - NEW->n3 = (SAINode*)(N.n3?N.n3->idx:InvalidNode); - NEW->n4 = (SAINode*)(N.n4?N.n4->idx:InvalidNode); - smoothed.push_back (NEW); + SAINode *NEW = xr_new(N); + NEW->n1 = (SAINode*)(N.n1 ? N.n1->idx : InvalidNode); + NEW->n2 = (SAINode*)(N.n2 ? N.n2->idx : InvalidNode); + NEW->n3 = (SAINode*)(N.n3 ? N.n3->idx : InvalidNode); + NEW->n4 = (SAINode*)(N.n4 ? N.n4->idx : InvalidNode); + smoothed.push_back(NEW); } int k = it-m_Nodes.begin(); - if (k%128==0) { + if (k%128==0) + { pb->Update(k); - if (UI->NeedAbort()) break; + if (UI->NeedAbort()) + break; } } UI->ProgressEnd(pb); - Clear (true); - m_Nodes = smoothed; - DenumerateNodes (); - hash_FillFromNodes (); - - UpdateHLSelected (); - - if (sm_nodes) Scene->UndoSave(); + Clear(true); + m_Nodes = smoothed; + DenumerateNodes(); + hash_FillFromNodes(); + + UpdateHLSelected(); + + if (sm_nodes) + Scene->UndoSave(); } diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapTools_MotionSimulator.cpp b/src/editors/LevelEditor/Edit/ESceneAIMapTools_MotionSimulator.cpp index e8140ac894f..bddb389cc2f 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapTools_MotionSimulator.cpp +++ b/src/editors/LevelEditor/Edit/ESceneAIMapTools_MotionSimulator.cpp @@ -4,43 +4,48 @@ #include "cl_intersect.h" #include "scene.h" #include "ESceneAIMapTools.h" -#include "../ECore/Editor/editobject.h" -#include "../ECore/Editor/editmesh.h" +#include "editors/ECore/Editor/editobject.h" +#include "editors/ECore/Editor/editmesh.h" #include "ETools.h" -struct cl_tri +struct cl_tri { - Fvector e10; float e10s; - Fvector e21; float e21s; - Fvector e02; float e02s; - Fvector p[3]; - Fvector N; - float d; + Fvector e10; + float e10s; + Fvector e21; + float e21s; + Fvector e02; + float e02s; + Fvector p[3]; + Fvector N; + float d; }; + struct SCollisionData { - // data about player movement - Fvector vVelocity; - Fvector vSourcePoint; - - // for error handling - Fvector vLastSafePosition; - BOOL bStuck; - - // data for collision response - bool bFoundCollision; - float fNearestDistance; // nearest distance to hit - Fvector vNearestIntersectionPoint; // on sphere - Fvector vNearestPolygonIntersectionPoint; // on polygon - - Fvector vRadius; + // data about player movement + Fvector vVelocity; + Fvector vSourcePoint; + + // for error handling + Fvector vLastSafePosition; + BOOL bStuck; + + // data for collision response + bool bFoundCollision; + float fNearestDistance; // nearest distance to hit + Fvector vNearestIntersectionPoint; // on sphere + Fvector vNearestPolygonIntersectionPoint; // on polygon + + Fvector vRadius; }; -DEF_VECTOR(vecTris,cl_tri); -static int psCollideActDepth = 8; -static int psCollideActStuckDepth = 16; -static float cl_epsilon = EPS_L; -static vecTris clContactedT; +DEF_VECTOR(vecTris, cl_tri); + +static int psCollideActDepth = 8; +static int psCollideActStuckDepth = 16; +static float cl_epsilon = EPS_L; +static vecTris clContactedT; // ---------------------------------------------------------------------- // Name : classifyPoint() @@ -50,12 +55,15 @@ static vecTris clContactedT; // Notes : // Return: One of 3 classification codes // ----------------------------------------------------------------------- -IC float classifyPoint(const Fvector& point, const Fvector& planeO, const Fvector& planeN) +IC + +float classifyPoint(const Fvector &point, const Fvector &planeO, const Fvector &planeN) { - Fvector dir; - dir.sub (point,planeO); - return dir.dotproduct(planeN); + Fvector dir; + dir.sub(point, planeO); + return dir.dotproduct(planeN); } + // ---------------------------------------------------------------------- // Name : intersectRayPlane() // Input : rOrigin - origin of ray in world space @@ -65,17 +73,20 @@ IC float classifyPoint(const Fvector& point, const Fvector& planeO, const Fvecto // Notes : Normalized directional vectors expected // Return: distance to plane in world units, -1 if no intersection. // ----------------------------------------------------------------------- -IC float intersectRayPlane( const Fvector& rayOrigin, const Fvector& rayDirection, - const Fvector& planeOrigin, const Fvector& planeNormal) +IC + +float intersectRayPlane(const Fvector &rayOrigin, const Fvector &rayDirection, + const Fvector &planeOrigin, const Fvector &planeNormal) { - float numer = classifyPoint(rayOrigin,planeOrigin,planeNormal); - float denom = planeNormal.dotproduct(rayDirection); - - if (denom == 0) // normal is orthogonal to vector, cant intersect - return (-1.0f); - - return -(numer / denom); + float numer = classifyPoint(rayOrigin, planeOrigin, planeNormal); + float denom = planeNormal.dotproduct(rayDirection); + + if (denom==0) // normal is orthogonal to vector, cant intersect + return (-1.0f); + + return -(numer/denom); } + // ---------------------------------------------------------------------- // Name : closestPointOnLine() // Input : a - first end of line segment @@ -85,41 +96,64 @@ IC float intersectRayPlane( const Fvector& rayOrigin, const Fvector& rayDirectio // Return: closest point on line segment // ----------------------------------------------------------------------- -IC void closestPointOnLine(Fvector& res, const Fvector& a, const Fvector& b, const Fvector& p) +IC + +void closestPointOnLine(Fvector &res, const Fvector &a, const Fvector &b, const Fvector &p) { - - // Determine t (the length of the vector from ‘a’ to ‘p’) - Fvector c; c.sub(p,a); - Fvector V; V.sub(b,a); - - float d = V.magnitude(); - - V.div(d); - float t = V.dotproduct(c); - - // Check to see if ‘t’ is beyond the extents of the line segment - if (t <= 0.0f) { res.set(a); return; } - if (t >= d) { res.set(b); return; } - - // Return the point between ‘a’ and ‘b’ - // set length of V to t. V is normalized so this is easy - res.mad (a,V,t); + // Determine t (the length of the vector from ‘a’ to ‘p’) + Fvector c; + c.sub(p, a); + Fvector V; + V.sub(b, a); + + float d = V.magnitude(); + + V.div(d); + float t = V.dotproduct(c); + + // Check to see if ‘t’ is beyond the extents of the line segment + if (t<=0.0f) + { + res.set(a); + return; + } + if (t>=d) + { + res.set(b); + return; + } + + // Return the point between ‘a’ and ‘b’ + // set length of V to t. V is normalized so this is easy + res.mad(a, V, t); } -IC void closestPointOnEdge(Fvector& res, // result - const Fvector& a, const Fvector& b, // points - const Fvector& ED, float elen, // edge direction (b-a) and length - const Fvector& P) // query point + +IC + +void closestPointOnEdge(Fvector &res, // result + const Fvector &a, const Fvector &b, // points + const Fvector &ED, float elen, // edge direction (b-a) and length + const Fvector &P) // query point { - // Determine t (the length of the vector from ‘a’ to ‘p’) - Fvector c; c.sub(P,a); - float t = ED.dotproduct(c); - - // Check to see if ‘t’ is beyond the extents of the line segment - if (t <= 0.0f) { res.set(a); return; } - if (t >= elen) { res.set(b); return; } - - // Return the point between ‘a’ and ‘b’ - res.mad(a,ED,t); + // Determine t (the length of the vector from ‘a’ to ‘p’) + Fvector c; + c.sub(P, a); + float t = ED.dotproduct(c); + + // Check to see if ‘t’ is beyond the extents of the line segment + if (t<=0.0f) + { + res.set(a); + return; + } + if (t>=elen) + { + res.set(b); + return; + } + + // Return the point between ‘a’ and ‘b’ + res.mad(a, ED, t); } // ---------------------------------------------------------------------- @@ -128,29 +162,58 @@ IC void closestPointOnEdge(Fvector& res, // result // Return: closest point on line triangle edge // ----------------------------------------------------------------------- -IC void closestPointOnTriangle(Fvector& result, const Fvector* V, const Fvector& p) { - Fvector Rab; closestPointOnLine(Rab, V[0], V[1], p); float dAB = p.distance_to_sqr(Rab); - Fvector Rbc; closestPointOnLine(Rbc, V[1], V[2], p); float dBC = p.distance_to_sqr(Rbc); - Fvector Rca; closestPointOnLine(Rca, V[2], V[0], p); float dCA = p.distance_to_sqr(Rca); - - float min = dAB; - result.set(Rab); - if (dBC < min) { - min = dBC; - result.set(Rbc); +IC + +void closestPointOnTriangle(Fvector &result, const Fvector *V, const Fvector &p) +{ + Fvector Rab; + closestPointOnLine(Rab, V[0], V[1], p); + float dAB = p.distance_to_sqr(Rab); + Fvector Rbc; + closestPointOnLine(Rbc, V[1], V[2], p); + float dBC = p.distance_to_sqr(Rbc); + Fvector Rca; + closestPointOnLine(Rca, V[2], V[0], p); + float dCA = p.distance_to_sqr(Rca); + + float min = dAB; + result.set(Rab); + if (dBC= 0){ - // calculate true sphere intersection point - sIPoint.mad(polyIPoint, normalizedVelocity, -distToEllipsoidIntersection); - } - } - - // Here we do the error checking to see if we got ourself stuck last frame - if (CheckPointInSphere(polyIPoint, source, 1.0f)) - { - cl.bStuck = TRUE; - } - - // Ok, now we might update the collision data if we hit something - if ((distToEllipsoidIntersection >= 0) && (distToEllipsoidIntersection <= distanceToTravel)) - { - if ((cl.bFoundCollision == FALSE) || (distToEllipsoidIntersection < cl.fNearestDistance)) - { - // if we are hit we have a closest hit so far. We save the information - cl.fNearestDistance = distToEllipsoidIntersection; - cl.vNearestIntersectionPoint.set(sIPoint); - cl.vNearestPolygonIntersectionPoint.set(polyIPoint); - cl.bFoundCollision = TRUE; - } - } - } // if not backface - } // for all faces + // from package + Fvector source; + Fvector velocity; + source.set(cl.vSourcePoint); + velocity.set(cl.vVelocity); + + // keep a copy of this as it's needed a few times + Fvector normalizedVelocity; + normalizedVelocity.normalize_safe(cl.vVelocity); + + // intersection data + Fvector sIPoint; // sphere intersection point + Fvector pIPoint; // plane intersection point + Fvector polyIPoint; // polygon intersection point + + // how long is our velocity + float distanceToTravel = velocity.magnitude(); + + float distToPlaneIntersection; + float distToEllipsoidIntersection; + + for (DWORD i_t = 0; i_t!=clContactedT.size(); i_t++) + { + cl_tri &T = clContactedT[i_t]; + + //ignore backfaces. What we cannot see we cannot collide with ;) + if (T.N.dotproduct(normalizedVelocity)<0.0f) + { + // calculate sphere intersection point (in future :) + // OLES: 'cause our radius has unit length, this point lies exactly on sphere + sIPoint.sub(source, T.N); + + // find the plane intersection point + // classify point to determine if ellipsoid span the plane + BOOL bInsideTri; + if ((sIPoint.dotproduct(T.N)+T.d)<-EPS_S) + { + // plane is embedded in ellipsoid / sphere + // find plane intersection point by shooting a ray from the + // sphere intersection point along the planes normal. + bInsideTri = ETOOLS::TestRayTri2(sIPoint, T.N, T.p, distToPlaneIntersection); + + // calculate plane intersection point + pIPoint.mad(sIPoint, T.N, distToPlaneIntersection); + } + else + { + // shoot ray along the velocity vector + bInsideTri = ETOOLS::TestRayTri2(sIPoint, normalizedVelocity, T.p, distToPlaneIntersection); + + // calculate plane intersection point + pIPoint.mad(sIPoint, normalizedVelocity, distToPlaneIntersection); + } + + + // find polygon intersection point. By default we assume its equal to the + // plane intersection point + + polyIPoint.set(pIPoint); + distToEllipsoidIntersection = distToPlaneIntersection; + + if (!bInsideTri) + { + // if not in triangle + closestPointOnTriangle(polyIPoint, T, pIPoint); + + Fvector _normalizedVelocity; + _normalizedVelocity.invert(normalizedVelocity); + distToEllipsoidIntersection = intersectRaySphere(polyIPoint, _normalizedVelocity, source, 1.0f); + + if (distToEllipsoidIntersection>=0) + { + // calculate true sphere intersection point + sIPoint.mad(polyIPoint, normalizedVelocity, -distToEllipsoidIntersection); + } + } + + // Here we do the error checking to see if we got ourself stuck last frame + if (CheckPointInSphere(polyIPoint, source, 1.0f)) + { + cl.bStuck = TRUE; + } + + // Ok, now we might update the collision data if we hit something + if ((distToEllipsoidIntersection>=0)&&(distToEllipsoidIntersection<=distanceToTravel)) + { + if ((cl.bFoundCollision==FALSE)||(distToEllipsoidIntersectionpsCollideActDepth) return cl.vLastSafePosition; - - Fvector ret_pos; - Fvector destinationPoint; - destinationPoint.add(position,velocity); - - // reset the collision package we send to the mesh - cl.vVelocity.set (velocity); - cl.vSourcePoint.set (position); - cl.bFoundCollision = FALSE; - cl.bStuck = FALSE; - cl.fNearestDistance = -1; - - // Check collision - msimulator_CheckCollision (cl); - - // check return value here, and possibly call recursively - if (cl.bFoundCollision == FALSE && !cl.bStuck) - { - // if no collision move very close to the desired destination. - float l = velocity.magnitude(); - Fvector V; - V.mul(velocity,(l-cl_epsilon)/l); - - // return the final position - ret_pos.add(position,V); - - // update the last safe position for future error recovery - cl.vLastSafePosition.set(ret_pos); - return ret_pos; - }else{ - // There was a collision - // OK, first task is to move close to where we hit something : - Fvector newSourcePoint; - - // If we are stuck, we just back up to last safe position - if (cl.bStuck){ - return cl.vLastSafePosition; - } - - // only update if we are not already very close - if (cl.fNearestDistance >= cl_epsilon) { - Fvector V; - V.set(velocity); - V.set_length(cl.fNearestDistance-cl_epsilon); - newSourcePoint.add(cl.vSourcePoint,V); - }else { - newSourcePoint.set(cl.vSourcePoint); - } - - // Now we must calculate the sliding plane - Fvector slidePlaneOrigin; slidePlaneOrigin.set(cl.vNearestPolygonIntersectionPoint); - Fvector slidePlaneNormal; slidePlaneNormal.sub(newSourcePoint,cl.vNearestPolygonIntersectionPoint); - - // We now project the destination point onto the sliding plane - float l = intersectRayPlane(destinationPoint, slidePlaneNormal, slidePlaneOrigin, slidePlaneNormal); - - // We can now calculate a _new destination point on the sliding plane - Fvector newDestinationPoint; - newDestinationPoint.mad(destinationPoint,slidePlaneNormal,l); - - // Generate the slide vector, which will become our _new velocity vector - // for the next iteration - Fvector newVelocityVector; - newVelocityVector.sub(newDestinationPoint, cl.vNearestPolygonIntersectionPoint); - - // now we recursively call the function with the _new position and velocity - cl.vLastSafePosition.set(position); - return msimulator_CollideWithWorld(cl, newSourcePoint, newVelocityVector,u16(cnt+1)); - } + // + msimulator_ResolveStuck(cl, position); + + // do we need to worry ? + // if (fsimilar(position.x,target.x,EPS_L)&&fsimilar(position.z,target.z,EPS_L)) + if (velocity.magnitude()psCollideActDepth) + return cl.vLastSafePosition; + + Fvector ret_pos; + Fvector destinationPoint; + destinationPoint.add(position, velocity); + + // reset the collision package we send to the mesh + cl.vVelocity.set(velocity); + cl.vSourcePoint.set(position); + cl.bFoundCollision = FALSE; + cl.bStuck = FALSE; + cl.fNearestDistance = -1; + + // Check collision + msimulator_CheckCollision(cl); + + // check return value here, and possibly call recursively + if (cl.bFoundCollision==FALSE&&!cl.bStuck) + { + // if no collision move very close to the desired destination. + float l = velocity.magnitude(); + Fvector V; + V.mul(velocity, (l-cl_epsilon)/l); + + // return the final position + ret_pos.add(position, V); + + // update the last safe position for future error recovery + cl.vLastSafePosition.set(ret_pos); + return ret_pos; + } + else + { + // There was a collision + // OK, first task is to move close to where we hit something : + Fvector newSourcePoint; + + // If we are stuck, we just back up to last safe position + if (cl.bStuck) + { + return cl.vLastSafePosition; + } + + // only update if we are not already very close + if (cl.fNearestDistance>=cl_epsilon) + { + Fvector V; + V.set(velocity); + V.set_length(cl.fNearestDistance-cl_epsilon); + newSourcePoint.add(cl.vSourcePoint, V); + } + else + { + newSourcePoint.set(cl.vSourcePoint); + } + + // Now we must calculate the sliding plane + Fvector slidePlaneOrigin; + slidePlaneOrigin.set(cl.vNearestPolygonIntersectionPoint); + Fvector slidePlaneNormal; + slidePlaneNormal.sub(newSourcePoint, cl.vNearestPolygonIntersectionPoint); + + // We now project the destination point onto the sliding plane + float l = intersectRayPlane(destinationPoint, slidePlaneNormal, slidePlaneOrigin, slidePlaneNormal); + + // We can now calculate a _new destination point on the sliding plane + Fvector newDestinationPoint; + newDestinationPoint.mad(destinationPoint, slidePlaneNormal, l); + + // Generate the slide vector, which will become our _new velocity vector + // for the next iteration + Fvector newVelocityVector; + newVelocityVector.sub(newDestinationPoint, cl.vNearestPolygonIntersectionPoint); + + // now we recursively call the function with the _new position and velocity + cl.vLastSafePosition.set(position); + return msimulator_CollideWithWorld(cl, newSourcePoint, newVelocityVector, u16(cnt+1)); + } } -IC void create_bb(Fbox& B, Fvector& P, float r, float h) +IC + +void create_bb(Fbox &B, Fvector &P, float r, float h) { - B.set(P.x-r, P.y, P.z-r, P.x+r, P.y+h, P.z+r); + B.set(P.x-r, P.y, P.z-r, P.x+r, P.y+h, P.z+r); } -void ESceneAIMapTool::MotionSimulate(Fvector& result, Fvector& start, Fvector& end, float _radius, float _height) + +void ESceneAIMapTool::MotionSimulate(Fvector &result, Fvector &start, Fvector &end, float _radius, float _height) { - SCollisionData cl_data; - float half_height = _height/2; - - // Calc BB - Fbox b1,b2,bb; - create_bb (b1,start, _radius,_height); - create_bb (b2,end, _radius,_height); - bb.merge (b1,b2); - bb.grow (0.05f); - - // Collision query - Fvector bbC,bbD; - bb.get_CD (bbC,bbD); + SCollisionData cl_data; + float half_height = _height/2; + + // Calc BB + Fbox b1, b2, bb; + create_bb(b1, start, _radius, _height); + create_bb(b2, end, _radius, _height); + bb.merge(b1, b2); + bb.grow(0.05f); + + // Collision query + Fvector bbC, bbD; + bb.get_CD(bbC, bbD); static SPickQuery PQ; - if (m_CFModel) Scene->BoxQuery(PQ,bb,CDB::OPT_FULL_TEST,m_CFModel); - else Scene->BoxQuery(PQ,bb,CDB::OPT_FULL_TEST,GetSnapList()); - - // XForm everything to ellipsoid space - Fvector xf; - xf.set (1/_radius,1/half_height,1/_radius); - - Fvector Lposition; - Lposition.set (start); - Lposition.y += half_height; - Lposition.mul (xf); - - Fvector target; - target.set (end); - target.y += half_height; - target.mul (xf); - - Fvector Lvelocity; - Lvelocity.sub (end,start); - Lvelocity.mul (xf); - - cl_data.vLastSafePosition.set (Lposition); - - // Get the data for the triangles in question and scale to ellipsoid space - int tri_count = PQ.r_count(); - clContactedT.clear (); -//. clContactedT.resize (tri_count); - - if (tri_count) { - Fvector vel_dir; - vel_dir.normalize_safe (Lvelocity); - for (int i_t=0; i_te_obj&&R->e_mesh){ - CSurface* surf = R->e_mesh->GetSurfaceByFaceID(R->tag); -//. SGameMtl* mtl = GMLib.GetMaterialByID(surf->_GameMtl()); -//. if (mtl->Flags.is(SGameMtl::flPassable))continue; - Shader_xrLC* c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); - if (!c_sh->flags.bCollision) continue; + if (m_CFModel) + Scene->BoxQuery(PQ, bb, CDB::OPT_FULL_TEST, m_CFModel); + else + Scene->BoxQuery(PQ, bb, CDB::OPT_FULL_TEST, GetSnapList()); + + // XForm everything to ellipsoid space + Fvector xf; + xf.set(1/_radius, 1/half_height, 1/_radius); + + Fvector Lposition; + Lposition.set(start); + Lposition.y += half_height; + Lposition.mul(xf); + + Fvector target; + target.set(end); + target.y += half_height; + target.mul(xf); + + Fvector Lvelocity; + Lvelocity.sub(end, start); + Lvelocity.mul(xf); + + cl_data.vLastSafePosition.set(Lposition); + + // Get the data for the triangles in question and scale to ellipsoid space + int tri_count = PQ.r_count(); + clContactedT.clear(); + //. clContactedT.resize (tri_count); + + if (tri_count) + { + Fvector vel_dir; + vel_dir.normalize_safe(Lvelocity); + for (int i_t = 0; i_te_obj&&R->e_mesh) + { + CSurface *surf = R->e_mesh->GetSurfaceByFaceID(R->tag); + //. SGameMtl* mtl = GMLib.GetMaterialByID(surf->_GameMtl()); + //. if (mtl->Flags.is(SGameMtl::flPassable))continue; + Shader_xrLC *c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); + if (!c_sh->flags.bCollision) + continue; } clContactedT.push_back(cl_tri()); - cl_tri& T = clContactedT.back(); - Fvector* V = R->verts; - - T.p[0].mul (V[0],xf); - T.p[1].mul (V[1],xf); - T.p[2].mul (V[2],xf); - T.N.mknormal (T.p[0],T.p[1],T.p[2]); - - T.d = -T.N.dotproduct(T.p[0]); - T.e10.sub(T.p[1],T.p[0]); T.e10s = T.e10.magnitude(); T.e10.div(T.e10s); - T.e21.sub(T.p[2],T.p[1]); T.e21s = T.e21.magnitude(); T.e21.div(T.e21s); - T.e02.sub(T.p[0],T.p[2]); T.e02s = T.e02.magnitude(); T.e02.div(T.e02s); - } - } - - // call the recursive collision response function - Fvector POS; - - for (int i=0; i<3; i++) { - POS.set(msimulator_CollideWithWorld(cl_data, Lposition, Lvelocity, 0)); - if (fsimilar(POS.x,target.x)&&fsimilar(POS.z,target.z)) break; - - Lposition.set (POS); - Lvelocity.sub (target,POS); - Lvelocity.y = 0; - } - - result.div(POS,xf); - result.y-=half_height; + cl_tri &T = clContactedT.back(); + Fvector *V = R->verts; + + T.p[0].mul(V[0], xf); + T.p[1].mul(V[1], xf); + T.p[2].mul(V[2], xf); + T.N.mknormal(T.p[0], T.p[1], T.p[2]); + + T.d = -T.N.dotproduct(T.p[0]); + T.e10.sub(T.p[1], T.p[0]); + T.e10s = T.e10.magnitude(); + T.e10.div(T.e10s); + T.e21.sub(T.p[2], T.p[1]); + T.e21s = T.e21.magnitude(); + T.e21.div(T.e21s); + T.e02.sub(T.p[0], T.p[2]); + T.e02s = T.e02.magnitude(); + T.e02.div(T.e02s); + } + } + + // call the recursive collision response function + Fvector POS; + + for (int i = 0; i<3; i++) + { + POS.set(msimulator_CollideWithWorld(cl_data, Lposition, Lvelocity, 0)); + if (fsimilar(POS.x, target.x)&&fsimilar(POS.z, target.z)) + break; + + Lposition.set(POS); + Lvelocity.sub(target, POS); + Lvelocity.y = 0; + } + + result.div(POS, xf); + result.y -= half_height; } + diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Pick.cpp b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Pick.cpp index 80537f108d0..a8261c47fb7 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Pick.cpp +++ b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Pick.cpp @@ -1,32 +1,41 @@ #include "stdafx.h" #pragma hdrstop -#include "ESceneAIMapTools.h" +#include "ESceneAIMapTools.h" #include "scene.h" -#include "../ECore/Editor/ui_main.h" -#include "ui_leveltools.h" -#include "ESceneAIMapControls.h" -#include "ui_levelmain.h" +#include "editors/ECore/Editor/ui_main.h" +#include "UI_LevelTools.h" +#include "ESceneAIMapControls.h" +#include "UI_LevelMain.h" -SAINode* ESceneAIMapTool::PickNode(const Fvector& start, const Fvector& dir, float& dist) +SAINode *ESceneAIMapTool::PickNode(const Fvector &start, const Fvector &dir, float &dist) { - SAINode* R = 0; + SAINode *R = 0; CFrustum frustum; - LUI->m_CurrentCp.add(1); // fake add min vaalue for calculate frustum - float psz = (m_Params.fPatchSize/2)*(m_Params.fPatchSize/2); - if (LUI->SelectionFrustum(frustum)){ - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++){ - SAINode& N = **it; - u32 mask = 0xffff; - Fbox bb; bb.set(N.Pos,N.Pos); bb.min.sub(m_Params.fPatchSize*0.35f); bb.max.add(m_Params.fPatchSize*0.35f); - if (frustum.testSAABB(N.Pos,m_Params.fPatchSize,bb.data(),mask)){ + LUI->m_CurrentCp.add(1); // fake add min vaalue for calculate frustum + float psz = (m_Params.fPatchSize/2)*(m_Params.fPatchSize/2); + if (LUI->SelectionFrustum(frustum)) + { + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + { + SAINode &N = **it; + u32 mask = 0xffff; + Fbox bb; + bb.set(N.Pos, N.Pos); + bb.min.sub(m_Params.fPatchSize*0.35f); + bb.max.add(m_Params.fPatchSize*0.35f); + if (frustum.testSAABB(N.Pos, m_Params.fPatchSize, bb.data(), mask)) + { Fvector dest; - if (N.Plane.intersectRayPoint(start,dir,dest)){ - if (N.Pos.distance_to_sqr(dest)empty()){ - if (Scene->RayQuery(PQ,start,dir,dist,CDB::OPT_ONLYNEAREST|CDB::OPT_CULL,GetSnapList())){ - dest.mad(start,dir,PQ.r_begin()->range); + +bool ESceneAIMapTool::PickObjects(Fvector &dest, const Fvector &start, const Fvector &dir, float dist) +{ + SPickQuery PQ; + if (!GetSnapList()->empty()) + { + if (Scene->RayQuery(PQ, start, dir, dist, CDB::OPT_ONLYNEAREST|CDB::OPT_CULL, GetSnapList())) + { + dest.mad(start, dir, PQ.r_begin()->range); return true; } - }else{ - ELog.DlgMsg(mtInformation,"Fill object list and try again."); + } + else + { + ELog.DlgMsg(mtInformation, "Fill object list and try again."); } return false; } - -int ESceneAIMapTool::RaySelect(int flag, float& distance, const Fvector& start, const Fvector& direction, BOOL bDistanceOnly) + +int ESceneAIMapTool::RaySelect(int flag, float &distance, const Fvector &start, const Fvector &direction, BOOL bDistanceOnly) { - int count=0; - if (!m_Flags.is(flHideNodes)){ - switch (LTools->GetSubTarget()){ - case estAIMapNode:{ - SAINode * N = PickNode(start, direction, distance); - if (N&&!bDistanceOnly){ - if (flag==-1) N->flags.invert(SAINode::flSelected); - N->flags.set (SAINode::flSelected,flag); - count++; + int count = 0; + if (!m_Flags.is(flHideNodes)) + { + switch (LTools->GetSubTarget()) + { + case estAIMapNode: + { + SAINode *N = PickNode(start, direction, distance); + if (N&&!bDistanceOnly) + { + if (flag==-1) + N->flags.invert(SAINode::flSelected); + N->flags.set(SAINode::flSelected, flag); + count++; + } } - }break; + break; } - UpdateHLSelected (); - UI->RedrawScene (); + UpdateHLSelected(); + UI->RedrawScene(); } return count; } -int ESceneAIMapTool::FrustumSelect(int flag, const CFrustum& frustum) +int ESceneAIMapTool::FrustumSelect(int flag, const CFrustum &frustum) { int count = 0; - if (!m_Flags.is(flHideNodes)){ - switch (LTools->GetSubTarget()){ - case estAIMapNode:{ - for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++){ - SAINode& N = **it; - u32 mask = 0xffff; - Fbox bb; bb.set(N.Pos,N.Pos); bb.min.sub(m_Params.fPatchSize*0.35f); bb.max.add(m_Params.fPatchSize*0.35f); - if (frustum.testSAABB(N.Pos,m_Params.fPatchSize,bb.data(),mask)){ - if (-1==flag) (*it)->flags.invert(SAINode::flSelected); - else (*it)->flags.set(SAINode::flSelected,flag); - count++; + if (!m_Flags.is(flHideNodes)) + { + switch (LTools->GetSubTarget()) + { + case estAIMapNode: + { + for (AINodeIt it = m_Nodes.begin(); it!=m_Nodes.end(); it++) + { + SAINode &N = **it; + u32 mask = 0xffff; + Fbox bb; + bb.set(N.Pos, N.Pos); + bb.min.sub(m_Params.fPatchSize*0.35f); + bb.max.add(m_Params.fPatchSize*0.35f); + if (frustum.testSAABB(N.Pos, m_Params.fPatchSize, bb.data(), mask)) + { + if (-1==flag) + (*it)->flags.invert(SAINode::flSelected); + else + (*it)->flags.set(SAINode::flSelected, flag); + count++; + } } } - }break; + break; } - - UpdateHLSelected (); - UI->RedrawScene (); - } + + UpdateHLSelected(); + UI->RedrawScene(); + } return count; } - diff --git a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Render.cpp b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Render.cpp index bbe5b031da0..00aec0f89a5 100644 --- a/src/editors/LevelEditor/Edit/ESceneAIMapTools_Render.cpp +++ b/src/editors/LevelEditor/Edit/ESceneAIMapTools_Render.cpp @@ -7,135 +7,180 @@ #include "ESceneAIMapTools.h" #include "../../ECORE/EDITOR/D3dUtils.h" #include "SceneObject.h" -#include "bottombar.h" -#include "ui_leveltools.h" +#include "BottomBar.h" +#include "UI_LevelTools.h" typedef Fvector2 t_node_tc[4]; static const float dtc = 0.25f; -static t_node_tc node_tc[16]= +static t_node_tc node_tc[16] = { - {{0.f+0*dtc,0.25f+0*dtc}, {0.25f+0*dtc,0.25f+0*dtc}, {0.25f+0*dtc,0.f+0*dtc}, {0.f+0*dtc,0.f+0*dtc}}, - {{0.f+1*dtc,0.25f+0*dtc}, {0.25f+1*dtc,0.25f+0*dtc}, {0.25f+1*dtc,0.f+0*dtc}, {0.f+1*dtc,0.f+0*dtc}}, - {{0.f+2*dtc,0.25f+0*dtc}, {0.25f+2*dtc,0.25f+0*dtc}, {0.25f+2*dtc,0.f+0*dtc}, {0.f+2*dtc,0.f+0*dtc}}, - {{0.f+3*dtc,0.25f+0*dtc}, {0.25f+3*dtc,0.25f+0*dtc}, {0.25f+3*dtc,0.f+0*dtc}, {0.f+3*dtc,0.f+0*dtc}}, - - {{0.f+0*dtc,0.25f+1*dtc}, {0.25f+0*dtc,0.25f+1*dtc}, {0.25f+0*dtc,0.f+1*dtc}, {0.f+0*dtc,0.f+1*dtc}}, - {{0.f+1*dtc,0.25f+1*dtc}, {0.25f+1*dtc,0.25f+1*dtc}, {0.25f+1*dtc,0.f+1*dtc}, {0.f+1*dtc,0.f+1*dtc}}, - {{0.f+2*dtc,0.25f+1*dtc}, {0.25f+2*dtc,0.25f+1*dtc}, {0.25f+2*dtc,0.f+1*dtc}, {0.f+2*dtc,0.f+1*dtc}}, - {{0.f+3*dtc,0.25f+1*dtc}, {0.25f+3*dtc,0.25f+1*dtc}, {0.25f+3*dtc,0.f+1*dtc}, {0.f+3*dtc,0.f+1*dtc}}, - - {{0.f+0*dtc,0.25f+2*dtc}, {0.25f+0*dtc,0.25f+2*dtc}, {0.25f+0*dtc,0.f+2*dtc}, {0.f+0*dtc,0.f+2*dtc}}, - {{0.f+1*dtc,0.25f+2*dtc}, {0.25f+1*dtc,0.25f+2*dtc}, {0.25f+1*dtc,0.f+2*dtc}, {0.f+1*dtc,0.f+2*dtc}}, - {{0.f+2*dtc,0.25f+2*dtc}, {0.25f+2*dtc,0.25f+2*dtc}, {0.25f+2*dtc,0.f+2*dtc}, {0.f+2*dtc,0.f+2*dtc}}, - {{0.f+3*dtc,0.25f+2*dtc}, {0.25f+3*dtc,0.25f+2*dtc}, {0.25f+3*dtc,0.f+2*dtc}, {0.f+3*dtc,0.f+2*dtc}}, - - {{0.f+0*dtc,0.25f+3*dtc}, {0.25f+0*dtc,0.25f+3*dtc}, {0.25f+0*dtc,0.f+3*dtc}, {0.f+0*dtc,0.f+3*dtc}}, - {{0.f+1*dtc,0.25f+3*dtc}, {0.25f+1*dtc,0.25f+3*dtc}, {0.25f+1*dtc,0.f+3*dtc}, {0.f+1*dtc,0.f+3*dtc}}, - {{0.f+2*dtc,0.25f+3*dtc}, {0.25f+2*dtc,0.25f+3*dtc}, {0.25f+2*dtc,0.f+3*dtc}, {0.f+2*dtc,0.f+3*dtc}}, - {{0.f+3*dtc,0.25f+3*dtc}, {0.25f+3*dtc,0.25f+3*dtc}, {0.25f+3*dtc,0.f+3*dtc}, {0.f+3*dtc,0.f+3*dtc}}, + {{0.f+0*dtc,0.25f+0*dtc},{0.25f+0*dtc,0.25f+0*dtc},{0.25f+0*dtc,0.f+0*dtc},{0.f+0*dtc,0.f+0*dtc}}, + {{0.f+1*dtc,0.25f+0*dtc},{0.25f+1*dtc,0.25f+0*dtc},{0.25f+1*dtc,0.f+0*dtc},{0.f+1*dtc,0.f+0*dtc}}, + {{0.f+2*dtc,0.25f+0*dtc},{0.25f+2*dtc,0.25f+0*dtc},{0.25f+2*dtc,0.f+0*dtc},{0.f+2*dtc,0.f+0*dtc}}, + {{0.f+3*dtc,0.25f+0*dtc},{0.25f+3*dtc,0.25f+0*dtc},{0.25f+3*dtc,0.f+0*dtc},{0.f+3*dtc,0.f+0*dtc}}, + + {{0.f+0*dtc,0.25f+1*dtc},{0.25f+0*dtc,0.25f+1*dtc},{0.25f+0*dtc,0.f+1*dtc},{0.f+0*dtc,0.f+1*dtc}}, + {{0.f+1*dtc,0.25f+1*dtc},{0.25f+1*dtc,0.25f+1*dtc},{0.25f+1*dtc,0.f+1*dtc},{0.f+1*dtc,0.f+1*dtc}}, + {{0.f+2*dtc,0.25f+1*dtc},{0.25f+2*dtc,0.25f+1*dtc},{0.25f+2*dtc,0.f+1*dtc},{0.f+2*dtc,0.f+1*dtc}}, + {{0.f+3*dtc,0.25f+1*dtc},{0.25f+3*dtc,0.25f+1*dtc},{0.25f+3*dtc,0.f+1*dtc},{0.f+3*dtc,0.f+1*dtc}}, + + {{0.f+0*dtc,0.25f+2*dtc},{0.25f+0*dtc,0.25f+2*dtc},{0.25f+0*dtc,0.f+2*dtc},{0.f+0*dtc,0.f+2*dtc}}, + {{0.f+1*dtc,0.25f+2*dtc},{0.25f+1*dtc,0.25f+2*dtc},{0.25f+1*dtc,0.f+2*dtc},{0.f+1*dtc,0.f+2*dtc}}, + {{0.f+2*dtc,0.25f+2*dtc},{0.25f+2*dtc,0.25f+2*dtc},{0.25f+2*dtc,0.f+2*dtc},{0.f+2*dtc,0.f+2*dtc}}, + {{0.f+3*dtc,0.25f+2*dtc},{0.25f+3*dtc,0.25f+2*dtc},{0.25f+3*dtc,0.f+2*dtc},{0.f+3*dtc,0.f+2*dtc}}, + + {{0.f+0*dtc,0.25f+3*dtc},{0.25f+0*dtc,0.25f+3*dtc},{0.25f+0*dtc,0.f+3*dtc},{0.f+0*dtc,0.f+3*dtc}}, + {{0.f+1*dtc,0.25f+3*dtc},{0.25f+1*dtc,0.25f+3*dtc},{0.25f+1*dtc,0.f+3*dtc},{0.f+1*dtc,0.f+3*dtc}}, + {{0.f+2*dtc,0.25f+3*dtc},{0.25f+2*dtc,0.25f+3*dtc},{0.25f+2*dtc,0.f+3*dtc},{0.f+2*dtc,0.f+3*dtc}}, + {{0.f+3*dtc,0.25f+3*dtc},{0.25f+3*dtc,0.25f+3*dtc},{0.25f+3*dtc,0.f+3*dtc},{0.f+3*dtc,0.f+3*dtc}}, }; void ESceneAIMapTool::OnDeviceCreate() { - m_Shader.create("editor\\ai_node","ed\\ed_ai_arrows_01"); - m_RGeom.create(FVF::F_LIT,RCache.Vertex.Buffer(),RCache.Index.Buffer()); + m_Shader.create("editor\\ai_node", "ed\\ed_ai_arrows_01"); + m_RGeom.create(FVF::F_LIT, RCache.Vertex.Buffer(), RCache.Index.Buffer()); } void ESceneAIMapTool::OnDeviceDestroy() { - m_Shader.destroy(); + m_Shader.destroy(); m_RGeom.destroy(); } BOOL ai_map_shown = TRUE; static const u32 block_size = 0x2000; + void ESceneAIMapTool::OnRender(int priority, bool strictB2F) { - if (m_Flags.is(flHideNodes) || !ai_map_shown) return; - if (1==priority){ - if (false==strictB2F){ + if (m_Flags.is(flHideNodes)||!ai_map_shown) + return; + if (1==priority) + { + if (false==strictB2F) + { RCache.set_xform_world(Fidentity); - if (OBJCLASS_AIMAP==LTools->CurrentClassID()){ - u32 clr = 0xffffc000; - EDevice.SetShader (EDevice.m_WireShader); - DU_impl.DrawSelectionBoxB (m_AIBBox,&clr); + if (OBJCLASS_AIMAP==LTools->CurrentClassID()) + { + u32 clr = 0xffffc000; + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawSelectionBoxB(m_AIBBox, &clr); } - if (Valid()){ + if (Valid()) + { // render nodes - EDevice.SetShader (m_Shader); - EDevice.SetRS (D3DRS_CULLMODE, D3DCULL_NONE); + EDevice.SetShader(m_Shader); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_NONE); Irect rect; - HashRect (EDevice.m_Camera.GetPosition(),m_VisRadius,rect); + HashRect(EDevice.m_Camera.GetPosition(), m_VisRadius, rect); u32 vBase; - _VertexStream* Stream= &RCache.Vertex; - FVF::LIT* pv = (FVF::LIT*)Stream->Lock(block_size,m_RGeom->vb_stride,vBase); - u32 cnt = 0; -// EDevice.Statistic.TEST0.Begin(); -// EDevice.Statistic.TEST2.Begin(); - for (int x=rect.x1; x<=rect.x2; x++){ - for (int z=rect.y1; z<=rect.y2; z++){ - AINodeVec* nodes = HashMap(x,z); - if (nodes){ - const Fvector DUP={0,1,0}; - const float st = (m_Params.fPatchSize*0.9f)*0.5f; - for (AINodeIt it=nodes->begin(); it!=nodes->end(); it++){ - SAINode& N = **it; - - Fvector v; v.set(N.Pos.x-st,N.Pos.y,N.Pos.z-st); - float p_denom = N.Plane.n.dotproduct(DUP); - float b = (_abs(p_denom)ViewBase.testSphere_dirty(N.Pos,_max(b,st))){ + _VertexStream *Stream = &RCache.Vertex; + FVF::LIT *pv = (FVF::LIT*)Stream->Lock(block_size, m_RGeom->vb_stride, vBase); + u32 cnt = 0; + // EDevice.Statistic.TEST0.Begin(); + // EDevice.Statistic.TEST2.Begin(); + for (int x = rect.x1; x<=rect.x2; x++) + { + for (int z = rect.y1; z<=rect.y2; z++) + { + AINodeVec *nodes = HashMap(x, z); + if (nodes) + { + const Fvector DUP = {0,1,0}; + const float st = (m_Params.fPatchSize*0.9f)*0.5f; + for (AINodeIt it = nodes->begin(); it!=nodes->end(); it++) + { + SAINode &N = **it; + + Fvector v; + v.set(N.Pos.x-st, N.Pos.y, N.Pos.z-st); + float p_denom = N.Plane.n.dotproduct(DUP); + float b = (_abs(p_denom)ViewBase.testSphere_dirty(N.Pos, _max(b, st))) + { u32 clr; - if (N.flags.is(SAINode::flSelected))clr = 0xffffffff; - else clr = N.flags.is(SAINode::flHLSelected)?0xff909090:0xff606060; + if (N.flags.is(SAINode::flSelected)) + clr = 0xffffffff; + else + clr = N.flags.is(SAINode::flHLSelected) ? 0xff909090 : 0xff606060; int k = 0; - if (N.n1) k |= 1<<0; - if (N.n2) k |= 1<<1; - if (N.n3) k |= 1<<2; - if (N.n4) k |= 1<<3; - Fvector v; - FVF::LIT v1,v2,v3,v4; - float tt = 0.01f; - v.set(N.Pos.x-st,N.Pos.y,N.Pos.z-st); N.Plane.intersectRayPoint(v,DUP,v1.p); v1.p.mad(v1.p,N.Plane.n,tt); v1.t.set(node_tc[k][0]); v1.color=clr; // minX,minZ - v.set(N.Pos.x+st,N.Pos.y,N.Pos.z-st); N.Plane.intersectRayPoint(v,DUP,v2.p); v2.p.mad(v2.p,N.Plane.n,tt); v2.t.set(node_tc[k][1]); v2.color=clr; // maxX,minZ - v.set(N.Pos.x+st,N.Pos.y,N.Pos.z+st); N.Plane.intersectRayPoint(v,DUP,v3.p); v3.p.mad(v3.p,N.Plane.n,tt); v3.t.set(node_tc[k][2]); v3.color=clr; // maxX,maxZ - v.set(N.Pos.x-st,N.Pos.y,N.Pos.z+st); N.Plane.intersectRayPoint(v,DUP,v4.p); v4.p.mad(v4.p,N.Plane.n,tt); v4.t.set(node_tc[k][3]); v4.color=clr; // minX,maxZ - pv->set(v3); pv++; - pv->set(v2); pv++; - pv->set(v1); pv++; - pv->set(v1); pv++; - pv->set(v4); pv++; - pv->set(v3); pv++; - cnt+=6; - if (cnt>=block_size-6){ - Stream->Unlock (cnt,m_RGeom->vb_stride); - EDevice.DP (D3DPT_TRIANGLELIST,m_RGeom,vBase,cnt/3); - pv = (FVF::LIT*)Stream->Lock(block_size,m_RGeom->vb_stride,vBase); - cnt = 0; - } + if (N.n1) + k |= 1<<0; + if (N.n2) + k |= 1<<1; + if (N.n3) + k |= 1<<2; + if (N.n4) + k |= 1<<3; + Fvector v; + FVF::LIT v1, v2, v3, v4; + float tt = 0.01f; + v.set(N.Pos.x-st, N.Pos.y, N.Pos.z-st); + N.Plane.intersectRayPoint(v, DUP, v1.p); + v1.p.mad(v1.p, N.Plane.n, tt); + v1.t.set(node_tc[k][0]); + v1.color = clr; // minX,minZ + v.set(N.Pos.x+st, N.Pos.y, N.Pos.z-st); + N.Plane.intersectRayPoint(v, DUP, v2.p); + v2.p.mad(v2.p, N.Plane.n, tt); + v2.t.set(node_tc[k][1]); + v2.color = clr; // maxX,minZ + v.set(N.Pos.x+st, N.Pos.y, N.Pos.z+st); + N.Plane.intersectRayPoint(v, DUP, v3.p); + v3.p.mad(v3.p, N.Plane.n, tt); + v3.t.set(node_tc[k][2]); + v3.color = clr; // maxX,maxZ + v.set(N.Pos.x-st, N.Pos.y, N.Pos.z+st); + N.Plane.intersectRayPoint(v, DUP, v4.p); + v4.p.mad(v4.p, N.Plane.n, tt); + v4.t.set(node_tc[k][3]); + v4.color = clr; // minX,maxZ + pv->set(v3); + pv++; + pv->set(v2); + pv++; + pv->set(v1); + pv++; + pv->set(v1); + pv++; + pv->set(v4); + pv++; + pv->set(v3); + pv++; + cnt += 6; + if (cnt>=block_size-6) + { + Stream->Unlock(cnt, m_RGeom->vb_stride); + EDevice.DP(D3DPT_TRIANGLELIST, m_RGeom, vBase, cnt/3); + pv = (FVF::LIT*)Stream->Lock(block_size, m_RGeom->vb_stride, vBase); + cnt = 0; + } } } } } } -// EDevice.Statistic.TEST2.End(); -// EDevice.Statistic.TEST0.End(); - Stream->Unlock (cnt,m_RGeom->vb_stride); - if (cnt) EDevice.DP (D3DPT_TRIANGLELIST,m_RGeom,vBase,cnt/3); - EDevice.SetRS (D3DRS_CULLMODE, D3DCULL_CCW); + // EDevice.Statistic.TEST2.End(); + // EDevice.Statistic.TEST0.End(); + Stream->Unlock(cnt, m_RGeom->vb_stride); + if (cnt) + EDevice.DP(D3DPT_TRIANGLELIST, m_RGeom, vBase, cnt/3); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CCW); } - }else{ -/* // render snap - if (m_Flags.is(flDrawSnapObjects)) - for(ObjectIt _F=m_SnapObjects.begin();_F!=m_SnapObjects.end();_F++) - if((*_F)->Visible()) ((CSceneObject*)(*_F))->RenderSelection(0x4046B646); -*/ } + } + else + { + /* // render snap + if (m_Flags.is(flDrawSnapObjects)) + for(ObjectIt _F=m_SnapObjects.begin();_F!=m_SnapObjects.end();_F++) + if((*_F)->Visible()) ((CSceneObject*)(*_F))->RenderSelection(0x4046B646); + */ + } } } + //---------------------------------------------------- - diff --git a/src/editors/LevelEditor/Edit/ESceneControlsCustom.cpp b/src/editors/LevelEditor/Edit/ESceneControlsCustom.cpp index 8f66d056da3..ed728034041 100644 --- a/src/editors/LevelEditor/Edit/ESceneControlsCustom.cpp +++ b/src/editors/LevelEditor/Edit/ESceneControlsCustom.cpp @@ -2,55 +2,73 @@ #pragma hdrstop #include "ESceneControlsCustom.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "scene.h" -#include "bottombar.h" -#include "ui_levelmain.h" -#include "leftbar.h" - -TUI_CustomControl::TUI_CustomControl(int st, int act, ESceneToolBase* parent){ - parent_tool = parent; VERIFY(parent); - sub_target = st; - action = act; - bBoxSelection = false; +#include "BottomBar.h" +#include "UI_LevelMain.h" +#include "LeftBar.h" + +TUI_CustomControl::TUI_CustomControl(int st, int act, ESceneToolBase *parent) +{ + parent_tool = parent; + VERIFY(parent); + sub_target = st; + action = act; + bBoxSelection = false; } -bool TUI_CustomControl::Start (TShiftState _Shift){ - switch(action){ - case etaSelect: return SelectStart(_Shift); - case etaAdd: return AddStart(_Shift); - case etaMove: return MovingStart(_Shift); - case etaRotate: return RotateStart(_Shift); - case etaScale: return ScaleStart(_Shift); +bool TUI_CustomControl::Start(TShiftState _Shift) +{ + switch (action) + { + case etaSelect: return SelectStart(_Shift); + case etaAdd: return AddStart(_Shift); + case etaMove: return MovingStart(_Shift); + case etaRotate: return RotateStart(_Shift); + case etaScale: return ScaleStart(_Shift); } return false; } -bool TUI_CustomControl::End (TShiftState _Shift){ - switch(action){ - case etaSelect: return SelectEnd(_Shift); - case etaAdd: return AddEnd(_Shift); - case etaMove: return MovingEnd(_Shift); - case etaRotate: return RotateEnd(_Shift); - case etaScale: return ScaleEnd(_Shift); + +bool TUI_CustomControl::End(TShiftState _Shift) +{ + switch (action) + { + case etaSelect: return SelectEnd(_Shift); + case etaAdd: return AddEnd(_Shift); + case etaMove: return MovingEnd(_Shift); + case etaRotate: return RotateEnd(_Shift); + case etaScale: return ScaleEnd(_Shift); } return false; } -void TUI_CustomControl::Move (TShiftState _Shift){ - switch(action){ - case etaSelect: SelectProcess(_Shift); break; - case etaAdd: AddProcess(_Shift); break; - case etaMove: MovingProcess(_Shift); break; - case etaRotate: RotateProcess(_Shift); break; - case etaScale: ScaleProcess(_Shift); break; + +void TUI_CustomControl::Move(TShiftState _Shift) +{ + switch (action) + { + case etaSelect: SelectProcess(_Shift); + break; + case etaAdd: AddProcess(_Shift); + break; + case etaMove: MovingProcess(_Shift); + break; + case etaRotate: RotateProcess(_Shift); + break; + case etaScale: ScaleProcess(_Shift); + break; } } -bool TUI_CustomControl::HiddenMode(){ - switch(action){ - case etaSelect: return false; - case etaAdd: return false; - case etaMove: return true; - case etaRotate: return true; - case etaScale: return true; + +bool TUI_CustomControl::HiddenMode() +{ + switch (action) + { + case etaSelect: return false; + case etaAdd: return false; + case etaMove: return true; + case etaRotate: return true; + case etaScale: return true; } return false; } @@ -58,48 +76,55 @@ bool TUI_CustomControl::HiddenMode(){ //------------------------------------------------------------------------------ // add //------------------------------------------------------------------------------ -CCustomObject* __fastcall TUI_CustomControl::DefaultAddObject(TShiftState Shift, TBeforeAppendCallback before, TAfterAppendCallback after) +CCustomObject * __fastcall TUI_CustomControl::DefaultAddObject(TShiftState Shift, TBeforeAppendCallback before, TAfterAppendCallback after) { - if (Shift==ssRBOnly){ ExecCommand(COMMAND_SHOWCONTEXTMENU,parent_tool->ClassID); return 0;} - Fvector p,n; - CCustomObject* obj=0; - if (LUI->PickGround(p,UI->m_CurrentRStart,UI->m_CurrentRDir,1,&n)) + if (Shift==ssRBOnly) { - // before callback - SBeforeAppendCallbackParams P; - if (before&&!before(&P)) return 0; + ExecCommand(COMMAND_SHOWCONTEXTMENU, parent_tool->ClassID); + return 0; + } + Fvector p, n; + CCustomObject*obj = 0; + if (LUI->PickGround(p, UI->m_CurrentRStart, UI->m_CurrentRDir, 1, &n)) + { + // before callback + SBeforeAppendCallbackParams P; + if (before&&!before(&P)) + return 0; - string256 namebuffer; + string256 namebuffer; Scene->GenObjectName(parent_tool->ClassID, namebuffer, P.name_prefix.c_str()); - obj=Scene->GetOTool(parent_tool->ClassID)->CreateObject(P.data, namebuffer); - if (!obj->Valid()){ - xr_delete(obj); + obj = Scene->GetOTool(parent_tool->ClassID)->CreateObject(P.data, namebuffer); + if (!obj->Valid()) + { + xr_delete(obj); return 0; } // after callback - if (after&&!after(Shift, obj)){ - xr_delete(obj); + if (after&&!after(Shift, obj)) + { + xr_delete(obj); return 0; } - obj->MoveTo(p,n); - Scene->SelectObjects(false,parent_tool->ClassID); - Scene->AppendObject(obj); - if (Shift.Contains(ssCtrl)) - ExecCommand(COMMAND_SHOW_PROPERTIES); - if (!Shift.Contains(ssAlt)) - ResetActionToSelect(); + obj->MoveTo(p, n); + Scene->SelectObjects(false, parent_tool->ClassID); + Scene->AppendObject(obj); + if (Shift.Contains(ssCtrl)) + ExecCommand(COMMAND_SHOW_PROPERTIES); + if (!Shift.Contains(ssAlt)) + ResetActionToSelect(); } return obj; } bool __fastcall TUI_CustomControl::AddStart(TShiftState Shift) { - DefaultAddObject(Shift,0); + DefaultAddObject(Shift, 0); return false; } -void __fastcall TUI_CustomControl::AddProcess(TShiftState _Shift) -{ -} + +void __fastcall TUI_CustomControl::AddProcess(TShiftState _Shift) {} + bool __fastcall TUI_CustomControl::AddEnd(TShiftState _Shift) { return true; @@ -107,25 +132,38 @@ bool __fastcall TUI_CustomControl::AddEnd(TShiftState _Shift) bool TUI_CustomControl::CheckSnapList(TShiftState Shift) { - if (fraLeftBar->ebSnapListMode->Down){ - CCustomObject* O=Scene->RayPickObject(UI->ZFar(),UI->m_CurrentRStart,UI->m_CurrentRDir,OBJCLASS_SCENEOBJECT,0,0); - if (O){ - if (Scene->FindObjectInSnapList(O)){ - if (Shift.Contains(ssAlt)){ + if (fraLeftBar->ebSnapListMode->Down) + { + CCustomObject*O = Scene->RayPickObject(UI->ZFar(), UI->m_CurrentRStart, UI->m_CurrentRDir, OBJCLASS_SCENEOBJECT, 0, 0); + if (O) + { + if (Scene->FindObjectInSnapList(O)) + { + if (Shift.Contains(ssAlt)) + { Scene->DelFromSnapList(O); - }else if (Shift.Contains(ssCtrl)){ + } + else if (Shift.Contains(ssCtrl)) + { Scene->DelFromSnapList(O); } - }else{ - if (!Shift.Contains(ssCtrl)&&!Shift.Contains(ssAlt)){ + } + else + { + if (!Shift.Contains(ssCtrl)&&!Shift.Contains(ssAlt)) + { Scene->AddToSnapList(O); - }else if (Shift.Contains(ssCtrl)){ + } + else if (Shift.Contains(ssCtrl)) + { Scene->AddToSnapList(O); } } - return true; - }else{ - return false; + return true; + } + else + { + return false; } } return false; @@ -136,32 +174,42 @@ bool TUI_CustomControl::CheckSnapList(TShiftState Shift) //------------------------------------------------------------------------------ bool __fastcall TUI_CustomControl::SelectStart(TShiftState Shift) { - ObjClassID cls = LTools->CurrentClassID(); + ObjClassID cls = LTools->CurrentClassID(); - if (CheckSnapList(Shift)) return false; - if (Shift==ssRBOnly){ ExecCommand(COMMAND_SHOWCONTEXTMENU,parent_tool->ClassID); return false;} - if (!(Shift.Contains(ssCtrl)||Shift.Contains(ssAlt))) Scene->SelectObjects( false, cls); + if (CheckSnapList(Shift)) + return false; + if (Shift==ssRBOnly) + { + ExecCommand(COMMAND_SHOWCONTEXTMENU, parent_tool->ClassID); + return false; + } + if (!(Shift.Contains(ssCtrl)||Shift.Contains(ssAlt))) + Scene->SelectObjects(false, cls); - int cnt = Scene->RaySelect(Shift.Contains(ssCtrl)?-1:Shift.Contains(ssAlt)?0:1,parent_tool->ClassID); - bBoxSelection = ((0!=cnt) && (Shift.Contains(ssCtrl)||Shift.Contains(ssAlt))) || (0==cnt); - if( bBoxSelection ){ - UI->EnableSelectionRect( true ); - UI->UpdateSelectionRect(UI->m_StartCp,UI->m_CurrentCp); + int cnt = Scene->RaySelect(Shift.Contains(ssCtrl) ? -1 : Shift.Contains(ssAlt) ? 0 : 1, parent_tool->ClassID); + bBoxSelection = ((0!=cnt)&&(Shift.Contains(ssCtrl)||Shift.Contains(ssAlt)))||(0==cnt); + if (bBoxSelection) + { + UI->EnableSelectionRect(true); + UI->UpdateSelectionRect(UI->m_StartCp, UI->m_CurrentCp); return true; } return false; } -void __fastcall TUI_CustomControl::SelectProcess(TShiftState _Shift){ - if (bBoxSelection) UI->UpdateSelectionRect(UI->m_StartCp,UI->m_CurrentCp); +void __fastcall TUI_CustomControl::SelectProcess(TShiftState _Shift) +{ + if (bBoxSelection) + UI->UpdateSelectionRect(UI->m_StartCp, UI->m_CurrentCp); } bool __fastcall TUI_CustomControl::SelectEnd(TShiftState _Shift) { - if (bBoxSelection){ - UI->EnableSelectionRect( false ); + if (bBoxSelection) + { + UI->EnableSelectionRect(false); bBoxSelection = false; - Scene->FrustumSelect(_Shift.Contains(ssAlt)?0:1,LTools->CurrentClassID()); + Scene->FrustumSelect(_Shift.Contains(ssAlt) ? 0 : 1, LTools->CurrentClassID()); } return true; } @@ -171,87 +219,110 @@ bool __fastcall TUI_CustomControl::SelectEnd(TShiftState _Shift) //------------------------------------------------------------------------------------ bool __fastcall TUI_CustomControl::MovingStart(TShiftState Shift) { - ObjClassID cls = LTools->CurrentClassID(); + ObjClassID cls = LTools->CurrentClassID(); - if(Shift==ssRBOnly){ ExecCommand(COMMAND_SHOWCONTEXTMENU,parent_tool->ClassID); return false;} - if(Scene->SelectionCount(true,cls)==0) return false; + if (Shift==ssRBOnly) + { + ExecCommand(COMMAND_SHOWCONTEXTMENU, parent_tool->ClassID); + return false; + } + if (Scene->SelectionCount(true, cls)==0) + return false; - if (Shift.Contains(ssCtrl)){ + if (Shift.Contains(ssCtrl)) + { ObjectList lst; - if (Scene->GetQueryObjects(lst,LTools->CurrentClassID(),1,1,0)){ - if (lst.size()==1){ - Fvector p,n; + if (Scene->GetQueryObjects(lst, LTools->CurrentClassID(), 1, 1, 0)) + { + if (lst.size()==1) + { + Fvector p, n; UI->IR_GetMousePosReal(EDevice.m_hRenderWnd, UI->m_CurrentCp); - EDevice.m_Camera.MouseRayFromPoint(UI->m_CurrentRStart,UI->m_CurrentRDir,UI->m_CurrentCp); - if (LUI->PickGround(p,UI->m_CurrentRStart,UI->m_CurrentRDir,1,&n)){ - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) (*_F)->MoveTo(p,n); + EDevice.m_Camera.MouseRayFromPoint(UI->m_CurrentRStart, UI->m_CurrentRDir, UI->m_CurrentCp); + if (LUI->PickGround(p, UI->m_CurrentRStart, UI->m_CurrentRDir, 1, &n)) + { + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + (*_F)->MoveTo(p, n); Scene->UndoSave(); } - }else{ - Fvector p,n; - Fvector D={0,-1,0}; - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++){ - if (LUI->PickGround(p,(*_F)->PPosition,D,1,&n)){ - (*_F)->MoveTo(p,n); + } + else + { + Fvector p, n; + Fvector D = {0,-1,0}; + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + { + if (LUI->PickGround(p, (*_F)->PPosition, D, 1, &n)) + { + (*_F)->MoveTo(p, n); } } } } return false; - }else{ - if (etAxisY==Tools->GetAxis()){ - m_MovingXVector.set(0,0,0); - m_MovingYVector.set(0,1,0); - }else{ - m_MovingXVector.set( EDevice.m_Camera.GetRight() ); + } + else + { + if (etAxisY==Tools->GetAxis()) + { + m_MovingXVector.set(0, 0, 0); + m_MovingYVector.set(0, 1, 0); + } + else + { + m_MovingXVector.set(EDevice.m_Camera.GetRight()); m_MovingXVector.y = 0; - m_MovingYVector.set( EDevice.m_Camera.GetDirection() ); + m_MovingYVector.set(EDevice.m_Camera.GetDirection()); m_MovingYVector.y = 0; m_MovingXVector.normalize_safe(); m_MovingYVector.normalize_safe(); } - m_MovingReminder.set(0,0,0); + m_MovingReminder.set(0, 0, 0); } return true; } -bool __fastcall TUI_CustomControl::DefaultMovingProcess(TShiftState Shift, Fvector& amount) +bool __fastcall TUI_CustomControl::DefaultMovingProcess(TShiftState Shift, Fvector &amount) { if (Shift.Contains(ssLeft)||Shift.Contains(ssRight)) { - amount.mul( m_MovingXVector, UI->m_MouseSM * UI->m_DeltaCpH.x ); - amount.mad( amount, m_MovingYVector, -UI->m_MouseSM * UI->m_DeltaCpH.y ); + amount.mul(m_MovingXVector, UI->m_MouseSM*UI->m_DeltaCpH.x); + amount.mad(amount, m_MovingYVector, -UI->m_MouseSM*UI->m_DeltaCpH.y); - if( Tools->GetSettings(etfMSnap) ) + if (Tools->GetSettings(etfMSnap)) { - CHECK_SNAP(m_MovingReminder.x,amount.x,Tools->m_MoveSnap); - CHECK_SNAP(m_MovingReminder.y,amount.y,Tools->m_MoveSnap); - CHECK_SNAP(m_MovingReminder.z,amount.z,Tools->m_MoveSnap); + CHECK_SNAP(m_MovingReminder.x,amount.x,Tools->m_MoveSnap); + CHECK_SNAP(m_MovingReminder.y,amount.y,Tools->m_MoveSnap); + CHECK_SNAP(m_MovingReminder.z,amount.z,Tools->m_MoveSnap); } - if (!(etAxisX==Tools->GetAxis())&&!(etAxisZX==Tools->GetAxis())) amount.x = 0.f; - if (!(etAxisZ==Tools->GetAxis())&&!(etAxisZX==Tools->GetAxis())) amount.z = 0.f; - if (!(etAxisY==Tools->GetAxis())) amount.y = 0.f; + if (!(etAxisX==Tools->GetAxis())&&!(etAxisZX==Tools->GetAxis())) + amount.x = 0.f; + if (!(etAxisZ==Tools->GetAxis())&&!(etAxisZX==Tools->GetAxis())) + amount.z = 0.f; + if (!(etAxisY==Tools->GetAxis())) + amount.y = 0.f; return (amount.square_magnitude()>EPS_S); - } + } return false; } void __fastcall TUI_CustomControl::MovingProcess(TShiftState _Shift) { - Fvector amount; - if (DefaultMovingProcess(_Shift,amount)) + Fvector amount; + if (DefaultMovingProcess(_Shift, amount)) { ObjectList lst; - if (Scene->GetQueryObjects(lst,LTools->CurrentClassID(),1,1,0)) - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) (*_F)->Move(amount); + if (Scene->GetQueryObjects(lst, LTools->CurrentClassID(), 1, 1, 0)) + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + (*_F)->Move(amount); } } bool __fastcall TUI_CustomControl::MovingEnd(TShiftState _Shift) { - Scene->UndoSave(); + Scene->UndoSave(); return true; } @@ -260,16 +331,24 @@ bool __fastcall TUI_CustomControl::MovingEnd(TShiftState _Shift) //------------------------------------------------------------------------------------ bool __fastcall TUI_CustomControl::RotateStart(TShiftState Shift) { - ObjClassID cls = LTools->CurrentClassID(); + ObjClassID cls = LTools->CurrentClassID(); - if(Shift==ssRBOnly){ ExecCommand(COMMAND_SHOWCONTEXTMENU,parent_tool->ClassID); return false;} - if(Scene->SelectionCount(true,cls)==0) return false; + if (Shift==ssRBOnly) + { + ExecCommand(COMMAND_SHOWCONTEXTMENU, parent_tool->ClassID); + return false; + } + if (Scene->SelectionCount(true, cls)==0) + return false; - m_RotateVector.set(0,0,0); - if (etAxisX==Tools->GetAxis()) m_RotateVector.set(1,0,0); - else if (etAxisY==Tools->GetAxis()) m_RotateVector.set(0,1,0); - else if (etAxisZ==Tools->GetAxis()) m_RotateVector.set(0,0,1); - m_fRotateSnapAngle = 0; + m_RotateVector.set(0, 0, 0); + if (etAxisX==Tools->GetAxis()) + m_RotateVector.set(1, 0, 0); + else if (etAxisY==Tools->GetAxis()) + m_RotateVector.set(0, 1, 0); + else if (etAxisZ==Tools->GetAxis()) + m_RotateVector.set(0, 0, 1); + m_fRotateSnapAngle = 0; return true; } @@ -277,24 +356,28 @@ void __fastcall TUI_CustomControl::RotateProcess(TShiftState _Shift) { if (_Shift.Contains(ssLeft)) { - float amount = -UI->m_DeltaCpH.x * UI->m_MouseSR; + float amount = -UI->m_DeltaCpH.x*UI->m_MouseSR; - if( Tools->GetSettings(etfASnap) ) CHECK_SNAP(m_fRotateSnapAngle,amount,Tools->m_RotateSnapAngle); + if (Tools->GetSettings(etfASnap)) + CHECK_SNAP(m_fRotateSnapAngle,amount,Tools->m_RotateSnapAngle); ObjectList lst; - if (Scene->GetQueryObjects(lst,LTools->CurrentClassID(),1,1,0)) - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) - if( Tools->GetSettings(etfCSParent) ) + if (Scene->GetQueryObjects(lst, LTools->CurrentClassID(), 1, 1, 0)) + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + if (Tools->GetSettings(etfCSParent)) { - (*_F)->RotateParent( m_RotateVector, amount ); - } else { - (*_F)->RotateLocal( m_RotateVector, amount ); + (*_F)->RotateParent(m_RotateVector, amount); + } + else + { + (*_F)->RotateLocal(m_RotateVector, amount); } } } + bool __fastcall TUI_CustomControl::RotateEnd(TShiftState _Shift) { - Scene->UndoSave(); + Scene->UndoSave(); return true; } @@ -303,36 +386,49 @@ bool __fastcall TUI_CustomControl::RotateEnd(TShiftState _Shift) //------------------------------------------------------------------------------ bool __fastcall TUI_CustomControl::ScaleStart(TShiftState Shift) { - ObjClassID cls = LTools->CurrentClassID(); - if(Shift==ssRBOnly){ ExecCommand(COMMAND_SHOWCONTEXTMENU,parent_tool->ClassID); return false;} - if(Scene->SelectionCount(true,cls)==0) return false; - return true; + ObjClassID cls = LTools->CurrentClassID(); + if (Shift==ssRBOnly) + { + ExecCommand(COMMAND_SHOWCONTEXTMENU, parent_tool->ClassID); + return false; + } + if (Scene->SelectionCount(true, cls)==0) + return false; + return true; } void __fastcall TUI_CustomControl::ScaleProcess(TShiftState _Shift) { - float dy = UI->m_DeltaCpH.x * UI->m_MouseSS; - if (dy>1.f) dy=1.f; else if (dy<-1.f) dy=-1.f; + float dy = UI->m_DeltaCpH.x*UI->m_MouseSS; + if (dy>1.f) + dy = 1.f; else if (dy<-1.f) + dy = -1.f; - Fvector amount; - amount.set( dy, dy, dy ); + Fvector amount; + amount.set(dy, dy, dy); - if (Tools->GetSettings(etfNUScale)){ - if (!(etAxisX==Tools->GetAxis())&&!(etAxisZX==Tools->GetAxis())) amount.x = 0.f; - if (!(etAxisZ==Tools->GetAxis())&&!(etAxisZX==Tools->GetAxis())) amount.z = 0.f; - if (!(etAxisY==Tools->GetAxis())) amount.y = 0.f; + if (Tools->GetSettings(etfNUScale)) + { + if (!(etAxisX==Tools->GetAxis())&&!(etAxisZX==Tools->GetAxis())) + amount.x = 0.f; + if (!(etAxisZ==Tools->GetAxis())&&!(etAxisZX==Tools->GetAxis())) + amount.z = 0.f; + if (!(etAxisY==Tools->GetAxis())) + amount.y = 0.f; } ObjectList lst; - if (Scene->GetQueryObjects(lst,LTools->CurrentClassID(),1,1,0)) - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) (*_F)->Scale( amount ); + if (Scene->GetQueryObjects(lst, LTools->CurrentClassID(), 1, 1, 0)) + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + (*_F)->Scale(amount); } + bool __fastcall TUI_CustomControl::ScaleEnd(TShiftState _Shift) { - Scene->UndoSave(); + Scene->UndoSave(); return true; } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ diff --git a/src/editors/LevelEditor/Edit/ESceneControlsCustom.h b/src/editors/LevelEditor/Edit/ESceneControlsCustom.h index 076273d1e67..50e97e5e8a6 100644 --- a/src/editors/LevelEditor/Edit/ESceneControlsCustom.h +++ b/src/editors/LevelEditor/Edit/ESceneControlsCustom.h @@ -1,76 +1,117 @@ #ifndef ESceneControlsCustomH #define ESceneControlsCustomH -#include "customobject.h" +#include "CustomObject.h" //--------------------------------------------------------------------------- // refs class ESceneToolBase; -struct SBeforeAppendCallbackParams{ - LPVOID data; - xr_string name_prefix; +struct SBeforeAppendCallbackParams +{ + LPVOID data; + xr_string name_prefix; + SBeforeAppendCallbackParams() { - data = 0; - name_prefix = ""; + data = 0; + name_prefix = ""; } }; -typedef bool __fastcall (__closure *TBeforeAppendCallback)(SBeforeAppendCallbackParams* p); -typedef bool __fastcall (__closure *TAfterAppendCallback)(TShiftState _Shift, CCustomObject* obj); -class TUI_CustomControl{ +typedef bool __fastcall(__closure*TBeforeAppendCallback)(SBeforeAppendCallbackParams +* +p +); +typedef bool __fastcall(__closure*TAfterAppendCallback)(TShiftState +_Shift +, +CCustomObject* obj +); + +class TUI_CustomControl +{ protected: friend class ESceneToolBase; int sub_target; int action; -// select + // select bool bBoxSelection; - bool SelectStart (TShiftState _Shift); - void SelectProcess (TShiftState _Shift); - bool SelectEnd (TShiftState _Shift); -// add - bool AddStart (TShiftState _Shift); - void AddProcess (TShiftState _Shift); - bool AddEnd (TShiftState _Shift); -// move - Fvector m_MovingXVector; - Fvector m_MovingYVector; - Fvector m_MovingReminder; - bool MovingStart (TShiftState _Shift); - void MovingProcess (TShiftState _Shift); - bool MovingEnd (TShiftState _Shift); -// scale - bool ScaleStart (TShiftState _Shift); - void ScaleProcess (TShiftState _Shift); - bool ScaleEnd (TShiftState _Shift); -// rotate - Fvector m_RotateVector; - float m_fRotateSnapAngle; - - bool RotateStart (TShiftState _Shift); - void RotateProcess (TShiftState _Shift); - bool RotateEnd (TShiftState _Shift); + bool SelectStart(TShiftState _Shift); + void SelectProcess(TShiftState _Shift); + bool SelectEnd(TShiftState _Shift); + // add + bool AddStart(TShiftState _Shift); + void AddProcess(TShiftState _Shift); + bool AddEnd(TShiftState _Shift); + // move + Fvector m_MovingXVector; + Fvector m_MovingYVector; + Fvector m_MovingReminder; + bool MovingStart(TShiftState _Shift); + void MovingProcess(TShiftState _Shift); + bool MovingEnd(TShiftState _Shift); + // scale + bool ScaleStart(TShiftState _Shift); + void ScaleProcess(TShiftState _Shift); + bool ScaleEnd(TShiftState _Shift); + // rotate + Fvector m_RotateVector; + float m_fRotateSnapAngle; + + bool RotateStart(TShiftState _Shift); + void RotateProcess(TShiftState _Shift); + bool RotateEnd(TShiftState _Shift); protected: - bool CheckSnapList (TShiftState Shift); + bool CheckSnapList(TShiftState Shift); - CCustomObject* DefaultAddObject(TShiftState Shift, TBeforeAppendCallback before=0, TAfterAppendCallback after=0); - bool DefaultMovingProcess(TShiftState Shift, Fvector& amount); + CCustomObject *DefaultAddObject(TShiftState Shift, TBeforeAppendCallback before = 0, TAfterAppendCallback after = 0); + bool DefaultMovingProcess(TShiftState Shift, Fvector &amount); public: - ESceneToolBase* parent_tool; + ESceneToolBase *parent_tool; public: - TUI_CustomControl (int st, int act, ESceneToolBase* parent); - virtual ~TUI_CustomControl (){;} - virtual bool Start (TShiftState _Shift); - virtual bool End (TShiftState _Shift); - virtual void Move (TShiftState _Shift); - virtual bool HiddenMode (); - virtual bool KeyDown (WORD Key, TShiftState Shift){return false;} - virtual bool KeyUp (WORD Key, TShiftState Shift){return false;} - virtual bool KeyPress (WORD Key, TShiftState Shift){return false;} - virtual void OnEnter (){;} - virtual void OnExit (){;} - - int Action (){return action;} + TUI_CustomControl(int st, int act, ESceneToolBase *parent); + + virtual ~TUI_CustomControl() + { + ; + } + + virtual bool Start(TShiftState _Shift); + virtual bool End(TShiftState _Shift); + virtual void Move(TShiftState _Shift); + virtual bool HiddenMode(); + + virtual bool KeyDown(WORD Key, TShiftState Shift) + { + return false; + } + + virtual bool KeyUp(WORD Key, TShiftState Shift) + { + return false; + } + + virtual bool KeyPress(WORD Key, TShiftState Shift) + { + return false; + } + + virtual void OnEnter() + { + ; + } + + virtual void OnExit() + { + ; + } + + int Action() + { + return action; + } }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneCustomMTools.cpp b/src/editors/LevelEditor/Edit/ESceneCustomMTools.cpp index a1cac7d80b2..3435d510fd8 100644 --- a/src/editors/LevelEditor/Edit/ESceneCustomMTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneCustomMTools.cpp @@ -2,89 +2,89 @@ #pragma hdrstop #include "ESceneCustomMTools.h" -#include "../ECore/Editor/ui_main.h" -#include "ui_levelmain.h" +#include "editors/ECore/Editor/ui_main.h" +#include "UI_LevelMain.h" #include "scene.h" #define CHUNK_TOOLS_TAG 0x7777 ESceneToolBase::ESceneToolBase(ObjClassID cls) { - ClassID = cls; + ClassID = cls; // controls - sub_target = 0; - pCurControl = 0; - pFrame = 0; - action = -1; - m_EditFlags.assign (flEnable|flVisible); - m_ModifName = ""; - m_ModifTime = 0; + sub_target = 0; + pCurControl = 0; + pFrame = 0; + action = -1; + m_EditFlags.assign(flEnable|flVisible); + m_ModifName = ""; + m_ModifTime = 0; } -ESceneToolBase::~ESceneToolBase() -{ -} +ESceneToolBase::~ESceneToolBase() {} void ESceneToolBase::Clear(bool bSpecific) { - m_ModifName = ""; - m_ModifTime = 0; + m_ModifName = ""; + m_ModifTime = 0; } void ESceneToolBase::Reset() { - Clear (); - m_EditFlags.set (flReadonly,FALSE); + Clear(); + m_EditFlags.set(flReadonly, FALSE); } - + void ESceneToolBase::OnCreate() { - OnDeviceCreate (); - CreateControls (); + OnDeviceCreate(); + CreateControls(); } + void ESceneToolBase::OnDestroy() { - OnDeviceDestroy (); - RemoveControls (); + OnDeviceDestroy(); + RemoveControls(); } -bool ESceneToolBase::LoadLTX(CInifile& ini) +bool ESceneToolBase::LoadLTX(CInifile &ini) { - m_ModifName = ini.r_string("modif", "name"); - m_ModifTime = ini.r_u32("modif", "time"); - return true; + m_ModifName = ini.r_string("modif", "name"); + m_ModifTime = ini.r_u32("modif", "time"); + return true; } -void ESceneToolBase::SaveLTX(CInifile& ini, int id) +void ESceneToolBase::SaveLTX(CInifile &ini, int id) { - ini.w_string ("modif", "name", m_ModifName.c_str()); - ini.w_u32 ("modif", "time", m_ModifTime); + ini.w_string("modif", "name", m_ModifName.c_str()); + ini.w_u32("modif", "time", m_ModifTime); } -bool ESceneToolBase::LoadStream(IReader& F) +bool ESceneToolBase::LoadStream(IReader &F) { - if (F.find_chunk(CHUNK_TOOLS_TAG)) + if (F.find_chunk(CHUNK_TOOLS_TAG)) { - F.r_stringZ (m_ModifName); - F.r (&m_ModifTime,sizeof(m_ModifTime)); - }else + F.r_stringZ(m_ModifName); + F.r(&m_ModifTime, sizeof(m_ModifTime)); + } + else { - m_ModifName = ""; - m_ModifTime = 0; + m_ModifName = ""; + m_ModifTime = 0; } return true; } -void ESceneToolBase::SaveStream(IWriter& F) +void ESceneToolBase::SaveStream(IWriter &F) { -/* - xr_string mn = AnsiString().sprintf("\\\\%s\\%s",Core.CompName,Core.UserName).c_str(); - time_t mt = time(NULL); - - F.open_chunk (CHUNK_TOOLS_TAG); - F.w_stringZ (mn); - F.w (&mt,sizeof(mt)); - F.close_chunk (); -*/ + /* + xr_string mn = AnsiString().sprintf("\\\\%s\\%s",Core.CompName,Core.UserName).c_str(); + time_t mt = time(NULL); + + F.open_chunk(CHUNK_TOOLS_TAG); + F.w_stringZ (mn); + F.w (&mt,sizeof(mt)); + F.close_chunk(); + */ } diff --git a/src/editors/LevelEditor/Edit/ESceneCustomMTools.h b/src/editors/LevelEditor/Edit/ESceneCustomMTools.h index 8e3c23f2f81..8dedc442f68 100644 --- a/src/editors/LevelEditor/Edit/ESceneCustomMTools.h +++ b/src/editors/LevelEditor/Edit/ESceneCustomMTools.h @@ -9,145 +9,229 @@ class ESceneCustomMTools; class SceneBuilder; struct SExportStreams; struct mesh_build_data; -DEFINE_VECTOR(TUI_CustomControl*,ControlsVec,ControlsIt); +DEFINE_VECTOR(TUI_CustomControl *, ControlsVec, ControlsIt); class ESceneToolBase { - ObjClassID FClassID; + ObjClassID FClassID; protected: - // controls - ControlsVec m_Controls; - int action; - int sub_target; + // controls + ControlsVec m_Controls; + int action; + int sub_target; public: - enum{ - flEnable = (1<<0), - flReadonly = (1<<1), - flForceReadonly = (1<<2), - flChanged = (1<<3), - flVisible = (1<<4), + enum + { + flEnable = (1<<0), + flReadonly = (1<<1), + flForceReadonly = (1<<2), + flChanged = (1<<3), + flVisible = (1<<4), }; - Flags32 m_EditFlags; - BOOL IsEnabled (){return m_EditFlags.is(flEnable);} - BOOL IsEditable (){return !m_EditFlags.is_any(flReadonly|flForceReadonly);} - BOOL IsReadonly (){return m_EditFlags.is(flReadonly);} - BOOL IsForceReadonly (){return m_EditFlags.is(flForceReadonly);} - BOOL IsChanged (){return m_EditFlags.is(flChanged);} - void SetChanged (BOOL b){m_EditFlags.set(flChanged,b);} - BOOL IsVisible (){return m_EditFlags.is(flVisible);} - virtual BOOL AllowMouseStart ()=0; + + Flags32 m_EditFlags; + + BOOL IsEnabled() + { + return m_EditFlags.is(flEnable); + } + + BOOL IsEditable() + { + return !m_EditFlags.is_any(flReadonly|flForceReadonly); + } + + BOOL IsReadonly() + { + return m_EditFlags.is(flReadonly); + } + + BOOL IsForceReadonly() + { + return m_EditFlags.is(flForceReadonly); + } + + BOOL IsChanged() + { + return m_EditFlags.is(flChanged); + } + + void SetChanged(BOOL b) + { + m_EditFlags.set(flChanged, b); + } + + BOOL IsVisible() + { + return m_EditFlags.is(flVisible); + } + + virtual BOOL AllowMouseStart() =0; public: - // modifiers - shared_str m_ModifName; - time_t m_ModifTime; - // frame & Controls - TUI_CustomControl* pCurControl; - TForm* pFrame; + // modifiers + shared_str m_ModifName; + time_t m_ModifTime; + // frame & Controls + TUI_CustomControl *pCurControl; + TForm *pFrame; protected: - void AddControl (TUI_CustomControl* c); - TUI_CustomControl* FindControl (int subtarget, int action); - void UpdateControl (); + void AddControl(TUI_CustomControl *c); + TUI_CustomControl *FindControl(int subtarget, int action); + void UpdateControl(); public: - void SetAction (int action); - void SetSubTarget (int target); - void ResetSubTarget (); + void SetAction(int action); + void SetSubTarget(int target); + void ResetSubTarget(); protected: - void CreateDefaultControls (u32 sub_target_id); - virtual void CreateControls ()=0; - virtual void RemoveControls (); + void CreateDefaultControls(u32 sub_target_id); + virtual void CreateControls() =0; + virtual void RemoveControls(); public: - virtual void OnActivate (); - virtual void OnDeactivate (); - virtual void OnObjectsUpdate (){;} + virtual void OnActivate(); + virtual void OnDeactivate(); + + virtual void OnObjectsUpdate() + { + ; + } + public: - PropertyGP (FClassID,FClassID) ObjClassID ClassID; - // definition - virtual LPCSTR ClassName ()=0; - virtual LPCSTR ClassDesc ()=0; - virtual int RenderPriority ()=0; + PropertyGP(FClassID, FClassID) ObjClassID ClassID; + // definition + virtual LPCSTR ClassName() =0; + virtual LPCSTR ClassDesc() =0; + virtual int RenderPriority() =0; public: - ESceneToolBase (ObjClassID cls); - virtual ~ESceneToolBase (); + ESceneToolBase(ObjClassID cls); + virtual ~ESceneToolBase(); + + virtual void OnCreate(); + virtual void OnDestroy(); - virtual void OnCreate (); - virtual void OnDestroy (); - - virtual bool AllowEnabling ()=0; + virtual bool AllowEnabling() =0; // snap - virtual ObjectList* GetSnapList ()=0; - virtual void UpdateSnapList ()=0; - - // selection manipulate + virtual ObjectList *GetSnapList() =0; + virtual void UpdateSnapList() =0; + + // selection manipulate // flags: [0 - FALSE, 1 - TRUE, -1 - INVERT] - virtual int RaySelect (int flag, float& distance, const Fvector& start, const Fvector& direction, BOOL bDistanceOnly)=0; - virtual int FrustumSelect (int flag, const CFrustum& frustum)=0; - virtual void SelectObjects (bool flag)=0; - virtual void InvertSelection ()=0; - virtual void RemoveSelection ()=0; - virtual int SelectionCount (bool testflag)=0; - virtual void ShowObjects (bool flag, bool bAllowSelectionFlag=false, bool bSelFlag=true)=0; + virtual int RaySelect(int flag, float &distance, const Fvector &start, const Fvector &direction, BOOL bDistanceOnly) =0; + virtual int FrustumSelect(int flag, const CFrustum &frustum) =0; + virtual void SelectObjects(bool flag) =0; + virtual void InvertSelection() =0; + virtual void RemoveSelection() =0; + virtual int SelectionCount(bool testflag) =0; + virtual void ShowObjects(bool flag, bool bAllowSelectionFlag = false, bool bSelFlag = true) =0; - virtual void Clear (bool bSpecific=false)=0; - virtual void Reset (); + virtual void Clear(bool bSpecific = false) =0; + virtual void Reset(); // validation - virtual bool Valid ()=0; - virtual bool Validate (bool)=0; + virtual bool Valid() =0; + virtual bool Validate(bool) =0; // events - virtual void OnDeviceCreate ()=0; - virtual void OnDeviceDestroy ()=0; - virtual void OnSynchronize ()=0; - virtual void OnSceneUpdate (){;} - virtual void OnObjectRemove (CCustomObject* O, bool bDeleting)=0; - virtual void OnBeforeObjectChange (CCustomObject* O){}; - virtual void OnFrame ()=0; + virtual void OnDeviceCreate() =0; + virtual void OnDeviceDestroy() =0; + virtual void OnSynchronize() =0; + + virtual void OnSceneUpdate() + { + ; + } + + virtual void OnObjectRemove(CCustomObject *O, bool bDeleting) =0; + + virtual void OnBeforeObjectChange(CCustomObject *O) {}; + + virtual void OnFrame() =0; // render - virtual void BeforeRender (){;} - virtual void OnRender (int priority, bool strictB2F)=0; - void OnRenderRoot (int priority, bool strictB2F){if(IsVisible())OnRender(priority, strictB2F);}; - virtual void AfterRender (){;} + virtual void BeforeRender() + { + ; + } + + virtual void OnRender(int priority, bool strictB2F) =0; + + void OnRenderRoot(int priority, bool strictB2F) + { + if (IsVisible()) + OnRender(priority, strictB2F); + }; + + virtual void AfterRender() + { + ; + } // IO - virtual int SaveFileCount () const {return 1;} - virtual bool IsNeedSave ()=0; + virtual int SaveFileCount() const + { + return 1; + } + + virtual bool IsNeedSave() =0; + + virtual bool LoadStream(IReader &) =0; + virtual bool LoadLTX(CInifile &) =0; + virtual void SaveStream(IWriter &) =0; + virtual void SaveLTX(CInifile &, int id) =0; + + virtual bool can_use_inifile() + { + return true; + } - virtual bool LoadStream (IReader&)=0; - virtual bool LoadLTX (CInifile&)=0; - virtual void SaveStream (IWriter&)=0; - virtual void SaveLTX (CInifile&, int id)=0; - virtual bool can_use_inifile () {return true;} + virtual bool LoadSelection(IReader &) =0; + virtual void SaveSelection(IWriter &) =0; - virtual bool LoadSelection (IReader&)=0; - virtual void SaveSelection (IWriter&)=0; + virtual bool Export(LPCSTR path) + { + return true; + } - virtual bool Export (LPCSTR path){return true;} - virtual bool ExportGame (SExportStreams* F){return true;} + virtual bool ExportGame(SExportStreams *F) + { + return true; + } - virtual bool ExportStatic (SceneBuilder* B, bool b_selected_only){return true;} - virtual void GetStaticDesc (int& v_cnt, int& f_cnt, bool b_selected_only, bool b_cform){} - virtual bool GetStaticCformData ( mesh_build_data &data, bool b_selected_only ) + virtual bool ExportStatic(SceneBuilder *B, bool b_selected_only) { -#ifdef DEBUG + return true; + } + + virtual void GetStaticDesc(int &v_cnt, int &f_cnt, bool b_selected_only, bool b_cform) {} + + virtual bool GetStaticCformData(mesh_build_data &data, bool b_selected_only) + { +#ifdef DEBUG int cnt_v = 0, cnt_f = 0; GetStaticDesc(cnt_v,cnt_f,b_selected_only,true);VERIFY(cnt_v==0&&cnt_f==0) ; #endif - return true; + return true; } - virtual void CompileStaticStart () {}; - virtual void CompileStaticEnd () {}; + + virtual void CompileStaticStart() {}; + + virtual void CompileStaticEnd() {}; // properties - virtual void FillProp (LPCSTR pref, PropItemVec& items)=0; + virtual void FillProp(LPCSTR pref, PropItemVec &items) =0; // utils - virtual bool GetSummaryInfo (SSceneSummary* inf)=0; - virtual void HighlightTexture (LPCSTR tex_name, bool allow_ratio, u32 t_width, u32 t_height, BOOL mark){} - virtual void GetBBox (Fbox& bb, bool bSelOnly)=0; - virtual const CCustomObject* LastSelected () const {return NULL;} - + virtual bool GetSummaryInfo(SSceneSummary *inf) =0; + + virtual void HighlightTexture(LPCSTR tex_name, bool allow_ratio, u32 t_width, u32 t_height, BOOL mark) {} + + virtual void GetBBox(Fbox &bb, bool bSelOnly) =0; + + virtual const CCustomObject *LastSelected() const + { + return NULL; + } }; -DEFINE_MAP(ObjClassID,ESceneToolBase*,SceneToolsMap,SceneToolsMapPairIt); +DEFINE_MAP(ObjClassID, ESceneToolBase *, SceneToolsMap, SceneToolsMapPairIt); #endif //ESceneCustomMToolsH - + + diff --git a/src/editors/LevelEditor/Edit/ESceneCustomMToolsControls.cpp b/src/editors/LevelEditor/Edit/ESceneCustomMToolsControls.cpp index c9683d33db6..62142c4bca8 100644 --- a/src/editors/LevelEditor/Edit/ESceneCustomMToolsControls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneCustomMToolsControls.cpp @@ -3,78 +3,86 @@ #include "ESceneCustomMTools.h" #include "ESceneControlsCustom.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" void ESceneToolBase::CreateDefaultControls(u32 sub_target_id) { - for (int a=0; a(sub_target_id,a,this)); + for (int a = 0; a(sub_target_id, a, this)); } void ESceneToolBase::RemoveControls() { // controls - for (ControlsIt it=m_Controls.begin(); it!=m_Controls.end(); it++) - xr_delete (*it); + for (ControlsIt it = m_Controls.begin(); it!=m_Controls.end(); it++) + xr_delete(*it); m_Controls.clear(); - xr_delete (pFrame); + xr_delete(pFrame); } -void ESceneToolBase::AddControl(TUI_CustomControl* c) +void ESceneToolBase::AddControl(TUI_CustomControl *c) { R_ASSERT(c); - for (ControlsIt it=m_Controls.begin(); it!=m_Controls.end(); it++){ - if (((*it)->sub_target==c->sub_target)&&((*it)->action==c->action)){ - xr_delete(*it); + for (ControlsIt it = m_Controls.begin(); it!=m_Controls.end(); it++) + { + if (((*it)->sub_target==c->sub_target)&&((*it)->action==c->action)) + { + xr_delete(*it); m_Controls.erase(it); - break; + break; } } m_Controls.push_back(c); } -TUI_CustomControl* ESceneToolBase::FindControl(int subtarget, int action) +TUI_CustomControl *ESceneToolBase::FindControl(int subtarget, int action) { - if (action==-1) return 0; - for (ControlsIt it=m_Controls.begin(); it!=m_Controls.end(); it++) - if (((*it)->sub_target==subtarget)&&((*it)->action==action)) return *it; + if (action==-1) + return 0; + for (ControlsIt it = m_Controls.begin(); it!=m_Controls.end(); it++) + if (((*it)->sub_target==subtarget)&&((*it)->action==action)) + return *it; return 0; } void ESceneToolBase::UpdateControl() { - if (pCurControl) pCurControl->OnExit(); - pCurControl=FindControl(sub_target,action); - if (pCurControl) pCurControl->OnEnter(); + if (pCurControl) + pCurControl->OnExit(); + pCurControl = FindControl(sub_target, action); + if (pCurControl) + pCurControl->OnEnter(); } -void ESceneToolBase::OnActivate () +void ESceneToolBase::OnActivate() { - if (pCurControl) pCurControl->OnEnter(); + if (pCurControl) + pCurControl->OnEnter(); - ExecCommand (COMMAND_CHANGE_ACTION,etaSelect,estDefault); - SetChanged (TRUE); + ExecCommand(COMMAND_CHANGE_ACTION, etaSelect,estDefault); + SetChanged(TRUE); } void ESceneToolBase::OnDeactivate() { - if (pCurControl) pCurControl->OnExit(); + if (pCurControl) + pCurControl->OnExit(); } -void ESceneToolBase::SetAction (int act) +void ESceneToolBase::SetAction(int act) { - action=act; + action = act; UpdateControl(); } void ESceneToolBase::SetSubTarget(int tgt) { - sub_target=tgt; + sub_target = tgt; UpdateControl(); } void ESceneToolBase::ResetSubTarget() { - SetSubTarget(estDefault); + SetSubTarget(estDefault); } diff --git a/src/editors/LevelEditor/Edit/ESceneCustomOTools.cpp b/src/editors/LevelEditor/Edit/ESceneCustomOTools.cpp index c05b63180d7..6c40fe8364f 100644 --- a/src/editors/LevelEditor/Edit/ESceneCustomOTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneCustomOTools.cpp @@ -2,324 +2,345 @@ #pragma hdrstop #include "ESceneCustomOTools.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "scene.h" #include "CustomObject.h" -ESceneCustomOTool::ESceneCustomOTool(ObjClassID cls):ESceneToolBase(cls) -{ -} +ESceneCustomOTool::ESceneCustomOTool(ObjClassID cls): ESceneToolBase(cls) {} + //---------------------------------------------------- -ESceneCustomOTool::~ESceneCustomOTool() -{ -} +ESceneCustomOTool::~ESceneCustomOTool() {} + //---------------------------------------------------- -void ESceneCustomOTool::UpdateSnapList() -{ -} +void ESceneCustomOTool::UpdateSnapList() {} + //---------------------------------------------------- -ObjectList* ESceneCustomOTool::GetSnapList() +ObjectList *ESceneCustomOTool::GetSnapList() { - return 0; + return 0; } + //---------------------------------------------------- -BOOL ESceneCustomOTool::_AppendObject(CCustomObject* object) +BOOL ESceneCustomOTool::_AppendObject(CCustomObject *object) { m_Objects.push_back(object); object->ParentTool = this; return TRUE; } + //---------------------------------------------------- -BOOL ESceneCustomOTool::_RemoveObject(CCustomObject* object) +BOOL ESceneCustomOTool::_RemoveObject(CCustomObject *object) { object->OnSceneRemove(); - m_Objects.remove(object); + m_Objects.remove(object); return FALSE; } + //---------------------------------------------------- void ESceneCustomOTool::Clear(bool bInternal) { - inherited::Clear (); - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) + inherited::Clear(); + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) { - (*it)->OnSceneRemove(); - xr_delete(*it); + (*it)->OnSceneRemove(); + xr_delete(*it); } m_Objects.clear(); } -BOOL ESceneCustomOTool::AllowMouseStart() +BOOL ESceneCustomOTool::AllowMouseStart() { - for(ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); ++it) + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); ++it) { - CCustomObject* CO = *it; - if(CO->Selected() && !CO->Editable() ) - return FALSE; + CCustomObject*CO = *it; + if (CO->Selected()&&!CO->Editable()) + return FALSE; } - + return TRUE; } void ESceneCustomOTool::OnFrame() { - ObjectList remove_objects; - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) + ObjectList remove_objects; + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) { - R_ASSERT (*it); - (*it)->OnFrame (); - if ((*it)->IsDeleted()) - remove_objects.push_back(*it); + R_ASSERT(*it); + (*it)->OnFrame(); + if ((*it)->IsDeleted()) + remove_objects.push_back(*it); } bool need_undo = remove_objects.size(); - while (!remove_objects.empty()){ - CCustomObject* O = remove_objects.back(); - Scene->RemoveObject (O,false,true); - xr_delete (O); + while (!remove_objects.empty()) + { + CCustomObject*O = remove_objects.back(); + Scene->RemoveObject(O, false, true); + xr_delete(O); remove_objects.pop_back(); } - if (need_undo) Scene->UndoSave(); + if (need_undo) + Scene->UndoSave(); } + //---------------------------------------------------- void ESceneCustomOTool::OnRender(int priority, bool strictB2F) { -// for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) -// (*it)->Render(priority,strictB2F); + // for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) + // (*it)->Render(priority,strictB2F); } + //---------------------------------------------------- void ESceneCustomOTool::OnSynchronize() { - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) - (*it)->OnSynchronize(); + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) + (*it)->OnSynchronize(); } + //---------------------------------------------------- void ESceneCustomOTool::OnSceneUpdate() { - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) - (*it)->OnSceneUpdate(); + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) + (*it)->OnSceneUpdate(); } + //---------------------------------------------------- void ESceneCustomOTool::OnDeviceCreate() { - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) - (*it)->OnDeviceCreate(); + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) + (*it)->OnDeviceCreate(); } + //---------------------------------------------------- void ESceneCustomOTool::OnDeviceDestroy() { - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) - (*it)->OnDeviceDestroy(); + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) + (*it)->OnDeviceDestroy(); } + //---------------------------------------------------- bool ESceneCustomOTool::Validate(bool) { - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) - if (!(*it)->Validate(true)) return false; + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) + if (!(*it)->Validate(true)) + return false; return true; } bool ESceneCustomOTool::Valid() { - return true; + return true; } bool ESceneCustomOTool::IsNeedSave() { - return !m_Objects.empty(); + return !m_Objects.empty(); } -void ESceneCustomOTool::OnObjectRemove(CCustomObject* O, bool bDeleting) +void ESceneCustomOTool::OnObjectRemove(CCustomObject *O, bool bDeleting) { - for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++) + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) (*_F)->OnObjectRemove(O); } void ESceneCustomOTool::SelectObjects(bool flag) { - for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++) - if((*_F)->Visible()){ - (*_F)->Select( flag ); + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) + if ((*_F)->Visible()) + { + (*_F)->Select(flag); } - UI->RedrawScene (); + UI->RedrawScene(); } void ESceneCustomOTool::RemoveSelection() { ObjectIt _F = m_Objects.begin(); - while(_F!=m_Objects.end()) + while (_F!=m_Objects.end()) { - if((*_F)->Selected() && !(*_F)->m_CO_Flags.test(CCustomObject::flObjectInGroup)) + if ((*_F)->Selected()&&!(*_F)->m_CO_Flags.test(CCustomObject::flObjectInGroup)) { if ((*_F)->OnSelectionRemove()) { - ObjectIt _D = _F; _F++; - CCustomObject* obj = *_D; - Scene->RemoveObject (obj,false,true); - xr_delete (obj); - }else{ + ObjectIt _D = _F; _F++; + CCustomObject*obj = *_D; + Scene->RemoveObject(obj, false, true); + xr_delete(obj); } - }else{ + else + { + _F++; + } + } + else + { _F++; } } - UI->RedrawScene (); + UI->RedrawScene(); } void ESceneCustomOTool::InvertSelection() { - for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++) - if((*_F)->Visible()){ + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) + if ((*_F)->Visible()) + { (*_F)->Select(-1); } - - UI->RedrawScene (); + + UI->RedrawScene(); } int ESceneCustomOTool::SelectionCount(bool testflag) { - int count = 0; + int count = 0; + + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) + if ((*_F)->Visible()&&((*_F)->Selected()==testflag)) + count++; - for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++) - if((*_F)->Visible() && ((*_F)->Selected() == testflag)) count++; - return count; } void ESceneCustomOTool::ShowObjects(bool flag, bool bAllowSelectionFlag, bool bSelFlag) { - for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++){ - if (bAllowSelectionFlag){ - if ((*_F)->Selected()==bSelFlag){ - (*_F)->Show( flag ); + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) + { + if (bAllowSelectionFlag) + { + if ((*_F)->Selected()==bSelFlag) + { + (*_F)->Show(flag); } - }else{ - (*_F)->Show( flag ); + } + else + { + (*_F)->Show(flag); } } UI->RedrawScene(); } -BOOL ESceneCustomOTool::RayPick(CCustomObject*& object, float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf) +BOOL ESceneCustomOTool::RayPick(CCustomObject *&object, float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf) { - object = 0; - for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++) - if((*_F)->Visible()&&(*_F)->RayPick(distance,start,direction,pinf)) - object=*_F; - return !!object; + object = 0; + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) + if ((*_F)->Visible()&&(*_F)->RayPick(distance, start, direction, pinf)) + object = *_F; + return !!object; } -BOOL ESceneCustomOTool::FrustumPick(ObjectList& lst, const CFrustum& frustum) +BOOL ESceneCustomOTool::FrustumPick(ObjectList &lst, const CFrustum &frustum) { - for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++) - if((*_F)->Visible()&&(*_F)->FrustumPick(frustum)) - lst.push_back(*_F); - return !lst.empty(); + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) + if ((*_F)->Visible()&&(*_F)->FrustumPick(frustum)) + lst.push_back(*_F); + return !lst.empty(); } -BOOL ESceneCustomOTool::SpherePick(ObjectList& lst, const Fvector& center, float radius) +BOOL ESceneCustomOTool::SpherePick(ObjectList &lst, const Fvector ¢er, float radius) { - for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++) - if((*_F)->Visible()&&(*_F)->SpherePick(center, radius)) - lst.push_back(*_F); - return !lst.empty(); + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) + if ((*_F)->Visible()&&(*_F)->SpherePick(center, radius)) + lst.push_back(*_F); + return !lst.empty(); } -int ESceneCustomOTool::RaySelect(int flag, float& distance, const Fvector& start, const Fvector& direction, BOOL bDistanceOnly) +int ESceneCustomOTool::RaySelect(int flag, float &distance, const Fvector &start, const Fvector &direction, BOOL bDistanceOnly) { - CCustomObject* nearest_object=0; - if (RayPick(nearest_object,distance,start,direction,0)&&!bDistanceOnly) - nearest_object->RaySelect(flag,start,direction,false); -// nearest_object->Select(flag); + CCustomObject*nearest_object = 0; + if (RayPick(nearest_object, distance, start, direction, 0)&&!bDistanceOnly) + nearest_object->RaySelect(flag, start, direction, false); + // nearest_object->Select(flag); UI->RedrawScene(); return !!nearest_object; } -int ESceneCustomOTool::FrustumSelect(int flag, const CFrustum& frustum) +int ESceneCustomOTool::FrustumSelect(int flag, const CFrustum &frustum) { - ObjectList lst; + ObjectList lst; - FrustumPick(lst,frustum); - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) - (*_F)->Select(flag); - - return 0; + FrustumPick(lst, frustum); + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + (*_F)->Select(flag); + + return 0; } -int ESceneCustomOTool::GetQueryObjects(ObjectList& lst, int iSel, int iVis, int iLock) +int ESceneCustomOTool::GetQueryObjects(ObjectList &lst, int iSel, int iVis, int iLock) { - int count=0; - for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++) + int count = 0; + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) { - if( ((iSel==-1)||((*_F)->Selected()==iSel))&& - ((iVis==-1)||((*_F)->Visible()==iVis)) ) - { - lst.push_back(*_F); - count++; - } + if (((iSel==-1)||((*_F)->Selected()==iSel))&& + ((iVis==-1)||((*_F)->Visible()==iVis))) + { + lst.push_back(*_F); + count++; + } } return count; } -CCustomObject* ESceneCustomOTool::FindObjectByName(LPCSTR name, CCustomObject* pass) +CCustomObject *ESceneCustomOTool::FindObjectByName(LPCSTR name, CCustomObject *pass) { - ObjectIt _I = m_Objects.begin(); + ObjectIt _I = m_Objects.begin(); ObjectIt _E = m_Objects.end(); - for(;_I!=_E;_I++) + for (; _I!=_E; _I++) { - CCustomObject* CO = (*_I); - LPCSTR _name = CO->Name; - R_ASSERT (_name); - if((pass!=*_I) && (0==strcmp(_name,name)) ) - return (*_I); + CCustomObject*CO = (*_I); + LPCSTR _name = CO->Name; + R_ASSERT(_name); + if ((pass!=*_I)&&(0==strcmp(_name, name))) + return (*_I); } return 0; } -void setEditable(PropItemVec& items, u32 start_idx, bool bEditableTool, bool bObjectInGroup, bool bObjectInGroupUnique) +void setEditable(PropItemVec &items, u32 start_idx, bool bEditableTool, bool bObjectInGroup, bool bObjectInGroupUnique) { - PropItemIt it = items.begin()+start_idx; - PropItemIt it_e = items.end(); - u32 idx=0; - - bool bEditableObject = bEditableTool && (!bObjectInGroup || (bObjectInGroup&&bObjectInGroupUnique) ); - - for(; it!=it_e;++it,++idx) + PropItemIt it = items.begin()+start_idx; + PropItemIt it_e = items.end(); + u32 idx = 0; + + bool bEditableObject = bEditableTool&&(!bObjectInGroup||(bObjectInGroup&&bObjectInGroupUnique)); + + for (; it!=it_e; ++it,++idx) { - bool bEnabledItem = bEditableObject; - if(!bEnabledItem && idx==4 && bObjectInGroup) + bool bEnabledItem = bEditableObject; + if (!bEnabledItem&&idx==4&&bObjectInGroup) bEnabledItem = true; - - (*it)->Enable(bEnabledItem); + + (*it)->Enable(bEnabledItem); } } -void ESceneCustomOTool::FillProp(LPCSTR pref, PropItemVec& items) +void ESceneCustomOTool::FillProp(LPCSTR pref, PropItemVec &items) { - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) { if ((*it)->Selected()) { - u32 cnt = items.size(); - (*it)->FillProp (PrepareKey(pref,"Items").c_str(), items); + (*it)->FillProp(PrepareKey(pref, "Items").c_str(), items); - setEditable ( items, - cnt, - IsEditable(), - (*it)->m_CO_Flags.test(CCustomObject::flObjectInGroup), - (*it)->m_CO_Flags.test(CCustomObject::flObjectInGroupUnique)); + setEditable(items, + cnt, + IsEditable(), + (*it)->m_CO_Flags.test(CCustomObject::flObjectInGroup), + (*it)->m_CO_Flags.test(CCustomObject::flObjectInGroupUnique)); } } } @@ -330,65 +351,68 @@ void ESceneCustomOTool::FillProp(LPCSTR pref, PropItemVec& items) for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); ++it) { if ((*it)->Selected()) - (*it)->FillProp (PrepareKey(pref,"Items").c_str(), items); + (*it)->FillProp(PrepareKey(pref,"Items").c_str(), items); } } */ -bool ESceneCustomOTool::GetSummaryInfo(SSceneSummary* inf) +bool ESceneCustomOTool::GetSummaryInfo(SSceneSummary *inf) { - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) - (*it)->GetSummaryInfo(inf); + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) + (*it)->GetSummaryInfo(inf); return true; } -void ESceneCustomOTool::GetBBox(Fbox& BB, bool bSelOnly) +void ESceneCustomOTool::GetBBox(Fbox &BB, bool bSelOnly) { - Fbox bb; + Fbox bb; ObjectList lst; - if (GetQueryObjects(lst, bSelOnly, true, -1)){ - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) - if ((*_F)->GetBox(bb)) BB.merge(bb); + if (GetQueryObjects(lst, bSelOnly, true, -1)) + { + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + if ((*_F)->GetBox(bb)) + BB.merge(bb); } } int ESceneCustomOTool::MultiRenameObjects() { - int cnt = 0; - for (ObjectIt o_it=m_Objects.begin(); o_it!=m_Objects.end(); o_it++){ - CCustomObject* obj = *o_it; - if (obj->Selected()){ - string256 buf; - Scene->GenObjectName(obj->ClassID,buf,obj->RefName()); - if (obj->Name!=buf){ - obj->Name = buf; - cnt++; + int cnt = 0; + for (ObjectIt o_it = m_Objects.begin(); o_it!=m_Objects.end(); o_it++) + { + CCustomObject*obj = *o_it; + if (obj->Selected()) + { + string256 buf; + Scene->GenObjectName(obj->ClassID, buf, obj->RefName()); + if (obj->Name!=buf) + { + obj->Name = buf; + cnt++; } } } return cnt; } -void ESceneCustomOTool::OnSelected(CCustomObject* object) +void ESceneCustomOTool::OnSelected(CCustomObject *object) { - for (ObjectIt o_it=m_Objects.begin(); o_it!=m_Objects.end(); ++o_it) + for (ObjectIt o_it = m_Objects.begin(); o_it!=m_Objects.end(); ++o_it) { - CCustomObject* obj = *o_it; - obj->m_RT_Flags.set(CCustomObject::flRT_SelectedLast, FALSE); - } + CCustomObject*obj = *o_it; + obj->m_RT_Flags.set(CCustomObject::flRT_SelectedLast, FALSE); + } object->m_RT_Flags.set(CCustomObject::flRT_SelectedLast, TRUE); } -const CCustomObject* ESceneCustomOTool::LastSelected() const +const CCustomObject *ESceneCustomOTool::LastSelected() const { - for (ObjectList::const_iterator o_it=m_Objects.begin(); o_it!=m_Objects.end(); ++o_it) + for (ObjectList::const_iterator o_it = m_Objects.begin(); o_it!=m_Objects.end(); ++o_it) { - const CCustomObject* obj = *o_it; - if(obj->m_RT_Flags.test(CCustomObject::flRT_SelectedLast)) - return obj; - } + const CCustomObject *obj = *o_it; + if (obj->m_RT_Flags.test(CCustomObject::flRT_SelectedLast)) + return obj; + } return NULL; } - - diff --git a/src/editors/LevelEditor/Edit/ESceneCustomOTools.h b/src/editors/LevelEditor/Edit/ESceneCustomOTools.h index 5f573648b4a..0e2f1a4f860 100644 --- a/src/editors/LevelEditor/Edit/ESceneCustomOTools.h +++ b/src/editors/LevelEditor/Edit/ESceneCustomOTools.h @@ -5,95 +5,114 @@ struct SRayPickInfo; struct mesh_build_data; + class ESceneCustomOTool: public ESceneToolBase { - typedef ESceneToolBase inherited; + typedef ESceneToolBase inherited; protected: - ObjectList m_Objects; - - bool OnLoadSelectionAppendObject(CCustomObject* obj); - bool OnLoadAppendObject (CCustomObject* obj); + ObjectList m_Objects; + + bool OnLoadSelectionAppendObject(CCustomObject *obj); + bool OnLoadAppendObject(CCustomObject *obj); public: - ESceneCustomOTool (ObjClassID cls); - virtual ~ESceneCustomOTool (); - - virtual bool AllowEnabling (){return true;} - virtual BOOL AllowMouseStart (); + ESceneCustomOTool(ObjClassID cls); + virtual ~ESceneCustomOTool(); + + virtual bool AllowEnabling() + { + return true; + } + + virtual BOOL AllowMouseStart(); // snap - virtual ObjectList* GetSnapList (); - virtual void UpdateSnapList (); - - // selection manipulate - virtual int RaySelect (int flag, float& distance, const Fvector& start, const Fvector& direction, BOOL bDistanceOnly); - virtual int FrustumSelect (int flag, const CFrustum& frustum); - virtual void SelectObjects (bool flag); - virtual void InvertSelection (); - virtual void RemoveSelection (); - virtual int SelectionCount (bool testflag); - virtual void ShowObjects (bool flag, bool bAllowSelectionFlag=false, bool bSelFlag=true); - - virtual void Clear (bool bSpecific=false)=0; + virtual ObjectList *GetSnapList(); + virtual void UpdateSnapList(); + + // selection manipulate + virtual int RaySelect(int flag, float &distance, const Fvector &start, const Fvector &direction, BOOL bDistanceOnly); + virtual int FrustumSelect(int flag, const CFrustum &frustum); + virtual void SelectObjects(bool flag); + virtual void InvertSelection(); + virtual void RemoveSelection(); + virtual int SelectionCount(bool testflag); + virtual void ShowObjects(bool flag, bool bAllowSelectionFlag = false, bool bSelFlag = true); + + virtual void Clear(bool bSpecific = false) =0; // validation - virtual bool Valid (); - virtual bool Validate (bool); + virtual bool Valid(); + virtual bool Validate(bool); // events - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); - virtual void OnSynchronize (); - virtual void OnSceneUpdate (); - virtual void OnObjectRemove (CCustomObject* O, bool bDeleting); + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); + virtual void OnSynchronize(); + virtual void OnSceneUpdate(); + virtual void OnObjectRemove(CCustomObject *O, bool bDeleting); + + virtual void OnBeforeObjectChange(CCustomObject *O) + { + inherited::OnBeforeObjectChange(O); + } - virtual void OnBeforeObjectChange (CCustomObject* O){inherited::OnBeforeObjectChange(O);} - virtual void OnFrame (); - virtual void OnRender (int priority, bool strictB2F); + virtual void OnFrame(); + virtual void OnRender(int priority, bool strictB2F); // IO - virtual bool IsNeedSave ()=0; + virtual bool IsNeedSave() =0; - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); - virtual bool Export (LPCSTR path); - virtual bool ExportGame (SExportStreams* F); - virtual bool ExportStatic (SceneBuilder* B, bool b_selected_only); - virtual bool GetStaticCformData ( mesh_build_data &data, bool b_selected_only ); + virtual bool Export(LPCSTR path); + virtual bool ExportGame(SExportStreams *F); + virtual bool ExportStatic(SceneBuilder *B, bool b_selected_only); + virtual bool GetStaticCformData(mesh_build_data &data, bool b_selected_only); // properties - virtual void FillProp (LPCSTR pref, PropItemVec& items); + virtual void FillProp(LPCSTR pref, PropItemVec &items); // utils - virtual bool GetSummaryInfo (SSceneSummary* inf); - virtual void GetBBox (Fbox& bb, bool bSelOnly); + virtual bool GetSummaryInfo(SSceneSummary *inf); + virtual void GetBBox(Fbox &bb, bool bSelOnly); //-------------------------------------------------------------------------- // object part //-------------------------------------------------------------------------- - IC ObjectList& GetObjects (){return m_Objects;} - IC int ObjCount (){return m_Objects.size();} + IC ObjectList&GetObjects() + { + return m_Objects; + } + + IC - virtual BOOL _AppendObject (CCustomObject* object); - virtual BOOL _RemoveObject (CCustomObject* object); + int ObjCount() + { + return m_Objects.size(); + } + + virtual BOOL _AppendObject(CCustomObject *object); + virtual BOOL _RemoveObject(CCustomObject *object); // pick function - virtual BOOL RayPick (CCustomObject*& object, float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf); - virtual BOOL FrustumPick (ObjectList& lst, const CFrustum& frustum); - virtual BOOL SpherePick (ObjectList& lst, const Fvector& center, float radius); - virtual int GetQueryObjects (ObjectList& lst, int iSel, int iVis, int iLock); + virtual BOOL RayPick(CCustomObject *&object, float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf); + virtual BOOL FrustumPick(ObjectList &lst, const CFrustum &frustum); + virtual BOOL SpherePick(ObjectList &lst, const Fvector ¢er, float radius); + virtual int GetQueryObjects(ObjectList &lst, int iSel, int iVis, int iLock); - virtual CCustomObject* FindObjectByName (LPCSTR name, CCustomObject* pass=0); + virtual CCustomObject *FindObjectByName(LPCSTR name, CCustomObject *pass = 0); - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name)=0; + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name) =0; - virtual int MultiRenameObjects (); - void OnSelected (CCustomObject* object); - virtual const CCustomObject* LastSelected () const; + virtual int MultiRenameObjects(); + void OnSelected(CCustomObject *object); + virtual const CCustomObject *LastSelected() const; }; #endif // ESceneCustomOToolsH + diff --git a/src/editors/LevelEditor/Edit/ESceneCustomOToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneCustomOToolsIO.cpp index af35cdd270e..98ac9226686 100644 --- a/src/editors/LevelEditor/Edit/ESceneCustomOToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneCustomOToolsIO.cpp @@ -3,180 +3,192 @@ #include "ESceneCustomOTools.h" #include "scene.h" -#include "../ECore/Editor/ui_main.h" -#include "builder.h" +#include "editors/ECore/Editor/ui_main.h" +#include "Builder.h" #include "CustomObject.h" // chunks //---------------------------------------------------- -static const u32 CHUNK_VERSION = 0x0001; -static const u32 CHUNK_OBJECT_COUNT = 0x0002; -static const u32 CHUNK_OBJECTS = 0x0003; -static const u32 CHUNK_FLAGS = 0x0004; +static const u32 CHUNK_VERSION = 0x0001; +static const u32 CHUNK_OBJECT_COUNT = 0x0002; +static const u32 CHUNK_OBJECTS = 0x0003; +static const u32 CHUNK_FLAGS = 0x0004; + //---------------------------------------------------- -bool ESceneCustomOTool::OnLoadSelectionAppendObject(CCustomObject* obj) +bool ESceneCustomOTool::OnLoadSelectionAppendObject(CCustomObject *obj) { - string256 buf; - Scene->GenObjectName (obj->ClassID,buf,obj->Name); - obj->Name = buf; - Scene->AppendObject (obj, false); - return true; + string256 buf; + Scene->GenObjectName(obj->ClassID, buf, obj->Name); + obj->Name = buf; + Scene->AppendObject(obj, false); + return true; } + //---------------------------------------------------- -bool ESceneCustomOTool::OnLoadAppendObject(CCustomObject* O) +bool ESceneCustomOTool::OnLoadAppendObject(CCustomObject *O) { - Scene->AppendObject (O,false); + Scene->AppendObject(O, false); return true; } + //---------------------------------------------------- -bool ESceneCustomOTool::LoadSelection(IReader& F) +bool ESceneCustomOTool::LoadSelection(IReader &F) { - int count = 0; - F.r_chunk (CHUNK_OBJECT_COUNT,&count); + int count = 0; + F.r_chunk(CHUNK_OBJECT_COUNT, &count); - SPBItem* pb = UI->ProgressStart(count,AnsiString().sprintf("Loading %s(stream)...",ClassDesc()).c_str()); - Scene->ReadObjectsStream (F,CHUNK_OBJECTS,OnLoadSelectionAppendObject,pb); - UI->ProgressEnd (pb); + SPBItem *pb = UI->ProgressStart(count, AnsiString().sprintf("Loading %s(stream)...", ClassDesc()).c_str()); + Scene->ReadObjectsStream(F, CHUNK_OBJECTS, OnLoadSelectionAppendObject, pb); + UI->ProgressEnd(pb); return true; } + //---------------------------------------------------- -void ESceneCustomOTool::SaveSelection(IWriter& F) +void ESceneCustomOTool::SaveSelection(IWriter &F) { - F.open_chunk (CHUNK_OBJECTS); - int count = 0; - for(ObjectIt it = m_Objects.begin();it!=m_Objects.end();++it) + F.open_chunk(CHUNK_OBJECTS); + int count = 0; + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); ++it) { - if ((*it)->Selected() && !(*it)->IsDeleted()) + if ((*it)->Selected()&&!(*it)->IsDeleted()) { - F.open_chunk(count++); - Scene->SaveObjectStream(*it,F); - F.close_chunk(); + F.open_chunk(count++); + Scene->SaveObjectStream(*it, F); + F.close_chunk(); } } - F.close_chunk (); + F.close_chunk(); - F.w_chunk (CHUNK_OBJECT_COUNT,&count,sizeof(count)); + F.w_chunk(CHUNK_OBJECT_COUNT, &count, sizeof(count)); } + //---------------------------------------------------- -bool ESceneCustomOTool::LoadLTX(CInifile& ini) +bool ESceneCustomOTool::LoadLTX(CInifile &ini) { - inherited::LoadLTX (ini); + inherited::LoadLTX(ini); - u32 count = ini.r_u32("main", "objects_count"); + u32 count = ini.r_u32("main", "objects_count"); - SPBItem* pb = UI->ProgressStart(count,AnsiString().sprintf("Loading %s(ltx)...",ClassDesc()).c_str()); + SPBItem *pb = UI->ProgressStart(count, AnsiString().sprintf("Loading %s(ltx)...", ClassDesc()).c_str()); - u32 i = 0; - string128 buff; + u32 i = 0; + string128 buff; - for(i=0; iReadObjectLTX(ini, buff, obj) ) - { - if (!OnLoadAppendObject(obj)) - xr_delete(obj); - } - pb->Inc(); - } + for (i = 0; iReadObjectLTX(ini, buff, obj)) + { + if (!OnLoadAppendObject(obj)) + xr_delete(obj); + } + pb->Inc(); + } - UI->ProgressEnd (pb); + UI->ProgressEnd(pb); return true; } -bool ESceneCustomOTool::LoadStream(IReader& F) +bool ESceneCustomOTool::LoadStream(IReader &F) { - inherited::LoadStream (F); + inherited::LoadStream(F); - int count = 0; - F.r_chunk (CHUNK_OBJECT_COUNT,&count); + int count = 0; + F.r_chunk(CHUNK_OBJECT_COUNT, &count); - SPBItem* pb = UI->ProgressStart(count,AnsiString().sprintf("Loading %s...",ClassDesc()).c_str()); - Scene->ReadObjectsStream (F,CHUNK_OBJECTS,OnLoadAppendObject,pb); - UI->ProgressEnd (pb); + SPBItem *pb = UI->ProgressStart(count, AnsiString().sprintf("Loading %s...", ClassDesc()).c_str()); + Scene->ReadObjectsStream(F, CHUNK_OBJECTS, OnLoadAppendObject, pb); + UI->ProgressEnd(pb); return true; } + //---------------------------------------------------- -void ESceneCustomOTool::SaveLTX(CInifile& ini, int id) +void ESceneCustomOTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); - - u32 count = 0; - for(ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); ++it) - { - CCustomObject* O = (*it); - if(O->save_id!=id) - continue; - - if (O->IsDeleted() || O->m_CO_Flags.test(CCustomObject::flObjectInGroup) ) - continue; - - string128 buff; - sprintf (buff,"object_%d",count); - Scene->SaveObjectLTX (*it, buff, ini); + inherited::SaveLTX(ini, id); + + u32 count = 0; + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); ++it) + { + CCustomObject*O = (*it); + if (O->save_id!=id) + continue; + + if (O->IsDeleted()||O->m_CO_Flags.test(CCustomObject::flObjectInGroup)) + continue; + + string128 buff; + sprintf(buff, "object_%d", count); + Scene->SaveObjectLTX(*it, buff, ini); count++; - } + } - ini.w_u32 ("main", "objects_count", count); + ini.w_u32("main", "objects_count", count); } -void ESceneCustomOTool::SaveStream(IWriter& F) +void ESceneCustomOTool::SaveStream(IWriter &F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - int Objcount = 0; + int Objcount = 0; - F.open_chunk (CHUNK_OBJECTS); - int count = 0; - for(ObjectIt it = m_Objects.begin();it!=m_Objects.end();++it) - { - if ( (*it)->IsDeleted() || (*it)->m_CO_Flags.test(CCustomObject::flObjectInGroup) ) - continue; + F.open_chunk(CHUNK_OBJECTS); + int count = 0; + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); ++it) + { + if ((*it)->IsDeleted()||(*it)->m_CO_Flags.test(CCustomObject::flObjectInGroup)) + continue; - F.open_chunk (count++); - Scene->SaveObjectStream (*it,F); - F.close_chunk (); + F.open_chunk(count++); + Scene->SaveObjectStream(*it, F); + F.close_chunk(); } - F.close_chunk (); + F.close_chunk(); - F.w_chunk (CHUNK_OBJECT_COUNT,&Objcount,sizeof(Objcount)); + F.w_chunk(CHUNK_OBJECT_COUNT, &Objcount, sizeof(Objcount)); } + //---------------------------------------------------- bool ESceneCustomOTool::Export(LPCSTR path) { - return true; + return true; } + //---------------------------------------------------- - -bool ESceneCustomOTool::ExportGame(SExportStreams* F) + +bool ESceneCustomOTool::ExportGame(SExportStreams *F) { - bool bres=true; - for(ObjectIt it = m_Objects.begin();it!=m_Objects.end();it++) - if (!(*it)->ExportGame(F)) bres=false; - return bres; + bool bres = true; + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) + if (!(*it)->ExportGame(F)) + bres = false; + return bres; } + //---------------------------------------------------- -bool ESceneCustomOTool::ExportStatic(SceneBuilder* B, bool b_selected_only) +bool ESceneCustomOTool::ExportStatic(SceneBuilder *B, bool b_selected_only) { - return B->ParseStaticObjects(m_Objects, NULL, b_selected_only); + return B->ParseStaticObjects(m_Objects, NULL, b_selected_only); } - BOOL GetStaticCformData ( ObjectList& lst, mesh_build_data &data, bool b_selected_only ); -bool ESceneCustomOTool::GetStaticCformData( mesh_build_data &data, bool b_selected_only ) //b_vertex* verts, int& vert_cnt, int& vert_it,b_face* faces, int& face_cnt, int& face_it, + +BOOL GetStaticCformData(ObjectList &lst, mesh_build_data &data, bool b_selected_only); + +bool ESceneCustomOTool::GetStaticCformData(mesh_build_data &data, bool b_selected_only) //b_vertex* verts, int& vert_cnt, int& vert_it,b_face* faces, int& face_cnt, int& face_it, { - return ::GetStaticCformData( m_Objects, data, b_selected_only ); + return ::GetStaticCformData(m_Objects, data, b_selected_only); } + //---------------------------------------------------- - + + diff --git a/src/editors/LevelEditor/Edit/ESceneDOTools.cpp b/src/editors/LevelEditor/Edit/ESceneDOTools.cpp index 3b04f67763b..a129b95094a 100644 --- a/src/editors/LevelEditor/Edit/ESceneDOTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneDOTools.cpp @@ -3,551 +3,620 @@ #pragma hdrstop #include "ESceneDOTools.h" -#include "../ECore/Editor/EditMesh.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Engine/Texture.h" +#include "editors/ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Engine/Texture.h" #include "Scene.h" #include "SceneObject.h" -#include "leftbar.h" +#include "LeftBar.h" #include "cl_intersect.h" -#include "../ECore/Editor/Library.h" -#include "ui_levelmain.h" +#include "editors/ECore/Editor/Library.h" +#include "UI_LevelMain.h" #include "..\..\Layers\xrRender\DetailFormat.h" -#include "bottombar.h" -#include "../ECore/Editor/ImageManager.h" +#include "BottomBar.h" +#include "editors/ECore/Editor/ImageManager.h" #include "../ECORE/Editor/D3DUtils.h" static const u32 DETMGR_VERSION = 0x0003ul; + //------------------------------------------------------------------------------ -enum{ - DETMGR_CHUNK_VERSION = 0x1000ul, - DETMGR_CHUNK_HEADER = 0x0000ul, - DETMGR_CHUNK_OBJECTS = 0x0001ul, - DETMGR_CHUNK_SLOTS = 0x0002ul, - DETMGR_CHUNK_BBOX = 0x1001ul, - DETMGR_CHUNK_BASE_TEXTURE = 0x1002ul, - DETMGR_CHUNK_COLOR_INDEX = 0x1003ul, - DETMGR_CHUNK_SNAP_OBJECTS = 0x1004ul, - DETMGR_CHUNK_DENSITY = 0x1005ul, - DETMGR_CHUNK_FLAGS = 0x1006ul, +enum +{ + DETMGR_CHUNK_VERSION = 0x1000ul, + DETMGR_CHUNK_HEADER = 0x0000ul, + DETMGR_CHUNK_OBJECTS = 0x0001ul, + DETMGR_CHUNK_SLOTS = 0x0002ul, + DETMGR_CHUNK_BBOX = 0x1001ul, + DETMGR_CHUNK_BASE_TEXTURE = 0x1002ul, + DETMGR_CHUNK_COLOR_INDEX = 0x1003ul, + DETMGR_CHUNK_SNAP_OBJECTS = 0x1004ul, + DETMGR_CHUNK_DENSITY = 0x1005ul, + DETMGR_CHUNK_FLAGS = 0x1006ul, }; + //---------------------------------------------------- //------------------------------------------------------------------------------ -EDetailManager::EDetailManager():ESceneToolBase(OBJCLASS_DO) +EDetailManager::EDetailManager(): ESceneToolBase(OBJCLASS_DO) { - dtSlots = 0; - ZeroMemory (&dtH,sizeof(dtH)); - m_Selected.clear (); - InitRender (); -//. EDevice.seqDevCreate.Add (this,REG_PRIORITY_LOW); -//. EDevice.seqDevDestroy.Add(this,REG_PRIORITY_NORMAL); - m_Flags.assign (flObjectsDraw); + dtSlots = 0; + ZeroMemory(&dtH, sizeof(dtH)); + m_Selected.clear(); + InitRender(); + //. EDevice.seqDevCreate.Add(this,REG_PRIORITY_LOW); + //. EDevice.seqDevDestroy.Add(this,REG_PRIORITY_NORMAL); + m_Flags.assign(flObjectsDraw); } -EDetailManager::~EDetailManager(){ -//. EDevice.seqDevCreate.Remove(this); -//. EDevice.seqDevDestroy.Remove(this); - Clear (); - Unload (); +EDetailManager::~EDetailManager() +{ + //. EDevice.seqDevCreate.Remove(this); + //. EDevice.seqDevDestroy.Remove(this); + Clear(); + Unload(); } + //------------------------------------------------------------------------------ void EDetailManager::ClearColorIndices() { - inherited::Clear (); - RemoveDOs (); + inherited::Clear(); + RemoveDOs(); m_ColorIndices.clear(); } + void EDetailManager::ClearSlots() { - ZeroMemory (&dtH,sizeof(DetailHeader)); - xr_free (dtSlots); - m_Selected.clear (); - InvalidateCache (); + ZeroMemory(&dtH, sizeof(DetailHeader)); + xr_free(dtSlots); + m_Selected.clear(); + InvalidateCache(); } + void EDetailManager::ClearBase() { - m_Base.Clear (); - m_SnapObjects.clear (); - ExecCommand (COMMAND_REFRESH_SNAP_OBJECTS); + m_Base.Clear(); + m_SnapObjects.clear(); + ExecCommand(COMMAND_REFRESH_SNAP_OBJECTS); } + void EDetailManager::Clear(bool bSpecific) { - ClearBase (); - ClearColorIndices (); - ClearSlots (); - m_Flags.zero (); - m_RTFlags.zero (); + ClearBase(); + ClearColorIndices(); + ClearSlots(); + m_Flags.zero(); + m_RTFlags.zero(); } + //------------------------------------------------------------------------------ void EDetailManager::InvalidateCache() { - // resize visible - m_visibles[0].resize (objects.size()); // dump(visible[0]); - m_visibles[1].resize (objects.size()); // dump(visible[1]); - m_visibles[2].resize (objects.size()); // dump(visible[2]); - // Initialize 'vis' and 'cache' - cache_Initialize (); + // resize visible + m_visibles[0].resize(objects.size()); // dump(visible[0]); + m_visibles[1].resize(objects.size()); // dump(visible[1]); + m_visibles[2].resize(objects.size()); // dump(visible[2]); + // Initialize 'vis' and 'cache' + cache_Initialize(); } -extern void bwdithermap (int levels, int magic[16][16] ); +extern void bwdithermap(int levels, int magic[16][16]); + void EDetailManager::InitRender() { - // inavlidate cache - InvalidateCache (); - // Make dither matrix - bwdithermap (2,dither); + // inavlidate cache + InvalidateCache(); + // Make dither matrix + bwdithermap(2, dither); - soft_Load (); + soft_Load(); } + //------------------------------------------------------------------------------ void EDetailManager::OnRender(int priority, bool strictB2F) { - if (dtSlots){ - if (1==priority){ - if (false==strictB2F){ - if (m_Flags.is(flSlotBoxesDraw)){ + if (dtSlots) + { + if (1==priority) + { + if (false==strictB2F) + { + if (m_Flags.is(flSlotBoxesDraw)) + { RCache.set_xform_world(Fidentity); - EDevice.SetShader (EDevice.m_WireShader); - - Fvector c; - Fbox bbox; - u32 inactive = 0xff808080; - u32 selected = 0xffffffff; - float dist_lim = 75.f*75.f; - for (u32 z=0; zr_ybase()+slot->r_yheight()*0.5f; //(slot->y_max+slot->y_min)*0.5f; + EDevice.SetShader(EDevice.m_WireShader); + + Fvector c; + Fbox bbox; + u32 inactive = 0xff808080; + u32 selected = 0xffffffff; + float dist_lim = 75.f*75.f; + for (u32 z = 0; zr_ybase()+slot->r_yheight()*0.5f; //(slot->y_max+slot->y_min)*0.5f; float dist = EDevice.m_Camera.GetPosition().distance_to_sqr(c); - if ((distViewBase.testSphere_dirty(c,DETAIL_SLOT_SIZE_2)){ - bbox.min.set(c.x-DETAIL_SLOT_SIZE_2, slot->r_ybase(), c.z-DETAIL_SLOT_SIZE_2); - bbox.max.set(c.x+DETAIL_SLOT_SIZE_2, slot->r_ybase()+slot->r_yheight(), c.z+DETAIL_SLOT_SIZE_2); - bbox.shrink (0.05f); - DU_impl.DrawSelectionBoxB(bbox,bSel?&selected:&inactive); - } + if ((distViewBase.testSphere_dirty(c,DETAIL_SLOT_SIZE_2)) + { + bbox.min.set(c.x-DETAIL_SLOT_SIZE_2, slot->r_ybase(), c.z-DETAIL_SLOT_SIZE_2); + bbox.max.set(c.x+DETAIL_SLOT_SIZE_2, slot->r_ybase()+slot->r_yheight(), c.z+DETAIL_SLOT_SIZE_2); + bbox.shrink(0.05f); + DU_impl.DrawSelectionBoxB(bbox, bSel ? &selected : &inactive); + } } } } - }else{ - RCache.set_xform_world (Fidentity); - if (m_Flags.is(flBaseTextureDraw)) m_Base.Render (m_Flags.is(flBaseTextureBlended)); - if (m_Flags.is(flObjectsDraw)) CDetailManager::Render (); + } + else + { + RCache.set_xform_world(Fidentity); + if (m_Flags.is(flBaseTextureDraw)) + m_Base.Render(m_Flags.is(flBaseTextureBlended)); + if (m_Flags.is(flObjectsDraw)) + CDetailManager::Render(); } } } } + //------------------------------------------------------------------------------ void EDetailManager::OnDeviceCreate() { - // base texture + // base texture m_Base.CreateShader(); - // detail objects - for (DetailIt it=objects.begin(); it!=objects.end(); it++) - ((EDetail*)(*it))->OnDeviceCreate(); - soft_Load (); + // detail objects + for (DetailIt it = objects.begin(); it!=objects.end(); it++) + ((EDetail*)(*it))->OnDeviceCreate(); + soft_Load(); } void EDetailManager::OnDeviceDestroy() { - // base texture + // base texture m_Base.DestroyShader(); - // detail objects - for (DetailIt it=objects.begin(); it!=objects.end(); it++) - ((EDetail*)(*it))->OnDeviceDestroy(); - soft_Unload (); + // detail objects + for (DetailIt it = objects.begin(); it!=objects.end(); it++) + ((EDetail*)(*it))->OnDeviceDestroy(); + soft_Unload(); } -void EDetailManager::OnObjectRemove(CCustomObject* O, bool bDeleting) +void EDetailManager::OnObjectRemove(CCustomObject *O, bool bDeleting) { - ObjectIt it=std::find(m_SnapObjects.begin(),m_SnapObjects.end(),O); - if (it!=m_SnapObjects.end()){ - m_RTFlags.set (flRTGenerateBaseMesh,TRUE); - m_SnapObjects.remove(O); + ObjectIt it = std::find(m_SnapObjects.begin(), m_SnapObjects.end(), O); + if (it!=m_SnapObjects.end()) + { + m_RTFlags.set(flRTGenerateBaseMesh, TRUE); + m_SnapObjects.remove(O); } } -void EDetailManager::OnSynchronize() -{ -} -void EDetailManager::OnSceneUpdate() -{ -} + +void EDetailManager::OnSynchronize() {} + +void EDetailManager::OnSceneUpdate() {} void EDetailManager::OnFrame() { - if (m_RTFlags.is(flRTGenerateBaseMesh)&&m_Base.Valid()){ - m_RTFlags.set (flRTGenerateBaseMesh,FALSE); - m_Base.CreateRMFromObjects(m_BBox,m_SnapObjects); + if (m_RTFlags.is(flRTGenerateBaseMesh)&&m_Base.Valid()) + { + m_RTFlags.set(flRTGenerateBaseMesh, FALSE); + m_Base.CreateRMFromObjects(m_BBox, m_SnapObjects); } } void EDetailManager::ExportColorIndices(LPCSTR fname) { - IWriter* F = FS.w_open(fname); - if (F){ - SaveColorIndices(*F); - FS.w_close (F); + IWriter *F = FS.w_open(fname); + if (F) + { + SaveColorIndices(*F); + FS.w_close(F); } } bool EDetailManager::ImportColorIndices(LPCSTR fname) { - IReader* F=FS.r_open(fname); - if (F){ - ClearColorIndices (); - LoadColorIndices (*F); - FS.r_close (F); + IReader *F = FS.r_open(fname); + if (F) + { + ClearColorIndices(); + LoadColorIndices(*F); + FS.r_close(F); return true; - }else{ - ELog.DlgMsg (mtError,"Can't open file '%s'.",fname); + } + else + { + ELog.DlgMsg(mtError, "Can't open file '%s'.", fname); return false; } } -void EDetailManager::SaveColorIndices(IWriter& F) +void EDetailManager::SaveColorIndices(IWriter &F) { - // objects - F.open_chunk (DETMGR_CHUNK_OBJECTS); - for (DetailIt it=objects.begin(); it!=objects.end(); it++){ - F.open_chunk (it-objects.begin()); - ((EDetail*)(*it))->Save (F); - F.close_chunk (); + // objects + F.open_chunk(DETMGR_CHUNK_OBJECTS); + for (DetailIt it = objects.begin(); it!=objects.end(); it++) + { + F.open_chunk(it-objects.begin()); + ((EDetail*)(*it))->Save(F); + F.close_chunk(); } - F.close_chunk (); + F.close_chunk(); // color index map - F.open_chunk (DETMGR_CHUNK_COLOR_INDEX); - F.w_u8 ((u8)m_ColorIndices.size()); - ColorIndexPairIt S = m_ColorIndices.begin(); - ColorIndexPairIt E = m_ColorIndices.end(); - ColorIndexPairIt i_it= S; - for(; i_it!=E; i_it++){ - F.w_u32 (i_it->first); - F.w_u8 ((u8)i_it->second.size()); - for (DOIt d_it=i_it->second.begin(); d_it!=i_it->second.end(); d_it++) - F.w_stringZ ((*d_it)->GetName()); + F.open_chunk(DETMGR_CHUNK_COLOR_INDEX); + F.w_u8((u8)m_ColorIndices.size()); + ColorIndexPairIt S = m_ColorIndices.begin(); + ColorIndexPairIt E = m_ColorIndices.end(); + ColorIndexPairIt i_it = S; + for (; i_it!=E; i_it++) + { + F.w_u32(i_it->first); + F.w_u8((u8)i_it->second.size()); + for (DOIt d_it = i_it->second.begin(); d_it!=i_it->second.end(); d_it++) + F.w_stringZ((*d_it)->GetName()); } - F.close_chunk (); + F.close_chunk(); } -bool EDetailManager::LoadColorIndices(IReader& F) +bool EDetailManager::LoadColorIndices(IReader &F) { - VERIFY (objects.empty()); - VERIFY (m_ColorIndices.empty()); + VERIFY(objects.empty()); + VERIFY(m_ColorIndices.empty()); - bool bRes = true; + bool bRes = true; // objects - IReader* OBJ = F.open_chunk(DETMGR_CHUNK_OBJECTS); - if (OBJ){ - IReader* O = OBJ->open_chunk(0); - for (int count=1; O; count++) { - EDetail* DO = xr_new(); - if (DO->Load(*O)) objects.push_back(DO); - else bRes = false; + IReader *OBJ = F.open_chunk(DETMGR_CHUNK_OBJECTS); + if (OBJ) + { + IReader *O = OBJ->open_chunk(0); + for (int count = 1; O; count++) + { + EDetail *DO = xr_new(); + if (DO->Load(*O)) + objects.push_back(DO); + else + bRes = false; O->close(); O = OBJ->open_chunk(count); } OBJ->close(); } // color index map - R_ASSERT (F.find_chunk(DETMGR_CHUNK_COLOR_INDEX)); - int cnt = F.r_u8(); - string256 buf; + R_ASSERT(F.find_chunk(DETMGR_CHUNK_COLOR_INDEX)); + int cnt = F.r_u8(); + string256 buf; u32 index; int ref_cnt; - for (int k=0; kName, NULL); -*/ + R_ASSERT2(0, "not_implemented"); + /* + inherited::SaveLTX(ini); + + ini.w_u32 ("main", "version", DETMGR_VERSION); + + ini.w_u32 ("main", "flags", m_Flags.get()); + + // header + + ini.w_u32 ("detail_header", "version", dtH.version); + ini.w_u32 ("detail_header", "object_count", dtH.object_count); + ini.w_ivector2 ("detail_header", "offset", Ivector2().set(dtH.offs_x, dtH.offs_z) ); + ini.w_ivector2 ("detail_header", "size", Ivector2().set(dtH.size_x, dtH.size_z) ); + + // objects + SaveColorIndicesLTX(F); + + // slots + F.open_chunk (DETMGR_CHUNK_SLOTS); + F.w_u32 (dtH.size_x*dtH.size_z); + F.w (dtSlots,dtH.size_x*dtH.size_z*sizeof(DetailSlot)); + F.close_chunk (); + + // internal + // bbox + ini.w_fvector3 ("main", "bbox_min", m_BBox.min); + ini.w_fvector3 ("main", "bbox_max", m_BBox.max); + + // base texture + if (m_Base.Valid()) + { + ini.w_string("main", "base_texture", m_Base.GetName()); + } + ini.w_float ("main", "detail_density", ps_r__Detail_density); + + // snap objects + for (ObjectIt o_it=m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); ++o_it) + ini.w_string("snap_objects", (*o_it)->Name, NULL); + */ } -bool EDetailManager::LoadStream(IReader& F) +bool EDetailManager::LoadStream(IReader &F) { - inherited::LoadStream (F); + inherited::LoadStream(F); string256 buf; - R_ASSERT (F.find_chunk(DETMGR_CHUNK_VERSION)); - u32 version = F.r_u32(); + R_ASSERT(F.find_chunk(DETMGR_CHUNK_VERSION)); + u32 version = F.r_u32(); - if (version!=DETMGR_VERSION){ - ELog.Msg(mtError,"EDetailManager: unsupported version."); + if (version!=DETMGR_VERSION) + { + ELog.Msg(mtError, "EDetailManager: unsupported version."); return false; } - if (F.find_chunk(DETMGR_CHUNK_FLAGS)) m_Flags.assign(F.r_u32()); - - // header - R_ASSERT (F.r_chunk(DETMGR_CHUNK_HEADER,&dtH)); + if (F.find_chunk(DETMGR_CHUNK_FLAGS)) + m_Flags.assign(F.r_u32()); + + // header + R_ASSERT(F.r_chunk(DETMGR_CHUNK_HEADER, &dtH)); // slots - R_ASSERT (F.find_chunk(DETMGR_CHUNK_SLOTS)); - int slot_cnt = F.r_u32(); - if (slot_cnt)dtSlots= xr_alloc(slot_cnt); - m_Selected.resize (slot_cnt); - F.r (dtSlots,slot_cnt*sizeof(DetailSlot)); + R_ASSERT(F.find_chunk(DETMGR_CHUNK_SLOTS)); + int slot_cnt = F.r_u32(); + if (slot_cnt) + dtSlots = xr_alloc(slot_cnt); + m_Selected.resize(slot_cnt); + F.r(dtSlots, slot_cnt*sizeof(DetailSlot)); // objects - if (!LoadColorIndices(F)){ - ELog.DlgMsg (mtError,"EDetailManager: Some objects removed. Reinitialize objects.",buf); - InvalidateSlots (); + if (!LoadColorIndices(F)) + { + ELog.DlgMsg(mtError, "EDetailManager: Some objects removed. Reinitialize objects.", buf); + InvalidateSlots(); } // internal // bbox - R_ASSERT (F.r_chunk(DETMGR_CHUNK_BBOX,&m_BBox)); - - // snap objects - if (F.find_chunk(DETMGR_CHUNK_SNAP_OBJECTS)){ - int snap_cnt = F.r_u32(); - if (snap_cnt){ - for (int i=0; iFindObjectByName(buf,OBJCLASS_SCENEOBJECT); - if (!O) ELog.Msg(mtError,"EDetailManager: Can't find snap object '%s'.",buf); - else m_SnapObjects.push_back(O); - } + R_ASSERT(F.r_chunk(DETMGR_CHUNK_BBOX, &m_BBox)); + + // snap objects + if (F.find_chunk(DETMGR_CHUNK_SNAP_OBJECTS)) + { + int snap_cnt = F.r_u32(); + if (snap_cnt) + { + for (int i = 0; iFindObjectByName(buf, OBJCLASS_SCENEOBJECT); + if (!O) + ELog.Msg(mtError, "EDetailManager: Can't find snap object '%s'.", buf); + else + m_SnapObjects.push_back(O); + } } } if (F.find_chunk(DETMGR_CHUNK_DENSITY)) - ps_r__Detail_density= F.r_float(); - - // base texture - if(F.find_chunk(DETMGR_CHUNK_BASE_TEXTURE)){ - F.r_stringZ (buf,sizeof(buf)); - if (m_Base.LoadImage(buf)){ - m_Base.CreateShader(); - m_RTFlags.set(flRTGenerateBaseMesh,TRUE); - }else{ - ELog.Msg(mtError,"EDetailManager: Can't find base texture '%s'.",buf); + ps_r__Detail_density = F.r_float(); + + // base texture + if (F.find_chunk(DETMGR_CHUNK_BASE_TEXTURE)) + { + F.r_stringZ(buf, sizeof(buf)); + if (m_Base.LoadImage(buf)) + { + m_Base.CreateShader(); + m_RTFlags.set(flRTGenerateBaseMesh, TRUE); + } + else + { + ELog.Msg(mtError, "EDetailManager: Can't find base texture '%s'.", buf); ClearSlots(); ClearBase(); } } - InvalidateCache (); + InvalidateCache(); return true; } -bool EDetailManager::LoadSelection(IReader& F) +bool EDetailManager::LoadSelection(IReader &F) { - Clear(); - return LoadStream (F); + Clear(); + return LoadStream(F); } -void EDetailManager::SaveStream(IWriter& F) +void EDetailManager::SaveStream(IWriter &F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - // version - F.open_chunk (DETMGR_CHUNK_VERSION); - F.w_u32 (DETMGR_VERSION); - F.close_chunk (); + // version + F.open_chunk(DETMGR_CHUNK_VERSION); + F.w_u32(DETMGR_VERSION); + F.close_chunk(); - F.open_chunk (DETMGR_CHUNK_FLAGS); - F.w_u32 (m_Flags.get()); - F.close_chunk (); + F.open_chunk(DETMGR_CHUNK_FLAGS); + F.w_u32(m_Flags.get()); + F.close_chunk(); - // header - F.w_chunk (DETMGR_CHUNK_HEADER,&dtH,sizeof(DetailHeader)); + // header + F.w_chunk(DETMGR_CHUNK_HEADER, &dtH, sizeof(DetailHeader)); // objects - SaveColorIndices (F); + SaveColorIndices(F); // slots - F.open_chunk (DETMGR_CHUNK_SLOTS); - F.w_u32 (dtH.size_x*dtH.size_z); - F.w (dtSlots,dtH.size_x*dtH.size_z*sizeof(DetailSlot)); - F.close_chunk (); + F.open_chunk(DETMGR_CHUNK_SLOTS); + F.w_u32(dtH.size_x*dtH.size_z); + F.w(dtSlots, dtH.size_x*dtH.size_z*sizeof(DetailSlot)); + F.close_chunk(); // internal // bbox - F.w_chunk (DETMGR_CHUNK_BBOX,&m_BBox,sizeof(Fbox)); - // base texture - if (m_Base.Valid()){ - F.open_chunk (DETMGR_CHUNK_BASE_TEXTURE); - F.w_stringZ (m_Base.GetName()); - F.close_chunk (); + F.w_chunk(DETMGR_CHUNK_BBOX, &m_BBox, sizeof(Fbox)); + // base texture + if (m_Base.Valid()) + { + F.open_chunk(DETMGR_CHUNK_BASE_TEXTURE); + F.w_stringZ(m_Base.GetName()); + F.close_chunk(); } - F.open_chunk (DETMGR_CHUNK_DENSITY); - F.w_float (ps_r__Detail_density); - F.close_chunk (); - // snap objects - F.open_chunk (DETMGR_CHUNK_SNAP_OBJECTS); - F.w_u32 (m_SnapObjects.size()); - for (ObjectIt o_it=m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); o_it++) - F.w_stringZ ((*o_it)->Name); - F.close_chunk (); + F.open_chunk(DETMGR_CHUNK_DENSITY); + F.w_float(ps_r__Detail_density); + F.close_chunk(); + // snap objects + F.open_chunk(DETMGR_CHUNK_SNAP_OBJECTS); + F.w_u32(m_SnapObjects.size()); + for (ObjectIt o_it = m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); o_it++) + F.w_stringZ((*o_it)->Name); + F.close_chunk(); } -void EDetailManager::SaveSelection(IWriter& F) +void EDetailManager::SaveSelection(IWriter &F) { - SaveStream(F); + SaveStream(F); } -bool EDetailManager::Export(LPCSTR path) +bool EDetailManager::Export(LPCSTR path) { - AnsiString fn = AnsiString(path)+"build.details"; - bool bRes=true; - - SPBItem* pb = UI->ProgressStart(5,"Making details..."); - CMemoryWriter F; - - pb->Inc ("merge textures"); - Fvector2Vec offsets; - Fvector2Vec scales; - boolVec rotated; - RStringSet textures_set; - RStringVec textures; - U32Vec remap; - U8Vec remap_object (objects.size(),u8(-1)); - - int slot_cnt = dtH.size_x*dtH.size_z; - for (int slot_idx=0; slot_idxr_id(part); - if (id!=DetailSlot::ID_Empty) { - textures_set.insert(((EDetail*)(objects[id]))->GetTextureName()); + AnsiString fn = AnsiString(path)+"build.details"; + bool bRes = true; + + SPBItem *pb = UI->ProgressStart(5, "Making details..."); + CMemoryWriter F; + + pb->Inc("merge textures"); + Fvector2Vec offsets; + Fvector2Vec scales; + boolVec rotated; + RStringSet textures_set; + RStringVec textures; + U32Vec remap; + U8Vec remap_object(objects.size(), u8(-1)); + + int slot_cnt = dtH.size_x*dtH.size_z; + for (int slot_idx = 0; slot_idxr_id(part); + if (id!=DetailSlot::ID_Empty) + { + textures_set.insert(((EDetail*)(objects[id]))->GetTextureName()); remap_object[id] = 1; } } } - textures.assign (textures_set.begin(),textures_set.end()); + textures.assign(textures_set.begin(), textures_set.end()); - U8It remap_object_it= remap_object.begin(); + U8It remap_object_it = remap_object.begin(); - u32 new_idx = 0; - for (DetailIt d_it=objects.begin(); d_it!=objects.end(); d_it++,remap_object_it++) - if ((*remap_object_it==1)&&(textures_set.find(((EDetail*)(*d_it))->GetTextureName())!=textures_set.end())) - *remap_object_it = (u8)new_idx++; + u32 new_idx = 0; + for (DetailIt d_it = objects.begin(); d_it!=objects.end(); d_it++,remap_object_it++) + if ((*remap_object_it==1)&&(textures_set.find(((EDetail*)(*d_it))->GetTextureName())!=textures_set.end())) + *remap_object_it = (u8)new_idx++; - AnsiString do_tex_name = ChangeFileExt(fn,"_details"); - int res = ImageLib.CreateMergedTexture(textures,do_tex_name.c_str(),STextureParams::tfADXT1,256,1024,256,1024,offsets,scales,rotated,remap); - if (1!=res) bRes=FALSE; + AnsiString do_tex_name = ChangeFileExt(fn, "_details"); + int res = ImageLib.CreateMergedTexture(textures, do_tex_name.c_str(), STextureParams::tfADXT1, 256, 1024, 256, 1024, offsets, scales, rotated, remap); + if (1!=res) + bRes = FALSE; - pb->Inc ("export geometry"); + pb->Inc("export geometry"); // objects - int object_idx = 0; - if (bRes){ - do_tex_name = ExtractFileName(do_tex_name); - F.open_chunk (DETMGR_CHUNK_OBJECTS); - for (DetailIt it=objects.begin(); it!=objects.end(); it++){ - if (remap_object[it-objects.begin()]!=u8(-1)){ - F.open_chunk (object_idx++); - if (!((EDetail*)(*it))->m_pRefs){ + int object_idx = 0; + if (bRes) + { + do_tex_name = ExtractFileName(do_tex_name); + F.open_chunk(DETMGR_CHUNK_OBJECTS); + for (DetailIt it = objects.begin(); it!=objects.end(); it++) + { + if (remap_object[it-objects.begin()]!=u8(-1)) + { + F.open_chunk(object_idx++); + if (!((EDetail*)(*it))->m_pRefs) + { ELog.DlgMsg(mtError, "Bad object or object not found '%s'.", ((EDetail*)(*it))->m_sRefs.c_str()); - bRes=false; - }else{ + bRes = false; + } + else + { LPCSTR tex_name = ((EDetail*)(*it))->GetTextureName(); - for (u32 t_idx=0; t_idxExport (F,do_tex_name.c_str(),offsets[t_idx],scales[t_idx],rotated[t_idx]); + ((EDetail*)(*it))->Export(F, do_tex_name.c_str(), offsets[t_idx], scales[t_idx], rotated[t_idx]); } - F.close_chunk (); - if (!bRes) break; + F.close_chunk(); + if (!bRes) + break; } } - F.close_chunk (); + F.close_chunk(); } - - pb->Inc ("export slots"); + + pb->Inc("export slots"); // slots - if (bRes){ - xr_vector dt_slots(slot_cnt); dt_slots.assign(dtSlots,dtSlots+slot_cnt); - for (slot_idx=0; slot_idx dt_slots(slot_cnt); + dt_slots.assign(dtSlots, dtSlots+slot_cnt); + for (slot_idx = 0; slot_idxInc(); // write header - dtH.version = DETAIL_VERSION; - dtH.object_count= object_idx; + dtH.version = DETAIL_VERSION; + dtH.object_count = object_idx; - F.w_chunk (DETMGR_CHUNK_HEADER,&dtH,sizeof(DetailHeader)); + F.w_chunk(DETMGR_CHUNK_HEADER, &dtH, sizeof(DetailHeader)); - bRes = F.save_to(fn.c_str()); + bRes = F.save_to(fn.c_str()); } pb->Inc(); @@ -555,40 +624,43 @@ bool EDetailManager::Export(LPCSTR path) return bRes; } -void EDetailManager::OnDensityChange(PropValue* prop) +void EDetailManager::OnDensityChange(PropValue *prop) { - InvalidateCache (); -} + InvalidateCache(); +} -void EDetailManager::OnBaseTextureChange(PropValue* prop) +void EDetailManager::OnBaseTextureChange(PropValue *prop) { - m_Base.OnImageChange (prop); - InvalidateSlots (); - ELog.DlgMsg (mtInformation,"Texture changed. Reinitialize objects."); + m_Base.OnImageChange(prop); + InvalidateSlots(); + ELog.DlgMsg(mtInformation, "Texture changed. Reinitialize objects."); } -void EDetailManager::FillProp(LPCSTR pref, PropItemVec& items) +void EDetailManager::FillProp(LPCSTR pref, PropItemVec &items) { - PropValue* P; - P=PHelper().CreateFloat (items, PrepareKey(pref,"Objects per square"), &ps_r__Detail_density); - P->OnChangeEvent.bind (this,&EDetailManager::OnDensityChange); - P=PHelper().CreateChoose(items, PrepareKey(pref,"Base Texture"), &m_Base.name, smTexture); - P->OnChangeEvent.bind (this,&EDetailManager::OnBaseTextureChange); - PHelper().CreateFlag32 (items, PrepareKey(pref,"Common\\Draw objects"), &m_Flags, flObjectsDraw); - PHelper().CreateFlag32 (items, PrepareKey(pref,"Common\\Draw base texture"), &m_Flags, flBaseTextureDraw); - PHelper().CreateFlag32 (items, PrepareKey(pref,"Common\\Base texture blended"), &m_Flags, flBaseTextureBlended); - PHelper().CreateFlag32 (items, PrepareKey(pref,"Common\\Draw slot boxes"), &m_Flags, flSlotBoxesDraw); + PropValue *P; + P = PHelper().CreateFloat(items, PrepareKey(pref, "Objects per square"), &ps_r__Detail_density); + P->OnChangeEvent.bind(this, &EDetailManager::OnDensityChange); + P = PHelper().CreateChoose(items, PrepareKey(pref, "Base Texture"), &m_Base.name, smTexture); + P->OnChangeEvent.bind(this, &EDetailManager::OnBaseTextureChange); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Draw objects"), &m_Flags, flObjectsDraw); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Draw base texture"), &m_Flags, flBaseTextureDraw); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Base texture blended"), &m_Flags, flBaseTextureBlended); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Draw slot boxes"), &m_Flags, flSlotBoxesDraw); } -bool EDetailManager::GetSummaryInfo(SSceneSummary* inf) +bool EDetailManager::GetSummaryInfo(SSceneSummary *inf) { - for (DetailIt it=objects.begin(); it!=objects.end(); it++){ - ((EDetail*)(*it))->OnDeviceCreate(); - CEditableObject* E = ((EDetail*)(*it))->m_pRefs; - if (!E) continue; - CSurface* surf = *E->FirstSurface(); VERIFY(surf); - inf->AppendTexture (surf->_Texture(),SSceneSummary::sttDO,0,0,"$DETAILS$"); + for (DetailIt it = objects.begin(); it!=objects.end(); it++) + { + ((EDetail*)(*it))->OnDeviceCreate(); + CEditableObject *E = ((EDetail*)(*it))->m_pRefs; + if (!E) + continue; + CSurface *surf = *E->FirstSurface(); + VERIFY(surf); + inf->AppendTexture(surf->_Texture(), SSceneSummary::sttDO, 0, 0, "$DETAILS$"); } return true; } diff --git a/src/editors/LevelEditor/Edit/ESceneDOTools.h b/src/editors/LevelEditor/Edit/ESceneDOTools.h index 7ea69cee174..70ad693751d 100644 --- a/src/editors/LevelEditor/Edit/ESceneDOTools.h +++ b/src/editors/LevelEditor/Edit/ESceneDOTools.h @@ -3,9 +3,9 @@ #define ESceneDOToolsH #include "..\..\Layers\xrRender\DetailFormat.h" -#include "../ECore/Editor/EDetailModel.h" -#include "../ECore/Editor/Library.h" -#include "customobject.h" +#include "editors/ECore/Editor/EDetailModel.h" +#include "editors/ECore/Editor/Library.h" +#include "CustomObject.h" #include "..\..\Layers\xrRender\DetailManager.h" #include "Custom2DProjector.h" #include "ESceneCustomMTools.H" @@ -14,167 +14,238 @@ class CFrustum; class CEditableObject; class Shader; -struct SIndexDist{ - u32 index; - float dist; - float dens[4]; - float cnt[4]; - SIndexDist(){ZeroMemory(this,sizeof(SIndexDist));} +struct SIndexDist +{ + u32 index; + float dist; + float dens[4]; + float cnt[4]; + + SIndexDist() + { + ZeroMemory(this, sizeof(SIndexDist)); + } }; -DEFINE_SVECTOR (SIndexDist,4,SIndexDistVec,SIndexDistIt); -DEFINE_MAP (u32,DOVec,ColorIndexMap,ColorIndexPairIt); +DEFINE_SVECTOR(SIndexDist, 4, SIndexDistVec, SIndexDistIt); + +DEFINE_MAP(u32, DOVec, ColorIndexMap, ColorIndexPairIt); #define DETAIL_SLOT_SIZE_2 DETAIL_SLOT_SIZE*0.5f #define DETAIL_SLOT_RADIUS DETAIL_SLOT_SIZE*0.7071f class EDetailManager: - public CDetailManager, + public CDetailManager, public ESceneToolBase -// ,public pureDeviceCreate, -// public pureDeviceDestroy + // ,public pureDeviceCreate, + // public pureDeviceDestroy { - friend class TfrmDOShuffle; - typedef ESceneToolBase inherited; - - enum{ - flBaseTextureDraw = (1<<31), - flBaseTextureBlended = (1<<30), - flSlotBoxesDraw = (1<<29), - flObjectsDraw = (1<<28), + friend class TfrmDOShuffle; + typedef ESceneToolBase inherited; + + enum + { + flBaseTextureDraw = (1<<31), + flBaseTextureBlended = (1<<30), + flSlotBoxesDraw = (1<<29), + flObjectsDraw = (1<<28), }; - Flags32 m_Flags; - enum{ - flRTGenerateBaseMesh = (1<<0) + Flags32 m_Flags; + + enum + { + flRTGenerateBaseMesh = (1<<0) }; - Flags32 m_RTFlags; - ObjectList m_SnapObjects; + Flags32 m_RTFlags; + + ObjectList m_SnapObjects; + + Fbox m_BBox; + + IC u32 toSlotX(float x) + { + return (x/DETAIL_SLOT_SIZE+0.5f)+dtH.offs_x; + } - Fbox m_BBox; + IC u32 toSlotZ(float z) + { + return (z/DETAIL_SLOT_SIZE+0.5f)+dtH.offs_z; + } - IC u32 toSlotX (float x) {return (x/DETAIL_SLOT_SIZE+0.5f)+dtH.offs_x;} - IC u32 toSlotZ (float z) {return (z/DETAIL_SLOT_SIZE+0.5f)+dtH.offs_z;} - IC float fromSlotX (int x) {return (x-dtH.offs_x)*DETAIL_SLOT_SIZE+DETAIL_SLOT_SIZE_2;} - IC float fromSlotZ (int z) {return (z-dtH.offs_z)*DETAIL_SLOT_SIZE+DETAIL_SLOT_SIZE_2;} + IC - void UpdateSlotBBox (int x, int z, DetailSlot& slot); + float fromSlotX(int x) + { + return (x-dtH.offs_x)*DETAIL_SLOT_SIZE+DETAIL_SLOT_SIZE_2; + } - void GetSlotRect (Frect& rect, int sx, int sz); - void GetSlotTCRect (Irect& rect, int sx, int sz); - u8 GetRandomObject (u32 color_index); - u8 GetObject (ColorIndexPairIt& CI, u8 id); + IC - void CalcClosestCount(int part, const Fcolor& C, SIndexDistVec& best); - void FindClosestIndex(const Fcolor& C, SIndexDistVec& best); + float fromSlotZ(int z) + { + return (z-dtH.offs_z)*DETAIL_SLOT_SIZE+DETAIL_SLOT_SIZE_2; + } - DetailSlot& GetSlot (u32 sx, u32 sz); + void UpdateSlotBBox(int x, int z, DetailSlot &slot); - void __stdcall OnDensityChange (PropValue* prop); - void __stdcall OnBaseTextureChange (PropValue* prop); + void GetSlotRect(Frect &rect, int sx, int sz); + void GetSlotTCRect(Irect &rect, int sx, int sz); + u8 GetRandomObject(u32 color_index); + u8 GetObject(ColorIndexPairIt &CI, u8 id); + + void CalcClosestCount(int part, const Fcolor &C, SIndexDistVec &best); + void FindClosestIndex(const Fcolor &C, SIndexDistVec &best); + + DetailSlot &GetSlot(u32 sx, u32 sz); + + void __stdcall OnDensityChange(PropValue *prop); + void __stdcall OnBaseTextureChange(PropValue *prop); protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: -// render part ----------------------------------------------------------------- - void InitRender (); - void RenderTexture (float alpha); - void InvalidateCache (); -// render part ----------------------------------------------------------------- + // render part ----------------------------------------------------------------- + void InitRender(); + void RenderTexture(float alpha); + void InvalidateCache(); + // render part ----------------------------------------------------------------- public: - ColorIndexMap m_ColorIndices; - U8Vec m_Selected; - CCustom2DProjector m_Base; + ColorIndexMap m_ColorIndices; + U8Vec m_Selected; + CCustom2DProjector m_Base; - void SaveColorIndices (IWriter&); - bool LoadColorIndices (IReader&); + void SaveColorIndices(IWriter &); + bool LoadColorIndices(IReader &); public: - EDetailManager (); - virtual ~EDetailManager (); + EDetailManager(); + virtual ~EDetailManager(); - virtual bool AllowEnabling (){return true;} - virtual BOOL AllowMouseStart (){return true;} + virtual bool AllowEnabling() + { + return true; + } + + virtual BOOL AllowMouseStart() + { + return true; + } // snap - virtual ObjectList* GetSnapList (){return &m_SnapObjects;} - virtual void UpdateSnapList (){}; + virtual ObjectList *GetSnapList() + { + return &m_SnapObjects; + } + + virtual void UpdateSnapList() {}; + + // selection manipulate + virtual int RaySelect(int flag, float &distance, const Fvector &start, const Fvector &direction, BOOL bDistanceOnly); + virtual int FrustumSelect(int flag, const CFrustum &frustum); + virtual void SelectObjects(bool flag); + virtual void InvertSelection(); - // selection manipulate - virtual int RaySelect (int flag, float& distance, const Fvector& start, const Fvector& direction, BOOL bDistanceOnly); - virtual int FrustumSelect (int flag, const CFrustum& frustum); - virtual void SelectObjects (bool flag); - virtual void InvertSelection (); - virtual void RemoveSelection (){} - virtual int SelectionCount (bool testflag); - virtual void ShowObjects (bool flag, bool bAllowSelectionFlag=false, bool bSelFlag=true){} + virtual void RemoveSelection() {} - virtual void Clear (bool bSpecific=false); + virtual int SelectionCount(bool testflag); - // definition - IC LPCSTR ClassName (){return "detail_object";} - IC LPCSTR ClassDesc (){return "Detail Objects";} - IC int RenderPriority (){return 10;} + virtual void ShowObjects(bool flag, bool bAllowSelectionFlag = false, bool bSelFlag = true) {} + + virtual void Clear(bool bSpecific = false); + + // definition + IC LPCSTR ClassName() + { + return "detail_object"; + } + + IC LPCSTR ClassDesc() + { + return "Detail Objects"; + } + + IC + + int RenderPriority() + { + return 10; + } // validation - virtual bool Valid (){return dtSlots||objects.size()||m_Base.Valid()||m_SnapObjects.size();} - virtual bool Validate (bool){return true;} + virtual bool Valid() + { + return dtSlots||objects.size()||m_Base.Valid()||m_SnapObjects.size(); + } + + virtual bool Validate(bool) + { + return true; + } // events - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); - virtual void OnSynchronize (); - virtual void OnObjectRemove (CCustomObject* O, bool bDeleting); - virtual void OnSceneUpdate (); - virtual void OnFrame (); - virtual void OnRender (int priority, bool strictB2F); + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); + virtual void OnSynchronize(); + virtual void OnObjectRemove(CCustomObject *O, bool bDeleting); + virtual void OnSceneUpdate(); + virtual void OnFrame(); + virtual void OnRender(int priority, bool strictB2F); // IO - virtual bool IsNeedSave () {return Valid();} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool can_use_inifile () {return false;} + virtual bool IsNeedSave() + { + return Valid(); + } + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - virtual bool Export (LPCSTR fn); + virtual bool can_use_inifile() + { + return false; + } - // properties - virtual void FillProp (LPCSTR pref, PropItemVec& items); + + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + virtual bool Export(LPCSTR fn); + + // properties + virtual void FillProp(LPCSTR pref, PropItemVec &items); // utils - virtual bool GetSummaryInfo (SSceneSummary* inf); - virtual void GetBBox (Fbox& bb, bool bSelOnly){} - - // other - bool UpdateHeader (); - bool UpdateSlots (); - bool UpdateSlotObjects (int x, int z); - bool UpdateObjects (bool bUpdateTex, bool bUpdateSelectedOnly); - bool Initialize (); - bool Reinitialize (); - void InvalidateSlots (); - - EDetail* AppendDO (LPCSTR name, bool bTestUnique=true); - bool RemoveDO (LPCSTR name); - int RemoveDOs (); - DetailIt FindDOByNameIt (LPCSTR name); - EDetail* FindDOByName (LPCSTR name); - - void RemoveColorIndices (); - void AppendIndexObject (u32 color,LPCSTR name,bool bTestUnique=true); - EDetail* FindObjectInColorIndices(u32 index, LPCSTR name); - void ExportColorIndices (LPCSTR fname); - bool ImportColorIndices (LPCSTR fname); - - void ClearColorIndices (); - void ClearSlots (); - void ClearBase (); + virtual bool GetSummaryInfo(SSceneSummary *inf); + virtual void GetBBox(Fbox &bb, bool bSelOnly) {} + + // other + bool UpdateHeader(); + bool UpdateSlots(); + bool UpdateSlotObjects(int x, int z); + bool UpdateObjects(bool bUpdateTex, bool bUpdateSelectedOnly); + bool Initialize(); + bool Reinitialize(); + void InvalidateSlots(); + + EDetail *AppendDO(LPCSTR name, bool bTestUnique = true); + bool RemoveDO(LPCSTR name); + int RemoveDOs(); + DetailIt FindDOByNameIt(LPCSTR name); + EDetail *FindDOByName(LPCSTR name); + + void RemoveColorIndices(); + void AppendIndexObject(u32 color, LPCSTR name, bool bTestUnique = true); + EDetail *FindObjectInColorIndices(u32 index, LPCSTR name); + void ExportColorIndices(LPCSTR fname); + bool ImportColorIndices(LPCSTR fname); + + void ClearColorIndices(); + void ClearSlots(); + void ClearBase(); }; #endif /*_INCDEF_DetailObjects_H_*/ diff --git a/src/editors/LevelEditor/Edit/ESceneDOTools_Controls.cpp b/src/editors/LevelEditor/Edit/ESceneDOTools_Controls.cpp index b398724aabc..9d24ffa4258 100644 --- a/src/editors/LevelEditor/Edit/ESceneDOTools_Controls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneDOTools_Controls.cpp @@ -8,16 +8,18 @@ void EDetailManager::CreateControls() { - AddControl (xr_new(estDefault, etaSelect, this)); - // frame - pFrame = xr_new((TComponent*)0,this); + AddControl(xr_new(estDefault, etaSelect, this)); + // frame + pFrame = xr_new((TComponent*)0, this); } + //---------------------------------------------------- - + void EDetailManager::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- - \ No newline at end of file + diff --git a/src/editors/LevelEditor/Edit/ESceneDOTools_Generate.cpp b/src/editors/LevelEditor/Edit/ESceneDOTools_Generate.cpp index 3af9f1bd551..98cb6bd8314 100644 --- a/src/editors/LevelEditor/Edit/ESceneDOTools_Generate.cpp +++ b/src/editors/LevelEditor/Edit/ESceneDOTools_Generate.cpp @@ -3,95 +3,114 @@ #pragma hdrstop #include "ESceneDOTools.h" -#include "../ECore/Editor/EditMesh.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Engine/Texture.h" +#include "editors/ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Engine/Texture.h" #include "Scene.h" #include "SceneObject.h" -#include "leftbar.h" -#include "../ECore/Engine/cl_intersect.h" -#include "../ECore/Editor/Library.h" -#include "../ECore/Editor/ui_main.h" +#include "LeftBar.h" +#include "editors/ECore/Engine/cl_intersect.h" +#include "editors/ECore/Editor/Library.h" +#include "editors/ECore/Editor/ui_main.h" #include "..\..\Layers\xrRender\DetailFormat.h" -#include "bottombar.h" -#include "../ECore/Editor/ImageManager.h" +#include "BottomBar.h" +#include "editors/ECore/Editor/ImageManager.h" #include "ETools.h" -static Fvector down_vec ={0.f,-1.f,0.f}; -static Fvector left_vec ={-1.f,0.f,0.f}; -static Fvector right_vec={1.f,0.f,0.f}; -static Fvector fwd_vec ={0.f,0.f,1.f}; -static Fvector back_vec ={0.f,0.f,-1.f}; +static Fvector down_vec = {0.f,-1.f,0.f}; +static Fvector left_vec = {-1.f,0.f,0.f}; +static Fvector right_vec = {1.f,0.f,0.f}; +static Fvector fwd_vec = {0.f,0.f,1.f}; +static Fvector back_vec = {0.f,0.f,-1.f}; static CRandom DetailRandom(0x26111975); //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -DetailSlot& EDetailManager::GetSlot(u32 sx, u32 sz){ - VERIFY(sxfirst); + ColorIndexPairIt it = S; + for (; it!=E; it++) + { + src.set(it->first); float d = inv_a+sqrtf((C.r-src.r)*(C.r-src.r)+(C.g-src.g)*(C.g-src.g)+(C.b-src.b)*(C.b-src.b)); - if (dfirst; - bRes = true; + if (dfirst; + bRes = true; } } - if (bRes){ - if (best.size()<4){ - bool bFound=false; - for (u32 k=0; k=0)){ - best[i].dist = dist; - best[i].index = index; + if (!bFound&&(i>=0)) + { + best[i].dist = dist; + best[i].index = index; } } } @@ -99,422 +118,508 @@ void EDetailManager::FindClosestIndex(const Fcolor& C, SIndexDistVec& best) bool EDetailManager::Initialize() { - if (m_SnapObjects.empty()){ - ELog.DlgMsg(mtError,"Snap list empty!"); - return false; + if (m_SnapObjects.empty()) + { + ELog.DlgMsg(mtError, "Snap list empty!"); + return false; + } + if (!m_Base.Valid()) + { + ELog.DlgMsg(mtError, "Base texture empty!"); + return false; } - if (!m_Base.Valid()){ - ELog.DlgMsg(mtError,"Base texture empty!"); - return false; - } - if (!UpdateHeader()) return false; - m_Base.CreateRMFromObjects (m_BBox,m_SnapObjects); - if (!UpdateSlots()) return false; - if (!objects.empty()&&!UpdateObjects(false,false)) return false; - return true; + if (!UpdateHeader()) + return false; + m_Base.CreateRMFromObjects(m_BBox, m_SnapObjects); + if (!UpdateSlots()) + return false; + if (!objects.empty()&&!UpdateObjects(false, false)) + return false; + return true; } bool EDetailManager::Reinitialize() { - if (m_SnapObjects.empty()){ - ELog.DlgMsg(mtError,"Snap list empty!"); - return false; + if (m_SnapObjects.empty()) + { + ELog.DlgMsg(mtError, "Snap list empty!"); + return false; + } + if (!m_Base.Valid()) + { + ELog.DlgMsg(mtError, "Base texture empty!"); + return false; } - if (!m_Base.Valid()){ - ELog.DlgMsg(mtError,"Base texture empty!"); - return false; - } InvalidateCache(); - if (!UpdateHeader()) return false; - m_Base.CreateRMFromObjects (m_BBox,m_SnapObjects); -//. if (!UpdateBaseTexture(0)) return false; - if (!UpdateSlots()) return false; - if (!objects.empty()&&!UpdateObjects(false,false))return false; + if (!UpdateHeader()) + return false; + m_Base.CreateRMFromObjects(m_BBox, m_SnapObjects); + //. if (!UpdateBaseTexture(0)) return false; + if (!UpdateSlots()) + return false; + if (!objects.empty()&&!UpdateObjects(false, false)) + return false; - return true; + return true; } -bool EDetailManager::UpdateHeader(){ +bool EDetailManager::UpdateHeader() +{ // get bounding box - if (!Scene->GetBox(m_BBox,m_SnapObjects)) return false; + if (!Scene->GetBox(m_BBox, m_SnapObjects)) + return false; // fill header - int mn_x = iFloor(m_BBox.min.x/DETAIL_SLOT_SIZE); - int mn_z = iFloor(m_BBox.min.z/DETAIL_SLOT_SIZE); - int mx_x = iFloor(m_BBox.max.x/DETAIL_SLOT_SIZE)+1; - int mx_z = iFloor(m_BBox.max.z/DETAIL_SLOT_SIZE)+1; - dtH.offs_x = -mn_x; - dtH.offs_z = -mn_z; - dtH.size_x = mx_x-mn_x; - dtH.size_z = mx_z-mn_z; + int mn_x = iFloor(m_BBox.min.x/DETAIL_SLOT_SIZE); + int mn_z = iFloor(m_BBox.min.z/DETAIL_SLOT_SIZE); + int mx_x = iFloor(m_BBox.max.x/DETAIL_SLOT_SIZE)+1; + int mx_z = iFloor(m_BBox.max.z/DETAIL_SLOT_SIZE)+1; + dtH.offs_x = -mn_x; + dtH.offs_z = -mn_z; + dtH.size_x = mx_x-mn_x; + dtH.size_z = mx_z-mn_z; return true; } #define EPS_L_VAR 0.0012345f -void EDetailManager::UpdateSlotBBox(int sx, int sz, DetailSlot& slot) + +void EDetailManager::UpdateSlotBBox(int sx, int sz, DetailSlot &slot) { - Fbox bbox; + Fbox bbox; Frect rect; - GetSlotRect (rect,sx,sz); - bbox.min.set (rect.x1, m_BBox.min.y, rect.y1); - bbox.max.set (rect.x2, m_BBox.max.y, rect.y2); + GetSlotRect(rect, sx, sz); + bbox.min.set(rect.x1, m_BBox.min.y, rect.y1); + bbox.max.set(rect.x2, m_BBox.max.y, rect.y2); SBoxPickInfoVec pinf; ETOOLS::box_options(0); - if (Scene->BoxPickObjects(bbox,pinf,&m_SnapObjects)){ - bbox.grow (EPS_L_VAR); - Fplane frustum_planes[4]; - frustum_planes[0].build(bbox.min,left_vec); - frustum_planes[1].build(bbox.min,back_vec); - frustum_planes[2].build(bbox.max,right_vec); - frustum_planes[3].build(bbox.max,fwd_vec); + if (Scene->BoxPickObjects(bbox, pinf, &m_SnapObjects)) + { + bbox.grow(EPS_L_VAR); + Fplane frustum_planes[4]; + frustum_planes[0].build(bbox.min, left_vec); + frustum_planes[1].build(bbox.min, back_vec); + frustum_planes[2].build(bbox.max, right_vec); + frustum_planes[3].build(bbox.max, fwd_vec); CFrustum frustum; - frustum.CreateFromPlanes(frustum_planes,4); - - float y_min = flt_max; - float y_max = flt_min; - for (SBoxPickInfoIt it=pinf.begin(); it!=pinf.end(); it++){ - for (int k=0; k<(int)it->inf.size(); k++){ + frustum.CreateFromPlanes(frustum_planes, 4); + + float y_min = flt_max; + float y_max = flt_min; + for (SBoxPickInfoIt it = pinf.begin(); it!=pinf.end(); it++) + { + for (int k = 0; k<(int)it->inf.size(); k++) + { float range; Fvector verts[3]; - it->e_obj->GetFaceWorld(it->s_obj->_Transform(),it->e_mesh,it->inf[k].id,verts); - sPoly sSrc (verts,3); + it->e_obj->GetFaceWorld(it->s_obj->_Transform(), it->e_mesh, it->inf[k].id, verts); + sPoly sSrc(verts, 3); sPoly sDest; - sPoly* sRes = frustum.ClipPoly(sSrc, sDest); - if (sRes){ - for (u32 k=0; ksize(); k++){ + sPoly *sRes = frustum.ClipPoly(sSrc, sDest); + if (sRes) + { + for (u32 k = 0; ksize(); k++) + { float H = (*sRes)[k].y; - if (H>y_max) y_max = H+0.03f; - if (Hy_max) + y_max = H+0.03f; + if (H(dtH.size_x*dtH.size_z); - - SPBItem* pb = UI->ProgressStart(dtH.size_x*dtH.size_z,"Updating bounding boxes..."); - for (u32 z=0; zInc(); + // clear previous slots + xr_free(dtSlots); + dtSlots = xr_alloc(dtH.size_x*dtH.size_z); + + SPBItem *pb = UI->ProgressStart(dtH.size_x*dtH.size_z, "Updating bounding boxes..."); + for (u32 z = 0; zInc(); } } UI->ProgressEnd(pb); - m_Selected.resize (dtH.size_x*dtH.size_z); + m_Selected.resize(dtH.size_x*dtH.size_z); return true; } -void EDetailManager::GetSlotRect(Frect& rect, int sx, int sz){ - float x = fromSlotX(sx); - float z = fromSlotZ(sz); - rect.x1 = x-DETAIL_SLOT_SIZE_2+EPS_L; - rect.y1 = z-DETAIL_SLOT_SIZE_2+EPS_L; - rect.x2 = x+DETAIL_SLOT_SIZE_2-EPS_L; - rect.y2 = z+DETAIL_SLOT_SIZE_2-EPS_L; +void EDetailManager::GetSlotRect(Frect &rect, int sx, int sz) +{ + float x = fromSlotX(sx); + float z = fromSlotZ(sz); + rect.x1 = x-DETAIL_SLOT_SIZE_2+EPS_L; + rect.y1 = z-DETAIL_SLOT_SIZE_2+EPS_L; + rect.x2 = x+DETAIL_SLOT_SIZE_2-EPS_L; + rect.y2 = z+DETAIL_SLOT_SIZE_2-EPS_L; } -void EDetailManager::GetSlotTCRect(Irect& rect, int sx, int sz){ - Frect R; - GetSlotRect (R,sx,sz); - rect.x1 = m_Base.GetPixelUFromX(R.x1,m_BBox); - rect.x2 = m_Base.GetPixelUFromX(R.x2,m_BBox); - rect.y2 = m_Base.GetPixelVFromZ(R.y1,m_BBox); // v - êîîðäèíàòà ôëèïíóòà - rect.y1 = m_Base.GetPixelVFromZ(R.y2,m_BBox); +void EDetailManager::GetSlotTCRect(Irect &rect, int sx, int sz) +{ + Frect R; + GetSlotRect(R, sx, sz); + rect.x1 = m_Base.GetPixelUFromX(R.x1, m_BBox); + rect.x2 = m_Base.GetPixelUFromX(R.x2, m_BBox); + rect.y2 = m_Base.GetPixelVFromZ(R.y1, m_BBox); // v - êîîðäèíàòà ôëèïíóòà + rect.y1 = m_Base.GetPixelVFromZ(R.y2, m_BBox); } -void EDetailManager::CalcClosestCount(int part, const Fcolor& C, SIndexDistVec& best){ +void EDetailManager::CalcClosestCount(int part, const Fcolor &C, SIndexDistVec &best) +{ float dist = flt_max; Fcolor src; float inv_a = 1-C.a; int idx = -1; - for (u32 k=0; k=0) best[idx].cnt[part]++; + if (idx>=0) + best[idx].cnt[part]++; } u8 EDetailManager::GetRandomObject(u32 color_index) { - ColorIndexPairIt CI=m_ColorIndices.find(color_index); - R_ASSERT(CI!=m_ColorIndices.end()); - int k = DetailRandom.randI(0,CI->second.size()); - DetailIt it = std::find(objects.begin(),objects.end(),CI->second[k]); + ColorIndexPairIt CI = m_ColorIndices.find(color_index); + R_ASSERT(CI!=m_ColorIndices.end()); + int k = DetailRandom.randI(0, CI->second.size()); + DetailIt it = std::find(objects.begin(), objects.end(), CI->second[k]); VERIFY(it!=objects.end()); - return u8(it-objects.begin()); + return u8(it-objects.begin()); } -u8 EDetailManager::GetObject(ColorIndexPairIt& CI, u8 id) +u8 EDetailManager::GetObject(ColorIndexPairIt &CI, u8 id) { - VERIFY(CI!=m_ColorIndices.end()); - DetailIt it = std::find(objects.begin(),objects.end(),(CDetail*)CI->second[id]); + VERIFY(CI!=m_ColorIndices.end()); + DetailIt it = std::find(objects.begin(), objects.end(), (CDetail*)CI->second[id]); VERIFY(it!=objects.end()); - return u8(it-objects.begin()); + return u8(it-objects.begin()); } -bool CompareWeightFunc(SIndexDist& d0, SIndexDist& d1){ - return d0.distbest.size()){ - while (best.size()<4){ - do{ - id++; - if (id>3) id=0; - }while(m_ColorIndices[best[id].index].size()<=1); - best.push_back(SIndexDist()); - best.back()=best[id]; - if (best.size()==o_cnt) break; + if (o_cnt>best.size()) + { + while (best.size()<4) + { + do + { + id++; + if (id>3) + id = 0; + } while (m_ColorIndices[best[id].index].size()<=1); + best.push_back(SIndexDist()); + best.back() = best[id]; + if (best.size()==o_cnt) + break; } } // çàïîëíèì ïàëèòðó è óñòàíîâèì Random'û -// Msg("Slot: %d %d",x,z); - for(u32 k=0; ksecond.size()); - for (U8It b_it=elem.begin(); b_it!=elem.end(); b_it++) *b_it=u8(b_it-elem.begin()); -// best_rand A(DetailRandom); - std::random_shuffle(elem.begin(),elem.end());//,A); - for (b_it=elem.begin(); b_it!=elem.end(); b_it++){ - bool bNotFound=true; - slot->w_id (k, GetObject(CI,*b_it)); - for (u32 j=0; jr_id(j)==slot->r_id(k)){ - bNotFound = false; + // Msg("Slot: %d %d",x,z); + for (u32 k = 0; ksecond.size()); + for (U8It b_it = elem.begin(); b_it!=elem.end(); b_it++) + *b_it = u8(b_it-elem.begin()); + // best_rand A(DetailRandom); + std::random_shuffle(elem.begin(), elem.end());//,A); + for (b_it = elem.begin(); b_it!=elem.end(); b_it++) + { + bool bNotFound = true; + slot->w_id(k, GetObject(CI, *b_it)); + for (u32 j = 0; jr_id(j)==slot->r_id(k)) + { + bNotFound = false; break; } - if (bNotFound) break; + if (bNotFound) + break; } slot->color_editor(); // density float f = ((EDetail*)objects[slot->r_id(k)])->m_fDensityFactor; - slot->palette[k].a0 = (u16)iFloor(best[k].dens[0]*f*15.f+.5f); - slot->palette[k].a1 = (u16)iFloor(best[k].dens[1]*f*15.f+.5f); - slot->palette[k].a2 = (u16)iFloor(best[k].dens[2]*f*15.f+.5f); - slot->palette[k].a3 = (u16)iFloor(best[k].dens[3]*f*15.f+.5f); + slot->palette[k].a0 = (u16)iFloor(best[k].dens[0]*f*15.f+.5f); + slot->palette[k].a1 = (u16)iFloor(best[k].dens[1]*f*15.f+.5f); + slot->palette[k].a2 = (u16)iFloor(best[k].dens[2]*f*15.f+.5f); + slot->palette[k].a3 = (u16)iFloor(best[k].dens[3]*f*15.f+.5f); } // îïðåäåëèì ID íåçàïîëíåííûõ ñëîòîâ êàê ïóñòûøêè - for(k=best.size(); k<4; k++) - slot->w_id(k,DetailSlot::ID_Empty); + for (k = best.size(); k<4; k++) + slot->w_id(k, DetailSlot::ID_Empty); return true; } bool EDetailManager::UpdateObjects(bool bUpdateTex, bool bUpdateSelectedOnly) { - m_Base.ReloadImage(); - if (!m_Base.Valid()){ - ELog.DlgMsg(mtError,"Invalid base texture!"); - return false; + m_Base.ReloadImage(); + if (!m_Base.Valid()) + { + ELog.DlgMsg(mtError, "Invalid base texture!"); + return false; } - if (objects.empty()){ - ELog.DlgMsg(mtError,"Object list empty!"); - return false; + if (objects.empty()) + { + ELog.DlgMsg(mtError, "Object list empty!"); + return false; } // update objects - SPBItem* pb = UI->ProgressStart(dtH.size_x*dtH.size_z,"Updating objects..."); - for (u32 z=0; zInc(); + SPBItem *pb = UI->ProgressStart(dtH.size_x*dtH.size_z, "Updating objects..."); + for (u32 z = 0; zInc(); } UI->ProgressEnd(pb); - InvalidateCache (); + InvalidateCache(); return true; } CDetailManager::DetailIt EDetailManager::FindDOByNameIt(LPCSTR name) { - for (DetailIt it=objects.begin(); it!=objects.end(); it++) - if (stricmp(((EDetail*)(*it))->GetName(),name)==0) return it; + for (DetailIt it = objects.begin(); it!=objects.end(); it++) + if (stricmp(((EDetail*)(*it))->GetName(), name)==0) + return it; return objects.end(); } -EDetail* EDetailManager::FindDOByName(LPCSTR name) +EDetail *EDetailManager::FindDOByName(LPCSTR name) { - DetailIt it = FindDOByNameIt(name); - return (it!=objects.end())?(EDetail*)*it:0; + DetailIt it = FindDOByNameIt(name); + return (it!=objects.end()) ? (EDetail*)*it : 0; } bool EDetailManager::RemoveDO(LPCSTR name) { DetailIt it = FindDOByNameIt(name); - if (it!=objects.end()){ - xr_delete (*it); - objects.erase (it); - InvalidateSlots (); - return true; - }else return false; + if (it!=objects.end()) + { + xr_delete(*it); + objects.erase(it); + InvalidateSlots(); + return true; + } + else + return false; } -EDetail* EDetailManager::AppendDO(LPCSTR name, bool bTestUnique) +EDetail *EDetailManager::AppendDO(LPCSTR name, bool bTestUnique) { - EDetail* D=0; - if (bTestUnique&&(0!=(D=FindDOByName(name)))) return D; + EDetail *D = 0; + if (bTestUnique&&(0!=(D = FindDOByName(name)))) + return D; D = xr_new(); - if (!D->Update(name)){ - xr_delete(D); + if (!D->Update(name)) + { + xr_delete(D); return 0; } - objects.push_back (D); - InvalidateCache (); - return D; + objects.push_back(D); + InvalidateCache(); + return D; } void EDetailManager::InvalidateSlots() { - int slot_cnt = dtH.size_x*dtH.size_z; - for (int k=0; kw_id(0,DetailSlot::ID_Empty); - it->w_id(1,DetailSlot::ID_Empty); - it->w_id(2,DetailSlot::ID_Empty); - it->w_id(3,DetailSlot::ID_Empty); + int slot_cnt = dtH.size_x*dtH.size_z; + for (int k = 0; kw_id(0, DetailSlot::ID_Empty); + it->w_id(1, DetailSlot::ID_Empty); + it->w_id(2, DetailSlot::ID_Empty); + it->w_id(3, DetailSlot::ID_Empty); } InvalidateCache(); } int EDetailManager::RemoveDOs() { - int cnt=0; - for (DetailIt it=objects.begin(); it!=objects.end(); it++) + int cnt = 0; + for (DetailIt it = objects.begin(); it!=objects.end(); it++) xr_delete(*it); cnt = objects.size(); objects.clear(); return cnt; } -void EDetailManager::RemoveColorIndices(){ - m_ColorIndices.clear(); +void EDetailManager::RemoveColorIndices() +{ + m_ColorIndices.clear(); } -EDetail* EDetailManager::FindObjectInColorIndices(u32 index, LPCSTR name) +EDetail *EDetailManager::FindObjectInColorIndices(u32 index, LPCSTR name) { - ColorIndexPairIt CI=m_ColorIndices.find(index); - if (CI!=m_ColorIndices.end()){ - DOVec& lst = CI->second; - for (DOIt it=lst.begin(); it!=lst.end(); it++) - if (stricmp((*it)->GetName(),name)==0) return *it; + ColorIndexPairIt CI = m_ColorIndices.find(index); + if (CI!=m_ColorIndices.end()) + { + DOVec &lst = CI->second; + for (DOIt it = lst.begin(); it!=lst.end(); it++) + if (stricmp((*it)->GetName(), name)==0) + return *it; } return 0; } -void EDetailManager::AppendIndexObject(u32 color,LPCSTR name, bool bTestUnique) +void EDetailManager::AppendIndexObject(u32 color, LPCSTR name, bool bTestUnique) { - if (bTestUnique){ - EDetail* DO = FindObjectInColorIndices(color,name); + if (bTestUnique) + { + EDetail *DO = FindObjectInColorIndices(color, name); if (DO) - m_ColorIndices[color].push_back(DO); - }else{ - EDetail* DO = FindDOByName(name); - R_ASSERT(DO); - m_ColorIndices[color].push_back(DO); + m_ColorIndices[color].push_back(DO); + } + else + { + EDetail *DO = FindDOByName(name); + R_ASSERT(DO); + m_ColorIndices[color].push_back(DO); } } - diff --git a/src/editors/LevelEditor/Edit/ESceneDOTools_Pick.cpp b/src/editors/LevelEditor/Edit/ESceneDOTools_Pick.cpp index ca723c55967..a7f84a6a68b 100644 --- a/src/editors/LevelEditor/Edit/ESceneDOTools_Pick.cpp +++ b/src/editors/LevelEditor/Edit/ESceneDOTools_Pick.cpp @@ -7,78 +7,90 @@ #include "ESceneDOTools.h" #include "Scene.h" #include "cl_intersect.h" -#include "bottombar.h" -#include "../ECore/Editor/ui_main.h" +#include "BottomBar.h" +#include "editors/ECore/Editor/ui_main.h" -int EDetailManager::RaySelect(int flag, float& dist, const Fvector& start, const Fvector& direction, BOOL bDistanceOnly) +int EDetailManager::RaySelect(int flag, float &dist, const Fvector &start, const Fvector &direction, BOOL bDistanceOnly) { -// box selected only + // box selected only - if (!m_Flags.is(flSlotBoxesDraw)) return 0; + if (!m_Flags.is(flSlotBoxesDraw)) + return 0; - float fx,fz; - Fbox bbox; - Fvector P; - int sx=-1, sz=-1; + float fx, fz; + Fbox bbox; + Fvector P; + int sx = -1, sz = -1; int count = 0; - for (u32 z=0; zr_ybase(), fz-DETAIL_SLOT_SIZE_2); - bbox.max.set(fx+DETAIL_SLOT_SIZE_2, slot->r_ybase()+slot->r_yheight(), fz+DETAIL_SLOT_SIZE_2); - if (bbox.Pick2(start,direction,P)){ - float d = start.distance_to(P); - if (dr_ybase(), fz-DETAIL_SLOT_SIZE_2); + bbox.max.set(fx+DETAIL_SLOT_SIZE_2, slot->r_ybase()+slot->r_yheight(), fz+DETAIL_SLOT_SIZE_2); + if (bbox.Pick2(start, direction, P)) + { + float d = start.distance_to(P); + if (d=0)||(sz>=0)){ - if (!bDistanceOnly){ - if (flag==-1) + if ((sx>=0)||(sz>=0)) + { + if (!bDistanceOnly) + { + if (flag==-1) m_Selected[sz*dtH.size_x+sx] = !m_Selected[sz*dtH.size_x+sx]; else m_Selected[sz*dtH.size_x+sx] = (u8)flag; count++; - UI->RedrawScene(); + UI->RedrawScene(); } } return count; } -int EDetailManager::FrustumSelect(int flag, const CFrustum& frustum) +int EDetailManager::FrustumSelect(int flag, const CFrustum &frustum) { -// box selected only - - if (!m_Flags.is(flSlotBoxesDraw)) return 0; - - int count=0; - - float fx,fz; - Fbox bbox; - for (u32 z=0; zr_ybase(), fz-DETAIL_SLOT_SIZE_2); - bbox.max.set(fx+DETAIL_SLOT_SIZE_2, slot->r_ybase()+slot->r_yheight(), fz+DETAIL_SLOT_SIZE_2); - u32 mask = 0xff; - bool bRes = !!frustum.testAABB(bbox.data(),mask); - if (bRes){ - if (flag==-1) - m_Selected[z*dtH.size_x+x] = !m_Selected[z*dtH.size_x+x]; + // box selected only + + if (!m_Flags.is(flSlotBoxesDraw)) + return 0; + + int count = 0; + + float fx, fz; + Fbox bbox; + for (u32 z = 0; zr_ybase(), fz-DETAIL_SLOT_SIZE_2); + bbox.max.set(fx+DETAIL_SLOT_SIZE_2, slot->r_ybase()+slot->r_yheight(), fz+DETAIL_SLOT_SIZE_2); + u32 mask = 0xff; + bool bRes = !!frustum.testAABB(bbox.data(), mask); + if (bRes) + { + if (flag==-1) + m_Selected[z*dtH.size_x+x] = !m_Selected[z*dtH.size_x+x]; else - m_Selected[z*dtH.size_x+x] = (u8)flag; - - count++; + m_Selected[z*dtH.size_x+x] = (u8)flag; + + count++; } } } @@ -88,29 +100,32 @@ int EDetailManager::FrustumSelect(int flag, const CFrustum& frustum) void EDetailManager::SelectObjects(bool flag) { -// for (int i=0; i0) { @@ -196,28 +196,28 @@ bool EFogVolume::LoadLTX(CInifile& ini, LPCSTR sect_name) if(version>1 && m_volumeType==fvEmitter) m_volume_profile = ini.r_string(sect_name,"profile"); - OnChangeEnvs (NULL); + OnChangeEnvs (NULL); return true; } void EFogVolume::SaveLTX(CInifile& ini, LPCSTR sect_name) { - inherited::SaveLTX (ini, sect_name); + inherited::SaveLTX(ini, sect_name); - ini.w_u32 (sect_name, "version", FOG_VOL_VERSION); - ini.w_u8 (sect_name, "folume_type", m_volumeType); - ini.w_u32 (sect_name, "group_id", m_group_id); + ini.w_u32 (sect_name, "version", FOG_VOL_VERSION); + ini.w_u8 (sect_name, "folume_type", m_volumeType); + ini.w_u32 (sect_name, "group_id", m_group_id); if(m_volumeType==fvEmitter) - ini.w_string (sect_name, "profile", m_volume_profile.c_str()); + ini.w_string(sect_name, "profile", m_volume_profile.c_str()); } bool EFogVolume::LoadStream(IReader& F) { u16 version = 0; - R_ASSERT (F.r_chunk(OBJ_CHUNK_VERSION,&version)); + R_ASSERT (F.r_chunk(OBJ_CHUNK_VERSION,&version)); inherited::LoadStream(F); @@ -227,36 +227,36 @@ bool EFogVolume::LoadStream(IReader& F) m_group_id = F.r_u32(); } if(version>1 && m_volumeType==fvEmitter) - F.r_stringZ (m_volume_profile); + F.r_stringZ (m_volume_profile); - OnChangeEnvs (NULL); + OnChangeEnvs (NULL); return true; } void EFogVolume::SaveStream(IWriter& F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - F.open_chunk (OBJ_CHUNK_VERSION); - F.w_u16 (FOG_VOL_VERSION); - F.close_chunk (); + F.open_chunk(OBJ_CHUNK_VERSION); + F.w_u16 (FOG_VOL_VERSION); + F.close_chunk(); - F.open_chunk (OBJ_CHUNK_DATA); - F.w_u8 (m_volumeType); - F.w_u32 (m_group_id); + F.open_chunk(OBJ_CHUNK_DATA); + F.w_u8 (m_volumeType); + F.w_u32 (m_group_id); if(m_volumeType==fvEmitter) - F.w_stringZ (m_volume_profile.c_str()); + F.w_stringZ (m_volume_profile.c_str()); - F.close_chunk (); + F.close_chunk(); } -void EFogVolume::OnChangeEnvs (PropValue* prop) +void EFogVolume::OnChangeEnvs(PropValue* prop) { if(m_volumeType == fvEmitter) - SetDrawColor (0x205050FF, 0xFF202020); + SetDrawColor (0x205050FF, 0xFF202020); else if(m_volumeType == fvOcclusion) - SetDrawColor (0x2050A050, 0xFF202020); + SetDrawColor (0x2050A050, 0xFF202020); ((ESceneFogVolumeTool*)ParentTool)->RegisterGroup(m_group_id); @@ -265,20 +265,20 @@ void EFogVolume::OnChangeEnvs (PropValue* prop) void EFogVolume::FillProp(LPCSTR pref, PropItemVec& values) { - inherited::FillProp (pref, values); + inherited::FillProp (pref, values); PropValue* P; - P=PHelper().CreateToken8 (values, PrepareKey(pref,"VolumeType"), &m_volumeType, fog_vol_type); - P->OnChangeEvent.bind (this,&EFogVolume::OnChangeEnvs); + P=PHelper().CreateToken8(values, PrepareKey(pref,"VolumeType"), &m_volumeType, fog_vol_type); + P->OnChangeEvent.bind (this,&EFogVolume::OnChangeEnvs); if(m_volumeType==fvEmitter) - P=PHelper().CreateRText (values, PrepareKey(pref,"profile (ltx)"), &m_volume_profile); + P=PHelper().CreateRText(values, PrepareKey(pref,"profile (ltx)"), &m_volume_profile); } //---------------------------------------------------- bool EFogVolume::GetSummaryInfo(SSceneSummary* inf) { - inherited::GetSummaryInfo (inf); + inherited::GetSummaryInfo(inf); return true; } @@ -292,6 +292,6 @@ void EFogVolume::Select(int flag) inherited::Select(flag); if(Selected()) - ((ESceneFogVolumeTool*)ParentTool)->Selected(this); + ((ESceneFogVolumeTool*)ParentTool)->Selected(this); } diff --git a/src/editors/LevelEditor/Edit/ESceneFogVolumeTools.h b/src/editors/LevelEditor/Edit/ESceneFogVolumeTools.h index fceaed14657..6369ee193e7 100644 --- a/src/editors/LevelEditor/Edit/ESceneFogVolumeTools.h +++ b/src/editors/LevelEditor/Edit/ESceneFogVolumeTools.h @@ -16,31 +16,31 @@ class ESceneFogVolumeTool: public ESceneCustomOTool protected: u32 m_group_counter; // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls (); + virtual void RemoveControls (); public: - ESceneFogVolumeTool ():ESceneCustomOTool(OBJCLASS_FOG_VOL){;} + ESceneFogVolumeTool ():ESceneCustomOTool(OBJCLASS_FOG_VOL){;} // definition - IC LPCSTR ClassName (){return "fog_volume";} - IC LPCSTR ClassDesc (){return "Scene fog volumes";} - IC int RenderPriority (){return 11;} + IC LPCSTR ClassName (){return "fog_volume";} + IC LPCSTR ClassDesc (){return "Scene fog volumes";} + IC int RenderPriority (){return 11;} - virtual void Clear (bool bSpecific=false); + virtual void Clear (bool bSpecific=false); // IO - virtual bool IsNeedSave (){return inherited::IsNeedSave();} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); + virtual bool IsNeedSave (){return inherited::IsNeedSave();} + virtual bool LoadStream (IReader&); + virtual bool LoadLTX (CInifile&); + virtual void SaveStream (IWriter&); + virtual void SaveLTX (CInifile&, int id); + virtual bool LoadSelection (IReader&); + virtual void SaveSelection (IWriter&); - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); + virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); - void GroupSelected (); - void UnGroupCurrent (); - void RegisterGroup (u32 group); - void Selected (EFogVolume* fv); + void GroupSelected (); + void UnGroupCurrent (); + void RegisterGroup (u32 group); + void Selected (EFogVolume* fv); }; #include "CustomObject.h" @@ -49,28 +49,28 @@ class ESceneFogVolumeTool: public ESceneCustomOTool class EFogVolume: public CEditShape { typedef CCustomObject inherited; - void __stdcall OnChangeEnvs (PropValue* prop); + void __stdcall OnChangeEnvs(PropValue* prop); public: u8 m_volumeType; u32 m_group_id; shared_str m_volume_profile; - EFogVolume (LPVOID data, LPCSTR name); - void Construct (LPVOID data); - virtual ~EFogVolume (); - virtual bool CanAttach () {return true;} + EFogVolume (LPVOID data, LPCSTR name); + void Construct (LPVOID data); + virtual ~EFogVolume (); + virtual bool CanAttach () {return true;} virtual void OnUpdateTransform(); - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); + virtual bool LoadStream (IReader&); + virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); + virtual void SaveStream (IWriter&); + virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); - virtual void FillProp (LPCSTR pref, PropItemVec& values); - virtual bool GetSummaryInfo (SSceneSummary* inf); - virtual void OnSceneUpdate (); + virtual void FillProp (LPCSTR pref, PropItemVec& values); + virtual bool GetSummaryInfo(SSceneSummary* inf); + virtual void OnSceneUpdate(); protected: - virtual void Select (int flag); + virtual void Select (int flag); }; diff --git a/src/editors/LevelEditor/Edit/ESceneGlowTools.cpp b/src/editors/LevelEditor/Edit/ESceneGlowTools.cpp index 9ef17e0f477..9e51ee06147 100644 --- a/src/editors/LevelEditor/Edit/ESceneGlowTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneGlowTools.cpp @@ -7,30 +7,35 @@ void ESceneGlowTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); - m_Flags.zero (); + inherited::CreateDefaultControls(estDefault); + m_Flags.zero(); } + //---------------------------------------------------- void ESceneGlowTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- -void ESceneGlowTool::FillProp(LPCSTR pref, PropItemVec& items) +void ESceneGlowTool::FillProp(LPCSTR pref, PropItemVec &items) { - PHelper().CreateFlag32(items, PrepareKey(pref,"Common\\Test Visibility"), &m_Flags, flTestVisibility); - PHelper().CreateFlag32(items, PrepareKey(pref,"Common\\Draw Cross"), &m_Flags, flDrawCross); - inherited::FillProp (pref, items); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Test Visibility"), &m_Flags, flTestVisibility); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Draw Cross"), &m_Flags, flDrawCross); + inherited::FillProp(pref, items); } + //------------------------------------------------------------------------------ -CCustomObject* ESceneGlowTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneGlowTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneGlowTools.h b/src/editors/LevelEditor/Edit/ESceneGlowTools.h index 6b3a3639512..ef96bdfdce3 100644 --- a/src/editors/LevelEditor/Edit/ESceneGlowTools.h +++ b/src/editors/LevelEditor/Edit/ESceneGlowTools.h @@ -6,37 +6,68 @@ class ESceneGlowTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; - friend class CGlow; + typedef ESceneCustomOTool inherited; + friend class CGlow; protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); - enum{ - flDrawCross = (1<<30), - flTestVisibility= (1<<31), + virtual void CreateControls(); + virtual void RemoveControls(); + + enum + { + flDrawCross = (1<<30), + flTestVisibility= (1<<31), }; - Flags32 m_Flags; + + Flags32 m_Flags; public: - ESceneGlowTool ():ESceneCustomOTool(OBJCLASS_GLOW){;} - // definition - IC LPCSTR ClassName (){return "glow";} - IC LPCSTR ClassDesc (){return "Glow";} - IC int RenderPriority (){return 20;} + ESceneGlowTool(): ESceneCustomOTool(OBJCLASS_GLOW) + { + ; + } + + // definition + IC LPCSTR ClassName() + { + return "glow"; + } + + IC LPCSTR ClassDesc() + { + return "Glow"; + } + + IC + + int RenderPriority() + { + return 20; + } - void FillProp (LPCSTR pref, PropItemVec& items); + void FillProp(LPCSTR pref, PropItemVec &items); + + virtual void Clear(bool bSpecific = false) + { + inherited::Clear(bSpecific); + m_Flags.zero(); + }; - virtual void Clear (bool bSpecific=false){inherited::Clear(bSpecific); m_Flags.zero();}; // IO - virtual bool IsNeedSave (){return true;} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); + virtual bool IsNeedSave() + { + return true; + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneGlowToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneGlowToolsIO.cpp index 386b221b31b..5fb9954467f 100644 --- a/src/editors/LevelEditor/Edit/ESceneGlowToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneGlowToolsIO.cpp @@ -4,89 +4,100 @@ #include "ESceneGlowTools.h" // chunks -static const u16 GLOW_TOOLS_VERSION = 0x0000; +static const u16 GLOW_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, - CHUNK_FLAGS = 0x1002ul, +enum +{ + CHUNK_VERSION = 0x1001ul, + CHUNK_FLAGS = 0x1002ul, }; + //---------------------------------------------------- -bool ESceneGlowTool::LoadLTX(CInifile& ini) +bool ESceneGlowTool::LoadLTX(CInifile &ini) { - u16 version = ini.r_u32("main","glow_tool_version"); + u16 version = ini.r_u32("main", "glow_tool_version"); - if( version!=GLOW_TOOLS_VERSION ) + if (version!=GLOW_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadLTX(ini)) - return false; + if (!inherited::LoadLTX(ini)) + return false; - m_Flags.assign(ini.r_u32("main","flags")); + m_Flags.assign(ini.r_u32("main", "flags")); return true; } -void ESceneGlowTool::SaveLTX(CInifile& ini, int id) +void ESceneGlowTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); + inherited::SaveLTX(ini, id); - ini.w_u32 ("main","glow_tool_version",GLOW_TOOLS_VERSION); + ini.w_u32("main", "glow_tool_version", GLOW_TOOLS_VERSION); - ini.w_u32 ("main","flags",m_Flags.get()); + ini.w_u32("main", "flags", m_Flags.get()); } -bool ESceneGlowTool::LoadStream(IReader& F) +bool ESceneGlowTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=GLOW_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=GLOW_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadStream(F)) return false; + if (!inherited::LoadStream(F)) + return false; if (F.find_chunk(CHUNK_FLAGS)) - m_Flags.assign(F.r_u32()); + m_Flags.assign(F.r_u32()); return true; } + //---------------------------------------------------- -void ESceneGlowTool::SaveStream(IWriter& F) +void ESceneGlowTool::SaveStream(IWriter &F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&GLOW_TOOLS_VERSION,sizeof(GLOW_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&GLOW_TOOLS_VERSION, sizeof(GLOW_TOOLS_VERSION)); - F.open_chunk (CHUNK_FLAGS); - F.w_u32 (m_Flags.get()); - F.close_chunk (); + F.open_chunk(CHUNK_FLAGS); + F.w_u32(m_Flags.get()); + F.close_chunk(); } + //---------------------------------------------------- -bool ESceneGlowTool::LoadSelection(IReader& F) +bool ESceneGlowTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=GLOW_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=GLOW_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void ESceneGlowTool::SaveSelection(IWriter& F) +void ESceneGlowTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&GLOW_TOOLS_VERSION,sizeof(GLOW_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&GLOW_TOOLS_VERSION, sizeof(GLOW_TOOLS_VERSION)); - inherited::SaveSelection(F); + inherited::SaveSelection(F); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneGroupControls.cpp b/src/editors/LevelEditor/Edit/ESceneGroupControls.cpp index 241d98bad34..d3fffbd39a8 100644 --- a/src/editors/LevelEditor/Edit/ESceneGroupControls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneGroupControls.cpp @@ -9,38 +9,38 @@ //------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ -__fastcall TUI_ControlGroupAdd::TUI_ControlGroupAdd(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent) -{ -} +__fastcall TUI_ControlGroupAdd::TUI_ControlGroupAdd(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} -bool __fastcall TUI_ControlGroupAdd::AfterAppendCallback(TShiftState Shift, CCustomObject* obj) +bool __fastcall TUI_ControlGroupAdd::AfterAppendCallback(TShiftState Shift, CCustomObject *obj) { - bool result = false; - ESceneGroupTool* ot = dynamic_cast(parent_tool); + bool result = false; + ESceneGroupTool *ot = dynamic_cast(parent_tool); if (ot->GetCurrentObject()) { - CGroupObject* group = dynamic_cast(obj); R_ASSERT(group); - LPCSTR short_name = ot->GetCurrentObject(); - result = group->SetReference(short_name); - if (result){ - string256 namebuffer; + CGroupObject *group = dynamic_cast(obj); + R_ASSERT(group); + LPCSTR short_name = ot->GetCurrentObject(); + result = group->SetReference(short_name); + if (result) + { + string256 namebuffer; Scene->GenObjectName(OBJCLASS_GROUP, namebuffer, short_name); - group->Name = namebuffer; + group->Name = namebuffer; } } return result; } + bool __fastcall TUI_ControlGroupAdd::Start(TShiftState Shift) { - DefaultAddObject (Shift,0,AfterAppendCallback); + DefaultAddObject(Shift, 0, AfterAppendCallback); return false; } -void __fastcall TUI_ControlGroupAdd::Move(TShiftState _Shift) -{ -} + +void __fastcall TUI_ControlGroupAdd::Move(TShiftState _Shift) {} + bool __fastcall TUI_ControlGroupAdd::End(TShiftState _Shift) { return true; } - diff --git a/src/editors/LevelEditor/Edit/ESceneGroupTools.cpp b/src/editors/LevelEditor/Edit/ESceneGroupTools.cpp index af1f83a1b0a..9162f1491d7 100644 --- a/src/editors/LevelEditor/Edit/ESceneGroupTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneGroupTools.cpp @@ -3,299 +3,317 @@ #include "ESceneGroupTools.h" #include "ESceneGroupControls.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "FrameGroup.h" #include "Scene.h" #include "GroupObject.h" -#include "../ECore/Editor/EThumbnail.h" +#include "editors/ECore/Editor/EThumbnail.h" void ESceneGroupTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); - AddControl (xr_new(estDefault,etaAdd, this)); - // frame - pFrame = xr_new((TComponent*)0,this); + inherited::CreateDefaultControls(estDefault); + AddControl(xr_new(estDefault, etaAdd, this)); + // frame + pFrame = xr_new((TComponent*)0, this); } + //---------------------------------------------------- void ESceneGroupTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- void ESceneGroupTool::UngroupObjects(bool bUndo) { - ObjectList lst = m_Objects; - int sel_cnt = 0; + ObjectList lst = m_Objects; + int sel_cnt = 0; if (!lst.empty()) { - bool bModif = false; - for (ObjectIt it=lst.begin(); it!=lst.end(); ++it) + bool bModif = false; + for (ObjectIt it = lst.begin(); it!=lst.end(); ++it) { if ((*it)->Selected()) { - sel_cnt++; - CGroupObject* obj = dynamic_cast(*it); + sel_cnt++; + CGroupObject *obj = dynamic_cast(*it); VERIFY(obj); if (obj->CanUngroup(true)) { - obj->UngroupObjects (); - Scene->RemoveObject (obj,false,true); - xr_delete (obj); - bModif = true; - }else - ELog.DlgMsg (mtError,"Can't ungroup object: '%s'.",obj->Name); + obj->UngroupObjects(); + Scene->RemoveObject(obj, false, true); + xr_delete(obj); + bModif = true; + } + else + ELog.DlgMsg(mtError, "Can't ungroup object: '%s'.", obj->Name); } } - if (bUndo&&bModif) + if (bUndo&&bModif) Scene->UndoSave(); } if (0==sel_cnt) - ELog.Msg (mtError,"Nothing selected."); + ELog.Msg(mtError, "Nothing selected."); } + //---------------------------------------------------- -BOOL ESceneGroupTool::_RemoveObject(CCustomObject* object) +BOOL ESceneGroupTool::_RemoveObject(CCustomObject *object) { - inherited::_RemoveObject(object); + inherited::_RemoveObject(object); - CGroupObject* go = dynamic_cast(object); - go->Clear1 (); - return TRUE; + CGroupObject *go = dynamic_cast(object); + go->Clear1(); + return TRUE; } void ESceneGroupTool::GroupObjects(bool bUndo) { - string256 namebuffer; - Scene->GenObjectName (OBJCLASS_GROUP, namebuffer); - CGroupObject* group = xr_new((LPVOID)0, namebuffer); + string256 namebuffer; + Scene->GenObjectName(OBJCLASS_GROUP, namebuffer); + CGroupObject *group = xr_new((LPVOID)0, namebuffer); // validate objects ObjectList lst; - if (Scene->GetQueryObjects(lst,OBJCLASS_DUMMY,1,1,0)) - group->GroupObjects(lst); - + if (Scene->GetQueryObjects(lst, OBJCLASS_DUMMY, 1, 1, 0)) + group->GroupObjects(lst); + if (group->ObjectInGroupCount()) { - ELog.DlgMsg(mtInformation,"Group '%s' successfully created.\nContain %d object(s)",group->Name,group->ObjectInGroupCount()); + ELog.DlgMsg(mtInformation, "Group '%s' successfully created.\nContain %d object(s)", group->Name, group->ObjectInGroupCount()); Scene->AppendObject(group, bUndo); - }else - { - ELog.DlgMsg (mtError,"Group can't be created."); - xr_delete (group); + } + else + { + ELog.DlgMsg(mtError, "Group can't be created."); + xr_delete(group); } } void ESceneGroupTool::CenterToGroup() { - ObjectList& lst = m_Objects; + ObjectList&lst = m_Objects; if (!lst.empty()) { - for (ObjectIt it=lst.begin(); it!=lst.end(); ++it) - ((CGroupObject*)(*it))->UpdatePivot(0, true); + for (ObjectIt it = lst.begin(); it!=lst.end(); ++it) + ((CGroupObject*)(*it))->UpdatePivot(0, true); - Scene->UndoSave(); + Scene->UndoSave(); } } + //---------------------------------------------------- -void __stdcall FillGroupItems(ChooseItemVec& items, void* param) +void __stdcall FillGroupItems(ChooseItemVec &items, void *param) { - CGroupObject* group = (CGroupObject*)param; - ObjectList grp_lst; - group->GetObjects (grp_lst); - - for (ObjectIt it=grp_lst.begin(); it!=grp_lst.end(); ++it) - items.push_back (SChooseItem((*it)->Name,"")); + CGroupObject *group = (CGroupObject*)param; + ObjectList grp_lst; + group->GetObjects(grp_lst); + + for (ObjectIt it = grp_lst.begin(); it!=grp_lst.end(); ++it) + items.push_back(SChooseItem((*it)->Name, "")); } void ESceneGroupTool::AlignToObject() { - ObjectList& lst = m_Objects; - int sel_cnt = 0; + ObjectList&lst = m_Objects; + int sel_cnt = 0; if (!lst.empty()) - { + { LPCSTR nm; - for (ObjectIt it=lst.begin(); it!=lst.end(); ++it) - { - if ((*it)->Selected()) - { - sel_cnt++; + for (ObjectIt it = lst.begin(); it!=lst.end(); ++it) + { + if ((*it)->Selected()) + { + sel_cnt++; if (TfrmChoseItem::SelectItem(smCustom, nm, 1, nm, FillGroupItems, *it)) - { - ((CGroupObject*)(*it))->UpdatePivot(nm,false); - }else - break; + { + ((CGroupObject*)(*it))->UpdatePivot(nm, false); + } + else + break; } } Scene->UndoSave(); } - if (0==sel_cnt) - ELog.Msg(mtError,"Nothing selected."); + if (0==sel_cnt) + ELog.Msg(mtError, "Nothing selected."); } + //---------------------------------------------------- -CCustomObject* ESceneGroupTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneGroupTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data, name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } void ESceneGroupTool::ReloadRefsSelectedObject() { - ObjectList lst = m_Objects; - int sel_cnt = 0; + ObjectList lst = m_Objects; + int sel_cnt = 0; if (!lst.empty()) { - string_path temp_file_name_sector,temp_file_name_portal; - GetTempFileName ( FS.get_path(_temp_)->m_Path, "tmp_sector", 0, temp_file_name_sector ); - Scene->SaveToolLTX (OBJCLASS_SECTOR, temp_file_name_sector); + string_path temp_file_name_sector, temp_file_name_portal; + GetTempFileName(FS.get_path(_temp_)->m_Path, "tmp_sector", 0, temp_file_name_sector); + Scene->SaveToolLTX(OBJCLASS_SECTOR, temp_file_name_sector); - GetTempFileName ( FS.get_path(_temp_)->m_Path, "tmp_portal", 0, temp_file_name_portal ); - Scene->SaveToolLTX (OBJCLASS_PORTAL, temp_file_name_portal); + GetTempFileName(FS.get_path(_temp_)->m_Path, "tmp_portal", 0, temp_file_name_portal); + Scene->SaveToolLTX(OBJCLASS_PORTAL, temp_file_name_portal); - bool bModif = false; - for (ObjectIt it=lst.begin(); it!=lst.end(); ++it) - { - if ((*it)->Selected()) + bool bModif = false; + for (ObjectIt it = lst.begin(); it!=lst.end(); ++it) + { + if ((*it)->Selected()) { - sel_cnt++; - CGroupObject* obj = dynamic_cast(*it); - VERIFY (obj); + sel_cnt++; + CGroupObject *obj = dynamic_cast(*it); + VERIFY(obj); if (obj->UpdateReference(true)) { - bModif = true; - }else + bModif = true; + } + else { - ELog.Msg (mtError,"Can't reload group: '%s'.",obj->Name); + ELog.Msg(mtError, "Can't reload group: '%s'.", obj->Name); } } } - if(bModif) - Scene->UndoSave (); + if (bModif) + Scene->UndoSave(); - Scene->LoadToolLTX (OBJCLASS_SECTOR, temp_file_name_sector); - Scene->LoadToolLTX (OBJCLASS_PORTAL, temp_file_name_portal); + Scene->LoadToolLTX(OBJCLASS_SECTOR, temp_file_name_sector); + Scene->LoadToolLTX(OBJCLASS_PORTAL, temp_file_name_portal); } - if (0==sel_cnt) - ELog.Msg (mtError,"Nothing selected."); + if (0==sel_cnt) + ELog.Msg(mtError, "Nothing selected."); } + //---------------------------------------------------- void ESceneGroupTool::SaveSelectedObject() { - u32 scnt = SelectionCount(true); - if(scnt==0) + u32 scnt = SelectionCount(true); + if (scnt==0) { - ELog.DlgMsg(mtError,"No object(s) selected."); + ELog.DlgMsg(mtError, "No object(s) selected."); return; - }else - if(scnt>1) + } + else if (scnt>1) { - if(mrYes != ELog.DlgMsg(mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, "Process multiple objects?") ) - return; + if (mrYes!=ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<Selected()) + if ((*it)->Selected()) { - obj = dynamic_cast(*it); - + obj = dynamic_cast(*it); + xr_string fn; - if(scnt==1) + if (scnt==1) { - fn = obj->RefName(); - if( !EFS.GetSaveName(_groups_,fn) ) + fn = obj->RefName(); + if (!EFS.GetSaveName(_groups_, fn)) return; - }else + } + else { - string_path S; - FS.update_path (S, _groups_, obj->RefName()); - fn = S; - fn += ".group"; + string_path S; + FS.update_path(S, _groups_, obj->RefName()); + fn = S; + fn += ".group"; } - - IWriter* W = FS.w_open(fn.c_str()); + + IWriter *W = FS.w_open(fn.c_str()); if (W) { - obj->SaveStream (*W); - FS.w_close (W); - }else - ELog.DlgMsg (mtError, "Cant write file [%s]", fn.c_str()); - } + obj->SaveStream(*W); + FS.w_close(W); + } + else + ELog.DlgMsg(mtError, "Cant write file [%s]", fn.c_str()); + } } } + //---------------------------------------------------- void ESceneGroupTool::SetCurrentObject(LPCSTR nm) { - m_CurrentObject = nm; - TfraGroup* frame =(TfraGroup*)pFrame; - frame->lbCurrent->Caption = m_CurrentObject.c_str(); + m_CurrentObject = nm; + TfraGroup *frame = (TfraGroup*)pFrame; + frame->lbCurrent->Caption = m_CurrentObject.c_str(); } + //---------------------------------------------------- void ESceneGroupTool::OnActivate() { - inherited::OnActivate (); - TfraGroup* frame = (TfraGroup*)pFrame; - frame->lbCurrent->Caption = m_CurrentObject.c_str(); + inherited::OnActivate(); + TfraGroup *frame = (TfraGroup*)pFrame; + frame->lbCurrent->Caption = m_CurrentObject.c_str(); } + //---------------------------------------------------- void ESceneGroupTool::MakeThumbnail() { - if (SelectionCount(true)==1) + if (SelectionCount(true)==1) { - CGroupObject* object = 0; - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) + CGroupObject *object = 0; + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) { - if ((*it)->Selected()) + if ((*it)->Selected()) { - object = dynamic_cast(*it); + object = dynamic_cast(*it); break; } } - VERIFY (object); - object->Select (false); + VERIFY(object); + object->Select(false); // save render params - Flags32 old_flag = psDeviceFlags; + Flags32 old_flag = psDeviceFlags; // set render params - psDeviceFlags.set (rsStatistic|rsDrawGrid,FALSE); + psDeviceFlags.set(rsStatistic|rsDrawGrid, FALSE); U32Vec pixels; - u32 w=512,h=512; - if (EDevice.MakeScreenshot (pixels,w,h)) + u32 w = 512, h = 512; + if (EDevice.MakeScreenshot(pixels, w, h)) { - AnsiString tex_name = ChangeFileExt(object->Name,".thm"); + AnsiString tex_name = ChangeFileExt(object->Name, ".thm"); SStringVec lst; - ObjectList grp_lst; - object->GetObjects (grp_lst); - - for (ObjectIt it=grp_lst.begin(); it!=grp_lst.end(); ++it) - lst.push_back ((*it)->Name); - - EGroupThumbnail tex (tex_name.c_str(),false); - tex.CreateFromData (pixels.begin(),w,h,lst); + ObjectList grp_lst; + object->GetObjects(grp_lst); + + for (ObjectIt it = grp_lst.begin(); it!=grp_lst.end(); ++it) + lst.push_back((*it)->Name); + + EGroupThumbnail tex(tex_name.c_str(), false); + tex.CreateFromData(pixels.begin(), w, h, lst); string_path fn; - FS.update_path (fn,_groups_,object->RefName()); - strcat (fn,".group"); - tex.Save (FS.get_file_age(fn)); - }else + FS.update_path(fn, _groups_, object->RefName()); + strcat(fn, ".group"); + tex.Save(FS.get_file_age(fn)); + } + else { - ELog.DlgMsg (mtError,"Can't make screenshot."); + ELog.DlgMsg(mtError, "Can't make screenshot."); } - object->Select (true); + object->Select(true); // restore render params - psDeviceFlags = old_flag; - }else + psDeviceFlags = old_flag; + } + else { - ELog.DlgMsg (mtError,"Select 1 GroupObject."); + ELog.DlgMsg(mtError, "Select 1 GroupObject."); } } + diff --git a/src/editors/LevelEditor/Edit/ESceneGroupTools.h b/src/editors/LevelEditor/Edit/ESceneGroupTools.h index f7e2eeaa070..e68c3fd526d 100644 --- a/src/editors/LevelEditor/Edit/ESceneGroupTools.h +++ b/src/editors/LevelEditor/Edit/ESceneGroupTools.h @@ -6,50 +6,84 @@ class ESceneGroupTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; - xr_string m_CurrentObject; - xr_vector m_stored_state; + typedef ESceneCustomOTool inherited; + xr_string m_CurrentObject; + xr_vector m_stored_state; protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - ESceneGroupTool ():ESceneCustomOTool(OBJCLASS_GROUP){;} - // definition - IC LPCSTR ClassName (){return "group";} - IC LPCSTR ClassDesc (){return "Group";} - IC int RenderPriority (){return 1;} + ESceneGroupTool(): ESceneCustomOTool(OBJCLASS_GROUP) + { + ; + } + + // definition + IC LPCSTR ClassName() + { + return "group"; + } + + IC LPCSTR ClassDesc() + { + return "Group"; + } + + IC + + int RenderPriority() + { + return 1; + } + + virtual void Clear(bool bSpecific = false) + { + inherited::Clear(bSpecific); + } - virtual void Clear (bool bSpecific=false){inherited::Clear(bSpecific);} // IO - virtual int SaveFileCount () const {return 2;} - virtual bool IsNeedSave (){return inherited::IsNeedSave();} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); + virtual int SaveFileCount() const + { + return 2; + } - virtual void OnActivate (); + virtual bool IsNeedSave() + { + return inherited::IsNeedSave(); + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + + virtual void OnActivate(); // group function - void UngroupObjects (bool bUndo=true); - void GroupObjects (bool bUndo=true); + void UngroupObjects(bool bUndo = true); + void GroupObjects(bool bUndo = true); - void CenterToGroup (); - void AlignToObject (); + void CenterToGroup(); + void AlignToObject(); - void MakeThumbnail (); + void MakeThumbnail(); - void SaveSelectedObject (); - void ReloadRefsSelectedObject(); - void SetCurrentObject (LPCSTR nm); - LPCSTR GetCurrentObject (){return m_CurrentObject.c_str();} + void SaveSelectedObject(); + void ReloadRefsSelectedObject(); + void SetCurrentObject(LPCSTR nm); - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); - virtual BOOL _RemoveObject (CCustomObject* object); + LPCSTR GetCurrentObject() + { + return m_CurrentObject.c_str(); + } + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); + virtual BOOL _RemoveObject(CCustomObject *object); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneGroupToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneGroupToolsIO.cpp index cd264655df8..f0338b4aa2f 100644 --- a/src/editors/LevelEditor/Edit/ESceneGroupToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneGroupToolsIO.cpp @@ -6,77 +6,85 @@ #include "SceneObject.h" // chunks -static const u16 GROUP_TOOLS_VERSION = 0x0000; +static const u16 GROUP_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, +enum +{ + CHUNK_VERSION = 0x1001ul, }; + //---------------------------------------------------- -bool ESceneGroupTool::LoadStream(IReader& F) +bool ESceneGroupTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=GROUP_TOOLS_VERSION ) + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=GROUP_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadStream(F)) return false; + if (!inherited::LoadStream(F)) + return false; return true; } + //---------------------------------------------------- -bool ESceneGroupTool::LoadLTX(CInifile& ini) +bool ESceneGroupTool::LoadLTX(CInifile &ini) { - LPCSTR section = "main"; - u16 version = ini.r_u16(section, "version"); + LPCSTR section = "main"; + u16 version = ini.r_u16(section, "version"); - if( version!=GROUP_TOOLS_VERSION ) + if (version!=GROUP_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadLTX(ini)) return false; + if (!inherited::LoadLTX(ini)) + return false; return true; } -void ESceneGroupTool::SaveLTX(CInifile& ini, int id) +void ESceneGroupTool::SaveLTX(CInifile &ini, int id) { - LPCSTR section = "main"; - ini.w_u16(section, "version", GROUP_TOOLS_VERSION); + LPCSTR section = "main"; + ini.w_u16(section, "version", GROUP_TOOLS_VERSION); - inherited::SaveLTX (ini, id); + inherited::SaveLTX(ini, id); } -void ESceneGroupTool::SaveStream(IWriter& F) +void ESceneGroupTool::SaveStream(IWriter &F) { - inherited::SaveStream(F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&GROUP_TOOLS_VERSION,sizeof(GROUP_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&GROUP_TOOLS_VERSION, sizeof(GROUP_TOOLS_VERSION)); } + //---------------------------------------------------- - -bool ESceneGroupTool::LoadSelection(IReader& F) + +bool ESceneGroupTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=GROUP_TOOLS_VERSION ) + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=GROUP_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void ESceneGroupTool::SaveSelection(IWriter& F) +void ESceneGroupTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&GROUP_TOOLS_VERSION,sizeof(GROUP_TOOLS_VERSION)); - - inherited::SaveSelection(F); + F.w_chunk(CHUNK_VERSION, (u16*)&GROUP_TOOLS_VERSION, sizeof(GROUP_TOOLS_VERSION)); + + inherited::SaveSelection(F); } diff --git a/src/editors/LevelEditor/Edit/ESceneLightTools.cpp b/src/editors/LevelEditor/Edit/ESceneLightTools.cpp index bdce06a5bd6..614faa4e875 100644 --- a/src/editors/LevelEditor/Edit/ESceneLightTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneLightTools.cpp @@ -3,267 +3,314 @@ #include "ESceneLightTools.h" #include "IGame_Persistent.h" -#include "../ECore/Editor/d3dutils.h" +#include "editors/ECore/Editor/d3dutils.h" #include "communicate.h" -#include "../ECore/Editor/ui_main.h" -#include "../xrEProps/TextForm.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/xrEProps/TextForm.h" #include "ELight.h" -ESceneLightTool::ESceneLightTool():ESceneCustomOTool(OBJCLASS_LIGHT) +ESceneLightTool::ESceneLightTool(): ESceneCustomOTool(OBJCLASS_LIGHT) { - Clear (); - m_Flags.zero (); + Clear(); + m_Flags.zero(); } + //------------------------------------------------------------------------------ -ESceneLightTool::~ESceneLightTool() -{ -} +ESceneLightTool::~ESceneLightTool() {} + //------------------------------------------------------------------------------ void ESceneLightTool::Clear(bool bSpecific) { - inherited::Clear(bSpecific); + inherited::Clear(bSpecific); - m_SunShadowDir.set (deg2rad(-25.f),deg2rad(292.f)); - - lcontrol_last_idx = 0; - lcontrols.clear (); - AppendLightControl (LCONTROL_STATIC); - AppendLightControl (LCONTROL_HEMI); - AppendLightControl (LCONTROL_SUN); - m_HemiControl = FindLightControl(LCONTROL_HEMI)->id; - m_Flags.zero (); + m_SunShadowDir.set(deg2rad(-25.f), deg2rad(292.f)); + + lcontrol_last_idx = 0; + lcontrols.clear(); + AppendLightControl(LCONTROL_STATIC); + AppendLightControl(LCONTROL_HEMI); + AppendLightControl(LCONTROL_SUN); + m_HemiControl = FindLightControl(LCONTROL_HEMI)->id; + m_Flags.zero(); } + //------------------------------------------------------------------------------ -void ESceneLightTool::SelectLightsForObject(CCustomObject* obj) +void ESceneLightTool::SelectLightsForObject(CCustomObject *obj) { - for (u32 i=0; iIsDynamic()&&!l->m_Flags.is(CLight::flAffectDynamic)) continue; -// if (!obj->IsDynamic()&&!l->m_Flags.is(CLight::flAffectStatic)) continue; - Fbox bb; obj->GetBox(bb); - Fvector C; float R; bb.getsphere(C,R); - float d = C.distance_to(l->PPosition) - l->m_Range - R; - EDevice.LightEnable(i,(d<0)); + for (u32 i = 0; iIsDynamic()&&!l->m_Flags.is(CLight::flAffectDynamic)) continue; + // if (!obj->IsDynamic()&&!l->m_Flags.is(CLight::flAffectStatic)) continue; + Fbox bb; + obj->GetBox(bb); + Fvector C; + float R; + bb.getsphere(C, R); + float d = C.distance_to(l->PPosition)-l->m_Range-R; + EDevice.LightEnable(i, (d<0)); } } -void ESceneLightTool::AppendFrameLight(CLight* src) +void ESceneLightTool::AppendFrameLight(CLight *src) { Flight L; - ZeroMemory (&L, sizeof(Flight)); - L.type = src->m_Type; - L.diffuse.mul_rgb (src->m_Color,src->m_Brightness); - L.specular.set (L.diffuse); - L.position.set (src->PPosition); - Fvector dir; dir.setHP(src->PRotation.y,src->PRotation.x); - L.direction.set (dir); - L.range = src->m_Range; - L.attenuation0 = src->m_Attenuation0+EPS_S; - L.attenuation1 = src->m_Attenuation1; - L.attenuation2 = src->m_Attenuation2; - L.phi = src->m_Cone; - L.falloff = 1.f; - EDevice.SetLight (frame_light.size(),L); + ZeroMemory(&L, sizeof(Flight)); + L.type = src->m_Type; + L.diffuse.mul_rgb(src->m_Color, src->m_Brightness); + L.specular.set(L.diffuse); + L.position.set(src->PPosition); + Fvector dir; + dir.setHP(src->PRotation.y, src->PRotation.x); + L.direction.set(dir); + L.range = src->m_Range; + L.attenuation0 = src->m_Attenuation0+EPS_S; + L.attenuation1 = src->m_Attenuation1; + L.attenuation2 = src->m_Attenuation2; + L.phi = src->m_Cone; + L.falloff = 1.f; + EDevice.SetLight(frame_light.size(), L); frame_light.push_back(src); } void ESceneLightTool::BeforeRender() { - if (psDeviceFlags.is(rsLighting)){ - int l_cnt = 0; + if (psDeviceFlags.is(rsLighting)) + { + int l_cnt = 0; // set scene lights - for(ObjectIt _F = m_Objects.begin();_F!=m_Objects.end();_F++){ - CLight* l = (CLight*)(*_F); + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) + { + CLight *l = (CLight*)(*_F); l_cnt++; if (l->Visible()&&l->m_UseInD3D&&l->m_Flags.is_any(ELight::flAffectDynamic|ELight::flAffectStatic)) - if (::Render->ViewBase.testSphere_dirty(l->PPosition,l->m_Range)) - AppendFrameLight(l); + if (::Render->ViewBase.testSphere_dirty(l->PPosition, l->m_Range)) + AppendFrameLight(l); } - // set sun - if (m_Flags.is(flShowSun)) + // set sun + if (m_Flags.is(flShowSun)) { Flight L; Fvector C; -// if (psDeviceFlags.is(rsEnvironment)){ -// C = g_pGamePersistent->Environment().CurrentEnv->sun_color; -// }else{ - C.set (1.f,1.f,1.f); -// } - L.direction.setHP(m_SunShadowDir.y,m_SunShadowDir.x); - L.diffuse.set (C.x,C.y,C.z,1.f); - L.ambient.set (0.f,0.f,0.f,0.f); - L.specular.set (C.x,C.y,C.z,1.f); - L.type = D3DLIGHT_DIRECTIONAL; - EDevice.SetLight (frame_light.size(),L); - EDevice.LightEnable(frame_light.size(),TRUE); + // if (psDeviceFlags.is(rsEnvironment)){ + // C = g_pGamePersistent->Environment().CurrentEnv->sun_color; + // }else{ + C.set(1.f, 1.f, 1.f); + // } + L.direction.setHP(m_SunShadowDir.y, m_SunShadowDir.x); + L.diffuse.set(C.x, C.y, C.z, 1.f); + L.ambient.set(0.f, 0.f, 0.f, 0.f); + L.specular.set(C.x, C.y, C.z, 1.f); + L.type = D3DLIGHT_DIRECTIONAL; + EDevice.SetLight(frame_light.size(), L); + EDevice.LightEnable(frame_light.size(), TRUE); } - // ambient -// if (psDeviceFlags.is(rsEnvironment)){ -// Fvector& V = g_pGamePersistent->Environment().CurrentEnv->ambient; -// Fcolor C; C.set(V.x,V.y,V.z,1.f); -// EDevice.SetRS (D3DRS_AMBIENT,C.get()); -// }else - EDevice.SetRS(D3DRS_AMBIENT,0x00000000); - - EDevice.Statistic->dwTotalLight = l_cnt; + // ambient + // if (psDeviceFlags.is(rsEnvironment)){ + // Fvector& V = g_pGamePersistent->Environment().CurrentEnv->ambient; + // Fcolor C; C.set(V.x,V.y,V.z,1.f); + // EDevice.SetRS(D3DRS_AMBIENT,C.get()); + // }else + EDevice.SetRS(D3DRS_AMBIENT, 0x00000000); + + EDevice.Statistic->dwTotalLight = l_cnt; EDevice.Statistic->dwLightInScene = frame_light.size(); } } + //------------------------------------------------------------------------------ void ESceneLightTool::AfterRender() { if (m_Flags.is(flShowSun)) - EDevice.LightEnable(frame_light.size(),FALSE); // sun - last light! - for (u32 i=0; iZFar()*0.95f; - p.mad (EDevice.vCameraPosition,dir,-fd); - DU_impl.DrawPointLight ( p ,VIS_RADIUS*fd, 0x00FFE020); - DU_impl.DrawLineSphere ( p, VIS_RADIUS*fd*0.3f, 0x00FF3000, false ); + float fd = UI->ZFar()*0.95f; + p.mad(EDevice.vCameraPosition, dir, -fd); + DU_impl.DrawPointLight(p,VIS_RADIUS*fd, 0x00FFE020); + DU_impl.DrawLineSphere(p, VIS_RADIUS*fd*0.3f, 0x00FF3000, false); } } } + //------------------------------------------------------------------------------ -void ESceneLightTool::OnControlAppendClick(ButtonValue* sender, bool& bDataModified, bool& bSafe) +void ESceneLightTool::OnControlAppendClick(ButtonValue *sender, bool &bDataModified, bool &bSafe) { - AppendLightControl(GenLightControlName().c_str()); + AppendLightControl(GenLightControlName().c_str()); ExecCommand(COMMAND_UPDATE_PROPERTIES); bDataModified = true; } + //------------------------------------------------------------------------------ -void ESceneLightTool::OnControlRenameRemoveClick(ButtonValue* V, bool& bDataModified, bool& bSafe) +void ESceneLightTool::OnControlRenameRemoveClick(ButtonValue *V, bool &bDataModified, bool &bSafe) { AnsiString item_name = V->Owner()->Item()->Text; - switch (V->btn_num){ - case 0:{ - AnsiString new_name=item_name; - if (TfrmText::RunEditor(new_name,"Control name")){ - if (FindLightControl(new_name.c_str())){ - ELog.DlgMsg(mtError,"Duplicate name found."); - }else if (new_name.IsEmpty()||new_name.Pos("\\")){ - ELog.DlgMsg(mtError,"Invalid control name."); - }else{ - RTokenVecIt it = FindLightControlIt(item_name.c_str()); - it->rename (new_name.c_str()); + switch (V->btn_num) + { + case 0: + { + AnsiString new_name = item_name; + if (TfrmText::RunEditor(new_name, "Control name")) + { + if (FindLightControl(new_name.c_str())) + { + ELog.DlgMsg(mtError, "Duplicate name found."); + } + else if (new_name.IsEmpty()||new_name.Pos("\\")) + { + ELog.DlgMsg(mtError, "Invalid control name."); + } + else + { + RTokenVecIt it = FindLightControlIt(item_name.c_str()); + it->rename(new_name.c_str()); + } } } - }break; - case 1: RemoveLightControl(item_name.c_str()); break; - } + break; + case 1: RemoveLightControl(item_name.c_str()); + break; + } ExecCommand(COMMAND_UPDATE_PROPERTIES); bDataModified = true; } + //------------------------------------------------------------------------------ -void ESceneLightTool::FillProp(LPCSTR pref, PropItemVec& items) +void ESceneLightTool::FillProp(LPCSTR pref, PropItemVec &items) { - ButtonValue* B = 0; + ButtonValue *B = 0; // hemisphere -//. PHelper().CreateRToken32(items, PrepareKey(pref,"Common\\Hemisphere\\Light Control"), &m_HemiControl, &*lcontrols.begin(), lcontrols.size()); - + //. PHelper().CreateRToken32(items, PrepareKey(pref,"Common\\Hemisphere\\Light Control"), &m_HemiControl, &*lcontrols.begin(), lcontrols.size()); + // sun - PHelper().CreateFlag32 (items, PrepareKey(pref,"Common\\Sun Shadow\\Visible"), &m_Flags, flShowSun); - PHelper().CreateAngle (items, PrepareKey(pref,"Common\\Sun Shadow\\Altitude"), &m_SunShadowDir.x, -PI_DIV_2,0); - PHelper().CreateAngle (items, PrepareKey(pref,"Common\\Sun Shadow\\Longitude"), &m_SunShadowDir.y, 0,PI_MUL_2); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Sun Shadow\\Visible"), &m_Flags, flShowSun); + PHelper().CreateAngle(items, PrepareKey(pref, "Common\\Sun Shadow\\Altitude"), &m_SunShadowDir.x, -PI_DIV_2, 0); + PHelper().CreateAngle(items, PrepareKey(pref, "Common\\Sun Shadow\\Longitude"), &m_SunShadowDir.y, 0, PI_MUL_2); // light controls - PHelper().CreateFlag32 (items, PrepareKey(pref,"Common\\Controls\\Draw Name"), &m_Flags, flShowControlName); - PHelper().CreateCaption (items,PrepareKey(pref,"Common\\Controls\\Count"), shared_str().printf("%d",lcontrols.size())); -// B=PHelper().CreateButton(items,PHelper().PrepareKey(pref,"Common\\Controls\\Edit"), "Append", ButtonValue::flFirstOnly); -// B->OnBtnClickEvent = OnControlAppendClick; - RTokenVecIt _I = lcontrols.begin(); - RTokenVecIt _E = lcontrols.end(); - for (;_I!=_E; _I++){ - if (_I->equal(LCONTROL_HEMI)||_I->equal(LCONTROL_STATIC)||_I->equal(LCONTROL_SUN)){ - PHelper().CreateCaption(items, PrepareKey(pref,"Common\\Controls\\System",*_I->name),""); - }else{ - B=PHelper().CreateButton(items, PrepareKey(pref,"Common\\Controls\\User",*_I->name),"Rename,Remove",ButtonValue::flFirstOnly); - B->OnBtnClickEvent.bind (this,&ESceneLightTool::OnControlRenameRemoveClick); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Controls\\Draw Name"), &m_Flags, flShowControlName); + PHelper().CreateCaption(items, PrepareKey(pref, "Common\\Controls\\Count"), shared_str().printf("%d", lcontrols.size())); + // B=PHelper().CreateButton(items,PHelper().PrepareKey(pref,"Common\\Controls\\Edit"), "Append", ButtonValue::flFirstOnly); + // B->OnBtnClickEvent = OnControlAppendClick; + RTokenVecIt _I = lcontrols.begin(); + RTokenVecIt _E = lcontrols.end(); + for (; _I!=_E; _I++) + { + if (_I->equal(LCONTROL_HEMI)||_I->equal(LCONTROL_STATIC)||_I->equal(LCONTROL_SUN)) + { + PHelper().CreateCaption(items, PrepareKey(pref, "Common\\Controls\\System", *_I->name), ""); + } + else + { + B = PHelper().CreateButton(items, PrepareKey(pref, "Common\\Controls\\User", *_I->name), "Rename,Remove", ButtonValue::flFirstOnly); + B->OnBtnClickEvent.bind(this, &ESceneLightTool::OnControlRenameRemoveClick); } - } - inherited::FillProp(pref, items); + } + inherited::FillProp(pref, items); } + //------------------------------------------------------------------------------ AnsiString ESceneLightTool::GenLightControlName() { - AnsiString name; - int idx=0; - do{ - name.sprintf("control_%02d",idx++); - }while (FindLightControl(name.c_str())); + AnsiString name; + int idx = 0; + do + { + name.sprintf("control_%02d", idx++); + } while (FindLightControl(name.c_str())); return name; } + //------------------------------------------------------------------------------ -xr_rtoken* ESceneLightTool::FindLightControl(int id) +xr_rtoken *ESceneLightTool::FindLightControl(int id) { - RTokenVecIt _I = lcontrols.begin(); - RTokenVecIt _E = lcontrols.end(); - for (;_I!=_E; _I++) - if (_I->id==id) return _I; + RTokenVecIt _I = lcontrols.begin(); + RTokenVecIt _E = lcontrols.end(); + for (; _I!=_E; _I++) + if (_I->id==id) + return _I; return 0; } + //------------------------------------------------------------------------------ RTokenVecIt ESceneLightTool::FindLightControlIt(LPCSTR name) { - RTokenVecIt _I = lcontrols.begin(); - RTokenVecIt _E = lcontrols.end(); - for (;_I!=_E; _I++) - if (_I->equal(name)) return _I; + RTokenVecIt _I = lcontrols.begin(); + RTokenVecIt _E = lcontrols.end(); + for (; _I!=_E; _I++) + if (_I->equal(name)) + return _I; return lcontrols.end(); } + //------------------------------------------------------------------------------ -void ESceneLightTool::AppendLightControl(LPCSTR nm, u32* idx) +void ESceneLightTool::AppendLightControl(LPCSTR nm, u32 *idx) { - AnsiString name = nm; _Trim(name); - if (name.IsEmpty()) return; - if (FindLightControl(name.c_str())) return; - lcontrols.push_back (xr_rtoken(name.c_str(),idx?*idx:lcontrol_last_idx++)); + AnsiString name = nm; + _Trim(name); + if (name.IsEmpty()) + return; + if (FindLightControl(name.c_str())) + return; + lcontrols.push_back(xr_rtoken(name.c_str(), idx ? *idx : lcontrol_last_idx++)); } + //------------------------------------------------------------------------------ void ESceneLightTool::RemoveLightControl(LPCSTR name) { - RTokenVecIt it = FindLightControlIt(name); - if (it!=lcontrols.end()) lcontrols.erase(it); + RTokenVecIt it = FindLightControlIt(name); + if (it!=lcontrols.end()) + lcontrols.erase(it); } + //------------------------------------------------------------------------------ bool ESceneLightTool::Validate(bool full_test) { - if (!inherited::Validate(full_test)) return false; - bool bRes = !m_Objects.empty(); - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++){ - CLight* L = dynamic_cast(*it); - if (!L->GetLControlName()){ - bRes=false; - ELog.Msg(mtError,"%s: '%s' - Invalid light control.",ClassDesc(),L->Name); + if (!inherited::Validate(full_test)) + return false; + bool bRes = !m_Objects.empty(); + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) + { + CLight *L = dynamic_cast(*it); + if (!L->GetLControlName()) + { + bRes = false; + ELog.Msg(mtError, "%s: '%s' - Invalid light control.", ClassDesc(), L->Name); } } return bRes; } + //------------------------------------------------------------------------------ @@ -272,31 +319,33 @@ bool ESceneLightTool::Validate(bool full_test) void ESceneLightTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); - // frame - pFrame = xr_new((TComponent*)0); + inherited::CreateDefaultControls(estDefault); + // frame + pFrame = xr_new((TComponent*)0); } + //---------------------------------------------------- - + void ESceneLightTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- -CCustomObject* ESceneLightTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneLightTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } -//---------------------------------------------------- +//---------------------------------------------------- /* - m_D3D.direction.setHP(PRotation.y,PRotation.x); - if (D3DLIGHT_DIRECTIONAL==m_D3D.type) m_LensFlare.Update(m_D3D.direction, m_D3D.diffuse); + m_D3D.direction.setHP(PRotation.y,PRotation.x); + if (D3DLIGHT_DIRECTIONAL==m_D3D.type) m_LensFlare.Update(m_D3D.direction, m_D3D.diffuse); //render case D3DLIGHT_DIRECTIONAL: @@ -304,58 +353,58 @@ CCustomObject* ESceneLightTool::CreateObject(LPVOID data, LPCSTR name) else DU.DrawDirectionalLight( m_D3D.position, m_D3D.direction, VIS_RADIUS, DIR_RANGE, clr ); break; else if ((3==priority)&&(true==strictB2F)){ - if (D3DLIGHT_DIRECTIONAL==m_D3D.type) m_LensFlare.Render(); + if (D3DLIGHT_DIRECTIONAL==m_D3D.type) m_LensFlare.Render(); } // update - if (D3DLIGHT_DIRECTIONAL==m_D3D.type){ - m_LensFlare.Update(m_D3D.direction, m_D3D.diffuse); - m_LensFlare.DeleteShaders(); - m_LensFlare.CreateShaders(); + if (D3DLIGHT_DIRECTIONAL==m_D3D.type){ + m_LensFlare.Update(m_D3D.direction, m_D3D.diffuse); + m_LensFlare.DeleteShaders(); + m_LensFlare.CreateShaders(); } // load - m_LensFlare.Load(F); + m_LensFlare.Load(F); // save - if (D3DLIGHT_DIRECTIONAL==m_D3D.type) m_LensFlare.Save(F); + if (D3DLIGHT_DIRECTIONAL==m_D3D.type) m_LensFlare.Save(F); void CLight:xr_token sun_quality[]={ - { "Low", 1 }, - { "Normal", 2 }, - { "Final", 3 }, - { 0, 0 } + { "Low", 1 }, + { "Normal", 2 }, + { "Final", 3 }, + { 0, 0 } }; :FillSunProp(LPCSTR pref, PropItemVec& items) { - CEditFlare& F = m_LensFlare; + CEditFlare& F = m_LensFlare; PropValue* prop = 0; - PHelper().CreateToken (items, PHelper().PrepareKey(pref,"Sun\\Quality"), &m_SunQuality, sun_quality); + PHelper().CreateToken (items, PHelper().PrepareKey(pref,"Sun\\Quality"), &m_SunQuality, sun_quality); - PHelper().CreateFlag32 (items, PHelper().PrepareKey(pref,"Sun\\Source\\Enabled"), &F.m_Flags, CEditFlare::flSource); - PHelper().CreateFloat (items, PHelper().PrepareKey(pref,"Sun\\Source\\Radius"), &F.m_Source.fRadius, 0.f,10.f); - prop = PHelper().CreateTexture (items, PHelper().PrepareKey(pref,"Sun\\Source\\Texture"), F.m_Source.texture, sizeof(F.m_Source.texture)); - prop->OnChangeEvent = OnNeedUpdate; - - PHelper().CreateFlag32 (items, PHelper().PrepareKey(pref,"Sun\\Gradient\\Enabled"), &F.m_Flags, CEditFlare::flGradient); - PHelper().CreateFloat (items, PHelper().PrepareKey(pref,"Sun\\Gradient\\Radius"), &F.m_Gradient.fRadius, 0.f,100.f); - PHelper().CreateFloat (items, PHelper().PrepareKey(pref,"Sun\\Gradient\\Opacity"), &F.m_Gradient.fOpacity, 0.f,1.f); - prop = PHelper().CreateTexture (items, PHelper().PrepareKey(pref,"Sun\\Gradient\\Texture"), F.m_Gradient.texture, sizeof(F.m_Gradient.texture)); - prop->OnChangeEvent = OnNeedUpdate; - - PHelper().CreateFlag32 (items, PHelper().PrepareKey(pref,"Sun\\Flares\\Enabled"), &F.m_Flags, CEditFlare::flFlare); - for (CEditFlare::FlareIt it=F.m_Flares.begin(); it!=F.m_Flares.end(); it++){ - AnsiString nm; nm.sprintf("%s\\Sun\\Flares\\Flare %d",pref,it-F.m_Flares.begin()); - PHelper().CreateFloat (items, PHelper().PrepareKey(nm.c_str(),"Radius"), &it->fRadius, 0.f,10.f); - PHelper().CreateFloat (items, PHelper().PrepareKey(nm.c_str(),"Opacity"), &it->fOpacity, 0.f,1.f); - PHelper().CreateFloat (items, PHelper().PrepareKey(nm.c_str(),"Position"), &it->fPosition, -10.f,10.f); - prop = PHelper().CreateTexture (items, PHelper().PrepareKey(nm.c_str(),"Texture"), it->texture, sizeof(it->texture)); + PHelper().CreateFlag32(items, PHelper().PrepareKey(pref,"Sun\\Source\\Enabled"), &F.m_Flags, CEditFlare::flSource); + PHelper().CreateFloat (items, PHelper().PrepareKey(pref,"Sun\\Source\\Radius"), &F.m_Source.fRadius, 0.f,10.f); + prop = PHelper().CreateTexture(items, PHelper().PrepareKey(pref,"Sun\\Source\\Texture"), F.m_Source.texture, sizeof(F.m_Source.texture)); + prop->OnChangeEvent = OnNeedUpdate; + + PHelper().CreateFlag32(items, PHelper().PrepareKey(pref,"Sun\\Gradient\\Enabled"), &F.m_Flags, CEditFlare::flGradient); + PHelper().CreateFloat (items, PHelper().PrepareKey(pref,"Sun\\Gradient\\Radius"), &F.m_Gradient.fRadius, 0.f,100.f); + PHelper().CreateFloat (items, PHelper().PrepareKey(pref,"Sun\\Gradient\\Opacity"), &F.m_Gradient.fOpacity, 0.f,1.f); + prop = PHelper().CreateTexture(items, PHelper().PrepareKey(pref,"Sun\\Gradient\\Texture"), F.m_Gradient.texture, sizeof(F.m_Gradient.texture)); + prop->OnChangeEvent = OnNeedUpdate; + + PHelper().CreateFlag32(items, PHelper().PrepareKey(pref,"Sun\\Flares\\Enabled"), &F.m_Flags, CEditFlare::flFlare); + for (CEditFlare::FlareIt it=F.m_Flares.begin(); it!=F.m_Flares.end(); it++){ + AnsiString nm; nm.sprintf("%s\\Sun\\Flares\\Flare %d",pref,it-F.m_Flares.begin()); + PHelper().CreateFloat(items, PHelper().PrepareKey(nm.c_str(),"Radius"), &it->fRadius, 0.f,10.f); + PHelper().CreateFloat(items, PHelper().PrepareKey(nm.c_str(),"Opacity"), &it->fOpacity, 0.f,1.f); + PHelper().CreateFloat(items, PHelper().PrepareKey(nm.c_str(),"Position"), &it->fPosition, -10.f,10.f); + prop = PHelper().CreateTexture(items, PHelper().PrepareKey(nm.c_str(),"Texture"), it->texture, sizeof(it->texture)); prop->OnChangeEvent = OnNeedUpdate; - } + } } //---------------------------------------------------- void CLight::OnDeviceCreate() { - if (D3DLIGHT_DIRECTIONAL==m_D3D.type) m_LensFlare.DDLoad(); + if (D3DLIGHT_DIRECTIONAL==m_D3D.type) m_LensFlare.DDLoad(); } void CLight::OnDeviceDestroy() { @@ -370,16 +419,16 @@ void CLight::OnDeviceDestroy() CEditFlare::CEditFlare() { m_Flags.set(flFlare|flSource|flGradient,TRUE); - // flares - m_Flares.resize (6); + // flares + m_Flares.resize (6); FlareIt it=m_Flares.begin(); - it->fRadius=0.08f; it->fOpacity=0.18f; it->fPosition=1.3f; strcpy(it->texture,"fx\\fx_flare1"); it++; - it->fRadius=0.12f; it->fOpacity=0.12f; it->fPosition=1.0f; strcpy(it->texture,"fx\\fx_flare2"); it++; - it->fRadius=0.04f; it->fOpacity=0.30f; it->fPosition=0.5f; strcpy(it->texture,"fx\\fx_flare2"); it++; - it->fRadius=0.08f; it->fOpacity=0.24f; it->fPosition=-0.3f; strcpy(it->texture,"fx\\fx_flare2"); it++; - it->fRadius=0.12f; it->fOpacity=0.12f; it->fPosition=-0.6f; strcpy(it->texture,"fx\\fx_flare3"); it++; - it->fRadius=0.30f; it->fOpacity=0.12f; it->fPosition=-1.0f; strcpy(it->texture,"fx\\fx_flare1"); it++; - // source + it->fRadius=0.08f; it->fOpacity=0.18f; it->fPosition=1.3f; strcpy(it->texture,"fx\\fx_flare1"); it++; + it->fRadius=0.12f; it->fOpacity=0.12f; it->fPosition=1.0f; strcpy(it->texture,"fx\\fx_flare2"); it++; + it->fRadius=0.04f; it->fOpacity=0.30f; it->fPosition=0.5f; strcpy(it->texture,"fx\\fx_flare2"); it++; + it->fRadius=0.08f; it->fOpacity=0.24f; it->fPosition=-0.3f; strcpy(it->texture,"fx\\fx_flare2"); it++; + it->fRadius=0.12f; it->fOpacity=0.12f; it->fPosition=-0.6f; strcpy(it->texture,"fx\\fx_flare3"); it++; + it->fRadius=0.30f; it->fOpacity=0.12f; it->fPosition=-1.0f; strcpy(it->texture,"fx\\fx_flare1"); it++; + // source strcpy(m_Source.texture,"fx\\fx_sun"); m_Source.fRadius = 0.15f; // gradient @@ -389,62 +438,62 @@ CEditFlare::CEditFlare() } void CEditFlare::Load(IReader& F){ - if (!F.find_chunk(FLARE_CHUNK_FLAG)) return; + if (!F.find_chunk(FLARE_CHUNK_FLAG)) return; R_ASSERT(F.find_chunk(FLARE_CHUNK_FLAG)); - F.r (&m_Flags.flags,sizeof(m_Flags)); + F.r (&m_Flags.flags,sizeof(m_Flags)); R_ASSERT(F.find_chunk(FLARE_CHUNK_SOURCE)); - F.r_stringZ (m_Source.texture); + F.r_stringZ (m_Source.texture); m_Source.fRadius= F.r_float(); if (F.find_chunk(FLARE_CHUNK_GRADIENT2)){ - F.r_stringZ (m_Gradient.texture); - m_Gradient.fOpacity = F.r_float(); - m_Gradient.fRadius = F.r_float(); + F.r_stringZ(m_Gradient.texture); + m_Gradient.fOpacity = F.r_float(); + m_Gradient.fRadius = F.r_float(); }else{ - R_ASSERT(F.find_chunk(FLARE_CHUNK_GRADIENT)); - m_Gradient.fOpacity = F.r_float(); + R_ASSERT(F.find_chunk(FLARE_CHUNK_GRADIENT)); + m_Gradient.fOpacity = F.r_float(); } // flares if (F.find_chunk(FLARE_CHUNK_FLARES2)){ - DeleteShaders(); - u32 deFCnt = F.r_u32(); VERIFY(deFCnt==6); - F.r (m_Flares.begin(),m_Flares.size()*sizeof(SFlare)); - for (FlareIt it=m_Flares.begin(); it!=m_Flares.end(); it++) it->hShader._clear(); - CreateShaders(); + DeleteShaders(); + u32 deFCnt = F.r_u32(); VERIFY(deFCnt==6); + F.r (m_Flares.begin(),m_Flares.size()*sizeof(SFlare)); + for (FlareIt it=m_Flares.begin(); it!=m_Flares.end(); it++) it->hShader._clear(); + CreateShaders(); } } //---------------------------------------------------- void CEditFlare::Save(IWriter& F) { - F.open_chunk (FLARE_CHUNK_FLAG); - F.w (&m_Flags.flags,sizeof(m_Flags)); - F.close_chunk (); - - F.open_chunk (FLARE_CHUNK_SOURCE); - F.w_stringZ (m_Source.texture); - F.w_float (m_Source.fRadius); - F.close_chunk (); - - F.open_chunk (FLARE_CHUNK_GRADIENT2); - F.w_stringZ (m_Gradient.texture); - F.w_float (m_Gradient.fOpacity); - F.w_float (m_Gradient.fRadius); - F.close_chunk (); - - F.open_chunk (FLARE_CHUNK_FLARES2); - F.w_u32 (m_Flares.size()); - F.w (m_Flares.begin(),m_Flares.size()*sizeof(SFlare)); - F.close_chunk (); + F.open_chunk(FLARE_CHUNK_FLAG); + F.w (&m_Flags.flags,sizeof(m_Flags)); + F.close_chunk(); + + F.open_chunk(FLARE_CHUNK_SOURCE); + F.w_stringZ (m_Source.texture); + F.w_float (m_Source.fRadius); + F.close_chunk(); + + F.open_chunk(FLARE_CHUNK_GRADIENT2); + F.w_stringZ (m_Gradient.texture); + F.w_float (m_Gradient.fOpacity); + F.w_float (m_Gradient.fRadius); + F.close_chunk(); + + F.open_chunk(FLARE_CHUNK_FLARES2); + F.w_u32 (m_Flares.size()); + F.w (m_Flares.begin(),m_Flares.size()*sizeof(SFlare)); + F.close_chunk(); } //---------------------------------------------------- void CEditFlare::Render() { - CLensFlare::Render(m_Flags.is(flSource),m_Flags.is(flFlare),m_Flags.is(flGradient)); + CLensFlare::Render(m_Flags.is(flSource),m_Flags.is(flFlare),m_Flags.is(flGradient)); } //---------------------------------------------------- @@ -460,38 +509,38 @@ void CEditFlare::CreateShaders() //---------------------------------------------------- - AnsiString suns; - for (ObjectIt it=lst.begin(); it!=lst.end(); it++){ - switch ((*it)->ClassID){ + AnsiString suns; + for (ObjectIt it=lst.begin(); it!=lst.end(); it++){ + switch ((*it)->ClassID){ case OBJCLASS_LIGHT:{ CLight *l = (CLight *)(*it); if (l->m_D3D.type==D3DLIGHT_DIRECTIONAL){ - if (suns.Length()) suns += ", "; - suns += l->Name; - pIni->w_fcolor (l->Name, "sun_color", l->m_D3D.diffuse); - pIni->w_fvector3(l->Name, "sun_dir", l->m_D3D.direction); - pIni->w_string (l->Name, "gradient", l->m_LensFlare.m_Flags.is(CLensFlare::flGradient)?"on":"off"); - pIni->w_string (l->Name, "source", l->m_LensFlare.m_Flags.is(CLensFlare::flSource)?"on":"off"); - pIni->w_string (l->Name, "flares", l->m_LensFlare.m_Flags.is(CLensFlare::flFlare)?"on":"off"); - pIni->w_float (l->Name, "gradient_opacity", l->m_LensFlare.m_Gradient.fOpacity); - pIni->w_string (l->Name, "gradient_texture", l->m_LensFlare.m_Gradient.texture); - pIni->w_float (l->Name, "gradient_radius", l->m_LensFlare.m_Gradient.fRadius); - pIni->w_string (l->Name, "source_texture", l->m_LensFlare.m_Source.texture); - pIni->w_float (l->Name, "source_radius", l->m_LensFlare.m_Source.fRadius); + if (suns.Length()) suns += ", "; + suns += l->Name; + pIni->w_fcolor(l->Name, "sun_color", l->m_D3D.diffuse); + pIni->w_fvector3(l->Name, "sun_dir", l->m_D3D.direction); + pIni->w_string(l->Name, "gradient", l->m_LensFlare.m_Flags.is(CLensFlare::flGradient)?"on":"off"); + pIni->w_string(l->Name, "source", l->m_LensFlare.m_Flags.is(CLensFlare::flSource)?"on":"off"); + pIni->w_string(l->Name, "flares", l->m_LensFlare.m_Flags.is(CLensFlare::flFlare)?"on":"off"); + pIni->w_float(l->Name, "gradient_opacity", l->m_LensFlare.m_Gradient.fOpacity); + pIni->w_string(l->Name, "gradient_texture", l->m_LensFlare.m_Gradient.texture); + pIni->w_float(l->Name, "gradient_radius", l->m_LensFlare.m_Gradient.fRadius); + pIni->w_string(l->Name, "source_texture", l->m_LensFlare.m_Source.texture); + pIni->w_float(l->Name, "source_radius", l->m_LensFlare.m_Source.fRadius); AnsiString FT=""; AnsiString FR=""; AnsiString FO=""; AnsiString FP=""; AnsiString T=""; int i=l->m_LensFlare.m_Flares.size(); for (CEditFlare::FlareIt it = l->m_LensFlare.m_Flares.begin(); it!=l->m_LensFlare.m_Flares.end(); it++,i--){ - FT += it->texture; - T.sprintf("%.3f",it->fRadius); FR += T; - T.sprintf("%.3f",it->fOpacity); FO += T; - T.sprintf("%.3f",it->fPosition);FP += T; + FT += it->texture; + T.sprintf("%.3f",it->fRadius); FR += T; + T.sprintf("%.3f",it->fOpacity); FO += T; + T.sprintf("%.3f",it->fPosition);FP += T; if (i>1){FT+=","; FR+=","; FO+=","; FP+=",";} } - pIni->w_string (l->Name, "flare_textures", FT.c_str()); - pIni->w_string (l->Name, "flare_radius", FR.c_str()); - pIni->w_string (l->Name, "flare_opacity", FO.c_str()); - pIni->w_string (l->Name, "flare_position", FP.c_str()); + pIni->w_string(l->Name, "flare_textures", FT.c_str()); + pIni->w_string(l->Name, "flare_radius", FR.c_str()); + pIni->w_string(l->Name, "flare_opacity", FO.c_str()); + pIni->w_string(l->Name, "flare_position", FP.c_str()); } }break; case OBJCLASS_GROUP:{ @@ -503,3 +552,4 @@ void CEditFlare::CreateShaders() if (suns.Length()) pIni->w_string("environment", "suns", suns.c_str()); } */ + diff --git a/src/editors/LevelEditor/Edit/ESceneLightTools.h b/src/editors/LevelEditor/Edit/ESceneLightTools.h index 0a094de00d5..84e4554fc16 100644 --- a/src/editors/LevelEditor/Edit/ESceneLightTools.h +++ b/src/editors/LevelEditor/Edit/ESceneLightTools.h @@ -4,84 +4,111 @@ #include "ESceneCustomOTools.H" #include "xr_efflensflare.h" -class CEditFlare: public CLensFlare{ +class CEditFlare: public CLensFlare +{ public: - CEditFlare(); - void Load(IReader& F); - void Save(IWriter& F); - void Render(); - void DeleteShaders(); - void CreateShaders(); + CEditFlare(); + void Load(IReader &F); + void Save(IWriter &F); + void Render(); + void DeleteShaders(); + void CreateShaders(); }; class ESceneLightTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; - friend class SceneBuilder; - friend class CLight; + typedef ESceneCustomOTool inherited; + friend class SceneBuilder; + friend class CLight; protected: - enum{ - flShowSun = (1<<31), - flShowControlName = (1<<30), + enum + { + flShowSun = (1<<31), + flShowControlName = (1<<30), }; - Flags32 m_Flags; - // hemisphere - u32 m_HemiControl; + + Flags32 m_Flags; + // hemisphere + u32 m_HemiControl; // sun - Fvector2 m_SunShadowDir; + Fvector2 m_SunShadowDir; // run time - xr_vector frame_light; - void AppendFrameLight (CLight* L); + xr_vector frame_light; + void AppendFrameLight(CLight *L); protected: // light control - int lcontrol_last_idx; - RTokenVec lcontrols; - void __stdcall OnControlAppendClick (ButtonValue* sender, bool& bDataModified, bool& bSafe); - void __stdcall OnControlRenameRemoveClick (ButtonValue* sender, bool& bDataModified, bool& bSafe); + int lcontrol_last_idx; + RTokenVec lcontrols; + void __stdcall OnControlAppendClick(ButtonValue *sender, bool &bDataModified, bool &bSafe); + void __stdcall OnControlRenameRemoveClick(ButtonValue *sender, bool &bDataModified, bool &bSafe); protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - ESceneLightTool (); - virtual ~ESceneLightTool (); + ESceneLightTool(); + virtual ~ESceneLightTool(); + + virtual void Clear(bool bSpecific = false); + + // definition + IC LPCSTR ClassName() + { + return "light"; + } - virtual void Clear (bool bSpecific=false); + IC LPCSTR ClassDesc() + { + return "Light"; + } - // definition - IC LPCSTR ClassName (){return "light";} - IC LPCSTR ClassDesc (){return "Light";} - IC int RenderPriority (){return 10;} + IC + + int RenderPriority() + { + return 10; + } // IO - virtual bool IsNeedSave (){return true;} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); + virtual bool IsNeedSave() + { + return true; + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); // utils - virtual bool Validate (bool full_build); - - virtual void BeforeRender (); - virtual void OnRender (int priority, bool strictB2F); - virtual void AfterRender (); - - void SelectLightsForObject (CCustomObject* obj); - - virtual void FillProp (LPCSTR pref, PropItemVec& items); - - AnsiString GenLightControlName (); - xr_rtoken* FindLightControl (int id); - RTokenVecIt FindLightControlIt (LPCSTR name); - xr_rtoken* FindLightControl (LPCSTR name){RTokenVecIt it = FindLightControlIt(name); return it!=lcontrols.end()?it:0;} - void AppendLightControl (LPCSTR name, u32* idx=0); - void RemoveLightControl (LPCSTR name); - - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); + virtual bool Validate(bool full_build); + + virtual void BeforeRender(); + virtual void OnRender(int priority, bool strictB2F); + virtual void AfterRender(); + + void SelectLightsForObject(CCustomObject *obj); + + virtual void FillProp(LPCSTR pref, PropItemVec &items); + + AnsiString GenLightControlName(); + xr_rtoken *FindLightControl(int id); + RTokenVecIt FindLightControlIt(LPCSTR name); + + xr_rtoken *FindLightControl(LPCSTR name) + { + RTokenVecIt it = FindLightControlIt(name); + return it!=lcontrols.end() ? it : 0; + } + + void AppendLightControl(LPCSTR name, u32 *idx = 0); + void RemoveLightControl(LPCSTR name); + + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); }; #endif // ESceneCustomOToolsH + diff --git a/src/editors/LevelEditor/Edit/ESceneLightToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneLightToolsIO.cpp index f959500f448..b082a17fd1a 100644 --- a/src/editors/LevelEditor/Edit/ESceneLightToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneLightToolsIO.cpp @@ -4,154 +4,168 @@ #include "ESceneLightTools.h" #include "elight.h" #include "scene.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" // chunks -static const u16 LIGHT_TOOLS_VERSION = 0x0000; +static const u16 LIGHT_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, - CHUNK_LCONTROLS = 0x1002ul, - CHUNK_LCONTROLS_LAST = 0x1003ul, - CHUNK_FLAGS = 0x1004ul, -// CHUNK_HEMI = 0x1005ul, // obsolette - CHUNK_SUN_SHADOW = 0x1006ul, - CHUNK_HEMI2 = 0x1007ul, +enum +{ + CHUNK_VERSION = 0x1001ul, + CHUNK_LCONTROLS = 0x1002ul, + CHUNK_LCONTROLS_LAST = 0x1003ul, + CHUNK_FLAGS = 0x1004ul, + // CHUNK_HEMI = 0x1005ul, // obsolette + CHUNK_SUN_SHADOW = 0x1006ul, + CHUNK_HEMI2 = 0x1007ul, }; + //---------------------------------------------------- -bool ESceneLightTool::LoadLTX(CInifile& ini) +bool ESceneLightTool::LoadLTX(CInifile &ini) { - u32 version = ini.r_u32("main", "version"); - if( version!=LIGHT_TOOLS_VERSION ) + u32 version = ini.r_u32("main", "version"); + if (version!=LIGHT_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); - return false; - } + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); + return false; + } - inherited::LoadLTX(ini); + inherited::LoadLTX(ini); - m_Flags.assign (ini.r_u32("main","flags")); + m_Flags.assign(ini.r_u32("main", "flags")); - m_SunShadowDir = ini.r_fvector2 ("main", "sun_shadow_dir"); - lcontrol_last_idx = ini.r_u32 ("main", "lcontrol_last_idx"); + m_SunShadowDir = ini.r_fvector2("main", "sun_shadow_dir"); + lcontrol_last_idx = ini.r_u32("main", "lcontrol_last_idx"); - CInifile::Sect S = ini.r_section ("lcontrols"); - CInifile::SectCIt it = S.Data.begin(); - CInifile::SectCIt it_e = S.Data.end(); - for(; it!=it_e; ++it) + CInifile::Sect S = ini.r_section("lcontrols"); + CInifile::SectCIt it = S.Data.begin(); + CInifile::SectCIt it_e = S.Data.end(); + for (; it!=it_e; ++it) { - u32 idx = ini.r_u32 ("lcontrols", it->first.c_str()); - AppendLightControl(it->first.c_str(),&idx); + u32 idx = ini.r_u32("lcontrols", it->first.c_str()); + AppendLightControl(it->first.c_str(), &idx); } - return true; + return true; } -void ESceneLightTool::SaveLTX(CInifile& ini, int id) +void ESceneLightTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); + inherited::SaveLTX(ini, id); - ini.w_u32 ("main", "version", LIGHT_TOOLS_VERSION); + ini.w_u32("main", "version", LIGHT_TOOLS_VERSION); - ini.w_u32 ("main", "flags", m_Flags.get()); + ini.w_u32("main", "flags", m_Flags.get()); - ini.w_fvector2 ("main", "sun_shadow_dir", m_SunShadowDir); + ini.w_fvector2("main", "sun_shadow_dir", m_SunShadowDir); - ini.w_u32 ("main", "lcontrol_last_idx", lcontrol_last_idx); + ini.w_u32("main", "lcontrol_last_idx", lcontrol_last_idx); - RTokenVecIt _I = lcontrols.begin(); - RTokenVecIt _E = lcontrols.end(); - for (;_I!=_E; ++_I) + RTokenVecIt _I = lcontrols.begin(); + RTokenVecIt _E = lcontrols.end(); + for (; _I!=_E; ++_I) { - ini.w_u32 ("lcontrols", _I->name.c_str(), _I->id); + ini.w_u32("lcontrols", _I->name.c_str(), _I->id); } } -bool ESceneLightTool::LoadStream(IReader& F) +bool ESceneLightTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=LIGHT_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=LIGHT_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadStream(F)) return false; + if (!inherited::LoadStream(F)) + return false; if (F.find_chunk(CHUNK_FLAGS)) - m_Flags.assign (F.r_u32()); + m_Flags.assign(F.r_u32()); - if (F.find_chunk(CHUNK_SUN_SHADOW)){ - F.r_u8 (); - F.r_fvector2 (m_SunShadowDir); + if (F.find_chunk(CHUNK_SUN_SHADOW)) + { + F.r_u8(); + F.r_fvector2(m_SunShadowDir); } if (F.find_chunk(CHUNK_LCONTROLS_LAST)) - lcontrol_last_idx = F.r_u32(); + lcontrol_last_idx = F.r_u32(); - IReader* R = F.open_chunk(CHUNK_LCONTROLS); - if (R){ - while (!R->eof()){ - shared_str l_name; + IReader *R = F.open_chunk(CHUNK_LCONTROLS); + if (R) + { + while (!R->eof()) + { + shared_str l_name; R->r_stringZ(l_name); - u32 l_idx = R->r_u32(); - AppendLightControl(l_name.c_str(),&l_idx); + u32 l_idx = R->r_u32(); + AppendLightControl(l_name.c_str(), &l_idx); } - R->close (); + R->close(); } return true; } + //---------------------------------------------------- -void ESceneLightTool::SaveStream(IWriter& F) +void ESceneLightTool::SaveStream(IWriter &F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&LIGHT_TOOLS_VERSION,sizeof(LIGHT_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&LIGHT_TOOLS_VERSION, sizeof(LIGHT_TOOLS_VERSION)); - F.open_chunk (CHUNK_FLAGS); - F.w_u32 (m_Flags.get()); - F.close_chunk (); + F.open_chunk(CHUNK_FLAGS); + F.w_u32(m_Flags.get()); + F.close_chunk(); - F.open_chunk (CHUNK_SUN_SHADOW); - F.w_u8 (0); - F.w_fvector2 (m_SunShadowDir); - F.close_chunk (); + F.open_chunk(CHUNK_SUN_SHADOW); + F.w_u8(0); + F.w_fvector2(m_SunShadowDir); + F.close_chunk(); - F.open_chunk (CHUNK_LCONTROLS_LAST); - F.w_u32 (lcontrol_last_idx); - F.close_chunk (); + F.open_chunk(CHUNK_LCONTROLS_LAST); + F.w_u32(lcontrol_last_idx); + F.close_chunk(); - F.open_chunk (CHUNK_LCONTROLS); - RTokenVecIt _I = lcontrols.begin(); - RTokenVecIt _E = lcontrols.end(); - for (;_I!=_E; _I++){ - F.w_stringZ (_I->name); - F.w_u32 (_I->id); + F.open_chunk(CHUNK_LCONTROLS); + RTokenVecIt _I = lcontrols.begin(); + RTokenVecIt _E = lcontrols.end(); + for (; _I!=_E; _I++) + { + F.w_stringZ(_I->name); + F.w_u32(_I->id); } - F.close_chunk (); + F.close_chunk(); } + //---------------------------------------------------- - -bool ESceneLightTool::LoadSelection(IReader& F) + +bool ESceneLightTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=LIGHT_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=LIGHT_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void ESceneLightTool::SaveSelection(IWriter& F) +void ESceneLightTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&LIGHT_TOOLS_VERSION,sizeof(LIGHT_TOOLS_VERSION)); - - inherited::SaveSelection(F); + F.w_chunk(CHUNK_VERSION, (u16*)&LIGHT_TOOLS_VERSION, sizeof(LIGHT_TOOLS_VERSION)); + + inherited::SaveSelection(F); } + //---------------------------------------------------- diff --git a/src/editors/LevelEditor/Edit/ESceneObjectControls.cpp b/src/editors/LevelEditor/Edit/ESceneObjectControls.cpp index 145be7f1fbb..5cc5fd39e2d 100644 --- a/src/editors/LevelEditor/Edit/ESceneObjectControls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneObjectControls.cpp @@ -2,96 +2,109 @@ #pragma hdrstop #include "ESceneObjectControls.h" -#include "ui_leveltools.h" -#include "../ECore/Editor/library.h" +#include "UI_LevelTools.h" +#include "editors/ECore/Editor/library.h" #include "scene.h" #include "SceneObject.h" #include "ESceneObjectTools.h" #include "FrameObject.h" -#include "leftbar.h" -#include "ui_levelmain.h" +#include "LeftBar.h" +#include "UI_LevelMain.h" //------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ -__fastcall TUI_ControlObjectAdd::TUI_ControlObjectAdd(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent) -{ -} +__fastcall TUI_ControlObjectAdd::TUI_ControlObjectAdd(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} bool __fastcall TUI_ControlObjectAdd::Start(TShiftState Shift) { - if (Shift==ssRBOnly){ ExecCommand(COMMAND_SHOWCONTEXTMENU,OBJCLASS_SCENEOBJECT); return false;} - TfraObject* fraObject = (TfraObject*)parent_tool->pFrame; VERIFY(fraObject); - Fvector p,n; - if(!LUI->PickGround(p,UI->m_CurrentRStart,UI->m_CurrentRDir,1,&n)) return false; + if (Shift==ssRBOnly) + { + ExecCommand(COMMAND_SHOWCONTEXTMENU, OBJCLASS_SCENEOBJECT); + return false; + } + TfraObject *fraObject = (TfraObject*)parent_tool->pFrame; + VERIFY(fraObject); + Fvector p, n; + if (!LUI->PickGround(p, UI->m_CurrentRStart, UI->m_CurrentRDir, 1, &n)) + return false; { // pick already executed (see top) - ESceneObjectTool* ot = dynamic_cast(parent_tool); - LPCSTR N; - if (ot->IsAppendRandomActive()&&ot->m_AppendRandomObjects.size()){ - N = ot->m_AppendRandomObjects[Random.randI(ot->m_AppendRandomObjects.size())].c_str(); - }else{ + ESceneObjectTool *ot = dynamic_cast(parent_tool); + LPCSTR N; + if (ot->IsAppendRandomActive()&&ot->m_AppendRandomObjects.size()) + { + N = ot->m_AppendRandomObjects[Random.randI(ot->m_AppendRandomObjects.size())].c_str(); + } + else + { N = ((TfraObject*)parent_tool->pFrame)->Current(); - if(!N){ - ELog.DlgMsg(mtInformation,"Nothing selected."); + if (!N) + { + ELog.DlgMsg(mtInformation, "Nothing selected."); return false; } } string256 namebuffer; Scene->GenObjectName(OBJCLASS_SCENEOBJECT, namebuffer, N); - CSceneObject *obj = xr_new((LPVOID)0,namebuffer); - CEditableObject* ref = obj->SetReference(N); - if (!ref){ - ELog.DlgMsg(mtError,"TUI_ControlObjectAdd:: Can't load reference object."); - xr_delete(obj); - return false; - } -/* if (ref->IsDynamic()){ - ELog.DlgMsg(mtError,"TUI_ControlObjectAdd:: Can't assign dynamic object."); + CSceneObject *obj = xr_new((LPVOID)0, namebuffer); + CEditableObject *ref = obj->SetReference(N); + if (!ref) + { + ELog.DlgMsg(mtError, "TUI_ControlObjectAdd:: Can't load reference object."); xr_delete(obj); return false; } -*/ - if (ot->IsAppendRandomActive()){ + /* if (ref->IsDynamic()){ + ELog.DlgMsg(mtError,"TUI_ControlObjectAdd:: Can't assign dynamic object."); + xr_delete(obj); + return false; + } + */ + if (ot->IsAppendRandomActive()) + { Fvector S; - if (ot->IsAppendRandomRotationActive()){ - Fvector p; - p.set( Random.randF(ot->m_AppendRandomMinRotation.x,ot->m_AppendRandomMaxRotation.x), - Random.randF(ot->m_AppendRandomMinRotation.y,ot->m_AppendRandomMaxRotation.y), - Random.randF(ot->m_AppendRandomMinRotation.z,ot->m_AppendRandomMaxRotation.z)); + if (ot->IsAppendRandomRotationActive()) + { + Fvector p; + p.set(Random.randF(ot->m_AppendRandomMinRotation.x, ot->m_AppendRandomMaxRotation.x), + Random.randF(ot->m_AppendRandomMinRotation.y, ot->m_AppendRandomMaxRotation.y), + Random.randF(ot->m_AppendRandomMinRotation.z, ot->m_AppendRandomMaxRotation.z)); obj->PRotation = p; } - if (ot->IsAppendRandomScaleActive()){ - Fvector s; - if (ot->IsAppendRandomScaleProportional()){ - s.x = Random.randF(ot->m_AppendRandomMinScale.x,ot->m_AppendRandomMaxScale.x); - s.set (s.x,s.x,s.x); - }else{ - s.set( Random.randF(ot->m_AppendRandomMinScale.x,ot->m_AppendRandomMaxScale.x), - Random.randF(ot->m_AppendRandomMinScale.y,ot->m_AppendRandomMaxScale.y), - Random.randF(ot->m_AppendRandomMinScale.z,ot->m_AppendRandomMaxScale.z)); + if (ot->IsAppendRandomScaleActive()) + { + Fvector s; + if (ot->IsAppendRandomScaleProportional()) + { + s.x = Random.randF(ot->m_AppendRandomMinScale.x, ot->m_AppendRandomMaxScale.x); + s.set(s.x, s.x, s.x); + } + else + { + s.set(Random.randF(ot->m_AppendRandomMinScale.x, ot->m_AppendRandomMaxScale.x), + Random.randF(ot->m_AppendRandomMinScale.y, ot->m_AppendRandomMaxScale.y), + Random.randF(ot->m_AppendRandomMinScale.z, ot->m_AppendRandomMaxScale.z)); } obj->PScale = s; } } - obj->MoveTo(p,n); + obj->MoveTo(p, n); - Scene->SelectObjects(false,OBJCLASS_SCENEOBJECT); - Scene->AppendObject( obj ); - if (Shift.Contains(ssCtrl)) - ExecCommand(COMMAND_SHOW_PROPERTIES); - if (!Shift.Contains(ssAlt)) - ResetActionToSelect(); + Scene->SelectObjects(false, OBJCLASS_SCENEOBJECT); + Scene->AppendObject(obj); + if (Shift.Contains(ssCtrl)) + ExecCommand(COMMAND_SHOW_PROPERTIES); + if (!Shift.Contains(ssAlt)) + ResetActionToSelect(); } return false; } -void __fastcall TUI_ControlObjectAdd::Move(TShiftState _Shift) -{ -} +void __fastcall TUI_ControlObjectAdd::Move(TShiftState _Shift) {} + bool __fastcall TUI_ControlObjectAdd::End(TShiftState _Shift) { return true; } - diff --git a/src/editors/LevelEditor/Edit/ESceneObjectTools.cpp b/src/editors/LevelEditor/Edit/ESceneObjectTools.cpp index b06334dd943..4913c357ddc 100644 --- a/src/editors/LevelEditor/Edit/ESceneObjectTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneObjectTools.cpp @@ -2,214 +2,248 @@ #pragma hdrstop #include "ESceneObjectTools.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "ESceneObjectControls.h" #include "FrameObject.h" #include "SceneObject.h" -#include "../ECore/Editor/library.h" +#include "editors/ECore/Editor/library.h" #include "Scene.h" -#include "../ECore/Editor/ui_main.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditMesh.h" -ESceneObjectTool::ESceneObjectTool():ESceneCustomOTool(OBJCLASS_SCENEOBJECT) +ESceneObjectTool::ESceneObjectTool(): ESceneCustomOTool(OBJCLASS_SCENEOBJECT) { - m_AppendRandomMinScale.set (1.f,1.f,1.f); - m_AppendRandomMaxScale.set (1.f,1.f,1.f); - m_AppendRandomMinRotation.set (0.f,0.f,0.f); - m_AppendRandomMaxRotation.set (0.f,0.f,0.f); - m_Flags.zero (); - m_Props = 0; + m_AppendRandomMinScale.set(1.f, 1.f, 1.f); + m_AppendRandomMaxScale.set(1.f, 1.f, 1.f); + m_AppendRandomMinRotation.set(0.f, 0.f, 0.f); + m_AppendRandomMaxRotation.set(0.f, 0.f, 0.f); + m_Flags.zero(); + m_Props = 0; } void ESceneObjectTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); - AddControl (xr_new(estDefault,etaAdd, this)); - // frame - pFrame = xr_new((TComponent*)0,this); + inherited::CreateDefaultControls(estDefault); + AddControl(xr_new(estDefault, etaAdd, this)); + // frame + pFrame = xr_new((TComponent*)0, this); } + //---------------------------------------------------- - + void ESceneObjectTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- bool ESceneObjectTool::Validate(bool full_test) { bool bRes = inherited::Validate(full_test); // verify position & refs duplicate - CSceneObject *A, *B; - for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){ + CSceneObject* A, * B; + for (ObjectIt a_it = m_Objects.begin(); a_it!=m_Objects.end(); a_it++) + { A = (CSceneObject*)(*a_it); - for (ObjectIt b_it=m_Objects.begin(); b_it!=m_Objects.end(); b_it++){ + for (ObjectIt b_it = m_Objects.begin(); b_it!=m_Objects.end(); b_it++) + { B = (CSceneObject*)(*b_it); - if (A==B) continue; - if (A->RefCompare(B->GetReference())){ - if (A->PPosition.similar(B->PPosition,EPS_L)){ - bRes = false; - ELog.Msg(mtError,"Duplicate object position '%s'-'%s' with reference '%s'.",A->Name,B->Name,A->RefName()); + if (A==B) + continue; + if (A->RefCompare(B->GetReference())) + { + if (A->PPosition.similar(B->PPosition, EPS_L)) + { + bRes = false; + ELog.Msg(mtError, "Duplicate object position '%s'-'%s' with reference '%s'.", A->Name, B->Name, A->RefName()); } } } - // validate lods - if (full_test&&A->IsMUStatic()){ - CEditableObject* E = A->GetReference(); VERIFY(E); - xr_string lod_name = E->GetLODTextureName(); - xr_string l_name = lod_name.c_str(); + // validate lods + if (full_test&&A->IsMUStatic()) + { + CEditableObject *E = A->GetReference(); + VERIFY(E); + xr_string lod_name = E->GetLODTextureName(); + xr_string l_name = lod_name.c_str(); string_path fn; - int age,age_nm; -//. FS.update_path (fn,_textures_,EFS.ChangeFileExt(l_name,".tga").c_str()); - FS.update_path (fn,_game_textures_,EFS.ChangeFileExt(l_name,".dds").c_str()); - age = FS.get_file_age(fn); - if(age==-1) Msg("!There is no texture '%s'", fn); - l_name += "_nm"; -//. FS.update_path (fn,_textures_,EFS.ChangeFileExt(l_name,".tga").c_str()); - FS.update_path (fn,_game_textures_,EFS.ChangeFileExt(l_name,".dds").c_str()); - age_nm = FS.get_file_age(fn); - if(age_nm==-1) Msg("!There is no texture '%s'", fn); - - if(age_nm==-1 || age==-1) - bRes = false; -/* - if ((age!=E->Version()) || (age_nm!=E->Version()) ) - { - Msg ("!Invalid LOD texture version: '%s'",E->GetName()); - Msg ("tex=%d obj=%d", age, E->Version()); - Msg ("tex=%d obj=%d", age_nm, E->Version()); - bRes = false; - } -*/ + int age, age_nm; + //. FS.update_path (fn,_textures_,EFS.ChangeFileExt(l_name,".tga").c_str()); + FS.update_path(fn, _game_textures_, EFS.ChangeFileExt(l_name, ".dds").c_str()); + age = FS.get_file_age(fn); + if (age==-1) + Msg("!There is no texture '%s'", fn); + l_name += "_nm"; + //. FS.update_path (fn,_textures_,EFS.ChangeFileExt(l_name,".tga").c_str()); + FS.update_path(fn, _game_textures_, EFS.ChangeFileExt(l_name, ".dds").c_str()); + age_nm = FS.get_file_age(fn); + if (age_nm==-1) + Msg("!There is no texture '%s'", fn); + + if (age_nm==-1||age==-1) + bRes = false; + /* + if ((age!=E->Version()) || (age_nm!=E->Version()) ) + { + Msg ("!Invalid LOD texture version: '%s'",E->GetName()); + Msg ("tex=%d obj=%d", age, E->Version()); + Msg ("tex=%d obj=%d", age_nm, E->Version()); + bRes = false; + } + */ } } - + return bRes; } + //---------------------------------------------------- -void ESceneObjectTool::OnChangeAppendRandomFlags(PropValue* prop) +void ESceneObjectTool::OnChangeAppendRandomFlags(PropValue *prop) { - m_Flags.set (flAppendRandomUpdateProps,TRUE); - _SequenceToList (m_AppendRandomObjects,*m_AppendRandomObjectsStr); + m_Flags.set(flAppendRandomUpdateProps, TRUE); + _SequenceToList(m_AppendRandomObjects, *m_AppendRandomObjectsStr); } void ESceneObjectTool::FillAppendRandomProperties(bool bUpdateOnly) { - if (!bUpdateOnly) m_Props = TProperties::CreateModalForm("Random Append Properties",false); - - m_AppendRandomObjectsStr = _ListToSequence(m_AppendRandomObjects).c_str(); - - PropValue* V; - PropItemVec items; - V=PHelper().CreateFlag32 (items,"Scale", &m_Flags, flAppendRandomScale); - V->OnChangeEvent.bind (this,&ESceneObjectTool::OnChangeAppendRandomFlags); - if (m_Flags.is(flAppendRandomScale)){ - V=PHelper().CreateFlag32 (items,"Scale\\Proportional",&m_Flags, flAppendRandomScaleProportional); - V->OnChangeEvent.bind (this,&ESceneObjectTool::OnChangeAppendRandomFlags); - if (m_Flags.is(flAppendRandomScaleProportional)){ - PHelper().CreateFloat (items,"Scale\\Minimum", &m_AppendRandomMinScale.x,0.001f,1000.f,0.001f,3); - PHelper().CreateFloat (items,"Scale\\Maximum", &m_AppendRandomMaxScale.x,0.001f,1000.f,0.001f,3); - }else{ - PHelper().CreateVector (items,"Scale\\Minimum", &m_AppendRandomMinScale,0.001f,1000.f,0.001f,3); - PHelper().CreateVector (items,"Scale\\Maximum", &m_AppendRandomMaxScale,0.001f,1000.f,0.001f,3); + if (!bUpdateOnly) + m_Props = TProperties::CreateModalForm("Random Append Properties", false); + + m_AppendRandomObjectsStr = _ListToSequence(m_AppendRandomObjects).c_str(); + + PropValue *V; + PropItemVec items; + V = PHelper().CreateFlag32(items, "Scale", &m_Flags, flAppendRandomScale); + V->OnChangeEvent.bind(this, &ESceneObjectTool::OnChangeAppendRandomFlags); + if (m_Flags.is(flAppendRandomScale)) + { + V = PHelper().CreateFlag32(items, "Scale\\Proportional", &m_Flags, flAppendRandomScaleProportional); + V->OnChangeEvent.bind(this, &ESceneObjectTool::OnChangeAppendRandomFlags); + if (m_Flags.is(flAppendRandomScaleProportional)) + { + PHelper().CreateFloat(items, "Scale\\Minimum", &m_AppendRandomMinScale.x, 0.001f, 1000.f, 0.001f, 3); + PHelper().CreateFloat(items, "Scale\\Maximum", &m_AppendRandomMaxScale.x, 0.001f, 1000.f, 0.001f, 3); + } + else + { + PHelper().CreateVector(items, "Scale\\Minimum", &m_AppendRandomMinScale, 0.001f, 1000.f, 0.001f, 3); + PHelper().CreateVector(items, "Scale\\Maximum", &m_AppendRandomMaxScale, 0.001f, 1000.f, 0.001f, 3); } } - V=PHelper().CreateFlag32 (items,"Rotate", &m_Flags, flAppendRandomRotation); - V->OnChangeEvent.bind (this,&ESceneObjectTool::OnChangeAppendRandomFlags); - if (m_Flags.is(flAppendRandomRotation)){ - PHelper().CreateAngle3 (items,"Rotate\\Minimum", &m_AppendRandomMinRotation); - PHelper().CreateAngle3 (items,"Rotate\\Maximum", &m_AppendRandomMaxRotation); + V = PHelper().CreateFlag32(items, "Rotate", &m_Flags, flAppendRandomRotation); + V->OnChangeEvent.bind(this, &ESceneObjectTool::OnChangeAppendRandomFlags); + if (m_Flags.is(flAppendRandomRotation)) + { + PHelper().CreateAngle3(items, "Rotate\\Minimum", &m_AppendRandomMinRotation); + PHelper().CreateAngle3(items, "Rotate\\Maximum", &m_AppendRandomMaxRotation); } - V=PHelper().CreateChoose (items,"Objects",&m_AppendRandomObjectsStr,smObject,0,0,32); - V->OnChangeEvent.bind (this,&ESceneObjectTool::OnChangeAppendRandomFlags); + V = PHelper().CreateChoose(items, "Objects", &m_AppendRandomObjectsStr, smObject, 0, 0, 32); + V->OnChangeEvent.bind(this, &ESceneObjectTool::OnChangeAppendRandomFlags); - m_Props->AssignItems (items); - - if (!bUpdateOnly){ + m_Props->AssignItems(items); + + if (!bUpdateOnly) + { if (mrOk==m_Props->ShowPropertiesModal()) - Scene->UndoSave (); - TProperties::DestroyForm (m_Props); + Scene->UndoSave(); + TProperties::DestroyForm(m_Props); } } + //---------------------------------------------------- -void ESceneObjectTool::Clear (bool bSpecific) +void ESceneObjectTool::Clear(bool bSpecific) { - inherited::Clear (bSpecific); - m_AppendRandomMinScale.set (1.f,1.f,1.f); - m_AppendRandomMaxScale.set (1.f,1.f,1.f); - m_AppendRandomMinRotation.set (0.f,0.f,0.f); - m_AppendRandomMaxRotation.set (0.f,0.f,0.f); - m_AppendRandomObjects.clear (); - m_Flags.zero (); + inherited::Clear(bSpecific); + m_AppendRandomMinScale.set(1.f, 1.f, 1.f); + m_AppendRandomMaxScale.set(1.f, 1.f, 1.f); + m_AppendRandomMinRotation.set(0.f, 0.f, 0.f); + m_AppendRandomMaxRotation.set(0.f, 0.f, 0.f); + m_AppendRandomObjects.clear(); + m_Flags.zero(); } -bool ESceneObjectTool::GetBox (Fbox& bb) +bool ESceneObjectTool::GetBox(Fbox &bb) { - bb.invalidate (); + bb.invalidate(); Fbox bbo; - for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){ - (*a_it)->GetBox (bbo); - bb.merge (bbo); + for (ObjectIt a_it = m_Objects.begin(); a_it!=m_Objects.end(); a_it++) + { + (*a_it)->GetBox(bbo); + bb.merge(bbo); } return bb.is_valid(); } -void ESceneObjectTool::OnFrame () +void ESceneObjectTool::OnFrame() { - inherited::OnFrame (); - if (m_Flags.is(flAppendRandomUpdateProps)){ - m_Flags.set (flAppendRandomUpdateProps,FALSE); - FillAppendRandomProperties (true); + inherited::OnFrame(); + if (m_Flags.is(flAppendRandomUpdateProps)) + { + m_Flags.set(flAppendRandomUpdateProps, FALSE); + FillAppendRandomProperties(true); } } -CCustomObject* ESceneObjectTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneObjectTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } + //---------------------------------------------------- void ESceneObjectTool::HighlightTexture(LPCSTR tex_name, bool allow_ratio, u32 t_width, u32 t_height, BOOL mark) { - if (tex_name&&tex_name[0]){ - for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){ - CSceneObject* s_obj = dynamic_cast(*a_it); - if (s_obj->Visible()){ - CEditableObject* e_obj = s_obj->GetReference(); VERIFY(e_obj); - SurfaceVec& s_vec = e_obj->Surfaces(); - for (SurfaceIt it=s_vec.begin(); it!=s_vec.end(); it++){ - if (0==stricmp((*it)->_Texture(),tex_name)){ - Fvector verts[3]; - for (EditMeshIt mesh_it=e_obj->FirstMesh(); mesh_it!=e_obj->LastMesh(); mesh_it++){ - const SurfFaces& surf_faces = (*mesh_it)->GetSurfFaces(); - SurfFaces::const_iterator sf_it = surf_faces.find(*it); - if (sf_it!=surf_faces.end()){ - const IntVec& lst = sf_it->second; - for (IntVec::const_iterator i_it=lst.begin(); i_it!=lst.end(); i_it++){ - e_obj->GetFaceWorld (s_obj->_Transform(),*mesh_it,*i_it,verts); - u32 clr = 0x80FFFFFF; - if (allow_ratio){ + if (tex_name&&tex_name[0]) + { + for (ObjectIt a_it = m_Objects.begin(); a_it!=m_Objects.end(); a_it++) + { + CSceneObject *s_obj = dynamic_cast(*a_it); + if (s_obj->Visible()) + { + CEditableObject *e_obj = s_obj->GetReference(); + VERIFY(e_obj); + SurfaceVec &s_vec = e_obj->Surfaces(); + for (SurfaceIt it = s_vec.begin(); it!=s_vec.end(); it++) + { + if (0==stricmp((*it)->_Texture(), tex_name)) + { + Fvector verts[3]; + for (EditMeshIt mesh_it = e_obj->FirstMesh(); mesh_it!=e_obj->LastMesh(); mesh_it++) + { + const SurfFaces &surf_faces = (*mesh_it)->GetSurfFaces(); + SurfFaces::const_iterator sf_it = surf_faces.find(*it); + if (sf_it!=surf_faces.end()) + { + const IntVec &lst = sf_it->second; + for (IntVec::const_iterator i_it = lst.begin(); i_it!=lst.end(); i_it++) + { + e_obj->GetFaceWorld(s_obj->_Transform(), *mesh_it, *i_it, verts); + u32 clr = 0x80FFFFFF; + if (allow_ratio) + { // select color - const Fvector2* tc[3]; - Fvector c,e01,e02; - e01.sub (verts[1],verts[0]); - e02.sub (verts[2],verts[0]); - float area = c.crossproduct(e01,e02).magnitude()/2.f; - (*mesh_it)->GetFaceTC(*i_it,tc); - e01.sub (Fvector().set(tc[1]->x,tc[1]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0)); - e02.sub (Fvector().set(tc[2]->x,tc[2]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0)); - float p_area = c.crossproduct(e01,e02).magnitude()/2.f; - float pm = _sqrt((p_area*t_width*t_height)/area); - clr = SSceneSummary::SelectPMColor(pm); + const Fvector2 *tc[3]; + Fvector c, e01, e02; + e01.sub(verts[1], verts[0]); + e02.sub(verts[2], verts[0]); + float area = c.crossproduct(e01, e02).magnitude()/2.f; + (*mesh_it)->GetFaceTC(*i_it, tc); + e01.sub(Fvector().set(tc[1]->x, tc[1]->y, 0), Fvector().set(tc[0]->x, tc[0]->y, 0)); + e02.sub(Fvector().set(tc[2]->x, tc[2]->y, 0), Fvector().set(tc[0]->x, tc[0]->y, 0)); + float p_area = c.crossproduct(e01, e02).magnitude()/2.f; + float pm = _sqrt((p_area*t_width*t_height)/area); + clr = SSceneSummary::SelectPMColor(pm); } - Tools->m_DebugDraw.AppendSolidFace(verts[0],verts[1],verts[2],clr,false); - if (mark) Tools->m_DebugDraw.AppendWireFace(verts[0],verts[1],verts[2],clr,false); + Tools->m_DebugDraw.AppendSolidFace(verts[0], verts[1], verts[2], clr, false); + if (mark) + Tools->m_DebugDraw.AppendWireFace(verts[0], verts[1], verts[2], clr, false); } } } @@ -219,5 +253,7 @@ void ESceneObjectTool::HighlightTexture(LPCSTR tex_name, bool allow_ratio, u32 t } } } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneObjectTools.h b/src/editors/LevelEditor/Edit/ESceneObjectTools.h index 566ff1c53c4..64d9064ded6 100644 --- a/src/editors/LevelEditor/Edit/ESceneObjectTools.h +++ b/src/editors/LevelEditor/Edit/ESceneObjectTools.h @@ -6,76 +6,120 @@ class ESceneObjectTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; + typedef ESceneCustomOTool inherited; protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); - - enum{ - flAppendRandomUpdateProps = (1<<27), - flAppendRandomScaleProportional = (1<<28), - flAppendRandom = (1<<29), - flAppendRandomScale = (1<<30), - flAppendRandomRotation = (1<<31), + virtual void CreateControls(); + virtual void RemoveControls(); + + enum + { + flAppendRandomUpdateProps = (1<<27), + flAppendRandomScaleProportional = (1<<28), + flAppendRandom = (1<<29), + flAppendRandomScale = (1<<30), + flAppendRandomRotation = (1<<31), }; - Flags32 m_Flags; - bool ExportBreakableObjects (SExportStreams* F); - bool ExportClimableObjects (SExportStreams* F); - TProperties* m_Props; - void OnChangeAppendRandomFlags(PropValue* prop); -//---------------------------------------------------- + Flags32 m_Flags; + bool ExportBreakableObjects(SExportStreams *F); + bool ExportClimableObjects(SExportStreams *F); + + TProperties *m_Props; + void OnChangeAppendRandomFlags(PropValue *prop); + //---------------------------------------------------- public: - Fvector m_AppendRandomMinScale; - Fvector m_AppendRandomMaxScale; - Fvector m_AppendRandomMinRotation; - Fvector m_AppendRandomMaxRotation; - shared_str m_AppendRandomObjectsStr; - RStringVec m_AppendRandomObjects; + Fvector m_AppendRandomMinScale; + Fvector m_AppendRandomMaxScale; + Fvector m_AppendRandomMinRotation; + Fvector m_AppendRandomMaxRotation; + shared_str m_AppendRandomObjectsStr; + RStringVec m_AppendRandomObjects; public: - ESceneObjectTool (); + ESceneObjectTool(); + + virtual bool AllowEnabling() + { + return false; + } + + virtual bool Validate(bool full_build); - virtual bool AllowEnabling (){return false;} + virtual void OnFrame(); - virtual bool Validate (bool full_build); + // definition + IC LPCSTR ClassName() + { + return "scene_object"; + } - virtual void OnFrame (); + IC LPCSTR ClassDesc() + { + return "Scene Object"; + } - // definition - IC LPCSTR ClassName (){return "scene_object";} - IC LPCSTR ClassDesc (){return "Scene Object";} - IC int RenderPriority (){return 1;} + IC - bool GetBox (Fbox& bb); + int RenderPriority() + { + return 1; + } + + bool GetBox(Fbox &bb); + + virtual void Clear(bool bSpecific = false); - virtual void Clear (bool bSpecific=false); // IO - virtual bool IsNeedSave (){return true;} + virtual bool IsNeedSave() + { + return true; + } - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); // append random - void FillAppendRandomProperties (bool bUpdateOnly=false); - void ActivateAppendRandom (BOOL val){m_Flags.set(flAppendRandom,val);} - BOOL IsAppendRandomActive (){return m_Flags.is(flAppendRandom);} - BOOL IsAppendRandomScaleActive (){return m_Flags.is(flAppendRandomScale);} - BOOL IsAppendRandomRotationActive(){return m_Flags.is(flAppendRandomRotation);} - BOOL IsAppendRandomScaleProportional(){return m_Flags.is(flAppendRandomScaleProportional);} + void FillAppendRandomProperties(bool bUpdateOnly = false); + + void ActivateAppendRandom(BOOL val) + { + m_Flags.set(flAppendRandom, val); + } + + BOOL IsAppendRandomActive() + { + return m_Flags.is(flAppendRandom); + } + + BOOL IsAppendRandomScaleActive() + { + return m_Flags.is(flAppendRandomScale); + } + + BOOL IsAppendRandomRotationActive() + { + return m_Flags.is(flAppendRandomRotation); + } + + BOOL IsAppendRandomScaleProportional() + { + return m_Flags.is(flAppendRandomScaleProportional); + } // tools - virtual bool ExportGame (SExportStreams* F); - virtual void GetStaticDesc (int& v_cnt, int& f_cnt, bool b_selected_only, bool b_cform); + virtual bool ExportGame(SExportStreams *F); + virtual void GetStaticDesc(int &v_cnt, int &f_cnt, bool b_selected_only, bool b_cform); - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); - virtual void HighlightTexture (LPCSTR tex_name, bool allow_ratio, u32 t_width, u32 t_height, BOOL mark); + virtual void HighlightTexture(LPCSTR tex_name, bool allow_ratio, u32 t_width, u32 t_height, BOOL mark); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneObjectToolsExportBreakable.cpp b/src/editors/LevelEditor/Edit/ESceneObjectToolsExportBreakable.cpp index 3ae4c5fd5d5..7c41ddb9b62 100644 --- a/src/editors/LevelEditor/Edit/ESceneObjectToolsExportBreakable.cpp +++ b/src/editors/LevelEditor/Edit/ESceneObjectToolsExportBreakable.cpp @@ -2,17 +2,17 @@ #pragma hdrstop #include "ESceneObjectTools.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditMesh.h" #include "SceneObject.h" #include "scene.h" -#include "../ECore/Editor/ExportSkeleton.h" +#include "editors/ECore/Editor/ExportSkeleton.h" //.#include "clsid_game.h" -#include "../ECore/Editor/ui_main.h" -#include "ui_leveltools.h" -#include "../ECore/Editor/GeometryCollector.h" +#include "editors/ECore/Editor/ui_main.h" +#include "UI_LevelTools.h" +#include "editors/ECore/Editor/GeometryCollector.h" -#include "../../xrServerEntities/xrServer_Objects_Abstract.h" +#include "xrServerEntities/xrServer_Objects_Abstract.h" #include "ESceneSpawnTools.h" #include "GeometryPartExtractor.h" #include "ResourceManager.h" @@ -20,142 +20,178 @@ static bool s_draw_dbg = false; //---------------------------------------------------- -IC bool build_mesh(const Fmatrix& parent, CEditableMesh* mesh, CGeomPartExtractor* extractor, u32 game_mtl_mask, BOOL ignore_shader) +IC + +bool build_mesh(const Fmatrix &parent, CEditableMesh *mesh, CGeomPartExtractor *extractor, u32 game_mtl_mask, BOOL ignore_shader) { - bool bResult = true; - mesh->GenerateVNormals (&parent); + bool bResult = true; + mesh->GenerateVNormals(&parent); // fill faces - for (SurfFaces::const_iterator sp_it=mesh->GetSurfFaces().begin(); sp_it!=mesh->GetSurfFaces().end(); sp_it++){ - const IntVec& face_lst = sp_it->second; - CSurface* surf = sp_it->first; - int gm_id = surf->_GameMtl(); - if (gm_id==GAMEMTL_NONE_ID){ - ELog.DlgMsg (mtError,"Object '%s', surface '%s' contain invalid game material.",mesh->Parent()->m_LibName.c_str(),surf->_Name()); - bResult = FALSE; - break; + for (SurfFaces::const_iterator sp_it = mesh->GetSurfFaces().begin(); sp_it!=mesh->GetSurfFaces().end(); sp_it++) + { + const IntVec &face_lst = sp_it->second; + CSurface *surf = sp_it->first; + int gm_id = surf->_GameMtl(); + if (gm_id==GAMEMTL_NONE_ID) + { + ELog.DlgMsg(mtError, "Object '%s', surface '%s' contain invalid game material.", mesh->Parent()->m_LibName.c_str(), surf->_Name()); + bResult = FALSE; + break; } - SGameMtl* M = GMLib.GetMaterialByID(gm_id); - if (0==M){ - ELog.DlgMsg (mtError,"Object '%s', surface '%s' contain undefined game material.",mesh->Parent()->m_LibName.c_str(),surf->_Name()); - bResult = FALSE; - break; + SGameMtl *M = GMLib.GetMaterialByID(gm_id); + if (0==M) + { + ELog.DlgMsg(mtError, "Object '%s', surface '%s' contain undefined game material.", mesh->Parent()->m_LibName.c_str(), surf->_Name()); + bResult = FALSE; + break; } - if (!M->Flags.is(game_mtl_mask)) continue; + if (!M->Flags.is(game_mtl_mask)) + continue; // check engine shader compatibility - if (!ignore_shader){ - IBlender* B = EDevice.Resources->_FindBlender(surf->_ShaderName()); - if (FALSE==B){ - ELog.Msg (mtError,"Can't find engine shader '%s'. Object '%s', surface '%s'. Export interrupted.",surf->_ShaderName(),mesh->Parent()->m_LibName.c_str(),surf->_Name()); - bResult = FALSE; - break; + if (!ignore_shader) + { + IBlender *B = EDevice.Resources->_FindBlender(surf->_ShaderName()); + if (FALSE==B) + { + ELog.Msg(mtError, "Can't find engine shader '%s'. Object '%s', surface '%s'. Export interrupted.", surf->_ShaderName(), mesh->Parent()->m_LibName.c_str(), surf->_Name()); + bResult = FALSE; + break; } - if (TRUE==B->canBeLMAPped()){ - ELog.Msg (mtError,"Object '%s', surface '%s' contain static engine shader - '%s'. Export interrupted.",mesh->Parent()->m_LibName.c_str(),surf->_Name(),surf->_ShaderName()); - bResult = FALSE; - break; + if (TRUE==B->canBeLMAPped()) + { + ELog.Msg(mtError, "Object '%s', surface '%s' contain static engine shader - '%s'. Export interrupted.", mesh->Parent()->m_LibName.c_str(), surf->_Name(), surf->_ShaderName()); + bResult = FALSE; + break; } } - - const st_Face* faces = mesh->GetFaces(); VERIFY(faces); - const Fvector* vn = mesh->GetVNormals(); VERIFY(vn); - const Fvector* pts = mesh->GetVertices(); VERIFY(pts); - for (IntVec::const_iterator f_it=face_lst.begin(); f_it!=face_lst.end(); f_it++){ - const st_Face& face = faces[*f_it]; - Fvector v[3],n[3]; - parent.transform_tiny (v[0],pts[face.pv[0].pindex]); - parent.transform_tiny (v[1],pts[face.pv[1].pindex]); - parent.transform_tiny (v[2],pts[face.pv[2].pindex]); - parent.transform_dir (n[0],vn[*f_it*3+0]); n[0].normalize(); - parent.transform_dir (n[1],vn[*f_it*3+1]); n[1].normalize(); - parent.transform_dir (n[2],vn[*f_it*3+2]); n[2].normalize(); - const Fvector2* uv[3]; - mesh->GetFaceTC (*f_it,uv); - extractor->AppendFace (surf,v,n,uv); + + const st_Face *faces = mesh->GetFaces(); + VERIFY(faces); + const Fvector *vn = mesh->GetVNormals(); + VERIFY(vn); + const Fvector *pts = mesh->GetVertices(); + VERIFY(pts); + for (IntVec::const_iterator f_it = face_lst.begin(); f_it!=face_lst.end(); f_it++) + { + const st_Face &face = faces[*f_it]; + Fvector v[3], n[3]; + parent.transform_tiny(v[0], pts[face.pv[0].pindex]); + parent.transform_tiny(v[1], pts[face.pv[1].pindex]); + parent.transform_tiny(v[2], pts[face.pv[2].pindex]); + parent.transform_dir(n[0], vn[*f_it*3+0]); + n[0].normalize(); + parent.transform_dir(n[1], vn[*f_it*3+1]); + n[1].normalize(); + parent.transform_dir(n[2], vn[*f_it*3+2]); + n[2].normalize(); + const Fvector2 *uv[3]; + mesh->GetFaceTC(*f_it, uv); + extractor->AppendFace(surf, v, n, uv); } - if (!bResult) break; + if (!bResult) + break; } - mesh->UnloadVNormals (); + mesh->UnloadVNormals(); return bResult; } -bool ESceneObjectTool::ExportBreakableObjects(SExportStreams* F) +bool ESceneObjectTool::ExportBreakableObjects(SExportStreams *F) { bool bResult = true; - CGeomPartExtractor* extractor=0; + CGeomPartExtractor *extractor = 0; - Fbox bb; - if (!GetBox(bb)) return false; + Fbox bb; + if (!GetBox(bb)) + return false; - extractor = xr_new(); - extractor->Initialize(bb,EPS_L,2); + extractor = xr_new(); + extractor->Initialize(bb, EPS_L, 2); - UI->SetStatus ("Export breakable objects..."); + UI->SetStatus("Export breakable objects..."); // collect verts&&faces { - SPBItem* pb = UI->ProgressStart(m_Objects.size(),"Prepare geometry..."); - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++){ + SPBItem *pb = UI->ProgressStart(m_Objects.size(), "Prepare geometry..."); + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) + { pb->Inc(); - CSceneObject* obj = dynamic_cast(*it); VERIFY(obj); - if (obj->IsStatic()){ - CEditableObject *O = obj->GetReference(); - const Fmatrix& T = obj->_Transform(); - for(EditMeshIt M=O->FirstMesh();M!=O->LastMesh();M++) - if (!build_mesh (T,*M,extractor,SGameMtl::flBreakable,FALSE)){bResult=false;break;} + CSceneObject *obj = dynamic_cast(*it); + VERIFY(obj); + if (obj->IsStatic()) + { + CEditableObject *O = obj->GetReference(); + const Fmatrix &T = obj->_Transform(); + for (EditMeshIt M = O->FirstMesh(); M!=O->LastMesh(); M++) + if (!build_mesh(T, *M, extractor, SGameMtl::flBreakable, FALSE)) + { + bResult = false; + break; + } } } UI->ProgressEnd(pb); } - if (!extractor->Process()) bResult = false; + if (!extractor->Process()) + bResult = false; // export parts - if (bResult){ - SBPartVec& parts = extractor->GetParts(); - SPBItem* pb = UI->ProgressStart(parts.size(),"Export Parts..."); - for (SBPartVecIt p_it=parts.begin(); p_it!=parts.end(); p_it++){ + if (bResult) + { + SBPartVec &parts = extractor->GetParts(); + SPBItem *pb = UI->ProgressStart(parts.size(), "Export Parts..."); + for (SBPartVecIt p_it = parts.begin(); p_it!=parts.end(); p_it++) + { pb->Inc(); - SBPart* P = *p_it; - if (P->Valid()){ + SBPart *P = *p_it; + if (P->Valid()) + { // export visual - AnsiString sn = AnsiString().sprintf("meshes\\brkbl#%d.ogf",(p_it-parts.begin())); - xr_string fn = Scene->LevelPath()+sn.c_str(); - IWriter* W = FS.w_open(fn.c_str()); R_ASSERT(W); - if (!P->Export(*W,1)){ - ELog.DlgMsg (mtError,"Invalid breakable object."); - bResult = false; + AnsiString sn = AnsiString().sprintf("meshes\\brkbl#%d.ogf", (p_it-parts.begin())); + xr_string fn = Scene->LevelPath()+sn.c_str(); + IWriter *W = FS.w_open(fn.c_str()); + R_ASSERT(W); + if (!P->Export(*W, 1)) + { + ELog.DlgMsg(mtError, "Invalid breakable object."); + bResult = false; break; } - FS.w_close (W); + FS.w_close(W); // export spawn object { - AnsiString entity_ref = "breakable_object"; - IServerEntity* m_Data = create_entity(entity_ref.c_str()); VERIFY(m_Data); - CSE_Visual* m_Visual = m_Data->visual(); VERIFY(m_Visual); + AnsiString entity_ref = "breakable_object"; + IServerEntity *m_Data = create_entity(entity_ref.c_str()); + VERIFY(m_Data); + CSE_Visual *m_Visual = m_Data->visual(); + VERIFY(m_Visual); // set params - m_Data->set_name (entity_ref.c_str()); - m_Data->set_name_replace (sn.c_str()); - m_Data->position().set (P->m_RefOffset); - m_Data->angle().set (P->m_RefRotate); - m_Visual->set_visual (sn.c_str(),false); + m_Data->set_name(entity_ref.c_str()); + m_Data->set_name_replace(sn.c_str()); + m_Data->position().set(P->m_RefOffset); + m_Data->angle().set(P->m_RefRotate); + m_Visual->set_visual(sn.c_str(), false); - if (s_draw_dbg){ + if (s_draw_dbg) + { Fmatrix MX; - MX.setXYZi (P->m_RefRotate); - MX.translate_over (P->m_RefOffset); - Fvector DR = {0,0,1}; - MX.transform_dir (DR); - Tools->m_DebugDraw.AppendLine(P->m_RefOffset,Fvector().mad(P->m_RefOffset,MX.k,1.f),0xFF0000FF,false,false); + MX.setXYZi(P->m_RefRotate); + MX.translate_over(P->m_RefOffset); + Fvector DR = {0,0,1}; + MX.transform_dir(DR); + Tools->m_DebugDraw.AppendLine(P->m_RefOffset, Fvector().mad(P->m_RefOffset, MX.k, 1.f), 0xFF0000FF, false, false); } - NET_Packet Packet; - m_Data->Spawn_Write (Packet,TRUE); + NET_Packet Packet; + m_Data->Spawn_Write(Packet, TRUE); - F->spawn.stream.open_chunk (F->spawn.chunk++); - F->spawn.stream.w (Packet.B.data,Packet.B.count); - F->spawn.stream.close_chunk (); - destroy_entity (m_Data); + F->spawn.stream.open_chunk(F->spawn.chunk++); + F->spawn.stream.w(Packet.B.data, Packet.B.count); + F->spawn.stream.close_chunk(); + destroy_entity(m_Data); } - }else{ - ELog.Msg(mtError,"Can't export invalid part #%d",p_it-parts.begin()); + } + else + { + ELog.Msg(mtError, "Can't export invalid part #%d", p_it-parts.begin()); } } UI->ProgressEnd(pb); @@ -165,20 +201,24 @@ bool ESceneObjectTool::ExportBreakableObjects(SExportStreams* F) return bResult; } + //---------------------------------------------------- -IC BOOL OrientToNorm(Fvector& local_norm, Fmatrix33& form, Fvector& hs) +IC BOOL OrientToNorm(Fvector &local_norm, Fmatrix33 &form, Fvector &hs) { - Fvector * ax_pointer= (Fvector*)&form; - int max_proj=0,min_size=0; - for (u32 k=1; k<3; k++){ + Fvector *ax_pointer = (Fvector*)&form; + int max_proj = 0, min_size = 0; + for (u32 k = 1; k<3; k++) + { if (_abs(local_norm[k])>_abs(local_norm[max_proj])) - max_proj=k; + max_proj = k; if (hs[k](); - extractor->Initialize (bb,EPS_L,int_max); + extractor = xr_new(); + extractor->Initialize(bb, EPS_L, int_max); - UI->SetStatus ("Export climable objects..."); + UI->SetStatus("Export climable objects..."); // collect verts&&faces { - SPBItem* pb = UI->ProgressStart(m_Objects.size(), "Prepare geometry..."); - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++) + SPBItem *pb = UI->ProgressStart(m_Objects.size(), "Prepare geometry..."); + for (ObjectIt it = m_Objects.begin(); it!=m_Objects.end(); it++) { pb->Inc(); - CSceneObject* obj = dynamic_cast(*it); - VERIFY (obj); + CSceneObject *obj = dynamic_cast(*it); + VERIFY(obj); if (obj->IsStatic()) { - CEditableObject *O = obj->GetReference(); - const Fmatrix& T = obj->_Transform(); - - for(EditMeshIt M =O->FirstMesh(); M!=O->LastMesh(); M++) - if (!build_mesh (T, *M, extractor, SGameMtl::flClimable, TRUE)) + CEditableObject *O = obj->GetReference(); + const Fmatrix &T = obj->_Transform(); + + for (EditMeshIt M = O->FirstMesh(); M!=O->LastMesh(); M++) + if (!build_mesh(T, *M, extractor, SGameMtl::flClimable, TRUE)) { - bResult = false; - break; + bResult = false; + break; } } } UI->ProgressEnd(pb); } if (!extractor->Process()) - bResult = false; + bResult = false; // export parts if (bResult) { - SBPartVec& parts = extractor->GetParts(); - SPBItem* pb = UI->ProgressStart(parts.size(),"Export Parts..."); - for (SBPartVecIt p_it=parts.begin(); p_it!=parts.end(); p_it++) + SBPartVec &parts = extractor->GetParts(); + SPBItem *pb = UI->ProgressStart(parts.size(), "Export Parts..."); + for (SBPartVecIt p_it = parts.begin(); p_it!=parts.end(); p_it++) { - pb->Inc (); - SBPart* P = *p_it; + pb->Inc(); + SBPart *P = *p_it; if (P->Valid()) { // export visual - AnsiString sn = AnsiString().sprintf("clmbl#%d",(p_it-parts.begin())); + AnsiString sn = AnsiString().sprintf("clmbl#%d", (p_it-parts.begin())); - Fvector local_normal = {0,0,0}; + Fvector local_normal = {0,0,0}; LPCSTR mat_name = NULL; - for (SBFaceVecIt it=P->m_Faces.begin(); it!=P->m_Faces.end(); it++) + for (SBFaceVecIt it = P->m_Faces.begin(); it!=P->m_Faces.end(); it++) { - for (u32 k=0; k<3; k++) - local_normal.add ((*it)->n[k]); + for (u32 k = 0; k<3; k++) + local_normal.add((*it)->n[k]); - mat_name = (*it)->surf->_GameMtlName(); + mat_name = (*it)->surf->_GameMtlName(); } - local_normal.normalize_safe (); - + local_normal.normalize_safe(); + // export spawn object { - AnsiString entity_ref = "climable_object"; - IServerEntity* m_Data = create_entity(entity_ref.c_str()); VERIFY(m_Data); - IServerEntityShape* m_Shape = m_Data->shape(); VERIFY(m_Shape); -// CSE_Visual* m_Visual = m_Data->visual(); VERIFY(m_Visual); + AnsiString entity_ref = "climable_object"; + IServerEntity *m_Data = create_entity(entity_ref.c_str()); + VERIFY(m_Data); + IServerEntityShape *m_Shape = m_Data->shape(); + VERIFY(m_Shape); + // CSE_Visual* m_Visual = m_Data->visual(); VERIFY(m_Visual); // set params - m_Data->set_name (entity_ref.c_str()); - m_Data->set_name_replace (sn.c_str()); + m_Data->set_name(entity_ref.c_str()); + m_Data->set_name_replace(sn.c_str()); // set shape - CShapeData::shape_def shape; - shape.type = CShapeData::cfBox; - shape.data.box.scale ((P->m_BBox.max.x-P->m_BBox.min.x)*0.5f, - (P->m_BBox.max.y-P->m_BBox.min.y)*0.5f, - (P->m_BBox.max.z-P->m_BBox.min.z)*0.5f); - m_Shape->assign_shapes (&shape,1); + CShapeData::shape_def shape; + shape.type = CShapeData::cfBox; + shape.data.box.scale((P->m_BBox.max.x-P->m_BBox.min.x)*0.5f, + (P->m_BBox.max.y-P->m_BBox.min.y)*0.5f, + (P->m_BBox.max.z-P->m_BBox.min.z)*0.5f); + m_Shape->assign_shapes(&shape, 1); // orientate object - if (!OrientToNorm(local_normal,P->m_OBB.m_rotate,P->m_OBB.m_halfsize)) + if (!OrientToNorm(local_normal, P->m_OBB.m_rotate, P->m_OBB.m_halfsize)) { - ELog.Msg(mtError,"Invalid climable object found. [%3.2f, %3.2f, %3.2f]",VPUSH(P->m_RefOffset)); + ELog.Msg(mtError, "Invalid climable object found. [%3.2f, %3.2f, %3.2f]", VPUSH(P->m_RefOffset)); } else { - Fmatrix M; M.set (P->m_OBB.m_rotate.i,P->m_OBB.m_rotate.j,P->m_OBB.m_rotate.k,P->m_OBB.m_translate); - M.getXYZ (P->m_RefRotate); // íå i ïîòîìó ÷òî â äâèæêå òàê - m_Data->position().set (P->m_RefOffset); - m_Data->angle().set (P->m_RefRotate); + Fmatrix M; + M.set(P->m_OBB.m_rotate.i, P->m_OBB.m_rotate.j, P->m_OBB.m_rotate.k, P->m_OBB.m_translate); + M.getXYZ(P->m_RefRotate); // íå i ïîòîìó ÷òî â äâèæêå òàê + m_Data->position().set(P->m_RefOffset); + m_Data->angle().set(P->m_RefRotate); m_Data->set_additional_info((void*)mat_name); - NET_Packet Packet; - m_Data->Spawn_Write (Packet,TRUE); + NET_Packet Packet; + m_Data->Spawn_Write(Packet, TRUE); - F->spawn.stream.open_chunk (F->spawn.chunk++); - F->spawn.stream.w (Packet.B.data,Packet.B.count); - F->spawn.stream.close_chunk (); + F->spawn.stream.open_chunk(F->spawn.chunk++); + F->spawn.stream.w(Packet.B.data, Packet.B.count); + F->spawn.stream.close_chunk(); if (s_draw_dbg) { Tools->m_DebugDraw.AppendOBB(P->m_OBB); - M.transform_dir (local_normal); - Tools->m_DebugDraw.AppendLine(P->m_RefOffset,Fvector().mad(P->m_RefOffset,local_normal,1.f)); + M.transform_dir(local_normal); + Tools->m_DebugDraw.AppendLine(P->m_RefOffset, Fvector().mad(P->m_RefOffset, local_normal, 1.f)); } } - destroy_entity (m_Data); + destroy_entity(m_Data); } - }else + } + else { - ELog.Msg(mtError,"Can't export invalid part #%d",p_it-parts.begin()); + ELog.Msg(mtError, "Can't export invalid part #%d", p_it-parts.begin()); } } - UI->ProgressEnd (pb); + UI->ProgressEnd(pb); } // clean up - xr_delete (extractor); + xr_delete(extractor); - return bResult; + return bResult; } diff --git a/src/editors/LevelEditor/Edit/ESceneObjectToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneObjectToolsIO.cpp index 5260b36cbf7..ca9aae22031 100644 --- a/src/editors/LevelEditor/Edit/ESceneObjectToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneObjectToolsIO.cpp @@ -5,177 +5,199 @@ #include "SceneObject.h" // chunks -static const u16 OBJECT_TOOLS_VERSION = 0x0000; +static const u16 OBJECT_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, - CHUNK_APPEND_RANDOM = 0x1002ul, - CHUNK_FLAGS = 0x1003ul, +enum +{ + CHUNK_VERSION = 0x1001ul, + CHUNK_APPEND_RANDOM = 0x1002ul, + CHUNK_FLAGS = 0x1003ul, }; -bool ESceneObjectTool::LoadLTX(CInifile& ini) + +bool ESceneObjectTool::LoadLTX(CInifile &ini) { - u32 version = ini.r_u32("main", "version"); - if( version!=OBJECT_TOOLS_VERSION ) + u32 version = ini.r_u32("main", "version"); + if (version!=OBJECT_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); - return false; + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); + return false; } - inherited::LoadLTX (ini); + inherited::LoadLTX(ini); - m_Flags.assign (ini.r_u32("main", "flags")); + m_Flags.assign(ini.r_u32("main", "flags")); - m_AppendRandomMinScale = ini.r_fvector3 ("AppendRandom", "AppendRandomMinScale"); - m_AppendRandomMaxScale = ini.r_fvector3 ("AppendRandom", "AppendRandomMaxScale"); - m_AppendRandomMinRotation = ini.r_fvector3 ("AppendRandom", "AppendRandomMinRotation"); - m_AppendRandomMaxRotation = ini.r_fvector3 ("AppendRandom", "AppendRandomMaxRotation"); - u32 cnt = ini.r_u32 ("AppendRandom", "AppendRandomObjects_size"); + m_AppendRandomMinScale = ini.r_fvector3("AppendRandom", "AppendRandomMinScale"); + m_AppendRandomMaxScale = ini.r_fvector3("AppendRandom", "AppendRandomMaxScale"); + m_AppendRandomMinRotation = ini.r_fvector3("AppendRandom", "AppendRandomMinRotation"); + m_AppendRandomMaxRotation = ini.r_fvector3("AppendRandom", "AppendRandomMaxRotation"); + u32 cnt = ini.r_u32("AppendRandom", "AppendRandomObjects_size"); - for (int i=0; iSelected()) - continue; + if (b_selected_only&&!obj->Selected()) + continue; - if(obj->IsStatic()||(b_cform && obj->IsMUStatic())) + if (obj->IsStatic()||(b_cform&&obj->IsMUStatic())) { - f_cnt += obj->GetFaceCount(); - v_cnt += obj->GetVertexCount(); + f_cnt += obj->GetFaceCount(); + v_cnt += obj->GetVertexCount(); } } } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneObjectTools_.cpp b/src/editors/LevelEditor/Edit/ESceneObjectTools_.cpp index 7c2641e9877..cb1c1727d78 100644 --- a/src/editors/LevelEditor/Edit/ESceneObjectTools_.cpp +++ b/src/editors/LevelEditor/Edit/ESceneObjectTools_.cpp @@ -2,7 +2,7 @@ #pragma hdrstop #include "ESceneObjectTools.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "ESceneObjectControls.h" #include "FrameObject.h" #include "SceneObject.h" @@ -14,195 +14,227 @@ #include "EditObject.h" #include "EditMesh.h" -ESceneObjectTools::ESceneObjectTools():ESceneCustomOTools(OBJCLASS_SCENEOBJECT) +ESceneObjectTools::ESceneObjectTools(): ESceneCustomOTools(OBJCLASS_SCENEOBJECT) { - m_AppendRandomMinScale.set (1.f,1.f,1.f); - m_AppendRandomMaxScale.set (1.f,1.f,1.f); - m_AppendRandomMinRotation.set (0.f,0.f,0.f); - m_AppendRandomMaxRotation.set (0.f,0.f,0.f); - m_Flags.zero (); - m_Props = 0; + m_AppendRandomMinScale.set(1.f, 1.f, 1.f); + m_AppendRandomMaxScale.set(1.f, 1.f, 1.f); + m_AppendRandomMinRotation.set(0.f, 0.f, 0.f); + m_AppendRandomMaxRotation.set(0.f, 0.f, 0.f); + m_Flags.zero(); + m_Props = 0; } void ESceneObjectTools::CreateControls() { - inherited::CreateDefaultControls(estDefault); - AddControl (xr_new(estDefault,etaAdd, this)); - // frame - pFrame = xr_new((TComponent*)0,this); + inherited::CreateDefaultControls(estDefault); + AddControl(xr_new(estDefault, etaAdd, this)); + // frame + pFrame = xr_new((TComponent*)0, this); } + //---------------------------------------------------- - + void ESceneObjectTools::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- bool ESceneObjectTools::Validate() { - if (!inherited::Validate()) return false; + if (!inherited::Validate()) + return false; // verify position & refs duplicate bool bRes = true; - CSceneObject *A, *B; - for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){ + CSceneObject* A, * B; + for (ObjectIt a_it = m_Objects.begin(); a_it!=m_Objects.end(); a_it++) + { A = (CSceneObject*)(*a_it); - for (ObjectIt b_it=m_Objects.begin(); b_it!=m_Objects.end(); b_it++){ + for (ObjectIt b_it = m_Objects.begin(); b_it!=m_Objects.end(); b_it++) + { B = (CSceneObject*)(*b_it); - if (A==B) continue; - if (A->RefCompare(B->GetReference())){ - if (A->PPosition.similar(B->PPosition,EPS_L)){ - bRes = false; - ELog.Msg(mtError,"Duplicate object position '%s'-'%s' with reference '%s'.",A->Name,B->Name,A->GetRefName()); + if (A==B) + continue; + if (A->RefCompare(B->GetReference())) + { + if (A->PPosition.similar(B->PPosition, EPS_L)) + { + bRes = false; + ELog.Msg(mtError, "Duplicate object position '%s'-'%s' with reference '%s'.", A->Name, B->Name, A->GetRefName()); } } } } return bRes; } + //---------------------------------------------------- -void ESceneObjectTools::OnChangeAppendRandomFlags(PropValue* prop) +void ESceneObjectTools::OnChangeAppendRandomFlags(PropValue *prop) { - m_Flags.set(flAppendRandomUpdateProps,TRUE); + m_Flags.set(flAppendRandomUpdateProps, TRUE); } void ESceneObjectTools::FillAppendRandomProperties(bool bUpdateOnly) { - if (!bUpdateOnly) m_Props = TProperties::CreateModalForm("Random Append Properties",true); + if (!bUpdateOnly) + m_Props = TProperties::CreateModalForm("Random Append Properties", true); shared_str temp; - temp = _ListToSequence(m_AppendRandomObjects).c_str(); - - PropValue* V; - - PropItemVec items; - V=PHelper().CreateFlag32 (items,"Scale", &m_Flags, flAppendRandomScale); - V->OnChangeEvent.bind (this,&ESceneObjectTools::OnChangeAppendRandomFlags); - if (m_Flags.is(flAppendRandomScale)){ - V=PHelper().CreateFlag32 (items,"Scale\\Proportional",&m_Flags, flAppendRandomScaleProportional); - V->OnChangeEvent.bind (this,&ESceneObjectTools::OnChangeAppendRandomFlags); - if (m_Flags.is(flAppendRandomScaleProportional)){ - PHelper().CreateFloat (items,"Scale\\Minimum", &m_AppendRandomMinScale.x,0.001f,1000.f,0.001f,3); - PHelper().CreateFloat (items,"Scale\\Maximum", &m_AppendRandomMaxScale.x,0.001f,1000.f,0.001f,3); - }else{ - PHelper().CreateVector (items,"Scale\\Minimum", &m_AppendRandomMinScale,0.001f,1000.f,0.001f,3); - PHelper().CreateVector (items,"Scale\\Maximum", &m_AppendRandomMaxScale,0.001f,1000.f,0.001f,3); + temp = _ListToSequence(m_AppendRandomObjects).c_str(); + + PropValue *V; + + PropItemVec items; + V = PHelper().CreateFlag32(items, "Scale", &m_Flags, flAppendRandomScale); + V->OnChangeEvent.bind(this, &ESceneObjectTools::OnChangeAppendRandomFlags); + if (m_Flags.is(flAppendRandomScale)) + { + V = PHelper().CreateFlag32(items, "Scale\\Proportional", &m_Flags, flAppendRandomScaleProportional); + V->OnChangeEvent.bind(this, &ESceneObjectTools::OnChangeAppendRandomFlags); + if (m_Flags.is(flAppendRandomScaleProportional)) + { + PHelper().CreateFloat(items, "Scale\\Minimum", &m_AppendRandomMinScale.x, 0.001f, 1000.f, 0.001f, 3); + PHelper().CreateFloat(items, "Scale\\Maximum", &m_AppendRandomMaxScale.x, 0.001f, 1000.f, 0.001f, 3); + } + else + { + PHelper().CreateVector(items, "Scale\\Minimum", &m_AppendRandomMinScale, 0.001f, 1000.f, 0.001f, 3); + PHelper().CreateVector(items, "Scale\\Maximum", &m_AppendRandomMaxScale, 0.001f, 1000.f, 0.001f, 3); } } - V=PHelper().CreateFlag32 (items,"Rotate",&m_Flags, flAppendRandomRotation); - V->OnChangeEvent.bind (this,&ESceneObjectTools::OnChangeAppendRandomFlags); - if (m_Flags.is(flAppendRandomRotation)){ - PHelper().CreateAngle3 (items,"Rotate\\Minimum",&m_AppendRandomMinRotation); - PHelper().CreateAngle3 (items,"Rotate\\Maximum",&m_AppendRandomMaxRotation); + V = PHelper().CreateFlag32(items, "Rotate", &m_Flags, flAppendRandomRotation); + V->OnChangeEvent.bind(this, &ESceneObjectTools::OnChangeAppendRandomFlags); + if (m_Flags.is(flAppendRandomRotation)) + { + PHelper().CreateAngle3(items, "Rotate\\Minimum", &m_AppendRandomMinRotation); + PHelper().CreateAngle3(items, "Rotate\\Maximum", &m_AppendRandomMaxRotation); } - V=PHelper().CreateChoose (items,"Objects",&temp,smObject,0,0,32); - - m_Props->AssignItems (items); - - if (!bUpdateOnly){ - if (mrOk==m_Props->ShowPropertiesModal()){ - _SequenceToList (m_AppendRandomObjects,*temp); - Scene->UndoSave (); + V = PHelper().CreateChoose(items, "Objects", &temp, smObject, 0, 0, 32); + + m_Props->AssignItems(items); + + if (!bUpdateOnly) + { + if (mrOk==m_Props->ShowPropertiesModal()) + { + _SequenceToList(m_AppendRandomObjects, *temp); + Scene->UndoSave(); } TProperties::DestroyForm(m_Props); } } + //---------------------------------------------------- -void ESceneObjectTools::Clear (bool bSpecific) +void ESceneObjectTools::Clear(bool bSpecific) { - inherited::Clear (bSpecific); - m_AppendRandomMinScale.set (1.f,1.f,1.f); - m_AppendRandomMaxScale.set (1.f,1.f,1.f); - m_AppendRandomMinRotation.set (0.f,0.f,0.f); - m_AppendRandomMaxRotation.set (0.f,0.f,0.f); - m_AppendRandomObjects.clear (); - m_Flags.zero (); + inherited::Clear(bSpecific); + m_AppendRandomMinScale.set(1.f, 1.f, 1.f); + m_AppendRandomMaxScale.set(1.f, 1.f, 1.f); + m_AppendRandomMinRotation.set(0.f, 0.f, 0.f); + m_AppendRandomMaxRotation.set(0.f, 0.f, 0.f); + m_AppendRandomObjects.clear(); + m_Flags.zero(); } -bool ESceneObjectTools::GetBox (Fbox& bb) +bool ESceneObjectTools::GetBox(Fbox &bb) { - bb.invalidate (); + bb.invalidate(); Fbox bbo; - for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){ - (*a_it)->GetBox (bbo); - bb.merge (bbo); + for (ObjectIt a_it = m_Objects.begin(); a_it!=m_Objects.end(); a_it++) + { + (*a_it)->GetBox(bbo); + bb.merge(bbo); } return bb.is_valid(); } -void ESceneObjectTools::OnFrame () +void ESceneObjectTools::OnFrame() { - inherited::OnFrame (); - if (m_Flags.is(flAppendRandomUpdateProps)){ - m_Flags.set (flAppendRandomUpdateProps,FALSE); - FillAppendRandomProperties (true); + inherited::OnFrame(); + if (m_Flags.is(flAppendRandomUpdateProps)) + { + m_Flags.set(flAppendRandomUpdateProps, FALSE); + FillAppendRandomProperties(true); } } -CCustomObject* ESceneObjectTools::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneObjectTools::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTools = this; + CCustomObject*O = xr_new(data, name); + O->ParentTools = this; return O; } + //---------------------------------------------------- static const u32 ratio_count = 6; u32 ratio_colors[ratio_count][2] = {{0,0x80FF0000}, - {50,0x80FFFF00}, - {150,0x8000FF00}, - {250,0x8000FFFF}, - {1000,0x800000FF}, - {1000000,0x800000FF}, - }; + {50,0x80FFFF00}, + {150,0x8000FF00}, + {250,0x8000FFFF}, + {1000,0x800000FF}, + {1000000,0x800000FF}, +}; void ESceneObjectTools::HighlightTexture(LPCSTR tex_name, bool allow_ratio, u32 t_width, u32 t_height, BOOL mark) { - if (tex_name&&tex_name[0]){ - for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){ - CSceneObject* s_obj = dynamic_cast(*a_it); - CEditableObject* e_obj = s_obj->GetReference(); VERIFY(e_obj); - SurfaceVec& s_vec = e_obj->Surfaces(); - for (SurfaceIt it=s_vec.begin(); it!=s_vec.end(); it++){ - if (0==stricmp((*it)->_Texture(),tex_name)){ - Fvector verts[3]; - for (EditMeshIt mesh_it=e_obj->FirstMesh(); mesh_it!=e_obj->LastMesh(); mesh_it++){ - SurfFaces& surf_faces = (*mesh_it)->GetSurfFaces(); - SurfFacesPairIt sf_it = surf_faces.find(*it); - if (sf_it!=surf_faces.end()){ - IntVec& lst = sf_it->second; - for (IntIt i_it=lst.begin(); i_it!=lst.end(); i_it++){ - e_obj->GetFaceWorld (s_obj->_Transform(),*mesh_it,*i_it,verts); - u32 clr = 0x80FFFFFF; - if (allow_ratio){ - // select color - const Fvector2* tc[3]; - Fvector c,e01,e02; - e01.sub (verts[1],verts[0]); - e02.sub (verts[2],verts[0]); - float area = c.crossproduct(e01,e02).magnitude()/2.f; - (*mesh_it)->GetFaceTC(*i_it,tc); - e01.sub (Fvector().set(tc[1]->x,tc[1]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0)); - e02.sub (Fvector().set(tc[2]->x,tc[2]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0)); - float p_area = c.crossproduct(e01,e02).magnitude()/2.f; - float ratio = _sqrt((p_area*t_width*t_height)/area); + if (tex_name&&tex_name[0]) + { + for (ObjectIt a_it = m_Objects.begin(); a_it!=m_Objects.end(); a_it++) + { + CSceneObject *s_obj = dynamic_cast(*a_it); + CEditableObject *e_obj = s_obj->GetReference(); + VERIFY(e_obj); + SurfaceVec &s_vec = e_obj->Surfaces(); + for (SurfaceIt it = s_vec.begin(); it!=s_vec.end(); it++) + { + if (0==stricmp((*it)->_Texture(), tex_name)) + { + Fvector verts[3]; + for (EditMeshIt mesh_it = e_obj->FirstMesh(); mesh_it!=e_obj->LastMesh(); mesh_it++) + { + SurfFaces &surf_faces = (*mesh_it)->GetSurfFaces(); + SurfFacesPairIt sf_it = surf_faces.find(*it); + if (sf_it!=surf_faces.end()) + { + IntVec &lst = sf_it->second; + for (IntIt i_it = lst.begin(); i_it!=lst.end(); i_it++) + { + e_obj->GetFaceWorld(s_obj->_Transform(), *mesh_it, *i_it, verts); + u32 clr = 0x80FFFFFF; + if (allow_ratio) + { + // select color + const Fvector2 *tc[3]; + Fvector c, e01, e02; + e01.sub(verts[1], verts[0]); + e02.sub(verts[2], verts[0]); + float area = c.crossproduct(e01, e02).magnitude()/2.f; + (*mesh_it)->GetFaceTC(*i_it, tc); + e01.sub(Fvector().set(tc[1]->x, tc[1]->y, 0), Fvector().set(tc[0]->x, tc[0]->y, 0)); + e02.sub(Fvector().set(tc[2]->x, tc[2]->y, 0), Fvector().set(tc[0]->x, tc[0]->y, 0)); + float p_area = c.crossproduct(e01, e02).magnitude()/2.f; + float ratio = _sqrt((p_area*t_width*t_height)/area); int idx_clr; - float w = 0.f; - for (idx_clr=0; idx_clr=ratio_colors[idx_clr][0] && ratio=ratio_colors[idx_clr][0]&&ratiom_DebugDraw.AppendSolidFace(verts[0],verts[1],verts[2],clr,false); - if (mark) Tools->m_DebugDraw.AppendWireFace(verts[0],verts[1],verts[2],clr,false); + Tools->m_DebugDraw.AppendSolidFace(verts[0], verts[1], verts[2], clr, false); + if (mark) + Tools->m_DebugDraw.AppendWireFace(verts[0], verts[1], verts[2], clr, false); } } } @@ -211,5 +243,7 @@ void ESceneObjectTools::HighlightTexture(LPCSTR tex_name, bool allow_ratio, u32 } } } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneObjectTools__.cpp b/src/editors/LevelEditor/Edit/ESceneObjectTools__.cpp index 5b634e145a2..0234ea8a22e 100644 --- a/src/editors/LevelEditor/Edit/ESceneObjectTools__.cpp +++ b/src/editors/LevelEditor/Edit/ESceneObjectTools__.cpp @@ -2,7 +2,7 @@ #pragma hdrstop #include "ESceneObjectTools.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "ESceneObjectControls.h" #include "FrameObject.h" #include "SceneObject.h" @@ -14,193 +14,240 @@ #include "EditObject.h" #include "EditMesh.h" -ESceneObjectTools::ESceneObjectTools():ESceneCustomOTools(OBJCLASS_SCENEOBJECT) +ESceneObjectTools::ESceneObjectTools(): ESceneCustomOTools(OBJCLASS_SCENEOBJECT) { - m_AppendRandomMinScale.set (1.f,1.f,1.f); - m_AppendRandomMaxScale.set (1.f,1.f,1.f); - m_AppendRandomMinRotation.set (0.f,0.f,0.f); - m_AppendRandomMaxRotation.set (0.f,0.f,0.f); - m_Flags.zero (); - m_Props = 0; + m_AppendRandomMinScale.set(1.f, 1.f, 1.f); + m_AppendRandomMaxScale.set(1.f, 1.f, 1.f); + m_AppendRandomMinRotation.set(0.f, 0.f, 0.f); + m_AppendRandomMaxRotation.set(0.f, 0.f, 0.f); + m_Flags.zero(); + m_Props = 0; } void ESceneObjectTools::CreateControls() { - inherited::CreateDefaultControls(estDefault); - AddControl (xr_new(estDefault,etaAdd, this)); - // frame - pFrame = xr_new((TComponent*)0,this); + inherited::CreateDefaultControls(estDefault); + AddControl(xr_new(estDefault, etaAdd, this)); + // frame + pFrame = xr_new((TComponent*)0, this); } + //---------------------------------------------------- - + void ESceneObjectTools::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- bool ESceneObjectTools::Validate() { - if (!inherited::Validate()) return false; + if (!inherited::Validate()) + return false; // verify position & refs duplicate bool bRes = true; - CSceneObject *A, *B; - for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){ + CSceneObject* A, * B; + for (ObjectIt a_it = m_Objects.begin(); a_it!=m_Objects.end(); a_it++) + { A = (CSceneObject*)(*a_it); - for (ObjectIt b_it=m_Objects.begin(); b_it!=m_Objects.end(); b_it++){ + for (ObjectIt b_it = m_Objects.begin(); b_it!=m_Objects.end(); b_it++) + { B = (CSceneObject*)(*b_it); - if (A==B) continue; - if (A->RefCompare(B->GetReference())){ - if (A->PPosition.similar(B->PPosition,EPS_L)){ - bRes = false; - ELog.Msg(mtError,"Duplicate object position '%s'-'%s' with reference '%s'.",A->Name,B->Name,A->GetRefName()); + if (A==B) + continue; + if (A->RefCompare(B->GetReference())) + { + if (A->PPosition.similar(B->PPosition, EPS_L)) + { + bRes = false; + ELog.Msg(mtError, "Duplicate object position '%s'-'%s' with reference '%s'.", A->Name, B->Name, A->GetRefName()); } } } } return bRes; } + //---------------------------------------------------- -void ESceneObjectTools::OnChangeAppendRandomFlags(PropValue* prop) +void ESceneObjectTools::OnChangeAppendRandomFlags(PropValue *prop) { - m_Flags.set(flAppendRandomUpdateProps,TRUE); + m_Flags.set(flAppendRandomUpdateProps, TRUE); } void ESceneObjectTools::FillAppendRandomProperties(bool bUpdateOnly) { - if (!bUpdateOnly) m_Props = TProperties::CreateModalForm("Random Append Properties",true); + if (!bUpdateOnly) + m_Props = TProperties::CreateModalForm("Random Append Properties", true); shared_str temp; - temp = _ListToSequence(m_AppendRandomObjects).c_str(); - - PropValue* V; - - PropItemVec items; - V=PHelper().CreateFlag32 (items,"Scale", &m_Flags, flAppendRandomScale); - V->OnChangeEvent.bind (this,&ESceneObjectTools::OnChangeAppendRandomFlags); - if (m_Flags.is(flAppendRandomScale)){ - V=PHelper().CreateFlag32 (items,"Scale\\Proportional",&m_Flags, flAppendRandomScaleProportional); - V->OnChangeEvent.bind (this,&ESceneObjectTools::OnChangeAppendRandomFlags); - if (m_Flags.is(flAppendRandomScaleProportional)){ - PHelper().CreateFloat (items,"Scale\\Minimum", &m_AppendRandomMinScale.x,0.001f,1000.f,0.001f,3); - PHelper().CreateFloat (items,"Scale\\Maximum", &m_AppendRandomMaxScale.x,0.001f,1000.f,0.001f,3); - }else{ - PHelper().CreateVector (items,"Scale\\Minimum", &m_AppendRandomMinScale,0.001f,1000.f,0.001f,3); - PHelper().CreateVector (items,"Scale\\Maximum", &m_AppendRandomMaxScale,0.001f,1000.f,0.001f,3); + temp = _ListToSequence(m_AppendRandomObjects).c_str(); + + PropValue *V; + + PropItemVec items; + V = PHelper().CreateFlag32(items, "Scale", &m_Flags, flAppendRandomScale); + V->OnChangeEvent.bind(this, &ESceneObjectTools::OnChangeAppendRandomFlags); + if (m_Flags.is(flAppendRandomScale)) + { + V = PHelper().CreateFlag32(items, "Scale\\Proportional", &m_Flags, flAppendRandomScaleProportional); + V->OnChangeEvent.bind(this, &ESceneObjectTools::OnChangeAppendRandomFlags); + if (m_Flags.is(flAppendRandomScaleProportional)) + { + PHelper().CreateFloat(items, "Scale\\Minimum", &m_AppendRandomMinScale.x, 0.001f, 1000.f, 0.001f, 3); + PHelper().CreateFloat(items, "Scale\\Maximum", &m_AppendRandomMaxScale.x, 0.001f, 1000.f, 0.001f, 3); + } + else + { + PHelper().CreateVector(items, "Scale\\Minimum", &m_AppendRandomMinScale, 0.001f, 1000.f, 0.001f, 3); + PHelper().CreateVector(items, "Scale\\Maximum", &m_AppendRandomMaxScale, 0.001f, 1000.f, 0.001f, 3); } } - V=PHelper().CreateFlag32 (items,"Rotate",&m_Flags, flAppendRandomRotation); - V->OnChangeEvent.bind (this,&ESceneObjectTools::OnChangeAppendRandomFlags); - if (m_Flags.is(flAppendRandomRotation)){ - PHelper().CreateAngle3 (items,"Rotate\\Minimum",&m_AppendRandomMinRotation); - PHelper().CreateAngle3 (items,"Rotate\\Maximum",&m_AppendRandomMaxRotation); + V = PHelper().CreateFlag32(items, "Rotate", &m_Flags, flAppendRandomRotation); + V->OnChangeEvent.bind(this, &ESceneObjectTools::OnChangeAppendRandomFlags); + if (m_Flags.is(flAppendRandomRotation)) + { + PHelper().CreateAngle3(items, "Rotate\\Minimum", &m_AppendRandomMinRotation); + PHelper().CreateAngle3(items, "Rotate\\Maximum", &m_AppendRandomMaxRotation); } - V=PHelper().CreateChoose (items,"Objects",&temp,smObject,0,0,32); - - m_Props->AssignItems (items); - - if (!bUpdateOnly){ - if (mrOk==m_Props->ShowPropertiesModal()){ - _SequenceToList (m_AppendRandomObjects,*temp); - Scene->UndoSave (); + V = PHelper().CreateChoose(items, "Objects", &temp, smObject, 0, 0, 32); + + m_Props->AssignItems(items); + + if (!bUpdateOnly) + { + if (mrOk==m_Props->ShowPropertiesModal()) + { + _SequenceToList(m_AppendRandomObjects, *temp); + Scene->UndoSave(); } TProperties::DestroyForm(m_Props); } } + //---------------------------------------------------- -void ESceneObjectTools::Clear (bool bSpecific) +void ESceneObjectTools::Clear(bool bSpecific) { - inherited::Clear (bSpecific); - m_AppendRandomMinScale.set (1.f,1.f,1.f); - m_AppendRandomMaxScale.set (1.f,1.f,1.f); - m_AppendRandomMinRotation.set (0.f,0.f,0.f); - m_AppendRandomMaxRotation.set (0.f,0.f,0.f); - m_AppendRandomObjects.clear (); - m_Flags.zero (); + inherited::Clear(bSpecific); + m_AppendRandomMinScale.set(1.f, 1.f, 1.f); + m_AppendRandomMaxScale.set(1.f, 1.f, 1.f); + m_AppendRandomMinRotation.set(0.f, 0.f, 0.f); + m_AppendRandomMaxRotation.set(0.f, 0.f, 0.f); + m_AppendRandomObjects.clear(); + m_Flags.zero(); } -bool ESceneObjectTools::GetBox (Fbox& bb) +bool ESceneObjectTools::GetBox(Fbox &bb) { - bb.invalidate (); + bb.invalidate(); Fbox bbo; - for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){ - (*a_it)->GetBox (bbo); - bb.merge (bbo); + for (ObjectIt a_it = m_Objects.begin(); a_it!=m_Objects.end(); a_it++) + { + (*a_it)->GetBox(bbo); + bb.merge(bbo); } return bb.is_valid(); } -void ESceneObjectTools::OnFrame () +void ESceneObjectTools::OnFrame() { - inherited::OnFrame (); - if (m_Flags.is(flAppendRandomUpdateProps)){ - m_Flags.set (flAppendRandomUpdateProps,FALSE); - FillAppendRandomProperties (true); + inherited::OnFrame(); + if (m_Flags.is(flAppendRandomUpdateProps)) + { + m_Flags.set(flAppendRandomUpdateProps, FALSE); + FillAppendRandomProperties(true); } } -CCustomObject* ESceneObjectTools::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneObjectTools::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTools = this; + CCustomObject*O = xr_new(data, name); + O->ParentTools = this; return O; } + //---------------------------------------------------- -u32 ratio_colors[5] = {{0x80FF0000}, - {0x80FFFF00}, - {0x8000FF00}, - {0x8000FFFF}, - {0x800000FF}, - }; +u32 ratio_colors[5] = {{0x80FF0000}, + {0x80FFFF00}, + {0x8000FF00}, + {0x8000FFFF}, + {0x800000FF}, +}; void ESceneObjectTools::HighlightTexture(LPCSTR tex_name, bool allow_ratio, u32 t_width, u32 t_height, BOOL mark) { - if (tex_name&&tex_name[0]){ - for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){ - CSceneObject* s_obj = dynamic_cast(*a_it); - CEditableObject* e_obj = s_obj->GetReference(); VERIFY(e_obj); - SurfaceVec& s_vec = e_obj->Surfaces(); - for (SurfaceIt it=s_vec.begin(); it!=s_vec.end(); it++){ - if (0==stricmp((*it)->_Texture(),tex_name)){ - Fvector verts[3]; - for (EditMeshIt mesh_it=e_obj->FirstMesh(); mesh_it!=e_obj->LastMesh(); mesh_it++){ - SurfFaces& surf_faces = (*mesh_it)->GetSurfFaces(); - SurfFacesPairIt sf_it = surf_faces.find(*it); - if (sf_it!=surf_faces.end()){ - IntVec& lst = sf_it->second; - for (IntIt i_it=lst.begin(); i_it!=lst.end(); i_it++){ - e_obj->GetFaceWorld (s_obj->_Transform(),*mesh_it,*i_it,verts); - u32 clr = 0x80FFFFFF; - if (allow_ratio){ - // select color - const Fvector2* tc[3]; - Fvector c,e01,e02; - e01.sub (verts[1],verts[0]); - e02.sub (verts[2],verts[0]); - float area = c.crossproduct(e01,e02).magnitude()/2.f; - (*mesh_it)->GetFaceTC(*i_it,tc); - e01.sub (Fvector().set(tc[1]->x,tc[1]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0)); - e02.sub (Fvector().set(tc[2]->x,tc[2]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0)); - float p_area = c.crossproduct(e01,e02).magnitude()/2.f; - float ratio = _sqrt((p_area*t_width*t_height)/area); - int idx_clr = 4; - float w = 0.f; - if (ratio>=0.f && ratio<50.f) {idx_clr=0; w=ratio/30.f;} - else if (ratio>=50.f && ratio<150.f) {idx_clr=1; w=(ratio-30.f)/150.f;} - else if (ratio>=150.f && ratio<250.f) {idx_clr=2; w=(ratio-150.f)/250.f;} - else if (ratio>=250.f && ratio<500.f) {idx_clr=3; w=(ratio-250.f)/500.f;} - float inv_w = 1.f-w; - clr = color_rgba(color_get_R(ratio_colors[idx_clr+0])*inv_w+color_get_R(ratio_colors[idx_clr+1])*w, - color_get_G(ratio_colors[idx_clr+0])*inv_w+color_get_G(ratio_colors[idx_clr+1])*w, - color_get_B(ratio_colors[idx_clr+0])*inv_w+color_get_B(ratio_colors[idx_clr+1])*w, - color_get_A(ratio_colors[idx_clr+0])*inv_w+color_get_A(ratio_colors[idx_clr+1])*w); + if (tex_name&&tex_name[0]) + { + for (ObjectIt a_it = m_Objects.begin(); a_it!=m_Objects.end(); a_it++) + { + CSceneObject *s_obj = dynamic_cast(*a_it); + CEditableObject *e_obj = s_obj->GetReference(); + VERIFY(e_obj); + SurfaceVec &s_vec = e_obj->Surfaces(); + for (SurfaceIt it = s_vec.begin(); it!=s_vec.end(); it++) + { + if (0==stricmp((*it)->_Texture(), tex_name)) + { + Fvector verts[3]; + for (EditMeshIt mesh_it = e_obj->FirstMesh(); mesh_it!=e_obj->LastMesh(); mesh_it++) + { + SurfFaces &surf_faces = (*mesh_it)->GetSurfFaces(); + SurfFacesPairIt sf_it = surf_faces.find(*it); + if (sf_it!=surf_faces.end()) + { + IntVec &lst = sf_it->second; + for (IntIt i_it = lst.begin(); i_it!=lst.end(); i_it++) + { + e_obj->GetFaceWorld(s_obj->_Transform(), *mesh_it, *i_it, verts); + u32 clr = 0x80FFFFFF; + if (allow_ratio) + { + // select color + const Fvector2 *tc[3]; + Fvector c, e01, e02; + e01.sub(verts[1], verts[0]); + e02.sub(verts[2], verts[0]); + float area = c.crossproduct(e01, e02).magnitude()/2.f; + (*mesh_it)->GetFaceTC(*i_it, tc); + e01.sub(Fvector().set(tc[1]->x, tc[1]->y, 0), Fvector().set(tc[0]->x, tc[0]->y, 0)); + e02.sub(Fvector().set(tc[2]->x, tc[2]->y, 0), Fvector().set(tc[0]->x, tc[0]->y, 0)); + float p_area = c.crossproduct(e01, e02).magnitude()/2.f; + float ratio = _sqrt((p_area*t_width*t_height)/area); + int idx_clr = 4; + float w = 0.f; + if (ratio>=0.f&&ratio<50.f) + { + idx_clr = 0; + w = ratio/30.f; + } + else if (ratio>=50.f&&ratio<150.f) + { + idx_clr = 1; + w = (ratio-30.f)/150.f; + } + else if (ratio>=150.f&&ratio<250.f) + { + idx_clr = 2; + w = (ratio-150.f)/250.f; + } + else if (ratio>=250.f&&ratio<500.f) + { + idx_clr = 3; + w = (ratio-250.f)/500.f; + } + float inv_w = 1.f-w; + clr = color_rgba(color_get_R(ratio_colors[idx_clr+0])*inv_w+color_get_R(ratio_colors[idx_clr+1])*w, + color_get_G(ratio_colors[idx_clr+0])*inv_w+color_get_G(ratio_colors[idx_clr+1])*w, + color_get_B(ratio_colors[idx_clr+0])*inv_w+color_get_B(ratio_colors[idx_clr+1])*w, + color_get_A(ratio_colors[idx_clr+0])*inv_w+color_get_A(ratio_colors[idx_clr+1])*w); } - Tools->m_DebugDraw.AppendSolidFace(verts[0],verts[1],verts[2],clr,false); - if (mark) Tools->m_DebugDraw.AppendWireFace(verts[0],verts[1],verts[2],clr,false); + Tools->m_DebugDraw.AppendSolidFace(verts[0], verts[1], verts[2], clr, false); + if (mark) + Tools->m_DebugDraw.AppendWireFace(verts[0], verts[1], verts[2], clr, false); } } } @@ -209,5 +256,7 @@ void ESceneObjectTools::HighlightTexture(LPCSTR tex_name, bool allow_ratio, u32 } } } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/EScenePSControls.cpp b/src/editors/LevelEditor/Edit/EScenePSControls.cpp index cfae106cbbc..2c9018670e1 100644 --- a/src/editors/LevelEditor/Edit/EScenePSControls.cpp +++ b/src/editors/LevelEditor/Edit/EScenePSControls.cpp @@ -2,29 +2,31 @@ #pragma hdrstop #include "EScenePSControls.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "..\..\Layers\xrRender\PSLibrary.h" #include "EParticlesObject.h" #include "scene.h" #include "FramePS.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" //---------------------------------------------------------------------- // //------------------------------------------------------------------------------ -__fastcall TUI_ControlPSAdd::TUI_ControlPSAdd(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent){ -} +__fastcall TUI_ControlPSAdd::TUI_ControlPSAdd(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} -bool __fastcall TUI_ControlPSAdd::AfterAppendCallback(TShiftState Shift, CCustomObject* obj) +bool __fastcall TUI_ControlPSAdd::AfterAppendCallback(TShiftState Shift, CCustomObject *obj) { - EParticlesObject* pg= dynamic_cast(obj); R_ASSERT(pg); - LPCSTR ref_name = ((TfraPS*)parent_tool->pFrame)->Current(); - if (!ref_name){ - ELog.DlgMsg(mtInformation,"Nothing selected."); - return false; + EParticlesObject *pg = dynamic_cast(obj); + R_ASSERT(pg); + LPCSTR ref_name = ((TfraPS*)parent_tool->pFrame)->Current(); + if (!ref_name) + { + ELog.DlgMsg(mtInformation, "Nothing selected."); + return false; } - if (!pg->Compile(ref_name)){ - ELog.DlgMsg(mtInformation,"Can't compile particle system '%s'.",ref_name); + if (!pg->Compile(ref_name)) + { + ELog.DlgMsg(mtInformation, "Can't compile particle system '%s'.", ref_name); return false; } return true; @@ -32,16 +34,14 @@ bool __fastcall TUI_ControlPSAdd::AfterAppendCallback(TShiftState Shift, CCustom bool __fastcall TUI_ControlPSAdd::Start(TShiftState Shift) { - DefaultAddObject(Shift,0,AfterAppendCallback); + DefaultAddObject(Shift, 0, AfterAppendCallback); return false; } -void __fastcall TUI_ControlPSAdd::Move(TShiftState _Shift) -{ -} +void __fastcall TUI_ControlPSAdd::Move(TShiftState _Shift) {} + bool __fastcall TUI_ControlPSAdd::End(TShiftState _Shift) { return true; } - diff --git a/src/editors/LevelEditor/Edit/EScenePSTools.cpp b/src/editors/LevelEditor/Edit/EScenePSTools.cpp index eba3738c15a..6118a1007d9 100644 --- a/src/editors/LevelEditor/Edit/EScenePSTools.cpp +++ b/src/editors/LevelEditor/Edit/EScenePSTools.cpp @@ -2,35 +2,38 @@ #pragma hdrstop #include "EScenePSTools.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "EScenePSControls.h" #include "FramePS.h" #include "EParticlesObject.h" void EScenePSTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); - AddControl (xr_new(estDefault,etaAdd, this)); - // frame - pFrame = xr_new((TComponent*)0); + inherited::CreateDefaultControls(estDefault); + AddControl(xr_new(estDefault, etaAdd, this)); + // frame + pFrame = xr_new((TComponent*)0); } + //---------------------------------------------------- void EScenePSTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- -CCustomObject* EScenePSTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *EScenePSTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } + //---------------------------------------------------- -bool EScenePSTool::ExportGame(SExportStreams* F) +bool EScenePSTool::ExportGame(SExportStreams *F) { - return inherited::ExportGame (F); + return inherited::ExportGame(F); } diff --git a/src/editors/LevelEditor/Edit/EScenePSTools.h b/src/editors/LevelEditor/Edit/EScenePSTools.h index 8586d0e8cf0..f947a77d6d3 100644 --- a/src/editors/LevelEditor/Edit/EScenePSTools.h +++ b/src/editors/LevelEditor/Edit/EScenePSTools.h @@ -6,30 +6,57 @@ class EScenePSTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; + typedef ESceneCustomOTool inherited; protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - EScenePSTool ():ESceneCustomOTool(OBJCLASS_PS){;} - // definition - IC LPCSTR ClassName (){return "ps";} - IC LPCSTR ClassDesc (){return "Particle System";} - IC int RenderPriority (){return 30;} + EScenePSTool(): ESceneCustomOTool(OBJCLASS_PS) + { + ; + } + + // definition + IC LPCSTR ClassName() + { + return "ps"; + } + + IC LPCSTR ClassDesc() + { + return "Particle System"; + } + + IC + + int RenderPriority() + { + return 30; + } + + virtual void Clear(bool bSpecific = false) + { + inherited::Clear(bSpecific); + } - virtual void Clear (bool bSpecific=false){inherited::Clear(bSpecific);} // IO - virtual bool IsNeedSave (){return inherited::IsNeedSave();} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - virtual bool ExportGame (SExportStreams* F); - - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); + virtual bool IsNeedSave() + { + return inherited::IsNeedSave(); + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + virtual bool ExportGame(SExportStreams *F); + + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/EScenePSToolsIO.cpp b/src/editors/LevelEditor/Edit/EScenePSToolsIO.cpp index aa884118c7a..d17049556fa 100644 --- a/src/editors/LevelEditor/Edit/EScenePSToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/EScenePSToolsIO.cpp @@ -4,71 +4,83 @@ #include "EScenePSTools.h" // chunks -static const u16 PS_TOOLS_VERSION = 0x0000; +static const u16 PS_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, +enum +{ + CHUNK_VERSION = 0x1001ul, }; + //---------------------------------------------------- -bool EScenePSTool::LoadLTX(CInifile& ini) +bool EScenePSTool::LoadLTX(CInifile &ini) { - u32 version = ini.r_u32("main","version"); - if( version!=PS_TOOLS_VERSION ) + u32 version = ini.r_u32("main", "version"); + if (version!=PS_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); - return false; + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); + return false; } - inherited::LoadLTX(ini); - return true; + inherited::LoadLTX(ini); + return true; } -void EScenePSTool::SaveLTX(CInifile& ini, int id) + +void EScenePSTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); - ini.w_u32 ("main", "version", PS_TOOLS_VERSION); + inherited::SaveLTX(ini, id); + ini.w_u32("main", "version", PS_TOOLS_VERSION); } -bool EScenePSTool::LoadStream(IReader& F) +bool EScenePSTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=PS_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=PS_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadStream(F)) return false; + if (!inherited::LoadStream(F)) + return false; return true; } + //---------------------------------------------------- -void EScenePSTool::SaveStream(IWriter& F) +void EScenePSTool::SaveStream(IWriter &F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&PS_TOOLS_VERSION,sizeof(PS_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&PS_TOOLS_VERSION, sizeof(PS_TOOLS_VERSION)); } + //---------------------------------------------------- -bool EScenePSTool::LoadSelection(IReader& F) +bool EScenePSTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=PS_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=PS_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void EScenePSTool::SaveSelection(IWriter& F) +void EScenePSTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&PS_TOOLS_VERSION,sizeof(PS_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&PS_TOOLS_VERSION, sizeof(PS_TOOLS_VERSION)); - inherited::SaveSelection(F); + inherited::SaveSelection(F); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/EScenePortalTools.cpp b/src/editors/LevelEditor/Edit/EScenePortalTools.cpp index d304421c300..f35d67d0f19 100644 --- a/src/editors/LevelEditor/Edit/EScenePortalTools.cpp +++ b/src/editors/LevelEditor/Edit/EScenePortalTools.cpp @@ -2,7 +2,7 @@ #pragma hdrstop #include "EScenePortalTools.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "FramePortal.h" #include "EScenePortalControls.h" #include "portal.h" @@ -13,133 +13,143 @@ void EScenePortalTool::CreateControls() { -// inherited::CreateControls(); - AddControl (xr_new(estDefault,etaSelect, this)); - // frame - pFrame = xr_new((TComponent*)0); - ((TfraPortal*)pFrame)->tool = this; + // inherited::CreateControls(); + AddControl(xr_new(estDefault, etaSelect, this)); + // frame + pFrame = xr_new((TComponent*)0); + ((TfraPortal*)pFrame)->tool = this; } + //---------------------------------------------------- void EScenePortalTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- -void EScenePortalTool::FillProp(LPCSTR pref, PropItemVec& items) +void EScenePortalTool::FillProp(LPCSTR pref, PropItemVec &items) { - PHelper().CreateFlag32(items, PrepareKey(pref,"Common\\Draw Simple Model"),&m_Flags, flDrawSimpleModel); - inherited::FillProp (pref, items); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Draw Simple Model"), &m_Flags, flDrawSimpleModel); + inherited::FillProp(pref, items); } + //---------------------------------------------------- -CCustomObject* EScenePortalTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *EScenePortalTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } + //---------------------------------------------------- -float plane_dot(const Fplane& P0, const Fplane& P1) +float plane_dot(const Fplane &P0, const Fplane &P1) { - return P0.n.x*P1.n.x + P0.n.y*P1.n.y + P0.n.z*P1.n.z + P0.d*P1.d; + return P0.n.x*P1.n.x+P0.n.y*P1.n.y+P0.n.z*P1.n.z+P0.d*P1.d; } -bool contains(Fbox P, const Fbox& P0) +bool contains(Fbox P, const Fbox &P0) { - if (P.contains(P0)) - return true; + if (P.contains(P0)) + return true; else { - P.grow(0.001f); + P.grow(0.001f); if (P.contains(P0)) - return true; - else - return false; + return true; + else + return false; } } struct co_plane_pred { - CPortal* m_portal; - Fplane m_plane; - co_plane_pred(CPortal* p):m_portal(p) + CPortal *m_portal; + Fplane m_plane; + + co_plane_pred(CPortal *p): m_portal(p) { Fvector rkOffset, rkNormal; Mgc::OrthogonalPlaneFit(m_portal->m_Vertices.size(), (Mgc::Vector3*)m_portal->m_Vertices.begin(), (Mgc::Vector3&)rkOffset, (Mgc::Vector3&)rkNormal); m_plane.build(rkOffset, rkNormal); - float plane_magn = sqrt(plane_dot(m_plane, m_plane)); + float plane_magn = sqrt(plane_dot(m_plane, m_plane)); m_plane.n.div(plane_magn); m_plane.d /= plane_magn; } - bool operator()(CCustomObject* p) + + bool operator()(CCustomObject *p) { - CPortal* P = (CPortal*)p; - if(m_portal==P) - return false; - - if(P->m_SectorFront==m_portal->m_SectorFront && P->m_SectorBack==m_portal->m_SectorBack) + CPortal *P = (CPortal*)p; + if (m_portal==P) + return false; + + if (P->m_SectorFront==m_portal->m_SectorFront&&P->m_SectorBack==m_portal->m_SectorBack) { Fvector rkOffset, rkNormal; - Fplane p_plane; + Fplane p_plane; Mgc::OrthogonalPlaneFit(P->m_Vertices.size(), (Mgc::Vector3*)P->m_Vertices.begin(), (Mgc::Vector3&)rkOffset, (Mgc::Vector3&)rkNormal); p_plane.build(rkOffset, rkNormal); float plane_magn = sqrt(plane_dot(p_plane, p_plane)); p_plane.n.div(plane_magn); p_plane.d /= plane_magn; - - float dot = _abs(plane_dot(m_plane, p_plane)); - if(fsimilar(dot, 1.0f, EPS_L)) + + float dot = _abs(plane_dot(m_plane, p_plane)); + if (fsimilar(dot, 1.0f, EPS_L)) { - Fbox m_box, p_box; - m_portal->GetBox(m_box); - P->GetBox(p_box); - return contains(m_box, p_box); - }else + Fbox m_box, p_box; + m_portal->GetBox(m_box); + P->GetBox(p_box); + return contains(m_box, p_box); + } + else + return false; + } + else return false; - }else - return false; } }; -template bool int_greater (int val) +template +bool int_greater(int val) { - return val>I; + return val>I; } void EScenePortalTool::RemoveSimilar() { - ObjectList& p_lst = Scene->ListObj(OBJCLASS_PORTAL); - ObjectList p_lst_del; - ObjectList p_lst_dup = p_lst; - - ObjectIt it = p_lst_dup.begin(); - ObjectIt it_e = p_lst_dup.end(); - - while(it!=p_lst_dup.end()) + ObjectList&p_lst = Scene->ListObj(OBJCLASS_PORTAL); + ObjectList p_lst_del; + ObjectList p_lst_dup = p_lst; + + ObjectIt it = p_lst_dup.begin(); + ObjectIt it_e = p_lst_dup.end(); + + while (it!=p_lst_dup.end()) { - CPortal* p = (CPortal*)(*it); - if( std::find(p_lst_del.begin(),p_lst_del.end(),*it)!=p_lst_del.end() ) + CPortal *p = (CPortal*)(*it); + if (std::find(p_lst_del.begin(), p_lst_del.end(), *it)!=p_lst_del.end()) { - ++it; + ++it; continue; } - ObjectIt pit = std::find_if(p_lst.begin(), p_lst.end(), co_plane_pred(p)); - if(pit!=p_lst.end()) + ObjectIt pit = std::find_if(p_lst.begin(), p_lst.end(), co_plane_pred(p)); + if (pit!=p_lst.end()) { - p_lst_del.push_back (*pit); - p_lst.erase (pit); - it = p_lst_dup.begin(); - }else - ++it; + p_lst_del.push_back(*pit); + p_lst.erase(pit); + it = p_lst_dup.begin(); + } + else + ++it; } - - for(ObjectIt p_del=p_lst_del.begin(); p_del!=p_lst_del.end(); ++p_del) + + for (ObjectIt p_del = p_lst_del.begin(); p_del!=p_lst_del.end(); ++p_del) { xr_delete(*p_del); } - ELog.DlgMsg(mtInformation,"Removed '%d' portal(s).",p_lst_del.size()); + ELog.DlgMsg(mtInformation, "Removed '%d' portal(s).", p_lst_del.size()); p_lst_del.clear(); - - } +} + diff --git a/src/editors/LevelEditor/Edit/EScenePortalTools.h b/src/editors/LevelEditor/Edit/EScenePortalTools.h index b1e0eec3437..63462995330 100644 --- a/src/editors/LevelEditor/Edit/EScenePortalTools.h +++ b/src/editors/LevelEditor/Edit/EScenePortalTools.h @@ -6,36 +6,66 @@ class EScenePortalTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; - friend class CPortal; + typedef ESceneCustomOTool inherited; + friend class CPortal; protected: - enum{ - flDrawSimpleModel = (1<<31), + enum + { + flDrawSimpleModel = (1<<31), }; - Flags32 m_Flags; + + Flags32 m_Flags; // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - EScenePortalTool ():ESceneCustomOTool(OBJCLASS_PORTAL){m_Flags.zero();} - // definition - IC LPCSTR ClassName (){return "portal";} - IC LPCSTR ClassDesc (){return "Portal";} - IC int RenderPriority (){return 20;} + EScenePortalTool(): ESceneCustomOTool(OBJCLASS_PORTAL) + { + m_Flags.zero(); + } + + // definition + IC LPCSTR ClassName() + { + return "portal"; + } + + IC LPCSTR ClassDesc() + { + return "Portal"; + } + + IC + + int RenderPriority() + { + return 20; + } - virtual void FillProp (LPCSTR pref, PropItemVec& items); + virtual void FillProp(LPCSTR pref, PropItemVec &items); + + virtual void Clear(bool bSpecific = false) + { + inherited::Clear(bSpecific); + m_Flags.zero(); + } - virtual void Clear (bool bSpecific=false){inherited::Clear(bSpecific);m_Flags.zero();} // IO - virtual bool IsNeedSave (){return true;} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - void RemoveSimilar (); - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); + virtual bool IsNeedSave() + { + return true; + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + void RemoveSimilar(); + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/EScenePortalToolsIO.cpp b/src/editors/LevelEditor/Edit/EScenePortalToolsIO.cpp index 7efb60d9c60..6b8840faa71 100644 --- a/src/editors/LevelEditor/Edit/EScenePortalToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/EScenePortalToolsIO.cpp @@ -4,83 +4,95 @@ #include "EScenePortalTools.h" // chunks -static const u16 PORTAL_TOOLS_VERSION = 0x0000; +static const u16 PORTAL_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, - CHUNK_FLAGS = 0x1002ul, +enum +{ + CHUNK_VERSION = 0x1001ul, + CHUNK_FLAGS = 0x1002ul, }; + //---------------------------------------------------- -bool EScenePortalTool::LoadLTX(CInifile& ini) +bool EScenePortalTool::LoadLTX(CInifile &ini) { - u32 version = ini.r_u32("main","version"); - if( version!=PORTAL_TOOLS_VERSION ) + u32 version = ini.r_u32("main", "version"); + if (version!=PORTAL_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); - return false; + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); + return false; } - inherited::LoadLTX(ini); + inherited::LoadLTX(ini); - m_Flags.assign (ini.r_u32("main","flags")); + m_Flags.assign(ini.r_u32("main", "flags")); - return true; + return true; } -void EScenePortalTool::SaveLTX(CInifile& ini, int id) + +void EScenePortalTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); - ini.w_u32 ("main", "version", PORTAL_TOOLS_VERSION); - ini.w_u32 ("main", "flags", m_Flags.get()); + inherited::SaveLTX(ini, id); + ini.w_u32("main", "version", PORTAL_TOOLS_VERSION); + ini.w_u32("main", "flags", m_Flags.get()); } -bool EScenePortalTool::LoadStream(IReader& F) +bool EScenePortalTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=PORTAL_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=PORTAL_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadStream(F)) return false; + if (!inherited::LoadStream(F)) + return false; if (F.find_chunk(CHUNK_FLAGS)) - m_Flags.assign(F.r_u32()); + m_Flags.assign(F.r_u32()); return true; } + //---------------------------------------------------- -void EScenePortalTool::SaveStream(IWriter& F) +void EScenePortalTool::SaveStream(IWriter &F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&PORTAL_TOOLS_VERSION,sizeof(PORTAL_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&PORTAL_TOOLS_VERSION, sizeof(PORTAL_TOOLS_VERSION)); - F.open_chunk (CHUNK_FLAGS); - F.w_u32 (m_Flags.get()); - F.close_chunk (); + F.open_chunk(CHUNK_FLAGS); + F.w_u32(m_Flags.get()); + F.close_chunk(); } + //---------------------------------------------------- -bool EScenePortalTool::LoadSelection(IReader& F) +bool EScenePortalTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=PORTAL_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=PORTAL_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void EScenePortalTool::SaveSelection(IWriter& F) +void EScenePortalTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&PORTAL_TOOLS_VERSION,sizeof(PORTAL_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&PORTAL_TOOLS_VERSION, sizeof(PORTAL_TOOLS_VERSION)); - inherited::SaveSelection(F); + inherited::SaveSelection(F); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneSectorControls.cpp b/src/editors/LevelEditor/Edit/ESceneSectorControls.cpp index 0c01528e15f..e388f189b10 100644 --- a/src/editors/LevelEditor/Edit/ESceneSectorControls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneSectorControls.cpp @@ -4,112 +4,129 @@ #include "ESceneSectorControls.h" #include "scene.h" #include "Sector.h" -#include "../ECore/Editor/editmesh.h" -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/editmesh.h" +#include "editors/ECore/Editor/EditObject.h" #include "SceneObject.h" #include "GroupObject.h" #include "frameSector.h" -#include "ui_leveltools.h" -#include "ui_levelmain.h" +#include "UI_LevelTools.h" +#include "UI_LevelMain.h" //--------------------------------------------------------------------------- // add //------------------------------------------------------------------------------ -__fastcall TUI_ControlSectorAdd::TUI_ControlSectorAdd(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent){ -} +__fastcall TUI_ControlSectorAdd::TUI_ControlSectorAdd(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} void __fastcall TUI_ControlSectorAdd::OnEnter() { m_Action = saNone; - TfraSector* fraSector = (TfraSector*)parent_tool->pFrame; VERIFY(fraSector); + TfraSector *fraSector = (TfraSector*)parent_tool->pFrame; + VERIFY(fraSector); fraSector->paSectorActions->Show(); } void __fastcall TUI_ControlSectorAdd::OnExit() { - TfraSector* fraSector = (TfraSector*)parent_tool->pFrame; VERIFY(fraSector); + TfraSector *fraSector = (TfraSector*)parent_tool->pFrame; + VERIFY(fraSector); fraSector->paSectorActions->Hide(); - fraSector = 0; + fraSector = 0; } -void TUI_ControlSectorAdd::AddMesh(){ +void TUI_ControlSectorAdd::AddMesh() +{ m_Action = saAddMesh; - CSector* sector=PortalUtils.GetSelectedSector(); - if (!sector) return; + CSector *sector = PortalUtils.GetSelectedSector(); + if (!sector) + return; SRayPickInfo pinf; - if (Scene->RayPickObject( pinf.inf.range, UI->m_CurrentRStart,UI->m_CurrentRDir, OBJCLASS_SCENEOBJECT, &pinf, 0)) - sector->AddMesh(dynamic_cast(pinf.s_obj),pinf.e_mesh); - else - if (Scene->RayPickObject( pinf.inf.range, UI->m_CurrentRStart,UI->m_CurrentRDir, OBJCLASS_GROUP, &pinf, 0)) + if (Scene->RayPickObject(pinf.inf.range, UI->m_CurrentRStart, UI->m_CurrentRDir, OBJCLASS_SCENEOBJECT, &pinf, 0)) + sector->AddMesh(dynamic_cast(pinf.s_obj), pinf.e_mesh); + else if (Scene->RayPickObject(pinf.inf.range, UI->m_CurrentRStart, UI->m_CurrentRDir, OBJCLASS_GROUP, &pinf, 0)) { - CSceneObject* so = dynamic_cast(pinf.s_obj); - if(so) + CSceneObject *so = dynamic_cast(pinf.s_obj); + if (so) { - sector->AddMesh(so,pinf.e_mesh); + sector->AddMesh(so, pinf.e_mesh); } } } -void TUI_ControlSectorAdd::DelMesh(){ +void TUI_ControlSectorAdd::DelMesh() +{ m_Action = saDelMesh; - CSector* sector=PortalUtils.GetSelectedSector(); - if (!sector) return; + CSector *sector = PortalUtils.GetSelectedSector(); + if (!sector) + return; SRayPickInfo pinf; - if (Scene->RayPickObject( pinf.inf.range, UI->m_CurrentRStart,UI->m_CurrentRDir, OBJCLASS_SCENEOBJECT, &pinf, 0)) - sector->DelMesh(dynamic_cast(pinf.s_obj),pinf.e_mesh); + if (Scene->RayPickObject(pinf.inf.range, UI->m_CurrentRStart, UI->m_CurrentRDir, OBJCLASS_SCENEOBJECT, &pinf, 0)) + sector->DelMesh(dynamic_cast(pinf.s_obj), pinf.e_mesh); } bool TUI_ControlSectorAdd::AddSector() { - string256 namebuffer; - Scene->GenObjectName( OBJCLASS_SECTOR, namebuffer ); - CSector* _O = xr_new((LPVOID)0,namebuffer); + string256 namebuffer; + Scene->GenObjectName(OBJCLASS_SECTOR, namebuffer); + CSector *_O = xr_new((LPVOID)0, namebuffer); SRayPickInfo pinf; - if (Scene->RayPickObject( pinf.inf.range, UI->m_CurrentRStart,UI->m_CurrentRDir, OBJCLASS_SCENEOBJECT, &pinf, 0)&& - (_O->AddMesh(dynamic_cast(pinf.s_obj),pinf.e_mesh))) + if (Scene->RayPickObject(pinf.inf.range, UI->m_CurrentRStart, UI->m_CurrentRDir, OBJCLASS_SCENEOBJECT, &pinf, 0)&& + (_O->AddMesh(dynamic_cast(pinf.s_obj), pinf.e_mesh))) { - Scene->SelectObjects(false,OBJCLASS_SECTOR); - Scene->AppendObject( _O ); + Scene->SelectObjects(false, OBJCLASS_SECTOR); + Scene->AppendObject(_O); return true; - }else{ - xr_delete(_O); - return false; + } + else + { + xr_delete(_O); + return false; } } bool valid_color(u32 clr) { - u32 _r = color_get_R(clr); - u32 _g = color_get_G(clr); - u32 _b = color_get_B(clr); - if ((_r==255)&&(_g==255)&&(_b==255)) return false; - if ((_r==127)&&(_g==127)&&(_b==127)) return false; - if ((_r== 0)&&(_g== 0)&&(_b== 0)) return false; - if ((_r==255)&&(_g== 0)&&(_b== 0)) return false; - if ((_r==127)&&(_g== 0)&&(_b== 0)) return false; - return true; + u32 _r = color_get_R(clr); + u32 _g = color_get_G(clr); + u32 _b = color_get_B(clr); + if ((_r==255)&&(_g==255)&&(_b==255)) + return false; + if ((_r==127)&&(_g==127)&&(_b==127)) + return false; + if ((_r==0)&&(_g==0)&&(_b==0)) + return false; + if ((_r==255)&&(_g==0)&&(_b==0)) + return false; + if ((_r==127)&&(_g==0)&&(_b==0)) + return false; + return true; } bool TUI_ControlSectorAdd::AddSectors() { - int cnt=0; + int cnt = 0; SRayPickInfo pinf; - if (Scene->RayPickObject( pinf.inf.range, UI->m_CurrentRStart,UI->m_CurrentRDir, OBJCLASS_SCENEOBJECT, &pinf, 0)){ - CSceneObject* S = dynamic_cast(pinf.s_obj); VERIFY(S); - EditMeshVec* meshes = S->Meshes(); - for (EditMeshIt it=meshes->begin(); it!=meshes->end(); it++){ + if (Scene->RayPickObject(pinf.inf.range, UI->m_CurrentRStart, UI->m_CurrentRDir, OBJCLASS_SCENEOBJECT, &pinf, 0)) + { + CSceneObject *S = dynamic_cast(pinf.s_obj); + VERIFY(S); + EditMeshVec *meshes = S->Meshes(); + for (EditMeshIt it = meshes->begin(); it!=meshes->end(); it++) + { string256 namebuffer; - Scene->GenObjectName( OBJCLASS_SECTOR, namebuffer ); - CSector* _O = xr_new((LPVOID)0,namebuffer); - if (_O->AddMesh(S,*it)){ - cnt++; - u32 clr = 0; - do{}while(!valid_color(clr=color_rgba(Random.randI(0,3)*255/2,Random.randI(0,3)*255/2,Random.randI(0,3)*255/2,0))); - _O->SetColor (clr); - Scene->SelectObjects(false,OBJCLASS_SECTOR); - Scene->AppendObject (_O); - }else{ - xr_delete (_O); + Scene->GenObjectName(OBJCLASS_SECTOR, namebuffer); + CSector *_O = xr_new((LPVOID)0, namebuffer); + if (_O->AddMesh(S, *it)) + { + cnt++; + u32 clr = 0; + do {} while (!valid_color(clr = color_rgba(Random.randI(0, 3)*255/2, Random.randI(0, 3)*255/2, Random.randI(0, 3)*255/2, 0))); + _O->SetColor(clr); + Scene->SelectObjects(false, OBJCLASS_SECTOR); + Scene->AppendObject(_O); + } + else + { + xr_delete(_O); } } } @@ -118,26 +135,41 @@ bool TUI_ControlSectorAdd::AddSectors() bool __fastcall TUI_ControlSectorAdd::Start(TShiftState Shift) { - if (Shift==ssRBOnly){ ExecCommand(COMMAND_SHOWCONTEXTMENU,OBJCLASS_SECTOR); return false;} - TfraSector* fraSector = (TfraSector*)parent_tool->pFrame; VERIFY(fraSector); - if (fraSector->ebCreateNewSingle->Down){ - if (AddSector()&&(!Shift.Contains(ssAlt))) fraSector->ebCreateNewSingle->Down=false; + if (Shift==ssRBOnly) + { + ExecCommand(COMMAND_SHOWCONTEXTMENU, OBJCLASS_SECTOR); return false; } - if (fraSector->ebCreateNewMultiple->Down){ - if (AddSectors()&&(!Shift.Contains(ssAlt))) fraSector->ebCreateNewSingle->Down=false; + TfraSector *fraSector = (TfraSector*)parent_tool->pFrame; + VERIFY(fraSector); + if (fraSector->ebCreateNewSingle->Down) + { + if (AddSector()&&(!Shift.Contains(ssAlt))) + fraSector->ebCreateNewSingle->Down = false; return false; } - if (fraSector->ebAddMesh->Down||fraSector->ebDelMesh->Down){ - bool bBoxSelection = fraSector->ebBoxPick->Down; - if( bBoxSelection ){ - UI->EnableSelectionRect( true ); - UI->UpdateSelectionRect(UI->m_StartCp,UI->m_CurrentCp); - m_Action = saMeshBoxSelection; + if (fraSector->ebCreateNewMultiple->Down) + { + if (AddSectors()&&(!Shift.Contains(ssAlt))) + fraSector->ebCreateNewSingle->Down = false; + return false; + } + if (fraSector->ebAddMesh->Down||fraSector->ebDelMesh->Down) + { + bool bBoxSelection = fraSector->ebBoxPick->Down; + if (bBoxSelection) + { + UI->EnableSelectionRect(true); + UI->UpdateSelectionRect(UI->m_StartCp, UI->m_CurrentCp); + m_Action = saMeshBoxSelection; return true; - } else { - if (fraSector->ebAddMesh->Down) AddMesh(); - if (fraSector->ebDelMesh->Down) DelMesh(); + } + else + { + if (fraSector->ebAddMesh->Down) + AddMesh(); + if (fraSector->ebDelMesh->Down) + DelMesh(); return false; } } @@ -146,77 +178,104 @@ bool __fastcall TUI_ControlSectorAdd::Start(TShiftState Shift) void __fastcall TUI_ControlSectorAdd::Move(TShiftState _Shift) { - switch (m_Action){ - case saAddMesh: AddMesh(); break; - case saDelMesh: DelMesh(); break; - case saMeshBoxSelection:UI->UpdateSelectionRect(UI->m_StartCp,UI->m_CurrentCp); break; + switch (m_Action) + { + case saAddMesh: AddMesh(); + break; + case saDelMesh: DelMesh(); + break; + case saMeshBoxSelection: UI->UpdateSelectionRect(UI->m_StartCp, UI->m_CurrentCp); + break; } } bool __fastcall TUI_ControlSectorAdd::End(TShiftState _Shift) { - TfraSector* fraSector = (TfraSector*)parent_tool->pFrame; VERIFY(fraSector); - CSector* sector=PortalUtils.GetSelectedSector(); - if (sector){ - if (m_Action==saMeshBoxSelection){ - UI->EnableSelectionRect( false ); + TfraSector *fraSector = (TfraSector*)parent_tool->pFrame; + VERIFY(fraSector); + CSector *sector = PortalUtils.GetSelectedSector(); + if (sector) + { + if (m_Action==saMeshBoxSelection) + { + UI->EnableSelectionRect(false); Fmatrix matrix; - CSceneObject* O_ref=NULL; - CEditableObject* O_lib=NULL; + CSceneObject *O_ref = NULL; + CEditableObject *O_lib = NULL; CFrustum frustum; ObjectList lst; - if (LUI->SelectionFrustum(frustum)){; + if (LUI->SelectionFrustum(frustum)) + { + ; Scene->FrustumPick(frustum, OBJCLASS_SCENEOBJECT, lst); - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++){ + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + { O_ref = (CSceneObject*)(*_F); O_lib = O_ref->GetReference(); - for(EditMeshIt m_def = O_lib->m_Meshes.begin();m_def!=O_lib->m_Meshes.end();m_def++){ + for (EditMeshIt m_def = O_lib->m_Meshes.begin(); m_def!=O_lib->m_Meshes.end(); m_def++) + { O_ref->GetFullTransformToWorld(matrix); - if ((*m_def)->FrustumPick(frustum,matrix)){ - if (fraSector->ebAddMesh->Down) sector->AddMesh(O_ref,*m_def); - if (fraSector->ebDelMesh->Down) if (sector->DelMesh(O_ref,*m_def)) break; + if ((*m_def)->FrustumPick(frustum, matrix)) + { + if (fraSector->ebAddMesh->Down) + sector->AddMesh(O_ref, *m_def); + if (fraSector->ebDelMesh->Down) + if (sector->DelMesh(O_ref, *m_def)) + break; } } } } } - switch (m_Action){ - case saAddMesh: - case saDelMesh: - case saMeshBoxSelection: - Scene->UndoSave(); - break; + switch (m_Action) + { + case saAddMesh: + case saDelMesh: + case saMeshBoxSelection: + Scene->UndoSave(); + break; } } - m_Action = saNone; + m_Action = saNone; return true; } //------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ -__fastcall TUI_ControlSectorSelect::TUI_ControlSectorSelect(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent){ - pFrame = 0; +__fastcall TUI_ControlSectorSelect::TUI_ControlSectorSelect(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) +{ + pFrame = 0; } -void TUI_ControlSectorSelect::OnEnter(){ - pFrame = (TfraSector*)parent_tool->pFrame; VERIFY(pFrame); + +void TUI_ControlSectorSelect::OnEnter() +{ + pFrame = (TfraSector*)parent_tool->pFrame; + VERIFY(pFrame); } -void TUI_ControlSectorSelect::OnExit (){ - pFrame = 0; + +void TUI_ControlSectorSelect::OnExit() +{ + pFrame = 0; } -bool __fastcall TUI_ControlSectorSelect::Start(TShiftState Shift){ - bool bRes = SelectStart(Shift); -// if(!bBoxSelection) pFrame->OnChange(); + +bool __fastcall TUI_ControlSectorSelect::Start(TShiftState Shift) +{ + bool bRes = SelectStart(Shift); + // if(!bBoxSelection) pFrame->OnChange(); return bRes; } -void __fastcall TUI_ControlSectorSelect::Move(TShiftState Shift){ - SelectProcess(Shift); + +void __fastcall TUI_ControlSectorSelect::Move(TShiftState Shift) +{ + SelectProcess(Shift); } -bool __fastcall TUI_ControlSectorSelect::End(TShiftState Shift){ - bool bRes = SelectEnd(Shift); -// if (bBoxSelection) pFrame->OnChange(); +bool __fastcall TUI_ControlSectorSelect::End(TShiftState Shift) +{ + bool bRes = SelectEnd(Shift); + // if (bBoxSelection) pFrame->OnChange(); return bRes; } diff --git a/src/editors/LevelEditor/Edit/ESceneSectorTools.cpp b/src/editors/LevelEditor/Edit/ESceneSectorTools.cpp index 7d7a642b922..ac24a329d75 100644 --- a/src/editors/LevelEditor/Edit/ESceneSectorTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneSectorTools.cpp @@ -3,7 +3,7 @@ #include "ESceneSectorTools.h" #include "ESceneSectorControls.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "FrameSector.h" #include "SceneObject.h" #include "GroupObject.h" @@ -13,30 +13,32 @@ void ESceneSectorTool::CreateControls() { -// inherited::CreateControls(); - AddControl (xr_new(estDefault,etaSelect, this)); - AddControl (xr_new (estDefault,etaAdd, this)); - // frame - pFrame = xr_new((TComponent*)0); + // inherited::CreateControls(); + AddControl(xr_new(estDefault, etaSelect, this)); + AddControl(xr_new(estDefault, etaAdd, this)); + // frame + pFrame = xr_new((TComponent*)0); } + //---------------------------------------------------- void ESceneSectorTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- -void ESceneSectorTool::_OnObjectRemove(CSceneObject* obj) +void ESceneSectorTool::_OnObjectRemove(CSceneObject *obj) { - if (obj && !m_Objects.empty()) + if (obj&&!m_Objects.empty()) { - EditMeshVec* meshes = obj->Meshes(); - for (EditMeshIt m_it= meshes->begin(); m_it!=meshes->end(); ++m_it) + EditMeshVec *meshes = obj->Meshes(); + for (EditMeshIt m_it = meshes->begin(); m_it!=meshes->end(); ++m_it) { - for(ObjectIt _F=m_Objects.begin();_F!=m_Objects.end();++_F) + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); ++_F) { - CSector* sector = dynamic_cast(*_F); - VERIFY (sector); + CSector *sector = dynamic_cast(*_F); + VERIFY(sector); if (sector->DelMesh(obj, *m_it)) break; } @@ -44,20 +46,20 @@ void ESceneSectorTool::_OnObjectRemove(CSceneObject* obj) } } -void ESceneSectorTool::OnObjectRemove(CCustomObject* O, bool bDeleting) +void ESceneSectorTool::OnObjectRemove(CCustomObject *O, bool bDeleting) { - inherited::OnObjectRemove(O, bDeleting); + inherited::OnObjectRemove(O, bDeleting); - if(bDeleting) + if (bDeleting) { - CSceneObject* obj = dynamic_cast(O); - if(!obj) - { /* + CSceneObject *obj = dynamic_cast(O); + if (!obj) + { /* CGroupObject* go = dynamic_cast(O); if(go && !go->IsOpened()) { ObjectList lst; - go->GetObjects (lst); + go->GetObjects (lst); ObjectList::iterator it = lst.begin(); ObjectList::iterator it_e = lst.end(); @@ -67,42 +69,50 @@ void ESceneSectorTool::OnObjectRemove(CCustomObject* O, bool bDeleting) _OnObjectRemove(obj2); } } */ - }else - _OnObjectRemove(obj); - + } + else + _OnObjectRemove(obj); } } -void ESceneSectorTool::OnBeforeObjectChange(CCustomObject* O) +void ESceneSectorTool::OnBeforeObjectChange(CCustomObject *O) { - inherited::OnBeforeObjectChange(O); - - CSceneObject* obj = dynamic_cast(O); - if (obj&&!m_Objects.empty()){ - EditMeshVec* meshes = obj->Meshes(); - for (EditMeshIt m_it= meshes->begin(); m_it!=meshes->end(); m_it++){ - for(ObjectIt _F=m_Objects.begin();_F!=m_Objects.end();_F++){ - CSector* sector = dynamic_cast(*_F); VERIFY(sector); - if (sector->DelMesh(obj, *m_it)) break; + inherited::OnBeforeObjectChange(O); + + CSceneObject *obj = dynamic_cast(O); + if (obj&&!m_Objects.empty()) + { + EditMeshVec *meshes = obj->Meshes(); + for (EditMeshIt m_it = meshes->begin(); m_it!=meshes->end(); m_it++) + { + for (ObjectIt _F = m_Objects.begin(); _F!=m_Objects.end(); _F++) + { + CSector *sector = dynamic_cast(*_F); + VERIFY(sector); + if (sector->DelMesh(obj, *m_it)) + break; } } - } + } } //---------------------------------------------------- -void ESceneSectorTool::FillProp(LPCSTR pref, PropItemVec& items) +void ESceneSectorTool::FillProp(LPCSTR pref, PropItemVec &items) { - PHelper().CreateFlag32(items, PrepareKey(pref,"Common\\Draw Solid"),&m_Flags, flDrawSolid); - inherited::FillProp (pref, items); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Draw Solid"), &m_Flags, flDrawSolid); + inherited::FillProp(pref, items); } + //---------------------------------------------------- -CCustomObject* ESceneSectorTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneSectorTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneSectorTools.h b/src/editors/LevelEditor/Edit/ESceneSectorTools.h index 7920ec0d818..2cefd3ae00c 100644 --- a/src/editors/LevelEditor/Edit/ESceneSectorTools.h +++ b/src/editors/LevelEditor/Edit/ESceneSectorTools.h @@ -7,40 +7,70 @@ class CSceneObject; class ESceneSectorTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; - friend class CSector; + typedef ESceneCustomOTool inherited; + friend class CSector; protected: - enum{ - flDrawSolid = (1<<31), + enum + { + flDrawSolid = (1<<31), }; - Flags32 m_Flags; + + Flags32 m_Flags; // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - ESceneSectorTool ():ESceneCustomOTool(OBJCLASS_SECTOR){m_Flags.zero();} - // definition - IC LPCSTR ClassName (){return "sector";} - IC LPCSTR ClassDesc (){return "Sector";} - IC int RenderPriority (){return 20;} + ESceneSectorTool(): ESceneCustomOTool(OBJCLASS_SECTOR) + { + m_Flags.zero(); + } + + // definition + IC LPCSTR ClassName() + { + return "sector"; + } + + IC LPCSTR ClassDesc() + { + return "Sector"; + } + + IC + + int RenderPriority() + { + return 20; + } - virtual void OnObjectRemove (CCustomObject* O, bool bDeleting); - void _OnObjectRemove (CSceneObject* O); - virtual void OnBeforeObjectChange (CCustomObject* O); + virtual void OnObjectRemove(CCustomObject *O, bool bDeleting); + void _OnObjectRemove(CSceneObject *O); + virtual void OnBeforeObjectChange(CCustomObject *O); - virtual void FillProp (LPCSTR pref, PropItemVec& items); + virtual void FillProp(LPCSTR pref, PropItemVec &items); + + virtual void Clear(bool bSpecific = false) + { + inherited::Clear(bSpecific); + m_Flags.zero(); + } - virtual void Clear (bool bSpecific=false){inherited::Clear(bSpecific);m_Flags.zero();} // IO - virtual bool IsNeedSave (){return true;} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); + virtual bool IsNeedSave() + { + return true; + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneSectorToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneSectorToolsIO.cpp index d73f4e3e9e0..37e218ae728 100644 --- a/src/editors/LevelEditor/Edit/ESceneSectorToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneSectorToolsIO.cpp @@ -4,85 +4,97 @@ #include "ESceneSectorTools.h" // chunks -static const u16 SECTOR_TOOLS_VERSION = 0x0000; +static const u16 SECTOR_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, - CHUNK_FLAGS = 0x1002ul, +enum +{ + CHUNK_VERSION = 0x1001ul, + CHUNK_FLAGS = 0x1002ul, }; + //---------------------------------------------------- -bool ESceneSectorTool::LoadLTX(CInifile& ini) +bool ESceneSectorTool::LoadLTX(CInifile &ini) { - u32 version = ini.r_u32("main","version"); - if( version!=SECTOR_TOOLS_VERSION ) + u32 version = ini.r_u32("main", "version"); + if (version!=SECTOR_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); - return false; + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); + return false; } - inherited::LoadLTX(ini); + inherited::LoadLTX(ini); - m_Flags.assign (ini.r_u32("main","flags")); + m_Flags.assign(ini.r_u32("main", "flags")); - return true; + return true; } -void ESceneSectorTool::SaveLTX(CInifile& ini, int id) + +void ESceneSectorTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); + inherited::SaveLTX(ini, id); - ini.w_u32 ("main", "version", SECTOR_TOOLS_VERSION); + ini.w_u32("main", "version", SECTOR_TOOLS_VERSION); - ini.w_u32 ("main", "flags", m_Flags.get()); + ini.w_u32("main", "flags", m_Flags.get()); } -bool ESceneSectorTool::LoadStream(IReader& F) +bool ESceneSectorTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=SECTOR_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=SECTOR_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadStream(F)) return false; + if (!inherited::LoadStream(F)) + return false; if (F.find_chunk(CHUNK_FLAGS)) - m_Flags.assign (F.r_u32()); + m_Flags.assign(F.r_u32()); return true; } + //---------------------------------------------------- -void ESceneSectorTool::SaveStream(IWriter& F) +void ESceneSectorTool::SaveStream(IWriter &F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&SECTOR_TOOLS_VERSION,sizeof(SECTOR_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&SECTOR_TOOLS_VERSION, sizeof(SECTOR_TOOLS_VERSION)); - F.open_chunk (CHUNK_FLAGS); - F.w_u32 (m_Flags.get()); - F.close_chunk (); + F.open_chunk(CHUNK_FLAGS); + F.w_u32(m_Flags.get()); + F.close_chunk(); } + //---------------------------------------------------- -bool ESceneSectorTool::LoadSelection(IReader& F) +bool ESceneSectorTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=SECTOR_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=SECTOR_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void ESceneSectorTool::SaveSelection(IWriter& F) +void ESceneSectorTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&SECTOR_TOOLS_VERSION,sizeof(SECTOR_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&SECTOR_TOOLS_VERSION, sizeof(SECTOR_TOOLS_VERSION)); - inherited::SaveSelection(F); + inherited::SaveSelection(F); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneShapeControls.cpp b/src/editors/LevelEditor/Edit/ESceneShapeControls.cpp index 1bfaf9d164c..275f34107c2 100644 --- a/src/editors/LevelEditor/Edit/ESceneShapeControls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneShapeControls.cpp @@ -2,58 +2,75 @@ #pragma hdrstop #include "ESceneShapeControls.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "FrameShape.h" #include "EShape.h" #include "scene.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" + //--------------------------------------------------------------------------- -__fastcall TUI_ControlShapeAdd::TUI_ControlShapeAdd(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent) -{ -} +__fastcall TUI_ControlShapeAdd::TUI_ControlShapeAdd(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} -bool __fastcall TUI_ControlShapeAdd::AfterAppendCallback(TShiftState Shift, CCustomObject* obj) +bool __fastcall TUI_ControlShapeAdd::AfterAppendCallback(TShiftState Shift, CCustomObject *obj) { - CEditShape* shape = dynamic_cast(obj); R_ASSERT(shape); - TfraShape* F = (TfraShape*)parent_tool->pFrame; - if (F->ebTypeSphere->Down){ - Fsphere S; S.identity(); - shape->add_sphere(S); - if (!Shift.Contains(ssAlt)) F->ebTypeSphere->Down = false; + CEditShape *shape = dynamic_cast(obj); + R_ASSERT(shape); + TfraShape *F = (TfraShape*)parent_tool->pFrame; + if (F->ebTypeSphere->Down) + { + Fsphere S; + S.identity(); + shape->add_sphere(S); + if (!Shift.Contains(ssAlt)) + F->ebTypeSphere->Down = false; return true; - }else if (F->ebTypeBox->Down){ - Fmatrix M; M.identity(); - shape->add_box(M); - if (!Shift.Contains(ssAlt)) F->ebTypeBox->Down = false; + } + else if (F->ebTypeBox->Down) + { + Fmatrix M; + M.identity(); + shape->add_box(M); + if (!Shift.Contains(ssAlt)) + F->ebTypeBox->Down = false; return true; - }else{ - ELog.DlgMsg(mtInformation,"Select shape type at first."); + } + else + { + ELog.DlgMsg(mtInformation, "Select shape type at first."); } return false; } bool __fastcall TUI_ControlShapeAdd::Start(TShiftState Shift) { - TfraShape* F = (TfraShape*)parent_tool->pFrame; - if (F->ebAttachShape->Down){ - CEditShape* from = dynamic_cast(Scene->RayPickObject(UI->ZFar(),UI->m_CurrentRStart, UI->m_CurrentRDir, OBJCLASS_SHAPE, 0, 0)); - if (from){ + TfraShape *F = (TfraShape*)parent_tool->pFrame; + if (F->ebAttachShape->Down) + { + CEditShape *from = dynamic_cast(Scene->RayPickObject(UI->ZFar(), UI->m_CurrentRStart, UI->m_CurrentRDir, OBJCLASS_SHAPE, 0, 0)); + if (from) + { ObjectList lst; - int cnt = Scene->GetQueryObjects(lst,OBJCLASS_SHAPE,1,1,0); - if (1!=cnt) ELog.DlgMsg(mtError,"Select one shape."); - else{ - CEditShape* base = dynamic_cast(lst.back()); R_ASSERT(base); - if (base!=from){ - base->Attach(from); - if (!Shift.Contains(ssAlt)){ - F->ebAttachShape->Down = false; - ResetActionToSelect (); - } + int cnt = Scene->GetQueryObjects(lst, OBJCLASS_SHAPE, 1, 1, 0); + if (1!=cnt) + ELog.DlgMsg(mtError, "Select one shape."); + else + { + CEditShape *base = dynamic_cast(lst.back()); + R_ASSERT(base); + if (base!=from) + { + base->Attach(from); + if (!Shift.Contains(ssAlt)) + { + F->ebAttachShape->Down = false; + ResetActionToSelect(); + } } } } - }else - DefaultAddObject(Shift,0,AfterAppendCallback); + } + else + DefaultAddObject(Shift, 0, AfterAppendCallback); return false; } diff --git a/src/editors/LevelEditor/Edit/ESceneShapeTools.cpp b/src/editors/LevelEditor/Edit/ESceneShapeTools.cpp index ad6950c755e..905fb89a3d9 100644 --- a/src/editors/LevelEditor/Edit/ESceneShapeTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneShapeTools.cpp @@ -3,91 +3,97 @@ #include "ESceneShapeTools.h" #include "ESceneShapeControls.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "FrameShape.h" #include "EShape.h" void ESceneShapeTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); - AddControl (xr_new(estDefault,etaAdd, this)); - // frame - pFrame = xr_new((TComponent*)0); + inherited::CreateDefaultControls(estDefault); + AddControl(xr_new(estDefault, etaAdd, this)); + // frame + pFrame = xr_new((TComponent*)0); ((TfraShape*)pFrame)->tool = this; } + //---------------------------------------------------- void ESceneShapeTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- -CCustomObject* ESceneShapeTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneShapeTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } + //---------------------------------------------------- #include "scene.h" + void ESceneShapeTool::OnEditLevelBounds(bool recalc) { ObjectList::iterator it = m_Objects.begin(); ObjectList::iterator it_e = m_Objects.end(); - CEditShape* level_shape = NULL; - - for(; it!=it_e; ++it) + CEditShape *level_shape = NULL; + + for (; it!=it_e; ++it) { - CEditShape* es = dynamic_cast(*it); + CEditShape *es = dynamic_cast(*it); R_ASSERT(es); - if(es->m_shape_type==eShapeLevelBound) + if (es->m_shape_type==eShapeLevelBound) { - level_shape = es; - break; + level_shape = es; + break; } } - bool b_recalc = recalc || (level_shape==NULL); - - if(!level_shape) + bool b_recalc = recalc||(level_shape==NULL); + + if (!level_shape) { - level_shape = dynamic_cast(CreateObject(NULL, "level_bbox")); - level_shape->m_shape_type=eShapeLevelBound; - Fmatrix M; - M.identity (); - level_shape->add_box (M); + level_shape = dynamic_cast(CreateObject(NULL, "level_bbox")); + level_shape->m_shape_type = eShapeLevelBound; + Fmatrix M; + M.identity(); + level_shape->add_box(M); - Scene->AppendObject (level_shape); + Scene->AppendObject(level_shape); } - if(b_recalc) + if (b_recalc) { - Fbox bg,br; - Scene->GetBox(br,OBJCLASS_SCENEOBJECT); - bool r1 = Scene->GetBox(bg,OBJCLASS_GROUP); - if (r1) br.merge(bg); + Fbox bg, br; + Scene->GetBox(br, OBJCLASS_SCENEOBJECT); + bool r1 = Scene->GetBox(bg, OBJCLASS_GROUP); + if (r1) + br.merge(bg); Fvector vec; br.getsize(vec); level_shape->PScale = vec; -// level_shape->OnUpdateTransform(); -// level_shape->ApplyScale(); - + // level_shape->OnUpdateTransform(); + // level_shape->ApplyScale(); + br.getcenter(vec); level_shape->FPosition = vec; - } } + void ESceneShapeTool::OnActivate() { - inherited::OnActivate(); - ((TfraShape*)pFrame)->ebEditLevelBoundMode->Down = false; + inherited::OnActivate(); + ((TfraShape*)pFrame)->ebEditLevelBoundMode->Down = false; } void ESceneShapeTool::OnDeactivate() { - inherited::OnDeactivate(); - ((TfraShape*)pFrame)->ebEditLevelBoundMode->Down = false; + inherited::OnDeactivate(); + ((TfraShape*)pFrame)->ebEditLevelBoundMode->Down = false; } + diff --git a/src/editors/LevelEditor/Edit/ESceneShapeTools.h b/src/editors/LevelEditor/Edit/ESceneShapeTools.h index 0aaf3ab9be3..73e817a964e 100644 --- a/src/editors/LevelEditor/Edit/ESceneShapeTools.h +++ b/src/editors/LevelEditor/Edit/ESceneShapeTools.h @@ -6,33 +6,60 @@ class ESceneShapeTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; + typedef ESceneCustomOTool inherited; protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - ESceneShapeTool ():ESceneCustomOTool(OBJCLASS_SHAPE){;} - // definition - IC LPCSTR ClassName (){return "shape";} - IC LPCSTR ClassDesc (){return "Shape";} - IC int RenderPriority (){return 20;} + ESceneShapeTool(): ESceneCustomOTool(OBJCLASS_SHAPE) + { + ; + } + + // definition + IC LPCSTR ClassName() + { + return "shape"; + } + + IC LPCSTR ClassDesc() + { + return "Shape"; + } + + IC + + int RenderPriority() + { + return 20; + } + + virtual void Clear(bool bSpecific = false) + { + inherited::Clear(bSpecific); + } - virtual void Clear (bool bSpecific=false){inherited::Clear(bSpecific);} // IO - virtual bool IsNeedSave (){return inherited::IsNeedSave();} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); - void OnEditLevelBounds (bool recalc); - - virtual void OnActivate (); - virtual void OnDeactivate (); + virtual bool IsNeedSave() + { + return inherited::IsNeedSave(); + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); + void OnEditLevelBounds(bool recalc); + + virtual void OnActivate(); + virtual void OnDeactivate(); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneShapeToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneShapeToolsIO.cpp index 006f5a566f8..c4bc33ab2b7 100644 --- a/src/editors/LevelEditor/Edit/ESceneShapeToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneShapeToolsIO.cpp @@ -4,72 +4,83 @@ #include "ESceneShapeTools.h" // chunks -static const u16 SHAPE_TOOLS_VERSION = 0x0000; +static const u16 SHAPE_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, +enum +{ + CHUNK_VERSION = 0x1001ul, }; + //---------------------------------------------------- -bool ESceneShapeTool::LoadLTX(CInifile& ini) +bool ESceneShapeTool::LoadLTX(CInifile &ini) { - u32 version = ini.r_u32("main","version"); - if( version!=SHAPE_TOOLS_VERSION ) + u32 version = ini.r_u32("main", "version"); + if (version!=SHAPE_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); - return false; + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); + return false; } - inherited::LoadLTX(ini); - return true; + inherited::LoadLTX(ini); + return true; } -void ESceneShapeTool::SaveLTX(CInifile& ini, int id) +void ESceneShapeTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX(ini, id); - ini.w_u32 ("main", "version",SHAPE_TOOLS_VERSION); + inherited::SaveLTX(ini, id); + ini.w_u32("main", "version", SHAPE_TOOLS_VERSION); } -bool ESceneShapeTool::LoadStream(IReader& F) +bool ESceneShapeTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=SHAPE_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=SHAPE_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadStream(F)) return false; + if (!inherited::LoadStream(F)) + return false; return true; } + //---------------------------------------------------- -void ESceneShapeTool::SaveStream(IWriter& F) +void ESceneShapeTool::SaveStream(IWriter &F) { - inherited::SaveStream(F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&SHAPE_TOOLS_VERSION,sizeof(SHAPE_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&SHAPE_TOOLS_VERSION, sizeof(SHAPE_TOOLS_VERSION)); } + //---------------------------------------------------- -bool ESceneShapeTool::LoadSelection(IReader& F) +bool ESceneShapeTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=SHAPE_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=SHAPE_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void ESceneShapeTool::SaveSelection(IWriter& F) +void ESceneShapeTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&SHAPE_TOOLS_VERSION,sizeof(SHAPE_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&SHAPE_TOOLS_VERSION, sizeof(SHAPE_TOOLS_VERSION)); - inherited::SaveSelection(F); + inherited::SaveSelection(F); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneSoundEnvTools.cpp b/src/editors/LevelEditor/Edit/ESceneSoundEnvTools.cpp index cd47ada1c7e..32ec4ea115d 100644 --- a/src/editors/LevelEditor/Edit/ESceneSoundEnvTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneSoundEnvTools.cpp @@ -8,28 +8,33 @@ void ESceneSoundEnvTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); + inherited::CreateDefaultControls(estDefault); } + //---------------------------------------------------- void ESceneSoundEnvTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- void ESceneSoundEnvTool::Clear(bool bSpecific) { - inherited::Clear (bSpecific); - LSndLib->RefreshEnvGeometry (); + inherited::Clear(bSpecific); + LSndLib->RefreshEnvGeometry(); } + //---------------------------------------------------- -CCustomObject* ESceneSoundEnvTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneSoundEnvTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneSoundEnvTools.h b/src/editors/LevelEditor/Edit/ESceneSoundEnvTools.h index 1c8535efdd3..a0fe6b835e6 100644 --- a/src/editors/LevelEditor/Edit/ESceneSoundEnvTools.h +++ b/src/editors/LevelEditor/Edit/ESceneSoundEnvTools.h @@ -6,29 +6,53 @@ class ESceneSoundEnvTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; + typedef ESceneCustomOTool inherited; protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - ESceneSoundEnvTool ():ESceneCustomOTool(OBJCLASS_SOUND_ENV){;} - // definition - IC LPCSTR ClassName (){return "sound_env";} - IC LPCSTR ClassDesc (){return "Sound Environment";} - IC int RenderPriority (){return 10;} + ESceneSoundEnvTool(): ESceneCustomOTool(OBJCLASS_SOUND_ENV) + { + ; + } + + // definition + IC LPCSTR ClassName() + { + return "sound_env"; + } + + IC LPCSTR ClassDesc() + { + return "Sound Environment"; + } + + IC + + int RenderPriority() + { + return 10; + } + + virtual void Clear(bool bSpecific = false); - virtual void Clear (bool bSpecific=false); // IO - virtual bool IsNeedSave (){return inherited::IsNeedSave();} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); + virtual bool IsNeedSave() + { + return inherited::IsNeedSave(); + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneSoundEnvToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneSoundEnvToolsIO.cpp index 0e5a808b9b9..4ddfa1b894b 100644 --- a/src/editors/LevelEditor/Edit/ESceneSoundEnvToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneSoundEnvToolsIO.cpp @@ -4,72 +4,84 @@ #include "ESceneSoundEnvTools.h" // chunks -static const u16 SOUND_ENV_TOOLS_VERSION = 0x0000; +static const u16 SOUND_ENV_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, +enum +{ + CHUNK_VERSION = 0x1001ul, }; + //---------------------------------------------------- -bool ESceneSoundEnvTool::LoadLTX(CInifile& ini) +bool ESceneSoundEnvTool::LoadLTX(CInifile &ini) { - u32 version = ini.r_u32("main","version"); - if( version!=SOUND_ENV_TOOLS_VERSION ) + u32 version = ini.r_u32("main", "version"); + if (version!=SOUND_ENV_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); - return false; + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); + return false; } - inherited::LoadLTX(ini); + inherited::LoadLTX(ini); - return true; + return true; } -void ESceneSoundEnvTool::SaveLTX(CInifile& ini, int id) + +void ESceneSoundEnvTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); - ini.w_u32 ("main", "version", SOUND_ENV_TOOLS_VERSION); + inherited::SaveLTX(ini, id); + ini.w_u32("main", "version", SOUND_ENV_TOOLS_VERSION); } -bool ESceneSoundEnvTool::LoadStream(IReader& F) +bool ESceneSoundEnvTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=SOUND_ENV_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=SOUND_ENV_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadStream(F)) return false; + if (!inherited::LoadStream(F)) + return false; return true; } + //---------------------------------------------------- -void ESceneSoundEnvTool::SaveStream(IWriter& F) +void ESceneSoundEnvTool::SaveStream(IWriter &F) { - inherited::SaveStream(F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&SOUND_ENV_TOOLS_VERSION,sizeof(SOUND_ENV_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&SOUND_ENV_TOOLS_VERSION, sizeof(SOUND_ENV_TOOLS_VERSION)); } + //---------------------------------------------------- -bool ESceneSoundEnvTool::LoadSelection(IReader& F) +bool ESceneSoundEnvTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=SOUND_ENV_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=SOUND_ENV_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void ESceneSoundEnvTool::SaveSelection(IWriter& F) +void ESceneSoundEnvTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&SOUND_ENV_TOOLS_VERSION,sizeof(SOUND_ENV_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&SOUND_ENV_TOOLS_VERSION, sizeof(SOUND_ENV_TOOLS_VERSION)); - inherited::SaveSelection(F); + inherited::SaveSelection(F); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneSoundSrcTools.h b/src/editors/LevelEditor/Edit/ESceneSoundSrcTools.h index 1eeaeb24e24..a716eba00b4 100644 --- a/src/editors/LevelEditor/Edit/ESceneSoundSrcTools.h +++ b/src/editors/LevelEditor/Edit/ESceneSoundSrcTools.h @@ -6,29 +6,56 @@ class ESceneSoundSrcTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; + typedef ESceneCustomOTool inherited; protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - ESceneSoundSrcTool ():ESceneCustomOTool(OBJCLASS_SOUND_SRC){;} - // definition - IC LPCSTR ClassName (){return "sound_src";} - IC LPCSTR ClassDesc (){return "Sound Source";} - IC int RenderPriority (){return 10;} + ESceneSoundSrcTool(): ESceneCustomOTool(OBJCLASS_SOUND_SRC) + { + ; + } + + // definition + IC LPCSTR ClassName() + { + return "sound_src"; + } + + IC LPCSTR ClassDesc() + { + return "Sound Source"; + } + + IC + + int RenderPriority() + { + return 10; + } + + virtual void Clear(bool bSpecific = false) + { + inherited::Clear(bSpecific); + } - virtual void Clear (bool bSpecific=false){inherited::Clear(bSpecific);} // IO - virtual bool IsNeedSave (){return inherited::IsNeedSave();} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); + virtual bool IsNeedSave() + { + return inherited::IsNeedSave(); + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneSoundSrcToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneSoundSrcToolsIO.cpp index 4225294acd0..8b6d4afd396 100644 --- a/src/editors/LevelEditor/Edit/ESceneSoundSrcToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneSoundSrcToolsIO.cpp @@ -4,72 +4,84 @@ #include "ESceneSoundSrcTools.h" // chunks -static const u16 SOUND_SRC_TOOLS_VERSION = 0x0000; +static const u16 SOUND_SRC_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, +enum +{ + CHUNK_VERSION = 0x1001ul, }; + //---------------------------------------------------- -bool ESceneSoundSrcTool::LoadLTX(CInifile& ini) +bool ESceneSoundSrcTool::LoadLTX(CInifile &ini) { - u32 version = ini.r_u32("main","version"); - if( version!=SOUND_SRC_TOOLS_VERSION ) + u32 version = ini.r_u32("main", "version"); + if (version!=SOUND_SRC_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); - return false; + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); + return false; } - inherited::LoadLTX(ini); - return true; + inherited::LoadLTX(ini); + return true; } -void ESceneSoundSrcTool::SaveLTX(CInifile& ini, int id) + +void ESceneSoundSrcTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX(ini, id); + inherited::SaveLTX(ini, id); - ini.w_u32 ("main","version",SOUND_SRC_TOOLS_VERSION); + ini.w_u32("main", "version", SOUND_SRC_TOOLS_VERSION); } -bool ESceneSoundSrcTool::LoadStream(IReader& F) +bool ESceneSoundSrcTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=SOUND_SRC_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=SOUND_SRC_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadStream(F)) return false; + if (!inherited::LoadStream(F)) + return false; return true; } + //---------------------------------------------------- -void ESceneSoundSrcTool::SaveStream(IWriter& F) +void ESceneSoundSrcTool::SaveStream(IWriter &F) { - inherited::SaveStream(F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&SOUND_SRC_TOOLS_VERSION,sizeof(SOUND_SRC_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&SOUND_SRC_TOOLS_VERSION, sizeof(SOUND_SRC_TOOLS_VERSION)); } + //---------------------------------------------------- -bool ESceneSoundSrcTool::LoadSelection(IReader& F) +bool ESceneSoundSrcTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=SOUND_SRC_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=SOUND_SRC_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void ESceneSoundSrcTool::SaveSelection(IWriter& F) +void ESceneSoundSrcTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&SOUND_SRC_TOOLS_VERSION,sizeof(SOUND_SRC_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&SOUND_SRC_TOOLS_VERSION, sizeof(SOUND_SRC_TOOLS_VERSION)); - inherited::SaveSelection(F); + inherited::SaveSelection(F); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneSpawnControls.cpp b/src/editors/LevelEditor/Edit/ESceneSpawnControls.cpp index a1a8e9139cb..7e0c6cac9b4 100644 --- a/src/editors/LevelEditor/Edit/ESceneSpawnControls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneSpawnControls.cpp @@ -2,57 +2,71 @@ #pragma hdrstop #include "ESceneSpawnControls.h" -#include "ui_leveltools.h" -#include "../ECore/Editor/ui_main.h" +#include "UI_LevelTools.h" +#include "editors/ECore/Editor/ui_main.h" #include "FrameSpawn.h" #include "Scene.h" #include "SpawnPoint.h" + //--------------------------------------------------------------------------- -__fastcall TUI_ControlSpawnAdd::TUI_ControlSpawnAdd(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent){ -} +__fastcall TUI_ControlSpawnAdd::TUI_ControlSpawnAdd(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} -bool __fastcall TUI_ControlSpawnAdd::AppendCallback(SBeforeAppendCallbackParams* p) +bool __fastcall TUI_ControlSpawnAdd::AppendCallback(SBeforeAppendCallbackParams *p) { - LPCSTR ref_name = ((TfraSpawn*)parent_tool->pFrame)->Current(); - if (!ref_name){ - ELog.DlgMsg(mtInformation,"Nothing selected."); - return false; + LPCSTR ref_name = ((TfraSpawn*)parent_tool->pFrame)->Current(); + if (!ref_name) + { + ELog.DlgMsg(mtInformation, "Nothing selected."); + return false; } - if(Scene->LevelPrefix().c_str()) + if (Scene->LevelPrefix().c_str()) { - p->name_prefix = Scene->LevelPrefix().c_str(); - p->name_prefix += "_"; + p->name_prefix = Scene->LevelPrefix().c_str(); + p->name_prefix += "_"; } - p->name_prefix += ref_name; - p->data = (void*)ref_name; + p->name_prefix += ref_name; + p->data = (void*)ref_name; return (0!=p->name_prefix.length()); } bool __fastcall TUI_ControlSpawnAdd::Start(TShiftState Shift) { - TfraSpawn* F = (TfraSpawn*)parent_tool->pFrame; - if (F->ebAttachObject->Down){ - CCustomObject* from = Scene->RayPickObject(UI->ZFar(), UI->m_CurrentRStart, UI->m_CurrentRDir, OBJCLASS_DUMMY, 0, 0); - if (from->ClassID!=OBJCLASS_SPAWNPOINT){ - ObjectList lst; - int cnt = Scene->GetQueryObjects(lst,OBJCLASS_SPAWNPOINT,1,1,0); - if (1!=cnt) ELog.DlgMsg(mtError,"Select one shape."); - else{ - CSpawnPoint* base = dynamic_cast(lst.back()); R_ASSERT(base); - if (base->AttachObject(from)){ - if (!Shift.Contains(ssAlt)){ - F->ebAttachObject->Down = false; - ResetActionToSelect (); + TfraSpawn *F = (TfraSpawn*)parent_tool->pFrame; + if (F->ebAttachObject->Down) + { + CCustomObject*from = Scene->RayPickObject(UI->ZFar(), UI->m_CurrentRStart, UI->m_CurrentRDir, OBJCLASS_DUMMY, 0, 0); + if (from->ClassID!=OBJCLASS_SPAWNPOINT) + { + ObjectList lst; + int cnt = Scene->GetQueryObjects(lst, OBJCLASS_SPAWNPOINT, 1, 1, 0); + if (1!=cnt) + ELog.DlgMsg(mtError, "Select one shape."); + else + { + CSpawnPoint *base = dynamic_cast(lst.back()); + R_ASSERT(base); + if (base->AttachObject(from)) + { + if (!Shift.Contains(ssAlt)) + { + F->ebAttachObject->Down = false; + ResetActionToSelect(); } - }else{ - ELog.DlgMsg(mtError,"Attach impossible."); + } + else + { + ELog.DlgMsg(mtError, "Attach impossible."); } } - }else{ - ELog.DlgMsg(mtError,"Attach impossible."); } - }else{ - DefaultAddObject(Shift,AppendCallback); + else + { + ELog.DlgMsg(mtError, "Attach impossible."); + } + } + else + { + DefaultAddObject(Shift, AppendCallback); } return false; } diff --git a/src/editors/LevelEditor/Edit/ESceneSpawnTools.cpp b/src/editors/LevelEditor/Edit/ESceneSpawnTools.cpp index 2c47b709fe9..7c7f7aa6a3b 100644 --- a/src/editors/LevelEditor/Edit/ESceneSpawnTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneSpawnTools.cpp @@ -2,187 +2,195 @@ #pragma hdrstop #include "ESceneSpawnTools.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "ESceneSpawnControls.h" #include "FrameSpawn.h" #include "Scene.h" #include "SceneObject.h" -#include "spawnpoint.h" -#include "builder.h" +#include "SpawnPoint.h" +#include "Builder.h" #include "EditLibrary.h" static HMODULE hXRSE_FACTORY = 0; -static LPCSTR xrse_factory_library = "xrSE_Factory"; -static LPCSTR create_entity_func = "_create_entity@4"; -static LPCSTR destroy_entity_func = "_destroy_entity@4"; -Tcreate_entity create_entity; +static LPCSTR xrse_factory_library = "xrSE_Factory"; +static LPCSTR create_entity_func = "_create_entity@4"; +static LPCSTR destroy_entity_func = "_destroy_entity@4"; +Tcreate_entity create_entity; Tdestroy_entity destroy_entity; -CEditableObject* ESceneSpawnTool::get_draw_visual(u8 _RP_TeamID, u8 _RP_Type, const GameTypeChooser& _GameType) +CEditableObject *ESceneSpawnTool::get_draw_visual(u8 _RP_TeamID, u8 _RP_Type, const GameTypeChooser &_GameType) { - CEditableObject* ret = NULL; - if(m_draw_RP_visuals.empty()) + CEditableObject *ret = NULL; + if (m_draw_RP_visuals.empty()) { - m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\artefakt_ah")); //0 - m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\artefakt_cta_blue")); //1 - m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\artefakt_cta_green")); //2 - m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\telo_ah_cta_blue")); //3 - m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\telo_ah_cta_green")); //4 - m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\telo_dm")); //5 - m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\telo_tdm_blue")); //6 - m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\telo_tdm_green")); //7 - m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\spectator")); //8 - m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\item_spawn")); //9 + m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\artefakt_ah")); //0 + m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\artefakt_cta_blue")); //1 + m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\artefakt_cta_green")); //2 + m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\telo_ah_cta_blue")); //3 + m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\telo_ah_cta_green")); //4 + m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\telo_dm")); //5 + m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\telo_tdm_blue")); //6 + m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\telo_tdm_green")); //7 + m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\spectator")); //8 + m_draw_RP_visuals.push_back(Lib.CreateEditObject("editor\\item_spawn")); //9 } switch (_RP_Type) { - case rptActorSpawn: //actor spawn + case rptActorSpawn: //actor spawn { - if(_GameType.MatchType(eGameIDDeathmatch)) + if (_GameType.MatchType(eGameIDDeathmatch)) { - if(_RP_TeamID==0) - ret = m_draw_RP_visuals[5]; + if (_RP_TeamID==0) + ret = m_draw_RP_visuals[5]; }; - if(_GameType.MatchType(eGameIDTeamDeathmatch)) + if (_GameType.MatchType(eGameIDTeamDeathmatch)) { - if(_RP_TeamID==2) - ret = m_draw_RP_visuals[7]; - else - if(_RP_TeamID==1) - ret = m_draw_RP_visuals[6]; + if (_RP_TeamID==2) + ret = m_draw_RP_visuals[7]; + else if (_RP_TeamID==1) + ret = m_draw_RP_visuals[6]; }; - - if(_GameType.MatchType(eGameIDCaptureTheArtefact)) + + if (_GameType.MatchType(eGameIDCaptureTheArtefact)) { - if(_RP_TeamID==0) - Msg("! incorrect ActorRP teamID [%d] for CTA",_RP_TeamID); - else - if(_RP_TeamID==1) - ret = m_draw_RP_visuals[4]; - else - if(_RP_TeamID==2) - ret = m_draw_RP_visuals[3]; + if (_RP_TeamID==0) + Msg("! incorrect ActorRP teamID [%d] for CTA", _RP_TeamID); + else if (_RP_TeamID==1) + ret = m_draw_RP_visuals[4]; + else if (_RP_TeamID==2) + ret = m_draw_RP_visuals[3]; }; - if(_GameType.MatchType(eGameIDArtefactHunt)) + if (_GameType.MatchType(eGameIDArtefactHunt)) { - if(_RP_TeamID==0) - ret = m_draw_RP_visuals[8]; //spactator - else - if(_RP_TeamID==1) - ret = m_draw_RP_visuals[4]; - else - if(_RP_TeamID==2) - ret = m_draw_RP_visuals[3]; + if (_RP_TeamID==0) + ret = m_draw_RP_visuals[8]; //spactator + else if (_RP_TeamID==1) + ret = m_draw_RP_visuals[4]; + else if (_RP_TeamID==2) + ret = m_draw_RP_visuals[3]; }; - - }break; - case rptArtefactSpawn: //AF spawn + } + break; + case rptArtefactSpawn: //AF spawn { - if(_GameType.MatchType(eGameIDCaptureTheArtefact)) + if (_GameType.MatchType(eGameIDCaptureTheArtefact)) { - if(_RP_TeamID==1) - ret = m_draw_RP_visuals[2]; - else - if(_RP_TeamID==2) - ret = m_draw_RP_visuals[1]; + if (_RP_TeamID==1) + ret = m_draw_RP_visuals[2]; + else if (_RP_TeamID==2) + ret = m_draw_RP_visuals[1]; else - Msg("! incorrect AF teamID [%d] for CTA",_RP_TeamID); - }else - if(_GameType.MatchType(eGameIDArtefactHunt)) + Msg("! incorrect AF teamID [%d] for CTA", _RP_TeamID); + } + else if (_GameType.MatchType(eGameIDArtefactHunt)) { - ret = m_draw_RP_visuals[0]; + ret = m_draw_RP_visuals[0]; } - }break; - case rptItemSpawn: + } + break; + case rptItemSpawn: { - ret = m_draw_RP_visuals[9]; - }break; + ret = m_draw_RP_visuals[9]; + } + break; } return ret; } -void __stdcall FillSpawnItems (ChooseItemVec& lst, void* param) +void __stdcall FillSpawnItems(ChooseItemVec &lst, void *param) { - LPCSTR gcs = (LPCSTR)param; + LPCSTR gcs = (LPCSTR)param; ObjectList objects; - Scene->GetQueryObjects (objects,OBJCLASS_SPAWNPOINT,-1,-1,-1); - + Scene->GetQueryObjects(objects, OBJCLASS_SPAWNPOINT, -1, -1, -1); + xr_string itm; - int cnt = _GetItemCount(gcs); - for (int k=0; kOnChooseQuery(itm.c_str())) lst.push_back(SChooseItem((*it)->Name,"")); + int cnt = _GetItemCount(gcs); + for (int k = 0; kOnChooseQuery(itm.c_str())) + lst.push_back(SChooseItem((*it)->Name, "")); } } -ESceneSpawnTool::ESceneSpawnTool():ESceneCustomOTool(OBJCLASS_SPAWNPOINT) +ESceneSpawnTool::ESceneSpawnTool(): ESceneCustomOTool(OBJCLASS_SPAWNPOINT) { - m_Flags.zero(); - TfrmChoseItem::AppendEvents (smSpawnItem, "Select Spawn Item", FillSpawnItems, 0,0,0,0); + m_Flags.zero(); + TfrmChoseItem::AppendEvents(smSpawnItem, "Select Spawn Item", FillSpawnItems, 0, 0, 0, 0); - hXRSE_FACTORY = LoadLibrary(xrse_factory_library); VERIFY3(hXRSE_FACTORY,"Can't load library:",xrse_factory_library); - create_entity = (Tcreate_entity) GetProcAddress(hXRSE_FACTORY,create_entity_func); VERIFY3(create_entity,"Can't find func:",create_entity_func); - destroy_entity = (Tdestroy_entity) GetProcAddress(hXRSE_FACTORY,destroy_entity_func); VERIFY3(destroy_entity,"Can't find func:",destroy_entity_func); + hXRSE_FACTORY = LoadLibrary(xrse_factory_library); + VERIFY3(hXRSE_FACTORY, "Can't load library:", xrse_factory_library); + create_entity = (Tcreate_entity) GetProcAddress(hXRSE_FACTORY, create_entity_func); + VERIFY3(create_entity, "Can't find func:", create_entity_func); + destroy_entity = (Tdestroy_entity) GetProcAddress(hXRSE_FACTORY, destroy_entity_func); + VERIFY3(destroy_entity, "Can't find func:", destroy_entity_func); - m_Classes.clear (); - CInifile::Root const& data = pSettings->sections(); - for (CInifile::RootCIt it=data.begin(); it!=data.end(); it++){ - LPCSTR val; - if ((*it)->line_exist ("$spawn",&val)){ - CLASS_ID cls_id = pSettings->r_clsid((*it)->Name,"class"); - shared_str v = pSettings->r_string_wb((*it)->Name,"$spawn"); - m_Classes[cls_id].push_back(SChooseItem(*v,*(*it)->Name)); + m_Classes.clear(); + CInifile::Root const &data = pSettings->sections(); + for (CInifile::RootCIt it = data.begin(); it!=data.end(); it++) + { + LPCSTR val; + if ((*it)->line_exist("$spawn", &val)) + { + CLASS_ID cls_id = pSettings->r_clsid((*it)->Name, "class"); + shared_str v = pSettings->r_string_wb((*it)->Name, "$spawn"); + m_Classes[cls_id].push_back(SChooseItem(*v, *(*it)->Name)); } } - } ESceneSpawnTool::~ESceneSpawnTool() { - FreeLibrary (hXRSE_FACTORY); - m_Icons.clear (); + FreeLibrary(hXRSE_FACTORY); + m_Icons.clear(); - xr_vector::iterator it = m_draw_RP_visuals.begin(); - xr_vector::iterator it_e = m_draw_RP_visuals.end(); - for(;it!=it_e;++it) + xr_vector::iterator it = m_draw_RP_visuals.begin(); + xr_vector::iterator it_e = m_draw_RP_visuals.end(); + for (; it!=it_e; ++it) { - Lib.RemoveEditObject(*it); + Lib.RemoveEditObject(*it); } m_draw_RP_visuals.clear(); } void ESceneSpawnTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); - AddControl (xr_new(estDefault,etaAdd, this)); - // frame - pFrame = xr_new((TComponent*)0); + inherited::CreateDefaultControls(estDefault); + AddControl(xr_new(estDefault, etaAdd, this)); + // frame + pFrame = xr_new((TComponent*)0); } + //---------------------------------------------------- - + void ESceneSpawnTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- -void ESceneSpawnTool::FillProp(LPCSTR pref, PropItemVec& items) -{ -//. PHelper().CreateFlag32(items, PrepareKey(pref,"Common\\Show Spawn Type"), &m_Flags, flShowSpawnType); -//. PHelper().CreateFlag32(items, PrepareKey(pref,"Common\\Trace Visibility"), &m_Flags, flPickSpawnType); - inherited::FillProp (pref, items); +void ESceneSpawnTool::FillProp(LPCSTR pref, PropItemVec &items) +{ + //. PHelper().CreateFlag32(items, PrepareKey(pref,"Common\\Show Spawn Type"), &m_Flags, flShowSpawnType); + //. PHelper().CreateFlag32(items, PrepareKey(pref,"Common\\Trace Visibility"), &m_Flags, flPickSpawnType); + inherited::FillProp(pref, items); } + //------------------------------------------------------------------------------ ref_shader ESceneSpawnTool::CreateIcon(shared_str name) { ref_shader S; - if (pSettings->line_exist(name,"$ed_icon")){ - LPCSTR tex_name = pSettings->r_string(name,"$ed_icon"); - S.create("editor\\spawn_icon",tex_name); + if (pSettings->line_exist(name, "$ed_icon")) + { + LPCSTR tex_name = pSettings->r_string(name, "$ed_icon"); + S.create("editor\\spawn_icon", tex_name); m_Icons[name] = S; - }else{ + } + else + { S = 0; } return S; @@ -190,81 +198,90 @@ ref_shader ESceneSpawnTool::CreateIcon(shared_str name) ref_shader ESceneSpawnTool::GetIcon(shared_str name) { - ShaderPairIt it = m_Icons.find(name); - if (it==m_Icons.end()) return CreateIcon(name); - else return it->second; + ShaderPairIt it = m_Icons.find(name); + if (it==m_Icons.end()) + return CreateIcon(name); + else + return it->second; } + //---------------------------------------------------- #include "EShape.h" -CCustomObject* ESceneSpawnTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneSpawnTool::CreateObject(LPVOID data, LPCSTR name) { - CSpawnPoint* O = xr_new(data,name); - O->ParentTool = this; + CSpawnPoint *O = xr_new(data, name); + O->ParentTool = this; - if(data && name) + if (data&&name) { - if(pSettings->line_exist( (LPCSTR)data, "$def_sphere") ) + if (pSettings->line_exist((LPCSTR)data, "$def_sphere")) { - float size = pSettings->r_float( (LPCSTR)data, "$def_sphere"); + float size = pSettings->r_float((LPCSTR)data, "$def_sphere"); - CCustomObject* S = Scene->GetOTool(OBJCLASS_SHAPE)->CreateObject(0,0); - CEditShape* shape = dynamic_cast(S); - R_ASSERT (shape); + CCustomObject*S = Scene->GetOTool(OBJCLASS_SHAPE)->CreateObject(0, 0); + CEditShape *shape = dynamic_cast(S); + R_ASSERT(shape); - Fsphere Sph; - Sph.identity (); - Sph.R = size; - shape->add_sphere (Sph); - O->AttachObject (S); + Fsphere Sph; + Sph.identity(); + Sph.R = size; + shape->add_sphere(Sph); + O->AttachObject(S); } } return O; } + //---------------------------------------------------- int ESceneSpawnTool::MultiRenameObjects() { - int cnt = 0; - for (ObjectIt o_it=m_Objects.begin(); o_it!=m_Objects.end(); o_it++){ - CCustomObject* obj = *o_it; - if (obj->Selected()){ - string256 pref; - strconcat (sizeof(pref),pref,Scene->LevelPrefix().c_str(),"_",obj->RefName()); - string256 buf; - Scene->GenObjectName(obj->ClassID,buf,pref); - if (obj->Name!=buf){ - obj->Name = buf; - cnt++; + int cnt = 0; + for (ObjectIt o_it = m_Objects.begin(); o_it!=m_Objects.end(); o_it++) + { + CCustomObject*obj = *o_it; + if (obj->Selected()) + { + string256 pref; + strconcat(sizeof(pref), pref, Scene->LevelPrefix().c_str(), "_", obj->RefName()); + string256 buf; + Scene->GenObjectName(obj->ClassID, buf, pref); + if (obj->Name!=buf) + { + obj->Name = buf; + cnt++; } } } return cnt; } + /* void ESceneSpawnTool::GetStaticDesc(int& v_cnt, int& f_cnt, bool b_selected_only) { - for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++){ - CSceneObject* obj = (CSceneObject*)(*it); + for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++){ + CSceneObject* obj = (CSceneObject*)(*it); if(b_selected_only && !obj->Selected()) - continue; + continue; CSpawnPoint* sp = dynamic_cast(obj); if(!sp){ - Msg("! ghm/ not a spawn object"); + Msg("! ghm/ not a spawn object"); continue; } - if(sp->m_SpawnData.Valid()) + if(sp->m_SpawnData.Valid()) { - f_cnt += obj->GetFaceCount(); - v_cnt += obj->GetVertexCount(); + f_cnt += obj->GetFaceCount(); + v_cnt += obj->GetVertexCount(); } } } bool ESceneSpawnTool::ExportStatic(SceneBuilder* B, bool b_selected_only) { - return B->ParseStaticObjects(m_Objects, NULL, b_selected_only); + return B->ParseStaticObjects(m_Objects, NULL, b_selected_only); } */ + diff --git a/src/editors/LevelEditor/Edit/ESceneSpawnToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneSpawnToolsIO.cpp index 2a263744d44..a60bc8e3a10 100644 --- a/src/editors/LevelEditor/Edit/ESceneSpawnToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneSpawnToolsIO.cpp @@ -4,86 +4,97 @@ #include "ESceneSpawnTools.h" // chunks -static const u16 SPAWN_TOOLS_VERSION = 0x0000; +static const u16 SPAWN_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, - CHUNK_FLAGS = 0x1002ul, +enum +{ + CHUNK_VERSION = 0x1001ul, + CHUNK_FLAGS = 0x1002ul, }; + //---------------------------------------------------- -bool ESceneSpawnTool::LoadLTX(CInifile& ini) +bool ESceneSpawnTool::LoadLTX(CInifile &ini) { - u32 version = ini.r_u32("main","version"); - if( version!=SPAWN_TOOLS_VERSION ) + u32 version = ini.r_u32("main", "version"); + if (version!=SPAWN_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - inherited::LoadLTX (ini); + inherited::LoadLTX(ini); - m_Flags.assign (ini.r_u32("main","flags")); + m_Flags.assign(ini.r_u32("main", "flags")); return true; } -void ESceneSpawnTool::SaveLTX(CInifile& ini, int id) +void ESceneSpawnTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); + inherited::SaveLTX(ini, id); - ini.w_u32 ("main", "version", SPAWN_TOOLS_VERSION); + ini.w_u32("main", "version", SPAWN_TOOLS_VERSION); - ini.w_u32 ("main", "flags", m_Flags.get()); + ini.w_u32("main", "flags", m_Flags.get()); } -bool ESceneSpawnTool::LoadStream(IReader& F) +bool ESceneSpawnTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=SPAWN_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=SPAWN_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); + return false; + } + + if (!inherited::LoadStream(F)) return false; - } - - if (!inherited::LoadStream(F)) return false; if (F.find_chunk(CHUNK_FLAGS)) - m_Flags.assign (F.r_u32()); + m_Flags.assign(F.r_u32()); return true; } + //---------------------------------------------------- -void ESceneSpawnTool::SaveStream(IWriter& F) +void ESceneSpawnTool::SaveStream(IWriter &F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&SPAWN_TOOLS_VERSION,sizeof(SPAWN_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&SPAWN_TOOLS_VERSION, sizeof(SPAWN_TOOLS_VERSION)); - F.open_chunk (CHUNK_FLAGS); - F.w_u32 (m_Flags.get()); - F.close_chunk (); + F.open_chunk(CHUNK_FLAGS); + F.w_u32(m_Flags.get()); + F.close_chunk(); } + //---------------------------------------------------- -bool ESceneSpawnTool::LoadSelection(IReader& F) +bool ESceneSpawnTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=SPAWN_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=SPAWN_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void ESceneSpawnTool::SaveSelection(IWriter& F) +void ESceneSpawnTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&SPAWN_TOOLS_VERSION,sizeof(SPAWN_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&SPAWN_TOOLS_VERSION, sizeof(SPAWN_TOOLS_VERSION)); - inherited::SaveSelection(F); + inherited::SaveSelection(F); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneWallmarkControls.cpp b/src/editors/LevelEditor/Edit/ESceneWallmarkControls.cpp index ad30b0151c0..43fac4ff3a0 100644 --- a/src/editors/LevelEditor/Edit/ESceneWallmarkControls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneWallmarkControls.cpp @@ -5,66 +5,68 @@ #include "ESceneWallmarkControls.h" #include "ESceneWallmarkTools.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "scene.h" -#include "ui_leveltools.h" -#include "ui_levelmain.h" +#include "UI_LevelTools.h" +#include "UI_LevelMain.h" //------------------------------------------------------------------------------ // Node Add //------------------------------------------------------------------------------ -TUI_ControlWallmarkAdd::TUI_ControlWallmarkAdd(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent){ -} +TUI_ControlWallmarkAdd::TUI_ControlWallmarkAdd(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} bool __fastcall TUI_ControlWallmarkAdd::Start(TShiftState Shift) { - ESceneWallmarkTool* S = (ESceneWallmarkTool*)parent_tool; - - S->SelectObjects (false); - wm_cnt = 0; - if (S->AddWallmark(UI->m_CurrentRStart,UI->m_CurrentRDir)) + ESceneWallmarkTool *S = (ESceneWallmarkTool*)parent_tool; + + S->SelectObjects(false); + wm_cnt = 0; + if (S->AddWallmark(UI->m_CurrentRStart, UI->m_CurrentRDir)) { - wm_cnt++; - if (!Shift.Contains(ssAlt)){ - Scene->UndoSave (); - ResetActionToSelect (); + wm_cnt++; + if (!Shift.Contains(ssAlt)) + { + Scene->UndoSave(); + ResetActionToSelect(); return false; - }else return true; + } + else + return true; } return false; } -void TUI_ControlWallmarkAdd::Move(TShiftState _Shift) -{ -} + +void TUI_ControlWallmarkAdd::Move(TShiftState _Shift) {} + bool TUI_ControlWallmarkAdd::End(TShiftState _Shift) { - if (!_Shift.Contains(ssAlt))ResetActionToSelect(); - if (wm_cnt) Scene->UndoSave (); - return true; + if (!_Shift.Contains(ssAlt)) + ResetActionToSelect(); + if (wm_cnt) + Scene->UndoSave(); + return true; } //------------------------------------------------------------------------------------ // WM Move //------------------------------------------------------------------------------------ -TUI_ControlWallmarkMove::TUI_ControlWallmarkMove(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent) -{ -} +TUI_ControlWallmarkMove::TUI_ControlWallmarkMove(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} + bool TUI_ControlWallmarkMove::Start(TShiftState Shift) { - if (Shift.Contains(ssCtrl)){ - ESceneWallmarkTool* S = (ESceneWallmarkTool*)parent_tool; - if (S->MoveSelectedWallmarkTo(UI->m_CurrentRStart,UI->m_CurrentRDir)) + if (Shift.Contains(ssCtrl)) + { + ESceneWallmarkTool *S = (ESceneWallmarkTool*)parent_tool; + if (S->MoveSelectedWallmarkTo(UI->m_CurrentRStart, UI->m_CurrentRDir)) Scene->UndoSave(); } return false; } -void __fastcall TUI_ControlWallmarkMove::Move(TShiftState _Shift) -{ -} +void __fastcall TUI_ControlWallmarkMove::Move(TShiftState _Shift) {} bool __fastcall TUI_ControlWallmarkMove::End(TShiftState _Shift) { - return false; + return false; } diff --git a/src/editors/LevelEditor/Edit/ESceneWallmarkTools.cpp b/src/editors/LevelEditor/Edit/ESceneWallmarkTools.cpp index de3ff8f1024..e4507990dea 100644 --- a/src/editors/LevelEditor/Edit/ESceneWallmarkTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneWallmarkTools.cpp @@ -6,12 +6,12 @@ #include "ESceneWallmarkControls.h" #include "Scene.h" #include "Builder.h" -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditObject.h" #include "SceneObject.h" -#include "../ECore/Editor/UI_ToolsCustom.h" +#include "editors/ECore/Editor/UI_ToolsCustom.h" #include "scene.h" -#include "../ECore/Editor/UI_Main.h" -#include "../ECore/Editor/D3DUtils.h" +#include "editors/ECore/Editor/UI_Main.h" +#include "editors/ECore/Editor/D3DUtils.h" #include "ResourceManager.h" #include "UI_LevelTools.h" @@ -29,224 +29,274 @@ #define MAX_WALLMARK_VERTEX_COUNT 512 #define COMPILER_SHADER "def_shaders\\def_vertex_ghost_no_shadow" -ESceneWallmarkTool::ESceneWallmarkTool():ESceneToolBase(OBJCLASS_WM) +ESceneWallmarkTool::ESceneWallmarkTool(): ESceneToolBase(OBJCLASS_WM) { - m_MarkWidth = 1.f; - m_MarkHeight = 1.f; - m_MarkRotate = 0.f; - m_Flags.assign (flDrawWallmark); -//. m_ShName = "effects\\wallmarkblend"; - m_ShName = "effects\\wallmarkmult"; - m_TxName = ""; + m_MarkWidth = 1.f; + m_MarkHeight = 1.f; + m_MarkRotate = 0.f; + m_Flags.assign(flDrawWallmark); + //. m_ShName = "effects\\wallmarkblend"; + m_ShName = "effects\\wallmarkmult"; + m_TxName = ""; } -ESceneWallmarkTool::~ESceneWallmarkTool() -{ -} +ESceneWallmarkTool::~ESceneWallmarkTool() {} -int ESceneWallmarkTool::RaySelect(int flag, float& distance, const Fvector& start, const Fvector& direction, BOOL bDistanceOnly) +int ESceneWallmarkTool::RaySelect(int flag, float &distance, const Fvector &start, const Fvector &direction, BOOL bDistanceOnly) { - if (!m_Flags.is(flDrawWallmark)) return 0; + if (!m_Flags.is(flDrawWallmark)) + return 0; - wallmark* W = 0; - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++){ - wm_slot* slot = *slot_it; - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++){ - Fvector pt; - if (Fbox::rpOriginOutside==(*w_it)->bbox.Pick2(start,direction,pt)){ - float range = start.distance_to(pt); - if (rangeitems.begin(); w_it!=slot->items.end(); w_it++) + { + Fvector pt; + if (Fbox::rpOriginOutside==(*w_it)->bbox.Pick2(start, direction, pt)) + { + float range = start.distance_to(pt); + if (rangeflags.invert(wallmark::flSelected); - W->flags.set (wallmark::flSelected,flag); + if (W&&!bDistanceOnly) + { + if (flag==-1) + W->flags.invert(wallmark::flSelected); + W->flags.set(wallmark::flSelected, flag); return 1; } return 0; } -int ESceneWallmarkTool::FrustumSelect(int flag, const CFrustum& frustum) +int ESceneWallmarkTool::FrustumSelect(int flag, const CFrustum &frustum) { - if (!m_Flags.is(flDrawWallmark)) return 0; + if (!m_Flags.is(flDrawWallmark)) + return 0; int count = 0; - for (WMSVecIt p_it=marks.begin(); p_it!=marks.end(); p_it++){ - for (WMVecIt m_it=(*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++){ - wallmark* W = *m_it; - u32 mask = 0xffff; - if (frustum.testSAABB(W->bounds.P,W->bounds.R,W->bbox.data(),mask)){ - if (-1==flag) W->flags.invert (wallmark::flSelected); - else W->flags.set (wallmark::flSelected,flag); + for (WMSVecIt p_it = marks.begin(); p_it!=marks.end(); p_it++) + { + for (WMVecIt m_it = (*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++) + { + wallmark *W = *m_it; + u32 mask = 0xffff; + if (frustum.testSAABB(W->bounds.P, W->bounds.R, W->bbox.data(), mask)) + { + if (-1==flag) + W->flags.invert(wallmark::flSelected); + else + W->flags.set(wallmark::flSelected, flag); count++; } } } - UI->RedrawScene (); + UI->RedrawScene(); return count; } void ESceneWallmarkTool::SelectObjects(bool flag) { - if (!m_Flags.is(flDrawWallmark)) return; - for (WMSVecIt p_it=marks.begin(); p_it!=marks.end(); p_it++){ - for (WMVecIt m_it=(*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++) - (*m_it)->flags.set(wallmark::flSelected,flag); + if (!m_Flags.is(flDrawWallmark)) + return; + for (WMSVecIt p_it = marks.begin(); p_it!=marks.end(); p_it++) + { + for (WMVecIt m_it = (*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++) + (*m_it)->flags.set(wallmark::flSelected, flag); } - UI->RedrawScene (); + UI->RedrawScene(); } void ESceneWallmarkTool::InvertSelection() { - if (!m_Flags.is(flDrawWallmark)) return; - for (WMSVecIt p_it=marks.begin(); p_it!=marks.end(); p_it++){ - for (WMVecIt m_it=(*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++) + if (!m_Flags.is(flDrawWallmark)) + return; + for (WMSVecIt p_it = marks.begin(); p_it!=marks.end(); p_it++) + { + for (WMVecIt m_it = (*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++) (*m_it)->flags.invert(wallmark::flSelected); } - UI->RedrawScene (); + UI->RedrawScene(); } void ESceneWallmarkTool::RemoveSelection() { - if (!m_Flags.is(flDrawWallmark)) return; - for (WMSVecIt p_it=marks.begin(); p_it!=marks.end(); p_it++){ - for (WMVecIt m_it=(*p_it)->items.begin(); m_it!=(*p_it)->items.end(); ) - if ((*m_it)->flags.is(wallmark::flSelected)){ - wm_destroy (*m_it); - *m_it = (*p_it)->items.back(); + if (!m_Flags.is(flDrawWallmark)) + return; + for (WMSVecIt p_it = marks.begin(); p_it!=marks.end(); p_it++) + { + for (WMVecIt m_it = (*p_it)->items.begin(); m_it!=(*p_it)->items.end();) + if ((*m_it)->flags.is(wallmark::flSelected)) + { + wm_destroy(*m_it); + *m_it = (*p_it)->items.back(); (*p_it)->items.pop_back(); - }else{ - m_it++; + } + else + { + m_it++; } } - UI->RedrawScene (); + UI->RedrawScene(); } int ESceneWallmarkTool::SelectionCount(bool testflag) { - if (!m_Flags.is(flDrawWallmark)) return 0; - int count = 0; - for (WMSVecIt p_it=marks.begin(); p_it!=marks.end(); p_it++) - for (WMVecIt m_it=(*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++) - if ((*m_it)->flags.is(wallmark::flSelected)) count++; - return count; + if (!m_Flags.is(flDrawWallmark)) + return 0; + int count = 0; + for (WMSVecIt p_it = marks.begin(); p_it!=marks.end(); p_it++) + for (WMVecIt m_it = (*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++) + if ((*m_it)->flags.is(wallmark::flSelected)) + count++; + return count; } void ESceneWallmarkTool::Clear(bool bOnlyNodes) { - inherited::Clear (); - { - for (WMSVecIt p_it=marks.begin(); p_it!=marks.end(); p_it++){ - for (WMVecIt m_it=(*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++) - wm_destroy (*m_it); - xr_delete(*p_it); - } - marks.clear (); - } - { - for (u32 it=0; ititems.begin(); m_it!=(*p_it)->items.end(); m_it++) + wm_destroy(*m_it); + xr_delete(*p_it); + } + marks.clear(); + } + { + for (u32 it = 0; it { - bool operator()(const ESceneWallmarkTool::wm_slot*& x){ return x==0; } + bool operator()(const ESceneWallmarkTool::wm_slot *&x) + { + return x==0; + } }; + void ESceneWallmarkTool::RefiningSlots() { - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++){ - wm_slot*& slot = *slot_it; - if (slot->items.empty()) xr_delete(slot); + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); slot_it++) + { + wm_slot *&slot = *slot_it; + if (slot->items.empty()) + xr_delete(slot); } - WMSVecIt new_end = std::remove_if(marks.begin(),marks.end(),zero_slot_pred()); - marks.erase (new_end,marks.end()); + WMSVecIt new_end = std::remove_if(marks.begin(), marks.end(), zero_slot_pred()); + marks.erase(new_end, marks.end()); } -extern ECORE_API float r_ssaDISCARD; -const int MAX_R_VERTEX = 4096; +extern ECORE_API +float r_ssaDISCARD; +const int MAX_R_VERTEX = 4096; void ESceneWallmarkTool::OnRender(int priority, bool strictB2F) { - if (!m_Flags.is(flDrawWallmark))return; - if (marks.empty()) return; + if (!m_Flags.is(flDrawWallmark)) + return; + if (marks.empty()) + return; - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++){ - wm_slot* slot = *slot_it; + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); slot_it++) + { + wm_slot *slot = *slot_it; VERIFY(slot->shader); - if ((u32(priority)==slot->shader->E[0]->flags.iPriority)&&(strictB2F==!!(slot->shader->E[0]->flags.bStrictB2F))){ + if ((u32(priority)==slot->shader->E[0]->flags.iPriority)&&(strictB2F==!!(slot->shader->E[0]->flags.bStrictB2F))) + { // Projection and xform - float _43 = EDevice.mProject._43; - EDevice.mProject._43 -= 0.01f; - RCache.set_xform_world (Fidentity); + float _43 = EDevice.mProject._43; + EDevice.mProject._43 -= 0.01f; + RCache.set_xform_world(Fidentity); RCache.set_xform_project(EDevice.mProject); - float ssaCLIP = r_ssaDISCARD/4; + float ssaCLIP = r_ssaDISCARD/4; - u32 w_offset = 0; - FVF::LIT* w_verts = (FVF::LIT*) RCache.Vertex.Lock(MAX_R_VERTEX,hGeom->vb_stride,w_offset); - FVF::LIT* w_start = w_verts; + u32 w_offset = 0; + FVF::LIT *w_verts = (FVF::LIT*) RCache.Vertex.Lock(MAX_R_VERTEX, hGeom->vb_stride, w_offset); + FVF::LIT *w_start = w_verts; - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++){ - wallmark* W = *w_it; - VERIFY3 (W->verts.size()<=MAX_R_VERTEX,"ERROR: Invalid wallmark.",*slot->tx_name); - if (RImplementation.ViewBase.testSphere_dirty(W->bounds.P,W->bounds.R)){ - float dst = EDevice.vCameraPosition.distance_to_sqr(W->bounds.P); - float ssa = W->bounds.R * W->bounds.R / dst; - if (ssa>=ssaCLIP){ + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) + { + wallmark *W = *w_it; + VERIFY3(W->verts.size()<=MAX_R_VERTEX, "ERROR: Invalid wallmark.", *slot->tx_name); + if (RImplementation.ViewBase.testSphere_dirty(W->bounds.P, W->bounds.R)) + { + float dst = EDevice.vCameraPosition.distance_to_sqr(W->bounds.P); + float ssa = W->bounds.R*W->bounds.R/dst; + if (ssa>=ssaCLIP) + { // fill wallmark - u32 C = color_rgba(255,255,255,255); - int t_cnt = W->verts.size()/3; - for (int t_idx=0; t_idxMAX_R_VERTEX){ + u32 C = color_rgba(255, 255, 255, 255); + int t_cnt = W->verts.size()/3; + for (int t_idx = 0; t_idxMAX_R_VERTEX) + { // Flush stream - RCache.Vertex.Unlock (w_count,hGeom->vb_stride); - RCache.set_Shader (slot->shader); - RCache.set_Geometry (hGeom); - RCache.Render (D3DPT_TRIANGLELIST,w_offset,w_count/3); + RCache.Vertex.Unlock(w_count, hGeom->vb_stride); + RCache.set_Shader(slot->shader); + RCache.set_Geometry(hGeom); + RCache.Render(D3DPT_TRIANGLELIST, w_offset, w_count/3); // Restart (re-lock/re-calc) - w_verts = (FVF::LIT*) RCache.Vertex.Lock (MAX_R_VERTEX,hGeom->vb_stride,w_offset); - w_start = w_verts; + w_verts = (FVF::LIT*) RCache.Vertex.Lock(MAX_R_VERTEX, hGeom->vb_stride, w_offset); + w_start = w_verts; } // real fill buffer - FVF::LIT* S = W->verts.begin()+t_idx*3; - for (int k=0; k<3; k++,S++,w_verts++){ - w_verts->p.set (S->p); - w_verts->color = C; - w_verts->t.set (S->t); + FVF::LIT *S = W->verts.begin()+t_idx*3; + for (int k = 0; k<3; k++,S++,w_verts++) + { + w_verts->p.set(S->p); + w_verts->color = C; + w_verts->t.set(S->t); } } } } } // Flush stream - u32 w_count = u32(w_verts-w_start); - RCache.Vertex.Unlock (w_count,hGeom->vb_stride); - if (w_count) + u32 w_count = u32(w_verts-w_start); + RCache.Vertex.Unlock(w_count, hGeom->vb_stride); + if (w_count) { - RCache.set_Shader (slot->shader); - RCache.set_Geometry (hGeom); - RCache.Render (D3DPT_TRIANGLELIST,w_offset,w_count/3); + RCache.set_Shader(slot->shader); + RCache.set_Geometry(hGeom); + RCache.Render(D3DPT_TRIANGLELIST, w_offset, w_count/3); } // Projection - EDevice.mProject._43 = _43; - RCache.set_xform_project (EDevice.mProject); + EDevice.mProject._43 = _43; + RCache.set_xform_project(EDevice.mProject); } - if ((1==priority)&&(false==strictB2F)){ - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++){ - wallmark* W = *w_it; + if ((1==priority)&&(false==strictB2F)) + { + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) + { + wallmark *W = *w_it; if (W->flags.is(wallmark::flSelected)) - if (RImplementation.ViewBase.testSphere_dirty(W->bounds.P,W->bounds.R)) + if (RImplementation.ViewBase.testSphere_dirty(W->bounds.P, W->bounds.R)) DU_impl.DrawSelectionBoxB(W->bbox); } } @@ -255,127 +305,137 @@ void ESceneWallmarkTool::OnRender(int priority, bool strictB2F) struct zero_item_pred : public std::unary_function { - bool operator()(const ESceneWallmarkTool::wallmark*& x){ return x==0; } + bool operator()(const ESceneWallmarkTool::wallmark *&x) + { + return x==0; + } }; -bool ESceneWallmarkTool::LoadLTX(CInifile& ini) + +bool ESceneWallmarkTool::LoadLTX(CInifile &ini) { - R_ASSERT(0); - return true; + R_ASSERT(0); + return true; } -void ESceneWallmarkTool::SaveLTX(CInifile& ini, int id) + +void ESceneWallmarkTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); + inherited::SaveLTX(ini, id); - ini.w_u32 ("main", "version", WM_VERSION); + ini.w_u32("main", "version", WM_VERSION); - ini.w_u32 ("main", "flags",m_Flags.get()); + ini.w_u32("main", "flags", m_Flags.get()); - ini.w_float ("main", "mark_width", m_MarkWidth); - ini.w_float ("main", "mark_height", m_MarkHeight); - ini.w_float ("main", "mark_rotate", m_MarkRotate); - ini.w_string ("main", "sh_name", m_ShName.c_str()); - ini.w_string ("main", "tx_name", m_TxName.c_str()); + ini.w_float("main", "mark_width", m_MarkWidth); + ini.w_float("main", "mark_height", m_MarkHeight); + ini.w_float("main", "mark_rotate", m_MarkRotate); + ini.w_string("main", "sh_name", m_ShName.c_str()); + ini.w_string("main", "tx_name", m_TxName.c_str()); - u32 i = 0; - string128 buff, buff2; - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); ++slot_it, ++i) + u32 i = 0; + string128 buff, buff2; + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); ++slot_it,++i) { - wm_slot* slot = *slot_it; + wm_slot *slot = *slot_it; - sprintf (buff,"slot_%d", i); - ini.w_u32 (buff, "items_count", slot->items.size()); + sprintf(buff, "slot_%d", i); + ini.w_u32(buff, "items_count", slot->items.size()); if (slot->items.size()==0) - continue; + continue; - ini.w_string (buff, "sh_name", slot->sh_name.c_str()); - ini.w_string (buff, "tx_name", slot->tx_name.c_str()); + ini.w_string(buff, "sh_name", slot->sh_name.c_str()); + ini.w_string(buff, "tx_name", slot->tx_name.c_str()); - u32 ii = 0; - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); ++w_it, ++ii) + u32 ii = 0; + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); ++w_it,++ii) { - wallmark* W = *w_it; - sprintf (buff2,"itm_%d_flags", ii); - ini.w_u32 (buff, buff2, W->flags.get()); - - sprintf (buff2,"itm_%d_bb_min", ii); - ini.w_fvector3 (buff, buff2, W->bbox.min); - sprintf (buff2,"itm_%d_bb_max", ii); - ini.w_fvector3 (buff, buff2, W->bbox.max); - - sprintf (buff2,"itm_%d_bsphere_p", ii); - ini.w_fvector3 (buff, buff2, W->bounds.P); - sprintf (buff2,"itm_%d_bsphere_r", ii); - ini.w_float (buff, buff2, W->bounds.R); - - sprintf (buff2,"itm_%d_w", ii); - ini.w_float (buff, buff2, W->w); - sprintf (buff2,"itm_%d_h", ii); - ini.w_float (buff, buff2, W->h); - sprintf (buff2,"itm_%d_r", ii); - ini.w_float (buff, buff2, W->r); - - sprintf (buff2,"itm_%d_vert_cnt", ii); - ini.w_u32 (buff, buff2, W->verts.size()); - - R_ASSERT2 (0, "not_implemented"); -//. F.w (&*W->verts.begin(),sizeof(FVF::LIT)*W->verts.size()); + wallmark *W = *w_it; + sprintf(buff2, "itm_%d_flags", ii); + ini.w_u32(buff, buff2, W->flags.get()); + + sprintf(buff2, "itm_%d_bb_min", ii); + ini.w_fvector3(buff, buff2, W->bbox.min); + sprintf(buff2, "itm_%d_bb_max", ii); + ini.w_fvector3(buff, buff2, W->bbox.max); + + sprintf(buff2, "itm_%d_bsphere_p", ii); + ini.w_fvector3(buff, buff2, W->bounds.P); + sprintf(buff2, "itm_%d_bsphere_r", ii); + ini.w_float(buff, buff2, W->bounds.R); + + sprintf(buff2, "itm_%d_w", ii); + ini.w_float(buff, buff2, W->w); + sprintf(buff2, "itm_%d_h", ii); + ini.w_float(buff, buff2, W->h); + sprintf(buff2, "itm_%d_r", ii); + ini.w_float(buff, buff2, W->r); + + sprintf(buff2, "itm_%d_vert_cnt", ii); + ini.w_u32(buff, buff2, W->verts.size()); + + R_ASSERT2(0, "not_implemented"); + //. F.w (&*W->verts.begin(),sizeof(FVF::LIT)*W->verts.size()); } } } -bool ESceneWallmarkTool::LoadStream(IReader& F) +bool ESceneWallmarkTool::LoadStream(IReader &F) { - inherited::LoadStream (F); + inherited::LoadStream(F); - u16 version = 0; + u16 version = 0; - R_ASSERT(F.r_chunk(WM_CHUNK_VERSION,&version)); + R_ASSERT(F.r_chunk(WM_CHUNK_VERSION, &version)); - if(version!=0x0003 && version!=WM_VERSION) + if (version!=0x0003&&version!=WM_VERSION) { - ELog.Msg( mtError, "Static Wallmark: Unsupported version."); + ELog.Msg(mtError, "Static Wallmark: Unsupported version."); return false; } R_ASSERT(F.find_chunk(WM_CHUNK_FLAGS)); - F.r (&m_Flags,sizeof(m_Flags)); + F.r(&m_Flags, sizeof(m_Flags)); R_ASSERT(F.find_chunk(WM_CHUNK_PARAMS)); - m_MarkWidth = F.r_float (); - m_MarkHeight = F.r_float (); - m_MarkRotate = F.r_float (); - F.r_stringZ (m_ShName); - - if(version==0x0003) - m_ShName = "effects\\wallmarkmult"; - - F.r_stringZ (m_TxName); - - IReader* OBJ = F.open_chunk(WM_CHUNK_ITEMS); - if (OBJ){ - IReader* O = OBJ->open_chunk(0); - for (int count=1; O; count++) { - u32 item_count = O->r_u32(); - if (item_count){ - shared_str tex_name,sh_name; - O->r_stringZ (sh_name); - O->r_stringZ (tex_name); - wm_slot* slot = AppendSlot(sh_name,tex_name); - if (slot){ + m_MarkWidth = F.r_float(); + m_MarkHeight = F.r_float(); + m_MarkRotate = F.r_float(); + F.r_stringZ(m_ShName); + + if (version==0x0003) + m_ShName = "effects\\wallmarkmult"; + + F.r_stringZ(m_TxName); + + IReader *OBJ = F.open_chunk(WM_CHUNK_ITEMS); + if (OBJ) + { + IReader *O = OBJ->open_chunk(0); + for (int count = 1; O; count++) + { + u32 item_count = O->r_u32(); + if (item_count) + { + shared_str tex_name, sh_name; + O->r_stringZ(sh_name); + O->r_stringZ(tex_name); + wm_slot *slot = AppendSlot(sh_name, tex_name); + if (slot) + { slot->items.resize(item_count); - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++){ - *w_it = wm_allocate(); - wallmark* W = *w_it; - O->r (&W->flags,sizeof(W->flags)); - O->r (&W->bbox,sizeof(W->bbox)); - O->r (&W->bounds,sizeof(W->bounds)); - W->parent = slot; - W->w = 1.f; - W->h = 1.f; - W->r = 1.f; + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) + { + *w_it = wm_allocate(); + wallmark *W = *w_it; + O->r(&W->flags, sizeof(W->flags)); + O->r(&W->bbox, sizeof(W->bbox)); + O->r(&W->bounds, sizeof(W->bounds)); + W->parent = slot; + W->w = 1.f; + W->h = 1.f; + W->r = 1.f; W->verts.resize(O->r_u32()); - O->r (&*W->verts.begin(),sizeof(FVF::LIT)*W->verts.size()); + O->r(&*W->verts.begin(), sizeof(FVF::LIT)*W->verts.size()); } } } @@ -383,31 +443,38 @@ bool ESceneWallmarkTool::LoadStream(IReader& F) O = OBJ->open_chunk(count); } OBJ->close(); - }else{ - IReader* OBJ = F.open_chunk(WM_CHUNK_ITEMS2); - if (OBJ){ - IReader* O = OBJ->open_chunk(0); - for (int count=1; O; count++) { - u32 item_count = O->r_u32(); - if (item_count){ - shared_str tex_name,sh_name; - O->r_stringZ (sh_name); - O->r_stringZ (tex_name); - wm_slot* slot = AppendSlot(sh_name,tex_name); - if (slot){ + } + else + { + IReader *OBJ = F.open_chunk(WM_CHUNK_ITEMS2); + if (OBJ) + { + IReader *O = OBJ->open_chunk(0); + for (int count = 1; O; count++) + { + u32 item_count = O->r_u32(); + if (item_count) + { + shared_str tex_name, sh_name; + O->r_stringZ(sh_name); + O->r_stringZ(tex_name); + wm_slot *slot = AppendSlot(sh_name, tex_name); + if (slot) + { slot->items.resize(item_count); - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++){ - *w_it = wm_allocate(); - wallmark* W = *w_it; - O->r (&W->flags,sizeof(W->flags)); - O->r (&W->bbox,sizeof(W->bbox)); - O->r (&W->bounds,sizeof(W->bounds)); - W->parent = slot; - W->w = O->r_float(); - W->h = O->r_float(); - W->r = O->r_float(); + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) + { + *w_it = wm_allocate(); + wallmark *W = *w_it; + O->r(&W->flags, sizeof(W->flags)); + O->r(&W->bbox, sizeof(W->bbox)); + O->r(&W->bounds, sizeof(W->bounds)); + W->parent = slot; + W->w = O->r_float(); + W->h = O->r_float(); + W->r = O->r_float(); W->verts.resize(O->r_u32()); - O->r (&*W->verts.begin(),sizeof(FVF::LIT)*W->verts.size()); + O->r(&*W->verts.begin(), sizeof(FVF::LIT)*W->verts.size()); } } } @@ -419,377 +486,435 @@ bool ESceneWallmarkTool::LoadStream(IReader& F) } // validate wallmarks - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++){ - wm_slot* slot = *slot_it; - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++){ - wallmark*& W = *w_it; - if (W->verts.size()>MAX_WALLMARK_VERTEX_COUNT){ - ELog.Msg (mtError,"ERROR: Invalid wallmark (Contain more than %d vertices). Removed.", MAX_WALLMARK_VERTEX_COUNT); - wm_destroy (W); - W = 0; + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); slot_it++) + { + wm_slot *slot = *slot_it; + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) + { + wallmark *&W = *w_it; + if (W->verts.size()>MAX_WALLMARK_VERTEX_COUNT) + { + ELog.Msg(mtError, "ERROR: Invalid wallmark (Contain more than %d vertices). Removed.", MAX_WALLMARK_VERTEX_COUNT); + wm_destroy(W); + W = 0; } } - WMVecIt new_end = std::remove_if(slot->items.begin(),slot->items.end(),zero_item_pred()); - slot->items.erase (new_end,slot->items.end()); + WMVecIt new_end = std::remove_if(slot->items.begin(), slot->items.end(), zero_item_pred()); + slot->items.erase(new_end, slot->items.end()); } - + return true; } -void ESceneWallmarkTool::SaveStream(IWriter& F) -{ - inherited::SaveStream (F); - - F.open_chunk (WM_CHUNK_VERSION); - F.w_u16 (WM_VERSION); - F.close_chunk (); - - F.open_chunk (WM_CHUNK_FLAGS); - F.w (&m_Flags,sizeof(m_Flags)); - F.close_chunk (); - - F.open_chunk (WM_CHUNK_PARAMS); - F.w_float (m_MarkWidth); - F.w_float (m_MarkHeight); - F.w_float (m_MarkRotate); - F.w_stringZ (m_ShName); - F.w_stringZ (m_TxName); - F.close_chunk (); - - F.open_chunk (WM_CHUNK_ITEMS2); - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++){ - F.open_chunk(slot_it-marks.begin()); - wm_slot* slot= *slot_it; - F.w_u32 (slot->items.size()); - if (slot->items.size()){ - F.w_stringZ (slot->sh_name); - F.w_stringZ (slot->tx_name); - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++){ - wallmark* W = *w_it; - F.w (&W->flags,sizeof(W->flags)); - F.w (&W->bbox,sizeof(W->bbox)); - F.w (&W->bounds,sizeof(W->bounds)); - F.w_float (W->w); - F.w_float (W->h); - F.w_float (W->r); - F.w_u32 (W->verts.size()); - F.w (&*W->verts.begin(),sizeof(FVF::LIT)*W->verts.size()); +void ESceneWallmarkTool::SaveStream(IWriter &F) +{ + inherited::SaveStream(F); + + F.open_chunk(WM_CHUNK_VERSION); + F.w_u16(WM_VERSION); + F.close_chunk(); + + F.open_chunk(WM_CHUNK_FLAGS); + F.w(&m_Flags, sizeof(m_Flags)); + F.close_chunk(); + + F.open_chunk(WM_CHUNK_PARAMS); + F.w_float(m_MarkWidth); + F.w_float(m_MarkHeight); + F.w_float(m_MarkRotate); + F.w_stringZ(m_ShName); + F.w_stringZ(m_TxName); + F.close_chunk(); + + F.open_chunk(WM_CHUNK_ITEMS2); + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); slot_it++) + { + F.open_chunk(slot_it-marks.begin()); + wm_slot *slot = *slot_it; + F.w_u32(slot->items.size()); + if (slot->items.size()) + { + F.w_stringZ(slot->sh_name); + F.w_stringZ(slot->tx_name); + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) + { + wallmark *W = *w_it; + F.w(&W->flags, sizeof(W->flags)); + F.w(&W->bbox, sizeof(W->bbox)); + F.w(&W->bounds, sizeof(W->bounds)); + F.w_float(W->w); + F.w_float(W->h); + F.w_float(W->r); + F.w_u32(W->verts.size()); + F.w(&*W->verts.begin(), sizeof(FVF::LIT)*W->verts.size()); } } - F.close_chunk(); + F.close_chunk(); } - F.close_chunk (); + F.close_chunk(); } -bool ESceneWallmarkTool::LoadSelection(IReader& F) +bool ESceneWallmarkTool::LoadSelection(IReader &F) { - Clear(); - return LoadStream(F); + Clear(); + return LoadStream(F); } -void ESceneWallmarkTool::SaveSelection(IWriter& F) +void ESceneWallmarkTool::SaveSelection(IWriter &F) { - SaveStream(F); + SaveStream(F); } bool ESceneWallmarkTool::Export(LPCSTR path) { - RefiningSlots (); - - AnsiString fn = AnsiString(path)+"level.wallmarks"; - IWriter* F = FS.w_open(fn.c_str()); R_ASSERT(F); - - F->open_chunk (1); - F->w_u32 (marks.size()); - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++){ - wm_slot* slot= *slot_it; - F->w_u32 (slot->items.size()); - if (slot->items.size()){ + RefiningSlots(); + + AnsiString fn = AnsiString(path)+"level.wallmarks"; + IWriter *F = FS.w_open(fn.c_str()); + R_ASSERT(F); + + F->open_chunk(1); + F->w_u32(marks.size()); + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); slot_it++) + { + wm_slot *slot = *slot_it; + F->w_u32(slot->items.size()); + if (slot->items.size()) + { F->w_stringZ(slot->sh_name); F->w_stringZ(slot->tx_name); - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++){ - wallmark* W = *w_it; - F->w (&W->bounds,sizeof(W->bounds)); + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) + { + wallmark *W = *w_it; + F->w(&W->bounds, sizeof(W->bounds)); F->w_u32(W->verts.size()); - F->w (&*W->verts.begin(),sizeof(FVF::LIT)*W->verts.size()); + F->w(&*W->verts.begin(), sizeof(FVF::LIT)*W->verts.size()); } } } - F->close_chunk (); + F->close_chunk(); + + FS.w_close(F); - FS.w_close (F); - - return true; -} + return true; +} void ESceneWallmarkTool::OnDeviceCreate() { - hGeom.create (FVF::F_LIT, RCache.Vertex.Buffer(), NULL); + hGeom.create(FVF::F_LIT, RCache.Vertex.Buffer(), NULL); } void ESceneWallmarkTool::OnDeviceDestroy() { - hGeom.destroy (); + hGeom.destroy(); } -void ESceneWallmarkTool::OnSynchronize() -{ -} +void ESceneWallmarkTool::OnSynchronize() {} // allocate -ESceneWallmarkTool::wallmark* ESceneWallmarkTool::wm_allocate () +ESceneWallmarkTool::wallmark *ESceneWallmarkTool::wm_allocate() { - wallmark* W = 0; - if (pool.empty()) W = xr_new (); - else { W = pool.back(); pool.pop_back(); } + wallmark *W = 0; + if (pool.empty()) + W = xr_new(); + else + { + W = pool.back(); + pool.pop_back(); + } - W->verts.clear (); - return W; + W->verts.clear(); + return W; } + // destroy -void ESceneWallmarkTool::wm_destroy (wallmark* W ) +void ESceneWallmarkTool::wm_destroy(wallmark *W) { - pool.push_back (W); + pool.push_back(W); } -struct SWMSlotFindPredicate { - shared_str sh_name; - shared_str tx_name; - SWMSlotFindPredicate(shared_str sh, shared_str tx):sh_name(sh),tx_name(tx){} - bool operator() (const ESceneWallmarkTool::wm_slot* slot) const - { - return (slot->tx_name==tx_name)&&(slot->sh_name==sh_name); - } +struct SWMSlotFindPredicate +{ + shared_str sh_name; + shared_str tx_name; + + SWMSlotFindPredicate(shared_str sh, shared_str tx): sh_name(sh), tx_name(tx) {} + + bool operator()(const ESceneWallmarkTool::wm_slot *slot) const + { + return (slot->tx_name==tx_name)&&(slot->sh_name==sh_name); + } }; -ESceneWallmarkTool::wm_slot* ESceneWallmarkTool::FindSlot (shared_str sh_name, shared_str tx_name) + +ESceneWallmarkTool::wm_slot *ESceneWallmarkTool::FindSlot(shared_str sh_name, shared_str tx_name) { - WMSVecIt it = std::find_if(marks.begin(),marks.end(),SWMSlotFindPredicate(sh_name,tx_name)); - return (it!=marks.end())?*it:0; + WMSVecIt it = std::find_if(marks.begin(), marks.end(), SWMSlotFindPredicate(sh_name, tx_name)); + return (it!=marks.end()) ? *it : 0; } -ESceneWallmarkTool::wm_slot* ESceneWallmarkTool::AppendSlot(shared_str sh_name, shared_str tx_name) + +ESceneWallmarkTool::wm_slot *ESceneWallmarkTool::AppendSlot(shared_str sh_name, shared_str tx_name) { - wm_slot* slot = xr_new(sh_name,tx_name); - if (0==slot->shader) xr_delete(slot); - else marks.push_back (slot); + wm_slot *slot = xr_new(sh_name, tx_name); + if (0==slot->shader) + xr_delete(slot); + else + marks.push_back(slot); return slot; } void ESceneWallmarkTool::RecurseTri(u32 t, Fmatrix &mView, wallmark &W) { - CDB::TRI* T = sml_collector.getT()+t; - if (T->dummy) return; - T->dummy = 0xffffffff; - - // Some vars - u32* v_ids = T->verts; - Fvector* v_data = sml_collector.getV(); - sml_poly_src.clear (); - sml_poly_src.push_back (v_data[v_ids[0]]); - sml_poly_src.push_back (v_data[v_ids[1]]); - sml_poly_src.push_back (v_data[v_ids[2]]); - sml_poly_dest.clear (); - - sPoly* P = sml_clipper.ClipPoly (sml_poly_src, sml_poly_dest); - - if (P) { - // Create vertices and triangulate poly (tri-fan style triangulation) - FVF::LIT V0,V1,V2; - Fvector UV; - - mView.transform_tiny(UV, (*P)[0]); - V0.set ((*P)[0],0,(1+UV.x)*.5f,(1-UV.y)*.5f); - mView.transform_tiny(UV, (*P)[1]); - V1.set ((*P)[1],0,(1+UV.x)*.5f,(1-UV.y)*.5f); - - for (u32 i=2; isize(); i++) - { - mView.transform_tiny(UV, (*P)[i]); - V2.set ((*P)[i],0,(1+UV.x)*.5f,(1-UV.y)*.5f); - W.verts.push_back (V0); - W.verts.push_back (V1); - W.verts.push_back (V2); - V1 = V2; - } - - // recurse - for (i=0; i<3; i++) - { - u32 adj = sml_adjacency[3*t+i]; - if (0xffffffff==adj) continue; - CDB::TRI* SML = sml_collector.getT() + adj; - v_ids = SML->verts; - - Fvector test_normal; - test_normal.mknormal (v_data[v_ids[0]],v_data[v_ids[1]],v_data[v_ids[2]]); - float cosa = test_normal.dotproduct(sml_normal); - if (cosa0.99f) y.set(1,0,0); - }else{ - y.set (EDevice.vCameraTop); - if (fsimilar(y.dotproduct(sml_normal),1.f,EPS)) y.set(EDevice.vCameraRight); - } - right.crossproduct (y,sml_normal); - up.crossproduct (sml_normal,right); - mView.build_camera (from,at,up); - mRot.rotateZ (angle); - mView.mulA_43 (mRot); - mScale.scale (inv_w,inv_h,_max(inv_w,inv_h)); - mView.mulA_43 (mScale); -} - -int ESceneWallmarkTool::ObjectCount() -{ - int count = 0; - for (WMSVecIt p_it=marks.begin(); p_it!=marks.end(); p_it++) - count += (*p_it)->items.size(); - return count; -} - -BOOL ESceneWallmarkTool::AddWallmark_internal(const Fvector& start, const Fvector& dir, shared_str sh, shared_str tx, float width, float height, float rotate) -{ - if (ObjectCount()>=MAX_WALLMARK_COUNT){ - ELog.DlgMsg (mtError,"Maximum wallmark per level is reached [Max: %d].",MAX_WALLMARK_COUNT); - return FALSE; - } - - if (0==sh.size()){ - ELog.DlgMsg (mtError,"Select texture before add wallmark."); - return FALSE; - } - if (0==tx.size()){ - ELog.DlgMsg (mtError,"Select texture before add wallmark."); - return FALSE; + CDB::TRI *T = sml_collector.getT()+t; + if (T->dummy) + return; + T->dummy = 0xffffffff; + + // Some vars + u32 *v_ids = T->verts; + Fvector *v_data = sml_collector.getV(); + sml_poly_src.clear(); + sml_poly_src.push_back(v_data[v_ids[0]]); + sml_poly_src.push_back(v_data[v_ids[1]]); + sml_poly_src.push_back(v_data[v_ids[2]]); + sml_poly_dest.clear(); + + sPoly *P = sml_clipper.ClipPoly(sml_poly_src, sml_poly_dest); + + if (P) + { + // Create vertices and triangulate poly (tri-fan style triangulation) + FVF::LIT V0, V1, V2; + Fvector UV; + + mView.transform_tiny(UV, (*P)[0]); + V0.set((*P)[0], 0, (1+UV.x)*.5f, (1-UV.y)*.5f); + mView.transform_tiny(UV, (*P)[1]); + V1.set((*P)[1], 0, (1+UV.x)*.5f, (1-UV.y)*.5f); + + for (u32 i = 2; isize(); i++) + { + mView.transform_tiny(UV, (*P)[i]); + V2.set((*P)[i], 0, (1+UV.x)*.5f, (1-UV.y)*.5f); + W.verts.push_back(V0); + W.verts.push_back(V1); + W.verts.push_back(V2); + V1 = V2; + } + + // recurse + for (i = 0; i<3; i++) + { + u32 adj = sml_adjacency[3*t+i]; + if (0xffffffff==adj) + continue; + CDB::TRI *SML = sml_collector.getT()+adj; + v_ids = SML->verts; + + Fvector test_normal; + test_normal.mknormal(v_data[v_ids[0]], v_data[v_ids[1]], v_data[v_ids[2]]); + float cosa = test_normal.dotproduct(sml_normal); + if (cosa0.99f) + y.set(1, 0, 0); + } + else + { + y.set(EDevice.vCameraTop); + if (fsimilar(y.dotproduct(sml_normal), 1.f, EPS)) + y.set(EDevice.vCameraRight); + } + right.crossproduct(y, sml_normal); + up.crossproduct(sml_normal, right); + mView.build_camera(from, at, up); + mRot.rotateZ(angle); + mView.mulA_43(mRot); + mScale.scale(inv_w, inv_h, _max(inv_w, inv_h)); + mView.mulA_43(mScale); +} + +int ESceneWallmarkTool::ObjectCount() +{ + int count = 0; + for (WMSVecIt p_it = marks.begin(); p_it!=marks.end(); p_it++) + count += (*p_it)->items.size(); + return count; +} + +BOOL ESceneWallmarkTool::AddWallmark_internal(const Fvector &start, const Fvector &dir, shared_str sh, shared_str tx, float width, float height, float rotate) +{ + if (ObjectCount()>=MAX_WALLMARK_COUNT) + { + ELog.DlgMsg(mtError, "Maximum wallmark per level is reached [Max: %d].",MAX_WALLMARK_COUNT); + return FALSE; + } + + if (0==sh.size()) + { + ELog.DlgMsg(mtError, "Select texture before add wallmark."); + return FALSE; + } + if (0==tx.size()) + { + ELog.DlgMsg(mtError, "Select texture before add wallmark."); + return FALSE; } // pick contact poly - Fvector contact_pt; - float dist = UI->ZFar(); - ObjectList* snap_list = Scene->GetSnapList(false); - if (!snap_list){ - ELog.DlgMsg (mtError,"Fill and activate snap list."); - return FALSE; + Fvector contact_pt; + float dist = UI->ZFar(); + ObjectList *snap_list = Scene->GetSnapList(false); + if (!snap_list) + { + ELog.DlgMsg(mtError, "Fill and activate snap list."); + return FALSE; } // pick contact poly - SPickQuery PQ; - sml_collector.clear (); - if (Scene->RayQuery(PQ,start,dir,dist,CDB::OPT_ONLYNEAREST|CDB::OPT_CULL,snap_list)){ - contact_pt.mad (PQ.m_Start,PQ.m_Direction,PQ.r_begin()->range); - sml_normal.mknormal (PQ.r_begin()->verts[0],PQ.r_begin()->verts[1],PQ.r_begin()->verts[2]); - sml_collector.add_face_packed_D (PQ.r_begin()->verts[0],PQ.r_begin()->verts[1],PQ.r_begin()->verts[2],0); - }else return FALSE; + SPickQuery PQ; + sml_collector.clear(); + if (Scene->RayQuery(PQ, start, dir, dist, CDB::OPT_ONLYNEAREST|CDB::OPT_CULL, snap_list)) + { + contact_pt.mad(PQ.m_Start, PQ.m_Direction, PQ.r_begin()->range); + sml_normal.mknormal(PQ.r_begin()->verts[0], PQ.r_begin()->verts[1], PQ.r_begin()->verts[2]); + sml_collector.add_face_packed_D(PQ.r_begin()->verts[0], PQ.r_begin()->verts[1], PQ.r_begin()->verts[2], 0); + } + else + return FALSE; // box pick poly - Fbox bbox; - bbox.set (contact_pt,contact_pt); - bbox.grow (_max(height,width)*2); - SPickQuery BQ; - if (Scene->BoxQuery(BQ,bbox,CDB::OPT_FULL_TEST,snap_list)){ - for (u32 k=0; k<(u32)BQ.r_count(); k++){ - SPickQuery::SResult* R = BQ.r_begin()+k; - Fvector test_normal; - test_normal.mknormal (R->verts[0],R->verts[1],R->verts[2]); - float cosa = test_normal.dotproduct(sml_normal); - if (cosa<0.1) continue; - sml_collector.add_face_packed_D (R->verts[0],R->verts[1],R->verts[2],0); + Fbox bbox; + bbox.set(contact_pt, contact_pt); + bbox.grow(_max(height, width)*2); + SPickQuery BQ; + if (Scene->BoxQuery(BQ, bbox, CDB::OPT_FULL_TEST, snap_list)) + { + for (u32 k = 0; k<(u32)BQ.r_count(); k++) + { + SPickQuery::SResult *R = BQ.r_begin()+k; + Fvector test_normal; + test_normal.mknormal(R->verts[0], R->verts[1], R->verts[2]); + float cosa = test_normal.dotproduct(sml_normal); + if (cosa<0.1) + continue; + sml_collector.add_face_packed_D(R->verts[0], R->verts[1], R->verts[2], 0); } } // remove duplicate poly - sml_collector.remove_duplicate_T (); + sml_collector.remove_duplicate_T(); // calculate adjacency - sml_collector.calc_adjacency (sml_adjacency); - - // build 3D ortho-frustum - Fmatrix mView; - BuildMatrix (mView,2/width,2/height,rotate,contact_pt); // width/2 height/2 (BuildMatrix need radius) - sml_clipper.CreateFromMatrix (mView,FRUSTUM_P_LRTB); - - // create wallmark - wallmark* W = wm_allocate(); - W->w = width; - W->h = height; - W->r = rotate; - - RecurseTri (0,mView,*W); - - // calc sphere - if ((W->verts.size()<3) || (W->verts.size()>MAX_WALLMARK_VERTEX_COUNT)) { - ELog.DlgMsg (mtError,"Invalid wallmark vertex count. [Min: %d. Max: %d].",3,MAX_WALLMARK_VERTEX_COUNT); - wm_destroy (W); - return FALSE; - }else{ - W->bbox.invalidate(); - FVF::LIT* I=&*W->verts.begin (); - FVF::LIT* E=&*W->verts.end (); - for (; I!=E; I++) W->bbox.modify(I->p); - W->bbox.getsphere (W->bounds.P,W->bounds.R); - W->flags.assign (wallmark::flSelected); - W->bbox.grow (EPS_L); - } - - // search if similar wallmark exists - wm_slot* slot = FindSlot(sh,tx); - if (slot){ - W->parent = slot; - WMVecIt it = slot->items.begin (); - WMVecIt end = slot->items.end (); - for (; it!=end; it++) - { - wallmark* wm = *it; - if (wm->bounds.P.similar(W->bounds.P,0.02f)){ // replace - wm_destroy (wm); - *it = W; - return TRUE; - } - } - }else{ - slot = AppendSlot(sh,tx); - W->parent = slot; - } - - // no similar - register _new_ - if (slot) slot->items.push_back(W); + sml_collector.calc_adjacency(sml_adjacency); + + // build 3D ortho-frustum + Fmatrix mView; + BuildMatrix(mView, 2/width, 2/height, rotate, contact_pt); // width/2 height/2 (BuildMatrix need radius) + sml_clipper.CreateFromMatrix(mView, FRUSTUM_P_LRTB); + + // create wallmark + wallmark *W = wm_allocate(); + W->w = width; + W->h = height; + W->r = rotate; + + RecurseTri(0, mView, *W); + + // calc sphere + if ((W->verts.size()<3)||(W->verts.size()>MAX_WALLMARK_VERTEX_COUNT)) + { + ELog.DlgMsg(mtError, "Invalid wallmark vertex count. [Min: %d. Max: %d].", 3,MAX_WALLMARK_VERTEX_COUNT); + wm_destroy(W); + return FALSE; + } + else + { + W->bbox.invalidate(); + FVF::LIT *I = &*W->verts.begin(); + FVF::LIT *E = &*W->verts.end(); + for (; I!=E; I++) + W->bbox.modify(I->p); + W->bbox.getsphere(W->bounds.P, W->bounds.R); + W->flags.assign(wallmark::flSelected); + W->bbox.grow(EPS_L); + } + + // search if similar wallmark exists + wm_slot *slot = FindSlot(sh, tx); + if (slot) + { + W->parent = slot; + WMVecIt it = slot->items.begin(); + WMVecIt end = slot->items.end(); + for (; it!=end; it++) + { + wallmark *wm = *it; + if (wm->bounds.P.similar(W->bounds.P, 0.02f)) + { // replace + wm_destroy(wm); + *it = W; + return TRUE; + } + } + } + else + { + slot = AppendSlot(sh, tx); + W->parent = slot; + } + + // no similar - register _new_ + if (slot) + slot->items.push_back(W); return TRUE; } -BOOL ESceneWallmarkTool::AddWallmark (const Fvector& start, const Fvector& dir) +BOOL ESceneWallmarkTool::AddWallmark(const Fvector &start, const Fvector &dir) { - return AddWallmark_internal(start,dir,m_ShName,m_TxName,m_MarkWidth,m_MarkHeight,m_MarkRotate); + return AddWallmark_internal(start, dir, m_ShName, m_TxName, m_MarkWidth, m_MarkHeight, m_MarkRotate); } -BOOL ESceneWallmarkTool::MoveSelectedWallmarkTo(const Fvector& start, const Fvector& dir) +BOOL ESceneWallmarkTool::MoveSelectedWallmarkTo(const Fvector &start, const Fvector &dir) { - if (!m_Flags.is(flDrawWallmark)) return 0; - wallmark* wm = 0; - for (WMSVecIt p_it=marks.begin(); p_it!=marks.end(); p_it++){ - for (WMVecIt m_it=(*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++){ - if ((*m_it)->flags.is(wallmark::flSelected)){ - if (wm) return FALSE; - wm = *m_it; + if (!m_Flags.is(flDrawWallmark)) + return 0; + wallmark *wm = 0; + for (WMSVecIt p_it = marks.begin(); p_it!=marks.end(); p_it++) + { + for (WMVecIt m_it = (*p_it)->items.begin(); m_it!=(*p_it)->items.end(); m_it++) + { + if ((*m_it)->flags.is(wallmark::flSelected)) + { + if (wm) + return FALSE; + wm = *m_it; } } } - if ((0!=wm)&&AddWallmark_internal(start,dir,wm->parent->sh_name,wm->parent->tx_name,wm->w,wm->h,wm->r)){ + if ((0!=wm)&&AddWallmark_internal(start, dir, wm->parent->sh_name, wm->parent->tx_name, wm->w, wm->h, wm->r)) + { // remove wm - for (WMSVecIt p_it=marks.begin(); p_it!=marks.end(); p_it++){ - for (WMVecIt m_it=(*p_it)->items.begin(); m_it!=(*p_it)->items.end(); ){ - if (*m_it==wm){ - wm_destroy (wm); - *m_it = (*p_it)->items.back(); + for (WMSVecIt p_it = marks.begin(); p_it!=marks.end(); p_it++) + { + for (WMVecIt m_it = (*p_it)->items.begin(); m_it!=(*p_it)->items.end();) + { + if (*m_it==wm) + { + wm_destroy(wm); + *m_it = (*p_it)->items.back(); (*p_it)->items.pop_back(); return TRUE; } @@ -799,117 +924,137 @@ BOOL ESceneWallmarkTool::MoveSelectedWallmarkTo(const Fvector& start, const Fvec return FALSE; } -void ESceneWallmarkTool::FillProp(LPCSTR pref, PropItemVec& items) +void ESceneWallmarkTool::FillProp(LPCSTR pref, PropItemVec &items) { - PHelper().CreateFlag32 (items, PrepareKey(pref,"Common\\Draw Wallmarks"), &m_Flags, flDrawWallmark); - PHelper().CreateFlag32 (items, PrepareKey(pref,"Common\\Alignment"), &m_Flags, flAxisAlign, "By Camera", "By World Axis"); - PHelper().CreateFloat (items, PrepareKey(pref,"Common\\Width"), &m_MarkWidth, 0.01f, 10.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Common\\Height"), &m_MarkHeight, 0.01f, 10.f); - PHelper().CreateAngle (items, PrepareKey(pref,"Common\\Rotate"), &m_MarkRotate); - PHelper().CreateChoose (items, PrepareKey(pref,"Common\\Shader"), &m_ShName, smEShader); - PHelper().CreateChoose (items, PrepareKey(pref,"Common\\Texture"), &m_TxName, smTexture); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Draw Wallmarks"), &m_Flags, flDrawWallmark); + PHelper().CreateFlag32(items, PrepareKey(pref, "Common\\Alignment"), &m_Flags, flAxisAlign, "By Camera", "By World Axis"); + PHelper().CreateFloat(items, PrepareKey(pref, "Common\\Width"), &m_MarkWidth, 0.01f, 10.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Common\\Height"), &m_MarkHeight, 0.01f, 10.f); + PHelper().CreateAngle(items, PrepareKey(pref, "Common\\Rotate"), &m_MarkRotate); + PHelper().CreateChoose(items, PrepareKey(pref, "Common\\Shader"), &m_ShName, smEShader); + PHelper().CreateChoose(items, PrepareKey(pref, "Common\\Texture"), &m_TxName, smTexture); } + //---------------------------------------------------- bool ESceneWallmarkTool::Validate(bool) { - bool bRes = true; + bool bRes = true; - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++){ - wm_slot* slot= *slot_it; - if (slot->items.size()){ - IBlender* B = EDevice.Resources->_FindBlender(*slot->sh_name); - if (!B||B->canBeLMAPped()){ - ELog.Msg (mtError,"Wallmarks: Invalid or missing shader '%s'.",*slot->sh_name); - bRes = false; + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); slot_it++) + { + wm_slot *slot = *slot_it; + if (slot->items.size()) + { + IBlender *B = EDevice.Resources->_FindBlender(*slot->sh_name); + if (!B||B->canBeLMAPped()) + { + ELog.Msg(mtError, "Wallmarks: Invalid or missing shader '%s'.", *slot->sh_name); + bRes = false; } } } return bRes; } + //---------------------------------------------------- -void ESceneWallmarkTool::GetStaticDesc(int& v_cnt, int& f_cnt, bool b_selected_only, bool b_cform) +void ESceneWallmarkTool::GetStaticDesc(int &v_cnt, int &f_cnt, bool b_selected_only, bool b_cform) { - if(b_cform) - return; - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++) + if (b_cform) + return; + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); slot_it++) { - wm_slot* slot = *slot_it; - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++) + wm_slot *slot = *slot_it; + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) { - wallmark* W = *w_it; + wallmark *W = *w_it; - if(b_selected_only && !W->flags.test(wallmark::flSelected)) - continue; + if (b_selected_only&&!W->flags.test(wallmark::flSelected)) + continue; - v_cnt += W->verts.size(); - f_cnt += W->verts.size()/3; + v_cnt += W->verts.size(); + f_cnt += W->verts.size()/3; } } } + //---------------------------------------------------- -bool ESceneWallmarkTool::ExportStatic(SceneBuilder* B, bool b_selected_only) +bool ESceneWallmarkTool::ExportStatic(SceneBuilder *B, bool b_selected_only) { - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++){ - wm_slot* slot = *slot_it; - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++){ - wallmark* W = *w_it; - int sect_num = B->CalculateSector(W->bounds.P,W->bounds.R); - int m_id = B->BuildMaterial (*slot->sh_name,COMPILER_SHADER,*slot->tx_name,1,sect_num,false); - u32 f_cnt = W->verts.size()/3; - for (u32 f_it=0; f_itl_face_it++){ + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); slot_it++) + { + wm_slot *slot = *slot_it; + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) + { + wallmark *W = *w_it; + int sect_num = B->CalculateSector(W->bounds.P, W->bounds.R); + int m_id = B->BuildMaterial(*slot->sh_name,COMPILER_SHADER, *slot->tx_name, 1, sect_num, false); + u32 f_cnt = W->verts.size()/3; + for (u32 f_it = 0; f_itl_face_it++) + { R_ASSERT(B->l_face_itl_face_cnt); - b_face& dst_f = B->l_faces[B->l_face_it]; - for (u32 k=0; k<3; k++,B->l_vert_it++){ - R_ASSERT(B->l_vert_itl_vert_cnt); - FVF::LIT& src = W->verts[f_it*3+k]; - Fvector& dst_v = B->l_verts[B->l_vert_it]; - dst_v.set (src.p); - dst_f.v[k] = B->l_vert_it; - dst_f.t[k].set (src.t); - dst_f.dwMaterial= (u16)m_id; + b_face &dst_f = B->l_faces[B->l_face_it]; + for (u32 k = 0; k<3; k++,B->l_vert_it++) + { + R_ASSERT(B->l_vert_itl_vert_cnt); + FVF::LIT &src = W->verts[f_it*3+k]; + Fvector &dst_v = B->l_verts[B->l_vert_it]; + dst_v.set(src.p); + dst_f.v[k] = B->l_vert_it; + dst_f.t[k].set(src.t); + dst_f.dwMaterial = (u16)m_id; } } } } - return true; + return true; } + //---------------------------------------------------- void ESceneWallmarkTool::CreateControls() { - inherited::CreateDefaultControls(estDefault); - // node tools - AddControl(xr_new (0, etaAdd, this)); - AddControl(xr_new (0, etaMove, this)); + inherited::CreateDefaultControls(estDefault); + // node tools + AddControl(xr_new(0, etaAdd, this)); + AddControl(xr_new(0, etaMove, this)); } + //---------------------------------------------------- - + void ESceneWallmarkTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- -void ESceneWallmarkTool::GetBBox(Fbox& bb, bool bSelOnly) +void ESceneWallmarkTool::GetBBox(Fbox &bb, bool bSelOnly) { - if (bSelOnly){ - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++){ - wm_slot* slot = *slot_it; - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++){ - wallmark* W = *w_it; - if (W->flags.is(wallmark::flSelected)) bb.merge (W->bbox); + if (bSelOnly) + { + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); slot_it++) + { + wm_slot *slot = *slot_it; + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) + { + wallmark *W = *w_it; + if (W->flags.is(wallmark::flSelected)) + bb.merge(W->bbox); } } - }else{ - for (WMSVecIt slot_it=marks.begin(); slot_it!=marks.end(); slot_it++){ - wm_slot* slot = *slot_it; - for (WMVecIt w_it=slot->items.begin(); w_it!=slot->items.end(); w_it++) - bb.merge ((*w_it)->bbox); + } + else + { + for (WMSVecIt slot_it = marks.begin(); slot_it!=marks.end(); slot_it++) + { + wm_slot *slot = *slot_it; + for (WMVecIt w_it = slot->items.begin(); w_it!=slot->items.end(); w_it++) + bb.merge((*w_it)->bbox); } } } diff --git a/src/editors/LevelEditor/Edit/ESceneWallmarkTools.h b/src/editors/LevelEditor/Edit/ESceneWallmarkTools.h index 97a9b247cc2..b0142d772f0 100644 --- a/src/editors/LevelEditor/Edit/ESceneWallmarkTools.h +++ b/src/editors/LevelEditor/Edit/ESceneWallmarkTools.h @@ -7,137 +7,195 @@ class ESceneWallmarkTool: public ESceneToolBase { - typedef ESceneToolBase inherited; -public: - DEFINE_VECTOR (FVF::LIT,LITVertVec,LITVertVecIt); + typedef ESceneToolBase inherited; +public: + DEFINE_VECTOR(FVF::LIT, LITVertVec, LITVertVecIt); struct wm_slot; - struct wallmark - { - enum{ - flSelected = (1<<0) + + struct wallmark + { + enum + { + flSelected = (1<<0) }; - wm_slot* parent; - float w,h,r; - Flags8 flags; - Fbox bbox; - Fsphere bounds; - LITVertVec verts; - wallmark (){flags.zero();parent=0;w=0;h=0;r=0;} - }; - DEFINE_VECTOR (wallmark*,WMVec,WMVecIt); - struct wm_slot - { - shared_str sh_name; - shared_str tx_name; - ref_shader shader; - WMVec items; - wm_slot (shared_str sh, shared_str tx) {sh_name=sh;tx_name=tx;shader.create(*sh_name,*tx_name);items.reserve(256);} - }; - DEFINE_VECTOR (wm_slot*,WMSVec,WMSVecIt); - WMSVec marks; - WMVec pool; + + wm_slot *parent; + float w, h, r; + Flags8 flags; + Fbox bbox; + Fsphere bounds; + LITVertVec verts; + + wallmark() + { + flags.zero(); + parent = 0; + w = 0; + h = 0; + r = 0; + } + }; + + DEFINE_VECTOR(wallmark *, WMVec, WMVecIt); + + struct wm_slot + { + shared_str sh_name; + shared_str tx_name; + ref_shader shader; + WMVec items; + + wm_slot(shared_str sh, shared_str tx) + { + sh_name = sh; + tx_name = tx; + shader.create(*sh_name, *tx_name); + items.reserve(256); + } + }; + + DEFINE_VECTOR(wm_slot *, WMSVec, WMSVecIt); + WMSVec marks; + WMVec pool; private: - ref_geom hGeom; + ref_geom hGeom; - Fvector sml_normal; - CFrustum sml_clipper; - sPoly sml_poly_dest; - sPoly sml_poly_src; + Fvector sml_normal; + CFrustum sml_clipper; + sPoly sml_poly_dest; + sPoly sml_poly_src; - CDB::Collector sml_collector; - xr_vector sml_adjacency; + CDB::Collector sml_collector; + xr_vector sml_adjacency; - wm_slot* FindSlot (shared_str sh_name, shared_str tx_name); - wm_slot* AppendSlot (shared_str sh_name, shared_str tx_name); + wm_slot *FindSlot(shared_str sh_name, shared_str tx_name); + wm_slot *AppendSlot(shared_str sh_name, shared_str tx_name); - void RecurseTri (u32 t, Fmatrix &mView, wallmark &W); - void BuildMatrix (Fmatrix &mView, float inv_w, float inv_h, float angle, const Fvector& from); - BOOL AddWallmark_internal (const Fvector& S, const Fvector& D, shared_str s, shared_str t, float w, float h, float r); + void RecurseTri(u32 t, Fmatrix &mView, wallmark &W); + void BuildMatrix(Fmatrix &mView, float inv_w, float inv_h, float angle, const Fvector &from); + BOOL AddWallmark_internal(const Fvector &S, const Fvector &D, shared_str s, shared_str t, float w, float h, float r); - void RefiningSlots (); + void RefiningSlots(); private: - wallmark* wm_allocate (); - void wm_destroy (wallmark* W); + wallmark *wm_allocate(); + void wm_destroy(wallmark *W); private: // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - enum{ - flDrawWallmark = (1<<0), - flAxisAlign = (1<<1) + enum + { + flDrawWallmark = (1<<0), + flAxisAlign = (1<<1) }; - Flags32 m_Flags; - float m_MarkWidth; - float m_MarkHeight; - float m_MarkRotate; - shared_str m_ShName; - shared_str m_TxName; + Flags32 m_Flags; - int ObjectCount (); + float m_MarkWidth; + float m_MarkHeight; + float m_MarkRotate; + shared_str m_ShName; + shared_str m_TxName; + + int ObjectCount(); public: - ESceneWallmarkTool (); - virtual ~ESceneWallmarkTool (); + ESceneWallmarkTool(); + virtual ~ESceneWallmarkTool(); + + virtual bool AllowEnabling() + { + return true; + } - virtual bool AllowEnabling (){return true;} - virtual BOOL AllowMouseStart (){return true;} + virtual BOOL AllowMouseStart() + { + return true; + } - virtual void OnObjectRemove (CCustomObject* O, bool bDeleting){} - virtual void UpdateSnapList (){} - virtual ObjectList* GetSnapList (){return 0;} + virtual void OnObjectRemove(CCustomObject *O, bool bDeleting) {} - // selection manipulate - virtual int RaySelect (int flag, float& distance, const Fvector& start, const Fvector& direction, BOOL bDistanceOnly); - virtual int FrustumSelect (int flag, const CFrustum& frustum); - virtual void SelectObjects (bool flag); - virtual void InvertSelection (); - virtual void RemoveSelection (); - virtual int SelectionCount (bool testflag); - virtual void ShowObjects (bool flag, bool bAllowSelectionFlag=false, bool bSelFlag=true){} + virtual void UpdateSnapList() {} - virtual void Clear (bool bOnlyNodes=false); + virtual ObjectList *GetSnapList() + { + return 0; + } - // definition - IC LPCSTR ClassName (){return "wallmark";} - IC LPCSTR ClassDesc (){return "Wallmark";} - IC int RenderPriority (){return 10;} + // selection manipulate + virtual int RaySelect(int flag, float &distance, const Fvector &start, const Fvector &direction, BOOL bDistanceOnly); + virtual int FrustumSelect(int flag, const CFrustum &frustum); + virtual void SelectObjects(bool flag); + virtual void InvertSelection(); + virtual void RemoveSelection(); + virtual int SelectionCount(bool testflag); + + virtual void ShowObjects(bool flag, bool bAllowSelectionFlag = false, bool bSelFlag = true) {} + + virtual void Clear(bool bOnlyNodes = false); + + // definition + IC LPCSTR ClassName() + { + return "wallmark"; + } + + IC LPCSTR ClassDesc() + { + return "Wallmark"; + } + + IC + + int RenderPriority() + { + return 10; + } // validation - virtual bool Valid (); - virtual bool Validate (bool full_test); - virtual bool IsNeedSave (); + virtual bool Valid(); + virtual bool Validate(bool full_test); + virtual bool IsNeedSave(); // events - virtual void OnFrame (); - virtual void OnRender (int priority, bool strictB2F); + virtual void OnFrame(); + virtual void OnRender(int priority, bool strictB2F); // IO - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool can_use_inifile () {return false;} - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); - virtual bool Export (LPCSTR fn); - virtual bool ExportStatic (SceneBuilder* B, bool b_selected_only); - virtual void GetStaticDesc (int& v_cnt, int& f_cnt, bool b_selected_only, bool b_cform); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + + virtual bool can_use_inifile() + { + return false; + } - // device dependent funcs - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); + virtual bool Export(LPCSTR fn); + virtual bool ExportStatic(SceneBuilder *B, bool b_selected_only); + virtual void GetStaticDesc(int &v_cnt, int &f_cnt, bool b_selected_only, bool b_cform); - virtual void OnSynchronize (); + // device dependent funcs + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); - virtual bool GetSummaryInfo (SSceneSummary* inf){return false;} + virtual void OnSynchronize(); - // properties - virtual void FillProp (LPCSTR pref, PropItemVec& items); + virtual bool GetSummaryInfo(SSceneSummary *inf) + { + return false; + } + + // properties + virtual void FillProp(LPCSTR pref, PropItemVec &items); // utils - virtual void GetBBox (Fbox& bb, bool bSelOnly); - BOOL AddWallmark (const Fvector& start, const Fvector& dir); - BOOL MoveSelectedWallmarkTo (const Fvector& start, const Fvector& dir); + virtual void GetBBox(Fbox &bb, bool bSelOnly); + BOOL AddWallmark(const Fvector &start, const Fvector &dir); + BOOL MoveSelectedWallmarkTo(const Fvector &start, const Fvector &dir); }; #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneWayControls.cpp b/src/editors/LevelEditor/Edit/ESceneWayControls.cpp index 83ae8f6b633..3ec411a5a01 100644 --- a/src/editors/LevelEditor/Edit/ESceneWayControls.cpp +++ b/src/editors/LevelEditor/Edit/ESceneWayControls.cpp @@ -3,66 +3,74 @@ #include "ESceneWayTools.h" #include "ESceneWayControls.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "FrameWayPoint.h" #include "WayPoint.h" #include "scene.h" -#include "ui_levelmain.h" +#include "UI_LevelMain.h" void ESceneWayTool::OnActivate() { - inherited::OnActivate (); - TfraWayPoint* frame =(TfraWayPoint*)pFrame; - if (sub_target==estWayModePoint) frame->ebModePoint->Down = true; - else frame->ebModeWay->Down = true; + inherited::OnActivate(); + TfraWayPoint *frame = (TfraWayPoint*)pFrame; + if (sub_target==estWayModePoint) + frame->ebModePoint->Down = true; + else + frame->ebModeWay->Down = true; } + //---------------------------------------------------- void ESceneWayTool::CreateControls() { - inherited::CreateDefaultControls(estWayModeWay); - inherited::CreateDefaultControls(estWayModePoint); - AddControl (xr_new (estWayModePoint, etaAdd, this)); - // frame - pFrame = xr_new((TComponent*)0); + inherited::CreateDefaultControls(estWayModeWay); + inherited::CreateDefaultControls(estWayModePoint); + AddControl(xr_new(estWayModePoint, etaAdd, this)); + // frame + pFrame = xr_new((TComponent*)0); } + //---------------------------------------------------- void ESceneWayTool::RemoveControls() { - inherited::RemoveControls(); + inherited::RemoveControls(); } + //---------------------------------------------------- //--------------------------------------------------------------------------- -__fastcall TUI_ControlWayPointAdd::TUI_ControlWayPointAdd(int st, int act, ESceneToolBase* parent):TUI_CustomControl(st,act,parent){ -} +__fastcall TUI_ControlWayPointAdd::TUI_ControlWayPointAdd(int st, int act, ESceneToolBase *parent): TUI_CustomControl(st, act, parent) {} bool __fastcall TUI_ControlWayPointAdd::Start(TShiftState Shift) { - ObjectList lst; Scene->GetQueryObjects(lst,OBJCLASS_WAY,1,1,-1); - TfraWayPoint* frame=(TfraWayPoint*)parent_tool->pFrame; - if (1!=lst.size()){ - ELog.DlgMsg(mtInformation,"Select one WayObject."); + ObjectList lst; + Scene->GetQueryObjects(lst, OBJCLASS_WAY, 1, 1, -1); + TfraWayPoint *frame = (TfraWayPoint*)parent_tool->pFrame; + if (1!=lst.size()) + { + ELog.DlgMsg(mtInformation, "Select one WayObject."); return false; } Fvector p; - if (LUI->PickGround(p,UI->m_CurrentRStart,UI->m_CurrentRDir,1)) + if (LUI->PickGround(p, UI->m_CurrentRStart, UI->m_CurrentRDir, 1)) { - CWayObject* obj = (CWayObject*)lst.front(); R_ASSERT(obj); - CWayPoint* last_wp=obj->GetFirstSelected(); - CWayPoint* wp=obj->AppendWayPoint(); + CWayObject *obj = (CWayObject*)lst.front(); + R_ASSERT(obj); + CWayPoint *last_wp = obj->GetFirstSelected(); + CWayPoint *wp = obj->AppendWayPoint(); wp->MoveTo(p); if (frame->ebAutoLink->Down) { - if (last_wp) last_wp->AddSingleLink(wp); + if (last_wp) + last_wp->AddSingleLink(wp); } Scene->UndoSave(); } - if (!Shift.Contains(ssAlt)) ResetActionToSelect(); + if (!Shift.Contains(ssAlt)) + ResetActionToSelect(); return false; } -void __fastcall TUI_ControlWayPointAdd::OnEnter(){ -} +void __fastcall TUI_ControlWayPointAdd::OnEnter() {} diff --git a/src/editors/LevelEditor/Edit/ESceneWayControls.h b/src/editors/LevelEditor/Edit/ESceneWayControls.h index b69da42fb8c..0a6c79bc457 100644 --- a/src/editors/LevelEditor/Edit/ESceneWayControls.h +++ b/src/editors/LevelEditor/Edit/ESceneWayControls.h @@ -6,17 +6,24 @@ // refs class CWayPoint; -enum{ - estWayModeWay, - estWayModePoint +enum +{ + estWayModeWay, + estWayModePoint }; + //--------------------------------------------------------------------------- -class TUI_ControlWayPointAdd: public TUI_CustomControl{ +class TUI_ControlWayPointAdd: public TUI_CustomControl +{ public: - TUI_ControlWayPointAdd(int st, int act, ESceneToolBase* parent); - virtual ~TUI_ControlWayPointAdd(){;} - virtual bool Start (TShiftState _Shift); + TUI_ControlWayPointAdd(int st, int act, ESceneToolBase *parent); + + virtual ~TUI_ControlWayPointAdd() {} + + virtual bool Start(TShiftState _Shift); virtual void OnEnter(); }; #endif //UI_WayPointToolsH + + diff --git a/src/editors/LevelEditor/Edit/ESceneWayTools.cpp b/src/editors/LevelEditor/Edit/ESceneWayTools.cpp index 72866e15a03..f70e26a5729 100644 --- a/src/editors/LevelEditor/Edit/ESceneWayTools.cpp +++ b/src/editors/LevelEditor/Edit/ESceneWayTools.cpp @@ -4,11 +4,13 @@ #include "ESceneWayTools.h" #include "WayPoint.h" -CCustomObject* ESceneWayTool::CreateObject(LPVOID data, LPCSTR name) +CCustomObject *ESceneWayTool::CreateObject(LPVOID data, LPCSTR name) { - CCustomObject* O = xr_new(data,name); - O->ParentTool = this; + CCustomObject*O = xr_new(data, name); + O->ParentTool = this; return O; } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/ESceneWayTools.h b/src/editors/LevelEditor/Edit/ESceneWayTools.h index eea954b4006..4722e97345f 100644 --- a/src/editors/LevelEditor/Edit/ESceneWayTools.h +++ b/src/editors/LevelEditor/Edit/ESceneWayTools.h @@ -6,31 +6,58 @@ class ESceneWayTool: public ESceneCustomOTool { - typedef ESceneCustomOTool inherited; + typedef ESceneCustomOTool inherited; protected: // controls - virtual void CreateControls (); - virtual void RemoveControls (); + virtual void CreateControls(); + virtual void RemoveControls(); public: - ESceneWayTool ():ESceneCustomOTool(OBJCLASS_WAY){;} - // definition - IC LPCSTR ClassName (){return "way";} - IC LPCSTR ClassDesc (){return "Way";} - IC int RenderPriority (){return 1;} + ESceneWayTool(): ESceneCustomOTool(OBJCLASS_WAY) + { + ; + } + + // definition + IC LPCSTR ClassName() + { + return "way"; + } + + IC LPCSTR ClassDesc() + { + return "Way"; + } + + IC + + int RenderPriority() + { + return 1; + } + + virtual void Clear(bool bSpecific = false) + { + inherited::Clear(bSpecific); + } - virtual void Clear (bool bSpecific=false){inherited::Clear(bSpecific);} // IO - virtual bool IsNeedSave (){return inherited::IsNeedSave();} - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile&); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile&, int id); - virtual bool LoadSelection (IReader&); - virtual void SaveSelection (IWriter&); + virtual bool IsNeedSave() + { + return inherited::IsNeedSave(); + } + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &, int id); + virtual bool LoadSelection(IReader &); + virtual void SaveSelection(IWriter &); - virtual void OnActivate (); + virtual void OnActivate(); - virtual CCustomObject* CreateObject (LPVOID data, LPCSTR name); + virtual CCustomObject *CreateObject(LPVOID data, LPCSTR name); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/ESceneWayToolsIO.cpp b/src/editors/LevelEditor/Edit/ESceneWayToolsIO.cpp index 4e296578600..36213b23116 100644 --- a/src/editors/LevelEditor/Edit/ESceneWayToolsIO.cpp +++ b/src/editors/LevelEditor/Edit/ESceneWayToolsIO.cpp @@ -4,74 +4,84 @@ #include "ESceneWayTools.h" // chunks -static const u16 WAY_TOOLS_VERSION = 0x0000; +static const u16 WAY_TOOLS_VERSION = 0x0000; + //---------------------------------------------------- -enum{ - CHUNK_VERSION = 0x1001ul, +enum +{ + CHUNK_VERSION = 0x1001ul, }; + //---------------------------------------------------- -bool ESceneWayTool::LoadLTX(CInifile& ini) +bool ESceneWayTool::LoadLTX(CInifile &ini) { - u32 version = ini.r_u32("main","version"); - if( version!=WAY_TOOLS_VERSION ) + u32 version = ini.r_u32("main", "version"); + if (version!=WAY_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); - return false; + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); + return false; } - inherited::LoadLTX(ini); - return true; + inherited::LoadLTX(ini); + return true; } -void ESceneWayTool::SaveLTX(CInifile& ini, int id) +void ESceneWayTool::SaveLTX(CInifile &ini, int id) { - inherited::SaveLTX (ini, id); + inherited::SaveLTX(ini, id); - ini.w_u32 ("main", "version",WAY_TOOLS_VERSION); + ini.w_u32("main", "version", WAY_TOOLS_VERSION); } -bool ESceneWayTool::LoadStream(IReader& F) +bool ESceneWayTool::LoadStream(IReader &F) { - u16 version = 0; - if(F.r_chunk(CHUNK_VERSION,&version)) - if( version!=WAY_TOOLS_VERSION ) + u16 version = 0; + if (F.r_chunk(CHUNK_VERSION, &version)) + if (version!=WAY_TOOLS_VERSION) { - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - if (!inherited::LoadStream(F)) return false; + if (!inherited::LoadStream(F)) + return false; return true; } + //---------------------------------------------------- -void ESceneWayTool::SaveStream(IWriter& F) +void ESceneWayTool::SaveStream(IWriter &F) { - inherited::SaveStream(F); + inherited::SaveStream(F); - F.w_chunk (CHUNK_VERSION,(u16*)&WAY_TOOLS_VERSION,sizeof(WAY_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&WAY_TOOLS_VERSION, sizeof(WAY_TOOLS_VERSION)); } + //---------------------------------------------------- -bool ESceneWayTool::LoadSelection(IReader& F) +bool ESceneWayTool::LoadSelection(IReader &F) { - u16 version = 0; - R_ASSERT(F.r_chunk(CHUNK_VERSION,&version)); - if( version!=WAY_TOOLS_VERSION ){ - ELog.DlgMsg( mtError, "%s tools: Unsupported version.",ClassDesc()); + u16 version = 0; + R_ASSERT(F.r_chunk(CHUNK_VERSION, &version)); + if (version!=WAY_TOOLS_VERSION) + { + ELog.DlgMsg(mtError, "%s tools: Unsupported version.", ClassDesc()); return false; } - return inherited::LoadSelection(F); + return inherited::LoadSelection(F); } + //---------------------------------------------------- -void ESceneWayTool::SaveSelection(IWriter& F) +void ESceneWayTool::SaveSelection(IWriter &F) { - F.w_chunk (CHUNK_VERSION,(u16*)&WAY_TOOLS_VERSION,sizeof(WAY_TOOLS_VERSION)); + F.w_chunk(CHUNK_VERSION, (u16*)&WAY_TOOLS_VERSION, sizeof(WAY_TOOLS_VERSION)); - inherited::SaveSelection(F); + inherited::SaveSelection(F); } + //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/EShape.cpp b/src/editors/LevelEditor/Edit/EShape.cpp index e8cee73e904..ee434d44c17 100644 --- a/src/editors/LevelEditor/Edit/EShape.cpp +++ b/src/editors/LevelEditor/Edit/EShape.cpp @@ -3,199 +3,236 @@ #pragma hdrstop #include "EShape.h" -#include "../../ecore/editor/D3DUtils.h" +#include "editors/ECore/Editor/D3DUtils.h" #include "du_box.h" #include "Scene.h" -#define SHAPE_COLOR_TRANSP 0x3C808080 -#define SHAPE_COLOR_EDGE 0xFF202020 +#define SHAPE_COLOR_TRANSP 0x3C808080 +#define SHAPE_COLOR_EDGE 0xFF202020 //--------------------------------------------------------------------------- -#define SHAPE_CURRENT_VERSION 0x0002 +#define SHAPE_CURRENT_VERSION 0x0002 //--------------------------------------------------------------------------- -#define SHAPE_CHUNK_VERSION 0x0000 -#define SHAPE_CHUNK_SHAPES 0x0001 -#define SHAPE_CHUNK_DATA 0x0002 +#define SHAPE_CHUNK_VERSION 0x0000 +#define SHAPE_CHUNK_SHAPES 0x0001 +#define SHAPE_CHUNK_DATA 0x0002 //--------------------------------------------------------------------------- -xr_token shape_type_tok[]={ - { "common", eShapeCommon }, - { "level bound", eShapeLevelBound}, - { 0, 0 } +xr_token shape_type_tok[] = { + {"common", eShapeCommon}, + {"level bound", eShapeLevelBound}, + {0, 0} }; -CEditShape::CEditShape(LPVOID data, LPCSTR name):CCustomObject(data,name) +CEditShape::CEditShape(LPVOID data, LPCSTR name): CCustomObject(data, name) { - Construct(data); + Construct(data); } -CEditShape::~CEditShape() -{ -} +CEditShape::~CEditShape() {} void CEditShape::Construct(LPVOID data) { - ClassID = OBJCLASS_SHAPE; - m_DrawTranspColor = SHAPE_COLOR_TRANSP; - m_DrawEdgeColor = SHAPE_COLOR_EDGE; - m_shape_type = eShapeCommon; - m_Box.invalidate(); + ClassID = OBJCLASS_SHAPE; + m_DrawTranspColor = SHAPE_COLOR_TRANSP; + m_DrawEdgeColor = SHAPE_COLOR_EDGE; + m_shape_type = eShapeCommon; + m_Box.invalidate(); } void CEditShape::OnUpdateTransform() { - inherited::OnUpdateTransform(); + inherited::OnUpdateTransform(); } void CEditShape::ComputeBounds() { - m_Box.invalidate (); - - for (ShapeIt it=shapes.begin(); it!=shapes.end(); it++){ - switch (it->type){ - case cfSphere:{ - Fsphere& T = it->data.sphere; - Fvector P; - P.set (T.P); P.sub(T.R); m_Box.modify(P); - P.set (T.P); P.add(T.R); m_Box.modify(P); - }break; - case cfBox:{ - Fvector P; - Fmatrix& T = it->data.box; - - // Build points - Fvector p; - for (int i=0; itype) + { + case cfSphere: + { + Fsphere &T = it->data.sphere; + Fvector P; + P.set(T.P); + P.sub(T.R); + m_Box.modify(P); + P.set(T.P); + P.add(T.R); + m_Box.modify(P); + } + break; + case cfBox: + { + Fvector P; + Fmatrix &T = it->data.box; + + // Build points + Fvector p; + for (int i = 0; itype){ - case cfSphere:{ - Fsphere& T = it->data.sphere; - FTransformS.transform_tiny(T.P); - T.R *= PScale.x; - }break; - case cfBox:{ - Fmatrix& B = it->data.box; - B.mulA_43 (FTransformS); - }break; + for (ShapeIt it = shapes.begin(); it!=shapes.end(); it++) + { + switch (it->type) + { + case cfSphere: + { + Fsphere &T = it->data.sphere; + FTransformS.transform_tiny(T.P); + T.R *= PScale.x; + } + break; + case cfBox: + { + Fmatrix &B = it->data.box; + B.mulA_43(FTransformS); + } + break; } } - FScale.set (1.f,1.f,1.f); - UpdateTransform (true); + FScale.set(1.f, 1.f, 1.f); + UpdateTransform(true); - ComputeBounds (); + ComputeBounds(); } -void CEditShape::add_sphere(const Fsphere& S) +void CEditShape::add_sphere(const Fsphere &S) { - shapes.push_back(shape_def()); - shapes.back().type = cfSphere; - shapes.back().data.sphere.set(S); + shapes.push_back(shape_def()); + shapes.back().type = cfSphere; + shapes.back().data.sphere.set(S); - ComputeBounds(); + ComputeBounds(); } -void CEditShape::add_box(const Fmatrix& B) +void CEditShape::add_box(const Fmatrix &B) { - shapes.push_back(shape_def()); - shapes.back().type = cfBox; - shapes.back().data.box.set(B); + shapes.push_back(shape_def()); + shapes.back().type = cfBox; + shapes.back().data.box.set(B); - ComputeBounds(); + ComputeBounds(); } -void CEditShape::Attach(CEditShape* from) +void CEditShape::Attach(CEditShape *from) { - ApplyScale (); - // transfer data - from->ApplyScale (); - Fmatrix M = from->_Transform(); - M.mulA_43 (_ITransform()); - for (ShapeIt it=from->shapes.begin(); it!=from->shapes.end(); it++){ - switch (it->type){ - case cfSphere:{ - Fsphere& T = it->data.sphere; - M.transform_tiny(T.P); - add_sphere (T); - }break; - case cfBox:{ - Fmatrix B = it->data.box; - B.mulA_43 (M); - add_box (B); - }break; - default: THROW; - } + ApplyScale(); + // transfer data + from->ApplyScale(); + Fmatrix M = from->_Transform(); + M.mulA_43(_ITransform()); + for (ShapeIt it = from->shapes.begin(); it!=from->shapes.end(); it++) + { + switch (it->type) + { + case cfSphere: + { + Fsphere &T = it->data.sphere; + M.transform_tiny(T.P); + add_sphere(T); + } + break; + case cfBox: + { + Fmatrix B = it->data.box; + B.mulA_43(M); + add_box(B); + } + break; + default: THROW; + } } // common - Scene->RemoveObject (from,true,true); - xr_delete (from); + Scene->RemoveObject(from, true, true); + xr_delete(from); - ComputeBounds (); + ComputeBounds(); } void CEditShape::Detach() { - if (shapes.size()>1){ - Select (true); - ApplyScale (); + if (shapes.size()>1) + { + Select(true); + ApplyScale(); // create scene shapes - const Fmatrix& M = _Transform(); - ShapeIt it=shapes.begin(); it++; - for (; it!=shapes.end(); it++){ + const Fmatrix &M = _Transform(); + ShapeIt it = shapes.begin(); + it++; + for (; it!=shapes.end(); it++) + { string256 namebuffer; - Scene->GenObjectName (OBJCLASS_SHAPE, namebuffer, Name); - CEditShape* shape = (CEditShape*)Scene->GetOTool(ClassID)->CreateObject(0, namebuffer); - switch (it->type){ - case cfSphere:{ - Fsphere T = it->data.sphere; - M.transform_tiny(T.P); - shape->PPosition= T.P; - T.P.set (0,0,0); - shape->add_sphere(T); - }break; - case cfBox:{ - Fmatrix B = it->data.box; - B.mulA_43 (M); - shape->PPosition= B.c; - B.c.set (0,0,0); - shape->add_box (B); - }break; - default: THROW; + Scene->GenObjectName(OBJCLASS_SHAPE, namebuffer, Name); + CEditShape *shape = (CEditShape*)Scene->GetOTool(ClassID)->CreateObject(0, namebuffer); + switch (it->type) + { + case cfSphere: + { + Fsphere T = it->data.sphere; + M.transform_tiny(T.P); + shape->PPosition = T.P; + T.P.set(0, 0, 0); + shape->add_sphere(T); + } + break; + case cfBox: + { + Fmatrix B = it->data.box; + B.mulA_43(M); + shape->PPosition = B.c; + B.c.set(0, 0, 0); + shape->add_box(B); + } + break; + default: THROW; } - Scene->AppendObject (shape,false); - shape->Select (true); + Scene->AppendObject(shape, false); + shape->Select(true); } // erase shapes in base object - it=shapes.begin(); it++; - shapes.erase(it,shapes.end()); + it = shapes.begin(); + it++; + shapes.erase(it, shapes.end()); ComputeBounds(); @@ -205,278 +242,303 @@ void CEditShape::Detach() void CEditShape::OnDetach() { - inherited::OnDetach (); + inherited::OnDetach(); - m_DrawTranspColor = SHAPE_COLOR_TRANSP; - m_DrawEdgeColor = SHAPE_COLOR_EDGE; + m_DrawTranspColor = SHAPE_COLOR_TRANSP; + m_DrawEdgeColor = SHAPE_COLOR_EDGE; } -bool CEditShape::RayPick(float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf) +bool CEditShape::RayPick(float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf) { - float dist = distance; - - for (ShapeIt it=shapes.begin(); it!=shapes.end(); it++){ - switch (it->type){ - case cfSphere:{ - Fvector S,D; - Fmatrix M; - M.invert (FTransformR); - M.transform_dir (D,direction); - FITransform.transform_tiny(S,start); - Fsphere& T = it->data.sphere; - float bk_r = T.R; -// T.R = FScale.x; - T.intersect (S,D,dist); - if (dist<=0.f) dist = distance; - - T.R = bk_r; - }break; - case cfBox:{ - Fbox box; - box.identity (); - Fmatrix BI; - BI.invert (it->data.box); - Fvector S,D,S1,D1,P; - FITransform.transform_tiny (S,start); - FITransform.transform_dir (D,direction); - BI.transform_tiny (S1,S); - BI.transform_dir (D1,D); - Fbox::ERP_Result rp_res = box.Pick2(S1,D1,P); - if (rp_res==Fbox::rpOriginOutside){ - it->data.box.transform_tiny (P); - FTransform.transform_tiny (P); - P.sub (start); - dist = P.magnitude(); + float dist = distance; + + for (ShapeIt it = shapes.begin(); it!=shapes.end(); it++) + { + switch (it->type) + { + case cfSphere: + { + Fvector S, D; + Fmatrix M; + M.invert(FTransformR); + M.transform_dir(D, direction); + FITransform.transform_tiny(S, start); + Fsphere &T = it->data.sphere; + float bk_r = T.R; + // T.R = FScale.x; + T.intersect(S, D, dist); + if (dist<=0.f) + dist = distance; + + T.R = bk_r; + } + break; + case cfBox: + { + Fbox box; + box.identity(); + Fmatrix BI; + BI.invert(it->data.box); + Fvector S, D, S1, D1, P; + FITransform.transform_tiny(S, start); + FITransform.transform_dir(D, direction); + BI.transform_tiny(S1, S); + BI.transform_dir(D1, D); + Fbox::ERP_Result rp_res = box.Pick2(S1, D1, P); + if (rp_res==Fbox::rpOriginOutside) + { + it->data.box.transform_tiny(P); + FTransform.transform_tiny(P); + P.sub(start); + dist = P.magnitude(); + } } - }break; - } + break; + } } - if (disttype){ - case cfSphere:{ - Fvector C; - Fsphere& T = it->data.sphere; - M.transform_tiny(C,T.P); - if (frustum.testSphere_dirty(C,T.R*FScale.x)) return true; - }break; - case cfBox:{ - Fbox box; - box.identity (); - Fmatrix B = it->data.box; - B.mulA_43 (_Transform()); - box.xform (B); - u32 mask = 0xff; - if (frustum.testAABB(box.data(),mask)) return true; - }break; - } + const Fmatrix &M = _Transform(); + for (ShapeIt it = shapes.begin(); it!=shapes.end(); it++) + { + switch (it->type) + { + case cfSphere: + { + Fvector C; + Fsphere &T = it->data.sphere; + M.transform_tiny(C, T.P); + if (frustum.testSphere_dirty(C, T.R*FScale.x)) + return true; + } + break; + case cfBox: + { + Fbox box; + box.identity(); + Fmatrix B = it->data.box; + B.mulA_43(_Transform()); + box.xform(B); + u32 mask = 0xff; + if (frustum.testAABB(box.data(), mask)) + return true; + } + break; + } } - return false; + return false; } -bool CEditShape::GetBox(Fbox& box) const +bool CEditShape::GetBox(Fbox &box) const { - if (m_Box.is_valid()){ - box.xform(m_Box,FTransform); - return true; + if (m_Box.is_valid()) + { + box.xform(m_Box, FTransform); + return true; } - return false; + return false; } -bool CEditShape::LoadLTX(CInifile& ini, LPCSTR sect_name) +bool CEditShape::LoadLTX(CInifile &ini, LPCSTR sect_name) { - u32 vers = ini.r_u32(sect_name, "version"); + u32 vers = ini.r_u32(sect_name, "version"); - inherited::LoadLTX (ini, sect_name); + inherited::LoadLTX(ini, sect_name); - u32 count = ini.r_u32 (sect_name, "shapes_count"); - if(vers>0x0001) - m_shape_type = ini.r_u8 (sect_name, "shape_type"); - - string128 buff; - shapes.resize (count); - for(u32 i=0; i0x0001) + m_shape_type = ini.r_u8(sect_name, "shape_type"); + + string128 buff; + shapes.resize(count); + for (u32 i = 0; itype) + switch (it->type) { - case cfSphere: - { - Fsphere& S = it->data.sphere; - Fmatrix B; - B.scale (S.R,S.R,S.R); - B.translate_over (S.P); - B.mulA_43 (_Transform()); - RCache.set_xform_world(B); - EDevice.SetShader (EDevice.m_WireShader); - DU_impl.DrawCross (zero,1.f,m_DrawEdgeColor,false); - DU_impl.DrawIdentSphere (true,true,clr,m_DrawEdgeColor); - }break; - case cfBox: - { - Fmatrix B = it->data.box; - B.mulA_43 (_Transform()); - RCache.set_xform_world(B); - DU_impl.DrawIdentBox(true,true,clr,m_DrawEdgeColor); - }break; + case cfSphere: + { + Fsphere &S = it->data.sphere; + Fmatrix B; + B.scale(S.R, S.R, S.R); + B.translate_over(S.P); + B.mulA_43(_Transform()); + RCache.set_xform_world(B); + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawCross(zero, 1.f, m_DrawEdgeColor, false); + DU_impl.DrawIdentSphere(true, true, clr, m_DrawEdgeColor); + } + break; + case cfBox: + { + Fmatrix B = it->data.box; + B.mulA_43(_Transform()); + RCache.set_xform_world(B); + DU_impl.DrawIdentBox(true, true, clr, m_DrawEdgeColor); + } + break; } } - EDevice.SetRS(D3DRS_CULLMODE,D3DCULL_CCW); - }else{ - if( Selected()&&m_Box.is_valid() ){ - EDevice.SetShader (EDevice.m_SelectionShader); - RCache.set_xform_world (_Transform()); - u32 clr = 0xFFFFFFFF; - EDevice.SetShader (EDevice.m_WireShader); - DU_impl.DrawSelectionBoxB(m_Box,&clr); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CCW); + } + else + { + if (Selected()&&m_Box.is_valid()) + { + EDevice.SetShader(EDevice.m_SelectionShader); + RCache.set_xform_world(_Transform()); + u32 clr = 0xFFFFFFFF; + EDevice.SetShader(EDevice.m_WireShader); + DU_impl.DrawSelectionBoxB(m_Box, &clr); } } } } + #include "FrameShape.h" void CEditShape::OnFrame() { - inherited::OnFrame(); - if(m_shape_type==eShapeLevelBound) + inherited::OnFrame(); + if (m_shape_type==eShapeLevelBound) { - TfraShape* F = (TfraShape*)ParentTool->pFrame; - BOOL bVis = F->ebEditLevelBoundMode->Down; - m_RT_Flags.set(flRT_Visible, bVis); + TfraShape *F = (TfraShape*)ParentTool->pFrame; + BOOL bVis = F->ebEditLevelBoundMode->Down; + m_RT_Flags.set(flRT_Visible, bVis); } } -void CEditShape::OnShowHint(AStringVec& dest) -{ -} +void CEditShape::OnShowHint(AStringVec &dest) {} diff --git a/src/editors/LevelEditor/Edit/ESound_Environment.cpp b/src/editors/LevelEditor/Edit/ESound_Environment.cpp index 8c8eb53d14d..4a91960af19 100644 --- a/src/editors/LevelEditor/Edit/ESound_Environment.cpp +++ b/src/editors/LevelEditor/Edit/ESound_Environment.cpp @@ -4,139 +4,144 @@ #include "ESound_Environment.h" #include "EShape.h" -#include "ui_levelmain.h" +#include "UI_LevelMain.h" //---------------------------------------------------- -#define SOUND_SEL0_COLOR 0x00A0A0A0 -#define SOUND_SEL1_COLOR 0x00FFFFFF -#define SOUND_NORM_COLOR 0x000000FF -#define SOUND_LOCK_COLOR 0x00FF0000 +#define SOUND_SEL0_COLOR 0x00A0A0A0 +#define SOUND_SEL1_COLOR 0x00FFFFFF +#define SOUND_NORM_COLOR 0x000000FF +#define SOUND_LOCK_COLOR 0x00FF0000 //---------------------------------------------------- -#define SOUND_ENV_VERSION 0x0012 +#define SOUND_ENV_VERSION 0x0012 //---------------------------------------------------- -#define SOUND_CHUNK_VERSION 0x1001 -#define SOUND_CHUNK_ENV_SHAPE 0x1002 -#define SOUND_CHUNK_ENV_REFS 0x1003 +#define SOUND_CHUNK_VERSION 0x1001 +#define SOUND_CHUNK_ENV_SHAPE 0x1002 +#define SOUND_CHUNK_ENV_REFS 0x1003 + //---------------------------------------------------- ESoundEnvironment::ESoundEnvironment(LPVOID data, LPCSTR name) - :CEditShape(data,name) + : CEditShape(data, name) { - Construct(data); + Construct(data); } void ESoundEnvironment::Construct(LPVOID data) { - ClassID = OBJCLASS_SOUND_ENV; - - add_box (Fidentity); - SetDrawColor (0x205050FF, 0xFF202020); - m_EnvInner = ""; - m_EnvOuter = ""; -} + ClassID = OBJCLASS_SOUND_ENV; -ESoundEnvironment::~ESoundEnvironment() -{ + add_box(Fidentity); + SetDrawColor(0x205050FF, 0xFF202020); + m_EnvInner = ""; + m_EnvOuter = ""; } + +ESoundEnvironment::~ESoundEnvironment() {} + //---------------------------------------------------- void ESoundEnvironment::OnUpdateTransform() { - inherited::OnUpdateTransform(); - ExecCommand (COMMAND_REFRESH_SOUND_ENV_GEOMETRY); + inherited::OnUpdateTransform(); + ExecCommand(COMMAND_REFRESH_SOUND_ENV_GEOMETRY); } + //---------------------------------------------------- -bool ESoundEnvironment::LoadLTX(CInifile& ini, LPCSTR sect_name) +bool ESoundEnvironment::LoadLTX(CInifile &ini, LPCSTR sect_name) { - u32 version = ini.r_u32(sect_name, "version"); + u32 version = ini.r_u32(sect_name, "version"); - if(version!=SOUND_ENV_VERSION) + if (version!=SOUND_ENV_VERSION) { - ELog.DlgMsg (mtError, "ESoundSource: Unsupported version."); - return false; + ELog.DlgMsg(mtError, "ESoundSource: Unsupported version."); + return false; } - inherited::LoadLTX (ini, sect_name); + inherited::LoadLTX(ini, sect_name); - return true; + return true; } -void ESoundEnvironment::SaveLTX(CInifile& ini, LPCSTR sect_name) +void ESoundEnvironment::SaveLTX(CInifile &ini, LPCSTR sect_name) { - inherited::SaveLTX (ini, sect_name); + inherited::SaveLTX(ini, sect_name); - ini.w_u32 (sect_name, "version", SOUND_ENV_VERSION); + ini.w_u32(sect_name, "version", SOUND_ENV_VERSION); - ini.w_string (sect_name, "env_inner", m_EnvInner.c_str()); - ini.w_string (sect_name, "env_outer", m_EnvOuter.c_str()); + ini.w_string(sect_name, "env_inner", m_EnvInner.c_str()); + ini.w_string(sect_name, "env_outer", m_EnvOuter.c_str()); } -bool ESoundEnvironment::LoadStream(IReader& F) +bool ESoundEnvironment::LoadStream(IReader &F) { - u16 version = 0; + u16 version = 0; - R_ASSERT(F.r_chunk(SOUND_CHUNK_VERSION,&version)); - if(version!=SOUND_ENV_VERSION){ - ELog.DlgMsg( mtError, "ESoundSource: Unsupported version."); + R_ASSERT(F.r_chunk(SOUND_CHUNK_VERSION, &version)); + if (version!=SOUND_ENV_VERSION) + { + ELog.DlgMsg(mtError, "ESoundSource: Unsupported version."); return false; } - inherited::LoadStream (F); + inherited::LoadStream(F); R_ASSERT(F.find_chunk(SOUND_CHUNK_ENV_REFS)); - F.r_stringZ (m_EnvInner); - F.r_stringZ (m_EnvOuter); + F.r_stringZ(m_EnvInner); + F.r_stringZ(m_EnvOuter); return true; } -void ESoundEnvironment::SaveStream(IWriter& F) +void ESoundEnvironment::SaveStream(IWriter &F) { - inherited::SaveStream (F); + inherited::SaveStream(F); - F.open_chunk (SOUND_CHUNK_VERSION); - F.w_u16 (SOUND_ENV_VERSION); - F.close_chunk (); + F.open_chunk(SOUND_CHUNK_VERSION); + F.w_u16(SOUND_ENV_VERSION); + F.close_chunk(); - F.open_chunk (SOUND_CHUNK_ENV_REFS); - F.w_stringZ (m_EnvInner); - F.w_stringZ (m_EnvOuter); - F.close_chunk (); + F.open_chunk(SOUND_CHUNK_ENV_REFS); + F.w_stringZ(m_EnvInner); + F.w_stringZ(m_EnvOuter); + F.close_chunk(); } + //---------------------------------------------------- -void ESoundEnvironment::OnChangeEnvs (PropValue* prop) +void ESoundEnvironment::OnChangeEnvs(PropValue *prop) { - ExecCommand (COMMAND_REFRESH_SOUND_ENV_GEOMETRY); + ExecCommand(COMMAND_REFRESH_SOUND_ENV_GEOMETRY); } + //---------------------------------------------------- -void ESoundEnvironment::FillProp(LPCSTR pref, PropItemVec& values) +void ESoundEnvironment::FillProp(LPCSTR pref, PropItemVec &values) { - inherited::FillProp (pref, values); - PropValue* P; - P=PHelper().CreateChoose (values, PrepareKey(pref,"Environment Inner"), &m_EnvInner, smSoundEnv); - P->OnChangeEvent.bind (this,&ESoundEnvironment::OnChangeEnvs); - P=PHelper().CreateChoose (values, PrepareKey(pref,"Environment Outer"), &m_EnvOuter, smSoundEnv); - P->OnChangeEvent.bind (this,&ESoundEnvironment::OnChangeEnvs); + inherited::FillProp(pref, values); + PropValue *P; + P = PHelper().CreateChoose(values, PrepareKey(pref, "Environment Inner"), &m_EnvInner, smSoundEnv); + P->OnChangeEvent.bind(this, &ESoundEnvironment::OnChangeEnvs); + P = PHelper().CreateChoose(values, PrepareKey(pref, "Environment Outer"), &m_EnvOuter, smSoundEnv); + P->OnChangeEvent.bind(this, &ESoundEnvironment::OnChangeEnvs); } + //---------------------------------------------------- -bool ESoundEnvironment::GetSummaryInfo(SSceneSummary* inf) +bool ESoundEnvironment::GetSummaryInfo(SSceneSummary *inf) { - inherited::GetSummaryInfo (inf); - return true; + inherited::GetSummaryInfo(inf); + return true; } -void ESoundEnvironment::get_box(Fmatrix& m) +void ESoundEnvironment::get_box(Fmatrix &m) { - CShapeData::shape_def shape = get_shape(0); + CShapeData::shape_def shape = get_shape(0); R_ASSERT(shape.type==CShapeData::cfBox); - m.mul (_Transform(),shape.data.box); + m.mul(_Transform(), shape.data.box); } void ESoundEnvironment::OnSceneUpdate() { - inherited::OnSceneUpdate(); - ExecCommand( COMMAND_REFRESH_SOUND_ENV_GEOMETRY ); + inherited::OnSceneUpdate(); + ExecCommand(COMMAND_REFRESH_SOUND_ENV_GEOMETRY); } diff --git a/src/editors/LevelEditor/Edit/ESound_Environment.h b/src/editors/LevelEditor/Edit/ESound_Environment.h index d4d1069b859..d9747efce77 100644 --- a/src/editors/LevelEditor/Edit/ESound_Environment.h +++ b/src/editors/LevelEditor/Edit/ESound_Environment.h @@ -5,35 +5,39 @@ #include "CustomObject.h" #include "EShape.h" + //#include "xrServer_Objects_Alife_All.h" class ESoundEnvironment: public CEditShape { - typedef CCustomObject inherited; + typedef CCustomObject inherited; - friend class CLevelSoundManager; - // Env - shared_str m_EnvInner; - shared_str m_EnvOuter; + friend class CLevelSoundManager; + // Env + shared_str m_EnvInner; + shared_str m_EnvOuter; - void __stdcall OnChangeEnvs (PropValue* prop); + void __stdcall OnChangeEnvs(PropValue *prop); public: - void get_box (Fmatrix& m); + void get_box(Fmatrix &m); public: - ESoundEnvironment(LPVOID data, LPCSTR name); - void Construct (LPVOID data); - ~ESoundEnvironment(); - virtual bool CanAttach () {return true;} - virtual void OnUpdateTransform(); - - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); - - virtual void FillProp (LPCSTR pref, PropItemVec& values); - virtual bool GetSummaryInfo (SSceneSummary* inf); - virtual void OnSceneUpdate (); + ESoundEnvironment(LPVOID data, LPCSTR name); + void Construct(LPVOID data); + ~ESoundEnvironment(); + virtual bool ( + ) + {return true;} + virtual void OnUpdateTransform(); + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); + + virtual void FillProp(LPCSTR pref, PropItemVec &values); + virtual bool GetSummaryInfo(SSceneSummary *inf); + virtual void OnSceneUpdate(); }; #endif + diff --git a/src/editors/LevelEditor/Edit/ESound_Source.cpp b/src/editors/LevelEditor/Edit/ESound_Source.cpp index 76809c9b794..aee2750a3eb 100644 --- a/src/editors/LevelEditor/Edit/ESound_Source.cpp +++ b/src/editors/LevelEditor/Edit/ESound_Source.cpp @@ -3,450 +3,482 @@ #pragma hdrstop #include "ESound_Source.h" -#include "../../xrSound/SoundRender_Source.h" -#include "../../ecore/editor/D3DUtils.h" -#include "../ECore/Editor/ui_main.h" +#include "xrSound/SoundRender_Source.h" +#include "editors/ECore/Editor/D3DUtils.h" +#include "editors/ECore/Editor/ui_main.h" #include "IGame_Persistent.h" //---------------------------------------------------- #define VIS_RADIUS 0.25f -#define SOUND_SEL0_COLOR 0x00A0A0F0 -#define SOUND_SEL1_COLOR 0x00FFFFFF -#define SOUND_NORM_COLOR 0x000000FF -#define SOUND_LOCK_COLOR 0x00FF0000 +#define SOUND_SEL0_COLOR 0x00A0A0F0 +#define SOUND_SEL1_COLOR 0x00FFFFFF +#define SOUND_NORM_COLOR 0x000000FF +#define SOUND_LOCK_COLOR 0x00FF0000 //---------------------------------------------------- -#define SOUND_SOURCE_VERSION 0x0014 +#define SOUND_SOURCE_VERSION 0x0014 //---------------------------------------------------- -#define SOUND_CHUNK_VERSION 0x1001 -#define SOUND_CHUNK_TYPE 0x1002 -#define SOUND_CHUNK_SOURCE_NAME 0x1003 -#define SOUND_CHUNK_SOURCE_PARAMS 0x1004 -#define SOUND_CHUNK_SOURCE_FLAGS 0x1005 -#define SOUND_CHUNK_SOURCE_PARAMS2 0x1006 -#define SOUND_CHUNK_SOURCE_PARAMS3 0x1007 -#define SOUND_CHUNK_GAME_PARAMS 0x1008 +#define SOUND_CHUNK_VERSION 0x1001 +#define SOUND_CHUNK_TYPE 0x1002 +#define SOUND_CHUNK_SOURCE_NAME 0x1003 +#define SOUND_CHUNK_SOURCE_PARAMS 0x1004 +#define SOUND_CHUNK_SOURCE_FLAGS 0x1005 +#define SOUND_CHUNK_SOURCE_PARAMS2 0x1006 +#define SOUND_CHUNK_SOURCE_PARAMS3 0x1007 +#define SOUND_CHUNK_GAME_PARAMS 0x1008 + //---------------------------------------------------- ESoundSource::ESoundSource(LPVOID data, LPCSTR name) - :CCustomObject(data,name) + : CCustomObject(data, name) { - Construct(data); + Construct(data); } void ESoundSource::Construct(LPVOID data) { - ClassID = OBJCLASS_SOUND_SRC; - - m_Type = stStaticSource; - - m_WAVName = ""; - m_Params.volume = 1.f; - m_Params.freq = 1.f; - m_Params.min_distance = 1.f; - m_Params.max_distance = 300.f; - m_Params.max_ai_distance= 300.f; - m_Params.position.set (0,0,0); - - m_Flags.set (flLooped,TRUE); - m_Command = stNothing; - m_RandomPause.set (0.f,0.f); - m_ActiveTime.set (0.f,0.f); - m_PlayTime.set (0.f,0.f); - m_NextTime = 0; - m_StopTime = 0; + ClassID = OBJCLASS_SOUND_SRC; + + m_Type = stStaticSource; + + m_WAVName = ""; + m_Params.volume = 1.f; + m_Params.freq = 1.f; + m_Params.min_distance = 1.f; + m_Params.max_distance = 300.f; + m_Params.max_ai_distance = 300.f; + m_Params.position.set(0, 0, 0); + + m_Flags.set(flLooped, TRUE); + m_Command = stNothing; + m_RandomPause.set(0.f, 0.f); + m_ActiveTime.set(0.f, 0.f); + m_PlayTime.set(0.f, 0.f); + m_NextTime = 0; + m_StopTime = 0; } ESoundSource::~ESoundSource() { - m_Source.destroy (); + m_Source.destroy(); } //---------------------------------------------------- -bool ESoundSource::GetBox( Fbox& box ) const +bool ESoundSource::GetBox(Fbox &box) const { - box.set( m_Params.position, m_Params.position ); - box.min.sub(m_Params.max_distance); - box.max.add(m_Params.max_distance); - return true; + box.set(m_Params.position, m_Params.position); + box.min.sub(m_Params.max_distance); + box.max.add(m_Params.max_distance); + return true; } void ESoundSource::Render(int priority, bool strictB2F) { - if((1==priority)&&(false==strictB2F)){ - RCache.set_xform_world (Fidentity); - EDevice.SetShader (EDevice.m_WireShader); - u32 clr0 = Selected()?SOUND_SEL0_COLOR:SOUND_NORM_COLOR; - u32 clr1 = Selected()?SOUND_SEL1_COLOR:SOUND_NORM_COLOR; - if (Selected()){ - DU_impl.DrawLineSphere (m_Params.position, m_Params.max_distance, clr1, true); - DU_impl.DrawLineSphere (m_Params.position, m_Params.min_distance, clr0, false); - }else{ - DU_impl.DrawSound (m_Params.position,VIS_RADIUS, clr1); + if ((1==priority)&&(false==strictB2F)) + { + RCache.set_xform_world(Fidentity); + EDevice.SetShader(EDevice.m_WireShader); + u32 clr0 = Selected() ? SOUND_SEL0_COLOR : SOUND_NORM_COLOR; + u32 clr1 = Selected() ? SOUND_SEL1_COLOR : SOUND_NORM_COLOR; + if (Selected()) + { + DU_impl.DrawLineSphere(m_Params.position, m_Params.max_distance, clr1, true); + DU_impl.DrawLineSphere(m_Params.position, m_Params.min_distance, clr0, false); + } + else + { + DU_impl.DrawSound(m_Params.position,VIS_RADIUS, clr1); } } } -bool ESoundSource::FrustumPick(const CFrustum& frustum) +bool ESoundSource::FrustumPick(const CFrustum &frustum) { - return (frustum.testSphere_dirty(m_Params.position,VIS_RADIUS))?true:false; + return (frustum.testSphere_dirty(m_Params.position,VIS_RADIUS)) ? true : false; } -bool ESoundSource::RayPick(float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf) +bool ESoundSource::RayPick(float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf) { - Fvector ray2; - ray2.sub( m_Params.position, start ); - - float d = ray2.dotproduct(direction); - if( d > 0 ){ - float d2 = ray2.magnitude(); - if( ((d2*d2-d*d) < (VIS_RADIUS*VIS_RADIUS)) && (d>VIS_RADIUS)){ - if (d0) + { + float d2 = ray2.magnitude(); + if (((d2*d2-d*d)<(VIS_RADIUS*VIS_RADIUS))&&(d>VIS_RADIUS)) + { + if (dbtn_num){ - case 0: Play(); break; - case 1: Stop(); break; -//. case 2: Simulate(); break; - } + switch (V->btn_num) + { + case 0: Play(); + break; + case 1: Stop(); + break; + //. case 2: Simulate(); break; + } UI->RedrawScene(); bModif = false; } -void ESoundSource::FillProp(LPCSTR pref, PropItemVec& values) +void ESoundSource::FillProp(LPCSTR pref, PropItemVec &values) { - inherited::FillProp (pref,values); - ButtonValue* B; - B=PHelper().CreateButton (values, PrepareKey(pref,"Custom\\Controls"), "Play,Stop,Simulate",0); - B->OnBtnClickEvent.bind (this,&ESoundSource::OnControlClick); - PropValue* V; - V=PHelper().CreateChoose (values,PrepareKey(pref,"Source\\WAVE name"), &m_WAVName, smSoundSource); - V->OnChangeEvent.bind (this,&ESoundSource::OnChangeWAV); - V=PHelper().CreateFloat (values,PrepareKey(pref,"Source\\Frequency"), &m_Params.freq, 0.0f,2.f); - V->OnChangeEvent.bind (this,&ESoundSource::OnChangeSource); - V=PHelper().CreateFloat (values,PrepareKey(pref,"Source\\Volume"), &m_Params.volume, 0.0f,1.f); - V->OnChangeEvent.bind (this,&ESoundSource::OnChangeSource); - V=PHelper().CreateFloat (values,PrepareKey(pref,"Source\\Min dist"), &m_Params.min_distance, 0.1f, 1000.f, 0.1f, 1); - V->Owner()->Enable (FALSE); - V=PHelper().CreateFloat (values,PrepareKey(pref,"Source\\Max dist"), &m_Params.max_distance, 0.1f, 1000.f, 0.1f, 1); - V->Owner()->Enable (FALSE); - V=PHelper().CreateFloat (values,PrepareKey(pref,"Source\\Max ai dist"), &m_Params.max_ai_distance, 0.1f, 1000.f, 0.1f, 1); - V->Owner()->Enable (FALSE); - PHelper().CreateCaption (values,PrepareKey(pref,"Game\\Active time\\Hint"), "Zero - play sound looped round the clock."); - PHelper().CreateTime (values,PrepareKey(pref,"Game\\Active time\\From"), &m_ActiveTime.x); - PHelper().CreateTime (values,PrepareKey(pref,"Game\\Active time\\To"), &m_ActiveTime.y); - PHelper().CreateCaption (values,PrepareKey(pref,"Game\\Play time\\Hint"), "Zero - play sound once."); - PHelper().CreateTime (values,PrepareKey(pref,"Game\\Play time\\From"), &m_PlayTime.x); - PHelper().CreateTime (values,PrepareKey(pref,"Game\\Play time\\To"), &m_PlayTime.y); - PHelper().CreateCaption (values,PrepareKey(pref,"Game\\Pause delta\\Hint"), "Zero - play sound looped."); - PHelper().CreateTime (values,PrepareKey(pref,"Game\\Pause delta\\From"), &m_RandomPause.x); - PHelper().CreateTime (values,PrepareKey(pref,"Game\\Pause delta\\To"), &m_RandomPause.y); -// V=PHelper().CreateFlag32 (values,PHelper().PrepareKey(pref,"Looped"), &m_Flags, flLooped); -// V->OnChangeEvent = OnChangeSource; + inherited::FillProp(pref, values); + ButtonValue *B; + B = PHelper().CreateButton(values, PrepareKey(pref, "Custom\\Controls"), "Play,Stop,Simulate", 0); + B->OnBtnClickEvent.bind(this, &ESoundSource::OnControlClick); + PropValue *V; + V = PHelper().CreateChoose(values, PrepareKey(pref, "Source\\WAVE name"), &m_WAVName, smSoundSource); + V->OnChangeEvent.bind(this, &ESoundSource::OnChangeWAV); + V = PHelper().CreateFloat(values, PrepareKey(pref, "Source\\Frequency"), &m_Params.freq, 0.0f, 2.f); + V->OnChangeEvent.bind(this, &ESoundSource::OnChangeSource); + V = PHelper().CreateFloat(values, PrepareKey(pref, "Source\\Volume"), &m_Params.volume, 0.0f, 1.f); + V->OnChangeEvent.bind(this, &ESoundSource::OnChangeSource); + V = PHelper().CreateFloat(values, PrepareKey(pref, "Source\\Min dist"), &m_Params.min_distance, 0.1f, 1000.f, 0.1f, 1); + V->Owner()->Enable(FALSE); + V = PHelper().CreateFloat(values, PrepareKey(pref, "Source\\Max dist"), &m_Params.max_distance, 0.1f, 1000.f, 0.1f, 1); + V->Owner()->Enable(FALSE); + V = PHelper().CreateFloat(values, PrepareKey(pref, "Source\\Max ai dist"), &m_Params.max_ai_distance, 0.1f, 1000.f, 0.1f, 1); + V->Owner()->Enable(FALSE); + PHelper().CreateCaption(values, PrepareKey(pref, "Game\\Active time\\Hint"), "Zero - play sound looped round the clock."); + PHelper().CreateTime(values, PrepareKey(pref, "Game\\Active time\\From"), &m_ActiveTime.x); + PHelper().CreateTime(values, PrepareKey(pref, "Game\\Active time\\To"), &m_ActiveTime.y); + PHelper().CreateCaption(values, PrepareKey(pref, "Game\\Play time\\Hint"), "Zero - play sound once."); + PHelper().CreateTime(values, PrepareKey(pref, "Game\\Play time\\From"), &m_PlayTime.x); + PHelper().CreateTime(values, PrepareKey(pref, "Game\\Play time\\To"), &m_PlayTime.y); + PHelper().CreateCaption(values, PrepareKey(pref, "Game\\Pause delta\\Hint"), "Zero - play sound looped."); + PHelper().CreateTime(values, PrepareKey(pref, "Game\\Pause delta\\From"), &m_RandomPause.x); + PHelper().CreateTime(values, PrepareKey(pref, "Game\\Pause delta\\To"), &m_RandomPause.y); + // V=PHelper().CreateFlag32 (values,PHelper().PrepareKey(pref,"Looped"), &m_Flags, flLooped); + // V->OnChangeEvent = OnChangeSource; } + //---------------------------------------------------- -bool ESoundSource::GetSummaryInfo(SSceneSummary* inf) +bool ESoundSource::GetSummaryInfo(SSceneSummary *inf) { - inherited::GetSummaryInfo (inf); - if (m_WAVName.size()) inf->waves.insert(*m_WAVName); + inherited::GetSummaryInfo(inf); + if (m_WAVName.size()) + inf->waves.insert(*m_WAVName); inf->sound_source_cnt++; - return true; + return true; } void ESoundSource::OnFrame() { - inherited::OnFrame(); - switch (m_Command){ - case stPlay: - m_Source.play (0,m_Flags.is(flLooped)); - m_Source.set_params (&m_Params); - m_Command = stNothing; - m_Flags.set (flPlaying,TRUE); - break; - case stStop: - m_Source.stop (); - m_Command = stNothing; - m_Flags.set (flPlaying,FALSE); - m_Flags.set (flSimulating,FALSE); - break; - case stSimulate: + inherited::OnFrame(); + switch (m_Command) { -/* - m_Flags.set (flSimulating,TRUE); - if ((fis_zero(m_ActiveTime.x)&&fis_zero(m_ActiveTime.y))|| - ((g_pGamePersistent->Environment().GetGameTime()>m_ActiveTime.x)&&(g_pGamePersistent->Environment().GetGameTime()=m_NextTime) - { - bool bFullPlay = fis_zero(m_PlayTime.x)&&fis_zero(m_PlayTime.y); - m_Source.play (0,bFullPlay?0:sm_Looped); - m_Source.set_params (&m_Params); - if (bFullPlay) + case stPlay: + m_Source.play(0, m_Flags.is(flLooped)); + m_Source.set_params(&m_Params); + m_Command = stNothing; + m_Flags.set(flPlaying, TRUE); + break; + case stStop: + m_Source.stop(); + m_Command = stNothing; + m_Flags.set(flPlaying, FALSE); + m_Flags.set(flSimulating, FALSE); + break; + case stSimulate: + { + /* + m_Flags.set (flSimulating,TRUE); + if ((fis_zero(m_ActiveTime.x)&&fis_zero(m_ActiveTime.y))|| + ((g_pGamePersistent->Environment().GetGameTime()>m_ActiveTime.x)&&(g_pGamePersistent->Environment().GetGameTime()=m_NextTime) + { + bool bFullPlay = fis_zero(m_PlayTime.x)&&fis_zero(m_PlayTime.y); + m_Source.play (0,bFullPlay?0:sm_Looped); + m_Source.set_params (&m_Params); + if (bFullPlay) + { + m_StopTime = 0xFFFFFFFF; + m_NextTime = EDevice.dwTimeGlobal+iFloor(m_Source.get_length_sec()/1000.0f)+Random.randF(m_RandomPause.x,m_RandomPause.y)*1000; + }else{ + m_StopTime = bFullPlay?0:EDevice.dwTimeGlobal+Random.randF(m_PlayTime.x,m_PlayTime.y)*1000; + m_NextTime = m_StopTime+Random.randF(m_RandomPause.x,m_RandomPause.y)*1000; + } + } + } }else{ - m_StopTime = bFullPlay?0:EDevice.dwTimeGlobal+Random.randF(m_PlayTime.x,m_PlayTime.y)*1000; - m_NextTime = m_StopTime+Random.randF(m_RandomPause.x,m_RandomPause.y)*1000; + if (EDevice.dwTimeGlobal>=m_StopTime) + m_Source.stop_deffered(); } + + }else{ + if (0!=m_Source._feedback()) + m_Source.stop_deffered(); } - } - }else{ - if (EDevice.dwTimeGlobal>=m_StopTime) - m_Source.stop_deffered(); - } - - }else{ - if (0!=m_Source._feedback()) - m_Source.stop_deffered(); + */ } -*/ - }break; - case stNothing: break; - default: THROW; + break; + case stNothing: break; + default: THROW; } } void ESoundSource::ResetSource() { - m_Source.destroy(); - if (m_WAVName.size()){ - m_Source.create (*m_WAVName,st_Effect,sg_Undefined); - CSoundRender_Source* src= (CSoundRender_Source*)m_Source._handle(); - m_Params.min_distance = src->m_fMinDist; - m_Params.max_distance = src->m_fMaxDist; - m_Params.max_ai_distance= src->m_fMaxAIDist; - ExecCommand (COMMAND_UPDATE_PROPERTIES); + m_Source.destroy(); + if (m_WAVName.size()) + { + m_Source.create(*m_WAVName, st_Effect, sg_Undefined); + CSoundRender_Source *src = (CSoundRender_Source*)m_Source._handle(); + m_Params.min_distance = src->m_fMinDist; + m_Params.max_distance = src->m_fMaxDist; + m_Params.max_ai_distance = src->m_fMaxAIDist; + ExecCommand(COMMAND_UPDATE_PROPERTIES); } - m_Source.set_params(&m_Params); + m_Source.set_params(&m_Params); } void ESoundSource::SetSourceWAV(LPCSTR fname) { - m_WAVName = fname; - ResetSource (); + m_WAVName = fname; + ResetSource(); } -bool ESoundSource::ExportGame(SExportStreams* F) +bool ESoundSource::ExportGame(SExportStreams *F) { - SExportStreamItem& I = F->sound_static; - I.stream.open_chunk (I.chunk++); - I.stream.open_chunk (0); - I.stream.w_stringZ (m_WAVName); - I.stream.w_fvector3 (m_Params.position); - I.stream.w_float (m_Params.volume); - I.stream.w_float (m_Params.freq); - I.stream.w_u32 (m_ActiveTime.x*1000); - I.stream.w_u32 (m_ActiveTime.y*1000); - I.stream.w_u32 (m_PlayTime.x*1000); - I.stream.w_u32 (m_PlayTime.y*1000); - I.stream.w_u32 (m_RandomPause.x*1000); - I.stream.w_u32 (m_RandomPause.y*1000); - I.stream.close_chunk (); - I.stream.close_chunk (); + SExportStreamItem &I = F->sound_static; + I.stream.open_chunk(I.chunk++); + I.stream.open_chunk(0); + I.stream.w_stringZ(m_WAVName); + I.stream.w_fvector3(m_Params.position); + I.stream.w_float(m_Params.volume); + I.stream.w_float(m_Params.freq); + I.stream.w_u32(m_ActiveTime.x*1000); + I.stream.w_u32(m_ActiveTime.y*1000); + I.stream.w_u32(m_PlayTime.x*1000); + I.stream.w_u32(m_PlayTime.y*1000); + I.stream.w_u32(m_RandomPause.x*1000); + I.stream.w_u32(m_RandomPause.y*1000); + I.stream.close_chunk(); + I.stream.close_chunk(); return true; } diff --git a/src/editors/LevelEditor/Edit/EditObjectExportLWO.cpp b/src/editors/LevelEditor/Edit/EditObjectExportLWO.cpp index 1cc853e9f2f..c0cd188a728 100644 --- a/src/editors/LevelEditor/Edit/EditObjectExportLWO.cpp +++ b/src/editors/LevelEditor/Edit/EditObjectExportLWO.cpp @@ -1,92 +1,107 @@ #include "stdafx.h" #pragma hdrstop -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditMesh.h" #include "FS2.h" -int FindLPCSTR(LPCSTRVec& vec, LPCSTR key){ - for (LPCSTRIt it=vec.begin(); it!=vec.end(); it++) - if (0==strcmp(*it,key)) return it-vec.begin(); - return -1; +int FindLPCSTR(LPCSTRVec &vec, LPCSTR key) +{ + for (LPCSTRIt it = vec.begin(); it!=vec.end(); it++) + if (0==strcmp(*it, key)) + return it-vec.begin(); + return -1; } bool CEditableObject::ExportLWO(LPCSTR fname) { - CLWMemoryStream* F = xr_new(); + CLWMemoryStream*F = xr_new(); - LPCSTRVec images; + LPCSTRVec images; - F->begin_save(); - // tags - F->open_chunk(ID_TAGS); - for (SurfaceIt s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ - CSurface* S=*s_it; - F->w_stringZ(S->_Name()); - S->tag = s_it-m_Surfaces.begin(); - if (FindLPCSTR(images,S->_Texture())<0) images.push_back(S->_Texture()); - } - F->close_chunk(); - // images - for (LPCSTRIt im_it=images.begin(); im_it!=images.end(); im_it++){ - F->open_chunk(ID_CLIP); - F->w_u32(im_it-images.begin()); - F->open_subchunk(ID_STIL); - F->w_stringZ(*im_it); - F->close_subchunk(); - F->close_chunk (); - } - // surfaces - for (s_it=m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++){ - CSurface* S=*s_it; - int im_idx=FindLPCSTR(images,S->_Texture()); - R_ASSERT(im_idx>=0); - LPCSTR vm_name=S->_VMap(); - F->Wsurface(S->_Name(),S->m_Flags.is(CSurface::sf2Sided),(u16)im_idx,(vm_name&&vm_name[0])?vm_name:"Texture",S->_ShaderName(),S->_ShaderXRLCName()); - } - // meshes/layers - for (EditMeshIt mesh_it=FirstMesh(); mesh_it!=LastMesh(); mesh_it++){ - CEditableMesh* MESH=*mesh_it; - F->w_layer(u16(mesh_it-FirstMesh()),MESH->Name().c_str()); - // bounding box - F->open_chunk(ID_BBOX); - F->w_vector(MESH->m_Box.min); - F->w_vector(MESH->m_Box.max); - F->close_chunk(); - // points - F->open_chunk(ID_PNTS); - for (u32 point_id=0; point_idGetVCount(); point_id++) - F->w_vector(MESH->GetVertices()[point_id]); - F->close_chunk(); - // polygons - F->open_chunk(ID_POLS); - F->w_u32(ID_FACE); - for (u32 f_id=0; f_idGetFCount(); f_id++) - F->w_face3(MESH->GetFaces()[f_id].pv[0].pindex,MESH->GetFaces()[f_id].pv[1].pindex,MESH->GetFaces()[f_id].pv[2].pindex); - F->close_chunk(); - // surf<->face - F->open_chunk(ID_PTAG); - F->w_u32(ID_SURF); - for (SurfFacesPairIt sf_it=MESH->m_SurfFaces.begin(); sf_it!=MESH->m_SurfFaces.end(); sf_it++){ - IntVec& lst = sf_it->second; - for (IntIt i_it=lst.begin(); i_it!=lst.end(); i_it++){ - F->w_vx (*i_it); - F->w_u16(WORD(sf_it->first->tag)); - } - } - F->close_chunk(); - // vmap&vmad - for (VMapIt vm_it=MESH->m_VMaps.begin(); vm_it!=MESH->m_VMaps.end(); vm_it++){ - st_VMap* vmap = *vm_it; - F->begin_vmap(vmap->polymap, (vmap->type==vmtUV)?ID_TXUV:ID_WGHT, vmap->dim, vmap->name.c_str()); - if (vmap->polymap) for (int k=0; ksize(); k++) F->w_vmad(vmap->vindices[k],vmap->pindices[k],vmap->dim,vmap->getVMdata(k)); - else for (int k=0; ksize(); k++) F->w_vmap(vmap->vindices[k],vmap->dim,vmap->getVMdata(k)); - F->end_vmap(); - } - } - F->end_save(fname); + F->begin_save(); + // tags + F->open_chunk(ID_TAGS); + for (SurfaceIt s_it = m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) + { + CSurface *S = *s_it; + F->w_stringZ(S->_Name()); + S->tag = s_it-m_Surfaces.begin(); + if (FindLPCSTR(images, S->_Texture())<0) + images.push_back(S->_Texture()); + } + F->close_chunk(); + // images + for (LPCSTRIt im_it = images.begin(); im_it!=images.end(); im_it++) + { + F->open_chunk(ID_CLIP); + F->w_u32(im_it-images.begin()); + F->open_subchunk(ID_STIL); + F->w_stringZ(*im_it); + F->close_subchunk(); + F->close_chunk(); + } + // surfaces + for (s_it = m_Surfaces.begin(); s_it!=m_Surfaces.end(); s_it++) + { + CSurface *S = *s_it; + int im_idx = FindLPCSTR(images, S->_Texture()); + R_ASSERT(im_idx>=0); + LPCSTR vm_name = S->_VMap(); + F->Wsurface(S->_Name(), S->m_Flags.is(CSurface::sf2Sided), (u16)im_idx, (vm_name&&vm_name[0]) ? vm_name : "Texture", S->_ShaderName(), S->_ShaderXRLCName()); + } + // meshes/layers + for (EditMeshIt mesh_it = FirstMesh(); mesh_it!=LastMesh(); mesh_it++) + { + CEditableMesh *MESH = *mesh_it; + F->w_layer(u16(mesh_it-FirstMesh()), MESH->Name().c_str()); + // bounding box + F->open_chunk(ID_BBOX); + F->w_vector(MESH->m_Box.min); + F->w_vector(MESH->m_Box.max); + F->close_chunk(); + // points + F->open_chunk(ID_PNTS); + for (u32 point_id = 0; point_idGetVCount(); point_id++) + F->w_vector(MESH->GetVertices()[point_id]); + F->close_chunk(); + // polygons + F->open_chunk(ID_POLS); + F->w_u32(ID_FACE); + for (u32 f_id = 0; f_idGetFCount(); f_id++) + F->w_face3(MESH->GetFaces()[f_id].pv[0].pindex, MESH->GetFaces()[f_id].pv[1].pindex, MESH->GetFaces()[f_id].pv[2].pindex); + F->close_chunk(); + // surf<->face + F->open_chunk(ID_PTAG); + F->w_u32(ID_SURF); + for (SurfFacesPairIt sf_it = MESH->m_SurfFaces.begin(); sf_it!=MESH->m_SurfFaces.end(); sf_it++) + { + IntVec &lst = sf_it->second; + for (IntIt i_it = lst.begin(); i_it!=lst.end(); i_it++) + { + F->w_vx(*i_it); + F->w_u16(WORD(sf_it->first->tag)); + } + } + F->close_chunk(); + // vmap&vmad + for (VMapIt vm_it = MESH->m_VMaps.begin(); vm_it!=MESH->m_VMaps.end(); vm_it++) + { + st_VMap *vmap = *vm_it; + F->begin_vmap(vmap->polymap, (vmap->type==vmtUV) ? ID_TXUV : ID_WGHT, vmap->dim, vmap->name.c_str()); + if (vmap->polymap) + for (int k = 0; ksize(); k++) + F->w_vmad(vmap->vindices[k], vmap->pindices[k], vmap->dim, vmap->getVMdata(k)); + else + for (int k = 0; ksize(); k++) + F->w_vmap(vmap->vindices[k], vmap->dim, vmap->getVMdata(k)); + F->end_vmap(); + } + } + F->end_save(fname); - xr_delete(F); + xr_delete(F); - return true; + return true; } + diff --git a/src/editors/LevelEditor/Edit/FS2.cpp b/src/editors/LevelEditor/Edit/FS2.cpp index 0302b198089..9a2cf74cd83 100644 --- a/src/editors/LevelEditor/Edit/FS2.cpp +++ b/src/editors/LevelEditor/Edit/FS2.cpp @@ -6,18 +6,23 @@ // memory CMemoryStream::~CMemoryStream() { - xr_free(data); + xr_free(data); } -void CMemoryStream::write(const void* ptr, u32 count) +void CMemoryStream::write(const void *ptr, u32 count) { - if (position+count > mem_size) { - // reallocate - if (mem_size==0) mem_size=128; - while (mem_size <= (position+count)) mem_size*=2; - data = (u8*)xr_realloc(data,mem_size); - } - CopyMemory(data+position,ptr,count); - position+=count; - if (position>file_size) file_size=position; + if (position+count>mem_size) + { + // reallocate + if (mem_size==0) + mem_size = 128; + while (mem_size<=(position+count)) + mem_size *= 2; + data = (u8*)xr_realloc(data, mem_size); + } + CopyMemory(data+position, ptr, count); + position += count; + if (position>file_size) + file_size = position; } + diff --git a/src/editors/LevelEditor/Edit/FS2.h b/src/editors/LevelEditor/Edit/FS2.h index e8d328ba356..0e4abbf6357 100644 --- a/src/editors/LevelEditor/Edit/FS2.h +++ b/src/editors/LevelEditor/Edit/FS2.h @@ -3,279 +3,288 @@ #pragma once -class ENGINE_API IBasicStream { -private: - std::stack chunk_pos; - std::stack subchunk_pos; - void revbytes ( void *bp, int elsize, int elcount ) - { - register unsigned char *p, *q; +class ENGINE_API IBasicStream +{ + private: + std::stack chunk_pos; + std::stack subchunk_pos; + void revbytes(void *bp, int elsize, int elcount) + { + register unsigned char *p, *q; - p = ( unsigned char * ) bp; + p = (unsigned char *) bp; - if ( elsize == 2 ) { - q = p + 1; - while ( elcount-- ) { - *p ^= *q; - *q ^= *p; - *p ^= *q; - p += 2; - q += 2; - } - return; - } + if (elsize==2){ + q = p+1; + while (elcount--){ + *p ^= *q; + *q ^= *p; + *p ^= *q; + p += 2; + q += 2; + } + return; + } - while ( elcount-- ) { - q = p + elsize - 1; - while ( p < q ) { - *p ^= *q; - *q ^= *p; - *p ^= *q; - ++p; - --q; - } - p += elsize >> 1; - } - } -public: - virtual ~IBasicStream () - { - R_ASSERT(subchunk_pos.empty()); - while (!chunk_pos.empty()) - close_chunk(); - } + while (elcount--){ + q = p+elsize-1; + while (p>1; + } + } + public: + virtual ~IBasicStream() + { + R_ASSERT(subchunk_pos.empty()); + while (!chunk_pos.empty()) + close_chunk(); + } - // kernel - virtual void write (const void* ptr, u32 count) = 0; - virtual void seek (u32 pos) = 0; - virtual u32 tell () = 0; + // kernel + virtual void write(const void* ptr, u32 count) = 0; + virtual void seek(u32 pos) = 0; + virtual u32 tell() = 0; - // generalized writing functions - IC void w_u32 (u32 d) { revbytes(&d,4,1); write(&d,sizeof(u32)); } - IC void w_u16 (u16 d) { revbytes(&d,2,1); write(&d,sizeof(u16)); } - IC void w_float (float d) { revbytes(&d,4,1); write(&d,sizeof(float)); } - IC void w_u8 (u8 d) { write(&d,sizeof(u8)); } - IC void w_string(const char *p) - { - write(p,xr_strlen(p)); - w_u8(13); - w_u8(10); + // generalized writing functions + IC void w_u32(u32 d){revbytes(&d, 4, 1); write(&d, sizeof(u32));} + IC void w_u16(u16 d){revbytes(&d, 2, 1); write(&d, sizeof(u16));} + IC void w_float(float d){revbytes(&d, 4, 1); write(&d, sizeof(float));} + IC void w_u8(u8 d){write(&d, sizeof(u8));} + IC void w_string(const char *p) + { + write(p, xr_strlen(p)); + w_u8(13); + w_u8(10); } - IC void w_stringZ(const char *p) { write(p,xr_strlen(p)+1); if (!(xr_strlen(p)&1)) w_u8(0);} - IC void w_vector(Fvector v) { revbytes(&v,4,3); write(&v,3*sizeof(float)); } - IC void w_color (Fcolor c) { revbytes(&c,4,4); write(&c,4*sizeof(float)); } + IC void w_stringZ(const char *p){write(p, xr_strlen(p)+1);if (!(xr_strlen(p)&1)) w_u8(0);} + IC void w_vector(Fvector v){revbytes(&v, 4, 3); write(&v, 3*sizeof(float));} + IC void w_color(Fcolor c){revbytes(&c, 4, 4); write(&c, 4*sizeof(float));} - // generalized chunking - IC void open_chunk (u32 type) - { - w_u32(type); - chunk_pos.push(tell()); - w_u32(0); // the place for 'size' - } - IC void close_chunk () - { - VERIFY(!chunk_pos.empty()); + // generalized chunking + IC void open_chunk(u32 type) + { + w_u32(type); + chunk_pos.push(tell()); + w_u32(0); // the place for 'size' + } + IC void close_chunk() + { + VERIFY(!chunk_pos.empty()); - int pos = tell(); - seek (chunk_pos.top()); - w_u32 (pos-chunk_pos.top()-4); - seek (pos); - chunk_pos.pop(); - } - // generalized chunking - IC void open_subchunk (u32 type) - { - w_u32(type); - subchunk_pos.push((u16)tell()); - w_u16(0); // the place for 'size' - } - IC void close_subchunk () - { - VERIFY(!subchunk_pos.empty()); + int pos = tell(); + seek(chunk_pos.top()); + w_u32(pos-chunk_pos.top()-4); + seek(pos); + chunk_pos.pop(); + } + // generalized chunking + IC void open_subchunk(u32 type) + { + w_u32(type); + subchunk_pos.push((u16)tell()); + w_u16(0); // the place for 'size' + } + IC void close_subchunk() + { + VERIFY(!subchunk_pos.empty()); - int pos = tell(); - seek (subchunk_pos.top()); - w_u16 (u16(pos-subchunk_pos.top()-2)); - seek (pos); - subchunk_pos.pop(); - } - IC void write_chunk (u32 type, void* data, u32 size) - { - open_chunk (type); - write (data,size); - close_chunk (); - } + int pos = tell(); + seek(subchunk_pos.top()); + w_u16(u16(pos-subchunk_pos.top()-2)); + seek(pos); + subchunk_pos.pop(); + } + IC void write_chunk(u32 type, void* data, u32 size) + { + open_chunk(type); + write(data, size); + close_chunk(); + } }; -class ENGINE_API CMemoryStream : public IBasicStream +class ENGINE_API CMemoryStream : + +public +IBasicStream { - u8* data; - u32 position; - u32 mem_size; - u32 file_size; -public: - CMemoryStream() { - data = 0; - position = 0; - mem_size = 0; - file_size = 0; - } - virtual ~CMemoryStream(); + u8* data; + u32 position; + u32 mem_size; + u32 file_size; + public: + CMemoryStream() { + data = 0; + position = 0; + mem_size = 0; + file_size = 0; +} +virtual ~CMemoryStream(); - // kernel - virtual void write (const void* ptr, u32 count); +// kernel +virtual void write (const void* ptr, u32 count); - virtual void seek (u32 pos) - { position = pos; } - virtual u32 tell () - { return position; } +virtual void seek (u32 pos) +{ position = pos; } +virtual u32 tell () +{ return position; } - // specific - u8* pointer () { return data; } - u32 size () { return file_size; } - void clear () { file_size=0; position=0; } - void SaveTo (const char* fn) - { - #ifdef M_BORLAND +// specific +u8* pointer () { return data; } +u32 size () { return file_size; } +void clear () { file_size=0; position=0; } +void SaveTo (const char* fn) +{ +#ifdef M_BORLAND int H = open(fn,O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,S_IREAD|S_IWRITE); - #else - int H = _open(fn,O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,S_IREAD|S_IWRITE); - #endif - R_ASSERT(H>0); - _write(H,pointer(),size()); - _close(H); - } +#else + int H = _open(fn,O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,S_IREAD|S_IWRITE); +#endif + R_ASSERT(H>0); + _write(H,pointer(),size()); + _close(H); +} }; #include "lwchunks.h" -class ENGINE_API CLWMemoryStream: public CMemoryStream{ - IC void make_ord( int nbloks, int index, unsigned char *ord ) - { - int i, d; +class ENGINE_API CLWMemoryStream: - for ( i = 8, d = 16; i < 128; i *= 2 ){ - if ( i >= nbloks ) break; - d /= 2; - } - ord[ 0 ] = u8(128 + index * d); - ord[ 1 ] = 0; - } +public +CMemoryStream +{ + IC void make_ord( int nbloks, int index, unsigned char *ord ) + { + int i, d; + + for ( i = 8, d = 16; i < 128; i *= 2 ){ + if ( i >= nbloks ) break; + d /= 2; +} +ord[ 0 ] = u8(128 + index * d); +ord[ 1 ] = 0; +} public: - IC void begin_save () { open_chunk(ID_FORM); w_u32(ID_LWO2);} - IC void end_save (LPCSTR name) { close_chunk(); SaveTo(name);} - IC void w_layer (u16 number, LPCSTR name){ - open_chunk(ID_LAYR); - w_u16 (number); // num - w_u16 (0); - w_float (0); // pivot - w_float (0); - w_float (0); - w_stringZ(name); - close_chunk(); - } - IC void w_vx (int idx) - { - if (idx>=0xFF00){ - idx|=0xff000000; - w_u32(idx); - }else - w_u16((u16)idx); - } +IC void begin_save () { open_chunk(ID_FORM); w_u32(ID_LWO2);} +IC void end_save (LPCSTR name) { close_chunk(); SaveTo(name);} +IC void w_layer (u16 number, LPCSTR name){ + open_chunk(ID_LAYR); + w_u16 (number); // num + w_u16 (0); + w_float (0); // pivot + w_float (0); + w_float (0); + w_stringZ(name); + close_chunk(); +} +IC void w_vx (int idx) +{ + if (idx>=0xFF00){ + idx|=0xff000000; + w_u32(idx); +}else +w_u16((u16)idx); +} - IC void w_face3 (int i0, int i1, int i2) - { w_u16(3); w_vx(i0); w_vx(i1); w_vx(i2); } +IC void w_face3 (int i0, int i1, int i2) +{ w_u16(3); w_vx(i0); w_vx(i1); w_vx(i2); } - IC void begin_vmap (BOOL polymap, u32 type, int dim, LPCSTR name){ - open_chunk(polymap?ID_VMAD:ID_VMAP); - w_u32 (type); - w_u16 ((u16)dim); - R_ASSERT2(name&&name[0],"Empty vmap name!"); - w_stringZ(name); - } - IC void end_vmap () - { close_chunk();} +IC void begin_vmap (BOOL polymap, u32 type, int dim, LPCSTR name){ + open_chunk(polymap?ID_VMAD:ID_VMAP); + w_u32 (type); + w_u16 ((u16)dim); + R_ASSERT2(name&&name[0],"Empty vmap name!"); + w_stringZ(name); +} +IC void end_vmap () +{ close_chunk();} - IC void w_vmap (int v_index, int dim, float* uv) - { w_vx(v_index); w_float(uv[0]); if (dim==2) w_float(1.f-uv[1]); } +IC void w_vmap (int v_index, int dim, float* uv) +{ w_vx(v_index); w_float(uv[0]); if (dim==2) w_float(1.f-uv[1]); } - IC void w_vmad (int v_index, int f_index, int dim, float* uv) - { w_vx(v_index); w_vx(f_index); w_float(uv[0]); if (dim==2) w_float(1.f-uv[1]); } +IC void w_vmad (int v_index, int f_index, int dim, float* uv) +{ w_vx(v_index); w_vx(f_index); w_float(uv[0]); if (dim==2) w_float(1.f-uv[1]); } - IC void Wsurface(LPCSTR name, BOOL b2Sided, u16 image, LPCSTR vmap, LPCSTR sh_eng, LPCSTR sh_comp){ - // surf screen - char ord[2]; - open_chunk(ID_SURF); - w_stringZ(name); - w_stringZ(""); - open_subchunk(ID_COLR); - w_float(1.f);w_float(1.f);w_float(1.f); w_u16(0); - close_subchunk(); - open_subchunk(ID_SIDE); - w_u16(u16(b2Sided?3:1)); - close_subchunk(); - open_subchunk(ID_BLOK); - open_subchunk(ID_IMAP); - make_ord(128,0,(u8*)ord); - w_stringZ(ord); - open_subchunk(ID_CHAN); - w_u32(ID_COLR); - close_subchunk(); - open_subchunk(ID_OPAC); - w_u16(0); - w_float(1.f); - w_u16(0); - close_subchunk(); - open_subchunk(ID_ENAB); - w_u16(1); - close_subchunk(); - close_subchunk(); - open_subchunk(ID_PROJ); - w_u16(5); - close_subchunk(); - open_subchunk(ID_IMAG); - w_u16(image); - close_subchunk(); - open_subchunk(ID_VMAP); - w_stringZ(vmap); - close_subchunk(); - open_subchunk(ID_AAST); - w_u16(1); w_float(1.f); - close_subchunk(); - open_subchunk(ID_PIXB); - w_u16(1); - close_subchunk(); - open_subchunk(ID_STCK); - w_float(0.f); w_u16(0); - close_subchunk(); - open_subchunk(ID_TAMP); - w_float(1.f); w_u16(0); - close_subchunk(); - close_subchunk(); - // plugins -/* open_subchunk(ID_BLOK); - open_subchunk(ID_SHDR); - make_ord(128,0,(u8*)ord); - w_stringZ(ord); - open_subchunk(ID_ENAB); - w_u16(1); - close_subchunk(); - open_subchunk(ID_FUNC); - w_stringZ("!XRayShader"); - string64 tmp; - strcpy(tmp,sh_eng); - write(tmp,sizeof(tmp)); - w_u32(-1); - strcpy(tmp,sh_comp); - write(tmp,sizeof(tmp)); - w_u32(-1); - write("",128); - close_subchunk(); - close_subchunk(); - close_subchunk(); -*/ close_chunk(); - } +IC void Wsurface(LPCSTR name, BOOL b2Sided, u16 image, LPCSTR vmap, LPCSTR sh_eng, LPCSTR sh_comp){ + // surf screen + char ord[2]; + open_chunk(ID_SURF); + w_stringZ(name); + w_stringZ(""); + open_subchunk(ID_COLR); + w_float(1.f);w_float(1.f);w_float(1.f); w_u16(0); + close_subchunk(); + open_subchunk(ID_SIDE); + w_u16(u16(b2Sided?3:1)); + close_subchunk(); + open_subchunk(ID_BLOK); + open_subchunk(ID_IMAP); + make_ord(128,0,(u8*)ord); + w_stringZ(ord); + open_subchunk(ID_CHAN); + w_u32(ID_COLR); + close_subchunk(); + open_subchunk(ID_OPAC); + w_u16(0); + w_float(1.f); + w_u16(0); + close_subchunk(); + open_subchunk(ID_ENAB); + w_u16(1); + close_subchunk(); + close_subchunk(); + open_subchunk(ID_PROJ); + w_u16(5); + close_subchunk(); + open_subchunk(ID_IMAG); + w_u16(image); + close_subchunk(); + open_subchunk(ID_VMAP); + w_stringZ(vmap); + close_subchunk(); + open_subchunk(ID_AAST); + w_u16(1); w_float(1.f); + close_subchunk(); + open_subchunk(ID_PIXB); + w_u16(1); + close_subchunk(); + open_subchunk(ID_STCK); + w_float(0.f); w_u16(0); + close_subchunk(); + open_subchunk(ID_TAMP); + w_float(1.f); w_u16(0); + close_subchunk(); + close_subchunk(); + // plugins + /* open_subchunk(ID_BLOK); + open_subchunk(ID_SHDR); + make_ord(128,0,(u8*)ord); + w_stringZ(ord); + open_subchunk(ID_ENAB); + w_u16(1); + close_subchunk(); + open_subchunk(ID_FUNC); + w_stringZ("!XRayShader"); + string64 tmp; + strcpy(tmp,sh_eng); + write(tmp,sizeof(tmp)); + w_u32(-1); + strcpy(tmp,sh_comp); + write(tmp,sizeof(tmp)); + w_u32(-1); + write("",128); + close_subchunk(); + close_subchunk(); + close_subchunk(); + */ close_chunk(); +} }; #endif + diff --git a/src/editors/LevelEditor/Edit/GeometryPartExtractor.cpp b/src/editors/LevelEditor/Edit/GeometryPartExtractor.cpp index 537dfcd93b0..6613e317bfb 100644 --- a/src/editors/LevelEditor/Edit/GeometryPartExtractor.cpp +++ b/src/editors/LevelEditor/Edit/GeometryPartExtractor.cpp @@ -2,324 +2,398 @@ #pragma hdrstop #include "GeometryPartExtractor.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/UI_Main.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/UI_Main.h" #include "UI_LevelTools.h" //------------------------------------------------------------------------------ // Parts //------------------------------------------------------------------------------ -void SBPart::append_face (SBFace* F) +void SBPart::append_face(SBFace *F) { - m_Faces.push_back (F); + m_Faces.push_back(F); } -void SBPart::use_face (SBFace* F, u32& cnt, u32 bone_id, float& area) + +void SBPart::use_face(SBFace *F, u32 &cnt, u32 bone_id, float &area) { - VERIFY (F->bone_id==-1); - F->marked = true; - F->bone_id = bone_id; - area += F->CalcArea(); + VERIFY(F->bone_id==-1); + F->marked = true; + F->bone_id = bone_id; + area += F->CalcArea(); cnt++; } -void SBPart::recurse_fragment (SBFace* F, u32& cnt, u32 bone_id, u32 max_faces, float& area) + +void SBPart::recurse_fragment(SBFace *F, u32 &cnt, u32 bone_id, u32 max_faces, float &area) { - if (F){ - if (!F->marked) use_face (F,cnt,bone_id,area); + if (F) + { + if (!F->marked) + use_face(F, cnt, bone_id, area); // fill nearest SBFaceVec r_vec; - for (SBFaceVecIt n_it=F->adjs.begin(); n_it!=F->adjs.end(); n_it++){ - if (cnt>=max_faces) break; - if ((*n_it)->marked) continue; - use_face (*n_it,cnt,bone_id,area); - r_vec.push_back (*n_it); - } + for (SBFaceVecIt n_it = F->adjs.begin(); n_it!=F->adjs.end(); n_it++) + { + if (cnt>=max_faces) + break; + if ((*n_it)->marked) + continue; + use_face(*n_it, cnt, bone_id, area); + r_vec.push_back(*n_it); + } // recurse adjs - for (SBFaceVecIt a_it=r_vec.begin(); a_it!=r_vec.end(); a_it++){ - if (cnt>=max_faces) break; - if ((*a_it)->bone_id!=(int)bone_id) continue; - recurse_fragment (*a_it,cnt,bone_id,max_faces,area); - } + for (SBFaceVecIt a_it = r_vec.begin(); a_it!=r_vec.end(); a_it++) + { + if (cnt>=max_faces) + break; + if ((*a_it)->bone_id!=(int)bone_id) + continue; + recurse_fragment(*a_it, cnt, bone_id, max_faces, area); + } } } -bool SBPart::prepare (SBAdjVec& adjs, u32 bone_face_min) + +bool SBPart::prepare(SBAdjVec &adjs, u32 bone_face_min) { - m_bValid = true; + m_bValid = true; // compute OBB - FvectorVec pts; pts.reserve (m_Faces.size()*3); - for (SBFaceVecIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++){ - (*f_it)->marked = false; - for (int k=0; k<3; k++) pts.push_back((*f_it)->o[k]); + FvectorVec pts; + pts.reserve(m_Faces.size()*3); + for (SBFaceVecIt f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++) + { + (*f_it)->marked = false; + for (int k = 0; k<3; k++) + pts.push_back((*f_it)->o[k]); } - ComputeOBB_RAPID (m_OBB,pts,pts.size()/3); + ComputeOBB_RAPID(m_OBB, pts, pts.size()/3); // fill adjacent - for (SBFaceVecIt a_it=m_Faces.begin(); a_it!=m_Faces.end(); a_it++){ - SBFace* A = *a_it; - for (int k=0; k<3; k++){ - SBFaceVec& b_vec = adjs[A->vert_id[k]]; - for (SBFaceVecIt b_it=b_vec.begin(); b_it!=b_vec.end(); b_it++){ - SBFace* B = *b_it; - if (A!=B){ - int cnt = 0; - for (int a=0; a<3; a++) for (int b=0; b<3; b++) if (A->vert_id[a]==B->vert_id[b]) cnt++; - if (cnt>=2){ - if (std::find(A->adjs.begin(),A->adjs.end(),B)==A->adjs.end()) A->adjs.push_back(B); - if (std::find(B->adjs.begin(),B->adjs.end(),A)==B->adjs.end()) B->adjs.push_back(A); + for (SBFaceVecIt a_it = m_Faces.begin(); a_it!=m_Faces.end(); a_it++) + { + SBFace *A = *a_it; + for (int k = 0; k<3; k++) + { + SBFaceVec &b_vec = adjs[A->vert_id[k]]; + for (SBFaceVecIt b_it = b_vec.begin(); b_it!=b_vec.end(); b_it++) + { + SBFace *B = *b_it; + if (A!=B) + { + int cnt = 0; + for (int a = 0; a<3; a++) + for (int b = 0; b<3; b++) + if (A->vert_id[a]==B->vert_id[b]) + cnt++; + if (cnt>=2) + { + if (std::find(A->adjs.begin(), A->adjs.end(), B)==A->adjs.end()) + A->adjs.push_back(B); + if (std::find(B->adjs.begin(), B->adjs.end(), A)==B->adjs.end()) + B->adjs.push_back(A); } } - } + } } } // prepare transform matrix - m_BBox.invalidate (); - Fmatrix M; M.set (m_OBB.m_rotate.i,m_OBB.m_rotate.j,m_OBB.m_rotate.k,m_OBB.m_translate); - m_RefOffset.set (m_OBB.m_translate); - M.getXYZ (m_RefRotate); // íå i ïîòîìó ÷òî â äâèæêå òàê - M.invert (); + m_BBox.invalidate(); + Fmatrix M; + M.set(m_OBB.m_rotate.i, m_OBB.m_rotate.j, m_OBB.m_rotate.k, m_OBB.m_translate); + m_RefOffset.set(m_OBB.m_translate); + M.getXYZ(m_RefRotate); // íå i ïîòîìó ÷òî â äâèæêå òàê + M.invert(); // transform vertices & calculate bounding box - for (f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++){ - SBFace* F = (*f_it); - if (F->adjs.empty()){ - ELog.Msg(mtError,"Error face found at pos: [%3.2f,%3.2f,%3.2f]",VPUSH(F->o[0])); - Tools->m_DebugDraw.AppendWireFace(F->o[0],F->o[1],F->o[2]); - m_bValid = false; + for (f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++) + { + SBFace *F = (*f_it); + if (F->adjs.empty()) + { + ELog.Msg(mtError, "Error face found at pos: [%3.2f,%3.2f,%3.2f]", VPUSH(F->o[0])); + Tools->m_DebugDraw.AppendWireFace(F->o[0], F->o[1], F->o[2]); + m_bValid = false; } - for (int k=0; k<3; k++){ - M.transform_dir (F->n[k]); - M.transform_tiny (F->o[k]); - m_BBox.modify (F->o[k]); + for (int k = 0; k<3; k++) + { + M.transform_dir(F->n[k]); + M.transform_tiny(F->o[k]); + m_BBox.modify(F->o[k]); } - } - if (m_bValid){ + } + if (m_bValid) + { // calculate bone params - int bone_cnt_calc = iFloor(float(m_Faces.size())/bone_face_min); - int bone_cnt_max = (bone_cnt_calc<62)?(bone_cnt_calc<=0?1:bone_cnt_calc):62; - int bone_face_max = iFloor(float(m_Faces.size())/bone_cnt_max+0.5f); bone_face_max *= 4.f; - int bone_idx = 0; + int bone_cnt_calc = iFloor(float(m_Faces.size())/bone_face_min); + int bone_cnt_max = (bone_cnt_calc<62) ? (bone_cnt_calc<=0 ? 1 : bone_cnt_calc) : 62; + int bone_face_max = iFloor(float(m_Faces.size())/bone_cnt_max+0.5f); + bone_face_max *= 4.f; + int bone_idx = 0; // create big fragment - u32 face_accum_total = 0; - AnsiString parent_bone = ""; - do{ - SBFace* F = 0; + u32 face_accum_total = 0; + AnsiString parent_bone = ""; + do + { + SBFace *F = 0; // find unused face - for (SBFaceVecIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++){ - if (!(*f_it)->marked){ - F = *f_it; - int cnt = 0; - for (SBFaceVecIt a_it=F->adjs.begin(); a_it!=F->adjs.end(); a_it++) cnt+=(*a_it)->marked?0:1; - if ((cnt==0)||(cnt>=2)) break; + for (SBFaceVecIt f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++) + { + if (!(*f_it)->marked) + { + F = *f_it; + int cnt = 0; + for (SBFaceVecIt a_it = F->adjs.begin(); a_it!=F->adjs.end(); a_it++) + cnt += (*a_it)->marked ? 0 : 1; + if ((cnt==0)||(cnt>=2)) + break; } } - if (!F) break; - float area = 0; - u32 face_accum = 0; - u32 face_max_count = Random.randI(bone_face_min,bone_face_max+1); + if (!F) + break; + float area = 0; + u32 face_accum = 0; + u32 face_max_count = Random.randI(bone_face_min, bone_face_max+1); // fill faces - recurse_fragment (F,face_accum,bone_idx,face_max_count,area); - if (face_accum==1){ -// F->marked = false; - F->bone_id = -1; - }else{ - m_Bones.push_back (SBBone(bone_idx,parent_bone,F->surf->_GameMtlName(),face_accum,area)); - parent_bone = "0"; - bone_idx ++; - face_accum_total += face_accum; + recurse_fragment(F, face_accum, bone_idx, face_max_count, area); + if (face_accum==1) + { + // F->marked = false; + F->bone_id = -1; + } + else + { + m_Bones.push_back(SBBone(bone_idx, parent_bone, F->surf->_GameMtlName(), face_accum, area)); + parent_bone = "0"; + bone_idx ++; + face_accum_total += face_accum; } // create bone - }while(bone_idxbone_id){ - F->marked = true; - F->bone_id = 0; + for (SBFaceVecIt f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++) + { + SBFace *F = *f_it; + if (-1==F->bone_id) + { + F->marked = true; + F->bone_id = 0; face_accum_total++; } - } + } } - for (SBFaceVecIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++){ - SBFace* F = *f_it; - if (-1==F->bone_id){ - SBFace* P = 0; - if (F->adjs.empty()){ - F->marked = true; - F->bone_id = 0; + for (SBFaceVecIt f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++) + { + SBFace *F = *f_it; + if (-1==F->bone_id) + { + SBFace *P = 0; + if (F->adjs.empty()) + { + F->marked = true; + F->bone_id = 0; face_accum_total++; - }else{ - for (SBFaceVecIt a_it=F->adjs.begin(); a_it!=F->adjs.end(); a_it++){ - if (-1!=(*a_it)->bone_id){ - P = *a_it; - break; + } + else + { + for (SBFaceVecIt a_it = F->adjs.begin(); a_it!=F->adjs.end(); a_it++) + { + if (-1!=(*a_it)->bone_id) + { + P = *a_it; + break; } } } - if (P){ - VERIFY(-1!=P->bone_id); - F->marked = true; - F->bone_id = P->bone_id; + if (P) + { + VERIFY(-1!=P->bone_id); + F->marked = true; + F->bone_id = P->bone_id; face_accum_total++; } } - } + } } - + // calculate bone offset - for (f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++){ - SBFace* F = *f_it; - VERIFY (F->bone_id!=-1); - SBBone& B = m_Bones[F->bone_id]; - for (int k=0; k<3; k++) B.offset.add(F->o[k]); + for (f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++) + { + SBFace *F = *f_it; + VERIFY(F->bone_id!=-1); + SBBone &B = m_Bones[F->bone_id]; + for (int k = 0; k<3; k++) + B.offset.add(F->o[k]); } - for (SBBoneVecIt b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++){ - SBBone& B = *b_it; - VERIFY (0!=B.f_cnt); - B.offset.div (B.f_cnt*3); + for (SBBoneVecIt b_it = m_Bones.begin(); b_it!=m_Bones.end(); b_it++) + { + SBBone &B = *b_it; + VERIFY(0!=B.f_cnt); + B.offset.div(B.f_cnt*3); } - Fvector& offs = m_Bones.front().offset; - for (b_it=m_Bones.begin(); b_it!=m_Bones.end(); b_it++) - b_it->offset.sub (offs); + Fvector &offs = m_Bones.front().offset; + for (b_it = m_Bones.begin(); b_it!=m_Bones.end(); b_it++) + b_it->offset.sub(offs); } return m_bValid; } -bool SBPart::Export (IWriter& F, u8 infl) + +bool SBPart::Export(IWriter &F, u8 infl) { - VERIFY (!m_Bones.empty()); - if (m_Bones.size()>63){ - ELog.Msg(mtError,"Breakable object cannot handle more than 63 parts."); - return false; + VERIFY(!m_Bones.empty()); + if (m_Bones.size()>63) + { + ELog.Msg(mtError, "Breakable object cannot handle more than 63 parts."); + return false; } bool bRes = true; - u32 bone_count = m_Bones.size(); - - xr_vector bone_points; - bone_points.resize (bone_count); - - u32 mtl_cnt = 0; - - for (SBFaceVecIt pf_it=m_Faces.begin(); pf_it!=m_Faces.end(); pf_it++){ - SBFace* face = *pf_it; - int mtl_idx = FindSplit(face->surf->_ShaderName(),face->surf->_Texture(),0); - if (mtl_idx<0){ - m_Splits.push_back(SSplit(face->surf,m_BBox,0)); - mtl_idx = mtl_cnt++; + u32 bone_count = m_Bones.size(); + + xr_vector bone_points; + bone_points.resize(bone_count); + + u32 mtl_cnt = 0; + + for (SBFaceVecIt pf_it = m_Faces.begin(); pf_it!=m_Faces.end(); pf_it++) + { + SBFace *face = *pf_it; + int mtl_idx = FindSplit(face->surf->_ShaderName(), face->surf->_Texture(), 0); + if (mtl_idx<0) + { + m_Splits.push_back(SSplit(face->surf, m_BBox, 0)); + mtl_idx = mtl_cnt++; } - SSplit& split=m_Splits[mtl_idx]; + SSplit &split = m_Splits[mtl_idx]; SSkelVert v[3]; - for (int k=0; k<3; k++){ + for (int k = 0; k<3; k++) + { st_SVert::bone b[1]; - b[0].id = face->bone_id; - b[0].w = 1.f; - v[k].set (face->o[k],face->n[k],face->uv[k],1,b); + b[0].id = face->bone_id; + b[0].w = 1.f; + v[k].set(face->o[k], face->n[k], face->uv[k], 1, b); } - split.add_face (v[0], v[1], v[2]); + split.add_face(v[0], v[1], v[2]); - if (face->surf->m_Flags.is(CSurface::sf2Sided)){ - v[0].norm.invert(); v[1].norm.invert(); v[2].norm.invert(); - if (!split.add_face(v[0], v[2], v[1])) split.invalid_faces++; + if (face->surf->m_Flags.is(CSurface::sf2Sided)) + { + v[0].norm.invert(); + v[1].norm.invert(); + v[2].norm.invert(); + if (!split.add_face(v[0], v[2], v[1])) + split.invalid_faces++; } } // fill per bone vertices - for (SplitIt split_it=m_Splits.begin(); split_it!=m_Splits.end(); split_it++){ - if (!split_it->valid()){ - ELog.Msg(mtError,"Degenerate part found (Texture '%s').",*split_it->m_Texture); + for (SplitIt split_it = m_Splits.begin(); split_it!=m_Splits.end(); split_it++) + { + if (!split_it->valid()) + { + ELog.Msg(mtError, "Degenerate part found (Texture '%s').", *split_it->m_Texture); bRes = false; break; } - if (0!=split_it->invalid_faces){ - ELog.Msg(mtError,"Part [texture '%s'] have %d duplicate(degenerate) face(s).",*split_it->m_Texture,split_it->invalid_faces); + if (0!=split_it->invalid_faces) + { + ELog.Msg(mtError, "Part [texture '%s'] have %d duplicate(degenerate) face(s).", *split_it->m_Texture, split_it->invalid_faces); } - // calculate T&B components - split_it->CalculateTB(); + // calculate T&B components + split_it->CalculateTB(); // subtract offset - SkelVertVec& lst = split_it->getV_Verts(); - for (SkelVertIt sv_it=lst.begin(); sv_it!=lst.end(); sv_it++){ - bone_points[sv_it->bones[0].id].push_back(sv_it->offs); + SkelVertVec &lst = split_it->getV_Verts(); + for (SkelVertIt sv_it = lst.begin(); sv_it!=lst.end(); sv_it++) + { + bone_points[sv_it->bones[0].id].push_back(sv_it->offs); bone_points[sv_it->bones[0].id].back().sub(m_Bones[sv_it->bones[0].id].offset); } } - if (!bRes) return false; + if (!bRes) + return false; // compute bounding - ComputeBounding (); + ComputeBounding(); - // create OGF + // create OGF // Header - ogf_header H; - H.format_version= xrOGF_FormatVersion; - H.type = MT_SKELETON_RIGID; - H.shader_id = 0; - H.bb.min = m_Box.min; - H.bb.max = m_Box.max; - m_Box.getsphere (H.bs.c,H.bs.r); - F.w_chunk (OGF_HEADER,&H,sizeof(H)); + ogf_header H; + H.format_version = xrOGF_FormatVersion; + H.type = MT_SKELETON_RIGID; + H.shader_id = 0; + H.bb.min = m_Box.min; + H.bb.max = m_Box.max; + m_Box.getsphere(H.bs.c, H.bs.r); + F.w_chunk(OGF_HEADER, &H, sizeof(H)); // Desc - ogf_desc desc; - F.open_chunk (OGF_S_DESC); - desc.Save (F); - F.close_chunk (); - + ogf_desc desc; + F.open_chunk(OGF_S_DESC); + desc.Save(F); + F.close_chunk(); + // OGF_CHILDREN - F.open_chunk (OGF_CHILDREN); - int chield=0; - for (split_it=m_Splits.begin(); split_it!=m_Splits.end(); split_it++){ - F.open_chunk(chield++); + F.open_chunk(OGF_CHILDREN); + int chield = 0; + for (split_it = m_Splits.begin(); split_it!=m_Splits.end(); split_it++) + { + F.open_chunk(chield++); split_it->Save(F); - F.close_chunk(); + F.close_chunk(); } F.close_chunk(); // BoneNames - F.open_chunk(OGF_S_BONE_NAMES); - F.w_u32 (bone_count); + F.open_chunk(OGF_S_BONE_NAMES); + F.w_u32(bone_count); // write other bones - for (u32 bone_idx=0; bone_idxmarked) return; + if (F->marked) + return; - P->append_face (F); - F->marked = true; + P->append_face(F); + F->marked = true; // recurse - for (int k=0; k<3; k++){ - SBFaceVec& PL = adjs[F->vert_id[k]]; - for (SBFaceVecIt pl_it=PL.begin(); pl_it!=PL.end(); pl_it++) - recurse_tri (P,faces,adjs,*pl_it); + for (int k = 0; k<3; k++) + { + SBFaceVec &PL = adjs[F->vert_id[k]]; + for (SBFaceVecIt pl_it = PL.begin(); pl_it!=PL.end(); pl_it++) + recurse_tri(P, faces, adjs, *pl_it); } } + //---------------------------------------------------- -void CGeomPartExtractor::AppendFace(CSurface* surf, const Fvector* v, const Fvector* n, const Fvector2* uvs[3]) +void CGeomPartExtractor::AppendFace(CSurface *surf, const Fvector *v, const Fvector *n, const Fvector2 *uvs[3]) { - SBFace* F = xr_new(surf,uvs); + SBFace *F = xr_new(surf, uvs); // insert verts - for (int k=0; k<3; k++){ - F->vert_id[k] = m_Verts->add_vert(v[k]); - F->o[k].set (v[k]); - F->n[k].set (n[k]); + for (int k = 0; k<3; k++) + { + F->vert_id[k] = m_Verts->add_vert(v[k]); + F->o[k].set(v[k]); + F->n[k].set(n[k]); } - m_Faces.push_back (F); + m_Faces.push_back(F); } -CGeomPartExtractor::CGeomPartExtractor () + +CGeomPartExtractor::CGeomPartExtractor() { - m_Verts = 0; + m_Verts = 0; } -void CGeomPartExtractor::Initialize (const Fbox& bb, float eps, u32 per_bone_face_count_min) + +void CGeomPartExtractor::Initialize(const Fbox &bb, float eps, u32 per_bone_face_count_min) { - VERIFY (0==m_Verts); - m_Verts = xr_new(bb,eps); - m_PerBoneFaceCountMin=per_bone_face_count_min; VERIFY(m_PerBoneFaceCountMin>0); + VERIFY(0==m_Verts); + m_Verts = xr_new(bb, eps); + m_PerBoneFaceCountMin = per_bone_face_count_min; + VERIFY(m_PerBoneFaceCountMin>0); } -void CGeomPartExtractor::Clear () + +void CGeomPartExtractor::Clear() { - xr_delete (m_Verts); - for (SBFaceVecIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++) - xr_delete (*f_it); - m_Faces.clear (); - for (SBPartVecIt p_it=m_Parts.begin(); p_it!=m_Parts.end(); p_it++) - xr_delete (*p_it); - m_Parts.clear (); - m_Adjs.clear (); + xr_delete(m_Verts); + for (SBFaceVecIt f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++) + xr_delete(*f_it); + m_Faces.clear(); + for (SBPartVecIt p_it = m_Parts.begin(); p_it!=m_Parts.end(); p_it++) + xr_delete(*p_it); + m_Parts.clear(); + m_Adjs.clear(); } + BOOL CGeomPartExtractor::Process() { // make adjacement { - m_Adjs.resize (m_Verts->getVS()); - for (SBFaceVecIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++) - for (int k=0; k<3; k++) m_Adjs[(*f_it)->vert_id[k]].push_back(*f_it); + m_Adjs.resize(m_Verts->getVS()); + for (SBFaceVecIt f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++) + for (int k = 0; k<3; k++) + m_Adjs[(*f_it)->vert_id[k]].push_back(*f_it); } // extract parts { - SPBItem* pb = UI->ProgressStart(m_Faces.size(),"Extract Parts..."); - for (SBFaceVecIt f_it=m_Faces.begin(); f_it!=m_Faces.end(); f_it++){ - pb->Inc(); - SBFace* F = *f_it; - if (!F->marked){ - SBPart* P = xr_new(); - recurse_tri (P,m_Faces,m_Adjs,*f_it); - m_Parts.push_back (P); + SPBItem *pb = UI->ProgressStart(m_Faces.size(), "Extract Parts..."); + for (SBFaceVecIt f_it = m_Faces.begin(); f_it!=m_Faces.end(); f_it++) + { + pb->Inc(); + SBFace *F = *f_it; + if (!F->marked) + { + SBPart *P = xr_new(); + recurse_tri(P, m_Faces, m_Adjs, *f_it); + m_Parts.push_back(P); } } UI->ProgressEnd(pb); } // simplify parts { - SPBItem* pb = UI->ProgressStart(m_Parts.size(),"Simplify Parts..."); - for (SBPartVecIt p_it=m_Parts.begin(); p_it!=m_Parts.end(); p_it++){ - pb->Inc(); - (*p_it)->prepare (m_Adjs,m_PerBoneFaceCountMin); + SPBItem *pb = UI->ProgressStart(m_Parts.size(), "Simplify Parts..."); + for (SBPartVecIt p_it = m_Parts.begin(); p_it!=m_Parts.end(); p_it++) + { + pb->Inc(); + (*p_it)->prepare(m_Adjs, m_PerBoneFaceCountMin); } - UI->ProgressEnd(pb); + UI->ProgressEnd(pb); } return TRUE; } diff --git a/src/editors/LevelEditor/Edit/GeometryPartExtractor.h b/src/editors/LevelEditor/Edit/GeometryPartExtractor.h index 70c3703feed..9da00f37e98 100644 --- a/src/editors/LevelEditor/Edit/GeometryPartExtractor.h +++ b/src/editors/LevelEditor/Edit/GeometryPartExtractor.h @@ -1,111 +1,139 @@ #ifndef GeometryPartExtractorH #define GeometryPartExtractorH -#include "../ECore/Editor/GeometryCollector.h" -#include "../ECore/Editor/ExportSkeleton.h" +#include "editors/ECore/Editor/GeometryCollector.h" +#include "editors/ECore/Editor/ExportSkeleton.h" #include "Scene.h" -struct SBFace; -class CSurface; -DEFINE_VECTOR (SBFace*,SBFaceVec,SBFaceVecIt); - -struct SBFace{ -// internal - int vert_id[3]; - bool marked; - SBFaceVec adjs; -// geom - Fvector o[3]; - Fvector n[3]; - Fvector2 uv[3]; - int bone_id; - CSurface* surf; -public: - SBFace (CSurface* _surf, const Fvector2* _uv[3]):surf(_surf),marked(false),bone_id(-1) - { - vert_id[0] = -1; - vert_id[1] = -1; - vert_id[2] = -1; - uv[0] = *_uv[0]; - uv[1] = *_uv[1]; - uv[2] = *_uv[2]; - n[0].set (0,0,0); - n[1].set (0,0,0); - n[2].set (0,0,0); +struct SBFace; +class CSurface; +DEFINE_VECTOR(SBFace *, SBFaceVec, SBFaceVecIt); + +struct SBFace +{ + // internal + int vert_id[3]; + bool marked; + SBFaceVec adjs; + // geom + Fvector o[3]; + Fvector n[3]; + Fvector2 uv[3]; + int bone_id; + CSurface *surf; +public: + SBFace(CSurface *_surf, const Fvector2 *_uv[3]): surf(_surf), marked(false), bone_id(-1) + { + vert_id[0] = -1; + vert_id[1] = -1; + vert_id[2] = -1; + uv[0] = *_uv[0]; + uv[1] = *_uv[1]; + uv[2] = *_uv[2]; + n[0].set(0, 0, 0); + n[1].set(0, 0, 0); + n[2].set(0, 0, 0); } - float CalcArea() + + float CalcArea() { - Fvector V0,V1; - V0.sub (o[1],o[0]); - V1.sub (o[2],o[0]); - float sqm0 = V0.square_magnitude(); - float sqm1 = V1.square_magnitude(); - return 0.5f*_sqrt(sqm0*sqm1-_sqr(V0.dotproduct(V1))); + Fvector V0, V1; + V0.sub(o[1], o[0]); + V1.sub(o[2], o[0]); + float sqm0 = V0.square_magnitude(); + float sqm1 = V1.square_magnitude(); + return 0.5f*_sqrt(sqm0*sqm1-_sqr(V0.dotproduct(V1))); } }; struct SBBone { - AnsiString mtl; - AnsiString name; - AnsiString parent; - Fvector offset; - u32 f_cnt; - float area; - SBBone (AnsiString _nm, AnsiString _parent, AnsiString _mtl, u32 _f_cnt, float _area) - :name(_nm),parent(_parent),mtl(_mtl),f_cnt(_f_cnt),area(_area) + AnsiString mtl; + AnsiString name; + AnsiString parent; + Fvector offset; + u32 f_cnt; + float area; + + SBBone(AnsiString _nm, AnsiString _parent, AnsiString _mtl, u32 _f_cnt, float _area) + : name(_nm), parent(_parent), mtl(_mtl), f_cnt(_f_cnt), area(_area) { - offset.set (0,0,0); + offset.set(0, 0, 0); } }; -DEFINE_VECTOR (SBBone,SBBoneVec,SBBoneVecIt); -DEFINE_VECTOR (SBFaceVec,SBAdjVec,SBAdjVecIt); + +DEFINE_VECTOR(SBBone, SBBoneVec, SBBoneVecIt); +DEFINE_VECTOR(SBFaceVec, SBAdjVec, SBAdjVecIt); struct SBPart: public CExportSkeletonCustom { - SBFaceVec m_Faces; - SBBoneVec m_Bones; + SBFaceVec m_Faces; + SBBoneVec m_Bones; - Fbox m_BBox; - Fobb m_OBB; + Fbox m_BBox; + Fobb m_OBB; - SBPart* m_Reference; - - Fvector m_RefOffset; - Fvector m_RefRotate; + SBPart *m_Reference; - bool m_bValid; + Fvector m_RefOffset; + Fvector m_RefRotate; + + bool m_bValid; public: - SBPart () {m_Reference=0;m_bValid=true;} - bool Valid () {return m_bValid;} - virtual bool Export (IWriter& F, u8 infl); - void append_face (SBFace* F); - void use_face (SBFace* F, u32& cnt, u32 bone_id, float& area); - void recurse_fragment (SBFace* F, u32& cnt, u32 bone_id, u32 max_faces, float& area); - bool prepare (SBAdjVec& adjs, u32 bone_face_min); + SBPart() + { + m_Reference = 0; + m_bValid = true; + } + + bool Valid() + { + return m_bValid; + } + + virtual bool Export(IWriter &F, u8 infl); + void append_face(SBFace *F); + void use_face(SBFace *F, u32 &cnt, u32 bone_id, float &area); + void recurse_fragment(SBFace *F, u32 &cnt, u32 bone_id, u32 max_faces, float &area); + bool prepare(SBAdjVec &adjs, u32 bone_face_min); }; -DEFINE_VECTOR (SBPart*,SBPartVec,SBPartVecIt); + +DEFINE_VECTOR(SBPart *, SBPartVec, SBPartVecIt); + //---------------------------------------------------- -class CGeomPartExtractor{ +class CGeomPartExtractor +{ protected: - VCPacked* m_Verts; - SBFaceVec m_Faces; - SBAdjVec m_Adjs; - SBPartVec m_Parts; + VCPacked *m_Verts; + SBFaceVec m_Faces; + SBAdjVec m_Adjs; + SBPartVec m_Parts; - u32 m_PerBoneFaceCountMin; + u32 m_PerBoneFaceCountMin; public: - CGeomPartExtractor (); - ~CGeomPartExtractor (){Clear();} - // init & clean up - void Initialize (const Fbox& bb, float eps, u32 per_bone_face_count_min); - void Clear (); - // I/O routines - void AppendFace (CSurface* surf, const Fvector* v, const Fvector* n, const Fvector2* uvs[3]); - SBPartVec& GetParts (){return m_Parts;} + CGeomPartExtractor(); + + ~CGeomPartExtractor() + { + Clear(); + } + + // init & clean up + void Initialize(const Fbox &bb, float eps, u32 per_bone_face_count_min); + void Clear(); + // I/O routines + void AppendFace(CSurface *surf, const Fvector *v, const Fvector *n, const Fvector2 *uvs[3]); + + SBPartVec &GetParts() + { + return m_Parts; + } + // utilities - BOOL Process (); + BOOL Process(); }; #endif //GeometryPartExtractorH + + diff --git a/src/editors/LevelEditor/Edit/GroupObject.cpp b/src/editors/LevelEditor/Edit/GroupObject.cpp index 4d7932d2ed9..9d0e3681825 100644 --- a/src/editors/LevelEditor/Edit/GroupObject.cpp +++ b/src/editors/LevelEditor/Edit/GroupObject.cpp @@ -14,47 +14,45 @@ #define GROUPOBJ_CHUNK_REFERENCE 0x0004 #define GROUPOBJ_CHUNK_OPEN_OBJECT_LIST 0x0005 -CGroupObject::CGroupObject(LPVOID data, LPCSTR name):CCustomObject(data,name) +CGroupObject::CGroupObject(LPVOID data, LPCSTR name): CCustomObject(data, name) { - Construct (data); + Construct(data); } void CGroupObject::Construct(LPVOID data) { - ClassID = OBJCLASS_GROUP; + ClassID = OBJCLASS_GROUP; } -CGroupObject::~CGroupObject() -{ -} +CGroupObject::~CGroupObject() {} -u32 CGroupObject::GetObjects(ObjectList& lst) +u32 CGroupObject::GetObjects(ObjectList &lst) { - lst.clear(); + lst.clear(); - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) - lst.push_back (it->pObject); + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + lst.push_back(it->pObject); return lst.size(); } -void CGroupObject::Select(int flag) +void CGroupObject::Select(int flag) { inherited::Select(flag); - if(EPrefs->object_flags.test(epoSelectInGroup)) + if (EPrefs->object_flags.test(epoSelectInGroup)) { - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) - it->pObject->Select(flag); + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + it->pObject->Select(flag); } } -void CGroupObject::ClearInternal(ObjectsInGroup& v) +void CGroupObject::ClearInternal(ObjectsInGroup &v) { - for (ObjectsInGroup::iterator it=v.begin(); it!=v.end(); ++it) + for (ObjectsInGroup::iterator it = v.begin(); it!=v.end(); ++it) { - it->pObject->m_pOwnerObject = 0; - Scene->RemoveObject (it->pObject, false, true); - xr_delete (it->pObject); + it->pObject->m_pOwnerObject = 0; + Scene->RemoveObject(it->pObject, false, true); + xr_delete(it->pObject); } v.clear(); } @@ -62,473 +60,487 @@ void CGroupObject::ClearInternal(ObjectsInGroup& v) void CGroupObject::OnFrame() { - inherited::OnFrame(); - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) - it->pObject->OnFrame(); + inherited::OnFrame(); + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + it->pObject->OnFrame(); } -bool CGroupObject::LL_AppendObject(CCustomObject* object) +bool CGroupObject::LL_AppendObject(CCustomObject *object) { if (!object->CanAttach()) { - ELog.Msg(mtError,"Can't attach object: '%s'",object->Name); - return false; + ELog.Msg(mtError, "Can't attach object: '%s'", object->Name); + return false; } - if(object->GetOwner()) + if (object->GetOwner()) { - if (mrNo==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Object '%s' already in group '%s'. Change group?",object->Name,object->GetOwner()->Name)) - return false; - - object->OnDetach(); + if (mrNo==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<Name, object->GetOwner()->Name)) + return false; + + object->OnDetach(); } - object->OnAttach (this); - object->m_CO_Flags.set (flObjectInGroupUnique, FALSE); - m_ObjectsInGroup.resize (m_ObjectsInGroup.size()+1); + object->OnAttach(this); + object->m_CO_Flags.set(flObjectInGroupUnique, FALSE); + m_ObjectsInGroup.resize(m_ObjectsInGroup.size()+1); m_ObjectsInGroup.back().pObject = object; return true; } -bool CGroupObject::AppendObjectLoadCB(CCustomObject* object) +bool CGroupObject::AppendObjectLoadCB(CCustomObject *object) { - object->m_pOwnerObject = this; - object->m_CO_Flags.set (flObjectInGroup, TRUE); - m_ObjectsInGroup.resize (m_ObjectsInGroup.size()+1); + object->m_pOwnerObject = this; + object->m_CO_Flags.set(flObjectInGroup, TRUE); + m_ObjectsInGroup.resize(m_ObjectsInGroup.size()+1); m_ObjectsInGroup.back().pObject = object; - string256 buf; + string256 buf; Scene->GenObjectName(object->ClassID, buf, object->Name); LPCSTR N = object->Name; - if (xr_strcmp(N,buf)!=0) + if (xr_strcmp(N, buf)!=0) { - Msg ("Load_Append name changed from[%s] to[%s]",object->Name, buf); - object->Name = buf; + Msg("Load_Append name changed from[%s] to[%s]", object->Name, buf); + object->Name = buf; } - Scene->AppendObject (object, false); - + Scene->AppendObject(object, false); + return true; } -void CGroupObject::SetRefName(LPCSTR nm) +void CGroupObject::SetRefName(LPCSTR nm) { - m_ReferenceName_ = nm; - if(nm && strstr(nm, "light_preset")) - save_id = 1; + m_ReferenceName_ = nm; + if (nm&&strstr(nm, "light_preset")) + save_id = 1; else - save_id = 0; + save_id = 0; } #include "AppendObjectInfoForm.h" //------------------------------------------------------------------------------ -bool CGroupObject::LoadLTX(CInifile& ini, LPCSTR sect_name) +bool CGroupObject::LoadLTX(CInifile &ini, LPCSTR sect_name) { u32 version = ini.r_u32(sect_name, "version"); if (version<0x0011) { - ELog.DlgMsg( mtError, "CGroupObject: unsupported file version. Object can't load."); + ELog.DlgMsg(mtError, "CGroupObject: unsupported file version. Object can't load."); return false; } - CCustomObject::LoadLTX(ini, sect_name); + CCustomObject::LoadLTX(ini, sect_name); - Flags32 tmp_flags;tmp_flags.zero(); - if(version<0x0012) - tmp_flags.assign(ini.r_u32(sect_name, "flags") ); + Flags32 tmp_flags; + tmp_flags.zero(); + if (version<0x0012) + tmp_flags.assign(ini.r_u32(sect_name, "flags")); - // objects - if(/*IsOpened()*/ tmp_flags.test((1<<0))) - { //old opened group save format - ELog.DlgMsg( mtError, "old opened group save format"); + // objects + if (/*IsOpened()*/ tmp_flags.test((1<<0))) + { //old opened group save format + ELog.DlgMsg(mtError, "old opened group save format"); return false; -/* - u32 cnt = ini.r_u32 (sect_name, "objects_in_group_count"); - shared_str tmp; - string128 buff; - - for (u32 k=0; kReadObjectsLTX (ini, sect_name, "ingroup", AppendObjectLoadCB, 0); + Scene->ReadObjectsLTX(ini, sect_name, "ingroup", AppendObjectLoadCB, 0); } VERIFY(m_ObjectsInGroup.size()); - SetRefName(ini.r_string (sect_name, "ref_name")) ; - if (!m_ReferenceName_.size()) - ELog.Msg (mtError,"ERROR: group '%s' - has empty reference. Corrupted file?", Name); - + SetRefName(ini.r_string(sect_name, "ref_name")) ; + if (!m_ReferenceName_.size()) + ELog.Msg(mtError, "ERROR: group '%s' - has empty reference. Corrupted file?", Name); - if(version<0x0012) + + if (version<0x0012) { - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) - if(it->pObject) + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + if (it->pObject) { - it->pObject->m_CO_Flags.set(flObjectInGroup, TRUE); - it->pObject->m_CO_Flags.set(flObjectInGroupUnique, TRUE); + it->pObject->m_CO_Flags.set(flObjectInGroup, TRUE); + it->pObject->m_CO_Flags.set(flObjectInGroupUnique, TRUE); } } - return true; + return true; } -void CGroupObject::SaveLTX(CInifile& ini, LPCSTR sect_name) +void CGroupObject::SaveLTX(CInifile &ini, LPCSTR sect_name) { - CCustomObject::SaveLTX(ini, sect_name); + CCustomObject::SaveLTX(ini, sect_name); - ini.w_u32 (sect_name, "version", GROUPOBJ_CURRENT_VERSION); + ini.w_u32(sect_name, "version", GROUPOBJ_CURRENT_VERSION); - ObjectList grp_lst; - GetObjects (grp_lst); + ObjectList grp_lst; + GetObjects(grp_lst); ObjectList::iterator it; - for(it=grp_lst.begin(); it!=grp_lst.end(); ++it) + for (it = grp_lst.begin(); it!=grp_lst.end(); ++it) (*it)->m_CO_Flags.set(CCustomObject::flObjectInGroup, FALSE); - + Scene->SaveObjectsLTX(grp_lst, sect_name, "ingroup", ini); - for(it=grp_lst.begin(); it!=grp_lst.end(); ++it) + for (it = grp_lst.begin(); it!=grp_lst.end(); ++it) (*it)->m_CO_Flags.set(CCustomObject::flObjectInGroup, TRUE); - ini.w_string (sect_name, "ref_name", m_ReferenceName_.c_str()); + ini.w_string(sect_name, "ref_name", m_ReferenceName_.c_str()); } -bool CGroupObject::LoadStream(IReader& F) +bool CGroupObject::LoadStream(IReader &F) { - u16 version=0; + u16 version = 0; - R_ASSERT(F.r_chunk(GROUPOBJ_CHUNK_VERSION,&version)); + R_ASSERT(F.r_chunk(GROUPOBJ_CHUNK_VERSION, &version)); if (version<0x0011) { - ELog.DlgMsg( mtError, "CGroupObject: unsupported file version. Object can't load."); + ELog.DlgMsg(mtError, "CGroupObject: unsupported file version. Object can't load."); return false; } - CCustomObject::LoadStream(F); + CCustomObject::LoadStream(F); - Flags32 tmp_flags; tmp_flags.zero(); - if(version<0x0012) - F.r_chunk(GROUPOBJ_CHUNK_FLAGS,&tmp_flags); + Flags32 tmp_flags; + tmp_flags.zero(); + if (version<0x0012) + F.r_chunk(GROUPOBJ_CHUNK_FLAGS, &tmp_flags); - // objects + // objects if (tmp_flags.test(1<<0)) { //old format, opened group - ELog.DlgMsg( mtError, "old format, opened group"); + ELog.DlgMsg(mtError, "old format, opened group"); return false; -/* - R_ASSERT(F.find_chunk(GROUPOBJ_CHUNK_OPEN_OBJECT_LIST)); - u32 cnt = F.r_u32(); - for (u32 k=0; kReadObjectsStream(F,GROUPOBJ_CHUNK_OBJECT_LIST,AppendObjectLoadCB,0); + Scene->ReadObjectsStream(F,GROUPOBJ_CHUNK_OBJECT_LIST, AppendObjectLoadCB, 0); } VERIFY(m_ObjectsInGroup.size()); - if (F.find_chunk(GROUPOBJ_CHUNK_REFERENCE)) + if (F.find_chunk(GROUPOBJ_CHUNK_REFERENCE)) { - shared_str rn; - F.r_stringZ (rn); + shared_str rn; + F.r_stringZ(rn); SetRefName(rn.c_str()); - } - - if(version<0x0012) + } + + if (version<0x0012) { - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) - if(it->pObject) + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + if (it->pObject) { - it->pObject->m_CO_Flags.set(flObjectInGroup, TRUE); - it->pObject->m_CO_Flags.set(flObjectInGroupUnique, TRUE); + it->pObject->m_CO_Flags.set(flObjectInGroup, TRUE); + it->pObject->m_CO_Flags.set(flObjectInGroupUnique, TRUE); } } - return true; + return true; } -void CGroupObject::SaveStream(IWriter& F) +void CGroupObject::SaveStream(IWriter &F) { - CCustomObject::SaveStream(F); + CCustomObject::SaveStream(F); - F.open_chunk (GROUPOBJ_CHUNK_VERSION); - F.w_u16 (GROUPOBJ_CURRENT_VERSION); - F.close_chunk (); + F.open_chunk(GROUPOBJ_CHUNK_VERSION); + F.w_u16(GROUPOBJ_CURRENT_VERSION); + F.close_chunk(); { - ObjectList grp_lst; - GetObjects (grp_lst); + ObjectList grp_lst; + GetObjects(grp_lst); ObjectList::iterator it; - for (it=grp_lst.begin(); it!=grp_lst.end(); ++it) + for (it = grp_lst.begin(); it!=grp_lst.end(); ++it) (*it)->m_CO_Flags.set(CCustomObject::flObjectInGroup, FALSE); - Scene->SaveObjectsStream(grp_lst,GROUPOBJ_CHUNK_OBJECT_LIST,F); + Scene->SaveObjectsStream(grp_lst,GROUPOBJ_CHUNK_OBJECT_LIST, F); - for (it=grp_lst.begin(); it!=grp_lst.end(); ++it) + for (it = grp_lst.begin(); it!=grp_lst.end(); ++it) (*it)->m_CO_Flags.set(CCustomObject::flObjectInGroup, TRUE); } - F.open_chunk (GROUPOBJ_CHUNK_REFERENCE); - F.w_stringZ (m_ReferenceName_); - F.close_chunk (); + F.open_chunk(GROUPOBJ_CHUNK_REFERENCE); + F.w_stringZ(m_ReferenceName_); + F.close_chunk(); } + //---------------------------------------------------- -bool CGroupObject::ExportGame(SExportStreams* data) +bool CGroupObject::ExportGame(SExportStreams *data) { - return true; + return true; } -void CGroupObject::ReferenceChange(PropValue* sender) +void CGroupObject::ReferenceChange(PropValue *sender) { - UpdateReference (true); + UpdateReference(true); } + //---------------------------------------------------- bool CGroupObject::SetReference(LPCSTR ref_name) { - shared_str old_refs = m_ReferenceName_; + shared_str old_refs = m_ReferenceName_; SetRefName(ref_name); - bool bres = UpdateReference(old_refs!=ref_name); - if (false==bres) - SetRefName(old_refs.c_str()); - + bool bres = UpdateReference(old_refs!=ref_name); + if (false==bres) + SetRefName(old_refs.c_str()); + return bres; } -#include "../ECore/Editor/ui_main.h" + +#include "editors/ECore/Editor/ui_main.h" #include "UI_LevelMain.h" extern BOOL bForceInitListBox; bool CGroupObject::UpdateReference(bool bForceReload) { - if (!m_ReferenceName_.size()) + if (!m_ReferenceName_.size()) { - ELog.Msg (mtError,"ERROR: '%s' - has empty reference.",Name); - return false; + ELog.Msg(mtError, "ERROR: '%s' - has empty reference.", Name); + return false; } - - xr_string fn = m_ReferenceName_.c_str(); - fn = EFS.ChangeFileExt(fn,".group"); - IReader* R = FS.r_open(_groups_, fn.c_str()); - bool bres = false; + + xr_string fn = m_ReferenceName_.c_str(); + fn = EFS.ChangeFileExt(fn, ".group"); + IReader *R = FS.r_open(_groups_, fn.c_str()); + bool bres = false; if (R) { - bForceInitListBox = TRUE; - ObjectsInGroup ObjectsInGroupBk = m_ObjectsInGroup; + bForceInitListBox = TRUE; + ObjectsInGroup ObjectsInGroupBk = m_ObjectsInGroup; + + if (bForceReload) + ClearInternal(ObjectsInGroupBk); - if(bForceReload) - ClearInternal (ObjectsInGroupBk); - m_ObjectsInGroup.clear(); - - xr_string nm = Name; - shared_str old_refs = m_ReferenceName_; - UpdateTransform (true); - Fvector old_pos = PPosition; - Fvector old_rot = PRotation; - Fvector old_sc = PScale; - if(LoadStream(*R)) + xr_string nm = Name; + shared_str old_refs = m_ReferenceName_; + UpdateTransform(true); + Fvector old_pos = PPosition; + Fvector old_rot = PRotation; + Fvector old_sc = PScale; + + if (LoadStream(*R)) { - Name = nm.c_str(); - bres = true; - UpdateTransform (true); + Name = nm.c_str(); + bres = true; + UpdateTransform(true); } - FS.r_close (R); - - SetRefName(old_refs.c_str()); - NumSetPosition (old_pos); - NumSetRotation (old_rot); - NumSetScale (old_sc); - UpdateTransform (true); - - if(m_ObjectsInGroup.size()==ObjectsInGroupBk.size()) + FS.r_close(R); + + SetRefName(old_refs.c_str()); + NumSetPosition(old_pos); + NumSetRotation(old_rot); + NumSetScale(old_sc); + UpdateTransform(true); + + if (m_ObjectsInGroup.size()==ObjectsInGroupBk.size()) { - ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); - ObjectsInGroup::iterator itBk = ObjectsInGroupBk.begin(); - for(; it!=m_ObjectsInGroup.end(); ++it, ++itBk) + ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); + ObjectsInGroup::iterator itBk = ObjectsInGroupBk.begin(); + for (; it!=m_ObjectsInGroup.end(); ++it,++itBk) { - it->pObject->m_CO_Flags.set(flObjectInGroupUnique, FALSE); - - if(itBk->pObject->m_CO_Flags.test(flObjectInGroupUnique) ) - { - std::swap(*itBk, *it); - }else - it->pObject->Name = itBk->pObject->Name; + it->pObject->m_CO_Flags.set(flObjectInGroupUnique, FALSE); + + if (itBk->pObject->m_CO_Flags.test(flObjectInGroupUnique)) + { + std::swap(*itBk, *it); + } + else + it->pObject->Name = itBk->pObject->Name; } - }else + } + else { - if(ObjectsInGroupBk.size()) + if (ObjectsInGroupBk.size()) { - ELog.Msg (mtError, "Not all objects synchronised correctly", Name); - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) - it->pObject->m_CO_Flags.set(flObjectInGroupUnique, FALSE); - }else + ELog.Msg(mtError, "Not all objects synchronised correctly", Name); + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + it->pObject->m_CO_Flags.set(flObjectInGroupUnique, FALSE); + } + else { // first setup - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) - it->pObject->m_CO_Flags.set(flObjectInGroupUnique, FALSE); + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + it->pObject->m_CO_Flags.set(flObjectInGroupUnique, FALSE); } } - ClearInternal (ObjectsInGroupBk); - - }else + ClearInternal(ObjectsInGroupBk); + } + else { - ELog.Msg (mtError,"ERROR: Can't open group file: '%s'.",fn.c_str()); + ELog.Msg(mtError, "ERROR: Can't open group file: '%s'.", fn.c_str()); } - + return bres; } + //---------------------------------------------------- -void CGroupObject::FillProp(LPCSTR pref, PropItemVec& items) +void CGroupObject::FillProp(LPCSTR pref, PropItemVec &items) { - inherited::FillProp(pref, items); - PropValue* V = PHelper().CreateChoose (items,PrepareKey(pref,"Reference"),&m_ReferenceName_, smGroup); - V->OnChangeEvent.bind(this,&CGroupObject::ReferenceChange); + inherited::FillProp(pref, items); + PropValue *V = PHelper().CreateChoose(items, PrepareKey(pref, "Reference"), &m_ReferenceName_, smGroup); + V->OnChangeEvent.bind(this, &CGroupObject::ReferenceChange); - ButtonValue* B; - B=PHelper().CreateButton (items,PrepareKey(pref,"FreezeObjects"), "Unique,Reference",0); - B->OnBtnClickEvent.bind (this,&CGroupObject::OnFreezeAllClick); + ButtonValue *B; + B = PHelper().CreateButton(items, PrepareKey(pref, "FreezeObjects"), "Unique,Reference", 0); + B->OnBtnClickEvent.bind(this, &CGroupObject::OnFreezeAllClick); - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) { - string_path pk; - sprintf (pk,"%s (%s)",PrepareKey(pref, it->pObject->Name).c_str(),it->pObject->ParentTool->ClassDesc()); - V = PHelper().CreateFlag32 (items, pk, &it->pObject->m_CO_Flags, flObjectInGroupUnique); - V->OnChangeEvent.bind (this,&CCustomObject::OnChangeIngroupUnique); + string_path pk; + sprintf(pk, "%s (%s)", PrepareKey(pref, it->pObject->Name).c_str(), it->pObject->ParentTool->ClassDesc()); + V = PHelper().CreateFlag32(items, pk, &it->pObject->m_CO_Flags, flObjectInGroupUnique); + V->OnChangeEvent.bind(this, &CCustomObject::OnChangeIngroupUnique); } } -void CGroupObject::OnFreezeAllClick(ButtonValue* sender, bool& bModif, bool& bSafe) +void CGroupObject::OnFreezeAllClick(ButtonValue *sender, bool &bModif, bool &bSafe) { - ButtonValue* V = dynamic_cast(sender); + ButtonValue *V = dynamic_cast(sender); BOOL bDoUnique = FALSE; switch (V->btn_num) { - case 0: - { - bDoUnique = TRUE; - }break; + case 0: + { + bDoUnique = TRUE; + } + break; case 1: - { - bDoUnique = FALSE; - }break; - } - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) - it->pObject->m_CO_Flags.set(flObjectInGroupUnique, bDoUnique); - + { + bDoUnique = FALSE; + } + break; + } + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + it->pObject->m_CO_Flags.set(flObjectInGroupUnique, bDoUnique); + bModif = true; } //---------------------------------------------------- -void CGroupObject::OnShowHint(AStringVec& dest) +void CGroupObject::OnShowHint(AStringVec &dest) { - inherited::OnShowHint(dest); + inherited::OnShowHint(dest); dest.push_back(AnsiString("Reference: ")+m_ReferenceName_.c_str()); dest.push_back(AnsiString("-------")); - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) - dest.push_back(it->pObject->Name); + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + dest.push_back(it->pObject->Name); } + //---------------------------------------------------- -void CGroupObject::OnObjectRemove(const CCustomObject* object) +void CGroupObject::OnObjectRemove(const CCustomObject *object) { - ObjectsInGroup::iterator it = std::find(m_ObjectsInGroup.begin(),m_ObjectsInGroup.end(),object); - if(it==m_ObjectsInGroup.end()) + ObjectsInGroup::iterator it = std::find(m_ObjectsInGroup.begin(), m_ObjectsInGroup.end(), object); + if (it==m_ObjectsInGroup.end()) return; - + m_ObjectsInGroup.erase(it); } void CGroupObject::OnSceneUpdate() { - inherited::OnSceneUpdate(); + inherited::OnSceneUpdate(); - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + { + if (it->pObject==NULL) { - if(it->pObject==NULL) - { - R_ASSERT(0); -/* - R_ASSERT(it->ObjectName.size()); - CCustomObject* CO = Scene->FindObjectByName(it->ObjectName.c_str(), (CCustomObject*)0); - - R_ASSERT2 (!CO->m_CO_Flags.test(flObjectInGroup), it->ObjectName.c_str()); - it->pObject = CO; - - string256 buf; - Scene->GenObjectName(CO->ClassID, buf, CO->Name); - if (CO->Name!=buf) - { - Msg("OG name changed from[%s] to[%s]",CO->Name, buf); - CO->Name = buf; - it->ObjectName = buf; - } - - it->pObject->m_CO_Flags.set(flObjectInGroup, TRUE); - it->pObject->m_CO_Flags.set(flObjectInGroupUnique, TRUE); - if(it->pObject==NULL) - ELog.Msg (mtError,"Gr%s' has invalid roup 'eference to object '%s'.", Name, it->ObjectName.c_str()); -*/ - } + R_ASSERT(0); + /* + R_ASSERT(it->ObjectName.size()); + CCustomObject* CO = Scene->FindObjectByName(it->ObjectName.c_str(), (CCustomObject*)0); + + R_ASSERT2 (!CO->m_CO_Flags.test(flObjectInGroup), it->ObjectName.c_str()); + it->pObject = CO; + string256 buf; + Scene->GenObjectName(CO->ClassID, buf, CO->Name); + if (CO->Name!=buf) + { + Msg("OG name changed from[%s] to[%s]",CO->Name, buf); + CO->Name = buf; + it->ObjectName = buf; + } + + it->pObject->m_CO_Flags.set(flObjectInGroup, TRUE); + it->pObject->m_CO_Flags.set(flObjectInGroupUnique, TRUE); + if(it->pObject==NULL) + ELog.Msg (mtError,"Gr%s' has invalid roup 'eference to object '%s'.", Name, it->ObjectName.c_str()); + */ + } } if (m_ObjectsInGroup.empty()) { - ELog.Msg (mtInformation,"Group '%s' has no objects and will be removed.",Name); - DeleteThis (); + ELog.Msg(mtInformation, "Group '%s' has no objects and will be removed.", Name); + DeleteThis(); } } //---------------------------------------------------- bool CGroupObject::CanUngroup(bool bMsg) { - bool res = true; - for (ObjectsInGroup::iterator it =m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + bool res = true; + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) { - ESceneToolBase* tool = Scene->GetTool(it->pObject->ClassID); - if ( !tool->IsEditable() ) + ESceneToolBase *tool = Scene->GetTool(it->pObject->ClassID); + if (!tool->IsEditable()) { - if (bMsg) Msg("!.Can't detach object '%s'. Target '%s' in readonly mode.",it->pObject->Name, tool->ClassDesc()); - res = false; + if (bMsg) + Msg("!.Can't detach object '%s'. Target '%s' in readonly mode.", it->pObject->Name, tool->ClassDesc()); + res = false; } } return res; } -void CGroupObject::GroupObjects(ObjectList& lst) +void CGroupObject::GroupObjects(ObjectList &lst) { - R_ASSERT(lst.size()); - for (ObjectIt it=lst.begin(); it!=lst.end(); ++it) + R_ASSERT(lst.size()); + for (ObjectIt it = lst.begin(); it!=lst.end(); ++it) + { + if ((*it)->m_CO_Flags.test(flObjectInGroup)) { - if((*it)->m_CO_Flags.test(flObjectInGroup) ) - { - ELog.DlgMsg (mtInformation,"object[%s] already in group", (*it)->Name); - continue; - } - LL_AppendObject(*it); + ELog.DlgMsg(mtInformation, "object[%s] already in group", (*it)->Name); + continue; } - if(m_ObjectsInGroup.size()) - UpdatePivot(0,false); + LL_AppendObject(*it); + } + if (m_ObjectsInGroup.size()) + UpdatePivot(0, false); } void CGroupObject::UngroupObjects() { - for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) - it->pObject->OnDetach (); + for (ObjectsInGroup::iterator it = m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) + it->pObject->OnDetach(); m_ObjectsInGroup.clear(); } diff --git a/src/editors/LevelEditor/Edit/GroupObjectUtils.cpp b/src/editors/LevelEditor/Edit/GroupObjectUtils.cpp index 50a0d44b16f..d2413b12294 100644 --- a/src/editors/LevelEditor/Edit/GroupObjectUtils.cpp +++ b/src/editors/LevelEditor/Edit/GroupObjectUtils.cpp @@ -2,7 +2,7 @@ #pragma hdrstop #include "GroupObject.h" -#include "../../ecore/editor/D3DUtils.h" +#include "editors/ECore/Editor/D3DUtils.h" static const float EMPTY_GROUP_SIZE = 0.5f; diff --git a/src/editors/LevelEditor/Edit/LevelPreferences.cpp b/src/editors/LevelEditor/Edit/LevelPreferences.cpp index 984791080a1..61635e95433 100644 --- a/src/editors/LevelEditor/Edit/LevelPreferences.cpp +++ b/src/editors/LevelEditor/Edit/LevelPreferences.cpp @@ -5,56 +5,62 @@ #include "LevelPreferences.h" #include "ESceneCustomMTools.h" #include "scene.h" -#include "ui_levelmain.h" -#include "ui_leveltools.h" +#include "UI_LevelMain.h" +#include "UI_LevelTools.h" + //--------------------------------------------------------------------------- -void CLevelPreferences::Load(CInifile* I) +void CLevelPreferences::Load(CInifile *I) { - inherited::Load (I); - SceneToolsMapPairIt _I = Scene->FirstTool(); - SceneToolsMapPairIt _E = Scene->LastTool(); + inherited::Load(I); + SceneToolsMapPairIt _I = Scene->FirstTool(); + SceneToolsMapPairIt _E = Scene->LastTool(); for (; _I!=_E; _I++) if (_I->second&&(_I->first!=OBJCLASS_DUMMY)) - _I->second->m_EditFlags.flags = R_U32_SAFE("targets",_I->second->ClassName(),_I->second->m_EditFlags.flags); + _I->second->m_EditFlags.flags = R_U32_SAFE("targets", _I->second->ClassName(), _I->second->m_EditFlags.flags); } -void CLevelPreferences::Save(CInifile* I) +void CLevelPreferences::Save(CInifile *I) { - inherited::Save (I); - SceneToolsMapPairIt _I = Scene->FirstTool(); - SceneToolsMapPairIt _E = Scene->LastTool(); + inherited::Save(I); + SceneToolsMapPairIt _I = Scene->FirstTool(); + SceneToolsMapPairIt _E = Scene->LastTool(); for (; _I!=_E; _I++) - if (_I->second&&(_I->first!=OBJCLASS_DUMMY)) I->w_u32 ("targets",_I->second->ClassName(),_I->second->m_EditFlags.get()); + if (_I->second&&(_I->first!=OBJCLASS_DUMMY)) + I->w_u32("targets", _I->second->ClassName(), _I->second->m_EditFlags.get()); } -void CLevelPreferences::OnEnabledChange(PropValue* prop) +void CLevelPreferences::OnEnabledChange(PropValue *prop) { - ESceneToolBase* M = Scene->GetTool(prop->tag); VERIFY(M); - ExecCommand (COMMAND_ENABLE_TARGET,prop->tag,M->IsEnabled()); + ESceneToolBase *M = Scene->GetTool(prop->tag); + VERIFY(M); + ExecCommand(COMMAND_ENABLE_TARGET, prop->tag, M->IsEnabled()); } -void CLevelPreferences::OnReadonlyChange(PropValue* prop) +void CLevelPreferences::OnReadonlyChange(PropValue *prop) { - ESceneToolBase* M = Scene->GetTool(prop->tag); VERIFY(M); - ExecCommand (COMMAND_READONLY_TARGET,prop->tag,M->IsForceReadonly()); + ESceneToolBase *M = Scene->GetTool(prop->tag); + VERIFY(M); + ExecCommand(COMMAND_READONLY_TARGET, prop->tag, M->IsForceReadonly()); } -void CLevelPreferences::FillProp(PropItemVec& items) +void CLevelPreferences::FillProp(PropItemVec &items) { - inherited::FillProp (items); - SceneToolsMapPairIt _I = Scene->FirstTool(); - SceneToolsMapPairIt _E = Scene->LastTool(); + inherited::FillProp(items); + SceneToolsMapPairIt _I = Scene->FirstTool(); + SceneToolsMapPairIt _E = Scene->LastTool(); for (; _I!=_E; _I++) - if (_I->second&&(_I->first!=OBJCLASS_DUMMY)){ - if (_I->second->AllowEnabling()){ - PropValue* V = PHelper().CreateFlag32(items,PrepareKey("Scene\\Targets\\Enable",_I->second->ClassDesc()), &_I->second->m_EditFlags, ESceneToolBase::flEnable); - V->tag = _I->second->ClassID; - V->OnChangeEvent.bind(this,&CLevelPreferences::OnEnabledChange); + if (_I->second&&(_I->first!=OBJCLASS_DUMMY)) + { + if (_I->second->AllowEnabling()) + { + PropValue *V = PHelper().CreateFlag32(items, PrepareKey("Scene\\Targets\\Enable", _I->second->ClassDesc()), &_I->second->m_EditFlags, ESceneToolBase::flEnable); + V->tag = _I->second->ClassID; + V->OnChangeEvent.bind(this, &CLevelPreferences::OnEnabledChange); } - PropValue* V = PHelper().CreateFlag32(items,PrepareKey("Scene\\Targets\\Read Only",_I->second->ClassDesc()), &_I->second->m_EditFlags, ESceneToolBase::flForceReadonly); - V->tag = _I->second->ClassID; - V->OnChangeEvent.bind(this,&CLevelPreferences::OnReadonlyChange); + PropValue *V = PHelper().CreateFlag32(items, PrepareKey("Scene\\Targets\\Read Only", _I->second->ClassDesc()), &_I->second->m_EditFlags, ESceneToolBase::flForceReadonly); + V->tag = _I->second->ClassID; + V->OnChangeEvent.bind(this, &CLevelPreferences::OnReadonlyChange); } } diff --git a/src/editors/LevelEditor/Edit/LevelPreferences.h b/src/editors/LevelEditor/Edit/LevelPreferences.h index 3280b66c75c..0c34b0b897f 100644 --- a/src/editors/LevelEditor/Edit/LevelPreferences.h +++ b/src/editors/LevelEditor/Edit/LevelPreferences.h @@ -2,18 +2,20 @@ #ifndef LevelPreferencesH #define LevelPreferencesH -#include "../ECore/Editor/EditorPreferences.h" +#include "editors/ECore/Editor/EditorPreferences.h" class CLevelPreferences: public CCustomPreferences { - typedef CCustomPreferences inherited; - void __stdcall OnEnabledChange (PropValue* prop); - void __stdcall OnReadonlyChange (PropValue* prop); + typedef CCustomPreferences inherited; + void __stdcall OnEnabledChange(PropValue *prop); + void __stdcall OnReadonlyChange(PropValue *prop); protected: - virtual void Load (CInifile*); - virtual void Save (CInifile*); + virtual void Load(CInifile *); + virtual void Save(CInifile *); public: - virtual void FillProp (PropItemVec& items); + virtual void FillProp(PropItemVec &items); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/SceneIO.cpp b/src/editors/LevelEditor/Edit/SceneIO.cpp index 84d90b37f57..0af7591cb7d 100644 --- a/src/editors/LevelEditor/Edit/SceneIO.cpp +++ b/src/editors/LevelEditor/Edit/SceneIO.cpp @@ -6,208 +6,214 @@ #pragma hdrstop #include "scene.h" -#include "../ECore/Editor/ui_main.h" -#include "ui_leveltools.h" +#include "editors/ECore/Editor/ui_main.h" +#include "UI_LevelTools.h" #include "CustomObject.h" #include "ESceneObjectTools.h" #include "SceneObject.h" -#include "../ECore/Editor/ExportObjectOGF.h" +#include "editors/ECore/Editor/ExportObjectOGF.h" #include "Builder.h" #include "SpawnPoint.h" // file: SceneChunks.h -#define CURRENT_FILE_VERSION 0x00000005 +#define CURRENT_FILE_VERSION 0x00000005 -#define CURRENT_LEVELOP_VERSION 0x0000000C +#define CURRENT_LEVELOP_VERSION 0x0000000C //0x00000008 -#define CURRENT_LEVELOP_BP_VERSION 0x00000009 -#define CURRENT_ENV_VERSION 0x00000007 +#define CURRENT_LEVELOP_BP_VERSION 0x00000009 +#define CURRENT_ENV_VERSION 0x00000007 -#define CHUNK_VERSION 0x9df3 -#define CHUNK_OBJECT_CLASS 0x7703 -#define CHUNK_OBJECT_LIST 0x7708 -#define CHUNK_CAMERA 0x7709 -#define CHUNK_SNAPOBJECTS 0x7710 -#define CHUNK_LEVELOP 0x7711 -#define CHUNK_OBJECT_COUNT 0x7712 -#define CHUNK_LEVEL_TAG 0x7777 +#define CHUNK_VERSION 0x9df3 +#define CHUNK_OBJECT_CLASS 0x7703 +#define CHUNK_OBJECT_LIST 0x7708 +#define CHUNK_CAMERA 0x7709 +#define CHUNK_SNAPOBJECTS 0x7710 +#define CHUNK_LEVELOP 0x7711 +#define CHUNK_OBJECT_COUNT 0x7712 +#define CHUNK_LEVEL_TAG 0x7777 -#define CHUNK_TOOLS_GUID 0x7000 -#define CHUNK_TOOLS_DATA 0x8000 +#define CHUNK_TOOLS_GUID 0x7000 +#define CHUNK_TOOLS_DATA 0x8000 // level options -#define CHUNK_LO_VERSION 0x7801 -#define CHUNK_LO_NAMES 0x7802 -#define CHUNK_LO_BOP 0x7803 -#define CHUNK_LO_PREFIX 0x7804 -#define CHUNK_LO_BP_VERSION 0x7849 -#define CHUNK_BUILD_PARAMS 0x7850 -#define CHUNK_LIGHT_QUALITY 0x7851 -#define CHUNK_MAP_USAGE 0x7852 -#define CHUNK_LO_MAP_VER 0x7853 +#define CHUNK_LO_VERSION 0x7801 +#define CHUNK_LO_NAMES 0x7802 +#define CHUNK_LO_BOP 0x7803 +#define CHUNK_LO_PREFIX 0x7804 +#define CHUNK_LO_BP_VERSION 0x7849 +#define CHUNK_BUILD_PARAMS 0x7850 +#define CHUNK_LIGHT_QUALITY 0x7851 +#define CHUNK_MAP_USAGE 0x7852 +#define CHUNK_LO_MAP_VER 0x7853 + //------------------------------------------------------------------------------------------------ // Level Options //------------------------------------------------------------------------------------------------ -void st_LevelOptions::SaveLTX( CInifile& ini ) +void st_LevelOptions::SaveLTX(CInifile &ini) { - LPCSTR section = "level_options"; - ini.w_u32 (section, "version", CURRENT_LEVELOP_VERSION); + LPCSTR section = "level_options"; + ini.w_u32(section, "version", CURRENT_LEVELOP_VERSION); - ini.w_string (section, "level_path", m_FNLevelPath.c_str()); - ini.w_string (section, "level_prefix", m_LevelPrefix.c_str()); - xr_string s = "\""; - s += m_BOPText.c_str(); - s += "\""; - ini.w_string (section, "bop", s.c_str()); - ini.w_string (section, "map_version", m_map_version.c_str()); + ini.w_string(section, "level_path", m_FNLevelPath.c_str()); + ini.w_string(section, "level_prefix", m_LevelPrefix.c_str()); + xr_string s = "\""; + s += m_BOPText.c_str(); + s += "\""; + ini.w_string(section, "bop", s.c_str()); + ini.w_string(section, "map_version", m_map_version.c_str()); - ini.w_u32 (section, "version_bp", CURRENT_LEVELOP_BP_VERSION); + ini.w_u32(section, "version_bp", CURRENT_LEVELOP_BP_VERSION); - m_BuildParams.SaveLTX (ini); + m_BuildParams.SaveLTX(ini); - ini.w_u8 (section, "light_hemi_quality", m_LightHemiQuality ); - ini.w_u8 (section, "light_sun_quality", m_LightSunQuality ); + ini.w_u8(section, "light_hemi_quality", m_LightHemiQuality); + ini.w_u8(section, "light_sun_quality", m_LightSunQuality); - m_mapUsage.SaveLTX(ini,section); + m_mapUsage.SaveLTX(ini, section); } -void st_LevelOptions::Save( IWriter& F ) +void st_LevelOptions::Save(IWriter &F) { - F.open_chunk( CHUNK_LO_VERSION ); - F.w_u32 ( CURRENT_LEVELOP_VERSION ); + F.open_chunk(CHUNK_LO_VERSION); + F.w_u32(CURRENT_LEVELOP_VERSION); F.close_chunk(); - F.open_chunk( CHUNK_LO_NAMES ); - F.w_stringZ ( m_FNLevelPath.size()?m_FNLevelPath.c_str():"" ); + F.open_chunk(CHUNK_LO_NAMES); + F.w_stringZ(m_FNLevelPath.size() ? m_FNLevelPath.c_str() : ""); F.close_chunk(); - F.open_chunk( CHUNK_LO_PREFIX ); - F.w_stringZ ( m_LevelPrefix.size()?m_LevelPrefix.c_str():""); + F.open_chunk(CHUNK_LO_PREFIX); + F.w_stringZ(m_LevelPrefix.size() ? m_LevelPrefix.c_str() : ""); F.close_chunk(); - F.open_chunk( CHUNK_LO_BOP ); - F.w_stringZ ( m_BOPText.size()?m_BOPText.c_str():"" ); + F.open_chunk(CHUNK_LO_BOP); + F.w_stringZ(m_BOPText.size() ? m_BOPText.c_str() : ""); F.close_chunk(); - F.open_chunk( CHUNK_LO_MAP_VER ); - F.w_stringZ ( m_map_version.size()?m_map_version.c_str():"1.0" ); + F.open_chunk(CHUNK_LO_MAP_VER); + F.w_stringZ(m_map_version.size() ? m_map_version.c_str() : "1.0"); F.close_chunk(); - F.open_chunk( CHUNK_LO_BP_VERSION ); - F.w_u32 ( CURRENT_LEVELOP_BP_VERSION ); + F.open_chunk(CHUNK_LO_BP_VERSION); + F.w_u32(CURRENT_LEVELOP_BP_VERSION); F.close_chunk(); - F.open_chunk( CHUNK_BUILD_PARAMS ); - F.w ( &m_BuildParams, sizeof(m_BuildParams) ); + F.open_chunk(CHUNK_BUILD_PARAMS); + F.w(&m_BuildParams, sizeof(m_BuildParams)); F.close_chunk(); - F.open_chunk( CHUNK_LIGHT_QUALITY ); - F.w_u8 ( m_LightHemiQuality ); - F.w_u8 ( m_LightSunQuality ); + F.open_chunk(CHUNK_LIGHT_QUALITY); + F.w_u8(m_LightHemiQuality); + F.w_u8(m_LightSunQuality); F.close_chunk(); - F.open_chunk( CHUNK_MAP_USAGE ); - F.w_u16 ( m_mapUsage.m_GameType.get() ); + F.open_chunk(CHUNK_MAP_USAGE); + F.w_u16(m_mapUsage.m_GameType.get()); F.close_chunk(); } -void st_LevelOptions::ReadLTX(CInifile& ini) +void st_LevelOptions::ReadLTX(CInifile &ini) { - LPCSTR section = "level_options"; + LPCSTR section = "level_options"; - u32 vers_op = ini.r_u32(section, "version"); - if( vers_op < 0x00000008 ) + u32 vers_op = ini.r_u32(section, "version"); + if (vers_op<0x00000008) { - ELog.DlgMsg( mtError, "Skipping bad version of level options." ); + ELog.DlgMsg(mtError, "Skipping bad version of level options."); return; } - m_FNLevelPath = ini.r_string (section, "level_path"); - m_LevelPrefix = ini.r_string (section, "level_prefix"); - m_BOPText = ini.r_string_wb (section, "bop"); + m_FNLevelPath = ini.r_string(section, "level_path"); + m_LevelPrefix = ini.r_string(section, "level_prefix"); + m_BOPText = ini.r_string_wb(section, "bop"); - if(vers_op > 0x0000000B) - m_map_version = ini.r_string (section, "map_version"); + if (vers_op>0x0000000B) + m_map_version = ini.r_string(section, "map_version"); m_BuildParams.LoadLTX(ini); - m_LightHemiQuality = ini.r_u8(section, "light_hemi_quality" ); - m_LightSunQuality = ini.r_u8(section, "light_sun_quality" ); + m_LightHemiQuality = ini.r_u8(section, "light_hemi_quality"); + m_LightSunQuality = ini.r_u8(section, "light_sun_quality"); - m_mapUsage.SetDefaults (); - if(vers_op > 0x0000000A) - { - m_mapUsage.LoadLTX (ini,section,false); - }else + m_mapUsage.SetDefaults(); + if (vers_op>0x0000000A) { - - m_mapUsage.m_GameType.set (eGameIDDeathmatch , ini.r_s32(section, "usage_deathmatch")); - m_mapUsage.m_GameType.set (eGameIDTeamDeathmatch, ini.r_s32(section, "usage_teamdeathmatch")); - m_mapUsage.m_GameType.set (eGameIDArtefactHunt, ini.r_s32(section, "usage_artefacthunt")); + m_mapUsage.LoadLTX(ini, section, false); + } + else + { + m_mapUsage.m_GameType.set(eGameIDDeathmatch, ini.r_s32(section, "usage_deathmatch")); + m_mapUsage.m_GameType.set(eGameIDTeamDeathmatch, ini.r_s32(section, "usage_teamdeathmatch")); + m_mapUsage.m_GameType.set(eGameIDArtefactHunt, ini.r_s32(section, "usage_artefacthunt")); - if(vers_op > 0x00000008) - { - m_mapUsage.m_GameType.set (eGameIDCaptureTheArtefact, ini.r_s32(section, "usage_captretheartefact")); + if (vers_op>0x00000008) + { + m_mapUsage.m_GameType.set(eGameIDCaptureTheArtefact, ini.r_s32(section, "usage_captretheartefact")); - m_mapUsage.m_GameType.set (eGameIDTeamDominationZone, ini.r_s32(section, "usage_team_domination_zone")); - if(vers_op==0x00000009) - m_mapUsage.m_GameType.set(eGameIDDominationZone, ini.r_s32(section, "domination_zone")); - else - m_mapUsage.m_GameType.set(eGameIDDominationZone, ini.r_s32(section, "usage_domination_zone")); - } + m_mapUsage.m_GameType.set(eGameIDTeamDominationZone, ini.r_s32(section, "usage_team_domination_zone")); + if (vers_op==0x00000009) + m_mapUsage.m_GameType.set(eGameIDDominationZone, ini.r_s32(section, "domination_zone")); + else + m_mapUsage.m_GameType.set(eGameIDDominationZone, ini.r_s32(section, "usage_domination_zone")); + } } } -void st_LevelOptions::Read(IReader& F) +void st_LevelOptions::Read(IReader &F) { - R_ASSERT(F.find_chunk(CHUNK_LO_VERSION)); - DWORD vers = F.r_u32( ); - if( vers < 0x00000008 ) + R_ASSERT(F.find_chunk(CHUNK_LO_VERSION)); + DWORD vers = F.r_u32(); + if (vers<0x00000008) { - ELog.DlgMsg( mtError, "Skipping bad version of level options." ); + ELog.DlgMsg(mtError, "Skipping bad version of level options."); return; } R_ASSERT(F.find_chunk(CHUNK_LO_NAMES)); - F.r_stringZ (m_FNLevelPath); + F.r_stringZ(m_FNLevelPath); - if (F.find_chunk(CHUNK_LO_PREFIX)) F.r_stringZ (m_LevelPrefix); + if (F.find_chunk(CHUNK_LO_PREFIX)) + F.r_stringZ(m_LevelPrefix); R_ASSERT(F.find_chunk(CHUNK_LO_BOP)); - F.r_stringZ (m_BOPText); + F.r_stringZ(m_BOPText); if (F.find_chunk(CHUNK_LO_MAP_VER)) - F.r_stringZ (m_map_version); + F.r_stringZ(m_map_version); vers = 0; if (F.find_chunk(CHUNK_LO_BP_VERSION)) - vers = F.r_u32( ); - - if (CURRENT_LEVELOP_BP_VERSION==vers){ - if (F.find_chunk(CHUNK_BUILD_PARAMS)) - F.r(&m_BuildParams, sizeof(m_BuildParams)); - }else{ - ELog.DlgMsg (mtError, "Skipping bad version of build params."); - m_BuildParams.Init(); + vers = F.r_u32(); + + if (CURRENT_LEVELOP_BP_VERSION==vers) + { + if (F.find_chunk(CHUNK_BUILD_PARAMS)) + F.r(&m_BuildParams, sizeof(m_BuildParams)); + } + else + { + ELog.DlgMsg(mtError, "Skipping bad version of build params."); + m_BuildParams.Init(); } if (F.find_chunk(CHUNK_LIGHT_QUALITY)) { - m_LightHemiQuality = F.r_u8(); - m_LightSunQuality = F.r_u8(); + m_LightHemiQuality = F.r_u8(); + m_LightSunQuality = F.r_u8(); } if (F.find_chunk(CHUNK_MAP_USAGE)) { - if(vers > 0x00000008) + if (vers>0x00000008) { - m_mapUsage.m_GameType.assign (F.r_u16()); - }else + m_mapUsage.m_GameType.assign(F.r_u16()); + } + else { - m_mapUsage.m_GameType.zero (); - m_mapUsage.m_GameType.set (eGameIDDeathmatch , F.r_s32()); - m_mapUsage.m_GameType.set (eGameIDTeamDeathmatch, F.r_s32()); - m_mapUsage.m_GameType.set (eGameIDArtefactHunt, F.r_s32()); + m_mapUsage.m_GameType.zero(); + m_mapUsage.m_GameType.set(eGameIDDeathmatch, F.r_s32()); + m_mapUsage.m_GameType.set(eGameIDTeamDeathmatch, F.r_s32()); + m_mapUsage.m_GameType.set(eGameIDArtefactHunt, F.r_s32()); } } } @@ -215,562 +221,577 @@ void st_LevelOptions::Read(IReader& F) //------------------------------------------------------------------------------------------------ // Scene //------------------------------------------------------------------------------------------------ -BOOL EScene::LoadLevelPartLTX(ESceneToolBase* M, LPCSTR mn) +BOOL EScene::LoadLevelPartLTX(ESceneToolBase *M, LPCSTR mn) { - string_path map_name; + string_path map_name; strcpy(map_name, mn); - - if(!M->can_use_inifile()) - return LoadLevelPart(M, map_name); - int fnidx=0; - while(FS.exist(map_name)) + if (!M->can_use_inifile()) + return LoadLevelPart(M, map_name); + + int fnidx = 0; + while (FS.exist(map_name)) { - IReader* R = FS.r_open (map_name); - VERIFY (R); - char ch; - R->r (&ch,sizeof(ch)); + IReader *R = FS.r_open(map_name); + VERIFY(R); + char ch; + R->r(&ch, sizeof(ch)); bool b_is_inifile = (ch=='['); - FS.r_close (R); + FS.r_close(R); - if(!b_is_inifile) + if (!b_is_inifile) return LoadLevelPart(M, map_name); - M->m_EditFlags.set(ESceneToolBase::flReadonly,FALSE); + M->m_EditFlags.set(ESceneToolBase::flReadonly, FALSE); - CInifile ini(map_name); + CInifile ini(map_name); // check level part GUID - xrGUID guid; - guid.LoadLTX (ini, "guid", "guid"); + xrGUID guid; + guid.LoadLTX(ini, "guid", "guid"); if (guid!=m_GUID) { - ELog.DlgMsg (mtError,"Skipping invalid version of level part: '%s\\%s.part'",EFS.ExtractFileName(map_name).c_str(),M->ClassName()); - return FALSE; + ELog.DlgMsg(mtError, "Skipping invalid version of level part: '%s\\%s.part'", EFS.ExtractFileName(map_name).c_str(), M->ClassName()); + return FALSE; } // read data - M->LoadLTX (ini); + M->LoadLTX(ini); - ++fnidx; + ++fnidx; sprintf(map_name, "%s%d", mn, fnidx); } - return TRUE; + return TRUE; } -BOOL EScene::LoadLevelPart(ESceneToolBase* M, LPCSTR map_name) +BOOL EScene::LoadLevelPart(ESceneToolBase *M, LPCSTR map_name) { - if(M->can_use_inifile()) - return LoadLevelPartLTX(M, map_name); - - if (FS.exist(map_name)) + if (M->can_use_inifile()) + return LoadLevelPartLTX(M, map_name); + + if (FS.exist(map_name)) { - // check locking - M->m_EditFlags.set(ESceneToolBase::flReadonly,FALSE); + // check locking + M->m_EditFlags.set(ESceneToolBase::flReadonly, FALSE); - IReader* R = FS.r_open (map_name); - VERIFY (R); - // check level part GUID - R_ASSERT (R->find_chunk (CHUNK_TOOLS_GUID)); - xrGUID guid; - R->r (&guid,sizeof(guid)); + IReader *R = FS.r_open(map_name); + VERIFY(R); + // check level part GUID + R_ASSERT(R->find_chunk(CHUNK_TOOLS_GUID)); + xrGUID guid; + R->r(&guid, sizeof(guid)); if (guid!=m_GUID) { - ELog.DlgMsg (mtError,"Skipping invalid version of level part: '%s\\%s.part'",EFS.ExtractFileName(map_name).c_str(),M->ClassName()); - FS.r_close (R); - return FALSE; + ELog.DlgMsg(mtError, "Skipping invalid version of level part: '%s\\%s.part'", EFS.ExtractFileName(map_name).c_str(), M->ClassName()); + FS.r_close(R); + return FALSE; } // read data - IReader* chunk = R->open_chunk (CHUNK_TOOLS_DATA+M->ClassID); - if(chunk!=NULL) + IReader *chunk = R->open_chunk(CHUNK_TOOLS_DATA+M->ClassID); + if (chunk!=NULL) { - M->LoadStream (*chunk); - chunk->close (); - }else + M->LoadStream(*chunk); + chunk->close(); + } + else { - ELog.DlgMsg (mtError,"Skipping corrupted version of level part: '%s\\%s.part'",EFS.ExtractFileName(map_name).c_str(),M->ClassName()); - FS.r_close (R); - return FALSE; + ELog.DlgMsg(mtError, "Skipping corrupted version of level part: '%s\\%s.part'", EFS.ExtractFileName(map_name).c_str(), M->ClassName()); + FS.r_close(R); + return FALSE; } //success - FS.r_close (R); - return TRUE; + FS.r_close(R); + return TRUE; } - return TRUE; + return TRUE; } BOOL EScene::LoadLevelPart(LPCSTR map_name, ObjClassID cls) { - xr_string pn = LevelPartName(map_name,cls); - if (LoadLevelPart(GetTool(cls),pn.c_str())) - return TRUE; + xr_string pn = LevelPartName(map_name, cls); + if (LoadLevelPart(GetTool(cls), pn.c_str())) + return TRUE; else - return FALSE; + return FALSE; } -BOOL EScene::UnloadLevelPart(ESceneToolBase* M) +BOOL EScene::UnloadLevelPart(ESceneToolBase *M) { - M->Clear (); - return TRUE; + M->Clear(); + return TRUE; } BOOL EScene::UnloadLevelPart(LPCSTR map_name, ObjClassID cls) { - xr_string pn = LevelPartName(map_name,cls); + xr_string pn = LevelPartName(map_name, cls); if (UnloadLevelPart(GetTool(cls))) - return TRUE; + return TRUE; else - return FALSE; + return FALSE; } xr_string EScene::LevelPartPath(LPCSTR full_name) { - return EFS.ExtractFilePath(full_name)+EFS.ExtractFileName(full_name)+"\\"; + return EFS.ExtractFilePath(full_name)+EFS.ExtractFileName(full_name)+"\\"; } xr_string EScene::LevelPartName(LPCSTR map_name, ObjClassID cls) { - return LevelPartPath(map_name)+GetTool(cls)->ClassName() + ".part"; + return LevelPartPath(map_name)+GetTool(cls)->ClassName()+".part"; } void EScene::SaveLTX(LPCSTR map_name, bool bForUndo, bool bForceSaveAll) { - VERIFY (map_name); - R_ASSERT (!bForUndo); + VERIFY(map_name); + R_ASSERT(!bForUndo); - CTimer T; - T.Start (); - xr_string full_name; - full_name = map_name; - - xr_string part_prefix; + CTimer T; + T.Start(); + xr_string full_name; + full_name = map_name; - bool bSaveMain = true; - - if (!bForUndo) + xr_string part_prefix; + + bool bSaveMain = true; + + if (!bForUndo) { if (bSaveMain) { - EFS.MarkFile (full_name.c_str(),true); + EFS.MarkFile(full_name.c_str(), true); } - part_prefix = LevelPartPath(full_name.c_str()); + part_prefix = LevelPartPath(full_name.c_str()); } - - CInifile ini(full_name.c_str(),FALSE,FALSE,TRUE); + + CInifile ini(full_name.c_str(), FALSE, FALSE, TRUE); if (bSaveMain) { - ini.w_u32 ("version","value",CURRENT_FILE_VERSION); + ini.w_u32("version", "value",CURRENT_FILE_VERSION); - m_LevelOp.SaveLTX (ini); + m_LevelOp.SaveLTX(ini); - m_GUID.SaveLTX (ini,"guid","guid"); + m_GUID.SaveLTX(ini, "guid", "guid"); - ini.w_string ("level_tag","owner",m_OwnerName.c_str()); - ini.w_u32 ("level_tag","create_time",m_CreateTime); + ini.w_string("level_tag", "owner", m_OwnerName.c_str()); + ini.w_u32("level_tag", "create_time", m_CreateTime); - ini.w_fvector3 ("camera","hpb",EDevice.m_Camera.GetHPB()); - ini.w_fvector3 ("camera","pos",EDevice.m_Camera.GetPosition()); + ini.w_fvector3("camera", "hpb", EDevice.m_Camera.GetHPB()); + ini.w_fvector3("camera", "pos", EDevice.m_Camera.GetPosition()); - for(ObjectIt SO=m_ESO_SnapObjects.begin(); SO!=m_ESO_SnapObjects.end(); ++SO) + for (ObjectIt SO = m_ESO_SnapObjects.begin(); SO!=m_ESO_SnapObjects.end(); ++SO) { - ini.w_string ("snap_objects",(*SO)->Name,NULL); + ini.w_string("snap_objects", (*SO)->Name, NULL); } } - m_SaveCache.clear (); + m_SaveCache.clear(); SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { - if ( (_I->first!=OBJCLASS_DUMMY) && - _I->second && - _I->second->IsEnabled() && - _I->second->IsEditable() - ) + if ((_I->first!=OBJCLASS_DUMMY)&& + _I->second&& + _I->second->IsEnabled()&& + _I->second->IsEditable() + ) { if (bForUndo) { - if (_I->second->IsNeedSave()) - _I->second->SaveStream (m_SaveCache); - }else + if (_I->second->IsNeedSave()) + _I->second->SaveStream(m_SaveCache); + } + else { - // !ForUndo - xr_string part_name = part_prefix + _I->second->ClassName() + ".part"; - if(_I->second->can_use_inifile()) - { - EFS.MarkFile (part_name.c_str(),true); - SaveToolLTX (_I->second->ClassID, part_name.c_str()); - } //can_use_ini_file - else - { - _I->second->SaveStream (m_SaveCache); - - EFS.MarkFile (part_name.c_str(),true); + // !ForUndo + xr_string part_name = part_prefix+_I->second->ClassName()+".part"; + if (_I->second->can_use_inifile()) + { + EFS.MarkFile(part_name.c_str(), true); + SaveToolLTX(_I->second->ClassID, part_name.c_str()); + } //can_use_ini_file + else + { + _I->second->SaveStream(m_SaveCache); - IWriter* FF = FS.w_open (part_name.c_str()); - R_ASSERT (FF); - FF->open_chunk (CHUNK_TOOLS_GUID); - FF->w (&m_GUID,sizeof(m_GUID)); - FF->close_chunk (); + EFS.MarkFile(part_name.c_str(), true); - FF->open_chunk (CHUNK_TOOLS_DATA+_I->first); - FF->w (m_SaveCache.pointer(),m_SaveCache.size()); - FF->close_chunk (); + IWriter *FF = FS.w_open(part_name.c_str()); + R_ASSERT(FF); + FF->open_chunk(CHUNK_TOOLS_GUID); + FF->w(&m_GUID, sizeof(m_GUID)); + FF->close_chunk(); - FS.w_close (FF); + FF->open_chunk(CHUNK_TOOLS_DATA+_I->first); + FF->w(m_SaveCache.pointer(), m_SaveCache.size()); + FF->close_chunk(); - }// ! can_use_ini_file + FS.w_close(FF); + }// ! can_use_ini_file } - m_SaveCache.clear (); + m_SaveCache.clear(); } } - - if (!bForUndo) + + if (!bForUndo) { - m_RTFlags.set (flRT_Unsaved,FALSE); - Msg ("Saving time: %3.2f sec",T.GetElapsed_sec()); + m_RTFlags.set(flRT_Unsaved, FALSE); + Msg("Saving time: %3.2f sec", T.GetElapsed_sec()); } } + //-------------------------------------------------------------------------------------------------- void EScene::SaveToolLTX(ObjClassID clsid, LPCSTR fn) { - ESceneToolBase* tool = GetTool(clsid); - int fc = tool->SaveFileCount(); - if(fc==1) + ESceneToolBase*tool = GetTool(clsid); + int fc = tool->SaveFileCount(); + if (fc==1) { - CInifile ini_part (fn, FALSE, FALSE, FALSE); - tool->SaveLTX (ini_part, 0); - m_GUID.SaveLTX (ini_part,"guid","guid"); - ini_part.save_as (); - }else + CInifile ini_part(fn, FALSE, FALSE, FALSE); + tool->SaveLTX(ini_part, 0); + m_GUID.SaveLTX(ini_part, "guid", "guid"); + ini_part.save_as(); + } + else { - for(int i=0; iSaveLTX (ini_part, i); - m_GUID.SaveLTX (ini_part,"guid","guid"); - ini_part.save_as (); + CInifile ini_part(filename, FALSE, FALSE, FALSE); + tool->SaveLTX(ini_part, i); + m_GUID.SaveLTX(ini_part, "guid", "guid"); + ini_part.save_as(); } } } bool EScene::LoadToolLTX(ObjClassID clsid, LPCSTR fn) { - ESceneToolBase* tool = GetTool(clsid); - tool->Clear (true); - bool res = LoadLevelPartLTX(tool, fn); - return res; + ESceneToolBase*tool = GetTool(clsid); + tool->Clear(true); + bool res = LoadLevelPartLTX(tool, fn); + return res; } void EScene::Save(LPCSTR map_name, bool bUndo, bool bForceSaveAll) { - R_ASSERT (bUndo); - VERIFY (map_name); + R_ASSERT(bUndo); + VERIFY(map_name); - CTimer T; - T.Start (); - xr_string full_name; - full_name = map_name; - - xr_string part_prefix; + CTimer T; + T.Start(); + xr_string full_name; + full_name = map_name; - bool bSaveMain = true; - - IWriter* F = 0; + xr_string part_prefix; + + bool bSaveMain = true; + + IWriter *F = 0; if (bSaveMain) { - F = FS.w_open(full_name.c_str()); R_ASSERT(F); - - F->open_chunk (CHUNK_VERSION); - F->w_u32 (CURRENT_FILE_VERSION); - F->close_chunk (); - - F->open_chunk (CHUNK_LEVELOP); - m_LevelOp.Save (*F); - F->close_chunk (); - - F->open_chunk (CHUNK_TOOLS_GUID); - F->w (&m_GUID,sizeof(m_GUID)); - F->close_chunk (); - - F->open_chunk (CHUNK_LEVEL_TAG); - F->w_stringZ (m_OwnerName); - F->w (&m_CreateTime,sizeof(m_CreateTime)); - F->close_chunk (); - - F->open_chunk (CHUNK_CAMERA); - F->w_fvector3 (EDevice.m_Camera.GetHPB()); - F->w_fvector3 (EDevice.m_Camera.GetPosition()); - F->close_chunk (); + F = FS.w_open(full_name.c_str()); + R_ASSERT(F); + + F->open_chunk(CHUNK_VERSION); + F->w_u32(CURRENT_FILE_VERSION); + F->close_chunk(); - F->open_chunk (CHUNK_SNAPOBJECTS); - F->w_u32 (m_ESO_SnapObjects.size()); + F->open_chunk(CHUNK_LEVELOP); + m_LevelOp.Save(*F); + F->close_chunk(); - for(ObjectIt _F=m_ESO_SnapObjects.begin();_F!=m_ESO_SnapObjects.end();++_F) - F->w_stringZ ((*_F)->Name); + F->open_chunk(CHUNK_TOOLS_GUID); + F->w(&m_GUID, sizeof(m_GUID)); + F->close_chunk(); - F->close_chunk (); + F->open_chunk(CHUNK_LEVEL_TAG); + F->w_stringZ(m_OwnerName); + F->w(&m_CreateTime, sizeof(m_CreateTime)); + F->close_chunk(); + + F->open_chunk(CHUNK_CAMERA); + F->w_fvector3(EDevice.m_Camera.GetHPB()); + F->w_fvector3(EDevice.m_Camera.GetPosition()); + F->close_chunk(); + + F->open_chunk(CHUNK_SNAPOBJECTS); + F->w_u32(m_ESO_SnapObjects.size()); + + for (ObjectIt _F = m_ESO_SnapObjects.begin(); _F!=m_ESO_SnapObjects.end(); ++_F) + F->w_stringZ((*_F)->Name); + + F->close_chunk(); } - m_SaveCache.clear (); + m_SaveCache.clear(); SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { - if ( (_I->first!=OBJCLASS_DUMMY) && - _I->second && - _I->second->IsEnabled() && - _I->second->IsEditable() && - (_I->second->IsChanged()||bForceSaveAll) ) + if ((_I->first!=OBJCLASS_DUMMY)&& + _I->second&& + _I->second->IsEnabled()&& + _I->second->IsEditable()&& + (_I->second->IsChanged()||bForceSaveAll)) { - if (_I->second->IsEnabled()&&_I->second->IsEditable()) { - if (_I->second->IsNeedSave()) + if (_I->second->IsNeedSave()) { - _I->second->SaveStream (m_SaveCache); - F->open_chunk (CHUNK_TOOLS_DATA+_I->first); - F->w (m_SaveCache.pointer(),m_SaveCache.size()); - F->close_chunk (); + _I->second->SaveStream(m_SaveCache); + F->open_chunk(CHUNK_TOOLS_DATA+_I->first); + F->w(m_SaveCache.pointer(), m_SaveCache.size()); + F->close_chunk(); } } - m_SaveCache.clear (); + m_SaveCache.clear(); } } - + // save data - if (bSaveMain) FS.w_close(F); + if (bSaveMain) + FS.w_close(F); } + //-------------------------------------------------------------------------------------------------- -void EScene::SaveObjectLTX(CCustomObject* O, LPCSTR sect_name, CInifile& ini) +void EScene::SaveObjectLTX(CCustomObject *O, LPCSTR sect_name, CInifile &ini) { - ini.w_u32 (sect_name,"clsid",O->ClassID); - O->SaveLTX (ini, sect_name); + ini.w_u32(sect_name, "clsid", O->ClassID); + O->SaveLTX(ini, sect_name); } -void EScene::SaveObjectStream( CCustomObject* O, IWriter& F ) +void EScene::SaveObjectStream(CCustomObject *O, IWriter &F) { - F.open_chunk (CHUNK_OBJECT_CLASS); - F.w_u32 (O->ClassID); - F.close_chunk (); - F.open_chunk (CHUNK_OBJECT_BODY); - O->SaveStream (F); - F.close_chunk (); + F.open_chunk(CHUNK_OBJECT_CLASS); + F.w_u32(O->ClassID); + F.close_chunk(); + F.open_chunk(CHUNK_OBJECT_BODY); + O->SaveStream(F); + F.close_chunk(); } + //-------------------------------------------------------------------------------------------------- -void EScene::SaveObjectsLTX(ObjectList& lst, LPCSTR sect_name_parent, LPCSTR sect_name_prefix, CInifile& ini) +void EScene::SaveObjectsLTX(ObjectList &lst, LPCSTR sect_name_parent, LPCSTR sect_name_prefix, CInifile &ini) { - u32 i = 0; - string256 buff; - for(ObjectIt _F = lst.begin(); _F!=lst.end(); ++_F, ++i) + u32 i = 0; + string256 buff; + for (ObjectIt _F = lst.begin(); _F!=lst.end(); ++_F,++i) { - sprintf (buff,"%s_%s_%d",sect_name_parent,sect_name_prefix,i); - SaveObjectLTX (*_F,buff,ini); + sprintf(buff, "%s_%s_%d", sect_name_parent, sect_name_prefix, i); + SaveObjectLTX(*_F, buff, ini); } - sprintf (buff,"%s_count",sect_name_prefix); - ini.w_u32 (sect_name_parent, buff, lst.size()); + sprintf(buff, "%s_count", sect_name_prefix); + ini.w_u32(sect_name_parent, buff, lst.size()); } -void EScene::SaveObjectsStream( ObjectList& lst, u32 chunk_id, IWriter& F ) +void EScene::SaveObjectsStream(ObjectList &lst, u32 chunk_id, IWriter &F) { - F.open_chunk (chunk_id); - int count = 0; - for(ObjectIt _F = lst.begin();_F!=lst.end();++_F) + F.open_chunk(chunk_id); + int count = 0; + for (ObjectIt _F = lst.begin(); _F!=lst.end(); ++_F) { - F.open_chunk (count); + F.open_chunk(count); ++count; - SaveObjectStream (*_F,F); - F.close_chunk (); + SaveObjectStream(*_F, F); + F.close_chunk(); } - F.close_chunk (); + F.close_chunk(); } + //-------------------------------------------------------------------------------------------------- -bool EScene::ReadObjectStream(IReader& F, CCustomObject*& O) +bool EScene::ReadObjectStream(IReader &F, CCustomObject *&O) { - ObjClassID clsid =OBJCLASS_DUMMY; - R_ASSERT (F.find_chunk(CHUNK_OBJECT_CLASS)); - clsid = ObjClassID(F.r_u32()); - O = GetOTool(clsid)->CreateObject(0,0); + ObjClassID clsid = OBJCLASS_DUMMY; + R_ASSERT(F.find_chunk(CHUNK_OBJECT_CLASS)); + clsid = ObjClassID(F.r_u32()); + O = GetOTool(clsid)->CreateObject(0, 0); - IReader* S = F.open_chunk(CHUNK_OBJECT_BODY); - R_ASSERT (S); - bool bRes = O->LoadStream(*S); - S->close (); + IReader *S = F.open_chunk(CHUNK_OBJECT_BODY); + R_ASSERT(S); + bool bRes = O->LoadStream(*S); + S->close(); - if (!bRes) - xr_delete (O); + if (!bRes) + xr_delete(O); - return bRes; + return bRes; } + //---------------------------------------------------- -bool EScene::ReadObjectLTX(CInifile& ini, LPCSTR sect_name, CCustomObject*& O) +bool EScene::ReadObjectLTX(CInifile &ini, LPCSTR sect_name, CCustomObject *&O) { - ObjClassID clsid = OBJCLASS_DUMMY; - clsid = ObjClassID(ini.r_u32(sect_name,"clsid")); - O = GetOTool(clsid)->CreateObject(0,0); + ObjClassID clsid = OBJCLASS_DUMMY; + clsid = ObjClassID(ini.r_u32(sect_name, "clsid")); + O = GetOTool(clsid)->CreateObject(0, 0); - bool bRes = O->LoadLTX(ini, sect_name); + bool bRes = O->LoadLTX(ini, sect_name); - if (!bRes) - xr_delete (O); + if (!bRes) + xr_delete(O); - return bRes; + return bRes; } #include "AppendObjectInfoForm.h" -bool EScene::ReadObjectsLTX(CInifile& ini, LPCSTR sect_name_parent, LPCSTR sect_name_prefix, TAppendObject on_append, SPBItem* pb) + +bool EScene::ReadObjectsLTX(CInifile &ini, LPCSTR sect_name_parent, LPCSTR sect_name_prefix, TAppendObject on_append, SPBItem *pb) { - string128 buff; - R_ASSERT (on_append); - sprintf (buff, "%s_count", sect_name_prefix); - u32 count = ini.r_u32(sect_name_parent, buff); - bool bRes = true; + string128 buff; + R_ASSERT(on_append); + sprintf(buff, "%s_count", sect_name_prefix); + u32 count = ini.r_u32(sect_name_parent, buff); + bool bRes = true; - for(u32 i=0; iName; - CCustomObject* existing = FindObjectByName(obj_name,obj->ClassID); - if(existing) + CCustomObject*existing = FindObjectByName(obj_name, obj->ClassID); + if (existing) { - - if(g_frmConflictLoadObject->m_result!=2 && g_frmConflictLoadObject->m_result!=4 && g_frmConflictLoadObject->m_result!=6) + if (g_frmConflictLoadObject->m_result!=2&&g_frmConflictLoadObject->m_result!=4&&g_frmConflictLoadObject->m_result!=6) { - g_frmConflictLoadObject->m_existing_object = existing; - g_frmConflictLoadObject->m_new_object = obj; - g_frmConflictLoadObject->Prepare (); - g_frmConflictLoadObject->ShowModal (); + g_frmConflictLoadObject->m_existing_object = existing; + g_frmConflictLoadObject->m_new_object = obj; + g_frmConflictLoadObject->Prepare(); + g_frmConflictLoadObject->ShowModal(); } - switch(g_frmConflictLoadObject->m_result) + switch (g_frmConflictLoadObject->m_result) { case 1: //Overwrite case 2: //Overwrite All { - bool res = RemoveObject (existing, true, true); - if(!res) + bool res = RemoveObject(existing, true, true); + if (!res) Msg("! RemoveObject [%s] failed", existing->Name); - else + else xr_delete(existing); - }break; + } + break; case 3: //Insert new case 4: //Insert new All { - string256 buf; - GenObjectName (obj->ClassID, buf, obj->Name); - obj->Name = buf; - }break; + string256 buf; + GenObjectName(obj->ClassID, buf, obj->Name); + obj->Name = buf; + } + break; case 0: //Cancel case 5: //Skip case 6: //Skip All { xr_delete(obj); - }break; + } + break; } //switch } //if exist - if (obj && !on_append(obj)) - xr_delete(obj);} - + if (obj&&!on_append(obj)) + xr_delete(obj); + } + else - bRes = false; + bRes = false; if (pb) - pb->Inc(); + pb->Inc(); } return bRes; } -bool EScene::ReadObjectsStream(IReader& F, u32 chunk_id, TAppendObject on_append, SPBItem* pb) +bool EScene::ReadObjectsStream(IReader &F, u32 chunk_id, TAppendObject on_append, SPBItem *pb) { - R_ASSERT (on_append); - bool bRes = true; - IReader* OBJ = F.open_chunk(chunk_id); + R_ASSERT(on_append); + bool bRes = true; + IReader *OBJ = F.open_chunk(chunk_id); if (OBJ) { - IReader* O = OBJ->open_chunk(0); - for (int count=1; O; ++count) + IReader *O = OBJ->open_chunk(0); + for (int count = 1; O; ++count) { - CCustomObject* obj =NULL; + CCustomObject*obj = NULL; if (ReadObjectStream(*O, obj)) { LPCSTR obj_name = obj->Name; - CCustomObject* existing = FindObjectByName(obj_name,obj->ClassID); - if(existing) + CCustomObject*existing = FindObjectByName(obj_name, obj->ClassID); + if (existing) { - if(g_frmConflictLoadObject->m_result!=2 && g_frmConflictLoadObject->m_result!=4 && g_frmConflictLoadObject->m_result!=6) + if (g_frmConflictLoadObject->m_result!=2&&g_frmConflictLoadObject->m_result!=4&&g_frmConflictLoadObject->m_result!=6) { - g_frmConflictLoadObject->m_existing_object = existing; - g_frmConflictLoadObject->m_new_object = obj; - g_frmConflictLoadObject->Prepare (); - g_frmConflictLoadObject->ShowModal (); + g_frmConflictLoadObject->m_existing_object = existing; + g_frmConflictLoadObject->m_new_object = obj; + g_frmConflictLoadObject->Prepare(); + g_frmConflictLoadObject->ShowModal(); } - switch(g_frmConflictLoadObject->m_result) + switch (g_frmConflictLoadObject->m_result) { - case 1: //Overwrite - case 2: //Overwrite All + case 1: //Overwrite + case 2: //Overwrite All { - bool res = RemoveObject (existing, true, true); - if(!res) - Msg("! RemoveObject [%s] failed", existing->Name); - else - xr_delete(existing); - }break; - case 3: //Insert new - case 4: //Insert new All + bool res = RemoveObject(existing, true, true); + if (!res) + Msg("! RemoveObject [%s] failed", existing->Name); + else + xr_delete(existing); + } + break; + case 3: //Insert new + case 4: //Insert new All { - string256 buf; - GenObjectName (obj->ClassID, buf, obj->Name); - obj->Name = buf; - }break; - case 0: //Cancel - case 5: //Skip - case 6: //Skip All + string256 buf; + GenObjectName(obj->ClassID, buf, obj->Name); + obj->Name = buf; + } + break; + case 0: //Cancel + case 5: //Skip + case 6: //Skip All { - xr_delete(obj); - }break; + xr_delete(obj); + } + break; } } - if (obj && !on_append(obj)) - xr_delete(obj);} + if (obj&&!on_append(obj)) + xr_delete(obj); + } else - bRes = false; + bRes = false; - O->close (); - O = OBJ->open_chunk(count); + O->close(); + O = OBJ->open_chunk(count); if (pb) - pb->Inc(); + pb->Inc(); } OBJ->close(); } return bRes; } -bool EScene::OnLoadAppendObject(CCustomObject* O) +bool EScene::OnLoadAppendObject(CCustomObject *O) { - AppendObject (O,false); + AppendObject(O, false); return true; } @@ -778,161 +799,169 @@ bool EScene::OnLoadAppendObject(CCustomObject* O) bool EScene::LoadLTX(LPCSTR map_name, bool bUndo) { DWORD version = 0; - if (!map_name||(0==map_name[0])) return false; + if (!map_name||(0==map_name[0])) + return false; - xr_string full_name; - full_name = map_name; + xr_string full_name; + full_name = map_name; - ELog.Msg( mtInformation, "EScene: loading '%s'", map_name); + ELog.Msg(mtInformation, "EScene: loading '%s'", map_name); if (FS.exist(full_name.c_str())) { - CTimer T; T.Start(); + CTimer T; + T.Start(); // lock main level - CInifile ini(full_name.c_str()); - version = ini.r_u32("version","value"); + CInifile ini(full_name.c_str()); + version = ini.r_u32("version", "value"); if (version!=CURRENT_FILE_VERSION) { - ELog.DlgMsg( mtError, "EScene: unsupported file version. Can't load Level."); + ELog.DlgMsg(mtError, "EScene: unsupported file version. Can't load Level."); UI->UpdateScene(); return false; } - m_LevelOp.ReadLTX (ini); + m_LevelOp.ReadLTX(ini); - Fvector hpb, pos; - pos = ini.r_fvector3("camera","pos"); - hpb = ini.r_fvector3("camera","hpb"); - EDevice.m_Camera.Set(hpb,pos); + Fvector hpb, pos; + pos = ini.r_fvector3("camera", "pos"); + hpb = ini.r_fvector3("camera", "hpb"); + EDevice.m_Camera.Set(hpb, pos); + EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); - EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); - m_GUID.LoadLTX (ini,"guid","guid"); + m_GUID.LoadLTX(ini, "guid", "guid"); - m_OwnerName = ini.r_string("level_tag","owner"); - m_CreateTime = ini.r_u32("level_tag","create_time"); + m_OwnerName = ini.r_string("level_tag", "owner"); + m_CreateTime = ini.r_u32("level_tag", "create_time"); - SceneToolsMapPairIt _I = m_SceneTools.begin(); - SceneToolsMapPairIt _E = m_SceneTools.end(); + SceneToolsMapPairIt _I = m_SceneTools.begin(); + SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { if (_I->second) { { - if (!bUndo && _I->second->IsEnabled() && (_I->first!=OBJCLASS_DUMMY)) + if (!bUndo&&_I->second->IsEnabled()&&(_I->first!=OBJCLASS_DUMMY)) { - xr_string fn = LevelPartName(map_name, _I->first).c_str(); - LoadLevelPartLTX (_I->second, fn.c_str()); + xr_string fn = LevelPartName(map_name, _I->first).c_str(); + LoadLevelPartLTX(_I->second, fn.c_str()); } } } - } + } - if(ini.section_exist("snap_objects")) + if (ini.section_exist("snap_objects")) { - CInifile::Sect& S = ini.r_section("snap_objects"); - CInifile::SectCIt Si = S.Data.begin(); - CInifile::SectCIt Se = S.Data.end(); - for(;Si!=Se; ++Si) + CInifile::Sect &S = ini.r_section("snap_objects"); + CInifile::SectCIt Si = S.Data.begin(); + CInifile::SectCIt Se = S.Data.end(); + for (; Si!=Se; ++Si) { - CCustomObject* O = FindObjectByName(Si->first.c_str(),OBJCLASS_SCENEOBJECT); + CCustomObject*O = FindObjectByName(Si->first.c_str(), OBJCLASS_SCENEOBJECT); if (!O) - ELog.Msg(mtError,"EScene: Can't find snap object '%s'.",Si->second.c_str()); + ELog.Msg(mtError, "EScene: Can't find snap object '%s'.", Si->second.c_str()); else - m_ESO_SnapObjects.push_back(O); + m_ESO_SnapObjects.push_back(O); } UpdateSnapList(); } - Msg("EScene: %d objects loaded, %3.2f sec", ObjCount(), T.GetElapsed_sec() ); + Msg("EScene: %d objects loaded, %3.2f sec", ObjCount(), T.GetElapsed_sec()); - UI->UpdateScene(true); + UI->UpdateScene(true); SynchronizeObjects(); - if (!bUndo) - m_RTFlags.set(flRT_Unsaved|flRT_Modified,FALSE); - - return true; - }else + if (!bUndo) + m_RTFlags.set(flRT_Unsaved|flRT_Modified, FALSE); + + return true; + } + else { - ELog.Msg(mtError,"Can't find file: '%s'",map_name); + ELog.Msg(mtError, "Can't find file: '%s'", map_name); } - return false; + return false; } bool EScene::Load(LPCSTR map_name, bool bUndo) { u32 version = 0; - if (!map_name||(0==map_name[0])) return false; + if (!map_name||(0==map_name[0])) + return false; - xr_string full_name; - full_name = map_name; + xr_string full_name; + full_name = map_name; - ELog.Msg( mtInformation, "EScene: loading '%s'", map_name); + ELog.Msg(mtInformation, "EScene: loading '%s'", map_name); if (FS.exist(full_name.c_str())) { - CTimer T; T.Start(); - + CTimer T; + T.Start(); + // read main level - IReader* F = FS.r_open(full_name.c_str()); VERIFY(F); + IReader *F = FS.r_open(full_name.c_str()); + VERIFY(F); // Version - R_ASSERT (F->r_chunk(CHUNK_VERSION, &version)); + R_ASSERT(F->r_chunk(CHUNK_VERSION, &version)); if (version!=CURRENT_FILE_VERSION) { - ELog.DlgMsg( mtError, "EScene: unsupported file version. Can't load Level."); + ELog.DlgMsg(mtError, "EScene: unsupported file version. Can't load Level."); UI->UpdateScene(); FS.r_close(F); return false; } // Lev. ops. - IReader* LOP = F->open_chunk(CHUNK_LEVELOP); + IReader *LOP = F->open_chunk(CHUNK_LEVELOP); if (LOP) { - m_LevelOp.Read (*LOP); - LOP->close (); - }else + m_LevelOp.Read(*LOP); + LOP->close(); + } + else { - ELog.DlgMsg (mtError, "Skipping old version of level options.\nCheck level options after loading."); - } + ELog.DlgMsg(mtError, "Skipping old version of level options.\nCheck level options after loading."); + } // if (F->find_chunk(CHUNK_CAMERA)) { - Fvector hpb, pos; - F->r_fvector3 (hpb); - F->r_fvector3 (pos); - EDevice.m_Camera.Set(hpb,pos); - EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); + Fvector hpb, pos; + F->r_fvector3(hpb); + F->r_fvector3(pos); + EDevice.m_Camera.Set(hpb, pos); + EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); } - if (F->find_chunk(CHUNK_TOOLS_GUID)) + if (F->find_chunk(CHUNK_TOOLS_GUID)) { - F->r (&m_GUID,sizeof(m_GUID)); + F->r(&m_GUID, sizeof(m_GUID)); } if (F->find_chunk(CHUNK_LEVEL_TAG)) { - F->r_stringZ (m_OwnerName); - F->r (&m_CreateTime,sizeof(m_CreateTime)); - }else + F->r_stringZ(m_OwnerName); + F->r(&m_CreateTime, sizeof(m_CreateTime)); + } + else { - m_OwnerName = ""; - m_CreateTime = 0; + m_OwnerName = ""; + m_CreateTime = 0; } - DWORD obj_cnt = 0; + DWORD obj_cnt = 0; if (F->find_chunk(CHUNK_OBJECT_COUNT)) - obj_cnt = F->r_u32(); + obj_cnt = F->r_u32(); - SPBItem* pb = UI->ProgressStart(obj_cnt,"Loading objects..."); - ReadObjectsStream (*F,CHUNK_OBJECT_LIST,OnLoadAppendObject,pb); - UI->ProgressEnd (pb); + SPBItem *pb = UI->ProgressStart(obj_cnt, "Loading objects..."); + ReadObjectsStream(*F,CHUNK_OBJECT_LIST, OnLoadAppendObject, pb); + UI->ProgressEnd(pb); SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); @@ -940,74 +969,79 @@ bool EScene::Load(LPCSTR map_name, bool bUndo) { if (_I->second) { - IReader* chunk = F->open_chunk(CHUNK_TOOLS_DATA+_I->first); - if (chunk){ - _I->second->LoadStream(*chunk); - chunk->close (); - }else{ - if (!bUndo && _I->second->IsEnabled() && (_I->first!=OBJCLASS_DUMMY)) + IReader *chunk = F->open_chunk(CHUNK_TOOLS_DATA+_I->first); + if (chunk) + { + _I->second->LoadStream(*chunk); + chunk->close(); + } + else + { + if (!bUndo&&_I->second->IsEnabled()&&(_I->first!=OBJCLASS_DUMMY)) { - LoadLevelPart (_I->second,LevelPartName(map_name,_I->first).c_str()); + LoadLevelPart(_I->second, LevelPartName(map_name, _I->first).c_str()); } } } - } - + } + // snap list if (F->find_chunk(CHUNK_SNAPOBJECTS)) { - shared_str buf; - int cnt = F->r_u32(); + shared_str buf; + int cnt = F->r_u32(); if (cnt) { - for (int i=0; ir_stringZ (buf); - CCustomObject* O = FindObjectByName(buf.c_str(),OBJCLASS_SCENEOBJECT); + F->r_stringZ(buf); + CCustomObject*O = FindObjectByName(buf.c_str(), OBJCLASS_SCENEOBJECT); if (!O) - ELog.Msg(mtError,"EScene: Can't find snap object '%s'.",buf.c_str()); + ELog.Msg(mtError, "EScene: Can't find snap object '%s'.", buf.c_str()); else - m_ESO_SnapObjects.push_back(O); + m_ESO_SnapObjects.push_back(O); } } UpdateSnapList(); } - Msg("EScene: %d objects loaded, %3.2f sec", ObjCount(), T.GetElapsed_sec() ); + Msg("EScene: %d objects loaded, %3.2f sec", ObjCount(), T.GetElapsed_sec()); - UI->UpdateScene(true); + UI->UpdateScene(true); - FS.r_close(F); + FS.r_close(F); SynchronizeObjects(); - if (!bUndo) - m_RTFlags.set(flRT_Unsaved|flRT_Modified,FALSE); - - return true; - }else + if (!bUndo) + m_RTFlags.set(flRT_Unsaved|flRT_Modified, FALSE); + + return true; + } + else { - ELog.Msg(mtError,"Can't find file: '%s'",map_name); + ELog.Msg(mtError, "Can't find file: '%s'", map_name); } - return false; + return false; } //--------------------------------------------------------------------------------------- //copy/paste utils //--------------------------------------------------------------------------------------- -void EScene::SaveSelection( ObjClassID classfilter, LPCSTR fname ) +void EScene::SaveSelection(ObjClassID classfilter, LPCSTR fname) { - VERIFY ( fname ); + VERIFY(fname); - xr_string full_name; - full_name = fname; + xr_string full_name; + full_name = fname; - IWriter* F = FS.w_open(full_name.c_str()); R_ASSERT(F); + IWriter *F = FS.w_open(full_name.c_str()); + R_ASSERT(F); - F->open_chunk (CHUNK_VERSION); - F->w_u32 (CURRENT_FILE_VERSION); - F->close_chunk (); + F->open_chunk(CHUNK_VERSION); + F->w_u32(CURRENT_FILE_VERSION); + F->close_chunk(); m_SaveCache.clear(); if (OBJCLASS_DUMMY==classfilter) @@ -1017,351 +1051,381 @@ void EScene::SaveSelection( ObjClassID classfilter, LPCSTR fname ) for (; _I!=_E; ++_I) if (_I->second&&_I->second->IsNeedSave()) { - F->open_chunk (CHUNK_TOOLS_DATA+_I->first); - _I->second->SaveSelection (m_SaveCache); - F->w (m_SaveCache.pointer(),m_SaveCache.size()); - m_SaveCache.clear (); - F->close_chunk (); + F->open_chunk(CHUNK_TOOLS_DATA+_I->first); + _I->second->SaveSelection(m_SaveCache); + F->w(m_SaveCache.pointer(), m_SaveCache.size()); + m_SaveCache.clear(); + F->close_chunk(); } - }else{ - ESceneToolBase* mt = GetTool(classfilter); VERIFY(mt); - F->open_chunk (CHUNK_TOOLS_DATA+classfilter); + } + else + { + ESceneToolBase*mt = GetTool(classfilter); + VERIFY(mt); + F->open_chunk(CHUNK_TOOLS_DATA+classfilter); mt->SaveSelection(m_SaveCache); - F->w (m_SaveCache.pointer(),m_SaveCache.size()); + F->w(m_SaveCache.pointer(), m_SaveCache.size()); m_SaveCache.clear(); - F->close_chunk (); + F->close_chunk(); } - - FS.w_close (F); + + FS.w_close(F); } //---------------------------------------------------- -bool EScene::OnLoadSelectionAppendObject(CCustomObject* obj) +bool EScene::OnLoadSelectionAppendObject(CCustomObject *obj) { - string256 buf; - GenObjectName (obj->ClassID,buf,obj->Name); - obj->Name = buf; - AppendObject (obj, false); - obj->Select (true); - return true; + string256 buf; + GenObjectName(obj->ClassID, buf, obj->Name); + obj->Name = buf; + AppendObject(obj, false); + obj->Select(true); + return true; } + //---------------------------------------------------- -bool EScene::LoadSelection( LPCSTR fname ) +bool EScene::LoadSelection(LPCSTR fname) { u32 version = 0; - VERIFY( fname ); + VERIFY(fname); - xr_string full_name; - full_name = fname; + xr_string full_name; + full_name = fname; - ELog.Msg( mtInformation, "EScene: loading part %s...", fname ); + ELog.Msg(mtInformation, "EScene: loading part %s...", fname); bool res = true; - if (FS.exist(full_name.c_str())){ - SelectObjects( false ); + if (FS.exist(full_name.c_str())) + { + SelectObjects(false); - IReader* F = FS.r_open(full_name.c_str()); + IReader *F = FS.r_open(full_name.c_str()); // Version R_ASSERT(F->r_chunk(CHUNK_VERSION, &version)); - if (version!=CURRENT_FILE_VERSION){ - ELog.DlgMsg( mtError, "EScene: unsupported file version. Can't load Level."); + if (version!=CURRENT_FILE_VERSION) + { + ELog.DlgMsg(mtError, "EScene: unsupported file version. Can't load Level."); UI->UpdateScene(); FS.r_close(F); return false; } // Objects - if (!ReadObjectsStream(*F,CHUNK_OBJECT_LIST,OnLoadSelectionAppendObject,0)) + if (!ReadObjectsStream(*F,CHUNK_OBJECT_LIST, OnLoadSelectionAppendObject, 0)) { - ELog.DlgMsg(mtError,"EScene. Failed to load selection."); + ELog.DlgMsg(mtError, "EScene. Failed to load selection."); res = false; } SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) - if (_I->second&&_I->second->IsEnabled()&&_I->second->IsEditable()){ - IReader* chunk = F->open_chunk(CHUNK_TOOLS_DATA+_I->first); - if (chunk){ - _I->second->LoadSelection(*chunk); - chunk->close (); + if (_I->second&&_I->second->IsEnabled()&&_I->second->IsEditable()) + { + IReader *chunk = F->open_chunk(CHUNK_TOOLS_DATA+_I->first); + if (chunk) + { + _I->second->LoadSelection(*chunk); + chunk->close(); } } // Synchronize - SynchronizeObjects(); - FS.r_close(F); + SynchronizeObjects(); + FS.r_close(F); } - return res; + return res; } + //---------------------------------------------------- #pragma pack(push,1) -struct SceneClipData { - int m_ClassFilter; - char m_FileName[MAX_PATH]; +struct SceneClipData +{ + int m_ClassFilter; + char m_FileName[MAX_PATH]; }; #pragma pack(pop) -void EScene::CopySelection( ObjClassID classfilter ) +void EScene::CopySelection(ObjClassID classfilter) { - HGLOBAL hmem = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, sizeof(SceneClipData) ); - SceneClipData *sceneclipdata = (SceneClipData *)GlobalLock(hmem); - - sceneclipdata->m_ClassFilter = classfilter; - GetTempFileName( FS.get_path(_temp_)->m_Path, "clip", 0, sceneclipdata->m_FileName ); - SaveSelection( classfilter, sceneclipdata->m_FileName ); - - GlobalUnlock( hmem ); - - int clipformat = RegisterClipboardFormat( "CF_XRAY_CLASS_LIST" ); - if( OpenClipboard( 0 ) ){ - SetClipboardData( clipformat, hmem ); - CloseClipboard(); - } else { - ELog.DlgMsg( mtError, "Failed to open clipboard" ); - GlobalFree( hmem ); - } -} + HGLOBAL hmem = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, sizeof(SceneClipData)); + SceneClipData *sceneclipdata = (SceneClipData *)GlobalLock(hmem); -void EScene::PasteSelection() -{ - int clipformat = RegisterClipboardFormat( "CF_XRAY_CLASS_LIST" ); - if( OpenClipboard( 0 ) ){ - - HGLOBAL hmem = GetClipboardData(clipformat); - if( hmem ){ - SceneClipData *sceneclipdata = (SceneClipData *)GlobalLock(hmem); - LoadSelection( sceneclipdata->m_FileName ); - GlobalUnlock( hmem ); - } else { - ELog.DlgMsg( mtError, "No data in clipboard" ); - } - - CloseClipboard(); - - } else { - ELog.DlgMsg( mtError, "Failed to open clipboard" ); - } -} + sceneclipdata->m_ClassFilter = classfilter; + GetTempFileName(FS.get_path(_temp_)->m_Path, "clip", 0, sceneclipdata->m_FileName); + SaveSelection(classfilter, sceneclipdata->m_FileName); -void EScene::CutSelection( ObjClassID classfilter ) -{ - CopySelection( classfilter ); - RemoveSelection( classfilter ); -} -//---------------------------------------------------- + GlobalUnlock(hmem); -void EScene::LoadCompilerError(LPCSTR fn) -{ - Tools->ClearDebugDraw(); -/* - CInifile ini(fn); - string256 buff; - LPCSTR sect; - u32 sz, i; - - sect = "t-junction"; - sz = ini.r_u32(sect,"count"); - Tools->m_DebugDraw.m_Points.resize(sz); - for(i=0; im_DebugDraw.m_Points[i]; - sprintf (buff,"%d_p",i); - pt.p[0] = ini.r_fvector3(sect,buff); - - sprintf (buff,"%d_c",i); - pt.c = ini.r_u32 (sect,buff); - - sprintf (buff,"%d_i",i); - pt.i = ini.r_bool(sect,buff); - - sprintf (buff,"%d_m",i); - pt.m = ini.r_bool(sect,buff); + SetClipboardData(clipformat, hmem); + CloseClipboard(); } - - sect = "m-edje"; - sz = ini.r_u32(sect,"count"); - Tools->m_DebugDraw.m_Lines.resize(sz); - for(i=0; im_DebugDraw.m_Lines[i]; - sprintf (buff,"%d_p0",i); - pt.p[0] = ini.r_fvector3(sect,buff); - - sprintf (buff,"%d_p1",i); - pt.p[1] = ini.r_fvector3(sect,buff); - - sprintf (buff,"%d_c",i); - pt.c = ini.r_u32 (sect,buff); + ELog.DlgMsg(mtError, "Failed to open clipboard"); + GlobalFree(hmem); + } +} - sprintf (buff,"%d_i",i); - pt.i = ini.r_bool(sect,buff); +void EScene::PasteSelection() +{ + int clipformat = RegisterClipboardFormat("CF_XRAY_CLASS_LIST"); + if (OpenClipboard(0)) + { + HGLOBAL hmem = GetClipboardData(clipformat); + if (hmem) + { + SceneClipData *sceneclipdata = (SceneClipData *)GlobalLock(hmem); + LoadSelection(sceneclipdata->m_FileName); + GlobalUnlock(hmem); + } + else + { + ELog.DlgMsg(mtError, "No data in clipboard"); + } - sprintf (buff,"%d_m",i); - pt.m = ini.r_bool(sect,buff); + CloseClipboard(); } - sect = "invalid_face"; - sz = ini.r_u32(sect,"count"); - Tools->m_DebugDraw.m_WireFaces.resize(sz); - for(i=0; im_DebugDraw.m_WireFaces[i]; - sprintf (buff,"%d_p0",i); - pt.p[0] = ini.r_fvector3(sect,buff); - - sprintf (buff,"%d_p1",i); - pt.p[1] = ini.r_fvector3(sect,buff); - - sprintf (buff,"%d_p2",i); - pt.p[2] = ini.r_fvector3(sect,buff); + ELog.DlgMsg(mtError, "Failed to open clipboard"); + } +} - sprintf (buff,"%d_c",i); - pt.c = ini.r_u32 (sect,buff); +void EScene::CutSelection(ObjClassID classfilter) +{ + CopySelection(classfilter); + RemoveSelection(classfilter); +} - sprintf (buff,"%d_i",i); - pt.i = ini.r_bool(sect,buff); +//---------------------------------------------------- - sprintf (buff,"%d_m",i); - pt.m = ini.r_bool(sect,buff); - } -*/ +void EScene::LoadCompilerError(LPCSTR fn) +{ + Tools->ClearDebugDraw(); + /* + CInifile ini(fn); + string256 buff; + LPCSTR sect; + u32 sz, i; + + sect = "t-junction"; + sz = ini.r_u32(sect,"count"); + Tools->m_DebugDraw.m_Points.resize(sz); + for(i=0; im_DebugDraw.m_Points[i]; + sprintf (buff,"%d_p",i); + pt.p[0] = ini.r_fvector3(sect,buff); + + sprintf (buff,"%d_c",i); + pt.c = ini.r_u32 (sect,buff); + + sprintf (buff,"%d_i",i); + pt.i = ini.r_bool(sect,buff); + + sprintf (buff,"%d_m",i); + pt.m = ini.r_bool(sect,buff); + } + + sect = "m-edje"; + sz = ini.r_u32(sect,"count"); + Tools->m_DebugDraw.m_Lines.resize(sz); + for(i=0; im_DebugDraw.m_Lines[i]; + sprintf (buff,"%d_p0",i); + pt.p[0] = ini.r_fvector3(sect,buff); + + sprintf (buff,"%d_p1",i); + pt.p[1] = ini.r_fvector3(sect,buff); + + sprintf (buff,"%d_c",i); + pt.c = ini.r_u32 (sect,buff); + + sprintf (buff,"%d_i",i); + pt.i = ini.r_bool(sect,buff); + + sprintf (buff,"%d_m",i); + pt.m = ini.r_bool(sect,buff); + } + sect = "invalid_face"; + sz = ini.r_u32(sect,"count"); + Tools->m_DebugDraw.m_WireFaces.resize(sz); + for(i=0; im_DebugDraw.m_WireFaces[i]; + sprintf (buff,"%d_p0",i); + pt.p[0] = ini.r_fvector3(sect,buff); + + sprintf (buff,"%d_p1",i); + pt.p[1] = ini.r_fvector3(sect,buff); + + sprintf (buff,"%d_p2",i); + pt.p[2] = ini.r_fvector3(sect,buff); + + sprintf (buff,"%d_c",i); + pt.c = ini.r_u32 (sect,buff); + + sprintf (buff,"%d_i",i); + pt.i = ini.r_bool(sect,buff); + + sprintf (buff,"%d_m",i); + pt.m = ini.r_bool(sect,buff); + } + */ - IReader* F = FS.r_open(fn); + IReader *F = FS.r_open(fn); Tools->ClearDebugDraw(); - Fvector pt[3]; - if (F->find_chunk(10)){ // lc error (TJ) + Fvector pt[3]; + if (F->find_chunk(10)) + { // lc error (TJ) Tools->m_DebugDraw.m_Points.resize(F->r_u32()); - F->r(Tools->m_DebugDraw.m_Points.begin(),sizeof(CLevelTool::SDebugDraw::Point)*Tools->m_DebugDraw.m_Points.size()); - }else if (F->find_chunk(0)){ // lc error (TJ) - u32 cnt = F->r_u32(); - for (u32 k=0;kr(pt,sizeof(Fvector)); Tools->m_DebugDraw.AppendPoint(pt[0],0xff00ff00,true,true,"TJ"); } + F->r(Tools->m_DebugDraw.m_Points.begin(), sizeof(CLevelTool::SDebugDraw::Point)*Tools->m_DebugDraw.m_Points.size()); } -/* - if (F->find_chunk(11)){ // lc error (multiple edges) - Tools->m_DebugDraw.m_Lines.resize(F->r_u32()); - F->r(Tools->m_DebugDraw.m_Lines.begin(),sizeof(CLevelTool::SDebugDraw::Line)*Tools->m_DebugDraw.m_Lines.size()); - }else if (F->find_chunk(1)){ // lc error (multiple edges) - u32 cnt = F->r_u32(); - for (u32 k=0;kr(pt,sizeof(Fvector)*2); Tools->m_DebugDraw.AppendLine(pt[0],pt[1],0xff0000ff,false,false); } + else if (F->find_chunk(0)) + { // lc error (TJ) + u32 cnt = F->r_u32(); + for (u32 k = 0; kr(pt, sizeof(Fvector)); + Tools->m_DebugDraw.AppendPoint(pt[0], 0xff00ff00, true, true, "TJ"); + } } -*/ - if (F->find_chunk(12)){ // lc error (invalid faces) + /* + if (F->find_chunk(11)){ // lc error (multiple edges) + Tools->m_DebugDraw.m_Lines.resize(F->r_u32()); + F->r(Tools->m_DebugDraw.m_Lines.begin(),sizeof(CLevelTool::SDebugDraw::Line)*Tools->m_DebugDraw.m_Lines.size()); + }else if (F->find_chunk(1)){ // lc error (multiple edges) + u32 cnt = F->r_u32(); + for (u32 k=0;kr(pt,sizeof(Fvector)*2); Tools->m_DebugDraw.AppendLine(pt[0],pt[1],0xff0000ff,false,false); } + } + */ + if (F->find_chunk(12)) + { // lc error (invalid faces) Tools->m_DebugDraw.m_WireFaces.resize(F->r_u32()); - F->r(Tools->m_DebugDraw.m_WireFaces.begin(),sizeof(CLevelTool::SDebugDraw::Face)*Tools->m_DebugDraw.m_WireFaces.size()); - }else if (F->find_chunk(2)){ // lc error (invalid faces) - u32 cnt = F->r_u32(); - for (u32 k=0;kr(pt,sizeof(Fvector)*3); Tools->m_DebugDraw.AppendWireFace(pt[0],pt[1],pt[2]); } + F->r(Tools->m_DebugDraw.m_WireFaces.begin(), sizeof(CLevelTool::SDebugDraw::Face)*Tools->m_DebugDraw.m_WireFaces.size()); + } + else if (F->find_chunk(2)) + { // lc error (invalid faces) + u32 cnt = F->r_u32(); + for (u32 k = 0; kr(pt, sizeof(Fvector)*3); + Tools->m_DebugDraw.AppendWireFace(pt[0], pt[1], pt[2]); + } } FS.r_close(F); - } void EScene::SaveCompilerError(LPCSTR fn) { -/* - CInifile ini(fn,FALSE,FALSE,TRUE); - string256 buff; - LPCSTR sect; - u32 sz, i; - - sz = Tools->m_DebugDraw.m_Points.size(); - sect = "t-junction"; - ini.w_u32 (sect,"count",sz); - for(i=0; im_DebugDraw.m_Points[i].p[0]); - - sprintf (buff,"%d_c",i); - ini.w_u32 (sect,buff,Tools->m_DebugDraw.m_Points[i].c); - - sprintf (buff,"%d_i",i); - ini.w_bool (sect,buff,Tools->m_DebugDraw.m_Points[i].i); - - sprintf (buff,"%d_m",i); - ini.w_bool (sect,buff,Tools->m_DebugDraw.m_Points[i].m); - } - - sz = Tools->m_DebugDraw.m_Lines.size(); - sect = "m-edje"; - ini.w_u32 ("sect","count",sz); - for(i=0; im_DebugDraw.m_Lines[i].p[0]); - - sprintf (buff,"%d_p1",i); - ini.w_fvector3(sect,buff,Tools->m_DebugDraw.m_Lines[i].p[1]); - - sprintf (buff,"%d_c",i); - ini.w_u32 (sect,buff,Tools->m_DebugDraw.m_Lines[i].c); - - sprintf (buff,"%d_i",i); - ini.w_bool (sect,buff,Tools->m_DebugDraw.m_Lines[i].i); - - sprintf (buff,"%d_m",i); - ini.w_bool (sect,buff,Tools->m_DebugDraw.m_Lines[i].m); - } - - sz = Tools->m_DebugDraw.m_WireFaces.size(); - sect = "invalid_face"; - ini.w_u32 (sect,"count",sz); - for(i=0; im_DebugDraw.m_WireFaces[i].p[0]); - - sprintf (buff,"%d_p1",i); - ini.w_fvector3(sect,buff,Tools->m_DebugDraw.m_WireFaces[i].p[1]); - - sprintf (buff,"%d_p2",i); - ini.w_fvector3(sect,buff,Tools->m_DebugDraw.m_WireFaces[i].p[2]); - - sprintf (buff,"%d_c",i); - ini.w_u32 (sect,buff,Tools->m_DebugDraw.m_WireFaces[i].c); - - sprintf (buff,"%d_i",i); - ini.w_bool (sect,buff,Tools->m_DebugDraw.m_WireFaces[i].i); - - sprintf (buff,"%d_m",i); - ini.w_bool (sect,buff,Tools->m_DebugDraw.m_WireFaces[i].m); - } -*/ - IWriter* fs = FS.w_open(fn); R_ASSERT(fs); - IWriter& err = *fs; - - // t-junction - err.open_chunk (10); - err.w_u32 (Tools->m_DebugDraw.m_Points.size()); - err.w (Tools->m_DebugDraw.m_Points.begin(), Tools->m_DebugDraw.m_Points.size()*sizeof(CLevelTool::SDebugDraw::Point)); - err.close_chunk (); - - // m-edje - err.open_chunk (11); - err.w_u32 (Tools->m_DebugDraw.m_Lines.size()); - err.w (Tools->m_DebugDraw.m_Lines.begin(), Tools->m_DebugDraw.m_Lines.size()*sizeof(CLevelTool::SDebugDraw::Line)); - err.close_chunk (); - - // invalid - err.open_chunk (12); - err.w_u32 (Tools->m_DebugDraw.m_WireFaces.size()); - err.w (Tools->m_DebugDraw.m_WireFaces.begin(), Tools->m_DebugDraw.m_WireFaces.size()*sizeof(CLevelTool::SDebugDraw::Face)); - err.close_chunk (); - - FS.w_close (fs); - + /* + CInifile ini(fn,FALSE,FALSE,TRUE); + string256 buff; + LPCSTR sect; + u32 sz, i; + + sz = Tools->m_DebugDraw.m_Points.size(); + sect = "t-junction"; + ini.w_u32 (sect,"count",sz); + for(i=0; im_DebugDraw.m_Points[i].p[0]); + + sprintf (buff,"%d_c",i); + ini.w_u32 (sect,buff,Tools->m_DebugDraw.m_Points[i].c); + + sprintf (buff,"%d_i",i); + ini.w_bool (sect,buff,Tools->m_DebugDraw.m_Points[i].i); + + sprintf (buff,"%d_m",i); + ini.w_bool (sect,buff,Tools->m_DebugDraw.m_Points[i].m); + } + + sz = Tools->m_DebugDraw.m_Lines.size(); + sect = "m-edje"; + ini.w_u32 ("sect","count",sz); + for(i=0; im_DebugDraw.m_Lines[i].p[0]); + + sprintf (buff,"%d_p1",i); + ini.w_fvector3(sect,buff,Tools->m_DebugDraw.m_Lines[i].p[1]); + + sprintf (buff,"%d_c",i); + ini.w_u32 (sect,buff,Tools->m_DebugDraw.m_Lines[i].c); + + sprintf (buff,"%d_i",i); + ini.w_bool (sect,buff,Tools->m_DebugDraw.m_Lines[i].i); + + sprintf (buff,"%d_m",i); + ini.w_bool (sect,buff,Tools->m_DebugDraw.m_Lines[i].m); + } + + sz = Tools->m_DebugDraw.m_WireFaces.size(); + sect = "invalid_face"; + ini.w_u32 (sect,"count",sz); + for(i=0; im_DebugDraw.m_WireFaces[i].p[0]); + + sprintf (buff,"%d_p1",i); + ini.w_fvector3(sect,buff,Tools->m_DebugDraw.m_WireFaces[i].p[1]); + + sprintf (buff,"%d_p2",i); + ini.w_fvector3(sect,buff,Tools->m_DebugDraw.m_WireFaces[i].p[2]); + + sprintf (buff,"%d_c",i); + ini.w_u32 (sect,buff,Tools->m_DebugDraw.m_WireFaces[i].c); + + sprintf (buff,"%d_i",i); + ini.w_bool (sect,buff,Tools->m_DebugDraw.m_WireFaces[i].i); + + sprintf (buff,"%d_m",i); + ini.w_bool (sect,buff,Tools->m_DebugDraw.m_WireFaces[i].m); + } + */ + IWriter *fs = FS.w_open(fn); + R_ASSERT(fs); + IWriter &err = *fs; + + // t-junction + err.open_chunk(10); + err.w_u32(Tools->m_DebugDraw.m_Points.size()); + err.w(Tools->m_DebugDraw.m_Points.begin(), Tools->m_DebugDraw.m_Points.size()*sizeof(CLevelTool::SDebugDraw::Point)); + err.close_chunk(); + + // m-edje + err.open_chunk(11); + err.w_u32(Tools->m_DebugDraw.m_Lines.size()); + err.w(Tools->m_DebugDraw.m_Lines.begin(), Tools->m_DebugDraw.m_Lines.size()*sizeof(CLevelTool::SDebugDraw::Line)); + err.close_chunk(); + + // invalid + err.open_chunk(12); + err.w_u32(Tools->m_DebugDraw.m_WireFaces.size()); + err.w(Tools->m_DebugDraw.m_WireFaces.begin(), Tools->m_DebugDraw.m_WireFaces.size()*sizeof(CLevelTool::SDebugDraw::Face)); + err.close_chunk(); + + FS.w_close(fs); } void EScene::ExportObj(bool b_selected_only) { - Builder.m_save_as_object = true; - Builder.Compile (b_selected_only); - Builder.m_save_as_object = false; - + Builder.m_save_as_object = true; + Builder.Compile(b_selected_only); + Builder.m_save_as_object = false; } diff --git a/src/editors/LevelEditor/Edit/SceneObject.cpp b/src/editors/LevelEditor/Edit/SceneObject.cpp index a77c593a519..7a5bab0f9a9 100644 --- a/src/editors/LevelEditor/Edit/SceneObject.cpp +++ b/src/editors/LevelEditor/Edit/SceneObject.cpp @@ -6,121 +6,134 @@ #pragma hdrstop #include "SceneObject.h" -#include "bottombar.h" -#include "../ECore/Editor/library.h" -#include "../ECore/Editor/EditMesh.h" -#include "../ECore/Editor/ui_main.h" -#include "../ECore/Editor/D3DUtils.h" +#include "BottomBar.h" +#include "editors/ECore/Editor/library.h" +#include "editors/ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/D3DUtils.h" #ifdef _LEVEL_EDITOR - #include "scene.h" +#include "scene.h" #endif #define BLINK_TIME 300.f //---------------------------------------------------- -CSceneObject::CSceneObject(LPVOID data, LPCSTR name):CCustomObject(data,name) +CSceneObject::CSceneObject(LPVOID data, LPCSTR name): CCustomObject(data, name) { - Construct (data); + Construct(data); } void CSceneObject::Construct(LPVOID data) { - ClassID = OBJCLASS_SCENEOBJECT; + ClassID = OBJCLASS_SCENEOBJECT; m_ReferenceName = ""; - m_pReference = 0; + m_pReference = 0; m_TBBox.invalidate(); - m_iBlinkTime = 0; - m_BlinkSurf = 0; + m_iBlinkTime = 0; + m_BlinkSurf = 0; - m_Flags.zero (); + m_Flags.zero(); } CSceneObject::~CSceneObject() { - Lib.RemoveEditObject(m_pReference); + Lib.RemoveEditObject(m_pReference); } + //---------------------------------------------------- void CSceneObject::EvictObject() { - if (m_pReference) m_pReference->EvictObject(); + if (m_pReference) + m_pReference->EvictObject(); } //---------------------------------------------------- void CSceneObject::Select(BOOL flag) { - inherited::Select(flag); - if (flag) Blink(); + inherited::Select(flag); + if (flag) + Blink(); } //---------------------------------------------------- int CSceneObject::GetFaceCount() { - return m_pReference?m_pReference->GetFaceCount():0; + return m_pReference ? m_pReference->GetFaceCount() : 0; } -int CSceneObject::GetSurfFaceCount(const char* surf_name) +int CSceneObject::GetSurfFaceCount(const char *surf_name) { - return m_pReference?m_pReference->GetSurfFaceCount(surf_name):0; + return m_pReference ? m_pReference->GetSurfFaceCount(surf_name) : 0; } int CSceneObject::GetVertexCount() { - return m_pReference?m_pReference->GetVertexCount():0; + return m_pReference ? m_pReference->GetVertexCount() : 0; } void CSceneObject::OnUpdateTransform() { - inherited::OnUpdateTransform(); + inherited::OnUpdateTransform(); // update bounding volume - if (m_pReference){ - m_TBBox.set (m_pReference->GetBox()); - m_TBBox.xform (_Transform()); + if (m_pReference) + { + m_TBBox.set(m_pReference->GetBox()); + m_TBBox.xform(_Transform()); } } -bool CSceneObject::GetBox( Fbox& box ) const +bool CSceneObject::GetBox(Fbox &box) const { - if (!m_pReference) return false; - box.set(m_TBBox); - return true; + if (!m_pReference) + return false; + box.set(m_TBBox); + return true; } -bool CSceneObject::GetUTBox( Fbox& box ) +bool CSceneObject::GetUTBox(Fbox &box) { - if (!m_pReference) return false; + if (!m_pReference) + return false; box.set(m_pReference->GetBox()); - return true; + return true; } bool CSceneObject::IsRender() { - if (!m_pReference) return false; + if (!m_pReference) + return false; return inherited::IsRender(); } void CSceneObject::Render(int priority, bool strictB2F) { - inherited::Render(priority,strictB2F); - if (!m_pReference) return; -#ifdef _LEVEL_EDITOR + inherited::Render(priority, strictB2F); + if (!m_pReference) + return; +#ifdef _LEVEL_EDITOR Scene->SelectLightsForObject(this); #endif - m_pReference->Render(_Transform(), priority, strictB2F); - if (Selected()){ - if (1==priority){ - if (false==strictB2F){ + m_pReference->Render(_Transform(), priority, strictB2F); + if (Selected()) + { + if (1==priority) + { + if (false==strictB2F) + { EDevice.SetShader(EDevice.m_WireShader); RCache.set_xform_world(_Transform()); u32 clr = 0xFFFFFFFF; - DU_impl.DrawSelectionBoxB(m_pReference->GetBox(),&clr); - }else{ - RenderBlink (); + DU_impl.DrawSelectionBoxB(m_pReference->GetBox(), &clr); + } + else + { + RenderBlink(); } } } @@ -128,228 +141,268 @@ void CSceneObject::Render(int priority, bool strictB2F) void CSceneObject::RenderBlink() { - if (m_iBlinkTime>0){ - if (m_iBlinkTime>(int)EDevice.dwTimeGlobal){ - int alpha = iFloor(sqrtf(float(m_iBlinkTime-EDevice.dwTimeGlobal)/BLINK_TIME)*64); - m_pReference->RenderSelection(_Transform(),0, m_BlinkSurf, color_argb(alpha,255,255,255)); - UI->RedrawScene (); - }else{ - m_iBlinkTime = 0; - m_BlinkSurf = 0; + if (m_iBlinkTime>0) + { + if (m_iBlinkTime>(int)EDevice.dwTimeGlobal) + { + int alpha = iFloor(sqrtf(float(m_iBlinkTime-EDevice.dwTimeGlobal)/BLINK_TIME)*64); + m_pReference->RenderSelection(_Transform(), 0, m_BlinkSurf, color_argb(alpha, 255, 255, 255)); + UI->RedrawScene(); + } + else + { + m_iBlinkTime = 0; + m_BlinkSurf = 0; } } } void CSceneObject::RenderSingle() { - if (!m_pReference) return; - m_pReference->RenderSingle(_Transform()); - RenderBlink (); + if (!m_pReference) + return; + m_pReference->RenderSingle(_Transform()); + RenderBlink(); } void CSceneObject::RenderBones() { - if (!m_pReference) return; - m_pReference->RenderBones(_Transform()); + if (!m_pReference) + return; + m_pReference->RenderBones(_Transform()); } -void CSceneObject::RenderEdge(CEditableMesh* mesh, u32 color) +void CSceneObject::RenderEdge(CEditableMesh *mesh, u32 color) { - if (!m_pReference) return; + if (!m_pReference) + return; if (::Render->occ_visible(m_TBBox)) - m_pReference->RenderEdge(_Transform(), mesh, 0, color); + m_pReference->RenderEdge(_Transform(), mesh, 0, color); } void CSceneObject::RenderSelection(u32 color) { - if (!m_pReference) return; - m_pReference->RenderSelection(_Transform(),0, 0, color); + if (!m_pReference) + return; + m_pReference->RenderSelection(_Transform(), 0, 0, color); } -bool CSceneObject::FrustumPick(const CFrustum& frustum) +bool CSceneObject::FrustumPick(const CFrustum &frustum) { - if (!m_pReference) return false; + if (!m_pReference) + return false; if (::Render->occ_visible(m_TBBox)) - return m_pReference->FrustumPick(frustum, _Transform()); + return m_pReference->FrustumPick(frustum, _Transform()); return false; } -bool CSceneObject::SpherePick(const Fvector& center, float radius) +bool CSceneObject::SpherePick(const Fvector ¢er, float radius) { - if (!m_pReference) return false; - float fR; Fvector vC; - m_TBBox.getsphere(vC,fR); - float R=radius+fR; - float dist_sqr=center.distance_to_sqr(vC); - if (dist_sqrocc_visible(m_TBBox)) - if (m_pReference->RayPick(dist, S, D, _ITransform(), pinf)){ - if (pinf) pinf->s_obj = this; + if (m_pReference->RayPick(dist, S, D, _ITransform(), pinf)) + { + if (pinf) + pinf->s_obj = this; return true; } - return false; + return false; } -void CSceneObject::RayQuery(SPickQuery& pinf) +void CSceneObject::RayQuery(SPickQuery &pinf) { - if (!m_pReference) return; + if (!m_pReference) + return; m_pReference->RayQuery(_Transform(), _ITransform(), pinf); } -void CSceneObject::BoxQuery(SPickQuery& pinf) +void CSceneObject::BoxQuery(SPickQuery &pinf) { - if (!m_pReference) return; + if (!m_pReference) + return; m_pReference->BoxQuery(_Transform(), _ITransform(), pinf); } -bool CSceneObject::BoxPick(const Fbox& box, SBoxPickInfoVec& pinf) +bool CSceneObject::BoxPick(const Fbox &box, SBoxPickInfoVec &pinf) { - if (!m_pReference) return false; - return m_pReference->BoxPick(this, box, _ITransform(), pinf); + if (!m_pReference) + return false; + return m_pReference->BoxPick(this, box, _ITransform(), pinf); } -void CSceneObject::GetFullTransformToWorld( Fmatrix& m ) +void CSceneObject::GetFullTransformToWorld(Fmatrix &m) { m.set(_Transform()); } -void CSceneObject::GetFullTransformToLocal( Fmatrix& m ) +void CSceneObject::GetFullTransformToLocal(Fmatrix &m) { m.set(_ITransform()); } -CEditableObject* CSceneObject::UpdateReference() +CEditableObject *CSceneObject::UpdateReference() { - Lib.RemoveEditObject(m_pReference); - m_pReference = (m_ReferenceName.size())?Lib.CreateEditObject(*m_ReferenceName):0; - UpdateTransform (); + Lib.RemoveEditObject(m_pReference); + m_pReference = (m_ReferenceName.size()) ? Lib.CreateEditObject(*m_ReferenceName) : 0; + UpdateTransform(); return m_pReference; } -CEditableObject* CSceneObject::SetReference(LPCSTR ref_name) +CEditableObject *CSceneObject::SetReference(LPCSTR ref_name) { - m_ReferenceName = ref_name; + m_ReferenceName = ref_name; return UpdateReference(); } void CSceneObject::OnFrame() { - inherited::OnFrame(); - if (!m_pReference) return; - if (m_pReference) m_pReference->OnFrame(); - if (psDeviceFlags.is(rsStatistic)){ - if (IsStatic()||IsMUStatic()||Selected()){ - EDevice.Statistic->dwLevelSelFaceCount += GetFaceCount(); + inherited::OnFrame(); + if (!m_pReference) + return; + if (m_pReference) + m_pReference->OnFrame(); + if (psDeviceFlags.is(rsStatistic)) + { + if (IsStatic()||IsMUStatic()||Selected()) + { + EDevice.Statistic->dwLevelSelFaceCount += GetFaceCount(); EDevice.Statistic->dwLevelSelVertexCount += GetVertexCount(); } } } -void CSceneObject::ReferenceChange(PropValue* sender) +void CSceneObject::ReferenceChange(PropValue *sender) { Scene->BeforeObjectChange(this); - UpdateReference (); + UpdateReference(); } -void CSceneObject::FillProp(LPCSTR pref, PropItemVec& items) +void CSceneObject::FillProp(LPCSTR pref, PropItemVec &items) { - inherited::FillProp (pref,items); - PropValue* V = PHelper().CreateChoose (items,PrepareKey(pref,"Reference"), &m_ReferenceName, smObject); - V->OnChangeEvent.bind(this,&CSceneObject::ReferenceChange); + inherited::FillProp(pref, items); + PropValue *V = PHelper().CreateChoose(items, PrepareKey(pref, "Reference"), &m_ReferenceName, smObject); + V->OnChangeEvent.bind(this, &CSceneObject::ReferenceChange); if (IsDynamic()) - inherited::AnimationFillProp(pref,items); -} - -bool CSceneObject::GetSummaryInfo(SSceneSummary* inf) -{ - inherited::GetSummaryInfo (inf); - CEditableObject* E = GetReference(); R_ASSERT(E); - if (IsStatic()||IsMUStatic()){ - for(SurfaceIt s_it=E->m_Surfaces.begin(); s_it!=E->m_Surfaces.end(); s_it++){ - float area = 0.f; - float pixel_area = 0.f; - for(EditMeshIt m = E->Meshes().begin();m!=E->Meshes().end();m++){ - area += (*m)->CalculateSurfaceArea(*s_it,true); - pixel_area += (*m)->CalculateSurfacePixelArea(*s_it,true); + inherited::AnimationFillProp(pref, items); +} + +bool CSceneObject::GetSummaryInfo(SSceneSummary *inf) +{ + inherited::GetSummaryInfo(inf); + CEditableObject*E = GetReference(); + R_ASSERT(E); + if (IsStatic()||IsMUStatic()) + { + for (SurfaceIt s_it = E->m_Surfaces.begin(); s_it!=E->m_Surfaces.end(); s_it++) + { + float area = 0.f; + float pixel_area = 0.f; + for (EditMeshIt m = E->Meshes().begin(); m!=E->Meshes().end(); m++) + { + area += (*m)->CalculateSurfaceArea(*s_it, true); + pixel_area += (*m)->CalculateSurfacePixelArea(*s_it, true); } - inf->AppendTexture(ChangeFileExt(AnsiString(*(*s_it)->m_Texture),"").LowerCase().c_str(),SSceneSummary::sttBase,area,pixel_area,E->m_LibName.c_str()); + inf->AppendTexture(ChangeFileExt(AnsiString(*(*s_it)->m_Texture), "").LowerCase().c_str(), SSceneSummary::sttBase, area, pixel_area, E->m_LibName.c_str()); } - if (m_Flags.is(CEditableObject::eoUsingLOD)){ - inf->AppendTexture(E->GetLODTextureName().c_str(),SSceneSummary::sttLOD,0,0,"$LOD$"); - inf->lod_objects.insert (E->m_LibName.c_str()); + if (m_Flags.is(CEditableObject::eoUsingLOD)) + { + inf->AppendTexture(E->GetLODTextureName().c_str(), SSceneSummary::sttLOD, 0, 0, "$LOD$"); + inf->lod_objects.insert(E->m_LibName.c_str()); inf->object_lod_ref_cnt++; } - if (m_Flags.is(CEditableObject::eoMultipleUsage)){ + if (m_Flags.is(CEditableObject::eoMultipleUsage)) + { inf->mu_objects.insert(E->m_LibName.c_str()); inf->object_mu_ref_cnt++; } - inf->face_cnt += E->GetFaceCount (); - inf->vert_cnt += E->GetVertexCount(); + inf->face_cnt += E->GetFaceCount(); + inf->vert_cnt += E->GetVertexCount(); } - if (m_Flags.is(CEditableObject::eoHOM)){ - inf->hom_face_cnt += E->GetFaceCount (); - inf->hom_vert_cnt += E->GetVertexCount(); + if (m_Flags.is(CEditableObject::eoHOM)) + { + inf->hom_face_cnt += E->GetFaceCount(); + inf->hom_vert_cnt += E->GetVertexCount(); } - if (m_Flags.is(CEditableObject::eoSoundOccluder)){ - inf->snd_occ_face_cnt += E->GetFaceCount(); - inf->snd_occ_vert_cnt += E->GetVertexCount(); + if (m_Flags.is(CEditableObject::eoSoundOccluder)) + { + inf->snd_occ_face_cnt += E->GetFaceCount(); + inf->snd_occ_vert_cnt += E->GetVertexCount(); } - inf->AppendObject (E->GetName()); - return true; + inf->AppendObject(E->GetName()); + return true; } extern xr_token ECORE_API eo_type_token[]; -void CSceneObject::OnShowHint(AStringVec& dest) +void CSceneObject::OnShowHint(AStringVec &dest) { - inherited::OnShowHint(dest); + inherited::OnShowHint(dest); dest.push_back(AnsiString("Reference: ")+*m_ReferenceName); dest.push_back(AnsiString("-------")); - float dist = UI->ZFar(); + float dist = UI->ZFar(); SRayPickInfo pinf; - if (m_pReference->RayPick(dist,UI->m_CurrentRStart,UI->m_CurrentRDir,_ITransform(),&pinf)){ - dest.push_back(AnsiString("Object Type: ")+get_token_name(eo_type_token,pinf.e_obj->m_objectFlags.flags)); + if (m_pReference->RayPick(dist, UI->m_CurrentRStart, UI->m_CurrentRDir, _ITransform(), &pinf)) + { + dest.push_back(AnsiString("Object Type: ")+get_token_name(eo_type_token, pinf.e_obj->m_objectFlags.flags)); R_ASSERT(pinf.e_mesh); - CSurface* surf=pinf.e_mesh->GetSurfaceByFaceID(pinf.inf.id); + CSurface *surf = pinf.e_mesh->GetSurfaceByFaceID(pinf.inf.id); dest.push_back(AnsiString("Surface: ")+AnsiString(surf->_Name())); - dest.push_back(AnsiString("2 Sided: ")+AnsiString(surf->m_Flags.is(CSurface::sf2Sided)?"on":"off")); - if (pinf.e_obj->m_objectFlags.is(CEditableObject::eoSoundOccluder)){ - dest.push_back(AnsiString("Game Mtl: ")+AnsiString(surf->_GameMtlName())); - int gm_id = surf->_GameMtl(); - if (gm_id!=GAMEMTL_NONE_ID){ - SGameMtl* mtl = GMLib.GetMaterialByID(gm_id); - if (mtl) dest.push_back(AnsiString().sprintf("Occlusion Factor: %3.2f",mtl->fSndOcclusionFactor)); + dest.push_back(AnsiString("2 Sided: ")+AnsiString(surf->m_Flags.is(CSurface::sf2Sided) ? "on" : "off")); + if (pinf.e_obj->m_objectFlags.is(CEditableObject::eoSoundOccluder)) + { + dest.push_back(AnsiString("Game Mtl: ")+AnsiString(surf->_GameMtlName())); + int gm_id = surf->_GameMtl(); + if (gm_id!=GAMEMTL_NONE_ID) + { + SGameMtl *mtl = GMLib.GetMaterialByID(gm_id); + if (mtl) + dest.push_back(AnsiString().sprintf("Occlusion Factor: %3.2f", mtl->fSndOcclusionFactor)); } - }else if (pinf.e_obj->m_objectFlags.is(CEditableObject::eoHOM)){ - }else{ - dest.push_back(AnsiString("Texture: ")+AnsiString(surf->_Texture())); - dest.push_back(AnsiString("Shader: ")+AnsiString(surf->_ShaderName())); - dest.push_back(AnsiString("LC Shader: ")+AnsiString(surf->_ShaderXRLCName())); - dest.push_back(AnsiString("Game Mtl: ")+AnsiString(surf->_GameMtlName())); + } + else if (pinf.e_obj->m_objectFlags.is(CEditableObject::eoHOM)) { } + else + { + dest.push_back(AnsiString("Texture: ")+AnsiString(surf->_Texture())); + dest.push_back(AnsiString("Shader: ")+AnsiString(surf->_ShaderName())); + dest.push_back(AnsiString("LC Shader: ")+AnsiString(surf->_ShaderXRLCName())); + dest.push_back(AnsiString("Game Mtl: ")+AnsiString(surf->_GameMtlName())); } } } + //---------------------------------------------------- -void CSceneObject::Blink(CSurface* surf) +void CSceneObject::Blink(CSurface *surf) { - m_BlinkSurf = surf; - m_iBlinkTime = EDevice.dwTimeGlobal+BLINK_TIME+EDevice.dwTimeDelta; + m_BlinkSurf = surf; + m_iBlinkTime = EDevice.dwTimeGlobal+BLINK_TIME+EDevice.dwTimeDelta; } + //---------------------------------------------------- bool CSceneObject::Validate(bool bMsg) { - CEditableObject* E = GetReference(); R_ASSERT(E); + CEditableObject*E = GetReference(); + R_ASSERT(E); return E->Validate(); } + //---------------------------------------------------- diff --git a/src/editors/LevelEditor/Edit/SceneObject.h b/src/editors/LevelEditor/Edit/SceneObject.h index 8456116a715..714bb1e969b 100644 --- a/src/editors/LevelEditor/Edit/SceneObject.h +++ b/src/editors/LevelEditor/Edit/SceneObject.h @@ -2,111 +2,164 @@ #ifndef SceneObjectH #define SceneObjectH -#include "../ECore/Editor/EditObject.h" -#include "customobject.h" +#include "editors/ECore/Editor/EditObject.h" +#include "CustomObject.h" + //---------------------------------------------------- class CSceneObject : public CCustomObject { - shared_str m_ReferenceName; - CEditableObject*m_pReference; - void ReferenceChange (PropValue* sender); + shared_str m_ReferenceName; + CEditableObject *m_pReference; + void ReferenceChange(PropValue *sender); public: - enum{ -// flDynamic = (1<<0), - flFORCE32 = u32(-1) + enum + { + // flDynamic = (1<<0), + flFORCE32 = u32(-1) }; + private: - Fbox m_TBBox; - // options - Flags32 m_Flags; + Fbox m_TBBox; + // options + Flags32 m_Flags; public: - virtual void SetScale (const Fvector& scale) + virtual void SetScale(const Fvector &scale) { - if (m_pReference && m_pReference->IsDynamic()){ - ELog.Msg(mtError,"Dynamic object %s - can't scale.", Name); - }else{ - FScale.set(scale); + if (m_pReference&&m_pReference->IsDynamic()) + { + ELog.Msg(mtError, "Dynamic object %s - can't scale.", Name); + } + else + { + FScale.set(scale); UpdateTransform(); } } + protected: - typedef CCustomObject inherited; - int m_iBlinkTime; - CSurface* m_BlinkSurf; - void RenderBlink (); + typedef CCustomObject inherited; + int m_iBlinkTime; + CSurface *m_BlinkSurf; + void RenderBlink(); public: // constructor/destructor methods - CSceneObject (LPVOID data, LPCSTR name); - virtual ~CSceneObject (); + CSceneObject(LPVOID data, LPCSTR name); + virtual ~CSceneObject(); - virtual void Select (BOOL flag); - void Construct (LPVOID data); + virtual void Select(BOOL flag); + void Construct(LPVOID data); // get object properties methods - IC bool RefCompare (CEditableObject *to){return m_pReference?!!(m_pReference==to):false; } - IC bool RefCompare (LPCSTR ref){return ref&&m_pReference?(strcmp(ref,m_pReference->GetName())==0):false; } - IC CEditableObject* GetReference () {return m_pReference; } - CEditableObject*SetReference (LPCSTR ref_name); - CEditableObject*UpdateReference (); - IC EditMeshVec* Meshes () {return m_pReference?&m_pReference->Meshes():0;} - virtual LPCSTR RefName () {return m_pReference?m_pReference->GetName():0;} - virtual bool CanAttach () {return true;} + IC + + bool RefCompare(CEditableObject *to) + { + return m_pReference ? !!(m_pReference==to) : false; + } + + IC + + bool RefCompare(LPCSTR ref) + { + return ref&&m_pReference ? (strcmp(ref, m_pReference->GetName())==0) : false; + } + + IC CEditableObject*GetReference() + { + return m_pReference; + } + + CEditableObject *SetReference(LPCSTR ref_name); + CEditableObject *UpdateReference(); + + IC EditMeshVec*Meshes() + { + return m_pReference ? &m_pReference->Meshes() : 0; + } + + virtual LPCSTR RefName() + { + return m_pReference ? m_pReference->GetName() : 0; + } + + virtual bool CanAttach() + { + return true; + } // statistics methods - IC bool IsDynamic () {return (m_pReference?m_pReference->IsDynamic():false); } - IC bool IsStatic () {return (m_pReference?m_pReference->IsStatic():false); } - IC bool IsMUStatic () {return (m_pReference?m_pReference->IsMUStatic():false); } - int GetFaceCount (); - int GetVertexCount (); - int GetSurfFaceCount (const char* surf_name); + IC + + bool IsDynamic() + { + return (m_pReference ? m_pReference->IsDynamic() : false); + } + + IC + + bool IsStatic() + { + return (m_pReference ? m_pReference->IsStatic() : false); + } + + IC + + bool IsMUStatic() + { + return (m_pReference ? m_pReference->IsMUStatic() : false); + } + + int GetFaceCount(); + int GetVertexCount(); + int GetSurfFaceCount(const char *surf_name); // render methods - virtual bool IsRender (); - virtual void Render (int priority, bool strictB2F); - void RenderSelection (u32 color=0x80E64646); - void RenderEdge (CEditableMesh* m=0, u32 color=0xFFC0C0C0); - void RenderBones (); - void RenderSingle (); + virtual bool IsRender(); + virtual void Render(int priority, bool strictB2F); + void RenderSelection(u32 color = 0x80E64646); + void RenderEdge(CEditableMesh *m = 0, u32 color = 0xFFC0C0C0); + void RenderBones(); + void RenderSingle(); // update methods - virtual void OnFrame (); - virtual void OnUpdateTransform (); + virtual void OnFrame(); + virtual void OnUpdateTransform(); // misc - void EvictObject (); + void EvictObject(); // pick methods - bool BoxPick (const Fbox& box, SBoxPickInfoVec& pinf); - virtual bool RayPick (float& dist, const Fvector& S, const Fvector& D, SRayPickInfo* pinf=0); - virtual void RayQuery (SPickQuery& pinf); - virtual void BoxQuery (SPickQuery& pinf); - virtual bool FrustumPick (const CFrustum& frustum); - virtual bool SpherePick (const Fvector& center, float radius); + bool BoxPick(const Fbox &box, SBoxPickInfoVec &pinf); + virtual bool RayPick(float &dist, const Fvector &S, const Fvector &D, SRayPickInfo *pinf = 0); + virtual void RayQuery(SPickQuery &pinf); + virtual void BoxQuery(SPickQuery &pinf); + virtual bool FrustumPick(const CFrustum &frustum); + virtual bool SpherePick(const Fvector ¢er, float radius); // get orintation/bounding volume methods - virtual bool GetBox (Fbox& box) const; - virtual bool GetUTBox (Fbox& box); - void GetFullTransformToWorld (Fmatrix& m); - void GetFullTransformToLocal (Fmatrix& m); + virtual bool GetBox(Fbox &box) const; + virtual bool GetUTBox(Fbox &box); + void GetFullTransformToWorld(Fmatrix &m); + void GetFullTransformToLocal(Fmatrix &m); - // editor integration - virtual void FillProp (LPCSTR pref, PropItemVec& values); - virtual bool GetSummaryInfo (SSceneSummary* inf); + // editor integration + virtual void FillProp(LPCSTR pref, PropItemVec &values); + virtual bool GetSummaryInfo(SSceneSummary *inf); // load/save methods - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); - virtual void OnShowHint (AStringVec& dest); + virtual void OnShowHint(AStringVec &dest); - void Blink (CSurface* surf=0); + void Blink(CSurface *surf = 0); - virtual bool Validate (bool bMsg); + virtual bool Validate(bool bMsg); }; + //---------------------------------------------------- #endif /*_INCDEF_EditObject_H_*/ - diff --git a/src/editors/LevelEditor/Edit/SceneObjectIO.cpp b/src/editors/LevelEditor/Edit/SceneObjectIO.cpp index b531064400f..fc3c264f27c 100644 --- a/src/editors/LevelEditor/Edit/SceneObjectIO.cpp +++ b/src/editors/LevelEditor/Edit/SceneObjectIO.cpp @@ -8,178 +8,184 @@ #include "SceneObject.h" #include "Scene.h" //---------------------------------------------------- -#define SCENEOBJ_CURRENT_VERSION 0x0012 +#define SCENEOBJ_CURRENT_VERSION 0x0012 //---------------------------------------------------- -#define SCENEOBJ_CHUNK_VERSION 0x0900 -#define SCENEOBJ_CHUNK_REFERENCE 0x0902 -#define SCENEOBJ_CHUNK_PLACEMENT 0x0904 -#define SCENEOBJ_CHUNK_FLAGS 0x0905 +#define SCENEOBJ_CHUNK_VERSION 0x0900 +#define SCENEOBJ_CHUNK_REFERENCE 0x0902 +#define SCENEOBJ_CHUNK_PLACEMENT 0x0904 +#define SCENEOBJ_CHUNK_FLAGS 0x0905 -bool CSceneObject::LoadLTX(CInifile& ini, LPCSTR sect_name) +bool CSceneObject::LoadLTX(CInifile &ini, LPCSTR sect_name) { bool bRes = true; - do + do { u32 version = ini.r_u32(sect_name, "version"); - CCustomObject::LoadLTX (ini, sect_name); + CCustomObject::LoadLTX(ini, sect_name); - xr_string ref_name = ini.r_string (sect_name, "reference_name"); + xr_string ref_name = ini.r_string(sect_name, "reference_name"); if (!SetReference(ref_name.c_str())) { - ELog.Msg ( mtError, "CSceneObject: '%s' not found in library", ref_name.c_str() ); - bRes = false; - int mr = mrNone; + ELog.Msg(mtError, "CSceneObject: '%s' not found in library", ref_name.c_str()); + bRes = false; + int mr = mrNone; - xr_string _new_name; - bool b_found = Scene->GetSubstObjectName(ref_name.c_str(), _new_name); - if(b_found) + xr_string _new_name; + bool b_found = Scene->GetSubstObjectName(ref_name.c_str(), _new_name); + if (b_found) { xr_string _message; _message = "Object ["+ref_name+"] not found. Relace it with ["+_new_name+"] or select other from library?"; - mr = ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo, _message.c_str()); - if(mrYes==mr) + mr = ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<RegisterSubstObjectName(ref_name.c_str(), new_val); } } Scene->Modified(); } -// if(!CheckVersion()) -// ELog.Msg( mtError, "CSceneObject: '%s' different file version!", ref_name.c_str() ); + // if(!CheckVersion()) + // ELog.Msg( mtError, "CSceneObject: '%s' different file version!", ref_name.c_str() ); - m_Flags.assign(ini.r_u32(sect_name, "flags")); + m_Flags.assign(ini.r_u32(sect_name, "flags")); - if (!bRes) break; - }while(0); + if (!bRes) + break; + } while (0); return bRes; } -void CSceneObject::SaveLTX(CInifile& ini, LPCSTR sect_name) +void CSceneObject::SaveLTX(CInifile &ini, LPCSTR sect_name) { - CCustomObject::SaveLTX (ini, sect_name); + CCustomObject::SaveLTX(ini, sect_name); - ini.w_u32 (sect_name, "version", SCENEOBJ_CURRENT_VERSION); + ini.w_u32(sect_name, "version", SCENEOBJ_CURRENT_VERSION); // reference object version - R_ASSERT (m_pReference); - ini.w_string (sect_name, "reference_name", m_ReferenceName.c_str()); + R_ASSERT(m_pReference); + ini.w_string(sect_name, "reference_name", m_ReferenceName.c_str()); - ini.w_u32 (sect_name, "flags", m_Flags.get()); + ini.w_u32(sect_name, "flags", m_Flags.get()); } -bool CSceneObject::LoadStream(IReader& F) +bool CSceneObject::LoadStream(IReader &F) { bool bRes = true; - do{ + do + { u16 version = 0; string1024 buf; - R_ASSERT(F.r_chunk(SCENEOBJ_CHUNK_VERSION,&version)); + R_ASSERT(F.r_chunk(SCENEOBJ_CHUNK_VERSION, &version)); if (version==0x0010) { - R_ASSERT(F.find_chunk(SCENEOBJ_CHUNK_PLACEMENT)); - F.r_fvector3(FPosition); - F.r_fvector3(FRotation); - F.r_fvector3(FScale); + R_ASSERT(F.find_chunk(SCENEOBJ_CHUNK_PLACEMENT)); + F.r_fvector3(FPosition); + F.r_fvector3(FRotation); + F.r_fvector3(FScale); } - CCustomObject::LoadStream(F); + CCustomObject::LoadStream(F); R_ASSERT(F.find_chunk(SCENEOBJ_CHUNK_REFERENCE)); - if(version<=0x0011) + if (version<=0x0011) { - F.r_u32(); - F.r_u32(); + F.r_u32(); + F.r_u32(); } - F.r_stringZ (buf,sizeof(buf)); + F.r_stringZ(buf, sizeof(buf)); if (!SetReference(buf)) { - ELog.Msg ( mtError, "CSceneObject: '%s' not found in library", buf ); - bRes = false; - int mr = mrNone; + ELog.Msg(mtError, "CSceneObject: '%s' not found in library", buf); + bRes = false; + int mr = mrNone; - xr_string _new_name; - bool b_found = Scene->GetSubstObjectName(buf, _new_name); - if(b_found) + xr_string _new_name; + bool b_found = Scene->GetSubstObjectName(buf, _new_name); + if (b_found) { xr_string _message; _message = "Object ["+xr_string(buf)+"] not found. Relace it with ["+_new_name+"] or select other from library?"; - mr = ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo, _message.c_str()); - if(mrYes==mr) + mr = ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<RegisterSubstObjectName(buf, new_val); } } Scene->Modified(); } -// if(!CheckVersion()){ -// ELog.Msg( mtError, "CSceneObject: '%s' different file version!", buf ); -// } + // if(!CheckVersion()){ + // ELog.Msg( mtError, "CSceneObject: '%s' different file version!", buf ); + // } // flags - if (F.find_chunk(SCENEOBJ_CHUNK_FLAGS)){ - m_Flags.assign(F.r_u32()); + if (F.find_chunk(SCENEOBJ_CHUNK_FLAGS)) + { + m_Flags.assign(F.r_u32()); } - if (!bRes) break; - }while(0); + if (!bRes) + break; + } while (0); return bRes; } -void CSceneObject::SaveStream(IWriter& F) +void CSceneObject::SaveStream(IWriter &F) { - CCustomObject::SaveStream(F); + CCustomObject::SaveStream(F); - F.open_chunk (SCENEOBJ_CHUNK_VERSION); - F.w_u16 (SCENEOBJ_CURRENT_VERSION); - F.close_chunk (); + F.open_chunk(SCENEOBJ_CHUNK_VERSION); + F.w_u16(SCENEOBJ_CURRENT_VERSION); + F.close_chunk(); // reference object version - F.open_chunk (SCENEOBJ_CHUNK_REFERENCE); R_ASSERT2(m_pReference,"Empty SceneObject REFS"); - F.w_stringZ (m_ReferenceName); - F.close_chunk (); - - F.open_chunk (SCENEOBJ_CHUNK_FLAGS); - F.w_u32 (m_Flags.flags); - F.close_chunk (); + F.open_chunk(SCENEOBJ_CHUNK_REFERENCE); + R_ASSERT2(m_pReference, "Empty SceneObject REFS"); + F.w_stringZ(m_ReferenceName); + F.close_chunk(); + + F.open_chunk(SCENEOBJ_CHUNK_FLAGS); + F.w_u32(m_Flags.flags); + F.close_chunk(); } + //---------------------------------------------------- diff --git a/src/editors/LevelEditor/Edit/ScenePick.cpp b/src/editors/LevelEditor/Edit/ScenePick.cpp index 4efe29d9f06..df71cf17695 100644 --- a/src/editors/LevelEditor/Edit/ScenePick.cpp +++ b/src/editors/LevelEditor/Edit/ScenePick.cpp @@ -2,188 +2,234 @@ #pragma hdrstop #include "Scene.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "SceneObject.h" #include "ETools.h" + //------------------------------------------------------------------------------ -int EScene::FrustumPick( const CFrustum& frustum, ObjClassID classfilter, ObjectList& ol ) +int EScene::FrustumPick(const CFrustum &frustum, ObjClassID classfilter, ObjectList &ol) { - int count = 0; + int count = 0; - if (classfilter==OBJCLASS_DUMMY){ + if (classfilter==OBJCLASS_DUMMY) + { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); - for (; _I!=_E; _I++){ - ESceneCustomOTool* mt = dynamic_cast(_I->second); - if (mt) count+=mt->FrustumPick(ol,frustum); + for (; _I!=_E; _I++) + { + ESceneCustomOTool*mt = dynamic_cast(_I->second); + if (mt) + count += mt->FrustumPick(ol, frustum); } - }else{ - ESceneCustomOTool* mt = GetOTool(classfilter); - if (mt) count+=mt->FrustumPick(ol,frustum); + } + else + { + ESceneCustomOTool*mt = GetOTool(classfilter); + if (mt) + count += mt->FrustumPick(ol, frustum); } - return count; + return count; } + //------------------------------------------------------------------------------ -int EScene::SpherePick( const Fvector& center, float radius, ObjClassID classfilter, ObjectList& ol ) +int EScene::SpherePick(const Fvector ¢er, float radius, ObjClassID classfilter, ObjectList &ol) { - int count = 0; + int count = 0; - if (classfilter==OBJCLASS_DUMMY){ + if (classfilter==OBJCLASS_DUMMY) + { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); - for (; _I!=_E; _I++){ - ESceneCustomOTool* mt = dynamic_cast(_I->second); - if (mt) count+=mt->SpherePick(ol,center, radius); + for (; _I!=_E; _I++) + { + ESceneCustomOTool*mt = dynamic_cast(_I->second); + if (mt) + count += mt->SpherePick(ol, center, radius); } - }else{ - ESceneCustomOTool* mt = GetOTool(classfilter); - if (mt) count+=mt->SpherePick(ol,center, radius); + } + else + { + ESceneCustomOTool*mt = GetOTool(classfilter); + if (mt) + count += mt->SpherePick(ol, center, radius); } - return count; + return count; } + //------------------------------------------------------------------------------ -int EScene::RayQuery(SPickQuery& PQ, const Fvector& start, const Fvector& dir, float dist, u32 flags, ObjectList* snap_list) +int EScene::RayQuery(SPickQuery &PQ, const Fvector &start, const Fvector &dir, float dist, u32 flags, ObjectList *snap_list) { - VERIFY (snap_list); - PQ.prepare_rq (start,dir,dist,flags); - ETOOLS::ray_options (flags); - for(ObjectIt _F=snap_list->begin();_F!=snap_list->end();_F++) + VERIFY(snap_list); + PQ.prepare_rq(start, dir, dist, flags); + ETOOLS::ray_options(flags); + for (ObjectIt _F = snap_list->begin(); _F!=snap_list->end(); _F++) ((CSceneObject*)(*_F))->RayQuery(PQ); - return PQ.r_count(); + return PQ.r_count(); } + //------------------------------------------------------------------------------ -int EScene::BoxQuery(SPickQuery& PQ, const Fbox& bb, u32 flags, ObjectList* snap_list) +int EScene::BoxQuery(SPickQuery &PQ, const Fbox &bb, u32 flags, ObjectList *snap_list) { - VERIFY (snap_list); - PQ.prepare_bq (bb,flags); - ETOOLS::box_options (flags); - for(ObjectIt _F=snap_list->begin();_F!=snap_list->end();_F++) + VERIFY(snap_list); + PQ.prepare_bq(bb, flags); + ETOOLS::box_options(flags); + for (ObjectIt _F = snap_list->begin(); _F!=snap_list->end(); _F++) ((CSceneObject*)(*_F))->BoxQuery(PQ); - return PQ.r_count(); + return PQ.r_count(); } + //------------------------------------------------------------------------------ -int EScene::RayQuery(SPickQuery& PQ, const Fvector& start, const Fvector& dir, float dist, u32 flags, CDB::MODEL* model) +int EScene::RayQuery(SPickQuery &PQ, const Fvector &start, const Fvector &dir, float dist, u32 flags, CDB::MODEL *model) { - PQ.prepare_rq (start,dir,dist,flags); - ETOOLS::ray_options (flags); - ETOOLS::ray_query (model,start,dir,dist); - for (int r=0; rbegin();_F!=from_list->end();_F++) - if((*_F)->Visible()&&(*_F)->RayPick(nearest_dist,start,direction,pinf)) + CCustomObject*nearest_object = 0; + if (from_list) + { + for (ObjectIt _F = from_list->begin(); _F!=from_list->end(); _F++) + if ((*_F)->Visible()&&(*_F)->RayPick(nearest_dist, start, direction, pinf)) nearest_object = (*_F); - }else{ - if (classfilter==OBJCLASS_DUMMY){ - CCustomObject *obj = 0; + } + else + { + if (classfilter==OBJCLASS_DUMMY) + { + CCustomObject*obj = 0; SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); - for (; _I!=_E; _I++){ - ESceneCustomOTool* mt = dynamic_cast(_I->second); - if (mt&&mt->RayPick(obj,nearest_dist,start,direction,pinf)) nearest_object = obj; + for (; _I!=_E; _I++) + { + ESceneCustomOTool*mt = dynamic_cast(_I->second); + if (mt&&mt->RayPick(obj, nearest_dist, start, direction, pinf)) + nearest_object = obj; } - }else{ - ESceneCustomOTool* mt = GetOTool(classfilter); - if (mt) mt->RayPick(nearest_object,nearest_dist,start,direction,pinf); + } + else + { + ESceneCustomOTool*mt = GetOTool(classfilter); + if (mt) + mt->RayPick(nearest_object, nearest_dist, start, direction, pinf); } } - return nearest_object; + return nearest_object; } + //------------------------------------------------------------------------------ -int EScene::GetQueryObjects(ObjectList& lst, ObjClassID classfilter, int iSel, int iVis, int iLock) +int EScene::GetQueryObjects(ObjectList &lst, ObjClassID classfilter, int iSel, int iVis, int iLock) { - if (classfilter==OBJCLASS_DUMMY){ + if (classfilter==OBJCLASS_DUMMY) + { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { - ESceneCustomOTool* mt = dynamic_cast(_I->second); - if (mt) mt->GetQueryObjects(lst, iSel, iVis, iLock); + ESceneCustomOTool*mt = dynamic_cast(_I->second); + if (mt) + mt->GetQueryObjects(lst, iSel, iVis, iLock); } - }else{ - ESceneCustomOTool* mt = GetOTool(classfilter); - if (mt) mt->GetQueryObjects(lst, iSel, iVis, iLock); + } + else + { + ESceneCustomOTool*mt = GetOTool(classfilter); + if (mt) + mt->GetQueryObjects(lst, iSel, iVis, iLock); } return lst.size(); } + //------------------------------------------------------------------------------ int EScene::RaySelect(int flag, ObjClassID classfilter) { - if( !valid() ) return 0; + if (!valid()) + return 0; - float dist = UI->ZFar(); - ESceneToolBase* mt = 0; + float dist = UI->ZFar(); + ESceneToolBase*mt = 0; if (classfilter==OBJCLASS_DUMMY) { - SceneToolsMapPairIt _I = m_SceneTools.begin(); - SceneToolsMapPairIt _E = m_SceneTools.end(); + SceneToolsMapPairIt _I = m_SceneTools.begin(); + SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) { - float range = UI->ZFar(); - _I->second->RaySelect(flag,range,UI->m_CurrentRStart,UI->m_CurrentRDir,TRUE); - if (rangesecond; - } + float range = UI->ZFar(); + _I->second->RaySelect(flag, range, UI->m_CurrentRStart, UI->m_CurrentRDir, TRUE); + if (rangesecond; + } } - }else{ - mt = GetTool(classfilter); } - int count = 0; - dist = UI->ZFar(); - if (mt) - count=mt->RaySelect (flag,dist,UI->m_CurrentRStart,UI->m_CurrentRDir,FALSE); - return count; -/* - CCustomObject *nearest_object = RayPickObject(flt_max,UI->m_CurrentRStart,UI->m_CurrentRNorm,classfilter,0,0); - if (nearest_object) nearest_object->Select(flag); - UI->RedrawScene(); - return nearest_object?1:0; -*/ + else + { + mt = GetTool(classfilter); + } + int count = 0; + dist = UI->ZFar(); + if (mt) + count = mt->RaySelect(flag, dist, UI->m_CurrentRStart, UI->m_CurrentRDir, FALSE); + return count; + /* + CCustomObject *nearest_object = RayPickObject(flt_max,UI->m_CurrentRStart,UI->m_CurrentRNorm,classfilter,0,0); + if (nearest_object) nearest_object->Select(flag); + UI->RedrawScene(); + return nearest_object?1:0; + */ } + //------------------------------------------------------------------------------ -int EScene::BoxPickObjects(const Fbox& box, SBoxPickInfoVec& pinf, ObjectList* lst) +int EScene::BoxPickObjects(const Fbox &box, SBoxPickInfoVec &pinf, ObjectList *lst) { - if (lst){ - for(ObjectIt _F=lst->begin();_F!=lst->end();_F++){ - CSceneObject* _S = dynamic_cast(*_F); - if (_S) _S->BoxPick(box,pinf); + if (lst) + { + for (ObjectIt _F = lst->begin(); _F!=lst->end(); _F++) + { + CSceneObject *_S = dynamic_cast(*_F); + if (_S) + _S->BoxPick(box, pinf); } } return pinf.size(); } + //------------------------------------------------------------------------------ - + + diff --git a/src/editors/LevelEditor/Edit/SceneRender.cpp b/src/editors/LevelEditor/Edit/SceneRender.cpp index 157f60017d0..305a0180a34 100644 --- a/src/editors/LevelEditor/Edit/SceneRender.cpp +++ b/src/editors/LevelEditor/Edit/SceneRender.cpp @@ -3,8 +3,8 @@ #include "Scene.h" #include "SceneObject.h" -#include "bottombar.h" -#include "d3dutils.h" +#include "BottomBar.h" +#include "D3DUtils.h" //------------------------------------------------------------------------------ @@ -17,16 +17,48 @@ ELog.DlgMsg(mtError, "Please notify AlexMX!!! Critical error has occured in render routine!!! [Type B] - Tools: '%s' Object: '%s'",(N->val)->ParentTool->ClassName(),(N->val)->Name);\ }\ } - -void __fastcall object_Normal_0(EScene::mapObject_Node *N) {RENDER_OBJECT(0,false); } -void __fastcall object_Normal_1(EScene::mapObject_Node *N) {RENDER_OBJECT(1,false); } -void __fastcall object_Normal_2(EScene::mapObject_Node *N) {RENDER_OBJECT(2,false); } -void __fastcall object_Normal_3(EScene::mapObject_Node *N) {RENDER_OBJECT(3,false); } + +void __fastcall object_Normal_0(EScene::mapObject_Node *N) +{ + RENDER_OBJECT(0,false); +} + +void __fastcall object_Normal_1(EScene::mapObject_Node *N) +{ + RENDER_OBJECT(1,false); +} + +void __fastcall object_Normal_2(EScene::mapObject_Node *N) +{ + RENDER_OBJECT(2,false); +} + +void __fastcall object_Normal_3(EScene::mapObject_Node *N) +{ + RENDER_OBJECT(3,false); +} + //------------------------------------------------------------------------------ -void __fastcall object_StrictB2F_0(EScene::mapObject_Node *N){RENDER_OBJECT(0,true);} -void __fastcall object_StrictB2F_1(EScene::mapObject_Node *N){RENDER_OBJECT(1,true);} -void __fastcall object_StrictB2F_2(EScene::mapObject_Node *N){RENDER_OBJECT(2,true);} -void __fastcall object_StrictB2F_3(EScene::mapObject_Node *N){RENDER_OBJECT(3,true);} +void __fastcall object_StrictB2F_0(EScene::mapObject_Node *N) +{ + RENDER_OBJECT(0,true); +} + +void __fastcall object_StrictB2F_1(EScene::mapObject_Node *N) +{ + RENDER_OBJECT(1,true); +} + +void __fastcall object_StrictB2F_2(EScene::mapObject_Node *N) +{ + RENDER_OBJECT(2,true); +} + +void __fastcall object_StrictB2F_3(EScene::mapObject_Node *N) +{ + RENDER_OBJECT(3,true); +} + //------------------------------------------------------------------------------ #define RENDER_SCENE_TOOLS(P,B)\ @@ -44,29 +76,35 @@ void __fastcall object_StrictB2F_3(EScene::mapObject_Node *N){RENDER_OBJECT(3,tr }\ } -void EScene::RenderSky(const Fmatrix& camera) +void EScene::RenderSky(const Fmatrix &camera) { - if( !valid() ) return; - -// draw sky -/* -//. - if (m_SkyDome&&fraBottomBar->miDrawSky->Checked){ - st_Environment& E = m_LevelOp.m_Envs[m_LevelOp.m_CurEnv]; - m_SkyDome->PPosition = camera.c; - m_SkyDome->UpdateTransform(true); - EDevice.SetRS(D3DRS_TEXTUREFACTOR, E.m_SkyColor.get()); - m_SkyDome->RenderSingle(); - EDevice.SetRS(D3DRS_TEXTUREFACTOR, 0xffffffff); - } -*/ + if (!valid()) + return; + + // draw sky + /* + //. + if (m_SkyDome&&fraBottomBar->miDrawSky->Checked){ + st_Environment& E = m_LevelOp.m_Envs[m_LevelOp.m_CurEnv]; + m_SkyDome->PPosition = camera.c; + m_SkyDome->UpdateTransform(true); + EDevice.SetRS(D3DRS_TEXTUREFACTOR, E.m_SkyColor.get()); + m_SkyDome->RenderSingle(); + EDevice.SetRS(D3DRS_TEXTUREFACTOR, 0xffffffff); + } + */ } + //------------------------------------------------------------------------------ struct tools_rp_pred : public std::binary_function { - IC bool operator()(ESceneToolBase* x, ESceneToolBase* y) const - { return x->RenderPriority()RenderPriority(); } + IC + + bool operator()(ESceneToolBase *x, ESceneToolBase *y) const + { + return x->RenderPriority()RenderPriority(); + } }; #define DEFINE_MSET_PRED(T,N,I,P) typedef xr_multiset< T, P > N; typedef N::iterator I; @@ -75,88 +113,95 @@ DEFINE_MSET_PRED(ESceneToolBase*,SceneMToolsSet,SceneMToolsIt,tools_rp_pred); DEFINE_MSET_PRED(ESceneCustomOTool*,SceneOToolsSet,SceneOToolsIt,tools_rp_pred); -void EScene::Render( const Fmatrix& camera ) +void EScene::Render(const Fmatrix &camera) { - if( !valid() ) return; + if (!valid()) + return; -// if( locked() ) return; + // if( locked() ) return; // extract and sort object tools SceneOToolsSet object_tools; SceneMToolsSet scene_tools; { - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); for (; t_it!=t_end; t_it++) - if (t_it->second){ - // before render - t_it->second->BeforeRender(); + if (t_it->second) + { + // before render + t_it->second->BeforeRender(); // sort tools - ESceneCustomOTool* mt = dynamic_cast(t_it->second); - if (mt) object_tools.insert(mt); - scene_tools.insert (t_it->second); + ESceneCustomOTool*mt = dynamic_cast(t_it->second); + if (mt) + object_tools.insert(mt); + scene_tools.insert(t_it->second); } } // insert objects { - SceneOToolsIt t_it = object_tools.begin(); - SceneOToolsIt t_end = object_tools.end(); + SceneOToolsIt t_it = object_tools.begin(); + SceneOToolsIt t_end = object_tools.end(); for (; t_it!=t_end; t_it++) { - ObjectList& lst = (*t_it)->GetObjects(); - ObjectIt o_it = lst.begin(); - ObjectIt o_end = lst.end(); - for(;o_it!=o_end;o_it++){ - if( (*o_it)->Visible()&& (*o_it)->IsRender() ){ + ObjectList&lst = (*t_it)->GetObjects(); + ObjectIt o_it = lst.begin(); + ObjectIt o_end = lst.end(); + for (; o_it!=o_end; o_it++) + { + if ((*o_it)->Visible()&&(*o_it)->IsRender()) + { float distSQ = EDevice.vCameraPosition.distance_to_sqr((*o_it)->FPosition); - mapRenderObjects.insertInAnyWay(distSQ,*o_it); + mapRenderObjects.insertInAnyWay(distSQ, *o_it); } } } } - -// priority #0 + + // priority #0 // normal - mapRenderObjects.traverseLR (object_Normal_0); - RENDER_SCENE_TOOLS (0,false); + mapRenderObjects.traverseLR(object_Normal_0); + RENDER_SCENE_TOOLS (0,false); // alpha - mapRenderObjects.traverseRL (object_StrictB2F_0); - RENDER_SCENE_TOOLS (0,true); + mapRenderObjects.traverseRL(object_StrictB2F_0); + RENDER_SCENE_TOOLS (0,true); -// priority #1 + // priority #1 // normal - mapRenderObjects.traverseLR (object_Normal_1); - RENDER_SCENE_TOOLS (1,false); + mapRenderObjects.traverseLR(object_Normal_1); + RENDER_SCENE_TOOLS (1,false); // alpha - mapRenderObjects.traverseRL (object_StrictB2F_1); - RENDER_SCENE_TOOLS (1,true); -// priority #2 + mapRenderObjects.traverseRL(object_StrictB2F_1); + RENDER_SCENE_TOOLS (1,true); + // priority #2 // normal - mapRenderObjects.traverseLR (object_Normal_2); - RENDER_SCENE_TOOLS (2,false); + mapRenderObjects.traverseLR(object_Normal_2); + RENDER_SCENE_TOOLS (2,false); // alpha - mapRenderObjects.traverseRL (object_StrictB2F_2); - RENDER_SCENE_TOOLS (2,true); -// priority #3 + mapRenderObjects.traverseRL(object_StrictB2F_2); + RENDER_SCENE_TOOLS (2,true); + // priority #3 // normal - mapRenderObjects.traverseLR (object_Normal_3); - RENDER_SCENE_TOOLS (3,false); + mapRenderObjects.traverseLR(object_Normal_3); + RENDER_SCENE_TOOLS (3,false); // alpha - mapRenderObjects.traverseRL (object_StrictB2F_3); - RENDER_SCENE_TOOLS (3,true); + mapRenderObjects.traverseRL(object_StrictB2F_3); + RENDER_SCENE_TOOLS (3,true); // render snap - RenderSnapList (); + RenderSnapList(); // clear - mapRenderObjects.clear (); + mapRenderObjects.clear(); - SceneMToolsIt s_it = scene_tools.begin(); - SceneMToolsIt s_end = scene_tools.end(); - for (; s_it!=s_end; s_it++) (*s_it)->AfterRender(); + SceneMToolsIt s_it = scene_tools.begin(); + SceneMToolsIt s_end = scene_tools.end(); + for (; s_it!=s_end; s_it++) + (*s_it)->AfterRender(); } + //------------------------------------------------------------------------------ - + diff --git a/src/editors/LevelEditor/Edit/SceneSelection.cpp b/src/editors/LevelEditor/Edit/SceneSelection.cpp index d728ccdf93d..60a0868e60e 100644 --- a/src/editors/LevelEditor/Edit/SceneSelection.cpp +++ b/src/editors/LevelEditor/Edit/SceneSelection.cpp @@ -2,139 +2,174 @@ #pragma hdrstop #include "Scene.h" -#include "ui_levelmain.h" +#include "UI_LevelMain.h" + //------------------------------------------------------------------------------ -void EScene::SelectObjects( bool flag, ObjClassID classfilter ) +void EScene::SelectObjects(bool flag, ObjClassID classfilter) { - if (classfilter==OBJCLASS_DUMMY){ + if (classfilter==OBJCLASS_DUMMY) + { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) - if (_I->second) _I->second->SelectObjects(flag); - }else{ - ESceneToolBase* mt = GetTool(classfilter); + if (_I->second) + _I->second->SelectObjects(flag); + } + else + { + ESceneToolBase*mt = GetTool(classfilter); if (mt) - mt->SelectObjects(flag); + mt->SelectObjects(flag); } UI->RedrawScene(); } + //------------------------------------------------------------------------------ -int EScene::FrustumSelect( int flag, ObjClassID classfilter ) +int EScene::FrustumSelect(int flag, ObjClassID classfilter) { - CFrustum frustum; - int count = 0; - if (!LUI->SelectionFrustum(frustum)) return 0; + CFrustum frustum; + int count = 0; + if (!LUI->SelectionFrustum(frustum)) + return 0; if (classfilter==OBJCLASS_DUMMY) { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) - if (_I->second) count+=_I->second->FrustumSelect(flag,frustum); - }else{ - ESceneToolBase* mt = GetTool(classfilter); + if (_I->second) + count += _I->second->FrustumSelect(flag, frustum); + } + else + { + ESceneToolBase*mt = GetTool(classfilter); if (mt) - count+=mt->FrustumSelect(flag,frustum); + count += mt->FrustumSelect(flag, frustum); } - + UI->RedrawScene(); - return count; + return count; } + //------------------------------------------------------------------------------ -void EScene::InvertSelection( ObjClassID classfilter ) +void EScene::InvertSelection(ObjClassID classfilter) { if (classfilter==OBJCLASS_DUMMY) { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) - if (_I->second) _I->second->InvertSelection(); - }else + if (_I->second) + _I->second->InvertSelection(); + } + else { - ESceneToolBase* mt = GetTool(classfilter); + ESceneToolBase*mt = GetTool(classfilter); if (mt) - mt->InvertSelection(); + mt->InvertSelection(); } UI->RedrawScene(); } + //------------------------------------------------------------------------------ -void EScene::RemoveSelection( ObjClassID classfilter ) +void EScene::RemoveSelection(ObjClassID classfilter) { - if (classfilter==OBJCLASS_DUMMY){ + if (classfilter==OBJCLASS_DUMMY) + { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) - if (_I->second&&_I->second->IsEditable()) _I->second->RemoveSelection(); - }else{ - ESceneToolBase* mt = GetTool(classfilter); - if (mt&&mt->IsEditable()) mt->RemoveSelection(); + if (_I->second&&_I->second->IsEditable()) + _I->second->RemoveSelection(); + } + else + { + ESceneToolBase*mt = GetTool(classfilter); + if (mt&&mt->IsEditable()) + mt->RemoveSelection(); } - UI->UpdateScene (true); + UI->UpdateScene(true); } + //------------------------------------------------------------------------------ int EScene::SelectionCount(bool testflag, ObjClassID classfilter) { - int count = 0; + int count = 0; - if (classfilter==OBJCLASS_DUMMY){ + if (classfilter==OBJCLASS_DUMMY) + { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) - if (_I->second) count+=_I->second->SelectionCount(testflag); - }else{ - ESceneToolBase* mt = GetTool(classfilter); - if (mt) count+=mt->SelectionCount(testflag); + if (_I->second) + count += _I->second->SelectionCount(testflag); + } + else + { + ESceneToolBase*mt = GetTool(classfilter); + if (mt) + count += mt->SelectionCount(testflag); } return count; } + //------------------------------------------------------------------------------ -bool EScene::ContainsObject( CCustomObject* object, ObjClassID classfilter ) +bool EScene::ContainsObject(CCustomObject *object, ObjClassID classfilter) { - VERIFY( object ); - VERIFY( m_Valid ); - ObjectList& lst = ListObj(classfilter); - ObjectIt it = std::find(lst.begin(), lst.end(), object); - if (it!=lst.end()) return true; + VERIFY(object); + VERIFY(m_Valid); + ObjectList&lst = ListObj(classfilter); + ObjectIt it = std::find(lst.begin(), lst.end(), object); + if (it!=lst.end()) + return true; return false; } + //------------------------------------------------------------------------------ int EScene::ObjCount() { - int cnt = 0; + int cnt = 0; SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); - for (; _I!=_E; _I++){ - ESceneCustomOTool* mt = dynamic_cast(_I->second); - if (mt) - cnt+=mt->ObjCount(); + for (; _I!=_E; _I++) + { + ESceneCustomOTool*mt = dynamic_cast(_I->second); + if (mt) + cnt += mt->ObjCount(); } - return cnt; + return cnt; } + //------------------------------------------------------------------------------ -void EScene::ShowObjects( bool flag, ObjClassID classfilter, bool bAllowSelectionFlag, bool bSelFlag ) +void EScene::ShowObjects(bool flag, ObjClassID classfilter, bool bAllowSelectionFlag, bool bSelFlag) { - if (classfilter==OBJCLASS_DUMMY){ + if (classfilter==OBJCLASS_DUMMY) + { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) - if (_I->second) _I->second->ShowObjects(flag, bAllowSelectionFlag, bSelFlag); - }else{ - ESceneToolBase* mt = GetTool(classfilter); + if (_I->second) + _I->second->ShowObjects(flag, bAllowSelectionFlag, bSelFlag); + } + else + { + ESceneToolBase*mt = GetTool(classfilter); if (mt) - mt->ShowObjects(flag, bAllowSelectionFlag, bSelFlag); + mt->ShowObjects(flag, bAllowSelectionFlag, bSelFlag); } UI->RedrawScene(); } + //------------------------------------------------------------------------------ void EScene::SynchronizeObjects() @@ -142,28 +177,42 @@ void EScene::SynchronizeObjects() SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) - if (_I->second) _I->second->OnSynchronize(); + if (_I->second) + _I->second->OnSynchronize(); } + //------------------------------------------------------------------------------ -void EScene::ZoomExtents( ObjClassID cls, BOOL bSel ) +void EScene::ZoomExtents(ObjClassID cls, BOOL bSel) { - Fbox BB; BB.invalidate(); - if (cls==OBJCLASS_DUMMY){ + Fbox BB; + BB.invalidate(); + if (cls==OBJCLASS_DUMMY) + { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) - if (_I->second){ - Fbox bb; bb.invalidate(); - _I->second->GetBBox (bb,bSel); - if (bb.is_valid()) BB.merge(bb); + if (_I->second) + { + Fbox bb; + bb.invalidate(); + _I->second->GetBBox(bb, bSel); + if (bb.is_valid()) + BB.merge(bb); } - }else{ - ESceneToolBase* mt = GetTool(cls); - if (mt) mt->GetBBox(BB,bSel); } - if (BB.is_valid()) EDevice.m_Camera.ZoomExtents(BB); - else ELog.Msg(mtError,"Can't calculate bounding box. Nothing selected or some object unsupported this function."); + else + { + ESceneToolBase*mt = GetTool(cls); + if (mt) + mt->GetBBox(BB, bSel); + } + if (BB.is_valid()) + EDevice.m_Camera.ZoomExtents(BB); + else + ELog.Msg(mtError, "Can't calculate bounding box. Nothing selected or some object unsupported this function."); } + //------------------------------------------------------------------------------ + diff --git a/src/editors/LevelEditor/Edit/SceneSnap.cpp b/src/editors/LevelEditor/Edit/SceneSnap.cpp index 6b1747f8c17..f973de2ac67 100644 --- a/src/editors/LevelEditor/Edit/SceneSnap.cpp +++ b/src/editors/LevelEditor/Edit/SceneSnap.cpp @@ -2,168 +2,205 @@ #pragma hdrstop #include "scene.h" -#include "leftbar.h" -#include "ui_leveltools.h" +#include "LeftBar.h" +#include "UI_LevelTools.h" #include "SceneObject.h" -#include "../ECore/Editor/UI_Main.h" +#include "editors/ECore/Editor/UI_Main.h" + //------------------------------------------------------------------------------ - -ObjectList* EScene::GetSnapList(bool bIgnoreUse) + +ObjectList *EScene::GetSnapList(bool bIgnoreUse) { - ObjClassID cls = LTools->CurrentClassID(); - ESceneToolBase* mt = m_SceneTools[cls]; - if (0==mt) return 0; - ObjectList* snap_list = mt->GetSnapList()?mt->GetSnapList():&m_ESO_SnapObjects; - return bIgnoreUse?snap_list:(fraLeftBar->ebUseSnapList->Down?snap_list:NULL); + ObjClassID cls = LTools->CurrentClassID(); + ESceneToolBase*mt = m_SceneTools[cls]; + if (0==mt) + return 0; + ObjectList*snap_list = mt->GetSnapList() ? mt->GetSnapList() : &m_ESO_SnapObjects; + return bIgnoreUse ? snap_list : (fraLeftBar->ebUseSnapList->Down ? snap_list : NULL); } + //-------------------------------------------------------------------------------------------------- -bool EScene::FindObjectInSnapList(CCustomObject* O) +bool EScene::FindObjectInSnapList(CCustomObject *O) { - ObjectList* snap_objects = GetSnapList(true); - return snap_objects?std::find(snap_objects->begin(),snap_objects->end(),O)!=snap_objects->end():false; + ObjectList*snap_objects = GetSnapList(true); + return snap_objects ? std::find(snap_objects->begin(), snap_objects->end(), O)!=snap_objects->end() : false; } void EScene::RenderSnapList() { - ObjectList* lst = GetSnapList(false); - if (lst){ - for(ObjectIt _F=lst->begin();_F!=lst->end();_F++) - if((*_F)->Visible()) ((CSceneObject*)(*_F))->RenderSelection(); + ObjectList*lst = GetSnapList(false); + if (lst) + { + for (ObjectIt _F = lst->begin(); _F!=lst->end(); _F++) + if ((*_F)->Visible()) + ((CSceneObject*)(*_F))->RenderSelection(); } } + //------------------------------------------------------------------------------ -bool EScene::AddToSnapList(CCustomObject* O, bool bUpdateScene) +bool EScene::AddToSnapList(CCustomObject *O, bool bUpdateScene) { - if (!O) return false; - ObjectList* snap_objects = GetSnapList(true); - if (snap_objects){ - if (std::find(snap_objects->begin(),snap_objects->end(),O)==snap_objects->end()){ + if (!O) + return false; + ObjectList*snap_objects = GetSnapList(true); + if (snap_objects) + { + if (std::find(snap_objects->begin(), snap_objects->end(), O)==snap_objects->end()) + { snap_objects->push_back(O); - if (bUpdateScene){ - UI->RedrawScene(); - UpdateSnapList(); - UndoSave(); + if (bUpdateScene) + { + UI->RedrawScene(); + UpdateSnapList(); + UndoSave(); } - return true; + return true; } } return false; } + //------------------------------------------------------------------------------ -bool EScene::DelFromSnapList(CCustomObject* O, bool bUpdateScene) +bool EScene::DelFromSnapList(CCustomObject *O, bool bUpdateScene) { - ObjectList* snap_objects = GetSnapList(true); - if (snap_objects){ - ObjectIt it = std::find(snap_objects->begin(),snap_objects->end(),O); - if (it!=snap_objects->end()){ + ObjectList*snap_objects = GetSnapList(true); + if (snap_objects) + { + ObjectIt it = std::find(snap_objects->begin(), snap_objects->end(), O); + if (it!=snap_objects->end()) + { snap_objects->erase(it); - if (bUpdateScene){ - UI->RedrawScene(); - UpdateSnapList(); - UndoSave(); + if (bUpdateScene) + { + UI->RedrawScene(); + UpdateSnapList(); + UndoSave(); } return true; } } return false; } + //------------------------------------------------------------------------------ int EScene::AddSelToSnapList() { - int count = 0; - if (GetSnapList(true)){ + int count = 0; + if (GetSnapList(true)) + { ObjectList lst; int count = GetQueryObjects(lst, OBJCLASS_SCENEOBJECT, 1, 1, 0); - if (count){ + if (count) + { count = 0; - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) - if (AddToSnapList(*_F,false)) count++; - if (count){ + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + if (AddToSnapList(*_F, false)) + count++; + if (count) + { UI->RedrawScene(); UpdateSnapList(); - UndoSave(); + UndoSave(); } } } - return count; + return count; } + //------------------------------------------------------------------------------ int EScene::DelSelFromSnapList() { - int count = 0; - if (GetSnapList(true)){ + int count = 0; + if (GetSnapList(true)) + { ObjectList lst; int count = GetQueryObjects(lst, OBJCLASS_SCENEOBJECT, 1, 1, 0); - if (count){ + if (count) + { count = 0; - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) - if (DelFromSnapList(*_F,false)) count++; - if (count){ + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + if (DelFromSnapList(*_F, false)) + count++; + if (count) + { UI->RedrawScene(); UpdateSnapList(); - UndoSave(); + UndoSave(); } } } return count; } + //------------------------------------------------------------------------------ int EScene::SetSnapList() { - ClearSnapList(true); - ObjectList* snap_objects = GetSnapList(true); - int count = 0; - if (snap_objects){ - ObjectList& lst = ListObj(OBJCLASS_SCENEOBJECT); - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) - if((*_F)->Visible()&&(*_F)->Selected()){ + ClearSnapList(true); + ObjectList*snap_objects = GetSnapList(true); + int count = 0; + if (snap_objects) + { + ObjectList&lst = ListObj(OBJCLASS_SCENEOBJECT); + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + if ((*_F)->Visible()&&(*_F)->Selected()) + { snap_objects->push_back(*_F); count++; } UI->RedrawScene(); UpdateSnapList(); - UndoSave(); + UndoSave(); } - return count; + return count; } + //------------------------------------------------------------------------------ void EScene::ClearSnapList(bool bCurrentOnly) { - if (bCurrentOnly){ - ObjectList* snap_objects = GetSnapList(true); - if (snap_objects){ - snap_objects->clear(); - UpdateSnapList(); + if (bCurrentOnly) + { + ObjectList*snap_objects = GetSnapList(true); + if (snap_objects) + { + snap_objects->clear(); + UpdateSnapList(); UndoSave(); - } - }else{ - m_ESO_SnapObjects.clear(); - for (int i=0; iGetSnapList()) mt->GetSnapList()->clear(); + } + } + else + { + m_ESO_SnapObjects.clear(); + for (int i = 0; iGetSnapList()) + mt->GetSnapList()->clear(); } UpdateSnapList(); } } + //------------------------------------------------------------------------------ void EScene::SelectSnapList() { - ObjectList* snap_objects = GetSnapList(true); - if (snap_objects){ - SelectObjects(FALSE,OBJCLASS_SCENEOBJECT); - for(ObjectIt _F = snap_objects->begin();_F!=snap_objects->end();_F++) + ObjectList*snap_objects = GetSnapList(true); + if (snap_objects) + { + SelectObjects(FALSE, OBJCLASS_SCENEOBJECT); + for (ObjectIt _F = snap_objects->begin(); _F!=snap_objects->end(); _F++) (*_F)->Select(TRUE); UI->RedrawScene(); } } + //------------------------------------------------------------------------------ void EScene::UpdateSnapList() @@ -173,17 +210,24 @@ void EScene::UpdateSnapList() void EScene::UpdateSnapListReal() { - if (NULL==LTools) return; + if (NULL==LTools) + return; ObjClassID cls = LTools->CurrentClassID(); - switch (cls){ - case OBJCLASS_DUMMY: break; - default: - ESceneToolBase* mt = m_SceneTools[cls]; - if (mt) mt->UpdateSnapList(); + switch (cls) + { + case OBJCLASS_DUMMY: break; + default: + ESceneToolBase*mt = m_SceneTools[cls]; + if (mt) + mt->UpdateSnapList(); } - // visual update - if (fraLeftBar) fraLeftBar->UpdateSnapList(); + // visual update + if (fraLeftBar) + fraLeftBar->UpdateSnapList(); m_RTFlags.set(flUpdateSnapList, FALSE); } + //------------------------------------------------------------------------------ + + diff --git a/src/editors/LevelEditor/Edit/SceneSummaryInfo.cpp b/src/editors/LevelEditor/Edit/SceneSummaryInfo.cpp index d3187fb7146..ce0feb9488b 100644 --- a/src/editors/LevelEditor/Edit/SceneSummaryInfo.cpp +++ b/src/editors/LevelEditor/Edit/SceneSummaryInfo.cpp @@ -2,445 +2,539 @@ #pragma hdrstop #include "SceneSummaryInfo.h" -#include "../ECore/Editor/ImageManager.h" -#include "../ECore/Editor/EThumbnail.h" +#include "editors/ECore/Editor/ImageManager.h" +#include "editors/ECore/Editor/EThumbnail.h" #include "SceneSummaryInfo.h" #include "Scene.h" #include "SceneObject.h" -#include "../ECore/Editor/ui_main.h" -#include "ui_levelmain.h" -#include "../ECore/Editor/Library.h" +#include "editors/ECore/Editor/ui_main.h" +#include "UI_LevelMain.h" +#include "editors/ECore/Editor/Library.h" static SSceneSummary s_summary; -xr_token summary_texture_type_tokens[]={ - { "Base", SSceneSummary::sttBase }, - { "Implicit", SSceneSummary::sttImplicit }, - { "DO", SSceneSummary::sttDO }, - { "Glow", SSceneSummary::sttGlow }, - { "LOD", SSceneSummary::sttLOD }, - { 0, 0 } +xr_token summary_texture_type_tokens[] = { + {"Base", SSceneSummary::sttBase}, + {"Implicit", SSceneSummary::sttImplicit}, + {"DO", SSceneSummary::sttDO}, + {"Glow", SSceneSummary::sttGlow}, + {"LOD", SSceneSummary::sttLOD}, + {0, 0} }; void SSceneSummary::Prepare() { - for (TISetIt t_it=textures.begin(); t_it!=textures.end(); t_it++){ - STextureInfo* info = (STextureInfo*)(&(*t_it)); - if (!info->bReady) info->Prepare(); + for (TISetIt t_it = textures.begin(); t_it!=textures.end(); t_it++) + { + STextureInfo *info = (STextureInfo*)(&(*t_it)); + if (!info->bReady) + info->Prepare(); } - for (OISetIt o_it=objects.begin(); o_it!=objects.end(); o_it++){ - SObjectInfo* info = (SObjectInfo*)(&(*o_it)); - if (!info->bReady) info->Prepare(); + for (OISetIt o_it = objects.begin(); o_it!=objects.end(); o_it++) + { + SObjectInfo *info = (SObjectInfo*)(&(*o_it)); + if (!info->bReady) + info->Prepare(); } } xr_string _itoa(int val) { - string64 tmp; - return itoa(val,tmp,10); + string64 tmp; + return itoa(val, tmp, 10); } + void SSceneSummary::SObjectInfo::Prepare() { - bReady = true; - if (object_name.size()){ - CEditableObject* O = Lib.CreateEditObject(object_name.c_str()); - xr_string pref = object_name.c_str(); - if (O){ - SPairInfo tmp; - tmp.first = pref+"\\References"; - tmp.second = _itoa(ref_count); - info.push_back (tmp); - tmp.first = pref+"\\Geometry\\Faces"; tmp.second = _itoa(O->GetFaceCount()); info.push_back (tmp); - tmp.first = pref+"\\Geometry\\Vertices"; tmp.second = _itoa(O->GetVertexCount()); info.push_back (tmp); - SurfaceVec& surfaces = O->Surfaces(); - for (SurfaceIt it=surfaces.begin(); it!=surfaces.end(); it++){ - xr_string pr= pref+xr_string("\\Materials\\")+(*it)->_Name(); - tmp.first = pr+"\\Texture"; tmp.second = (*it)->_Texture(); info.push_back (tmp); - tmp.first = pr+"\\Faces"; tmp.second = _itoa(O->GetSurfFaceCount((*it)->_Name()));info.push_back (tmp); + bReady = true; + if (object_name.size()) + { + CEditableObject *O = Lib.CreateEditObject(object_name.c_str()); + xr_string pref = object_name.c_str(); + if (O) + { + SPairInfo tmp; + tmp.first = pref+"\\References"; + tmp.second = _itoa(ref_count); + info.push_back(tmp); + tmp.first = pref+"\\Geometry\\Faces"; + tmp.second = _itoa(O->GetFaceCount()); + info.push_back(tmp); + tmp.first = pref+"\\Geometry\\Vertices"; + tmp.second = _itoa(O->GetVertexCount()); + info.push_back(tmp); + SurfaceVec &surfaces = O->Surfaces(); + for (SurfaceIt it = surfaces.begin(); it!=surfaces.end(); it++) + { + xr_string pr = pref+xr_string("\\Materials\\")+(*it)->_Name(); + tmp.first = pr+"\\Texture"; + tmp.second = (*it)->_Texture(); + info.push_back(tmp); + tmp.first = pr+"\\Faces"; + tmp.second = _itoa(O->GetSurfFaceCount((*it)->_Name())); + info.push_back(tmp); } - Lib.RemoveEditObject(O); + Lib.RemoveEditObject(O); } - }else{ + } + else + { Msg("!Empty object name found."); } } -void SSceneSummary::SObjectInfo::FillProp(PropItemVec& items, LPCSTR main_pref) + +void SSceneSummary::SObjectInfo::FillProp(PropItemVec &items, LPCSTR main_pref) { - if (object_name.size()){ - for (PIVecIt it=info.begin(); it!=info.end(); it++) - PHelper().CreateCaption(items,PrepareKey(main_pref,it->first.c_str()), it->second.c_str()); + if (object_name.size()) + { + for (PIVecIt it = info.begin(); it!=info.end(); it++) + PHelper().CreateCaption(items, PrepareKey(main_pref, it->first.c_str()), it->second.c_str()); } } -void SSceneSummary::SObjectInfo::Export (IWriter* F) + +void SSceneSummary::SObjectInfo::Export(IWriter *F) { - string1024 tmp; - for (PIVecIt it=info.begin(); it!=info.end(); it++){ - sprintf (tmp,"%s=%s",it->first.c_str(),it->second.c_str()); - F->w_string (tmp); + string1024 tmp; + for (PIVecIt it = info.begin(); it!=info.end(); it++) + { + sprintf(tmp, "%s=%s", it->first.c_str(), it->second.c_str()); + F->w_string(tmp); } } -void SSceneSummary::STextureInfo::Prepare () +void SSceneSummary::STextureInfo::Prepare() { - bReady = true; - if (file_name.size()){ - ETextureThumbnail* T= (ETextureThumbnail*)ImageLib.CreateThumbnail(file_name.c_str(),ECustomThumbnail::ETTexture,true); - if (!T->Valid()){ - Msg("!Can't get info from texture: '%s'",file_name.c_str()); - }else{ - info = T->_Format(); + bReady = true; + if (file_name.size()) + { + ETextureThumbnail *T = (ETextureThumbnail*)ImageLib.CreateThumbnail(file_name.c_str(), ECustomThumbnail::ETTexture, true); + if (!T->Valid()) + { + Msg("!Can't get info from texture: '%s'", file_name.c_str()); + } + else + { + info = T->_Format(); if (info.flags.is(STextureParams::flImplicitLighted)) - type = sttImplicit; + type = sttImplicit; } - xr_delete (T); - }else{ + xr_delete(T); + } + else + { Msg("!Empty texture name found."); } } -void SSceneSummary::STextureInfo::OnHighlightClick(ButtonValue* sender, bool& bDataModified, bool& bSafe) +void SSceneSummary::STextureInfo::OnHighlightClick(ButtonValue *sender, bool &bDataModified, bool &bSafe) { - ButtonValue* V = dynamic_cast(sender); R_ASSERT(V); + ButtonValue *V = dynamic_cast(sender); + R_ASSERT(V); AnsiString item_name = sender->Owner()->Item()->Text; - switch (V->btn_num){ - case 0: Scene->HighlightTexture ((LPCSTR)sender->tag,false,info.width,info.height,false); break; - case 1: Scene->HighlightTexture ((LPCSTR)sender->tag,true,info.width,info.height,false); break; - case 2: Scene->HighlightTexture ((LPCSTR)sender->tag,true,info.width,info.height,true); break; - case 3: ExecCommand(COMMAND_CLEAR_DEBUG_DRAW); break; - } - bDataModified = false; - bSafe = false; + switch (V->btn_num) + { + case 0: Scene->HighlightTexture((LPCSTR)sender->tag, false, info.width, info.height, false); + break; + case 1: Scene->HighlightTexture((LPCSTR)sender->tag, true, info.width, info.height, false); + break; + case 2: Scene->HighlightTexture((LPCSTR)sender->tag, true, info.width, info.height, true); + break; + case 3: ExecCommand(COMMAND_CLEAR_DEBUG_DRAW); + break; + } + bDataModified = false; + bSafe = false; } -void SSceneSummary::STextureInfo::FillProp (PropItemVec& items, LPCSTR main_pref, u32& mem_use) +void SSceneSummary::STextureInfo::FillProp(PropItemVec &items, LPCSTR main_pref, u32 &mem_use) { - if (file_name.size()){ - int tex_mem = info.MemoryUsage(*file_name); - mem_use += tex_mem; - AnsiString pref = PrepareKey(AnsiString(main_pref).c_str(),*file_name).c_str(); - PropValue* V=0; - V=PHelper().CreateChoose(items,PrepareKey(pref.c_str(),"Texture"), &file_name, smTexture); V->Owner()->Enable(FALSE); - PHelper().CreateCaption(items,PrepareKey(pref.c_str(),"Format"), info.FormatString()); - PHelper().CreateCaption(items,PrepareKey(pref.c_str(),"Size"), shared_str().printf("%d x %d x %s",info.width,info.height,info.HasAlpha()?"32b":"24b")); - PHelper().CreateCaption(items,PrepareKey(pref.c_str(),"Memory Usage"), shared_str().printf("%d Kb",iFloor(tex_mem/1024))); - PHelper().CreateCaption(items,PrepareKey(pref.c_str(),"Effective Area"),shared_str().printf("%3.2f m^2",effective_area)); - PHelper().CreateCaption(items,PrepareKey(pref.c_str(),"Pixel Density"), shared_str().printf("%3.2f p/m",_sqrt((pixel_area*info.width*info.height)/effective_area))); -/* -//. óáðàë èç-çà êîë-âà > 4096 - AnsiString tmp = "on demand"; - for (objinf_map_it o_it=objects.begin(); o_it!=objects.end(); o_it++){ - tmp += AnsiString().sprintf("%s%s[%d*%3.2f]",tmp.Length()?"; ":"",o_it->first.c_str(),o_it->second.ref_count,o_it->second.area); - } - PHelper().CreateCaption(items,PrepareKey(pref.c_str(),"Objects"), tmp.c_str()); -*/ - if (info.flags.is_any(STextureParams::flDiffuseDetail|STextureParams::flBumpDetail)){ - if (0!=info.detail_name.size()){ - V=PHelper().CreateChoose(items,PrepareKey(pref.c_str(),"Detail Texture"), &info.detail_name,smTexture); V->Owner()->Enable(FALSE); - PHelper().CreateCaption(items,PrepareKey(pref.c_str(), "Detail Scale"), shared_str().printf("%3.2f",info.detail_scale)); - }else{ - PHelper().CreateCaption(items,PrepareKey(pref.c_str(), "Detail Texture"), "INVALID"); - ELog.Msg(mtError,"Empty details on texture: '%s'",*file_name); + if (file_name.size()) + { + int tex_mem = info.MemoryUsage(*file_name); + mem_use += tex_mem; + AnsiString pref = PrepareKey(AnsiString(main_pref).c_str(), *file_name).c_str(); + PropValue *V = 0; + V = PHelper().CreateChoose(items, PrepareKey(pref.c_str(), "Texture"), &file_name, smTexture); + V->Owner()->Enable(FALSE); + PHelper().CreateCaption(items, PrepareKey(pref.c_str(), "Format"), info.FormatString()); + PHelper().CreateCaption(items, PrepareKey(pref.c_str(), "Size"), shared_str().printf("%d x %d x %s", info.width, info.height, info.HasAlpha() ? "32b" : "24b")); + PHelper().CreateCaption(items, PrepareKey(pref.c_str(), "Memory Usage"), shared_str().printf("%d Kb", iFloor(tex_mem/1024))); + PHelper().CreateCaption(items, PrepareKey(pref.c_str(), "Effective Area"), shared_str().printf("%3.2f m^2", effective_area)); + PHelper().CreateCaption(items, PrepareKey(pref.c_str(), "Pixel Density"), shared_str().printf("%3.2f p/m", _sqrt((pixel_area*info.width*info.height)/effective_area))); + /* + //. óáðàë èç-çà êîë-âà > 4096 + AnsiString tmp = "on demand"; + for (objinf_map_it o_it=objects.begin(); o_it!=objects.end(); o_it++){ + tmp += AnsiString().sprintf("%s%s[%d*%3.2f]",tmp.Length()?"; ":"",o_it->first.c_str(),o_it->second.ref_count,o_it->second.area); + } + PHelper().CreateCaption(items,PrepareKey(pref.c_str(),"Objects"), tmp.c_str()); + */ + if (info.flags.is_any(STextureParams::flDiffuseDetail|STextureParams::flBumpDetail)) + { + if (0!=info.detail_name.size()) + { + V = PHelper().CreateChoose(items, PrepareKey(pref.c_str(), "Detail Texture"), &info.detail_name, smTexture); + V->Owner()->Enable(FALSE); + PHelper().CreateCaption(items, PrepareKey(pref.c_str(), "Detail Scale"), shared_str().printf("%3.2f", info.detail_scale)); + } + else + { + PHelper().CreateCaption(items, PrepareKey(pref.c_str(), "Detail Texture"), "INVALID"); + ELog.Msg(mtError, "Empty details on texture: '%s'", *file_name); } } - if (info.bump_mode==STextureParams::tbmUse){ - if (0!=info.bump_name.size()){ - V=PHelper().CreateChoose(items,PrepareKey(pref.c_str(),"Bump Texture"), &info.bump_name,smTexture); V->Owner()->Enable(FALSE); - }else{ - PHelper().CreateCaption(items,PrepareKey(pref.c_str(), "Bump Texture"), "INVALID"); - ELog.Msg(mtError,"Empty bump on texture: '%s'",*file_name); + if (info.bump_mode==STextureParams::tbmUse) + { + if (0!=info.bump_name.size()) + { + V = PHelper().CreateChoose(items, PrepareKey(pref.c_str(), "Bump Texture"), &info.bump_name, smTexture); + V->Owner()->Enable(FALSE); + } + else + { + PHelper().CreateCaption(items, PrepareKey(pref.c_str(), "Bump Texture"), "INVALID"); + ELog.Msg(mtError, "Empty bump on texture: '%s'", *file_name); } } - ButtonValue* B = PHelper().CreateButton(items,PrepareKey(pref.c_str(),"Highlight Texture"), "Select,Density =,Density +,Clear", 0); - B->OnBtnClickEvent.bind(this,&SSceneSummary::STextureInfo::OnHighlightClick); - B->tag = (int)(*file_name); + ButtonValue *B = PHelper().CreateButton(items, PrepareKey(pref.c_str(), "Highlight Texture"), "Select,Density =,Density +,Clear", 0); + B->OnBtnClickEvent.bind(this, &SSceneSummary::STextureInfo::OnHighlightClick); + B->tag = (int)(*file_name); } } -void SSceneSummary::STextureInfo::Export (IWriter* F, u32& mem_use) + +void SSceneSummary::STextureInfo::Export(IWriter *F, u32 &mem_use) { - string128 mask; - AnsiString tmp; - strcpy (mask,"%s=%s,%d,%d,%s,%d,%3.2f,%3.2f,%s"); - if (info.flags.is_any(STextureParams::flDiffuseDetail|STextureParams::flBumpDetail)){ - if (0!=info.detail_name.size()){ - strcat (mask,",%s,%3.2f"); + string128 mask; + AnsiString tmp; + strcpy(mask, "%s=%s,%d,%d,%s,%d,%3.2f,%3.2f,%s"); + if (info.flags.is_any(STextureParams::flDiffuseDetail|STextureParams::flBumpDetail)) + { + if (0!=info.detail_name.size()) + { + strcat(mask, ",%s,%3.2f"); } } - if (info.bump_mode==STextureParams::tbmUse){ - if (0!=info.bump_name.size()){ - strcat (mask,",%s"); + if (info.bump_mode==STextureParams::tbmUse) + { + if (0!=info.bump_name.size()) + { + strcat(mask, ",%s"); } } - AnsiString tmp2; - for (objinf_map_it o_it=objects.begin(); o_it!=objects.end(); o_it++){ - tmp2 += AnsiString().sprintf("%s%s[%d*%3.2f]",tmp2.Length()?"; ":"",o_it->first.c_str(),o_it->second.ref_count,o_it->second.area); + AnsiString tmp2; + for (objinf_map_it o_it = objects.begin(); o_it!=objects.end(); o_it++) + { + tmp2 += AnsiString().sprintf("%s%s[%d*%3.2f]", tmp2.Length() ? "; " : "", o_it->first.c_str(), o_it->second.ref_count, o_it->second.area); } - int tex_mem = info.MemoryUsage(*file_name); - mem_use +=tex_mem; - tmp.sprintf (mask,*file_name,info.FormatString(), - info.width,info.height,info.HasAlpha()?"present":"absent", - iFloor(tex_mem/1024), - effective_area, _sqrt((pixel_area*info.width*info.height)/effective_area), tmp2.c_str(), - *info.detail_name, info.detail_scale, *info.bump_name); - F->w_string (tmp.c_str()); + int tex_mem = info.MemoryUsage(*file_name); + mem_use += tex_mem; + tmp.sprintf(mask, *file_name, info.FormatString(), + info.width, info.height, info.HasAlpha() ? "present" : "absent", + iFloor(tex_mem/1024), + effective_area, _sqrt((pixel_area*info.width*info.height)/effective_area), tmp2.c_str(), + *info.detail_name, info.detail_scale, *info.bump_name); + F->w_string(tmp.c_str()); } -void SSceneSummary::OnFileClick(ButtonValue* sender, bool& bModif, bool& bSafe) +void SSceneSummary::OnFileClick(ButtonValue *sender, bool &bModif, bool &bSafe) { - ButtonValue* V = dynamic_cast(sender); R_ASSERT(V); - switch (V->btn_num){ - case 0:{ - xr_string fn = Scene->m_LevelOp.m_FNLevelPath.c_str(); - if (EFS.GetSaveName(_import_,fn,0,2)) - if (ExportSummaryInfo(fn.c_str())) ELog.DlgMsg(mtInformation,"Export completed."); - else ELog.DlgMsg(mtInformation,"Export failed."); - }break; - } + ButtonValue *V = dynamic_cast(sender); + R_ASSERT(V); + switch (V->btn_num) + { + case 0: + { + xr_string fn = Scene->m_LevelOp.m_FNLevelPath.c_str(); + if (EFS.GetSaveName(_import_, fn, 0, 2)) + if (ExportSummaryInfo(fn.c_str())) + ELog.DlgMsg(mtInformation, "Export completed."); + else + ELog.DlgMsg(mtInformation, "Export failed."); + } + break; + } bModif = false; } -void SSceneSummary::OnHighlightClick(ButtonValue* V, bool& bDataModified, bool& bSafe) + +void SSceneSummary::OnHighlightClick(ButtonValue *V, bool &bDataModified, bool &bSafe) { AnsiString item_name = V->Owner()->Item()->Text; - switch (V->btn_num){ - case 0:{ - ExecCommand (COMMAND_CLEAR_DEBUG_DRAW); - for (TISetIt it=textures.begin(); it!=textures.end(); it++){ - STextureInfo* info = (STextureInfo*)(&(*it)); - if (info->type==sttBase) - Scene->HighlightTexture (info->file_name.c_str(),true,info->info.width,info->info.height,true); + switch (V->btn_num) + { + case 0: + { + ExecCommand(COMMAND_CLEAR_DEBUG_DRAW); + for (TISetIt it = textures.begin(); it!=textures.end(); it++) + { + STextureInfo *info = (STextureInfo*)(&(*it)); + if (info->type==sttBase) + Scene->HighlightTexture(info->file_name.c_str(), true, info->info.width, info->info.height, true); + } } - }break; - case 1: ExecCommand(COMMAND_CLEAR_DEBUG_DRAW); break; - } - bDataModified = false; - bSafe = false; - - + break; + case 1: ExecCommand(COMMAND_CLEAR_DEBUG_DRAW); + break; + } + bDataModified = false; + bSafe = false; } bool SSceneSummary::ExportSummaryInfo(LPCSTR fn) { - IWriter* F = FS.w_open(fn); - if (F){ - string256 tmp; + IWriter *F = FS.w_open(fn); + if (F) + { + string256 tmp; // textures - u32 total_mem_usage = 0; - F->w_string ("[TEXTURES]"); - F->w_string ("texture name=format,width,height,alpha,mem usage (Kb),area,pixel density,objects (name[count*area]),detail name,detail scale,bump name"); - for (u32 stt=sttFirst; sttw_string (pref.c_str()); - for (TISetIt it=textures.begin(); it!=textures.end(); it++){ - STextureInfo* info= (STextureInfo*)(&(*it)); - if (info->type==stt){ - cur_area += info->effective_area; - info->Export(F,cur_mem_usage); + u32 total_mem_usage = 0; + F->w_string("[TEXTURES]"); + F->w_string("texture name=format,width,height,alpha,mem usage (Kb),area,pixel density,objects (name[count*area]),detail name,detail scale,bump name"); + for (u32 stt = sttFirst; sttw_string(pref.c_str()); + for (TISetIt it = textures.begin(); it!=textures.end(); it++) + { + STextureInfo *info = (STextureInfo*)(&(*it)); + if (info->type==stt) + { + cur_area += info->effective_area; + info->Export(F, cur_mem_usage); } } - total_mem_usage += cur_mem_usage; - sprintf (tmp,"%s mem usage - %d Kb",pref.c_str(),cur_mem_usage); - F->w_string (tmp); - sprintf (tmp,"%s effective area - %3.2f m^2",pref.c_str(),cur_area); - F->w_string (tmp); + total_mem_usage += cur_mem_usage; + sprintf(tmp, "%s mem usage - %d Kb", pref.c_str(), cur_mem_usage); + F->w_string(tmp); + sprintf(tmp, "%s effective area - %3.2f m^2", pref.c_str(), cur_area); + F->w_string(tmp); } - sprintf (tmp,"Total mem usage - %d Kb",total_mem_usage); - F->w_string (tmp); + sprintf(tmp, "Total mem usage - %d Kb", total_mem_usage); + F->w_string(tmp); // objects - F->w_string (""); - sprintf (tmp,"[OBJECTS]"); F->w_string(tmp); - for (OISetIt o_it=objects.begin(); o_it!=objects.end(); o_it++){ - SObjectInfo* info= (SObjectInfo*)(&(*o_it)); - info->Export (F); + F->w_string(""); + sprintf(tmp, "[OBJECTS]"); + F->w_string(tmp); + for (OISetIt o_it = objects.begin(); o_it!=objects.end(); o_it++) + { + SObjectInfo *info = (SObjectInfo*)(&(*o_it)); + info->Export(F); } - FS.w_close (F); - return true; - }else{ - return false; + FS.w_close(F); + return true; + } + else + { + return false; } } -bool SSceneSummary::OnWeightAfterEditClick(PropValue* sender, float& edit_val) + +bool SSceneSummary::OnWeightAfterEditClick(PropValue *sender, float &edit_val) { - if (sender->tag==0){ - return edit_valtag+1].pm; - }else if (sender->tag==pm_colors.size()-1){ - return edit_val>pm_colors[sender->tag-1].pm; - }else{ - return edit_val>pm_colors[sender->tag-1].pm && edit_valtag+1].pm; + if (sender->tag==0) + { + return edit_valtag+1].pm; + } + else if (sender->tag==pm_colors.size()-1) + { + return edit_val>pm_colors[sender->tag-1].pm; + } + else + { + return edit_val>pm_colors[sender->tag-1].pm&&edit_valtag+1].pm; } } -void SSceneSummary::FillProp(PropItemVec& items) + +void SSceneSummary::FillProp(PropItemVec &items) { // fill items - ButtonValue* B =PHelper().CreateButton (items,"Common\\File","Export...",0); - B->OnBtnClickEvent.bind(this,&SSceneSummary::OnFileClick); + ButtonValue *B = PHelper().CreateButton(items, "Common\\File", "Export...", 0); + B->OnBtnClickEvent.bind(this, &SSceneSummary::OnFileClick); // fill items - PHelper().CreateCaption(items,"Common\\Level Name", Scene->m_LevelOp.m_FNLevelPath.c_str()); - PHelper().CreateCaption(items,"Geometry\\Bounding\\Min", shared_str().printf("{%3.2f, %3.2f, %3.2f}",VPUSH(bbox.min))); - PHelper().CreateCaption(items,"Geometry\\Bounding\\Max", shared_str().printf("{%3.2f, %3.2f, %3.2f}",VPUSH(bbox.max))); - PHelper().CreateCaption(items,"Geometry\\Mesh\\Total Faces", shared_str().printf("%d",face_cnt)); - PHelper().CreateCaption(items,"Geometry\\Mesh\\Total Vertices", shared_str().printf("%d",vert_cnt)); - PHelper().CreateCaption(items,"Geometry\\MU\\Objects", shared_str().printf("%d",mu_objects.size())); - PHelper().CreateCaption(items,"Geometry\\MU\\References", shared_str().printf("%d",object_mu_ref_cnt)); - PHelper().CreateCaption(items,"Geometry\\LOD\\Objects", shared_str().printf("%d",lod_objects.size())); - PHelper().CreateCaption(items,"Geometry\\LOD\\References", shared_str().printf("%d",object_lod_ref_cnt)); - PHelper().CreateCaption(items,"Visibility\\HOM\\Faces", shared_str().printf("%d",hom_face_cnt)); - PHelper().CreateCaption(items,"Visibility\\HOM\\Vertices", shared_str().printf("%d",hom_vert_cnt)); - PHelper().CreateCaption(items,"Visibility\\Sectors", shared_str().printf("%d",sector_cnt)); - PHelper().CreateCaption(items,"Visibility\\Portals", shared_str().printf("%d",portal_cnt)); - PHelper().CreateCaption(items,"Lights\\Count", shared_str().printf("%d",light_point_cnt+light_spot_cnt)); - PHelper().CreateCaption(items,"Lights\\By Type\\Point", shared_str().printf("%d",light_point_cnt)); - PHelper().CreateCaption(items,"Lights\\By Type\\Spot", shared_str().printf("%d",light_spot_cnt)); - PHelper().CreateCaption(items,"Lights\\By Usage\\Dynamic", shared_str().printf("%d",light_dynamic_cnt)); - PHelper().CreateCaption(items,"Lights\\By Usage\\Static", shared_str().printf("%d",light_static_cnt)); - PHelper().CreateCaption(items,"Lights\\By Usage\\Breakable",shared_str().printf("%d",light_breakable_cnt)); - PHelper().CreateCaption(items,"Lights\\By Usage\\Procedural",shared_str().printf("%d",light_procedural_cnt)); - PHelper().CreateCaption(items,"Glows\\Count", shared_str().printf("%d",glow_cnt)); + PHelper().CreateCaption(items, "Common\\Level Name", Scene->m_LevelOp.m_FNLevelPath.c_str()); + PHelper().CreateCaption(items, "Geometry\\Bounding\\Min", shared_str().printf("{%3.2f, %3.2f, %3.2f}", VPUSH(bbox.min))); + PHelper().CreateCaption(items, "Geometry\\Bounding\\Max", shared_str().printf("{%3.2f, %3.2f, %3.2f}", VPUSH(bbox.max))); + PHelper().CreateCaption(items, "Geometry\\Mesh\\Total Faces", shared_str().printf("%d", face_cnt)); + PHelper().CreateCaption(items, "Geometry\\Mesh\\Total Vertices", shared_str().printf("%d", vert_cnt)); + PHelper().CreateCaption(items, "Geometry\\MU\\Objects", shared_str().printf("%d", mu_objects.size())); + PHelper().CreateCaption(items, "Geometry\\MU\\References", shared_str().printf("%d", object_mu_ref_cnt)); + PHelper().CreateCaption(items, "Geometry\\LOD\\Objects", shared_str().printf("%d", lod_objects.size())); + PHelper().CreateCaption(items, "Geometry\\LOD\\References", shared_str().printf("%d", object_lod_ref_cnt)); + PHelper().CreateCaption(items, "Visibility\\HOM\\Faces", shared_str().printf("%d", hom_face_cnt)); + PHelper().CreateCaption(items, "Visibility\\HOM\\Vertices", shared_str().printf("%d", hom_vert_cnt)); + PHelper().CreateCaption(items, "Visibility\\Sectors", shared_str().printf("%d", sector_cnt)); + PHelper().CreateCaption(items, "Visibility\\Portals", shared_str().printf("%d", portal_cnt)); + PHelper().CreateCaption(items, "Lights\\Count", shared_str().printf("%d", light_point_cnt+light_spot_cnt)); + PHelper().CreateCaption(items, "Lights\\By Type\\Point", shared_str().printf("%d", light_point_cnt)); + PHelper().CreateCaption(items, "Lights\\By Type\\Spot", shared_str().printf("%d", light_spot_cnt)); + PHelper().CreateCaption(items, "Lights\\By Usage\\Dynamic", shared_str().printf("%d", light_dynamic_cnt)); + PHelper().CreateCaption(items, "Lights\\By Usage\\Static", shared_str().printf("%d", light_static_cnt)); + PHelper().CreateCaption(items, "Lights\\By Usage\\Breakable", shared_str().printf("%d", light_breakable_cnt)); + PHelper().CreateCaption(items, "Lights\\By Usage\\Procedural", shared_str().printf("%d", light_procedural_cnt)); + PHelper().CreateCaption(items, "Glows\\Count", shared_str().printf("%d", glow_cnt)); // objects - for (OISetIt o_it=objects.begin(); o_it!=objects.end(); o_it++){ - SObjectInfo* info= (SObjectInfo*)(&(*o_it)); - info->FillProp (items,"Objects"); + for (OISetIt o_it = objects.begin(); o_it!=objects.end(); o_it++) + { + SObjectInfo *info = (SObjectInfo*)(&(*o_it)); + info->FillProp(items, "Objects"); } // textures - CaptionValue* total_count=PHelper().CreateCaption (items,"Textures\\Count",""); - CaptionValue* total_mem = PHelper().CreateCaption (items,"Textures\\Memory Usage",""); - u32 total_mem_usage = 0; - ButtonValue* BB = PHelper().CreateButton (items,"Textures\\Highlight Textures\\Command", "Pixel Density,Clear", ButtonValue::flFirstOnly); - BB->OnBtnClickEvent.bind(this,&SSceneSummary::OnHighlightClick); - for (PDVecIt pd_it=pm_colors.begin(); pd_it!=pm_colors.end(); pd_it++){ - string128 tmp; - sprintf (tmp,"Textures\\Highlight Textures\\Color Legend\\Item #%d",pd_it-pm_colors.begin()); - PHelper().CreateColor(items,PrepareKey(tmp,"Color").c_str(),&pd_it->color); - FloatValue* V = PHelper().CreateFloat(items,PrepareKey(tmp,"Weight (p/m)").c_str(),&pd_it->pm,0,1000000,1,0); - V->OnAfterEditEvent.bind(this,&SSceneSummary::OnWeightAfterEditClick); - V->tag = pd_it-pm_colors.begin(); + CaptionValue *total_count = PHelper().CreateCaption(items, "Textures\\Count", ""); + CaptionValue *total_mem = PHelper().CreateCaption(items, "Textures\\Memory Usage", ""); + u32 total_mem_usage = 0; + ButtonValue *BB = PHelper().CreateButton(items, "Textures\\Highlight Textures\\Command", "Pixel Density,Clear", ButtonValue::flFirstOnly); + BB->OnBtnClickEvent.bind(this, &SSceneSummary::OnHighlightClick); + for (PDVecIt pd_it = pm_colors.begin(); pd_it!=pm_colors.end(); pd_it++) + { + string128 tmp; + sprintf(tmp, "Textures\\Highlight Textures\\Color Legend\\Item #%d", pd_it-pm_colors.begin()); + PHelper().CreateColor(items, PrepareKey(tmp, "Color").c_str(), &pd_it->color); + FloatValue *V = PHelper().CreateFloat(items, PrepareKey(tmp, "Weight (p/m)").c_str(), &pd_it->pm, 0, 1000000, 1, 0); + V->OnAfterEditEvent.bind(this, &SSceneSummary::OnWeightAfterEditClick); + V->tag = pd_it-pm_colors.begin(); } - for (u32 stt=sttFirst; stttype==stt){ - cur_area += info->effective_area; - info->FillProp(items,pref.c_str(),cur_mem_usage); + for (u32 stt = sttFirst; stttype==stt) + { + cur_area += info->effective_area; + info->FillProp(items, pref.c_str(), cur_mem_usage); } } - mem->ApplyValue (shared_str().printf("%d Kb",iFloor(cur_mem_usage/1024))); - area->ApplyValue (shared_str().printf("%3.2f m^2",cur_area)); - total_mem_usage += cur_mem_usage; + mem->ApplyValue(shared_str().printf("%d Kb", iFloor(cur_mem_usage/1024))); + area->ApplyValue(shared_str().printf("%3.2f m^2", cur_area)); + total_mem_usage += cur_mem_usage; } } - total_count->ApplyValue (shared_str().printf("%d", textures.size())); - total_mem->ApplyValue (shared_str().printf("%d Kb", iFloor(total_mem_usage/1024))); - // sound - PHelper().CreateCaption (items,"Sounds\\Occluder\\Faces", shared_str().printf("%d",snd_occ_face_cnt)); - PHelper().CreateCaption (items,"Sounds\\Occluder\\Vertices", shared_str().printf("%d",snd_occ_vert_cnt)); - PHelper().CreateCaption (items,"Sounds\\Sources", shared_str().printf("%d",sound_source_cnt)); - PHelper().CreateCaption (items,"Sounds\\Waves\\Count", shared_str().printf("%d",waves.size())); - for (RStringSetIt w_it=waves.begin(); w_it!=waves.end(); w_it++) - PHelper().CreateCaption(items,PrepareKey("Sounds\\Waves",w_it->c_str()),"-"); + total_count->ApplyValue(shared_str().printf("%d", textures.size())); + total_mem->ApplyValue(shared_str().printf("%d Kb", iFloor(total_mem_usage/1024))); + // sound + PHelper().CreateCaption(items, "Sounds\\Occluder\\Faces", shared_str().printf("%d", snd_occ_face_cnt)); + PHelper().CreateCaption(items, "Sounds\\Occluder\\Vertices", shared_str().printf("%d", snd_occ_vert_cnt)); + PHelper().CreateCaption(items, "Sounds\\Sources", shared_str().printf("%d", sound_source_cnt)); + PHelper().CreateCaption(items, "Sounds\\Waves\\Count", shared_str().printf("%d", waves.size())); + for (RStringSetIt w_it = waves.begin(); w_it!=waves.end(); w_it++) + PHelper().CreateCaption(items, PrepareKey("Sounds\\Waves", w_it->c_str()), "-"); // particles - PHelper().CreateCaption (items,"Particle System\\Sources", shared_str().printf("%d",pe_static_cnt)); - PHelper().CreateCaption (items,"Particle System\\Refs\\Count", shared_str().printf("%d",pe_static.size())); - for (RStringSetIt pe_it=pe_static.begin(); pe_it!=pe_static.end(); pe_it++) - PHelper().CreateCaption(items,PrepareKey("Particle System\\Refs",pe_it->c_str()),"-"); + PHelper().CreateCaption(items, "Particle System\\Sources", shared_str().printf("%d", pe_static_cnt)); + PHelper().CreateCaption(items, "Particle System\\Refs\\Count", shared_str().printf("%d", pe_static.size())); + for (RStringSetIt pe_it = pe_static.begin(); pe_it!=pe_static.end(); pe_it++) + PHelper().CreateCaption(items, PrepareKey("Particle System\\Refs", pe_it->c_str()), "-"); } SSceneSummary::SSceneSummary() { - Clear (); - pm_colors.push_back (SPixelDensityPair(0,0x80FF0000)); - pm_colors.push_back (SPixelDensityPair(100,0x80FFFF00)); - pm_colors.push_back (SPixelDensityPair(200,0x8000FF00)); - pm_colors.push_back (SPixelDensityPair(500,0x8000FFFF)); - pm_colors.push_back (SPixelDensityPair(1000,0x800000FF)); + Clear(); + pm_colors.push_back(SPixelDensityPair(0, 0x80FF0000)); + pm_colors.push_back(SPixelDensityPair(100, 0x80FFFF00)); + pm_colors.push_back(SPixelDensityPair(200, 0x8000FF00)); + pm_colors.push_back(SPixelDensityPair(500, 0x8000FFFF)); + pm_colors.push_back(SPixelDensityPair(1000, 0x800000FF)); } -void SSceneSummary::Save(CInifile* I) +void SSceneSummary::Save(CInifile *I) { - I->w_u32 ("summary_info","pm_count",s_summary.pm_colors.size()); - for (u32 idx=0; idxw_u32 ("summary_info",tmp,s_summary.pm_colors[idx].color); - sprintf (tmp,"pm_item_%d_weight",idx); - I->w_float ("summary_info",tmp,s_summary.pm_colors[idx].pm); + I->w_u32("summary_info", "pm_count", s_summary.pm_colors.size()); + for (u32 idx = 0; idxw_u32("summary_info", tmp, s_summary.pm_colors[idx].color); + sprintf(tmp, "pm_item_%d_weight", idx); + I->w_float("summary_info", tmp, s_summary.pm_colors[idx].pm); } } -void SSceneSummary::Load(CInifile* I) +void SSceneSummary::Load(CInifile *I) { - if (I->section_exist("summary_info")&&I->line_exist("summary_info","pm_count")&&(5==I->r_u32("summary_info","pm_count"))){ - for (u32 idx=0; idxsection_exist("summary_info")&&I->line_exist("summary_info", "pm_count")&&(5==I->r_u32("summary_info", "pm_count"))) + { + for (u32 idx = 0; idx=s_summary.pm_colors[s_summary.pm_colors.size()-1].pm){ - from = s_summary.pm_colors.back().color; - to = s_summary.pm_colors.back().color; - }else{ - u32 idx_clr = 0; + float w = 0.f; + if (pm=s_summary.pm_colors[s_summary.pm_colors.size()-1].pm) + { + from = s_summary.pm_colors.back().color; + to = s_summary.pm_colors.back().color; + } + else + { + u32 idx_clr = 0; for (; idx_clr=s_summary.pm_colors[idx_clr].pm && pm=s_summary.pm_colors[idx_clr].pm&&pmsecond) _I->second->GetSummaryInfo(&s_summary); - s_summary.Prepare (); + if (_I->second) + _I->second->GetSummaryInfo(&s_summary); + s_summary.Prepare(); } -void EScene::ShowSummaryInfo () +void EScene::ShowSummaryInfo() { - PropItemVec items; + PropItemVec items; // fill items - s_summary.FillProp (items); - m_SummaryInfo->ShowProperties (); - m_SummaryInfo->AssignItems (items); + s_summary.FillProp(items); + m_SummaryInfo->ShowProperties(); + m_SummaryInfo->AssignItems(items); } -void EScene::ExportSummaryInfo (LPCSTR f_name) +void EScene::ExportSummaryInfo(LPCSTR f_name) { - s_summary.ExportSummaryInfo (f_name); + s_summary.ExportSummaryInfo(f_name); } + //-------------------------------------------------------------------------------------------------- - + diff --git a/src/editors/LevelEditor/Edit/SceneSummaryInfo.h b/src/editors/LevelEditor/Edit/SceneSummaryInfo.h index 3d560fa4e5c..44cbbfe557b 100644 --- a/src/editors/LevelEditor/Edit/SceneSummaryInfo.h +++ b/src/editors/LevelEditor/Edit/SceneSummaryInfo.h @@ -2,13 +2,15 @@ #define SceneSummaryInfoH #pragma once -#include "../Layers/xrRender/ETextureParams.h" +#include "Layers/xrRender/ETextureParams.h" -class SSceneSummary{ +class SSceneSummary +{ public: - enum ESummaryTextureType{ - sttFirst = 0, - sttBase = 0, + enum ESummaryTextureType + { + sttFirst = 0, + sttBase = 0, sttImplicit, sttDetail, sttBump, @@ -18,166 +20,221 @@ class SSceneSummary{ sttLast }; // íå çàáûâàòü òîêåí ìåíÿòü private: - struct STextureInfo{ - shared_str file_name; - STextureParams info; - ESummaryTextureType type; - bool bReady; - struct SObjInfo{ - int ref_count; - float area; - SObjInfo(float a):ref_count(0),area(a){} + struct STextureInfo + { + shared_str file_name; + STextureParams info; + ESummaryTextureType type; + bool bReady; + + struct SObjInfo + { + int ref_count; + float area; + + SObjInfo(float a): ref_count(0), area(a) {} }; - DEFINE_MAP(shared_str,SObjInfo,objinf_map,objinf_map_it); - objinf_map objects; - float effective_area; - float pixel_area; - void OnHighlightClick (ButtonValue* sender, bool& bDataModified, bool& bSafe); + + DEFINE_MAP(shared_str, SObjInfo, objinf_map, objinf_map_it); + objinf_map objects; + float effective_area; + float pixel_area; + void OnHighlightClick(ButtonValue *sender, bool &bDataModified, bool &bSafe); public: - STextureInfo(const shared_str& fn, ESummaryTextureType t) + STextureInfo(const shared_str &fn, ESummaryTextureType t) { - file_name = fn; - ZeroMemory (&info,sizeof(info)); - type = t; - effective_area = 0; - pixel_area = 0; - bReady = false; + file_name = fn; + ZeroMemory(&info, sizeof(info)); + type = t; + effective_area = 0; + pixel_area = 0; + bReady = false; } - void Prepare (); - void FillProp(PropItemVec& items, LPCSTR pref, u32& mem_use); - void Export (IWriter* F, u32& mem_use); - bool operator < (const STextureInfo& other) const{return xr_strcmp(file_name,other.file_name)<0;}; - bool operator < (const shared_str& fn) const{return xr_strcmp(file_name,fn)<0;}; - bool operator ==(const shared_str& fn) const{return file_name.equal(fn);}; + + void Prepare(); + void FillProp(PropItemVec &items, LPCSTR pref, u32 &mem_use); + void Export(IWriter *F, u32 &mem_use); + + bool operator <(const STextureInfo &other) const + { + return xr_strcmp(file_name, other.file_name)<0; + }; + + bool operator <(const shared_str &fn) const + { + return xr_strcmp(file_name, fn)<0; + }; + + bool operator ==(const shared_str &fn) const + { + return file_name.equal(fn); + }; }; - DEFINE_SET (STextureInfo,TISet,TISetIt); - TISet textures; - struct SPairInfo{ - xr_string first; - xr_string second; + + DEFINE_SET(STextureInfo, TISet, TISetIt); + TISet textures; + + struct SPairInfo + { + xr_string first; + xr_string second; }; - DEFINE_VECTOR(SPairInfo,PIVec,PIVecIt); - struct SObjectInfo{ - shared_str object_name; - PIVec info; - u32 ref_count; - bool bReady; + + DEFINE_VECTOR(SPairInfo, PIVec, PIVecIt); + + struct SObjectInfo + { + shared_str object_name; + PIVec info; + u32 ref_count; + bool bReady; public: - SObjectInfo(const shared_str& name) + SObjectInfo(const shared_str &name) { - object_name = name; - ref_count = 0; - bReady = false; + object_name = name; + ref_count = 0; + bReady = false; } - void Prepare (); - void FillProp(PropItemVec& items, LPCSTR prvectoref); - void Export (IWriter* F); - bool operator < (const SObjectInfo& other) const{return xr_strcmp(object_name,other.object_name)<0;}; - bool operator < (const shared_str& fn) const{return xr_strcmp(object_name,fn)<0;}; - bool operator ==(const shared_str& fn) const{return object_name.equal(fn);}; + + void Prepare(); + void FillProp(PropItemVec &items, LPCSTR prvectoref); + void Export(IWriter *F); + + bool operator <(const SObjectInfo &other) const + { + return xr_strcmp(object_name, other.object_name)<0; + }; + + bool operator <(const shared_str &fn) const + { + return xr_strcmp(object_name, fn)<0; + }; + + bool operator ==(const shared_str &fn) const + { + return object_name.equal(fn); + }; }; - DEFINE_SET (SObjectInfo,OISet,OISetIt); - OISet objects; -public: - RStringSet lod_objects; - RStringSet mu_objects; - RStringSet waves; - RStringSet pe_static; - int face_cnt; - int vert_cnt; - int hom_face_cnt, hom_vert_cnt; - int snd_occ_face_cnt, snd_occ_vert_cnt; - int object_mu_ref_cnt; - int object_lod_ref_cnt; - int light_point_cnt; - int light_spot_cnt; - int light_dynamic_cnt; - int light_static_cnt; - int light_breakable_cnt; - int light_procedural_cnt; - int glow_cnt; - int sector_cnt; - int portal_cnt; - int sound_source_cnt; - int pe_static_cnt; - Fbox bbox; + + DEFINE_SET(SObjectInfo, OISet, OISetIt); + OISet objects; +public: + RStringSet lod_objects; + RStringSet mu_objects; + RStringSet waves; + RStringSet pe_static; + int face_cnt; + int vert_cnt; + int hom_face_cnt, hom_vert_cnt; + int snd_occ_face_cnt, snd_occ_vert_cnt; + int object_mu_ref_cnt; + int object_lod_ref_cnt; + int light_point_cnt; + int light_spot_cnt; + int light_dynamic_cnt; + int light_static_cnt; + int light_breakable_cnt; + int light_procedural_cnt; + int glow_cnt; + int sector_cnt; + int portal_cnt; + int sound_source_cnt; + int pe_static_cnt; + Fbox bbox; private: - void OnFileClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void OnHighlightClick (ButtonValue* sender, bool& bDataModified, bool& bSafe); + void OnFileClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void OnHighlightClick(ButtonValue *sender, bool &bDataModified, bool &bSafe); public: - void Prepare (); + void Prepare(); protected: - struct SPixelDensityPair{ - float pm; - u32 color; - SPixelDensityPair(float _pm, u32 _c):pm(_pm),color(_c){} - bool operator < (const SPixelDensityPair& other)const{return pm < other.pm;}; + struct SPixelDensityPair + { + float pm; + u32 color; + + SPixelDensityPair(float _pm, u32 _c): pm(_pm), color(_c) {} + + bool operator <(const SPixelDensityPair &other) const + { + return pm res = textures.insert (STextureInfo(name,type)); - it = res.first; + TISetIt it = std::find(textures.begin(), textures.end(), name); + if (it==textures.end()) + { + std::pair res = textures.insert(STextureInfo(name, type)); + it = res.first; } - STextureInfo* info = (STextureInfo*)(&(*it)); - - STextureInfo::objinf_map_it o_it = info->objects.find(obj_name); - if (o_it==info->objects.end()){ - std::pair res = info->objects.insert(std::make_pair(obj_name,STextureInfo::SObjInfo(area))); - o_it = res.first; + STextureInfo *info = (STextureInfo*)(&(*it)); + + STextureInfo::objinf_map_it o_it = info->objects.find(obj_name); + if (o_it==info->objects.end()) + { + std::pair res = info->objects.insert(std::make_pair(obj_name, STextureInfo::SObjInfo(area))); + o_it = res.first; } o_it->second.ref_count++; - info->effective_area+=area; - info->pixel_area+=pixel_area; + info->effective_area += area; + info->pixel_area += pixel_area; } - void AppendObject (shared_str name) + + void AppendObject(shared_str name) { - OISetIt it = std::find(objects.begin(),objects.end(),name); - if (it==objects.end()){ - std::pair res = objects.insert (SObjectInfo(name)); - it = res.first; + OISetIt it = std::find(objects.begin(), objects.end(), name); + if (it==objects.end()) + { + std::pair res = objects.insert(SObjectInfo(name)); + it = res.first; } - SObjectInfo* info = (SObjectInfo*)(&(*it)); + SObjectInfo *info = (SObjectInfo*)(&(*it)); info->ref_count++; } - bool ExportSummaryInfo (LPCSTR fn); - void FillProp (PropItemVec& items); - void Clear (){ - bbox.invalidate (); - textures.clear (); - lod_objects.clear (); - mu_objects.clear (); - waves.clear (); + + bool ExportSummaryInfo(LPCSTR fn); + void FillProp(PropItemVec &items); + + void Clear() + { + bbox.invalidate(); + textures.clear(); + lod_objects.clear(); + mu_objects.clear(); + waves.clear(); pe_static; - face_cnt = 0; - vert_cnt = 0; - hom_face_cnt = 0; - hom_vert_cnt = 0; - snd_occ_face_cnt = 0; - snd_occ_vert_cnt = 0; - object_mu_ref_cnt = 0; - object_lod_ref_cnt = 0; - light_point_cnt = 0; - light_spot_cnt = 0; - light_dynamic_cnt = 0; - light_static_cnt = 0; - light_breakable_cnt = 0; - light_procedural_cnt= 0; - glow_cnt = 0; - sector_cnt = 0; - portal_cnt = 0; - sound_source_cnt = 0; - pe_static_cnt = 0; + face_cnt = 0; + vert_cnt = 0; + hom_face_cnt = 0; + hom_vert_cnt = 0; + snd_occ_face_cnt = 0; + snd_occ_vert_cnt = 0; + object_mu_ref_cnt = 0; + object_lod_ref_cnt = 0; + light_point_cnt = 0; + light_spot_cnt = 0; + light_dynamic_cnt = 0; + light_static_cnt = 0; + light_breakable_cnt = 0; + light_procedural_cnt = 0; + glow_cnt = 0; + sector_cnt = 0; + portal_cnt = 0; + sound_source_cnt = 0; + pe_static_cnt = 0; } - static void Load (CInifile* I); - static void Save (CInifile* I); + + static void Load(CInifile *I); + static void Save(CInifile *I); }; #endif + diff --git a/src/editors/LevelEditor/Edit/SceneUndo.cpp b/src/editors/LevelEditor/Edit/SceneUndo.cpp index 46a7a77f25e..705b26d8cd8 100644 --- a/src/editors/LevelEditor/Edit/SceneUndo.cpp +++ b/src/editors/LevelEditor/Edit/SceneUndo.cpp @@ -16,89 +16,106 @@ #pragma hdrstop #include "Scene.h" -#include "../ECore/Editor/EditorPreferences.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/EditorPreferences.h" +#include "editors/ECore/Editor/ui_main.h" //---------------------------------------------------- void EScene::UndoClear() { - while( !m_RedoStack.empty() ){ - unlink( m_RedoStack.back().m_FileName ); - m_RedoStack.pop_back(); } - while( !m_UndoStack.empty() ){ - unlink( m_UndoStack.back().m_FileName ); - m_UndoStack.pop_back(); } + while (!m_RedoStack.empty()) + { + unlink(m_RedoStack.back().m_FileName); + m_RedoStack.pop_back(); + } + while (!m_UndoStack.empty()) + { + unlink(m_UndoStack.back().m_FileName); + m_UndoStack.pop_back(); + } } void EScene::UndoSave() { - if (UI->GetEState()!=esEditScene) return; + if (UI->GetEState()!=esEditScene) + return; Modified(); UI->RedrawScene(); - if (0==EPrefs->scene_undo_level) return; + if (0==EPrefs->scene_undo_level) + return; - UndoItem item; - GetTempFileName( FS.get_path(_temp_)->m_Path, "undo", 0, item.m_FileName ); + UndoItem item; + GetTempFileName(FS.get_path(_temp_)->m_Path, "undo", 0, item.m_FileName); - Save( item.m_FileName, true, true ); - m_UndoStack.push_back( item ); + Save(item.m_FileName, true, true); + m_UndoStack.push_back(item); - while( !m_RedoStack.empty() ){ - unlink( m_RedoStack.back().m_FileName ); - m_RedoStack.pop_back(); } + while (!m_RedoStack.empty()) + { + unlink(m_RedoStack.back().m_FileName); + m_RedoStack.pop_back(); + } - if( m_UndoStack.size() > EPrefs->scene_undo_level ){ - unlink( m_UndoStack.front().m_FileName ); - m_UndoStack.pop_front(); } + if (m_UndoStack.size()>EPrefs->scene_undo_level) + { + unlink(m_UndoStack.front().m_FileName); + m_UndoStack.pop_front(); + } } bool EScene::Undo() { -// if( !m_UndoStack.empty() ){ - if( m_UndoStack.size()>1 ){ - m_RedoStack.push_back( m_UndoStack.back() ); - m_UndoStack.pop_back(); - - if( m_RedoStack.size() > EPrefs->scene_undo_level ){ - unlink( m_RedoStack.front().m_FileName ); - m_RedoStack.pop_front(); + // if( !m_UndoStack.empty() ){ + if (m_UndoStack.size()>1) + { + m_RedoStack.push_back(m_UndoStack.back()); + m_UndoStack.pop_back(); + + if (m_RedoStack.size()>EPrefs->scene_undo_level) + { + unlink(m_RedoStack.front().m_FileName); + m_RedoStack.pop_front(); } - if( !m_UndoStack.empty() ){ - Unload(TRUE); - Load( m_UndoStack.back().m_FileName, true ); + if (!m_UndoStack.empty()) + { + Unload(TRUE); + Load(m_UndoStack.back().m_FileName, true); } UI->UpdateScene(); Modified(); - return true; - } - return false; + return true; + } + return false; } bool EScene::Redo() { - if( !m_RedoStack.empty() ){ + if (!m_RedoStack.empty()) + { Unload(TRUE); - Load( m_RedoStack.back().m_FileName, true ); + Load(m_RedoStack.back().m_FileName, true); - m_UndoStack.push_back( m_RedoStack.back() ); - m_RedoStack.pop_back(); + m_UndoStack.push_back(m_RedoStack.back()); + m_RedoStack.pop_back(); - if( m_UndoStack.size() > EPrefs->scene_undo_level ){ - unlink( m_UndoStack.front().m_FileName ); - m_UndoStack.pop_front(); } + if (m_UndoStack.size()>EPrefs->scene_undo_level) + { + unlink(m_UndoStack.front().m_FileName); + m_UndoStack.pop_front(); + } UI->UpdateScene(); Modified(); - return true; - } - return false; + return true; + } + return false; } //---------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/SceneUtil.cpp b/src/editors/LevelEditor/Edit/SceneUtil.cpp index 9e996f6d8c9..e3ea18fb434 100644 --- a/src/editors/LevelEditor/Edit/SceneUtil.cpp +++ b/src/editors/LevelEditor/Edit/SceneUtil.cpp @@ -8,57 +8,66 @@ #include "Scene.h" #include "ELight.h" #include "SceneObject.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" //---------------------------------------------------- -CCustomObject* EScene::FindObjectByName( LPCSTR name, ObjClassID classfilter ) +CCustomObject *EScene::FindObjectByName(LPCSTR name, ObjClassID classfilter) { - if(!name) - return NULL; - - CCustomObject* object = 0; + if (!name) + return NULL; + + CCustomObject*object = 0; if (classfilter==OBJCLASS_DUMMY) { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { - ESceneCustomOTool* mt = dynamic_cast(_I->second); + ESceneCustomOTool*mt = dynamic_cast(_I->second); - if (mt&&(0!=(object=mt->FindObjectByName(name)))) - return object; + if (mt&&(0!=(object = mt->FindObjectByName(name)))) + return object; } - }else{ - ESceneCustomOTool* mt = GetOTool(classfilter); VERIFY(mt); - if (mt&&(0!=(object=mt->FindObjectByName(name)))) return object; + } + else + { + ESceneCustomOTool*mt = GetOTool(classfilter); + VERIFY(mt); + if (mt&&(0!=(object = mt->FindObjectByName(name)))) + return object; } return object; } -CCustomObject* EScene::FindObjectByName( LPCSTR name, CCustomObject* pass_object ) +CCustomObject *EScene::FindObjectByName(LPCSTR name, CCustomObject *pass_object) { - CCustomObject* object = 0; + CCustomObject*object = 0; SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); - for (; _I!=_E; _I++){ - ESceneCustomOTool* mt = dynamic_cast(_I->second); - if (mt&&(0!=(object=mt->FindObjectByName(name,pass_object)))) return object; + for (; _I!=_E; _I++) + { + ESceneCustomOTool*mt = dynamic_cast(_I->second); + if (mt&&(0!=(object = mt->FindObjectByName(name, pass_object)))) + return object; } return 0; } bool EScene::FindDuplicateName() { -// find duplicate name + // find duplicate name SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); - for (; _I!=_E; _I++){ - ESceneCustomOTool* mt = dynamic_cast(_I->second); - if (mt){ - ObjectList& lst = mt->GetObjects(); - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) - if (FindObjectByName((*_F)->Name, *_F)){ - ELog.DlgMsg(mtError,"Duplicate object name already exists: '%s'",(*_F)->Name); + for (; _I!=_E; _I++) + { + ESceneCustomOTool*mt = dynamic_cast(_I->second); + if (mt) + { + ObjectList&lst = mt->GetObjects(); + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + if (FindObjectByName((*_F)->Name, *_F)) + { + ELog.DlgMsg(mtError, "Duplicate object name already exists: '%s'", (*_F)->Name); return true; } } @@ -66,12 +75,14 @@ bool EScene::FindDuplicateName() return false; } -void EScene::GenObjectName( ObjClassID cls_id, char *buffer, const char* pref ) +void EScene::GenObjectName(ObjClassID cls_id, char *buffer, const char *pref) { - ESceneCustomOTool* ot = GetOTool(cls_id); VERIFY(ot); - AnsiString result = FHelper.GenerateName(pref&&pref[0]?pref:ot->ClassName(),4,fastdelegate::bind(this,&EScene::FindObjectByNameCB),true,true); - strcpy (buffer,result.c_str()); + ESceneCustomOTool*ot = GetOTool(cls_id); + VERIFY(ot); + AnsiString result = FHelper.GenerateName(pref&&pref[0] ? pref : ot->ClassName(), 4, fastdelegate::bind(this, &EScene::FindObjectByNameCB), true, true); + strcpy(buffer, result.c_str()); } + //------------------------------------------------------------------------------ diff --git a/src/editors/LevelEditor/Edit/Scene_Tools.cpp b/src/editors/LevelEditor/Edit/Scene_Tools.cpp index 353864614eb..85570f1faa2 100644 --- a/src/editors/LevelEditor/Edit/Scene_Tools.cpp +++ b/src/editors/LevelEditor/Edit/Scene_Tools.cpp @@ -22,32 +22,32 @@ #include "ESceneWallmarkTools.h" #include "ESceneFogVolumeTools.h" -void EScene::RegisterSceneTools(ESceneToolBase* mt) +void EScene::RegisterSceneTools(ESceneToolBase *mt) { - m_SceneTools[mt->ClassID]= mt; - mt->OnCreate (); + m_SceneTools[mt->ClassID] = mt; + mt->OnCreate(); } void EScene::CreateSceneTools() { - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new() ); //+ - RegisterSceneTools (xr_new() ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new () ); //+ - RegisterSceneTools (xr_new() ); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ + RegisterSceneTools(xr_new()); //+ } void EScene::DestroySceneTools() @@ -56,11 +56,11 @@ void EScene::DestroySceneTools() SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; _I++) { - if(_I->second) - _I->second->OnDestroy(); + if (_I->second) + _I->second->OnDestroy(); - xr_delete(_I->second); + xr_delete(_I->second); } - m_SceneTools.clear (); + m_SceneTools.clear(); } diff --git a/src/editors/LevelEditor/Edit/SoundManager_LE.cpp b/src/editors/LevelEditor/Edit/SoundManager_LE.cpp index a17ef5413d8..74f15bca195 100644 --- a/src/editors/LevelEditor/Edit/SoundManager_LE.cpp +++ b/src/editors/LevelEditor/Edit/SoundManager_LE.cpp @@ -8,53 +8,61 @@ #include "du_box.h" #include "Common/LevelStructure.hpp" -CLevelSoundManager*& LSndLib=(CLevelSoundManager*)SndLib; +CLevelSoundManager *&LSndLib = (CLevelSoundManager*)SndLib; bool CLevelSoundManager::Validate() { - ObjectList& snd_envs = Scene->ListObj(OBJCLASS_SOUND_ENV); - for (ObjectIt it=snd_envs.begin(); it!=snd_envs.end(); it++){ - ESoundEnvironment* E = dynamic_cast(*it); R_ASSERT(E); - if (E->m_EnvInner==E->m_EnvOuter){ - ELog.DlgMsg(mtError,"SoundEnvironment: '%s' inner and outer environment must be different.",E->Name); - return false; + ObjectList &snd_envs = Scene->ListObj(OBJCLASS_SOUND_ENV); + for (ObjectIt it = snd_envs.begin(); it!=snd_envs.end(); it++) + { + ESoundEnvironment *E = dynamic_cast(*it); + R_ASSERT(E); + if (E->m_EnvInner==E->m_EnvOuter) + { + ELog.DlgMsg(mtError, "SoundEnvironment: '%s' inner and outer environment must be different.", E->Name); + return false; } } - ObjectList& snd_src = Scene->ListObj(OBJCLASS_SOUND_SRC); - for (it=snd_src.begin(); it!=snd_src.end(); it++){ - ESoundSource* S = dynamic_cast(*it); R_ASSERT(S); - if (!S->GetSourceWAV()||(0==strlen(S->GetSourceWAV()))){ - ELog.DlgMsg(mtError,"SoundSource: '%s' hasn't wave.",S->Name); - return false; - } + ObjectList &snd_src = Scene->ListObj(OBJCLASS_SOUND_SRC); + for (it = snd_src.begin(); it!=snd_src.end(); it++) + { + ESoundSource *S = dynamic_cast(*it); + R_ASSERT(S); + if (!S->GetSourceWAV()||(0==strlen(S->GetSourceWAV()))) + { + ELog.DlgMsg(mtError, "SoundSource: '%s' hasn't wave.", S->Name); + return false; + } } return true; } + /* void CLevelSoundManager::RealRefreshEnvGeometry() { - CMemoryWriter F; - if (MakeEnvGeometry(F,false)){ - IReader R(F.pointer(), F.size()); - ::Sound->set_geometry_env(&R); - } + CMemoryWriter F; + if ( MakeEnvGeometry(F, false) ) + { + IReader R( F.pointer(), F.size() ); + ::Sound->set_geometry_env( &R ); + } } bool CLevelSoundManager::MakeEnvGeometry(CMemoryWriter& F, bool bErrMsg) { - ObjectList& snd_envs = Scene->ListObj(OBJCLASS_SOUND_ENV); + ObjectList& snd_envs = Scene->ListObj(OBJCLASS_SOUND_ENV); if (snd_envs.empty()){ - if (bErrMsg) ELog.Msg(mtError,"Scene hasn't sound environment geometry."); - return false; + if (bErrMsg) ELog.Msg(mtError,"Scene hasn't sound environment geometry."); + return false; } - RStringVec env_names; + RStringVec env_names; CDB::Collector CP; - Fbox aabb; aabb.invalidate(); + Fbox aabb; aabb.invalidate(); for (ObjectIt it=snd_envs.begin(); it!=snd_envs.end(); it++){ - ESoundEnvironment* E = dynamic_cast(*it); R_ASSERT(E); + ESoundEnvironment* E = dynamic_cast(*it); R_ASSERT(E); Fbox bb; R_ASSERT (E->GetBox(bb)); aabb.merge (bb); @@ -66,8 +74,8 @@ bool CLevelSoundManager::MakeEnvGeometry(CMemoryWriter& F, bool bErrMsg) int inner = -1; int outer = -1; for (RStringVecIt e_it=env_names.begin(); e_it!=env_names.end(); e_it++){ - if ((-1==inner)&&(E->m_EnvInner==*e_it)) inner = e_it-env_names.begin(); - if ((-1==outer)&&(E->m_EnvOuter==*e_it)) outer = e_it-env_names.begin(); + if ((-1==inner)&&(E->m_EnvInner==*e_it)) inner = e_it-env_names.begin(); + if ((-1==outer)&&(E->m_EnvOuter==*e_it)) outer = e_it-env_names.begin(); if ((inner>-1)&&(outer>-1)) break; } @@ -76,31 +84,31 @@ bool CLevelSoundManager::MakeEnvGeometry(CMemoryWriter& F, bool bErrMsg) u32 idx = (inner<<16)|(outer); // append to collector - Fmatrix M; E->get_box (M); + Fmatrix M; E->get_box (M); Fvector bv[DU_BOX_NUMVERTEX]; for (int k=0; kc_str()); + for (RStringVecIt e_it=env_names.begin(); e_it!=env_names.end(); e_it++) + F.w_stringZ (e_it->c_str()); F.close_chunk (); // write geom F.open_chunk (1); // write header - hdrCFORM H; + hdrCFORM H; H.version = CFORM_CURRENT_VERSION; H.vertcount = CP.getVS(); H.facecount = CP.getTS(); H.aabb = aabb; - F.w (&H,sizeof(hdrCFORM)); + F.w (&H,sizeof(hdrCFORM)); // write vertices&TRIs F.w (CP.getV(),sizeof(Fvector)*H.vertcount); F.w (CP.getT(),sizeof(CDB::TRI)*H.facecount); @@ -111,16 +119,19 @@ bool CLevelSoundManager::MakeEnvGeometry(CMemoryWriter& F, bool bErrMsg) */ void CLevelSoundManager::OnFrame() { - inherited::OnFrame(); - if (bNeedRefreshEnvGeom){ - bNeedRefreshEnvGeom = false; - // RealRefreshEnvGeometry (); + inherited::OnFrame(); + if (bNeedRefreshEnvGeom) + { + bNeedRefreshEnvGeom = false; + // RealRefreshEnvGeometry (); } } + /* void CLevelSoundManager::RefreshEnvLibrary() { - Sound->refresh_env_library(); - RefreshEnvGeometry (); + Sound->refresh_env_library(); + RefreshEnvGeometry (); } */ + diff --git a/src/editors/LevelEditor/Edit/SoundManager_LE.h b/src/editors/LevelEditor/Edit/SoundManager_LE.h index 0a3aeaa7163..8015e692155 100644 --- a/src/editors/LevelEditor/Edit/SoundManager_LE.h +++ b/src/editors/LevelEditor/Edit/SoundManager_LE.h @@ -2,36 +2,46 @@ #ifndef SoundManager_LEH #define SoundManager_LEH -#include "../ECore/Editor/SoundManager.h" +#include "editors/ECore/Editor/SoundManager.h" // refs class ESoundThumbnail; -class CLevelSoundManager: public CSoundManager{ - typedef CSoundManager inherited; - bool bNeedRefreshEnvGeom; - void RealRefreshEnvGeometry(); - void MakeGameSound (ESoundThumbnail* THM, LPCSTR src_name, LPCSTR game_name); +class CLevelSoundManager: public CSoundManager +{ + typedef CSoundManager inherited; + bool bNeedRefreshEnvGeom; + void RealRefreshEnvGeometry(); + void MakeGameSound(ESoundThumbnail *THM, LPCSTR src_name, LPCSTR game_name); public: - CLevelSoundManager (){bNeedRefreshEnvGeom = false;} - ~CLevelSoundManager (){;} + CLevelSoundManager() + { + bNeedRefreshEnvGeom = false; + } - virtual void OnFrame (); + ~CLevelSoundManager() { } - void RefreshEnvLibrary (); - void RefreshEnvGeometry (){bNeedRefreshEnvGeom = true;} + virtual void OnFrame(); -// bool MakeEnvGeometry (CMemoryWriter& F, bool bErrMsg=false); + void RefreshEnvLibrary(); - bool Validate (); + void RefreshEnvGeometry() + { + bNeedRefreshEnvGeom = true; + } - void MuteSounds (BOOL bVal); + // bool MakeEnvGeometry(CMemoryWriter& F, bool bErrMsg=false); - void RefreshSounds (bool bSync); + bool Validate(); - AnsiString UpdateFileName (AnsiString& fn); + void MuteSounds(BOOL bVal); + + void RefreshSounds(bool bSync); + + AnsiString UpdateFileName(AnsiString &fn); }; -extern CLevelSoundManager*& LSndLib; +extern CLevelSoundManager *&LSndLib; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/Edit/SpawnPoint.cpp b/src/editors/LevelEditor/Edit/SpawnPoint.cpp index 7ff468abd37..db6a48855a4 100644 --- a/src/editors/LevelEditor/Edit/SpawnPoint.cpp +++ b/src/editors/LevelEditor/Edit/SpawnPoint.cpp @@ -4,19 +4,19 @@ #include "stdafx.h" #pragma hdrstop -#include "spawnpoint.h" +#include "SpawnPoint.h" #include "ESceneSpawnTools.h" -#include "eshape.h" -#include "../../xrServerEntities/xrServer_Objects_Abstract.h" -#include "../ECore/Editor/ui_main.h" +#include "EShape.h" +#include "xrServerEntities/xrServer_Objects_Abstract.h" +#include "editors/ECore/Editor/ui_main.h" #include "SkeletonAnimated.h" #include "ObjectAnimator.h" -#include "../../xrServerEntities/xrMessages.h" +#include "xrServerEntities/xrMessages.h" #include "scene.h" -#include "../ECore/Editor/D3DUtils.h" +#include "editors/ECore/Editor/D3DUtils.h" #include "iniStreamImpl.h" -#include "../Ecore/Editor/EditObject.h" -#include "../ETools/ETools.h" +#include "editors/ECore/Editor/EditObject.h" +#include "utils/ETools/ETools.h" //---------------------------------------------------- #define SPAWNPOINT_CHUNK_VERSION 0xE411 @@ -42,72 +42,74 @@ #define RPOINT_SIZE 0.5f #define ENVMOD_SIZE 0.25f #define MAX_TEAM 6 -const u32 RP_COLORS[MAX_TEAM]={0xff0000,0x00ff00,0x0000ff,0xffff00,0x00ffff,0xff00ff}; +const u32 RP_COLORS[MAX_TEAM] = {0xff0000,0x00ff00,0x0000ff,0xffff00,0x00ffff,0xff00ff}; + //---------------------------------------------------- -void CSE_Visual::set_visual (LPCSTR name, bool load) +void CSE_Visual::set_visual(LPCSTR name, bool load) { - string_path tmp; - strcpy (tmp,name); - if (strext(tmp)) *strext(tmp) = 0; - xr_strlwr (tmp); - visual_name = tmp; + string_path tmp; + strcpy(tmp, name); + if (strext(tmp)) + *strext(tmp) = 0; + xr_strlwr(tmp); + visual_name = tmp; } //------------------------------------------------------------------------------ // CLE_Visual //------------------------------------------------------------------------------ -CSpawnPoint::CLE_Visual::CLE_Visual(CSE_Visual* src) +CSpawnPoint::CLE_Visual::CLE_Visual(CSE_Visual *src) { - source = src; - visual = 0; + source = src; + visual = 0; } bool CSpawnPoint::CLE_Visual::g_tmp_lock = false; CSpawnPoint::CLE_Visual::~CLE_Visual() { - ::Render->model_Delete (visual,TRUE); + ::Render->model_Delete(visual, TRUE); } -void CSpawnPoint::CLE_Visual::OnChangeVisual () +void CSpawnPoint::CLE_Visual::OnChangeVisual() { - ::Render->model_Delete (visual,TRUE); + ::Render->model_Delete(visual, TRUE); if (source->visual_name.size()) { - visual = ::Render->model_Create(source->visual_name.c_str()); + visual = ::Render->model_Create(source->visual_name.c_str()); - if(NULL==visual && !g_tmp_lock) + if (NULL==visual&&!g_tmp_lock) { - xr_string _msg = "Model [" + xr_string(source->visual_name.c_str())+"] not found. Do you want to select it from library?"; - int mr = ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo, _msg.c_str()); - LPCSTR _new_val = 0; - g_tmp_lock = true; - if (mr==mrYes && TfrmChoseItem::SelectItem(smVisual,_new_val, 1) ) - { - source->visual_name = _new_val; - visual = ::Render->model_Create(source->visual_name.c_str()); - } - g_tmp_lock = false; - + xr_string _msg = "Model ["+xr_string(source->visual_name.c_str())+"] not found. Do you want to select it from library?"; + int mr = ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<visual_name = _new_val; + visual = ::Render->model_Create(source->visual_name.c_str()); + } + g_tmp_lock = false; } - PlayAnimationFirstFrame (); + PlayAnimationFirstFrame(); } - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void CSpawnPoint::CLE_Visual::PlayAnimation () +void CSpawnPoint::CLE_Visual::PlayAnimation() { - if(g_tmp_lock) return; + if (g_tmp_lock) + return; // play motion if skeleton - StopAllAnimations (); + StopAllAnimations(); - CKinematicsAnimated* KA = PKinematicsAnimated(visual); - IKinematics* K = PKinematics(visual); + CKinematicsAnimated *KA = PKinematicsAnimated(visual); + IKinematics *K = PKinematics(visual); if (KA) { - MotionID M = KA->ID_Cycle_Safe(source->startup_animation.c_str()); - if (M.valid()) - KA->PlayCycle (M); + MotionID M = KA->ID_Cycle_Safe(source->startup_animation.c_str()); + if (M.valid()) + KA->PlayCycle(M); } if (K) K->CalculateBones(); @@ -115,41 +117,45 @@ void CSpawnPoint::CLE_Visual::PlayAnimation () void CSpawnPoint::CLE_Visual::StopAllAnimations() { - if(g_tmp_lock) return; + if (g_tmp_lock) + return; // play motion if skeleton - CKinematicsAnimated* KA = PKinematicsAnimated(visual); + CKinematicsAnimated *KA = PKinematicsAnimated(visual); if (KA) { - for (u16 i=0; iLL_CloseCycle(i, u8(-1)); + for (u16 i = 0; iLL_CloseCycle(i, u8(-1)); } } void CSpawnPoint::CLE_Visual::PlayAnimationFirstFrame() { - if(g_tmp_lock) return; + if (g_tmp_lock) + return; // play motion if skeleton - StopAllAnimations (); - - CKinematicsAnimated* KA = PKinematicsAnimated(visual); - IKinematics* K = PKinematics(visual); + StopAllAnimations(); + + CKinematicsAnimated *KA = PKinematicsAnimated(visual); + IKinematics *K = PKinematics(visual); if (KA) { - MotionID M = KA->ID_Cycle_Safe(source->startup_animation.c_str()); + MotionID M = KA->ID_Cycle_Safe(source->startup_animation.c_str()); if (M.valid()) - { - KA->PlayCycle (M); - PauseAnimation (); - }else - Msg("! visual [%s] has no animation [%s]", source->visual_name.c_str(), source->startup_animation.c_str()); + { + KA->PlayCycle(M); + PauseAnimation(); + } + else + Msg("! visual [%s] has no animation [%s]", source->visual_name.c_str(), source->startup_animation.c_str()); } if (K) K->CalculateBones(); } + struct SetBlendLastFrameCB : public IterateBlendsCallback { - virtual void operator () ( CBlend &B ) + virtual void operator ()(CBlend &B) { B.timeCurrent = B.timeTotal-0.4444f; B.blendAmount = 1.0f; @@ -159,19 +165,20 @@ struct SetBlendLastFrameCB : public IterateBlendsCallback void CSpawnPoint::CLE_Visual::PlayAnimationLastFrame() { - if(g_tmp_lock) return; + if (g_tmp_lock) + return; // play motion if skeleton - StopAllAnimations (); - - CKinematicsAnimated* KA = PKinematicsAnimated(visual); - IKinematics* K = PKinematics(visual); + StopAllAnimations(); + + CKinematicsAnimated *KA = PKinematicsAnimated(visual); + IKinematics *K = PKinematics(visual); if (KA) { - MotionID M = KA->ID_Cycle_Safe(source->startup_animation.c_str()); + MotionID M = KA->ID_Cycle_Safe(source->startup_animation.c_str()); if (M.valid()) - { - KA->PlayCycle (M); + { + KA->PlayCycle(M); KA->LL_IterateBlends(g_Set_blend_last_frame_CB); } } @@ -181,18 +188,19 @@ void CSpawnPoint::CLE_Visual::PlayAnimationLastFrame() struct TogglelendCB : public IterateBlendsCallback { - virtual void operator () ( CBlend &B ) + virtual void operator ()(CBlend &B) { B.playing = !B.playing; } } g_toggle_pause_blendCB; -void CSpawnPoint::CLE_Visual::PauseAnimation () +void CSpawnPoint::CLE_Visual::PauseAnimation() { - if(g_tmp_lock) return; - - CKinematicsAnimated* KA = PKinematicsAnimated(visual); - IKinematics* K = PKinematics(visual); + if (g_tmp_lock) + return; + + CKinematicsAnimated *KA = PKinematicsAnimated(visual); + IKinematics *K = PKinematics(visual); if (KA) KA->LL_IterateBlends(g_toggle_pause_blendCB); @@ -204,266 +212,284 @@ void CSpawnPoint::CLE_Visual::PauseAnimation () //------------------------------------------------------------------------------ // CLE_Motion //------------------------------------------------------------------------------ -CSpawnPoint::CLE_Motion::CLE_Motion (CSE_Motion* src) +CSpawnPoint::CLE_Motion::CLE_Motion(CSE_Motion *src) { - source = src; - animator = 0; + source = src; + animator = 0; } -CSpawnPoint::CLE_Motion::~CLE_Motion() -{ -} -void __stdcall CSpawnPoint::CLE_Motion::OnChangeMotion () + +CSpawnPoint::CLE_Motion::~CLE_Motion() {} + +void __stdcall CSpawnPoint::CLE_Motion::OnChangeMotion() { - xr_delete (animator); - if (source->motion_name.size()){ - animator = xr_new(); - animator->Load (*source->motion_name); - PlayMotion (); + xr_delete(animator); + if (source->motion_name.size()) + { + animator = xr_new(); + animator->Load(*source->motion_name); + PlayMotion(); } - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } + void CSpawnPoint::CLE_Motion::PlayMotion() { // play motion if skeleton - if (animator) animator->Play(true); + if (animator) + animator->Play(true); } + //------------------------------------------------------------------------------ // SpawnData //------------------------------------------------------------------------------ void CSpawnPoint::SSpawnData::Create(LPCSTR _entity_ref) { - m_Data = create_entity (_entity_ref); - if (m_Data){ - m_Data->set_name (_entity_ref); + m_Data = create_entity(_entity_ref); + if (m_Data) + { + m_Data->set_name(_entity_ref); if (m_Data->visual()) { - m_Visual = xr_new(m_Data->visual()); + m_Visual = xr_new(m_Data->visual()); m_Data->set_editor_flag(IServerEntity::flVisualChange|IServerEntity::flVisualAnimationChange); } if (m_Data->motion()) { - m_Motion = xr_new(m_Data->motion()); + m_Motion = xr_new(m_Data->motion()); m_Data->set_editor_flag(IServerEntity::flMotionChange); } - if (pSettings->line_exist(m_Data->name(),"$player")) + if (pSettings->line_exist(m_Data->name(), "$player")) { - if (pSettings->r_bool(m_Data->name(),"$player")) + if (pSettings->r_bool(m_Data->name(), "$player")) { - m_Data->flags().set(M_SPAWN_OBJECT_ASPLAYER,TRUE); + m_Data->flags().set(M_SPAWN_OBJECT_ASPLAYER, TRUE); } } - m_ClassID = pSettings->r_clsid(m_Data->name(),"class"); - }else{ - Log("!Can't create entity: ",_entity_ref); + m_ClassID = pSettings->r_clsid(m_Data->name(), "class"); + } + else + { + Log("!Can't create entity: ", _entity_ref); } - if(pSettings->line_exist( _entity_ref, "$render_if_selected") ) + if (pSettings->line_exist(_entity_ref, "$render_if_selected")) { m_owner->SetRenderIfSelected(TRUE); - }else + } + else m_owner->SetRenderIfSelected(FALSE); - } void CSpawnPoint::SSpawnData::Destroy() { - destroy_entity (m_Data); - xr_delete (m_Visual); - xr_delete (m_Motion); + destroy_entity(m_Data); + xr_delete(m_Visual); + xr_delete(m_Motion); } -void CSpawnPoint::SSpawnData::get_bone_xform (LPCSTR name, Fmatrix& xform) + +void CSpawnPoint::SSpawnData::get_bone_xform(LPCSTR name, Fmatrix &xform) { - xform.identity (); - if (name&&name[0]&&m_Visual&&m_Visual->visual){ - IKinematics* P = PKinematics(m_Visual->visual); - if (P){ - u16 id = P->LL_BoneID(name); + xform.identity(); + if (name&&name[0]&&m_Visual&&m_Visual->visual) + { + IKinematics *P = PKinematics(m_Visual->visual); + if (P) + { + u16 id = P->LL_BoneID(name); if (id!=BI_NONE) - xform = P->LL_GetTransform(id); - } + xform = P->LL_GetTransform(id); + } } } -bool CSpawnPoint::SSpawnData::LoadLTX (CInifile& ini, LPCSTR sect_name) -{ - xr_string temp = ini.r_string (sect_name, "name"); - Create (temp.c_str()); - - if(ini.line_exist(sect_name,"fl")) - m_flags.assign (ini.r_u8(sect_name,"fl")); - - NET_Packet Packet; - SIniFileStream ini_stream; - ini_stream.ini = &ini; - ini_stream.sect = sect_name; - ini_stream.move_begin (); - Packet.inistream = &ini_stream; - +bool CSpawnPoint::SSpawnData::LoadLTX(CInifile &ini, LPCSTR sect_name) +{ + xr_string temp = ini.r_string(sect_name, "name"); + Create(temp.c_str()); + + if (ini.line_exist(sect_name, "fl")) + m_flags.assign(ini.r_u8(sect_name, "fl")); + + NET_Packet Packet; + SIniFileStream ini_stream; + ini_stream.ini = &ini; + ini_stream.sect = sect_name; + ini_stream.move_begin(); + Packet.inistream = &ini_stream; + if (Valid()) if (!m_Data->Spawn_Read(Packet)) - Destroy (); + Destroy(); return Valid(); } -void CSpawnPoint::SSpawnData::SaveLTX (CInifile& ini, LPCSTR sect_name) +void CSpawnPoint::SSpawnData::SaveLTX(CInifile &ini, LPCSTR sect_name) { ini.w_string(sect_name, "name", m_Data->name()); - ini.w_u8 (sect_name,"fl", m_flags.get()); - - NET_Packet Packet; - SIniFileStream ini_stream; - ini_stream.ini = &ini; - ini_stream.sect = sect_name; - ini_stream.move_begin (); - Packet.inistream = &ini_stream; - - m_Data->Spawn_Write (Packet,TRUE); -} + ini.w_u8(sect_name, "fl", m_flags.get()); -void CSpawnPoint::SSpawnData::SaveStream(IWriter& F) -{ - F.open_chunk (SPAWNPOINT_CHUNK_ENTITYREF); - F.w_stringZ (m_Data->name()); - F.close_chunk (); + NET_Packet Packet; + SIniFileStream ini_stream; + ini_stream.ini = &ini; + ini_stream.sect = sect_name; + ini_stream.move_begin(); + Packet.inistream = &ini_stream; - F.open_chunk (SPAWNPOINT_CHUNK_FLAGS); - F.w_u8 (m_flags.get()); - F.close_chunk (); + m_Data->Spawn_Write(Packet, TRUE); +} - F.open_chunk (SPAWNPOINT_CHUNK_SPAWNDATA); - NET_Packet Packet; - m_Data->Spawn_Write (Packet,TRUE); - F.w_u32 (Packet.B.count); - F.w (Packet.B.data,Packet.B.count); - F.close_chunk (); +void CSpawnPoint::SSpawnData::SaveStream(IWriter &F) +{ + F.open_chunk(SPAWNPOINT_CHUNK_ENTITYREF); + F.w_stringZ(m_Data->name()); + F.close_chunk(); + + F.open_chunk(SPAWNPOINT_CHUNK_FLAGS); + F.w_u8(m_flags.get()); + F.close_chunk(); + + F.open_chunk(SPAWNPOINT_CHUNK_SPAWNDATA); + NET_Packet Packet; + m_Data->Spawn_Write(Packet, TRUE); + F.w_u32(Packet.B.count); + F.w(Packet.B.data, Packet.B.count); + F.close_chunk(); } -bool CSpawnPoint::SSpawnData::LoadStream(IReader& F) +bool CSpawnPoint::SSpawnData::LoadStream(IReader &F) { - string64 temp; - R_ASSERT (F.find_chunk(SPAWNPOINT_CHUNK_ENTITYREF)); - F.r_stringZ (temp,sizeof(temp)); + string64 temp; + R_ASSERT(F.find_chunk(SPAWNPOINT_CHUNK_ENTITYREF)); + F.r_stringZ(temp, sizeof(temp)); - if(F.find_chunk(SPAWNPOINT_CHUNK_FLAGS)) - m_flags.assign (F.r_u8()); + if (F.find_chunk(SPAWNPOINT_CHUNK_FLAGS)) + m_flags.assign(F.r_u8()); - NET_Packet Packet; + NET_Packet Packet; R_ASSERT(F.find_chunk(SPAWNPOINT_CHUNK_SPAWNDATA)); - Packet.B.count = F.r_u32(); - F.r (Packet.B.data,Packet.B.count); - Create (temp); + Packet.B.count = F.r_u32(); + F.r(Packet.B.data, Packet.B.count); + Create(temp); if (Valid()) if (!m_Data->Spawn_Read(Packet)) - Destroy (); + Destroy(); return Valid(); } -bool CSpawnPoint::SSpawnData::ExportGame(SExportStreams* F, CSpawnPoint* owner) + +bool CSpawnPoint::SSpawnData::ExportGame(SExportStreams *F, CSpawnPoint *owner) { // set params - m_Data->set_name_replace (owner->Name); - m_Data->position().set (owner->PPosition); - m_Data->angle().set (owner->PRotation); + m_Data->set_name_replace(owner->Name); + m_Data->position().set(owner->PPosition); + m_Data->angle().set(owner->PRotation); // export cform (if needed) - IServerEntityShape* cform = m_Data->shape(); -// SHAPE - if (cform&&!(owner->m_AttachedObject&&(owner->m_AttachedObject->ClassID==OBJCLASS_SHAPE))){ - ELog.DlgMsg (mtError,"Spawn Point: '%s' must contain attached shape.",owner->Name); + IServerEntityShape *cform = m_Data->shape(); + // SHAPE + if (cform&&!(owner->m_AttachedObject&&(owner->m_AttachedObject->ClassID==OBJCLASS_SHAPE))) + { + ELog.DlgMsg(mtError, "Spawn Point: '%s' must contain attached shape.", owner->Name); return false; } - if (cform){ - CEditShape* shape = dynamic_cast(owner->m_AttachedObject); R_ASSERT(shape); - shape->ApplyScale (); - owner->PScale = shape->PScale; - cform->assign_shapes (&*shape->GetShapes().begin(),shape->GetShapes().size()); + if (cform) + { + CEditShape *shape = dynamic_cast(owner->m_AttachedObject); + R_ASSERT(shape); + shape->ApplyScale(); + owner->PScale = shape->PScale; + cform->assign_shapes(&*shape->GetShapes().begin(), shape->GetShapes().size()); } // end - NET_Packet Packet; - m_Data->Spawn_Write (Packet,TRUE); + NET_Packet Packet; + m_Data->Spawn_Write(Packet, TRUE); - SExportStreamItem& tgt = (m_flags.test(eSDTypeRespawn))? F->spawn_rs : F->spawn; - tgt.stream.open_chunk (tgt.chunk++); - tgt.stream.w (Packet.B.data,Packet.B.count); - tgt.stream.close_chunk (); + SExportStreamItem &tgt = (m_flags.test(eSDTypeRespawn)) ? F->spawn_rs : F->spawn; + tgt.stream.open_chunk(tgt.chunk++); + tgt.stream.w(Packet.B.data, Packet.B.count); + tgt.stream.close_chunk(); return true; } -void CSpawnPoint::SSpawnData::OnAnimControlClick(ButtonValue* value, bool& bModif, bool& bSafe) +void CSpawnPoint::SSpawnData::OnAnimControlClick(ButtonValue *value, bool &bModif, bool &bSafe) { - ButtonValue* B = dynamic_cast(value); R_ASSERT(B); - switch(B->btn_num) + ButtonValue *B = dynamic_cast(value); + R_ASSERT(B); + switch (B->btn_num) { -// "First,Play,Pause,Stop,Last", + // "First,Play,Pause,Stop,Last", case 0: //first { m_Visual->PlayAnimationFirstFrame(); - }break; + } + break; case 1: //play { m_Visual->PlayAnimation(); - }break; + } + break; case 2: //pause { m_Visual->PauseAnimation(); - }break; + } + break; case 3: //stop { m_Visual->StopAllAnimations(); - }break; + } + break; case 4: //last { m_Visual->PlayAnimationLastFrame(); - }break; - + } + break; } } -void CSpawnPoint::SSpawnData::FillProp(LPCSTR pref, PropItemVec& items) +void CSpawnPoint::SSpawnData::FillProp(LPCSTR pref, PropItemVec &items) { - m_Data->FillProp (pref,items); - - if(Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDDeathmatch|eGameIDTeamDeathmatch|eGameIDArtefactHunt|eGameIDCaptureTheArtefact)) - PHelper().CreateFlag8 (items, PrepareKey(pref,"MP respawn"), &m_flags, eSDTypeRespawn); + m_Data->FillProp(pref, items); - if(m_Visual) - { - ButtonValue* BV = PHelper().CreateButton ( items, - PrepareKey(pref,m_Data->name(),"Model\\AnimationControl"), - "|<<,Play,Pause,Stop,>>|", - 0); - BV->OnBtnClickEvent.bind (this,&CSpawnPoint::SSpawnData::OnAnimControlClick); + if (Scene->m_LevelOp.m_mapUsage.MatchType(eGameIDDeathmatch|eGameIDTeamDeathmatch|eGameIDArtefactHunt|eGameIDCaptureTheArtefact)) + PHelper().CreateFlag8(items, PrepareKey(pref, "MP respawn"), &m_flags, eSDTypeRespawn); - } + if (m_Visual) + { + ButtonValue *BV = PHelper().CreateButton(items, + PrepareKey(pref, m_Data->name(), "Model\\AnimationControl"), + "|<<,Play,Pause,Stop,>>|", + 0); + BV->OnBtnClickEvent.bind(this, &CSpawnPoint::SSpawnData::OnAnimControlClick); + } } -void CSpawnPoint::SSpawnData::Render(bool bSelected, const Fmatrix& parent,int priority, bool strictB2F) +void CSpawnPoint::SSpawnData::Render(bool bSelected, const Fmatrix &parent, int priority, bool strictB2F) { if (m_Visual&&m_Visual->visual) - ::Render->model_Render (m_Visual->visual,parent,priority,strictB2F,1.f); + ::Render->model_Render(m_Visual->visual, parent, priority, strictB2F, 1.f); if (m_Motion&&m_Motion->animator&&bSelected&&(1==priority)&&(false==strictB2F)) m_Motion->animator->DrawPath(); - RCache.set_xform_world (Fidentity); - EDevice.SetShader (EDevice.m_WireShader); - m_Data->on_render (&DU_impl,this,bSelected,parent,priority,strictB2F); + RCache.set_xform_world(Fidentity); + EDevice.SetShader(EDevice.m_WireShader); + m_Data->on_render(&DU_impl, this, bSelected, parent, priority, strictB2F); - if(bSelected) + if (bSelected) { - xr_vector::iterator it = m_VisualHelpers.begin(); - xr_vector::iterator it_e = m_VisualHelpers.end(); + xr_vector::iterator it = m_VisualHelpers.begin(); + xr_vector::iterator it_e = m_VisualHelpers.end(); Fmatrix M; u32 idx = 0; - for(;it!=it_e;++it,++idx) + for (; it!=it_e; ++it,++idx) { - visual_data* vc = m_Data->visual_collection()+idx; - M.mul (parent, vc->matrix); - CLE_Visual* v = *it; - ::Render->model_Render (v->visual,M,priority,strictB2F,1.f); + visual_data *vc = m_Data->visual_collection()+idx; + M.mul(parent, vc->matrix); + CLE_Visual *v = *it; + ::Render->model_Render(v->visual, M, priority, strictB2F, 1.f); } } } @@ -471,21 +497,21 @@ void CSpawnPoint::SSpawnData::Render(bool bSelected, const Fmatrix& parent,int p void CSpawnPoint::SSpawnData::OnFrame() { if (m_Data->m_editor_flags.is(IServerEntity::flUpdateProperties)) - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); // visual part if (m_Visual) { if (m_Data->m_editor_flags.is(IServerEntity::flVisualChange)) m_Visual->OnChangeVisual(); - if(m_Data->m_editor_flags.is(IServerEntity::flVisualAnimationChange)) + if (m_Data->m_editor_flags.is(IServerEntity::flVisualAnimationChange)) { m_Visual->PlayAnimationFirstFrame(); m_Data->m_editor_flags.set(IServerEntity::flVisualAnimationChange, FALSE); } if (m_Visual->visual&&PKinematics(m_Visual->visual)) - PKinematics (m_Visual->visual)->CalculateBones(TRUE); + PKinematics(m_Visual->visual)->CalculateBones(TRUE); } // motion part if (m_Motion) @@ -498,153 +524,172 @@ void CSpawnPoint::SSpawnData::OnFrame() if (m_Data->m_editor_flags.is(IServerEntity::flVisualChange)) { - xr_vector::iterator it = m_VisualHelpers.begin(); - xr_vector::iterator it_e = m_VisualHelpers.end(); - for(;it!=it_e;++it) + xr_vector::iterator it = m_VisualHelpers.begin(); + xr_vector::iterator it_e = m_VisualHelpers.end(); + for (; it!=it_e; ++it) { - CLE_Visual* v = *it; - xr_delete (v); + CLE_Visual *v = *it; + xr_delete(v); } - m_VisualHelpers.clear (); + m_VisualHelpers.clear(); - u32 cnt = m_Data->visual_collection_size(); - visual_data* vc = m_Data->visual_collection(); + u32 cnt = m_Data->visual_collection_size(); + visual_data *vc = m_Data->visual_collection(); - for(u32 i=0; i(vc->visual); + CLE_Visual *V = xr_new(vc->visual); V->OnChangeVisual(); m_VisualHelpers.push_back(V); V->PlayAnimation(); } } - xr_vector::iterator it = m_VisualHelpers.begin(); - xr_vector::iterator it_e = m_VisualHelpers.end(); - for(;it!=it_e;++it) + xr_vector::iterator it = m_VisualHelpers.begin(); + xr_vector::iterator it_e = m_VisualHelpers.end(); + for (; it!=it_e; ++it) { - CLE_Visual* v = *it; + CLE_Visual *v = *it; if (PKinematics(v->visual)) - PKinematics (v->visual)->CalculateBones(TRUE); + PKinematics(v->visual)->CalculateBones(TRUE); } // reset editor flags - m_Data->m_editor_flags.zero (); + m_Data->m_editor_flags.zero(); } + //------------------------------------------------------------------------------ -CSpawnPoint::CSpawnPoint(LPVOID data, LPCSTR name):CCustomObject(data,name),m_SpawnData(this) +CSpawnPoint::CSpawnPoint(LPVOID data, LPCSTR name): CCustomObject(data, name), m_SpawnData(this) { - m_rpProfile = ""; - m_EM_Flags.one (); - Construct (data); + m_rpProfile = ""; + m_EM_Flags.one(); + Construct(data); } void CSpawnPoint::Construct(LPVOID data) { - ClassID = OBJCLASS_SPAWNPOINT; - m_AttachedObject= 0; - if (data){ - if (strcmp(LPSTR(data),RPOINT_CHOOSE_NAME)==0) + ClassID = OBJCLASS_SPAWNPOINT; + m_AttachedObject = 0; + if (data) + { + if (strcmp(LPSTR(data), RPOINT_CHOOSE_NAME)==0) { - m_Type = ptRPoint; - m_RP_Type = rptActorSpawn; + m_Type = ptRPoint; + m_RP_Type = rptActorSpawn; m_GameType.SetDefaults(); - m_RP_TeamID = 1; - }else if (strcmp(LPSTR(data),ENVMOD_CHOOSE_NAME)==0) + m_RP_TeamID = 1; + } + else if (strcmp(LPSTR(data), ENVMOD_CHOOSE_NAME)==0) + { + m_Type = ptEnvMod; + m_EM_Radius = 10.f; + m_EM_Power = 1.f; + m_EM_ViewDist = 300.f; + m_EM_FogColor = 0x00808080; + m_EM_FogDensity = 1.f; + m_EM_AmbientColor = 0x00000000; + m_EM_SkyColor = 0x00FFFFFF; + m_EM_HemiColor = 0x00FFFFFF; + } + else { - m_Type = ptEnvMod; - m_EM_Radius = 10.f; - m_EM_Power = 1.f; - m_EM_ViewDist = 300.f; - m_EM_FogColor = 0x00808080; - m_EM_FogDensity = 1.f; - m_EM_AmbientColor = 0x00000000; - m_EM_SkyColor = 0x00FFFFFF; - m_EM_HemiColor = 0x00FFFFFF; - }else{ CreateSpawnData(LPCSTR(data)); if (!m_SpawnData.Valid()) { SetValid(false); - }else{ - m_Type = ptSpawnPoint; + } + else + { + m_Type = ptSpawnPoint; } } - }else{ + } + else + { SetValid(false); } } -void CSpawnPoint:: OnSceneRemove () + +void CSpawnPoint::OnSceneRemove() { DeletePhysicsShell(); - inherited::OnSceneRemove (); + inherited::OnSceneRemove(); } + CSpawnPoint::~CSpawnPoint() { xr_delete(m_AttachedObject); OnDeviceDestroy(); } -void CSpawnPoint::Select(int flag) +void CSpawnPoint::Select(int flag) { inherited::Select(flag); - if (m_AttachedObject) m_AttachedObject->Select(flag); + if (m_AttachedObject) + m_AttachedObject->Select(flag); } -void CSpawnPoint::Move( Fvector& amount ) +void CSpawnPoint::Move(Fvector &amount) { - inherited::Move( amount ); - const float f_drag_factor = 200.f; - if(m_physics_shell) - ApplyDragForce( Fvector().mul(amount,f_drag_factor) ); + inherited::Move(amount); + const float f_drag_factor = 200.f; + if (m_physics_shell) + ApplyDragForce(Fvector().mul(amount, f_drag_factor)); } -void CSpawnPoint::SetPosition(const Fvector& pos) +void CSpawnPoint::SetPosition(const Fvector &pos) { - if(m_physics_shell) + if (m_physics_shell) return; - inherited::SetPosition (pos); - if (m_AttachedObject) m_AttachedObject->PPosition = pos; + inherited::SetPosition(pos); + if (m_AttachedObject) + m_AttachedObject->PPosition = pos; } -void CSpawnPoint::SetRotation(const Fvector& rot) + +void CSpawnPoint::SetRotation(const Fvector &rot) { - if(m_physics_shell) + if (m_physics_shell) return; - inherited::SetRotation (rot); - if (m_AttachedObject) m_AttachedObject->PRotation = rot; + inherited::SetRotation(rot); + if (m_AttachedObject) + m_AttachedObject->PRotation = rot; } -void CSpawnPoint::SetScale(const Fvector& scale) + +void CSpawnPoint::SetScale(const Fvector &scale) { - if(m_physics_shell) + if (m_physics_shell) return; - inherited::SetScale (scale); - if (m_AttachedObject) m_AttachedObject->PScale = scale; + inherited::SetScale(scale); + if (m_AttachedObject) + m_AttachedObject->PScale = scale; } -bool CSpawnPoint::AttachObject(CCustomObject* obj) +bool CSpawnPoint::AttachObject(CCustomObject *obj) { bool bAllowed = false; // - if (m_SpawnData.Valid()){ - switch(obj->ClassID){ - case OBJCLASS_SHAPE: - bAllowed = !!m_SpawnData.m_Data->shape(); - break; -// case OBJCLASS_SCENEOBJECT: -// bAllowed = !!dynamic_cast(m_SpawnData.m_Data); -// break; + if (m_SpawnData.Valid()) + { + switch (obj->ClassID) + { + case OBJCLASS_SHAPE: + bAllowed = !!m_SpawnData.m_Data->shape(); + break; + // case OBJCLASS_SCENEOBJECT: + // bAllowed = !!dynamic_cast(m_SpawnData.m_Data); + // break; } } // if (bAllowed) { - DetachObject (); - OnAppendObject (obj); - m_AttachedObject->OnAttach (this); - PPosition = m_AttachedObject->PPosition; - PRotation = m_AttachedObject->PRotation; - PScale = m_AttachedObject->PScale; + DetachObject(); + OnAppendObject(obj); + m_AttachedObject->OnAttach(this); + PPosition = m_AttachedObject->PPosition; + PRotation = m_AttachedObject->PRotation; + PScale = m_AttachedObject->PScale; } return bAllowed; } @@ -654,101 +699,125 @@ void CSpawnPoint::DetachObject() if (m_AttachedObject) { m_AttachedObject->OnDetach(); - Scene->AppendObject(m_AttachedObject,false); + Scene->AppendObject(m_AttachedObject, false); m_AttachedObject = 0; } } -bool CSpawnPoint::RefCompare (LPCSTR ref) +bool CSpawnPoint::RefCompare(LPCSTR ref) { - return ref&&ref[0]&&m_SpawnData.Valid()?(strcmp(ref,m_SpawnData.m_Data->name())==0):false; + return ref&&ref[0]&&m_SpawnData.Valid() ? (strcmp(ref, m_SpawnData.m_Data->name())==0) : false; } -LPCSTR CSpawnPoint::RefName () +LPCSTR CSpawnPoint::RefName() { - return m_SpawnData.Valid()?m_SpawnData.m_Data->name():0; + return m_SpawnData.Valid() ? m_SpawnData.m_Data->name() : 0; } bool CSpawnPoint::CreateSpawnData(LPCSTR entity_ref) { R_ASSERT(entity_ref&&entity_ref[0]); - m_SpawnData.Destroy (); - m_SpawnData.Create (entity_ref); - if (m_SpawnData.Valid()) m_Type = ptSpawnPoint; + m_SpawnData.Destroy(); + m_SpawnData.Create(entity_ref); + if (m_SpawnData.Valid()) + m_Type = ptSpawnPoint; return m_SpawnData.Valid(); } + //---------------------------------------------------- -bool CSpawnPoint::GetBox( Fbox& box ) const -{ - switch (m_Type){ - case ptRPoint: - box.set ( PPosition, PPosition ); - box.min.x -= RPOINT_SIZE; - box.min.y -= 0; - box.min.z -= RPOINT_SIZE; - box.max.x += RPOINT_SIZE; - box.max.y += RPOINT_SIZE*2.f; - box.max.z += RPOINT_SIZE; - break; - case ptEnvMod: - box.set (PPosition, PPosition); - box.grow (Selected()?m_EM_Radius:ENVMOD_SIZE); - break; - case ptSpawnPoint: - if (m_SpawnData.Valid()){ - if (m_SpawnData.m_Visual&&m_SpawnData.m_Visual->visual) +bool CSpawnPoint::GetBox(Fbox &box) const +{ + switch (m_Type) + { + case ptRPoint: + box.set(PPosition, PPosition); + box.min.x -= RPOINT_SIZE; + box.min.y -= 0; + box.min.z -= RPOINT_SIZE; + box.max.x += RPOINT_SIZE; + box.max.y += RPOINT_SIZE*2.f; + box.max.z += RPOINT_SIZE; + break; + case ptEnvMod: + box.set(PPosition, PPosition); + box.grow(Selected() ? m_EM_Radius : ENVMOD_SIZE); + break; + case ptSpawnPoint: + if (m_SpawnData.Valid()) { - box.set (m_SpawnData.m_Visual->visual->getVisData().box); - Fmatrix transform = FTransformRP; - if(m_physics_shell) - UpdateObjectXform( transform ); - - box.xform (transform); - }else{ - CEditShape* shape = dynamic_cast(m_AttachedObject); - if (shape&&!shape->GetShapes().empty()){ - CShapeData::ShapeVec& SV = shape->GetShapes(); - box.invalidate(); - Fvector p; - for (CShapeData::ShapeIt it=SV.begin(); it!=SV.end(); it++){ - switch (it->type){ - case CShapeData::cfSphere: - p.add(it->data.sphere.P,it->data.sphere.R); shape->_Transform().transform_tiny(p); box.modify(p); - p.sub(it->data.sphere.P,it->data.sphere.R); shape->_Transform().transform_tiny(p); box.modify(p); - break; - case CShapeData::cfBox: - p.set( 0.5f, 0.5f, 0.5f);it->data.box.transform_tiny(p); shape->_Transform().transform_tiny(p); box.modify(p); - p.set(-0.5f,-0.5f,-0.5f);it->data.box.transform_tiny(p); shape->_Transform().transform_tiny(p); box.modify(p); - break; + if (m_SpawnData.m_Visual&&m_SpawnData.m_Visual->visual) + { + box.set(m_SpawnData.m_Visual->visual->getVisData().box); + Fmatrix transform = FTransformRP; + if (m_physics_shell) + UpdateObjectXform(transform); + + box.xform(transform); + } + else + { + CEditShape *shape = dynamic_cast(m_AttachedObject); + if (shape&&!shape->GetShapes().empty()) + { + CShapeData::ShapeVec &SV = shape->GetShapes(); + box.invalidate(); + Fvector p; + for (CShapeData::ShapeIt it = SV.begin(); it!=SV.end(); it++) + { + switch (it->type) + { + case CShapeData::cfSphere: + p.add(it->data.sphere.P, it->data.sphere.R); + shape->_Transform().transform_tiny(p); + box.modify(p); + p.sub(it->data.sphere.P, it->data.sphere.R); + shape->_Transform().transform_tiny(p); + box.modify(p); + break; + case CShapeData::cfBox: + p.set(0.5f, 0.5f, 0.5f); + it->data.box.transform_tiny(p); + shape->_Transform().transform_tiny(p); + box.modify(p); + p.set(-0.5f, -0.5f, -0.5f); + it->data.box.transform_tiny(p); + shape->_Transform().transform_tiny(p); + box.modify(p); + break; + } } } - }else{ - box.set ( PPosition, PPosition ); - box.min.x -= RPOINT_SIZE; - box.min.y -= 0; - box.min.z -= RPOINT_SIZE; - box.max.x += RPOINT_SIZE; - box.max.y += RPOINT_SIZE*2.f; - box.max.z += RPOINT_SIZE; + else + { + box.set(PPosition, PPosition); + box.min.x -= RPOINT_SIZE; + box.min.y -= 0; + box.min.z -= RPOINT_SIZE; + box.max.x += RPOINT_SIZE; + box.max.y += RPOINT_SIZE*2.f; + box.max.z += RPOINT_SIZE; + } } } - }else{ - box.set ( PPosition, PPosition ); - box.min.x -= RPOINT_SIZE; - box.min.y -= 0; - box.min.z -= RPOINT_SIZE; - box.max.x += RPOINT_SIZE; - box.max.y += RPOINT_SIZE*2.f; - box.max.z += RPOINT_SIZE; - } - break; - default: NODEFAULT; + else + { + box.set(PPosition, PPosition); + box.min.x -= RPOINT_SIZE; + box.min.y -= 0; + box.min.z -= RPOINT_SIZE; + box.max.x += RPOINT_SIZE; + box.max.y += RPOINT_SIZE*2.f; + box.max.z += RPOINT_SIZE; + } + break; + default: NODEFAULT; } - if (m_AttachedObject){ - Fbox bb; + if (m_AttachedObject) + { + Fbox bb; m_AttachedObject->GetBox(bb); - box.merge (bb); + box.merge(bb); } return true; } @@ -756,189 +825,214 @@ bool CSpawnPoint::GetBox( Fbox& box ) const void CSpawnPoint::OnFrame() { inherited::OnFrame(); - if (m_AttachedObject) m_AttachedObject->OnFrame (); + if (m_AttachedObject) + m_AttachedObject->OnFrame(); if (m_SpawnData.Valid()) { - if(m_physics_shell&&m_SpawnData.m_Data->m_editor_flags.is(IServerEntity::flVisualAnimationChange)) + if (m_physics_shell&&m_SpawnData.m_Data->m_editor_flags.is(IServerEntity::flVisualAnimationChange)) { - DeletePhysicsShell (); - m_SpawnData.OnFrame (); - CreatePhysicsShell ( &FTransform ); + DeletePhysicsShell(); + m_SpawnData.OnFrame(); + CreatePhysicsShell(&FTransform); } - else - m_SpawnData.OnFrame (); + else + m_SpawnData.OnFrame(); } } + void CSpawnPoint::RenderSimBox() { Fbox box; - GetBox( box ); + GetBox(box); - Fvector c,s; + Fvector c, s; - box.get_CD( c, s ); + box.get_CD(c, s); Fmatrix m; - m.scale(Fvector().mul(s,2)); + m.scale(Fvector().mul(s, 2)); m.c.set(c); - - // B.mulA_43 (_Transform()); + + // B.mulA_43 (_Transform()); RCache.set_xform_world(m); u32 clr = 0x06005000; - DU_impl.DrawIdentBox(true,false,clr,clr); + DU_impl.DrawIdentBox(true, false, clr, clr); } -void CSpawnPoint::Render( int priority, bool strictB2F ) -{ - Fmatrix SaveTransform = FTransformRP; +void CSpawnPoint::Render(int priority, bool strictB2F) +{ + Fmatrix SaveTransform = FTransformRP; - if( m_physics_shell ) + if (m_physics_shell) { - UpdateObjectXform( FTransformRP ); - RenderSimBox( ); + UpdateObjectXform(FTransformRP); + RenderSimBox(); } - inherited::Render (priority, strictB2F); + inherited::Render(priority, strictB2F); Scene->SelectLightsForObject(this); - + // render attached object if (m_AttachedObject) - m_AttachedObject->Render(priority, strictB2F); + m_AttachedObject->Render(priority, strictB2F); if (m_SpawnData.Valid()) - m_SpawnData.Render(Selected(),FTransformRP,priority, strictB2F); + m_SpawnData.Render(Selected(), FTransformRP, priority, strictB2F); // render spawn point - if (1==priority){ - if (strictB2F){ + if (1==priority) + { + if (strictB2F) + { RCache.set_xform_world(FTransformRP); - if (m_SpawnData.Valid()){ + if (m_SpawnData.Valid()) + { // render icon - ESceneSpawnTool* st = dynamic_cast(ParentTool); VERIFY(st); - ref_shader s = st->GetIcon(m_SpawnData.m_Data->name()); - DU_impl.DrawEntity (0xffffffff,s); - }else{ + ESceneSpawnTool *st = dynamic_cast(ParentTool); + VERIFY(st); + ref_shader s = st->GetIcon(m_SpawnData.m_Data->name()); + DU_impl.DrawEntity(0xffffffff, s); + } + else + { switch (m_Type) { case ptRPoint: { - ESceneSpawnTool* st = dynamic_cast(ParentTool); VERIFY(st); - if( NULL==st->get_draw_visual(m_RP_TeamID, m_RP_Type, m_GameType) ) + ESceneSpawnTool *st = dynamic_cast(ParentTool); + VERIFY(st); + if (NULL==st->get_draw_visual(m_RP_TeamID, m_RP_Type, m_GameType)) { float k = 1.f/(float(m_RP_TeamID+1)/float(MAX_TEAM)); int r = m_RP_TeamID%MAX_TEAM; Fcolor c; c.set(RP_COLORS[r]); c.mul_rgb(k*0.9f+0.1f); - DU_impl.DrawEntity(c.get(),EDevice.m_WireShader); + DU_impl.DrawEntity(c.get(), EDevice.m_WireShader); } - }break; + } + break; case ptEnvMod: { - Fvector pos={0,0,0}; + Fvector pos = {0,0,0}; EDevice.SetShader(EDevice.m_WireShader); - DU_impl.DrawCross(pos,0.25f,0x20FFAE00,true); + DU_impl.DrawCross(pos, 0.25f, 0x20FFAE00, true); if (Selected()) - DU_impl.DrawSphere(Fidentity,PPosition,m_EM_Radius,0x30FFAE00,0x00FFAE00,true,true); - }break; + DU_impl.DrawSphere(Fidentity, PPosition, m_EM_Radius, 0x30FFAE00, 0x00FFAE00, true, true); + } + break; default: THROW2("CSpawnPoint:: Unknown Type"); } } - }else{ - ESceneSpawnTool* st = dynamic_cast(ParentTool); VERIFY(st); + } + else + { + ESceneSpawnTool *st = dynamic_cast(ParentTool); + VERIFY(st); if (st->m_Flags.is(ESceneSpawnTool::flShowSpawnType)) { AnsiString s_name; if (m_SpawnData.Valid()) { - s_name = m_SpawnData.m_Data->name(); - }else{ + s_name = m_SpawnData.m_Data->name(); + } + else + { switch (m_Type) { - case ptRPoint: s_name.sprintf("RPoint T:%d",m_RP_TeamID); break; - case ptEnvMod: - s_name.sprintf("EnvMod V:%3.2f, F:%3.2f",m_EM_ViewDist,m_EM_FogDensity); - break; - default: THROW2("CSpawnPoint:: Unknown Type"); + case ptRPoint: s_name.sprintf("RPoint T:%d", m_RP_TeamID); + break; + case ptEnvMod: + s_name.sprintf("EnvMod V:%3.2f, F:%3.2f", m_EM_ViewDist, m_EM_FogDensity); + break; + default: THROW2("CSpawnPoint:: Unknown Type"); } } - - Fvector D; D.sub(EDevice.vCameraPosition,PPosition); - float dist = D.normalize_magn(); + + Fvector D; + D.sub(EDevice.vCameraPosition, PPosition); + float dist = D.normalize_magn(); if (!st->m_Flags.is(ESceneSpawnTool::flPickSpawnType)|| - !Scene->RayPickObject(dist,PPosition,D,OBJCLASS_SCENEOBJECT,0,0)) - DU_impl.OutText (PPosition,s_name.c_str(),0xffffffff,0xff000000); + !Scene->RayPickObject(dist, PPosition, D, OBJCLASS_SCENEOBJECT, 0, 0)) + DU_impl.OutText(PPosition, s_name.c_str(), 0xffffffff, 0xff000000); } - if(Selected()) + if (Selected()) { RCache.set_xform_world(Fidentity); - Fbox bb; GetBox(bb); + Fbox bb; + GetBox(bb); u32 clr = 0xFFFFFFFF; EDevice.SetShader(EDevice.m_WireShader); - DU_impl.DrawSelectionBoxB(bb,&clr); + DU_impl.DrawSelectionBoxB(bb, &clr); } } } - - if(m_Type==ptRPoint) + + if (m_Type==ptRPoint) { - ESceneSpawnTool* st = dynamic_cast(ParentTool); VERIFY(st); - CEditableObject* v = st->get_draw_visual(m_RP_TeamID, m_RP_Type, m_GameType); - if(v) - v->Render (FTransformRP, priority, strictB2F); + ESceneSpawnTool *st = dynamic_cast(ParentTool); + VERIFY(st); + CEditableObject *v = st->get_draw_visual(m_RP_TeamID, m_RP_Type, m_GameType); + if (v) + v->Render(FTransformRP, priority, strictB2F); } FTransformRP = SaveTransform; } -bool CSpawnPoint::FrustumPick(const CFrustum& frustum) +bool CSpawnPoint::FrustumPick(const CFrustum &frustum) { - if (m_AttachedObject&&m_AttachedObject->FrustumPick(frustum)) return true; - Fbox bb; GetBox(bb); - u32 mask=0xff; - return (frustum.testAABB(bb.data(),mask)); + if (m_AttachedObject&&m_AttachedObject->FrustumPick(frustum)) + return true; + Fbox bb; + GetBox(bb); + u32 mask = 0xff; + return (frustum.testAABB(bb.data(), mask)); } -bool CSpawnPoint::RayPick(float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf) +bool CSpawnPoint::RayPick(float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf) { - bool bPick = false; - if (m_AttachedObject){ - bPick = m_AttachedObject->RayPick(distance, start, direction, pinf); - return bPick; + bool bPick = false; + if (m_AttachedObject) + { + bPick = m_AttachedObject->RayPick(distance, start, direction, pinf); + return bPick; } - Fbox bb; - Fvector pos; - float radius; - GetBox (bb); - bb.getsphere(pos,radius); + Fbox bb; + Fvector pos; + float radius; + GetBox(bb); + bb.getsphere(pos, radius); Fvector ray2; - ray2.sub (pos, start); + ray2.sub(pos, start); float d = ray2.dotproduct(direction); - if( d > 0 ){ + if (d>0) + { float d2 = ray2.magnitude(); - if( ((d2*d2-d*d) < (radius*radius)) && (d>radius) ){ + if (((d2*d2-d*d)<(radius*radius))&&(d>radius)) + { Fvector pt; - if (Fbox::rpOriginOutside==bb.Pick2(start,direction,pt)){ - d = start.distance_to(pt); - if (dvisual ) + if (Fbox::rpOriginOutside==bb.Pick2(start, direction, pt)) + { + d = start.distance_to(pt); + if (dvisual) { - - IKinematics* K = m_SpawnData.m_Visual->visual->dcast_PKinematics(); + IKinematics *K = m_SpawnData.m_Visual->visual->dcast_PKinematics(); u16 b_id = u16(-1); Fvector norm; - if( K ) + if (K) { - bPick = ETOOLS::intersect( FTransformRP, *K, start, direction, b_id, distance, norm ); - if( bPick ) - { - pinf->visual_inf.K = K; - pinf->visual_inf.normal = norm; - pt.mad( start, direction, distance ); - } - + bPick = ETOOLS::intersect(FTransformRP, *K, start, direction, b_id, distance, norm); + if (bPick) + { + pinf->visual_inf.K = K; + pinf->visual_inf.normal = norm; + pt.mad(start, direction, distance); + } } @@ -955,157 +1049,162 @@ bool CSpawnPoint::RayPick(float& distance, const Fvector& start, const Fvector& return bPick; } + //---------------------------------------------------- -bool CSpawnPoint::OnAppendObject(CCustomObject* object) +bool CSpawnPoint::OnAppendObject(CCustomObject *object) { R_ASSERT(!m_AttachedObject); - if (object->ClassID!=OBJCLASS_SHAPE) return false; + if (object->ClassID!=OBJCLASS_SHAPE) + return false; // all right - m_AttachedObject = object; - object->m_pOwnerObject = this; - Scene->RemoveObject (object, false, false); + m_AttachedObject = object; + object->m_pOwnerObject = this; + Scene->RemoveObject(object, false, false); - CEditShape* sh = dynamic_cast(m_AttachedObject); - if(m_SpawnData.Valid()) + CEditShape *sh = dynamic_cast(m_AttachedObject); + if (m_SpawnData.Valid()) { - if(pSettings->line_exist(m_SpawnData.m_Data->name(),"shape_transp_color")) + if (pSettings->line_exist(m_SpawnData.m_Data->name(), "shape_transp_color")) { - sh->m_DrawTranspColor = pSettings->r_color(m_SpawnData.m_Data->name(),"shape_transp_color"); - sh->m_DrawEdgeColor = pSettings->r_color(m_SpawnData.m_Data->name(),"shape_edge_color"); + sh->m_DrawTranspColor = pSettings->r_color(m_SpawnData.m_Data->name(), "shape_transp_color"); + sh->m_DrawEdgeColor = pSettings->r_color(m_SpawnData.m_Data->name(), "shape_edge_color"); } } return true; } -bool CSpawnPoint::LoadLTX(CInifile& ini, LPCSTR sect_name) +bool CSpawnPoint::LoadLTX(CInifile &ini, LPCSTR sect_name) { - u32 version = ini.r_u32(sect_name, "version"); - if(version<0x0014) + if (version<0x0014) { - ELog.Msg( mtError, "SPAWNPOINT: Unsupported version."); + ELog.Msg(mtError, "SPAWNPOINT: Unsupported version."); return false; } CCustomObject::LoadLTX(ini, sect_name); - m_Type = (EPointType)ini.r_u32(sect_name, "type"); + m_Type = (EPointType)ini.r_u32(sect_name, "type"); if (m_Type>=ptMaxType) { - ELog.Msg( mtError, "SPAWNPOINT: Unsupported spawn version."); + ELog.Msg(mtError, "SPAWNPOINT: Unsupported spawn version."); return false; } switch (m_Type) { - case ptSpawnPoint: - { - string128 buff; - strconcat (sizeof(buff), buff, sect_name, "_spawndata"); - if (!m_SpawnData.LoadLTX(ini, buff)) + case ptSpawnPoint: { - ELog.Msg( mtError, "SPAWNPOINT: Can't load Spawn Data."); - return false; + string128 buff; + strconcat(sizeof(buff), buff, sect_name, "_spawndata"); + if (!m_SpawnData.LoadLTX(ini, buff)) + { + ELog.Msg(mtError, "SPAWNPOINT: Can't load Spawn Data."); + return false; + } + SetValid(true); } - SetValid (true); - }break; - case ptRPoint: + break; + case ptRPoint: { - if(version>=0x0017) - m_rpProfile = ini.r_string(sect_name, "rp_profile"); - - m_RP_TeamID = ini.r_u8 (sect_name, "team_id"); - m_RP_Type = ini.r_u8 (sect_name, "rp_type"); - m_GameType.LoadLTX (ini, sect_name, (version==0x0014) ); + if (version>=0x0017) + m_rpProfile = ini.r_string(sect_name, "rp_profile"); + + m_RP_TeamID = ini.r_u8(sect_name, "team_id"); + m_RP_Type = ini.r_u8(sect_name, "rp_type"); + m_GameType.LoadLTX(ini, sect_name, (version==0x0014)); } - break; - case ptEnvMod: + break; + case ptEnvMod: { - m_EM_Radius = ini.r_float(sect_name, "em_radius"); - m_EM_Power = ini.r_float(sect_name, "em_power"); - m_EM_ViewDist = ini.r_float(sect_name, "view_dist"); - m_EM_FogColor = ini.r_u32(sect_name, "fog_color"); - m_EM_FogDensity = ini.r_float(sect_name, "fog_density"); - m_EM_AmbientColor = ini.r_u32(sect_name, "ambient_color"); - m_EM_SkyColor = ini.r_u32(sect_name, "sky_color"); - m_EM_HemiColor = ini.r_u32(sect_name, "hemi_color"); - if(version>=0x0016) - m_EM_Flags.assign (ini.r_u16(sect_name, "em_flags")); + m_EM_Radius = ini.r_float(sect_name, "em_radius"); + m_EM_Power = ini.r_float(sect_name, "em_power"); + m_EM_ViewDist = ini.r_float(sect_name, "view_dist"); + m_EM_FogColor = ini.r_u32(sect_name, "fog_color"); + m_EM_FogDensity = ini.r_float(sect_name, "fog_density"); + m_EM_AmbientColor = ini.r_u32(sect_name, "ambient_color"); + m_EM_SkyColor = ini.r_u32(sect_name, "sky_color"); + m_EM_HemiColor = ini.r_u32(sect_name, "hemi_color"); + if (version>=0x0016) + m_EM_Flags.assign(ini.r_u16(sect_name, "em_flags")); } - break; - default: THROW; + break; + default: THROW; } // objects - if(ini.line_exist(sect_name, "attached_count")) - Scene->ReadObjectsLTX(ini, sect_name, "attached",OnAppendObject,0); + if (ini.line_exist(sect_name, "attached_count")) + Scene->ReadObjectsLTX(ini, sect_name, "attached", OnAppendObject, 0); - UpdateTransform (); + UpdateTransform(); // BUG fix - CEditShape* shape = dynamic_cast(m_AttachedObject); + CEditShape *shape = dynamic_cast(m_AttachedObject); if (shape) - PScale = shape->PScale; - + PScale = shape->PScale; + return true; } -void CSpawnPoint::SaveLTX(CInifile& ini, LPCSTR sect_name) +void CSpawnPoint::SaveLTX(CInifile &ini, LPCSTR sect_name) { CCustomObject::SaveLTX(ini, sect_name); - ini.w_u32 (sect_name, "version", SPAWNPOINT_VERSION); + ini.w_u32(sect_name, "version", SPAWNPOINT_VERSION); // save attachment if (m_AttachedObject) { - ObjectList lst; - lst.push_back (m_AttachedObject); - Scene->SaveObjectsLTX (lst, sect_name, "attached", ini); + ObjectList lst; + lst.push_back(m_AttachedObject); + Scene->SaveObjectsLTX(lst, sect_name, "attached", ini); } - ini.w_u32 (sect_name, "type", m_Type); - + ini.w_u32(sect_name, "type", m_Type); + switch (m_Type) { - case ptSpawnPoint: - { - string128 buff; - m_SpawnData.SaveLTX(ini, strconcat(sizeof(buff), buff, sect_name, "_spawndata")); - }break; - case ptRPoint: - { - ini.w_u8 (sect_name, "team_id", m_RP_TeamID); - ini.w_string (sect_name, "rp_profile", m_rpProfile.c_str()); - ini.w_u8 (sect_name, "rp_type", m_RP_Type); - m_GameType.SaveLTX(ini, sect_name); - }break; - case ptEnvMod: - { - ini.w_float (sect_name, "em_radius", m_EM_Radius); - ini.w_float (sect_name, "em_power", m_EM_Power); - ini.w_float (sect_name, "view_dist", m_EM_ViewDist); - ini.w_u32 (sect_name, "fog_color", m_EM_FogColor); - ini.w_float (sect_name, "fog_density", m_EM_FogDensity); - ini.w_u32 (sect_name, "ambient_color", m_EM_AmbientColor); - ini.w_u32 (sect_name, "sky_color", m_EM_SkyColor); - ini.w_u32 (sect_name, "hemi_color", m_EM_HemiColor); - ini.w_u16 (sect_name, "em_flags", m_EM_Flags.get()); - }break; - - default: THROW; + case ptSpawnPoint: + { + string128 buff; + m_SpawnData.SaveLTX(ini, strconcat(sizeof(buff), buff, sect_name, "_spawndata")); + } + break; + case ptRPoint: + { + ini.w_u8(sect_name, "team_id", m_RP_TeamID); + ini.w_string(sect_name, "rp_profile", m_rpProfile.c_str()); + ini.w_u8(sect_name, "rp_type", m_RP_Type); + m_GameType.SaveLTX(ini, sect_name); + } + break; + case ptEnvMod: + { + ini.w_float(sect_name, "em_radius", m_EM_Radius); + ini.w_float(sect_name, "em_power", m_EM_Power); + ini.w_float(sect_name, "view_dist", m_EM_ViewDist); + ini.w_u32(sect_name, "fog_color", m_EM_FogColor); + ini.w_float(sect_name, "fog_density", m_EM_FogDensity); + ini.w_u32(sect_name, "ambient_color", m_EM_AmbientColor); + ini.w_u32(sect_name, "sky_color", m_EM_SkyColor); + ini.w_u32(sect_name, "hemi_color", m_EM_HemiColor); + ini.w_u16(sect_name, "em_flags", m_EM_Flags.get()); + } + break; + + default: THROW; } } -bool CSpawnPoint::LoadStream(IReader& F) +bool CSpawnPoint::LoadStream(IReader &F) { u16 version = 0; - R_ASSERT(F.r_chunk(SPAWNPOINT_CHUNK_VERSION,&version)); - if(version<0x0014) + R_ASSERT(F.r_chunk(SPAWNPOINT_CHUNK_VERSION, &version)); + if (version<0x0014) { - ELog.Msg( mtError, "SPAWNPOINT: Unsupported version."); + ELog.Msg(mtError, "SPAWNPOINT: Unsupported version."); return false; } @@ -1116,339 +1215,377 @@ bool CSpawnPoint::LoadStream(IReader& F) { if (!m_SpawnData.LoadStream(F)) { - ELog.Msg( mtError, "SPAWNPOINT: Can't load Spawn Data."); + ELog.Msg(mtError, "SPAWNPOINT: Can't load Spawn Data."); return false; } - SetValid (true); - m_Type = ptSpawnPoint; - }else{ - if (F.find_chunk(SPAWNPOINT_CHUNK_TYPE)) m_Type = (EPointType)F.r_u32(); - if (m_Type>=ptMaxType){ - ELog.Msg( mtError, "SPAWNPOINT: Unsupported spawn version."); + SetValid(true); + m_Type = ptSpawnPoint; + } + else + { + if (F.find_chunk(SPAWNPOINT_CHUNK_TYPE)) + m_Type = (EPointType)F.r_u32(); + if (m_Type>=ptMaxType) + { + ELog.Msg(mtError, "SPAWNPOINT: Unsupported spawn version."); return false; } - switch (m_Type){ - case ptRPoint: - if (F.find_chunk(SPAWNPOINT_CHUNK_RPOINT)) - { - - m_RP_TeamID = F.r_u8(); - m_RP_Type = F.r_u8(); - m_GameType.LoadStream (F); - if(version>=0x0017) - F.r_stringZ (m_rpProfile); - } - break; - case ptEnvMod: - if (F.find_chunk(SPAWNPOINT_CHUNK_ENVMOD)){ - m_EM_Radius = F.r_float(); - m_EM_Power = F.r_float(); - m_EM_ViewDist = F.r_float(); - m_EM_FogColor = F.r_u32(); - m_EM_FogDensity = F.r_float(); - m_EM_AmbientColor = F.r_u32(); - m_EM_SkyColor = F.r_u32(); - if (F.find_chunk(SPAWNPOINT_CHUNK_ENVMOD2)) - m_EM_HemiColor = F.r_u32(); - if (F.find_chunk(SPAWNPOINT_CHUNK_ENVMOD3)) - m_EM_Flags.assign(F.r_u16()); - } - break; - default: THROW; + switch (m_Type) + { + case ptRPoint: + if (F.find_chunk(SPAWNPOINT_CHUNK_RPOINT)) + { + m_RP_TeamID = F.r_u8(); + m_RP_Type = F.r_u8(); + m_GameType.LoadStream(F); + if (version>=0x0017) + F.r_stringZ(m_rpProfile); + } + break; + case ptEnvMod: + if (F.find_chunk(SPAWNPOINT_CHUNK_ENVMOD)) + { + m_EM_Radius = F.r_float(); + m_EM_Power = F.r_float(); + m_EM_ViewDist = F.r_float(); + m_EM_FogColor = F.r_u32(); + m_EM_FogDensity = F.r_float(); + m_EM_AmbientColor = F.r_u32(); + m_EM_SkyColor = F.r_u32(); + if (F.find_chunk(SPAWNPOINT_CHUNK_ENVMOD2)) + m_EM_HemiColor = F.r_u32(); + if (F.find_chunk(SPAWNPOINT_CHUNK_ENVMOD3)) + m_EM_Flags.assign(F.r_u16()); + } + break; + default: THROW; } } // objects - Scene->ReadObjectsStream(F,SPAWNPOINT_CHUNK_ATTACHED_OBJ,OnAppendObject,0); + Scene->ReadObjectsStream(F,SPAWNPOINT_CHUNK_ATTACHED_OBJ, OnAppendObject, 0); - UpdateTransform (); + UpdateTransform(); // BUG fix - CEditShape* shape = dynamic_cast(m_AttachedObject); - if (shape) PScale = shape->PScale; - + CEditShape *shape = dynamic_cast(m_AttachedObject); + if (shape) + PScale = shape->PScale; + return true; } -void CSpawnPoint::SaveStream(IWriter& F) +void CSpawnPoint::SaveStream(IWriter &F) { CCustomObject::SaveStream(F); - F.open_chunk (SPAWNPOINT_CHUNK_VERSION); - F.w_u16 (SPAWNPOINT_VERSION); - F.close_chunk (); + F.open_chunk(SPAWNPOINT_CHUNK_VERSION); + F.w_u16(SPAWNPOINT_VERSION); + F.close_chunk(); // save attachment if (m_AttachedObject) { - ObjectList lst; lst.push_back(m_AttachedObject); - Scene->SaveObjectsStream(lst,SPAWNPOINT_CHUNK_ATTACHED_OBJ,F); + ObjectList lst; + lst.push_back(m_AttachedObject); + Scene->SaveObjectsStream(lst,SPAWNPOINT_CHUNK_ATTACHED_OBJ, F); } if (m_SpawnData.Valid()) { m_SpawnData.SaveStream(F); - }else{ - F.w_chunk (SPAWNPOINT_CHUNK_TYPE, &m_Type, sizeof(u32)); - switch (m_Type){ - case ptRPoint: - F.open_chunk (SPAWNPOINT_CHUNK_RPOINT); - F.w_u8 (m_RP_TeamID); - F.w_u8 (m_RP_Type); - m_GameType.SaveStream (F); - F.w_stringZ (m_rpProfile); - F.close_chunk (); - break; - case ptEnvMod: - F.open_chunk(SPAWNPOINT_CHUNK_ENVMOD); - F.w_float (m_EM_Radius); - F.w_float (m_EM_Power); - F.w_float (m_EM_ViewDist); - F.w_u32 (m_EM_FogColor); - F.w_float (m_EM_FogDensity); - F.w_u32 (m_EM_AmbientColor); - F.w_u32 (m_EM_SkyColor); - F.close_chunk(); - F.open_chunk(SPAWNPOINT_CHUNK_ENVMOD2); - F.w_u32 (m_EM_HemiColor); - F.close_chunk(); - - F.open_chunk(SPAWNPOINT_CHUNK_ENVMOD3); - F.w_u16 (m_EM_Flags.get()); - F.close_chunk(); - break; - default: THROW; + } + else + { + F.w_chunk(SPAWNPOINT_CHUNK_TYPE, &m_Type, sizeof(u32)); + switch (m_Type) + { + case ptRPoint: + F.open_chunk(SPAWNPOINT_CHUNK_RPOINT); + F.w_u8(m_RP_TeamID); + F.w_u8(m_RP_Type); + m_GameType.SaveStream(F); + F.w_stringZ(m_rpProfile); + F.close_chunk(); + break; + case ptEnvMod: + F.open_chunk(SPAWNPOINT_CHUNK_ENVMOD); + F.w_float(m_EM_Radius); + F.w_float(m_EM_Power); + F.w_float(m_EM_ViewDist); + F.w_u32(m_EM_FogColor); + F.w_float(m_EM_FogDensity); + F.w_u32(m_EM_AmbientColor); + F.w_u32(m_EM_SkyColor); + F.close_chunk(); + F.open_chunk(SPAWNPOINT_CHUNK_ENVMOD2); + F.w_u32(m_EM_HemiColor); + F.close_chunk(); + + F.open_chunk(SPAWNPOINT_CHUNK_ENVMOD3); + F.w_u16(m_EM_Flags.get()); + F.close_chunk(); + break; + default: THROW; } } } + //---------------------------------------------------- Fvector3 u32_3f(u32 clr) { Fvector tmp; - float f = 1.f / 255.f; - tmp.x = f * float((clr >> 16)& 0xff); - tmp.y = f * float((clr >> 8)& 0xff); - tmp.z = f * float((clr >> 0)& 0xff); - return tmp; + float f = 1.f/255.f; + tmp.x = f*float((clr>>16)&0xff); + tmp.y = f*float((clr>>8)&0xff); + tmp.z = f*float((clr>>0)&0xff); + return tmp; } -bool CSpawnPoint::ExportGame(SExportStreams* F) +bool CSpawnPoint::ExportGame(SExportStreams *F) { // spawn - if (m_SpawnData.Valid()){ - if (m_SpawnData.m_Data->validate()){ - m_SpawnData.ExportGame (F,this); - }else{ - Log ("!Invalid spawn data:",Name); + if (m_SpawnData.Valid()) + { + if (m_SpawnData.m_Data->validate()) + { + m_SpawnData.ExportGame(F, this); + } + else + { + Log("!Invalid spawn data:", Name); return false; } - }else{ + } + else + { // game - switch (m_Type){ - case ptRPoint: - F->rpoint.stream.open_chunk (F->rpoint.chunk++); - F->rpoint.stream.w_fvector3 (PPosition); - F->rpoint.stream.w_fvector3 (PRotation); - F->rpoint.stream.w_u8 (m_RP_TeamID); - F->rpoint.stream.w_u8 (m_RP_Type); - F->rpoint.stream.w_u16 (m_GameType.m_GameType.get()); - F->rpoint.stream.w_stringZ (m_rpProfile); - F->rpoint.stream.close_chunk (); - break; - case ptEnvMod: - Fcolor tmp; - F->envmodif.stream.open_chunk(F->envmodif.chunk++); - F->envmodif.stream.w_fvector3(PPosition); - F->envmodif.stream.w_float (m_EM_Radius); - F->envmodif.stream.w_float (m_EM_Power); - F->envmodif.stream.w_float (m_EM_ViewDist); - F->envmodif.stream.w_fvector3(u32_3f(m_EM_FogColor)); - F->envmodif.stream.w_float (m_EM_FogDensity); - F->envmodif.stream.w_fvector3(u32_3f(m_EM_AmbientColor)); - F->envmodif.stream.w_fvector3(u32_3f(m_EM_SkyColor)); - F->envmodif.stream.w_fvector3(u32_3f(m_EM_HemiColor)); - F->envmodif.stream.w_u16(m_EM_Flags.get()); - F->envmodif.stream.close_chunk(); - break; - default: THROW; + switch (m_Type) + { + case ptRPoint: + F->rpoint.stream.open_chunk(F->rpoint.chunk++); + F->rpoint.stream.w_fvector3(PPosition); + F->rpoint.stream.w_fvector3(PRotation); + F->rpoint.stream.w_u8(m_RP_TeamID); + F->rpoint.stream.w_u8(m_RP_Type); + F->rpoint.stream.w_u16(m_GameType.m_GameType.get()); + F->rpoint.stream.w_stringZ(m_rpProfile); + F->rpoint.stream.close_chunk(); + break; + case ptEnvMod: + Fcolor tmp; + F->envmodif.stream.open_chunk(F->envmodif.chunk++); + F->envmodif.stream.w_fvector3(PPosition); + F->envmodif.stream.w_float(m_EM_Radius); + F->envmodif.stream.w_float(m_EM_Power); + F->envmodif.stream.w_float(m_EM_ViewDist); + F->envmodif.stream.w_fvector3(u32_3f(m_EM_FogColor)); + F->envmodif.stream.w_float(m_EM_FogDensity); + F->envmodif.stream.w_fvector3(u32_3f(m_EM_AmbientColor)); + F->envmodif.stream.w_fvector3(u32_3f(m_EM_SkyColor)); + F->envmodif.stream.w_fvector3(u32_3f(m_EM_HemiColor)); + F->envmodif.stream.w_u16(m_EM_Flags.get()); + F->envmodif.stream.close_chunk(); + break; + default: THROW; } } return true; } + //---------------------------------------------------- -void CSpawnPoint::OnFillRespawnItemProfile(ChooseValue* val) +void CSpawnPoint::OnFillRespawnItemProfile(ChooseValue *val) { - val->m_Items->clear (); - string_path fn; - FS.update_path (fn,"$game_config$", "mp\\respawn_items.ltx"); - CInifile ini(fn); - CInifile::RootIt it = ini.sections().begin(); - CInifile::RootIt it_e = ini.sections().end(); - - for(;it!=it_e;++it) + val->m_Items->clear(); + string_path fn; + FS.update_path(fn, "$game_config$", "mp\\respawn_items.ltx"); + CInifile ini(fn); + CInifile::RootIt it = ini.sections().begin(); + CInifile::RootIt it_e = ini.sections().end(); + + for (; it!=it_e; ++it) { - shared_str name = (*it)->Name; + shared_str name = (*it)->Name; shared_str hint; - if(ini.line_exist(name,"description")) - hint = ini.r_string(name,"description"); + if (ini.line_exist(name, "description")) + hint = ini.r_string(name, "description"); else - hint = ""; - - val->m_Items->push_back( SChooseItem( name.c_str(), hint.c_str() ) ); + hint = ""; + + val->m_Items->push_back(SChooseItem(name.c_str(), hint.c_str())); } } -void CSpawnPoint::OnFillChooseItems (ChooseValue* val) +void CSpawnPoint::OnFillChooseItems(ChooseValue *val) { - ESceneSpawnTool* st = dynamic_cast(ParentTool); VERIFY(st); - CLASS_ID cls_id = m_SpawnData.m_ClassID; - ESceneSpawnTool::ClassSpawnMapIt cls_it = st->m_Classes.find(cls_id); VERIFY(cls_it!=st->m_Classes.end()); - *val->m_Items = cls_it->second; + ESceneSpawnTool *st = dynamic_cast(ParentTool); + VERIFY(st); + CLASS_ID cls_id = m_SpawnData.m_ClassID; + ESceneSpawnTool::ClassSpawnMapIt cls_it = st->m_Classes.find(cls_id); + VERIFY(cls_it!=st->m_Classes.end()); + *val->m_Items = cls_it->second; } shared_str CSpawnPoint::SectionToEditor(shared_str nm) { - ESceneSpawnTool* st = dynamic_cast(ParentTool); VERIFY(st); - ESceneSpawnTool::ClassSpawnMapIt cls_it = st->m_Classes.find(m_SpawnData.m_ClassID); VERIFY(cls_it!=st->m_Classes.end()); - for (ESceneSpawnTool::SSVecIt ss_it=cls_it->second.begin(); ss_it!=cls_it->second.end(); ++ss_it) - if (nm.equal(ss_it->hint)) return ss_it->name; + ESceneSpawnTool *st = dynamic_cast(ParentTool); + VERIFY(st); + ESceneSpawnTool::ClassSpawnMapIt cls_it = st->m_Classes.find(m_SpawnData.m_ClassID); + VERIFY(cls_it!=st->m_Classes.end()); + for (ESceneSpawnTool::SSVecIt ss_it = cls_it->second.begin(); ss_it!=cls_it->second.end(); ++ss_it) + if (nm.equal(ss_it->hint)) + return ss_it->name; return 0; } shared_str CSpawnPoint::EditorToSection(shared_str nm) { - ESceneSpawnTool* st = dynamic_cast(ParentTool); VERIFY(st); - ESceneSpawnTool::ClassSpawnMapIt cls_it = st->m_Classes.find(m_SpawnData.m_ClassID); VERIFY(cls_it!=st->m_Classes.end()); - for (ESceneSpawnTool::SSVecIt ss_it=cls_it->second.begin(); ss_it!=cls_it->second.end(); ++ss_it) - if (nm.equal(ss_it->name)) return ss_it->hint; + ESceneSpawnTool *st = dynamic_cast(ParentTool); + VERIFY(st); + ESceneSpawnTool::ClassSpawnMapIt cls_it = st->m_Classes.find(m_SpawnData.m_ClassID); + VERIFY(cls_it!=st->m_Classes.end()); + for (ESceneSpawnTool::SSVecIt ss_it = cls_it->second.begin(); ss_it!=cls_it->second.end(); ++ss_it) + if (nm.equal(ss_it->name)) + return ss_it->hint; return 0; } -void CSpawnPoint::OnRPointTypeChange(PropValue* prop) +void CSpawnPoint::OnRPointTypeChange(PropValue *prop) { - ExecCommand (COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void CSpawnPoint::OnProfileChange(PropValue* prop) +void CSpawnPoint::OnProfileChange(PropValue *prop) { - if (m_SpawnData.m_Profile.size()!=0){ - shared_str s_name = EditorToSection(m_SpawnData.m_Profile); - VERIFY (s_name.size()); - if (0!=strcmp(m_SpawnData.m_Data->name(),*s_name)) + if (m_SpawnData.m_Profile.size()!=0) + { + shared_str s_name = EditorToSection(m_SpawnData.m_Profile); + VERIFY(s_name.size()); + if (0!=strcmp(m_SpawnData.m_Data->name(), *s_name)) { - IServerEntity* tmp = create_entity (*s_name); - VERIFY (tmp); - NET_Packet Packet; - tmp->Spawn_Write (Packet,TRUE); - R_ASSERT (m_SpawnData.m_Data->Spawn_Read(Packet)); + IServerEntity *tmp = create_entity(*s_name); + VERIFY(tmp); + NET_Packet Packet; + tmp->Spawn_Write(Packet, TRUE); + R_ASSERT(m_SpawnData.m_Data->Spawn_Read(Packet)); m_SpawnData.m_Data->set_editor_flag(IServerEntity::flVisualChange|IServerEntity::flVisualAnimationChange); - destroy_entity (tmp); + destroy_entity(tmp); } - }else{ - m_SpawnData.m_Profile = SectionToEditor(m_SpawnData.m_Data->name()); + } + else + { + m_SpawnData.m_Profile = SectionToEditor(m_SpawnData.m_Data->name()); } } -void CSpawnPoint::FillProp(LPCSTR pref, PropItemVec& items) +void CSpawnPoint::FillProp(LPCSTR pref, PropItemVec &items) { - inherited::FillProp(pref,items); + inherited::FillProp(pref, items); if (m_SpawnData.Valid()) { - shared_str pref1 = PrepareKey(pref,m_SpawnData.m_Data->name()); - m_SpawnData.m_Profile = SectionToEditor(m_SpawnData.m_Data->name()); - ChooseValue* C = PHelper().CreateChoose(items,PrepareKey(pref1.c_str(),"Profile (spawn section)"),&m_SpawnData.m_Profile,smCustom,0,0,1,cfFullExpand); - C->OnChooseFillEvent.bind (this,&CSpawnPoint::OnFillChooseItems); - C->OnChangeEvent.bind (this,&CSpawnPoint::OnProfileChange); - m_SpawnData.FillProp (pref,items); - }else{ + shared_str pref1 = PrepareKey(pref, m_SpawnData.m_Data->name()); + m_SpawnData.m_Profile = SectionToEditor(m_SpawnData.m_Data->name()); + ChooseValue *C = PHelper().CreateChoose(items, PrepareKey(pref1.c_str(), "Profile (spawn section)"), &m_SpawnData.m_Profile, smCustom, 0, 0, 1, cfFullExpand); + C->OnChooseFillEvent.bind(this, &CSpawnPoint::OnFillChooseItems); + C->OnChangeEvent.bind(this, &CSpawnPoint::OnProfileChange); + m_SpawnData.FillProp(pref, items); + } + else + { switch (m_Type) { - case ptRPoint: - { + case ptRPoint: + { + if (m_RP_Type==rptItemSpawn) + { + ChooseValue *C = PHelper().CreateChoose(items, PrepareKey(pref, "Respawn Point\\Profile"), &m_rpProfile, smCustom, 0, 0, 10, cfMultiSelect); + C->OnChooseFillEvent.bind(this, &CSpawnPoint::OnFillRespawnItemProfile); + } + else + { + PHelper().CreateU8(items, PrepareKey(pref, "Respawn Point\\Team"), &m_RP_TeamID, 0, 7); + } + Token8Value *TV = PHelper().CreateToken8(items, PrepareKey(pref, "Respawn Point\\Spawn Type"), &m_RP_Type, rpoint_type); + TV->OnChangeEvent.bind(this, &CSpawnPoint::OnRPointTypeChange); - if(m_RP_Type==rptItemSpawn) - { - ChooseValue* C = PHelper().CreateChoose(items,PrepareKey(pref,"Respawn Point\\Profile"),&m_rpProfile,smCustom,0,0,10,cfMultiSelect); - C->OnChooseFillEvent.bind (this,&CSpawnPoint::OnFillRespawnItemProfile); - }else + m_GameType.FillProp(pref, items); + } + break; + case ptEnvMod: { - PHelper().CreateU8 (items, PrepareKey(pref,"Respawn Point\\Team"), &m_RP_TeamID, 0,7); + PHelper().CreateFloat(items, PrepareKey(pref, "Environment Modificator\\Radius"), &m_EM_Radius, EPS_L, 10000.f); + PHelper().CreateFloat(items, PrepareKey(pref, "Environment Modificator\\Power"), &m_EM_Power, EPS, 1000.f); + + Flag16Value *FV = NULL; + + FV = PHelper().CreateFlag16(items, PrepareKey(pref, "Environment Modificator\\View Distance"), &m_EM_Flags, eViewDist); + FV->OnChangeEvent.bind(this, &CSpawnPoint::OnEnvModFlagChange); + if (m_EM_Flags.test(eViewDist)) + PHelper().CreateFloat(items, PrepareKey(pref, "Environment Modificator\\View Distance\\ "), &m_EM_ViewDist, EPS_L, 10000.f); + + FV = PHelper().CreateFlag16(items, PrepareKey(pref, "Environment Modificator\\Fog Color"), &m_EM_Flags, eFogColor); + FV->OnChangeEvent.bind(this, &CSpawnPoint::OnEnvModFlagChange); + if (m_EM_Flags.test(eFogColor)) + PHelper().CreateColor(items, PrepareKey(pref, "Environment Modificator\\Fog Color\\ "), &m_EM_FogColor); + + FV = PHelper().CreateFlag16(items, PrepareKey(pref, "Environment Modificator\\Fog Density"), &m_EM_Flags, eFogDensity); + FV->OnChangeEvent.bind(this, &CSpawnPoint::OnEnvModFlagChange); + if (m_EM_Flags.test(eFogDensity)) + PHelper().CreateFloat(items, PrepareKey(pref, "Environment Modificator\\Fog Density\\ "), &m_EM_FogDensity, 0.f, 10000.f); + + FV = PHelper().CreateFlag16(items, PrepareKey(pref, "Environment Modificator\\Ambient Color"), &m_EM_Flags, eAmbientColor); + FV->OnChangeEvent.bind(this, &CSpawnPoint::OnEnvModFlagChange); + if (m_EM_Flags.test(eAmbientColor)) + PHelper().CreateColor(items, PrepareKey(pref, "Environment Modificator\\Ambient Color\\ "), &m_EM_AmbientColor); + + FV = PHelper().CreateFlag16(items, PrepareKey(pref, "Environment Modificator\\Sky Color"), &m_EM_Flags, eSkyColor); + FV->OnChangeEvent.bind(this, &CSpawnPoint::OnEnvModFlagChange); + if (m_EM_Flags.test(eSkyColor)) + PHelper().CreateColor(items, PrepareKey(pref, "Environment Modificator\\Sky Color\\ "), &m_EM_SkyColor); + + FV = PHelper().CreateFlag16(items, PrepareKey(pref, "Environment Modificator\\Hemi Color"), &m_EM_Flags, eHemiColor); + FV->OnChangeEvent.bind(this, &CSpawnPoint::OnEnvModFlagChange); + if (m_EM_Flags.test(eHemiColor)) + PHelper().CreateColor(items, PrepareKey(pref, "Environment Modificator\\Hemi Color\\ "), &m_EM_HemiColor); } - Token8Value* TV = PHelper().CreateToken8 (items, PrepareKey(pref,"Respawn Point\\Spawn Type"), &m_RP_Type, rpoint_type); - TV->OnChangeEvent.bind (this,&CSpawnPoint::OnRPointTypeChange); - - m_GameType.FillProp (pref, items); - }break; - case ptEnvMod:{ - PHelper().CreateFloat (items, PrepareKey(pref,"Environment Modificator\\Radius"), &m_EM_Radius, EPS_L,10000.f); - PHelper().CreateFloat (items, PrepareKey(pref,"Environment Modificator\\Power"), &m_EM_Power, EPS,1000.f); - - Flag16Value* FV = NULL; - - FV = PHelper().CreateFlag16(items, PrepareKey(pref,"Environment Modificator\\View Distance"), &m_EM_Flags, eViewDist); - FV->OnChangeEvent.bind (this,&CSpawnPoint::OnEnvModFlagChange); - if(m_EM_Flags.test(eViewDist)) - PHelper().CreateFloat(items, PrepareKey(pref,"Environment Modificator\\View Distance\\ "), &m_EM_ViewDist, EPS_L,10000.f); - - FV = PHelper().CreateFlag16(items, PrepareKey(pref,"Environment Modificator\\Fog Color"), &m_EM_Flags, eFogColor); - FV->OnChangeEvent.bind (this,&CSpawnPoint::OnEnvModFlagChange); - if(m_EM_Flags.test(eFogColor)) - PHelper().CreateColor (items, PrepareKey(pref,"Environment Modificator\\Fog Color\\ "), &m_EM_FogColor); - - FV = PHelper().CreateFlag16(items, PrepareKey(pref,"Environment Modificator\\Fog Density"), &m_EM_Flags, eFogDensity); - FV->OnChangeEvent.bind (this,&CSpawnPoint::OnEnvModFlagChange); - if(m_EM_Flags.test(eFogDensity)) - PHelper().CreateFloat (items, PrepareKey(pref,"Environment Modificator\\Fog Density\\ "), &m_EM_FogDensity, 0.f,10000.f); - - FV = PHelper().CreateFlag16(items, PrepareKey(pref,"Environment Modificator\\Ambient Color"), &m_EM_Flags, eAmbientColor); - FV->OnChangeEvent.bind (this,&CSpawnPoint::OnEnvModFlagChange); - if(m_EM_Flags.test(eAmbientColor)) - PHelper().CreateColor (items, PrepareKey(pref,"Environment Modificator\\Ambient Color\\ "), &m_EM_AmbientColor); - - FV = PHelper().CreateFlag16(items, PrepareKey(pref,"Environment Modificator\\Sky Color"), &m_EM_Flags, eSkyColor); - FV->OnChangeEvent.bind (this,&CSpawnPoint::OnEnvModFlagChange); - if(m_EM_Flags.test(eSkyColor)) - PHelper().CreateColor (items, PrepareKey(pref,"Environment Modificator\\Sky Color\\ "), &m_EM_SkyColor); - - FV = PHelper().CreateFlag16(items, PrepareKey(pref,"Environment Modificator\\Hemi Color"), &m_EM_Flags, eHemiColor); - FV->OnChangeEvent.bind (this,&CSpawnPoint::OnEnvModFlagChange); - if(m_EM_Flags.test(eHemiColor)) - PHelper().CreateColor (items, PrepareKey(pref,"Environment Modificator\\Hemi Color\\ "), &m_EM_HemiColor); - }break; - default: THROW; + break; + default: THROW; } } } + #include "UI_LevelTools.h" -void CSpawnPoint::OnEnvModFlagChange(PropValue* prop) + +void CSpawnPoint::OnEnvModFlagChange(PropValue *prop) { LTools->UpdateProperties(FALSE); } + //---------------------------------------------------- bool CSpawnPoint::OnChooseQuery(LPCSTR specific) { - return (m_SpawnData.Valid()&&(0==strcmp(m_SpawnData.m_Data->name(),specific))); + return (m_SpawnData.Valid()&&(0==strcmp(m_SpawnData.m_Data->name(), specific))); } + ///----------------------------------------------------------------------------- - void CSpawnPoint::UseSimulatePose () - { - if(m_physics_shell) - { - Fmatrix m; - UpdateObjectXform(m); - FPosition.set(m.c); - //m.getXYZi( FRotation ); - m.getXYZ ( FRotation ); - UpdateTransform(); - } - } - void CSpawnPoint::OnUpdateTransform() - { - - inherited::OnUpdateTransform(); - - } +void CSpawnPoint::UseSimulatePose() +{ + if (m_physics_shell) + { + Fmatrix m; + UpdateObjectXform(m); + FPosition.set(m.c); + //m.getXYZi( FRotation ); + m.getXYZ(FRotation); + UpdateTransform(); + } +} + +void CSpawnPoint::OnUpdateTransform() +{ + inherited::OnUpdateTransform(); +} diff --git a/src/editors/LevelEditor/Edit/SpawnPoint.h b/src/editors/LevelEditor/Edit/SpawnPoint.h index 77b7e9f57a1..3d69e9b0b27 100644 --- a/src/editors/LevelEditor/Edit/SpawnPoint.h +++ b/src/editors/LevelEditor/Edit/SpawnPoint.h @@ -7,10 +7,10 @@ #define SPAWNPOINT_VERSION 0x0017 -#include "../../xrServerEntities/LevelGameDef.h" -#include "../../xrServerEntities/xrServer_Objects_abstract.h" +#include "xrServerEntities/LevelGameDef.h" +#include "xrServerEntities/xrServer_Objects_abstract.h" #include "CustomObject.h" -#include "../Ecore/editor/physicsshellholdereditorbase.h" +#include "editors/ECore/Editor/PhysicsShellHolderEditorBase.h" // refs class CSE_Visual; class CSE_Motion; @@ -23,161 +23,189 @@ class CSpawnPoint : public CCustomObject, { typedef CCustomObject inherited; - friend class SceneBuilder; -public: + friend class SceneBuilder; +public: class CLE_Visual { public: - static bool g_tmp_lock; - CSE_Visual* source; - IRenderVisual* visual; - void OnChangeVisual (); - void StopAllAnimations (); - void PlayAnimation (); - void PlayAnimationFirstFrame (); - void PlayAnimationLastFrame (); - void PauseAnimation (); + static bool g_tmp_lock; + CSE_Visual *source; + IRenderVisual *visual; + void OnChangeVisual(); + void StopAllAnimations(); + void PlayAnimation(); + void PlayAnimationFirstFrame(); + void PlayAnimationLastFrame(); + void PauseAnimation(); public: - CLE_Visual (CSE_Visual* src); - virtual ~CLE_Visual (); + CLE_Visual(CSE_Visual *src); + virtual ~CLE_Visual(); }; + class CLE_Motion { public: - CSE_Motion* source; - CObjectAnimator*animator; - void OnChangeMotion (); - void PlayMotion (); + CSE_Motion *source; + CObjectAnimator *animator; + void OnChangeMotion(); + void PlayMotion(); public: - CLE_Motion (CSE_Motion* src); - virtual ~CLE_Motion (); + CLE_Motion(CSE_Motion *src); + virtual ~CLE_Motion(); }; + struct SSpawnData: public IServerEntityLEOwner { - CLASS_ID m_ClassID; - shared_str m_Profile; - IServerEntity* m_Data; - CLE_Visual* m_Visual; - Flags8 m_flags; + CLASS_ID m_ClassID; + shared_str m_Profile; + IServerEntity *m_Data; + CLE_Visual *m_Visual; + Flags8 m_flags; xr_vector m_VisualHelpers; - CLE_Motion* m_Motion; - CSpawnPoint* m_owner; - enum{ eSDTypeRespawn = (1<<0),}; - SSpawnData (CSpawnPoint* o) + CLE_Motion *m_Motion; + CSpawnPoint *m_owner; + + enum + { + eSDTypeRespawn = (1<<0), + }; + + SSpawnData(CSpawnPoint *o) { - m_ClassID = 0; - m_Data = 0; - m_Visual = 0; - m_Motion = 0; - m_owner = o; + m_ClassID = 0; + m_Data = 0; + m_Visual = 0; + m_Motion = 0; + m_owner = o; m_flags.zero(); } - ~SSpawnData () + + ~SSpawnData() + { + Destroy(); + } + + void Create(LPCSTR entity_ref); + void Destroy(); + + bool Valid() { - Destroy (); + return m_Data; } - void Create (LPCSTR entity_ref); - void Destroy (); - bool Valid (){return m_Data;} - bool LoadStream (IReader&); - void SaveStream (IWriter&); - bool LoadLTX (CInifile& ini, LPCSTR sect_name); - void SaveLTX (CInifile& ini, LPCSTR sect_name); + bool LoadStream(IReader &); + void SaveStream(IWriter &); + bool LoadLTX(CInifile &ini, LPCSTR sect_name); + void SaveLTX(CInifile &ini, LPCSTR sect_name); + + bool ExportGame(SExportStreams *F, CSpawnPoint *owner); - bool ExportGame (SExportStreams* F, CSpawnPoint* owner); + void FillProp(LPCSTR pref, PropItemVec &values); - void FillProp (LPCSTR pref, PropItemVec& values); + void Render(bool bSelected, const Fmatrix &parent, int priority, bool strictB2F); + void OnFrame(); + void __stdcall OnAnimControlClick(ButtonValue *value, bool &bModif, bool &bSafe); - void Render (bool bSelected, const Fmatrix& parent,int priority, bool strictB2F); - void OnFrame (); - void __stdcall OnAnimControlClick (ButtonValue* value, bool& bModif, bool& bSafe); - - virtual void get_bone_xform (LPCSTR name, Fmatrix& xform); + virtual void get_bone_xform(LPCSTR name, Fmatrix &xform); }; - SSpawnData m_SpawnData; - CCustomObject* m_AttachedObject; + SSpawnData m_SpawnData; + CCustomObject *m_AttachedObject; - EPointType m_Type; - shared_str m_rpProfile; - union{ - struct{ - u8 m_RP_TeamID; - u8 m_RP_Type; - GameTypeChooser m_GameType; + EPointType m_Type; + shared_str m_rpProfile; + + union + { + struct + { + u8 m_RP_TeamID; + u8 m_RP_Type; + GameTypeChooser m_GameType; }; - struct{ - float m_EM_Radius; - float m_EM_Power; - float m_EM_ViewDist; - u32 m_EM_FogColor; - float m_EM_FogDensity; - u32 m_EM_AmbientColor; - u32 m_EM_SkyColor; - u32 m_EM_HemiColor; + + struct + { + float m_EM_Radius; + float m_EM_Power; + float m_EM_ViewDist; + u32 m_EM_FogColor; + float m_EM_FogDensity; + u32 m_EM_AmbientColor; + u32 m_EM_SkyColor; + u32 m_EM_HemiColor; Flags16 m_EM_Flags; }; }; - shared_str SectionToEditor (shared_str); - shared_str EditorToSection (shared_str); - void __stdcall OnProfileChange (PropValue* prop); - void __stdcall OnRPointTypeChange (PropValue* prop); - - void __stdcall OnEnvModFlagChange (PropValue* prop); - void __stdcall OnFillChooseItems (ChooseValue*); - void __stdcall OnFillRespawnItemProfile(ChooseValue*); - bool OnAppendObject (CCustomObject* object); + shared_str SectionToEditor(shared_str); + shared_str EditorToSection(shared_str); + void __stdcall OnProfileChange(PropValue *prop); + void __stdcall OnRPointTypeChange(PropValue *prop); + + void __stdcall OnEnvModFlagChange(PropValue *prop); + void __stdcall OnFillChooseItems(ChooseValue *); + void __stdcall OnFillRespawnItemProfile(ChooseValue *); + bool OnAppendObject(CCustomObject *object); protected: - virtual void SetPosition (const Fvector& pos); - virtual void SetRotation (const Fvector& rot); - virtual void SetScale (const Fvector& scale); + virtual void SetPosition(const Fvector &pos); + virtual void SetRotation(const Fvector &rot); + virtual void SetScale(const Fvector &scale); protected: - virtual void Move (Fvector& amount); + virtual void Move(Fvector &amount); public: - CSpawnPoint (LPVOID data, LPCSTR name); - void Construct (LPVOID data); - virtual ~CSpawnPoint (); - virtual bool CanAttach () {return true;} - - bool RefCompare (LPCSTR ref); - virtual LPCSTR RefName (); + CSpawnPoint(LPVOID data, LPCSTR name); + void Construct(LPVOID data); + virtual ~CSpawnPoint(); - bool CreateSpawnData (LPCSTR entity_ref); - virtual void Render ( int priority, bool strictB2F ); + virtual bool CanAttach() + { + return true; + } - virtual bool RayPick ( float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf = NULL ); - virtual bool FrustumPick ( const CFrustum& frustum ); - virtual bool GetBox (Fbox& box) const; + bool RefCompare(LPCSTR ref); + virtual LPCSTR RefName(); - virtual void OnFrame (); + bool CreateSpawnData(LPCSTR entity_ref); + virtual void Render(int priority, bool strictB2F); - virtual void Select (int flag); + virtual bool RayPick(float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf = NULL); + virtual bool FrustumPick(const CFrustum &frustum); + virtual bool GetBox(Fbox &box) const; - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); + virtual void OnFrame(); - virtual bool ExportGame (SExportStreams* data); + virtual void Select(int flag); - virtual void FillProp (LPCSTR pref, PropItemVec& values); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); - bool AttachObject (CCustomObject* obj); - void DetachObject (); - - virtual bool OnChooseQuery (LPCSTR specific); - virtual void OnSceneRemove (); - void UseSimulatePose (); + virtual bool ExportGame(SExportStreams *data); + + virtual void FillProp(LPCSTR pref, PropItemVec &values); + + bool AttachObject(CCustomObject *obj); + void DetachObject(); + + virtual bool OnChooseQuery(LPCSTR specific); + virtual void OnSceneRemove(); + void UseSimulatePose(); public: - - virtual IKinematics* _BCL ObjectKinematics () { if(!m_SpawnData.m_Visual||!m_SpawnData.m_Visual->visual)return 0;return m_SpawnData.m_Visual->visual->dcast_PKinematics();} + + virtual IKinematics* _BCL ObjectKinematics() + { + if (!m_SpawnData.m_Visual||!m_SpawnData.m_Visual->visual) + return 0; + return m_SpawnData.m_Visual->visual->dcast_PKinematics(); + } + private: - virtual void OnUpdateTransform(); + virtual void OnUpdateTransform(); private: - void RenderSimBox (); + void RenderSimBox(); }; #endif /*_INCDEF_Glow_H_*/ diff --git a/src/editors/LevelEditor/Edit/UI_LevelMain.cpp b/src/editors/LevelEditor/Edit/UI_LevelMain.cpp index 4aabbfe5d94..a4c451f9f7c 100644 --- a/src/editors/LevelEditor/Edit/UI_LevelMain.cpp +++ b/src/editors/LevelEditor/Edit/UI_LevelMain.cpp @@ -6,22 +6,22 @@ #include "UI_LevelTools.h" #include "EditLibrary.h" -#include "../ECore/Editor/ImageEditor.h" -#include "leftbar.h" -#include "topbar.h" +#include "editors/ECore/Editor/ImageEditor.h" +#include "LeftBar.h" +#include "TopBar.h" #include "scene.h" -#include "sceneobject.h" +#include "SceneObject.h" #include "Cursor3D.h" -#include "bottombar.h" -#include "xr_trims.h" +#include "BottomBar.h" +#include "xrCore/xr_trims.h" #include "main.h" -#include "xr_input.h" -#include "../ECore/Editor/ui_main.h" -#include "d3dutils.h" +#include "xrEngine/xr_input.h" +#include "editors/ECore/Editor/ui_main.h" +#include "D3DUtils.h" #include "EditLightAnim.h" -#include "builder.h" +#include "Builder.h" #include "SoundManager_LE.h" -#include "../xrEProps/NumericVector.h" +#include "editors/xrEProps/NumericVector.h" #include "LevelPreferences.h" #include "LEClipEditor.h" @@ -29,40 +29,43 @@ //. if (m_Cursor->GetVisible()) RedrawScene(); #endif -CLevelMain*& LUI=(CLevelMain*)UI; +CLevelMain *&LUI = (CLevelMain*)UI; CLevelMain::CLevelMain() { - m_Cursor = xr_new(); - EPrefs = xr_new(); + m_Cursor = xr_new(); + EPrefs = xr_new(); } CLevelMain::~CLevelMain() { - xr_delete (EPrefs); - xr_delete (m_Cursor); + xr_delete(EPrefs); + xr_delete(m_Cursor); TClipMaker::DestroyForm(g_clip_maker); } - //------------------------------------------------------------------------------ // Tools commands //------------------------------------------------------------------------------ CCommandVar CLevelTool::CommandChangeTarget(CCommandVar p1, CCommandVar p2) { - if (Scene->GetTool(p1)->IsEnabled()) + if (Scene->GetTool(p1)->IsEnabled()) + { + SetTarget(p1, p2); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + return TRUE; + } + else { - SetTarget (p1,p2); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - return TRUE; - }else{ - return FALSE; + return FALSE; } } + CCommandVar CLevelTool::CommandShowObjectList(CCommandVar p1, CCommandVar p2) { - if (LUI->GetEState()==esEditScene) ShowObjectList(); + if (LUI->GetEState()==esEditScene) + ShowObjectList(); return TRUE; } @@ -71,737 +74,903 @@ CCommandVar CLevelTool::CommandShowObjectList(CCommandVar p1, CCommandVar p2) //------------------------------------------------------------------------------ CCommandVar CommandLibraryEditor(CCommandVar p1, CCommandVar p2) { - if (Scene->ObjCount()||(LUI->GetEState()!=esEditScene)){ - if (LUI->GetEState()==esEditLibrary) TfrmEditLibrary::ShowEditor(); - else ELog.DlgMsg(mtError, "Scene must be empty before editing library!"); - }else{ + if (Scene->ObjCount()||(LUI->GetEState()!=esEditScene)) + { + if (LUI->GetEState()==esEditLibrary) + TfrmEditLibrary::ShowEditor(); + else + ELog.DlgMsg(mtError, "Scene must be empty before editing library!"); + } + else + { TfrmEditLibrary::ShowEditor(); } return TRUE; } + CCommandVar CommandLAnimEditor(CCommandVar p1, CCommandVar p2) { TfrmEditLightAnim::ShowEditor(); return TRUE; } + CCommandVar CommandFileMenu(CCommandVar p1, CCommandVar p2) { - FHelper.ShowPPMenu(fraLeftBar->pmSceneFile,0); + FHelper.ShowPPMenu(fraLeftBar->pmSceneFile, 0); return TRUE; } + CCommandVar CLevelTool::CommandEnableTarget(CCommandVar p1, CCommandVar p2) { - ESceneToolBase* M = Scene->GetTool(p1); - VERIFY (M); - BOOL res = FALSE; - if (p2) + ESceneToolBase *M = Scene->GetTool(p1); + VERIFY(M); + BOOL res = FALSE; + if (p2) { - res = ExecCommand(COMMAND_LOAD_LEVEL_PART,M->ClassID,TRUE); - if(res) - M->m_EditFlags.set(ESceneToolBase::flEnable,TRUE); - }else + res = ExecCommand(COMMAND_LOAD_LEVEL_PART, M->ClassID, TRUE); + if (res) + M->m_EditFlags.set(ESceneToolBase::flEnable, TRUE); + } + else { if (!Scene->IfModified()) { - M->m_EditFlags.set(ESceneToolBase::flEnable,TRUE); - res = FALSE; - }else + M->m_EditFlags.set(ESceneToolBase::flEnable, TRUE); + res = FALSE; + } + else { - res = ExecCommand(COMMAND_UNLOAD_LEVEL_PART,M->ClassID,TRUE); - if(res) - M->m_EditFlags.set(ESceneToolBase::flEnable,FALSE); + res = ExecCommand(COMMAND_UNLOAD_LEVEL_PART, M->ClassID, TRUE); + if (res) + M->m_EditFlags.set(ESceneToolBase::flEnable, FALSE); } - if (res) - ExecCommand(COMMAND_CHANGE_TARGET,OBJCLASS_SCENEOBJECT); + if (res) + ExecCommand(COMMAND_CHANGE_TARGET, OBJCLASS_SCENEOBJECT); } - ExecCommand (COMMAND_REFRESH_UI_BAR); + ExecCommand(COMMAND_REFRESH_UI_BAR); return res; } CCommandVar CLevelTool::CommandShowTarget(CCommandVar p1, CCommandVar p2) { - ESceneToolBase* M = Scene->GetTool(p1); - if(p2) - M->m_EditFlags.set(ESceneToolBase::flVisible,TRUE); + ESceneToolBase *M = Scene->GetTool(p1); + if (p2) + M->m_EditFlags.set(ESceneToolBase::flVisible, TRUE); else - M->m_EditFlags.set(ESceneToolBase::flVisible,FALSE); - + M->m_EditFlags.set(ESceneToolBase::flVisible, FALSE); + return TRUE; } CCommandVar CLevelTool::CommandReadonlyTarget(CCommandVar p1, CCommandVar p2) { - ESceneToolBase* M = Scene->GetTool(p1); VERIFY(M); - BOOL res = TRUE; - if (p2){ + ESceneToolBase *M = Scene->GetTool(p1); + VERIFY(M); + BOOL res = TRUE; + if (p2) + { if (!Scene->IfModified()) { - M->m_EditFlags.set(ESceneToolBase::flForceReadonly,FALSE); - res = FALSE; - }else + M->m_EditFlags.set(ESceneToolBase::flForceReadonly, FALSE); + res = FALSE; + } + else { -//. xr_string pn = Scene->LevelPartName(LTools->m_LastFileName.c_str(),M->ClassID); + //. xr_string pn = Scene->LevelPartName(LTools->m_LastFileName.c_str(),M->ClassID); } - }else + } + else { -//. xr_string pn = Scene->LevelPartName(LTools->m_LastFileName.c_str(), M->ClassID); + //. xr_string pn = Scene->LevelPartName(LTools->m_LastFileName.c_str(), M->ClassID); } if (res) { - Reset (); - ExecCommand (COMMAND_REFRESH_UI_BAR); + Reset(); + ExecCommand(COMMAND_REFRESH_UI_BAR); } return res; } CCommandVar CLevelTool::CommandMultiRenameObjects(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ) + if (!Scene->locked()) { if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<MultiRenameObjects(); + int cnt = Scene->MultiRenameObjects(); if (cnt) { - ExecCommand (COMMAND_UPDATE_PROPERTIES); - Scene->UndoSave(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + Scene->UndoSave(); } - ELog.DlgMsg ( mtInformation, "%d - objects are renamed.", cnt ); + ELog.DlgMsg(mtInformation, "%d - objects are renamed.", cnt); } - }else + } + else { - ELog.DlgMsg ( mtError, "Scene sharing violation" ); + ELog.DlgMsg(mtError, "Scene sharing violation"); } - return FALSE; + return FALSE; } + CCommandVar CommandLoadLevelPart(CCommandVar p1, CCommandVar p2) { - xr_string temp_fn = LTools->m_LastFileName.c_str(); + xr_string temp_fn = LTools->m_LastFileName.c_str(); if (!temp_fn.empty()) - return Scene->LoadLevelPart(temp_fn.c_str(),p1); - return TRUE; + return Scene->LoadLevelPart(temp_fn.c_str(), p1); + return TRUE; } + CCommandVar CommandUnloadLevelPart(CCommandVar p1, CCommandVar p2) { - xr_string temp_fn = LTools->m_LastFileName.c_str(); + xr_string temp_fn = LTools->m_LastFileName.c_str(); if (!temp_fn.empty()) - return Scene->UnloadLevelPart(temp_fn.c_str(),p1); - return TRUE; + return Scene->UnloadLevelPart(temp_fn.c_str(), p1); + return TRUE; } + CCommandVar CommandLoad(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ) + if (!Scene->locked()) { - if (!p1.IsString()) + if (!p1.IsString()) { - xr_string temp_fn = LTools->m_LastFileName.c_str(); - if (EFS.GetOpenName ( _maps_, temp_fn )) - return ExecCommand(COMMAND_LOAD,temp_fn); - }else + xr_string temp_fn = LTools->m_LastFileName.c_str(); + if (EFS.GetOpenName(_maps_, temp_fn)) + return ExecCommand(COMMAND_LOAD, temp_fn); + } + else { - xr_string temp_fn = p1; - xr_strlwr (temp_fn); + xr_string temp_fn = p1; + xr_strlwr(temp_fn); if (!Scene->IfModified()) - return FALSE; - - UI->SetStatus ("Level loading..."); - ExecCommand (COMMAND_CLEAR); + return FALSE; + + UI->SetStatus("Level loading..."); + ExecCommand(COMMAND_CLEAR); - IReader* R = FS.r_open (temp_fn.c_str()); + IReader *R = FS.r_open(temp_fn.c_str()); char ch; R->r(&ch, sizeof(ch)); bool is_ltx = (ch=='['); FS.r_close(R); bool res; - LTools->m_LastFileName = temp_fn.c_str(); + LTools->m_LastFileName = temp_fn.c_str(); - if(is_ltx) - res = Scene->LoadLTX(temp_fn.c_str(), false); + if (is_ltx) + res = Scene->LoadLTX(temp_fn.c_str(), false); else - res = Scene->Load(temp_fn.c_str(), false); + res = Scene->Load(temp_fn.c_str(), false); if (res) { - UI->ResetStatus (); - Scene->UndoClear (); - - BOOL bk1 = Scene->m_RTFlags.test(EScene::flRT_Unsaved); - BOOL bk2 = Scene->m_RTFlags.test(EScene::flRT_Modified); + UI->ResetStatus(); + Scene->UndoClear(); - Scene->UndoSave (); + BOOL bk1 = Scene->m_RTFlags.test(EScene::flRT_Unsaved); + BOOL bk2 = Scene->m_RTFlags.test(EScene::flRT_Modified); - Scene->m_RTFlags.set(EScene::flRT_Unsaved,bk1); - Scene->m_RTFlags.set(EScene::flRT_Modified,bk2); + Scene->UndoSave(); - ExecCommand (COMMAND_CLEAN_LIBRARY); - ExecCommand (COMMAND_UPDATE_CAPTION); - ExecCommand (COMMAND_CHANGE_ACTION,etaSelect); + Scene->m_RTFlags.set(EScene::flRT_Unsaved, bk1); + Scene->m_RTFlags.set(EScene::flRT_Modified, bk2); + + ExecCommand(COMMAND_CLEAN_LIBRARY); + ExecCommand(COMMAND_UPDATE_CAPTION); + ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); EPrefs->AppendRecentFile(temp_fn.c_str()); - }else + } + else { - ELog.DlgMsg ( mtError, "Can't load map '%s'", temp_fn.c_str() ); + ELog.DlgMsg(mtError, "Can't load map '%s'", temp_fn.c_str()); LTools->m_LastFileName = ""; } // update props - ExecCommand (COMMAND_UPDATE_PROPERTIES); - UI->RedrawScene (); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + UI->RedrawScene(); } - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); return FALSE; } return TRUE; } + CCommandVar CommandSaveBackup(CCommandVar p1, CCommandVar p2) { - string_path fn; - strconcat(sizeof(fn),fn,Core.CompName,"_",Core.UserName,"_backup.level"); - FS.update_path (fn,_maps_,fn); - return ExecCommand(COMMAND_SAVE,xr_string(fn)); + string_path fn; + strconcat(sizeof(fn), fn, Core.CompName, "_", Core.UserName, "_backup.level"); + FS.update_path(fn, _maps_, fn); + return ExecCommand(COMMAND_SAVE, xr_string(fn)); } + CCommandVar CommandSave(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ) + if (!Scene->locked()) { if (p2==1) { - xr_string temp_fn = LTools->m_LastFileName.c_str(); - if (EFS.GetSaveName ( _maps_, temp_fn )) - return ExecCommand(COMMAND_SAVE,temp_fn, 66); + xr_string temp_fn = LTools->m_LastFileName.c_str(); + if (EFS.GetSaveName(_maps_, temp_fn)) + return ExecCommand(COMMAND_SAVE, temp_fn, 66); else - return FALSE; - }else{ + return FALSE; + } + else + { if (p1.IsInteger()) - return ExecCommand(COMMAND_SAVE,xr_string(LTools->m_LastFileName.c_str()),0); - - xr_string temp_fn = xr_string(p1); + return ExecCommand(COMMAND_SAVE, xr_string(LTools->m_LastFileName.c_str()), 0); + + xr_string temp_fn = xr_string(p1); if (temp_fn.empty()) { - return ExecCommand(COMMAND_SAVE,temp_fn,1); - }else + return ExecCommand(COMMAND_SAVE, temp_fn, 1); + } + else { - xr_strlwr (temp_fn); + xr_strlwr(temp_fn); - UI->SetStatus ("Level saving..."); + UI->SetStatus("Level saving..."); - if(LUI->m_rt_object_props->section_exist(temp_fn.c_str())) + if (LUI->m_rt_object_props->section_exist(temp_fn.c_str())) { - CInifile::Sect& S = LUI->m_rt_object_props->r_section(temp_fn.c_str()); - S.Data.clear (); + CInifile::Sect &S = LUI->m_rt_object_props->r_section(temp_fn.c_str()); + S.Data.clear(); } - Scene->SaveLTX (temp_fn.c_str(), false, (p2==66)); + Scene->SaveLTX(temp_fn.c_str(), false, (p2==66)); - UI->ResetStatus (); + UI->ResetStatus(); // set new name - if (0!=xr_strcmp(Tools->m_LastFileName.c_str(),temp_fn.c_str())) + if (0!=xr_strcmp(Tools->m_LastFileName.c_str(), temp_fn.c_str())) { - Tools->m_LastFileName = temp_fn.c_str(); + Tools->m_LastFileName = temp_fn.c_str(); } - ExecCommand (COMMAND_UPDATE_CAPTION); + ExecCommand(COMMAND_UPDATE_CAPTION); EPrefs->AppendRecentFile(temp_fn.c_str()); - return TRUE; + return TRUE; } } - } else { - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } CCommandVar CommandClear(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - if (!Scene->IfModified()) return TRUE; - EDevice.m_Camera.Reset (); - Scene->Reset (); - Scene->m_LevelOp.Reset (); - Tools->m_LastFileName = ""; + if (!Scene->locked()) + { + if (!Scene->IfModified()) + return TRUE; + EDevice.m_Camera.Reset(); + Scene->Reset(); + Scene->m_LevelOp.Reset(); + Tools->m_LastFileName = ""; LTools->m_LastSelectionName = ""; - Scene->UndoClear (); - ExecCommand (COMMAND_UPDATE_CAPTION); - ExecCommand (COMMAND_CHANGE_TARGET,OBJCLASS_SCENEOBJECT); - ExecCommand (COMMAND_CHANGE_ACTION,etaSelect,estDefault); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - Scene->UndoSave (); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); - return FALSE; + Scene->UndoClear(); + ExecCommand(COMMAND_UPDATE_CAPTION); + ExecCommand(COMMAND_CHANGE_TARGET, OBJCLASS_SCENEOBJECT); + ExecCommand(COMMAND_CHANGE_ACTION, etaSelect,estDefault); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + Scene->UndoSave(); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandLoadFirstRecent(CCommandVar p1, CCommandVar p2) { if (EPrefs->FirstRecentFile()) - return ExecCommand(COMMAND_LOAD,xr_string(EPrefs->FirstRecentFile())); - return FALSE; + return ExecCommand(COMMAND_LOAD, xr_string(EPrefs->FirstRecentFile())); + return FALSE; } CCommandVar CommandClearDebugDraw(CCommandVar p1, CCommandVar p2) { - Tools->ClearDebugDraw (); - UI->RedrawScene (); - return TRUE; + Tools->ClearDebugDraw(); + UI->RedrawScene(); + return TRUE; } + #include "SpawnPoint.h" + CCommandVar CommandShowClipEditor(CCommandVar p1, CCommandVar p2) { - if(g_clip_maker==NULL) - g_clip_maker = TClipMaker::CreateForm(); + if (g_clip_maker==NULL) + g_clip_maker = TClipMaker::CreateForm(); - if(!g_clip_maker->Visible) + if (!g_clip_maker->Visible) { - ESceneCustomOTool* st = Scene->GetOTool(OBJCLASS_SPAWNPOINT); + ESceneCustomOTool *st = Scene->GetOTool(OBJCLASS_SPAWNPOINT); - ObjectList& ol = st->GetObjects(); - ObjectList::iterator it = ol.begin(); - ObjectList::iterator it_e = ol.end(); + ObjectList &ol = st->GetObjects(); + ObjectList::iterator it = ol.begin(); + ObjectList::iterator it_e = ol.end(); - CCustomObject* CO = NULL; - for(;it!=it_e;++it) + CCustomObject*CO = NULL; + for (; it!=it_e; ++it) { - if((*it)->Selected()==true) + if ((*it)->Selected()==true) { - CO=*it; + CO = *it; break; } } - if(!CO) - return TRUE; - - CSpawnPoint* sp = dynamic_cast(CO); + if (!CO) + return TRUE; + + CSpawnPoint *sp = dynamic_cast(CO); + - - CKinematicsAnimated* KA = PKinematicsAnimated(sp->m_SpawnData.m_Visual->visual); - R_ASSERT (KA); - g_clip_maker->ShowEditor (KA); + CKinematicsAnimated *KA = PKinematicsAnimated(sp->m_SpawnData.m_Visual->visual); + R_ASSERT(KA); + g_clip_maker->ShowEditor(KA); } - return TRUE; + return TRUE; } CCommandVar CommandImportCompilerError(CCommandVar p1, CCommandVar p2) { xr_string fn; - if(EFS.GetOpenName("$logs$", fn, false, NULL, 0)){ + if (EFS.GetOpenName("$logs$", fn, false, NULL, 0)) + { Scene->LoadCompilerError(fn.c_str()); } - UI->RedrawScene (); + UI->RedrawScene(); return TRUE; } + CCommandVar CommandExportCompilerError(CCommandVar p1, CCommandVar p2) { xr_string fn; - if(EFS.GetSaveName("$logs$", fn, NULL, 0)){ + if (EFS.GetSaveName("$logs$", fn, NULL, 0)) + { Scene->SaveCompilerError(fn.c_str()); } return TRUE; } + CCommandVar CommandValidateScene(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->Validate (true,true,true,true,true,true); - return TRUE; - } else { - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->Validate(true, true, true, true, true, true); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandCleanLibrary(CCommandVar p1, CCommandVar p2) { - if ( !Scene->locked() ){ + if (!Scene->locked()) + { Lib.CleanLibrary(); - return TRUE; - }else{ - ELog.DlgMsg (mtError, "Scene must be empty before refreshing library!"); - return FALSE; + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene must be empty before refreshing library!"); + return FALSE; } } CCommandVar CommandReloadObjects(CCommandVar p1, CCommandVar p2) { - Lib.ReloadObjects (); - return TRUE; + Lib.ReloadObjects(); + return TRUE; } CCommandVar CommandCut(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ + if (!Scene->locked()) + { Scene->CutSelection(LTools->CurrentClassID()); fraLeftBar->miPaste->Enabled = true; fraLeftBar->miPaste2->Enabled = true; - Scene->UndoSave (); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); - return FALSE; + Scene->UndoSave(); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandCopy(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ + if (!Scene->locked()) + { Scene->CopySelection(LTools->CurrentClassID()); fraLeftBar->miPaste->Enabled = true; fraLeftBar->miPaste2->Enabled = true; - return TRUE; - } else { - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } CCommandVar CommandPaste(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ + if (!Scene->locked()) + { Scene->PasteSelection(); - Scene->UndoSave (); - return TRUE; - } else { - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + Scene->UndoSave(); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } #include "AppendObjectInfoForm.h" + CCommandVar CommandLoadSelection(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ) + if (!Scene->locked()) { - xr_string fn = LTools->m_LastSelectionName; - if( EFS.GetOpenName( _maps_, fn ) ) + xr_string fn = LTools->m_LastSelectionName; + if (EFS.GetOpenName(_maps_, fn)) { - LPCSTR maps_path = FS.get_path(_maps_)->m_Path; - if (fn.c_str()==strstr(fn.c_str(),maps_path)) - LTools->m_LastSelectionName = fn.c_str()+xr_strlen(maps_path); - UI->SetStatus ("Fragment loading..."); + LPCSTR maps_path = FS.get_path(_maps_)->m_Path; + if (fn.c_str()==strstr(fn.c_str(), maps_path)) + LTools->m_LastSelectionName = fn.c_str()+xr_strlen(maps_path); + UI->SetStatus("Fragment loading..."); - g_frmConflictLoadObject->m_result = 0; + g_frmConflictLoadObject->m_result = 0; Scene->LoadSelection(fn.c_str()); - g_frmConflictLoadObject->m_result = 4; //auto-rename - - UI->ResetStatus (); - Scene->UndoSave (); - ExecCommand (COMMAND_CHANGE_ACTION,etaSelect); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - UI->RedrawScene (); - return TRUE; - } - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); - } - return FALSE; -} + g_frmConflictLoadObject->m_result = 4; //auto-rename + + UI->ResetStatus(); + Scene->UndoSave(); + ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + UI->RedrawScene(); + return TRUE; + } + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + } + return FALSE; +} + CCommandVar CommandSaveSelection(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - xr_string fn = LTools->m_LastSelectionName; - if( EFS.GetSaveName ( _maps_, fn ) ){ - LPCSTR maps_path = FS.get_path(_maps_)->m_Path; - if (fn.c_str()==strstr(fn.c_str(),maps_path)) - LTools->m_LastSelectionName = fn.c_str()+xr_strlen(maps_path); - UI->SetStatus ("Fragment saving..."); - Scene->SaveSelection(LTools->CurrentClassID(),fn.c_str()); - UI->ResetStatus (); - return TRUE; + if (!Scene->locked()) + { + xr_string fn = LTools->m_LastSelectionName; + if (EFS.GetSaveName(_maps_, fn)) + { + LPCSTR maps_path = FS.get_path(_maps_)->m_Path; + if (fn.c_str()==strstr(fn.c_str(), maps_path)) + LTools->m_LastSelectionName = fn.c_str()+xr_strlen(maps_path); + UI->SetStatus("Fragment saving..."); + Scene->SaveSelection(LTools->CurrentClassID(), fn.c_str()); + UI->ResetStatus(); + return TRUE; } - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); } - return FALSE; + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + } + return FALSE; } CCommandVar CommandUndo(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - if( !Scene->Undo() ) ELog.DlgMsg( mtInformation, "Undo buffer empty" ); - else{ - LTools->Reset (); - ExecCommand (COMMAND_CHANGE_ACTION, etaSelect); - return TRUE; + if (!Scene->locked()) + { + if (!Scene->Undo()) + ELog.DlgMsg(mtInformation, "Undo buffer empty"); + else + { + LTools->Reset(); + ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); + return TRUE; } - } else { - ELog.DlgMsg ( mtError, "Scene sharing violation" ); } - return FALSE; + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + } + return FALSE; } CCommandVar CommandRedo(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - if( !Scene->Redo() ) ELog.DlgMsg( mtInformation, "Redo buffer empty" ); - else{ - LTools->Reset (); - ExecCommand (COMMAND_CHANGE_ACTION, etaSelect); - return TRUE; + if (!Scene->locked()) + { + if (!Scene->Redo()) + ELog.DlgMsg(mtInformation, "Redo buffer empty"); + else + { + LTools->Reset(); + ExecCommand(COMMAND_CHANGE_ACTION, etaSelect); + return TRUE; } - } else { - ELog.DlgMsg ( mtError, "Scene sharing violation" ); } - return FALSE; + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + } + return FALSE; } CCommandVar CommandClearSceneSummary(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->ClearSummaryInfo (); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->ClearSummaryInfo(); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandCollectSceneSummary(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ + if (!Scene->locked()) + { Scene->CollectSummaryInfo(); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); - return FALSE; + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandShowSceneSummary(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ + if (!Scene->locked()) + { Scene->ShowSummaryInfo(); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); - return FALSE; + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandExportSceneSummary(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ + if (!Scene->locked()) + { Scene->ExportSummaryInfo(xr_string(p1).c_str()); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); - return FALSE; + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } CCommandVar CommandSceneHighlightTexture(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - LPCSTR new_val = 0; - if (TfrmChoseItem::SelectItem(smTexture,new_val,1)){ - Scene->HighlightTexture(new_val,false,0,0,false); - return TRUE; + if (!Scene->locked()) + { + LPCSTR new_val = 0; + if (TfrmChoseItem::SelectItem(smTexture, new_val, 1)) + { + Scene->HighlightTexture(new_val, false, 0, 0, false); + return TRUE; } - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); } - return FALSE; + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + } + return FALSE; } CCommandVar CommandOptions(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - ExecCommand (COMMAND_SHOW_PROPERTIES, p1, p2); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + ExecCommand(COMMAND_SHOW_PROPERTIES, p1, p2); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } CCommandVar CommandBuild(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ + if (!Scene->locked()) + { if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<locked() ){ + if (!Scene->locked()) + { if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<locked() ){ + if (!Scene->locked()) + { if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<locked() ){ + if (!Scene->locked()) + { if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<locked() ){ + if (!Scene->locked()) + { if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<locked() ){ + if (!Scene->locked()) + { if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<locked() ){ - Scene->InvertSelection (LTools->CurrentClassID()); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); + if (!Scene->locked()) + { + Scene->InvertSelection(LTools->CurrentClassID()); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); } - return FALSE; + return FALSE; } CCommandVar CommandSelectAll(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->SelectObjects (true,LTools->CurrentClassID()); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); + if (!Scene->locked()) + { + Scene->SelectObjects(true, LTools->CurrentClassID()); + return TRUE; } - return FALSE; + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + } + return FALSE; } CCommandVar CommandDeselectAll(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->SelectObjects (false,LTools->CurrentClassID()); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->SelectObjects(false, LTools->CurrentClassID()); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } CCommandVar CommandDeleteSelection(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->RemoveSelection ( LTools->CurrentClassID() ); - Scene->UndoSave (); - return TRUE; - } else { - ELog.DlgMsg( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->RemoveSelection(LTools->CurrentClassID()); + Scene->UndoSave(); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } CCommandVar CommandHideUnsel(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->ShowObjects ( false, LTools->CurrentClassID(), true, false ); - Scene->UndoSave (); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - return TRUE; - } else { - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->ShowObjects(false, LTools->CurrentClassID(), true, false); + Scene->UndoSave(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandHideSel(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->ShowObjects ( bool(p1), LTools->CurrentClassID(), true, true ); - Scene->UndoSave (); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - return TRUE; - } else { - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->ShowObjects(bool(p1), LTools->CurrentClassID(), true, true); + Scene->UndoSave(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandHideAll(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->ShowObjects ( bool(p1), LTools->CurrentClassID(), false ); - Scene->UndoSave (); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - return TRUE; - }else{ - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->ShowObjects(bool(p1), LTools->CurrentClassID(), false); + Scene->UndoSave(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandSetSnapObjects(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->SetSnapList (); - return TRUE; - }else{ - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->SetSnapList(); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandAddSelSnapObjects(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->AddSelToSnapList (); - return TRUE; - }else{ - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->AddSelToSnapList(); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandDelSelSnapObjects(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ + if (!Scene->locked()) + { Scene->DelSelFromSnapList(); - return TRUE; - }else{ - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandClearSnapObjects(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->ClearSnapList (true); - return TRUE; - }else{ - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->ClearSnapList(true); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandSelectSnapObjects(CCommandVar p1, CCommandVar p2) { - if( !Scene->locked() ){ - Scene->SelectSnapList (); - return TRUE; - }else{ - ELog.DlgMsg ( mtError, "Scene sharing violation" ); - return FALSE; + if (!Scene->locked()) + { + Scene->SelectSnapList(); + return TRUE; + } + else + { + ELog.DlgMsg(mtError, "Scene sharing violation"); + return FALSE; } } + CCommandVar CommandRefreshSnapObjects(CCommandVar p1, CCommandVar p2) { fraLeftBar->UpdateSnapList(); - return TRUE; + return TRUE; } + /* CCommandVar CommandRefreshSoundEnvs(CCommandVar p1, CCommandVar p2) { @@ -814,405 +983,419 @@ CCommandVar CommandRefreshSoundEnvs(CCommandVar p1, CCommandVar p2) CCommandVar CommandRefreshSoundEnvGeometry(CCommandVar p1, CCommandVar p2) { LSndLib->RefreshEnvGeometry(); - return TRUE; + return TRUE; } + CCommandVar CommandShowContextMenu(CCommandVar p1, CCommandVar p2) { - LUI->ShowContextMenu (p1); - return TRUE; + LUI->ShowContextMenu(p1); + return TRUE; } + //------ CCommandVar CommandRefreshUIBar(CCommandVar p1, CCommandVar p2) { - fraTopBar->RefreshBar (); - fraLeftBar->RefreshBar (); - fraBottomBar->RefreshBar (); - return TRUE; + fraTopBar->RefreshBar(); + fraLeftBar->RefreshBar(); + fraBottomBar->RefreshBar(); + return TRUE; } + CCommandVar CommandRestoreUIBar(CCommandVar p1, CCommandVar p2) { fraTopBar->fsStorage->RestoreFormPlacement(); fraLeftBar->fsStorage->RestoreFormPlacement(); fraBottomBar->fsStorage->RestoreFormPlacement(); - return TRUE; + return TRUE; } + CCommandVar CommandSaveUIBar(CCommandVar p1, CCommandVar p2) { fraTopBar->fsStorage->SaveFormPlacement(); fraLeftBar->fsStorage->SaveFormPlacement(); fraBottomBar->fsStorage->SaveFormPlacement(); - return TRUE; + return TRUE; } + CCommandVar CommandUpdateToolBar(CCommandVar p1, CCommandVar p2) { - fraLeftBar->UpdateBar (); - return TRUE; + fraLeftBar->UpdateBar(); + return TRUE; } + CCommandVar CommandUpdateCaption(CCommandVar p1, CCommandVar p2) { - frmMain->UpdateCaption (); - return TRUE; + frmMain->UpdateCaption(); + return TRUE; } + //------ CCommandVar CommandCreateSoundLib(CCommandVar p1, CCommandVar p2) { - SndLib = xr_new(); - return TRUE; + SndLib = xr_new(); + return TRUE; } extern BOOL ai_map_shown; + CCommandVar CommandToggleAiMapVisibility(CCommandVar p1, CCommandVar p2) { - ai_map_shown = !ai_map_shown; - return TRUE; + ai_map_shown = !ai_map_shown; + return TRUE; } void CLevelMain::RegisterCommands() { - inherited::RegisterCommands (); + inherited::RegisterCommands(); // tools - REGISTER_SUB_CMD_CE (COMMAND_CHANGE_TARGET, "Change Target", LTools,CLevelTool::CommandChangeTarget, true); - APPEND_SUB_CMD ("Object", OBJCLASS_SCENEOBJECT, 0); - APPEND_SUB_CMD ("Light", OBJCLASS_LIGHT, 0); - APPEND_SUB_CMD ("Sound Source", OBJCLASS_SOUND_SRC, 0); - APPEND_SUB_CMD ("Sound Env", OBJCLASS_SOUND_ENV, 0); - APPEND_SUB_CMD ("Glow", OBJCLASS_GLOW, 0); - APPEND_SUB_CMD ("Shape", OBJCLASS_SHAPE, 0); - APPEND_SUB_CMD ("Spawn Point", OBJCLASS_SPAWNPOINT, 0); - APPEND_SUB_CMD ("Way", OBJCLASS_WAY, 0); - APPEND_SUB_CMD ("Way Point", OBJCLASS_WAY, 1); - APPEND_SUB_CMD ("Toggle Way Mode", OBJCLASS_WAY, 2); - APPEND_SUB_CMD ("Sector", OBJCLASS_SECTOR, 0); - APPEND_SUB_CMD ("Portal", OBJCLASS_PORTAL, 0); - APPEND_SUB_CMD ("Group", OBJCLASS_GROUP, 0); - APPEND_SUB_CMD ("Particle System", OBJCLASS_PS, 0); - APPEND_SUB_CMD ("Detail Objects", OBJCLASS_DO, 0); - APPEND_SUB_CMD ("AI Map", OBJCLASS_AIMAP, 0); - APPEND_SUB_CMD ("Static Wallmark", OBJCLASS_WM, 0); - REGISTER_SUB_CMD_END; - REGISTER_CMD_C (COMMAND_ENABLE_TARGET, LTools,CLevelTool::CommandEnableTarget); - REGISTER_CMD_C (COMMAND_SHOW_TARGET, LTools,CLevelTool::CommandShowTarget); - REGISTER_CMD_C (COMMAND_READONLY_TARGET, LTools,CLevelTool::CommandReadonlyTarget); - REGISTER_CMD_C (COMMAND_MULTI_RENAME_OBJECTS, LTools,CLevelTool::CommandMultiRenameObjects); - - REGISTER_CMD_CE (COMMAND_SHOW_OBJECTLIST, "Scene\\Show Object List", LTools,CLevelTool::CommandShowObjectList, false); - // common - REGISTER_CMD_S (COMMAND_LIBRARY_EDITOR, CommandLibraryEditor); - REGISTER_CMD_S (COMMAND_LANIM_EDITOR, CommandLAnimEditor); - REGISTER_CMD_SE (COMMAND_FILE_MENU, "File\\Menu", CommandFileMenu, true); - REGISTER_CMD_S (COMMAND_LOAD_LEVEL_PART, CommandLoadLevelPart); - REGISTER_CMD_S (COMMAND_UNLOAD_LEVEL_PART, CommandUnloadLevelPart); - REGISTER_CMD_SE (COMMAND_LOAD, "File\\Load Level", CommandLoad, true); - REGISTER_SUB_CMD_SE (COMMAND_SAVE, "File", CommandSave, true); - APPEND_SUB_CMD ("Save", 0, 0); - APPEND_SUB_CMD ("Save As", 0, 1); + REGISTER_SUB_CMD_CE(COMMAND_CHANGE_TARGET, "Change Target", LTools, CLevelTool::CommandChangeTarget, true); + APPEND_SUB_CMD("Object", OBJCLASS_SCENEOBJECT, 0); + APPEND_SUB_CMD("Light", OBJCLASS_LIGHT, 0); + APPEND_SUB_CMD("Sound Source", OBJCLASS_SOUND_SRC, 0); + APPEND_SUB_CMD("Sound Env", OBJCLASS_SOUND_ENV, 0); + APPEND_SUB_CMD("Glow", OBJCLASS_GLOW, 0); + APPEND_SUB_CMD("Shape", OBJCLASS_SHAPE, 0); + APPEND_SUB_CMD("Spawn Point", OBJCLASS_SPAWNPOINT, 0); + APPEND_SUB_CMD("Way", OBJCLASS_WAY, 0); + APPEND_SUB_CMD("Way Point", OBJCLASS_WAY, 1); + APPEND_SUB_CMD("Toggle Way Mode", OBJCLASS_WAY, 2); + APPEND_SUB_CMD("Sector", OBJCLASS_SECTOR, 0); + APPEND_SUB_CMD("Portal", OBJCLASS_PORTAL, 0); + APPEND_SUB_CMD("Group", OBJCLASS_GROUP, 0); + APPEND_SUB_CMD("Particle System", OBJCLASS_PS, 0); + APPEND_SUB_CMD("Detail Objects", OBJCLASS_DO, 0); + APPEND_SUB_CMD("AI Map", OBJCLASS_AIMAP, 0); + APPEND_SUB_CMD("Static Wallmark", OBJCLASS_WM, 0); REGISTER_SUB_CMD_END; - REGISTER_CMD_S (COMMAND_SAVE_BACKUP, CommandSaveBackup); - REGISTER_CMD_SE (COMMAND_CLEAR, "File\\Clear Scene", CommandClear, true); - REGISTER_CMD_SE (COMMAND_LOAD_FIRSTRECENT, "File\\Load First Recent", CommandLoadFirstRecent, true); - REGISTER_CMD_S (COMMAND_CLEAR_DEBUG_DRAW, CommandClearDebugDraw); - REGISTER_CMD_S (COMMAND_IMPORT_COMPILER_ERROR, CommandImportCompilerError); - REGISTER_CMD_S (COMMAND_EXPORT_COMPILER_ERROR, CommandExportCompilerError); - REGISTER_CMD_S (COMMAND_VALIDATE_SCENE, CommandValidateScene); - REGISTER_CMD_S (COMMAND_CLEAN_LIBRARY, CommandCleanLibrary); - REGISTER_CMD_S (COMMAND_RELOAD_OBJECTS, CommandReloadObjects); - REGISTER_CMD_SE (COMMAND_CUT, "Edit\\Cut", CommandCut,false); - REGISTER_CMD_SE (COMMAND_COPY, "Edit\\Copy", CommandCopy,false); - REGISTER_CMD_SE (COMMAND_PASTE, "Edit\\Paste", CommandPaste,false); - REGISTER_CMD_S (COMMAND_LOAD_SELECTION, CommandLoadSelection); - REGISTER_CMD_S (COMMAND_SAVE_SELECTION, CommandSaveSelection); - REGISTER_CMD_SE (COMMAND_UNDO, "Edit\\Undo", CommandUndo,false); - REGISTER_CMD_SE (COMMAND_REDO, "Edit\\Redo", CommandRedo,false); - REGISTER_CMD_S (COMMAND_CLEAR_SCENE_SUMMARY, CommandClearSceneSummary); - REGISTER_CMD_S (COMMAND_COLLECT_SCENE_SUMMARY, CommandCollectSceneSummary); - REGISTER_CMD_S (COMMAND_SHOW_SCENE_SUMMARY, CommandShowSceneSummary); - REGISTER_CMD_S (COMMAND_EXPORT_SCENE_SUMMARY, CommandExportSceneSummary); - REGISTER_CMD_S (COMMAND_SCENE_HIGHLIGHT_TEXTURE, CommandSceneHighlightTexture); - REGISTER_CMD_SE (COMMAND_OPTIONS, "Scene\\Options", CommandOptions,false); - REGISTER_CMD_SE (COMMAND_BUILD, "Compile\\Build", CommandBuild,false); - REGISTER_CMD_SE (COMMAND_MAKE_GAME, "Compile\\Make Game", CommandMakeGame,false); - REGISTER_CMD_SE (COMMAND_MAKE_AIMAP, "Compile\\Make AI Map", CommandMakeAIMap,false); - REGISTER_CMD_SE (COMMAND_MAKE_DETAILS, "Compile\\Make Details", CommandMakeDetails,false); - REGISTER_CMD_SE (COMMAND_MAKE_HOM, "Compile\\Make HOM", CommandMakeHOM,false); - REGISTER_CMD_SE (COMMAND_MAKE_SOM, "Compile\\Make SOM", CommandMakeSOM,false); - REGISTER_CMD_SE (COMMAND_INVERT_SELECTION_ALL, "Selection\\Invert", CommandInvertSelectionAll,false); - REGISTER_CMD_SE (COMMAND_SELECT_ALL, "Selection\\Select All", CommandSelectAll,false); - REGISTER_CMD_SE (COMMAND_DESELECT_ALL, "Selection\\Unselect All", CommandDeselectAll,false); - REGISTER_CMD_SE (COMMAND_DELETE_SELECTION, "Edit\\Delete", CommandDeleteSelection,false); - REGISTER_CMD_SE (COMMAND_HIDE_UNSEL, "Visibility\\Hide Unselected", CommandHideUnsel,false); - REGISTER_CMD_SE (COMMAND_HIDE_SEL, "Visibility\\Hide Selected", CommandHideSel,false); - REGISTER_CMD_SE (COMMAND_HIDE_ALL, "Visibility\\Hide All", CommandHideAll,false); - REGISTER_CMD_S (COMMAND_SET_SNAP_OBJECTS, CommandSetSnapObjects); - REGISTER_CMD_S (COMMAND_ADD_SEL_SNAP_OBJECTS, CommandAddSelSnapObjects); - REGISTER_CMD_S (COMMAND_DEL_SEL_SNAP_OBJECTS, CommandDelSelSnapObjects); - REGISTER_CMD_S (COMMAND_CLEAR_SNAP_OBJECTS, CommandClearSnapObjects); - REGISTER_CMD_S (COMMAND_SELECT_SNAP_OBJECTS, CommandSelectSnapObjects); - REGISTER_CMD_S (COMMAND_REFRESH_SNAP_OBJECTS, CommandRefreshSnapObjects); -// REGISTER_CMD_S (COMMAND_REFRESH_SOUND_ENVS, CommandRefreshSoundEnvs); - REGISTER_CMD_S (COMMAND_REFRESH_SOUND_ENV_GEOMETRY,CommandRefreshSoundEnvGeometry); - REGISTER_CMD_S (COMMAND_SHOWCONTEXTMENU, CommandShowContextMenu); - REGISTER_CMD_S (COMMAND_REFRESH_UI_BAR, CommandRefreshUIBar); - REGISTER_CMD_S (COMMAND_RESTORE_UI_BAR, CommandRestoreUIBar); - REGISTER_CMD_S (COMMAND_SAVE_UI_BAR, CommandSaveUIBar); - REGISTER_CMD_S (COMMAND_UPDATE_TOOLBAR, CommandUpdateToolBar); - REGISTER_CMD_S (COMMAND_UPDATE_CAPTION, CommandUpdateCaption); - REGISTER_CMD_S (COMMAND_CREATE_SOUND_LIB, CommandCreateSoundLib); - REGISTER_CMD_SE (COMMAND_TOGGLE_AIMAP_VISIBILITY, "Visibility\\Toggle AIMap", CommandToggleAiMapVisibility,true); - REGISTER_CMD_S (COMMAND_SHOW_CLIP_EDITOR, CommandShowClipEditor); - -} - -char* CLevelMain::GetCaption() -{ - return Tools->m_LastFileName.IsEmpty()?"noname":Tools->m_LastFileName.c_str(); + REGISTER_CMD_C(COMMAND_ENABLE_TARGET, LTools, CLevelTool::CommandEnableTarget); + REGISTER_CMD_C(COMMAND_SHOW_TARGET, LTools, CLevelTool::CommandShowTarget); + REGISTER_CMD_C(COMMAND_READONLY_TARGET, LTools, CLevelTool::CommandReadonlyTarget); + REGISTER_CMD_C(COMMAND_MULTI_RENAME_OBJECTS, LTools, CLevelTool::CommandMultiRenameObjects); + + REGISTER_CMD_CE(COMMAND_SHOW_OBJECTLIST, "Scene\\Show Object List", LTools, CLevelTool::CommandShowObjectList, false); + // common + REGISTER_CMD_S(COMMAND_LIBRARY_EDITOR, CommandLibraryEditor); + REGISTER_CMD_S(COMMAND_LANIM_EDITOR, CommandLAnimEditor); + REGISTER_CMD_SE(COMMAND_FILE_MENU, "File\\Menu", CommandFileMenu, true); + REGISTER_CMD_S(COMMAND_LOAD_LEVEL_PART, CommandLoadLevelPart); + REGISTER_CMD_S(COMMAND_UNLOAD_LEVEL_PART, CommandUnloadLevelPart); + REGISTER_CMD_SE(COMMAND_LOAD, "File\\Load Level", CommandLoad, true); + REGISTER_SUB_CMD_SE(COMMAND_SAVE, "File", CommandSave, true); + APPEND_SUB_CMD("Save", 0, 0); + APPEND_SUB_CMD("Save As", 0, 1); + REGISTER_SUB_CMD_END; + REGISTER_CMD_S(COMMAND_SAVE_BACKUP, CommandSaveBackup); + REGISTER_CMD_SE(COMMAND_CLEAR, "File\\Clear Scene", CommandClear, true); + REGISTER_CMD_SE(COMMAND_LOAD_FIRSTRECENT, "File\\Load First Recent", CommandLoadFirstRecent, true); + REGISTER_CMD_S(COMMAND_CLEAR_DEBUG_DRAW, CommandClearDebugDraw); + REGISTER_CMD_S(COMMAND_IMPORT_COMPILER_ERROR, CommandImportCompilerError); + REGISTER_CMD_S(COMMAND_EXPORT_COMPILER_ERROR, CommandExportCompilerError); + REGISTER_CMD_S(COMMAND_VALIDATE_SCENE, CommandValidateScene); + REGISTER_CMD_S(COMMAND_CLEAN_LIBRARY, CommandCleanLibrary); + REGISTER_CMD_S(COMMAND_RELOAD_OBJECTS, CommandReloadObjects); + REGISTER_CMD_SE(COMMAND_CUT, "Edit\\Cut", CommandCut, false); + REGISTER_CMD_SE(COMMAND_COPY, "Edit\\Copy", CommandCopy, false); + REGISTER_CMD_SE(COMMAND_PASTE, "Edit\\Paste", CommandPaste, false); + REGISTER_CMD_S(COMMAND_LOAD_SELECTION, CommandLoadSelection); + REGISTER_CMD_S(COMMAND_SAVE_SELECTION, CommandSaveSelection); + REGISTER_CMD_SE(COMMAND_UNDO, "Edit\\Undo", CommandUndo, false); + REGISTER_CMD_SE(COMMAND_REDO, "Edit\\Redo", CommandRedo, false); + REGISTER_CMD_S(COMMAND_CLEAR_SCENE_SUMMARY, CommandClearSceneSummary); + REGISTER_CMD_S(COMMAND_COLLECT_SCENE_SUMMARY, CommandCollectSceneSummary); + REGISTER_CMD_S(COMMAND_SHOW_SCENE_SUMMARY, CommandShowSceneSummary); + REGISTER_CMD_S(COMMAND_EXPORT_SCENE_SUMMARY, CommandExportSceneSummary); + REGISTER_CMD_S(COMMAND_SCENE_HIGHLIGHT_TEXTURE, CommandSceneHighlightTexture); + REGISTER_CMD_SE(COMMAND_OPTIONS, "Scene\\Options", CommandOptions, false); + REGISTER_CMD_SE(COMMAND_BUILD, "Compile\\Build", CommandBuild, false); + REGISTER_CMD_SE(COMMAND_MAKE_GAME, "Compile\\Make Game", CommandMakeGame, false); + REGISTER_CMD_SE(COMMAND_MAKE_AIMAP, "Compile\\Make AI Map", CommandMakeAIMap, false); + REGISTER_CMD_SE(COMMAND_MAKE_DETAILS, "Compile\\Make Details", CommandMakeDetails, false); + REGISTER_CMD_SE(COMMAND_MAKE_HOM, "Compile\\Make HOM", CommandMakeHOM, false); + REGISTER_CMD_SE(COMMAND_MAKE_SOM, "Compile\\Make SOM", CommandMakeSOM, false); + REGISTER_CMD_SE(COMMAND_INVERT_SELECTION_ALL, "Selection\\Invert", CommandInvertSelectionAll, false); + REGISTER_CMD_SE(COMMAND_SELECT_ALL, "Selection\\Select All", CommandSelectAll, false); + REGISTER_CMD_SE(COMMAND_DESELECT_ALL, "Selection\\Unselect All", CommandDeselectAll, false); + REGISTER_CMD_SE(COMMAND_DELETE_SELECTION, "Edit\\Delete", CommandDeleteSelection, false); + REGISTER_CMD_SE(COMMAND_HIDE_UNSEL, "Visibility\\Hide Unselected", CommandHideUnsel, false); + REGISTER_CMD_SE(COMMAND_HIDE_SEL, "Visibility\\Hide Selected", CommandHideSel, false); + REGISTER_CMD_SE(COMMAND_HIDE_ALL, "Visibility\\Hide All", CommandHideAll, false); + REGISTER_CMD_S(COMMAND_SET_SNAP_OBJECTS, CommandSetSnapObjects); + REGISTER_CMD_S(COMMAND_ADD_SEL_SNAP_OBJECTS, CommandAddSelSnapObjects); + REGISTER_CMD_S(COMMAND_DEL_SEL_SNAP_OBJECTS, CommandDelSelSnapObjects); + REGISTER_CMD_S(COMMAND_CLEAR_SNAP_OBJECTS, CommandClearSnapObjects); + REGISTER_CMD_S(COMMAND_SELECT_SNAP_OBJECTS, CommandSelectSnapObjects); + REGISTER_CMD_S(COMMAND_REFRESH_SNAP_OBJECTS, CommandRefreshSnapObjects); + // REGISTER_CMD_S (COMMAND_REFRESH_SOUND_ENVS, CommandRefreshSoundEnvs); + REGISTER_CMD_S(COMMAND_REFRESH_SOUND_ENV_GEOMETRY, CommandRefreshSoundEnvGeometry); + REGISTER_CMD_S(COMMAND_SHOWCONTEXTMENU, CommandShowContextMenu); + REGISTER_CMD_S(COMMAND_REFRESH_UI_BAR, CommandRefreshUIBar); + REGISTER_CMD_S(COMMAND_RESTORE_UI_BAR, CommandRestoreUIBar); + REGISTER_CMD_S(COMMAND_SAVE_UI_BAR, CommandSaveUIBar); + REGISTER_CMD_S(COMMAND_UPDATE_TOOLBAR, CommandUpdateToolBar); + REGISTER_CMD_S(COMMAND_UPDATE_CAPTION, CommandUpdateCaption); + REGISTER_CMD_S(COMMAND_CREATE_SOUND_LIB, CommandCreateSoundLib); + REGISTER_CMD_SE(COMMAND_TOGGLE_AIMAP_VISIBILITY, "Visibility\\Toggle AIMap", CommandToggleAiMapVisibility, true); + REGISTER_CMD_S(COMMAND_SHOW_CLIP_EDITOR, CommandShowClipEditor); +} + +char *CLevelMain::GetCaption() +{ + return Tools->m_LastFileName.IsEmpty() ? "noname" : Tools->m_LastFileName.c_str(); } bool __fastcall CLevelMain::ApplyShortCut(WORD Key, TShiftState Shift) { - return inherited::ApplyShortCut(Key,Shift); + return inherited::ApplyShortCut(Key, Shift); } + //--------------------------------------------------------------------------- bool __fastcall CLevelMain::ApplyGlobalShortCut(WORD Key, TShiftState Shift) { - return inherited::ApplyGlobalShortCut(Key,Shift); + return inherited::ApplyGlobalShortCut(Key, Shift); } + //--------------------------------------------------------------------------- -void RetrieveSceneObjPointAndNormal( Fvector& hitpoint, Fvector* hitnormal, const SRayPickInfo &pinf, int bSnap ) +void RetrieveSceneObjPointAndNormal(Fvector &hitpoint, Fvector *hitnormal, const SRayPickInfo &pinf, int bSnap) { - if(pinf.e_mesh == 0) + if (pinf.e_mesh==0) { - hitpoint = pinf.pt; - if (hitnormal && pinf.visual_inf.K ) - *hitnormal = pinf.visual_inf.normal; - return; + hitpoint = pinf.pt; + if (hitnormal&&pinf.visual_inf.K) + *hitnormal = pinf.visual_inf.normal; + return; } - if ( Tools->GetSettings(etfVSnap) && bSnap ) + if (Tools->GetSettings(etfVSnap)&&bSnap) { - Fvector pn; + Fvector pn; float u = pinf.inf.u; float v = pinf.inf.v; float w = 1-(u+v); Fvector verts[3]; - pinf.e_obj->GetFaceWorld( pinf.s_obj->_Transform(), pinf.e_mesh, pinf.inf.id, verts ); - - if ((w>u) && (w>v)) - pn.set(verts[0]); - else if ((u>w) && (u>v)) - pn.set(verts[1]); + pinf.e_obj->GetFaceWorld(pinf.s_obj->_Transform(), pinf.e_mesh, pinf.inf.id, verts); + + if ((w>u)&&(w>v)) + pn.set(verts[0]); + else if ((u>w)&&(u>v)) + pn.set(verts[1]); else - pn.set(verts[2]); - - if (pn.distance_to(pinf.pt) < LTools->m_MoveSnap) - hitpoint.set(pn); + pn.set(verts[2]); + + if (pn.distance_to(pinf.pt)m_MoveSnap) + hitpoint.set(pn); else - hitpoint.set(pinf.pt); - + hitpoint.set(pinf.pt); } else { - hitpoint.set(pinf.pt); + hitpoint.set(pinf.pt); } if (hitnormal) { - Fvector verts[3]; - pinf.e_obj->GetFaceWorld(pinf.s_obj->_Transform(),pinf.e_mesh,pinf.inf.id,verts); - hitnormal->mknormal(verts[0],verts[1],verts[2]); + Fvector verts[3]; + pinf.e_obj->GetFaceWorld(pinf.s_obj->_Transform(), pinf.e_mesh, pinf.inf.id, verts); + hitnormal->mknormal(verts[0], verts[1], verts[2]); } } -bool EditLibPickObjectGeometry( Fvector& hitpoint, const Fvector& start, const Fvector& direction, int bSnap, Fvector* hitnormal ) +bool EditLibPickObjectGeometry(Fvector &hitpoint, const Fvector &start, const Fvector &direction, int bSnap, Fvector *hitnormal) { - SRayPickInfo pinf; - if( TfrmEditLibrary::RayPick( start, direction, &pinf ) ) + SRayPickInfo pinf; + if (TfrmEditLibrary::RayPick(start, direction, &pinf)) { - RetrieveSceneObjPointAndNormal( hitpoint, hitnormal, pinf, bSnap ); + RetrieveSceneObjPointAndNormal(hitpoint, hitnormal, pinf, bSnap); return true; } return false; } -bool ScenePickObjectGeometry( Fvector& hitpoint, const Fvector& start, const Fvector& direction, int bSnap, Fvector* hitnormal ) +bool ScenePickObjectGeometry(Fvector &hitpoint, const Fvector &start, const Fvector &direction, int bSnap, Fvector *hitnormal) { + SRayPickInfo pinf; - SRayPickInfo pinf; - SRayPickInfo l_pinf; bool bResult = false; { - SRayPickInfo l_pinf; - bool l_bres = Scene->RayPickObject( l_pinf.inf.range, start,direction, OBJCLASS_SPAWNPOINT , &l_pinf, Scene->GetSnapList(false) ); - - if( l_bres ) - { - pinf = l_pinf; - bResult = true; - } - + SRayPickInfo l_pinf; + bool l_bres = Scene->RayPickObject(l_pinf.inf.range, start, direction, OBJCLASS_SPAWNPOINT, &l_pinf, Scene->GetSnapList(false)); + + if (l_bres) + { + pinf = l_pinf; + bResult = true; + } } { - - SRayPickInfo l_pinf; - bool l_bres = Scene->RayPickObject( l_pinf.inf.range, start, direction, OBJCLASS_SCENEOBJECT , &l_pinf, Scene->GetSnapList(false) ); + SRayPickInfo l_pinf; + bool l_bres = Scene->RayPickObject(l_pinf.inf.range, start, direction, OBJCLASS_SCENEOBJECT, &l_pinf, Scene->GetSnapList(false)); - if( !bResult||(l_bres && l_pinf.inf.range < pinf.inf.range) ) - pinf = l_pinf; - if( l_bres ) - bResult = true; - + if (!bResult||(l_bres&&l_pinf.inf.rangeGetSettings(etfGSnap) && bSnap) + hitpoint.x = start.x+direction.x*alpha; + hitpoint.y = start.y+direction.y*alpha; + hitpoint.z = start.z+direction.z*alpha; + + if (Tools->GetSettings(etfGSnap)&&bSnap) { - hitpoint.x = snapto( hitpoint.x, LTools->m_MoveSnap ); - hitpoint.z = snapto( hitpoint.z, LTools->m_MoveSnap ); + hitpoint.x = snapto(hitpoint.x, LTools->m_MoveSnap); + hitpoint.z = snapto(hitpoint.z, LTools->m_MoveSnap); hitpoint.y = 0.f; } - - if (hitnormal) - hitnormal->set(0,1,0); - return true; + + if (hitnormal) + hitnormal->set(0, 1, 0); + return true; } -bool CLevelMain::PickGround(Fvector& hitpoint, const Fvector& start, const Fvector& direction, int bSnap, Fvector* hitnormal){ - VERIFY(m_bReady); - +bool CLevelMain::PickGround(Fvector &hitpoint, const Fvector &start, const Fvector &direction, int bSnap, Fvector *hitnormal) +{ + VERIFY(m_bReady); + EEditorState est = GetEState(); - if( est!= esEditLibrary && est != esEditScene ) - return false; - + if (est!=esEditLibrary&&est!=esEditScene) + return false; + // pick object geometry - if( (bSnap==-1) || ( Tools->GetSettings(etfOSnap) && (bSnap==1) ) ) + if ((bSnap==-1)||(Tools->GetSettings(etfOSnap)&&(bSnap==1))) { - bool b = PickObjectGeometry( est, hitpoint, start, direction, bSnap, hitnormal ); - if(b) - return true; + bool b = PickObjectGeometry(est, hitpoint, start, direction, bSnap, hitnormal); + if (b) + return true; } - return PickGrid( hitpoint, start, direction, bSnap, hitnormal ); - + return PickGrid(hitpoint, start, direction, bSnap, hitnormal); } + //---------------------------------------------------- -bool CLevelMain::SelectionFrustum(CFrustum& frustum) +bool CLevelMain::SelectionFrustum(CFrustum &frustum) { - VERIFY(m_bReady); - Fvector st,d,p[4]; + VERIFY(m_bReady); + Fvector st, d, p[4]; Ivector2 pt[4]; float depth = 0; - float x1=m_StartCp.x, x2=m_CurrentCp.x; - float y1=m_StartCp.y, y2=m_CurrentCp.y; + float x1 = m_StartCp.x, x2 = m_CurrentCp.x; + float y1 = m_StartCp.y, y2 = m_CurrentCp.y; - if(!(x1!=x2&&y1!=y2)) return false; + if (!(x1!=x2&&y1!=y2)) + return false; - pt[0].set(_min(x1,x2),_min(y1,y2)); - pt[1].set(_max(x1,x2),_min(y1,y2)); - pt[2].set(_max(x1,x2),_max(y1,y2)); - pt[3].set(_min(x1,x2),_max(y1,y2)); + pt[0].set(_min(x1, x2), _min(y1, y2)); + pt[1].set(_max(x1, x2), _min(y1, y2)); + pt[2].set(_max(x1, x2), _max(y1, y2)); + pt[3].set(_min(x1, x2), _max(y1, y2)); SRayPickInfo pinf; - for (int i=0; i<4; i++){ - EDevice.m_Camera.MouseRayFromPoint(st, d, pt[i]); - if (EPrefs->bp_lim_depth){ - pinf.inf.range = EDevice.m_Camera._Zfar(); // max pick range + for (int i = 0; i<4; i++) + { + EDevice.m_Camera.MouseRayFromPoint(st, d, pt[i]); + if (EPrefs->bp_lim_depth) + { + pinf.inf.range = EDevice.m_Camera._Zfar(); // max pick range if (Scene->RayPickObject(pinf.inf.range, st, d, OBJCLASS_SCENEOBJECT, &pinf, 0)) - if (pinf.inf.range > depth) depth = pinf.inf.range; + if (pinf.inf.range>depth) + depth = pinf.inf.range; } } - if (depthbp_depth_tolerance; + if (depthbp_depth_tolerance; - for (i=0; i<4; i++){ - EDevice.m_Camera.MouseRayFromPoint(st, d, pt[i]); - p[i].mad(st,d,depth); + for (i = 0; i<4; i++) + { + EDevice.m_Camera.MouseRayFromPoint(st, d, pt[i]); + p[i].mad(st, d, depth); } Fvector pos = EDevice.m_Camera.GetPosition(); - frustum.CreateFromPoints(p,4,pos); + frustum.CreateFromPoints(p, 4, pos); - Fplane P; P.build(p[0],p[1],p[2]); - if (P.classify(st)>0) P.build(p[2],p[1],p[0]); - frustum._add(P); + Fplane P; + P.build(p[0], p[1], p[2]); + if (P.classify(st)>0) + P.build(p[2], p[1], p[0]); + frustum._add(P); - return true; + return true; } + //---------------------------------------------------- void CLevelMain::RealUpdateScene() { - inherited::RealUpdateScene (); - if (GetEState()==esEditScene){ - Scene->OnObjectsUpdate (); - LTools->OnObjectsUpdate (); // îáíîâèòü âñå ÷òî êàê-òî ñâÿçàíî ñ îáúåêòàìè - RedrawScene (); + inherited::RealUpdateScene(); + if (GetEState()==esEditScene) + { + Scene->OnObjectsUpdate(); + LTools->OnObjectsUpdate(); // îáíîâèòü âñå ÷òî êàê-òî ñâÿçàíî ñ îáúåêòàìè + RedrawScene(); } } + //--------------------------------------------------------------------------- void CLevelMain::ShowContextMenu(int cls) { - VERIFY(m_bReady); + VERIFY(m_bReady); POINT pt; GetCursorPos(&pt); fraLeftBar->miProperties->Enabled = false; - if (Scene->SelectionCount( true, cls )) fraLeftBar->miProperties->Enabled = true; + if (Scene->SelectionCount(true, cls)) + fraLeftBar->miProperties->Enabled = true; RedrawScene(true); fraLeftBar->pmObjectContext->TrackButton = tbRightButton; - fraLeftBar->pmObjectContext->Popup(pt.x,pt.y); + fraLeftBar->pmObjectContext->Popup(pt.x, pt.y); } -//--------------------------------------------------------------------------- - +//--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -1220,103 +1403,123 @@ void CLevelMain::ShowContextMenu(int cls) //--------------------------------------------------------------------------- void CLevelMain::ResetStatus() { - VERIFY(m_bReady); - if (fraBottomBar->paStatus->Caption!=""){ - fraBottomBar->paStatus->Caption=""; fraBottomBar->paStatus->Repaint(); + VERIFY(m_bReady); + if (fraBottomBar->paStatus->Caption!="") + { + fraBottomBar->paStatus->Caption = ""; + fraBottomBar->paStatus->Repaint(); } } + void CLevelMain::SetStatus(LPSTR s, bool bOutLog) { - VERIFY(m_bReady); - if (fraBottomBar->paStatus->Caption!=s){ - fraBottomBar->paStatus->Caption=s; fraBottomBar->paStatus->Repaint(); - if (bOutLog&&s&&s[0]) ELog.Msg(mtInformation,s); + VERIFY(m_bReady); + if (fraBottomBar->paStatus->Caption!=s) + { + fraBottomBar->paStatus->Caption = s; + fraBottomBar->paStatus->Repaint(); + if (bOutLog&&s&&s[0]) + ELog.Msg(mtInformation, s); } } + void CLevelMain::ProgressDraw() { - fraBottomBar->RedrawBar(); + fraBottomBar->RedrawBar(); } + //--------------------------------------------------------------------------- void CLevelMain::OutCameraPos() { - if (m_bReady){ + if (m_bReady) + { AnsiString s; - const Fvector& c = EDevice.m_Camera.GetPosition(); - s.sprintf("C: %3.1f, %3.1f, %3.1f",c.x,c.y,c.z); - // const Fvector& hpb = EDevice.m_Camera.GetHPB(); - // s.sprintf(" Cam: %3.1f°, %3.1f°, %3.1f°",rad2deg(hpb.y),rad2deg(hpb.x),rad2deg(hpb.z)); - fraBottomBar->paCamera->Caption=s; fraBottomBar->paCamera->Repaint(); + const Fvector &c = EDevice.m_Camera.GetPosition(); + s.sprintf("C: %3.1f, %3.1f, %3.1f", c.x, c.y, c.z); + // const Fvector& hpb = EDevice.m_Camera.GetHPB(); + // s.sprintf(" Cam: %3.1f°, %3.1f°, %3.1f°",rad2deg(hpb.y),rad2deg(hpb.x),rad2deg(hpb.z)); + fraBottomBar->paCamera->Caption = s; + fraBottomBar->paCamera->Repaint(); } } + //--------------------------------------------------------------------------- void CLevelMain::OutUICursorPos() { - VERIFY(fraBottomBar); - AnsiString s; POINT pt; + VERIFY(fraBottomBar); + AnsiString s; + POINT pt; GetCursorPos(&pt); - s.sprintf("Cur: %d, %d",pt.x,pt.y); - fraBottomBar->paUICursor->Caption=s; fraBottomBar->paUICursor->Repaint(); + s.sprintf("Cur: %d, %d", pt.x, pt.y); + fraBottomBar->paUICursor->Caption = s; + fraBottomBar->paUICursor->Repaint(); } + //--------------------------------------------------------------------------- void CLevelMain::OutGridSize() { - VERIFY(fraBottomBar); + VERIFY(fraBottomBar); AnsiString s; - s.sprintf("Grid: %1.1f",EPrefs->grid_cell_size); - fraBottomBar->paGridSquareSize->Caption=s; fraBottomBar->paGridSquareSize->Repaint(); + s.sprintf("Grid: %1.1f", EPrefs->grid_cell_size); + fraBottomBar->paGridSquareSize->Caption = s; + fraBottomBar->paGridSquareSize->Repaint(); } + //--------------------------------------------------------------------------- void CLevelMain::OutInfo() { - fraBottomBar->paSel->Caption = Tools->GetInfo(); + fraBottomBar->paSel->Caption = Tools->GetInfo(); } + //--------------------------------------------------------------------------- void CLevelMain::RealQuit() { - frmMain->Close(); + frmMain->Close(); } + //--------------------------------------------------------------------------- #define INI_RTP_NAME(buf) {FS.update_path(buf,"$local_root$","rt_object_props.ltx");} -void CLevelMain::SaveSettings(CInifile* I) +void CLevelMain::SaveSettings(CInifile *I) { - m_rt_object_props->save_as(); - - inherited::SaveSettings(I); + m_rt_object_props->save_as(); + + inherited::SaveSettings(I); SSceneSummary::Save(I); } -void CLevelMain::LoadSettings(CInifile* I) + +void CLevelMain::LoadSettings(CInifile *I) { - string_path fn; - INI_RTP_NAME (fn); - m_rt_object_props = CInifile::Create(fn,FALSE); - m_rt_object_props->save_at_end(FALSE); - - inherited::LoadSettings(I); + string_path fn; + INI_RTP_NAME (fn); + m_rt_object_props = CInifile::Create(fn, FALSE); + m_rt_object_props->save_at_end(FALSE); + + inherited::LoadSettings(I); SSceneSummary::Load(I); } -void CLevelMain::store_rt_flags(const CCustomObject* CO) +void CLevelMain::store_rt_flags(const CCustomObject *CO) { - if(LTools->m_LastFileName.Length() && CO->Name && xr_strlen(CO->Name) ) + if (LTools->m_LastFileName.Length()&&CO->Name&&xr_strlen(CO->Name)) { - m_rt_object_props->remove_line(LTools->m_LastFileName.c_str(), CO->Name); - if(CO->Selected() || !CO->Visible()) - m_rt_object_props->w_u32(LTools->m_LastFileName.c_str(), CO->Name, CO->m_RT_Flags.get()&(CCustomObject::flRT_Selected|CCustomObject::flRT_Visible)); + m_rt_object_props->remove_line(LTools->m_LastFileName.c_str(), CO->Name); + if (CO->Selected()||!CO->Visible()) + m_rt_object_props->w_u32(LTools->m_LastFileName.c_str(), CO->Name, CO->m_RT_Flags.get()&(CCustomObject::flRT_Selected|CCustomObject::flRT_Visible)); } } -void CLevelMain::restore_rt_flags(CCustomObject* CO) +void CLevelMain::restore_rt_flags(CCustomObject *CO) { - if(CO->Name && LTools->m_LastFileName.Length() && m_rt_object_props->line_exist(LTools->m_LastFileName.c_str(), CO->Name)) + if (CO->Name&<ools->m_LastFileName.Length()&&m_rt_object_props->line_exist(LTools->m_LastFileName.c_str(), CO->Name)) { - u32 fl = m_rt_object_props->r_u32(LTools->m_LastFileName.c_str(), CO->Name); - CO->m_RT_Flags.set (CCustomObject::flRT_Visible|CCustomObject::flRT_Selected|CCustomObject::flRT_SelectedLast, FALSE); - CO->m_RT_Flags.or (fl); + u32 fl = m_rt_object_props->r_u32(LTools->m_LastFileName.c_str(), CO->Name); + CO->m_RT_Flags.set(CCustomObject::flRT_Visible|CCustomObject::flRT_Selected|CCustomObject::flRT_SelectedLast, FALSE); + CO->m_RT_Flags.or(fl); } } //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/Edit/UI_LevelMain.h b/src/editors/LevelEditor/Edit/UI_LevelMain.h index 72a68882996..2ca9e0de1aa 100644 --- a/src/editors/LevelEditor/Edit/UI_LevelMain.h +++ b/src/editors/LevelEditor/Edit/UI_LevelMain.h @@ -1,122 +1,132 @@ #ifndef UI_LevelMainH #define UI_LevelMainH -#include "../ECore/Editor/ui_main.h" -#include "../ECore/Editor/UI_MainCommand.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/UI_MainCommand.h" -enum { - COMMAND_EXTFIRST_EXT = COMMAND_MAIN_LAST-1, +enum +{ + COMMAND_EXTFIRST_EXT = COMMAND_MAIN_LAST-1, - COMMAND_CHANGE_TARGET, - COMMAND_ENABLE_TARGET, - COMMAND_READONLY_TARGET, - COMMAND_SHOW_TARGET, + COMMAND_CHANGE_TARGET, + COMMAND_ENABLE_TARGET, + COMMAND_READONLY_TARGET, + COMMAND_SHOW_TARGET, - COMMAND_SHOW_OBJECTLIST, + COMMAND_SHOW_OBJECTLIST, COMMAND_MULTI_RENAME_OBJECTS, - COMMAND_REFRESH_SOUND_ENVS, + COMMAND_REFRESH_SOUND_ENVS, COMMAND_REFRESH_SOUND_ENV_GEOMETRY, - - COMMAND_CLEAN_LIBRARY, + + COMMAND_CLEAN_LIBRARY, COMMAND_LIBRARY_EDITOR, COMMAND_LANIM_EDITOR, COMMAND_FILE_MENU, - COMMAND_CLEAR_DEBUG_DRAW, + COMMAND_CLEAR_DEBUG_DRAW, COMMAND_IMPORT_COMPILER_ERROR, COMMAND_EXPORT_COMPILER_ERROR, - COMMAND_VALIDATE_SCENE, + COMMAND_VALIDATE_SCENE, COMMAND_RELOAD_OBJECTS, - COMMAND_CUT, - COMMAND_COPY, - COMMAND_PASTE, - COMMAND_LOAD_SELECTION, - COMMAND_SAVE_SELECTION, - COMMAND_LOAD_LEVEL_PART, - COMMAND_UNLOAD_LEVEL_PART, - + COMMAND_CUT, + COMMAND_COPY, + COMMAND_PASTE, + COMMAND_LOAD_SELECTION, + COMMAND_SAVE_SELECTION, + COMMAND_LOAD_LEVEL_PART, + COMMAND_UNLOAD_LEVEL_PART, + COMMAND_CLEAR_SCENE_SUMMARY, COMMAND_COLLECT_SCENE_SUMMARY, - COMMAND_SHOW_SCENE_SUMMARY, - COMMAND_EXPORT_SCENE_SUMMARY, + COMMAND_SHOW_SCENE_SUMMARY, + COMMAND_EXPORT_SCENE_SUMMARY, COMMAND_SCENE_HIGHLIGHT_TEXTURE, - COMMAND_OPTIONS, - COMMAND_BUILD, + COMMAND_OPTIONS, + COMMAND_BUILD, - COMMAND_MAKE_GAME, + COMMAND_MAKE_GAME, COMMAND_MAKE_DETAILS, - COMMAND_MAKE_HOM, + COMMAND_MAKE_HOM, COMMAND_MAKE_SOM, COMMAND_MAKE_AIMAP, - COMMAND_INVERT_SELECTION_ALL, - COMMAND_SELECT_ALL, - COMMAND_DESELECT_ALL, - COMMAND_DELETE_SELECTION, - COMMAND_HIDE_UNSEL, - COMMAND_HIDE_SEL, - COMMAND_HIDE_ALL, + COMMAND_INVERT_SELECTION_ALL, + COMMAND_SELECT_ALL, + COMMAND_DESELECT_ALL, + COMMAND_DELETE_SELECTION, + COMMAND_HIDE_UNSEL, + COMMAND_HIDE_SEL, + COMMAND_HIDE_ALL, COMMAND_SET_SNAP_OBJECTS, COMMAND_ADD_SEL_SNAP_OBJECTS, - COMMAND_DEL_SEL_SNAP_OBJECTS, + COMMAND_DEL_SEL_SNAP_OBJECTS, COMMAND_CLEAR_SNAP_OBJECTS, - COMMAND_SELECT_SNAP_OBJECTS, - COMMAND_REFRESH_SNAP_OBJECTS, + COMMAND_SELECT_SNAP_OBJECTS, + COMMAND_REFRESH_SNAP_OBJECTS, COMMAND_LOAD_FIRSTRECENT, COMMAND_SHOWCONTEXTMENU, COMMAND_SHOW_CLIP_EDITOR, }; + //------------------------------------------------------------------------------ -class CLevelMain: public TUI{ - typedef TUI inherited; - - virtual void RealUpdateScene (); - virtual void RealQuit (); +class CLevelMain: public TUI +{ + typedef TUI inherited; + + virtual void RealUpdateScene(); + virtual void RealQuit(); public: - CInifile* m_rt_object_props; - C3DCursor* m_Cursor; + CInifile *m_rt_object_props; + C3DCursor *m_Cursor; public: - CLevelMain (); - virtual ~CLevelMain (); + CLevelMain(); + virtual ~CLevelMain(); - void store_rt_flags (const CCustomObject* CO); - void restore_rt_flags (CCustomObject* CO); + void store_rt_flags(const CCustomObject *CO); + void restore_rt_flags(CCustomObject *CO); - virtual LPSTR GetCaption (); + virtual LPSTR GetCaption(); - virtual void ResetStatus (); - virtual void SetStatus (LPSTR s, bool bOutLog=true); - virtual void ProgressDraw (); - virtual void OutCameraPos (); - virtual void OutUICursorPos (); - virtual void OutGridSize (); - virtual void OutInfo (); + virtual void ResetStatus(); + virtual void SetStatus(LPSTR s, bool bOutLog = true); + virtual void ProgressDraw(); + virtual void OutCameraPos(); + virtual void OutUICursorPos(); + virtual void OutGridSize(); + virtual void OutInfo(); - virtual LPCSTR EditorName (){return "level";} - virtual LPCSTR EditorDesc (){return "Level Editor";} + virtual LPCSTR EditorName() + { + return "level"; + } - void ShowContextMenu (int cls); - bool PickGround (Fvector& hitpoint, const Fvector& start, const Fvector& direction, int bSnap=1, Fvector* hitnormal=0); - bool SelectionFrustum (CFrustum& frustum); + virtual LPCSTR EditorDesc() + { + return "Level Editor"; + } - virtual bool ApplyShortCut (WORD Key, TShiftState Shift); - virtual bool ApplyGlobalShortCut (WORD Key, TShiftState Shift); + void ShowContextMenu(int cls); + bool PickGround(Fvector &hitpoint, const Fvector &start, const Fvector &direction, int bSnap = 1, Fvector *hitnormal = 0); + bool SelectionFrustum(CFrustum &frustum); + + virtual bool ApplyShortCut(WORD Key, TShiftState Shift); + virtual bool ApplyGlobalShortCut(WORD Key, TShiftState Shift); // commands - virtual void RegisterCommands (); + virtual void RegisterCommands(); + + virtual void SaveSettings(CInifile *); + virtual void LoadSettings(CInifile *); +}; - virtual void SaveSettings (CInifile*); - virtual void LoadSettings (CInifile*); -}; -extern CLevelMain*& LUI; +extern CLevelMain *&LUI; #endif //UI_MainCommandH - diff --git a/src/editors/LevelEditor/Edit/UI_LevelTools.cpp b/src/editors/LevelEditor/Edit/UI_LevelTools.cpp index 54cde695155..6c8cee62c42 100644 --- a/src/editors/LevelEditor/Edit/UI_LevelTools.cpp +++ b/src/editors/LevelEditor/Edit/UI_LevelTools.cpp @@ -3,536 +3,613 @@ #include "UI_LevelTools.h" #include "ESceneControlsCustom.h" -#include "cursor3d.h" +#include "Cursor3D.h" #include "LeftBar.h" #include "Scene.h" -#include "ui_levelmain.h" +#include "UI_LevelMain.h" -#include "editlibrary.h" +#include "EditLibrary.h" #include "ObjectList.h" -#include "igame_persistent.h" +#include "xrEngine/IGame_Persistent.h" #include "Builder.h" #include "lephysics.h" #define DETACH_FRAME(a) if (a){ (a)->Hide(); (a)->Parent = NULL; } -#define ATTACH_FRAME(a,b) if (a){ (a)->Parent=(b);(a)->Show(); } +#define ATTACH_FRAME(a,b) if (a){ (a)->Parent=(b);(a)->Show(); } -CLevelTool*& LTools=(CLevelTool*)Tools; +CLevelTool *<ools = (CLevelTool*)Tools; TShiftState ssRBOnly; + //--------------------------------------------------------------------------- CLevelTool::CLevelTool() { - fFogness = 0.9f; - dwFogColor = 0xffffffff; + fFogness = 0.9f; + dwFogColor = 0xffffffff; m_Flags.zero(); } + //--------------------------------------------------------------------------- -CLevelTool::~CLevelTool() -{ -} +CLevelTool::~CLevelTool() {} + //--------------------------------------------------------------------------- -TForm* CLevelTool::GetFrame() +TForm *CLevelTool::GetFrame() { - if (pCurTool) - return pCurTool->pFrame; - + if (pCurTool) + return pCurTool->pFrame; + return 0; } + //--------------------------------------------------------------------------- bool CLevelTool::OnCreate() { - inherited::OnCreate(); - target = OBJCLASS_DUMMY; - sub_target = -1; - pCurTool = 0; - ssRBOnly << ssRight; - paParent = fraLeftBar->paFrames; VERIFY(paParent); - m_Flags.set (flChangeAction,FALSE); - m_Flags.set (flChangeTarget,FALSE); + inherited::OnCreate(); + target = OBJCLASS_DUMMY; + sub_target = -1; + pCurTool = 0; + ssRBOnly<paFrames; + VERIFY(paParent); + m_Flags.set(flChangeAction, FALSE); + m_Flags.set(flChangeTarget, FALSE); // scene creating - Scene->OnCreate (); + Scene->OnCreate(); // change target to Object - ExecCommand (COMMAND_CHANGE_TARGET, OBJCLASS_SCENEOBJECT); - m_Props = TProperties::CreateForm( "Object Inspector", - 0, - alClient, - TOnModifiedEvent(this,&CLevelTool::OnPropsModified), - 0, - TOnCloseEvent(this,&CLevelTool::OnPropsClose), - TProperties::plItemFolders|TProperties::plFolderStore|TProperties::plNoClearStore|TProperties::plFullExpand); + ExecCommand(COMMAND_CHANGE_TARGET, OBJCLASS_SCENEOBJECT); + m_Props = TProperties::CreateForm("Object Inspector", + 0, + alClient, + TOnModifiedEvent(this, &CLevelTool::OnPropsModified), + 0, + TOnCloseEvent(this, &CLevelTool::OnPropsClose), + TProperties::plItemFolders|TProperties::plFolderStore|TProperties::plNoClearStore|TProperties::plFullExpand); pObjectListForm = TfrmObjectList::CreateForm(); return true; } + //--------------------------------------------------------------------------- void CLevelTool::OnDestroy() { - inherited::OnDestroy(); + inherited::OnDestroy(); TfrmObjectList::DestroyForm(pObjectListForm); - TProperties::DestroyForm(m_Props); + TProperties::DestroyForm(m_Props); // scene destroing if (pCurTool) - pCurTool->OnDeactivate(); - Scene->OnDestroy (); + pCurTool->OnDeactivate(); + Scene->OnDestroy(); } + //--------------------------------------------------------------------------- void CLevelTool::Reset() { - RealSetTarget(GetTarget(),estDefault,true); + RealSetTarget(GetTarget(),estDefault, true); } + //--------------------------------------------------------------------------- bool __fastcall CLevelTool::MouseStart(TShiftState Shift) { - inherited::MouseStart(Shift); - if(pCurTool && pCurTool->pCurControl) + inherited::MouseStart(Shift); + if (pCurTool&&pCurTool->pCurControl) { - if ((pCurTool->pCurControl->Action()!=etaSelect)&& - (!pCurTool->IsEditable() || !pCurTool->AllowMouseStart() || (pCurTool->ClassID==OBJCLASS_DUMMY))) + if ((pCurTool->pCurControl->Action()!=etaSelect)&& + (!pCurTool->IsEditable()||!pCurTool->AllowMouseStart()||(pCurTool->ClassID==OBJCLASS_DUMMY))) return false; return pCurTool->pCurControl->Start(Shift); } return false; } + //--------------------------------------------------------------------------- void __fastcall CLevelTool::MouseMove(TShiftState Shift) { - inherited::MouseMove(Shift); - if(pCurTool&&pCurTool->pCurControl) + inherited::MouseMove(Shift); + if (pCurTool&&pCurTool->pCurControl) { - if (HiddenMode()) - ExecCommand(COMMAND_UPDATE_PROPERTIES); + if (HiddenMode()) + ExecCommand(COMMAND_UPDATE_PROPERTIES); - pCurTool->pCurControl->Move(Shift); + pCurTool->pCurControl->Move(Shift); } } + //--------------------------------------------------------------------------- bool __fastcall CLevelTool::MouseEnd(TShiftState Shift) { - inherited::MouseEnd(Shift); - if(pCurTool&&pCurTool->pCurControl) + inherited::MouseEnd(Shift); + if (pCurTool&&pCurTool->pCurControl) { - if (HiddenMode()) - ExecCommand(COMMAND_UPDATE_PROPERTIES); + if (HiddenMode()) + ExecCommand(COMMAND_UPDATE_PROPERTIES); - return pCurTool->pCurControl->End(Shift); + return pCurTool->pCurControl->End(Shift); } return false; } + //--------------------------------------------------------------------------- void __fastcall CLevelTool::OnObjectsUpdate() { - UpdateProperties(false); - if(pCurTool&&pCurTool->pCurControl) - return pCurTool->OnObjectsUpdate(); + UpdateProperties(false); + if (pCurTool&&pCurTool->pCurControl) + return pCurTool->OnObjectsUpdate(); } + //--------------------------------------------------------------------------- bool __fastcall CLevelTool::HiddenMode() { - if(pCurTool&&pCurTool->pCurControl) - return pCurTool->pCurControl->HiddenMode(); + if (pCurTool&&pCurTool->pCurControl) + return pCurTool->pCurControl->HiddenMode(); return false; } + //--------------------------------------------------------------------------- -bool __fastcall CLevelTool::KeyDown (WORD Key, TShiftState Shift) +bool __fastcall CLevelTool::KeyDown(WORD Key, TShiftState Shift) { - if(pCurTool&&pCurTool->pCurControl) - return pCurTool->pCurControl->KeyDown(Key,Shift); + if (pCurTool&&pCurTool->pCurControl) + return pCurTool->pCurControl->KeyDown(Key, Shift); return false; } + //--------------------------------------------------------------------------- -bool __fastcall CLevelTool::KeyUp (WORD Key, TShiftState Shift) +bool __fastcall CLevelTool::KeyUp(WORD Key, TShiftState Shift) { - if(pCurTool&&pCurTool->pCurControl) - return pCurTool->pCurControl->KeyUp(Key,Shift); + if (pCurTool&&pCurTool->pCurControl) + return pCurTool->pCurControl->KeyUp(Key, Shift); return false; } + //--------------------------------------------------------------------------- -bool __fastcall CLevelTool::KeyPress (WORD Key, TShiftState Shift) +bool __fastcall CLevelTool::KeyPress(WORD Key, TShiftState Shift) { - if(pCurTool&&pCurTool->pCurControl) - return pCurTool->pCurControl->KeyPress(Key,Shift); + if (pCurTool&&pCurTool->pCurControl) + return pCurTool->pCurControl->KeyPress(Key, Shift); return false; } + //--------------------------------------------------------------------------- -void CLevelTool::RealSetAction (ETAction act) +void CLevelTool::RealSetAction(ETAction act) { - inherited::SetAction(act); + inherited::SetAction(act); if (pCurTool) - pCurTool->SetAction(act); + pCurTool->SetAction(act); ExecCommand(COMMAND_UPDATE_TOOLBAR); - m_Flags.set (flChangeAction,FALSE); + m_Flags.set(flChangeAction, FALSE); } void __fastcall CLevelTool::SetAction(ETAction act) { - // åñëè ìûøü çàõâà÷åíà - èçìåíèì action ïîñëå òîãî êàê îíà îñâîáîäèòñÿ - if (UI->IsMouseCaptured()||UI->IsMouseInUse()||!false){ - m_Flags.set (flChangeAction,TRUE); - iNeedAction=act; - }else - RealSetAction (act); + // åñëè ìûøü çàõâà÷åíà - èçìåíèì action ïîñëå òîãî êàê îíà îñâîáîäèòñÿ + if (UI->IsMouseCaptured()||UI->IsMouseInUse()||!false) + { + m_Flags.set(flChangeAction, TRUE); + iNeedAction = act; + } + else + RealSetAction(act); } + //--------------------------------------------------------------------------- -void __fastcall CLevelTool::RealSetTarget (ObjClassID tgt,int sub_tgt,bool bForced) +void __fastcall CLevelTool::RealSetTarget(ObjClassID tgt, int sub_tgt, bool bForced) { - if(bForced||(target!=tgt)||(sub_target!=sub_tgt)){ - target = tgt; - sub_target = sub_tgt; - if (pCurTool){ + if (bForced||(target!=tgt)||(sub_target!=sub_tgt)) + { + target = tgt; + sub_target = sub_tgt; + if (pCurTool) + { DETACH_FRAME(pCurTool->pFrame); pCurTool->OnDeactivate(); } - pCurTool = Scene->GetTool(tgt); - VERIFY (pCurTool); - pCurTool->SetSubTarget (sub_target); + pCurTool = Scene->GetTool(tgt); + VERIFY(pCurTool); + pCurTool->SetSubTarget(sub_target); - pCurTool->OnActivate (); + pCurTool->OnActivate(); - pCurTool->SetAction (GetAction()); + pCurTool->SetAction(GetAction()); if (pCurTool->IsEditable()) - ATTACH_FRAME(pCurTool->pFrame, paParent); + ATTACH_FRAME(pCurTool->pFrame, paParent); } UI->RedrawScene(); fraLeftBar->ChangeTarget(tgt); fraLeftBar->UpdateSnapList(); ExecCommand(COMMAND_UPDATE_TOOLBAR); - m_Flags.set(flChangeTarget,FALSE); + m_Flags.set(flChangeTarget, FALSE); } + //--------------------------------------------------------------------------- void __fastcall CLevelTool::ResetSubTarget() { - VERIFY(pCurTool); - pCurTool->ResetSubTarget(); + VERIFY(pCurTool); + pCurTool->ResetSubTarget(); } + //--------------------------------------------------------------------------- void __fastcall CLevelTool::SetTarget(ObjClassID tgt, int sub_tgt) { - // åñëè ìûøü çàõâà÷åíà - èçìåíèì target ïîñëå òîãî êàê îíà îñâîáîäèòñÿ - if (UI->IsMouseCaptured()||UI->IsMouseInUse()||!false){ - m_Flags.set(flChangeTarget,TRUE); - if(tgt == OBJCLASS_WAY && sub_tgt==2 && target==tgt) + // åñëè ìûøü çàõâà÷åíà - èçìåíèì target ïîñëå òîãî êàê îíà îñâîáîäèòñÿ + if (UI->IsMouseCaptured()||UI->IsMouseInUse()||!false) + { + m_Flags.set(flChangeTarget, TRUE); + if (tgt==OBJCLASS_WAY&&sub_tgt==2&&target==tgt) { - iNeedTarget = tgt; - iNeedSubTarget = (sub_target)?0:1; - }else + iNeedTarget = tgt; + iNeedSubTarget = (sub_target) ? 0 : 1; + } + else { - iNeedTarget = tgt; - iNeedSubTarget = sub_tgt; + iNeedTarget = tgt; + iNeedSubTarget = sub_tgt; } - }else - RealSetTarget(tgt,sub_tgt,false); + } + else + RealSetTarget(tgt, sub_tgt, false); } + //--------------------------------------------------------------------------- ObjClassID CLevelTool::CurrentClassID() { - return GetTarget(); + return GetTarget(); } + //--------------------------------------------------------------------------- -void CLevelTool::OnShowHint(AStringVec& ss) +void CLevelTool::OnShowHint(AStringVec &ss) { - Scene->OnShowHint(ss); + Scene->OnShowHint(ss); } + //--------------------------------------------------------------------------- bool CLevelTool::Pick(TShiftState Shift) { - if( Scene->locked() && (esEditLibrary==UI->GetEState())){ + if (Scene->locked()&&(esEditLibrary==UI->GetEState())) + { UI->IR_GetMousePosReal(EDevice.m_hRenderWnd, UI->m_CurrentCp); UI->m_StartCp = UI->m_CurrentCp; - EDevice.m_Camera.MouseRayFromPoint(UI->m_CurrentRStart, UI->m_CurrentRDir, UI->m_CurrentCp ); + EDevice.m_Camera.MouseRayFromPoint(UI->m_CurrentRStart, UI->m_CurrentRDir, UI->m_CurrentCp); SRayPickInfo pinf; - TfrmEditLibrary::RayPick(UI->m_CurrentRStart,UI->m_CurrentRDir,&pinf); + TfrmEditLibrary::RayPick(UI->m_CurrentRStart, UI->m_CurrentRDir, &pinf); return true; } return false; } + //--------------------------------------------------------------------------- void CLevelTool::RefreshProperties() { - m_Props->RefreshForm(); + m_Props->RefreshForm(); } void CLevelTool::ShowProperties(LPCSTR focus_to_item) { - m_Props->ShowProperties (); - RealUpdateProperties (); + m_Props->ShowProperties(); + RealUpdateProperties(); - if(focus_to_item) - m_Props->SelectFolder (focus_to_item); + if (focus_to_item) + m_Props->SelectFolder(focus_to_item); else { - if(pCurTool && pCurTool->ClassID!=OBJCLASS_DUMMY) + if (pCurTool&&pCurTool->ClassID!=OBJCLASS_DUMMY) { - LPCSTR cn = pCurTool->ClassDesc(); - m_Props->SelectFolder (cn); + LPCSTR cn = pCurTool->ClassDesc(); + m_Props->SelectFolder(cn); } } - UI->RedrawScene (); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- void CLevelTool::RealUpdateProperties() { - if (m_Props->Visible) + if (m_Props->Visible) { - if (m_Props->IsModified()) Scene->UndoSave(); - + if (m_Props->IsModified()) + Scene->UndoSave(); + ObjectList lst; PropItemVec items; // scene common props - Scene->FillProp ("",items,CurrentClassID()); + Scene->FillProp("", items, CurrentClassID()); - m_Props->AssignItems (items); + m_Props->AssignItems(items); } - m_Flags.set(flUpdateProperties,FALSE); + m_Flags.set(flUpdateProperties, FALSE); } + //--------------------------------------------------------------------------- void CLevelTool::OnPropsClose() { - if (m_Props->IsModified()) Scene->UndoSave(); + if (m_Props->IsModified()) + Scene->UndoSave(); } + //--------------------------------------------------------------------------- void __fastcall CLevelTool::OnPropsModified() { - Scene->Modified(); -// Scene->UndoSave(); - UI->RedrawScene(); + Scene->Modified(); + // Scene->UndoSave(); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- #include "EditLightAnim.h" bool CLevelTool::IfModified() { - EEditorState est = UI->GetEState(); - switch(est){ - case esEditLightAnim: return TfrmEditLightAnim::FinalClose(); - case esEditLibrary: return TfrmEditLibrary::FinalClose(); - case esEditScene: return Scene->IfModified(); - default: THROW; + EEditorState est = UI->GetEState(); + switch (est) + { + case esEditLightAnim: return TfrmEditLightAnim::FinalClose(); + case esEditLibrary: return TfrmEditLibrary::FinalClose(); + case esEditScene: return Scene->IfModified(); + default: THROW; } return false; } + //--------------------------------------------------------------------------- void CLevelTool::ZoomObject(BOOL bSelectedOnly) { - if( !Scene->locked() ){ - Scene->ZoomExtents(CurrentClassID(),bSelectedOnly); - } else { - if (UI->GetEState()==esEditLibrary){ + if (!Scene->locked()) + { + Scene->ZoomExtents(CurrentClassID(), bSelectedOnly); + } + else + { + if (UI->GetEState()==esEditLibrary) + { TfrmEditLibrary::ZoomObject(); } } } + //--------------------------------------------------------------------------- -void CLevelTool::GetCurrentFog(u32& fog_color, float& s_fog, float& e_fog) +void CLevelTool::GetCurrentFog(u32 &fog_color, float &s_fog, float &e_fog) { -/* - if (psDeviceFlags.is(rsEnvironment)&&psDeviceFlags.is(rsFog)){ - s_fog = g_pGamePersistent->Environment().CurrentEnv->fog_near; - e_fog = g_pGamePersistent->Environment().CurrentEnv->fog_far; - Fvector& f_clr = g_pGamePersistent->Environment().CurrentEnv->fog_color; - fog_color = color_rgba_f(f_clr.x,f_clr.y,f_clr.z,1.f); - }else{ -*/ - s_fog = psDeviceFlags.is(rsFog)?(1.0f - fFogness)* 0.85f * UI->ZFar():0.99f*UI->ZFar(); - e_fog = psDeviceFlags.is(rsFog)?0.91f * UI->ZFar():UI->ZFar(); - fog_color = dwFogColor; -/* - } -*/ + /* + if (psDeviceFlags.is(rsEnvironment)&&psDeviceFlags.is(rsFog)){ + s_fog = g_pGamePersistent->Environment().CurrentEnv->fog_near; + e_fog = g_pGamePersistent->Environment().CurrentEnv->fog_far; + Fvector& f_clr = g_pGamePersistent->Environment().CurrentEnv->fog_color; + fog_color = color_rgba_f(f_clr.x,f_clr.y,f_clr.z,1.f); + }else{ + */ + s_fog = psDeviceFlags.is(rsFog) ? (1.0f-fFogness)*0.85f*UI->ZFar() : 0.99f*UI->ZFar(); + e_fog = psDeviceFlags.is(rsFog) ? 0.91f*UI->ZFar() : UI->ZFar(); + fog_color = dwFogColor; + /* + } + */ } + //--------------------------------------------------------------------------- LPCSTR CLevelTool::GetInfo() { - static AnsiString sel; - int cnt = Scene->SelectionCount(true,CurrentClassID()); - return sel.sprintf(" Sel: %d",cnt).c_str(); + static AnsiString sel; + int cnt = Scene->SelectionCount(true, CurrentClassID()); + return sel.sprintf(" Sel: %d", cnt).c_str(); } + //--------------------------------------------------------------------------- void __fastcall CLevelTool::OnFrame() { - Scene->OnFrame (EDevice.fTimeDelta); - EEditorState est = UI->GetEState(); - if ((est==esEditScene)||(est==esEditLibrary)||(est==esEditLightAnim)){ + Scene->OnFrame(EDevice.fTimeDelta); + EEditorState est = UI->GetEState(); + if ((est==esEditScene)||(est==esEditLibrary)||(est==esEditLightAnim)) + { if (true/*!UI->IsMouseCaptured()*/) { // åñëè íóæíî èçìåíèòü target âûïîëíÿåì ïîñëå òîãî êàê ìûøü îñâîáîäèòñÿ - if(m_Flags.is(flChangeTarget)) RealSetTarget(iNeedTarget,iNeedSubTarget,false); + if (m_Flags.is(flChangeTarget)) + RealSetTarget(iNeedTarget, iNeedSubTarget, false); // åñëè íóæíî èçìåíèòü action âûïîëíÿåì ïîñëå òîãî êàê ìûøü îñâîáîäèòñÿ - if(m_Flags.is(flChangeAction)) RealSetAction(ETAction(iNeedAction)); + if (m_Flags.is(flChangeAction)) + RealSetAction(ETAction(iNeedAction)); } - if (m_Flags.is(flUpdateProperties)) RealUpdateProperties(); - if (m_Flags.is(flUpdateObjectList)) RealUpdateObjectList(); - if (est==esEditLightAnim) TfrmEditLightAnim::OnIdle(); + if (m_Flags.is(flUpdateProperties)) + RealUpdateProperties(); + if (m_Flags.is(flUpdateObjectList)) + RealUpdateObjectList(); + if (est==esEditLightAnim) + TfrmEditLightAnim::OnIdle(); } } + //--------------------------------------------------------------------------- #include "d3dutils.h" + void __fastcall CLevelTool::RenderEnvironment() { // draw sky - EEditorState est = UI->GetEState(); - switch(est){ - case esEditLightAnim: - case esEditScene: - if (psDeviceFlags.is(rsEnvironment)) - { -//. g_pGamePersistent->Environment().RenderSky (); -//. g_pGamePersistent->Environment().RenderClouds (); - } + EEditorState est = UI->GetEState(); + switch (est) + { + case esEditLightAnim: + case esEditScene: + if (psDeviceFlags.is(rsEnvironment)) + { + //. g_pGamePersistent->Environment().RenderSky (); + //. g_pGamePersistent->Environment().RenderClouds (); + } } } void __fastcall CLevelTool::Render() { - // Render update - ::Render->Calculate (); - ::Render->Render (); + // Render update + ::Render->Calculate(); + ::Render->Render(); - EEditorState est = UI->GetEState(); + EEditorState est = UI->GetEState(); // draw scene - switch(est){ - case esEditLibrary: TfrmEditLibrary::OnRender(); break; - case esEditLightAnim: - case esEditScene: - Scene->Render(EDevice.m_Camera.GetTransform()); -//. if (psDeviceFlags.is(rsEnvironment)) g_pGamePersistent->Environment().RenderLast (); - break; - case esBuildLevel: Builder.OnRender(); break; + switch (est) + { + case esEditLibrary: TfrmEditLibrary::OnRender(); + break; + case esEditLightAnim: + case esEditScene: + Scene->Render(EDevice.m_Camera.GetTransform()); + //. if (psDeviceFlags.is(rsEnvironment)) g_pGamePersistent->Environment().RenderLast (); + break; + case esBuildLevel: Builder.OnRender(); + break; } // draw cursor LUI->m_Cursor->Render(); - inherited::Render (); + inherited::Render(); } + //--------------------------------------------------------------------------- void CLevelTool::ShowObjectList() { - if (pObjectListForm) pObjectListForm->ShowObjectList(); + if (pObjectListForm) + pObjectListForm->ShowObjectList(); } + //--------------------------------------------------------------------------- void CLevelTool::RealUpdateObjectList() { - if (pObjectListForm) pObjectListForm->UpdateObjectList(); - m_Flags.set(flUpdateObjectList,FALSE); + if (pObjectListForm) + pObjectListForm->UpdateObjectList(); + m_Flags.set(flUpdateObjectList, FALSE); } + //--------------------------------------------------------------------------- bool CLevelTool::IsModified() { - return Scene->IsUnsaved(); + return Scene->IsUnsaved(); } + //--------------------------------------------------------------------------- -#include "../ECore/Editor/EditMesh.h" -bool CLevelTool::RayPick(const Fvector& start, const Fvector& dir, float& dist, Fvector* pt, Fvector* n) +#include "editors/ECore/Editor/EditMesh.h" + +bool CLevelTool::RayPick(const Fvector &start, const Fvector &dir, float &dist, Fvector *pt, Fvector *n) { - if (Scene->ObjCount()&&(UI->GetEState()==esEditScene)){ + if (Scene->ObjCount()&&(UI->GetEState()==esEditScene)) + { SRayPickInfo pinf; - pinf.inf.range = dist; - if (Scene->RayPickObject(dist, start,dir,OBJCLASS_SCENEOBJECT,&pinf,0)){ - dist = pinf.inf.range; - if (pt) pt->set(pinf.pt); - if (n){ - const Fvector* PT[3]; + pinf.inf.range = dist; + if (Scene->RayPickObject(dist, start, dir, OBJCLASS_SCENEOBJECT, &pinf, 0)) + { + dist = pinf.inf.range; + if (pt) + pt->set(pinf.pt); + if (n) + { + const Fvector *PT[3]; pinf.e_mesh->GetFacePT(pinf.inf.id, PT); - n->mknormal(*PT[0],*PT[1],*PT[2]); + n->mknormal(*PT[0], *PT[1], *PT[2]); } return true; } } - Fvector N={0.f,-1.f,0.f}; - Fvector P={0.f,0.f,0.f}; - Fplane PL; PL.build(P,N); + Fvector N = {0.f,-1.f,0.f}; + Fvector P = {0.f,0.f,0.f}; + Fplane PL; + PL.build(P, N); float d; - if (PL.intersectRayDist(start,dir,d)&&(d<=dist)){ + if (PL.intersectRayDist(start, dir, d)&&(d<=dist)) + { dist = d; - if (pt) pt->mad(start,dir,dist); - if (n) n->set(N); + if (pt) + pt->mad(start, dir, dist); + if (n) + n->set(N); return true; - }else return false; + } + else + return false; } -bool CLevelTool::GetSelectionPosition(Fmatrix& result) +bool CLevelTool::GetSelectionPosition(Fmatrix &result) { - if(pCurTool) + if (pCurTool) { - Fvector center; - Fbox BB; - BB.invalidate (); -// pCurTool->GetBBox (BB, true); - - const CCustomObject* object = pCurTool->LastSelected(); - if(!object) - return false; - - object->GetBox (BB); - - BB.getcenter (center); - center.y = BB.max.y; - - Fvector2 pt_ss; - pt_ss.set (10000,-10000); - Fvector pt_ss_3d; - BB.setb (center, Fvector().set(1.0f,1.0f,1.0f)); - for(int k=0;k<8;++k) + Fvector center; + Fbox BB; + BB.invalidate(); + // pCurTool->GetBBox (BB, true); + + const CCustomObject *object = pCurTool->LastSelected(); + if (!object) + return false; + + object->GetBox(BB); + + BB.getcenter(center); + center.y = BB.max.y; + + Fvector2 pt_ss; + pt_ss.set(10000, -10000); + Fvector pt_ss_3d; + BB.setb(center, Fvector().set(1.0f, 1.0f, 1.0f)); + for (int k = 0; k<8; ++k) { - Fvector pt; - BB.getpoint(k,pt); - EDevice.mFullTransform.transform(pt_ss_3d, pt); - + Fvector pt; + BB.getpoint(k, pt); + EDevice.mFullTransform.transform(pt_ss_3d, pt); + pt_ss.x = _min(pt_ss.x, pt_ss_3d.y); pt_ss.y = _max(pt_ss.y, pt_ss_3d.y); } - float r_bb_ss = pt_ss.y - pt_ss.x; - clamp(r_bb_ss, 0.0f,0.10f); - float des_radius = 0.2f; - float csale = des_radius/r_bb_ss; - - result.scale (csale,csale,csale); - result.c = center; - return true; - }else - return false; -} -void CLevelTool::Simulate() -{ - if( !g_scene_physics.Simulating() ) - g_scene_physics.CreateShellsSelected(); + float r_bb_ss = pt_ss.y-pt_ss.x; + clamp(r_bb_ss, 0.0f, 0.10f); + float des_radius = 0.2f; + float csale = des_radius/r_bb_ss; + + result.scale(csale, csale, csale); + result.c = center; + return true; + } else - g_scene_physics.DestroyAll(); + return false; +} + +void CLevelTool::Simulate() +{ + if (!g_scene_physics.Simulating()) + g_scene_physics.CreateShellsSelected(); + else + g_scene_physics.DestroyAll(); UI->RedrawScene(); ExecCommand(COMMAND_REFRESH_UI_BAR); } -void CLevelTool::UseSimulatePositions() + +void CLevelTool::UseSimulatePositions() { - g_scene_physics.UseSimulatePoses(); + g_scene_physics.UseSimulatePoses(); } + diff --git a/src/editors/LevelEditor/Edit/UI_LevelTools.h b/src/editors/LevelEditor/Edit/UI_LevelTools.h index b0849737c12..569d95524ee 100644 --- a/src/editors/LevelEditor/Edit/UI_LevelTools.h +++ b/src/editors/LevelEditor/Edit/UI_LevelTools.h @@ -7,134 +7,184 @@ class TProperties; class TfrmObjectList; #include "ESceneClassList.h" -#include "../ECore/Editor/UI_ToolsCustom.h" -#include "../ECore/Editor/UI_mainCommand.h" +#include "editors/ECore/Editor/UI_ToolsCustom.h" +#include "editors/ECore/Editor/UI_mainCommand.h" //--------------------------------------------------------------------------- #define estDefault 0 -#define CHECK_SNAP(R,A,C){ R+=A; if(fabsf(R)>=C){ A=snapto(R,C); R=0; }else{A=0;}} +#define CHECK_SNAP(R, A, C) { R += A; if(fabsf(R) >= C){ A = snapto(R, C); R = 0; } else { A=0; } } class CLevelTool: public CToolCustom { - typedef CToolCustom inherited; + typedef CToolCustom inherited; - TPanel* paParent; - int sub_target; - ObjClassID target; + TPanel *paParent; + int sub_target; + ObjClassID target; - Flags32 m_Flags; + Flags32 m_Flags; - enum{ - flChangeAction = (1<<0), - flChangeTarget = (1<<1), - flUpdateProperties = (1<<2), - flUpdateObjectList = (1<<3) - // flSimulating = (1<<4) + enum + { + flChangeAction = (1<<0), + flChangeTarget = (1<<1), + flUpdateProperties = (1<<2), + flUpdateObjectList = (1<<3) + // flSimulating = (1<<4) }; - int iNeedAction; - ObjClassID iNeedTarget; - int iNeedSubTarget; + int iNeedAction; + ObjClassID iNeedTarget; + int iNeedSubTarget; - ESceneToolBase* pCurTool; - - TfrmObjectList* pObjectListForm; + ESceneToolBase *pCurTool; - void __fastcall SetTargetAction (); + TfrmObjectList *pObjectListForm; - void __fastcall RealSetAction (ETAction act); - void __fastcall RealSetTarget (ObjClassID tgt,int sub_tgt, bool bForced);//=false); + void __fastcall SetTargetAction(); - TProperties* m_Props; - void __stdcall OnPropsModified (); - void __stdcall OnPropsClose (); + void __fastcall RealSetAction(ETAction act); + void __fastcall RealSetTarget(ObjClassID tgt, int sub_tgt, bool bForced);//=false); - void RealUpdateProperties(); - void RealUpdateObjectList(); + TProperties *m_Props; + void __stdcall OnPropsModified(); + void __stdcall OnPropsClose(); + + void RealUpdateProperties(); + void RealUpdateObjectList(); public: - float fFogness; - u32 dwFogColor; - xr_string m_LastSelectionName; + float fFogness; + u32 dwFogColor; + xr_string m_LastSelectionName; public: - CLevelTool (); - virtual ~CLevelTool (); - - IC ObjClassID GetTarget (){return target;} - IC int GetSubTarget (){return sub_target;} - virtual void SetAction (ETAction act); - void SetTarget (ObjClassID tgt, int sub_tgt); - - virtual void SetFog (u32 fog_color, float fogness){dwFogColor=fog_color;fFogness=fogness;} - virtual void GetCurrentFog (u32& fog_color, float& s_fog, float& e_fog); - - virtual void Render (); - virtual void RenderEnvironment (); - virtual void OnFrame (); - - virtual bool OnCreate (); - virtual void OnDestroy (); - - virtual bool IfModified (); - virtual bool IsModified (); - virtual void Modified (){;} - - virtual LPCSTR GetInfo (); - - virtual void ZoomObject (BOOL bSelOnly); - - virtual bool Load (LPCSTR name){return true;} - virtual bool Save (LPCSTR name, bool bInternal=false){return true;} - virtual void Reload (){;} - - virtual void OnDeviceCreate (){;} - virtual void OnDeviceDestroy (){;} - - virtual void Clear (){inherited::Clear();} - - virtual void OnShowHint (AStringVec& SS); - - virtual bool __fastcall MouseStart (TShiftState Shift); - virtual bool __fastcall MouseEnd (TShiftState Shift); - virtual void __fastcall MouseMove (TShiftState Shift); - virtual bool __fastcall HiddenMode (); - virtual bool __fastcall KeyDown (WORD Key, TShiftState Shift); - virtual bool __fastcall KeyUp (WORD Key, TShiftState Shift); - virtual bool __fastcall KeyPress (WORD Key, TShiftState Shift); - - virtual bool Pick (TShiftState Shift); - virtual bool RayPick (const Fvector& start, const Fvector& dir, float& dist, Fvector* pt, Fvector* n); - - virtual void ShowProperties (LPCSTR focused_item); - virtual void UpdateProperties (BOOL bForced){m_Flags.set(flUpdateProperties|flUpdateObjectList,TRUE); if (bForced) OnFrame();} - virtual void RefreshProperties (); + CLevelTool(); + virtual ~CLevelTool(); + + IC ObjClassID GetTarget() + { + return target; + } + + IC + + int GetSubTarget() + { + return sub_target; + } + + virtual void SetAction(ETAction act); + void SetTarget(ObjClassID tgt, int sub_tgt); + + virtual void SetFog(u32 fog_color, float fogness) + { + dwFogColor = fog_color; + fFogness = fogness; + } + + virtual void GetCurrentFog(u32 &fog_color, float &s_fog, float &e_fog); + + virtual void Render(); + virtual void RenderEnvironment(); + virtual void OnFrame(); + + virtual bool OnCreate(); + virtual void OnDestroy(); + + virtual bool IfModified(); + virtual bool IsModified(); + + virtual void Modified() + { + ; + } + + virtual LPCSTR GetInfo(); + + virtual void ZoomObject(BOOL bSelOnly); + + virtual bool Load(LPCSTR name) + { + return true; + } + + virtual bool Save(LPCSTR name, bool bInternal = false) + { + return true; + } + + virtual void Reload() + { + ; + } + + virtual void OnDeviceCreate() + { + ; + } + + virtual void OnDeviceDestroy() + { + ; + } + + virtual void Clear() + { + inherited::Clear(); + } + + virtual void OnShowHint(AStringVec &SS); + + virtual bool __fastcall MouseStart(TShiftState Shift); + virtual bool __fastcall MouseEnd(TShiftState Shift); + virtual void __fastcall MouseMove(TShiftState Shift); + virtual bool __fastcall HiddenMode(); + virtual bool __fastcall KeyDown(WORD Key, TShiftState Shift); + virtual bool __fastcall KeyUp(WORD Key, TShiftState Shift); + virtual bool __fastcall KeyPress(WORD Key, TShiftState Shift); + + virtual bool Pick(TShiftState Shift); + virtual bool RayPick(const Fvector &start, const Fvector &dir, float &dist, Fvector *pt, Fvector *n); + + virtual void ShowProperties(LPCSTR focused_item); + + virtual void UpdateProperties(BOOL bForced) + { + m_Flags.set(flUpdateProperties|flUpdateObjectList, TRUE); + if (bForced) + OnFrame(); + } + + virtual void RefreshProperties(); private: - virtual void Simulate (); - virtual void UseSimulatePositions(); + virtual void Simulate(); + virtual void UseSimulatePositions(); public: // specified functions - void Reset (); + void Reset(); - TForm* GetFrame (); + TForm *GetFrame(); - void __fastcall ResetSubTarget (); + void __fastcall ResetSubTarget(); - void __fastcall OnObjectsUpdate (); + void __fastcall OnObjectsUpdate(); - ObjClassID CurrentClassID (); + ObjClassID CurrentClassID(); - void ShowObjectList (); - virtual bool GetSelectionPosition(Fmatrix& result); + void ShowObjectList(); + virtual bool GetSelectionPosition(Fmatrix &result); // commands - CCommandVar CommandChangeTarget (CCommandVar p1, CCommandVar p2); - CCommandVar CommandShowObjectList (CCommandVar p1, CCommandVar p2); - CCommandVar CommandEnableTarget (CCommandVar p1, CCommandVar p2); - CCommandVar CommandShowTarget (CCommandVar p1, CCommandVar p2); - CCommandVar CommandReadonlyTarget (CCommandVar p1, CCommandVar p2); - CCommandVar CommandMultiRenameObjects(CCommandVar p1,CCommandVar p2); + CCommandVar CommandChangeTarget(CCommandVar p1, CCommandVar p2); + CCommandVar CommandShowObjectList(CCommandVar p1, CCommandVar p2); + CCommandVar CommandEnableTarget(CCommandVar p1, CCommandVar p2); + CCommandVar CommandShowTarget(CCommandVar p1, CCommandVar p2); + CCommandVar CommandReadonlyTarget(CCommandVar p1, CCommandVar p2); + CCommandVar CommandMultiRenameObjects(CCommandVar p1, CCommandVar p2); }; -extern CLevelTool*& LTools; + +extern CLevelTool *<ools; extern void ResetActionToSelect(); extern TShiftState ssRBOnly; #endif + diff --git a/src/editors/LevelEditor/Edit/WayPoint.cpp b/src/editors/LevelEditor/Edit/WayPoint.cpp index c99af68c8fb..d86e8e7824b 100644 --- a/src/editors/LevelEditor/Edit/WayPoint.cpp +++ b/src/editors/LevelEditor/Edit/WayPoint.cpp @@ -5,11 +5,11 @@ #pragma hdrstop #include "WayPoint.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "FrameWayPoint.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "ESceneWayControls.h" -#include "../ECore/Editor/d3dUtils.h" +#include "editors/ECore/Editor/d3dUtils.h" //---------------------------------------------------- @@ -18,7 +18,7 @@ bool IsPointMode() { - return LTools->GetSubTarget() == estWayModePoint; + return LTools->GetSubTarget()==estWayModePoint; } //------------------------------------------------------------------------------ @@ -26,237 +26,310 @@ bool IsPointMode() //------------------------------------------------------------------------------ CWayPoint::CWayPoint(LPCSTR name) { - m_Name = name; - m_vPosition.set (0,0,0); - m_Flags.zero (); - m_bSelected = false; + m_Name = name; + m_vPosition.set(0, 0, 0); + m_Flags.zero(); + m_bSelected = false; } CWayPoint::~CWayPoint() { - for (WPLIt it=m_Links.begin(); it!=m_Links.end(); it++) - xr_delete (*it); - m_Links.clear (); + for (WPLIt it = m_Links.begin(); it!=m_Links.end(); it++) + xr_delete(*it); + m_Links.clear(); } -void CWayPoint::GetBox(Fbox& bb) +void CWayPoint::GetBox(Fbox &bb) { - bb.set(m_vPosition,m_vPosition); - bb.max.y+=WAYPOINT_SIZE; - bb.max.x+=WAYPOINT_RADIUS; - bb.max.z+=WAYPOINT_RADIUS; - bb.min.x-=WAYPOINT_RADIUS; - bb.min.z-=WAYPOINT_RADIUS; + bb.set(m_vPosition, m_vPosition); + bb.max.y += WAYPOINT_SIZE; + bb.max.x += WAYPOINT_RADIUS; + bb.max.z += WAYPOINT_RADIUS; + bb.min.x -= WAYPOINT_RADIUS; + bb.min.z -= WAYPOINT_RADIUS; } + void CWayPoint::Render(LPCSTR parent_name, bool bParentSelect) { - Fvector pos; - pos.set (m_vPosition.x,m_vPosition.y+WAYPOINT_SIZE*0.85f,m_vPosition.z); - DU_impl.DrawCross(pos,WAYPOINT_RADIUS,WAYPOINT_SIZE*0.85f,WAYPOINT_RADIUS,WAYPOINT_RADIUS,WAYPOINT_SIZE*0.15f,WAYPOINT_RADIUS,0x0000ff00); - // draw links - Fvector p1; - p1.set (m_vPosition.x,m_vPosition.y+WAYPOINT_SIZE*0.85f,m_vPosition.z); - - if (bParentSelect){ - u32 c = (m_bSelected)?0xFFFFFFFF:0xFFA0A0A0; - u32 s = 0xFF000000; - - AnsiString hint = AnsiString(" ")+parent_name; - hint += " ["; - hint += *m_Name; - hint += "]"; - Fvector p2; - for (WPLIt it=m_Links.begin(); it!=m_Links.end(); it++){ - SWPLink* O = (SWPLink*)(*it); - p2.set (O->way_point->m_vPosition.x,O->way_point->m_vPosition.y+WAYPOINT_SIZE*0.85f,O->way_point->m_vPosition.z); + Fvector pos; + pos.set(m_vPosition.x, m_vPosition.y+WAYPOINT_SIZE*0.85f, m_vPosition.z); + DU_impl.DrawCross(pos,WAYPOINT_RADIUS,WAYPOINT_SIZE*0.85f,WAYPOINT_RADIUS,WAYPOINT_RADIUS,WAYPOINT_SIZE*0.15f,WAYPOINT_RADIUS, 0x0000ff00); + // draw links + Fvector p1; + p1.set(m_vPosition.x, m_vPosition.y+WAYPOINT_SIZE*0.85f, m_vPosition.z); + + if (bParentSelect) + { + u32 c = (m_bSelected) ? 0xFFFFFFFF : 0xFFA0A0A0; + u32 s = 0xFF000000; + + AnsiString hint = AnsiString(" ")+parent_name; + hint += " ["; + hint += *m_Name; + hint += "]"; + Fvector p2; + for (WPLIt it = m_Links.begin(); it!=m_Links.end(); it++) + { + SWPLink *O = (SWPLink*)(*it); + p2.set(O->way_point->m_vPosition.x, O->way_point->m_vPosition.y+WAYPOINT_SIZE*0.85f, O->way_point->m_vPosition.z); Fvector xx; - xx.sub (p2,p1); - xx.mul (0.95f); - xx.add (p1); - DU_impl.OutText(xx,AnsiString().sprintf("P: %1.2f",O->probability).c_str(),c,s); + xx.sub(p2, p1); + xx.mul(0.95f); + xx.add(p1); + DU_impl.OutText(xx, AnsiString().sprintf("P: %1.2f", O->probability).c_str(), c, s); } - DU_impl.OutText(m_vPosition,hint.c_str(),c,s); + DU_impl.OutText(m_vPosition, hint.c_str(), c, s); } - Fvector p2; + Fvector p2; u32 l = 0xff606000; - if (bParentSelect) l = m_bSelected?0xffffff00:0xff909000; - for (WPLIt it=m_Links.begin(); it!=m_Links.end(); it++){ - SWPLink* O = (SWPLink*)(*it); - p2.set (O->way_point->m_vPosition.x,O->way_point->m_vPosition.y+WAYPOINT_SIZE*0.85f,O->way_point->m_vPosition.z); - DU_impl.DrawLink(p1,p2,0.25f,l); - } - if (bParentSelect&&m_bSelected){ - Fbox bb; GetBox(bb); + if (bParentSelect) + l = m_bSelected ? 0xffffff00 : 0xff909000; + for (WPLIt it = m_Links.begin(); it!=m_Links.end(); it++) + { + SWPLink *O = (SWPLink*)(*it); + p2.set(O->way_point->m_vPosition.x, O->way_point->m_vPosition.y+WAYPOINT_SIZE*0.85f, O->way_point->m_vPosition.z); + DU_impl.DrawLink(p1, p2, 0.25f, l); + } + if (bParentSelect&&m_bSelected) + { + Fbox bb; + GetBox(bb); u32 clr = 0xffffffff; - DU_impl.DrawSelectionBoxB(bb,&clr); - } + DU_impl.DrawSelectionBoxB(bb, &clr); + } } -bool CWayPoint::RayPick(float& distance, const Fvector& S, const Fvector& D) + +bool CWayPoint::RayPick(float &distance, const Fvector &S, const Fvector &D) { - Fvector ray2; - ray2.sub( m_vPosition, S ); ray2.y+=WAYPOINT_RADIUS; + Fvector ray2; + ray2.sub(m_vPosition, S); + ray2.y += WAYPOINT_RADIUS; float d = ray2.dotproduct(D); - if( d > 0 ){ + if (d>0) + { float d2 = ray2.magnitude(); - if( ((d2*d2-d*d) < (WAYPOINT_RADIUS*WAYPOINT_RADIUS)) && (d>WAYPOINT_RADIUS) ){ - if (dWAYPOINT_RADIUS)) + { + if (dRedrawScene(); - ExecCommand (COMMAND_UPDATE_PROPERTIES); -} -WPLIt CWayPoint::FindLink(CWayPoint* P) -{ - for (WPLIt it=m_Links.begin(); it!=m_Links.end(); it++) - if ((*it)->way_point==P) return it; - return m_Links.end(); -} -void CWayPoint::InvertLink(CWayPoint* P) -{ - WPLIt A=FindLink(P); - WPLIt B=P->FindLink(this); - bool a=(A!=m_Links.end()), b=(B!=P->m_Links.end()); - float p_a; - float p_b; - if (a){ p_a = (*A)->probability; xr_delete(*A); m_Links.erase(A); } - if (b){ p_b = (*B)->probability; xr_delete(*B); P->m_Links.erase(B);} - if (a){ P->CreateLink(this, p_a);} - if (b){ CreateLink(P, p_b); } -} -void CWayPoint::Convert1Link(CWayPoint* P) -{ - WPLIt A=FindLink(P); - WPLIt B=P->FindLink(this); - bool a=(A!=m_Links.end()), b=(B!=P->m_Links.end()); - float p_a=1.f; - float p_b=1.f; - if ((a&&!b)||(!a&&b)||(!a&&!b)) return; - if (a){ p_a = (*A)->probability; xr_delete(*A); m_Links.erase(A); } - - if (b){ -// p_b = (*B)->probability; + ExecCommand(COMMAND_UPDATE_PROPERTIES); +} + +WPLIt CWayPoint::FindLink(CWayPoint *P) +{ + for (WPLIt it = m_Links.begin(); it!=m_Links.end(); it++) + if ((*it)->way_point==P) + return it; + return m_Links.end(); +} + +void CWayPoint::InvertLink(CWayPoint *P) +{ + WPLIt A = FindLink(P); + WPLIt B = P->FindLink(this); + bool a = (A!=m_Links.end()), b = (B!=P->m_Links.end()); + float p_a; + float p_b; + if (a) + { + p_a = (*A)->probability; + xr_delete(*A); + m_Links.erase(A); + } + if (b) + { + p_b = (*B)->probability; xr_delete(*B); - P->m_Links.erase(B);} + P->m_Links.erase(B); + } + if (a) + { + P->CreateLink(this, p_a); + } + if (b) + { + CreateLink(P, p_b); + } +} + +void CWayPoint::Convert1Link(CWayPoint *P) +{ + WPLIt A = FindLink(P); + WPLIt B = P->FindLink(this); + bool a = (A!=m_Links.end()), b = (B!=P->m_Links.end()); + float p_a = 1.f; + float p_b = 1.f; + if ((a&&!b)||(!a&&b)||(!a&&!b)) + return; + if (a) + { + p_a = (*A)->probability; + xr_delete(*A); + m_Links.erase(A); + } - CreateLink (P, p_a); + if (b) + { + // p_b = (*B)->probability; + xr_delete(*B); + P->m_Links.erase(B); + } + + CreateLink(P, p_a); } -void CWayPoint::Convert2Link(CWayPoint* P) + +void CWayPoint::Convert2Link(CWayPoint *P) { - WPLIt A=FindLink(P); - WPLIt B=P->FindLink(this); - bool a=(A!=m_Links.end()), b=(B!=P->m_Links.end()); - float p_a=1.f; - float p_b=1.f; - if ((a&&b)||(!a&&!b)) return; - if (a){ p_a = (*A)->probability; xr_delete(*A); m_Links.erase(A); } - if (b){ p_b = (*B)->probability; xr_delete(*B); P->m_Links.erase(B);} + WPLIt A = FindLink(P); + WPLIt B = P->FindLink(this); + bool a = (A!=m_Links.end()), b = (B!=P->m_Links.end()); + float p_a = 1.f; + float p_b = 1.f; + if ((a&&b)||(!a&&!b)) + return; + if (a) + { + p_a = (*A)->probability; + xr_delete(*A); + m_Links.erase(A); + } + if (b) + { + p_b = (*B)->probability; + xr_delete(*B); + P->m_Links.erase(B); + } P->CreateLink(this, p_b); - CreateLink(P, p_a); + CreateLink(P, p_a); } -void CWayPoint::CreateLink(CWayPoint* P, float pb) + +void CWayPoint::CreateLink(CWayPoint *P, float pb) { - if (P!=this) m_Links.push_back(xr_new(P,pb)); + if (P!=this) + m_Links.push_back(xr_new(P, pb)); } -bool CWayPoint::AppendLink(CWayPoint* P, float pb) + +bool CWayPoint::AppendLink(CWayPoint *P, float pb) { - if (FindLink(P)==m_Links.end()){ - CreateLink(P,pb); + if (FindLink(P)==m_Links.end()) + { + CreateLink(P, pb); return true; } return false; } -bool CWayPoint::DeleteLink(CWayPoint* P) + +bool CWayPoint::DeleteLink(CWayPoint *P) { - WPLIt it = FindLink(P); - if (it!=m_Links.end()){ - xr_delete (*it); - m_Links.erase (it); - UI->RedrawScene (); - return true; + WPLIt it = FindLink(P); + if (it!=m_Links.end()) + { + xr_delete(*it); + m_Links.erase(it); + UI->RedrawScene(); + return true; } return false; } -bool CWayPoint::AddSingleLink(CWayPoint* P) + +bool CWayPoint::AddSingleLink(CWayPoint *P) { UI->RedrawScene(); - return AppendLink(P,1.f); + return AppendLink(P, 1.f); } -bool CWayPoint::AddDoubleLink(CWayPoint* P) + +bool CWayPoint::AddDoubleLink(CWayPoint *P) { UI->RedrawScene(); - bool bRes = AppendLink (P,1.f); - bRes |= P->AppendLink (this,1.f); + bool bRes = AppendLink(P, 1.f); + bRes |= P->AppendLink(this, 1.f); return bRes; } -bool CWayPoint::RemoveLink(CWayPoint* P) + +bool CWayPoint::RemoveLink(CWayPoint *P) { - if (DeleteLink(P)){ - P->DeleteLink(this); + if (DeleteLink(P)) + { + P->DeleteLink(this); return true; } - return false; + return false; } + //------------------------------------------------------------------------------ // Way Object //------------------------------------------------------------------------------ -CWayObject::CWayObject(LPVOID data, LPCSTR name):CCustomObject(data,name) +CWayObject::CWayObject(LPVOID data, LPCSTR name): CCustomObject(data, name) { - Construct(data); + Construct(data); } void CWayObject::Construct(LPVOID data) { - ClassID = OBJCLASS_WAY; - m_Type = wtPatrolPath; - AppendWayPoint(); + ClassID = OBJCLASS_WAY; + m_Type = wtPatrolPath; + AppendWayPoint(); } CWayObject::~CWayObject() { - Clear(); + Clear(); } void CWayObject::Clear() { - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - xr_delete(*it); + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + xr_delete(*it); } void CWayObject::InvertLink() { WPVec objects; - if (GetSelectedPoints(objects)){ - WPIt _A0=objects.begin(); - WPIt _A1=objects.end(); _A1--; - WPIt _B1=objects.end(); - for (WPIt _A=_A0; _A!=_A1; _A++){ - CWayPoint* A = (CWayPoint*)(*_A); - WPIt _B=_A; _B++; - for (; _B!=_B1; _B++){ - CWayPoint* B = (CWayPoint*)(*_B); + if (GetSelectedPoints(objects)) + { + WPIt _A0 = objects.begin(); + WPIt _A1 = objects.end(); + _A1--; + WPIt _B1 = objects.end(); + for (WPIt _A = _A0; _A!=_A1; _A++) + { + CWayPoint *A = (CWayPoint*)(*_A); + WPIt _B = _A; + _B++; + for (; _B!=_B1; _B++) + { + CWayPoint *B = (CWayPoint*)(*_B); A->InvertLink(B); } } @@ -266,15 +339,20 @@ void CWayObject::InvertLink() void CWayObject::Convert1Link() { WPVec objects; - if (GetSelectedPoints(objects)){ - WPIt _A0=objects.begin(); - WPIt _A1=objects.end(); _A1--; - WPIt _B1=objects.end(); - for (WPIt _A=_A0; _A!=_A1; _A++){ - CWayPoint* A = (CWayPoint*)(*_A); - WPIt _B=_A; _B++; - for (; _B!=_B1; _B++){ - CWayPoint* B = (CWayPoint*)(*_B); + if (GetSelectedPoints(objects)) + { + WPIt _A0 = objects.begin(); + WPIt _A1 = objects.end(); + _A1--; + WPIt _B1 = objects.end(); + for (WPIt _A = _A0; _A!=_A1; _A++) + { + CWayPoint *A = (CWayPoint*)(*_A); + WPIt _B = _A; + _B++; + for (; _B!=_B1; _B++) + { + CWayPoint *B = (CWayPoint*)(*_B); A->Convert1Link(B); } } @@ -284,15 +362,20 @@ void CWayObject::Convert1Link() void CWayObject::Convert2Link() { WPVec objects; - if (GetSelectedPoints(objects)){ - WPIt _A0=objects.begin(); - WPIt _A1=objects.end(); _A1--; - WPIt _B1=objects.end(); - for (WPIt _A=_A0; _A!=_A1; _A++){ - CWayPoint* A = (CWayPoint*)(*_A); - WPIt _B=_A; _B++; - for (; _B!=_B1; _B++){ - CWayPoint* B = (CWayPoint*)(*_B); + if (GetSelectedPoints(objects)) + { + WPIt _A0 = objects.begin(); + WPIt _A1 = objects.end(); + _A1--; + WPIt _B1 = objects.end(); + for (WPIt _A = _A0; _A!=_A1; _A++) + { + CWayPoint *A = (CWayPoint*)(*_A); + WPIt _B = _A; + _B++; + for (; _B!=_B1; _B++) + { + CWayPoint *B = (CWayPoint*)(*_B); A->Convert2Link(B); } } @@ -301,20 +384,25 @@ void CWayObject::Convert2Link() bool CWayObject::Add1Link() { - bool bRes = false; - //RemoveLink(); + bool bRes = false; + //RemoveLink(); WPVec objects; - if (GetSelectedPoints(objects)){ - WPIt _A0=objects.begin(); - WPIt _A1=objects.end(); _A1--; - WPIt _B1=objects.end(); - for (WPIt _A=_A0; _A!=_A1; _A++){ - CWayPoint* A = (CWayPoint*)(*_A); - WPIt _B=_A; _B++; - for (; _B!=_B1; _B++){ - CWayPoint* B = (CWayPoint*)(*_B); - bRes |= A->AddSingleLink(B); - A->InvertLink (B); + if (GetSelectedPoints(objects)) + { + WPIt _A0 = objects.begin(); + WPIt _A1 = objects.end(); + _A1--; + WPIt _B1 = objects.end(); + for (WPIt _A = _A0; _A!=_A1; _A++) + { + CWayPoint *A = (CWayPoint*)(*_A); + WPIt _B = _A; + _B++; + for (; _B!=_B1; _B++) + { + CWayPoint *B = (CWayPoint*)(*_B); + bRes |= A->AddSingleLink(B); + A->InvertLink(B); } } } @@ -323,18 +411,23 @@ bool CWayObject::Add1Link() bool CWayObject::Add2Link() { - bool bRes = false; + bool bRes = false; //RemoveLink(); WPVec objects; - if (GetSelectedPoints(objects)){ - WPIt _A0=objects.begin(); - WPIt _A1=objects.end(); _A1--; - WPIt _B1=objects.end(); - for (WPIt _A=_A0; _A!=_A1; _A++){ - CWayPoint* A = (CWayPoint*)(*_A); - WPIt _B=_A; _B++; - for (; _B!=_B1; _B++){ - CWayPoint* B = (CWayPoint*)(*_B); + if (GetSelectedPoints(objects)) + { + WPIt _A0 = objects.begin(); + WPIt _A1 = objects.end(); + _A1--; + WPIt _B1 = objects.end(); + for (WPIt _A = _A0; _A!=_A1; _A++) + { + CWayPoint *A = (CWayPoint*)(*_A); + WPIt _B = _A; + _B++; + for (; _B!=_B1; _B++) + { + CWayPoint *B = (CWayPoint*)(*_B); bRes |= A->AddDoubleLink(B); } } @@ -344,16 +437,19 @@ bool CWayObject::Add2Link() void CWayObject::RemoveLink() { - WPVec objects; - if (GetSelectedPoints(objects)){ - WPIt _A0=objects.begin(); - WPIt _A1=objects.end(); - WPIt _B1=objects.end(); - for (WPIt _A=_A0; _A!=_A1; _A++){ - CWayPoint* A = (CWayPoint*)(*_A); - WPIt _B=_A0; - for (; _B!=_B1; _B++){ - CWayPoint* B = (CWayPoint*)(*_B); + WPVec objects; + if (GetSelectedPoints(objects)) + { + WPIt _A0 = objects.begin(); + WPIt _A1 = objects.end(); + WPIt _B1 = objects.end(); + for (WPIt _A = _A0; _A!=_A1; _A++) + { + CWayPoint *A = (CWayPoint*)(*_A); + WPIt _B = _A0; + for (; _B!=_B1; _B++) + { + CWayPoint *B = (CWayPoint*)(*_B); A->RemoveLink(B); } } @@ -363,445 +459,508 @@ void CWayObject::RemoveLink() void CWayObject::RemoveSelectedPoints() { - for (WPIt f_it=m_WayPoints.begin(); f_it!=m_WayPoints.end(); f_it++){ - if ((*f_it)->m_bSelected){ - for (WPIt l_it=m_WayPoints.begin(); l_it!=m_WayPoints.end(); l_it++){ - if (l_it==f_it) continue; - (*l_it)->DeleteLink(*f_it); + for (WPIt f_it = m_WayPoints.begin(); f_it!=m_WayPoints.end(); f_it++) + { + if ((*f_it)->m_bSelected) + { + for (WPIt l_it = m_WayPoints.begin(); l_it!=m_WayPoints.end(); l_it++) + { + if (l_it==f_it) + continue; + (*l_it)->DeleteLink(*f_it); } } } - for (int i=0; i<(int)m_WayPoints.size(); i++) - if (m_WayPoints[i]->m_bSelected){ - WPIt it = m_WayPoints.begin()+i; - xr_delete(*it); - m_WayPoints.erase(it); + for (int i = 0; i<(int)m_WayPoints.size(); i++) + if (m_WayPoints[i]->m_bSelected) + { + WPIt it = m_WayPoints.begin()+i; + xr_delete(*it); + m_WayPoints.erase(it); i--; } } -int CWayObject::GetSelectedPoints(WPVec& lst) +int CWayObject::GetSelectedPoints(WPVec &lst) { - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - if ((*it)->m_bSelected) lst.push_back(*it); + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + if ((*it)->m_bSelected) + lst.push_back(*it); return lst.size(); } -CWayPoint* CWayObject::GetFirstSelected() +CWayPoint *CWayObject::GetFirstSelected() { - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - if ((*it)->m_bSelected) return *it; + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + if ((*it)->m_bSelected) + return *it; return 0; } -CWayPoint* CWayObject::AppendWayPoint() +CWayPoint *CWayObject::AppendWayPoint() { - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - (*it)->Select(0); - m_WayPoints.push_back(xr_new(FHelper.GenerateName("wp",2,fastdelegate::bind(this,&CWayObject::FindWPByName),false,false).c_str())); - m_WayPoints.back()->m_bSelected=true; + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + (*it)->Select(0); + m_WayPoints.push_back(xr_new(FHelper.GenerateName("wp", 2, fastdelegate::bind(this, &CWayObject::FindWPByName), false, false).c_str())); + m_WayPoints.back()->m_bSelected = true; return m_WayPoints.back(); } void CWayObject::Select(int flag) { - if (IsPointMode()){ - if (Selected()){ - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) (*it)->Select(flag); + if (IsPointMode()) + { + if (Selected()) + { + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + (*it)->Select(flag); } - }else{ - inherited::Select(flag); + } + else + { + inherited::Select(flag); } } -bool CWayObject::RaySelect(int flag, const Fvector& start, const Fvector& dir, bool bRayTest) +bool CWayObject::RaySelect(int flag, const Fvector &start, const Fvector &dir, bool bRayTest) { - if (IsPointMode()){ - float dist = UI->ZFar(); - CWayPoint* nearest=0; + if (IsPointMode()) + { + float dist = UI->ZFar(); + CWayPoint *nearest = 0; dist = UI->ZFar(); - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - if ((*it)->RayPick(dist,start,dir)) nearest=*it; - if (nearest!=0){ - nearest->Select(flag); + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + if ((*it)->RayPick(dist, start, dir)) + nearest = *it; + if (nearest!=0) + { + nearest->Select(flag); return true; } - }else return inherited::RaySelect(flag,start,dir,bRayTest); + } + else + return inherited::RaySelect(flag, start, dir, bRayTest); return false; } -bool CWayObject::FrustumSelect(int flag, const CFrustum& frustum) +bool CWayObject::FrustumSelect(int flag, const CFrustum &frustum) { - if (IsPointMode()){ - if (Selected()){ - bool bRes=false; - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - bRes|=(*it)->FrustumSelect(flag,frustum); + if (IsPointMode()) + { + if (Selected()) + { + bool bRes = false; + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + bRes |= (*it)->FrustumSelect(flag, frustum); return true; } return false; - }else return inherited::FrustumSelect(flag,frustum); -} - -bool CWayObject::GetBox( Fbox& box ) const -{ - box.invalidate(); - for (WPVec::const_iterator it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - box.modify((*it)->m_vPosition); - - box.max.x+=WAYPOINT_RADIUS; - box.max.z+=WAYPOINT_RADIUS; - box.max.y+=WAYPOINT_SIZE; - box.min.x-=WAYPOINT_RADIUS; - box.min.z-=WAYPOINT_RADIUS; - return true; -} - -void CWayObject::MoveTo(const Fvector& pos, const Fvector& up) -{ - if (IsPointMode()){ - CWayPoint* sel_point = 0; - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - if ((*it)->m_bSelected){ - if (sel_point){ Msg("!Only one selected way point supported."); return; } - sel_point=*it; - } - if (sel_point) sel_point->m_vPosition.set(pos); - }else{ - if (!m_WayPoints.empty()){ - Fvector diff; - diff.sub (pos,m_WayPoints.front()->m_vPosition); - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + } + else + return inherited::FrustumSelect(flag, frustum); +} + +bool CWayObject::GetBox(Fbox &box) const +{ + box.invalidate(); + for (WPVec::const_iterator it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + box.modify((*it)->m_vPosition); + + box.max.x += WAYPOINT_RADIUS; + box.max.z += WAYPOINT_RADIUS; + box.max.y += WAYPOINT_SIZE; + box.min.x -= WAYPOINT_RADIUS; + box.min.z -= WAYPOINT_RADIUS; + return true; +} + +void CWayObject::MoveTo(const Fvector &pos, const Fvector &up) +{ + if (IsPointMode()) + { + CWayPoint *sel_point = 0; + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + if ((*it)->m_bSelected) + { + if (sel_point) + { + Msg("!Only one selected way point supported."); + return; + } + sel_point = *it; + } + if (sel_point) + sel_point->m_vPosition.set(pos); + } + else + { + if (!m_WayPoints.empty()) + { + Fvector diff; + diff.sub(pos, m_WayPoints.front()->m_vPosition); + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) (*it)->m_vPosition.add(diff); } } } -void CWayObject::Move(Fvector& amount) +void CWayObject::Move(Fvector &amount) { - if (IsPointMode()){ - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - if ((*it)->m_bSelected) (*it)->m_vPosition.add(amount); - }else{ - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + if (IsPointMode()) + { + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + if ((*it)->m_bSelected) + (*it)->m_vPosition.add(amount); + } + else + { + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) (*it)->m_vPosition.add(amount); } } void CWayObject::Render(int priority, bool strictB2F) { -// inherited::Render(priority, strictB2F); - if ((1==priority)&&(false==strictB2F)){ + // inherited::Render(priority, strictB2F); + if ((1==priority)&&(false==strictB2F)) + { RCache.set_xform_world(Fidentity); - EDevice.SetShader (EDevice.m_WireShader); - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) (*it)->Render(Name,Selected()); - if( Selected() ){ + EDevice.SetShader(EDevice.m_WireShader); + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + (*it)->Render(Name, Selected()); + if (Selected()) + { u32 clr = 0xFFFFFFFF; - Fbox bb; GetBox(bb); - DU_impl.DrawSelectionBoxB(bb,&clr); + Fbox bb; + GetBox(bb); + DU_impl.DrawSelectionBoxB(bb, &clr); } } } -bool CWayObject::RayPick(float& distance, const Fvector& S, const Fvector& D, SRayPickInfo* pinf) +bool CWayObject::RayPick(float &distance, const Fvector &S, const Fvector &D, SRayPickInfo *pinf) { - bool bPick=false; - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - if ((*it)->RayPick(distance,S,D)) bPick=true; + bool bPick = false; + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + if ((*it)->RayPick(distance, S, D)) + bPick = true; return bPick; } -bool CWayObject::FrustumPick(const CFrustum& frustum) +bool CWayObject::FrustumPick(const CFrustum &frustum) { - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - if ((*it)->FrustumPick(frustum)) return true; + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + if ((*it)->FrustumPick(frustum)) + return true; return false; } -bool CWayObject::LoadLTX(CInifile& ini, LPCSTR sect_name) +bool CWayObject::LoadLTX(CInifile &ini, LPCSTR sect_name) { - Clear(); + Clear(); - u32 version = ini.r_u32(sect_name, "version"); + u32 version = ini.r_u32(sect_name, "version"); - if(version!=WAYOBJECT_VERSION) + if (version!=WAYOBJECT_VERSION) { - ELog.DlgMsg ( mtError, "CWayPoint: Unsupported version."); - return false; + ELog.DlgMsg(mtError, "CWayPoint: Unsupported version."); + return false; } - CCustomObject::LoadLTX(ini, sect_name); + CCustomObject::LoadLTX(ini, sect_name); - if(!Name) + if (!Name) { - ELog.DlgMsg(mtError,"Corrupted scene file.[%s] sect[%s] has empty name",ini.fname(), sect_name); - return false; + ELog.DlgMsg(mtError, "Corrupted scene file.[%s] sect[%s] has empty name", ini.fname(), sect_name); + return false; } u32 cnt = ini.r_u32(sect_name, "wp_count"); m_WayPoints.resize(cnt); - string128 buff; - u32 wp_idx = 0; - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); ++it,++wp_idx) + string128 buff; + u32 wp_idx = 0; + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); ++it,++wp_idx) { - CWayPoint* W = xr_new(""); - *it = W; + CWayPoint *W = xr_new(""); + *it = W; - sprintf (buff,"wp_%d_pos",wp_idx); - W->m_vPosition = ini.r_fvector3(sect_name, buff); + sprintf(buff, "wp_%d_pos", wp_idx); + W->m_vPosition = ini.r_fvector3(sect_name, buff); - sprintf (buff,"wp_%d_flags",wp_idx); - W->m_Flags.assign (ini.r_u32(sect_name, buff)); + sprintf(buff, "wp_%d_flags", wp_idx); + W->m_Flags.assign(ini.r_u32(sect_name, buff)); - sprintf (buff,"wp_%d_selected",wp_idx); - W->m_bSelected = ini.r_bool(sect_name, buff); + sprintf(buff, "wp_%d_selected", wp_idx); + W->m_bSelected = ini.r_bool(sect_name, buff); - sprintf (buff,"wp_%d_name",wp_idx); - W->m_Name = ini.r_string(sect_name, buff); + sprintf(buff, "wp_%d_name", wp_idx); + W->m_Name = ini.r_string(sect_name, buff); } - CInifile::Sect& S = ini.r_section(sect_name); - CInifile::SectCIt cit = S.Data.begin(); - CInifile::SectCIt cit_e = S.Data.end(); - for( ;cit!=cit_e; ++cit) + CInifile::Sect &S = ini.r_section(sect_name); + CInifile::SectCIt cit = S.Data.begin(); + CInifile::SectCIt cit_e = S.Data.end(); + for (; cit!=cit_e; ++cit) { - if( cit->first.c_str() == strstr(cit->first.c_str(),"link_wp_") ) + if (cit->first.c_str()==strstr(cit->first.c_str(), "link_wp_")) { - u32 wp_idx = u32(-1); - u32 wp_link_idx = u32(-1); + u32 wp_idx = u32(-1); + u32 wp_link_idx = u32(-1); - int res = sscanf(cit->first.c_str(),"link_wp_%4d_%4d",&wp_idx, &wp_link_idx); + int res = sscanf(cit->first.c_str(), "link_wp_%4d_%4d", &wp_idx, &wp_link_idx); R_ASSERT4(res==2, "bad waypoint link record format", sect_name, cit->first.c_str()); - Fvector2 val = ini.r_fvector2(sect_name,cit->first.c_str()); - u32 wp_to_idx = iFloor(val.x); - m_WayPoints[wp_idx]->CreateLink(m_WayPoints[wp_to_idx], val.y); + Fvector2 val = ini.r_fvector2(sect_name, cit->first.c_str()); + u32 wp_to_idx = iFloor(val.x); + m_WayPoints[wp_idx]->CreateLink(m_WayPoints[wp_to_idx], val.y); } } - m_Type = EWayType(ini.r_u32(sect_name, "type")); + m_Type = EWayType(ini.r_u32(sect_name, "type")); return true; } -void CWayObject::SaveLTX(CInifile& ini, LPCSTR sect_name) +void CWayObject::SaveLTX(CInifile &ini, LPCSTR sect_name) { - CCustomObject::SaveLTX (ini, sect_name); - ini.w_u32 (sect_name, "version", WAYOBJECT_VERSION); + CCustomObject::SaveLTX(ini, sect_name); + ini.w_u32(sect_name, "version", WAYOBJECT_VERSION); - ini.w_u32 (sect_name, "wp_count", m_WayPoints.size()); + ini.w_u32(sect_name, "wp_count", m_WayPoints.size()); - u32 wp_idx = 0; - string128 buff; - for(WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); ++it, ++wp_idx) + u32 wp_idx = 0; + string128 buff; + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); ++it,++wp_idx) { - CWayPoint* W = *it; - sprintf (buff,"wp_%d_pos",wp_idx); - ini.w_fvector3 (sect_name, buff, W->m_vPosition); - sprintf (buff,"wp_%d_flags",wp_idx); - ini.w_u32 (sect_name, buff, W->m_Flags.get()); + CWayPoint *W = *it; + sprintf(buff, "wp_%d_pos", wp_idx); + ini.w_fvector3(sect_name, buff, W->m_vPosition); + sprintf(buff, "wp_%d_flags", wp_idx); + ini.w_u32(sect_name, buff, W->m_Flags.get()); - sprintf (buff,"wp_%d_selected",wp_idx); - ini.w_bool (sect_name, buff, W->m_bSelected); + sprintf(buff, "wp_%d_selected", wp_idx); + ini.w_bool(sect_name, buff, W->m_bSelected); - sprintf (buff,"wp_%d_name",wp_idx); - ini.w_string (sect_name, buff, *W->m_Name?*W->m_Name:""); + sprintf(buff, "wp_%d_name", wp_idx); + ini.w_string(sect_name, buff, *W->m_Name ? *W->m_Name : ""); } - for (wp_idx=0, it=m_WayPoints.begin(); it!=m_WayPoints.end(); ++it, ++wp_idx) + for (wp_idx = 0,it = m_WayPoints.begin(); it!=m_WayPoints.end(); ++it,++wp_idx) { - CWayPoint* W = *it; - u32 link_idx = 0; - for (WPLIt l_it=W->m_Links.begin(); l_it!=W->m_Links.end(); ++l_it,++link_idx) + CWayPoint *W = *it; + u32 link_idx = 0; + for (WPLIt l_it = W->m_Links.begin(); l_it!=W->m_Links.end(); ++l_it,++link_idx) { - sprintf (buff, "link_wp_%4d_%4d", wp_idx, link_idx); + sprintf(buff, "link_wp_%4d_%4d", wp_idx, link_idx); - WPIt to = std::find(m_WayPoints.begin(),m_WayPoints.end(),(*l_it)->way_point); + WPIt to = std::find(m_WayPoints.begin(), m_WayPoints.end(), (*l_it)->way_point); - R_ASSERT (to!=m_WayPoints.end()); - Fvector2 tmp; - tmp.set (float((to-m_WayPoints.begin())),(*l_it)->probability); - ini.w_fvector2 (sect_name, buff, tmp); + R_ASSERT(to!=m_WayPoints.end()); + Fvector2 tmp; + tmp.set(float((to-m_WayPoints.begin())), (*l_it)->probability); + ini.w_fvector2(sect_name, buff, tmp); } } - ini.w_u32 (sect_name, "type", m_Type); + ini.w_u32(sect_name, "type", m_Type); } -bool CWayObject::LoadStream(IReader& F) +bool CWayObject::LoadStream(IReader &F) { - Clear(); + Clear(); - u16 version = 0; + u16 version = 0; shared_str buf; - if (!F.find_chunk(WAYOBJECT_CHUNK_VERSION)) return false; - R_ASSERT(F.r_chunk(WAYOBJECT_CHUNK_VERSION,&version)); - if(version!=WAYOBJECT_VERSION){ - ELog.DlgMsg( mtError, "CWayPoint: Unsupported version."); + if (!F.find_chunk(WAYOBJECT_CHUNK_VERSION)) + return false; + R_ASSERT(F.r_chunk(WAYOBJECT_CHUNK_VERSION, &version)); + if (version!=WAYOBJECT_VERSION) + { + ELog.DlgMsg(mtError, "CWayPoint: Unsupported version."); return false; } - CCustomObject::LoadStream(F); + CCustomObject::LoadStream(F); - R_ASSERT(F.find_chunk(WAYOBJECT_CHUNK_POINTS)); + R_ASSERT(F.find_chunk(WAYOBJECT_CHUNK_POINTS)); m_WayPoints.resize(F.r_u16()); - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++){ - CWayPoint* W = xr_new(""); *it = W; - F.r_fvector3 (W->m_vPosition); - W->m_Flags.assign(F.r_u32()); - W->m_bSelected = F.r_u16(); - F.r_stringZ (buf); - W->m_Name = buf.c_str(); + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + { + CWayPoint *W = xr_new(""); + *it = W; + F.r_fvector3(W->m_vPosition); + W->m_Flags.assign(F.r_u32()); + W->m_bSelected = F.r_u16(); + F.r_stringZ(buf); + W->m_Name = buf.c_str(); } - R_ASSERT(F.find_chunk(WAYOBJECT_CHUNK_LINKS)); + R_ASSERT(F.find_chunk(WAYOBJECT_CHUNK_LINKS)); int l_cnt = F.r_u16(); - for (int k=0; kCreateLink(m_WayPoints[idx1],pb); + for (int k = 0; kCreateLink(m_WayPoints[idx1], pb); } - R_ASSERT(F.find_chunk(WAYOBJECT_CHUNK_TYPE)); - m_Type = EWayType(F.r_u32()); + R_ASSERT(F.find_chunk(WAYOBJECT_CHUNK_TYPE)); + m_Type = EWayType(F.r_u32()); return true; } + //---------------------------------------------------- -void CWayObject::SaveStream(IWriter& F) -{ - CCustomObject::SaveStream(F); - - F.open_chunk (WAYOBJECT_CHUNK_VERSION); - F.w_u16 (WAYOBJECT_VERSION); - F.close_chunk (); - - int l_cnt = 0; - F.open_chunk (WAYOBJECT_CHUNK_POINTS); - F.w_u16 ((u16)m_WayPoints.size()); - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++){ - CWayPoint* W = *it; - F.w_fvector3(W->m_vPosition); - F.w_u32 (W->m_Flags.get()); - F.w_u16 ((u16)W->m_bSelected); - F.w_stringZ (*W->m_Name?*W->m_Name:""); - l_cnt += W->m_Links.size(); - } - F.close_chunk (); - - F.open_chunk (WAYOBJECT_CHUNK_LINKS); - F.w_u16 ((u16)l_cnt); - for (it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++){ - CWayPoint* W= *it; - int from = it-m_WayPoints.begin(); - for (WPLIt l_it=W->m_Links.begin(); l_it!=W->m_Links.end(); l_it++){ - WPIt to = std::find(m_WayPoints.begin(),m_WayPoints.end(),(*l_it)->way_point); R_ASSERT(to!=m_WayPoints.end()); - F.w_u16 ((u16)from); - F.w_u16 ((u16)(to-m_WayPoints.begin())); +void CWayObject::SaveStream(IWriter &F) +{ + CCustomObject::SaveStream(F); + + F.open_chunk(WAYOBJECT_CHUNK_VERSION); + F.w_u16(WAYOBJECT_VERSION); + F.close_chunk(); + + int l_cnt = 0; + F.open_chunk(WAYOBJECT_CHUNK_POINTS); + F.w_u16((u16)m_WayPoints.size()); + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + { + CWayPoint *W = *it; + F.w_fvector3(W->m_vPosition); + F.w_u32(W->m_Flags.get()); + F.w_u16((u16)W->m_bSelected); + F.w_stringZ(*W->m_Name ? *W->m_Name : ""); + l_cnt += W->m_Links.size(); + } + F.close_chunk(); + + F.open_chunk(WAYOBJECT_CHUNK_LINKS); + F.w_u16((u16)l_cnt); + for (it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + { + CWayPoint *W = *it; + int from = it-m_WayPoints.begin(); + for (WPLIt l_it = W->m_Links.begin(); l_it!=W->m_Links.end(); l_it++) + { + WPIt to = std::find(m_WayPoints.begin(), m_WayPoints.end(), (*l_it)->way_point); + R_ASSERT(to!=m_WayPoints.end()); + F.w_u16((u16)from); + F.w_u16((u16)(to-m_WayPoints.begin())); F.w_float((*l_it)->probability); } } - F.close_chunk (); + F.close_chunk(); - F.open_chunk (WAYOBJECT_CHUNK_TYPE); - F.w_u32 (m_Type); - F.close_chunk (); + F.open_chunk(WAYOBJECT_CHUNK_TYPE); + F.w_u32(m_Type); + F.close_chunk(); } -bool CWayObject::ExportGame(SExportStreams* F) +bool CWayObject::ExportGame(SExportStreams *F) { - F->patrolpath.stream.open_chunk (F->patrolpath.chunk++); - { - F->patrolpath.stream.open_chunk (WAYOBJECT_CHUNK_VERSION); - F->patrolpath.stream.w_u16 (WAYOBJECT_VERSION); - F->patrolpath.stream.close_chunk (); - - F->patrolpath.stream.open_chunk (WAYOBJECT_CHUNK_NAME); - F->patrolpath.stream.w_stringZ (Name); - F->patrolpath.stream.close_chunk (); - - int l_cnt = 0; - F->patrolpath.stream.open_chunk (WAYOBJECT_CHUNK_POINTS); - F->patrolpath.stream.w_u16 ((u16)m_WayPoints.size()); - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++){ - CWayPoint* W = *it; - F->patrolpath.stream.w_fvector3 (W->m_vPosition); - F->patrolpath.stream.w_u32 (W->m_Flags.get()); - F->patrolpath.stream.w_stringZ (*W->m_Name?*W->m_Name:""); - l_cnt += W->m_Links.size(); + F->patrolpath.stream.open_chunk(F->patrolpath.chunk++); + { + F->patrolpath.stream.open_chunk(WAYOBJECT_CHUNK_VERSION); + F->patrolpath.stream.w_u16(WAYOBJECT_VERSION); + F->patrolpath.stream.close_chunk(); + + F->patrolpath.stream.open_chunk(WAYOBJECT_CHUNK_NAME); + F->patrolpath.stream.w_stringZ(Name); + F->patrolpath.stream.close_chunk(); + + int l_cnt = 0; + F->patrolpath.stream.open_chunk(WAYOBJECT_CHUNK_POINTS); + F->patrolpath.stream.w_u16((u16)m_WayPoints.size()); + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + { + CWayPoint *W = *it; + F->patrolpath.stream.w_fvector3(W->m_vPosition); + F->patrolpath.stream.w_u32(W->m_Flags.get()); + F->patrolpath.stream.w_stringZ(*W->m_Name ? *W->m_Name : ""); + l_cnt += W->m_Links.size(); } - F->patrolpath.stream.close_chunk (); - - F->patrolpath.stream.open_chunk (WAYOBJECT_CHUNK_LINKS); - F->patrolpath.stream.w_u16 ((u16)l_cnt); - for (it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++){ - CWayPoint* W= *it; - int from = it-m_WayPoints.begin(); - for (WPLIt l_it=W->m_Links.begin(); l_it!=W->m_Links.end(); l_it++){ - WPIt to= std::find(m_WayPoints.begin(),m_WayPoints.end(),(*l_it)->way_point); R_ASSERT(to!=m_WayPoints.end()); - F->patrolpath.stream.w_u16 ((u16)from); - F->patrolpath.stream.w_u16 ((u16)(to-m_WayPoints.begin())); - F->patrolpath.stream.w_float ((*l_it)->probability); + F->patrolpath.stream.close_chunk(); + + F->patrolpath.stream.open_chunk(WAYOBJECT_CHUNK_LINKS); + F->patrolpath.stream.w_u16((u16)l_cnt); + for (it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + { + CWayPoint *W = *it; + int from = it-m_WayPoints.begin(); + for (WPLIt l_it = W->m_Links.begin(); l_it!=W->m_Links.end(); l_it++) + { + WPIt to = std::find(m_WayPoints.begin(), m_WayPoints.end(), (*l_it)->way_point); + R_ASSERT(to!=m_WayPoints.end()); + F->patrolpath.stream.w_u16((u16)from); + F->patrolpath.stream.w_u16((u16)(to-m_WayPoints.begin())); + F->patrolpath.stream.w_float((*l_it)->probability); } } - F->patrolpath.stream.close_chunk (); + F->patrolpath.stream.close_chunk(); } - F->patrolpath.stream.close_chunk (); + F->patrolpath.stream.close_chunk(); return true; } + //---------------------------------------------------- -CWayPoint* CWayObject::FindWayPoint(const shared_str& nm) +CWayPoint *CWayObject::FindWayPoint(const shared_str &nm) { - for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++) - if ((*it)->m_Name.equal(nm)) return *it; + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); it++) + if ((*it)->m_Name.equal(nm)) + return *it; return 0; } -bool CWayObject::OnWayPointNameAfterEdit(PropValue* sender, shared_str& edit_val) +bool CWayObject::OnWayPointNameAfterEdit(PropValue *sender, shared_str &edit_val) { - edit_val = AnsiString(edit_val.c_str()).LowerCase().c_str(); + edit_val = AnsiString(edit_val.c_str()).LowerCase().c_str(); return !FindWayPoint(edit_val); } -void CWayObject::FillProp(LPCSTR pref, PropItemVec& items) +void CWayObject::FillProp(LPCSTR pref, PropItemVec &items) { -//. inherited::FillProp (pref,items); + //. inherited::FillProp (pref,items); - PropValue* V; - V = PHelper().CreateNameCB (items, PrepareKey(pref, "Way Name"),&FName,NULL,NULL,RTextValue::TOnAfterEditEvent(this,&CCustomObject::OnObjectNameAfterEdit)); - V->OnChangeEvent.bind (this,&CCustomObject::OnNameChange); + PropValue *V; + V = PHelper().CreateNameCB(items, PrepareKey(pref, "Way Name"), &FName, NULL, NULL, RTextValue::TOnAfterEditEvent(this, &CCustomObject::OnObjectNameAfterEdit)); + V->OnChangeEvent.bind(this, &CCustomObject::OnNameChange); - if(IsPointMode()) + if (IsPointMode()) { - for(WPIt it=m_WayPoints.begin();it!=m_WayPoints.end();++it) + for (WPIt it = m_WayPoints.begin(); it!=m_WayPoints.end(); ++it) { - CWayPoint* W = *it; + CWayPoint *W = *it; if ((*it)->m_bSelected) { - PHelper().CreateNameCB (items, PrepareKey(pref,"Way Point\\Name"),&W->m_Name,0,0,fastdelegate::bind(this,&CWayObject::OnWayPointNameAfterEdit)); - PHelper().CreateVector (items, PrepareKey(pref,"Way Point\\Transform\\Position"), &W->m_vPosition, -10000, 10000, 0.01, 2); - - for (WPLIt l_it=W->m_Links.begin(); l_it!=W->m_Links.end(); l_it++) - PHelper().CreateFloat (items, PrepareKey(pref,"Way Point\\Links",*(*l_it)->way_point->m_Name),&(*l_it)->probability); - - for (int k=0; k<32; k++) - PHelper().CreateFlag32(items, PrepareKey(pref,"Way Point\\Flags",AnsiString(k).c_str()), &W->m_Flags, 1<m_Name, 0, 0, fastdelegate::bind(this, &CWayObject::OnWayPointNameAfterEdit)); + PHelper().CreateVector(items, PrepareKey(pref, "Way Point\\Transform\\Position"), &W->m_vPosition, -10000, 10000, 0.01, 2); + + for (WPLIt l_it = W->m_Links.begin(); l_it!=W->m_Links.end(); l_it++) + PHelper().CreateFloat(items, PrepareKey(pref, "Way Point\\Links", *(*l_it)->way_point->m_Name), &(*l_it)->probability); + + for (int k = 0; k<32; k++) + PHelper().CreateFlag32(items, PrepareKey(pref, "Way Point\\Flags", AnsiString(k).c_str()), &W->m_Flags, 1<m_vPosition; } - virtual void SetPosition (const Fvector& pos) { MoveTo(pos, Fvector().set(0,1,0) ); UpdateTransform();} + bool __stdcall OnWayPointNameAfterEdit(PropValue *sender, shared_str &edit_val); +public: + CWayObject(LPVOID data, LPCSTR name); + void Construct(LPVOID data); + virtual ~CWayObject(); + void Clear(); + + virtual bool CanAttach() + { + return true; + } + + EWayType GetType() + { + return m_Type; + } + + virtual void Select(int flag); + virtual bool RaySelect(int flag, const Fvector &start, const Fvector &dir, bool bRayTest = false); // flag 1,0,-1 (-1 invert) + virtual bool FrustumSelect(int flag, const CFrustum &frustum); + + CWayPoint *AppendWayPoint(); + CWayPoint *GetFirstSelected(); + int GetSelectedPoints(WPVec &lst); + void RemoveSelectedPoints(); + void RemoveLink(); + void InvertLink(); + void Convert1Link(); + void Convert2Link(); + bool Add1Link(); + bool Add2Link(); + // change position/orientation methods + virtual void MoveTo(const Fvector &pos, const Fvector &up); + virtual void Move(Fvector &amount); + + virtual void RotateParent(Fvector &axis, float angle) + { + ; + } + + virtual void RotateLocal(Fvector &axis, float angle) + { + ; + } + + virtual void RotatePivot(const Fmatrix &prev_inv, const Fmatrix ¤t) + { + ; + } + + virtual void Scale(Fvector &amount) + { + ; + } + + virtual void ScalePivot(const Fmatrix &prev_inv, const Fmatrix ¤t, Fvector &amount) + { + ; + } + + virtual bool GetBox(Fbox &box) const; + virtual void Render(int priority, bool strictB2F); + virtual bool RayPick(float &distance, const Fvector &S, const Fvector &D, SRayPickInfo *pinf = NULL); + virtual bool FrustumPick(const CFrustum &frustum); + + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); + + virtual bool ExportGame(SExportStreams *data); + + virtual void FillProp(LPCSTR pref, PropItemVec &items); + + virtual bool OnSelectionRemove(); + + virtual const Fvector &GetPosition() const + { + return m_WayPoints.front()->m_vPosition; + } + + virtual void SetPosition(const Fvector &pos) + { + MoveTo(pos, Fvector().set(0, 1, 0)); + UpdateTransform(); + } }; #endif /*_INCDEF_WayPoint_H_*/ diff --git a/src/editors/LevelEditor/Edit/glow.cpp b/src/editors/LevelEditor/Edit/glow.cpp index 52ae931e61e..be169012bb8 100644 --- a/src/editors/LevelEditor/Edit/glow.cpp +++ b/src/editors/LevelEditor/Edit/glow.cpp @@ -4,11 +4,11 @@ #include "stdafx.h" #pragma hdrstop -#include "Log.h" +#include "xrCore/Log.h" #include "Glow.h" -#include "xr_trims.h" -#include "bottombar.h" -#include "../../ecore/editor/D3DUtils.h" +#include "xrCore/xr_trims.h" +#include "BottomBar.h" +#include "editors/ECore/Editor/D3DUtils.h" #include "scene.h" #include "ESceneGlowTools.h" @@ -21,232 +21,268 @@ #define GLOW_CHUNK_FLAGS 0xC416 //---------------------------------------------------- -#define VIS_RADIUS 0.25f +#define VIS_RADIUS 0.25f -CGlow::CGlow(LPVOID data, LPCSTR name):CCustomObject(data,name){ - Construct(data); +CGlow::CGlow(LPVOID data, LPCSTR name): CCustomObject(data, name) +{ + Construct(data); } -void CGlow::Construct(LPVOID data){ - ClassID = OBJCLASS_GLOW; - m_GShader = 0; - m_fRadius = 0.5f; - m_bDefLoad = false; +void CGlow::Construct(LPVOID data) +{ + ClassID = OBJCLASS_GLOW; + m_GShader = 0; + m_fRadius = 0.5f; + m_bDefLoad = false; m_Flags.zero(); - m_ShaderName= "effects\\glow"; + m_ShaderName = "effects\\glow"; } CGlow::~CGlow() { - OnDeviceDestroy(); + OnDeviceDestroy(); } void CGlow::OnDeviceCreate() { - if (m_bDefLoad) return; - // ñîçäàòü çàíîâî shaders - if (m_TexName.size()&&m_ShaderName.size()) m_GShader.create(*m_ShaderName,*m_TexName); - m_bDefLoad = true; + if (m_bDefLoad) + return; + // ñîçäàòü çàíîâî shaders + if (m_TexName.size()&&m_ShaderName.size()) + m_GShader.create(*m_ShaderName, *m_TexName); + m_bDefLoad = true; } void CGlow::OnDeviceDestroy() { - m_bDefLoad = false; - // óäàëèòü shaders - m_GShader.destroy(); + m_bDefLoad = false; + // óäàëèòü shaders + m_GShader.destroy(); } -void CGlow::ShaderChange(PropValue* value) +void CGlow::ShaderChange(PropValue *value) { - OnDeviceDestroy(); + OnDeviceDestroy(); } -bool CGlow::GetBox( Fbox& box ) const +bool CGlow::GetBox(Fbox &box) const { - box.set( PPosition, PPosition ); - box.min.sub(m_fRadius); - box.max.add(m_fRadius); - return true; + box.set(PPosition, PPosition); + box.min.sub(m_fRadius); + box.max.add(m_fRadius); + return true; } void CGlow::Render(int priority, bool strictB2F) { if ((1==priority)&&(true==strictB2F)) { - if (!m_bDefLoad) OnDeviceCreate(); - ESceneGlowTool* gt = dynamic_cast(ParentTool); - VERIFY (gt); - RCache.set_xform_world (Fidentity); + if (!m_bDefLoad) + OnDeviceCreate(); + ESceneGlowTool *gt = dynamic_cast(ParentTool); + VERIFY(gt); + RCache.set_xform_world(Fidentity); if (gt->m_Flags.is(ESceneGlowTool::flTestVisibility)) - { + { Fvector D; - D.sub(EDevice.vCameraPosition,PPosition); - float dist = D.normalize_magn(); - if (!Scene->RayPickObject(dist,PPosition,D,OBJCLASS_SCENEOBJECT,0,0)){ - if (m_GShader){ EDevice.SetShader(m_GShader); - }else{ EDevice.SetShader(EDevice.m_WireShader);} - m_RenderSprite.Render(PPosition,m_fRadius,m_Flags.is(gfFixedSize)); + D.sub(EDevice.vCameraPosition, PPosition); + float dist = D.normalize_magn(); + if (!Scene->RayPickObject(dist, PPosition, D, OBJCLASS_SCENEOBJECT, 0, 0)) + { + if (m_GShader) + { + EDevice.SetShader(m_GShader); + } + else + { + EDevice.SetShader(EDevice.m_WireShader); + } + m_RenderSprite.Render(PPosition, m_fRadius, m_Flags.is(gfFixedSize)); DU_impl.DrawRomboid(PPosition, VIS_RADIUS, 0x00FF8507); - }else{ + } + else + { // ðåíäåðèì bounding sphere EDevice.SetShader(EDevice.m_WireShader); DU_impl.DrawRomboid(PPosition, VIS_RADIUS, 0x00FF8507); } - }else{ - if (m_GShader){ EDevice.SetShader(m_GShader); - }else{ EDevice.SetShader(EDevice.m_WireShader);} - m_RenderSprite.Render(PPosition,m_fRadius,m_Flags.is(gfFixedSize)); } - if( Selected() ){ - Fbox bb; GetBox(bb); + else + { + if (m_GShader) + { + EDevice.SetShader(m_GShader); + } + else + { + EDevice.SetShader(EDevice.m_WireShader); + } + m_RenderSprite.Render(PPosition, m_fRadius, m_Flags.is(gfFixedSize)); + } + if (Selected()) + { + Fbox bb; + GetBox(bb); u32 clr = 0xFFFFFFFF; EDevice.SetShader(EDevice.m_WireShader); - DU_impl.DrawSelectionBoxB(bb,&clr); + DU_impl.DrawSelectionBoxB(bb, &clr); if (gt->m_Flags.is(ESceneGlowTool::flDrawCross)) { - Fvector sz; bb.getradius(sz); - DU_impl.DrawCross(PPosition,sz.x,sz.y,sz.z, sz.x,sz.y,sz.z,0xFFFFFFFF,false); + Fvector sz; + bb.getradius(sz); + DU_impl.DrawCross(PPosition, sz.x, sz.y, sz.z, sz.x, sz.y, sz.z, 0xFFFFFFFF, false); } } } } -bool CGlow::FrustumPick(const CFrustum& frustum) +bool CGlow::FrustumPick(const CFrustum &frustum) { - return (frustum.testSphere_dirty(PPosition,m_fRadius))?true:false; + return (frustum.testSphere_dirty(PPosition, m_fRadius)) ? true : false; } -bool CGlow::RayPick(float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf) +bool CGlow::RayPick(float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf) { - Fvector ray2; - ray2.sub( PPosition, start ); + Fvector ray2; + ray2.sub(PPosition, start); float d = ray2.dotproduct(direction); - if( d > 0 ){ + if (d>0) + { float d2 = ray2.magnitude(); - if( ((d2*d2-d*d) < (m_fRadius*m_fRadius)) && (d>m_fRadius) ){ - if (dm_fRadius)) + { + if (dOnChangeEvent.bind(this,&CGlow::ShaderChange); - V=PHelper().CreateChoose (items,PrepareKey(pref,"Shader"), &m_ShaderName, smEShader); V->OnChangeEvent.bind(this,&CGlow::ShaderChange); - PHelper().CreateFloat (items,PrepareKey(pref,"Radius"), &m_fRadius, 0.01f,10000.f); -//. PHelper().CreateFlag(items,PHelper().PrepareKey(pref,"Fixed size"), &m_Flags, gfFixedSize); + inherited::FillProp(pref, items); + PropValue *V = 0; + V = PHelper().CreateChoose(items, PrepareKey(pref, "Texture"), &m_TexName, smTexture); + V->OnChangeEvent.bind(this, &CGlow::ShaderChange); + V = PHelper().CreateChoose(items, PrepareKey(pref, "Shader"), &m_ShaderName, smEShader); + V->OnChangeEvent.bind(this, &CGlow::ShaderChange); + PHelper().CreateFloat(items, PrepareKey(pref, "Radius"), &m_fRadius, 0.01f, 10000.f); + //. PHelper().CreateFlag(items,PHelper().PrepareKey(pref,"Fixed size"), &m_Flags, gfFixedSize); } + //---------------------------------------------------- -bool CGlow::GetSummaryInfo(SSceneSummary* inf) +bool CGlow::GetSummaryInfo(SSceneSummary *inf) { - inherited::GetSummaryInfo (inf); - if (m_TexName.size()) inf->AppendTexture(ChangeFileExt(*m_TexName,"").LowerCase().c_str(),SSceneSummary::sttGlow,0,0,"$GLOW$"); - inf->glow_cnt++; - return true; + inherited::GetSummaryInfo(inf); + if (m_TexName.size()) + inf->AppendTexture(ChangeFileExt(*m_TexName, "").LowerCase().c_str(), SSceneSummary::sttGlow, 0, 0, "$GLOW$"); + inf->glow_cnt++; + return true; } diff --git a/src/editors/LevelEditor/Edit/glow.h b/src/editors/LevelEditor/Edit/glow.h index 0f1e1693043..0d26ec26de7 100644 --- a/src/editors/LevelEditor/Edit/glow.h +++ b/src/editors/LevelEditor/Edit/glow.h @@ -5,56 +5,80 @@ #ifndef GlowH #define GlowH -#include "../ECore/Editor/tlsprite.h" -#include "customobject.h" +#include "editors/ECore/Editor/TLSprite.h" +#include "CustomObject.h" class CFrustum; class CGlow : public CCustomObject { - typedef CCustomObject inherited ; - CTLSprite m_RenderSprite; + typedef CCustomObject inherited; + CTLSprite m_RenderSprite; public: - enum EFlags{ - gfFixedSize = (1<<0), - gfForce_u8 = u8(-1) + enum EFlags + { + gfFixedSize = (1<<0), + gfForce_u8 = u8(-1) }; - ref_shader m_GShader; - shared_str m_ShaderName; - shared_str m_TexName; - float m_fRadius; - Flags8 m_Flags; - - bool m_bDefLoad; - void ShaderChange (PropValue* value); + + ref_shader m_GShader; + shared_str m_ShaderName; + shared_str m_TexName; + float m_fRadius; + Flags8 m_Flags; + + bool m_bDefLoad; + void ShaderChange(PropValue *value); protected: - virtual const Fvector& GetScale () const { FScale.set(m_fRadius,m_fRadius,m_fRadius); return FScale; } - virtual void SetScale (const Fvector& sc){float v=m_fRadius; if (!fsimilar(FScale.x,sc.x)) v=sc.x; if (!fsimilar(FScale.y,sc.y)) v=sc.y; if (!fsimilar(FScale.z,sc.z)) v=sc.z; FScale.set(v,v,v); m_fRadius=v; UpdateTransform();} + virtual const Fvector &GetScale() const + { + FScale.set(m_fRadius, m_fRadius, m_fRadius); + return FScale; + } + + virtual void SetScale(const Fvector &sc) + { + float v = m_fRadius; + if (!fsimilar(FScale.x, sc.x)) + v = sc.x; + if (!fsimilar(FScale.y, sc.y)) + v = sc.y; + if (!fsimilar(FScale.z, sc.z)) + v = sc.z; + FScale.set(v, v, v); + m_fRadius = v; + UpdateTransform(); + } + public: - CGlow (LPVOID data, LPCSTR name); - void Construct (LPVOID data); - virtual ~CGlow (); - virtual bool CanAttach () {return true;} + CGlow(LPVOID data, LPCSTR name); + void Construct(LPVOID data); + virtual ~CGlow(); + + virtual bool CanAttach() + { + return true; + } - void Compile (); + void Compile(); - virtual void Render (int priority, bool strictB2F); - virtual bool RayPick ( float& distance, const Fvector& start, const Fvector& direction, - SRayPickInfo* pinf = NULL ); - virtual bool FrustumPick ( const CFrustum& frustum ); + virtual void Render(int priority, bool strictB2F); + virtual bool RayPick(float &distance, const Fvector &start, const Fvector &direction, + SRayPickInfo *pinf = NULL); + virtual bool FrustumPick(const CFrustum &frustum); - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); - virtual bool GetBox ( Fbox& box ) const; - virtual void FillProp ( LPCSTR pref, PropItemVec& values ); + virtual bool GetBox(Fbox &box) const; + virtual void FillProp(LPCSTR pref, PropItemVec &values); // device dependent routine - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); - virtual bool GetSummaryInfo(SSceneSummary* inf); + virtual bool GetSummaryInfo(SSceneSummary *inf); }; #endif /*_INCDEF_Glow_H_*/ diff --git a/src/editors/LevelEditor/Edit/portal.cpp b/src/editors/LevelEditor/Edit/portal.cpp index 82c77fd1e0e..ae8ca057519 100644 --- a/src/editors/LevelEditor/Edit/portal.cpp +++ b/src/editors/LevelEditor/Edit/portal.cpp @@ -11,189 +11,226 @@ #include "sector.h" #include "MgcConvexHull2D.h" #include "MgcAppr3DPlaneFit.h" -#include "../../ecore/editor/D3DUtils.h" -#include "../ECore/Editor/ui_main.h" -#include "ui_leveltools.h" +#include "editors/ECore/Editor/D3DUtils.h" +#include "editors/ECore/Editor/ui_main.h" +#include "UI_LevelTools.h" #include "SceneObject.h" -#define PORTAL_VERSION 0x0010 +#define PORTAL_VERSION 0x0010 //------------------------------------------------------------------------------ -#define PORTAL_CHUNK_VERSION 0xFA10 -#define PORTAL_CHUNK_COLOR 0xFA20 -#define PORTAL_CHUNK_SECTOR_FRONT 0xFA30 -#define PORTAL_CHUNK_SECTOR_BACK 0xFA40 -#define PORTAL_CHUNK_VERTICES 0xFA50 +#define PORTAL_CHUNK_VERSION 0xFA10 +#define PORTAL_CHUNK_COLOR 0xFA20 +#define PORTAL_CHUNK_SECTOR_FRONT 0xFA30 +#define PORTAL_CHUNK_SECTOR_BACK 0xFA40 +#define PORTAL_CHUNK_VERTICES 0xFA50 + //------------------------------------------------------------------------------ -CPortal::CPortal(LPVOID data, LPCSTR name):CCustomObject(data,name){ - Construct(data); +CPortal::CPortal(LPVOID data, LPCSTR name): CCustomObject(data, name) +{ + Construct(data); } + //------------------------------------------------------------------------------ -void CPortal::Construct(LPVOID data){ - ClassID = OBJCLASS_PORTAL; - m_Center.set(0,0,0); - m_SectorFront=0; - m_SectorBack=0; +void CPortal::Construct(LPVOID data) +{ + ClassID = OBJCLASS_PORTAL; + m_Center.set(0, 0, 0); + m_SectorFront = 0; + m_SectorBack = 0; } + //------------------------------------------------------------------------------ -CPortal::~CPortal(){ -} +CPortal::~CPortal() {} + //------------------------------------------------------------------------------ -bool CPortal::GetBox( Fbox& box ) const +bool CPortal::GetBox(Fbox &box) const { - if( m_Vertices.empty() ) + if (m_Vertices.empty()) { - box.set(0,0,0, 0,0,0); - return false; + box.set(0, 0, 0, 0, 0, 0); + return false; } - - box.set( m_Vertices[0], m_Vertices[0] ); - for( FvectorVec::const_iterator pt=m_Vertices.begin()+1; pt!=m_Vertices.end(); pt++) - box.modify(*pt); - - return true; + + box.set(m_Vertices[0], m_Vertices[0]); + for (FvectorVec::const_iterator pt = m_Vertices.begin()+1; pt!=m_Vertices.end(); pt++) + box.modify(*pt); + + return true; } + //------------------------------------------------------------------------------ void CPortal::Render(int priority, bool strictB2F) { - if ((1==priority)&&(false==strictB2F)){ - FvectorVec& src = m_SimplifyVertices;//(fraBottomBar->miDrawPortalSimpleModel->Checked)?m_SimplifyVertices:m_Vertices; - if (src.size()<2) return; - - EDevice.SetShader (EDevice.m_WireShader); - RCache.set_xform_world (Fidentity); - - u32 i; - FvectorVec V; - V.resize (src.size()+2); - V[0].set (m_Center); - for(i=0; imiDrawPortalSimpleModel->Checked)?m_SimplifyVertices:m_Vertices; + if (src.size()<2) + return; + + EDevice.SetShader(EDevice.m_WireShader); + RCache.set_xform_world(Fidentity); + + u32 i; + FvectorVec V; + V.resize(src.size()+2); + V[0].set(m_Center); + for (i = 0; isector_color); - if (!Selected())col.mul_rgb(0.7f); - EDevice.SetRS(D3DRS_CULLMODE,D3DCULL_CCW); - DU_impl.DrawPrimitiveL (D3DPT_TRIANGLEFAN, V.size()-2, V.begin(), V.size(), col.get(), true, false); - EDevice.SetRS(D3DRS_CULLMODE,D3DCULL_CCW); + if (m_SectorFront) + { + col.set(m_SectorFront->sector_color); + if (!Selected()) + col.mul_rgb(0.7f); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CCW); + DU_impl.DrawPrimitiveL(D3DPT_TRIANGLEFAN, V.size()-2, V.begin(), V.size(), col.get(), true, false); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CCW); } // back - if (m_SectorBack){ - col.set (m_SectorBack->sector_color); - if (!Selected())col.mul_rgb(0.7f); - EDevice.SetRS(D3DRS_CULLMODE,D3DCULL_CW); - DU_impl.DrawPrimitiveL (D3DPT_TRIANGLEFAN, V.size()-2, V.begin(), V.size(), col.get(), true, false); - EDevice.SetRS(D3DRS_CULLMODE,D3DCULL_CCW); + if (m_SectorBack) + { + col.set(m_SectorBack->sector_color); + if (!Selected()) + col.mul_rgb(0.7f); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CW); + DU_impl.DrawPrimitiveL(D3DPT_TRIANGLEFAN, V.size()-2, V.begin(), V.size(), col.get(), true, false); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CCW); } - col.set (1.f,1.f,1.f,1.f); - EDevice.RenderNearer(0.0002); - if (!Selected()) col.mul_rgb(0.5f); - // render portal edges - EScenePortalTool* lt = dynamic_cast(ParentTool); VERIFY(lt); - FvectorVec& src_ln = (lt->m_Flags.is(EScenePortalTool::flDrawSimpleModel))?m_SimplifyVertices:m_Vertices; - DU_impl.DrawPrimitiveL (D3DPT_LINESTRIP, src_ln.size(), src_ln.begin(), src_ln.size(), col.get(), true, true); - EDevice.ResetNearer (); - DU_impl.DrawFaceNormal (m_Center,m_Normal,1,0xFFFFFFFF); - DU_impl.DrawFaceNormal (m_Center,m_Normal,1,0x00000000); -/* for (int k=0; k<1000; k++){ - Fvector dir; - dir.random_dir(m_Normal,deg2rad(45.f)); - DU.DrawFaceNormal (m_Center,dir,1,0x00FF0000); - } -*/ - } + col.set(1.f, 1.f, 1.f, 1.f); + EDevice.RenderNearer(0.0002); + if (!Selected()) + col.mul_rgb(0.5f); + // render portal edges + EScenePortalTool *lt = dynamic_cast(ParentTool); + VERIFY(lt); + FvectorVec &src_ln = (lt->m_Flags.is(EScenePortalTool::flDrawSimpleModel)) ? m_SimplifyVertices : m_Vertices; + DU_impl.DrawPrimitiveL(D3DPT_LINESTRIP, src_ln.size(), src_ln.begin(), src_ln.size(), col.get(), true, true); + EDevice.ResetNearer(); + DU_impl.DrawFaceNormal(m_Center, m_Normal, 1, 0xFFFFFFFF); + DU_impl.DrawFaceNormal(m_Center, m_Normal, 1, 0x00000000); + /* for (int k=0; k<1000; k++){ + Fvector dir; + dir.random_dir(m_Normal,deg2rad(45.f)); + DU.DrawFaceNormal (m_Center,dir,1,0x00FF0000); + } + */ + } } + //------------------------------------------------------------------------------ -void CPortal::Move( Fvector& amount ){ -// internal use only!!! - FvectorIt v_it; - for(v_it=m_Vertices.begin(); v_it!=m_Vertices.end(); v_it++) - v_it->add(amount); - for(v_it=m_SimplifyVertices.begin(); v_it!=m_SimplifyVertices.end(); v_it++) - v_it->add(amount); +void CPortal::Move(Fvector &amount) +{ + // internal use only!!! + FvectorIt v_it; + for (v_it = m_Vertices.begin(); v_it!=m_Vertices.end(); v_it++) + v_it->add(amount); + for (v_it = m_SimplifyVertices.begin(); v_it!=m_SimplifyVertices.end(); v_it++) + v_it->add(amount); m_Center.add(amount); } + //------------------------------------------------------------------------------ -bool CPortal::FrustumPick(const CFrustum& frustum){ - if (frustum.testPolyInside(m_Vertices.begin(),m_Vertices.size())) return true; +bool CPortal::FrustumPick(const CFrustum &frustum) +{ + if (frustum.testPolyInside(m_Vertices.begin(), m_Vertices.size())) + return true; return false; } + //------------------------------------------------------------------------------ -bool CPortal::RayPick(float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf) +bool CPortal::RayPick(float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf) { - Fvector p[3]; + Fvector p[3]; float range; - bool bPick=false; - p[0].set(m_Center); - EScenePortalTool* lt = dynamic_cast(ParentTool); VERIFY(lt); - FvectorVec& src=(lt->m_Flags.is(EScenePortalTool::flDrawSimpleModel))?m_SimplifyVertices:m_Vertices; - for(FvectorIt it=src.begin(); it!=src.end(); it++){ - p[1].set(*it); - p[2].set(((it+1)==src.end())?src.front():*(it+1)); - range=UI->ZFar(); - if (CDB::TestRayTri2(start,direction,p,range)){ - if ((range>=0)&&(range(ParentTool); + VERIFY(lt); + FvectorVec &src = (lt->m_Flags.is(EScenePortalTool::flDrawSimpleModel)) ? m_SimplifyVertices : m_Vertices; + for (FvectorIt it = src.begin(); it!=src.end(); it++) + { + p[1].set(*it); + p[2].set(((it+1)==src.end()) ? src.front() : *(it+1)); + range = UI->ZFar(); + if (CDB::TestRayTri2(start, direction, p, range)) + { + if ((range>=0)&&(range=3); - for (u32 i=0; im_DebugDraw.AppendWireFace(m_Vertices[0],m_Vertices[1],m_Vertices[2]); - ELog.Msg(mtError,"Portal: Degenerate portal found."); + float m = m_Normal.magnitude(); + if (fabsf(m)<=EPS_S) + { + Tools->m_DebugDraw.AppendWireFace(m_Vertices[0], m_Vertices[1], m_Vertices[2]); + ELog.Msg(mtError, "Portal: Degenerate portal found."); SetValid(false); - return false; + return false; } m_Normal.div(m); // simplify portal - Simplify(); + Simplify(); if (!bLoadMode) { - xr_map A,B; + xr_map A, B; Fvector SF_dir, SB_dir; Fvector InvNorm; InvNorm.invert(m_Normal); float dist; - for (int k=0; k<100; k++) + for (int k = 0; k<100; k++) { - SF_dir.random_dir(m_Normal,PI_DIV_4); - SB_dir.random_dir(InvNorm,PI_DIV_4); - dist=1000; if (m_SectorFront->RayPick(dist,m_Center,SF_dir)) A[m_SectorFront] += 1; - dist=1000; if (m_SectorBack->RayPick(dist,m_Center,SB_dir)) A[m_SectorBack] += 1; - dist=1000; if (m_SectorFront->RayPick(dist,m_Center,SB_dir)) B[m_SectorFront] += 1; - dist=1000; if (m_SectorBack->RayPick(dist,m_Center,SF_dir)) B[m_SectorBack] += 1; + SF_dir.random_dir(m_Normal, PI_DIV_4); + SB_dir.random_dir(InvNorm, PI_DIV_4); + dist = 1000; + if (m_SectorFront->RayPick(dist, m_Center, SF_dir)) + A[m_SectorFront] += 1; + dist = 1000; + if (m_SectorBack->RayPick(dist, m_Center, SB_dir)) + A[m_SectorBack] += 1; + dist = 1000; + if (m_SectorFront->RayPick(dist, m_Center, SB_dir)) + B[m_SectorFront] += 1; + dist = 1000; + if (m_SectorBack->RayPick(dist, m_Center, SF_dir)) + B[m_SectorBack] += 1; } int a = A[m_SectorFront]+A[m_SectorBack]; int b = B[m_SectorFront]+B[m_SectorBack]; @@ -201,353 +238,405 @@ bool CPortal::Update(bool bLoadMode){ else if (aRedrawScene(); - if (bUndo) Scene->UndoSave(); + if (bUndo) + Scene->UndoSave(); } + //------------------------------------------------------------------------------ double tri_area(Fvector2 P0, Fvector2 P1, Fvector2 P2) { - double e1 = P0.distance_to(P1); - double e2 = P1.distance_to(P2); - double e3 = P2.distance_to(P0); + double e1 = P0.distance_to(P1); + double e2 = P1.distance_to(P2); + double e3 = P2.distance_to(P0); - double p = (e1+e2+e3)/2.0; - return sqrt(p*(p-e1)*(p-e2)*(p-e3)); + double p = (e1+e2+e3)/2.0; + return sqrt(p*(p-e1)*(p-e2)*(p-e3)); } + //------------------------------------------------------------------------------ -bool Isect2DLvs2DL (Fvector2& P1, Fvector2& P2, Fvector2& P3, Fvector2& P4, Fvector2& P) +bool Isect2DLvs2DL(Fvector2 &P1, Fvector2 &P2, Fvector2 &P3, Fvector2 &P4, Fvector2 &P) { - double a1, a2, b1, b2, c1, c2; /* Coefficients of line eqns. */ - double r1, r2, r3, r4; /* 'Sign' values */ - double denom, num; /* Intermediate values */ + double a1, a2, b1, b2, c1, c2; /* Coefficients of line eqns. */ + double r1, r2, r3, r4; /* 'Sign' values */ + double denom, num; /* Intermediate values */ - /* Compute a1, b1, c1, where line joining points 1 and 2 - * is "a1 x + b1 y + c1 = 0". */ + /* Compute a1, b1, c1, where line joining points 1 and 2 + * is "a1 x + b1 y + c1 = 0". */ - a1 = P2.y - P1.y; - b1 = P1.x - P2.x; - c1 = P2.x * P1.y - P1.x * P2.y; + a1 = P2.y-P1.y; + b1 = P1.x-P2.x; + c1 = P2.x*P1.y-P1.x*P2.y; /* Compute a2, b2, c2 */ - a2 = P4.y - P3.y; - b2 = P3.x - P4.x; - c2 = P4.x * P3.y - P3.x * P4.y; + a2 = P4.y-P3.y; + b2 = P3.x-P4.x; + c2 = P4.x*P3.y-P3.x*P4.y; /* Lines intersect: compute intersection point. - */ + */ - denom = a1 * b2 - a2 * b1; - if ( fabs(denom) < EPS ) return false; + denom = a1*b2-a2*b1; + if (fabs(denom)=int(vertices.size())) L2a -= vertices.size(); - int L2b = I+2; if (L2b>=int(vertices.size())) L2b -= vertices.size(); + int L2a = I+1; + if (L2a>=int(vertices.size())) + L2a -= vertices.size(); + int L2b = I+2; + if (L2b>=int(vertices.size())) + L2b -= vertices.size(); Fvector2 P_Test; - if (!Isect2DLvs2DL(vertices[L1a],vertices[L1b],vertices[L2b],vertices[L2a],P_Test)) continue; + if (!Isect2DLvs2DL(vertices[L1a], vertices[L1b], vertices[L2b], vertices[L2a], P_Test)) + continue; - double area = tri_area(vertices[L1b],P_Test,vertices[L2a]); //*(vertices[L1b].dist(vertices[L2a])); + double area = tri_area(vertices[L1b], P_Test, vertices[L2a]); //*(vertices[L1b].dist(vertices[L2a])); - if (area=int(vertices.size())) L2a -= vertices.size(); + int L2a = edge_id+1; + if (L2a>=int(vertices.size())) + L2a -= vertices.size(); vertices[L1b] = P; vertices.erase(vertices.begin()+L2a); } + //------------------------------------------------------------------------------ void CPortal::Simplify() { - Fvector rkOffset; + Fvector rkOffset; Fvector rkNormal; // compute plane Fplane P; - Mgc::OrthogonalPlaneFit(m_Vertices.size(), (Mgc::Vector3*)m_Vertices.begin(), (Mgc::Vector3&)rkOffset, (Mgc::Vector3&)rkNormal); + Mgc::OrthogonalPlaneFit(m_Vertices.size(), (Mgc::Vector3*)m_Vertices.begin(), (Mgc::Vector3&)rkOffset, (Mgc::Vector3&)rkNormal); P.build(rkOffset, rkNormal); // project points - Fmatrix mView; - Fvector at,from,up,right,y; - from.set (rkOffset); - at.sub (from,rkNormal); - y.set (0,1,0); - if (fabsf(rkNormal.y)>0.99f) y.set(1,0,0); - right.crossproduct(y,rkNormal); right.normalize(); - up.crossproduct(rkNormal,right);up.normalize(); - mView.build_camera(from,at,up); + Fmatrix mView; + Fvector at, from, up, right, y; + from.set(rkOffset); + at.sub(from, rkNormal); + y.set(0, 1, 0); + if (fabsf(rkNormal.y)>0.99f) + y.set(1, 0, 0); + right.crossproduct(y, rkNormal); + right.normalize(); + up.crossproduct(rkNormal, right); + up.normalize(); + mView.build_camera(from, at, up); Fvector2Vec points, vertices; Fvector p; points.resize(m_Vertices.size()); - for (u32 k=0; k marks(Count,false); - marks[0]=true; - for (int A=0; A marks(Count,false); + marks[0]=true; + for (int A=0; AXR_MAX_PORTAL_VERTS){ - int f_cnt=vertices.size(); - SimplifyVertices(vertices); - if (f_cnt==int(vertices.size())){ SetValid(false); return; } + while (vertices.size()>XR_MAX_PORTAL_VERTS) + { + int f_cnt = vertices.size(); + SimplifyVertices(vertices); + if (f_cnt==int(vertices.size())) + { + SetValid(false); + return; + } } - if (vertices.size()<=2){ SetValid(false); return; } - else SetValid(true); + if (vertices.size()<=2) + { + SetValid(false); + return; + } + else + SetValid(true); // convert to 3D & check portal normal Fvector center, temp, norm; - center.set(0,0,0); + center.set(0, 0, 0); mView.invert(); m_SimplifyVertices.resize(vertices.size()); - for (k=0; kEPS); norm.div(m); + float m = norm.magnitude(); + VERIFY(fabsf(m)>EPS); + norm.div(m); - if (norm.dotproduct(m_Normal)<0){ - std::reverse(m_SimplifyVertices.begin(), m_SimplifyVertices.end()); - m_Normal.invert(norm); - }else{ - m_Normal.set(norm); + if (norm.dotproduct(m_Normal)<0) + { + std::reverse(m_SimplifyVertices.begin(), m_SimplifyVertices.end()); + m_Normal.invert(norm); + } + else + { + m_Normal.set(norm); } } + //------------------------------------------------------------------------------ -bool CPortal::LoadLTX(CInifile& ini, LPCSTR sect_name) +bool CPortal::LoadLTX(CInifile &ini, LPCSTR sect_name) { - u32 version = ini.r_u32(sect_name, "version"); + u32 version = ini.r_u32(sect_name, "version"); - if( version!=PORTAL_VERSION ) + if (version!=PORTAL_VERSION) { - ELog.Msg( mtError, "CPortal: Unsupported version."); + ELog.Msg(mtError, "CPortal: Unsupported version."); return false; } - CCustomObject::LoadLTX(ini, sect_name); - LPCSTR str; - str = ini.r_string (sect_name, "sector_front"); - m_SectorFront = (CSector*)Scene->FindObjectByName(str,OBJCLASS_SECTOR); + CCustomObject::LoadLTX(ini, sect_name); + LPCSTR str; + str = ini.r_string(sect_name, "sector_front"); + m_SectorFront = (CSector*)Scene->FindObjectByName(str, OBJCLASS_SECTOR); - str = ini.r_string (sect_name, "sector_back"); - m_SectorBack = (CSector*)Scene->FindObjectByName(str,OBJCLASS_SECTOR); + str = ini.r_string(sect_name, "sector_back"); + m_SectorBack = (CSector*)Scene->FindObjectByName(str, OBJCLASS_SECTOR); if (!m_SectorBack||!m_SectorFront) { - ELog.Msg( mtError, "Portal: Can't find required sectors.\nObject '%s' can't load.", Name); - return false; + ELog.Msg(mtError, "Portal: Can't find required sectors.\nObject '%s' can't load.", Name); + return false; } - u32 cnt = ini.r_u32(sect_name, "vert_count"); - m_Vertices.resize (cnt); - string512 buff; - for(u32 i=0; iName:""); - ini.w_string (sect_name, "sector_back", m_SectorBack?m_SectorBack->Name:""); + ini.w_string(sect_name, "sector_front", m_SectorFront ? m_SectorFront->Name : ""); + ini.w_string(sect_name, "sector_back", m_SectorBack ? m_SectorBack->Name : ""); - ini.w_u32 (sect_name, "vert_count", m_Vertices.size()); - string512 buff; - for(u32 i=0; iFindObjectByName(buf,OBJCLASS_SECTOR); + if (F.find_chunk(PORTAL_CHUNK_SECTOR_FRONT)) + { + F.r_stringZ(buf, sizeof(buf)); + m_SectorFront = (CSector*)Scene->FindObjectByName(buf, OBJCLASS_SECTOR); } - if (F.find_chunk (PORTAL_CHUNK_SECTOR_BACK)){ - F.r_stringZ (buf,sizeof(buf)); - m_SectorBack=(CSector*)Scene->FindObjectByName(buf,OBJCLASS_SECTOR); + if (F.find_chunk(PORTAL_CHUNK_SECTOR_BACK)) + { + F.r_stringZ(buf, sizeof(buf)); + m_SectorBack = (CSector*)Scene->FindObjectByName(buf, OBJCLASS_SECTOR); } - if (!m_SectorBack||!m_SectorFront){ - ELog.Msg( mtError, "Portal: Can't find required sectors.\nObject '%s' can't load.", Name); - return false; + if (!m_SectorBack||!m_SectorFront) + { + ELog.Msg(mtError, "Portal: Can't find required sectors.\nObject '%s' can't load.", Name); + return false; } R_ASSERT(F.find_chunk(PORTAL_CHUNK_VERTICES)); - m_Vertices.resize(F.r_u16()); - F.r (m_Vertices.begin(), m_Vertices.size()*sizeof(Fvector)); + m_Vertices.resize(F.r_u16()); + F.r(m_Vertices.begin(), m_Vertices.size()*sizeof(Fvector)); - if (m_Vertices.size()<3){ - ELog.Msg( mtError, "Portal: '%s' can't create.\nInvalid portal. (m_Vertices.size()<3)", Name); - return false; + if (m_Vertices.size()<3) + { + ELog.Msg(mtError, "Portal: '%s' can't create.\nInvalid portal. (m_Vertices.size()<3)", Name); + return false; } Update(true); return true; } + //------------------------------------------------------------------------------ -void CPortal::SaveStream(IWriter& F) +void CPortal::SaveStream(IWriter &F) { - CCustomObject::SaveStream(F); + CCustomObject::SaveStream(F); - F.open_chunk (PORTAL_CHUNK_VERSION); - F.w_u16 (PORTAL_VERSION); - F.close_chunk (); + F.open_chunk(PORTAL_CHUNK_VERSION); + F.w_u16(PORTAL_VERSION); + F.close_chunk(); - if (m_SectorFront){ - F.open_chunk (PORTAL_CHUNK_SECTOR_FRONT); - F.w_stringZ (m_SectorFront->Name); - F.close_chunk (); + if (m_SectorFront) + { + F.open_chunk(PORTAL_CHUNK_SECTOR_FRONT); + F.w_stringZ(m_SectorFront->Name); + F.close_chunk(); } - if (m_SectorBack){ - F.open_chunk (PORTAL_CHUNK_SECTOR_BACK); - F.w_stringZ (m_SectorBack->Name); - F.close_chunk (); + if (m_SectorBack) + { + F.open_chunk(PORTAL_CHUNK_SECTOR_BACK); + F.w_stringZ(m_SectorBack->Name); + F.close_chunk(); } - F.open_chunk (PORTAL_CHUNK_VERTICES); - F.w_u16 ((u16)m_Vertices.size()); - F.w (m_Vertices.begin(),m_Vertices.size()*sizeof(Fvector)); - F.close_chunk (); + F.open_chunk(PORTAL_CHUNK_VERTICES); + F.w_u16((u16)m_Vertices.size()); + F.w(m_Vertices.begin(), m_Vertices.size()*sizeof(Fvector)); + F.close_chunk(); } + //------------------------------------------------------------------------------ -bool CPortal::GetSummaryInfo(SSceneSummary* inf) +bool CPortal::GetSummaryInfo(SSceneSummary *inf) { - inherited::GetSummaryInfo (inf); - inf->portal_cnt++; - return true; + inherited::GetSummaryInfo(inf); + inf->portal_cnt++; + return true; } diff --git a/src/editors/LevelEditor/Edit/portalutils.cpp b/src/editors/LevelEditor/Edit/portalutils.cpp index 62b676b0f84..af95a31e0a2 100644 --- a/src/editors/LevelEditor/Edit/portalutils.cpp +++ b/src/editors/LevelEditor/Edit/portalutils.cpp @@ -8,115 +8,133 @@ #include "Scene.h" #include "Portal.h" #include "Sector.h" -#include "../ECore/Editor/EditMesh.h" -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/EditObject.h" #include "SceneObject.h" -#include "../ECore/Editor/Library.h" -#include "../ECore/Editor/ui_main.h" -#include "ui_leveltools.h" +#include "editors/ECore/Editor/Library.h" +#include "editors/ECore/Editor/ui_main.h" +#include "UI_LevelTools.h" CPortalUtils PortalUtils; #define EPS_P 0.001f -CSector* CPortalUtils::GetSelectedSector() +CSector *CPortalUtils::GetSelectedSector() { - ObjectList lst; - Scene->GetQueryObjects(lst,OBJCLASS_SECTOR,1,1,0); - if (lst.size()==0) return 0; - if (lst.size()>1){ - ELog.DlgMsg(mtError,"Please select only one sector."); - return 0; + ObjectList lst; + Scene->GetQueryObjects(lst, OBJCLASS_SECTOR, 1, 1, 0); + if (lst.size()==0) + return 0; + if (lst.size()>1) + { + ELog.DlgMsg(mtError, "Please select only one sector."); + return 0; } - CSector* sector=(CSector*)*lst.begin(); + CSector *sector = (CSector*)*lst.begin(); VERIFY(sector); return sector; } -void CPortalUtils::RemoveSectorPortal(CSector* S) +void CPortalUtils::RemoveSectorPortal(CSector *S) { // remove existence sector portal - ObjectList& lst = Scene->ListObj(OBJCLASS_PORTAL); + ObjectList &lst = Scene->ListObj(OBJCLASS_PORTAL); ObjectIt _I = lst.begin(); ObjectIt _E = lst.end(); - for (;_I!=_E;_I++){ - CPortal* P=(CPortal*)(*_I); - if((P->m_SectorFront==S)||(P->m_SectorBack==S)) + for (; _I!=_E; _I++) + { + CPortal *P = (CPortal*)(*_I); + if ((P->m_SectorFront==S)||(P->m_SectorBack==S)) xr_delete(*_I); } - _I = remove(lst.begin(),lst.end(),(CCustomObject*)0); - lst.erase(_I,lst.end()); + _I = remove(lst.begin(), lst.end(), (CCustomObject*)0); + lst.erase(_I, lst.end()); } int CPortalUtils::CalculateSelectedPortals() { - int iPCount=0; - if (Validate(false)){ + int iPCount = 0; + if (Validate(false)) + { // get selected sectors ObjectList s_lst; - int s_cnt=Scene->GetQueryObjects(s_lst, OBJCLASS_SECTOR, 1, 1, -1); - if (s_cnt<2){ - ELog.DlgMsg(mtError,"Select at least 2 sectors."); + int s_cnt = Scene->GetQueryObjects(s_lst, OBJCLASS_SECTOR, 1, 1, -1); + if (s_cnt<2) + { + ELog.DlgMsg(mtError, "Select at least 2 sectors."); return 0; } // remove exists portals - ObjectList& p_lst=Scene->ListObj(OBJCLASS_PORTAL); - for(ObjectIt _F=p_lst.begin(); _F!=p_lst.end(); _F++){ - CSector* SF = ((CPortal*)(*_F))->m_SectorFront; - CSector* SB = ((CPortal*)(*_F))->m_SectorBack; - if ((std::find(s_lst.begin(),s_lst.end(),SF)!=s_lst.end())&&(std::find(s_lst.begin(),s_lst.end(),SB)!=s_lst.end())) - xr_delete(*_F); + ObjectList &p_lst = Scene->ListObj(OBJCLASS_PORTAL); + for (ObjectIt _F = p_lst.begin(); _F!=p_lst.end(); _F++) + { + CSector *SF = ((CPortal*)(*_F))->m_SectorFront; + CSector *SB = ((CPortal*)(*_F))->m_SectorBack; + if ((std::find(s_lst.begin(), s_lst.end(), SF)!=s_lst.end())&&(std::find(s_lst.begin(), s_lst.end(), SB)!=s_lst.end())) + xr_delete(*_F); } - ObjectIt _E = remove(p_lst.begin(),p_lst.end(),(CCustomObject*)0); - p_lst.erase(_E,p_lst.end()); + ObjectIt _E = remove(p_lst.begin(), p_lst.end(), (CCustomObject*)0); + p_lst.erase(_E, p_lst.end()); // transfer from list to vector iPCount = CalculateSelectedPortals(s_lst); - }else{ - ELog.DlgMsg(mtError,"*ERROR: Scene has non associated face (face without sector)!"); + } + else + { + ELog.DlgMsg(mtError, "*ERROR: Scene has non associated face (face without sector)!"); } - UI->SetStatus("..."); + UI->SetStatus("..."); return iPCount; } + //--------------------------------------------------------------------------- void CPortalUtils::RemoveAllPortals() { // remove all existence portal - ObjectList& p_lst = Scene->ListObj(OBJCLASS_PORTAL); - for (ObjectIt _F=p_lst.begin(); _F!=p_lst.end(); _F++) xr_delete(*_F); - p_lst.erase(p_lst.begin(),p_lst.end()); + ObjectList &p_lst = Scene->ListObj(OBJCLASS_PORTAL); + for (ObjectIt _F = p_lst.begin(); _F!=p_lst.end(); _F++) + xr_delete(*_F); + p_lst.erase(p_lst.begin(), p_lst.end()); } + //--------------------------------------------------------------------------- bool CPortalUtils::CreateDefaultSector() { Fbox box; - if (Scene->GetBox(box,OBJCLASS_SCENEOBJECT)){ - CSector* sector_def=xr_new((LPVOID)0,DEFAULT_SECTOR_NAME); - sector_def->sector_color.set(1,0,0,0); - sector_def->m_bDefault=true; + if (Scene->GetBox(box, OBJCLASS_SCENEOBJECT)) + { + CSector *sector_def = xr_new((LPVOID)0,DEFAULT_SECTOR_NAME); + sector_def->sector_color.set(1, 0, 0, 0); + sector_def->m_bDefault = true; sector_def->CaptureAllUnusedMeshes(); - if (!sector_def->IsEmpty()){ - Scene->AppendObject (sector_def,true); + if (!sector_def->IsEmpty()) + { + Scene->AppendObject(sector_def, true); return true; - } else xr_delete(sector_def); + } + else + xr_delete(sector_def); } return false; } + //--------------------------------------------------------------------------- bool CPortalUtils::RemoveDefaultSector() { - CCustomObject* O=Scene->FindObjectByName(DEFAULT_SECTOR_NAME,OBJCLASS_SECTOR); - if (O){ - Scene->RemoveObject (O,false,true); - xr_delete (O); - Scene->UndoSave (); - UI->UpdateScene (); + CCustomObject*O = Scene->FindObjectByName(DEFAULT_SECTOR_NAME, OBJCLASS_SECTOR); + if (O) + { + Scene->RemoveObject(O, false, true); + xr_delete(O); + Scene->UndoSave(); + UI->UpdateScene(); return true; } return false; } + //--------------------------------------------------------------------------- /* int CPortalUtils::CalculateAllPortals2() @@ -144,103 +162,125 @@ int CPortalUtils::CalculateAllPortals2() Scene->UndoSave(); }else{ - ELog.DlgMsg(mtError,"*ERROR: Scene has non associated face (face without sector)!"); + ELog.DlgMsg(mtError,"*ERROR: Scene has non associated face (face without sector)!"); } - UI->SetStatus("..."); + UI->SetStatus("..."); return bResult; } */ //--------------------------------------------------------------------------- -CSector* CPortalUtils::FindSector(CSceneObject* o, CEditableMesh* m){ - ObjectIt _F = Scene->FirstObj(OBJCLASS_SECTOR); - ObjectIt _E = Scene->LastObj(OBJCLASS_SECTOR); - for(;_F!=_E;_F++) - if (((CSector*)(*_F))->Contains(o,m)) - return (CSector*)(*_F); +CSector *CPortalUtils::FindSector(CSceneObject *o, CEditableMesh *m) +{ + ObjectIt _F = Scene->FirstObj(OBJCLASS_SECTOR); + ObjectIt _E = Scene->LastObj(OBJCLASS_SECTOR); + for (; _F!=_E; _F++) + if (((CSector*)(*_F))->Contains(o, m)) + return (CSector*)(*_F); return 0; } bool CPortalUtils::Validate(bool bMsg) { Fbox box; - bool bResult = false; - if (Scene->GetBox(box,OBJCLASS_SCENEOBJECT)){ - bResult = true; - CSector* sector_def=xr_new((LPVOID)0,DEFAULT_SECTOR_NAME); + bool bResult = false; + if (Scene->GetBox(box, OBJCLASS_SCENEOBJECT)) + { + bResult = true; + CSector *sector_def = xr_new((LPVOID)0,DEFAULT_SECTOR_NAME); sector_def->CaptureAllUnusedMeshes(); int f_cnt; - sector_def->GetCounts(0,0,&f_cnt); - if (f_cnt!=0){ - if (bMsg){ - ELog.DlgMsg(mtError,"*ERROR: Scene has '%d' non associated face!",f_cnt); - for (SItemIt it=sector_def->sector_items.begin();it!=sector_def->sector_items.end();it++) - Msg ("! - scene object: '%s' [O:'%s', M:'%s']",it->object->Name, it->object->RefName(), it->mesh->Name().c_str()); + sector_def->GetCounts(0, 0, &f_cnt); + if (f_cnt!=0) + { + if (bMsg) + { + ELog.DlgMsg(mtError, "*ERROR: Scene has '%d' non associated face!", f_cnt); + for (SItemIt it = sector_def->sector_items.begin(); it!=sector_def->sector_items.end(); it++) + Msg("! - scene object: '%s' [O:'%s', M:'%s']", it->object->Name, it->object->RefName(), it->mesh->Name().c_str()); } bResult = false; } - xr_delete (sector_def); + xr_delete(sector_def); // verify sectors - ObjectList& s_lst=Scene->ListObj(OBJCLASS_SECTOR); - for(ObjectIt _F=s_lst.begin(); _F!=s_lst.end(); _F++) - if (!((CSector*)(*_F))->Validate(bMsg)) bResult = false; - }else{ - if (bMsg) ELog.DlgMsg(mtInformation,"Validation failed! Can't compute bbox."); + ObjectList &s_lst = Scene->ListObj(OBJCLASS_SECTOR); + for (ObjectIt _F = s_lst.begin(); _F!=s_lst.end(); _F++) + if (!((CSector*)(*_F))->Validate(bMsg)) + bResult = false; + } + else + { + if (bMsg) + ELog.DlgMsg(mtInformation, "Validation failed! Can't compute bbox."); } return bResult; } + //-------------------------------------------------------------------------------------------------- // calculate portals //-------------------------------------------------------------------------------------------------- -const int clpMX = 64, clpMY=24, clpMZ=64; +const int clpMX = 64, clpMY = 24, clpMZ = 64; class sCollector { struct sFace { - u32 v[3]; - CSector* sector; + u32 v[3]; + CSector *sector; - bool hasVertex(u32 vert) + bool hasVertex(u32 vert) { return (v[0]==vert)||(v[1]==vert)||(v[2]==vert); } }; + struct sVert : public Fvector { U32Vec adj; }; + struct sEdge { - CSector* s[2]; + CSector *s[2]; u32 v[2]; u32 used; u32 dummy; - sEdge() { used=false; } - static bool c_less(const sEdge& E1, const sEdge& E2) + sEdge() + { + used = false; + } + + static bool c_less(const sEdge &E1, const sEdge &E2) { - if (E1.s[0] e; - CSector* s[2]; + xr_deque e; + CSector *s[2]; }; DEFINE_VECTOR(sVert, sVertVec, sVertIt); @@ -248,35 +288,35 @@ class sCollector DEFINE_VECTOR(sEdge, sEdgeVec, sEdgeIt); DEFINE_VECTOR(sPortal, sPortalVec, sPortalIt); public: - sVertVec verts; - sFaceVec faces; - sEdgeVec edges; - sPortalVec portals; + sVertVec verts; + sFaceVec faces; + sEdgeVec edges; + sPortalVec portals; - Fvector VMmin, VMscale; - U32Vec VM[clpMX+1][clpMY+1][clpMZ+1]; - Fvector VMeps; + Fvector VMmin, VMscale; + U32Vec VM[clpMX+1][clpMY+1][clpMZ+1]; + Fvector VMeps; - u32 VPack(Fvector& V) + u32 VPack(Fvector &V) { u32 P = 0xffffffff; - u32 ix,iy,iz; - ix = floorf(float(V.x-VMmin.x)/VMscale.x*clpMX); - iy = floorf(float(V.y-VMmin.y)/VMscale.y*clpMY); - iz = floorf(float(V.z-VMmin.z)/VMscale.z*clpMZ); - R_ASSERT (ix<=clpMX && iy<=clpMY && iz<=clpMZ); + u32 ix, iy, iz; + ix = floorf(float(V.x-VMmin.x)/VMscale.x*clpMX); + iy = floorf(float(V.y-VMmin.y)/VMscale.y*clpMY); + iz = floorf(float(V.z-VMmin.z)/VMscale.z*clpMZ); + R_ASSERT(ix<=clpMX&&iy<=clpMY&&iz<=clpMZ); { - U32Vec* vl; - vl = &(VM[ix][iy][iz]); - U32It it = vl->begin(); - U32It it_e = vl->end(); + U32Vec *vl; + vl = &(VM[ix][iy][iz]); + U32It it = vl->begin(); + U32It it_e = vl->end(); xr_vector::iterator verts_begin = verts.begin(); - for(;it!=it_e; ++it) + for (; it!=it_e; ++it) { -// if(verts[*it].similar(V) ) - if( (*(verts_begin+*it)).similar(V) ) + // if(verts[*it].similar(V) ) + if ((*(verts_begin+*it)).similar(V)) { P = *it; break; @@ -285,263 +325,334 @@ class sCollector } if (0xffffffff==P) { - P = verts.size(); - sVert sV; - sV.set (V); - verts.push_back (sV); + P = verts.size(); + sVert sV; + sV.set(V); + verts.push_back(sV); VM[ix][iy][iz].push_back(P); - u32 ixE,iyE,izE; - ixE = floorf(float(V.x+VMeps.x-VMmin.x)/VMscale.x*clpMX); - iyE = floorf(float(V.y+VMeps.y-VMmin.y)/VMscale.y*clpMY); - izE = floorf(float(V.z+VMeps.z-VMmin.z)/VMscale.z*clpMZ); + u32 ixE, iyE, izE; + ixE = floorf(float(V.x+VMeps.x-VMmin.x)/VMscale.x*clpMX); + iyE = floorf(float(V.y+VMeps.y-VMmin.y)/VMscale.y*clpMY); + izE = floorf(float(V.z+VMeps.z-VMmin.z)/VMscale.z*clpMZ); - R_ASSERT(ixE<=clpMX && iyE<=clpMY && izE<=clpMZ); + R_ASSERT(ixE<=clpMX&&iyE<=clpMY&&izE<=clpMZ); - if (ixE!=ix) - VM[ixE][iy][iz].push_back (P); + if (ixE!=ix) + VM[ixE][iy][iz].push_back(P); - if (iyE!=iy) - VM[ix][iyE][iz].push_back (P); + if (iyE!=iy) + VM[ix][iyE][iz].push_back(P); - if (izE!=iz) - VM[ix][iy][izE].push_back (P); + if (izE!=iz) + VM[ix][iy][izE].push_back(P); - if ((ixE!=ix)&&(iyE!=iy)) - VM[ixE][iyE][iz].push_back (P); + if ((ixE!=ix)&&(iyE!=iy)) + VM[ixE][iyE][iz].push_back(P); - if ((ixE!=ix)&&(izE!=iz)) - VM[ixE][iy][izE].push_back (P); + if ((ixE!=ix)&&(izE!=iz)) + VM[ixE][iy][izE].push_back(P); - if ((iyE!=iy)&&(izE!=iz)) - VM[ix][iyE][izE].push_back (P); - - if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) - VM[ixE][iyE][izE].push_back (P); + if ((iyE!=iy)&&(izE!=iz)) + VM[ix][iyE][izE].push_back(P); + + if ((ixE!=ix)&&(iyE!=iy)&&(izE!=iz)) + VM[ixE][iyE][izE].push_back(P); } return P; } sCollector(const Fbox &bb) { - VMscale.set (bb.max.x-bb.min.x, bb.max.y-bb.min.y, bb.max.z-bb.min.z); - VMmin.set (bb.min); - VMeps.set (VMscale.x/clpMX/2, VMscale.y/clpMY/2, VMscale.z/clpMZ/2); - VMeps.x = (VMeps.xE.v[1]) std::swap(E.v[0],E.v[1]); - if (E.s[0]>E.s[1]) std::swap(E.s[0],E.s[1]); + + void sort_edges() + { + // sort inside edges + for (u32 i = 0; iE.v[1]) + std::swap(E.v[0], E.v[1]); + if (E.s[0]>E.s[1]) + std::swap(E.s[0], E.s[1]); } // remove equal - qsort(edges.begin(),edges.size(),sizeof(sEdge),sEdge::compare); - sEdgeIt NewEnd = std::unique(edges.begin(),edges.end(),sEdge::c_equal); - edges.erase(NewEnd,edges.end()); - //dump_edges(); + qsort(edges.begin(), edges.size(), sizeof(sEdge), sEdge::compare); + sEdgeIt NewEnd = std::unique(edges.begin(), edges.end(), sEdge::c_equal); + edges.erase(NewEnd, edges.end()); + //dump_edges(); } - - void make_portals() { - for(u32 e_it=0; e_itClearDebugDraw(); + Tools->ClearDebugDraw(); int ps = portals.size(); int curr = 0; - for (sPortalIt p_it=portals.begin(); p_it!=portals.end(); ++p_it, ++curr) + for (sPortalIt p_it = portals.begin(); p_it!=portals.end(); ++p_it,++curr) { - if (p_it->e.size()>1) + if (p_it->e.size()>1) { Msg("portal %d of %d", curr, ps); - // build vert-list - xr_vector vlist; - xr_deque& elist=p_it->e; - vlist.reserve (elist.size()*2); - for (xr_deque::iterator e=elist.begin(); e!=elist.end(); e++) + // build vert-list + xr_vector vlist; + xr_deque &elist = p_it->e; + vlist.reserve(elist.size()*2); + for (xr_deque::iterator e = elist.begin(); e!=elist.end(); e++) { - vlist.push_back(edges[*e].v[0]); - vlist.push_back(edges[*e].v[1]); + vlist.push_back(edges[*e].v[0]); + vlist.push_back(edges[*e].v[1]); } IntIt end = std::unique(vlist.begin(), vlist.end()); - vlist.erase(end,vlist.end()); + vlist.erase(end, vlist.end()); // append portal string256 namebuffer; - Scene->GenObjectName( OBJCLASS_PORTAL, namebuffer ); - CPortal* _O = xr_new((LPVOID)0,namebuffer); - for (u32 i=0; iVertices().push_back(verts[vlist[i]]); + Scene->GenObjectName(OBJCLASS_PORTAL, namebuffer); + CPortal *_O = xr_new((LPVOID)0, namebuffer); + for (u32 i = 0; iVertices().push_back(verts[vlist[i]]); } - _O->SetSectors(p_it->s[0],p_it->s[1]); + _O->SetSectors(p_it->s[0], p_it->s[1]); _O->Update(); - if (_O->Valid()){ - Scene->AppendObject(_O,false); - }else{ - xr_delete(_O); - ELog.Msg(mtError,"Can't simplify Portal :(\nPlease check geometry.\n'%s'<->'%s'",p_it->s[0]->Name,p_it->s[1]->Name); + if (_O->Valid()) + { + Scene->AppendObject(_O, false); } - }else - if (p_it->e.size()==0){ - ELog.Msg(mtError,"Can't create Portal from 0 edge :(\nPlease check geometry.\n'%s'<->'%s'\n",p_it->s[0]->Name,p_it->s[1]->Name); - }else{ - Fvector& v0=verts[edges[p_it->e[0]].v[0]]; - Fvector& v1=verts[edges[p_it->e[0]].v[1]]; - ELog.Msg(mtError,"Can't create Portal from one edge :(\nPlease check geometry.\n'%s'<->'%s'", p_it->s[0]->Name, p_it->s[1]->Name); - Tools->m_DebugDraw.AppendLine(v0,v1); + else + { + xr_delete(_O); + ELog.Msg(mtError, "Can't simplify Portal :(\nPlease check geometry.\n'%s'<->'%s'", p_it->s[0]->Name, p_it->s[1]->Name); } - + } + else if (p_it->e.size()==0) + { + ELog.Msg(mtError, "Can't create Portal from 0 edge :(\nPlease check geometry.\n'%s'<->'%s'\n", p_it->s[0]->Name, p_it->s[1]->Name); + } + else + { + Fvector &v0 = verts[edges[p_it->e[0]].v[0]]; + Fvector &v1 = verts[edges[p_it->e[0]].v[1]]; + ELog.Msg(mtError, "Can't create Portal from one edge :(\nPlease check geometry.\n'%s'<->'%s'", p_it->s[0]->Name, p_it->s[1]->Name); + Tools->m_DebugDraw.AppendLine(v0, v1); + } } } }; -int CPortalUtils::CalculateSelectedPortals(ObjectList& sectors){ +int CPortalUtils::CalculateSelectedPortals(ObjectList §ors) +{ // calculate portals Fbox bb; - Scene->GetBox(bb,OBJCLASS_SCENEOBJECT); - sCollector* CL = xr_new(bb); + Scene->GetBox(bb, OBJCLASS_SCENEOBJECT); + sCollector *CL = xr_new(bb); Fmatrix T; //1. xform + weld UI->SetStatus("xform + weld..."); - for (ObjectIt s_it=sectors.begin(); s_it!=sectors.end(); s_it++){ - CSector* S=(CSector*)(*s_it); - for (SItemIt s_it=S->sector_items.begin();s_it!=S->sector_items.end();s_it++){ - if (s_it->object->IsMUStatic()) continue; + for (ObjectIt s_it = sectors.begin(); s_it!=sectors.end(); s_it++) + { + CSector *S = (CSector*)(*s_it); + for (SItemIt s_it = S->sector_items.begin(); s_it!=S->sector_items.end(); s_it++) + { + if (s_it->object->IsMUStatic()) + continue; s_it->GetTransform(T); - Fvector* m_verts=s_it->mesh->m_Vertices; - for (u32 f_id=0; f_idmesh->GetFCount(); f_id++){ + Fvector *m_verts = s_it->mesh->m_Vertices; + for (u32 f_id = 0; f_idmesh->GetFCount(); f_id++) + { Fvector v0, v1, v2; - st_Face& P = s_it->mesh->GetFaces()[f_id]; - T.transform_tiny (v0,m_verts[P.pv[0].pindex]); - T.transform_tiny (v1,m_verts[P.pv[1].pindex]); - T.transform_tiny (v2,m_verts[P.pv[2].pindex]); - CL->add_face (v0,v1,v2,S); + st_Face &P = s_it->mesh->GetFaces()[f_id]; + T.transform_tiny(v0, m_verts[P.pv[0].pindex]); + T.transform_tiny(v1, m_verts[P.pv[1].pindex]); + T.transform_tiny(v2, m_verts[P.pv[2].pindex]); + CL->add_face(v0, v1, v2, S); } } } @@ -572,25 +683,29 @@ int CPortalUtils::CalculateSelectedPortals(ObjectList& sectors){ int CPortalUtils::CalculateAllPortals() { - int iPCount=0; - if (Validate(false)){ - UI->SetStatus("Prepare..."); + int iPCount = 0; + if (Validate(false)) + { + UI->SetStatus("Prepare..."); RemoveAllPortals(); - ObjectList& s_lst=Scene->ListObj(OBJCLASS_SECTOR); + ObjectList &s_lst = Scene->ListObj(OBJCLASS_SECTOR); iPCount = CalculateSelectedPortals(s_lst); - }else{ - ELog.DlgMsg(mtError,"*ERROR: Sector validation failed."); + } + else + { + ELog.DlgMsg(mtError, "*ERROR: Sector validation failed."); } - UI->ResetStatus(); + UI->ResetStatus(); return iPCount; } -int CPortalUtils::CalculatePortals(CSector* SF, CSector* SB) +int CPortalUtils::CalculatePortals(CSector *SF, CSector *SB) { - int iPCount=0; - if (Validate(false)){ - UI->SetStatus("Prepare..."); + int iPCount = 0; + if (Validate(false)) + { + UI->SetStatus("Prepare..."); RemoveAllPortals(); // transfer from list to vector ObjectList sectors; @@ -598,10 +713,13 @@ int CPortalUtils::CalculatePortals(CSector* SF, CSector* SB) sectors.push_back(SB); iPCount = CalculateSelectedPortals(sectors); - }else{ - ELog.DlgMsg(mtError,"*ERROR: Scene has non associated face (face without sector)!"); + } + else + { + ELog.DlgMsg(mtError, "*ERROR: Scene has non associated face (face without sector)!"); } - UI->ResetStatus(); + UI->ResetStatus(); return iPCount; } + diff --git a/src/editors/LevelEditor/Edit/scene.cpp b/src/editors/LevelEditor/Edit/scene.cpp index 0c2ffbf8555..53fede272e7 100644 --- a/src/editors/LevelEditor/Edit/scene.cpp +++ b/src/editors/LevelEditor/Edit/scene.cpp @@ -7,13 +7,13 @@ #include "Scene.h" #include "SceneObject.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "Sector.h" #include "SpawnPoint.h" -#include "../ECore/Editor/SoundManager.h" +#include "editors/ECore/Editor/SoundManager.h" #include "EParticlesObject.h" -#include "ui_leveltools.h" -#include "../ECore/Engine/guid_generator.h" +#include "UI_LevelTools.h" +#include "editors/ECore/Engine/guid_generator.h" #include "ESceneAIMapTools.h" #include "ESceneDOTools.h" @@ -21,44 +21,46 @@ #include "AppendObjectInfoForm.h" #include "lephysics.h" //---------------------------------------------------- -EScene* Scene; +EScene *Scene; + //---------------------------------------------------- st_LevelOptions::st_LevelOptions() { - Reset(); + Reset(); } void st_LevelOptions::Reset() { - m_FNLevelPath = "level"; - m_LevelPrefix = "level_prefix"; - m_LightHemiQuality = 3; - m_LightSunQuality = 3; - m_BOPText = ""; - m_map_version = "1.0"; - m_BuildParams.Init (); + m_FNLevelPath = "level"; + m_LevelPrefix = "level_prefix"; + m_LightHemiQuality = 3; + m_LightSunQuality = 3; + m_BOPText = ""; + m_map_version = "1.0"; + m_BuildParams.Init(); m_BuildParams.setHighQuality(); - m_mapUsage.SetDefaults (); + m_mapUsage.SetDefaults(); } void st_LevelOptions::SetCustomQuality() { - m_BuildParams.m_quality = ebqCustom; + m_BuildParams.m_quality = ebqCustom; } void st_LevelOptions::SetDraftQuality() { m_BuildParams.setDraftQuality(); - m_LightHemiQuality = 0; - m_LightSunQuality = 0; + m_LightHemiQuality = 0; + m_LightSunQuality = 0; } void st_LevelOptions::SetHighQuality() { m_BuildParams.setHighQuality(); - m_LightHemiQuality = 3; - m_LightSunQuality = 3; + m_LightHemiQuality = 3; + m_LightSunQuality = 3; } + //------------------------------------------------------------------------------ @@ -66,234 +68,251 @@ void st_LevelOptions::SetHighQuality() EScene::EScene() { - m_Valid = false; - m_Locked = 0; + m_Valid = false; + m_Locked = 0; - for (int i=0; i((TComponent*)NULL); - + g_frmConflictLoadObject = xr_new((TComponent*)NULL); } EScene::~EScene() { - xr_delete(g_frmConflictLoadObject); + xr_delete(g_frmConflictLoadObject); - VERIFY( m_Valid == false ); - m_ESO_SnapObjects.clear (); + VERIFY(m_Valid==false); + m_ESO_SnapObjects.clear(); } void EScene::OnCreate() { - CreateSceneTools (); - - m_LastAvailObject = 0; - m_LevelOp.Reset (); - ELog.Msg ( mtInformation, "Scene: initialized" ); - m_Valid = true; - m_RTFlags.zero (); - ExecCommand (COMMAND_UPDATE_CAPTION); - m_SummaryInfo = TProperties::CreateForm("Level Summary Info", 0, alNone, 0,0,0, TProperties::plFolderStore|TProperties::plItemFolders); + CreateSceneTools(); + + m_LastAvailObject = 0; + m_LevelOp.Reset(); + ELog.Msg(mtInformation, "Scene: initialized"); + m_Valid = true; + m_RTFlags.zero(); + ExecCommand(COMMAND_UPDATE_CAPTION); + m_SummaryInfo = TProperties::CreateForm("Level Summary Info", 0, alNone, 0, 0, 0, TProperties::plFolderStore|TProperties::plItemFolders); } void EScene::OnDestroy() { - g_scene_physics.DestroyAll(); - - TProperties::DestroyForm(m_SummaryInfo); - Unload (FALSE); - UndoClear (); - ELog.Msg ( mtInformation, "Scene: cleared" ); - m_LastAvailObject = 0; - m_Valid = false; - DestroySceneTools (); - -} - -void EScene::AppendObject( CCustomObject* object, bool bUndo ) -{ - VERIFY (object); - VERIFY (m_Valid); - - ESceneCustomOTool* mt = GetOTool(object->ClassID); - VERIFY3(mt,"Can't find Object Tools:",GetTool(object->ClassID)->ClassDesc()); - mt->_AppendObject (object); - UI->UpdateScene (); - if (bUndo){ - object->Select (true); + g_scene_physics.DestroyAll(); + + TProperties::DestroyForm(m_SummaryInfo); + Unload(FALSE); + UndoClear(); + ELog.Msg(mtInformation, "Scene: cleared"); + m_LastAvailObject = 0; + m_Valid = false; + DestroySceneTools(); +} + +void EScene::AppendObject(CCustomObject *object, bool bUndo) +{ + VERIFY(object); + VERIFY(m_Valid); + + ESceneCustomOTool*mt = GetOTool(object->ClassID); + VERIFY3(mt, "Can't find Object Tools:", GetTool(object->ClassID)->ClassDesc()); + mt->_AppendObject(object); + UI->UpdateScene(); + if (bUndo) + { + object->Select(true); UndoSave(); } } -bool EScene::RemoveObject( CCustomObject* object, bool bUndo, bool bDeleting ) +bool EScene::RemoveObject(CCustomObject *object, bool bUndo, bool bDeleting) { - VERIFY (object); - VERIFY (m_Valid); + VERIFY(object); + VERIFY(m_Valid); - ESceneCustomOTool* mt = GetOTool(object->ClassID); + ESceneCustomOTool*mt = GetOTool(object->ClassID); if (mt&&mt->IsEditable()) { - mt->_RemoveObject(object); + mt->_RemoveObject(object); // signal everyone "I'm deleting" -// if (object->ClassID==OBJCLASS_SCENEOBJECT) + // if (object->ClassID==OBJCLASS_SCENEOBJECT) { - m_ESO_SnapObjects.remove (object); + m_ESO_SnapObjects.remove(object); SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); - for (; _I!=_E; _I++){ - ESceneToolBase* mt = _I->second; + for (; _I!=_E; _I++) + { + ESceneToolBase*mt = _I->second; if (mt) - mt->OnObjectRemove(object, bDeleting); + mt->OnObjectRemove(object, bDeleting); } - UpdateSnapList (); + UpdateSnapList(); } - UI->UpdateScene (); + UI->UpdateScene(); } - if (bUndo) UndoSave(); + if (bUndo) + UndoSave(); return true; } -void EScene::BeforeObjectChange( CCustomObject* object ) +void EScene::BeforeObjectChange(CCustomObject *object) { - VERIFY (object); - VERIFY (m_Valid); + VERIFY(object); + VERIFY(m_Valid); - ESceneCustomOTool* mt = GetOTool(object->ClassID); - if (mt&&mt->IsEditable()){ + ESceneCustomOTool*mt = GetOTool(object->ClassID); + if (mt&&mt->IsEditable()) + { SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); - for (; _I!=_E; _I++){ - ESceneToolBase* mt = _I->second; + for (; _I!=_E; _I++) + { + ESceneToolBase*mt = _I->second; if (mt) - mt->OnBeforeObjectChange(object); + mt->OnBeforeObjectChange(object); } - UI->UpdateScene (); + UI->UpdateScene(); } } int EScene::MultiRenameObjects() { - int cnt = 0; - - if (LTools->GetTarget()==OBJCLASS_DUMMY){ - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); + int cnt = 0; + + if (LTools->GetTarget()==OBJCLASS_DUMMY) + { + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); for (; t_it!=t_end; t_it++) { - ESceneCustomOTool* ot = dynamic_cast(t_it->second); + ESceneCustomOTool*ot = dynamic_cast(t_it->second); if (ot&&(t_it->first!=OBJCLASS_DUMMY)) - cnt += ot->MultiRenameObjects (); + cnt += ot->MultiRenameObjects(); } - }else{ - ESceneCustomOTool* ot = GetOTool(LTools->GetTarget()); - if (ot) cnt += ot->MultiRenameObjects (); + } + else + { + ESceneCustomOTool*ot = GetOTool(LTools->GetTarget()); + if (ot) + cnt += ot->MultiRenameObjects(); } return cnt; } -void EScene::OnFrame( float dT ) +void EScene::OnFrame(float dT) { - if( !valid() ) return; - if( locked() ) return; + if (!valid()) + return; + if (locked()) + return; - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); for (; t_it!=t_end; t_it++) - if (t_it->second && t_it->second->IsEnabled()) - t_it->second->OnFrame(); + if (t_it->second&&t_it->second->IsEnabled()) + t_it->second->OnFrame(); - if(m_RTFlags.test(flUpdateSnapList) ) - UpdateSnapListReal(); + if (m_RTFlags.test(flUpdateSnapList)) + UpdateSnapListReal(); } void EScene::Reset() { - // unload scene - Unload (FALSE); + // unload scene + Unload(FALSE); // reset tools - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); for (; t_it!=t_end; t_it++) if (t_it->second&&t_it->first!=OBJCLASS_DUMMY) - t_it->second->Reset (); + t_it->second->Reset(); g_scene_physics.UpdateLevelCollision(); } -void EScene::Unload (BOOL bEditableOnly) +void EScene::Unload(BOOL bEditableOnly) { - m_LastAvailObject = 0; - Clear (bEditableOnly); - if (m_SummaryInfo) m_SummaryInfo->HideProperties(); + m_LastAvailObject = 0; + Clear(bEditableOnly); + if (m_SummaryInfo) + m_SummaryInfo->HideProperties(); } void EScene::Clear(BOOL bEditableToolsOnly) { - // clear snap - ClearSnapList (false); - // clear scene tools - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); + // clear snap + ClearSnapList(false); + // clear scene tools + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); for (; t_it!=t_end; t_it++) - if (t_it->second&&t_it->first!=OBJCLASS_DUMMY){ - if (!bEditableToolsOnly||(bEditableToolsOnly&&t_it->second->IsEditable())){ - t_it->second->Clear(); + if (t_it->second&&t_it->first!=OBJCLASS_DUMMY) + { + if (!bEditableToolsOnly||(bEditableToolsOnly&&t_it->second->IsEditable())) + { + t_it->second->Clear(); } } - - Tools->ClearDebugDraw (); - m_RTFlags.set (flRT_Unsaved|flRT_Modified,FALSE); + Tools->ClearDebugDraw(); - m_GUID = generate_guid(); - m_OwnerName = AnsiString().sprintf("\\\\%s\\%s",Core.CompName,Core.UserName).c_str(); - m_CreateTime = time(NULL); + m_RTFlags.set(flRT_Unsaved|flRT_Modified, FALSE); - m_SaveCache.free (); + m_GUID = generate_guid(); + m_OwnerName = AnsiString().sprintf("\\\\%s\\%s", Core.CompName, Core.UserName).c_str(); + m_CreateTime = time(NULL); + + m_SaveCache.free(); } + //---------------------------------------------------- -bool EScene::GetBox(Fbox& box, ObjClassID classfilter) +bool EScene::GetBox(Fbox &box, ObjClassID classfilter) { - return GetBox(box,ListObj(classfilter)); + return GetBox(box, ListObj(classfilter)); } + //---------------------------------------------------- -bool EScene::GetBox(Fbox& box, ObjectList& lst) +bool EScene::GetBox(Fbox &box, ObjectList &lst) { box.invalidate(); - bool bRes=false; - for(ObjectIt it=lst.begin();it!=lst.end();it++){ + bool bRes = false; + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + { Fbox bb; - if((*it)->GetBox(bb)) + if ((*it)->GetBox(bb)) { box.modify(bb.min); box.modify(bb.max); - bRes=true; + bRes = true; } } return bRes; } + //---------------------------------------------------- void EScene::Modified() { - m_RTFlags.set(flRT_Modified|flRT_Unsaved,TRUE); + m_RTFlags.set(flRT_Modified|flRT_Unsaved, TRUE); g_scene_physics.OnSceneModified(); ExecCommand(COMMAND_UPDATE_CAPTION); } bool EScene::IsUnsaved() { - return (m_RTFlags.is(flRT_Unsaved) && (ObjCount()||!Tools->GetEditFileName().IsEmpty())); + return (m_RTFlags.is(flRT_Unsaved)&&(ObjCount()||!Tools->GetEditFileName().IsEmpty())); } + bool EScene::IsModified() { return (m_RTFlags.is(flRT_Modified)); @@ -301,19 +320,26 @@ bool EScene::IsModified() bool EScene::IfModified() { - if (locked()){ - ELog.DlgMsg( mtError, "Scene sharing violation" ); + if (locked()) + { + ELog.DlgMsg(mtError, "Scene sharing violation"); return false; } - if (m_RTFlags.is(flRT_Unsaved) && (ObjCount()||!Tools->GetEditFileName().IsEmpty())){ + if (m_RTFlags.is(flRT_Unsaved)&&(ObjCount()||!Tools->GetEditFileName().IsEmpty())) + { int mr = ELog.DlgMsg(mtConfirmation, "The scene has been modified. Do you want to save your changes?"); - switch(mr){ - case mrYes: if (!ExecCommand(COMMAND_SAVE)) return false; break; - case mrNo:{ - m_RTFlags.set(flRT_Unsaved,FALSE); - ExecCommand (COMMAND_UPDATE_CAPTION); - }break; - case mrCancel: return false; + switch (mr) + { + case mrYes: if (!ExecCommand(COMMAND_SAVE)) + return false; + break; + case mrNo: + { + m_RTFlags.set(flRT_Unsaved, FALSE); + ExecCommand(COMMAND_UPDATE_CAPTION); + } + break; + case mrCancel: return false; } } return true; @@ -321,146 +347,186 @@ bool EScene::IfModified() void EScene::OnObjectsUpdate() { - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); for (; t_it!=t_end; t_it++) - if (t_it->second) t_it->second->OnSceneUpdate(); + if (t_it->second) + t_it->second->OnSceneUpdate(); } void EScene::OnDeviceCreate() { - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); for (; t_it!=t_end; t_it++) - if (t_it->second) t_it->second->OnDeviceCreate(); + if (t_it->second) + t_it->second->OnDeviceCreate(); } void EScene::OnDeviceDestroy() { - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); for (; t_it!=t_end; t_it++) - if (t_it->second) t_it->second->OnDeviceDestroy(); + if (t_it->second) + t_it->second->OnDeviceDestroy(); } + //------------------------------------------------------------------------------ -void EScene::OnShowHint(AStringVec& dest) +void EScene::OnShowHint(AStringVec &dest) { - CCustomObject* obj = RayPickObject(flt_max,UI->m_CurrentRStart,UI->m_CurrentRDir,LTools->CurrentClassID(),0,0); - if (obj) obj->OnShowHint(dest); + CCustomObject*obj = RayPickObject(flt_max, UI->m_CurrentRStart, UI->m_CurrentRDir, LTools->CurrentClassID(), 0, 0); + if (obj) + obj->OnShowHint(dest); } + //------------------------------------------------------------------------------ -bool EScene::ExportGame(SExportStreams* F) +bool EScene::ExportGame(SExportStreams *F) { - bool bres = true; - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); + bool bres = true; + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); for (; t_it!=t_end; t_it++) - if (t_it->second) if (!t_it->second->ExportGame(F)) bres=false; + if (t_it->second) + if (!t_it->second->ExportGame(F)) + bres = false; return bres; } + //------------------------------------------------------------------------------ bool EScene::Validate(bool bNeedOkMsg, bool bTestPortal, bool bTestHOM, bool bTestGlow, bool bTestShaderCompatible, bool bFullTest) { - bool bRes = true; - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); - for (; t_it!=t_end; t_it++){ - if (t_it->second){ - if (!t_it->second->Validate(bFullTest)){ - ELog.Msg(mtError,"ERROR: Validate '%s' failed!",t_it->second->ClassDesc()); + bool bRes = true; + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); + for (; t_it!=t_end; t_it++) + { + if (t_it->second) + { + if (!t_it->second->Validate(bFullTest)) + { + ELog.Msg(mtError, "ERROR: Validate '%s' failed!", t_it->second->ClassDesc()); bRes = false; } } } - if (bTestPortal){ + if (bTestPortal) + { if (Scene->ObjCount(OBJCLASS_SECTOR)||Scene->ObjCount(OBJCLASS_PORTAL)) if (!PortalUtils.Validate(true)) - bRes = false; + bRes = false; } - if (bTestHOM){ - bool bHasHOM=false; - ObjectList& lst = ListObj(OBJCLASS_SCENEOBJECT); - for(ObjectIt it=lst.begin();it!=lst.end();it++){ - CEditableObject* O = ((CSceneObject*)(*it))->GetReference(); R_ASSERT(O); - if (O->m_objectFlags.is(CEditableObject::eoHOM)){ bHasHOM = true; break; } + if (bTestHOM) + { + bool bHasHOM = false; + ObjectList&lst = ListObj(OBJCLASS_SCENEOBJECT); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + { + CEditableObject *O = ((CSceneObject*)(*it))->GetReference(); + R_ASSERT(O); + if (O->m_objectFlags.is(CEditableObject::eoHOM)) + { + bHasHOM = true; + break; + } } if (!bHasHOM) - Msg("!Level doesn't contain HOM objects!"); -//. if (mrNo==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Level doesn't contain HOM.\nContinue anyway?")) -//. return false; + Msg("!Level doesn't contain HOM objects!"); + //. if (mrNo==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Level doesn't contain HOM.\nContinue anyway?")) + //. return false; } - if (ObjCount(OBJCLASS_SPAWNPOINT)==0){ - ELog.Msg(mtError,"*ERROR: Can't find any Spawn Object."); + if (ObjCount(OBJCLASS_SPAWNPOINT)==0) + { + ELog.Msg(mtError, "*ERROR: Can't find any Spawn Object."); bRes = false; } - if (ObjCount(OBJCLASS_LIGHT)==0){ - ELog.Msg(mtError,"*ERROR: Can't find any Light Object."); + if (ObjCount(OBJCLASS_LIGHT)==0) + { + ELog.Msg(mtError, "*ERROR: Can't find any Light Object."); bRes = false; } - if (ObjCount(OBJCLASS_SCENEOBJECT)==0){ - ELog.Msg(mtError,"*ERROR: Can't find any Scene Object."); + if (ObjCount(OBJCLASS_SCENEOBJECT)==0) + { + ELog.Msg(mtError, "*ERROR: Can't find any Scene Object."); bRes = false; } - if (bTestGlow){ - if (ObjCount(OBJCLASS_GLOW)==0){ - ELog.Msg(mtError,"*ERROR: Can't find any Glow Object."); + if (bTestGlow) + { + if (ObjCount(OBJCLASS_GLOW)==0) + { + ELog.Msg(mtError, "*ERROR: Can't find any Glow Object."); bRes = false; } } - if (FindDuplicateName()){ - ELog.Msg(mtError,"*ERROR: Found duplicate object name."); + if (FindDuplicateName()) + { + ELog.Msg(mtError, "*ERROR: Found duplicate object name."); bRes = false; } - - if (bTestShaderCompatible){ - bool res = true; - ObjectList& lst = ListObj(OBJCLASS_SCENEOBJECT); - DEFINE_SET(CEditableObject*,EOSet,EOSetIt); + + if (bTestShaderCompatible) + { + bool res = true; + ObjectList&lst = ListObj(OBJCLASS_SCENEOBJECT); + DEFINE_SET(CEditableObject*, EOSet, EOSetIt); EOSet objects; - int static_obj = 0; - for(ObjectIt it=lst.begin();it!=lst.end();it++){ - CSceneObject* S = (CSceneObject*)(*it); - if (S->IsStatic()||S->IsMUStatic()){ - static_obj++; - CEditableObject* O = ((CSceneObject*)(*it))->GetReference(); R_ASSERT(O); - if (objects.find(O)==objects.end()){ - if (!O->CheckShaderCompatible()) res = false; + int static_obj = 0; + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + { + CSceneObject *S = (CSceneObject*)(*it); + if (S->IsStatic()||S->IsMUStatic()) + { + static_obj++; + CEditableObject *O = ((CSceneObject*)(*it))->GetReference(); + R_ASSERT(O); + if (objects.find(O)==objects.end()) + { + if (!O->CheckShaderCompatible()) + res = false; objects.insert(O); } } } - if (!res){ - ELog.Msg (mtError,"*ERROR: Scene has non compatible shaders. See log."); + if (!res) + { + ELog.Msg(mtError, "*ERROR: Scene has non compatible shaders. See log."); bRes = false; } - if (0==static_obj){ - ELog.Msg (mtError,"*ERROR: Can't find static geometry."); + if (0==static_obj) + { + ELog.Msg(mtError, "*ERROR: Can't find static geometry."); bRes = false; } } - - if (!SndLib->Validate()) + + if (!SndLib->Validate()) bRes = false; { - ObjectList& lst = ListObj(OBJCLASS_PS); - for(ObjectIt it=lst.begin();it!=lst.end();it++){ - EParticlesObject* S = (EParticlesObject*)(*it); - if (!S->GetParticles()){ - ELog.Msg(mtError,"*ERROR: Particle System hasn't reference."); + ObjectList&lst = ListObj(OBJCLASS_PS); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + { + EParticlesObject *S = (EParticlesObject*)(*it); + if (!S->GetParticles()) + { + ELog.Msg(mtError, "*ERROR: Particle System hasn't reference."); bRes = false; } } } - - if (bRes){ - if (bNeedOkMsg) ELog.DlgMsg(mtInformation,"Validation OK!"); - }else{ - ELog.DlgMsg(mtInformation,"Validation FAILED!"); + + if (bRes) + { + if (bNeedOkMsg) + ELog.DlgMsg(mtInformation, "Validation OK!"); + } + else + { + ELog.DlgMsg(mtInformation, "Validation FAILED!"); } return bRes; } @@ -468,145 +534,162 @@ bool EScene::Validate(bool bNeedOkMsg, bool bTestPortal, bool bTestHOM, bool bTe xr_string EScene::LevelPath() { string_path path; - if (m_LevelOp.m_FNLevelPath.size()){ - FS.update_path (path,"$level$",m_LevelOp.m_FNLevelPath.c_str()); - strcat(path,"\\"); + if (m_LevelOp.m_FNLevelPath.size()) + { + FS.update_path(path, "$level$", m_LevelOp.m_FNLevelPath.c_str()); + strcat(path, "\\"); } return xr_string(path); } #include "ESceneLightTools.h" -void EScene::SelectLightsForObject(CCustomObject* obj) + +void EScene::SelectLightsForObject(CCustomObject *obj) { - ESceneCustomOTool* t = Scene->GetOTool(OBJCLASS_LIGHT); - if(!t) - return; + ESceneCustomOTool*t = Scene->GetOTool(OBJCLASS_LIGHT); + if (!t) + return; - ESceneLightTool* lt = dynamic_cast(t); - VERIFY (lt); - lt->SelectLightsForObject (obj); + ESceneLightTool *lt = dynamic_cast(t); + VERIFY(lt); + lt->SelectLightsForObject(obj); } void EScene::HighlightTexture(LPCSTR t_name, bool allow_ratio, u32 t_width, u32 t_height, bool leave_previous) { if (!leave_previous) - Tools->ClearDebugDraw(); + Tools->ClearDebugDraw(); - SceneToolsMapPairIt t_it = m_SceneTools.begin(); - SceneToolsMapPairIt t_end = m_SceneTools.end(); + SceneToolsMapPairIt t_it = m_SceneTools.begin(); + SceneToolsMapPairIt t_end = m_SceneTools.end(); for (; t_it!=t_end; ++t_it) - if (t_it->second) t_it->second->HighlightTexture(t_name,allow_ratio,t_width,t_height,!leave_previous); + if (t_it->second) + t_it->second->HighlightTexture(t_name, allow_ratio, t_width, t_height, !leave_previous); - UI->RedrawScene (); + UI->RedrawScene(); } -xr_token js_token [ ]={ - { "1 - Low", 1 }, - { "4 - Medium", 4 }, - { "9 - High", 9 }, - { 0, 0 } +xr_token js_token [ ] = { + {"1 - Low", 1}, + {"4 - Medium", 4}, + {"9 - High", 9}, + {0, 0} }; -void EScene::OnBuildControlClick (ButtonValue* V, bool& bModif, bool& bSafe) +void EScene::OnBuildControlClick(ButtonValue *V, bool &bModif, bool &bSafe) { - switch (V->btn_num){ - case 0: m_LevelOp.SetDraftQuality(); break; - case 1: m_LevelOp.SetHighQuality(); break; - case 2: m_LevelOp.SetCustomQuality(); break; - } + switch (V->btn_num) + { + case 0: m_LevelOp.SetDraftQuality(); + break; + case 1: m_LevelOp.SetHighQuality(); + break; + case 2: m_LevelOp.SetCustomQuality(); + break; + } ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void EScene::OnRTFlagsChange (PropValue* sender) +void EScene::OnRTFlagsChange(PropValue *sender) { ExecCommand(COMMAND_UPDATE_PROPERTIES); } -void EScene::FillProp(LPCSTR pref, PropItemVec& items, ObjClassID cls_id) +void EScene::FillProp(LPCSTR pref, PropItemVec &items, ObjClassID cls_id) { - PHelper().CreateCaption (items,PrepareKey(pref,"Scene\\Name"), LTools->m_LastFileName.c_str()); - PHelper().CreateRText (items,PrepareKey(pref,"Scene\\Name prefix"), &m_LevelOp.m_LevelPrefix); + PHelper().CreateCaption(items, PrepareKey(pref, "Scene\\Name"), LTools->m_LastFileName.c_str()); + PHelper().CreateRText(items, PrepareKey(pref, "Scene\\Name prefix"), &m_LevelOp.m_LevelPrefix); - PropValue* V; - PHelper().CreateRText (items,PrepareKey(pref,"Scene\\Build options\\Level path"), &m_LevelOp.m_FNLevelPath); - PHelper().CreateRText (items,PrepareKey(pref,"Scene\\Build options\\Custom data"), &m_LevelOp.m_BOPText); - PHelper().CreateRText (items,PrepareKey(pref,"Scene\\Map version"), &m_LevelOp.m_map_version); + PropValue *V; + PHelper().CreateRText(items, PrepareKey(pref, "Scene\\Build options\\Level path"), &m_LevelOp.m_FNLevelPath); + PHelper().CreateRText(items, PrepareKey(pref, "Scene\\Build options\\Custom data"), &m_LevelOp.m_BOPText); + PHelper().CreateRText(items, PrepareKey(pref, "Scene\\Map version"), &m_LevelOp.m_map_version); m_LevelOp.m_mapUsage.FillProp("Scene\\Usage", items); // common - ButtonValue* B; - B=PHelper().CreateButton (items,PrepareKey(pref,"Scene\\Build options\\Quality"), "Draft,High,Custom",0); - B->OnBtnClickEvent.bind (this,&EScene::OnBuildControlClick); + ButtonValue *B; + B = PHelper().CreateButton(items, PrepareKey(pref, "Scene\\Build options\\Quality"), "Draft,High,Custom", 0); + B->OnBtnClickEvent.bind(this, &EScene::OnBuildControlClick); - BOOL enabled = (m_LevelOp.m_BuildParams.m_quality==ebqCustom); - V=PHelper().CreateU8 (items,PrepareKey(pref,"Scene\\Build options\\Lighting\\Hemisphere quality [0-3]"), &m_LevelOp.m_LightHemiQuality, 0,3); V->Owner()->Enable(enabled); - V=PHelper().CreateU8 (items,PrepareKey(pref,"Scene\\Build options\\Lighting\\Sun shadow quality [0-3]"), &m_LevelOp.m_LightSunQuality, 0,3); V->Owner()->Enable(enabled); + BOOL enabled = (m_LevelOp.m_BuildParams.m_quality==ebqCustom); + V = PHelper().CreateU8(items, PrepareKey(pref, "Scene\\Build options\\Lighting\\Hemisphere quality [0-3]"), &m_LevelOp.m_LightHemiQuality, 0, 3); + V->Owner()->Enable(enabled); + V = PHelper().CreateU8(items, PrepareKey(pref, "Scene\\Build options\\Lighting\\Sun shadow quality [0-3]"), &m_LevelOp.m_LightSunQuality, 0, 3); + V->Owner()->Enable(enabled); // Build Options // Normals & optimization - V=PHelper().CreateFloat (items,PrepareKey(pref,"Scene\\Build options\\Optimizing\\Normal smooth angle"), &m_LevelOp.m_BuildParams.m_sm_angle, 0.f,180.f); V->Owner()->Enable(enabled); - V=PHelper().CreateFloat (items,PrepareKey(pref,"Scene\\Build options\\Optimizing\\Weld distance (m)"), &m_LevelOp.m_BuildParams.m_weld_distance, 0.f,1.f,0.001f,4); V->Owner()->Enable(enabled); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Scene\\Build options\\Optimizing\\Normal smooth angle"), &m_LevelOp.m_BuildParams.m_sm_angle, 0.f, 180.f); + V->Owner()->Enable(enabled); + V = PHelper().CreateFloat(items, PrepareKey(pref, "Scene\\Build options\\Optimizing\\Weld distance (m)"), &m_LevelOp.m_BuildParams.m_weld_distance, 0.f, 1.f, 0.001f, 4); + V->Owner()->Enable(enabled); // Light maps - V=PHelper().CreateFloat (items,PrepareKey(pref,"Scene\\Build options\\Lighting\\Pixel per meter"), &m_LevelOp.m_BuildParams.m_lm_pixels_per_meter, 0.f,20.f); V->Owner()->Enable(enabled); - V=PHelper().CreateU32 (items,PrepareKey(pref,"Scene\\Build options\\Lighting\\Error (LM collapsing)"), &m_LevelOp.m_BuildParams.m_lm_rms, 0,255); V->Owner()->Enable(enabled); - V=PHelper().CreateU32 (items,PrepareKey(pref,"Scene\\Build options\\Lighting\\Error (LM zero)"), &m_LevelOp.m_BuildParams.m_lm_rms_zero, 0,255); V->Owner()->Enable(enabled); - V=PHelper().CreateToken32 (items,PrepareKey(pref,"Scene\\Build options\\Lighting\\Jitter samples"), &m_LevelOp.m_BuildParams.m_lm_jitter_samples, js_token); V->Owner()->Enable(enabled); - + V = PHelper().CreateFloat(items, PrepareKey(pref, "Scene\\Build options\\Lighting\\Pixel per meter"), &m_LevelOp.m_BuildParams.m_lm_pixels_per_meter, 0.f, 20.f); + V->Owner()->Enable(enabled); + V = PHelper().CreateU32(items, PrepareKey(pref, "Scene\\Build options\\Lighting\\Error (LM collapsing)"), &m_LevelOp.m_BuildParams.m_lm_rms, 0, 255); + V->Owner()->Enable(enabled); + V = PHelper().CreateU32(items, PrepareKey(pref, "Scene\\Build options\\Lighting\\Error (LM zero)"), &m_LevelOp.m_BuildParams.m_lm_rms_zero, 0, 255); + V->Owner()->Enable(enabled); + V = PHelper().CreateToken32(items, PrepareKey(pref, "Scene\\Build options\\Lighting\\Jitter samples"), &m_LevelOp.m_BuildParams.m_lm_jitter_samples, js_token); + V->Owner()->Enable(enabled); + // tools options if (OBJCLASS_DUMMY==cls_id) { - SceneToolsMapPairIt _I = FirstTool(); - SceneToolsMapPairIt _E = LastTool(); - for(; _I!=_E; _I++) + SceneToolsMapPairIt _I = FirstTool(); + SceneToolsMapPairIt _E = LastTool(); + for (; _I!=_E; _I++) { - ESceneToolBase* mt = _I->second; - if((_I->first!=OBJCLASS_DUMMY) && mt) + ESceneToolBase*mt = _I->second; + if ((_I->first!=OBJCLASS_DUMMY)&&mt) { - mt->FillProp (mt->ClassDesc(), items); + mt->FillProp(mt->ClassDesc(), items); } } - }else{ - ESceneToolBase* mt = GetTool (cls_id); - if(mt) + } + else + { + ESceneToolBase*mt = GetTool(cls_id); + if (mt) { - mt->FillProp (mt->ClassDesc(), items); + mt->FillProp(mt->ClassDesc(), items); } } } -void EScene::RegisterSubstObjectName(const xr_string& _from, const xr_string& _to) +void EScene::RegisterSubstObjectName(const xr_string &_from, const xr_string &_to) { xr_string _tmp; bool b = GetSubstObjectName(_from, _tmp); - if(b) - Msg("! subst for '%s' already exist -'%s'",_from.c_str(), _tmp.c_str()); + if (b) + Msg("! subst for '%s' already exist -'%s'", _from.c_str(), _tmp.c_str()); - TSubstPairs_it It = m_subst_pairs.begin(); - TSubstPairs_it It_e = m_subst_pairs.end(); - for(;It!=It_e;++It) + TSubstPairs_it It = m_subst_pairs.begin(); + TSubstPairs_it It_e = m_subst_pairs.end(); + for (; It!=It_e; ++It) { - if(It->first == _from) + if (It->first==_from) { It->second = _to; break; } } - if(It==It_e) + if (It==It_e) m_subst_pairs.push_back(TSubstPair(_from, _to)); } -bool EScene::GetSubstObjectName(const xr_string& _from, xr_string& _to) const +bool EScene::GetSubstObjectName(const xr_string &_from, xr_string &_to) const { - TSubstPairs_cit It = m_subst_pairs.begin(); - TSubstPairs_cit It_e = m_subst_pairs.end(); - for(;It!=It_e;++It) + TSubstPairs_cit It = m_subst_pairs.begin(); + TSubstPairs_cit It_e = m_subst_pairs.end(); + for (; It!=It_e; ++It) { - if(It->first == _from) + if (It->first==_from) { _to = It->second; break; @@ -615,3 +698,4 @@ bool EScene::GetSubstObjectName(const xr_string& _from, xr_string& _to) const return (It!=It_e); } + diff --git a/src/editors/LevelEditor/Edit/scene.h b/src/editors/LevelEditor/Edit/scene.h index 8c082814dc8..bfe32cc2916 100644 --- a/src/editors/LevelEditor/Edit/scene.h +++ b/src/editors/LevelEditor/Edit/scene.h @@ -12,7 +12,7 @@ #include "ESceneCustomMTools.h" #include "ESceneCustomOTools.h" #include "Common/LevelStructure.hpp" -#include "../ECore/Editor/pick_defs.h" +#include "editors/ECore/Editor/pick_defs.h" //refs struct FSChunkDef; class PropValue; @@ -20,280 +20,374 @@ struct SPBItem; //---------------------------------------------------- #pragma pack( push,1 ) -struct UndoItem { - char m_FileName[MAX_PATH]; +struct UndoItem +{ + char m_FileName[MAX_PATH]; }; #pragma pack( pop ) class TProperties; -struct st_LevelOptions{ - shared_str m_FNLevelPath; - shared_str m_LevelPrefix; - shared_str m_BOPText; - shared_str m_map_version; - - u8 m_LightHemiQuality; - u8 m_LightSunQuality; - - b_params m_BuildParams; - - GameTypeChooser m_mapUsage; - st_LevelOptions (); - - void SetCustomQuality(); - void SetDraftQuality (); - void SetHighQuality (); - - void Save (IWriter&); - void SaveLTX (CInifile&); - - void Read (IReader&); - void ReadLTX (CInifile&); - void Reset (); +struct st_LevelOptions +{ + shared_str m_FNLevelPath; + shared_str m_LevelPrefix; + shared_str m_BOPText; + shared_str m_map_version; + + u8 m_LightHemiQuality; + u8 m_LightSunQuality; + + b_params m_BuildParams; + + GameTypeChooser m_mapUsage; + st_LevelOptions(); + + void SetCustomQuality(); + void SetDraftQuality(); + void SetHighQuality(); + + void Save(IWriter &); + void SaveLTX(CInifile &); + + void Read(IReader &); + void ReadLTX(CInifile &); + void Reset(); }; class EScene { - CMemoryWriter m_SaveCache; + CMemoryWriter m_SaveCache; public: - typedef FixedMAP mapObject_D; - typedef mapObject_D::TNode mapObject_Node; - mapObject_D mapRenderObjects; + typedef FixedMAP mapObject_D; + typedef mapObject_D::TNode mapObject_Node; + mapObject_D mapRenderObjects; public: - st_LevelOptions m_LevelOp; + st_LevelOptions m_LevelOp; protected: - bool m_Valid; - int m_Locked; + bool m_Valid; + int m_Locked; // version control - xrGUID m_GUID; - shared_str m_OwnerName; - time_t m_CreateTime; + xrGUID m_GUID; + shared_str m_OwnerName; + time_t m_CreateTime; // - int m_LastAvailObject; + int m_LastAvailObject; - SceneToolsMap m_SceneTools; + SceneToolsMap m_SceneTools; - xr_deque m_UndoStack; - xr_deque m_RedoStack; + xr_deque m_UndoStack; + xr_deque m_RedoStack; - TProperties* m_SummaryInfo; + TProperties *m_SummaryInfo; - ObjectList m_ESO_SnapObjects; // âðåìåííî çäåñü à âîîáùå íóæíî ïåðåíåñòè â ESceneTools + ObjectList m_ESO_SnapObjects; // âðåìåííî çäåñü à âîîáùå íóæíî ïåðåíåñòè â ESceneTools protected: - bool OnLoadAppendObject (CCustomObject* O); - bool OnLoadSelectionAppendObject(CCustomObject* O); + bool OnLoadAppendObject(CCustomObject *O); + bool OnLoadSelectionAppendObject(CCustomObject *O); protected: - void RegisterSceneTools (ESceneToolBase* mt); - void CreateSceneTools (); - void DestroySceneTools (); + void RegisterSceneTools(ESceneToolBase *mt); + void CreateSceneTools(); + void DestroySceneTools(); - void FindObjectByNameCB (LPCSTR new_name, bool& res){res=!!FindObjectByName(new_name,(CCustomObject*)0);} + void FindObjectByNameCB(LPCSTR new_name, bool &res) + { + res = !!FindObjectByName(new_name, (CCustomObject*)0); + } - void __stdcall OnBuildControlClick (ButtonValue* sender, bool& bModif, bool& bSafe); - void __stdcall OnRTFlagsChange (PropValue* sender); + void __stdcall OnBuildControlClick(ButtonValue *sender, bool &bModif, bool &bSafe); + void __stdcall OnRTFlagsChange(PropValue *sender); public: - enum{ - flRT_Unsaved = (1<<0), - flRT_Modified = (1<<1), - flUpdateSnapList = (1<<2), + enum + { + flRT_Unsaved = (1<<0), + flRT_Modified = (1<<1), + flUpdateSnapList = (1<<2), }; - Flags32 m_RTFlags; + + Flags32 m_RTFlags; public: - typedef bool (__closure *TAppendObject)(CCustomObject* object); + typedef bool (__closure + * + TAppendObject + ) + (CCustomObject + * + object + ); - bool ReadObjectStream (IReader& F, CCustomObject*& O); - bool ReadObjectLTX (CInifile& ini, LPCSTR sect_name, CCustomObject*& O); - bool ReadObjectsStream (IReader& F, u32 chunk_id, TAppendObject on_append, SPBItem* pb); - bool ReadObjectsLTX (CInifile& ini, LPCSTR sect_name_parent, LPCSTR sect_name_prefix, TAppendObject on_append, SPBItem* pb); + bool ReadObjectStream(IReader &F, CCustomObject *&O); + bool ReadObjectLTX(CInifile &ini, LPCSTR sect_name, CCustomObject *&O); + bool ReadObjectsStream(IReader &F, u32 chunk_id, TAppendObject on_append, SPBItem *pb); + bool ReadObjectsLTX(CInifile &ini, LPCSTR sect_name_parent, LPCSTR sect_name_prefix, TAppendObject on_append, SPBItem *pb); - void SaveObjectStream (CCustomObject* O,IWriter& F); - void SaveObjectLTX (CCustomObject* O, LPCSTR sect_name, CInifile& ini); - void SaveObjectsStream (ObjectList& lst, u32 chunk_id, IWriter& F ); - void SaveObjectsLTX (ObjectList& lst, LPCSTR sect_name_parent, LPCSTR sect_name_prefix, CInifile& ini); + void SaveObjectStream(CCustomObject *O, IWriter &F); + void SaveObjectLTX(CCustomObject *O, LPCSTR sect_name, CInifile &ini); + void SaveObjectsStream(ObjectList &lst, u32 chunk_id, IWriter &F); + void SaveObjectsLTX(ObjectList &lst, LPCSTR sect_name_parent, LPCSTR sect_name_prefix, CInifile &ini); - xr_string LevelPartPath (LPCSTR map_name); - xr_string LevelPartName (LPCSTR map_name, ObjClassID cls); + xr_string LevelPartPath(LPCSTR map_name); + xr_string LevelPartName(LPCSTR map_name, ObjClassID cls); - BOOL LoadLevelPart (ESceneToolBase* M, LPCSTR map_name); - BOOL LoadLevelPartLTX (ESceneToolBase* M, LPCSTR map_name); + BOOL LoadLevelPart(ESceneToolBase *M, LPCSTR map_name); + BOOL LoadLevelPartLTX(ESceneToolBase *M, LPCSTR map_name); - BOOL LoadLevelPart (LPCSTR map_name, ObjClassID cls); - BOOL UnloadLevelPart (ESceneToolBase* M); - BOOL UnloadLevelPart (LPCSTR map_name, ObjClassID cls); + BOOL LoadLevelPart(LPCSTR map_name, ObjClassID cls); + BOOL UnloadLevelPart(ESceneToolBase *M); + BOOL UnloadLevelPart(LPCSTR map_name, ObjClassID cls); public: - bool ExportGame (SExportStreams* F); + bool ExportGame(SExportStreams *F); + + bool Load(LPCSTR map_name, bool bUndo); + bool LoadLTX(LPCSTR map_name, bool bUndo); + + void Save(LPCSTR map_name, bool bUndo, bool bForceSaveAll); + void SaveLTX(LPCSTR map_name, bool bUndo, bool bForceSaveAll); + + bool LoadSelection(LPCSTR fname); + void SaveSelection(ObjClassID classfilter, LPCSTR fname); + + void SaveToolLTX(ObjClassID clsid, LPCSTR fn); + bool LoadToolLTX(ObjClassID clsid, LPCSTR fn); + + void Unload(BOOL bEditableToolsOnly); + void Clear(BOOL bEditableToolsOnly); + void Reset(); + void LoadCompilerError(LPCSTR fn); + void SaveCompilerError(LPCSTR fn); + void HighlightTexture(LPCSTR t_name, bool allow_ratio, u32 t_width, u32 t_height, bool leave_previous); + + int MultiRenameObjects(); + + IC + + bool valid() + { + return m_Valid; + } + + IC + + bool locked() + { + return m_Locked!=0; + } + + IC - bool Load (LPCSTR map_name, bool bUndo); - bool LoadLTX (LPCSTR map_name, bool bUndo); + void lock() + { + m_Locked++; + } + + IC - void Save (LPCSTR map_name, bool bUndo, bool bForceSaveAll); - void SaveLTX (LPCSTR map_name, bool bUndo, bool bForceSaveAll); + void unlock() + { + m_Locked--; + } - bool LoadSelection (LPCSTR fname); - void SaveSelection (ObjClassID classfilter, LPCSTR fname); + IC - void SaveToolLTX (ObjClassID clsid, LPCSTR fn); - bool LoadToolLTX (ObjClassID clsid, LPCSTR fn); - - void Unload (BOOL bEditableToolsOnly); - void Clear (BOOL bEditableToolsOnly); - void Reset (); - void LoadCompilerError (LPCSTR fn); - void SaveCompilerError (LPCSTR fn); - void HighlightTexture (LPCSTR t_name, bool allow_ratio, u32 t_width, u32 t_height, bool leave_previous); + void waitlock() + { + while (locked()) + Sleep(0); + } - int MultiRenameObjects (); + IC ESceneToolBase*GetTool(ObjClassID cat) + { + return m_SceneTools[cat]; + } - IC bool valid () { return m_Valid; } + IC ESceneCustomOTool*GetOTool(ObjClassID cat) + { + return dynamic_cast(GetTool(cat)); + } - IC bool locked () { return m_Locked!=0; } - IC void lock () { m_Locked++; } - IC void unlock () { m_Locked--; } - IC void waitlock () { while( locked() ) Sleep(0); } + IC SceneToolsMapPairIt FirstTool() + { + return m_SceneTools.begin(); + } - IC ESceneToolBase* GetTool (ObjClassID cat) { return m_SceneTools[cat];} + IC SceneToolsMapPairIt LastTool() + { + return m_SceneTools.end(); + } - IC ESceneCustomOTool* GetOTool (ObjClassID cat) { return dynamic_cast(GetTool(cat)); } + IC ObjectList&ListObj(ObjClassID cat) + { + VERIFY(GetOTool(cat)); + return GetOTool(cat)->GetObjects(); + } - IC SceneToolsMapPairIt FirstTool () { return m_SceneTools.begin(); } - IC SceneToolsMapPairIt LastTool () { return m_SceneTools.end(); } + IC ObjectIt FirstObj(ObjClassID cat) + { + VERIFY(GetOTool(cat)); + return ListObj(cat).begin(); + } - IC ObjectList& ListObj (ObjClassID cat) { VERIFY(GetOTool(cat)); return GetOTool(cat)->GetObjects(); } - IC ObjectIt FirstObj (ObjClassID cat) { VERIFY(GetOTool(cat)); return ListObj(cat).begin(); } - IC ObjectIt LastObj (ObjClassID cat) { VERIFY(GetOTool(cat)); return ListObj(cat).end(); } - IC int ObjCount (ObjClassID cat) { return ListObj(cat).size(); } - int ObjCount (); + IC ObjectIt LastObj(ObjClassID cat) + { + VERIFY(GetOTool(cat)); + return ListObj(cat).end(); + } - void RenderSky (const Fmatrix& camera); - void Render (const Fmatrix& camera); - void OnFrame (float dT); + IC - virtual void AppendObject (CCustomObject* object, bool bExecUnd= true); - virtual bool RemoveObject (CCustomObject* object, bool bExecUndo, bool bDeleting); - void BeforeObjectChange (CCustomObject* object); - bool ContainsObject (CCustomObject* object, ObjClassID classfilter); + int ObjCount(ObjClassID cat) + { + return ListObj(cat).size(); + } + + int ObjCount(); + + void RenderSky(const Fmatrix &camera); + void Render(const Fmatrix &camera); + void OnFrame(float dT); + + virtual void AppendObject(CCustomObject *object, bool bExecUnd = true); + virtual bool RemoveObject(CCustomObject *object, bool bExecUndo, bool bDeleting); + void BeforeObjectChange(CCustomObject *object); + bool ContainsObject(CCustomObject *object, ObjClassID classfilter); // Snap List Part - bool FindObjectInSnapList(CCustomObject* O); - bool AddToSnapList (CCustomObject* O, bool bUpdateScene=true); - bool DelFromSnapList (CCustomObject* O, bool bUpdateScene=true); - int AddSelToSnapList (); - int DelSelFromSnapList (); - int SetSnapList (); - void RenderSnapList (); - void ClearSnapList (bool bCurrentOnly); - void SelectSnapList (); - void UpdateSnapList (); - void UpdateSnapListReal (); - virtual ObjectList* GetSnapList (bool bIgnoreUse); - - virtual CCustomObject* RayPickObject (float dist, const Fvector& start, const Fvector& dir, ObjClassID classfilter, SRayPickInfo* pinf, ObjectList* from_list); - int BoxPickObjects (const Fbox& box, SBoxPickInfoVec& pinf, ObjectList* from_list); - int RayQuery (SPickQuery& RQ, const Fvector& start, const Fvector& dir, float dist, u32 flags, ObjectList* snap_list); - int BoxQuery (SPickQuery& RQ, const Fbox& bb, u32 flags, ObjectList* snap_list); - int RayQuery (SPickQuery& RQ, const Fvector& start, const Fvector& dir, float dist, u32 flags, CDB::MODEL* model); - int BoxQuery (SPickQuery& RQ, const Fbox& bb, u32 flags, CDB::MODEL* model); - - int RaySelect (int flag, ObjClassID classfilter=OBJCLASS_DUMMY); // flag=0,1,-1 (-1 invert) - int FrustumSelect (int flag, ObjClassID classfilter=OBJCLASS_DUMMY); - void SelectObjects (bool flag, ObjClassID classfilter=OBJCLASS_DUMMY); - void ShowObjects (bool flag, ObjClassID classfilter=OBJCLASS_DUMMY, bool bAllowSelectionFlag=false, bool bSelFlag=true); - void InvertSelection (ObjClassID classfilter); - int SelectionCount (bool testflag, ObjClassID classfilter); - void RemoveSelection (ObjClassID classfilter); - void CutSelection (ObjClassID classfilter); - void CopySelection (ObjClassID classfilter); - void PasteSelection (); - - void SelectLightsForObject(CCustomObject* obj); - - void ZoomExtents (ObjClassID cls, BOOL bSelectedOnly); - - int FrustumPick (const CFrustum& frustum, ObjClassID classfilter, ObjectList& ol); - int SpherePick (const Fvector& center, float radius, ObjClassID classfilter, ObjectList& ol); - - virtual void GenObjectName (ObjClassID cls_id, char *buffer, const char* prefix=NULL); - virtual CCustomObject* FindObjectByName (LPCSTR name, ObjClassID classfilter); - virtual CCustomObject* FindObjectByName (LPCSTR name, CCustomObject* pass_object); - bool FindDuplicateName (); - - void UndoClear (); - void UndoSave (); - bool Undo (); - bool Redo (); - - bool GetBox (Fbox& box, ObjClassID classfilter); - bool GetBox (Fbox& box, ObjectList& lst); + bool FindObjectInSnapList(CCustomObject *O); + bool AddToSnapList(CCustomObject *O, bool bUpdateScene = true); + bool DelFromSnapList(CCustomObject *O, bool bUpdateScene = true); + int AddSelToSnapList(); + int DelSelFromSnapList(); + int SetSnapList(); + void RenderSnapList(); + void ClearSnapList(bool bCurrentOnly); + void SelectSnapList(); + void UpdateSnapList(); + void UpdateSnapListReal(); + virtual ObjectList *GetSnapList(bool bIgnoreUse); + + virtual CCustomObject *RayPickObject(float dist, const Fvector &start, const Fvector &dir, ObjClassID classfilter, SRayPickInfo *pinf, ObjectList *from_list); + int BoxPickObjects(const Fbox &box, SBoxPickInfoVec &pinf, ObjectList *from_list); + int RayQuery(SPickQuery &RQ, const Fvector &start, const Fvector &dir, float dist, u32 flags, ObjectList *snap_list); + int BoxQuery(SPickQuery &RQ, const Fbox &bb, u32 flags, ObjectList *snap_list); + int RayQuery(SPickQuery &RQ, const Fvector &start, const Fvector &dir, float dist, u32 flags, CDB::MODEL *model); + int BoxQuery(SPickQuery &RQ, const Fbox &bb, u32 flags, CDB::MODEL *model); + + int RaySelect(int flag, ObjClassID classfilter = OBJCLASS_DUMMY); // flag=0,1,-1 (-1 invert) + int FrustumSelect(int flag, ObjClassID classfilter = OBJCLASS_DUMMY); + void SelectObjects(bool flag, ObjClassID classfilter = OBJCLASS_DUMMY); + void ShowObjects(bool flag, ObjClassID classfilter = OBJCLASS_DUMMY, bool bAllowSelectionFlag = false, bool bSelFlag = true); + void InvertSelection(ObjClassID classfilter); + int SelectionCount(bool testflag, ObjClassID classfilter); + void RemoveSelection(ObjClassID classfilter); + void CutSelection(ObjClassID classfilter); + void CopySelection(ObjClassID classfilter); + void PasteSelection(); + + void SelectLightsForObject(CCustomObject *obj); + + void ZoomExtents(ObjClassID cls, BOOL bSelectedOnly); + + int FrustumPick(const CFrustum &frustum, ObjClassID classfilter, ObjectList &ol); + int SpherePick(const Fvector ¢er, float radius, ObjClassID classfilter, ObjectList &ol); + + virtual void GenObjectName(ObjClassID cls_id, char *buffer, const char *prefix = NULL); + virtual CCustomObject *FindObjectByName(LPCSTR name, ObjClassID classfilter); + virtual CCustomObject *FindObjectByName(LPCSTR name, CCustomObject *pass_object); + bool FindDuplicateName(); + + void UndoClear(); + void UndoSave(); + bool Undo(); + bool Redo(); + + bool GetBox(Fbox &box, ObjClassID classfilter); + bool GetBox(Fbox &box, ObjectList &lst); public: - int GetQueryObjects (ObjectList& objset, ObjClassID classfilter, int iSel=1, int iVis=1, int iLock=0); - template - int GetQueryObjects_if (ObjectList& dest, ObjClassID classfilter, Predicate cmp){ - for(ObjectPairIt it=FirstClass(); it!=LastClass(); it++){ - ObjectList& lst = it->second; - if ((classfilter==OBJCLASS_DUMMY)||(classfilter==it->first)){ - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++){ - if (cmp(_F)) dest.push_back(*_F); + int GetQueryObjects(ObjectList &objset, ObjClassID classfilter, int iSel = 1, int iVis = 1, int iLock = 0); + + template + int GetQueryObjects_if(ObjectList &dest, ObjClassID classfilter, Predicate cmp) + { + for (ObjectPairIt it = FirstClass(); it!=LastClass(); it++) + { + ObjectList&lst = it->second; + if ((classfilter==OBJCLASS_DUMMY)||(classfilter==it->first)) + { + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + { + if (cmp(_F)) + dest.push_back(*_F); } } } return dest.size(); } + public: - void OnCreate (); - void OnDestroy (); - void Modified (); - bool IfModified (); - bool IsUnsaved (); - bool IsModified (); + void OnCreate(); + void OnDestroy(); + void Modified(); + bool IfModified(); + bool IsUnsaved(); + bool IsModified(); - int GetUndoCount (){return m_UndoStack.size();} - int GetRedoCount (){return m_RedoStack.size();} + int GetUndoCount() + { + return m_UndoStack.size(); + } - bool Validate (bool bNeedOkMsg, bool bTestPortal, bool bTestHOM, bool bTestGlow, bool bTestShaderCompatible, bool bFullTest); - void OnObjectsUpdate (); + int GetRedoCount() + { + return m_RedoStack.size(); + } - EScene (); - virtual ~EScene (); + bool Validate(bool bNeedOkMsg, bool bTestPortal, bool bTestHOM, bool bTestGlow, bool bTestShaderCompatible, bool bFullTest); + void OnObjectsUpdate(); - virtual void OnDeviceCreate (); - virtual void OnDeviceDestroy (); + EScene(); + virtual ~EScene(); - void OnShowHint (AStringVec& dest); + virtual void OnDeviceCreate(); + virtual void OnDeviceDestroy(); - void SynchronizeObjects(); + void OnShowHint(AStringVec &dest); - void ClearSummaryInfo (); - void CollectSummaryInfo (); - void ExportObj (bool b_selected_only); - void ShowSummaryInfo (); - void ExportSummaryInfo (LPCSTR f_name); + void SynchronizeObjects(); - xr_string LevelPath (); - shared_str LevelPrefix (){return m_LevelOp.m_LevelPrefix; } + void ClearSummaryInfo(); + void CollectSummaryInfo(); + void ExportObj(bool b_selected_only); + void ShowSummaryInfo(); + void ExportSummaryInfo(LPCSTR f_name); - void FillProp (LPCSTR pref, PropItemVec& items, ObjClassID cls_id); + xr_string LevelPath(); + + shared_str LevelPrefix() + { + return m_LevelOp.m_LevelPrefix; + } + + void FillProp(LPCSTR pref, PropItemVec &items, ObjClassID cls_id); protected: - typedef std::pair TSubstPair; - typedef xr_vector TSubstPairs; - typedef TSubstPairs::iterator TSubstPairs_it; - typedef TSubstPairs::const_iterator TSubstPairs_cit; - TSubstPairs m_subst_pairs; + typedef std::pair TSubstPair; + typedef xr_vector TSubstPairs; + typedef TSubstPairs::iterator TSubstPairs_it; + typedef TSubstPairs::const_iterator TSubstPairs_cit; + TSubstPairs m_subst_pairs; - -public: - void RegisterSubstObjectName (const xr_string& from, const xr_string& to ); - bool GetSubstObjectName (const xr_string& from, xr_string& to) const; +public: + void RegisterSubstObjectName(const xr_string &from, const xr_string &to); + bool GetSubstObjectName(const xr_string &from, xr_string &to) const; }; //---------------------------------------------------- -extern EScene* Scene; +extern EScene *Scene; //---------------------------------------------------- #endif /*_INCDEF_Scene_H_*/ diff --git a/src/editors/LevelEditor/Edit/sector.cpp b/src/editors/LevelEditor/Edit/sector.cpp index 37935293942..85d05b45948 100644 --- a/src/editors/LevelEditor/Edit/sector.cpp +++ b/src/editors/LevelEditor/Edit/sector.cpp @@ -6,166 +6,187 @@ #include "ESceneSectorTools.h" #include "Sector.h" -#include "../ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/EditMesh.h" #include "SceneObject.h" #include "Scene.h" -#include "../ECore/Engine/Texture.h" -#include "../../ECore/Engine/cl_intersect.h" -#include "../../ECore/Engine/cl_collector.h" +#include "editors/ECore/Engine/Texture.h" +#include "editors/ECore/Engine/cl_intersect.h" +#include "editors/ECore/Engine/cl_collector.h" #include "portal.h" #include "portalutils.h" #include "MgcConvexHull3D.h" -#include "../ECore/Editor/ui_main.h" -#include "../ECore/Editor/D3DUtils.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/D3DUtils.h" #include "ESceneGroupTools.h" -#define SECTOR_VERSION 0x0012 +#define SECTOR_VERSION 0x0012 //---------------------------------------------------- -#define SECTOR_CHUNK_VERSION 0xF010 -#define SECTOR_CHUNK_COLOR 0xF020 -#define SECTOR_CHUNK_PRIVATE 0xF025 -#define SECTOR_CHUNK_ITEMS 0xF030 -#define SECTOR_CHUNK_ONE_ITEM 0xF031 -#define SECTOR_CHUNK_MAP_IDX 0xF032 +#define SECTOR_CHUNK_VERSION 0xF010 +#define SECTOR_CHUNK_COLOR 0xF020 +#define SECTOR_CHUNK_PRIVATE 0xF025 +#define SECTOR_CHUNK_ITEMS 0xF030 +#define SECTOR_CHUNK_ONE_ITEM 0xF031 +#define SECTOR_CHUNK_MAP_IDX 0xF032 + //---------------------------------------------------- -CSectorItem::CSectorItem(){ - object=NULL; - mesh=NULL; +CSectorItem::CSectorItem() +{ + object = NULL; + mesh = NULL; } -CSectorItem::CSectorItem(CSceneObject* o, CEditableMesh* m){ - object=o; - mesh=m; + +CSectorItem::CSectorItem(CSceneObject *o, CEditableMesh *m) +{ + object = o; + mesh = m; } -void CSectorItem::GetTransform(Fmatrix& parent){ - object->GetFullTransformToWorld(parent); + +void CSectorItem::GetTransform(Fmatrix &parent) +{ + object->GetFullTransformToWorld(parent); } -bool CSectorItem::IsItem(const char* O, const char* M){ - return (0==stricmp(O,object->Name))&&(0==stricmp(M,mesh->Name().c_str())); + +bool CSectorItem::IsItem(const char *O, const char *M) +{ + return (0==stricmp(O, object->Name))&&(0==stricmp(M, mesh->Name().c_str())); } + //------------------------------------------------------------------------------ -CSector::CSector(LPVOID data, LPCSTR name):CCustomObject(data,name) +CSector::CSector(LPVOID data, LPCSTR name): CCustomObject(data, name) { - Construct(data); + Construct(data); } void CSector::Construct(LPVOID data) { - ClassID = OBJCLASS_SECTOR; - sector_color.set(1,1,1,0); - m_bDefault = false; - m_sector_num = -1; - m_bHasLoadError = false; - m_Flags.zero (); - m_map_idx = u8(-1); + ClassID = OBJCLASS_SECTOR; + sector_color.set(1, 1, 1, 0); + m_bDefault = false; + m_sector_num = -1; + m_bHasLoadError = false; + m_Flags.zero(); + m_map_idx = u8(-1); } CSector::~CSector() { - OnDestroy(); + OnDestroy(); } void CSector::OnFrame() { - inherited::OnFrame(); + inherited::OnFrame(); if (m_Flags.is(flNeedUpdateVolume)) - UpdateVolume(); + UpdateVolume(); } -bool CSector::FindSectorItem(const char* O, const char* M, SItemIt& it){ - for (it=sector_items.begin();it!=sector_items.end();it++) - if ((*it).IsItem(O,M)) return true; +bool CSector::FindSectorItem(const char *O, const char *M, SItemIt &it) +{ + for (it = sector_items.begin(); it!=sector_items.end(); it++) + if ((*it).IsItem(O, M)) + return true; return false; } -bool CSector::FindSectorItem(CSceneObject* o, CEditableMesh* m, SItemIt& it){ - for (it=sector_items.begin();it!=sector_items.end();it++) - if ((*it).IsItem(o,m)) return true; +bool CSector::FindSectorItem(CSceneObject *o, CEditableMesh *m, SItemIt &it) +{ + for (it = sector_items.begin(); it!=sector_items.end(); it++) + if ((*it).IsItem(o, m)) + return true; return false; } -bool CSector::AddMesh (CSceneObject* O, CEditableMesh* M) +bool CSector::AddMesh(CSceneObject *O, CEditableMesh *M) { - VERIFY(O&&M); - SItemIt it; - if (!(O->IsStatic()||O->IsMUStatic())) return false; - if (!PortalUtils.FindSector(O,M)) - if (!FindSectorItem(O, M, it)){ - sector_items.push_back(CSectorItem(O, M)); - m_Flags.set(flNeedUpdateVolume,TRUE); + VERIFY(O&&M); + SItemIt it; + if (!(O->IsStatic()||O->IsMUStatic())) + return false; + if (!PortalUtils.FindSector(O, M)) + if (!FindSectorItem(O, M, it)) + { + sector_items.push_back(CSectorItem(O, M)); + m_Flags.set(flNeedUpdateVolume, TRUE); return true; } return false; -} +} -int CSector::DelMesh (CSceneObject* O, CEditableMesh* M) +int CSector::DelMesh(CSceneObject *O, CEditableMesh *M) { - VERIFY(O&&M); - int res = 0; - SItemIt it; - if (FindSectorItem(O, M, it)){ - sector_items.erase(it); - m_Flags.set(flNeedUpdateVolume,TRUE); + VERIFY(O&&M); + int res = 0; + SItemIt it; + if (FindSectorItem(O, M, it)) + { + sector_items.erase(it); + m_Flags.set(flNeedUpdateVolume, TRUE); res = 1; } - if (sector_items.empty()){ - res = 2; - ELog.Msg(mtInformation,"Last mesh deleted.\nSector has no meshes and will be removed."); + if (sector_items.empty()) + { + res = 2; + ELog.Msg(mtInformation, "Last mesh deleted.\nSector has no meshes and will be removed."); DeleteThis(); } return res; } -bool CSector::GetBox( Fbox& box ) const +bool CSector::GetBox(Fbox &box) const { - box.set(m_SectorBox); - return true; + box.set(m_SectorBox); + return true; } void CSector::Render(int priority, bool strictB2F) { - ESceneSectorTool* lt = dynamic_cast(ParentTool); VERIFY(lt); - if (2==priority) + ESceneSectorTool *lt = dynamic_cast(ParentTool); + VERIFY(lt); + if (2==priority) { if (true==strictB2F) { - if (!lt->m_Flags.is(ESceneSectorTool::flDrawSolid)){ + if (!lt->m_Flags.is(ESceneSectorTool::flDrawSolid)) + { Fmatrix matrix; Fcolor color; - float k = Selected()?0.4f:0.2f; - color.set(sector_color.r,sector_color.g,sector_color.b,k); - EDevice.SetShader(EDevice.m_SelectionShader); - EDevice.SetRS(D3DRS_CULLMODE,D3DCULL_NONE); - for (SItemIt it=sector_items.begin();it!=sector_items.end();++it) + float k = Selected() ? 0.4f : 0.2f; + color.set(sector_color.r, sector_color.g, sector_color.b, k); + EDevice.SetShader(EDevice.m_SelectionShader); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_NONE); + for (SItemIt it = sector_items.begin(); it!=sector_items.end(); ++it) { it->object->GetFullTransformToWorld(matrix); - it->mesh->RenderSelection( matrix, 0, color.get() ); + it->mesh->RenderSelection(matrix, 0, color.get()); } - EDevice.SetRS(D3DRS_CULLMODE,D3DCULL_CCW); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CCW); } - }else if (false==strictB2F) + } + else if (false==strictB2F) { Fmatrix matrix; Fcolor color; Fcolor color2; - float k = Selected()?0.8f:0.5f; - float k2 = Selected()?0.5f:0.2f; - color.set(sector_color.r*k,sector_color.g*k,sector_color.b*k,1.f); - color2.set(sector_color.r*k2,sector_color.g*k2,sector_color.b*k2,1.f); + float k = Selected() ? 0.8f : 0.5f; + float k2 = Selected() ? 0.5f : 0.2f; + color.set(sector_color.r*k, sector_color.g*k, sector_color.b*k, 1.f); + color2.set(sector_color.r*k2, sector_color.g*k2, sector_color.b*k2, 1.f); if (lt->m_Flags.is(ESceneSectorTool::flDrawSolid)) { EDevice.SetShader(EDevice.m_WireShader); - EDevice.SetRS(D3DRS_CULLMODE,D3DCULL_NONE); - for (SItemIt it=sector_items.begin();it!=sector_items.end();++it) + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_NONE); + for (SItemIt it = sector_items.begin(); it!=sector_items.end(); ++it) { it->object->GetFullTransformToWorld(matrix); - it->mesh->RenderSelection( matrix, 0, color.get() ); - it->mesh->RenderEdge( matrix, 0, color2.get() ); + it->mesh->RenderSelection(matrix, 0, color.get()); + it->mesh->RenderEdge(matrix, 0, color2.get()); } - EDevice.SetRS(D3DRS_CULLMODE,D3DCULL_CCW); + EDevice.SetRS(D3DRS_CULLMODE, D3DCULL_CCW); } - if (Selected()){ + if (Selected()) + { RCache.set_xform_world(Fidentity); DU_impl.DrawSelectionBoxB(m_SectorBox); } @@ -173,25 +194,31 @@ void CSector::Render(int priority, bool strictB2F) } } -void CSector::Move( Fvector& amount ){ -// internal use only!!! +void CSector::Move(Fvector &amount) +{ + // internal use only!!! m_SectorCenter.add(amount); } -bool CSector::FrustumPick(const CFrustum& frustum) +bool CSector::FrustumPick(const CFrustum &frustum) { - if (!frustum.testSphere_dirty(m_SectorCenter,m_SectorRadius)) return false; - for (SItemIt s_it=sector_items.begin();s_it!=sector_items.end();s_it++) - if (s_it->mesh->FrustumPick(frustum,s_it->object->_Transform())) return true; - return false; + if (!frustum.testSphere_dirty(m_SectorCenter, m_SectorRadius)) + return false; + for (SItemIt s_it = sector_items.begin(); s_it!=sector_items.end(); s_it++) + if (s_it->mesh->FrustumPick(frustum, s_it->object->_Transform())) + return true; + return false; } -bool CSector::RayPick(float& distance, const Fvector& start, const Fvector& direction, SRayPickInfo* pinf){ - bool bPick=false; - for (SItemIt s_it=sector_items.begin();s_it!=sector_items.end();s_it++) - if (s_it->mesh->RayPick(distance,start,direction,s_it->object->_ITransform(),pinf)) bPick=true; - return bPick; +bool CSector::RayPick(float &distance, const Fvector &start, const Fvector &direction, SRayPickInfo *pinf) +{ + bool bPick = false; + for (SItemIt s_it = sector_items.begin(); s_it!=sector_items.end(); s_it++) + if (s_it->mesh->RayPick(distance, start, direction, s_it->object->_ITransform(), pinf)) + bPick = true; + return bPick; } + //---------------------------------------------------- void CSector::UpdateVolume() @@ -199,22 +226,25 @@ void CSector::UpdateVolume() Fbox bb; Fvector pt; m_SectorBox.invalidate(); - for (SItemIt s_it=sector_items.begin();s_it!=sector_items.end();s_it++){ + for (SItemIt s_it = sector_items.begin(); s_it!=sector_items.end(); s_it++) + { s_it->mesh->GetBox(bb); bb.xform(s_it->object->_Transform()); - for(int i=0; i<8; i++){ + for (int i = 0; i<8; i++) + { bb.getpoint(i, pt); m_SectorBox.modify(pt); } } - m_SectorBox.getsphere(m_SectorCenter,m_SectorRadius); + m_SectorBox.getsphere(m_SectorCenter, m_SectorRadius); UI->RedrawScene(); - m_Flags.set(flNeedUpdateVolume,FALSE); + m_Flags.set(flNeedUpdateVolume, FALSE); } + //---------------------------------------------------- -void CSector::OnDestroy( ) +void CSector::OnDestroy() { // remove existence sector portal PortalUtils.RemoveSectorPortal(this); @@ -222,206 +252,237 @@ void CSector::OnDestroy( ) void CSector::OnSceneUpdate() { -/* - bool bUpdate=false; - for(SItemIt it = sector_items.begin();it!=sector_items.end();it++){ - if (!(Scene->ContainsObject(it->object,OBJCLASS_SCENEOBJECT)&&it->object->GetReference()->ContainsMesh(it->mesh))){ - sector_items.erase(it); it--; - bUpdate=true; + /* + bool bUpdate=false; + for(SItemIt it = sector_items.begin();it!=sector_items.end();it++){ + if (!(Scene->ContainsObject(it->object,OBJCLASS_SCENEOBJECT)&&it->object->GetReference()->ContainsMesh(it->mesh))){ + sector_items.erase(it); it--; + bUpdate=true; + } } - } - if (bUpdate) PortalUtils.RemoveSectorPortal(this); -*/ - m_Flags.set(flNeedUpdateVolume,TRUE); + if (bUpdate) PortalUtils.RemoveSectorPortal(this); + */ + m_Flags.set(flNeedUpdateVolume, TRUE); } + //---------------------------------------------------- -EVisible CSector::Intersect(const Fvector& center, float radius) +EVisible CSector::Intersect(const Fvector ¢er, float radius) { - float dist=m_SectorCenter.distance_to(center); + float dist = m_SectorCenter.distance_to(center); Fvector R; m_SectorBox.getradius(R); - bool bInSphere = ((dist+radius)R.x)&&(radius>R.y)&&(radius>R.z); - if (m_SectorBox.contains(center)){ - if (bInSphere) return fvFully; - else return fvPartialInside; - }else{ - if (dist<(radius+m_SectorRadius)) return fvPartialOutside; + bool bInSphere = ((dist+radius)R.x)&&(radius>R.y)&&(radius>R.z); + if (m_SectorBox.contains(center)) + { + if (bInSphere) + return fvFully; + else + return fvPartialInside; + } + else + { + if (dist<(radius+m_SectorRadius)) + return fvPartialOutside; } - return fvNone; + return fvNone; } + //---------------------------------------------------- -EVisible CSector::Intersect(const Fbox& box) +EVisible CSector::Intersect(const Fbox &box) { - if (m_SectorBox.intersect(box)){ - Fvector c; float r; - box.getsphere(c,r); - return Intersect(c,r); - }else return fvNone; + if (m_SectorBox.intersect(box)) + { + Fvector c; + float r; + box.getsphere(c, r); + return Intersect(c, r); + } + else + return fvNone; } + //---------------------------------------------------- -void CSector::CaptureInsideVolume(){ - // test all mesh faces - // fill object list (test bounding sphere intersection) +void CSector::CaptureInsideVolume() +{ + // test all mesh faces + // fill object list (test bounding sphere intersection) ObjectList lst; - if (Scene->SpherePick(m_SectorCenter, m_SectorRadius, OBJCLASS_SCENEOBJECT, lst)){ - // test all object meshes + if (Scene->SpherePick(m_SectorCenter, m_SectorRadius, OBJCLASS_SCENEOBJECT, lst)) + { + // test all object meshes Fmatrix matrix; - CSceneObject *obj=NULL; + CSceneObject *obj = NULL; // ignore dynamic objects - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++){ - obj = (CSceneObject*)(*_F); - if (!(obj->IsStatic()||obj->IsMUStatic())) continue; - EditMeshVec* M = obj->Meshes(); + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + { + obj = (CSceneObject*)(*_F); + if (!(obj->IsStatic()||obj->IsMUStatic())) + continue; + EditMeshVec *M = obj->Meshes(); R_ASSERT(M); - for(EditMeshIt m_def = M->begin();m_def!=M->end();m_def++){ + for (EditMeshIt m_def = M->begin(); m_def!=M->end(); m_def++) + { obj->GetFullTransformToWorld(matrix); Fbox bb; - (*m_def)->GetBox(bb); + (*m_def)->GetBox(bb); bb.xform(matrix); - EVisible vis=Intersect(bb); - if ((fvFully==vis)||(fvPartialInside==vis)) - AddMesh(obj,*m_def); + EVisible vis = Intersect(bb); + if ((fvFully==vis)||(fvPartialInside==vis)) + AddMesh(obj, *m_def); } } - m_Flags.set (flNeedUpdateVolume,TRUE); - UI->RedrawScene (); - ExecCommand (COMMAND_UPDATE_PROPERTIES); + m_Flags.set(flNeedUpdateVolume, TRUE); + UI->RedrawScene(); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } } + //---------------------------------------------------- //. Fvector _dir[6]={{0,-1,0},{0,1,0},} -void CSector::DistributeInsideObjects(){ -/* - // test all mesh faces - // fill object list (test bounding sphere intersection) - ObjectList lst; - if (Scene->SpherePick(m_SectorCenter, m_SectorRadius, OBJCLASS_SCENEOBJECT, lst)){ - // test all object meshes - Fmatrix matrix; - CSceneObject *obj=NULL; - // ignore dynamic objects - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++){ - obj = (CSceneObject*)(*_F); - if (!(obj->IsStatic()||obj->IsMUStatic())) continue; - EditMeshVec* M = obj->Meshes(); - R_ASSERT(M); - for(EditMeshIt m_def = M->begin();m_def!=M->end();m_def++){ - obj->GetFullTransformToWorld(matrix); - Fbox bb; - (*m_def)->GetBox(bb); - bb.xform (matrix); - EVisible vis=Intersect(bb); - if ((fvFully==vis)||(fvPartialInside==vis)){ - float dist = m_SectorRadius; - Fvector start,dir; - bb.getcenter (start); - _f o r () - Scene->RayPickObject(dist,start,dir,) - //.AddMesh(obj,*m_def); +void CSector::DistributeInsideObjects() +{ + /* + // test all mesh faces + // fill object list (test bounding sphere intersection) + ObjectList lst; + if (Scene->SpherePick(m_SectorCenter, m_SectorRadius, OBJCLASS_SCENEOBJECT, lst)){ + // test all object meshes + Fmatrix matrix; + CSceneObject *obj=NULL; + // ignore dynamic objects + for(ObjectIt _F = lst.begin();_F!=lst.end();_F++){ + obj = (CSceneObject*)(*_F); + if (!(obj->IsStatic()||obj->IsMUStatic())) continue; + EditMeshVec* M = obj->Meshes(); + R_ASSERT(M); + for(EditMeshIt m_def = M->begin();m_def!=M->end();m_def++){ + obj->GetFullTransformToWorld(matrix); + Fbox bb; + (*m_def)->GetBox(bb); + bb.xform (matrix); + EVisible vis=Intersect(bb); + if ((fvFully==vis)||(fvPartialInside==vis)){ + float dist = m_SectorRadius; + Fvector start,dir; + bb.getcenter (start); + _f o r () + Scene->RayPickObject(dist,start,dir,) + //.AddMesh(obj,*m_def); + } } } + m_Flags.set (flNeedUpdateVolume,TRUE); + UI->RedrawScene (); + ExecCommand (COMMAND_UPDATE_PROPERTIES); } - m_Flags.set (flNeedUpdateVolume,TRUE); - UI->RedrawScene (); - ExecCommand (COMMAND_UPDATE_PROPERTIES); - } -*/ + */ } + //---------------------------------------------------- void CSector::CaptureAllUnusedMeshes() { U32Vec fl; - CSceneObject *obj=NULL; - ObjectList& lst=Scene->ListObj(OBJCLASS_SCENEOBJECT); + CSceneObject *obj = NULL; + ObjectList &lst = Scene->ListObj(OBJCLASS_SCENEOBJECT); // ignore dynamic objects - SPBItem* pb = UI->ProgressStart(lst.size(),"Capturing unused face..."); - for(ObjectIt _F = lst.begin();_F!=lst.end();_F++){ + SPBItem *pb = UI->ProgressStart(lst.size(), "Capturing unused face..."); + for (ObjectIt _F = lst.begin(); _F!=lst.end(); _F++) + { pb->Inc(); obj = (CSceneObject*)(*_F); - if (!(obj->IsStatic()||obj->IsMUStatic())) continue; - EditMeshVec* M = obj->Meshes(); + if (!(obj->IsStatic()||obj->IsMUStatic())) + continue; + EditMeshVec *M = obj->Meshes(); R_ASSERT(M); - for(EditMeshIt m_def = M->begin(); m_def!=M->end();m_def++) - AddMesh(obj,*m_def); + for (EditMeshIt m_def = M->begin(); m_def!=M->end(); m_def++) + AddMesh(obj, *m_def); } UI->ProgressEnd(pb); UI->RedrawScene(); } //---------------------------------------------------- -bool CSector::SpherePick(const Fvector& center, float radius){ - float R=radius+m_SectorRadius; - float dist_sqr=center.distance_to_sqr(m_SectorCenter); - if (dist_sqrmesh->GetFaceCount(true); - return !count; + int count = 0; + for (SItemIt it = sector_items.begin(); it!=sector_items.end(); it++) + count += it->mesh->GetFaceCount(true); + return !count; } + //---------------------------------------------------- -void CSector::GetCounts(int* objects, int* meshes, int* faces) +void CSector::GetCounts(int *objects, int *meshes, int *faces) { - if (faces){ - *faces=0; - for (SItemIt it=sector_items.begin();it!=sector_items.end();it++) - *faces+=it->mesh->GetFaceCount(true); + if (faces) + { + *faces = 0; + for (SItemIt it = sector_items.begin(); it!=sector_items.end(); it++) + *faces += it->mesh->GetFaceCount(true); } - if (meshes) *meshes=sector_items.size(); - if (objects){ + if (meshes) + *meshes = sector_items.size(); + if (objects) + { xr_set objs; - for (SItemIt it=sector_items.begin();it!=sector_items.end();it++) - objs.insert(it->object); - *objects=objs.size(); + for (SItemIt it = sector_items.begin(); it!=sector_items.end(); it++) + objs.insert(it->object); + *objects = objs.size(); } } + //---------------------------------------------------- -void CSector::LoadSectorDef( IReader* F ) +void CSector::LoadSectorDef(IReader *F) { - string256 o_name=""; - string256 m_name=""; + string256 o_name = ""; + string256 m_name = ""; CSectorItem sitem; - // sector item + // sector item R_ASSERT(F->find_chunk(SECTOR_CHUNK_ONE_ITEM)); - F->r_stringZ(o_name,sizeof(o_name)); - sitem.object=(CSceneObject*)Scene->FindObjectByName(o_name,OBJCLASS_SCENEOBJECT); + F->r_stringZ(o_name, sizeof(o_name)); + sitem.object = (CSceneObject*)Scene->FindObjectByName(o_name, OBJCLASS_SCENEOBJECT); if (sitem.object==NULL) { - ELog.Msg (mtError,"Sector Item contains object '%s' - can't load.\nObject not found.",o_name); + ELog.Msg(mtError, "Sector Item contains object '%s' - can't load.\nObject not found.", o_name); m_bHasLoadError = true; return; } if (!(sitem.object->IsStatic()||sitem.object->IsMUStatic())) { - ELog.Msg(mtError,"Sector Item contains object '%s' - can't load.\nObject is dynamic.",o_name); + ELog.Msg(mtError, "Sector Item contains object '%s' - can't load.\nObject is dynamic.", o_name); m_bHasLoadError = true; return; } - F->r_stringZ(m_name,sizeof(m_name)); - sitem.mesh=sitem.object->GetReference()->FindMeshByName(m_name); + F->r_stringZ(m_name, sizeof(m_name)); + sitem.mesh = sitem.object->GetReference()->FindMeshByName(m_name); if (sitem.mesh==0) { - ELog.Msg(mtError,"Sector Item contains object '%s' mesh '%s' - can't load.\nMesh not found.",o_name,m_name); + ELog.Msg(mtError, "Sector Item contains object '%s' mesh '%s' - can't load.\nMesh not found.", o_name, m_name); m_bHasLoadError = true; return; } @@ -429,44 +490,44 @@ void CSector::LoadSectorDef( IReader* F ) sector_items.push_back(sitem); } -void CSector::LoadSectorDefLTX( CInifile& ini, LPCSTR sect_name, u32 item_idx ) +void CSector::LoadSectorDefLTX(CInifile &ini, LPCSTR sect_name, u32 item_idx) { - LPCSTR o_name = NULL; - LPCSTR m_name = NULL; + LPCSTR o_name = NULL; + LPCSTR m_name = NULL; - CSectorItem sitem; - string512 buff; + CSectorItem sitem; + string512 buff; - sprintf (buff,"item_object_name_%.4d",item_idx); - o_name = ini.r_string (sect_name, buff); + sprintf(buff, "item_object_name_%.4d", item_idx); + o_name = ini.r_string(sect_name, buff); - // sector item - o_name = ini.r_string(sect_name, buff); - if(!o_name) - ELog.Msg (mtError,"Sector Item contains not nnamed object - can't load"); - - sitem.object=(CSceneObject*)Scene->FindObjectByName(o_name,OBJCLASS_SCENEOBJECT); + // sector item + o_name = ini.r_string(sect_name, buff); + if (!o_name) + ELog.Msg(mtError, "Sector Item contains not nnamed object - can't load"); + + sitem.object = (CSceneObject*)Scene->FindObjectByName(o_name, OBJCLASS_SCENEOBJECT); if (sitem.object==NULL) { - ELog.Msg (mtError,"Sector Item contains object '%s' - can't load.\nObject not found.",o_name); + ELog.Msg(mtError, "Sector Item contains object '%s' - can't load.\nObject not found.", o_name); m_bHasLoadError = true; return; } if (!(sitem.object->IsStatic()||sitem.object->IsMUStatic())) { - ELog.Msg(mtError,"Sector Item contains object '%s' - can't load.\nObject is dynamic.",o_name); + ELog.Msg(mtError, "Sector Item contains object '%s' - can't load.\nObject is dynamic.", o_name); m_bHasLoadError = true; return; } - sprintf (buff,"item_mesh_name_%.4d",item_idx); - m_name = ini.r_string (sect_name, buff); + sprintf(buff, "item_mesh_name_%.4d", item_idx); + m_name = ini.r_string(sect_name, buff); - sitem.mesh=sitem.object->GetReference()->FindMeshByName(m_name); + sitem.mesh = sitem.object->GetReference()->FindMeshByName(m_name); if (sitem.mesh==0) { - ELog.Msg(mtError,"Sector Item contains object '%s' mesh '%s' - can't load.\nMesh not found.",o_name,m_name); + ELog.Msg(mtError, "Sector Item contains object '%s' mesh '%s' - can't load.\nMesh not found.", o_name, m_name); m_bHasLoadError = true; return; } @@ -474,185 +535,199 @@ void CSector::LoadSectorDefLTX( CInifile& ini, LPCSTR sect_name, u32 item_idx ) sector_items.push_back(sitem); } -bool CSector::LoadLTX(CInifile& ini, LPCSTR sect_name) +bool CSector::LoadLTX(CInifile &ini, LPCSTR sect_name) { - u32 version = ini.r_u32 (sect_name, "version"); - if( version<0x0011) + u32 version = ini.r_u32(sect_name, "version"); + if (version<0x0011) { - ELog.Msg( mtError, "CSector: Unsupported version."); + ELog.Msg(mtError, "CSector: Unsupported version."); return false; } - CCustomObject::LoadLTX (ini, sect_name); + CCustomObject::LoadLTX(ini, sect_name); - sector_color.set( ini.r_color(sect_name, "sector_color") ); + sector_color.set(ini.r_color(sect_name, "sector_color")); - m_bDefault = ini.r_bool(sect_name, "default"); + m_bDefault = ini.r_bool(sect_name, "default"); - u32 obj_cnt = ini.r_u32(sect_name, "items_count"); - for(u32 i=0; i=0x0012) - m_map_idx = ini.r_u8(sect_name, "change_map_to_idx"); - - if (sector_items.empty()) return false; + if (version>=0x0012) + m_map_idx = ini.r_u8(sect_name, "change_map_to_idx"); + + if (sector_items.empty()) + return false; - m_Flags.set(flNeedUpdateVolume,TRUE); + m_Flags.set(flNeedUpdateVolume, TRUE); return true; } -void CSector::SaveLTX(CInifile& ini, LPCSTR sect_name) +void CSector::SaveLTX(CInifile &ini, LPCSTR sect_name) { - CCustomObject::SaveLTX(ini, sect_name); + CCustomObject::SaveLTX(ini, sect_name); - ini.w_u32 (sect_name, "version", SECTOR_VERSION); + ini.w_u32(sect_name, "version", SECTOR_VERSION); - ini.w_color (sect_name, "sector_color", sector_color.get()); + ini.w_color(sect_name, "sector_color", sector_color.get()); - ini.w_bool (sect_name, "default", m_bDefault); + ini.w_bool(sect_name, "default", m_bDefault); - int count=0; - ini.w_u32 (sect_name, "items_count", sector_items.size()); - string512 buff; - for(SItemIt it=sector_items.begin(); it!=sector_items.end(); ++it) + int count = 0; + ini.w_u32(sect_name, "items_count", sector_items.size()); + string512 buff; + for (SItemIt it = sector_items.begin(); it!=sector_items.end(); ++it) { - sprintf (buff,"item_object_name_%.4d",count); - ini.w_string (sect_name, buff, it->object->Name); - sprintf (buff,"item_mesh_name_%.4d",count); - ini.w_string (sect_name, buff, it->mesh->Name().c_str()); - ++count; + sprintf(buff, "item_object_name_%.4d", count); + ini.w_string(sect_name, buff, it->object->Name); + sprintf(buff, "item_mesh_name_%.4d", count); + ini.w_string(sect_name, buff, it->mesh->Name().c_str()); + ++count; } - ini.w_u8(sect_name, "change_map_to_idx", m_map_idx); - + ini.w_u8(sect_name, "change_map_to_idx", m_map_idx); } -bool CSector::LoadStream(IReader& F) +bool CSector::LoadStream(IReader &F) { - u16 version = 0; + u16 version = 0; char buf[1024]; - R_ASSERT(F.r_chunk(SECTOR_CHUNK_VERSION,&version)); - if( version!=SECTOR_VERSION ){ - ELog.Msg( mtError, "CSector: Unsupported version."); + R_ASSERT(F.r_chunk(SECTOR_CHUNK_VERSION, &version)); + if (version!=SECTOR_VERSION) + { + ELog.Msg(mtError, "CSector: Unsupported version."); return false; } - CCustomObject::LoadStream(F); + CCustomObject::LoadStream(F); - R_ASSERT(F.r_chunk(SECTOR_CHUNK_COLOR,§or_color)); + R_ASSERT(F.r_chunk(SECTOR_CHUNK_COLOR, §or_color)); - R_ASSERT(F.find_chunk(SECTOR_CHUNK_PRIVATE)); - m_bDefault = F.r_u8(); + R_ASSERT(F.find_chunk(SECTOR_CHUNK_PRIVATE)); + m_bDefault = F.r_u8(); // Objects - IReader* OBJ = F.open_chunk(SECTOR_CHUNK_ITEMS); - if(OBJ){ - IReader* O = OBJ->open_chunk(0); - for (int count=1; O; count++) { + IReader *OBJ = F.open_chunk(SECTOR_CHUNK_ITEMS); + if (OBJ) + { + IReader *O = OBJ->open_chunk(0); + for (int count = 1; O; count++) + { LoadSectorDef(O); - O->close (); - O = OBJ->open_chunk(count); + O->close(); + O = OBJ->open_chunk(count); } OBJ->close(); } - if(F.find_chunk (SECTOR_CHUNK_MAP_IDX)) - m_map_idx = F.r_u8(); + if (F.find_chunk(SECTOR_CHUNK_MAP_IDX)) + m_map_idx = F.r_u8(); - if (sector_items.empty()) return false; + if (sector_items.empty()) + return false; - m_Flags.set(flNeedUpdateVolume,TRUE); + m_Flags.set(flNeedUpdateVolume, TRUE); return true; } -void CSector::SaveStream(IWriter& F) +void CSector::SaveStream(IWriter &F) { - CCustomObject::SaveStream(F); + CCustomObject::SaveStream(F); - F.open_chunk (SECTOR_CHUNK_VERSION); - F.w_u16 (SECTOR_VERSION); - F.close_chunk (); + F.open_chunk(SECTOR_CHUNK_VERSION); + F.w_u16(SECTOR_VERSION); + F.close_chunk(); - F.w_chunk (SECTOR_CHUNK_COLOR,§or_color,sizeof(Fcolor)); + F.w_chunk(SECTOR_CHUNK_COLOR, §or_color, sizeof(Fcolor)); - F.open_chunk (SECTOR_CHUNK_PRIVATE); - F.w_u8 (m_bDefault); - F.close_chunk (); + F.open_chunk(SECTOR_CHUNK_PRIVATE); + F.w_u8(m_bDefault); + F.close_chunk(); - F.open_chunk (SECTOR_CHUNK_ITEMS); - int count=0; - for(SItemIt it=sector_items.begin(); it!=sector_items.end(); it++){ - F.open_chunk(count); count++; - F.open_chunk (SECTOR_CHUNK_ONE_ITEM); - F.w_stringZ (it->object->Name); - F.w_stringZ (it->mesh->Name()); - F.close_chunk (); - F.close_chunk (); + F.open_chunk(SECTOR_CHUNK_ITEMS); + int count = 0; + for (SItemIt it = sector_items.begin(); it!=sector_items.end(); it++) + { + F.open_chunk(count); + count++; + F.open_chunk(SECTOR_CHUNK_ONE_ITEM); + F.w_stringZ(it->object->Name); + F.w_stringZ(it->mesh->Name()); + F.close_chunk(); + F.close_chunk(); } - F.close_chunk (); + F.close_chunk(); - F.open_chunk (SECTOR_CHUNK_MAP_IDX); - F.w_u8 (m_map_idx); - F.close_chunk (); + F.open_chunk(SECTOR_CHUNK_MAP_IDX); + F.w_u8(m_map_idx); + F.close_chunk(); } //---------------------------------------------------- xr_token level_sub_map[] = { - {"default", u8(-1)}, - {"#0", 0}, - {"#1", 1}, - {"#2", 2}, - {"#3", 3}, - {NULL, 4} + {"default", u8(-1)}, + {"#0", 0}, + {"#1", 1}, + {"#2", 2}, + {"#3", 3}, + {NULL, 4} }; -void CSector::FillProp(LPCSTR pref, PropItemVec& items) +void CSector::FillProp(LPCSTR pref, PropItemVec &items) { - inherited::FillProp(pref,items); - PHelper().CreateFColor(items, PrepareKey(pref,"Color"), §or_color); + inherited::FillProp(pref, items); + PHelper().CreateFColor(items, PrepareKey(pref, "Color"), §or_color); int faces, objects, meshes; - GetCounts(&objects,&meshes,&faces); - PHelper().CreateCaption(items,PrepareKey(pref,Name,"Contents\\Objects"), AnsiString(objects).c_str()); - PHelper().CreateCaption(items,PrepareKey(pref,Name,"Contents\\Meshes"), AnsiString(meshes).c_str()); - PHelper().CreateCaption(items,PrepareKey(pref,Name,"Contents\\Faces"), AnsiString(faces).c_str()); - PHelper().CreateToken8(items, PrepareKey(pref,Name,"Change LevelMap to"), &m_map_idx, level_sub_map); - + GetCounts(&objects, &meshes, &faces); + PHelper().CreateCaption(items, PrepareKey(pref, Name, "Contents\\Objects"), AnsiString(objects).c_str()); + PHelper().CreateCaption(items, PrepareKey(pref, Name, "Contents\\Meshes"), AnsiString(meshes).c_str()); + PHelper().CreateCaption(items, PrepareKey(pref, Name, "Contents\\Faces"), AnsiString(faces).c_str()); + PHelper().CreateToken8(items, PrepareKey(pref, Name, "Change LevelMap to"), &m_map_idx, level_sub_map); } + //---------------------------------------------------- -bool CSector::GetSummaryInfo(SSceneSummary* inf) +bool CSector::GetSummaryInfo(SSceneSummary *inf) { - inherited::GetSummaryInfo (inf); - inf->sector_cnt++; - return true; + inherited::GetSummaryInfo(inf); + inf->sector_cnt++; + return true; } bool CSector::Validate(bool bMsg) { - bool bRes = true; + bool bRes = true; // verify face count int f_cnt; - GetCounts (0,0,&f_cnt); - if (f_cnt<=4){ - if (bMsg) ELog.Msg(mtError,"*ERROR: Sector: '%s' - face count < 4!",Name); - bRes = false; + GetCounts(0, 0, &f_cnt); + if (f_cnt<=4) + { + if (bMsg) + ELog.Msg(mtError, "*ERROR: Sector: '%s' - face count < 4!", Name); + bRes = false; } // verify shader compatibility - bool bRenderableFound = false; - for (SItemIt it=sector_items.begin();it!=sector_items.end();it++){ - for (SurfFacesPairIt sf_it=it->mesh->m_SurfFaces.begin(); sf_it!=it->mesh->m_SurfFaces.end(); sf_it++){ - CSurface* surf = sf_it->first; - Shader_xrLC* c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); - if (c_sh->flags.bRendering) bRenderableFound = true; + bool bRenderableFound = false; + for (SItemIt it = sector_items.begin(); it!=sector_items.end(); it++) + { + for (SurfFacesPairIt sf_it = it->mesh->m_SurfFaces.begin(); sf_it!=it->mesh->m_SurfFaces.end(); sf_it++) + { + CSurface *surf = sf_it->first; + Shader_xrLC *c_sh = EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName()); + if (c_sh->flags.bRendering) + bRenderableFound = true; } - } - if (!bRenderableFound){ - if (bMsg) ELog.Msg(mtError,"*ERROR: Sector: '%s' - can't find any renderable face!",Name); - bRes = false; - } - return bRes; + } + if (!bRenderableFound) + { + if (bMsg) + ELog.Msg(mtError, "*ERROR: Sector: '%s' - can't find any renderable face!", Name); + bRes = false; + } + return bRes; } + diff --git a/src/editors/LevelEditor/Edit/sector.h b/src/editors/LevelEditor/Edit/sector.h index 0ce4784edfb..095a7bb9b8f 100644 --- a/src/editors/LevelEditor/Edit/sector.h +++ b/src/editors/LevelEditor/Edit/sector.h @@ -3,8 +3,10 @@ #include "portalutils.h" #include "CustomObject.h" -enum EVisible{ - fvNone, + +enum EVisible +{ + fvNone, fvPartialInside, fvPartialOutside, fvFully @@ -14,98 +16,122 @@ enum EVisible{ // refs class CEditableMesh; -class CSectorItem{ - friend class CSector; - friend class SceneBuilder; +class CSectorItem +{ + friend class CSector; + friend class SceneBuilder; friend class CPortalUtils; - CSceneObject* object; - CEditableMesh* mesh; + CSceneObject *object; + CEditableMesh *mesh; public: - CSectorItem (); - CSectorItem (CSceneObject* o, CEditableMesh* m); - void GetTransform(Fmatrix& parent); - bool IsItem (const char* O, const char* M); - IC bool IsItem (CSceneObject* o, CEditableMesh* m){ return (o==object)&&(m==mesh); } + CSectorItem(); + CSectorItem(CSceneObject *o, CEditableMesh *m); + void GetTransform(Fmatrix &parent); + bool IsItem(const char *O, const char *M); + IC + + bool IsItem(CSceneObject *o, CEditableMesh *m) + { + return (o==object)&&(m==mesh); + } }; -DEFINE_VECTOR(CSectorItem,SItemVec,SItemIt); +DEFINE_VECTOR(CSectorItem, SItemVec, SItemIt); -class CSector : public CCustomObject { - friend class TfrmPropertiesSector; - friend class SceneBuilder; +class CSector : public CCustomObject +{ + friend class TfrmPropertiesSector; + friend class SceneBuilder; friend class CPortalUtils; friend class CPortal; - typedef CCustomObject inherited; + typedef CCustomObject inherited; + + u8 m_bDefault; + bool m_bHasLoadError; - u8 m_bDefault; - bool m_bHasLoadError; + Fbox m_SectorBox; - Fbox m_SectorBox; + Fvector m_SectorCenter; + float m_SectorRadius; - Fvector m_SectorCenter; - float m_SectorRadius; + Fcolor sector_color; + SItemVec sector_items; + bool FindSectorItem(CSceneObject *o, CEditableMesh *m, SItemIt &it); + bool FindSectorItem(const char *O, const char *M, SItemIt &it); + void LoadSectorDef(IReader *F); + void LoadSectorDefLTX(CInifile &ini, LPCSTR sect_name, u32 item_idx); - Fcolor sector_color; - SItemVec sector_items; - bool FindSectorItem (CSceneObject* o, CEditableMesh* m, SItemIt& it); - bool FindSectorItem (const char* O, const char* M, SItemIt& it); - void LoadSectorDef ( IReader* F ); - void LoadSectorDefLTX ( CInifile& ini, LPCSTR sect_name, u32 item_idx ); - enum{ - flNeedUpdateVolume = (1<<0) + enum + { + flNeedUpdateVolume = (1<<0) }; - Flags32 m_Flags; + Flags32 m_Flags; // only for build - int m_sector_num; - void OnDestroy (); - void UpdateVolume(); + int m_sector_num; + void OnDestroy(); + void UpdateVolume(); public: - u8 m_map_idx; - - CSector (LPVOID data, LPCSTR name); - void Construct (LPVOID data); - virtual ~CSector (); - virtual bool CanAttach () {return false;} - - virtual void Render (int priority, bool strictB2F); - virtual bool RayPick (float& distance,const Fvector& start,const Fvector& direction, - SRayPickInfo* pinf = NULL); - virtual bool FrustumPick (const CFrustum& frustum); - virtual bool SpherePick (const Fvector& center, float radius); - virtual bool GetBox (Fbox& box) const; - virtual void Move ( Fvector& amount ); // need for Shift Level - virtual void OnSceneUpdate(); + u8 m_map_idx; + + CSector(LPVOID data, LPCSTR name); + void Construct(LPVOID data); + virtual ~CSector(); + + virtual bool CanAttach() + { + return false; + } + + virtual void Render(int priority, bool strictB2F); + virtual bool RayPick(float &distance, const Fvector &start, const Fvector &direction, + SRayPickInfo *pinf = NULL); + virtual bool FrustumPick(const CFrustum &frustum); + virtual bool SpherePick(const Fvector ¢er, float radius); + virtual bool GetBox(Fbox &box) const; + virtual void Move(Fvector &amount); // need for Shift Level + virtual void OnSceneUpdate(); // file system function - virtual bool LoadStream (IReader&); - virtual bool LoadLTX (CInifile& ini, LPCSTR sect_name); - virtual void SaveStream (IWriter&); - virtual void SaveLTX (CInifile& ini, LPCSTR sect_name); - virtual void FillProp (LPCSTR pref, PropItemVec& values); - virtual bool GetSummaryInfo (SSceneSummary* inf); - - bool AddMesh (CSceneObject* O, CEditableMesh* M); // âîçâðàùàåò äîáàâëåí ëè îáúåêò - int DelMesh (CSceneObject* O, CEditableMesh* M); // 0-íå óäàëåí 1-óäàëåí 2-óäàëåí ñåêòîð âîîáùå - - bool IsDefault (){return m_bDefault;} - bool Contains (CSceneObject* O, CEditableMesh* M){SItemIt it; return FindSectorItem(O,M,it);} - - void SetColor (u32 clr){sector_color.set(subst_alpha(clr,0));} - - void CaptureInsideVolume(); - void DistributeInsideObjects (); - void CaptureAllUnusedMeshes (); - void GetCounts (int* objects, int* meshes, int* faces); - bool IsEmpty (); - - virtual void OnFrame (); - - EVisible Intersect (const Fvector& center, float radius); - EVisible Intersect (const Fbox& box); - - virtual bool Validate (bool bMsg); + virtual bool LoadStream(IReader &); + virtual bool LoadLTX(CInifile &ini, LPCSTR sect_name); + virtual void SaveStream(IWriter &); + virtual void SaveLTX(CInifile &ini, LPCSTR sect_name); + virtual void FillProp(LPCSTR pref, PropItemVec &values); + virtual bool GetSummaryInfo(SSceneSummary *inf); + + bool AddMesh(CSceneObject *O, CEditableMesh *M); // âîçâðàùàåò äîáàâëåí ëè îáúåêò + int DelMesh(CSceneObject *O, CEditableMesh *M); // 0-íå óäàëåí 1-óäàëåí 2-óäàëåí ñåêòîð âîîáùå + + bool IsDefault() + { + return m_bDefault; + } + + bool Contains(CSceneObject *O, CEditableMesh *M) + { + SItemIt it; + return FindSectorItem(O, M, it); + } + + void SetColor(u32 clr) + { + sector_color.set(subst_alpha(clr, 0)); + } + + void CaptureInsideVolume(); + void DistributeInsideObjects(); + void CaptureAllUnusedMeshes(); + void GetCounts(int *objects, int *meshes, int *faces); + bool IsEmpty(); + + virtual void OnFrame(); + + EVisible Intersect(const Fvector ¢er, float radius); + EVisible Intersect(const Fbox &box); + + virtual bool Validate(bool bMsg); }; #endif /*_INCDEF_Sector_H_*/ diff --git a/src/editors/LevelEditor/EditLibrary.cpp b/src/editors/LevelEditor/EditLibrary.cpp index 40e724f7fd5..27607879491 100644 --- a/src/editors/LevelEditor/EditLibrary.cpp +++ b/src/editors/LevelEditor/EditLibrary.cpp @@ -4,21 +4,21 @@ #pragma hdrstop #include "EditLibrary.h" -#include "../ECore/Editor/Library.h" -#include "ui_leveltools.h" -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/Library.h" +#include "UI_LevelTools.h" +#include "editors/ECore/Editor/EditObject.h" #include "Main.h" #include "Scene.h" #include "Builder.h" -#include "../ECore/Engine/Texture.h" +#include "editors/ECore/Engine/Texture.h" #include "BottomBar.h" -#include "../ECore/Editor/ImageManager.h" -#include "../ECore/Editor/EThumbnail.h" +#include "editors/ECore/Editor/ImageManager.h" +#include "editors/ECore/Editor/EThumbnail.h" #include "ESceneDOTools.h" -#include "xr_trims.h" +#include "xrCore/xr_trims.h" #include "SceneObject.h" -#include "../ECore/Engine/Image.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Engine/Image.h" +#include "editors/ECore/Editor/ui_main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "ElTree" @@ -34,50 +34,54 @@ #pragma link "MXCtrls" #pragma resource "*.dfm" -TfrmEditLibrary* TfrmEditLibrary::form=0; +TfrmEditLibrary *TfrmEditLibrary::form = 0; FS_FileSet TfrmEditLibrary::modif_map; bool TfrmEditLibrary::bFinalExit = false; -bool TfrmEditLibrary::bExitResult= true; +bool TfrmEditLibrary::bExitResult = true; //--------------------------------------------------------------------------- -__fastcall TfrmEditLibrary::TfrmEditLibrary(TComponent* Owner) +__fastcall TfrmEditLibrary::TfrmEditLibrary(TComponent *Owner) : TForm(Owner) { DEFINE_INI(fsStorage); -// m_pEditObject = xr_new((LPVOID)0,(LPSTR)0); - m_Props = TfrmPropertiesEObject::CreateProperties(0,alNone,TOnModifiedEvent(this,&TfrmEditLibrary::OnModified)); - m_Items = TItemList::CreateForm("Objects",paItems,alClient,TItemList::ilMultiSelect|TItemList::ilEditMenu|TItemList::ilDragAllowed|TItemList::ilFolderStore); - m_Items->SetOnItemsFocusedEvent (fastdelegate::bind(this,&TfrmEditLibrary::OnItemsFocused)); + // m_pEditObject = xr_new((LPVOID)0,(LPSTR)0); + m_Props = TfrmPropertiesEObject::CreateProperties(0, alNone, TOnModifiedEvent(this, &TfrmEditLibrary::OnModified)); + m_Items = TItemList::CreateForm("Objects", paItems, alClient, TItemList::ilMultiSelect|TItemList::ilEditMenu|TItemList::ilDragAllowed|TItemList::ilFolderStore); + m_Items->SetOnItemsFocusedEvent(fastdelegate::bind(this, &TfrmEditLibrary::OnItemsFocused)); - m_Items->SetOnItemRemoveEvent (fastdelegate::bind(&Lib,&ELibrary::RemoveObject)); - m_Items->SetOnItemRenameEvent (fastdelegate::bind(&Lib,&ELibrary::RenameObject)); - bReadOnly = false; + m_Items->SetOnItemRemoveEvent(fastdelegate::bind(&Lib, &ELibrary::RemoveObject)); + m_Items->SetOnItemRenameEvent(fastdelegate::bind(&Lib, &ELibrary::RenameObject)); + bReadOnly = false; } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ShowEditor() { - if (!form){ - form = xr_new((TComponent*)0); - Scene->lock(); + if (!form) + { + form = xr_new((TComponent*)0); + Scene->lock(); } form->Show(); } + //--------------------------------------------------------------------------- -CSceneObject* __fastcall TfrmEditLibrary::RayPick(const Fvector& start, const Fvector& direction, SRayPickInfo* pinf) +CSceneObject * __fastcall TfrmEditLibrary::RayPick(const Fvector &start, const Fvector &direction, SRayPickInfo *pinf) { - if (!form) return 0; - if (form->cbPreview->Checked) + if (!form) + return 0; + if (form->cbPreview->Checked) { - float dist=UI->ZFar(); - xr_vector::iterator it = form->m_pEditObjects.begin(); + float dist = UI->ZFar(); + xr_vector::iterator it = form->m_pEditObjects.begin(); xr_vector::iterator it_e = form->m_pEditObjects.end(); - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - CSceneObject* SO = *it; + CSceneObject *SO = *it; - if(SO->RayPick(dist,start,direction,pinf) ) + if (SO->RayPick(dist, start, direction, pinf)) { - R_ASSERT(pinf&&pinf->e_mesh && pinf->e_obj); + R_ASSERT(pinf&&pinf->e_mesh&&pinf->e_obj); form->m_Props->OnPick(*pinf); pinf->s_obj = SO; return SO; @@ -86,33 +90,36 @@ CSceneObject* __fastcall TfrmEditLibrary::RayPick(const Fvector& start, const Fv } return 0; } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::OnRender() { - if (!form) return; - if (!form->cbPreview->Checked) return; - xr_vector::iterator it = form->m_pEditObjects.begin(); + if (!form) + return; + if (!form->cbPreview->Checked) + return; + xr_vector::iterator it = form->m_pEditObjects.begin(); xr_vector::iterator it_e = form->m_pEditObjects.end(); - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - CSceneObject* SO = *it; + CSceneObject *SO = *it; - CSceneObject* S = SO; + CSceneObject *S = SO; - CEditableObject* O = SO->GetReference(); + CEditableObject *O = SO->GetReference(); if (O) { if (!S->PPosition.similar(O->t_vPosition)) - S->PPosition = O->t_vPosition; + S->PPosition = O->t_vPosition; if (!S->PRotation.similar(O->t_vRotate)) - S->PRotation = O->t_vRotate; + S->PRotation = O->t_vRotate; if (!S->PScale.similar(O->t_vScale)) - S->PScale = O->t_vScale; + S->PScale = O->t_vScale; - SO->OnFrame (); - SO->RenderSingle (); + SO->OnFrame(); + SO->RenderSingle(); } } } @@ -120,631 +127,682 @@ void __fastcall TfrmEditLibrary::OnRender() //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ZoomObject() { - if (!form) return; - if (!form->cbPreview->Checked) return; + if (!form) + return; + if (!form->cbPreview->Checked) + return; - xr_vector::iterator it = form->m_pEditObjects.begin(); + xr_vector::iterator it = form->m_pEditObjects.begin(); xr_vector::iterator it_e = form->m_pEditObjects.end(); Fbox bb_max; - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - CSceneObject* SO = *it; - Fbox bb; + CSceneObject *SO = *it; + Fbox bb; if (SO->GetBox(bb)) - bb_max.merge(bb); - } - EDevice.m_Camera.ZoomExtents(bb_max); + bb_max.merge(bb); + } + EDevice.m_Camera.ZoomExtents(bb_max); } //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::FormShow(TObject *Sender) { - UI->BeginEState(esEditLibrary); - modif_map.clear(); + UI->BeginEState(esEditLibrary); + modif_map.clear(); InitObjects(); ebSave->Enabled = false; // add directional light Flight L; - ZeroMemory(&L,sizeof(Flight)); + ZeroMemory(&L, sizeof(Flight)); L.type = D3DLIGHT_DIRECTIONAL; - L.diffuse.set(1,1,1,1); - L.direction.set(1,-1,1); L.direction.normalize(); - EDevice.SetLight(0,L); - EDevice.LightEnable(0,true); - L.diffuse.set(0.5,0.5,0.5,1); - L.direction.set(1,-1,-1); L.direction.normalize(); - EDevice.SetLight(1,L); - EDevice.LightEnable(1,true); + L.diffuse.set(1, 1, 1, 1); + L.direction.set(1, -1, 1); + L.direction.normalize(); + EDevice.SetLight(0, L); + EDevice.LightEnable(0, true); + L.diffuse.set(0.5, 0.5, 0.5, 1); + L.direction.set(1, -1, -1); + L.direction.normalize(); + EDevice.SetLight(1, L); + EDevice.LightEnable(1, true); - // check window position - UI->CheckWindowPos(this); + // check window position + UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::FormClose(TObject *Sender, TCloseAction &Action) { - Action = caFree; + Action = caFree; - if (!bFinalExit&&ebSave->Enabled){ - bFinalExit = false; + if (!bFinalExit&&ebSave->Enabled) + { + bFinalExit = false; UI->SetStatus("Objects reloading..."); - FS_FileSetIt it=modif_map.begin(); - FS_FileSetIt _E=modif_map.end(); - for (;it!=_E;it++) - Lib.ReloadObject(it->name.c_str()); + FS_FileSetIt it = modif_map.begin(); + FS_FileSetIt _E = modif_map.end(); + for (; it!=_E; it++) + Lib.ReloadObject(it->name.c_str()); UI->ResetStatus(); } - Scene->unlock(); + Scene->unlock(); UI->EndEState(esEditLibrary); // remove directional light - EDevice.LightEnable(0,false); - EDevice.LightEnable(1,false); + EDevice.LightEnable(0, false); + EDevice.LightEnable(1, false); - xr_vector::iterator it = form->m_pEditObjects.begin(); + xr_vector::iterator it = form->m_pEditObjects.begin(); xr_vector::iterator it_e = form->m_pEditObjects.end(); - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - CSceneObject* SO = *it; - xr_delete (SO); - } - form->m_pEditObjects.clear (); - xr_delete (m_Thm); - - + CSceneObject *SO = *it; + xr_delete(SO); + } + form->m_pEditObjects.clear(); + xr_delete(m_Thm); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::FormDestroy(TObject *Sender) { - TItemList::DestroyForm(m_Items); + TItemList::DestroyForm(m_Items); TfrmPropertiesEObject::DestroyProperties(m_Props); - form = 0; + form = 0; ExecCommand(COMMAND_CLEAR); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::FormCloseQuery(TObject *Sender, bool &CanClose) { CanClose = true; - if (ebSave->Enabled){ - int res = ELog.DlgMsg(mtConfirmation, "Library was change. Do you want save?"); - if (res==mrCancel) CanClose = false; - if (res==mrYes) ebSaveClick(0); + if (ebSave->Enabled) + { + int res = ELog.DlgMsg(mtConfirmation, "Library was change. Do you want save?"); + if (res==mrCancel) + CanClose = false; + if (res==mrYes) + ebSaveClick(0); } bExitResult = CanClose; } + //--------------------------------------------------------------------------- bool TfrmEditLibrary::FinalClose() { - if (!form) return true; + if (!form) + return true; bFinalExit = true; form->Close(); return bExitResult; } + //--------------------------------------------------------------------------- void TfrmEditLibrary::OnModified() { - if (!form) return; - form->ebSave->Enabled = true; + if (!form) + return; + form->ebSave->Enabled = true; - xr_vector::iterator it = form->m_pEditObjects.begin(); + xr_vector::iterator it = form->m_pEditObjects.begin(); xr_vector::iterator it_e = form->m_pEditObjects.end(); - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - CSceneObject* SO = *it; - CEditableObject* E = SO->GetReference(); + CSceneObject *SO = *it; + CEditableObject *E = SO->GetReference(); if (E) { modif_map.insert(FS_File(E->GetName())); E->Modified(); SO->UpdateTransform(); } - } + } UI->RedrawScene(); } + //--------------------------------------------------------------------------- -void __fastcall TfrmEditLibrary::OnItemsFocused(ListItemsVec& items) +void __fastcall TfrmEditLibrary::OnItemsFocused(ListItemsVec &items) { - xr_delete (m_Thm); -// bool mt = false; - bool b_one = (items.size()==1); + xr_delete(m_Thm); + // bool mt = false; + bool b_one = (items.size()==1); - if (b_one /*&& FHelper.IsObject(items[0])*/ && UI->ContainEState(esEditLibrary)) + if (b_one /*&& FHelper.IsObject(items[0])*/&&UI->ContainEState(esEditLibrary)) { // change thm - ListItem* prop = items[0]; - VERIFY (prop); - AnsiString nm = prop->Key(); - string_path thm_fn; + ListItem *prop = items[0]; + VERIFY(prop); + AnsiString nm = prop->Key(); + string_path thm_fn; ebRenameObject->Enabled = !bReadOnly; ebRemoveObject->Enabled = !bReadOnly; -// ebExportLWO->Enabled = !bReadOnly; + // ebExportLWO->Enabled = !bReadOnly; - FS.update_path (thm_fn,_objects_,ChangeFileExt(nm,".thm").c_str()); + FS.update_path(thm_fn,_objects_, ChangeFileExt(nm, ".thm").c_str()); if (FS.exist(thm_fn)) - m_Thm = xr_new(nm.c_str()); + m_Thm = xr_new(nm.c_str()); /* if (cbPreview->Checked || m_Props->Visible) { ChangeReference(nm.c_str()); - if (cbPreview->Checked) - mt = true; + if (cbPreview->Checked) + mt = true; } */ - }else + } + else { -// ChangeReference(0); + // ChangeReference(0); } - if (cbPreview->Checked || m_Props->Visible) - SelectionToReference (&items); - - if (m_Thm && m_Thm->Valid()) + if (cbPreview->Checked||m_Props->Visible) + SelectionToReference(&items); + + if (m_Thm&&m_Thm->Valid()) { - lbFaces->Caption = m_Thm->_FaceCount()?AnsiString(m_Thm->_FaceCount()):AnsiString("?"); - lbVertices->Caption = m_Thm->_VertexCount()?AnsiString(m_Thm->_VertexCount()):AnsiString("?"); - }else + lbFaces->Caption = m_Thm->_FaceCount() ? AnsiString(m_Thm->_FaceCount()) : AnsiString("?"); + lbVertices->Caption = m_Thm->_VertexCount() ? AnsiString(m_Thm->_VertexCount()) : AnsiString("?"); + } + else { - lbFaces->Caption = "?"; + lbFaces->Caption = "?"; lbVertices->Caption = "?"; } - - paImage->Repaint (); - UpdateObjectProperties (); - UI->RedrawScene (); - ebMakeThm->Enabled = m_pEditObjects.size()>0; - ebMakeLOD_high->Enabled = cbPreview->Checked; - ebMakeLOD_low->Enabled = cbPreview->Checked; + paImage->Repaint(); + UpdateObjectProperties(); + UI->RedrawScene(); + ebMakeThm->Enabled = m_pEditObjects.size()>0; + ebMakeLOD_high->Enabled = cbPreview->Checked; + ebMakeLOD_low->Enabled = cbPreview->Checked; } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::cbPreviewClick(TObject *Sender) { - RefreshSelected(); + RefreshSelected(); } + //--------------------------------------------------------------------------- void TfrmEditLibrary::InitObjects() { - ListItemsVec items; + ListItemsVec items; FS_FileSet lst; Lib.GetObjects(lst); - FS_FileSetIt it=lst.begin(); - FS_FileSetIt _E=lst.end(); - for(; it!=_E; it++) - LHelper().CreateItem(items,it->name.c_str(),0,0,0); - m_Items->AssignItems(items,false,true); + FS_FileSetIt it = lst.begin(); + FS_FileSetIt _E = lst.end(); + for (; it!=_E; it++) + LHelper().CreateItem(items, it->name.c_str(), 0, 0, 0); + m_Items->AssignItems(items, false, true); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) -{ - if (Shift.Contains(ssCtrl)){ - if (Key==VK_CANCEL) ExecCommand(COMMAND_BREAK_LAST_OPERATION); - }else{ - if (Key==VK_ESCAPE){ - if (bFormLocked) ExecCommand(COMMAND_BREAK_LAST_OPERATION); - else ebCancel->Click(); + TShiftState Shift) +{ + if (Shift.Contains(ssCtrl)) + { + if (Key==VK_CANCEL) + ExecCommand(COMMAND_BREAK_LAST_OPERATION); + } + else + { + if (Key==VK_ESCAPE) + { + if (bFormLocked) + ExecCommand(COMMAND_BREAK_LAST_OPERATION); + else + ebCancel->Click(); Key = 0; // :-) íóæíî äëÿ òîãî ÷òîáû AccessVoilation íå âûëàçèë ïî ESCAPE } } } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ebPropertiesClick(TObject *Sender) { - SelectionToReference (NULL); - UpdateObjectProperties (); - m_Props->ShowProperties (); + SelectionToReference(NULL); + UpdateObjectProperties(); + m_Props->ShowProperties(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ebSaveClick(TObject *Sender) { - RStringVec sel_strings; - ebSave->Enabled = false; - ChangeReference (sel_strings); - Lib.Save (&modif_map); - modif_map.clear (); - RefreshSelected (); + RStringVec sel_strings; + ebSave->Enabled = false; + ChangeReference(sel_strings); + Lib.Save(&modif_map); + modif_map.clear(); + RefreshSelected(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ebCancelClick(TObject *Sender) { Close(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::tvItemsDblClick(TObject *Sender) { - ebPropertiesClick(Sender); + ebPropertiesClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ebMakeThmClick(TObject *Sender) { - U32Vec pixels; + U32Vec pixels; - ListItemsVec sel_items; - m_Items->GetSelected (NULL, sel_items, false); - ListItemsIt it = sel_items.begin(); - ListItemsIt it_e = sel_items.end(); + ListItemsVec sel_items; + m_Items->GetSelected(NULL, sel_items, false); + ListItemsIt it = sel_items.begin(); + ListItemsIt it_e = sel_items.end(); - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - ListItem* item = *it; - CEditableObject* obj = Lib.CreateEditObject(item->Key()); - if(obj && cbPreview->Checked) + ListItem *item = *it; + CEditableObject *obj = Lib.CreateEditObject(item->Key()); + if (obj&&cbPreview->Checked) { - string_path fn; - FS.update_path (fn,_objects_,ChangeFileExt(obj->GetName(),".thm").c_str()); + string_path fn; + FS.update_path(fn,_objects_, ChangeFileExt(obj->GetName(), ".thm").c_str()); - m_Items->SelectItem (item->Key(),true,false,true); - if (ImageLib.CreateOBJThumbnail (fn,obj,obj->Version())) + m_Items->SelectItem(item->Key(), true, false, true); + if (ImageLib.CreateOBJThumbnail(fn, obj, obj->Version())) { - ELog.Msg (mtInformation,"Thumbnail successfully created."); -// AnsiString full_name; -// FHelper.MakeFullName (node,0,full_name); -// m_Items->SelectItem (item->Key(),true,false,true); + ELog.Msg(mtInformation, "Thumbnail successfully created."); + // AnsiString full_name; + // FHelper.MakeFullName (node,0,full_name); + // m_Items->SelectItem (item->Key(),true,false,true); } - }else{ - ELog.DlgMsg(mtError,"Can't create thumbnail. Set preview mode."); } - Lib.RemoveEditObject(obj); - } + else + { + ELog.DlgMsg(mtError, "Can't create thumbnail. Set preview mode."); + } + Lib.RemoveEditObject(obj); + } -/* - TElTreeItem* node = m_Items->GetSelected(); - if (node&&FHelper.IsObject(node)) - { - AnsiString name; - FHelper.MakeName (node,0,name,false); - CEditableObject* obj = Lib.CreateEditObject(name.c_str()); - if (obj&&cbPreview->Checked) + /* + TElTreeItem* node = m_Items->GetSelected(); + if (node&&FHelper.IsObject(node)) { - string_path fn; - FS.update_path (fn,_objects_,ChangeFileExt(obj->GetName(),".thm").c_str()); - - if (ImageLib.CreateOBJThumbnail (fn,obj,obj->Version())){ - ELog.Msg (mtInformation,"Thumbnail successfully created."); - AnsiString full_name; - FHelper.MakeFullName (node,0,full_name); - m_Items->SelectItem (full_name.c_str(),true,false,true); + AnsiString name; + FHelper.MakeName (node,0,name,false); + CEditableObject* obj = Lib.CreateEditObject(name.c_str()); + if (obj&&cbPreview->Checked) + { + string_path fn; + FS.update_path (fn,_objects_,ChangeFileExt(obj->GetName(),".thm").c_str()); + + if (ImageLib.CreateOBJThumbnail(fn,obj,obj->Version())){ + ELog.Msg (mtInformation,"Thumbnail successfully created."); + AnsiString full_name; + FHelper.MakeFullName (node,0,full_name); + m_Items->SelectItem (full_name.c_str(),true,false,true); + } + }else{ + ELog.DlgMsg(mtError,"Can't create thumbnail. Set preview mode."); } - }else{ - ELog.DlgMsg(mtError,"Can't create thumbnail. Set preview mode."); + Lib.RemoveEditObject(obj); } - Lib.RemoveEditObject(obj); - } -*/ - ELog.DlgMsg(mtInformation,"Done."); + */ + ELog.DlgMsg(mtInformation, "Done."); } + //--------------------------------------------------------------------------- -bool TfrmEditLibrary::GenerateLOD(ListItemsVec& props, bool bHighQuality) +bool TfrmEditLibrary::GenerateLOD(ListItemsVec &props, bool bHighQuality) { - ListItemsIt it = props.begin(); - ListItemsIt it_e = props.end(); + ListItemsIt it = props.begin(); + ListItemsIt it_e = props.end(); - SPBItem* pb = UI->ProgressStart(props.size(),"Making LOD"); - for( ;it!=it_e; ++it) + SPBItem *pb = UI->ProgressStart(props.size(), "Making LOD"); + for (; it!=it_e; ++it) { - ListItem* item = *it; - m_Items->SelectItem (item->Key(),true,false,true); - R_ASSERT (form->m_pEditObjects.size()==1); + ListItem *item = *it; + m_Items->SelectItem(item->Key(), true, false, true); + R_ASSERT(form->m_pEditObjects.size()==1); - CSceneObject* SO = form->m_pEditObjects[0]; - CEditableObject* O = SO->GetReference(); + CSceneObject *SO = form->m_pEditObjects[0]; + CEditableObject *O = SO->GetReference(); - if (O && O->IsMUStatic()) + if (O&&O->IsMUStatic()) { - pb->Inc (O->GetName()); - BOOL bLod = O->m_objectFlags.is(CEditableObject::eoUsingLOD); - O->m_objectFlags.set (CEditableObject::eoUsingLOD,FALSE); - xr_string tex_name; - tex_name = EFS.ChangeFileExt(O->GetName(),""); - - string_path tmp; - strcpy (tmp,tex_name.c_str()); _ChangeSymbol(tmp,'\\','_'); - tex_name = xr_string("lod_")+tmp; - tex_name = ImageLib.UpdateFileName(tex_name); - ImageLib.CreateLODTexture(O, tex_name.c_str(),LOD_IMAGE_SIZE,LOD_IMAGE_SIZE,LOD_SAMPLE_COUNT,O->Version(),bHighQuality?4/*7*/:1); - O->OnDeviceDestroy (); - O->m_objectFlags.set (CEditableObject::eoUsingLOD,bLod); - ELog.Msg (mtInformation,"LOD for object '%s' successfully created.",O->GetName()); - }else{ - ELog.Msg (mtError,"Can't create LOD texture from non 'Multiple Usage' object.", SO->Name); + pb->Inc(O->GetName()); + BOOL bLod = O->m_objectFlags.is(CEditableObject::eoUsingLOD); + O->m_objectFlags.set(CEditableObject::eoUsingLOD, FALSE); + xr_string tex_name; + tex_name = EFS.ChangeFileExt(O->GetName(), ""); + + string_path tmp; + strcpy(tmp, tex_name.c_str()); + _ChangeSymbol(tmp, '\\', '_'); + tex_name = xr_string("lod_")+tmp; + tex_name = ImageLib.UpdateFileName(tex_name); + ImageLib.CreateLODTexture(O, tex_name.c_str(), LOD_IMAGE_SIZE, LOD_IMAGE_SIZE, LOD_SAMPLE_COUNT, O->Version(), bHighQuality ? 4/*7*/ : 1); + O->OnDeviceDestroy(); + O->m_objectFlags.set(CEditableObject::eoUsingLOD, bLod); + ELog.Msg(mtInformation, "LOD for object '%s' successfully created.", O->GetName()); + } + else + { + ELog.Msg(mtError, "Can't create LOD texture from non 'Multiple Usage' object.", SO->Name); } - if (UI->NeedAbort()) break; + if (UI->NeedAbort()) + break; } - UI->ProgressEnd (pb); - -/* - SelectionToReference (&props); - - xr_vector::iterator it = form->m_pEditObjects.begin(); - xr_vector::iterator it_e = form->m_pEditObjects.end(); - SPBItem* pb = UI->ProgressStart(form->m_pEditObjects.size(),"Making LOD"); - for( ;it!=it_e; ++it) - { - CSceneObject* SO = *it; - CEditableObject* O = SO->GetReference(); + UI->ProgressEnd(pb); - if (O && O->IsMUStatic()) + /* + SelectionToReference (&props); + + xr_vector::iterator it = form->m_pEditObjects.begin(); + xr_vector::iterator it_e = form->m_pEditObjects.end(); + SPBItem* pb = UI->ProgressStart(form->m_pEditObjects.size(),"Making LOD"); + for( ;it!=it_e; ++it) { - pb->Inc (O->GetName()); - BOOL bLod = O->m_objectFlags.is(CEditableObject::eoUsingLOD); - O->m_objectFlags.set (CEditableObject::eoUsingLOD,FALSE); - xr_string tex_name; - tex_name = EFS.ChangeFileExt(O->GetName(),""); - - string_path tmp; - strcpy (tmp,tex_name.c_str()); _ChangeSymbol(tmp,'\\','_'); - tex_name = xr_string("lod_")+tmp; - tex_name = ImageLib.UpdateFileName(tex_name); - ImageLib.CreateLODTexture(O, tex_name.c_str(),LOD_IMAGE_SIZE,LOD_IMAGE_SIZE,LOD_SAMPLE_COUNT,O->Version(),bHighQuality?7:1); - O->OnDeviceDestroy (); - O->m_objectFlags.set (CEditableObject::eoUsingLOD,bLod); - ELog.Msg (mtInformation,"LOD for object '%s' successfully created.",O->GetName()); - }else{ - ELog.Msg (mtError,"Can't create LOD texture from non 'Multiple Usage' object.", SO->Name); + CSceneObject* SO = *it; + CEditableObject* O = SO->GetReference(); + + if (O && O->IsMUStatic()) + { + pb->Inc (O->GetName()); + BOOL bLod = O->m_objectFlags.is(CEditableObject::eoUsingLOD); + O->m_objectFlags.set(CEditableObject::eoUsingLOD,FALSE); + xr_string tex_name; + tex_name = EFS.ChangeFileExt(O->GetName(),""); + + string_path tmp; + strcpy (tmp,tex_name.c_str()); _ChangeSymbol(tmp,'\\','_'); + tex_name = xr_string("lod_")+tmp; + tex_name = ImageLib.UpdateFileName(tex_name); + ImageLib.CreateLODTexture(O, tex_name.c_str(),LOD_IMAGE_SIZE,LOD_IMAGE_SIZE,LOD_SAMPLE_COUNT,O->Version(),bHighQuality?7:1); + O->OnDeviceDestroy (); + O->m_objectFlags.set(CEditableObject::eoUsingLOD,bLod); + ELog.Msg (mtInformation,"LOD for object '%s' successfully created.",O->GetName()); + }else{ + ELog.Msg (mtError,"Can't create LOD texture from non 'Multiple Usage' object.", SO->Name); + } + if (UI->NeedAbort()) break; } - if (UI->NeedAbort()) break; - } - UI->ProgressEnd (pb); -*/ + UI->ProgressEnd(pb); + */ return true; } + //--------------------------------------------------------------------------- void TfrmEditLibrary::MakeLOD(bool bHighQuality) { - if (ebSave->Enabled){ - ELog.DlgMsg (mtError,"Save library changes before generating LOD."); + if (ebSave->Enabled) + { + ELog.DlgMsg(mtError, "Save library changes before generating LOD."); return; } - ListItemsVec sel_items; - m_Items->GetSelected (NULL, sel_items, false /*true*/); - GenerateLOD (sel_items,bHighQuality); - ELog.DlgMsg(mtInformation,"Done."); - -/* - TElTreeItem* node = m_Items->GetSelected(); - if (node && cbPreview->Checked) - { - LockForm(); - int res = ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo << mbCancel,"Do you want to select multiple objects?"); - if (res!=mrCancel) + ListItemsVec sel_items; + m_Items->GetSelected(NULL, sel_items, false /*true*/); + GenerateLOD(sel_items, bHighQuality); + ELog.DlgMsg(mtInformation, "Done."); + + /* + TElTreeItem* node = m_Items->GetSelected(); + if (node && cbPreview->Checked) { - if (res==mrYes) + LockForm(); + int res = ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo << mbCancel,"Do you want to select multiple objects?"); + if (res!=mrCancel) { - LPCSTR new_val = 0; - if (TfrmChoseItem::SelectItem(smObject,new_val,256)) + if (res==mrYes) { - int cnt = _GetItemCount(new_val); - int iLODcnt = 0; - SPBItem* pb = UI->ProgressStart(cnt,"Making LOD"); - - for (int k=0; kInc (tmp.c_str()); - ListItem* I = m_Items->FindItem(tmp.c_str()); - VERIFY (I); - ListItemsVec V; - V.push_back (I); - if (GenerateLOD (V,bHighQuality)) - iLODcnt++; - - if (UI->NeedAbort()) break; + int cnt = _GetItemCount(new_val); + int iLODcnt = 0; + SPBItem* pb = UI->ProgressStart(cnt,"Making LOD"); + + for (int k=0; kInc (tmp.c_str()); + ListItem* I = m_Items->FindItem(tmp.c_str()); + VERIFY (I); + ListItemsVec V; + V.push_back (I); + if (GenerateLOD(V,bHighQuality)) + iLODcnt++; + + if (UI->NeedAbort()) break; + } + ELog.DlgMsg (mtInformation,"'%d' LOD's succesfully created.",iLODcnt); + UI->ProgressEnd(pb); } - ELog.DlgMsg (mtInformation,"'%d' LOD's succesfully created.",iLODcnt); - UI->ProgressEnd (pb); - } - }else{ - AnsiString m_LastSelection; - FHelper.MakeFullName(node,0,m_LastSelection); - if (FHelper.IsObject(node)) - { - ListItem* prop = (ListItem*)node->Tag; VERIFY(prop); - ListItemsVec V2; - V2.push_back (prop); - GenerateLOD (V2,bHighQuality); - - } if(FHelper.IsFolder(node)) - { - if (mrYes==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Are you sure to generate LOD for all object in this folder?")) + }else{ + AnsiString m_LastSelection; + FHelper.MakeFullName(node,0,m_LastSelection); + if (FHelper.IsObject(node)) + { + ListItem* prop = (ListItem*)node->Tag; VERIFY(prop); + ListItemsVec V2; + V2.push_back (prop); + GenerateLOD (V2,bHighQuality); + + } if(FHelper.IsFolder(node)) { - int iLODcnt = 0; - SPBItem* pb = UI->ProgressStart(node->ChildrenCount,"Making LOD"); - for (TElTreeItem* item=node->GetFirstChild(); item; item=node->GetNextChild(item)) + if (mrYes==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Are you sure to generate LOD for all object in this folder?")) { - ListItem* prop = (ListItem*)node->Tag; VERIFY(prop); - pb->Inc (prop->Key()); - ListItemsVec V3; - V3.push_back (prop); - if (GenerateLOD(V3,bHighQuality)) - iLODcnt++; - - if (UI->NeedAbort()) break; + int iLODcnt = 0; + SPBItem* pb = UI->ProgressStart(node->ChildrenCount,"Making LOD"); + for (TElTreeItem* item=node->GetFirstChild(); item; item=node->GetNextChild(item)) + { + ListItem* prop = (ListItem*)node->Tag; VERIFY(prop); + pb->Inc (prop->Key()); + ListItemsVec V3; + V3.push_back (prop); + if (GenerateLOD(V3,bHighQuality)) + iLODcnt++; + + if (UI->NeedAbort()) break; + } + UI->ProgressEnd (pb); + ELog.DlgMsg (mtInformation,"'%d' LOD's succesfully created.",iLODcnt); } - UI->ProgressEnd (pb); - ELog.DlgMsg (mtInformation,"'%d' LOD's succesfully created.",iLODcnt); } } } + UnlockForm(); + // m_Items->SelectItem(m_LastSelection.c_str(),true,false,true); } - UnlockForm(); -// m_Items->SelectItem (m_LastSelection.c_str(),true,false,true); - } -*/ + */ } void __fastcall TfrmEditLibrary::ebMakeLOD_highClick(TObject *Sender) { - MakeLOD(true); + MakeLOD(true); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ebMakeLOD_lowClick(TObject *Sender) { - MakeLOD(false); + MakeLOD(false); } + //--------------------------------------------------------------------------- -void TfrmEditLibrary::ChangeReference(const RStringVec& items) +void TfrmEditLibrary::ChangeReference(const RStringVec &items) { - xr_vector::iterator it = m_pEditObjects.begin(); + xr_vector::iterator it = m_pEditObjects.begin(); xr_vector::iterator it_e = m_pEditObjects.end(); - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - CSceneObject* SO = *it; - xr_delete (SO); + CSceneObject *SO = *it; + xr_delete(SO); } - m_pEditObjects.clear (); + m_pEditObjects.clear(); - RStringVec::const_iterator sit = items.begin(); - RStringVec::const_iterator sit_e = items.end(); - for(;sit!=sit_e; ++sit) + RStringVec::const_iterator sit = items.begin(); + RStringVec::const_iterator sit_e = items.end(); + for (; sit!=sit_e; ++sit) { - CSceneObject* SO = xr_new((LPVOID)0,(LPSTR)0); - m_pEditObjects.push_back (SO); - SO->SetReference ((*sit).c_str()); - - CEditableObject* NE = SO->GetReference(); - if (NE) - { - SO->PPosition = NE->t_vPosition; - SO->PScale = NE->t_vScale; - SO->PRotation = NE->t_vRotate; - } - // update transformation - SO->UpdateTransform (); + CSceneObject *SO = xr_new((LPVOID)0, (LPSTR)0); + m_pEditObjects.push_back(SO); + SO->SetReference((*sit).c_str()); -/* - // save new position - CEditableObject* E = m_pEditObject->GetReference(); - - if (E && new_name && (stricmp(E->GetName(),new_name))==0 ) return; + CEditableObject *NE = SO->GetReference(); + if (NE) + { + SO->PPosition = NE->t_vPosition; + SO->PScale = NE->t_vScale; + SO->PRotation = NE->t_vRotate; + } + // update transformation + SO->UpdateTransform(); - if (E) - { - E->t_vPosition.set (m_pEditObject->PPosition); - E->t_vScale.set (m_pEditObject->PScale); - E->t_vRotate.set (m_pEditObject->PRotation); - } - m_pEditObject->SetReference (new_name); - // get old position - E = m_pEditObject->GetReference(); - if (E) - { - m_pEditObject->PPosition = E->t_vPosition; - m_pEditObject->PScale = E->t_vScale; - m_pEditObject->PRotation = E->t_vRotate; - } - // update transformation - m_pEditObject->UpdateTransform (); -*/ + /* + // save new position + CEditableObject* E = m_pEditObject->GetReference(); + + if (E && new_name && (stricmp(E->GetName(),new_name))==0 ) return; + + if (E) + { + E->t_vPosition.set (m_pEditObject->PPosition); + E->t_vScale.set (m_pEditObject->PScale); + E->t_vRotate.set (m_pEditObject->PRotation); + } + m_pEditObject->SetReference (new_name); + // get old position + E = m_pEditObject->GetReference(); + if (E) + { + m_pEditObject->PPosition = E->t_vPosition; + m_pEditObject->PScale = E->t_vScale; + m_pEditObject->PRotation = E->t_vRotate; + } + // update transformation + m_pEditObject->UpdateTransform(); + */ } - ExecCommand (COMMAND_EVICT_OBJECTS); - ExecCommand (COMMAND_EVICT_TEXTURES); + ExecCommand(COMMAND_EVICT_OBJECTS); + ExecCommand(COMMAND_EVICT_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ResetSelected() { - if (form) + if (form) { - xr_vector::iterator it = form->m_pEditObjects.begin(); + xr_vector::iterator it = form->m_pEditObjects.begin(); xr_vector::iterator it_e = form->m_pEditObjects.end(); - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - CSceneObject* SO = *it; - SO->SetReference (0); + CSceneObject *SO = *it; + SO->SetReference(0); } } } + //--------------------------------------------------------------------------- -bool TfrmEditLibrary::SelectionToReference(ListItemsVec* props) +bool TfrmEditLibrary::SelectionToReference(ListItemsVec *props) { - RStringVec sel_strings; - ListItemsVec sel_items; + RStringVec sel_strings; + ListItemsVec sel_items; - if(props==NULL) - m_Items->GetSelected (NULL, sel_items, false /*true*/); + if (props==NULL) + m_Items->GetSelected(NULL, sel_items, false /*true*/); else - sel_items = *props; + sel_items = *props; - ListItemsIt it = sel_items.begin(); - ListItemsIt it_e = sel_items.end(); + ListItemsIt it = sel_items.begin(); + ListItemsIt it_e = sel_items.end(); - for( ;it!=it_e; ++it) + for (; it!=it_e; ++it) { - ListItem* item = *it; - sel_strings.push_back (item->Key()); + ListItem *item = *it; + sel_strings.push_back(item->Key()); } - ChangeReference (sel_strings); - return sel_strings.size() > 0; + ChangeReference(sel_strings); + return sel_strings.size()>0; } void __fastcall TfrmEditLibrary::RefreshSelected() { - if (form) + if (form) { - bool mt = false; - if(cbPreview->Checked) - mt = SelectionToReference (NULL); - - ebMakeThm->Enabled = !bReadOnly && mt; - ebMakeLOD_high->Enabled = !bReadOnly && cbPreview->Checked; - ebMakeLOD_low->Enabled = !bReadOnly && cbPreview->Checked; - UI->RedrawScene (); + bool mt = false; + if (cbPreview->Checked) + mt = SelectionToReference(NULL); + + ebMakeThm->Enabled = !bReadOnly&&mt; + ebMakeLOD_high->Enabled = !bReadOnly&&cbPreview->Checked; + ebMakeLOD_low->Enabled = !bReadOnly&&cbPreview->Checked; + UI->RedrawScene(); } } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::paImagePaint(TObject *Sender) { - if (m_Thm) m_Thm->Draw(paImage); + if (m_Thm) + m_Thm->Draw(paImage); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ebExportLWOClick(TObject *Sender) { - TElTreeItem* node = m_Items->GetSelected(); + TElTreeItem *node = m_Items->GetSelected(); if (node&&FHelper.IsObject(node)) { - AnsiString name; - FHelper.MakeName (node,0,name,false); - xr_string save_nm; + AnsiString name; + FHelper.MakeName(node, 0, name, false); + xr_string save_nm; - if (EFS.GetSaveName(_import_,save_nm,0,1)) + if (EFS.GetSaveName(_import_, save_nm, 0, 1)) { - CEditableObject* obj = Lib.CreateEditObject(name.c_str()); + CEditableObject *obj = Lib.CreateEditObject(name.c_str()); if (obj) { if (!obj->ExportLWO(save_nm.c_str())) { ELog.DlgMsg(mtInformation, "Can't export object '%s'.", obj->GetName()); - }else{ - ELog.DlgMsg(mtInformation, "Export complete."); } - }else + else + { + ELog.DlgMsg(mtInformation, "Export complete."); + } + } + else { - ELog.DlgMsg (mtError,"Can't load object."); - } - Lib.RemoveEditObject (obj); - } - }else{ - ELog.DlgMsg (mtInformation, "Select object to export."); + ELog.DlgMsg(mtError, "Can't load object."); + } + Lib.RemoveEditObject(obj); + } + } + else + { + ELog.DlgMsg(mtInformation, "Select object to export."); } } @@ -752,173 +810,187 @@ void __fastcall TfrmEditLibrary::ebExportLWOClick(TObject *Sender) void __fastcall TfrmEditLibrary::ebImportClick(TObject *Sender) { xr_string open_nm, save_nm, nm; - if (EFS.GetOpenName(_import_,open_nm,true)) + if (EFS.GetOpenName(_import_, open_nm, true)) { - // remove selected object - ResetSelected (); - // load - AStringVec lst; - _SequenceToList (lst,open_nm.c_str()); - bool bNeedUpdate = false; + // remove selected object + ResetSelected(); + // load + AStringVec lst; + _SequenceToList(lst, open_nm.c_str()); + bool bNeedUpdate = false; // folder name - AnsiString folder; + AnsiString folder; - ListItemsVec sel_items; - m_Items->GetSelected (NULL, sel_items, false); - if(sel_items.size()) - FHelper.GetFolderName (sel_items[0]->Key(), folder); + ListItemsVec sel_items; + m_Items->GetSelected(NULL, sel_items, false); + if (sel_items.size()) + FHelper.GetFolderName(sel_items[0]->Key(), folder); - xr_string m_LastSelection; - for (AStringIt it=lst.begin(); it!=lst.end(); ++it) + xr_string m_LastSelection; + for (AStringIt it = lst.begin(); it!=lst.end(); ++it) { - nm = ChangeFileExt(ExtractFileName(*it),"").c_str(); - CEditableObject* O = xr_new(nm.c_str()); + nm = ChangeFileExt(ExtractFileName(*it), "").c_str(); + CEditableObject *O = xr_new(nm.c_str()); if (O->Load(it->c_str())) { - save_nm = xr_string(FS.get_path(_objects_)->m_Path)+folder.c_str()+EFS.ChangeFileExt(nm,".object"); + save_nm = xr_string(FS.get_path(_objects_)->m_Path)+folder.c_str()+EFS.ChangeFileExt(nm, ".object"); if (FS.exist(save_nm.c_str())) - if (mrNo==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Object '%s' already exist. Owerwrite it?",nm.c_str())) + if (mrNo==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<Save (save_nm.c_str()); - EFS.MarkFile (it->c_str(),true); - bNeedUpdate = true; - }else - ELog.DlgMsg (mtError,"Can't load file '%s'.",it->c_str()); + + O->Save(save_nm.c_str()); + EFS.MarkFile(it->c_str(), true); + bNeedUpdate = true; + } + else + ELog.DlgMsg(mtError, "Can't load file '%s'.", it->c_str()); xr_delete(O); LPCSTR p = FS.get_path(_objects_)->m_Path; if (folder.Pos(p)>0) { - m_LastSelection = xr_string(folder.c_str()+strlen(p))+nm; - xr_strlwr (m_LastSelection); - }else{ - m_LastSelection = xr_string(folder.c_str())+nm; + m_LastSelection = xr_string(folder.c_str()+strlen(p))+nm; + xr_strlwr(m_LastSelection); + } + else + { + m_LastSelection = xr_string(folder.c_str())+nm; } } if (bNeedUpdate) { - Lib.CleanLibrary (); - InitObjects (); - m_Items->SelectItem (m_LastSelection.c_str(),true,false,true); + Lib.CleanLibrary(); + InitObjects(); + m_Items->SelectItem(m_LastSelection.c_str(), true, false, true); } } } + //--------------------------------------------------------------------------- void TfrmEditLibrary::UpdateObjectProperties() { - m_Props->UpdateProperties(m_pEditObjects,bReadOnly); + m_Props->UpdateProperties(m_pEditObjects, bReadOnly); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::FormActivate(TObject *Sender) { - m_Items->SetILFocus(); + m_Items->SetILFocus(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::OnObjectRename(LPCSTR p0, LPCSTR p1, EItemType type) { - Lib.RenameObject(p0,p1,type); + Lib.RenameObject(p0, p1, type); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::fsStorageRestorePlacement(TObject *Sender) { - m_Items->LoadSelection(fsStorage); + m_Items->LoadSelection(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::fsStorageSavePlacement(TObject *Sender) { - m_Items->SaveSelection(fsStorage); + m_Items->SaveSelection(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ebRenameObjectClick(TObject *Sender) { - m_Items->RenameSelItem(); + m_Items->RenameSelItem(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLibrary::ebRemoveObjectClick(TObject *Sender) { - m_Items->RemoveSelItems(); + m_Items->RemoveSelItems(); } + //--------------------------------------------------------------------------- -#include "../ECore/Editor/ExportObjectOGF.h" +#include "editors/ECore/Editor/ExportObjectOGF.h" void __fastcall TfrmEditLibrary::ebExportOBJClick(TObject *Sender) { - if(!cbPreview->Checked) + if (!cbPreview->Checked) { - ListItemsVec sel_items; - m_Items->GetSelected (NULL, sel_items, false); - ListItemsIt it = sel_items.begin(); - ListItemsIt it_e = sel_items.end(); - - SPBItem* pb = UI->ProgressStart(form->m_pEditObjects.size(),"Expotring to OBJ"); - CSceneObject* SO = xr_new((LPVOID)0,(LPSTR)0); - for( ;it!=it_e; ++it) + ListItemsVec sel_items; + m_Items->GetSelected(NULL, sel_items, false); + ListItemsIt it = sel_items.begin(); + ListItemsIt it_e = sel_items.end(); + + SPBItem *pb = UI->ProgressStart(form->m_pEditObjects.size(), "Expotring to OBJ"); + CSceneObject *SO = xr_new((LPVOID)0, (LPSTR)0); + for (; it!=it_e; ++it) { - ListItem* item = *it; - pb->Inc (item->Key()); - SO->SetReference (item->Key()); - CEditableObject* NE = SO->GetReference(); - SO->UpdateTransform (); + ListItem *item = *it; + pb->Inc(item->Key()); + SO->SetReference(item->Key()); + CEditableObject *NE = SO->GetReference(); + SO->UpdateTransform(); if (NE) { - SO->PPosition = NE->t_vPosition; - SO->PScale = NE->t_vScale; - SO->PRotation = NE->t_vRotate; + SO->PPosition = NE->t_vPosition; + SO->PScale = NE->t_vScale; + SO->PRotation = NE->t_vRotate; - ExportOneOBJ (NE); + ExportOneOBJ(NE); } - if (UI->NeedAbort()) break; + if (UI->NeedAbort()) + break; } - xr_delete (SO); - UI->ProgressEnd (pb); - }else + xr_delete(SO); + UI->ProgressEnd(pb); + } + else { - xr_vector::iterator it = form->m_pEditObjects.begin(); + xr_vector::iterator it = form->m_pEditObjects.begin(); xr_vector::iterator it_e = form->m_pEditObjects.end(); - SPBItem* pb = UI->ProgressStart(form->m_pEditObjects.size(),"Expotring to OBJ"); - for( ;it!=it_e; ++it) + SPBItem *pb = UI->ProgressStart(form->m_pEditObjects.size(), "Expotring to OBJ"); + for (; it!=it_e; ++it) { - CSceneObject* SO = *it; - CEditableObject* O = SO->GetReference(); - pb->Inc (O->GetName()); + CSceneObject *SO = *it; + CEditableObject *O = SO->GetReference(); + pb->Inc(O->GetName()); - if(O) + if (O) { - ExportOneOBJ (O); + ExportOneOBJ(O); } - if (UI->NeedAbort()) break; + if (UI->NeedAbort()) + break; } - UI->ProgressEnd (pb); + UI->ProgressEnd(pb); } - ELog.DlgMsg(mtInformation,"Done."); + ELog.DlgMsg(mtInformation, "Done."); } -void TfrmEditLibrary::ExportOneOBJ(CEditableObject* EO) +void TfrmEditLibrary::ExportOneOBJ(CEditableObject *EO) { - string_path fn; - FS.update_path (fn, _import_, EO->m_LibName.c_str()); - CExportObjectOGF E(EO); - CMemoryWriter F; - if (E.ExportAsWavefrontOBJ(F,fn)) + string_path fn; + FS.update_path(fn, _import_, EO->m_LibName.c_str()); + CExportObjectOGF E(EO); + CMemoryWriter F; + if (E.ExportAsWavefrontOBJ(F, fn)) { - strcat (fn,".obj"); - F.save_to (fn); + strcat(fn, ".obj"); + F.save_to(fn); } } diff --git a/src/editors/LevelEditor/EditLibrary.h b/src/editors/LevelEditor/EditLibrary.h index 8c4584e7b1a..0efe6f60f17 100644 --- a/src/editors/LevelEditor/EditLibrary.h +++ b/src/editors/LevelEditor/EditLibrary.h @@ -12,7 +12,7 @@ #include #include -#include "../ECore/Editor/Library.h" +#include "editors/ECore/Editor/Library.h" #include #include "ElTree.hpp" #include "ElXPThemedControl.hpp" @@ -27,91 +27,107 @@ // refs class TObjectPreview; class EObjectThumbnail; + //--------------------------------------------------------------------------- class TfrmEditLibrary : public TForm { -__published: // IDE-managed Components - TPanel *paCommands; - TExtBtn *ebMakeThm; - TFormStorage *fsStorage; - TExtBtn *ebProperties; - TCheckBox *cbPreview; - TExtBtn *ebMakeLOD_high; - TPanel *Panel3; - TLabel *lbFaces; - TLabel *RxLabel2; - TLabel *RxLabel3; - TLabel *lbVertices; - TBevel *Bevel4; - TPanel *paItems; - TPanel *paControl; - TExtBtn *ebImport; - TExtBtn *ebExportLWO; - TExtBtn *ebSave; - TExtBtn *ebCancel; - TExtBtn *ebRenameObject; - TExtBtn *ebRemoveObject; - TMxPanel *paImage; - TExtBtn *ebMakeLOD_low; - TExtBtn *ebExportOBJ; + __published: // IDE-managed Components + TPanel*paCommands; + TExtBtn *ebMakeThm; + TFormStorage *fsStorage; + TExtBtn *ebProperties; + TCheckBox *cbPreview; + TExtBtn *ebMakeLOD_high; + TPanel *Panel3; + TLabel *lbFaces; + TLabel *RxLabel2; + TLabel *RxLabel3; + TLabel *lbVertices; + TBevel *Bevel4; + TPanel *paItems; + TPanel *paControl; + TExtBtn *ebImport; + TExtBtn *ebExportLWO; + TExtBtn *ebSave; + TExtBtn *ebCancel; + TExtBtn *ebRenameObject; + TExtBtn *ebRemoveObject; + TMxPanel *paImage; + TExtBtn *ebMakeLOD_low; + TExtBtn *ebExportOBJ; void __fastcall ebSaveClick(TObject *Sender); void __fastcall ebCancelClick(TObject *Sender); void __fastcall FormShow(TObject *Sender); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall ebPropertiesClick(TObject *Sender); void __fastcall tvItemsDblClick(TObject *Sender); void __fastcall cbPreviewClick(TObject *Sender); - void __fastcall ebMakeThmClick(TObject *Sender); - void __fastcall paImagePaint(TObject *Sender); - void __fastcall ebImportClick(TObject *Sender); - void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); - void __fastcall ebMakeLOD_highClick(TObject *Sender); - void __fastcall FormActivate(TObject *Sender); - void __fastcall ebExportLWOClick(TObject *Sender); - void __fastcall FormDestroy(TObject *Sender); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); - void __fastcall ebRenameObjectClick(TObject *Sender); - void __fastcall ebRemoveObjectClick(TObject *Sender); - void __fastcall ebMakeLOD_lowClick(TObject *Sender); - void __fastcall ebExportOBJClick(TObject *Sender); -private: // User declarations + void __fastcall ebMakeThmClick(TObject *Sender); + void __fastcall paImagePaint(TObject *Sender); + void __fastcall ebImportClick(TObject *Sender); + void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); + void __fastcall ebMakeLOD_highClick(TObject *Sender); + void __fastcall FormActivate(TObject *Sender); + void __fastcall ebExportLWOClick(TObject *Sender); + void __fastcall FormDestroy(TObject *Sender); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); + void __fastcall ebRenameObjectClick(TObject *Sender); + void __fastcall ebRemoveObjectClick(TObject *Sender); + void __fastcall ebMakeLOD_lowClick(TObject *Sender); + void __fastcall ebExportOBJClick(TObject *Sender); +private: // User declarations void InitObjects(); - EObjectThumbnail* m_Thm; - static TfrmEditLibrary* form; + EObjectThumbnail *m_Thm; + static TfrmEditLibrary *form; xr_vector m_pEditObjects; - static FS_FileSet modif_map; - static bool bFinalExit; - static bool bExitResult; - TfrmPropertiesEObject* m_Props; - void UpdateObjectProperties (); - void ChangeReference (const RStringVec& items); + static FS_FileSet modif_map; + static bool bFinalExit; + static bool bExitResult; + TfrmPropertiesEObject *m_Props; + void UpdateObjectProperties(); + void ChangeReference(const RStringVec &items); + + void __fastcall OnObjectRename(LPCSTR p0, LPCSTR p1, EItemType type); + + bool bReadOnly; + TItemList *m_Items; + void __stdcall OnItemsFocused(ListItemsVec &items); + bool GenerateLOD(ListItemsVec &props, bool bHighQuality); + void MakeLOD(bool bHighQuality); + bool bFormLocked; - void __fastcall OnObjectRename (LPCSTR p0, LPCSTR p1, EItemType type); + void LockForm() + { + bFormLocked = true; + paCommands->Enabled = false; + paItems->Enabled = false; + } - bool bReadOnly; - TItemList* m_Items; - void __stdcall OnItemsFocused (ListItemsVec& items); - bool GenerateLOD (ListItemsVec& props, bool bHighQuality); - void MakeLOD (bool bHighQuality); - bool bFormLocked; - void LockForm () { bFormLocked = true; paCommands->Enabled = false; paItems->Enabled = false; } - void UnlockForm () { bFormLocked = false; paCommands->Enabled = true; paItems->Enabled = true; } - void __fastcall ResetSelected (); - void __fastcall RefreshSelected (); - bool SelectionToReference(ListItemsVec* props); - void ExportOneOBJ (CEditableObject*); -public: // User declarations - void __stdcall OnModified (); - __fastcall TfrmEditLibrary (TComponent* Owner); - static bool FinalClose (); - static void __fastcall OnRender (); - static void __fastcall ZoomObject (); - static CSceneObject* __fastcall RayPick (const Fvector& start, const Fvector& direction, SRayPickInfo* pinf); - static void __fastcall ShowEditor (); + void UnlockForm() + { + bFormLocked = false; + paCommands->Enabled = true; + paItems->Enabled = true; + } + + void __fastcall ResetSelected(); + void __fastcall RefreshSelected(); + bool SelectionToReference(ListItemsVec *props); + void ExportOneOBJ(CEditableObject *); +public: // User declarations + void __stdcall OnModified(); + __fastcall TfrmEditLibrary(TComponent *Owner); + static bool FinalClose(); + static void __fastcall OnRender(); + static void __fastcall ZoomObject(); + static CSceneObject * __fastcall RayPick(const Fvector &start, const Fvector &direction, SRayPickInfo *pinf); + static void __fastcall ShowEditor(); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/EditLightAnim.cpp b/src/editors/LevelEditor/EditLightAnim.cpp index f1a328358dc..1e42e769b4f 100644 --- a/src/editors/LevelEditor/EditLightAnim.cpp +++ b/src/editors/LevelEditor/EditLightAnim.cpp @@ -6,8 +6,8 @@ #include "EditLightAnim.h" #include "Scene.h" #include "LightAnimLibrary.h" -#include "../ECore/Editor/ColorPicker.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ColorPicker.h" +#include "editors/ECore/Editor/ui_main.h" //--------------------------------------------------------------------------- #pragma link "multi_edit" #pragma link "Gradient" @@ -18,66 +18,74 @@ #pragma link "RenderWindow" #pragma resource "*.dfm" -TfrmEditLightAnim* TfrmEditLightAnim::form=0; +TfrmEditLightAnim *TfrmEditLightAnim::form = 0; //--------------------------------------------------------------------------- -__fastcall TfrmEditLightAnim::TfrmEditLightAnim(TComponent* Owner) +__fastcall TfrmEditLightAnim::TfrmEditLightAnim(TComponent *Owner) : TForm(Owner) { DEFINE_INI(fsStorage); - bFinalClose = false; - m_CurrentItem = 0; - m_CurrentOwner = 0; - iMoveKey = -1; - m_Props = 0; - m_Items = 0; + bFinalClose = false; + m_CurrentItem = 0; + m_CurrentOwner = 0; + iMoveKey = -1; + m_Props = 0; + m_Items = 0; } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::FormCreate(TObject *Sender) { - m_Props = TProperties::CreateForm("LAProps",paProps,alClient,TOnModifiedEvent(this,&TfrmEditLightAnim::OnModified)); - m_Items = TItemList::CreateForm("LA Items",paItems,alClient,TItemList::ilEditMenu|TItemList::ilDragAllowed|TItemList::ilFolderStore); - m_Items->SetOnModifiedEvent (TOnModifiedEvent(this,&TfrmEditLightAnim::OnModified)); - m_Items->SetOnItemFocusedEvent (fastdelegate::bind(this,&TfrmEditLightAnim::OnItemFocused)); - m_Items->SetOnItemRemoveEvent (fastdelegate::bind(&LALib,&ELightAnimLibrary::RemoveObject)); - m_Items->SetOnItemRenameEvent (fastdelegate::bind(&LALib,&ELightAnimLibrary::RenameObject)); + m_Props = TProperties::CreateForm("LAProps", paProps, alClient, TOnModifiedEvent(this, &TfrmEditLightAnim::OnModified)); + m_Items = TItemList::CreateForm("LA Items", paItems, alClient, TItemList::ilEditMenu|TItemList::ilDragAllowed|TItemList::ilFolderStore); + m_Items->SetOnModifiedEvent(TOnModifiedEvent(this, &TfrmEditLightAnim::OnModified)); + m_Items->SetOnItemFocusedEvent(fastdelegate::bind(this, &TfrmEditLightAnim::OnItemFocused)); + m_Items->SetOnItemRemoveEvent(fastdelegate::bind(&LALib, &ELightAnimLibrary::RemoveObject)); + m_Items->SetOnItemRenameEvent(fastdelegate::bind(&LALib, &ELightAnimLibrary::RenameObject)); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::FormDestroy(TObject *Sender) { - TProperties::DestroyForm(m_Props); + TProperties::DestroyForm(m_Props); TItemList::DestroyForm(m_Items); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::fsStorageRestorePlacement( - TObject *Sender) -{ - m_Props->RestoreParams(fsStorage); -} + TObject *Sender) +{ + m_Props->RestoreParams(fsStorage); +} + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::fsStorageSavePlacement(TObject *Sender) { - m_Props->SaveParams(fsStorage); + m_Props->SaveParams(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::OnModified() { - ebSave->Enabled = true; + ebSave->Enabled = true; UpdateView(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ShowEditor() { - if (!form){ - form = xr_new((TComponent*)0); - Scene->lock(); + if (!form) + { + form = xr_new((TComponent*)0); + Scene->lock(); } form->Show(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::FormShow(TObject *Sender) { @@ -85,478 +93,570 @@ void __fastcall TfrmEditLightAnim::FormShow(TObject *Sender) UI->BeginEState(esEditLightAnim); InitItems(); - // check window position - UI->CheckWindowPos(this); + // check window position + UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::FormClose(TObject *Sender, TCloseAction &Action) { - form = 0; - Action = caFree; - Scene->unlock(); + form = 0; + Action = caFree; + Scene->unlock(); UI->EndEState(esEditLightAnim); - if (ebSave->Enabled&&!bFinalClose) - LALib.Reload(); + if (ebSave->Enabled&&!bFinalClose) + LALib.Reload(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::FormCloseQuery(TObject *Sender, - bool &CanClose) + bool &CanClose) { - if (!bFinalClose) CanClose = IsClose(); - else CanClose = true; + if (!bFinalClose) + CanClose = IsClose(); + else + CanClose = true; } + //--------------------------------------------------------------------------- -bool TfrmEditLightAnim::IsClose(){ - if (ebSave->Enabled){ - int res = ELog.DlgMsg(mtConfirmation, "Library was change. Do you want save?"); - if (res==mrCancel) return false; - if (res==mrYes) ebSaveClick(0); +bool TfrmEditLightAnim::IsClose() +{ + if (ebSave->Enabled) + { + int res = ELog.DlgMsg(mtConfirmation, "Library was change. Do you want save?"); + if (res==mrCancel) + return false; + if (res==mrYes) + ebSaveClick(0); } return true; } + //--------------------------------------------------------------------------- -bool TfrmEditLightAnim::FinalClose(){ - if (!form) return true; - if (form->IsClose()){ - form->bFinalClose=true; - form->Close(); +bool TfrmEditLightAnim::FinalClose() +{ + if (!form) + return true; + if (form->IsClose()) + { + form->bFinalClose = true; + form->Close(); return true; } return false; } + //--------------------------------------------------------------------------- -void __fastcall TfrmEditLightAnim::OnItemFocused(TElTreeItem* item) +void __fastcall TfrmEditLightAnim::OnItemFocused(TElTreeItem *item) { - if (item&&FHelper.IsObject(item)){ - ListItem* prop = (ListItem*)item->Tag; VERIFY(prop); - AnsiString nm = prop->Key(); - CLAItem* I = LALib.FindItem(nm.c_str()); - SetCurrentItem (I,prop); - }else{ - SetCurrentItem (0,0); + if (item&&FHelper.IsObject(item)) + { + ListItem *prop = (ListItem*)item->Tag; + VERIFY(prop); + AnsiString nm = prop->Key(); + CLAItem *I = LALib.FindItem(nm.c_str()); + SetCurrentItem(I, prop); + } + else + { + SetCurrentItem(0, 0); } } + //--------------------------------------------------------------------------- void TfrmEditLightAnim::InitItems() { - ListItemsVec items; - for (LAItemIt it=LALib.Items.begin(); it!=LALib.Items.end(); it++) - LHelper().CreateItem(items,*(*it)->cName,0,0,0); - m_Items->AssignItems(items,false,true); + ListItemsVec items; + for (LAItemIt it = LALib.Items.begin(); it!=LALib.Items.end(); it++) + LHelper().CreateItem(items, *(*it)->cName, 0, 0, 0); + m_Items->AssignItems(items, false, true); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if (Key==VK_ESCAPE) Close(); + if (Key==VK_ESCAPE) + Close(); } + //--------------------------------------------------------------------------- void TfrmEditLightAnim::UpdateView() { - if (m_CurrentItem){ + if (m_CurrentItem) + { stStartFrame->Caption = 0; stEndFrame->Caption = m_CurrentItem->iFrameCount-1; - sePointer->MaxValue = m_CurrentItem->iFrameCount-1; - if (sePointer->Value>sePointer->MaxValue) sePointer->Value = sePointer->MaxValue; - sePointer->Enabled = m_CurrentItem->iFrameCount>1; + sePointer->MaxValue = m_CurrentItem->iFrameCount-1; + if (sePointer->Value>sePointer->MaxValue) + sePointer->Value = sePointer->MaxValue; + sePointer->Enabled = m_CurrentItem->iFrameCount>1; pbG->Repaint(); -// stStartFrame->Caption = m_CurrentItem->Keys.size(); - sePointer->Color = TColor(m_CurrentItem->IsKey(sePointer->Value)?0x00BFFFFF:0x00A0A0A0); + // stStartFrame->Caption = m_CurrentItem->Keys.size(); + sePointer->Color = TColor(m_CurrentItem->IsKey(sePointer->Value) ? 0x00BFFFFF : 0x00A0A0A0); } - Caption = AnsiString().sprintf("Light Animation Library%s",ebSave->Enabled?"*":""); + Caption = AnsiString().sprintf("Light Animation Library%s", ebSave->Enabled ? "*" : ""); } + //------------------------------------------------------------------------------ -bool TfrmEditLightAnim::OnFrameCountAfterEdit (PropValue* v, s32& val) +bool TfrmEditLightAnim::OnFrameCountAfterEdit(PropValue *v, s32 &val) { - if (val!=m_CurrentItem->iFrameCount) OnModified(); - m_CurrentItem->Resize(val); - UpdateView(); + if (val!=m_CurrentItem->iFrameCount) + OnModified(); + m_CurrentItem->Resize(val); + UpdateView(); return true; } + //--------------------------------------------------------------------------- void TfrmEditLightAnim::UpdateProperties() { // fill data PropItemVec items; - if (m_CurrentItem){ - PHelper().CreateName (items, "Name", &m_CurrentItem->cName, m_CurrentOwner); - PHelper().CreateFloat (items, "FPS", &m_CurrentItem->fFPS, 0.1f,1000,1.f,1); - S32Value* V; - V=PHelper().CreateS32 (items, "Frame Count", &m_CurrentItem->iFrameCount,1,100000,1); - V->OnAfterEditEvent.bind(this,&TfrmEditLightAnim::OnFrameCountAfterEdit); - - u32 frame = sePointer->Value; - PHelper().CreateCaption (items, "Current\\Frame", shared_str().printf("%d",frame)); - u32* val = m_CurrentItem->GetKey(sePointer->Value); - if (val){ - PHelper().CreateColor(items,"Current\\Color", val); - PHelper().CreateU8 (items, "Current\\Alpha", ((u8*)val)+3, 0x00, 0xFF); + if (m_CurrentItem) + { + PHelper().CreateName(items, "Name", &m_CurrentItem->cName, m_CurrentOwner); + PHelper().CreateFloat(items, "FPS", &m_CurrentItem->fFPS, 0.1f, 1000, 1.f, 1); + S32Value *V; + V = PHelper().CreateS32(items, "Frame Count", &m_CurrentItem->iFrameCount, 1, 100000, 1); + V->OnAfterEditEvent.bind(this, &TfrmEditLightAnim::OnFrameCountAfterEdit); + + u32 frame = sePointer->Value; + PHelper().CreateCaption(items, "Current\\Frame", shared_str().printf("%d", frame)); + u32 *val = m_CurrentItem->GetKey(sePointer->Value); + if (val) + { + PHelper().CreateColor(items, "Current\\Color", val); + PHelper().CreateU8(items, "Current\\Alpha", ((u8*)val)+3, 0x00, 0xFF); } } - m_Props->AssignItems (items); - UpdateView (); + m_Props->AssignItems(items); + UpdateView(); } + //--------------------------------------------------------------------------- -void TfrmEditLightAnim::SetCurrentItem(CLAItem* I, ListItem* owner) +void TfrmEditLightAnim::SetCurrentItem(CLAItem *I, ListItem *owner) { - m_CurrentItem = I; - m_CurrentOwner = owner; - paItemProps->Visible = !!I; - UpdateProperties (); + m_CurrentItem = I; + m_CurrentOwner = owner; + paItemProps->Visible = !!I; + UpdateProperties(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebAddAnimClick(TObject *Sender) { // folder name AnsiString pref; - TElTreeItem* item = m_Items->GetSelected(); - if (item) FHelper.MakeName(item,0,pref,true); - pref += "la"; - AnsiString name = FHelper.GenerateName (pref.c_str(),2,fastdelegate::bind(this,&TfrmEditLightAnim::FindItemByName),false,true); - CLAItem* I = LALib.AppendItem(name.c_str(),0); - InitItems (); - m_Items->SelectItem (*I->cName,true,false,true); - OnModified (); + TElTreeItem *item = m_Items->GetSelected(); + if (item) + FHelper.MakeName(item, 0, pref, true); + pref += "la"; + AnsiString name = FHelper.GenerateName(pref.c_str(), 2, fastdelegate::bind(this, &TfrmEditLightAnim::FindItemByName), false, true); + CLAItem *I = LALib.AppendItem(name.c_str(), 0); + InitItems(); + m_Items->SelectItem(*I->cName, true, false, true); + OnModified(); } + //--------------------------------------------------------------------------- -void TfrmEditLightAnim::FindItemByName(LPCSTR name, bool& res) -{ - res = !!LALib.FindItem(name); +void TfrmEditLightAnim::FindItemByName(LPCSTR name, bool &res) +{ + res = !!LALib.FindItem(name); } void __fastcall TfrmEditLightAnim::ebCloneClick(TObject *Sender) { - if (m_CurrentItem){ + if (m_CurrentItem) + { // folder name - AnsiString name = FHelper.GenerateName (m_CurrentItem->cName.c_str(),2,fastdelegate::bind(this,&TfrmEditLightAnim::FindItemByName),false,true); - CLAItem* I = LALib.AppendItem(name.c_str(),m_CurrentItem); - InitItems (); - m_Items->SelectItem (*I->cName,true,false,true); - OnModified (); - }else{ - ELog.DlgMsg(mtError, "Select item at first."); + AnsiString name = FHelper.GenerateName(m_CurrentItem->cName.c_str(), 2, fastdelegate::bind(this, &TfrmEditLightAnim::FindItemByName), false, true); + CLAItem *I = LALib.AppendItem(name.c_str(), m_CurrentItem); + InitItems(); + m_Items->SelectItem(*I->cName, true, false, true); + OnModified(); + } + else + { + ELog.DlgMsg(mtError, "Select item at first."); } } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebDeleteAnimClick(TObject *Sender) { - m_Items->RemoveSelItems (); + m_Items->RemoveSelItems(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebSaveClick(TObject *Sender) { - ebSave->Enabled = false; - LALib.Save (); - UpdateView (); + ebSave->Enabled = false; + LALib.Save(); + UpdateView(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebReloadClick(TObject *Sender) { - ebSave->Enabled = false; - m_CurrentItem = 0; - LALib.Reload (); - m_Props->ClearProperties (); - m_Items->ClearList (); - InitItems (); + ebSave->Enabled = false; + m_CurrentItem = 0; + LALib.Reload(); + m_Props->ClearProperties(); + m_Items->ClearList(); + InitItems(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::pbGMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - if (Shift.Contains(ssLeft)){ - TRect R = pbG->ClientRect; - TPoint pt(X,Y); - pbG->ScreenToClient(pt); + if (Shift.Contains(ssLeft)) + { + TRect R = pbG->ClientRect; + TPoint pt(X, Y); + pbG->ScreenToClient(pt); sePointer->Value = iFloor(float(m_CurrentItem->iFrameCount)*float(X)/float(R.Width())); pbG->Repaint(); - if (Shift.Contains(ssDouble)) - ebCreateKeyClick(Sender); - else{ - if (m_CurrentItem->IsKey(sePointer->Value)&&(sePointer->Value!=0)){ - iMoveKey = sePointer->Value; + if (Shift.Contains(ssDouble)) + ebCreateKeyClick(Sender); + else + { + if (m_CurrentItem->IsKey(sePointer->Value)&&(sePointer->Value!=0)) + { + iMoveKey = sePointer->Value; iTgtMoveKey = iMoveKey; } } } wnShape->SetFocus(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::pbGMouseMove(TObject *Sender, - TShiftState Shift, int X, int Y) + TShiftState Shift, int X, int Y) { if (Shift.Contains(ssLeft)) - if (iMoveKey>=0){ - TRect R = pbG->ClientRect; - TPoint pt(X,Y); + if (iMoveKey>=0) + { + TRect R = pbG->ClientRect; + TPoint pt(X, Y); pbG->ScreenToClient(pt); int new_key = iFloor(float(m_CurrentItem->iFrameCount)*float(X)/float(R.Width())); - if ((new_key!=iTgtMoveKey)&&(new_keyiFrameCount)&&(!m_CurrentItem->IsKey(new_key)||(new_key==iMoveKey))){ - iTgtMoveKey = new_key; - pbG->Repaint(); + if ((new_key!=iTgtMoveKey)&&(new_keyiFrameCount)&&(!m_CurrentItem->IsKey(new_key)||(new_key==iMoveKey))) + { + iTgtMoveKey = new_key; + pbG->Repaint(); } } } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::pbGMouseUp(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) -{ - if (iMoveKey>=0){ - if (iTgtMoveKey!=iMoveKey){ - m_CurrentItem->MoveKey(iMoveKey,iTgtMoveKey); - sePointer->Value = iTgtMoveKey; + TMouseButton Button, TShiftState Shift, int X, int Y) +{ + if (iMoveKey>=0) + { + if (iTgtMoveKey!=iMoveKey) + { + m_CurrentItem->MoveKey(iMoveKey, iTgtMoveKey); + sePointer->Value = iTgtMoveKey; pbG->Repaint(); OnModified(); } - iMoveKey = -1; + iMoveKey = -1; } } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebDeleteKeyClick(TObject *Sender) { - m_CurrentItem->DeleteKey(sePointer->Value); + m_CurrentItem->DeleteKey(sePointer->Value); UpdateView(); OnModified(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebCreateKeyClick(TObject *Sender) { - u32 color = m_CurrentItem->InterpolateRGB(sePointer->Value); + u32 color = m_CurrentItem->InterpolateRGB(sePointer->Value); + + m_CurrentItem->InsertKey(sePointer->Value, color); + UpdateProperties(); + OnModified(); +} - m_CurrentItem->InsertKey(sePointer->Value,color); - UpdateProperties (); - OnModified (); -} //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::pbGPaint(TObject *Sender) { - TRect R = pbG->ClientRect; - Graphics::TBitmap* B = xr_new(); - B->Width = R.Width()-2; - B->Height = R.Height()-2; - pbG->Canvas->Brush->Style = bsSolid; - pbG->Canvas->Brush->Color = clBlack; - pbG->Canvas->FrameRect (R); - R.right -= 2; - R.bottom -= 2; - B->Canvas->Brush->Color = TColor(0x00707070); + TRect R = pbG->ClientRect; + Graphics::TBitmap *B = xr_new(); + B->Width = R.Width()-2; + B->Height = R.Height()-2; + pbG->Canvas->Brush->Style = bsSolid; + pbG->Canvas->Brush->Color = clBlack; + pbG->Canvas->FrameRect(R); + R.right -= 2; + R.bottom -= 2; + B->Canvas->Brush->Color = TColor(0x00707070); B->Canvas->FillRect(R); - if (m_CurrentItem){ - float segment = float(R.Width())/(float(m_CurrentItem->iFrameCount)); - int half_segment= iFloor(segment/2); + if (m_CurrentItem) + { + float segment = float(R.Width())/(float(m_CurrentItem->iFrameCount)); + int half_segment = iFloor(segment/2); // draw gradient - CLAItem::KeyMap& Keys=m_CurrentItem->Keys; - int last=m_CurrentItem->iFrameCount; - Keys[last]=Keys.rbegin()->second; - CLAItem::KeyPairIt prev_key=Keys.begin(); - CLAItem::KeyPairIt it=prev_key; it++; - float x_prev=(float(prev_key->first)/float(m_CurrentItem->iFrameCount))*R.Width(); - TRect cb; - cb.Top = R.Top; - cb.Bottom = R.Bottom-R.Height()*0.3f; - for (; it!=Keys.end(); it++){ - float x = (it->first/float(m_CurrentItem->iFrameCount))*R.Width(); - float g_cnt = it->first-prev_key->first; - for (int k=0; kCanvas->Brush->Color = TColor(subst_alpha(m_CurrentItem->InterpolateBGR(prev_key->first+k),0)); - B->Canvas->FillRect(cb); + CLAItem::KeyMap &Keys = m_CurrentItem->Keys; + int last = m_CurrentItem->iFrameCount; + Keys[last] = Keys.rbegin()->second; + CLAItem::KeyPairIt prev_key = Keys.begin(); + CLAItem::KeyPairIt it = prev_key; + it++; + float x_prev = (float(prev_key->first)/float(m_CurrentItem->iFrameCount))*R.Width(); + TRect cb; + cb.Top = R.Top; + cb.Bottom = R.Bottom-R.Height()*0.3f; + for (; it!=Keys.end(); it++) + { + float x = (it->first/float(m_CurrentItem->iFrameCount))*R.Width(); + float g_cnt = it->first-prev_key->first; + for (int k = 0; kCanvas->Brush->Color = TColor(subst_alpha(m_CurrentItem->InterpolateBGR(prev_key->first+k), 0)); + B->Canvas->FillRect(cb); } - prev_key = it; - x_prev = x; + prev_key = it; + x_prev = x; } Keys.erase(Keys.find(last)); // draw keys - B->Canvas->Brush->Color= TColor(0x00BFFFFF); - cb.Top = R.Bottom-R.Height()*0.1f; - cb.Bottom = R.Bottom; - for (it=m_CurrentItem->Keys.begin(); it!=m_CurrentItem->Keys.end(); it++){ - int t = iFloor((it->first/float(m_CurrentItem->iFrameCount))*R.Width()); - cb.Left = t-1+half_segment; - cb.Right = t+2+half_segment; - B->Canvas->FillRect(cb); + B->Canvas->Brush->Color = TColor(0x00BFFFFF); + cb.Top = R.Bottom-R.Height()*0.1f; + cb.Bottom = R.Bottom; + for (it = m_CurrentItem->Keys.begin(); it!=m_CurrentItem->Keys.end(); it++) + { + int t = iFloor((it->first/float(m_CurrentItem->iFrameCount))*R.Width()); + cb.Left = t-1+half_segment; + cb.Right = t+2+half_segment; + B->Canvas->FillRect(cb); } - // draw pointer - int t=iFloor((sePointer->Value/float(m_CurrentItem->iFrameCount))*R.Width())+half_segment; - B->Canvas->Pen->Color= TColor(0x0000FF00); - B->Canvas->MoveTo(t,R.Bottom); - B->Canvas->LineTo(t,R.Top+R.Height()*0.75f); - if ((iMoveKey>=0)&&(iTgtMoveKey!=iMoveKey)) - t=iFloor((iTgtMoveKey/float(m_CurrentItem->iFrameCount))*R.Width())+half_segment; - TRect rp=R; - rp.Left = t-2; - rp.Right = t+3; - rp.Top = R.Top+1; - rp.Bottom = R.Bottom-R.Height()*0.3f-1; - B->Canvas->Brush->Color = TColor(0x00AAAAAA); - B->Canvas->FrameRect(rp); - rp.Left -=1; - rp.Right +=1; - rp.Top -=1; - rp.Bottom +=1; - B->Canvas->Brush->Color = TColor(0x00000000); - B->Canvas->FrameRect(rp); + // draw pointer + int t = iFloor((sePointer->Value/float(m_CurrentItem->iFrameCount))*R.Width())+half_segment; + B->Canvas->Pen->Color = TColor(0x0000FF00); + B->Canvas->MoveTo(t, R.Bottom); + B->Canvas->LineTo(t, R.Top+R.Height()*0.75f); + if ((iMoveKey>=0)&&(iTgtMoveKey!=iMoveKey)) + t = iFloor((iTgtMoveKey/float(m_CurrentItem->iFrameCount))*R.Width())+half_segment; + TRect rp = R; + rp.Left = t-2; + rp.Right = t+3; + rp.Top = R.Top+1; + rp.Bottom = R.Bottom-R.Height()*0.3f-1; + B->Canvas->Brush->Color = TColor(0x00AAAAAA); + B->Canvas->FrameRect(rp); + rp.Left -= 1; + rp.Right += 1; + rp.Top -= 1; + rp.Bottom += 1; + B->Canvas->Brush->Color = TColor(0x00000000); + B->Canvas->FrameRect(rp); // } - pbG->Canvas->Draw(1,1,B); + pbG->Canvas->Draw(1, 1, B); xr_delete(B); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::sePointerKeyDown(TObject *Sender, - WORD &Key, TShiftState Shift) + WORD &Key, TShiftState Shift) { - if (Key==VK_RETURN) pbG->Repaint(); + if (Key==VK_RETURN) + pbG->Repaint(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::sePointerExit(TObject *Sender) { - pbG->Repaint(); + pbG->Repaint(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::OnIdle() { - if (form){ - if (form->m_CurrentItem){ - int frame; - u32 C = form->m_CurrentItem->CalculateBGR(EDevice.fTimeGlobal,frame); - form->paColor->Color = TColor(subst_alpha(C,0)); - form->lbCurFrame->Caption = AnsiString().sprintf("%d",frame); - form->lbAlpha->Caption = AnsiString().sprintf("[%d]",color_get_A(C)); + if (form) + { + if (form->m_CurrentItem) + { + int frame; + u32 C = form->m_CurrentItem->CalculateBGR(EDevice.fTimeGlobal, frame); + form->paColor->Color = TColor(subst_alpha(C, 0)); + form->lbCurFrame->Caption = AnsiString().sprintf("%d", frame); + form->lbAlpha->Caption = AnsiString().sprintf("[%d]", color_get_A(C)); } UI->RedrawScene(); } } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::sePointerChange(TObject *Sender) { - sePointer->Color = TColor(m_CurrentItem->IsKey(sePointer->Value)?0x00BFFFFF:0x00A0A0A0); + sePointer->Color = TColor(m_CurrentItem->IsKey(sePointer->Value) ? 0x00BFFFFF : 0x00A0A0A0); UpdateProperties(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebFirstKeyClick(TObject *Sender) { - sePointer->Value = m_CurrentItem->FirstKeyFrame(); - pbG->Repaint(); + sePointer->Value = m_CurrentItem->FirstKeyFrame(); + pbG->Repaint(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebPrevKeyClick(TObject *Sender) { - sePointer->Value = m_CurrentItem->PrevKeyFrame(sePointer->Value); - pbG->Repaint(); + sePointer->Value = m_CurrentItem->PrevKeyFrame(sePointer->Value); + pbG->Repaint(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebNextKeyClick(TObject *Sender) { - sePointer->Value = m_CurrentItem->NextKeyFrame(sePointer->Value); - pbG->Repaint(); + sePointer->Value = m_CurrentItem->NextKeyFrame(sePointer->Value); + pbG->Repaint(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebLastKeyClick(TObject *Sender) { - sePointer->Value = m_CurrentItem->LastKeyFrame(); - pbG->Repaint(); + sePointer->Value = m_CurrentItem->LastKeyFrame(); + pbG->Repaint(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebMoveKeyLeftClick(TObject *Sender) { - if ((sePointer->Value!=0)&&(m_CurrentItem->IsKey(sePointer->Value))){ - int f0, f1; - f1 = f0 = sePointer->Value; + if ((sePointer->Value!=0)&&(m_CurrentItem->IsKey(sePointer->Value))) + { + int f0, f1; + f1 = f0 = sePointer->Value; f1--; - if (f1>=0){ - m_CurrentItem->MoveKey(f0,f1); - sePointer->Value--; - pbG->Repaint(); - OnModified(); + if (f1>=0) + { + m_CurrentItem->MoveKey(f0, f1); + sePointer->Value--; + pbG->Repaint(); + OnModified(); } } } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebMoveKeyRightClick(TObject *Sender) { - if ((sePointer->Value!=0)&&(m_CurrentItem->IsKey(sePointer->Value))){ - int f0, f1; - f1 = f0 = sePointer->Value; + if ((sePointer->Value!=0)&&(m_CurrentItem->IsKey(sePointer->Value))) + { + int f0, f1; + f1 = f0 = sePointer->Value; f1++; - if (f1iFrameCount){ - m_CurrentItem->MoveKey(f0,f1); - sePointer->Value++; - pbG->Repaint(); - OnModified(); + if (f1iFrameCount) + { + m_CurrentItem->MoveKey(f0, f1); + sePointer->Value++; + pbG->Repaint(); + OnModified(); } } } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebLastFrameClick(TObject *Sender) { - sePointer->Value = m_CurrentItem->iFrameCount-1; - pbG->Repaint(); + sePointer->Value = m_CurrentItem->iFrameCount-1; + pbG->Repaint(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::ebFirstFrameClick(TObject *Sender) { - sePointer->Value = 0; - pbG->Repaint(); + sePointer->Value = 0; + pbG->Repaint(); } + //--------------------------------------------------------------------------- void __fastcall TfrmEditLightAnim::wnShapeKeyDown(TObject *Sender, - WORD &Key, TShiftState Shift) -{ - if (m_CurrentItem){ - if (Key==VK_LEFT){ - if (Shift.Contains(ssAlt)){ + WORD &Key, TShiftState Shift) +{ + if (m_CurrentItem) + { + if (Key==VK_LEFT) + { + if (Shift.Contains(ssAlt)) + { sePointer->Value--; pbG->Repaint(); - }else if (Shift.Contains(ssCtrl)){ - ebFirstKeyClick(Sender); - }else{ + } + else if (Shift.Contains(ssCtrl)) + { + ebFirstKeyClick(Sender); + } + else + { ebPrevKeyClick(Sender); } - }else if (Key==VK_RIGHT){ - if (Shift.Contains(ssAlt)){ + } + else if (Key==VK_RIGHT) + { + if (Shift.Contains(ssAlt)) + { sePointer->Value++; pbG->Repaint(); - }else if (Shift.Contains(ssCtrl)){ - ebLastKeyClick(Sender); - }else{ + } + else if (Shift.Contains(ssCtrl)) + { + ebLastKeyClick(Sender); + } + else + { ebNextKeyClick(Sender); } } } } + //--------------------------------------------------------------------------- diff --git a/src/editors/LevelEditor/EditLightAnim.h b/src/editors/LevelEditor/EditLightAnim.h index 0ca78d2459d..a3e8a1a13cf 100644 --- a/src/editors/LevelEditor/EditLightAnim.h +++ b/src/editors/LevelEditor/EditLightAnim.h @@ -29,104 +29,107 @@ class CLAItem; class TProperties; class ListItem; class PropValue; + //--------------------------------------------------------------------------- class TfrmEditLightAnim : public TForm { -__published: // IDE-managed Components - TPanel *paItemProps; - TFormStorage *fsStorage; - TPanel *paListAndButtons; - TPanel *Panel2; - TExtBtn *ebAddAnim; - TExtBtn *ebDeleteAnim; - TExtBtn *ebSave; - TExtBtn *ebReload; - TPanel *paItems; - TPanel *paColorAndControls; - TPanel *paPropsGroup; - TPanel *paProps; - TPanel *paColor; - TMxLabel *lbCurFrame; - TPanel *Panel1; - TExtBtn *ebPrevKey; - TExtBtn *ebFirstKey; - TExtBtn *ebNextKey; - TExtBtn *ebLastKey; - TExtBtn *ebMoveKeyLeft; - TExtBtn *ebMoveKeyRight; - TExtBtn *ebFirstFrame; - TExtBtn *ebLastFrame; - TMultiObjSpinEdit *sePointer; - TStaticText *stStartFrame; - TStaticText *stEndFrame; - TExtBtn *ebDeleteKey; - TExtBtn *ebCreateKey; - TD3DWindow *wnShape; - TPaintBox *pbG; - TMxLabel *lbAlpha; - TExtBtn *ebClone; + __published: // IDE-managed Components + TPanel*paItemProps; + TFormStorage *fsStorage; + TPanel *paListAndButtons; + TPanel *Panel2; + TExtBtn *ebAddAnim; + TExtBtn *ebDeleteAnim; + TExtBtn *ebSave; + TExtBtn *ebReload; + TPanel *paItems; + TPanel *paColorAndControls; + TPanel *paPropsGroup; + TPanel *paProps; + TPanel *paColor; + TMxLabel *lbCurFrame; + TPanel *Panel1; + TExtBtn *ebPrevKey; + TExtBtn *ebFirstKey; + TExtBtn *ebNextKey; + TExtBtn *ebLastKey; + TExtBtn *ebMoveKeyLeft; + TExtBtn *ebMoveKeyRight; + TExtBtn *ebFirstFrame; + TExtBtn *ebLastFrame; + TMultiObjSpinEdit *sePointer; + TStaticText *stStartFrame; + TStaticText *stEndFrame; + TExtBtn *ebDeleteKey; + TExtBtn *ebCreateKey; + TD3DWindow *wnShape; + TPaintBox *pbG; + TMxLabel *lbAlpha; + TExtBtn *ebClone; void __fastcall FormShow(TObject *Sender); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall ebAddAnimClick(TObject *Sender); - void __fastcall ebDeleteAnimClick(TObject *Sender); - void __fastcall ebSaveClick(TObject *Sender); - void __fastcall ebReloadClick(TObject *Sender); - void __fastcall pbGPaint(TObject *Sender); - void __fastcall pbGMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall sePointerKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall sePointerExit(TObject *Sender); - void __fastcall ebDeleteKeyClick(TObject *Sender); - void __fastcall ebCreateKeyClick(TObject *Sender); - void __fastcall pbGMouseMove(TObject *Sender, TShiftState Shift, int X, - int Y); - void __fastcall pbGMouseUp(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall sePointerChange(TObject *Sender); - void __fastcall ebFirstKeyClick(TObject *Sender); - void __fastcall ebPrevKeyClick(TObject *Sender); - void __fastcall ebNextKeyClick(TObject *Sender); - void __fastcall ebLastKeyClick(TObject *Sender); - void __fastcall ebMoveKeyLeftClick(TObject *Sender); - void __fastcall ebMoveKeyRightClick(TObject *Sender); - void __fastcall ebLastFrameClick(TObject *Sender); - void __fastcall ebFirstFrameClick(TObject *Sender); - void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); - void __fastcall FormCreate(TObject *Sender); - void __fastcall FormDestroy(TObject *Sender); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); - void __fastcall wnShapeKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall ebCloneClick(TObject *Sender); -private: // User declarations - void InitItems(); - bool bFinalClose; - bool IsClose(); - static TfrmEditLightAnim *form; - CLAItem* m_CurrentItem; - ListItem* m_CurrentOwner; - void SetCurrentItem (CLAItem* item, ListItem* owner); - void UpdateView (); - int iMoveKey; - int iTgtMoveKey; - bool __stdcall OnFrameCountAfterEdit (PropValue* v, s32& val); - void __stdcall OnItemFocused (TElTreeItem* item); + TShiftState Shift); + void __fastcall ebAddAnimClick(TObject *Sender); + void __fastcall ebDeleteAnimClick(TObject *Sender); + void __fastcall ebSaveClick(TObject *Sender); + void __fastcall ebReloadClick(TObject *Sender); + void __fastcall pbGPaint(TObject *Sender); + void __fastcall pbGMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall sePointerKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall sePointerExit(TObject *Sender); + void __fastcall ebDeleteKeyClick(TObject *Sender); + void __fastcall ebCreateKeyClick(TObject *Sender); + void __fastcall pbGMouseMove(TObject *Sender, TShiftState Shift, int X, + int Y); + void __fastcall pbGMouseUp(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall sePointerChange(TObject *Sender); + void __fastcall ebFirstKeyClick(TObject *Sender); + void __fastcall ebPrevKeyClick(TObject *Sender); + void __fastcall ebNextKeyClick(TObject *Sender); + void __fastcall ebLastKeyClick(TObject *Sender); + void __fastcall ebMoveKeyLeftClick(TObject *Sender); + void __fastcall ebMoveKeyRightClick(TObject *Sender); + void __fastcall ebLastFrameClick(TObject *Sender); + void __fastcall ebFirstFrameClick(TObject *Sender); + void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); + void __fastcall FormCreate(TObject *Sender); + void __fastcall FormDestroy(TObject *Sender); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); + void __fastcall wnShapeKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall ebCloneClick(TObject *Sender); +private: // User declarations + void InitItems(); + bool bFinalClose; + bool IsClose(); + static TfrmEditLightAnim *form; + CLAItem *m_CurrentItem; + ListItem *m_CurrentOwner; + void SetCurrentItem(CLAItem *item, ListItem *owner); + void UpdateView(); + int iMoveKey; + int iTgtMoveKey; + bool __stdcall OnFrameCountAfterEdit(PropValue *v, s32 &val); + void __stdcall OnItemFocused(TElTreeItem *item); - TItemList* m_Items; - TProperties* m_Props; - void __stdcall OnModified (void); - void UpdateProperties (); - void __stdcall FindItemByName (LPCSTR name, bool& res); -public: // User declarations - __fastcall TfrmEditLightAnim (TComponent* Owner); - static bool FinalClose (); - static void __fastcall ShowEditor (); - static void __fastcall OnIdle (); + TItemList *m_Items; + TProperties *m_Props; + void __stdcall OnModified(void); + void UpdateProperties(); + void __stdcall FindItemByName(LPCSTR name, bool &res); +public: // User declarations + __fastcall TfrmEditLightAnim(TComponent *Owner); + static bool FinalClose(); + static void __fastcall ShowEditor(); + static void __fastcall OnIdle(); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FrameAIMap.cpp b/src/editors/LevelEditor/FrameAIMap.cpp index 9133a9e1a2a..314b36aeeaf 100644 --- a/src/editors/LevelEditor/FrameAIMap.cpp +++ b/src/editors/LevelEditor/FrameAIMap.cpp @@ -1,12 +1,12 @@ #include "stdafx.h" #pragma hdrstop -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "FrameAIMap.h" #include "Scene.h" #include "ESceneAIMapTools.h" #include "ESceneAIMapControls.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "mxPlacemnt" @@ -18,128 +18,153 @@ #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraAIMap::TfraAIMap(TComponent* Owner, ESceneAIMapTool* _tools) -: TForm(Owner) -{ - tools = _tools; R_ASSERT(tools); +__fastcall TfraAIMap::TfraAIMap(TComponent *Owner, ESceneAIMapTool *_tools) + : TForm(Owner) +{ + tools = _tools; + R_ASSERT(tools); } + //--------------------------------------------------------------------------- void __fastcall TfraAIMap::PanelMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraAIMap::ExpandClick(TObject *Sender) { PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraAIMap::ebGenerateMapClick(TObject *Sender) { - tools->GenerateMap(false); + tools->GenerateMap(false); } + //--------------------------------------------------------------------------- void __fastcall TfraAIMap::ebGenerateSelectedClick(TObject *Sender) { - tools->GenerateMap(true); + tools->GenerateMap(true); } + //--------------------------------------------------------------------------- void __fastcall TfraAIMap::ebResetSelectedClick(TObject *Sender) { - tools->ResetNodes(); + tools->ResetNodes(); } + //--------------------------------------------------------------------------- void __fastcall TfraAIMap::ebSmoothNodesClick(TObject *Sender) { - tools->SmoothNodes(); + tools->SmoothNodes(); } + //--------------------------------------------------------------------------- void __fastcall TfraAIMap::ExtBtn6Click(TObject *Sender) { - if (ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Are you sure to clear AI Map?")==mrYes){ - tools->Clear(); - Scene->UndoSave(); + if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<Clear(); + Scene->UndoSave(); } } + //--------------------------------------------------------------------------- void __fastcall TfraAIMap::ebDrawSnapObjectsClick(TObject *Sender) { UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraAIMap::ebInvertLinkClick(TObject *Sender) { - tools->InvertLinks(); + tools->InvertLinks(); Scene->UndoSave(); UI->RedrawScene(); } + //--------------------------------------------------------------------------- -static const int idx[5][4]={ - {0,1,2,3}, - {1,2,3,0}, - {2,3,0,1}, - {3,0,1,2}, - {4,4,4,4}, +static const int idx[5][4] = { + {0,1,2,3}, + {1,2,3,0}, + {2,3,0,1}, + {3,0,1,2}, + {4,4,4,4}, }; int ConvertV2L(int side) { - if (side<4){ - const Fvector& HPB = EDevice.m_Camera.GetHPB(); - float h = angle_normalize(HPB.x)/PI; R_ASSERT((h>=0.f)&&(h<=2.f)); - if (h>0.25f&&h<=0.75f) return idx[3][side]; - else if (h>0.75f&&h<=1.25f) return idx[2][side]; - else if (h>1.25f&&h<=1.75f) return idx[1][side]; - else return idx[0][side]; - }else return side; + if (side<4) + { + const Fvector &HPB = EDevice.m_Camera.GetHPB(); + float h = angle_normalize(HPB.x)/PI; + R_ASSERT((h>=0.f)&&(h<=2.f)); + if (h>0.25f&&h<=0.75f) + return idx[3][side]; + else if (h>0.75f&&h<=1.25f) + return idx[2][side]; + else if (h>1.25f&&h<=1.75f) + return idx[1][side]; + else + return idx[0][side]; + } + else + return side; } - -static const u8 fl[5] = {SAINode::flN1,SAINode::flN2,SAINode::flN3,SAINode::flN4, - SAINode::flN1|SAINode::flN2|SAINode::flN3|SAINode::flN4, -// SAINode::flN1|SAINode::flN2,SAINode::flN2|SAINode::flN3, -// SAINode::flN3|SAINode::flN4,SAINode::flN4|SAINode::flN1 - }; + +static const u8 fl[5] = {SAINode::flN1,SAINode::flN2,SAINode::flN3,SAINode::flN4, + SAINode::flN1|SAINode::flN2|SAINode::flN3|SAINode::flN4, + // SAINode::flN1|SAINode::flN2,SAINode::flN2|SAINode::flN3, + // SAINode::flN3|SAINode::flN4,SAINode::flN4|SAINode::flN1 +}; + void __fastcall TfraAIMap::ebSideClick(TObject *Sender) { - ESceneAIMapTool::EMode mode; - if (ebModeAppend->Down) mode = ESceneAIMapTool::mdAppend; - else if (ebModeRemove->Down) mode = ESceneAIMapTool::mdRemove; - else if (ebModeInvert->Down) mode = ESceneAIMapTool::mdInvert; - TExtBtn* btn = dynamic_cast(Sender); R_ASSERT(btn); - tools->MakeLinks(fl[ConvertV2L(btn->Tag)], mode, ebIgnoreConstraints->Down); + ESceneAIMapTool::EMode mode; + if (ebModeAppend->Down) + mode = ESceneAIMapTool::mdAppend; + else if (ebModeRemove->Down) + mode = ESceneAIMapTool::mdRemove; + else if (ebModeInvert->Down) + mode = ESceneAIMapTool::mdInvert; + TExtBtn *btn = dynamic_cast(Sender); + R_ASSERT(btn); + tools->MakeLinks(fl[ConvertV2L(btn->Tag)], mode, ebIgnoreConstraints->Down); Scene->UndoSave(); - UI->RedrawScene(); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraAIMap::ebSelLinkClick(TObject *Sender) { - TExtBtn* btn = dynamic_cast(Sender); R_ASSERT(btn); - tools->SelectNodesByLink (btn->Tag); + TExtBtn *btn = dynamic_cast(Sender); + R_ASSERT(btn); + tools->SelectNodesByLink(btn->Tag); Scene->UndoSave(); } -//--------------------------------------------------------------------------- - - +//--------------------------------------------------------------------------- void __fastcall TfraAIMap::btnAddIgnoredMaterialClick(TObject *Sender) { LPCSTR new_val = 0; - if ( TfrmChoseItem::SelectItem(smGameMaterial,new_val,1) ) + if (TfrmChoseItem::SelectItem(smGameMaterial, new_val, 1)) { lbIgnoreMaterialsList->AddItem(new_val, NULL); - SGameMtl* mtl = GMLib.GetMaterial(new_val); + SGameMtl *mtl = GMLib.GetMaterial(new_val); tools->m_ignored_materials.push_back(mtl->GetID()); } } @@ -151,5 +176,7 @@ void __fastcall TfraAIMap::btnIgnoreMaterialClearClick(TObject *Sender) lbIgnoreMaterialsList->Clear(); tools->m_ignored_materials.clear(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/FrameDetObj.cpp b/src/editors/LevelEditor/FrameDetObj.cpp index 69faf818f76..bd89bed6ce8 100644 --- a/src/editors/LevelEditor/FrameDetObj.cpp +++ b/src/editors/LevelEditor/FrameDetObj.cpp @@ -2,7 +2,7 @@ #pragma hdrstop #include "FrameDetObj.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "ESceneDOTools.h" #include "Scene.h" #include "DOShuffle.h" @@ -13,85 +13,100 @@ #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraDetailObject::TfraDetailObject(TComponent* Owner, EDetailManager* dm_tools) - : TForm(Owner) +__fastcall TfraDetailObject::TfraDetailObject(TComponent *Owner, EDetailManager *dm_tools) + : TForm(Owner) { - DM = dm_tools; VERIFY(DM); + DM = dm_tools; + VERIFY(DM); DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraDetailObject::PaneMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraDetailObject::ExpandClick(TObject *Sender) { PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraDetailObject::ExtBtn1Click(TObject *Sender) { - if (DM->Initialize()) Scene->UndoSave(); + if (DM->Initialize()) + Scene->UndoSave(); } + //--------------------------------------------------------------------------- void __fastcall TfraDetailObject::ExtBtn5Click(TObject *Sender) { - if (TfrmDOShuffle::Run()) - Scene->UndoSave(); + if (TfrmDOShuffle::Run()) + Scene->UndoSave(); } + //--------------------------------------------------------------------------- void __fastcall TfraDetailObject::ebUpdateObjectsClick(TObject *Sender) { - if (DM->UpdateObjects(true,false)) - Scene->UndoSave(); + if (DM->UpdateObjects(true, false)) + Scene->UndoSave(); } + //--------------------------------------------------------------------------- void __fastcall TfraDetailObject::ebInvalidateCacheClick(TObject *Sender) { - DM->InvalidateCache(); - Scene->UndoSave(); + DM->InvalidateCache(); + Scene->UndoSave(); } + //--------------------------------------------------------------------------- void __fastcall TfraDetailObject::ebResetSlotsClick(TObject *Sender) { - if (ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Are you sure to reset slots?")==mrYes){ - DM->ClearSlots(); - Scene->UndoSave(); + if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<ClearSlots(); + Scene->UndoSave(); } } + //--------------------------------------------------------------------------- void __fastcall TfraDetailObject::ebClearDetailsClick(TObject *Sender) { - if (ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Are you sure to clear details?")==mrYes){ - ExecCommand(COMMAND_UPDATE_PROPERTIES); - DM->Clear(); - Scene->UndoSave(); + if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<Clear(); + Scene->UndoSave(); } } + //--------------------------------------------------------------------------- void __fastcall TfraDetailObject::ebReinitializeSlotObjectsClick( - TObject *Sender) + TObject *Sender) { - if (DM->UpdateObjects(false,true)) - Scene->UndoSave(); + if (DM->UpdateObjects(false, true)) + Scene->UndoSave(); } + //--------------------------------------------------------------------------- void __fastcall TfraDetailObject::ExtBtn6Click(TObject *Sender) { - if (DM->Reinitialize()) - Scene->UndoSave(); + if (DM->Reinitialize()) + Scene->UndoSave(); } + //--------------------------------------------------------------------------- diff --git a/src/editors/LevelEditor/FrameEmitter.cpp b/src/editors/LevelEditor/FrameEmitter.cpp index 54b7a469fb0..b55fee5d797 100644 --- a/src/editors/LevelEditor/FrameEmitter.cpp +++ b/src/editors/LevelEditor/FrameEmitter.cpp @@ -12,84 +12,91 @@ #pragma link "ElXPThemedControl" #pragma resource "*.dfm" TfraEmitter *fraEmitter; + //--------------------------------------------------------------------------- -__fastcall TfraEmitter::TfraEmitter(TComponent* Owner) - : TFrame(Owner) -{ -} +__fastcall TfraEmitter::TfraEmitter(TComponent *Owner) + : TFrame(Owner) {} + //--------------------------------------------------------------------------- -void TfraEmitter::GetInfoFirst(const PS::SEmitterDef& E){ - pcEmitterType->ActivePageIndex = E.m_EmitterType; - // cone - seConeDirH->ObjFirstInit (rad2deg(E.m_ConeHPB.x)); - seConeDirP->ObjFirstInit (rad2deg(E.m_ConeHPB.y)); - seConeDirB->ObjFirstInit (rad2deg(E.m_ConeHPB.z)); - seConeAngle->ObjFirstInit (rad2deg(E.m_ConeAngle)); +void TfraEmitter::GetInfoFirst(const PS::SEmitterDef &E) +{ + pcEmitterType->ActivePageIndex = E.m_EmitterType; + // cone + seConeDirH->ObjFirstInit(rad2deg(E.m_ConeHPB.x)); + seConeDirP->ObjFirstInit(rad2deg(E.m_ConeHPB.y)); + seConeDirB->ObjFirstInit(rad2deg(E.m_ConeHPB.z)); + seConeAngle->ObjFirstInit(rad2deg(E.m_ConeAngle)); // sphere - seSphereRadius->ObjFirstInit (E.m_SphereRadius); + seSphereRadius->ObjFirstInit(E.m_SphereRadius); // box - seBoxSizeX->ObjFirstInit (E.m_BoxSize.x); - seBoxSizeY->ObjFirstInit (E.m_BoxSize.y); - seBoxSizeZ->ObjFirstInit (E.m_BoxSize.z); + seBoxSizeX->ObjFirstInit(E.m_BoxSize.x); + seBoxSizeY->ObjFirstInit(E.m_BoxSize.y); + seBoxSizeZ->ObjFirstInit(E.m_BoxSize.z); // birth - seBirthRate->ObjFirstInit (E.m_fBirthRate); - ebBirthFunc->Down = E.m_Flags.is(PS_EM_BIRTHFUNC); - seParticleLimit->ObjFirstInit (E.m_ParticleLimit); - // burst - cbBurst->ObjFirstInit ((E.m_Flags.is(PS_EM_BURST))?cbChecked:cbUnchecked); + seBirthRate->ObjFirstInit(E.m_fBirthRate); + ebBirthFunc->Down = E.m_Flags.is(PS_EM_BIRTHFUNC); + seParticleLimit->ObjFirstInit(E.m_ParticleLimit); + // burst + cbBurst->ObjFirstInit((E.m_Flags.is(PS_EM_BURST)) ? cbChecked : cbUnchecked); // play once - cbPlayOnce->ObjFirstInit ((E.m_Flags.is(PS_EM_PLAY_ONCE))?cbChecked:cbUnchecked); + cbPlayOnce->ObjFirstInit((E.m_Flags.is(PS_EM_PLAY_ONCE)) ? cbChecked : cbUnchecked); } + //--------------------------------------------------------------------------- -void TfraEmitter::GetInfoNext(const PS::SEmitterDef& E){ - pcEmitterType->ActivePageIndex = E.m_EmitterType; - // cone - seConeDirH->ObjNextInit (rad2deg(E.m_ConeHPB.x)); - seConeDirP->ObjNextInit (rad2deg(E.m_ConeHPB.y)); - seConeDirB->ObjNextInit (rad2deg(E.m_ConeHPB.z)); - seConeAngle->ObjNextInit (rad2deg(E.m_ConeAngle)); +void TfraEmitter::GetInfoNext(const PS::SEmitterDef &E) +{ + pcEmitterType->ActivePageIndex = E.m_EmitterType; + // cone + seConeDirH->ObjNextInit(rad2deg(E.m_ConeHPB.x)); + seConeDirP->ObjNextInit(rad2deg(E.m_ConeHPB.y)); + seConeDirB->ObjNextInit(rad2deg(E.m_ConeHPB.z)); + seConeAngle->ObjNextInit(rad2deg(E.m_ConeAngle)); // sphere - seSphereRadius->ObjNextInit (E.m_SphereRadius); + seSphereRadius->ObjNextInit(E.m_SphereRadius); // box - seBoxSizeX->ObjNextInit (E.m_BoxSize.x); - seBoxSizeY->ObjNextInit (E.m_BoxSize.y); - seBoxSizeZ->ObjNextInit (E.m_BoxSize.z); + seBoxSizeX->ObjNextInit(E.m_BoxSize.x); + seBoxSizeY->ObjNextInit(E.m_BoxSize.y); + seBoxSizeZ->ObjNextInit(E.m_BoxSize.z); // birth - seBirthRate->ObjNextInit (E.m_fBirthRate); - ebBirthFunc->Down = E.m_Flags.is(PS_EM_BIRTHFUNC); - seParticleLimit->ObjNextInit (E.m_ParticleLimit); - // burst - cbBurst->ObjNextInit ((E.m_Flags.is(PS_EM_BURST))?cbChecked:cbUnchecked); + seBirthRate->ObjNextInit(E.m_fBirthRate); + ebBirthFunc->Down = E.m_Flags.is(PS_EM_BIRTHFUNC); + seParticleLimit->ObjNextInit(E.m_ParticleLimit); + // burst + cbBurst->ObjNextInit((E.m_Flags.is(PS_EM_BURST)) ? cbChecked : cbUnchecked); // play once - cbPlayOnce->ObjNextInit ((E.m_Flags.is(PS_EM_PLAY_ONCE))?cbChecked:cbUnchecked); + cbPlayOnce->ObjNextInit((E.m_Flags.is(PS_EM_PLAY_ONCE)) ? cbChecked : cbUnchecked); } + //--------------------------------------------------------------------------- -void TfraEmitter::SetInfo(PS::SEmitterDef& E){ - E.m_EmitterType = PS::SEmitter::EEmitterType(pcEmitterType->ActivePageIndex); - // cone +void TfraEmitter::SetInfo(PS::SEmitterDef &E) +{ + E.m_EmitterType = PS::SEmitter::EEmitterType(pcEmitterType->ActivePageIndex); + // cone E.m_Flags.zero(); - E.m_Flags.set (PS_EM_BIRTHFUNC,ebBirthFunc->Down); - E.m_ConeHPB.set (float(deg2rad(seConeDirH->Value)), - float(deg2rad(seConeDirP->Value)), - float(deg2rad(seConeDirB->Value))); - E.UpdateConeOrientation (); - E.m_ConeAngle = deg2rad(seConeAngle->Value); + E.m_Flags.set(PS_EM_BIRTHFUNC, ebBirthFunc->Down); + E.m_ConeHPB.set(float(deg2rad(seConeDirH->Value)), + float(deg2rad(seConeDirP->Value)), + float(deg2rad(seConeDirB->Value))); + E.UpdateConeOrientation(); + E.m_ConeAngle = deg2rad(seConeAngle->Value); // sphere - seSphereRadius->ObjApplyFloat (E.m_SphereRadius); + seSphereRadius->ObjApplyFloat(E.m_SphereRadius); // box - seBoxSizeX->ObjApplyFloat (E.m_BoxSize.x); - seBoxSizeY->ObjApplyFloat (E.m_BoxSize.y); - seBoxSizeZ->ObjApplyFloat (E.m_BoxSize.z); + seBoxSizeX->ObjApplyFloat(E.m_BoxSize.x); + seBoxSizeY->ObjApplyFloat(E.m_BoxSize.y); + seBoxSizeZ->ObjApplyFloat(E.m_BoxSize.z); // birth - seBirthRate->ObjApplyFloat (E.m_fBirthRate); - seParticleLimit->ObjApplyFloat (E.m_ParticleLimit); - // burst - E.m_Flags.set (PS_EM_BURST,cbBurst->Checked); + seBirthRate->ObjApplyFloat(E.m_fBirthRate); + seParticleLimit->ObjApplyFloat(E.m_ParticleLimit); + // burst + E.m_Flags.set(PS_EM_BURST, cbBurst->Checked); // play once - E.m_Flags.set (PS_EM_PLAY_ONCE,cbPlayOnce->Checked); + E.m_Flags.set(PS_EM_PLAY_ONCE, cbPlayOnce->Checked); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/FrameEmitter.h b/src/editors/LevelEditor/FrameEmitter.h index 4c78a5fc9d1..b79a17776b8 100644 --- a/src/editors/LevelEditor/FrameEmitter.h +++ b/src/editors/LevelEditor/FrameEmitter.h @@ -22,52 +22,62 @@ class TfraEmitter : public TFrame { -__published: // IDE-managed Components - TLabel *RxLabel20; - TLabel *RxLabel22; - TExtBtn *ebBirthFunc; - TMultiObjSpinEdit *seBirthRate; - TMultiObjSpinEdit *seParticleLimit; - TLabel *RxLabel1; - TMultiObjCheck *cbBurst; - TLabel *RxLabel6; - TMultiObjCheck *cbPlayOnce; - TElPageControl *pcEmitterType; - TElTabSheet *tsPoint1; - TPanel *Panel3; - TElTabSheet *tsCone; - TPanel *Panel1; - TElTabSheet *tsSphere; - TPanel *Panel5; - TElTabSheet *tsBox; - TPanel *Panel4; - TLabel *RxLabel42; - TLabel *RxLabel4; - TLabel *RxLabel35; - TLabel *RxLabel36; - TLabel *RxLabel37; - TMultiObjSpinEdit *seConeAngle; - TMultiObjSpinEdit *seConeDirH; - TMultiObjSpinEdit *seConeDirP; - TMultiObjSpinEdit *seConeDirB; - TLabel *RxLabel38; - TMultiObjSpinEdit *seSphereRadius; - TLabel *RxLabel39; - TLabel *RxLabel40; - TLabel *RxLabel41; - TMultiObjSpinEdit *seBoxSizeX; - TMultiObjSpinEdit *seBoxSizeY; - TMultiObjSpinEdit *seBoxSizeZ; -private: // User declarations -public: // User declarations - __fastcall TfraEmitter(TComponent* Owner); - void GetInfoFirst(const PS::SEmitterDef& E); - void GetInfoNext(const PS::SEmitterDef& E); - void SetInfo(PS::SEmitterDef& E); - virtual void OnEnter (){;} - virtual void OnExit (){;} + __published: // IDE-managed Components + TLabel*RxLabel20; + TLabel *RxLabel22; + TExtBtn *ebBirthFunc; + TMultiObjSpinEdit *seBirthRate; + TMultiObjSpinEdit *seParticleLimit; + TLabel *RxLabel1; + TMultiObjCheck *cbBurst; + TLabel *RxLabel6; + TMultiObjCheck *cbPlayOnce; + TElPageControl *pcEmitterType; + TElTabSheet *tsPoint1; + TPanel *Panel3; + TElTabSheet *tsCone; + TPanel *Panel1; + TElTabSheet *tsSphere; + TPanel *Panel5; + TElTabSheet *tsBox; + TPanel *Panel4; + TLabel *RxLabel42; + TLabel *RxLabel4; + TLabel *RxLabel35; + TLabel *RxLabel36; + TLabel *RxLabel37; + TMultiObjSpinEdit *seConeAngle; + TMultiObjSpinEdit *seConeDirH; + TMultiObjSpinEdit *seConeDirP; + TMultiObjSpinEdit *seConeDirB; + TLabel *RxLabel38; + TMultiObjSpinEdit *seSphereRadius; + TLabel *RxLabel39; + TLabel *RxLabel40; + TLabel *RxLabel41; + TMultiObjSpinEdit *seBoxSizeX; + TMultiObjSpinEdit *seBoxSizeY; + TMultiObjSpinEdit *seBoxSizeZ; +private: // User declarations +public: // User declarations + __fastcall TfraEmitter(TComponent *Owner); + void GetInfoFirst(const PS::SEmitterDef &E); + void GetInfoNext(const PS::SEmitterDef &E); + void SetInfo(PS::SEmitterDef &E); + + virtual void OnEnter() + { + ; + } + + virtual void OnExit() + { + ; + } }; + //--------------------------------------------------------------------------- -extern PACKAGE TfraEmitter *fraEmitter; +extern PACKAGE TfraEmitter * fraEmitter; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FrameGroup.cpp b/src/editors/LevelEditor/FrameGroup.cpp index 82c454c2340..8b1ff5d265b 100644 --- a/src/editors/LevelEditor/FrameGroup.cpp +++ b/src/editors/LevelEditor/FrameGroup.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #pragma hdrstop -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "FrameGroup.h" #include "GroupObject.h" #include "Scene.h" @@ -14,168 +14,201 @@ #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraGroup::TfraGroup(TComponent* Owner, ESceneGroupTool* gt) - : TForm(Owner) +__fastcall TfraGroup::TfraGroup(TComponent *Owner, ESceneGroupTool *gt) + : TForm(Owner) { - ParentTools = gt; VERIFY(ParentTools); + ParentTools = gt; + VERIFY(ParentTools); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::PaneMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ExpandClick(TObject *Sender) { PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ebMakeGroupClick(TObject *Sender) { - ParentTools->GroupObjects (); + ParentTools->GroupObjects(); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ebMakeThumbnailClick(TObject *Sender) { - ParentTools->MakeThumbnail (); + ParentTools->MakeThumbnail(); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ebUngroupClick(TObject *Sender) { - ParentTools->UngroupObjects (); + ParentTools->UngroupObjects(); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ebCenterToGroupClick(TObject *Sender) { - ParentTools->CenterToGroup (); + ParentTools->CenterToGroup(); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ebAlignToObjectClick(TObject *Sender) { - ParentTools->AlignToObject(); + ParentTools->AlignToObject(); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ebSelectClick(TObject *Sender) { - LPCSTR nm; - xr_string N = lbCurrent->Caption.c_str(); - if (TfrmChoseItem::SelectItem(smGroup,nm,1,N.c_str())) - ParentTools->SetCurrentObject(nm); + LPCSTR nm; + xr_string N = lbCurrent->Caption.c_str(); + if (TfrmChoseItem::SelectItem(smGroup, nm, 1, N.c_str())) + ParentTools->SetCurrentObject(nm); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ebSaveSelectedClick(TObject *Sender) { - ParentTools->SaveSelectedObject(); + ParentTools->SaveSelectedObject(); } + //--------------------------------------------------------------------------- #include "UI_LevelTools.h" extern BOOL bForceInitListBox; + void __fastcall TfraGroup::ebReloadRefsClick(TObject *Sender) { - ParentTools->ReloadRefsSelectedObject(); + ParentTools->ReloadRefsSelectedObject(); bForceInitListBox = TRUE; Tools->UpdateProperties(TRUE); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ExtBtn1Click(TObject *Sender) { - SelByRefObject( true ); + SelByRefObject(true); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ExtBtn3Click(TObject *Sender) { - SelByRefObject( false ); + SelByRefObject(false); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ExtBtn6Click(TObject *Sender) { - MultiSelByRefObject(true); + MultiSelByRefObject(true); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::ExtBtn7Click(TObject *Sender) { - MultiSelByRefObject(false); + MultiSelByRefObject(false); } + //--------------------------------------------------------------------------- void __fastcall TfraGroup::seSelPercentKeyPress(TObject *Sender, char &Key) { - if (Key==VK_RETURN) ExecCommand(COMMAND_RENDER_FOCUS); + if (Key==VK_RETURN) + ExecCommand(COMMAND_RENDER_FOCUS); } + //--------------------------------------------------------------------------- -void __fastcall TfraGroup::MultiSelByRefObject ( bool clear_prev ) +void __fastcall TfraGroup::MultiSelByRefObject(bool clear_prev) { - ObjectList objlist; - LPU32Vec sellist; - if (Scene->GetQueryObjects(objlist,OBJCLASS_GROUP,1,1,-1)){ - for (ObjectIt it=objlist.begin(); it!=objlist.end(); it++){ - LPCSTR N = ((CGroupObject*)*it)->RefName(); + ObjectList objlist; + LPU32Vec sellist; + if (Scene->GetQueryObjects(objlist, OBJCLASS_GROUP, 1, 1, -1)) + { + for (ObjectIt it = objlist.begin(); it!=objlist.end(); it++) + { + LPCSTR N = ((CGroupObject*)*it)->RefName(); ObjectIt _F = Scene->FirstObj(OBJCLASS_GROUP); ObjectIt _E = Scene->LastObj(OBJCLASS_GROUP); - for(;_F!=_E;_F++){ - CGroupObject *_O = (CGroupObject *)(*_F); - if((*_F)->Visible()&&_O->RefCompare(N)){ - if (clear_prev){ - _O->Select( false ); - sellist.push_back((u32*)_O); - }else{ - if (!_O->Selected()) - sellist.push_back((u32*)_O); + for (; _F!=_E; _F++) + { + CGroupObject *_O = (CGroupObject *)(*_F); + if ((*_F)->Visible()&&_O->RefCompare(N)) + { + if (clear_prev) + { + _O->Select(false); + sellist.push_back((u32*)_O); + } + else + { + if (!_O->Selected()) + sellist.push_back((u32*)_O); } } } } - std::sort (sellist.begin(),sellist.end()); - sellist.erase (std::unique(sellist.begin(),sellist.end()),sellist.end()); - std::random_shuffle (sellist.begin(),sellist.end()); - int max_k = iFloor(float(sellist.size())/100.f*float(seSelPercent->Value)+0.5f); - int k = 0; - for (LPU32It o_it=sellist.begin(); kValue)+0.5f); + int k = 0; + for (LPU32It o_it = sellist.begin(); kSelect( true ); + _O->Select(true); } } } + //--------------------------------------------------------------------------- -void TfraGroup::SelByRefObject( bool flag ) +void TfraGroup::SelByRefObject(bool flag) { ObjectList objlist; - LPCSTR N=lbCurrent->Caption.c_str(); - if (N){ + LPCSTR N = lbCurrent->Caption.c_str(); + if (N) + { ObjectIt _F = Scene->FirstObj(OBJCLASS_GROUP); ObjectIt _E = Scene->LastObj(OBJCLASS_GROUP); - for(;_F!=_E;_F++){ - if((*_F)->Visible() ){ + for (; _F!=_E; _F++) + { + if ((*_F)->Visible()) + { CGroupObject *_O = (CGroupObject*)(*_F); - if(_O->RefCompare(N)) _O->Select( flag ); + if (_O->RefCompare(N)) + _O->Select(flag); } } } } -//--------------------------------------------------------------------------- - +//--------------------------------------------------------------------------- void __fastcall TfraGroup::ExtBtn2Click(TObject *Sender) { - FHelper.ShowPPMenu(pmGroupCommands,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmGroupCommands, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/FrameGroup.h b/src/editors/LevelEditor/FrameGroup.h index be700c99113..be24bd928d2 100644 --- a/src/editors/LevelEditor/FrameGroup.h +++ b/src/editors/LevelEditor/FrameGroup.h @@ -17,67 +17,70 @@ #include // refs class ESceneGroupTool; + //--------------------------------------------------------------------------- class TfraGroup : public TForm { -__published: // IDE-managed Components - TPanel *paCommands; - TExtBtn *ExtBtn2; - TExtBtn *ebUngroup; - TExtBtn *ebGroup; - TPanel *paCurrentObject; - TLabel *APHeadLabel2; - TPanel *Panel2; - TLabel *Label1; - TExtBtn *ebCenterToGroup; - TExtBtn *ebAlignToObject; - TExtBtn *ebSaveSelected; - TExtBtn *ebSelect; - TMxLabel *MxLabel1; - TMxLabel *lbCurrent; - TPanel *paSelectObject; - TBevel *Bevel3; - TLabel *Label2; - TExtBtn *ExtBtn1; - TExtBtn *ExtBtn3; - TLabel *APHeadLabel3; - TExtBtn *ExtBtn5; - TExtBtn *ExtBtn6; - TLabel *Label4; - TExtBtn *ExtBtn7; - TLabel *Label6; - TMultiObjSpinEdit *seSelPercent; - TExtBtn *ebMakeThumbnail; - TExtBtn *ebReloadRefs; - TMxPopupMenu *pmGroupCommands; - TMenuItem *N17; - TMenuItem *Ungroup1; - TMenuItem *N1; - TMenuItem *MakeThumbnail1; - TMenuItem *SaveAs1; - TMenuItem *N2; + __published: // IDE-managed Components + TPanel*paCommands; + TExtBtn *ExtBtn2; + TExtBtn *ebUngroup; + TExtBtn *ebGroup; + TPanel *paCurrentObject; + TLabel *APHeadLabel2; + TPanel *Panel2; + TLabel *Label1; + TExtBtn *ebCenterToGroup; + TExtBtn *ebAlignToObject; + TExtBtn *ebSaveSelected; + TExtBtn *ebSelect; + TMxLabel *MxLabel1; + TMxLabel *lbCurrent; + TPanel *paSelectObject; + TBevel *Bevel3; + TLabel *Label2; + TExtBtn *ExtBtn1; + TExtBtn *ExtBtn3; + TLabel *APHeadLabel3; + TExtBtn *ExtBtn5; + TExtBtn *ExtBtn6; + TLabel *Label4; + TExtBtn *ExtBtn7; + TLabel *Label6; + TMultiObjSpinEdit *seSelPercent; + TExtBtn *ebMakeThumbnail; + TExtBtn *ebReloadRefs; + TMxPopupMenu *pmGroupCommands; + TMenuItem *N17; + TMenuItem *Ungroup1; + TMenuItem *N1; + TMenuItem *MakeThumbnail1; + TMenuItem *SaveAs1; + TMenuItem *N2; void __fastcall PaneMinClick(TObject *Sender); void __fastcall ExpandClick(TObject *Sender); - void __fastcall ebMakeGroupClick(TObject *Sender); - void __fastcall ebUngroupClick(TObject *Sender); - void __fastcall ebCenterToGroupClick(TObject *Sender); - void __fastcall ebAlignToObjectClick(TObject *Sender); - void __fastcall ebSelectClick(TObject *Sender); - void __fastcall ebSaveSelectedClick(TObject *Sender); - void __fastcall ExtBtn1Click(TObject *Sender); - void __fastcall ExtBtn3Click(TObject *Sender); - void __fastcall ExtBtn6Click(TObject *Sender); - void __fastcall ExtBtn7Click(TObject *Sender); - void __fastcall seSelPercentKeyPress(TObject *Sender, char &Key); - void __fastcall ebReloadRefsClick(TObject *Sender); - void __fastcall ebMakeThumbnailClick(TObject *Sender); - void __fastcall ExtBtn2Click(TObject *Sender); -private: // User declarations - ESceneGroupTool* ParentTools; - void SelByRefObject ( bool flag ); - void MultiSelByRefObject ( bool clear_prev ); -public: // User declarations - __fastcall TfraGroup(TComponent* Owner, ESceneGroupTool* gt); + void __fastcall ebMakeGroupClick(TObject *Sender); + void __fastcall ebUngroupClick(TObject *Sender); + void __fastcall ebCenterToGroupClick(TObject *Sender); + void __fastcall ebAlignToObjectClick(TObject *Sender); + void __fastcall ebSelectClick(TObject *Sender); + void __fastcall ebSaveSelectedClick(TObject *Sender); + void __fastcall ExtBtn1Click(TObject *Sender); + void __fastcall ExtBtn3Click(TObject *Sender); + void __fastcall ExtBtn6Click(TObject *Sender); + void __fastcall ExtBtn7Click(TObject *Sender); + void __fastcall seSelPercentKeyPress(TObject *Sender, char &Key); + void __fastcall ebReloadRefsClick(TObject *Sender); + void __fastcall ebMakeThumbnailClick(TObject *Sender); + void __fastcall ExtBtn2Click(TObject *Sender); +private: // User declarations + ESceneGroupTool *ParentTools; + void SelByRefObject(bool flag); + void MultiSelByRefObject(bool clear_prev); +public: // User declarations + __fastcall TfraGroup(TComponent *Owner, ESceneGroupTool *gt); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FrameLight.cpp b/src/editors/LevelEditor/FrameLight.cpp index 18c5a9e2366..c1e22508c86 100644 --- a/src/editors/LevelEditor/FrameLight.cpp +++ b/src/editors/LevelEditor/FrameLight.cpp @@ -1,42 +1,49 @@ #include "stdafx.h" #pragma hdrstop -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "FrameLight.h" #include "ELight.h" #include "Scene.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraLight::TfraLight(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfraLight::TfraLight(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TfraLight::PaneMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraLight::ExpandClick(TObject *Sender) { PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- -void TfraLight::UseInD3D(bool bAll, bool bFlag){ - ObjectIt _F = Scene->FirstObj(OBJCLASS_LIGHT); +void TfraLight::UseInD3D(bool bAll, bool bFlag) +{ + ObjectIt _F = Scene->FirstObj(OBJCLASS_LIGHT); ObjectIt _E = Scene->LastObj(OBJCLASS_LIGHT); - for(;_F!=_E;_F++){ - CLight* L=(CLight*)*_F; - if(bAll){ + for (; _F!=_E; _F++) + { + CLight *L = (CLight*)*_F; + if (bAll) + { L->AffectD3D(bFlag); - }else{ - if(L->Selected() && L->Visible()) L->AffectD3D(bFlag); + } + else + { + if (L->Selected()&&L->Visible()) + L->AffectD3D(bFlag); } } UI->RedrawScene(); @@ -46,26 +53,30 @@ void TfraLight::UseInD3D(bool bAll, bool bFlag){ void __fastcall TfraLight::ebUseSelInD3DClick(TObject *Sender) { - UseInD3D(false, true); + UseInD3D(false, true); } + //--------------------------------------------------------------------------- void __fastcall TfraLight::ebUnuseSelInD3DClick(TObject *Sender) { - UseInD3D(false, false); + UseInD3D(false, false); } + //--------------------------------------------------------------------------- void __fastcall TfraLight::ebUseAllInD3DClick(TObject *Sender) { - UseInD3D(true, true); + UseInD3D(true, true); } + //--------------------------------------------------------------------------- void __fastcall TfraLight::ebUnuseAllInD3DClick(TObject *Sender) { - UseInD3D(true, false); + UseInD3D(true, false); } + //--------------------------------------------------------------------------- diff --git a/src/editors/LevelEditor/FrameObject.cpp b/src/editors/LevelEditor/FrameObject.cpp index 9105d0a5967..9f3ac48c0f2 100644 --- a/src/editors/LevelEditor/FrameObject.cpp +++ b/src/editors/LevelEditor/FrameObject.cpp @@ -1,15 +1,15 @@ #include "stdafx.h" #pragma hdrstop -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "FrameObject.h" #include "scene.h" -#include "../ECore/Editor/ui_main.h" -#include "../ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/EditObject.h" #include "SceneObject.h" -#include "../ECore/Editor/library.h" +#include "editors/ECore/Editor/library.h" #include "ESceneObjectTools.h" -#include "../ECore/Editor/EThumbnail.h" +#include "editors/ECore/Editor/EThumbnail.h" #include "Scene.h" //--------------------------------------------------------------------------- #pragma package(smart_init) @@ -18,40 +18,45 @@ #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraObject::TfraObject(TComponent* Owner,ESceneObjectTool* parent_tools) - : TForm(Owner) +__fastcall TfraObject::TfraObject(TComponent *Owner, ESceneObjectTool *parent_tools) + : TForm(Owner) { DEFINE_INI(fsStorage); - m_Current = 0; - ParentTools = parent_tools; + m_Current = 0; + ParentTools = parent_tools; } + //--------------------------------------------------------------------------- void TfraObject::OnDrawObjectThumbnail(LPCSTR name, HDC hdc, const Irect &r) { - EObjectThumbnail* thm = xr_new(name); - thm->Draw (hdc,r); - xr_delete (thm); + EObjectThumbnail *thm = xr_new(name); + thm->Draw(hdc, r); + xr_delete(thm); } + //--------------------------------------------------------------------------- -void __fastcall TfraObject::OnItemFocused(ListItemsVec& items) +void __fastcall TfraObject::OnItemFocused(ListItemsVec &items) { - VERIFY(items.size()<=1); - m_Current = 0; - for (ListItemsIt it=items.begin(); it!=items.end(); it++) - m_Current = (*it)->Key(); - ExecCommand (COMMAND_RENDER_FOCUS); + VERIFY(items.size()<=1); + m_Current = 0; + for (ListItemsIt it = items.begin(); it!=items.end(); it++) + m_Current = (*it)->Key(); + ExecCommand(COMMAND_RENDER_FOCUS); } + //------------------------------------------------------------------------------ void __fastcall TfraObject::PaneMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::ExpandClick(TObject *Sender) { PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -60,207 +65,247 @@ void __fastcall TfraObject::ExpandClick(TObject *Sender) void __fastcall TfraObject::ebSelectByRefsClick(TObject *Sender) { - SelByRefObject( true ); + SelByRefObject(true); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::ebDeselectByRefsClick(TObject *Sender) { - SelByRefObject( false ); + SelByRefObject(false); } + //--------------------------------------------------------------------------- -void __fastcall TfraObject::MultiSelByRefObject ( bool clear_prev ) +void __fastcall TfraObject::MultiSelByRefObject(bool clear_prev) { - ObjectList objlist; - LPU32Vec sellist; - if (Scene->GetQueryObjects(objlist,OBJCLASS_SCENEOBJECT,1,1,-1)){ - for (ObjectIt it=objlist.begin(); it!=objlist.end(); it++){ - LPCSTR N = ((CSceneObject*)*it)->RefName(); + ObjectList objlist; + LPU32Vec sellist; + if (Scene->GetQueryObjects(objlist, OBJCLASS_SCENEOBJECT, 1, 1, -1)) + { + for (ObjectIt it = objlist.begin(); it!=objlist.end(); it++) + { + LPCSTR N = ((CSceneObject*)*it)->RefName(); ObjectIt _F = Scene->FirstObj(OBJCLASS_SCENEOBJECT); ObjectIt _E = Scene->LastObj(OBJCLASS_SCENEOBJECT); - for(;_F!=_E;_F++){ - CSceneObject *_O = (CSceneObject *)(*_F); - if((*_F)->Visible()&&_O->RefCompare(N)){ - if (clear_prev){ - _O->Select( false ); - sellist.push_back((u32*)_O); - }else{ - if (!_O->Selected()) - sellist.push_back((u32*)_O); + for (; _F!=_E; _F++) + { + CSceneObject *_O = (CSceneObject *)(*_F); + if ((*_F)->Visible()&&_O->RefCompare(N)) + { + if (clear_prev) + { + _O->Select(false); + sellist.push_back((u32*)_O); + } + else + { + if (!_O->Selected()) + sellist.push_back((u32*)_O); } } } } - std::sort (sellist.begin(),sellist.end()); - sellist.erase (std::unique(sellist.begin(),sellist.end()),sellist.end()); - std::random_shuffle (sellist.begin(),sellist.end()); - int max_k = iFloor(float(sellist.size())/100.f*float(seSelPercent->Value)+0.5f); - int k = 0; - for (LPU32It o_it=sellist.begin(); kValue)+0.5f); + int k = 0; + for (LPU32It o_it = sellist.begin(); kSelect( true ); + _O->Select(true); } } } + //--------------------------------------------------------------------------- -void TfraObject::SelByRefObject( bool flag ) +void TfraObject::SelByRefObject(bool flag) { ObjectList objlist; -// LPCSTR sel_name=0; -// if (Scene->GetQueryObjects(objlist,OBJCLASS_SCENEOBJECT,1,1,-1)) -// sel_name = ((CSceneObject*)objlist.front())->GetRefName(); - LPCSTR N=Current(); -// if (!TfrmChoseItem::SelectItem(TfrmChoseItem::smObject,N,1,sel_name)) return; - if (N){ + // LPCSTR sel_name=0; + // if (Scene->GetQueryObjects(objlist,OBJCLASS_SCENEOBJECT,1,1,-1)) + // sel_name = ((CSceneObject*)objlist.front())->GetRefName(); + LPCSTR N = Current(); + // if (!TfrmChoseItem::SelectItem(TfrmChoseItem::smObject,N,1,sel_name)) return; + if (N) + { ObjectIt _F = Scene->FirstObj(OBJCLASS_SCENEOBJECT); ObjectIt _E = Scene->LastObj(OBJCLASS_SCENEOBJECT); - for(;_F!=_E;_F++){ - if((*_F)->Visible() ){ + for (; _F!=_E; _F++) + { + if ((*_F)->Visible()) + { CSceneObject *_O = (CSceneObject *)(*_F); - if(_O->RefCompare(N)) _O->Select( flag ); + if (_O->RefCompare(N)) + _O->Select(flag); } } } } + //--------------------------------------------------------------------------- void __fastcall TfraObject::ebMultiAppendClick(TObject *Sender) { - LPCSTR N; - if (TfrmChoseItem::SelectItem(smObject,N,32,0)){ - Fvector pos={0.f,0.f,0.f}; - Fvector up={0.f,1.f,0.f}; - Scene->SelectObjects(false,OBJCLASS_SCENEOBJECT); - AStringVec lst; - _SequenceToList(lst,N); - SPBItem* pb = UI->ProgressStart(lst.size(),"Append object: "); - for (AStringIt it=lst.begin(); it!=lst.end(); it++){ + LPCSTR N; + if (TfrmChoseItem::SelectItem(smObject, N, 32, 0)) + { + Fvector pos = {0.f,0.f,0.f}; + Fvector up = {0.f,1.f,0.f}; + Scene->SelectObjects(false, OBJCLASS_SCENEOBJECT); + AStringVec lst; + _SequenceToList(lst, N); + SPBItem *pb = UI->ProgressStart(lst.size(), "Append object: "); + for (AStringIt it = lst.begin(); it!=lst.end(); it++) + { string256 namebuffer; Scene->GenObjectName(OBJCLASS_SCENEOBJECT, namebuffer, it->c_str()); - CSceneObject *obj = xr_new((LPVOID)0,namebuffer); - CEditableObject* ref = obj->SetReference(it->c_str()); - if (!ref){ - ELog.DlgMsg(mtError,"TfraObject:: Can't load reference object."); + CSceneObject *obj = xr_new((LPVOID)0, namebuffer); + CEditableObject *ref = obj->SetReference(it->c_str()); + if (!ref) + { + ELog.DlgMsg(mtError, "TfraObject:: Can't load reference object."); xr_delete(obj); return; } -/* if (ref->IsDynamic()){ - ELog.DlgMsg(mtError,"TfraObject:: Can't assign dynamic object."); - xr_delete(obj); - return; - } -*/ - obj->MoveTo(pos,up); - Scene->AppendObject( obj ); - } + /* if (ref->IsDynamic()){ + ELog.DlgMsg(mtError,"TfraObject:: Can't assign dynamic object."); + xr_delete(obj); + return; + } + */ + obj->MoveTo(pos, up); + Scene->AppendObject(obj); + } UI->ProgressEnd(pb); } } + //--------------------------------------------------------------------------- void __fastcall TfraObject::ebMultiSelectByRefMoveClick(TObject *Sender) { - MultiSelByRefObject(true); + MultiSelByRefObject(true); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::ebMultiSelectByRefAppendClick(TObject *Sender) { - MultiSelByRefObject(false); + MultiSelByRefObject(false); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::seSelPercentKeyPress(TObject *Sender, - char &Key) + char &Key) { - if (Key==VK_RETURN) ExecCommand(COMMAND_RENDER_FOCUS); + if (Key==VK_RETURN) + ExecCommand(COMMAND_RENDER_FOCUS); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::ExtBtn4Click(TObject *Sender) { - if (TfrmChoseItem::SelectItem(smObject,m_Current,1,m_Current)){ - m_Items->SelectItem (m_Current,true,false,true); -//.. RefreshList (); + if (TfrmChoseItem::SelectItem(smObject, m_Current, 1, m_Current)) + { + m_Items->SelectItem(m_Current, true, false, true); + //.. RefreshList (); } } + //--------------------------------------------------------------------------- void __fastcall TfraObject::paCurrentObjectResize(TObject *Sender) { - if (m_Current) m_Items->SelectItem(m_Current,true,false,true); + if (m_Current) + m_Items->SelectItem(m_Current, true, false, true); } + //--------------------------------------------------------------------------- void TfraObject::RefreshList() { ListItemsVec items; FS_FileSet lst; - if (Lib.GetObjects(lst)){ - FS_FileSetIt it = lst.begin(); - FS_FileSetIt _E = lst.end(); - for (; it!=_E; it++){ + if (Lib.GetObjects(lst)) + { + FS_FileSetIt it = lst.begin(); + FS_FileSetIt _E = lst.end(); + for (; it!=_E; it++) + { xr_string fn; - ListItem* I=LHelper().CreateItem(items,it->name.c_str(),0,ListItem::flDrawThumbnail,0); - if (I->m_Flags.is(ListItem::flDrawThumbnail)) I->OnDrawThumbnail.bind(this,&TfraObject::OnDrawObjectThumbnail); + ListItem *I = LHelper().CreateItem(items, it->name.c_str(), 0, ListItem::flDrawThumbnail, 0); + if (I->m_Flags.is(ListItem::flDrawThumbnail)) + I->OnDrawThumbnail.bind(this, &TfraObject::OnDrawObjectThumbnail); } } - m_Items->AssignItems (items,false,true); + m_Items->AssignItems(items, false, true); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::FormShow(TObject *Sender) { - m_Items->LoadSelection (fsStorage); - m_Items->LoadParams (fsStorage); + m_Items->LoadSelection(fsStorage); + m_Items->LoadParams(fsStorage); -//..RefreshList (); + //..RefreshList (); - ebRandomAppendMode->Down= ParentTools->IsAppendRandomActive(); + ebRandomAppendMode->Down = ParentTools->IsAppendRandomActive(); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::FormHide(TObject *Sender) { - m_Items->SaveSelection (fsStorage); - m_Items->SaveParams (fsStorage); + m_Items->SaveSelection(fsStorage); + m_Items->SaveParams(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::FormCreate(TObject *Sender) { - m_Items = TItemList::CreateForm("Objects", paItems, alClient, 0); - m_Items->SetOnItemsFocusedEvent(TOnILItemsFocused(this,&TfraObject::OnItemFocused)); - // fill list - RefreshList (); + m_Items = TItemList::CreateForm("Objects", paItems, alClient, 0); + m_Items->SetOnItemsFocusedEvent(TOnILItemsFocused(this, &TfraObject::OnItemFocused)); + // fill list + RefreshList(); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::FormDestroy(TObject *Sender) { - TItemList::DestroyForm (m_Items); + TItemList::DestroyForm(m_Items); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::ebRandomAppendModeClick(TObject *Sender) { ParentTools->ActivateAppendRandom(ebRandomAppendMode->Down); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::ExtBtn8Click(TObject *Sender) { ParentTools->FillAppendRandomProperties(); } + //--------------------------------------------------------------------------- void __fastcall TfraObject::ExtBtn9Click(TObject *Sender) { - RefreshList(); + RefreshList(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/FrameObject.h b/src/editors/LevelEditor/FrameObject.h index 3935c33f46a..65abb522278 100644 --- a/src/editors/LevelEditor/FrameObject.h +++ b/src/editors/LevelEditor/FrameObject.h @@ -18,75 +18,82 @@ // refs class CEditableObject; class ESceneObjectTool; + //--------------------------------------------------------------------------- class TfraObject : public TForm { -__published: // IDE-managed Components - TFormStorage *fsStorage; - TLabel *Label5; - TExtBtn *ebSelectByRefs; - TExtBtn *ebDeselectByRefs; - TExtBtn *ebMultiSelectByRefMove; - TBevel *Bevel1; - TLabel *Label2; - TExtBtn *ebMultiSelectByRefAppend; - TLabel *Label3; - TPanel *paSelectObject; - TLabel *Label1; - TExtBtn *ExtBtn1; - TExtBtn *ExtBtn3; - TLabel *APHeadLabel3; - TExtBtn *ExtBtn5; - TExtBtn *ExtBtn6; - TBevel *Bevel3; - TLabel *Label4; - TExtBtn *ExtBtn7; - TLabel *Label6; - TPanel *paCommands; - TExtBtn *ebMultiAppend; - TLabel *APHeadLabel1; - TExtBtn *ExtBtn2; - TBevel *Bevel4; - TExtBtn *ebRandomAppendMode; - TExtBtn *ExtBtn8; - TPanel *paCurrentObject; - TLabel *APHeadLabel2; - TBevel *Bevel2; - TPanel *paItems; - TPanel *Panel1; - TExtBtn *ExtBtn4; - TMultiObjSpinEdit *seSelPercent; - TExtBtn *ExtBtn9; + __published: // IDE-managed Components + TFormStorage*fsStorage; + TLabel *Label5; + TExtBtn *ebSelectByRefs; + TExtBtn *ebDeselectByRefs; + TExtBtn *ebMultiSelectByRefMove; + TBevel *Bevel1; + TLabel *Label2; + TExtBtn *ebMultiSelectByRefAppend; + TLabel *Label3; + TPanel *paSelectObject; + TLabel *Label1; + TExtBtn *ExtBtn1; + TExtBtn *ExtBtn3; + TLabel *APHeadLabel3; + TExtBtn *ExtBtn5; + TExtBtn *ExtBtn6; + TBevel *Bevel3; + TLabel *Label4; + TExtBtn *ExtBtn7; + TLabel *Label6; + TPanel *paCommands; + TExtBtn *ebMultiAppend; + TLabel *APHeadLabel1; + TExtBtn *ExtBtn2; + TBevel *Bevel4; + TExtBtn *ebRandomAppendMode; + TExtBtn *ExtBtn8; + TPanel *paCurrentObject; + TLabel *APHeadLabel2; + TBevel *Bevel2; + TPanel *paItems; + TPanel *Panel1; + TExtBtn *ExtBtn4; + TMultiObjSpinEdit *seSelPercent; + TExtBtn *ExtBtn9; void __fastcall PaneMinClick(TObject *Sender); void __fastcall ebSelectByRefsClick(TObject *Sender); void __fastcall ebDeselectByRefsClick(TObject *Sender); void __fastcall ExpandClick(TObject *Sender); - void __fastcall ebMultiAppendClick(TObject *Sender); - void __fastcall ebMultiSelectByRefMoveClick(TObject *Sender); - void __fastcall ebMultiSelectByRefAppendClick(TObject *Sender); - void __fastcall seSelPercentKeyPress(TObject *Sender, char &Key); - void __fastcall ExtBtn4Click(TObject *Sender); - void __fastcall paCurrentObjectResize(TObject *Sender); - void __fastcall FormShow(TObject *Sender); - void __fastcall FormHide(TObject *Sender); - void __fastcall FormCreate(TObject *Sender); - void __fastcall FormDestroy(TObject *Sender); - void __fastcall ebRandomAppendModeClick(TObject *Sender); - void __fastcall ExtBtn8Click(TObject *Sender); - void __fastcall ExtBtn9Click(TObject *Sender); -private: // User declarations - void __fastcall MultiSelByRefObject ( bool clear_prev ); - void __fastcall SelByRefObject ( bool flag ); - TItemList* m_Items; - void __stdcall OnItemFocused (ListItemsVec& items); + void __fastcall ebMultiAppendClick(TObject *Sender); + void __fastcall ebMultiSelectByRefMoveClick(TObject *Sender); + void __fastcall ebMultiSelectByRefAppendClick(TObject *Sender); + void __fastcall seSelPercentKeyPress(TObject *Sender, char &Key); + void __fastcall ExtBtn4Click(TObject *Sender); + void __fastcall paCurrentObjectResize(TObject *Sender); + void __fastcall FormShow(TObject *Sender); + void __fastcall FormHide(TObject *Sender); + void __fastcall FormCreate(TObject *Sender); + void __fastcall FormDestroy(TObject *Sender); + void __fastcall ebRandomAppendModeClick(TObject *Sender); + void __fastcall ExtBtn8Click(TObject *Sender); + void __fastcall ExtBtn9Click(TObject *Sender); +private: // User declarations + void __fastcall MultiSelByRefObject(bool clear_prev); + void __fastcall SelByRefObject(bool flag); + TItemList *m_Items; + void __stdcall OnItemFocused(ListItemsVec &items); LPCSTR m_Current; - void __stdcall OnDrawObjectThumbnail(LPCSTR name, HDC hdc, const Irect &R); -public: // User declarations - ESceneObjectTool* ParentTools; - void RefreshList(); -public: // User declarations - __fastcall TfraObject(TComponent* Owner,ESceneObjectTool* parent_tools); - LPCSTR Current (){return m_Current;} + void __stdcall OnDrawObjectThumbnail(LPCSTR name, HDC hdc, const Irect &R); +public: // User declarations + ESceneObjectTool *ParentTools; + void RefreshList(); +public: // User declarations + __fastcall TfraObject(TComponent *Owner, ESceneObjectTool *parent_tools); + + LPCSTR Current() + { + return m_Current; + } }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FramePS.cpp b/src/editors/LevelEditor/FramePS.cpp index 99ea7837bd9..b5061d71a91 100644 --- a/src/editors/LevelEditor/FramePS.cpp +++ b/src/editors/LevelEditor/FramePS.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #pragma hdrstop -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "FramePS.h" #include "..\..\Layers\xrRender\PSLibrary.h" #include "Scene.h" @@ -13,32 +13,36 @@ #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraPS::TfraPS(TComponent* Owner) - : TForm(Owner) +__fastcall TfraPS::TfraPS(TComponent *Owner) + : TForm(Owner) { DEFINE_INI(fsStorage); m_Current = 0; } + //--------------------------------------------------------------------------- -void TfraPS::OnItemFocused(ListItemsVec& items) +void TfraPS::OnItemFocused(ListItemsVec &items) { - VERIFY(items.size()<=1); - m_Current = 0; - for (ListItemsIt it=items.begin(); it!=items.end(); it++) - m_Current = (*it)->Key(); - ExecCommand (COMMAND_RENDER_FOCUS); + VERIFY(items.size()<=1); + m_Current = 0; + for (ListItemsIt it = items.begin(); it!=items.end(); it++) + m_Current = (*it)->Key(); + ExecCommand(COMMAND_RENDER_FOCUS); } + //------------------------------------------------------------------------------ void __fastcall TfraPS::PaneMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraPS::ExpandClick(TObject *Sender) { PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -46,85 +50,102 @@ void __fastcall TfraPS::ExpandClick(TObject *Sender) //--------------------------------------------------------------------------- void __fastcall TfraPS::ebSelectByRefsClick(TObject *Sender) { - SelByRef( true ); + SelByRef(true); } + //--------------------------------------------------------------------------- void __fastcall TfraPS::ebDeselectByRefsClick(TObject *Sender) { - SelByRef( false ); + SelByRef(false); } - -void __fastcall TfraPS::SelByRef( bool flag ) + +void __fastcall TfraPS::SelByRef(bool flag) { - if(m_Current){ - ObjectIt _F = Scene->FirstObj(OBJCLASS_PS); + if (m_Current) + { + ObjectIt _F = Scene->FirstObj(OBJCLASS_PS); ObjectIt _E = Scene->LastObj(OBJCLASS_PS); - for(;_F!=_E;_F++){ - if( (*_F)->Visible() ){ - EParticlesObject *_O = (EParticlesObject *)(*_F); - if(_O->RefCompare(m_Current)) _O->Select( flag ); - } - } - } + for (; _F!=_E; _F++) + { + if ((*_F)->Visible()) + { + EParticlesObject *_O = (EParticlesObject *)(*_F); + if (_O->RefCompare(m_Current)) + _O->Select(flag); + } + } + } } + //--------------------------------------------------------------------------- void __fastcall TfraPS::ebCurrentPSPlayClick(TObject *Sender) { ObjectIt _F = Scene->FirstObj(OBJCLASS_PS); ObjectIt _E = Scene->LastObj(OBJCLASS_PS); - for(;_F!=_E;_F++){ - if( (*_F)->Visible() && (*_F)->Selected()) + for (; _F!=_E; _F++) + { + if ((*_F)->Visible()&&(*_F)->Selected()) ((EParticlesObject *)(*_F))->Play(); } } + //--------------------------------------------------------------------------- void __fastcall TfraPS::ebCurrentPSStopClick(TObject *Sender) { ObjectIt _F = Scene->FirstObj(OBJCLASS_PS); ObjectIt _E = Scene->LastObj(OBJCLASS_PS); - for(;_F!=_E;_F++){ - if( (*_F)->Visible() && (*_F)->Selected()) + for (; _F!=_E; _F++) + { + if ((*_F)->Visible()&&(*_F)->Selected()) ((EParticlesObject *)(*_F))->Stop(); } } + //--------------------------------------------------------------------------- void __fastcall TfraPS::FormHide(TObject *Sender) { - m_Items->SaveSelection (fsStorage); + m_Items->SaveSelection(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraPS::FormShow(TObject *Sender) { - m_Items->LoadSelection (fsStorage); + m_Items->LoadSelection(fsStorage); ListItemsVec items; - for (PS::PEDIt E=::Render->PSLibrary.FirstPED(); E!=::Render->PSLibrary.LastPED(); E++){ - ListItem* I=LHelper().CreateItem(items,*(*E)->m_Name,0,0,*E); + for (PS::PEDIt E = ::Render->PSLibrary.FirstPED(); E!=::Render->PSLibrary.LastPED(); E++) + { + ListItem *I = LHelper().CreateItem(items, *(*E)->m_Name, 0, 0, *E); I->SetIcon(1); } - for (PS::PGDIt G=::Render->PSLibrary.FirstPGD(); G!=::Render->PSLibrary.LastPGD(); G++){ - ListItem* I=LHelper().CreateItem(items,*(*G)->m_Name,0,0,*G); + for (PS::PGDIt G = ::Render->PSLibrary.FirstPGD(); G!=::Render->PSLibrary.LastPGD(); G++) + { + ListItem *I = LHelper().CreateItem(items, *(*G)->m_Name, 0, 0, *G); I->SetIcon(2); } - m_Items->AssignItems (items,false,true); + m_Items->AssignItems(items, false, true); } + //--------------------------------------------------------------------------- void __fastcall TfraPS::FormCreate(TObject *Sender) { - m_Items = TItemList::CreateForm("Particles",paItems, alClient, 0); - m_Items->SetImages (ilModeIcons); - m_Items->SetOnItemsFocusedEvent(TOnILItemsFocused(this,&TfraPS::OnItemFocused)); + m_Items = TItemList::CreateForm("Particles", paItems, alClient, 0); + m_Items->SetImages(ilModeIcons); + m_Items->SetOnItemsFocusedEvent(TOnILItemsFocused(this, &TfraPS::OnItemFocused)); } + //--------------------------------------------------------------------------- void __fastcall TfraPS::FormDestroy(TObject *Sender) { - TItemList::DestroyForm (m_Items); + TItemList::DestroyForm(m_Items); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/FramePS.h b/src/editors/LevelEditor/FramePS.h index 3d044fc064c..dd7f2237786 100644 --- a/src/editors/LevelEditor/FramePS.h +++ b/src/editors/LevelEditor/FramePS.h @@ -15,43 +15,50 @@ #include "ESceneCustomMTools.h" // refs class CEditObject; + //--------------------------------------------------------------------------- class TfraPS : public TForm { -__published: // IDE-managed Components - TPanel *paSelectObject; + __published: // IDE-managed Components + TPanel*paSelectObject; TLabel *Label5; - TExtBtn *ebSelectByRefs; - TExtBtn *ebDeselectByRefs; - TLabel *Label; - TExtBtn *ExtBtn3; - TPanel *Panel1; - TLabel *APHeadLabel2; - TExtBtn *ebCurrentPSPlay; - TExtBtn *ebCurrentPSStop; - TLabel *Label1; - TPanel *paItems; - TFormStorage *fsStorage; - TImageList *ilModeIcons; - TBevel *Bevel1; + TExtBtn *ebSelectByRefs; + TExtBtn *ebDeselectByRefs; + TLabel *Label; + TExtBtn *ExtBtn3; + TPanel *Panel1; + TLabel *APHeadLabel2; + TExtBtn *ebCurrentPSPlay; + TExtBtn *ebCurrentPSStop; + TLabel *Label1; + TPanel *paItems; + TFormStorage *fsStorage; + TImageList *ilModeIcons; + TBevel *Bevel1; void __fastcall PaneMinClick(TObject *Sender); void __fastcall ebSelectByRefsClick(TObject *Sender); void __fastcall ebDeselectByRefsClick(TObject *Sender); void __fastcall ExpandClick(TObject *Sender); - void __fastcall ebCurrentPSPlayClick(TObject *Sender); - void __fastcall ebCurrentPSStopClick(TObject *Sender); - void __fastcall FormHide(TObject *Sender); - void __fastcall FormShow(TObject *Sender); - void __fastcall FormCreate(TObject *Sender); - void __fastcall FormDestroy(TObject *Sender); -private: // User declarations - void __fastcall SelByRef (bool flag); - TItemList* m_Items; - void __stdcall OnItemFocused (ListItemsVec& items); + void __fastcall ebCurrentPSPlayClick(TObject *Sender); + void __fastcall ebCurrentPSStopClick(TObject *Sender); + void __fastcall FormHide(TObject *Sender); + void __fastcall FormShow(TObject *Sender); + void __fastcall FormCreate(TObject *Sender); + void __fastcall FormDestroy(TObject *Sender); +private: // User declarations + void __fastcall SelByRef(bool flag); + TItemList *m_Items; + void __stdcall OnItemFocused(ListItemsVec &items); LPCSTR m_Current; -public: // User declarations - __fastcall TfraPS (TComponent* Owner); - LPCSTR Current (){return m_Current;} +public: // User declarations + __fastcall TfraPS(TComponent *Owner); + + LPCSTR Current() + { + return m_Current; + } }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FramePortal.cpp b/src/editors/LevelEditor/FramePortal.cpp index 06f91ec09cd..1deb12089db 100644 --- a/src/editors/LevelEditor/FramePortal.cpp +++ b/src/editors/LevelEditor/FramePortal.cpp @@ -4,7 +4,7 @@ #include "FramePortal.h" #include "scene.h" #include "portal.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "sector.h" #include "portalutils.h" #include "EScenePortalTools.h" @@ -14,57 +14,67 @@ #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraPortal::TfraPortal(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfraPortal::TfraPortal(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TfraPortal::PanelMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraPortal::TopClick(TObject *Sender) { PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraPortal::ebComputeAllPortalsClick(TObject *Sender) { - if (mrYes==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Are you sure want to destroy all existing portals and compute them again?")) + if (mrYes==ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<GetQueryObjects(lst,OBJCLASS_PORTAL,1,1,0)){ - for (ObjectIt it=lst.begin(); it!=lst.end(); it++){ - CPortal* _O = (CPortal*)*it; - _O->InvertOrientation(true); + ObjectList lst; + if (Scene->GetQueryObjects(lst, OBJCLASS_PORTAL, 1, 1, 0)) + { + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + { + CPortal *_O = (CPortal*)*it; + _O->InvertOrientation(true); } } } + //--------------------------------------------------------------------------- void __fastcall TfraPortal::ExtBtn1Click(TObject *Sender) { - tool->RemoveSimilar(); + tool->RemoveSimilar(); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/FrameSector.cpp b/src/editors/LevelEditor/FrameSector.cpp index 72f30b5126e..3928999c911 100644 --- a/src/editors/LevelEditor/FrameSector.cpp +++ b/src/editors/LevelEditor/FrameSector.cpp @@ -4,7 +4,7 @@ #include "FrameSector.h" #include "scene.h" #include "sector.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" #include "portal.h" #include "portalutils.h" //--------------------------------------------------------------------------- @@ -13,68 +13,82 @@ #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraSector::TfraSector(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfraSector::TfraSector(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TfraSector::PanelMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraSector::TopClick(TObject *Sender) { - PanelMaximizeClick(Sender); + PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraSector::ebCaptureInsideVolumeClick(TObject *Sender) { - CSector* S = PortalUtils.GetSelectedSector(); - if (S){ - S->CaptureInsideVolume(); + CSector *S = PortalUtils.GetSelectedSector(); + if (S) + { + S->CaptureInsideVolume(); Scene->UndoSave(); } } + //--------------------------------------------------------------------------- void __fastcall TfraSector::ebDistributeObjectsClick(TObject *Sender) { - CSector* S = PortalUtils.GetSelectedSector(); - if (S){ - S->DistributeInsideObjects (); - Scene->UndoSave (); + CSector *S = PortalUtils.GetSelectedSector(); + if (S) + { + S->DistributeInsideObjects(); + Scene->UndoSave(); } } + //--------------------------------------------------------------------------- void __fastcall TfraSector::ebCreateDefaultClick(TObject *Sender) { - CCustomObject* O=Scene->FindObjectByName(DEFAULT_SECTOR_NAME,OBJCLASS_SECTOR); - if (O) ELog.DlgMsg(mtInformation,"Default sector already present. Remove this and try again."); - else{ - if (!PortalUtils.CreateDefaultSector()) ELog.DlgMsg(mtInformation,"Default can't created."); + CCustomObject *O = Scene->FindObjectByName(DEFAULT_SECTOR_NAME, OBJCLASS_SECTOR); + if (O) + ELog.DlgMsg(mtInformation, "Default sector already present. Remove this and try again."); + else + { + if (!PortalUtils.CreateDefaultSector()) + ELog.DlgMsg(mtInformation, "Default can't created."); } } + //--------------------------------------------------------------------------- void __fastcall TfraSector::ebRemoveDefaultClick(TObject *Sender) { - if (!PortalUtils.RemoveDefaultSector()) ELog.DlgMsg(mtInformation,"Default sector not found."); + if (!PortalUtils.RemoveDefaultSector()) + ELog.DlgMsg(mtInformation, "Default sector not found."); } + //--------------------------------------------------------------------------- void __fastcall TfraSector::ebValidateClick(TObject *Sender) { - PortalUtils.Validate(true); + PortalUtils.Validate(true); } + //--------------------------------------------------------------------------- void __fastcall TfraSector::ebBoxPickClick(TObject *Sender) { - if (ebCreateNewSingle->Down || ebCreateNewMultiple->Down) ebBoxPick->Down = false; + if (ebCreateNewSingle->Down||ebCreateNewMultiple->Down) + ebBoxPick->Down = false; } + //--------------------------------------------------------------------------- diff --git a/src/editors/LevelEditor/FrameShape.cpp b/src/editors/LevelEditor/FrameShape.cpp index de626c259a1..4b6ca4ac9d0 100644 --- a/src/editors/LevelEditor/FrameShape.cpp +++ b/src/editors/LevelEditor/FrameShape.cpp @@ -2,67 +2,75 @@ #pragma hdrstop #include "FrameShape.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "scene.h" #include "EShape.h" #include "ESceneShapeTools.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraShape::TfraShape(TComponent* Owner) - : TForm(Owner) +__fastcall TfraShape::TfraShape(TComponent *Owner) + : TForm(Owner) { DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraShape::PaneMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraShape::ExpandClick(TObject *Sender) { PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraShape::ebDetachAllShapesClick(TObject *Sender) { ObjectList lst; - if (Scene->GetQueryObjects(lst,OBJCLASS_SHAPE,1,1,0)){ - Scene->SelectObjects(false,OBJCLASS_SHAPE); - for (ObjectIt it=lst.begin(); it!=lst.end(); it++) - ((CEditShape*)*it)->Detach(); + if (Scene->GetQueryObjects(lst, OBJCLASS_SHAPE, 1, 1, 0)) + { + Scene->SelectObjects(false, OBJCLASS_SHAPE); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + ((CEditShape*)*it)->Detach(); } } + //--------------------------------------------------------------------------- void __fastcall TfraShape::ebAttachShapeClick(TObject *Sender) { - if (ebAttachShape->Down) ExecCommand(COMMAND_CHANGE_ACTION, etaAdd); + if (ebAttachShape->Down) + ExecCommand(COMMAND_CHANGE_ACTION, etaAdd); } -//--------------------------------------------------------------------------- - +//--------------------------------------------------------------------------- void __fastcall TfraShape::ebEditLevelBoundModeClick(TObject *Sender) { - ebRecalcLB->Enabled = ebEditLevelBoundMode->Down; - if(ebEditLevelBoundMode->Down) + ebRecalcLB->Enabled = ebEditLevelBoundMode->Down; + if (ebEditLevelBoundMode->Down) { - tool->OnEditLevelBounds(false); + tool->OnEditLevelBounds(false); } } + //--------------------------------------------------------------------------- void __fastcall TfraShape::ebRecalcLBClick(TObject *Sender) { - tool->OnEditLevelBounds(true); + tool->OnEditLevelBounds(true); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/FrameSpawn.cpp b/src/editors/LevelEditor/FrameSpawn.cpp index 2ad13e51ad4..647d38346eb 100644 --- a/src/editors/LevelEditor/FrameSpawn.cpp +++ b/src/editors/LevelEditor/FrameSpawn.cpp @@ -1,200 +1,236 @@ #include "stdafx.h" #pragma hdrstop -#include "ui_leveltools.h" -#include "../ECore/Editor/ui_main.h" +#include "UI_LevelTools.h" +#include "editors/ECore/Editor/ui_main.h" #include "FrameSpawn.h" #include "Scene.h" #include "SpawnPoint.h" -#include "../ECore/Editor/EThumbnail.h" +#include "editors/ECore/Editor/EThumbnail.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraSpawn::TfraSpawn(TComponent* Owner) - : TForm(Owner) +__fastcall TfraSpawn::TfraSpawn(TComponent *Owner) + : TForm(Owner) { DEFINE_INI(fsStorage); m_Current = 0; } + //--------------------------------------------------------------------------- -void TfraSpawn::OnItemFocused(ListItemsVec& items) +void TfraSpawn::OnItemFocused(ListItemsVec &items) { - VERIFY(items.size()<=1); - m_Current = 0; - for (ListItemsIt it=items.begin(); it!=items.end(); it++) - m_Current = (LPCSTR)(*it)->m_Object; - ExecCommand (COMMAND_RENDER_FOCUS); + VERIFY(items.size()<=1); + m_Current = 0; + for (ListItemsIt it = items.begin(); it!=items.end(); it++) + m_Current = (LPCSTR)(*it)->m_Object; + ExecCommand(COMMAND_RENDER_FOCUS); } + //------------------------------------------------------------------------------ void __fastcall TfraSpawn::PaneMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::ExpandClick(TObject *Sender) { PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::ebAttachObjectClick(TObject *Sender) { - if (ebAttachObject->Down) ExecCommand(COMMAND_CHANGE_ACTION, etaAdd); + if (ebAttachObject->Down) + ExecCommand(COMMAND_CHANGE_ACTION, etaAdd); } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::evDetachObjectClick(TObject *Sender) { ObjectList lst; - if (Scene->GetQueryObjects(lst,OBJCLASS_SPAWNPOINT,1,1,0)){ - for (ObjectIt it=lst.begin(); it!=lst.end(); it++){ - CSpawnPoint* O = dynamic_cast(*it); R_ASSERT(O); - O->DetachObject(); + if (Scene->GetQueryObjects(lst, OBJCLASS_SPAWNPOINT, 1, 1, 0)) + { + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + { + CSpawnPoint *O = dynamic_cast(*it); + R_ASSERT(O); + O->DetachObject(); } } } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::FormHide(TObject *Sender) { - m_Items->SaveSelection (fsStorage); + m_Items->SaveSelection(fsStorage); } + //--------------------------------------------------------------------------- void TfraSpawn::OnDrawObjectThumbnail(LPCSTR name, HDC hdc, const Irect &r) { - const shared_str& sect = m_caption_to_sect[name]; - if(pSettings->line_exist(sect, "visual")) + const shared_str § = m_caption_to_sect[name]; + if (pSettings->line_exist(sect, "visual")) { - const shared_str& visual = pSettings->r_string(sect,"visual"); - EObjectThumbnail* thm = xr_new(visual.c_str()); - thm->Draw (hdc,r); - xr_delete (thm); + const shared_str &visual = pSettings->r_string(sect, "visual"); + EObjectThumbnail *thm = xr_new(visual.c_str()); + thm->Draw(hdc, r); + xr_delete(thm); } } void __fastcall TfraSpawn::FormShow(TObject *Sender) { - m_caption_to_sect.clear(); - m_Items->LoadSelection (fsStorage); + m_caption_to_sect.clear(); + m_Items->LoadSelection(fsStorage); ListItemsVec items; - LHelper().CreateItem (items,RPOINT_CHOOSE_NAME,0,0,RPOINT_CHOOSE_NAME); - LHelper().CreateItem (items,ENVMOD_CHOOSE_NAME,0,0,ENVMOD_CHOOSE_NAME); - CInifile::Root& data = pSettings->sections(); - for (CInifile::RootIt it=data.begin(); it!=data.end(); it++){ - LPCSTR val; - if ((*it)->line_exist("$spawn",&val)) + LHelper().CreateItem(items, RPOINT_CHOOSE_NAME, 0, 0, RPOINT_CHOOSE_NAME); + LHelper().CreateItem(items, ENVMOD_CHOOSE_NAME, 0, 0, ENVMOD_CHOOSE_NAME); + CInifile::Root &data = pSettings->sections(); + for (CInifile::RootIt it = data.begin(); it!=data.end(); it++) + { + LPCSTR val; + if ((*it)->line_exist("$spawn", &val)) { - shared_str caption = pSettings->r_string_wb((*it)->Name,"$spawn"); - shared_str sect = (*it)->Name; + shared_str caption = pSettings->r_string_wb((*it)->Name, "$spawn"); + shared_str sect = (*it)->Name; if (caption.size()) { - ListItem* I = LHelper().CreateItem(items,caption.c_str(),0,ListItem::flDrawThumbnail,(LPVOID)*(*it)->Name); + ListItem *I = LHelper().CreateItem(items, caption.c_str(), 0, ListItem::flDrawThumbnail, (LPVOID)*(*it)->Name); m_caption_to_sect[caption] = sect; - if (I->m_Flags.is(ListItem::flDrawThumbnail)) - I->OnDrawThumbnail.bind(this,&TfraSpawn::OnDrawObjectThumbnail); + if (I->m_Flags.is(ListItem::flDrawThumbnail)) + I->OnDrawThumbnail.bind(this, &TfraSpawn::OnDrawObjectThumbnail); } } } - m_Items->AssignItems (items,false,true); + m_Items->AssignItems(items, false, true); } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::FormCreate(TObject *Sender) { - m_Items = TItemList::CreateForm("Spawns",paItems, alClient, 0); - m_Items->SetOnItemsFocusedEvent(TOnILItemsFocused(this,&TfraSpawn::OnItemFocused)); + m_Items = TItemList::CreateForm("Spawns", paItems, alClient, 0); + m_Items->SetOnItemsFocusedEvent(TOnILItemsFocused(this, &TfraSpawn::OnItemFocused)); } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::FormDestroy(TObject *Sender) { - TItemList::DestroyForm (m_Items); + TItemList::DestroyForm(m_Items); } + //--------------------------------------------------------------------------- -void TfraSpawn::SelByRefObject( bool flag ) +void TfraSpawn::SelByRefObject(bool flag) { ObjectList objlist; - LPCSTR N=Current(); - if (N){ + LPCSTR N = Current(); + if (N) + { ObjectIt _F = Scene->FirstObj(OBJCLASS_SPAWNPOINT); ObjectIt _E = Scene->LastObj(OBJCLASS_SPAWNPOINT); - for(;_F!=_E;_F++){ - if((*_F)->Visible() ){ + for (; _F!=_E; _F++) + { + if ((*_F)->Visible()) + { CSpawnPoint *_O = (CSpawnPoint*)(*_F); - if(_O->RefCompare(N)) _O->Select( flag ); + if (_O->RefCompare(N)) + _O->Select(flag); } } } } + //--------------------------------------------------------------------------- -void TfraSpawn::MultiSelByRefObject ( bool clear_prev ) +void TfraSpawn::MultiSelByRefObject(bool clear_prev) { - ObjectList objlist; - LPU32Vec sellist; - if (Scene->GetQueryObjects(objlist,OBJCLASS_SPAWNPOINT,1,1,-1)){ - for (ObjectIt it=objlist.begin(); it!=objlist.end(); it++){ - LPCSTR N = ((CSpawnPoint*)*it)->RefName(); + ObjectList objlist; + LPU32Vec sellist; + if (Scene->GetQueryObjects(objlist, OBJCLASS_SPAWNPOINT, 1, 1, -1)) + { + for (ObjectIt it = objlist.begin(); it!=objlist.end(); it++) + { + LPCSTR N = ((CSpawnPoint*)*it)->RefName(); ObjectIt _F = Scene->FirstObj(OBJCLASS_SPAWNPOINT); ObjectIt _E = Scene->LastObj(OBJCLASS_SPAWNPOINT); - for(;_F!=_E;_F++){ - CSpawnPoint *_O = (CSpawnPoint *)(*_F); - if((*_F)->Visible()&&_O->RefCompare(N)){ - if (clear_prev){ - _O->Select( false ); - sellist.push_back((u32*)_O); - }else{ - if (!_O->Selected()) - sellist.push_back((u32*)_O); + for (; _F!=_E; _F++) + { + CSpawnPoint *_O = (CSpawnPoint *)(*_F); + if ((*_F)->Visible()&&_O->RefCompare(N)) + { + if (clear_prev) + { + _O->Select(false); + sellist.push_back((u32*)_O); + } + else + { + if (!_O->Selected()) + sellist.push_back((u32*)_O); } } } } - std::sort (sellist.begin(),sellist.end()); - sellist.erase (std::unique(sellist.begin(),sellist.end()),sellist.end()); - std::random_shuffle (sellist.begin(),sellist.end()); - int max_k = iFloor(float(sellist.size())/100.f*float(seSelPercent->Value)+0.5f); - int k = 0; - for (LPU32It o_it=sellist.begin(); kValue)+0.5f); + int k = 0; + for (LPU32It o_it = sellist.begin(); kSelect( true ); + _O->Select(true); } } } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::ebSelectByRefsClick(TObject *Sender) { - SelByRefObject( true ); + SelByRefObject(true); } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::ebDeselectByRefsClick(TObject *Sender) { - SelByRefObject( false ); + SelByRefObject(false); } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::ebMultiSelectByRefMoveClick(TObject *Sender) { - MultiSelByRefObject(true); + MultiSelByRefObject(true); } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::ebMultiSelectByRefAppendClick(TObject *Sender) { - MultiSelByRefObject(false); + MultiSelByRefObject(false); } + //--------------------------------------------------------------------------- void __fastcall TfraSpawn::seSelPercentKeyPress(TObject *Sender, char &Key) { - if (Key==VK_RETURN) ExecCommand(COMMAND_RENDER_FOCUS); + if (Key==VK_RETURN) + ExecCommand(COMMAND_RENDER_FOCUS); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/FrameSpawn.h b/src/editors/LevelEditor/FrameSpawn.h index eb46e4f3d38..4ef16bd29d3 100644 --- a/src/editors/LevelEditor/FrameSpawn.h +++ b/src/editors/LevelEditor/FrameSpawn.h @@ -17,56 +17,63 @@ #include "ESceneCustomMTools.h" // refs class CEditObject; + //--------------------------------------------------------------------------- class TfraSpawn : public TForm { -__published: // IDE-managed Components - TPanel *paCurrent; - TLabel *APHeadLabel1; - TFormStorage *fsStorage; - TPanel *paCommands; - TLabel *Label1; - TExtBtn *ExtBtn1; - TExtBtn *ebAttachObject; - TExtBtn *evDetachObject; - TPanel *paItems; - TBevel *Bevel1; - TPanel *paSelectObject; - TLabel *Label5; - TExtBtn *ebSelectByRefs; - TExtBtn *ebDeselectByRefs; - TLabel *APHeadLabel3; - TExtBtn *ExtBtn3; - TExtBtn *ebMultiSelectByRefMove; - TBevel *Bevel2; - TLabel *Label2; - TExtBtn *ebMultiSelectByRefAppend; - TMultiObjSpinEdit *seSelPercent; - TLabel *Label3; + __published: // IDE-managed Components + TPanel*paCurrent; + TLabel *APHeadLabel1; + TFormStorage *fsStorage; + TPanel *paCommands; + TLabel *Label1; + TExtBtn *ExtBtn1; + TExtBtn *ebAttachObject; + TExtBtn *evDetachObject; + TPanel *paItems; + TBevel *Bevel1; + TPanel *paSelectObject; + TLabel *Label5; + TExtBtn *ebSelectByRefs; + TExtBtn *ebDeselectByRefs; + TLabel *APHeadLabel3; + TExtBtn *ExtBtn3; + TExtBtn *ebMultiSelectByRefMove; + TBevel *Bevel2; + TLabel *Label2; + TExtBtn *ebMultiSelectByRefAppend; + TMultiObjSpinEdit *seSelPercent; + TLabel *Label3; void __fastcall PaneMinClick(TObject *Sender); void __fastcall ExpandClick(TObject *Sender); - void __fastcall ebAttachObjectClick(TObject *Sender); - void __fastcall evDetachObjectClick(TObject *Sender); - void __fastcall FormHide(TObject *Sender); - void __fastcall FormShow(TObject *Sender); - void __fastcall FormCreate(TObject *Sender); - void __fastcall FormDestroy(TObject *Sender); - void __fastcall ebSelectByRefsClick(TObject *Sender); - void __fastcall ebDeselectByRefsClick(TObject *Sender); - void __fastcall ebMultiSelectByRefMoveClick(TObject *Sender); - void __fastcall ebMultiSelectByRefAppendClick(TObject *Sender); - void __fastcall seSelPercentKeyPress(TObject *Sender, char &Key); -private: // User declarations - TItemList* m_Items; - void __stdcall OnItemFocused (ListItemsVec& items); + void __fastcall ebAttachObjectClick(TObject *Sender); + void __fastcall evDetachObjectClick(TObject *Sender); + void __fastcall FormHide(TObject *Sender); + void __fastcall FormShow(TObject *Sender); + void __fastcall FormCreate(TObject *Sender); + void __fastcall FormDestroy(TObject *Sender); + void __fastcall ebSelectByRefsClick(TObject *Sender); + void __fastcall ebDeselectByRefsClick(TObject *Sender); + void __fastcall ebMultiSelectByRefMoveClick(TObject *Sender); + void __fastcall ebMultiSelectByRefAppendClick(TObject *Sender); + void __fastcall seSelPercentKeyPress(TObject *Sender, char &Key); +private: // User declarations + TItemList *m_Items; + void __stdcall OnItemFocused(ListItemsVec &items); LPCSTR m_Current; - void SelByRefObject ( bool flag ); - void MultiSelByRefObject ( bool clear_prev ); - void __stdcall OnDrawObjectThumbnail(LPCSTR name, HDC hdc, const Irect &R); - xr_map m_caption_to_sect; -public: // User declarations - __fastcall TfraSpawn(TComponent* Owner); - LPCSTR Current (){return m_Current;} + void SelByRefObject(bool flag); + void MultiSelByRefObject(bool clear_prev); + void __stdcall OnDrawObjectThumbnail(LPCSTR name, HDC hdc, const Irect &R); + xr_map m_caption_to_sect; +public: // User declarations + __fastcall TfraSpawn(TComponent *Owner); + + LPCSTR Current() + { + return m_Current; + } }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/FrameWayPoint.cpp b/src/editors/LevelEditor/FrameWayPoint.cpp index 139dae9689d..7e46a23e3e2 100644 --- a/src/editors/LevelEditor/FrameWayPoint.cpp +++ b/src/editors/LevelEditor/FrameWayPoint.cpp @@ -1,8 +1,8 @@ #include "stdafx.h" #pragma hdrstop -#include "../ECore/Editor/ui_main.h" -#include "ui_leveltools.h" +#include "editors/ECore/Editor/ui_main.h" +#include "UI_LevelTools.h" #include "FrameWayPoint.h" #include "Scene.h" #include "WayPoint.h" @@ -12,115 +12,136 @@ #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfraWayPoint::TfraWayPoint(TComponent* Owner) - : TForm(Owner) +__fastcall TfraWayPoint::TfraWayPoint(TComponent *Owner) + : TForm(Owner) { DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfraWayPoint::PanelMinClick(TObject *Sender) { PanelMinMaxClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraWayPoint::ExpandClick(TObject *Sender) { PanelMaximizeClick(Sender); } + //--------------------------------------------------------------------------- void __fastcall TfraWayPoint::ebAdd1LinksClick(TObject *Sender) { - if (!ebModePoint->Down){ - ELog.DlgMsg(mtInformation,"Before editing enter Point Mode."); - return; + if (!ebModePoint->Down) + { + ELog.DlgMsg(mtInformation, "Before editing enter Point Mode."); + return; } bool bRes = false; - ObjectList lst; + ObjectList lst; Scene->GetQueryObjects(lst, OBJCLASS_WAY, 1, 1, 0); - // remove links - for (ObjectIt it=lst.begin(); it!=lst.end(); it++){ - ((CWayObject*)(*it))->RemoveLink(); - bRes|=((CWayObject*)(*it))->Add1Link(); + // remove links + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + { + ((CWayObject*)(*it))->RemoveLink(); + bRes |= ((CWayObject*)(*it))->Add1Link(); } - if (bRes) Scene->UndoSave(); + if (bRes) + Scene->UndoSave(); ExecCommand(COMMAND_UPDATE_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfraWayPoint::ebAdd2LinkClick(TObject *Sender) { - if (!ebModePoint->Down){ - ELog.DlgMsg(mtInformation,"Before editing enter Point Mode."); - return; + if (!ebModePoint->Down) + { + ELog.DlgMsg(mtInformation, "Before editing enter Point Mode."); + return; } bool bRes = false; - ObjectList lst; + ObjectList lst; Scene->GetQueryObjects(lst, OBJCLASS_WAY, 1, 1, 0); - for (ObjectIt it=lst.begin(); it!=lst.end(); it++) - bRes|=((CWayObject*)(*it))->Add2Link(); - if (bRes) Scene->UndoSave(); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + bRes |= ((CWayObject*)(*it))->Add2Link(); + if (bRes) + Scene->UndoSave(); ExecCommand(COMMAND_UPDATE_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfraWayPoint::ebConvert1Click(TObject *Sender) { - ObjectList lst; + ObjectList lst; int cnt = Scene->GetQueryObjects(lst, OBJCLASS_WAY, 1, 1, 0); - for (ObjectIt it=lst.begin(); it!=lst.end(); it++) - ((CWayObject*)(*it))->Convert1Link(); - if (cnt) Scene->UndoSave(); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + ((CWayObject*)(*it))->Convert1Link(); + if (cnt) + Scene->UndoSave(); ExecCommand(COMMAND_UPDATE_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfraWayPoint::ebConvert2Click(TObject *Sender) { - ObjectList lst; + ObjectList lst; int cnt = Scene->GetQueryObjects(lst, OBJCLASS_WAY, 1, 1, 0); - for (ObjectIt it=lst.begin(); it!=lst.end(); it++) - ((CWayObject*)(*it))->Convert2Link(); - if (cnt) Scene->UndoSave(); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + ((CWayObject*)(*it))->Convert2Link(); + if (cnt) + Scene->UndoSave(); ExecCommand(COMMAND_UPDATE_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfraWayPoint::ebRemoveLinksClick(TObject *Sender) { - if (!ebModePoint->Down){ - ELog.DlgMsg(mtInformation,"Before editing enter Point Mode."); - return; + if (!ebModePoint->Down) + { + ELog.DlgMsg(mtInformation, "Before editing enter Point Mode."); + return; } - ObjectList lst; + ObjectList lst; int cnt = Scene->GetQueryObjects(lst, OBJCLASS_WAY, 1, 1, 0); - for (ObjectIt it=lst.begin(); it!=lst.end(); it++) - ((CWayObject*)(*it))->RemoveLink(); - if (cnt) Scene->UndoSave(); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + ((CWayObject*)(*it))->RemoveLink(); + if (cnt) + Scene->UndoSave(); ExecCommand(COMMAND_UPDATE_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfraWayPoint::ebInvertLinkClick(TObject *Sender) { - if (!ebModePoint->Down){ - ELog.DlgMsg(mtInformation,"Before editing enter Point Mode."); - return; + if (!ebModePoint->Down) + { + ELog.DlgMsg(mtInformation, "Before editing enter Point Mode."); + return; } - ObjectList lst; + ObjectList lst; int cnt = Scene->GetQueryObjects(lst, OBJCLASS_WAY, 1, 1, 0); - for (ObjectIt it=lst.begin(); it!=lst.end(); it++) - ((CWayObject*)(*it))->InvertLink(); - if (cnt) Scene->UndoSave(); + for (ObjectIt it = lst.begin(); it!=lst.end(); it++) + ((CWayObject*)(*it))->InvertLink(); + if (cnt) + Scene->UndoSave(); ExecCommand(COMMAND_UPDATE_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfraWayPoint::ebModeWayClick(TObject *Sender) { - LTools->SetTarget (OBJCLASS_WAY,dynamic_cast(Sender)->Tag); + LTools->SetTarget(OBJCLASS_WAY, dynamic_cast(Sender)->Tag); } + //--------------------------------------------------------------------------- diff --git a/src/editors/LevelEditor/FrmDBXpacker.cpp b/src/editors/LevelEditor/FrmDBXpacker.cpp index 1868497e68c..f56441d0aa2 100644 --- a/src/editors/LevelEditor/FrmDBXpacker.cpp +++ b/src/editors/LevelEditor/FrmDBXpacker.cpp @@ -14,169 +14,176 @@ #pragma link "MXCtrls" #pragma resource "*.dfm" -TDB_packer* TDB_packer::m_form = NULL; +TDB_packer *TDB_packer::m_form = NULL; //--------------------------------------------------------------------------- -__fastcall TDB_packer::TDB_packer(TComponent* Owner) - : TForm(Owner) +__fastcall TDB_packer::TDB_packer(TComponent *Owner) + : TForm(Owner) { - m_cfgFileName = "mod_pack.ltx"; - _load_ (m_cfgFileName); + m_cfgFileName = "mod_pack.ltx"; + _load_(m_cfgFileName); } + //--------------------------------------------------------------------------- void __fastcall TDB_packer::ActivatePacker() { - if(!m_form) + if (!m_form) { - m_form = xr_new((TComponent*)0); + m_form = xr_new((TComponent*)0); } - m_form->prepare (); - m_form->ShowModal (); + m_form->prepare(); + m_form->ShowModal(); } void __fastcall TDB_packer::prepare() { - string_path _curr_path; - GetCurrentDirectory (sizeof(_curr_path), _curr_path); - FS_Path* pth = FS.get_path ("$game_data$"); - u32 sz = xr_strlen(_curr_path); - string16 tmp; - tmp[0] = 0; - - if(_curr_path[sz-1] !='\\') - strcpy(tmp,"\\"); - - strconcat (sizeof(m_root_folder),m_root_folder, _curr_path, tmp, pth->m_Path); - + string_path _curr_path; + GetCurrentDirectory(sizeof(_curr_path), _curr_path); + FS_Path *pth = FS.get_path("$game_data$"); + u32 sz = xr_strlen(_curr_path); + string16 tmp; + tmp[0] = 0; + + if (_curr_path[sz-1]!='\\') + strcpy(tmp, "\\"); + + strconcat(sizeof(m_root_folder), m_root_folder, _curr_path, tmp, pth->m_Path); + Log(m_root_folder); - shellTree->CustomRootFolder = m_root_folder; + shellTree->CustomRootFolder = m_root_folder; Log(m_root_folder); - shellTree->RootFolder = sfoCustom; + shellTree->RootFolder = sfoCustom; Log(m_root_folder); } void __fastcall TDB_packer::btnSaveClick(TObject *Sender) { - CInifile ini (m_cfgFileName.c_str(), FALSE, FALSE, TRUE); + CInifile ini(m_cfgFileName.c_str(), FALSE, FALSE, TRUE); - for(int i=0; iItems->Count; ++i) + for (int i = 0; iItems->Count; ++i) { - AnsiString astr = lbIncludeFolders->Items->Strings[i]; - ini.w_bool("include_folders",astr.c_str(), TRUE); + AnsiString astr = lbIncludeFolders->Items->Strings[i]; + ini.w_bool("include_folders", astr.c_str(), TRUE); } - for(int j=0; jItems->Count; ++j) + for (int j = 0; jItems->Count; ++j) { - AnsiString astr = lbIncludeFiles->Items->Strings[j]; - ini.w_bool("include_files",astr.c_str(), TRUE); + AnsiString astr = lbIncludeFiles->Items->Strings[j]; + ini.w_bool("include_files", astr.c_str(), TRUE); } - } -void TDB_packer::_load_(const xr_string& fname) +void TDB_packer::_load_(const xr_string &fname) { - lbIncludeFolders->Items->Clear (); - lbIncludeFiles->Items->Clear (); + lbIncludeFolders->Items->Clear(); + lbIncludeFiles->Items->Clear(); - CInifile ini (fname.c_str()); + CInifile ini(fname.c_str()); - if(ini.section_exist("include_folders")) + if (ini.section_exist("include_folders")) + { + CInifile::Sect S = ini.r_section("include_folders"); + CInifile::SectCIt it = S.Data.begin(); + CInifile::SectCIt it_e = S.Data.end(); + for (; it!=it_e; ++it) { - CInifile::Sect S = ini.r_section("include_folders"); - CInifile::SectCIt it = S.Data.begin(); - CInifile::SectCIt it_e = S.Data.end(); - for( ;it!=it_e; ++it) - { - WideString ws; - ws = (*it).first.c_str(); - lbIncludeFolders->Items->Add (ws); - } + WideString ws; + ws = (*it).first.c_str(); + lbIncludeFolders->Items->Add(ws); } - if(ini.section_exist("include_files")) + } + if (ini.section_exist("include_files")) + { + CInifile::Sect S = ini.r_section("include_files"); + CInifile::SectCIt it = S.Data.begin(); + CInifile::SectCIt it_e = S.Data.end(); + for (; it!=it_e; ++it) { - CInifile::Sect S = ini.r_section("include_files"); - CInifile::SectCIt it = S.Data.begin(); - CInifile::SectCIt it_e = S.Data.end(); - for( ;it!=it_e; ++it) - { - WideString ws; - ws = (*it).first.c_str(); - lbIncludeFiles->Items->Add (ws); - } + WideString ws; + ws = (*it).first.c_str(); + lbIncludeFiles->Items->Add(ws); } - Caption = fname.c_str(); + } + Caption = fname.c_str(); } void __fastcall TDB_packer::btnLoadClick(TObject *Sender) { - if( EFS.GetOpenName("$fs_root$", m_cfgFileName, false, NULL, 0) ) + if (EFS.GetOpenName("$fs_root$", m_cfgFileName, false, NULL, 0)) { - _load_(m_cfgFileName); + _load_(m_cfgFileName); } } -void remove_item_from_lb(TElListBox* lb) + +void remove_item_from_lb(TElListBox *lb) { -bool b = true; - while(b) + bool b = true; + while (b) { - b = false; - for(int i=0; iItems->Count; ++i) + b = false; + for (int i = 0; iItems->Count; ++i) { - if( lb->Selected[i] ) + if (lb->Selected[i]) { - lb->Items->Delete(i); + lb->Items->Delete(i); b = true; break; } } - } + } } void __fastcall TDB_packer::ExtBtn2Click(TObject *Sender) { - remove_item_from_lb(lbIncludeFolders); + remove_item_from_lb(lbIncludeFolders); } + //--------------------------------------------------------------------------- void __fastcall TDB_packer::ExtBtn4Click(TObject *Sender) { - remove_item_from_lb(lbIncludeFiles); + remove_item_from_lb(lbIncludeFiles); } + //--------------------------------------------------------------------------- void __fastcall TDB_packer::ExtBtn1Click(TObject *Sender) { - TElShellTreeItem* itm = shellTree->ItemFocused; - if(itm->IsFolder) + TElShellTreeItem *itm = shellTree->ItemFocused; + if (itm->IsFolder) { - AnsiString str = itm->FullName; - int root_len = xr_strlen(m_root_folder); - int len = str.Length(); - lbIncludeFolders->Items->Add( str.SubString(root_len+1,len-root_len) ); + AnsiString str = itm->FullName; + int root_len = xr_strlen(m_root_folder); + int len = str.Length(); + lbIncludeFolders->Items->Add(str.SubString(root_len+1, len-root_len)); } } + //--------------------------------------------------------------------------- void __fastcall TDB_packer::ExtBtn3Click(TObject *Sender) { - TElShellTreeItem* itm = shellTree->ItemFocused; - if(!itm->IsFolder) + TElShellTreeItem *itm = shellTree->ItemFocused; + if (!itm->IsFolder) { - AnsiString str = itm->FullName; - int root_len = xr_strlen(m_root_folder); - int len = str.Length(); - lbIncludeFiles->Items->Add( str.SubString(root_len+1,len-root_len) ); + AnsiString str = itm->FullName; + int root_len = xr_strlen(m_root_folder); + int len = str.Length(); + lbIncludeFiles->Items->Add(str.SubString(root_len+1, len-root_len)); } } + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TDB_packer::ExtBtn5Click(TObject *Sender) { - btnSaveClick((TObject*)0); - spawnl(P_WAIT, "compress_dbx.bat", "compress_dbx.bat", m_cfgFileName.c_str()); + btnSaveClick((TObject*)0); + spawnl(P_WAIT, "compress_dbx.bat", "compress_dbx.bat", m_cfgFileName.c_str()); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/FrmDBXpacker.h b/src/editors/LevelEditor/FrmDBXpacker.h index 85eebf3da90..c9e2363b914 100644 --- a/src/editors/LevelEditor/FrmDBXpacker.h +++ b/src/editors/LevelEditor/FrmDBXpacker.h @@ -14,47 +14,50 @@ #include "ElListBox.hpp" #include "ExtBtn.hpp" #include "MXCtrls.hpp" + //--------------------------------------------------------------------------- class TDB_packer : public TForm { -__published: // IDE-managed Components - TPanel *Panel1; - TPanel *Panel2; - TExtBtn *btnLoad; - TExtBtn *btnSave; - TExtBtn *ExtBtn5; - TPanel *Panel5; - TElShellTree *shellTree; - TPanel *Panel6; - TPanel *Panel3; - TMxLabel *MxLabel2; - TExtBtn *ExtBtn3; - TExtBtn *ExtBtn4; - TElListBox *lbIncludeFiles; - TPanel *Panel4; - TMxLabel *MxLabel1; - TExtBtn *ExtBtn1; - TExtBtn *ExtBtn2; - TElListBox *lbIncludeFolders; - TSplitter *Splitter1; - void __fastcall btnLoadClick(TObject *Sender); - void __fastcall ExtBtn2Click(TObject *Sender); - void __fastcall ExtBtn4Click(TObject *Sender); - void __fastcall ExtBtn1Click(TObject *Sender); - void __fastcall ExtBtn3Click(TObject *Sender); - void __fastcall btnSaveClick(TObject *Sender); - void __fastcall ExtBtn5Click(TObject *Sender); -private: // User declarations - static TDB_packer* m_form; - xr_string m_cfgFileName; - string_path m_root_folder; - void _load_(const xr_string& fn); -public: // User declarations - __fastcall TDB_packer(TComponent* Owner); - void __fastcall prepare (); - static void __fastcall ActivatePacker (); + __published: // IDE-managed Components + TPanel*Panel1; + TPanel *Panel2; + TExtBtn *btnLoad; + TExtBtn *btnSave; + TExtBtn *ExtBtn5; + TPanel *Panel5; + TElShellTree *shellTree; + TPanel *Panel6; + TPanel *Panel3; + TMxLabel *MxLabel2; + TExtBtn *ExtBtn3; + TExtBtn *ExtBtn4; + TElListBox *lbIncludeFiles; + TPanel *Panel4; + TMxLabel *MxLabel1; + TExtBtn *ExtBtn1; + TExtBtn *ExtBtn2; + TElListBox *lbIncludeFolders; + TSplitter *Splitter1; + void __fastcall btnLoadClick(TObject *Sender); + void __fastcall ExtBtn2Click(TObject *Sender); + void __fastcall ExtBtn4Click(TObject *Sender); + void __fastcall ExtBtn1Click(TObject *Sender); + void __fastcall ExtBtn3Click(TObject *Sender); + void __fastcall btnSaveClick(TObject *Sender); + void __fastcall ExtBtn5Click(TObject *Sender); +private: // User declarations + static TDB_packer *m_form; + xr_string m_cfgFileName; + string_path m_root_folder; + void _load_(const xr_string &fn); +public: // User declarations + __fastcall TDB_packer(TComponent *Owner); + void __fastcall prepare(); + static void __fastcall ActivatePacker(); }; + //--------------------------------------------------------------------------- -extern PACKAGE TDB_packer *DB_packer; +extern PACKAGE TDB_packer * DB_packer; //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/LEClipEditor.cpp b/src/editors/LevelEditor/LEClipEditor.cpp index 487a3e4a5af..ecafe21bd24 100644 --- a/src/editors/LevelEditor/LEClipEditor.cpp +++ b/src/editors/LevelEditor/LEClipEditor.cpp @@ -4,10 +4,10 @@ #include "LEClipEditor.h" #include "SkeletonAnimated.h" #include "motion.h" -#include "../ECore/Editor/editobject.h" +#include "editors/ECore/Editor/editobject.h" //.#include "UI_ActorTools.h" -#include "../ECore/Editor/UI_Main.h" -#include "../xrEProps/ItemList.h" +#include "editors/ECore/Editor/UI_Main.h" +#include "editors/xrEProps/ItemList.h" #include #include @@ -95,15 +95,15 @@ void TClipMaker::DestroyForm(TClipMaker* form) { if(form) { - TItemList::DestroyForm (form->m_ObjectItems); - xr_delete (form); + TItemList::DestroyForm(form->m_ObjectItems); + xr_delete (form); } } void TClipMaker::ShowEditor(CKinematicsAnimated* O) { - VERIFY (O); - Show (); + VERIFY (O); + Show (); if(m_RenderObject != O) { @@ -122,42 +122,42 @@ void TClipMaker::ShowEditor(CKinematicsAnimated* O) ListItem* I = LHelper().CreateItem(items,_I->first.c_str(),0,0,0); MotionID mid; - mid.set (k, _I->second); + mid.set (k, _I->second); I->tag = mid.val; } } m_ObjectItems->AssignItems(items,false); } - UpdateClips (); + UpdateClips (); UpdateProperties(); } void TClipMaker::HideEditor() { m_RenderObject = NULL; - Clear (); - Hide (); + Clear (); + Hide (); } void TClipMaker::Clear() { m_ClipProps->ClearProperties(); - m_ClipList->ClearList (); - Stop (); + m_ClipList->ClearList (); + Stop (); for (AnimClipIt it=clips.begin(); it!=clips.end(); ++it) - xr_delete (*it); + xr_delete(*it); - clips.clear (); + clips.clear (); sel_clip = 0; - UpdateClips (true); - m_RTFlags.zero (); + UpdateClips (true); + m_RTFlags.zero(); } __fastcall TClipMaker::TClipMaker(TComponent* Owner) : TForm(Owner) { - DEFINE_INI (fsStorage); + DEFINE_INI (fsStorage); m_LB[0] = lbBPName0; m_LB[1] = lbBPName1; m_LB[2] = lbBPName2; @@ -175,16 +175,16 @@ void __fastcall TClipMaker::FormCreate(TObject *Sender) m_ClipList = TItemList::CreateForm("Clips",paClipList,alClient,0); m_ClipList->SetOnItemsFocusedEvent(TOnILItemsFocused(this,&TClipMaker::OnClipItemFocused)); - EDevice.seqFrame.Add (this); + EDevice.seqFrame.Add(this); } //--------------------------------------------------------------------------- void __fastcall TClipMaker::FormDestroy(TObject *Sender) { EDevice.seqFrame.Remove(this); - Clear (); + Clear (); TProperties::DestroyForm(m_ClipProps); - TItemList::DestroyForm (m_ClipList); + TItemList::DestroyForm(m_ClipList); } //--------------------------------------------------------------------------- @@ -214,7 +214,7 @@ void __fastcall TClipMaker::FormCloseQuery(TObject *Sender, bool &CanClose) switch (res){ case mrYes:{ for (ClipIt it=tgt.begin(); it!=tgt.end(); it++) - xr_delete (*it); + xr_delete(*it); tgt.resize(clips.size()); ClipIt t_it=tgt.begin(); for (UIClipIt s_it=clips.begin(); s_it!=clips.end(); s_it++,t_it++){ @@ -234,7 +234,7 @@ void __fastcall TClipMaker::FormCloseQuery(TObject *Sender, bool &CanClose) void __fastcall TClipMaker::FormClose(TObject *Sender, TCloseAction &Action) { - Stop (); + Stop(); //. Clear(); } //--------------------------------------------------------------------------- @@ -296,9 +296,9 @@ void __fastcall TClipMaker::ClipDragOver(TObject *Sender, void __fastcall TClipMaker::ClipDragDrop(TObject *Sender, TObject *Source, int X, int Y) { - VERIFY (Sender==paClips); + VERIFY (Sender==paClips); CAnimationClip* tgt = FindClip(X); - VERIFY (tgt); + VERIFY (tgt); TElTreeDragObject* obj = dynamic_cast(Source); if (obj) { @@ -315,7 +315,7 @@ void __fastcall TClipMaker::ClipDragDrop(TObject *Sender, CMotionDef* MD = m_RenderObject->LL_GetMotionDef(mid); u8 pc = m_RenderObject->partitions().count(); - tgt->SetCycle (mid, MD->bone_or_part, pc); + tgt->SetCycle (mid, MD->bone_or_part, pc); break; } } @@ -328,7 +328,7 @@ void __fastcall TClipMaker::ClipDragDrop(TObject *Sender, else sel_clip->start_time = tgt->start_time+EPS_L; } - UpdateClips (); + UpdateClips (); } //--------------------------------------------------------------------------- @@ -353,11 +353,11 @@ void __fastcall TClipMaker::ClipMouseDown(TObject *Sender, TMouseButton Button, { if (Button==mbLeft) { - SelectClip (FindClip(X)); + SelectClip (FindClip(X)); if (paClips->Cursor==crHSplit) { g_resizing = TRUE; - Stop (); + Stop (); g_X_prev = X; g_X_dx = X-sel_clip->PRightUI(); RepaintClips(); @@ -371,7 +371,7 @@ void __fastcall TClipMaker::ClipMouseDown(TObject *Sender, TMouseButton Button, void __fastcall TClipMaker::ClipMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { - VERIFY (sel_clip); + VERIFY (sel_clip); TMxPanel* P = dynamic_cast(Sender); CAnimationClip* C = FindClip(X); VERIFY(C); @@ -392,9 +392,9 @@ void __fastcall TClipMaker::ClipMouseMove(TObject *Sender, sel_clip->length += dx; if (sel_clip->length<0.01f) sel_clip->length=0.01f; g_X_prev = sel_clip->PRightUI(); - UI->ShowHint (AnsiString().sprintf("Length: %s",FloatTimeToStrTime(sel_clip->Length(),false,true,true,true).c_str())); + UI->ShowHint(AnsiString().sprintf("Length: %s",FloatTimeToStrTime(sel_clip->Length(),false,true,true,true).c_str())); } - UpdateClips (); + UpdateClips (); } } //--------------------------------------------------------------------------- @@ -403,9 +403,9 @@ void __fastcall TClipMaker::ClipMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (Button==mbLeft){ - UI->HideHint (); + UI->HideHint(); g_resizing = FALSE; - UpdateClips (); + UpdateClips(); } } //--------------------------------------------------------------------------- @@ -453,18 +453,18 @@ void __fastcall TClipMaker::BPDragDrop(TObject *Sender, TObject *Source, /* if (drag_state.Contains(ssAlt)) { - std::swap (tgt->fx,src->fx); + std::swap (tgt->fx,src->fx); }else if (drag_state.Contains(ssCtrl)) { tgt->fx = src->fx; }else{ tgt->fx = src->fx; - src->fx.clear (); + src->fx.clear(); } */ }else{ if (drag_state.Contains(ssAlt)) { - std::swap (tgt->animItems[P->Tag], src->animItems[P->Tag]); + std::swap (tgt->animItems[P->Tag], src->animItems[P->Tag]); }else if (drag_state.Contains(ssCtrl)) { tgt->animItems[P->Tag] = src->animItems[P->Tag]; @@ -487,7 +487,7 @@ void __fastcall TClipMaker::BPMouseDown(TObject *Sender, // pt=P->ClientToScreen(pt); // pmClip->Popup(pt.x,pt.y-10); }else if (Button==mbLeft){ - SelectClip (FindClip(X)); + SelectClip(FindClip(X)); P->BeginDrag(false, 2); drag_state = Shift; } @@ -526,31 +526,31 @@ void __fastcall TClipMaker::OnNameChange(PropValue* V) void __fastcall TClipMaker::OnClipLengthChange(PropValue* V) { - UpdateClips (); + UpdateClips (); } //------------------------------------------------------------------------------ void __fastcall TClipMaker::OnZoomChange(PropValue* V) { - UpdateClips (); + UpdateClips (); } //--------------------------------------------------------------------------- void TClipMaker::RealUpdateProperties() { - m_RTFlags.set (flRT_UpdateProperties,FALSE); + m_RTFlags.set(flRT_UpdateProperties,FALSE); // clip props PropItemVec p_items; PropValue* V = 0; - PHelper().CreateCaption (p_items,"Length", FloatTimeToStrTime(m_TotalLength,true,true,true,true).c_str()); - V=PHelper().CreateFloat (p_items,"Zoom", &m_Zoom, 1.f,1000.f,0.1f,1); - V->OnChangeEvent.bind (this,&TClipMaker::OnZoomChange); + PHelper().CreateCaption (p_items,"Length", FloatTimeToStrTime(m_TotalLength,true,true,true,true).c_str()); + V=PHelper().CreateFloat (p_items,"Zoom", &m_Zoom, 1.f,1000.f,0.1f,1); + V->OnChangeEvent.bind (this,&TClipMaker::OnZoomChange); if (sel_clip){ ListItem* l_owner = m_ClipList->FindItem(*sel_clip->name); VERIFY(l_owner); - V=PHelper().CreateName (p_items,"Current Clip\\Name", &sel_clip->name, l_owner); - V->OnChangeEvent.bind (this,&TClipMaker::OnNameChange); - V=PHelper().CreateFloat (p_items,"Current Clip\\Length",&sel_clip->length, 0.f,10000.f,0.1f,2); - V->OnChangeEvent.bind (this,&TClipMaker::OnClipLengthChange); + V=PHelper().CreateName(p_items,"Current Clip\\Name", &sel_clip->name, l_owner); + V->OnChangeEvent.bind(this,&TClipMaker::OnNameChange); + V=PHelper().CreateFloat(p_items,"Current Clip\\Length",&sel_clip->length, 0.f,10000.f,0.1f,2); + V->OnChangeEvent.bind(this,&TClipMaker::OnClipLengthChange); //TEMP /* for (u16 k=0; k<4; k++) @@ -560,8 +560,8 @@ void TClipMaker::RealUpdateProperties() if (mname.IsEmpty()) continue; - CMotionDef* MD = m_RenderObject->FindMotionDef (mname.c_str(),slot); - CMotion* MI = m_RenderObject->FindMotionKeys (mname.c_str(),slot); + CMotionDef* MD = m_RenderObject->FindMotionDef (mname.c_str(),slot); + CMotion* MI = m_RenderObject->FindMotionKeys(mname.c_str(),slot); SBonePart* BP = (k<(u16)m_CurrentObject->BoneParts().size())?&m_CurrentObject->BoneParts()[k]:0; shared_str tmp; @@ -569,11 +569,11 @@ void TClipMaker::RealUpdateProperties() tmp.sprintf("%s [%3.2fs, %s]",mname.c_str(),MI->GetLength()/MD->Speed(),MD->bone_or_part?"stop at end":"looped"); if (BP) - PHelper().CreateCaption (p_items,PrepareKey("Current Clip\\Cycles",BP->alias.c_str()), tmp); + PHelper().CreateCaption(p_items,PrepareKey("Current Clip\\Cycles",BP->alias.c_str()), tmp); } if (sel_clip->fx.valid()) - PHelper().CreateFloat (p_items,PrepareKey("Current Clip\\FXs",*sel_clip->fx.name), &sel_clip->fx_power, 0.f, 1000.f); + PHelper().CreateFloat (p_items,PrepareKey("Current Clip\\FXs",*sel_clip->fx.name), &sel_clip->fx_power, 0.f, 1000.f); */ } m_ClipProps->AssignItems(p_items); @@ -586,19 +586,19 @@ void TClipMaker::SelectClip(CAnimationClip* clip) { AnsiString nm = clip?*clip->name:""; sel_clip = clip; - m_ClipList->SelectItem (nm.c_str(),true,false,true); - RepaintClips (); - UpdateProperties (); + m_ClipList->SelectItem(nm.c_str(),true,false,true); + RepaintClips (); + UpdateProperties (); } } void TClipMaker::InsertClip() { shared_str nm; - m_ClipList->GenerateObjectName (nm,0,"clip",true); + m_ClipList->GenerateObjectName(nm,0,"clip",true); CAnimationClip* clip = xr_new(*nm,this); clip->start_time = (sel_clip)?sel_clip->StartTime()-EPS_L:0; - clips.push_back (clip); + clips.push_back (clip); UpdateClips (true,false); SelectClip (clip); } @@ -607,12 +607,12 @@ void TClipMaker::InsertClip() void TClipMaker::AppendClip() { shared_str nm; - m_ClipList->GenerateObjectName (nm,0,"clip",true); + m_ClipList->GenerateObjectName(nm,0,"clip",true); CAnimationClip* clip = xr_new(*nm,this); clip->start_time = (sel_clip)?sel_clip->StartTime()+sel_clip->Length()-EPS_L:0; - clips.push_back (clip); - UpdateClips (true,false); - SelectClip (clip); + clips.push_back (clip); + UpdateClips (true,false); + SelectClip (clip); } //--------------------------------------------------------------------------- @@ -624,7 +624,7 @@ void TClipMaker::LoadClips() bool bRes=true; if (EFS.GetOpenName("$clips$",m_ClipFName)) { - Clear (); + Clear (); IReader* F = FS.r_open(m_ClipFName.c_str()); VERIFY(F); m_ClipFName = EFS.ExcludeBasePath(m_ClipFName.c_str(),FS.get_path("$clips$")->m_Path); if (F->find_chunk(CHUNK_ZOOM)) @@ -648,8 +648,8 @@ void TClipMaker::LoadClips() clips.push_back(clip); M = C->open_chunk(count); } - C->close (); - UpdateClips (); + C->close(); + UpdateClips(); } FS.r_close(F); } @@ -666,10 +666,10 @@ void TClipMaker::SaveClips() if (F) { F->open_chunk(CHUNK_ZOOM); - F->w_float (m_Zoom); + F->w_float(m_Zoom); F->close_chunk(); - F->open_chunk (CHUNK_CLIPS); + F->open_chunk(CHUNK_CLIPS); int count = 0; for (AnimClipIt c_it=clips.begin(); c_it!=clips.end(); ++c_it) { @@ -677,11 +677,11 @@ void TClipMaker::SaveClips() (*c_it)->Save(*F); F->close_chunk(); } - F->close_chunk (); + F->close_chunk(); FS.w_close(F); }else { - Log ("!Can't save clip:",m_ClipFName.c_str()); + Log ("!Can't save clip:",m_ClipFName.c_str()); } } }else{ @@ -692,20 +692,20 @@ void TClipMaker::SaveClips() void TClipMaker::RemoveAllClips() { - SelectClip (0); + SelectClip (0); for (AnimClipIt it=clips.begin(); it!=clips.end(); it++) xr_delete(*it); - clips.clear (); - UpdateClips (); - Stop (); + clips.clear (); + UpdateClips (); + Stop (); } //--------------------------------------------------------------------------- void TClipMaker::RemoveClip(CAnimationClip* clip) { if (clip){ - Stop (); + Stop (); AnimClipIt it = std::find(clips.begin(),clips.end(),clip); if (it!=clips.end()) { @@ -715,10 +715,10 @@ void TClipMaker::RemoveClip(CAnimationClip* clip) { p_it=it; p_it--;} CAnimationClip* C = p_it==clips.end()?0:*p_it; - xr_delete (*it); - clips.erase (it); - SelectClip (C); - UpdateClips (); + xr_delete(*it); + clips.erase(it); + SelectClip(C); + UpdateClips(); } } } @@ -734,8 +734,8 @@ void __fastcall TClipMaker::gtClipPaint(TObject *Sender) canvas->Pen->Style = psSolid; for (AnimClipIt it=clips.begin(); it!=clips.end(); ++it) { - canvas->MoveTo ((*it)->PLeftUI(), 0); - canvas->LineTo ((*it)->PLeftUI(), 6); + canvas->MoveTo((*it)->PLeftUI(), 0); + canvas->LineTo((*it)->PLeftUI(), 6); AnsiString s = AnsiString().sprintf("%2.1f",(*it)->StartTime()); float dx = 2.f; float dy = canvas->TextHeight(s); @@ -745,8 +745,8 @@ void __fastcall TClipMaker::gtClipPaint(TObject *Sender) if (!clips.empty()) { CAnimationClip* C = clips.back(); - canvas->MoveTo (C->PRightUI()-1, 0); - canvas->LineTo (C->PRightUI()-1, 6); + canvas->MoveTo(C->PRightUI()-1, 0); + canvas->LineTo(C->PRightUI()-1, 6); AnsiString s = AnsiString().sprintf("%2.1f",m_TotalLength); float dx = canvas->TextWidth(s); float dy = canvas->TextHeight(s); @@ -755,15 +755,15 @@ void __fastcall TClipMaker::gtClipPaint(TObject *Sender) } /* if (g_resizing){ canvas->Pen->Color = clGreen; - canvas->MoveTo (g_X_cur, 0); - canvas->LineTo (g_X_cur, gtClip->Width); + canvas->MoveTo(g_X_cur, 0); + canvas->LineTo(g_X_cur, gtClip->Width); } */ if (m_RTFlags.is(flRT_Playing)){ canvas->Pen->Color = clRed; canvas->Pen->Width = 3; - canvas->MoveTo (m_CurrentPlayTime*m_Zoom, 0); - canvas->LineTo (m_CurrentPlayTime*m_Zoom, gtClip->Width); + canvas->MoveTo (m_CurrentPlayTime*m_Zoom, 0); + canvas->LineTo (m_CurrentPlayTime*m_Zoom, gtClip->Width); } } //--------------------------------------------------------------------------- @@ -783,12 +783,12 @@ void __fastcall TClipMaker::ClipPaint(TObject *Sender) TRect R = TRect((*it)->PLeftUI(), 1, (*it)->PRightUI()-1, paClips->Height); canvas->Pen->Width = 1; canvas->Brush->Color= (*it==sel_clip)?(drag_obj==P->Tag?CLIP_ACTIVE_DRAG_COLOR:CLIP_ACTIVE_COLOR):CLIP_INACTIVE_COLOR; - canvas->Rectangle (R); + canvas->Rectangle(R); R.Top += 1; R.Bottom -= 1; R.Left += 1; R.Right -= 1; - canvas->TextRect (R,R.Left,R.Top,*(*it)->name); + canvas->TextRect(R,R.Left,R.Top,*(*it)->name); } } //--------------------------------------------------------------------------- @@ -816,12 +816,12 @@ void __fastcall TClipMaker::BPOnPaint(TObject *Sender) TRect R = TRect((*it)->PLeft(), 1, (*it)->PRight()-1, 15); AnsiString fx_name = (*it)->FXName(); if (!fx_name.IsEmpty()){ - canvas->Rectangle (R); + canvas->Rectangle(R); R.Top += 1; R.Bottom -= 1; R.Left += 1; R.Right -= 1; - canvas->TextRect (R,R.Left,R.Top,fx_name); + canvas->TextRect(R,R.Left,R.Top,fx_name); } } */ @@ -836,18 +836,18 @@ void __fastcall TClipMaker::BPOnPaint(TObject *Sender) if (!mn.IsEmpty()) { canvas->Brush->Color= (*it==sel_clip)?(drag_obj==bp->Tag?BP_ACTIVE_DRAG_COLOR:BP_ACTIVE_COLOR):BP_INACTIVE_COLOR; - canvas->Rectangle (R); + canvas->Rectangle(R); R.Top += 1; R.Bottom -= 1; R.Left += 1; R.Right -= 1; - canvas->TextRect (R,R.Left,R.Top,mn); + canvas->TextRect(R,R.Left,R.Top,mn); mn_prev = mn; }else if (!mn_prev.IsEmpty()) { - canvas->MoveTo ((*it)->PLeftUI()+1,13); - canvas->LineTo (R.Right,13); - canvas->LineTo (R.Width()>5?R.Right-5:R.Right-R.Width(),8); + canvas->MoveTo ((*it)->PLeftUI()+1,13); + canvas->LineTo (R.Right,13); + canvas->LineTo (R.Width()>5?R.Right-5:R.Right-R.Width(),8); R.Top += 1; R.Bottom -= 1; R.Left += 1; @@ -860,45 +860,45 @@ void __fastcall TClipMaker::BPOnPaint(TObject *Sender) void TClipMaker::RealRepaintClips() { - m_RTFlags.set (flRT_RepaintClips,FALSE); + m_RTFlags.set (flRT_RepaintClips,FALSE); // repaint - paClips->Repaint (); - gtClip->Repaint (); - paBP0->Repaint (); - paBP1->Repaint (); - paBP2->Repaint (); - paBP3->Repaint (); - paFXs->Repaint (); + paClips->Repaint(); + gtClip->Repaint (); + paBP0->Repaint (); + paBP1->Repaint (); + paBP2->Repaint (); + paBP3->Repaint (); + paFXs->Repaint (); // set BP name CPartition* P = m_RenderObject->m_Partition; for (u16 k=0; kCaption = (P->part(k).Name.size())?P->part(k).Name.c_str():"-"; - UpdateProperties (); + UpdateProperties(); } //--------------------------------------------------------------------------- void TClipMaker::RealUpdateClips() { - m_RTFlags.set (flRT_UpdateClips,FALSE); + m_RTFlags.set(flRT_UpdateClips,FALSE); m_TotalLength = 0.f; - std::sort (clips.begin(),clips.end(),clip_pred); + std::sort (clips.begin(),clips.end(),clip_pred); for (AnimClipIt it=clips.begin(); it!=clips.end(); ++it) { - (*it)->start_time = m_TotalLength; + (*it)->start_time = m_TotalLength; m_TotalLength += (*it)->length; (*it)->idx = it-clips.begin(); } paFrame->Width = m_TotalLength*m_Zoom; - Stop (); + Stop (); // clip list ListItemsVec l_items; for (it=clips.begin(); it!=clips.end(); ++it) - LHelper().CreateItem (l_items,*(*it)->name,0,0,*it); + LHelper().CreateItem(l_items,*(*it)->name,0,0,*it); - m_ClipList->AssignItems (l_items,true); + m_ClipList->AssignItems (l_items,true); // select default clip if (!clips.empty()&&(sel_clip==0)) @@ -908,7 +908,7 @@ void TClipMaker::RealUpdateClips() void __fastcall TClipMaker::fsStorageRestorePlacement(TObject *Sender) { - m_ClipProps->RestoreParams (fsStorage); + m_ClipProps->RestoreParams(fsStorage); int idx = fsStorage->ReadInteger("sel_clip",0); if (idx<(int)clips.size()) SelectClip(clips[idx]); } @@ -917,7 +917,7 @@ void __fastcall TClipMaker::fsStorageRestorePlacement(TObject *Sender) void __fastcall TClipMaker::fsStorageSavePlacement(TObject *Sender) { m_ClipProps->SaveParams(fsStorage); - fsStorage->WriteInteger ("sel_clip",sel_clip?sel_clip->idx:0); + fsStorage->WriteInteger ("sel_clip",sel_clip?sel_clip->idx:0); } //--------------------------------------------------------------------------- @@ -970,25 +970,25 @@ void TClipMaker::OnFrame() void __fastcall TClipMaker::ebInsertClipClick(TObject *Sender) { - InsertClip (); + InsertClip (); } //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebAppendClipClick(TObject *Sender) { - AppendClip (); + AppendClip (); } //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebLoadClipsClick(TObject *Sender) { - LoadClips (); + LoadClips (); } //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebSaveClipsClick(TObject *Sender) { - SaveClips (); + SaveClips (); } //--------------------------------------------------------------------------- @@ -1005,8 +1005,8 @@ void __fastcall TClipMaker::ebSyncClick(TObject *Sender) { AnsiString mname = (*c_it)->CycleName(k); u16 slot = (*c_it)->CycleSlot(k); - CMotion* MI = ATools->m_RenderObject.FindMotionKeys (mname.c_str(),slot); - CMotionDef* MD = ATools->m_RenderObject.FindMotionDef (mname.c_str(),slot); + CMotion* MI = ATools->m_RenderObject.FindMotionKeys(mname.c_str(),slot); + CMotionDef* MD = ATools->m_RenderObject.FindMotionDef(mname.c_str(),slot); if (MI) { float new_len = (MD->StopAtEnd()?MI->GetLength()-SAMPLE_SPF:MI->GetLength())/MD->Speed(); @@ -1016,7 +1016,7 @@ void __fastcall TClipMaker::ebSyncClick(TObject *Sender) } (*c_it)->length = fis_zero(len)?2.f:len; } - UpdateClips (); + UpdateClips (); }else{ ELog.DlgMsg(mtInformation,"Time syncronize only in Engine Mode."); } @@ -1053,19 +1053,19 @@ void __fastcall TClipMaker::ebNextClipClick(TObject *Sender) void __fastcall TClipMaker::ebPlayClick(TObject *Sender) { - Play (FALSE); + Play (FALSE); } //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebPlayCycleClick(TObject *Sender) { - Play (TRUE); + Play (TRUE); } //--------------------------------------------------------------------------- void __fastcall TClipMaker::ebStopClick(TObject *Sender) { - Stop (); + Stop (); } //--------------------------------------------------------------------------- @@ -1073,11 +1073,11 @@ void TClipMaker::Play(BOOL bLoop) { if (sel_clip) { - m_RTFlags.set (flRT_Playing,TRUE); - m_RTFlags.set (flRT_PlayingLooped,bLoop); + m_RTFlags.set(flRT_Playing,TRUE); + m_RTFlags.set(flRT_PlayingLooped,bLoop); play_clip = sel_clip->idx; m_CurrentPlayTime=sel_clip->start_time; - PlayAnimation (sel_clip); + PlayAnimation(sel_clip); } } //--------------------------------------------------------------------------- @@ -1086,9 +1086,9 @@ void TClipMaker::Stop() { if(m_RTFlags.is(flRT_Playing)) { - m_RTFlags.set (flRT_Playing,FALSE); + m_RTFlags.set (flRT_Playing,FALSE); m_CurrentPlayTime = 0.f; - RepaintClips (); + RepaintClips (); for (u16 i=0; iLL_CloseCycle(i, u8(-1)); @@ -1100,7 +1100,7 @@ void __fastcall TClipMaker::ebTrashClick(TObject *Sender) { if (!clips.empty()) if (mrYes==ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo, "Remove selected clip?")) - RemoveClip (sel_clip); + RemoveClip(sel_clip); } //--------------------------------------------------------------------------- diff --git a/src/editors/LevelEditor/LEClipEditor.h b/src/editors/LevelEditor/LEClipEditor.h index 781f662ddca..5be5562883a 100644 --- a/src/editors/LevelEditor/LEClipEditor.h +++ b/src/editors/LevelEditor/LEClipEditor.h @@ -15,7 +15,7 @@ #include #include #include "multi_edit.hpp" -#include "../xrEProps/PropertiesList.h" +#include "editors/xrEProps/PropertiesList.h" #include "motion.h" #include "ElTrackBar.hpp" #include "SkeletonAnimated.h" @@ -159,66 +159,66 @@ class TClipMaker: public TForm, TMxLabel* m_LB[4]; CKinematicsAnimated* m_RenderObject; - DEFINE_VECTOR (CAnimationClip*,AnimClipVec,AnimClipIt); + DEFINE_VECTOR (CAnimationClip*,AnimClipVec,AnimClipIt); AnimClipVec clips; CAnimationClip* sel_clip; u32 play_clip; TProperties* m_ClipProps; TItemList* m_ClipList; - void PlayAnimation (CAnimationClip* clip); + void PlayAnimation(CAnimationClip* clip); - void RemoveAllClips (); - void LoadClips (); - void SaveClips (); - void InsertClip (); - void AppendClip (); - void RemoveClip (CAnimationClip* clip); - void SelectClip (CAnimationClip* clip); - - CAnimationClip* FindClip (float t); - CAnimationClip* FindClip (int x); + void RemoveAllClips(); + void LoadClips (); + void SaveClips (); + void InsertClip (); + void AppendClip (); + void RemoveClip (CAnimationClip* clip); + void SelectClip (CAnimationClip* clip); + + CAnimationClip* FindClip (float t); + CAnimationClip* FindClip (int x); void RealRepaintClips(); - void RepaintClips (bool bForced=false){m_RTFlags.set(flRT_RepaintClips,TRUE); if(bForced) RealRepaintClips(); } + void RepaintClips(bool bForced=false){m_RTFlags.set(flRT_RepaintClips,TRUE); if(bForced) RealRepaintClips(); } void RealUpdateProperties(); void UpdateProperties(bool bForced=false){m_RTFlags.set(flRT_UpdateProperties,TRUE); if(bForced) RealUpdateProperties(); } - void RealUpdateClips (); - void UpdateClips (bool bForced=false, bool bRepaint=true){m_RTFlags.set(flRT_UpdateClips,TRUE); m_RTFlags.set(flRT_RepaintClips,bRepaint); if(bForced) RealUpdateClips(); } + void RealUpdateClips(); + void UpdateClips (bool bForced=false, bool bRepaint=true){m_RTFlags.set(flRT_UpdateClips,TRUE); m_RTFlags.set(flRT_RepaintClips,bRepaint); if(bForced) RealUpdateClips(); } - void Clear (); + void Clear (); - void __stdcall OnZoomChange (PropValue* V); - void __stdcall OnNameChange (PropValue* V); - void __stdcall OnClipLengthChange (PropValue* V); + void __stdcall OnZoomChange (PropValue* V); + void __stdcall OnNameChange (PropValue* V); + void __stdcall OnClipLengthChange(PropValue* V); - void __stdcall OnClipItemFocused (ListItemsVec& items); + void __stdcall OnClipItemFocused(ListItemsVec& items); public: float m_CurrentPlayTime; float m_TotalLength; float m_Zoom; - void Play (BOOL bLoop); - void Stop (); + void Play (BOOL bLoop); + void Stop (); public: // User declarations - __fastcall TClipMaker (TComponent* Owner); + __fastcall TClipMaker (TComponent* Owner); - static TClipMaker* CreateForm (); - static void DestroyForm (TClipMaker* form); + static TClipMaker* CreateForm (); + static void DestroyForm (TClipMaker* form); - void ShowEditor (CKinematicsAnimated* O); - void HideEditor (); + void ShowEditor (CKinematicsAnimated* O); + void HideEditor (); - virtual void OnFrame (void); + virtual void OnFrame (void); TItemList* m_ObjectItems; }; struct AnimClipItem { MotionID mid; - AnimClipItem (){} - void clear () {mid.invalidate();} - bool valid () const {return mid.valid();} + AnimClipItem(){} + void clear () {mid.invalidate();} + bool valid () const {return mid.valid();} }; class CAnimationClip @@ -232,21 +232,21 @@ class CAnimationClip s32 idx; TClipMaker* owner; public: - CAnimationClip (LPCSTR name, TClipMaker* owner); - CAnimationClip (TClipMaker* owner); - ~CAnimationClip (); - float Length () const {return length;} - const float& StartTime () const {return start_time;} + CAnimationClip(LPCSTR name, TClipMaker* owner); + CAnimationClip(TClipMaker* owner); + ~CAnimationClip(); + float Length () const {return length;} + const float& StartTime () const {return start_time;} - int PWidthUI (){return Length()*owner->m_Zoom;} - int PLeftUI (){return StartTime()*owner->m_Zoom;} - int PRightUI (){return PLeftUI()+PWidthUI();} + int PWidthUI (){return Length()*owner->m_Zoom;} + int PLeftUI (){return StartTime()*owner->m_Zoom;} + int PRightUI (){return PLeftUI()+PWidthUI();} public: - void Save (IWriter& F){R_ASSERT(0);} - bool Load (IReader& F){R_ASSERT(0);return true;} + void Save (IWriter& F){R_ASSERT(0);} + bool Load (IReader& F){R_ASSERT(0);return true;} - void SetCycle (MotionID mid, u16 part_id, u8 part_count); + void SetCycle (MotionID mid, u16 part_id, u8 part_count); }; extern TClipMaker* g_clip_maker; #endif diff --git a/src/editors/LevelEditor/LEPhysics.cpp b/src/editors/LevelEditor/LEPhysics.cpp index c51a80f8a03..89912224212 100644 --- a/src/editors/LevelEditor/LEPhysics.cpp +++ b/src/editors/LevelEditor/LEPhysics.cpp @@ -5,20 +5,20 @@ #include "scene.h" -#include "../../xrphysics/iphworld.h" -#include "../../xrcdb/xr_area.h" +#include "xrphysics/iphworld.h" +#include "xrcdb/xr_area.h" -//#include "../ECore/Editor/EditObject.h" +//#include "editors/ECore/Editor/EditObject.h" -#include "sceneobject.h" -#include "ui_leveltools.h" +#include "SceneObject.h" +#include "UI_LevelTools.h" #include "mesh_data.h" -#include "spawnpoint.h" +#include "SpawnPoint.h" CScenePhyscs g_scene_physics; -bool CScenePhyscs ::Simulating () +bool CScenePhyscs ::Simulating () { return !!physics_world(); } @@ -79,7 +79,7 @@ BOOL GetStaticCformData ( ObjectList& lst, mesh_build_data &data, bool b_selec CGroupObject* group = (CGroupObject*)(*_F); ObjectList grp_lst; - group->GetObjects (grp_lst); + group->GetObjects(grp_lst); bResult = ParseStaticObjects(grp_lst, group->Name, b_selected_only); }break; */ @@ -109,7 +109,7 @@ void CScenePhyscs::OnSceneModified() UpdateLevelCollision(); } -bool CScenePhyscs::CreateObjectSpace (bool b_selected_only) +bool CScenePhyscs::CreateObjectSpace(bool b_selected_only) { ObjClassID cls = LTools->CurrentClassID(); @@ -143,7 +143,7 @@ bool CScenePhyscs::CreateObjectSpace (bool b_selected_only) if(!bResult) return false; - build_data.l_faces = xr_alloc (build_data.l_face_cnt); + build_data.l_faces = xr_alloc(build_data.l_face_cnt); build_data.l_verts = xr_alloc(build_data.l_vert_cnt); if(b_selected_only) { @@ -179,25 +179,25 @@ bool CScenePhyscs::CreateObjectSpace (bool b_selected_only) return bResult; } -CScenePhyscs::~CScenePhyscs () +CScenePhyscs::~CScenePhyscs () { - // DestroyAll () ; - DestroyObjectSpace () ; + // DestroyAll () ; + DestroyObjectSpace() ; R_ASSERT( !m_object_space ); } -void CScenePhyscs::DestroyObjectSpace () +void CScenePhyscs::DestroyObjectSpace() { destroy_object_space( m_object_space ); } - void CScenePhyscs::DestroyWorld () + void CScenePhyscs::DestroyWorld () { if(physics_world()) destroy_physics_world(); } -void CScenePhyscs::CreateWorld () +void CScenePhyscs::CreateWorld () { @@ -221,7 +221,7 @@ void CreatePhysicsShellsSelected() } } } -void CScenePhyscs:: UseSimulatePoses () +void CScenePhyscs:: UseSimulatePoses() { ObjectList lst; if (Scene->GetQueryObjects(lst,OBJCLASS_SPAWNPOINT,1,1,0)){ @@ -252,10 +252,10 @@ void DestroyPhysicsShells() if(!m_object_space) CreateObjectSpace(false); - CreateWorld (); - CreatePhysicsShellsSelected (); + CreateWorld (); + CreatePhysicsShellsSelected(); } - void CScenePhyscs:: DestroyAll () + void CScenePhyscs:: DestroyAll () { DestroyPhysicsShells(); DestroyWorld(); diff --git a/src/editors/LevelEditor/LeftBar.cpp b/src/editors/LevelEditor/LeftBar.cpp index 93ee2c43c3e..2e302f41336 100644 --- a/src/editors/LevelEditor/LeftBar.cpp +++ b/src/editors/LevelEditor/LeftBar.cpp @@ -9,7 +9,7 @@ #include "scene.h" #include "EditLibrary.h" #include "UI_LevelTools.h" -#include "ui_levelmain.h" +#include "UI_LevelMain.h" #include "CustomObject.h" #include "ESceneCustomMTools.h" #include "FrmDBXpacker.h" @@ -22,103 +22,126 @@ TfraLeftBar *fraLeftBar; //--------------------------------------------------------------------------- -__fastcall TfraLeftBar::TfraLeftBar(TComponent* Owner) - : TFrame(Owner) -{ - m_TargetButtons.resize (OBJCLASS_COUNT); - m_TargetButtons[OBJCLASS_GROUP ] = std::make_pair(ebTargetGroup,btEnableGroup); - m_TargetButtons[OBJCLASS_SCENEOBJECT] = std::make_pair(ebTargetObject,btEnableObject); - m_TargetButtons[OBJCLASS_LIGHT ] = std::make_pair(ebTargetLight,btEnableLight); - m_TargetButtons[OBJCLASS_SHAPE ] = std::make_pair(ebTargetShape,btEnableShape); - m_TargetButtons[OBJCLASS_SOUND_SRC ] = std::make_pair(ebTargetSoundSrc,btEnableSoundSrc); - m_TargetButtons[OBJCLASS_SOUND_ENV ] = std::make_pair(ebTargetSoundEnv,btEnableSoundEnv); - m_TargetButtons[OBJCLASS_GLOW ] = std::make_pair(ebTargetGlow,btEnableGlow); - m_TargetButtons[OBJCLASS_SPAWNPOINT ] = std::make_pair(ebTargetSpawnPoint,btEnableSpawnPoint); - m_TargetButtons[OBJCLASS_WAY ] = std::make_pair(ebTargetWay,btEnableWay); - m_TargetButtons[OBJCLASS_SECTOR ] = std::make_pair(ebTargetSector,btEnableSector); - m_TargetButtons[OBJCLASS_PORTAL ] = std::make_pair(ebTargetPortal,btEnablePortal); - m_TargetButtons[OBJCLASS_PS ] = std::make_pair(ebTargetPS,btEnablePS); - m_TargetButtons[OBJCLASS_DO ] = std::make_pair(ebTargetDO,btEnableDO); - m_TargetButtons[OBJCLASS_AIMAP ] = std::make_pair(ebTargetAIMap,btEnableAIMap); - m_TargetButtons[OBJCLASS_WM ] = std::make_pair(ebTargetWallmarks,btEnableWallmarks); - m_TargetButtons[OBJCLASS_FOG_VOL ] = std::make_pair(ebTargetFogVolumes,btEnableFogVolumes); +__fastcall TfraLeftBar::TfraLeftBar(TComponent *Owner) + : TFrame(Owner) +{ + m_TargetButtons.resize(OBJCLASS_COUNT); + m_TargetButtons[OBJCLASS_GROUP] = std::make_pair(ebTargetGroup, btEnableGroup); + m_TargetButtons[OBJCLASS_SCENEOBJECT] = std::make_pair(ebTargetObject, btEnableObject); + m_TargetButtons[OBJCLASS_LIGHT] = std::make_pair(ebTargetLight, btEnableLight); + m_TargetButtons[OBJCLASS_SHAPE] = std::make_pair(ebTargetShape, btEnableShape); + m_TargetButtons[OBJCLASS_SOUND_SRC] = std::make_pair(ebTargetSoundSrc, btEnableSoundSrc); + m_TargetButtons[OBJCLASS_SOUND_ENV] = std::make_pair(ebTargetSoundEnv, btEnableSoundEnv); + m_TargetButtons[OBJCLASS_GLOW] = std::make_pair(ebTargetGlow, btEnableGlow); + m_TargetButtons[OBJCLASS_SPAWNPOINT] = std::make_pair(ebTargetSpawnPoint, btEnableSpawnPoint); + m_TargetButtons[OBJCLASS_WAY] = std::make_pair(ebTargetWay, btEnableWay); + m_TargetButtons[OBJCLASS_SECTOR] = std::make_pair(ebTargetSector, btEnableSector); + m_TargetButtons[OBJCLASS_PORTAL] = std::make_pair(ebTargetPortal, btEnablePortal); + m_TargetButtons[OBJCLASS_PS] = std::make_pair(ebTargetPS, btEnablePS); + m_TargetButtons[OBJCLASS_DO] = std::make_pair(ebTargetDO, btEnableDO); + m_TargetButtons[OBJCLASS_AIMAP] = std::make_pair(ebTargetAIMap, btEnableAIMap); + m_TargetButtons[OBJCLASS_WM] = std::make_pair(ebTargetWallmarks, btEnableWallmarks); + m_TargetButtons[OBJCLASS_FOG_VOL] = std::make_pair(ebTargetFogVolumes, btEnableFogVolumes); int startGroupIndex = 999; - for (ObjClassID k=OBJCLASS_FIRST_CLASS; kTag = k; - m_TargetButtons[k].second->Tag = k; - m_TargetButtons[k].second->GroupIndex = ++startGroupIndex; + m_TargetButtons[k].first->Tag = k; + m_TargetButtons[k].second->Tag = k; + m_TargetButtons[k].second->GroupIndex = ++startGroupIndex; } - DEFINE_INI (fsStorage); + DEFINE_INI (fsStorage); } + //--------------------------------------------------------------------------- -void UpdatePanel(TPanel* p){ - if (p){ - for (int j=0; jControlCount; j++){ - TExtBtn* btn = dynamic_cast(p->Controls[j]); - if (btn) btn->UpdateMouseInControl(); +void UpdatePanel(TPanel *p) +{ + if (p) + { + for (int j = 0; jControlCount; j++) + { + TExtBtn *btn = dynamic_cast(p->Controls[j]); + if (btn) + btn->UpdateMouseInControl(); } } } + //--------------------------------------------------------------------------- -void GetHeight(int& h, TForm* f) +void GetHeight(int &h, TForm *f) { - if (f){ - TPanel* pa; - for (int j=0; jControlCount; j++){ - TComponent* temp = f->Controls[j]; - GetHeight(h,dynamic_cast(temp)); + if (f) + { + TPanel *pa; + for (int j = 0; jControlCount; j++) + { + TComponent *temp = f->Controls[j]; + GetHeight(h, dynamic_cast(temp)); pa = dynamic_cast(temp); - if (pa&&pa->Visible){ h+=pa->Height; UpdatePanel(pa);} + if (pa&&pa->Visible) + { + h += pa->Height; + UpdatePanel(pa); + } } } } + //--------------------------------------------------------------------------- void TfraLeftBar::OnTimer() { - RedrawBar(); + RedrawBar(); } void TfraLeftBar::RedrawBar() { - int i, j, h=0; - for (i=0; iComponentCount; i++){ - TComponent* temp = fraLeftBar->Components[i]; - if (dynamic_cast(temp) != NULL) + int i, j, h = 0; + for (i = 0; iComponentCount; i++) + { + TComponent *temp = fraLeftBar->Components[i]; + if (dynamic_cast(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } - for (i=0; iControlCount; i++) - GetHeight(h,dynamic_cast(paFrames->Controls[i])); - + for (i = 0; iControlCount; i++) + GetHeight(h, dynamic_cast(paFrames->Controls[i])); + int hh = fraLeftBar->Height-(paLeftBar->Height+h); - if (hh<=0) hh = 0; + if (hh<=0) + hh = 0; paFrames->Height = h+hh; - h=0; - for (j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(paLeftBar->Controls[j]); - if (pa&&pa->Visible) h+=pa->Height; + h = 0; + for (j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(paLeftBar->Controls[j]); + if (pa&&pa->Visible) + h += pa->Height; } paLeftBar->Height = h+2; paFrames->Top = paLeftBar->Top+paLeftBar->Height; } + //--------------------------------------------------------------------------- void TfraLeftBar::UpdateBar() { - for (int i=0; iControlCount; i++){ - TForm* f = dynamic_cast(paFrames->Controls[i]); - if (f){ - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(f->Controls[j]); - if (pa){ - if (pa->Align==alClient){ - paFrames->Height-=(pa->Height-pa->Constraints->MinHeight); + for (int i = 0; iControlCount; i++) + { + TForm *f = dynamic_cast(paFrames->Controls[i]); + if (f) + { + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(f->Controls[j]); + if (pa) + { + if (pa->Align==alClient) + { + paFrames->Height -= (pa->Height-pa->Constraints->MinHeight); } } } @@ -129,230 +152,278 @@ void TfraLeftBar::UpdateBar() void TfraLeftBar::MinimizeAllFrames() { - for (int i=0; iControlCount; i++){ - TForm* f = dynamic_cast(paFrames->Controls[i]); - if (f){ - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(f->Controls[j]); - if (pa) PanelMinimize(pa); + for (int i = 0; iControlCount; i++) + { + TForm *f = dynamic_cast(paFrames->Controls[i]); + if (f) + { + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(f->Controls[j]); + if (pa) + PanelMinimize(pa); } } } - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(paLeftBar->Controls[j]); - if (pa) PanelMinimize(pa); + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(paLeftBar->Controls[j]); + if (pa) + PanelMinimize(pa); } - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- void TfraLeftBar::MaximizeAllFrames() { - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(paLeftBar->Controls[j]); - if (pa) PanelMaximize(pa); + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(paLeftBar->Controls[j]); + if (pa) + PanelMaximize(pa); } - for (int i=0; iControlCount; i++){ - TForm* f = dynamic_cast(paFrames->Controls[i]); - if (f){ - for (int j=0; jControlCount; j++){ - TPanel* pa = dynamic_cast(f->Controls[j]); - if (pa){ - if (pa->Align==alClient){ - paFrames->Height-=(pa->Height-pa->Constraints->MinHeight); - }else - PanelMaximize(pa); + for (int i = 0; iControlCount; i++) + { + TForm *f = dynamic_cast(paFrames->Controls[i]); + if (f) + { + for (int j = 0; jControlCount; j++) + { + TPanel *pa = dynamic_cast(f->Controls[j]); + if (pa) + { + if (pa->Align==alClient) + { + paFrames->Height -= (pa->Height-pa->Constraints->MinHeight); + } + else + PanelMaximize(pa); } } } } - UpdateBar(); + UpdateBar(); } + //--------------------------------------------------------------------------- void TfraLeftBar::ChangeTarget(ObjClassID tgt) { - for (int i=0; iControlCount; i++){ - TExtBtn* B = dynamic_cast(paTarget->Controls[i]); - if (B&&ObjClassID(B->Tag)==tgt) B->Down = true; + for (int i = 0; iControlCount; i++) + { + TExtBtn *B = dynamic_cast(paTarget->Controls[i]); + if (B&&ObjClassID(B->Tag)==tgt) + B->Down = true; } - UI->RedrawScene (); - UpdateBar (); + UI->RedrawScene(); + UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebClearClick(TObject *Sender) { - ExecCommand( COMMAND_CLEAR ); + ExecCommand(COMMAND_CLEAR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebLoadClick(TObject *Sender) { - ExecCommand( COMMAND_LOAD ); + ExecCommand(COMMAND_LOAD); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSaveClick(TObject *Sender) { - ExecCommand( COMMAND_SAVE, xr_string(LTools->m_LastFileName.c_str()) ); + ExecCommand(COMMAND_SAVE, xr_string(LTools->m_LastFileName.c_str())); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSaveAsClick(TObject *Sender) { - ExecCommand( COMMAND_SAVE, 0, 1 ); + ExecCommand(COMMAND_SAVE, 0, 1); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebBuildClick(TObject *Sender) { - ExecCommand( COMMAND_BUILD ); + ExecCommand(COMMAND_BUILD); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::miSceneSummaryClick(TObject *Sender) { - ExecCommand( COMMAND_CLEAR_SCENE_SUMMARY ); - ExecCommand( COMMAND_COLLECT_SCENE_SUMMARY ); - ExecCommand( COMMAND_SHOW_SCENE_SUMMARY ); + ExecCommand(COMMAND_CLEAR_SCENE_SUMMARY); + ExecCommand(COMMAND_COLLECT_SCENE_SUMMARY); + ExecCommand(COMMAND_SHOW_SCENE_SUMMARY); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::miHightlightTextureClick(TObject *Sender) { - ExecCommand( COMMAND_SCENE_HIGHLIGHT_TEXTURE ); + ExecCommand(COMMAND_SCENE_HIGHLIGHT_TEXTURE); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebOptionsClick(TObject *Sender) { - ExecCommand( COMMAND_OPTIONS, CCommandVar("Scene") ); + ExecCommand(COMMAND_OPTIONS, CCommandVar("Scene")); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebCutClick(TObject *Sender) { - ExecCommand( COMMAND_CUT ); + ExecCommand(COMMAND_CUT); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebCopyClick(TObject *Sender) { - ExecCommand( COMMAND_COPY ); + ExecCommand(COMMAND_COPY); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebPasteClick(TObject *Sender) { - ExecCommand( COMMAND_PASTE ); + ExecCommand(COMMAND_PASTE); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebUndoClick(TObject *Sender) { - ExecCommand( COMMAND_UNDO ); + ExecCommand(COMMAND_UNDO); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebRedoClick(TObject *Sender) { - ExecCommand( COMMAND_REDO ); + ExecCommand(COMMAND_REDO); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebOpenSelClick(TObject *Sender) { - ExecCommand( COMMAND_LOAD_SELECTION ); + ExecCommand(COMMAND_LOAD_SELECTION); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSaveSelClick(TObject *Sender) { - ExecCommand( COMMAND_SAVE_SELECTION ); + ExecCommand(COMMAND_SAVE_SELECTION); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebValidateSceneClick(TObject *Sender) { - ExecCommand( COMMAND_VALIDATE_SCENE ); + ExecCommand(COMMAND_VALIDATE_SCENE); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebRefreshEditorClick(TObject *Sender) { - ExecCommand( COMMAND_REFRESH_TEXTURES ); + ExecCommand(COMMAND_REFRESH_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::RefreshObjects1Click(TObject *Sender) { - ExecCommand( COMMAND_RELOAD_OBJECTS ); + ExecCommand(COMMAND_RELOAD_OBJECTS); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::CleanLibraryClick(TObject *Sender) { - ExecCommand( COMMAND_CLEAN_LIBRARY ); + ExecCommand(COMMAND_CLEAN_LIBRARY); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::CheckNewTexturesClick(TObject *Sender) { - ExecCommand( COMMAND_CHECK_TEXTURES ); + ExecCommand(COMMAND_CHECK_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ImageEditor1Click(TObject *Sender) { - ExecCommand( COMMAND_IMAGE_EDITOR ); + ExecCommand(COMMAND_IMAGE_EDITOR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::UpdateSceneTextures1Click(TObject *Sender) { - ExecCommand( COMMAND_RELOAD_TEXTURES ); + ExecCommand(COMMAND_RELOAD_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MenuItem9Click(TObject *Sender) { - ExecCommand( COMMAND_REFRESH_TEXTURES ); + ExecCommand(COMMAND_REFRESH_TEXTURES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MenuItem14Click(TObject *Sender) { - ExecCommand( COMMAND_REFRESH_SOUND_ENVS ); + ExecCommand(COMMAND_REFRESH_SOUND_ENVS); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::UpdateEnvironmentGeometry1Click( - TObject *Sender) + TObject *Sender) { - ExecCommand( COMMAND_REFRESH_SOUND_ENV_GEOMETRY ); + ExecCommand(COMMAND_REFRESH_SOUND_ENV_GEOMETRY); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebObjectListClick(TObject *Sender) { - ExecCommand( COMMAND_SHOW_OBJECTLIST ); + ExecCommand(COMMAND_SHOW_OBJECTLIST); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebEditLibClick(TObject *Sender) { - ExecCommand( COMMAND_LIBRARY_EDITOR ); + ExecCommand(COMMAND_LIBRARY_EDITOR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::TargetClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); VERIFY(btn); - ExecCommand(COMMAND_CHANGE_TARGET, btn->Down?btn->Tag:OBJCLASS_DUMMY); + TExtBtn *btn = dynamic_cast(Sender); + VERIFY(btn); + ExecCommand(COMMAND_CHANGE_TARGET, btn->Down ? btn->Tag : OBJCLASS_DUMMY); // turn off snap mode - ebSnapListMode->Down = false; + ebSnapListMode->Down = false; } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::PanelMimimizeClickClick(TObject *Sender) @@ -360,6 +431,7 @@ void __fastcall TfraLeftBar::PanelMimimizeClickClick(TObject *Sender) PanelMinMaxClick(Sender); UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::PanelMaximizeClick(TObject *Sender) @@ -367,395 +439,460 @@ void __fastcall TfraLeftBar::PanelMaximizeClick(TObject *Sender) ::PanelMaximizeClick(Sender); UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebEditorPreferencesClick(TObject *Sender) { - ExecCommand(COMMAND_EDITOR_PREF); + ExecCommand(COMMAND_EDITOR_PREF); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebInvertClick(TObject *Sender) { - ExecCommand(COMMAND_INVERT_SELECTION_ALL); + ExecCommand(COMMAND_INVERT_SELECTION_ALL); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSelectAllClick(TObject *Sender) { - ExecCommand(COMMAND_SELECT_ALL); + ExecCommand(COMMAND_SELECT_ALL); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebUnselectAllClick(TObject *Sender) { - ExecCommand(COMMAND_DESELECT_ALL); + ExecCommand(COMMAND_DESELECT_ALL); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebDeleteClick(TObject *Sender) { - ExecCommand(COMMAND_DELETE_SELECTION); + ExecCommand(COMMAND_DELETE_SELECTION); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebHideAllClick(TObject *Sender) { - ExecCommand(COMMAND_HIDE_ALL,FALSE); + ExecCommand(COMMAND_HIDE_ALL, FALSE); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebUnhideAllClick(TObject *Sender) { - ExecCommand(COMMAND_HIDE_ALL,TRUE); + ExecCommand(COMMAND_HIDE_ALL, TRUE); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebHideSelectedClick(TObject *Sender) { - ExecCommand(COMMAND_HIDE_SEL,FALSE); + ExecCommand(COMMAND_HIDE_SEL, FALSE); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebHideUnselectedClick(TObject *Sender) { - ExecCommand(COMMAND_HIDE_UNSEL); + ExecCommand(COMMAND_HIDE_UNSEL); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebMakeGameClick(TObject *Sender) { - ExecCommand( COMMAND_MAKE_GAME ); + ExecCommand(COMMAND_MAKE_GAME); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MakeDetailsClick(TObject *Sender) { - ExecCommand( COMMAND_MAKE_DETAILS ); + ExecCommand(COMMAND_MAKE_DETAILS); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MakeHOM1Click(TObject *Sender) { - ExecCommand( COMMAND_MAKE_HOM ); + ExecCommand(COMMAND_MAKE_HOM); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MakeSoundOccluder1Click(TObject *Sender) { - ExecCommand( COMMAND_MAKE_SOM ); + ExecCommand(COMMAND_MAKE_SOM); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MakeAIMap1Click(TObject *Sender) { - ExecCommand( COMMAND_MAKE_AIMAP ); + ExecCommand(COMMAND_MAKE_AIMAP); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSceneFileMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmSceneFile,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmSceneFile, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSceneMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmScene,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmScene, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebCompileMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmCompile,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmCompile, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExtBtn2MouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmObjects,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmObjects, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebImagesMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmImages,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmImages, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSoundsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmSounds,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmSounds, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExtBtn7MouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmToolsEdit,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmToolsEdit, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExtBtn8MouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmToolsSelection,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmToolsSelection, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExtBtn10MouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmToolsVisibility,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmToolsVisibility, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebLightAnimationEditorClick(TObject *Sender) { - ExecCommand(COMMAND_LANIM_EDITOR); + ExecCommand(COMMAND_LANIM_EDITOR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebClearSnapClick(TObject *Sender) { - if (ELog.DlgMsg(mtConfirmation,TMsgDlgButtons() << mbYes << mbNo,"Are you sure to clear snap objects?")==mrYes) - ExecCommand(COMMAND_CLEAR_SNAP_OBJECTS); + if (ELog.DlgMsg(mtConfirmation, TMsgDlgButtons()<Items->Clear(); - ObjectList* lst = Scene->GetSnapList(true); - if (lst&&!lst->empty()){ - int idx=0; - ObjectIt _F=lst->begin(); - for (;_F!=lst->end(); _F++,idx++){ - AnsiString s; s.sprintf("%d: %s",idx,(*_F)->Name); - lbSnapList->Items->Add(s); + lbSnapList->Items->Clear(); + ObjectList *lst = Scene->GetSnapList(true); + if (lst&&!lst->empty()) + { + int idx = 0; + ObjectIt _F = lst->begin(); + for (; _F!=lst->end(); _F++,idx++) + { + AnsiString s; + s.sprintf("%d: %s", idx, (*_F)->Name); + lbSnapList->Items->Add(s); } } Repaint(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExtBtn1MouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - FHelper.ShowPPMenu(pmSnapListCommand,dynamic_cast(Sender)); + FHelper.ShowPPMenu(pmSnapListCommand, dynamic_cast(Sender)); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebUseSnapListClick(TObject *Sender) { - UI->RedrawScene(); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::miPropertiesClick(TObject *Sender) { ExecCommand(COMMAND_SHOW_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Quit1Click(TObject *Sender) { - ExecCommand(COMMAND_QUIT); + ExecCommand(COMMAND_QUIT); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebPropertiesClick(TObject *Sender) { - ExecCommand(COMMAND_SHOW_PROPERTIES); + ExecCommand(COMMAND_SHOW_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebMultiRenameClick(TObject *Sender) { - ExecCommand(COMMAND_MULTI_RENAME_OBJECTS); + ExecCommand(COMMAND_MULTI_RENAME_OBJECTS); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ImportCompilerErrorsClick(TObject *Sender) { - ExecCommand(COMMAND_IMPORT_COMPILER_ERROR); + ExecCommand(COMMAND_IMPORT_COMPILER_ERROR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExportErrorList1Click(TObject *Sender) { - ExecCommand(COMMAND_EXPORT_COMPILER_ERROR); + ExecCommand(COMMAND_EXPORT_COMPILER_ERROR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebIgnoreModeClick(TObject *Sender) { - ExecCommand(COMMAND_UPDATE_PROPERTIES); + ExecCommand(COMMAND_UPDATE_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::miClearErrorListClick(TObject *Sender) { - ExecCommand(COMMAND_CLEAR_DEBUG_DRAW); + ExecCommand(COMMAND_CLEAR_DEBUG_DRAW); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ebSnapListModeClick(TObject *Sender) { - TExtBtn* E = dynamic_cast(Sender); VERIFY(E); - if (E->Down&&(etaSelect!=Tools->GetAction())){ - ELog.Msg(mtError,"Before modify snap list activate select mode!"); + TExtBtn *E = dynamic_cast(Sender); + VERIFY(E); + if (E->Down&&(etaSelect!=Tools->GetAction())) + { + ELog.Msg(mtError, "Before modify snap list activate select mode!"); E->Down = false; } } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::MenuItem12Click(TObject *Sender) { - ExecCommand(COMMAND_SOUND_EDITOR); + ExecCommand(COMMAND_SOUND_EDITOR); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::SynchronizeSounds1Click(TObject *Sender) { - ExecCommand(COMMAND_SYNC_SOUNDS); + ExecCommand(COMMAND_SYNC_SOUNDS); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::miRecentFilesClick(TObject *Sender) { - TMenuItem* MI = dynamic_cast(Sender); R_ASSERT(MI&&(MI->Tag==0x1001)); - xr_string fn = AnsiString(MI->Caption).c_str(); - ExecCommand (COMMAND_LOAD,fn); + TMenuItem *MI = dynamic_cast(Sender); + R_ASSERT(MI&&(MI->Tag==0x1001)); + xr_string fn = AnsiString(MI->Caption).c_str(); + ExecCommand(COMMAND_LOAD, fn); } + //--------------------------------------------------------------------------- void TfraLeftBar::RefreshBar() { - miRecentFiles->Clear(); - u32 idx = 0; - for (AStringIt it=EPrefs->scene_recent_list.begin(); it!=EPrefs->scene_recent_list.end(); it++){ - TMenuItem *MI = xr_new((TComponent*)0); - MI->Caption = *it; - MI->OnClick = miRecentFilesClick; - MI->Tag = 0x1001; - miRecentFiles->Insert(idx++,MI); + miRecentFiles->Clear(); + u32 idx = 0; + for (AStringIt it = EPrefs->scene_recent_list.begin(); it!=EPrefs->scene_recent_list.end(); it++) + { + TMenuItem *MI = xr_new((TComponent*)0); + MI->Caption = *it; + MI->OnClick = miRecentFilesClick; + MI->Tag = 0x1001; + miRecentFiles->Insert(idx++, MI); } miRecentFiles->Enabled = miRecentFiles->Count; // refresh target - for (ObjClassID k=OBJCLASS_FIRST_CLASS; kGetTool(k); - if(!t) + ESceneToolBase *t = Scene->GetTool(k); + if (!t) { - Msg("unknown tool"); - }else + Msg("unknown tool"); + } + else { - m_TargetButtons[k].first->Enabled = t->IsEnabled(); - m_TargetButtons[k].first->NormalColor = t->IsEditable()?clBlack:clGray; - m_TargetButtons[k].first->Font->Style = t->IsForceReadonly()?TFontStyles()<Enabled = t->IsEnabled(); + m_TargetButtons[k].first->NormalColor = t->IsEditable() ? clBlack : clGray; + m_TargetButtons[k].first->Font->Style = t->IsForceReadonly() ? TFontStyles()<Down = t->IsVisible(); + m_TargetButtons[k].second->Down = t->IsVisible(); } } } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ClearDebugDraw1Click(TObject *Sender) { - ExecCommand(COMMAND_CLEAR_DEBUG_DRAW); + ExecCommand(COMMAND_CLEAR_DEBUG_DRAW); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Editminimap1Click(TObject *Sender) { - ExecCommand( COMMAND_MINIMAP_EDITOR ); + ExecCommand(COMMAND_MINIMAP_EDITOR); } + //--------------------------------------------------------------------------- //. #include "..\ECore\editor\EThumbnailTexture.h" #include "..\ECore\editor\EThumbnail.h" + void __fastcall TfraLeftBar::SyncTHM1Click(TObject *Sender) { - FS_FileSet files; - FS.file_list (files,_textures_,FS_ListFiles,"*.thm"); - FS_FileSet::iterator I = files.begin(); - FS_FileSet::iterator E = files.end(); + FS_FileSet files; + FS.file_list(files,_textures_, FS_ListFiles, "*.thm"); + FS_FileSet::iterator I = files.begin(); + FS_FileSet::iterator E = files.end(); - for(; I!=E; ++I) - { - ETextureThumbnail* TH = xr_new( (*I).name.c_str(), false); - TH->Load((*I).name.c_str(),_textures_); - TH->Save(); - xr_delete(TH); - } + for (; I!=E; ++I) + { + ETextureThumbnail*TH = xr_new((*I).name.c_str(),false); + TH->Load((*I).name.c_str(),_textures_); + TH->Save(); + xr_delete(TH); + } } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::Makepack1Click(TObject *Sender) { - TDB_packer::ActivatePacker(); + TDB_packer::ActivatePacker(); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ExportObjClick(TObject *Sender) { - Scene->ExportObj(false); + Scene->ExportObj(false); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::e1Click(TObject *Sender) { - Scene->ExportObj(true); + Scene->ExportObj(true); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::btEnableObjectClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); VERIFY(btn); + TExtBtn *btn = dynamic_cast(Sender); + VERIFY(btn); - ESceneToolBase* M = Scene->GetTool(btn->Tag); - VERIFY (M); - int whatToDo = M->IsVisible()? 0 : 1; - ExecCommand (COMMAND_SHOW_TARGET, btn->Tag, whatToDo); + ESceneToolBase *M = Scene->GetTool(btn->Tag); + VERIFY(M); + int whatToDo = M->IsVisible() ? 0 : 1; + ExecCommand(COMMAND_SHOW_TARGET, btn->Tag, whatToDo); } + //--------------------------------------------------------------------------- void __fastcall TfraLeftBar::ClipEditor1Click(TObject *Sender) { - ExecCommand (COMMAND_SHOW_CLIP_EDITOR); + ExecCommand(COMMAND_SHOW_CLIP_EDITOR); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/LevelEditor.cpp b/src/editors/LevelEditor/LevelEditor.cpp index da73748060e..67c84c14ca5 100644 --- a/src/editors/LevelEditor/LevelEditor.cpp +++ b/src/editors/LevelEditor/LevelEditor.cpp @@ -1,94 +1,207 @@ #include "stdafx.h" #pragma hdrstop #include "splash.h" -#include "../ECore/Editor/LogForm.h" -#include "../ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/LogForm.h" +#include "editors/ECore/Editor/EditMesh.h" #include "main.h" #include "scene.h" #include "UI_LevelMain.h" #include "UI_LevelTools.h" //--------------------------------------------------------------------------- -USEFORM("BottomBar.cpp", fraBottomBar); /* TFrame: File Type */ -USEFORM("main.cpp", frmMain); -USEFORM("TopBar.cpp", fraTopBar); /* TFrame: File Type */ -USEFORM("DOOneColor.cpp", frmOneColor); -USEFORM("DOShuffle.cpp", frmDOShuffle); -USEFORM("EditLibrary.cpp", frmEditLibrary); -USEFORM("EditLightAnim.cpp", frmEditLightAnim); -USEFORM("FrameAIMap.cpp", fraAIMap); -USEFORM("FrameDetObj.cpp", fraDetailObject); -USEFORM("FrameGroup.cpp", fraGroup); -USEFORM("FrameLight.cpp", fraLight); -USEFORM("FrameObject.cpp", fraObject); -USEFORM("FramePortal.cpp", fraPortal); -USEFORM("FramePS.cpp", fraPS); -USEFORM("FrameSector.cpp", fraSector); -USEFORM("FrameShape.cpp", fraShape); -USEFORM("FrameSpawn.cpp", fraSpawn); -USEFORM("FrameWayPoint.cpp", fraWayPoint); -USEFORM("LeftBar.cpp", fraLeftBar); /* TFrame: File Type */ -USEFORM("ObjectList.cpp", frmObjectList); -USEFORM("previewimage.cpp", frmPreviewImage); -USEFORM("PropertiesEObject.cpp", frmPropertiesEObject); -USEFORM("Splash.cpp", frmSplash); -USEFORM("FrmDBXpacker.cpp", DB_packer); -USEFORM("RightForm.cpp", frmRight); -USEFORM("FrameFogVol.cpp", fraFogVol); -USEFORM("Edit\AppendObjectInfoForm.cpp", frmAppendObjectInfo); -USEFORM("LEClipEditor.cpp", ClipMaker); +USEFORM ( +"BottomBar.cpp" +, +fraBottomBar +); /* TFrame: File Type */ +USEFORM ( +"main.cpp" +, +frmMain +); +USEFORM ( +"TopBar.cpp" +, +fraTopBar +); /* TFrame: File Type */ +USEFORM ( +"DOOneColor.cpp" +, +frmOneColor +); +USEFORM ( +"DOShuffle.cpp" +, +frmDOShuffle +); +USEFORM ( +"EditLibrary.cpp" +, +frmEditLibrary +); +USEFORM ( +"EditLightAnim.cpp" +, +frmEditLightAnim +); +USEFORM ( +"FrameAIMap.cpp" +, +fraAIMap +); +USEFORM ( +"FrameDetObj.cpp" +, +fraDetailObject +); +USEFORM ( +"FrameGroup.cpp" +, +fraGroup +); +USEFORM ( +"FrameLight.cpp" +, +fraLight +); +USEFORM ( +"FrameObject.cpp" +, +fraObject +); +USEFORM ( +"FramePortal.cpp" +, +fraPortal +); +USEFORM ( +"FramePS.cpp" +, +fraPS +); +USEFORM ( +"FrameSector.cpp" +, +fraSector +); +USEFORM ( +"FrameShape.cpp" +, +fraShape +); +USEFORM ( +"FrameSpawn.cpp" +, +fraSpawn +); +USEFORM ( +"FrameWayPoint.cpp" +, +fraWayPoint +); +USEFORM ( +"LeftBar.cpp" +, +fraLeftBar +); /* TFrame: File Type */ +USEFORM ( +"ObjectList.cpp" +, +frmObjectList +); +USEFORM ( +"previewimage.cpp" +, +frmPreviewImage +); +USEFORM ( +"PropertiesEObject.cpp" +, +frmPropertiesEObject +); +USEFORM ( +"Splash.cpp" +, +frmSplash +); +USEFORM ( +"FrmDBXpacker.cpp" +, +DB_packer +); +USEFORM ( +"RightForm.cpp" +, +frmRight +); +USEFORM ( +"FrameFogVol.cpp" +, +fraFogVol +); +USEFORM ( +"Edit\AppendObjectInfoForm.cpp" +, +frmAppendObjectInfo +); +USEFORM ( +"LEClipEditor.cpp" +, +ClipMaker +); + //--------------------------------------------------------------------------- WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int) { -// try{ - if (!Application->Handle){ - Application->CreateHandle (); - Application->Icon->Handle = LoadIcon(MainInstance, "MAINICON"); - Application->Title = "Loading..."; - } - frmSplash = xr_new((TComponent*)0); - frmSplash->Show (); - frmSplash->Repaint (); - frmSplash->SetStatus ("Core initializing..."); + // try{ + if (!Application->Handle) + { + Application->CreateHandle(); + Application->Icon->Handle = LoadIcon(MainInstance, "MAINICON"); + Application->Title = "Loading..."; + } + frmSplash = xr_new((TComponent*)0); + frmSplash->Show(); + frmSplash->Repaint(); + frmSplash->SetStatus("Core initializing..."); + + Core._initialize("level", ELogCallback); + CEditableMesh::m_bDraftMeshMode = TRUE; + Application->Initialize(); - Core._initialize ("level",ELogCallback); - CEditableMesh::m_bDraftMeshMode = TRUE; - Application->Initialize (); - - frmSplash->SetStatus ("Loading..."); + frmSplash->SetStatus("Loading..."); -// startup create - Tools = xr_new(); - UI = xr_new(); - UI->RegisterCommands (); - Scene = xr_new(); - Application->Title = UI->EditorDesc(); - TfrmLog::CreateLog (); - Application->CreateForm(__classid(TfrmMain), &frmMain); - Application->CreateForm(__classid(TfrmRight), &frmRight); - frmMain->SetHInst (hInst); + // startup create + Tools = xr_new(); + UI = xr_new(); + UI->RegisterCommands(); + Scene = xr_new(); + Application->Title = UI->EditorDesc(); + TfrmLog::CreateLog(); + Application->CreateForm(__classid(TfrmMain), &frmMain); + Application->CreateForm(__classid(TfrmRight), &frmRight); + frmMain->SetHInst(hInst); - xr_delete(frmSplash); + xr_delete(frmSplash); - Application->Run (); + Application->Run(); - TfrmLog::DestroyLog (); + TfrmLog::DestroyLog(); - UI->ClearCommands (); - xr_delete (Scene); - xr_delete (Tools); - xr_delete (UI); + UI->ClearCommands(); + xr_delete(Scene); + xr_delete(Tools); + xr_delete(UI); - Core._destroy (); -// } -// catch (Exception &exception) -// { -// Application->ShowException(&exception); -// } + Core._destroy(); + // } + // catch (Exception &exception) + // { + // Application->ShowException(&exception); + // } return 0; } -//--------------------------------------------------------------------------- - +//--------------------------------------------------------------------------- diff --git a/src/editors/LevelEditor/ObjectList.cpp b/src/editors/LevelEditor/ObjectList.cpp index 50193826339..b25f488e600 100644 --- a/src/editors/LevelEditor/ObjectList.cpp +++ b/src/editors/LevelEditor/ObjectList.cpp @@ -3,555 +3,586 @@ // test comment #include "ObjectList.h" #include "GroupObject.h" -#include "ui_leveltools.h" +#include "UI_LevelTools.h" #include "Scene.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "mxPlacemnt" #pragma link "ElEdits" #pragma resource "*.dfm" //--------------------------------------------------------------------------- -TfrmObjectList* TfrmObjectList::CreateForm(TWinControl* parent) +TfrmObjectList *TfrmObjectList::CreateForm(TWinControl *parent) { - TfrmObjectList* OL=xr_new(parent); - if (parent) OL->Parent = parent; - return OL; + TfrmObjectList *OL = xr_new(parent); + if (parent) + OL->Parent = parent; + return OL; } -void TfrmObjectList::DestroyForm(TfrmObjectList*& obj_list) +void TfrmObjectList::DestroyForm(TfrmObjectList *&obj_list) { - VERIFY(obj_list); + VERIFY(obj_list); xr_delete(obj_list); } void __fastcall TfrmObjectList::ShowObjectList() { - Show(); + Show(); } void __fastcall TfrmObjectList::ShowObjectListModal() { - ShowModal(); + ShowModal(); } void __fastcall TfrmObjectList::HideObjectList() { - Hide(); + Hide(); } void __fastcall TfrmObjectList::UpdateObjectList() { - if (Visible&&!bLockUpdate) sbRefreshListClick(0); + if (Visible&&!bLockUpdate) + sbRefreshListClick(0); } //--------------------------------------------------------------------------- -__fastcall TfrmObjectList::TfrmObjectList(TComponent* Owner) +__fastcall TfrmObjectList::TfrmObjectList(TComponent *Owner) : TForm(Owner) { - bLockUpdate = false; - find_node = NULL; + bLockUpdate = false; + find_node = NULL; } void __fastcall TfrmObjectList::sbCloseClick(TObject *Sender) { Close(); } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::FormShow(TObject *Sender) { obj_count = 0; m_cur_cls = OBJCLASS_DUMMY; - tvItems->FilteredVisibility = ((rgSO->ItemIndex==1)||(rgSO->ItemIndex==2)); + tvItems->FilteredVisibility = ((rgSO->ItemIndex==1)||(rgSO->ItemIndex==2)); InitListBox(); - // check window position + // check window position UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- -TElTreeItem* TfrmObjectList::FindFolderByType(int type) +TElTreeItem *TfrmObjectList::FindFolderByType(int type) { - for ( TElTreeItem* node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) - if (!node->Parent && (node->Tag == type)) return node; + for (TElTreeItem *node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) + if (!node->Parent&&(node->Tag==type)) + return node; return 0; } + //--------------------------------------------------------------------------- -TElTreeItem* TfrmObjectList::FindObjectByType(int type, void *obj) +TElTreeItem *TfrmObjectList::FindObjectByType(int type, void *obj) { - for ( TElTreeItem* node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) - if (!node->Parent && (node->Tag==type)) + for (TElTreeItem *node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) + if (!node->Parent&&(node->Tag==type)) { - for (TElTreeItem* chield = node->GetFirstChild(); chield; chield = node->GetNextChild(chield)) - if (chield->Data==obj) - return chield; + for (TElTreeItem *chield = node->GetFirstChild(); chield; chield = node->GetNextChild(chield)) + if (chield->Data==obj) + return chield; break; } return 0; } + //--------------------------------------------------------------------------- -TElTreeItem* TfrmObjectList::AddFolder(LPCSTR name, void* data, TElTreeItem* parent_node) +TElTreeItem *TfrmObjectList::AddFolder(LPCSTR name, void *data, TElTreeItem *parent_node) { - for(TElTreeItem* fnode = tvItems->Items->GetFirstNode(); fnode; fnode = fnode->GetNext()) + for (TElTreeItem *fnode = tvItems->Items->GetFirstNode(); fnode; fnode = fnode->GetNext()) { - if( fnode->Parent==parent_node ) - if( AnsiString(fnode->Text)==name ) - return fnode; + if (fnode->Parent==parent_node) + if (AnsiString(fnode->Text)==name) + return fnode; } - TElTreeItem* node; - if(parent_node) - node = tvItems->Items->AddChildObject(parent_node, name, NULL); + TElTreeItem *node; + if (parent_node) + node = tvItems->Items->AddChildObject(parent_node, name, NULL); else - node = tvItems->Items->AddObject(parent_node, name, NULL); - - node->ParentStyle = false; - node->Bold = true; - return node; + node = tvItems->Items->AddObject(parent_node, name, NULL); + + node->ParentStyle = false; + node->Bold = true; + return node; } -TElTreeItem* TfrmObjectList::AddObject(TElTreeItem* node, LPCSTR name, void* obj, TColor color) +TElTreeItem *TfrmObjectList::AddObject(TElTreeItem *node, LPCSTR name, void *obj, TColor color) { - TElTreeItem* ret = tvItems->Items->AddChildObject(node, name, obj); + TElTreeItem *ret = tvItems->Items->AddChildObject(node, name, obj); - ret->ParentColors = false; + ret->ParentColors = false; node->ParentStyle = false; - ret->Color = color; - ret->BkColor = clGray; + ret->Color = color; + ret->BkColor = clGray; return ret; } -void gen_object_name(CCustomObject* O, string1024& str_name, bool b_parent_is_group) +void gen_object_name(CCustomObject *O, string1024 &str_name, bool b_parent_is_group) { - if(b_parent_is_group) - { - sprintf ( str_name, - "[%s] %s", - O->ParentTool->ClassDesc(), - O->Name); - }else - { - sprintf ( str_name, - "%s", - O->Name); - } + if (b_parent_is_group) + { + sprintf(str_name, + "[%s] %s", + O->ParentTool->ClassDesc(), + O->Name); + } + else + { + sprintf(str_name, + "%s", + O->Name); + } } -void gen_group_name(CGroupObject* O, string1024& str_name) +void gen_group_name(CGroupObject *O, string1024 &str_name) { - strcpy (str_name, O->RefName()); + strcpy(str_name, O->RefName()); - if(strchr(str_name,'\\')) - *strchr(str_name,'\\') = 0; + if (strchr(str_name, '\\')) + *strchr(str_name, '\\') = 0; } void TfrmObjectList::storeExpandedItems() { - ItemsStore.clear(); + ItemsStore.clear(); - for ( TElTreeItem* node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) + for (TElTreeItem *node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) { - if(node->Expanded) - ItemsStore[node->Text].expanded = true; - } + if (node->Expanded) + ItemsStore[node->Text].expanded = true; + } } void TfrmObjectList::restoreExpandedItems() { - for ( TElTreeItem* node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) + for (TElTreeItem *node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) { - FolderStorePairIt it = ItemsStore.find(node->Text); + FolderStorePairIt it = ItemsStore.find(node->Text); if (it!=ItemsStore.end()) - node->Expand(false); - } - + node->Expand(false); + } } void __fastcall TfrmObjectList::InitListBox() { - storeExpandedItems (); - tvItems->IsUpdating = true; - tvItems->Items->Clear (); - m_cur_cls = LTools->CurrentClassID(); - string1024 str_name; - - for(SceneToolsMapPairIt it=Scene->FirstTool(); it!=Scene->LastTool(); ++it) + storeExpandedItems(); + tvItems->IsUpdating = true; + tvItems->Items->Clear(); + m_cur_cls = LTools->CurrentClassID(); + string1024 str_name; + + for (SceneToolsMapPairIt it = Scene->FirstTool(); it!=Scene->LastTool(); ++it) { - ESceneCustomOTool* ot = dynamic_cast(it->second); + ESceneCustomOTool *ot = dynamic_cast(it->second); if (ot&&((m_cur_cls==OBJCLASS_DUMMY)||(it->first==m_cur_cls))) { - if (it->first==OBJCLASS_DUMMY) - continue; + if (it->first==OBJCLASS_DUMMY) + continue; - TElTreeItem* tool_node = FindFolderByType(it->first); + TElTreeItem *tool_node = FindFolderByType(it->first); if (!tool_node) { - AnsiString name; - name.sprintf ("%ss",it->second->ClassDesc()); - tool_node = AddFolder(name.LowerCase().c_str(), NULL, NULL); - tool_node->Tag = it->first; + AnsiString name; + name.sprintf("%ss", it->second->ClassDesc()); + tool_node = AddFolder(name.LowerCase().c_str(), NULL, NULL); + tool_node->Tag = it->first; } - ObjectList& lst = ot->GetObjects(); - + ObjectList &lst = ot->GetObjects(); + if (OBJCLASS_GROUP==it->first) { - for(ObjectIt _F = lst.begin();_F!=lst.end();++_F) + for (ObjectIt _F = lst.begin(); _F!=lst.end(); ++_F) { - TElTreeItem* group_profile_node = NULL; - - gen_group_name ((CGroupObject*)(*_F), str_name); - group_profile_node = AddFolder(str_name, NULL, tool_node); - group_profile_node->Tag = -1; - - TElTreeItem* grp_node = AddObject(group_profile_node, str_name, (void*)(*_F), clBlack); - - ObjectList grp_lst; - + TElTreeItem *group_profile_node = NULL; + + gen_group_name((CGroupObject*)(*_F), str_name); + group_profile_node = AddFolder(str_name, NULL, tool_node); + group_profile_node->Tag = -1; + + TElTreeItem *grp_node = AddObject(group_profile_node, str_name, (void*)(*_F), clBlack); + + ObjectList grp_lst; + ((CGroupObject*)(*_F))->GetObjects(grp_lst); - - for (ObjectIt _G=grp_lst.begin(); _G!=grp_lst.end(); ++_G) + + for (ObjectIt _G = grp_lst.begin(); _G!=grp_lst.end(); ++_G) { - gen_object_name (*_G, str_name, true); - TElTreeItem* obj = AddObject ( grp_node, - str_name, - (void*)(*_G), - (*_G)->m_CO_Flags.test(CCustomObject::flObjectInGroupUnique)?clBlack:TColor(0x00a9a6a0)); + gen_object_name(*_G, str_name, true); + TElTreeItem *obj = AddObject(grp_node, + str_name, + (void*)(*_G), + (*_G)->m_CO_Flags.test(CCustomObject::flObjectInGroupUnique) ? clBlack : TColor(0x00a9a6a0)); } } - for (TElTreeItem* chield = tool_node->GetFirstChild(); chield; chield = tool_node->GetNextChild(chield)) - chield->Collapse(true); - - - }else + for (TElTreeItem *chield = tool_node->GetFirstChild(); chield; chield = tool_node->GetNextChild(chield)) + chield->Collapse(true); + } + else { - for(ObjectIt _F = lst.begin();_F!=lst.end();++_F) + for (ObjectIt _F = lst.begin(); _F!=lst.end(); ++_F) { - Flags32 fl = (*_F)->m_CO_Flags; - TElTreeItem* parent_node = tool_node; - if(fl.test(CCustomObject::flObjectInGroup)) - { - CGroupObject* GO = (CGroupObject*)((*_F)->GetOwner()); + Flags32 fl = (*_F)->m_CO_Flags; + TElTreeItem *parent_node = tool_node; + if (fl.test(CCustomObject::flObjectInGroup)) + { + CGroupObject *GO = (CGroupObject*)((*_F)->GetOwner()); string1024 gn; - gen_group_name (GO, gn); - sprintf (str_name,"inGroup %s", gn /*GO->RefName()*/); - parent_node = AddFolder(str_name, NULL, tool_node); - parent_node->Tag = -1; + gen_group_name(GO, gn); + sprintf(str_name, "inGroup %s", gn /*GO->RefName()*/); + parent_node = AddFolder(str_name, NULL, tool_node); + parent_node->Tag = -1; } - gen_object_name (*_F, str_name, false); - TColor clr = (fl.test(CCustomObject::flObjectInGroup) && !fl.test(CCustomObject::flObjectInGroupUnique)) ? TColor(0x00a9a6a0):clBlack; - AddObject (parent_node, str_name, (void*)(*_F), clr); + gen_object_name(*_F, str_name, false); + TColor clr = (fl.test(CCustomObject::flObjectInGroup)&&!fl.test(CCustomObject::flObjectInGroupUnique)) ? TColor(0x00a9a6a0) : clBlack; + AddObject(parent_node, str_name, (void*)(*_F), clr); } } tool_node->Expand(false); } } - tvItems->Sort (true); - tvItems->IsUpdating = false; + tvItems->Sort(true); + tvItems->IsUpdating = false; - UpdateState (); -//. tvItems->FullExpand (); - obj_count = Scene->ObjCount(); - find_node = NULL; + UpdateState(); + //. tvItems->FullExpand (); + obj_count = Scene->ObjCount(); + find_node = NULL; - restoreExpandedItems (); + restoreExpandedItems(); } void TfrmObjectList::UpdateState() { - tvItems->IsUpdating = true; + tvItems->IsUpdating = true; - tvItems->OnItemSelectedChange = 0; + tvItems->OnItemSelectedChange = 0; - TElTreeItem* sel_node = NULL; - u32 sel_count = 0; - TElTreeItem* first_sel_node = NULL; - bool need_sort = false; - - for ( TElTreeItem* node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) + TElTreeItem *sel_node = NULL; + u32 sel_count = 0; + TElTreeItem *first_sel_node = NULL; + bool need_sort = false; + + for (TElTreeItem *node = tvItems->Items->GetFirstNode(); node; node = node->GetNext()) { - if(NULL==node->Data) + if (NULL==node->Data) { - node->Selected = false; + node->Selected = false; continue; } - - TElTreeItem* parent_node = node->Parent; - CCustomObject* PO = (parent_node && parent_node->Data)?(CCustomObject*)parent_node->Data : NULL; - - CCustomObject* O = (CCustomObject*)node->Data; - - node->ParentStyle = false; - node->StrikeOut = !O->Visible(); - - if(rgSO->ItemIndex==1) - node->Hidden = !O->Visible(); - else - if(rgSO->ItemIndex==2) - node->Hidden = O->Visible(); - - if (O->Visible()) - node->Selected = O->Selected(); - - if (O->Selected()) + + TElTreeItem *parent_node = node->Parent; + CCustomObject *PO = (parent_node&&parent_node->Data) ? (CCustomObject*)parent_node->Data : NULL; + + CCustomObject *O = (CCustomObject*)node->Data; + + node->ParentStyle = false; + node->StrikeOut = !O->Visible(); + + if (rgSO->ItemIndex==1) + node->Hidden = !O->Visible(); + else if (rgSO->ItemIndex==2) + node->Hidden = O->Visible(); + + if (O->Visible()) + node->Selected = O->Selected(); + + if (O->Selected()) { ++sel_count; - sel_node = node; - if(first_sel_node==NULL && O->Visible()) - first_sel_node = node; + sel_node = node; + if (first_sel_node==NULL&&O->Visible()) + first_sel_node = node; } if (!node->Hidden) { - string1024 str_name; - bool b_parent_is_group = false; - if(PO && PO->ClassID==OBJCLASS_GROUP) - b_parent_is_group = true; - - gen_object_name (O, str_name, b_parent_is_group); - + string1024 str_name; + bool b_parent_is_group = false; + if (PO&&PO->ClassID==OBJCLASS_GROUP) + b_parent_is_group = true; + + gen_object_name(O, str_name, b_parent_is_group); + if (AnsiString(node->Text)!=str_name) { - node->Text = str_name; - need_sort = true; + node->Text = str_name; + need_sort = true; } - Flags32 fl = O->m_CO_Flags; - TColor clr = (fl.test(CCustomObject::flObjectInGroup) && !fl.test(CCustomObject::flObjectInGroupUnique)) ? TColor(0x00a9a6a0):clBlack; - if(node->Color!=clr) - node->Color = clr; + Flags32 fl = O->m_CO_Flags; + TColor clr = (fl.test(CCustomObject::flObjectInGroup)&&!fl.test(CCustomObject::flObjectInGroupUnique)) ? TColor(0x00a9a6a0) : clBlack; + if (node->Color!=clr) + node->Color = clr; } } - tvItems->IsUpdating = false; + tvItems->IsUpdating = false; - if (need_sort) - tvItems->Sort (true); - - if (first_sel_node && sel_count==1) - tvItems->EnsureVisible(first_sel_node); -} + if (need_sort) + tvItems->Sort(true); + + if (first_sel_node&&sel_count==1) + tvItems->EnsureVisible(first_sel_node); +} void TfrmObjectList::UpdateSelection() { - if(tvItems->Items->Count) + if (tvItems->Items->Count) { bLockUpdate = true; - Scene->SelectObjects( false, OBJCLASS_DUMMY/*m_cur_cls*/); - - for(TElTreeItem* node = tvItems->GetNextSelected(0); node; node=tvItems->GetNextSelected(node)) + Scene->SelectObjects(false, OBJCLASS_DUMMY/*m_cur_cls*/); + + for (TElTreeItem *node = tvItems->GetNextSelected(0); node; node = tvItems->GetNextSelected(node)) { - if(node->Data) + if (node->Data) { - CCustomObject* O = (CCustomObject*)(node->Data); + CCustomObject *O = (CCustomObject*)(node->Data); O->Select(true); ElEdit1->Text = O->Name; - - for(TElTreeItem* child = node->GetFirstChild(); child; child=node->GetNextChild(child)) + + for (TElTreeItem *child = node->GetFirstChild(); child; child = node->GetNextChild(child)) { - CCustomObject* CO = (CCustomObject*)(child->Data); - R_ASSERT (CO); - CO->Select (true); + CCustomObject *CO = (CCustomObject*)(child->Data); + R_ASSERT(CO); + CO->Select(true); } } - } + } UI->RedrawScene(); bLockUpdate = false; } } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::ebHideSelClick(TObject *Sender) { - for (TElTreeItem* node = tvItems->GetNextSelected(0); node; node=tvItems->GetNextSelected(node)) - if (node->Parent) - ((CCustomObject*)(node->Data))->Show(false); - + for (TElTreeItem *node = tvItems->GetNextSelected(0); node; node = tvItems->GetNextSelected(node)) + if (node->Parent) + ((CCustomObject*)(node->Data))->Show(false); + UpdateState(); } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::ebShowSelClick(TObject *Sender) { - for (TElTreeItem* node = tvItems->GetNextSelected(0); node; node=tvItems->GetNextSelected(node)) + for (TElTreeItem *node = tvItems->GetNextSelected(0); node; node = tvItems->GetNextSelected(node)) if (node->Parent) { - ((CCustomObject*)(node->Data))->Show (true); - ((CCustomObject*)(node->Data))->Select (true); + ((CCustomObject*)(node->Data))->Show(true); + ((CCustomObject*)(node->Data))->Select(true); } UpdateState(); } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::ebShowPropertiesClick(TObject *Sender) { - ExecCommand (COMMAND_SHOW_PROPERTIES); + ExecCommand(COMMAND_SHOW_PROPERTIES); } + //--------------------------------------------------------------------------- BOOL bForceInitListBox = FALSE; + void __fastcall TfrmObjectList::sbRefreshListClick(TObject *Sender) { - if((Scene->ObjCount()!=obj_count)||(m_cur_cls!=LTools->CurrentClassID()) || bForceInitListBox) + if ((Scene->ObjCount()!=obj_count)||(m_cur_cls!=LTools->CurrentClassID())||bForceInitListBox) { - InitListBox(); + InitListBox(); bForceInitListBox = FALSE; - }else - UpdateState(); + } + else + UpdateState(); } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::tmRefreshListTimer(TObject *Sender) { UpdateState(); } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::FormClose(TObject *Sender, - TCloseAction &Action) + TCloseAction &Action) { - tvItems->IsUpdating = true; - tvItems->Items->Clear (); - tvItems->IsUpdating = false; + tvItems->IsUpdating = true; + tvItems->Items->Clear(); + tvItems->IsUpdating = false; } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if (Key==VK_ESCAPE) sbClose->Click(); + if (Key==VK_ESCAPE) + sbClose->Click(); } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::rgSOClick(TObject *Sender) { - UpdateState(); - tvItems->FilteredVisibility = ((rgSO->ItemIndex==1)||(rgSO->ItemIndex==2)); + UpdateState(); + tvItems->FilteredVisibility = ((rgSO->ItemIndex==1)||(rgSO->ItemIndex==2)); } + //--------------------------------------------------------------------------- -extern bool __fastcall LookupFunc(TElTreeItem* Item, void* SearchDetails); +extern bool __fastcall LookupFunc(TElTreeItem *Item, void *SearchDetails); + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::tvItemsKeyPress(TObject *Sender, - char &Key) -{ - if (Key==VK_RETURN){ - ExecCommand (COMMAND_SHOW_PROPERTIES); - }else{ - TElTreeItem* node = tvItems->Items->LookForItemEx(tvItems->Selected,-1,false,false,false,&Key,LookupFunc); - if (!node) - node = tvItems->Items->LookForItemEx(0,-1,false,false,false,&Key,LookupFunc); - - FHelper.RestoreSelection(tvItems,node,false); + char &Key) +{ + if (Key==VK_RETURN) + { + ExecCommand(COMMAND_SHOW_PROPERTIES); + } + else + { + TElTreeItem *node = tvItems->Items->LookForItemEx(tvItems->Selected, -1, false, false, false, &Key, LookupFunc); + if (!node) + node = tvItems->Items->LookForItemEx(0, -1, false, false, false, &Key, LookupFunc); + + FHelper.RestoreSelection(tvItems, node, false); } } + //--------------------------------------------------------------------------- -#include "xr_input.h" +#include "xrEngine/xr_input.h" + void __fastcall TfrmObjectList::tvItemsItemFocused(TObject *Sender) { UpdateSelection(); } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::tvItemsAfterSelectionChange( - TObject *Sender) + TObject *Sender) { UpdateSelection(); } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::tvItemsDblClick(TObject *Sender) { - TElTreeItem* node = tvItems->ItemFocused; - if(node->Data) - ExecCommand (COMMAND_SHOW_PROPERTIES); + TElTreeItem *node = tvItems->ItemFocused; + if (node->Data) + ExecCommand(COMMAND_SHOW_PROPERTIES); } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::ElEdit1Change(TObject *Sender) { - TElEdit* edt = (TElEdit*)Sender; - AnsiString str = edt->Text; - ProcessFindItemInList (tvItems->Items->GetFirstNode(), str); + TElEdit *edt = (TElEdit*)Sender; + AnsiString str = edt->Text; + ProcessFindItemInList(tvItems->Items->GetFirstNode(), str); } + //--------------------------------------------------------------------------- -void TfrmObjectList::ProcessFindItemInList(TElTreeItem* from, AnsiString str) +void TfrmObjectList::ProcessFindItemInList(TElTreeItem *from, AnsiString str) { - bool bfound = false; - for ( TElTreeItem* node = from; node; node = node->GetNext()) + bool bfound = false; + for (TElTreeItem *node = from; node; node = node->GetNext()) { - if(NULL==node->Data) - continue; - - CCustomObject* O = (CCustomObject*)node->Data; - if( strstr(O->FName.c_str(), str.c_str()) ) + if (NULL==node->Data) + continue; + + CCustomObject *O = (CCustomObject*)node->Data; + if (strstr(O->FName.c_str(), str.c_str())) { - if(find_node) + if (find_node) { - find_node->ParentColors = stored_parent_colors; - find_node->BkColor = storred_bk_color; + find_node->ParentColors = stored_parent_colors; + find_node->BkColor = storred_bk_color; } - stored_parent_colors = node->ParentColors; - storred_bk_color = node->BkColor; - find_node = node; + stored_parent_colors = node->ParentColors; + storred_bk_color = node->BkColor; + find_node = node; - find_node->MakeVisible (); - find_node->ParentColors = false; - find_node->BkColor = clYellow; + find_node->MakeVisible(); + find_node->ParentColors = false; + find_node->BkColor = clYellow; - bfound = true; + bfound = true; break; - } - } + } + } - if(!bfound && find_node) + if (!bfound&&find_node) { - find_node->ParentColors = stored_parent_colors; - find_node->BkColor = storred_bk_color; - find_node = NULL; + find_node->ParentColors = stored_parent_colors; + find_node->BkColor = storred_bk_color; + find_node = NULL; } } void __fastcall TfrmObjectList::ElEdit1Exit(TObject *Sender) { - if(find_node) + if (find_node) { - find_node->ParentColors = stored_parent_colors; - find_node->BkColor = storred_bk_color; + find_node->ParentColors = stored_parent_colors; + find_node->BkColor = storred_bk_color; } -//. find_node = NULL; + //. find_node = NULL; } + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::ElEdit1KeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if(Key == VK_F3) + if (Key==VK_F3) { - TElEdit* edt = ElEdit1; - AnsiString str = edt->Text; - ProcessFindItemInList ((find_node&&find_node->GetNext())?find_node->GetNext():tvItems->Items->GetFirstNode(), str); + TElEdit *edt = ElEdit1; + AnsiString str = edt->Text; + ProcessFindItemInList((find_node&&find_node->GetNext()) ? find_node->GetNext() : tvItems->Items->GetFirstNode(), str); } } + //--------------------------------------------------------------------------- void __fastcall TfrmObjectList::tvItemsMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - TElTreeItem* node = tvItems->GetNodeAt(X,Y); - if(node && NULL==node->Data) + TElTreeItem *node = tvItems->GetNodeAt(X, Y); + if (node&&NULL==node->Data) { - if(node->Expanded) + if (node->Expanded) node->Collapse(Button==mbRight); else node->Expand(Button==mbRight); } } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/ObjectList.h b/src/editors/LevelEditor/ObjectList.h index 9d14d17882d..663f2ac9c5c 100644 --- a/src/editors/LevelEditor/ObjectList.h +++ b/src/editors/LevelEditor/ObjectList.h @@ -23,74 +23,78 @@ //--------------------------------------------------------------------------- class TfrmObjectList : public TForm { -__published: // IDE-managed Components - TPanel *Panel1; - TRadioGroup *rgSO; - TExtBtn *ebShowSel; - TExtBtn *ebHideSel; - TFormStorage *fsStorage; - TPanel *Panel2; - TExtBtn *sbRefreshList; - TExtBtn *sbClose; - TExtBtn *ebShowProperties; - TPanel *Panel3; - TElTree *tvItems; - TPanel *Panel4; - TElEdit *ElEdit1; - void __fastcall sbCloseClick (TObject *Sender); - void __fastcall FormShow (TObject *Sender); - void __fastcall ebHideSelClick (TObject *Sender); - void __fastcall ebShowSelClick (TObject *Sender); - void __fastcall sbRefreshListClick (TObject *Sender); - void __fastcall tmRefreshListTimer (TObject *Sender); - void __fastcall FormClose (TObject *Sender, TCloseAction &Action); - void __fastcall FormKeyDown (TObject *Sender, WORD &Key, TShiftState Shift); - void __fastcall rgSOClick (TObject *Sender); - void __fastcall tvItemsKeyPress (TObject *Sender, char &Key); - void __fastcall tvItemsItemFocused (TObject *Sender); - void __fastcall tvItemsAfterSelectionChange(TObject *Sender); - void __fastcall ebShowPropertiesClick(TObject *Sender); - void __fastcall tvItemsDblClick (TObject *Sender); - void __fastcall ElEdit1Change(TObject *Sender); - void __fastcall ElEdit1Exit(TObject *Sender); - void __fastcall ElEdit1KeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall tvItemsMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); -private: // User declarations - int obj_count; - ObjClassID m_cur_cls; - void __fastcall InitListBox (); - TElTreeItem* FindObjectByType (int type, void *obj); - TElTreeItem* FindFolderByType (int type); - TElTreeItem* AddFolder (LPCSTR name, void* data, TElTreeItem* parent_node); - TElTreeItem* AddObject (TElTreeItem* node, LPCSTR name, void* obj, TColor color); - void UpdateState (); - void UpdateSelection (); - bool bLockUpdate; - TElTreeItem* find_node; - bool stored_parent_colors; - TColor storred_bk_color; - void ProcessFindItemInList(TElTreeItem* from, AnsiString str); + __published: // IDE-managed Components + TPanel*Panel1; + TRadioGroup *rgSO; + TExtBtn *ebShowSel; + TExtBtn *ebHideSel; + TFormStorage *fsStorage; + TPanel *Panel2; + TExtBtn *sbRefreshList; + TExtBtn *sbClose; + TExtBtn *ebShowProperties; + TPanel *Panel3; + TElTree *tvItems; + TPanel *Panel4; + TElEdit *ElEdit1; + void __fastcall sbCloseClick(TObject *Sender); + void __fastcall FormShow(TObject *Sender); + void __fastcall ebHideSelClick(TObject *Sender); + void __fastcall ebShowSelClick(TObject *Sender); + void __fastcall sbRefreshListClick(TObject *Sender); + void __fastcall tmRefreshListTimer(TObject *Sender); + void __fastcall FormClose(TObject *Sender, TCloseAction &Action); + void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift); + void __fastcall rgSOClick(TObject *Sender); + void __fastcall tvItemsKeyPress(TObject *Sender, char &Key); + void __fastcall tvItemsItemFocused(TObject *Sender); + void __fastcall tvItemsAfterSelectionChange(TObject *Sender); + void __fastcall ebShowPropertiesClick(TObject *Sender); + void __fastcall tvItemsDblClick(TObject *Sender); + void __fastcall ElEdit1Change(TObject *Sender); + void __fastcall ElEdit1Exit(TObject *Sender); + void __fastcall ElEdit1KeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall tvItemsMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); +private: // User declarations + int obj_count; + ObjClassID m_cur_cls; + void __fastcall InitListBox(); + TElTreeItem *FindObjectByType(int type, void *obj); + TElTreeItem *FindFolderByType(int type); + TElTreeItem *AddFolder(LPCSTR name, void *data, TElTreeItem *parent_node); + TElTreeItem *AddObject(TElTreeItem *node, LPCSTR name, void *obj, TColor color); + void UpdateState(); + void UpdateSelection(); + bool bLockUpdate; + TElTreeItem *find_node; + bool stored_parent_colors; + TColor storred_bk_color; + void ProcessFindItemInList(TElTreeItem *from, AnsiString str); - struct SFolderStore{ - bool expanded; + struct SFolderStore + { + bool expanded; }; - DEFINE_MAP (AnsiString,SFolderStore,FolderStoreMap,FolderStorePairIt); - FolderStoreMap ItemsStore; - void storeExpandedItems(); - void restoreExpandedItems(); -public: // User declarations - __fastcall TfrmObjectList (TComponent* Owner); - static TfrmObjectList* CreateForm (TWinControl* parent=0); - static void DestroyForm (TfrmObjectList*& obj_list); - void __fastcall ShowObjectListModal (); - void __fastcall ShowObjectList (); - void __fastcall HideObjectList (); - void __fastcall UpdateObjectList (); + DEFINE_MAP(AnsiString, SFolderStore, FolderStoreMap, FolderStorePairIt); + FolderStoreMap ItemsStore; + + void storeExpandedItems(); + void restoreExpandedItems(); +public: // User declarations + __fastcall TfrmObjectList(TComponent *Owner); + static TfrmObjectList *CreateForm(TWinControl *parent = 0); + static void DestroyForm(TfrmObjectList *&obj_list); + void __fastcall ShowObjectListModal(); + void __fastcall ShowObjectList(); + void __fastcall HideObjectList(); + void __fastcall UpdateObjectList(); }; + //--------------------------------------------------------------------------- extern void frmObjectListShow(); //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/PropertiesEObject.cpp b/src/editors/LevelEditor/PropertiesEObject.cpp index 15e562f99a7..93e8cdcb6b4 100644 --- a/src/editors/LevelEditor/PropertiesEObject.cpp +++ b/src/editors/LevelEditor/PropertiesEObject.cpp @@ -3,10 +3,10 @@ #include "PropertiesEObject.h" #include "SceneObject.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EditMesh.h" -#include "../ECore/Editor/EThumbnail.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EditMesh.h" +#include "editors/ECore/Editor/EThumbnail.h" +#include "editors/ECore/Editor/ui_main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "ElXPThemedControl" @@ -18,189 +18,208 @@ #pragma link "MXCtrls" #pragma resource "*.dfm" //--------------------------------------------------------------------------- -__fastcall TfrmPropertiesEObject::TfrmPropertiesEObject(TComponent* Owner) +__fastcall TfrmPropertiesEObject::TfrmPropertiesEObject(TComponent *Owner) : TForm(Owner) { - m_Thumbnail = 0; -// m_pEditObject=0; + m_Thumbnail = 0; + // m_pEditObject=0; } + //--------------------------------------------------------------------------- -TfrmPropertiesEObject* TfrmPropertiesEObject::CreateProperties(TWinControl* parent, TAlign align, TOnModifiedEvent modif) +TfrmPropertiesEObject *TfrmPropertiesEObject::CreateProperties(TWinControl *parent, TAlign align, TOnModifiedEvent modif) { - TfrmPropertiesEObject* props = xr_new(parent); + TfrmPropertiesEObject *props = xr_new(parent); props->OnModifiedEvent = modif; - if (parent){ - props->Parent = parent; - props->Align = align; - props->BorderStyle = bsNone; + if (parent) + { + props->Parent = parent; + props->Align = align; + props->BorderStyle = bsNone; props->ShowProperties(); } - props->m_BasicProp = TProperties::CreateForm("",props->paBasic,alClient,props->OnModifiedEvent); - props->m_SurfProp = TProperties::CreateForm("",props->paSurfaces,alClient,props->OnModifiedEvent,TOnILItemFocused(props,&TfrmPropertiesEObject::OnSurfaceFocused)); - return props; + props->m_BasicProp = TProperties::CreateForm("", props->paBasic, alClient, props->OnModifiedEvent); + props->m_SurfProp = TProperties::CreateForm("", props->paSurfaces, alClient, props->OnModifiedEvent, TOnILItemFocused(props, &TfrmPropertiesEObject::OnSurfaceFocused)); + return props; } + //--------------------------------------------------------------------------- -void TfrmPropertiesEObject::DestroyProperties(TfrmPropertiesEObject*& props) +void TfrmPropertiesEObject::DestroyProperties(TfrmPropertiesEObject *&props) { - VERIFY(props); - props->Close(); + VERIFY(props); + props->Close(); xr_delete(props); } + //--------------------------------------------------------------------------- void TfrmPropertiesEObject::FillBasicProps() { - xr_vector::iterator it = m_pEditObjects.begin(); - xr_vector::iterator it_e = m_pEditObjects.end(); - PropItemVec items; - for(;it!=it_e;++it) - { - // basic - CSceneObject* S = *it; - if (S->GetReference()) + xr_vector::iterator it = m_pEditObjects.begin(); + xr_vector::iterator it_e = m_pEditObjects.end(); + PropItemVec items; + for (; it!=it_e; ++it) { - CEditableObject* O = S->GetReference(); - O->FillBasicProps (0,items); - } + // basic + CSceneObject *S = *it; + if (S->GetReference()) + { + CEditableObject *O = S->GetReference(); + O->FillBasicProps(0, items); + } } - m_BasicProp->AssignItems(items); + m_BasicProp->AssignItems(items); } + //--------------------------------------------------------------------------- void TfrmPropertiesEObject::FillSurfProps() { - xr_vector::iterator it = m_pEditObjects.begin(); - xr_vector::iterator it_e = m_pEditObjects.end(); + xr_vector::iterator it = m_pEditObjects.begin(); + xr_vector::iterator it_e = m_pEditObjects.end(); PropItemVec values; - for(;it!=it_e;++it) + for (; it!=it_e; ++it) { // surfaces - CSceneObject* S = *it; + CSceneObject *S = *it; if (S->GetReference()) { - CEditableObject* O = S->GetReference(); - for (SurfaceIt it=O->FirstSurface(); it!=O->LastSurface(); it++) + CEditableObject *O = S->GetReference(); + for (SurfaceIt it = O->FirstSurface(); it!=O->LastSurface(); it++) { - AnsiString pref = AnsiString("Surfaces\\")+(*it)->_Name(); - PropValue* V = PHelper().CreateCaption(values,pref.c_str(),""); - V->tag = (int)*it; - O->FillSurfaceProps (*it,pref.c_str(),values); + AnsiString pref = AnsiString("Surfaces\\")+(*it)->_Name(); + PropValue *V = PHelper().CreateCaption(values, pref.c_str(), ""); + V->tag = (int)*it; + O->FillSurfaceProps(*it, pref.c_str(), values); } } } m_SurfProp->AssignItems(values); } + //--------------------------------------------------------------------------- void TfrmPropertiesEObject::UpdateProperties(xr_vector Ss, bool bReadOnly) { - m_BasicProp->SetReadOnly(bReadOnly); - m_SurfProp->SetReadOnly (bReadOnly); -//. m_pEditObject = S; - m_pEditObjects = Ss; - FillBasicProps (); - FillSurfProps (); + m_BasicProp->SetReadOnly(bReadOnly); + m_SurfProp->SetReadOnly(bReadOnly); + //. m_pEditObject = S; + m_pEditObjects = Ss; + FillBasicProps(); + FillSurfProps(); } void __fastcall TfrmPropertiesEObject::FormDestroy(TObject *Sender) { - xr_delete(m_Thumbnail); + xr_delete(m_Thumbnail); TProperties::DestroyForm(m_BasicProp); TProperties::DestroyForm(m_SurfProp); } + //--------------------------------------------------------------------------- void __fastcall TfrmPropertiesEObject::fsStorageRestorePlacement( - TObject *Sender) + TObject *Sender) { - m_BasicProp->RestoreParams(fsStorage); - m_SurfProp->RestoreParams(fsStorage); + m_BasicProp->RestoreParams(fsStorage); + m_SurfProp->RestoreParams(fsStorage); } + //--------------------------------------------------------------------------- void __fastcall TfrmPropertiesEObject::fsStorageSavePlacement( - TObject *Sender) + TObject *Sender) { - m_BasicProp->SaveParams(fsStorage); - m_SurfProp->SaveParams(fsStorage); + m_BasicProp->SaveParams(fsStorage); + m_SurfProp->SaveParams(fsStorage); } + //--------------------------------------------------------------------------- -void TfrmPropertiesEObject::OnSurfaceFocused(TElTreeItem* item) +void TfrmPropertiesEObject::OnSurfaceFocused(TElTreeItem *item) { - xr_delete(m_Thumbnail); + xr_delete(m_Thumbnail); - if (item&&item->Tag) + if (item&&item->Tag) { - PropItem* prop = (PropItem*)item->Tag; - EPropType type = TProperties::GetItemType(item); - switch (type) + PropItem *prop = (PropItem*)item->Tag; + EPropType type = TProperties::GetItemType(item); + switch (type) { - case PROP_CAPTION: + case PROP_CAPTION: { - if(m_pEditObjects.size()==1) + if (m_pEditObjects.size()==1) { - PropValue* V = prop->GetFrontValue(); VERIFY(V); - CSceneObject* O = m_pEditObjects[0]; - CSurface* S = (CSurface*)V->tag; - O->Blink (S); + PropValue *V = prop->GetFrontValue(); + VERIFY(V); + CSceneObject *O = m_pEditObjects[0]; + CSurface *S = (CSurface*)V->tag; + O->Blink(S); } - }break; - case PROP_CHOOSE: + } + break; + case PROP_CHOOSE: { - ChooseValue* V = dynamic_cast(prop->GetFrontValue()); VERIFY(V); + ChooseValue *V = dynamic_cast(prop->GetFrontValue()); + VERIFY(V); if (smTexture==V->m_ChooseID) { - LPCSTR nm = TProperties::GetItemColumn(item,0); + LPCSTR nm = TProperties::GetItemColumn(item, 0); if (nm&&nm[0]) { m_Thumbnail = xr_new(nm); - lbWidth->Caption = m_Thumbnail->_Width(); - lbHeight->Caption = m_Thumbnail->_Height(); - lbAlpha->Caption = (m_Thumbnail->_Alpha())?"present":"absent"; - if (m_Thumbnail->_Width()!=m_Thumbnail->_Height()) paImage->Repaint(); - paImage->Repaint (); + lbWidth->Caption = m_Thumbnail->_Width(); + lbHeight->Caption = m_Thumbnail->_Height(); + lbAlpha->Caption = (m_Thumbnail->_Alpha()) ? "present" : "absent"; + if (m_Thumbnail->_Width()!=m_Thumbnail->_Height()) + paImage->Repaint(); + paImage->Repaint(); } } - }break; + } + break; } } if (!m_Thumbnail) { - lbWidth->Caption = "..."; - lbHeight->Caption = "..."; - lbAlpha->Caption = "..."; + lbWidth->Caption = "..."; + lbHeight->Caption = "..."; + lbAlpha->Caption = "..."; paImage->Repaint(); } } + //--------------------------------------------------------------------------- void __fastcall TfrmPropertiesEObject::paImagePaint(TObject *Sender) { - if (m_Thumbnail) m_Thumbnail->Draw(paImage); + if (m_Thumbnail) + m_Thumbnail->Draw(paImage); } + //--------------------------------------------------------------------------- -void __fastcall TfrmPropertiesEObject::OnPick(const SRayPickInfo& pinf) +void __fastcall TfrmPropertiesEObject::OnPick(const SRayPickInfo &pinf) { - R_ASSERT(pinf.e_mesh); - if (ebDropper->Down && /*m_pEditObject*/ m_pEditObjects.size()) + R_ASSERT(pinf.e_mesh); + if (ebDropper->Down&&/*m_pEditObject*/ m_pEditObjects.size()) { - CSurface* surf=pinf.e_mesh->GetSurfaceByFaceID(pinf.inf.id); + CSurface *surf = pinf.e_mesh->GetSurfaceByFaceID(pinf.inf.id); AnsiString s_name = AnsiString("Surfaces\\")+AnsiString(surf->_Name()); - FHelper.RestoreSelection(m_SurfProp->tvProperties,s_name,false); + FHelper.RestoreSelection(m_SurfProp->tvProperties, s_name, false); } } + //--------------------------------------------------------------------------- void __fastcall TfrmPropertiesEObject::FormShow(TObject *Sender) { - // check window position + // check window position UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- - + diff --git a/src/editors/LevelEditor/PropertiesEObject.h b/src/editors/LevelEditor/PropertiesEObject.h index db42746cfa3..dca5da8df7c 100644 --- a/src/editors/LevelEditor/PropertiesEObject.h +++ b/src/editors/LevelEditor/PropertiesEObject.h @@ -21,53 +21,68 @@ struct SRayPickInfo; class TfrmPropertiesEObject : public TForm { -__published: // IDE-managed Components - TFormStorage *fsStorage; - TElPageControl *ElPageControl1; - TElTabSheet *tsBasic; - TElTabSheet *tsSurfaces; - TPanel *paBasic; - TPanel *paSurfaces; - TPanel *Panel2; - TGroupBox *gbTexture; - TLabel *RxLabel7; - TLabel *RxLabel8; - TLabel *RxLabel9; - TLabel *lbWidth; - TLabel *lbHeight; - TLabel *lbAlpha; - TPanel *Panel1; - TExtBtn *ebSortByImage; - TExtBtn *ebSortByName; - TExtBtn *ebDropper; - TExtBtn *ebSortByShader; - TLabel *Label1; - TMxPanel *paImage; - void __fastcall FormDestroy(TObject *Sender); - void __fastcall fsStorageRestorePlacement(TObject *Sender); - void __fastcall fsStorageSavePlacement(TObject *Sender); - void __fastcall paImagePaint(TObject *Sender); - void __fastcall FormShow(TObject *Sender); -private: // User declarations - TProperties* m_BasicProp; - TProperties* m_SurfProp; - bool bModified; + __published: // IDE-managed Components + TFormStorage*fsStorage; + TElPageControl *ElPageControl1; + TElTabSheet *tsBasic; + TElTabSheet *tsSurfaces; + TPanel *paBasic; + TPanel *paSurfaces; + TPanel *Panel2; + TGroupBox *gbTexture; + TLabel *RxLabel7; + TLabel *RxLabel8; + TLabel *RxLabel9; + TLabel *lbWidth; + TLabel *lbHeight; + TLabel *lbAlpha; + TPanel *Panel1; + TExtBtn *ebSortByImage; + TExtBtn *ebSortByName; + TExtBtn *ebDropper; + TExtBtn *ebSortByShader; + TLabel *Label1; + TMxPanel *paImage; + void __fastcall FormDestroy(TObject *Sender); + void __fastcall fsStorageRestorePlacement(TObject *Sender); + void __fastcall fsStorageSavePlacement(TObject *Sender); + void __fastcall paImagePaint(TObject *Sender); + void __fastcall FormShow(TObject *Sender); +private: // User declarations + TProperties *m_BasicProp; + TProperties *m_SurfProp; + bool bModified; TOnModifiedEvent OnModifiedEvent; - void __stdcall OnSurfaceFocused (TElTreeItem* item); - ETextureThumbnail* m_Thumbnail; -//. CSceneObject* m_pEditObject; - xr_vector m_pEditObjects; - void FillBasicProps (); - void FillSurfProps (); -public: // User declarations - __fastcall TfrmPropertiesEObject (TComponent* Owner); - static TfrmPropertiesEObject* CreateProperties (TWinControl* parent=0, TAlign align=alNone, TOnModifiedEvent modif=0); - static void DestroyProperties (TfrmPropertiesEObject*& props); - void UpdateProperties (xr_vector Ss, bool bReadOnly); - void ShowProperties (){Show();} - void HideProperties (){Hide();} - bool __fastcall IsModified (){return (m_BasicProp->IsModified()||m_SurfProp->IsModified());} - void __fastcall OnPick (const SRayPickInfo& pinf); + void __stdcall OnSurfaceFocused(TElTreeItem *item); + ETextureThumbnail *m_Thumbnail; + //. CSceneObject* m_pEditObject; + xr_vector m_pEditObjects; + void FillBasicProps(); + void FillSurfProps(); +public: // User declarations + __fastcall TfrmPropertiesEObject(TComponent *Owner); + static TfrmPropertiesEObject *CreateProperties(TWinControl *parent = 0, TAlign align = alNone, TOnModifiedEvent modif = 0); + static void DestroyProperties(TfrmPropertiesEObject *&props); + void UpdateProperties(xr_vector Ss, bool bReadOnly); + + void ShowProperties() + { + Show(); + } + + void HideProperties() + { + Hide(); + } + + bool __fastcall IsModified() + { + return (m_BasicProp->IsModified()||m_SurfProp->IsModified()); + } + + void __fastcall OnPick(const SRayPickInfo &pinf); }; + //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/ShaderFunction.cpp b/src/editors/LevelEditor/ShaderFunction.cpp index 0de98bcb3a8..5eef7617cac 100644 --- a/src/editors/LevelEditor/ShaderFunction.cpp +++ b/src/editors/LevelEditor/ShaderFunction.cpp @@ -12,54 +12,65 @@ #pragma link "MxMenus" #pragma link "mxPlacemnt" #pragma resource "*.dfm" -TfrmShaderFunction *TfrmShaderFunction::form=0; -WaveForm* TfrmShaderFunction::m_CurFunc=0; -WaveForm* TfrmShaderFunction::m_SaveFunc=0; -//--------------------------------------------------------------------------- -xr_token function_token [ ]={ - { "Constant", WaveForm::fCONSTANT }, - { "Sin", WaveForm::fSIN }, - { "Triangle", WaveForm::fTRIANGLE }, - { "Square", WaveForm::fSQUARE }, - { "Saw-Tooth", WaveForm::fSAWTOOTH }, - { "Inv Saw-Tooth", WaveForm::fINVSAWTOOTH }, - { 0, 0 } +TfrmShaderFunction *TfrmShaderFunction::form = 0; +WaveForm *TfrmShaderFunction::m_CurFunc = 0; +WaveForm *TfrmShaderFunction::m_SaveFunc = 0; +//--------------------------------------------------------------------------- +xr_token function_token [ ] = { + {"Constant", WaveForm::fCONSTANT}, + {"Sin", WaveForm::fSIN}, + {"Triangle", WaveForm::fTRIANGLE}, + {"Square", WaveForm::fSQUARE}, + {"Saw-Tooth", WaveForm::fSAWTOOTH}, + {"Inv Saw-Tooth", WaveForm::fINVSAWTOOTH}, + {0, 0} }; + //--------------------------------------------------------------------------- -void FillMenuFromToken(TMxPopupMenu* menu, const xr_token *token_list, ClickEvent func ){ - menu->Items->Clear(); - for( int i=0; token_list[i].name; i++ ){ - TMenuItem* mi = xr_new((TComponent*)0); - mi->Caption = token_list[i].name; +void FillMenuFromToken(TMxPopupMenu *menu, const xr_token *token_list, ClickEvent func) +{ + menu->Items->Clear(); + for (int i = 0; token_list[i].name; i++) + { + TMenuItem *mi = xr_new((TComponent*)0); + mi->Caption = token_list[i].name; mi->OnClick = func; - menu->Items->Add(mi); + menu->Items->Add(mi); } } + //--------------------------------------------------------------------------- -AnsiString& GetTokenNameFromVal_EQ(u32 val, AnsiString& res, const xr_token *token_list) +AnsiString &GetTokenNameFromVal_EQ(u32 val, AnsiString &res, const xr_token *token_list) { - bool bRes=false; - for( u32 i=0; token_list[i].name; i++ ) - if (token_list[i].id==int(val)) {res = token_list[i].name; bRes=true; break; } - if (!bRes) res=""; + bool bRes = false; + for (u32 i = 0; token_list[i].name; i++) + if (token_list[i].id==int(val)) + { + res = token_list[i].name; + bRes = true; + break; + } + if (!bRes) + res = ""; return res; } u32 GetTokenValFromName(const LPCSTR val, const xr_token *token_list) { - for( int i=0; token_list[i].name; i++ ) - if( !stricmp(val,token_list[i].name) ) - return token_list[i].id; + for (int i = 0; token_list[i].name; i++) + if (!stricmp(val, token_list[i].name)) + return token_list[i].id; return 0; } //--------------------------------------------------------------------------- -__fastcall TfrmShaderFunction::TfrmShaderFunction(TComponent* Owner) +__fastcall TfrmShaderFunction::TfrmShaderFunction(TComponent *Owner) : TForm(Owner) { - DEFINE_INI(fsStorage); - FillMenuFromToken(pmFunction, function_token, stFunctionClick); + DEFINE_INI(fsStorage); + FillMenuFromToken(pmFunction, function_token, stFunctionClick); } + //--------------------------------------------------------------------------- @@ -68,165 +79,195 @@ void __fastcall TfrmShaderFunction::DrawGraph() int w = imDraw->Width-4; int h = imDraw->Height-4; - TRect r; r.Left=0; r.Top=0; r.Right=w+4; r.Bottom=h+4; - TCanvas* C=imDraw->Canvas; + TRect r; + r.Left = 0; + r.Top = 0; + r.Right = w+4; + r.Bottom = h+4; + TCanvas *C = imDraw->Canvas; C->Brush->Color = clBlack; C->FillRect(r); C->Pen->Color = TColor(0x00006600); // draw center C->Pen->Color = clLime; C->Pen->Style = psDot; - C->MoveTo(2,h/2+2); - C->LineTo(w+2,h/2+2); + C->MoveTo(2, h/2+2); + C->LineTo(w+2, h/2+2); // draw rect C->Pen->Color = TColor(0x00006600); C->Pen->Style = psSolid; - C->MoveTo(0,0); - C->LineTo(w+3,0); C->LineTo(w+3,h+3); - C->LineTo(0,h+3); C->LineTo(0,0); + C->MoveTo(0, 0); + C->LineTo(w+3, 0); + C->LineTo(w+3, h+3); + C->LineTo(0, h+3); + C->LineTo(0, 0); // draw graph C->Pen->Color = clYellow; float t_cost = 1.f/w; float tm = 0; - float y = m_CurFunc->Calculate(tm) - m_CurFunc->arg[0]; + float y = m_CurFunc->Calculate(tm)-m_CurFunc->arg[0]; float delta = m_CurFunc->arg[1]*2; - delta = delta?(h/delta):0; - float yy = h-(delta*y + h/2); - C->MoveTo(2,yy+2); - for (int t=1; tValue*t*t_cost/(fis_zero(m_CurFunc->arg[3])?1.f:m_CurFunc->arg[3]); - y = m_CurFunc->Calculate(tm) - m_CurFunc->arg[0]; - yy = h-(delta*y + h/2); - C->LineTo(t+2,yy+2); + delta = delta ? (h/delta) : 0; + float yy = h-(delta*y+h/2); + C->MoveTo(2, yy+2); + for (int t = 1; tValue*t*t_cost/(fis_zero(m_CurFunc->arg[3]) ? 1.f : m_CurFunc->arg[3]); + y = m_CurFunc->Calculate(tm)-m_CurFunc->arg[0]; + yy = h-(delta*y+h/2); + C->LineTo(t+2, yy+2); } // draw X-axis C->Pen->Color = clGreen; - float AxisX = h-(delta*(-m_CurFunc->arg[0]) + h/2); - C->MoveTo(2,AxisX+2); - C->LineTo(w+2,AxisX+2); + float AxisX = h-(delta*(-m_CurFunc->arg[0])+h/2); + C->MoveTo(2, AxisX+2); + C->LineTo(w+2, AxisX+2); } + //--------------------------------------------------------------------------- void __fastcall TfrmShaderFunction::FormKeyDown(TObject *Sender, - WORD &Key, TShiftState Shift) + WORD &Key, TShiftState Shift) { - if (Key==VK_ESCAPE) ebCancel->Click(); + if (Key==VK_ESCAPE) + ebCancel->Click(); } //---------------------------------------------------- void __fastcall TfrmShaderFunction::ebOkClick(TObject *Sender) { - UpdateFuncData(); + UpdateFuncData(); Close(); ModalResult = mrOk; } + //--------------------------------------------------------------------------- void __fastcall TfrmShaderFunction::ebCancelClick(TObject *Sender) { - CopyMemory(m_CurFunc,m_SaveFunc,sizeof(WaveForm)); + CopyMemory(m_CurFunc, m_SaveFunc, sizeof(WaveForm)); Close(); ModalResult = mrCancel; -// *m_CurFunc = *m_SaveFunc; + // *m_CurFunc = *m_SaveFunc; } + //--------------------------------------------------------------------------- //---------------------------------------------------- -int __fastcall TfrmShaderFunction::Run(WaveForm* func) +int __fastcall TfrmShaderFunction::Run(WaveForm *func) { - VERIFY(func); - form = xr_new((TComponent*)0); - form->m_CurFunc = func; - form->m_SaveFunc = xr_new(*func); - form->GetFuncData (); + VERIFY(func); + form = xr_new((TComponent*)0); + form->m_CurFunc = func; + form->m_SaveFunc = xr_new(*func); + form->GetFuncData(); form->UpdateFuncData(); - int res = form->ShowModal(); + int res = form->ShowModal(); xr_delete(form->m_SaveFunc); return res; } -static TStaticText* temp_text=0; +static TStaticText *temp_text = 0; + void __fastcall TfrmShaderFunction::stFunctionMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { POINT pt; GetCursorPos(&pt); temp_text = (TStaticText*)Sender; - pmFunction->Popup(pt.x,pt.y); + pmFunction->Popup(pt.x, pt.y); } + //--------------------------------------------------------------------------- void __fastcall TfrmShaderFunction::stFunctionClick(TObject *Sender) { - if (temp_text) temp_text->Caption=((TMenuItem*)Sender)->Caption; + if (temp_text) + temp_text->Caption = ((TMenuItem*)Sender)->Caption; temp_text = 0; UpdateFuncData(); } + //--------------------------------------------------------------------------- -void TfrmShaderFunction::GetFuncData(){ - bLoadMode = true; +void TfrmShaderFunction::GetFuncData() +{ + bLoadMode = true; AnsiString buf; - stFunction->Caption = GetTokenNameFromVal_EQ(m_CurFunc->F, buf, function_token); + stFunction->Caption = GetTokenNameFromVal_EQ(m_CurFunc->F, buf, function_token); seArg1->Value = m_CurFunc->arg[0]; seArg2->Value = m_CurFunc->arg[1]; seArg3->Value = m_CurFunc->arg[2]; seArg4->Value = m_CurFunc->arg[3]; - bLoadMode = false; + bLoadMode = false; } -void TfrmShaderFunction::UpdateFuncData(){ - if (bLoadMode) return; - m_CurFunc->F = (WaveForm::EFunction)GetTokenValFromName(stFunction->Caption.c_str(), function_token); +void TfrmShaderFunction::UpdateFuncData() +{ + if (bLoadMode) + return; + m_CurFunc->F = (WaveForm::EFunction)GetTokenValFromName(stFunction->Caption.c_str(), function_token); m_CurFunc->arg[0] = seArg1->Value; m_CurFunc->arg[1] = seArg2->Value; m_CurFunc->arg[2] = seArg3->Value; m_CurFunc->arg[3] = seArg4->Value; AnsiString t; - t.sprintf("%.2f",m_CurFunc->arg[1]+m_CurFunc->arg[0]); lbMax->Caption = t; - t.sprintf("%.2f",-m_CurFunc->arg[1]+m_CurFunc->arg[0]); lbMin->Caption = t; - t.sprintf("%.2f",m_CurFunc->arg[0]); lbCenter->Caption = t; - float v=seScale->Value*1000/m_CurFunc->arg[3]; - if (v<=1000) t.sprintf("%4.0f ms",v); - else t.sprintf("%.2f s",v/1000); + t.sprintf("%.2f", m_CurFunc->arg[1]+m_CurFunc->arg[0]); + lbMax->Caption = t; + t.sprintf("%.2f", -m_CurFunc->arg[1]+m_CurFunc->arg[0]); + lbMin->Caption = t; + t.sprintf("%.2f", m_CurFunc->arg[0]); + lbCenter->Caption = t; + float v = seScale->Value*1000/m_CurFunc->arg[3]; + if (v<=1000) + t.sprintf("%4.0f ms", v); + else + t.sprintf("%.2f s", v/1000); lbEnd->Caption = t; - DrawGraph(); + DrawGraph(); } + void __fastcall TfrmShaderFunction::seArgExit(TObject *Sender) { - UpdateFuncData(); + UpdateFuncData(); } + //--------------------------------------------------------------------------- void __fastcall TfrmShaderFunction::seArgLWChange(TObject *Sender, - int Val) + int Val) { - UpdateFuncData(); + UpdateFuncData(); } + //--------------------------------------------------------------------------- void __fastcall TfrmShaderFunction::seArgKeyDown(TObject *Sender, - WORD &Key, TShiftState Shift) + WORD &Key, TShiftState Shift) { - if (Key==VK_RETURN) UpdateFuncData(); + if (Key==VK_RETURN) + UpdateFuncData(); } + //--------------------------------------------------------------------------- void __fastcall TfrmShaderFunction::FormClose(TObject *Sender, - TCloseAction &Action) + TCloseAction &Action) { - Action = caFree; - form = 0; + Action = caFree; + form = 0; } -//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- void __fastcall TfrmShaderFunction::FormShow(TObject *Sender) { - // check window position - UI->CheckWindowPos(this); + // check window position + UI->CheckWindowPos(this); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/ShaderFunction.h b/src/editors/LevelEditor/ShaderFunction.h index eb5b5d8f12e..21ca912e689 100644 --- a/src/editors/LevelEditor/ShaderFunction.h +++ b/src/editors/LevelEditor/ShaderFunction.h @@ -19,66 +19,70 @@ struct WaveForm; class TfrmShaderFunction : public TForm { -__published: // IDE-managed Components - TPanel *Panel1; - TStaticText *stFunction; - TLabel *RxLabel1; - TLabel *Label4; - TMultiObjSpinEdit *seArg1; - TLabel *Label1; - TMultiObjSpinEdit *seArg2; - TLabel *Label2; - TMultiObjSpinEdit *seArg3; - TLabel *Label3; - TMultiObjSpinEdit *seArg4; - TBevel *Bevel2; - TImage *imDraw; - TLabel *Label5; - TLabel *lbMax; - TLabel *lbCenter; - TLabel *lbMin; - TLabel *lbStart; - TLabel *lbEnd; - TExtBtn *ebOk; - TExtBtn *ebCancel; - TMxPopupMenu *pmFunction; - TFormStorage *fsStorage; - TMultiObjSpinEdit *seScale; - TLabel *Label6; + __published: // IDE-managed Components + TPanel*Panel1; + TStaticText *stFunction; + TLabel *RxLabel1; + TLabel *Label4; + TMultiObjSpinEdit *seArg1; + TLabel *Label1; + TMultiObjSpinEdit *seArg2; + TLabel *Label2; + TMultiObjSpinEdit *seArg3; + TLabel *Label3; + TMultiObjSpinEdit *seArg4; + TBevel *Bevel2; + TImage *imDraw; + TLabel *Label5; + TLabel *lbMax; + TLabel *lbCenter; + TLabel *lbMin; + TLabel *lbStart; + TLabel *lbEnd; + TExtBtn *ebOk; + TExtBtn *ebCancel; + TMxPopupMenu *pmFunction; + TFormStorage *fsStorage; + TMultiObjSpinEdit *seScale; + TLabel *Label6; void __fastcall FormKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); + TShiftState Shift); void __fastcall ebCancelClick(TObject *Sender); void __fastcall ebOkClick(TObject *Sender); - void __fastcall stFunctionMouseDown(TObject *Sender, TMouseButton Button, - TShiftState Shift, int X, int Y); - void __fastcall stFunctionClick(TObject *Sender); - void __fastcall seArgExit(TObject *Sender); - void __fastcall seArgLWChange(TObject *Sender, int Val); - void __fastcall seArgKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift); - void __fastcall FormClose(TObject *Sender, TCloseAction &Action); - void __fastcall FormShow(TObject *Sender); -private: // User declarations + void __fastcall stFunctionMouseDown(TObject *Sender, TMouseButton Button, + TShiftState Shift, int X, int Y); + void __fastcall stFunctionClick(TObject *Sender); + void __fastcall seArgExit(TObject *Sender); + void __fastcall seArgLWChange(TObject *Sender, int Val); + void __fastcall seArgKeyDown(TObject *Sender, WORD &Key, + TShiftState Shift); + void __fastcall FormClose(TObject *Sender, TCloseAction &Action); + void __fastcall FormShow(TObject *Sender); +private: // User declarations bool bLoadMode; - static WaveForm* m_CurFunc; - static WaveForm* m_SaveFunc; + static WaveForm *m_CurFunc; + static WaveForm *m_SaveFunc; void GetFuncData(); void UpdateFuncData(); - void __fastcall DrawGraph(); + void __fastcall DrawGraph(); static TfrmShaderFunction *form; -public: // User declarations - __fastcall TfrmShaderFunction(TComponent* Owner); - static int __fastcall Run(WaveForm* func); +public: // User declarations + __fastcall TfrmShaderFunction(TComponent *Owner); + static int __fastcall Run(WaveForm *func); }; -typedef void __fastcall (__closure *ClickEvent)(System::TObject* Sender); -AnsiString& GetTokenNameFromVal_EQ (u32 val, AnsiString& res, const xr_token *token_list); -u32 GetTokenValFromName (AnsiString& res, const xr_token *token_list); -void FillMenuFromToken (TMxPopupMenu* menu, const xr_token *token_list, ClickEvent func); +typedef void __fastcall(__closure*ClickEvent)(System::TObject +* +Sender +); +AnsiString &GetTokenNameFromVal_EQ(u32 val, AnsiString &res, const xr_token *token_list); +u32 GetTokenValFromName(AnsiString &res, const xr_token *token_list); +void FillMenuFromToken(TMxPopupMenu *menu, const xr_token *token_list, ClickEvent func); //--------------------------------------------------------------------------- #endif + diff --git a/src/editors/LevelEditor/TopBar.cpp b/src/editors/LevelEditor/TopBar.cpp index fb16f1fae6d..5cad68c6afd 100644 --- a/src/editors/LevelEditor/TopBar.cpp +++ b/src/editors/LevelEditor/TopBar.cpp @@ -2,9 +2,9 @@ #pragma hdrstop #include "TopBar.h" -#include "../ECore/Editor/UI_ToolsCustom.h" -#include "../ECore/Editor/ui_main.h" -#include "../ECore/Editor/ui_MainCommand.h" +#include "editors/ECore/Editor/UI_ToolsCustom.h" +#include "editors/ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ui_MainCommand.h" #include "lephysics.h" //--------------------------------------------------------------------------- #pragma package(smart_init) @@ -12,188 +12,229 @@ #pragma link "mxPlacemnt" #pragma resource "*.dfm" TfraTopBar *fraTopBar; + //--------------------------------------------------------------------------- -__fastcall TfraTopBar::TfraTopBar(TComponent* Owner) - : TFrame(Owner) +__fastcall TfraTopBar::TfraTopBar(TComponent *Owner) + : TFrame(Owner) { - ebActionSelect->Tag = etaSelect; - ebActionAdd->Tag = etaAdd; - ebActionMove->Tag = etaMove; - ebActionRotate->Tag = etaRotate; - ebActionScale->Tag = etaScale; - - ebAxisX->Tag = etAxisX; - ebAxisY->Tag = etAxisY; - ebAxisZ->Tag = etAxisZ; - ebAxisZX->Tag = etAxisZX; - - ebCSParent->Tag = etfCSParent; - ebNUScale->Tag = etfNUScale; - ebNormalAlign->Tag = etfNormalAlign; - ebGSnap->Tag = etfGSnap; - ebOSnap->Tag = etfOSnap; - ebMTSnap->Tag = etfMTSnap; - ebVSnap->Tag = etfVSnap; - ebASnap->Tag = etfASnap; - ebMSnap->Tag = etfMSnap; + ebActionSelect->Tag = etaSelect; + ebActionAdd->Tag = etaAdd; + ebActionMove->Tag = etaMove; + ebActionRotate->Tag = etaRotate; + ebActionScale->Tag = etaScale; + + ebAxisX->Tag = etAxisX; + ebAxisY->Tag = etAxisY; + ebAxisZ->Tag = etAxisZ; + ebAxisZX->Tag = etAxisZX; + + ebCSParent->Tag = etfCSParent; + ebNUScale->Tag = etfNUScale; + ebNormalAlign->Tag = etfNormalAlign; + ebGSnap->Tag = etfGSnap; + ebOSnap->Tag = etfOSnap; + ebMTSnap->Tag = etfMTSnap; + ebVSnap->Tag = etfVSnap; + ebASnap->Tag = etfASnap; + ebMSnap->Tag = etfMSnap; DEFINE_INI(fsStorage); } + //--------------------------------------------------------------------------- -void TfraTopBar::OnTimer(){ - for (int j=0; j(temp) != NULL) +void TfraTopBar::OnTimer() +{ + for (int j = 0; j(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebEditUndoClick(TObject *Sender) -{ - ExecCommand( COMMAND_UNDO ); +{ + ExecCommand(COMMAND_UNDO); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebEditRedoClick(TObject *Sender) { - ExecCommand( COMMAND_REDO ); + ExecCommand(COMMAND_REDO); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ActionClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_CHANGE_ACTION, btn->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebAxisClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_CHANGE_AXIS, btn->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebSettingsClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); + TExtBtn *btn = dynamic_cast(Sender); VERIFY(btn); ExecCommand(COMMAND_SET_SETTINGS, btn->Tag, btn->Down); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebViewClick(TObject *Sender) { - TExtBtn* btn=dynamic_cast(Sender); - if (btn){ - if (btn==ebViewFront) EDevice.m_Camera.ViewFront(); - if (btn==ebViewBack) EDevice.m_Camera.ViewBack(); - if (btn==ebViewLeft) EDevice.m_Camera.ViewLeft(); - if (btn==ebViewRight) EDevice.m_Camera.ViewRight(); - if (btn==ebViewTop) EDevice.m_Camera.ViewTop(); - if (btn==ebViewBottom) EDevice.m_Camera.ViewBottom(); - if (btn==ebViewReset) EDevice.m_Camera.ViewReset(); + TExtBtn *btn = dynamic_cast(Sender); + if (btn) + { + if (btn==ebViewFront) + EDevice.m_Camera.ViewFront(); + if (btn==ebViewBack) + EDevice.m_Camera.ViewBack(); + if (btn==ebViewLeft) + EDevice.m_Camera.ViewLeft(); + if (btn==ebViewRight) + EDevice.m_Camera.ViewRight(); + if (btn==ebViewTop) + EDevice.m_Camera.ViewTop(); + if (btn==ebViewBottom) + EDevice.m_Camera.ViewBottom(); + if (btn==ebViewReset) + EDevice.m_Camera.ViewReset(); } UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::RefreshBar() { - TExtBtn* btn = 0; - //actions - switch(Tools->GetAction()){ - case etaSelect: btn=ebActionSelect; break; - case etaAdd: btn=ebActionAdd; break; - case etaMove: btn=ebActionMove; break; - case etaRotate: btn=ebActionRotate; break; - case etaScale: btn=ebActionScale; break; - default: THROW; + TExtBtn *btn = 0; + //actions + switch (Tools->GetAction()) + { + case etaSelect: btn = ebActionSelect; + break; + case etaAdd: btn = ebActionAdd; + break; + case etaMove: btn = ebActionMove; + break; + case etaRotate: btn = ebActionRotate; + break; + case etaScale: btn = ebActionScale; + break; + default: THROW; } - btn->Down = true; + btn->Down = true; // axis - switch (Tools->GetAxis()){ - case etAxisX: btn=ebAxisX; break; - case etAxisY: btn=ebAxisY; break; - case etAxisZ: btn=ebAxisZ; break; - case etAxisZX: btn=ebAxisZX; break; - case etAxisUndefined: btn=NULL; break; - default: THROW; + switch (Tools->GetAxis()) + { + case etAxisX: btn = ebAxisX; + break; + case etAxisY: btn = ebAxisY; + break; + case etAxisZ: btn = ebAxisZ; + break; + case etAxisZX: btn = ebAxisZX; + break; + case etAxisUndefined: btn = NULL; + break; + default: THROW; } - - if(btn) - btn->Down = true; + + if (btn) + btn->Down = true; // settings - ebCSParent->Down = Tools->GetSettings(etfCSParent); - ebNUScale->Down = Tools->GetSettings(etfNUScale); - ebNormalAlign->Down = Tools->GetSettings(etfNormalAlign); - ebGSnap->Down = Tools->GetSettings(etfGSnap); - ebOSnap->Down = Tools->GetSettings(etfOSnap); - ebMTSnap->Down = Tools->GetSettings(etfMTSnap); - ebVSnap->Down = Tools->GetSettings(etfVSnap); - ebASnap->Down = Tools->GetSettings(etfASnap); - ebMSnap->Down = Tools->GetSettings(etfMSnap); - - SimulateButton->Down = g_scene_physics.Simulating(); + ebCSParent->Down = Tools->GetSettings(etfCSParent); + ebNUScale->Down = Tools->GetSettings(etfNUScale); + ebNormalAlign->Down = Tools->GetSettings(etfNormalAlign); + ebGSnap->Down = Tools->GetSettings(etfGSnap); + ebOSnap->Down = Tools->GetSettings(etfOSnap); + ebMTSnap->Down = Tools->GetSettings(etfMTSnap); + ebVSnap->Down = Tools->GetSettings(etfVSnap); + ebASnap->Down = Tools->GetSettings(etfASnap); + ebMSnap->Down = Tools->GetSettings(etfMSnap); + + SimulateButton->Down = g_scene_physics.Simulating(); // redraw scene - UI->RedrawScene (); + UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebZoomExtentsClick(TObject *Sender) { - ExecCommand( COMMAND_ZOOM_EXTENTS, FALSE ); + ExecCommand(COMMAND_ZOOM_EXTENTS, FALSE); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebZoomExtentsSelectedClick(TObject *Sender) { - ExecCommand( COMMAND_ZOOM_EXTENTS, TRUE ); + ExecCommand(COMMAND_ZOOM_EXTENTS, TRUE); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::ebCameraStyleClick(TObject *Sender) { - EDevice.m_Camera.SetStyle((ECameraStyle)((TExtBtn*)Sender)->Tag); + EDevice.m_Camera.SetStyle((ECameraStyle)((TExtBtn*)Sender)->Tag); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::fsStorageRestorePlacement(TObject *Sender) { - if (ebCameraPlane->Down) EDevice.m_Camera.SetStyle(csPlaneMove); - else if (ebCameraArcBall->Down) EDevice.m_Camera.SetStyle(cs3DArcBall); - else if (ebCameraFly->Down) EDevice.m_Camera.SetStyle(csFreeFly); + if (ebCameraPlane->Down) + EDevice.m_Camera.SetStyle(csPlaneMove); + else if (ebCameraArcBall->Down) + EDevice.m_Camera.SetStyle(cs3DArcBall); + else if (ebCameraFly->Down) + EDevice.m_Camera.SetStyle(csFreeFly); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfraTopBar::SimulateButtonClick(TObject *Sender) { - // if ( SimulateButton->Down ) - // g_scene_physics.CreateShellsSelected(); - // else + // if ( SimulateButton->Down ) + // g_scene_physics.CreateShellsSelected(); + // else // g_scene_physics.DestroyAll(); - - ExecCommand( COMMAND_SIMULATE, TRUE ); -// + ExecCommand(COMMAND_SIMULATE, TRUE); + + // } -//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- void __fastcall TfraTopBar::UseSimulatePositions(TObject *Sender) { - // g_scene_physics.UseSimulatePoses(); - ExecCommand( COMMAND_USE_SIMULATE_POSITIONS, TRUE ); + // g_scene_physics.UseSimulatePoses(); + ExecCommand(COMMAND_USE_SIMULATE_POSITIONS, TRUE); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/iniStreamImpl.h b/src/editors/LevelEditor/iniStreamImpl.h index cc51114b744..8b1f1ae869e 100644 --- a/src/editors/LevelEditor/iniStreamImpl.h +++ b/src/editors/LevelEditor/iniStreamImpl.h @@ -9,37 +9,37 @@ struct SIniFileStream :public IIniFileStream shared_str sect; string128 tmp_buff; u32 counter; - LPCSTR gen_name (); + LPCSTR gen_name(); - virtual void __stdcall move_begin () {counter=0;}; + virtual void __stdcall move_begin () {counter=0;}; - virtual void __stdcall w_float ( float a); - virtual void __stdcall w_vec3 ( const Fvector& a); - virtual void __stdcall w_vec4 ( const Fvector4& a); - virtual void __stdcall w_u64 ( u64 a); - virtual void __stdcall w_s64 ( s64 a); - virtual void __stdcall w_u32 ( u32 a); - virtual void __stdcall w_s32 ( s32 a); - virtual void __stdcall w_u16 ( u16 a); - virtual void __stdcall w_s16 ( s16 a); - virtual void __stdcall w_u8 ( u8 a); - virtual void __stdcall w_s8 ( s8 a); - virtual void __stdcall w_stringZ ( LPCSTR S); + virtual void __stdcall w_float ( float a); + virtual void __stdcall w_vec3 ( const Fvector& a); + virtual void __stdcall w_vec4 ( const Fvector4& a); + virtual void __stdcall w_u64 ( u64 a); + virtual void __stdcall w_s64 ( s64 a); + virtual void __stdcall w_u32 ( u32 a); + virtual void __stdcall w_s32 ( s32 a); + virtual void __stdcall w_u16 ( u16 a); + virtual void __stdcall w_s16 ( s16 a); + virtual void __stdcall w_u8 ( u8 a); + virtual void __stdcall w_s8 ( s8 a); + virtual void __stdcall w_stringZ ( LPCSTR S); - virtual void __stdcall r_vec3 (Fvector&); - virtual void __stdcall r_vec4 (Fvector4&); - virtual void __stdcall r_float (float&); - virtual void __stdcall r_u8 (u8&); - virtual void __stdcall r_u16 (u16&); - virtual void __stdcall r_u32 (u32&); - virtual void __stdcall r_u64 (u64&); - virtual void __stdcall r_s8 (s8&); - virtual void __stdcall r_s16 (s16&); - virtual void __stdcall r_s32 (s32&); - virtual void __stdcall r_s64 (s64&); + virtual void __stdcall r_vec3 (Fvector&); + virtual void __stdcall r_vec4 (Fvector4&); + virtual void __stdcall r_float (float&); + virtual void __stdcall r_u8 (u8&); + virtual void __stdcall r_u16 (u16&); + virtual void __stdcall r_u32 (u32&); + virtual void __stdcall r_u64 (u64&); + virtual void __stdcall r_s8 (s8&); + virtual void __stdcall r_s16 (s16&); + virtual void __stdcall r_s32 (s32&); + virtual void __stdcall r_s64 (s64&); - virtual void __stdcall r_string (LPSTR dest, u32 dest_size) ; - virtual void __stdcall skip_stringZ (); + virtual void __stdcall r_string (LPSTR dest, u32 dest_size) ; + virtual void __stdcall skip_stringZ(); }; #pragma pack (pop) diff --git a/src/editors/LevelEditor/lephysics.h b/src/editors/LevelEditor/lephysics.h index ba2e7e80090..10147a8ec35 100644 --- a/src/editors/LevelEditor/lephysics.h +++ b/src/editors/LevelEditor/lephysics.h @@ -1,7 +1,7 @@ #ifndef _LE_PHYSICS_H_ #define _LE_PHYSICS_H_ -#include "../../xrphysics/xrphysics.h" +#include "xrPhysics/xrPhysics.h" class CObjectSpace; class CScenePhyscs @@ -9,20 +9,20 @@ class CScenePhyscs CObjectSpace *m_object_space ; bool b_update_level_collision; public: - CScenePhyscs () : m_object_space(0), b_update_level_collision(false) {} - ~CScenePhyscs () ; + CScenePhyscs () : m_object_space(0), b_update_level_collision(false) {} + ~CScenePhyscs () ; public: - void CreateWorld (); - void DestroyWorld (); + void CreateWorld (); + void DestroyWorld (); void CreateShellsSelected(); - void DestroyAll (); - void UseSimulatePoses (); + void DestroyAll (); + void UseSimulatePoses(); void UpdateLevelCollision(){ b_update_level_collision=true; } - void OnSceneModified (); - bool Simulating (); + void OnSceneModified (); + bool Simulating (); private: - bool CreateObjectSpace (bool b_selected_only); - void DestroyObjectSpace (); + bool CreateObjectSpace(bool b_selected_only); + void DestroyObjectSpace(); }; extern CScenePhyscs g_scene_physics; diff --git a/src/editors/LevelEditor/main.cpp b/src/editors/LevelEditor/main.cpp index 9c37e055fc3..f3716eca456 100644 --- a/src/editors/LevelEditor/main.cpp +++ b/src/editors/LevelEditor/main.cpp @@ -11,90 +11,99 @@ TfrmMain *frmMain; #pragma link "RenderWindow" #pragma resource "*.dfm" -#include "topbar.h" -#include "leftbar.h" -#include "bottombar.h" +#include "TopBar.h" +#include "LeftBar.h" +#include "BottomBar.h" //------------------------------------------------------------------------------ #include "shader.h" #include "shader_xrlc.h" -#include "../ECore/Engine/texture.h" -#include "../ECore/Editor/Library.h" -#include "../ECore/Editor/EditObject.h" -#include "../ECore/Editor/EThumbnail.h" -#include "../xrEProps/FolderLib.h" +#include "editors/ECore/Engine/texture.h" +#include "editors/ECore/Editor/Library.h" +#include "editors/ECore/Editor/EditObject.h" +#include "editors/ECore/Editor/EThumbnail.h" +#include "editors/xrEProps/FolderLib.h" #include "LightAnimLibrary.h" -#include "../ECore/Editor/ImageManager.h" -#include "../ECore/Editor/SoundManager.h" -#include "../ECore/Editor/ui_main.h" +#include "editors/ECore/Editor/ImageManager.h" +#include "editors/ECore/Editor/SoundManager.h" +#include "editors/ECore/Editor/ui_main.h" #include "..\..\Layers\xrRender\PSLibrary.h" #include "GameMtlLib.h" -#include "../../xrSound/soundrender_source.h" +#include "xrSound/soundrender_source.h" #include "ResourceManager.h" -#include "../xrEProps/EditorChooseEvents.h" +#include "editors/xrEProps/EditorChooseEvents.h" -__fastcall TfrmMain::TfrmMain(TComponent* Owner) - : TForm(Owner) +__fastcall TfrmMain::TfrmMain(TComponent *Owner) + : TForm(Owner) { -// forms - fraBottomBar = xr_new ((TComponent*)0); - fraTopBar = xr_new ((TComponent*)0); - fraLeftBar = xr_new ((TComponent*)0); -//- - - fraBottomBar->Parent = paBottomBar; - fraTopBar->Parent = paTopBar; - fraLeftBar->Parent = paLeftBar; - if (paLeftBar->Tag > 0) paLeftBar->Parent = paTopBar; - else paLeftBar->Parent = frmMain; - - EDevice.SetHandle (Handle,D3DWindow->Handle); - EnableReceiveCommands (); - if (!ExecCommand(COMMAND_INITIALIZE,(u32)D3DWindow,(u32)paRender)){ - FlushLog (); - TerminateProcess(GetCurrentProcess(),-1); + // forms + fraBottomBar = xr_new((TComponent*)0); + fraTopBar = xr_new((TComponent*)0); + fraLeftBar = xr_new((TComponent*)0); + //- + + fraBottomBar->Parent = paBottomBar; + fraTopBar->Parent = paTopBar; + fraLeftBar->Parent = paLeftBar; + if (paLeftBar->Tag>0) + paLeftBar->Parent = paTopBar; + else + paLeftBar->Parent = frmMain; + + EDevice.SetHandle(Handle, D3DWindow->Handle); + EnableReceiveCommands(); + if (!ExecCommand(COMMAND_INITIALIZE, (u32)D3DWindow, (u32)paRender)) + { + FlushLog(); + TerminateProcess(GetCurrentProcess(), -1); } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormShow(TObject *Sender) { - tmRefresh->Enabled = true; tmRefreshTimer(Sender); - ExecCommand (COMMAND_UPDATE_GRID); - ExecCommand (COMMAND_RENDER_FOCUS); - FillChooseEvents (); + tmRefresh->Enabled = true; + tmRefreshTimer(Sender); + ExecCommand(COMMAND_UPDATE_GRID); + ExecCommand(COMMAND_RENDER_FOCUS); + FillChooseEvents(); // special case :( - frmMain->WindowState = (TWindowState)fsStorage->ReadInteger("window_state",frmMain->WindowState); + frmMain->WindowState = (TWindowState)fsStorage->ReadInteger("window_state", frmMain->WindowState); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormClose(TObject *Sender, TCloseAction &Action) { - Application->OnIdle = 0; + Application->OnIdle = 0; - ClearChooseEvents (); + ClearChooseEvents(); - ExecCommand (COMMAND_DESTROY); + ExecCommand(COMMAND_DESTROY); - fraTopBar->Parent = 0; - fraLeftBar->Parent = 0; - fraBottomBar->Parent = 0; + fraTopBar->Parent = 0; + fraLeftBar->Parent = 0; + fraBottomBar->Parent = 0; xr_delete(fraTopBar); xr_delete(fraBottomBar); - xr_delete(fraLeftBar); + xr_delete(fraLeftBar); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormCloseQuery(TObject *Sender, bool &CanClose) { tmRefresh->Enabled = false; CanClose = ExecCommand(COMMAND_EXIT); - if (!CanClose) tmRefresh->Enabled = true; + if (!CanClose) + tmRefresh->Enabled = true; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormCreate(TObject *Sender) { - DEFINE_INI(fsStorage); + DEFINE_INI(fsStorage); Application->OnIdle = IdleHandler; } @@ -102,32 +111,38 @@ void __fastcall TfrmMain::FormCreate(TObject *Sender) #include "RightForm.h" #define MIN_PANEL_HEIGHT 17 + void __fastcall TfrmMain::sbToolsMinClick(TObject *Sender) { - if (paLeftBar->Tag > 0) + if (paLeftBar->Tag>0) + { + paLeftBar->Parent = frmMain; + paLeftBar->Tag = 0; + frmRight->Visible = false; + } + else { - paLeftBar->Parent = frmMain; - paLeftBar->Tag = 0; - frmRight->Visible = false; - }else{ paLeftBar->Parent = frmRight; //paTopBar; - frmRight->Width = paLeftBar->Width; - frmRight->Height = 1024; - paLeftBar->Tag = 1; + frmRight->Width = paLeftBar->Width; + frmRight->Height = 1024; + paLeftBar->Tag = 1; frmRight->Visible = true; } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::TopClick(TObject *Sender) { - if (paLeftBar->Tag > 0){ - paLeftBar->Align = alRight; + if (paLeftBar->Tag>0) + { + paLeftBar->Align = alRight; paLeftBar->Parent = frmMain; paLeftBar->Height = paLeftBar->Tag; - paLeftBar->Tag = 0; + paLeftBar->Tag = 0; } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::IdleHandler(TObject *Sender, bool &Done) @@ -135,132 +150,169 @@ void __fastcall TfrmMain::IdleHandler(TObject *Sender, bool &Done) Done = false; UI->Idle(); } + void __fastcall TfrmMain::D3DWindowResize(TObject *Sender) { UI->Resize(); -} +} + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyDown(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { ShiftKey = Shift; - if (!UI->KeyDown(Key, Shift)){UI->ApplyShortCut(Key, Shift);} + if (!UI->KeyDown(Key, Shift)) + { + UI->ApplyShortCut(Key, Shift); + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyUp(TObject *Sender, WORD &Key, - TShiftState Shift) + TShiftState Shift) { - if (!UI->KeyUp(Key, Shift)){;} + if (!UI->KeyUp(Key, Shift)) + { + ; + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowKeyPress(TObject *Sender, char &Key) { - if (!UI->KeyPress(Key, ShiftKey)){;} + if (!UI->KeyPress(Key, ShiftKey)) + { + ; + } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { - if (!D3DWindow->Focused()) UI->ApplyGlobalShortCut(Key, Shift); - if (Key==VK_MENU) Key=0; + if (!D3DWindow->Focused()) + UI->ApplyGlobalShortCut(Key, Shift); + if (Key==VK_MENU) + Key = 0; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::UpdateCaption() { AnsiString name; - name.sprintf("%s - [%s%s]",UI->EditorDesc(),UI->GetCaption(),UI->IsModified()?"*":""); + name.sprintf("%s - [%s%s]", UI->EditorDesc(), UI->GetCaption(), UI->IsModified() ? "*" : ""); Caption = name; } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::tmRefreshTimer(TObject *Sender) { int i; - for (i=0; iComponentCount; i++){ - TComponent* temp = frmMain->Components[i]; - if (dynamic_cast(temp) != NULL) + for (i = 0; iComponentCount; i++) + { + TComponent *temp = frmMain->Components[i]; + if (dynamic_cast(temp)!=NULL) ((TExtBtn*)temp)->UpdateMouseInControl(); } - fraLeftBar->OnTimer(); - fraTopBar->OnTimer(); + fraLeftBar->OnTimer(); + fraTopBar->OnTimer(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowPaint(TObject *Sender) { - if (!UI||!UI->m_bReady) return; + if (!UI||!UI->m_bReady) + return; UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowChangeFocus(TObject *Sender) { - if (!UI||!UI->m_bReady) return; - if (D3DWindow->Focused()){ + if (!UI||!UI->m_bReady) + return; + if (D3DWindow->Focused()) + { UI->IR_Capture(); - UI->OnAppActivate(); - }else{ - UI->OnAppDeactivate(); + UI->OnAppActivate(); + } + else + { + UI->OnAppDeactivate(); UI->IR_Release(); -// paRender->Color=paRender->Color; // ÷òîáû íå áûëî internal code gen error + // paRender->Color=paRender->Color; // ÷òîáû íå áûëî internal code gen error } } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - UI->MousePress(Shift,X,Y); + UI->MousePress(Shift, X, Y); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseUp(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - UI->MouseRelease(Shift,X,Y); + UI->MouseRelease(Shift, X, Y); UI->RedrawScene(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::D3DWindowMouseMove(TObject *Sender, - TShiftState Shift, int X, int Y) + TShiftState Shift, int X, int Y) { - UI->MouseMove(Shift,X,Y); + UI->MouseMove(Shift, X, Y); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::ebAllMinClick(TObject *Sender) { - fraLeftBar->MinimizeAllFrames(); + fraLeftBar->MinimizeAllFrames(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::ebAllMaxClick(TObject *Sender) { - fraLeftBar->MaximizeAllFrames(); + fraLeftBar->MaximizeAllFrames(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::FormResize(TObject *Sender) { - if (fraLeftBar) fraLeftBar->UpdateBar(); + if (fraLeftBar) + fraLeftBar->UpdateBar(); } + //--------------------------------------------------------------------------- void __fastcall TfrmMain::paRenderResize(TObject *Sender) { - ExecCommand(COMMAND_RENDER_RESIZE); + ExecCommand(COMMAND_RENDER_RESIZE); } + //--------------------------------------------------------------------------- - + void __fastcall TfrmMain::fsStorageSavePlacement(TObject *Sender) { - fsStorage->WriteInteger("window_state",frmMain->WindowState); + fsStorage->WriteInteger("window_state", frmMain->WindowState); } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/previewimage.cpp b/src/editors/LevelEditor/previewimage.cpp index 8e2383125ab..f2956dc08d5 100644 --- a/src/editors/LevelEditor/previewimage.cpp +++ b/src/editors/LevelEditor/previewimage.cpp @@ -2,76 +2,91 @@ #pragma hdrstop #include "PreviewImage.h" -#include "../ECore/Engine/Texture.h" +#include "editors/ECore/Engine/Texture.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" -TfrmPreviewImage* TfrmPreviewImage::form = 0; +TfrmPreviewImage *TfrmPreviewImage::form = 0; + //--------------------------------------------------------------------------- -__fastcall TfrmPreviewImage::TfrmPreviewImage(TComponent* Owner) - : TForm(Owner) -{ -} +__fastcall TfrmPreviewImage::TfrmPreviewImage(TComponent *Owner) + : TForm(Owner) {} + //--------------------------------------------------------------------------- void __fastcall TfrmPreviewImage::FormKeyDown(TObject *Sender, - WORD &Key, TShiftState Shift) + WORD &Key, TShiftState Shift) { - if (Key==VK_ESCAPE) Close(); + if (Key==VK_ESCAPE) + Close(); } //---------------------------------------------------- -int __fastcall TfrmPreviewImage::Run(){ - form = xr_new((TComponent*)0); +int __fastcall TfrmPreviewImage::Run() +{ + form = xr_new((TComponent*)0); -//S -/* - VERIFY(T); - form->tex = T; - form->ClientHeight = T->height()+4; - form->ClientWidth = T->width()+4; - form->mult = 1; -*/ + //S + /* + VERIFY(T); + form->tex = T; + form->ClientHeight = T->height()+4; + form->ClientWidth = T->width()+4; + form->mult = 1; + */ return form->ShowModal(); } //---------------------------------------------------- void __fastcall TfrmPreviewImage::FormClose(TObject *Sender, - TCloseAction &Action) + TCloseAction &Action) { - Action = caFree; + Action = caFree; form = 0; } + //--------------------------------------------------------------------------- void __fastcall TfrmPreviewImage::pbImagePaint(TObject *Sender) { - if (tex){ + if (tex) + { int w = paImage->Width-4; int h = paImage->Height-4; RECT r; - r.left = 2; r.top = 2; - r.right = w+2; r.bottom = h+2; -//S tex->DrawStretch(paImage->Handle, &r); + r.left = 2; + r.top = 2; + r.right = w+2; + r.bottom = h+2; + //S tex->DrawStretch(paImage->Handle, &r); } } + //--------------------------------------------------------------------------- void __fastcall TfrmPreviewImage::pbImageMouseDown(TObject *Sender, - TMouseButton Button, TShiftState Shift, int X, int Y) + TMouseButton Button, TShiftState Shift, int X, int Y) { - if (Shift.Contains(ssShift)){ - if (Button==mbLeft){ + if (Shift.Contains(ssShift)) + { + if (Button==mbLeft) + { mult *= 2; - }else if (Button==mbRight){ + } + else if (Button==mbRight) + { mult /= 2; } - if (mult<=0.0625) mult = 0.0625; - if (mult>=2) mult = 2; -//S ClientHeight = tex->height()*mult+4; -//S ClientWidth = tex->width()*mult+4; + if (mult<=0.0625) + mult = 0.0625; + if (mult>=2) + mult = 2; + //S ClientHeight = tex->height()*mult+4; + //S ClientWidth = tex->width()*mult+4; } } + //--------------------------------------------------------------------------- + diff --git a/src/editors/LevelEditor/stdafx.h b/src/editors/LevelEditor/stdafx.h index 99743e17ec3..41eb98a82ce 100644 --- a/src/editors/LevelEditor/stdafx.h +++ b/src/editors/LevelEditor/stdafx.h @@ -18,9 +18,9 @@ #define DIRECTINPUT_VERSION 0x0800 -#define R_R1 1 -#define R_R2 2 -#define RENDER R_R1 +#define R_R1 1 +#define R_R2 2 +#define RENDER R_R1 // Std C++ headers #include @@ -35,38 +35,58 @@ #ifdef _eof #undef _eof #endif -__inline int _eof (int _a) { return ::eof(_a); } +__inline int _eof(int _a) +{ + return ::eof(_a); +} #ifdef _access #undef _access #endif -__inline int _access(const char *_a, int _b) { return ::access(_a,_b); } +__inline int _access(const char *_a, int _b) +{ + return ::access(_a, _b); +} #ifdef _lseek #undef _lseek #endif -__inline long _lseek(int handle, long offset, int fromwhere){ return ::lseek(handle, offset, fromwhere);} +__inline long _lseek(int handle, long offset, int fromwhere) +{ + return ::lseek(handle, offset, fromwhere); +} #ifdef _dup #undef _dup #endif #define fmodf fmod -__inline int _dup (int handle) { return ::dup(handle);} -__inline float modff(float a, float *b){ - double x,y; - y = modf(double(a),&x); + +__inline int _dup(int handle) +{ + return ::dup(handle); +} + +__inline float modff(float a, float *b) +{ + double x, y; + y = modf(double(a), &x); *b = x; return float(y); } -__inline float expf (float val) { return ::exp(val);} +__inline float expf(float val) +{ + return ::exp(val); +} + +#include "xrCore/Platform.h" -#ifdef _ECOREB - #define ECORE_API __declspec(dllexport) - #define ENGINE_API __declspec(dllexport) +#ifdef _ECOREB + #define ECORE_API XR_EXPORT + #define ENGINE_API XR_EXPORT #else - #define ECORE_API __declspec(dllimport) - #define ENGINE_API __declspec(dllimport) +#define ECORE_API XR_IMPORT +#define ENGINE_API XR_IMPORT #endif -#define DLL_API __declspec(dllimport) +#define DLL_API XR_IMPORT #define PropertyGP(a,b) __declspec( property( get=a, put=b ) ) #define THROW FATAL("THROW"); #define THROW2(a) FATAL(a); @@ -75,7 +95,7 @@ __inline float expf (float val) { return ::exp(val);} #define clMsg Msg // core -#include +#include #ifdef _EDITOR class PropValue; @@ -86,61 +106,70 @@ __inline float expf (float val) { return ::exp(val);} DEFINE_VECTOR(ListItem*,ListItemsVec,ListItemsIt); #endif -#include "../../xrCDB/xrCDB.h" -#include "../../xrSound/Sound.h" -#include +#include "xrCDB/xrCDB.h" +#include "xrSound/Sound.h" +#include // DirectX headers #include #include -#include "..\..\Layers\xrRender\xrD3dDefs.h" +#include "Layers/xrRender/xrD3dDefs.h" #include #include // some user components -#include "fmesh.h" -#include "_d3d_extensions.h" +#include "xrCore/FMesh.hpp" +#include "Common/_d3d_extensions.h" -#include "../ECore/Editor/D3DX_Wrapper.h" +#include "editors/ECore/Editor/D3DX_Wrapper.h" -DEFINE_VECTOR (AnsiString,AStringVec,AStringIt); -DEFINE_VECTOR (AnsiString*,LPAStringVec,LPAStringIt); +DEFINE_VECTOR(AnsiString, AStringVec, AStringIt); +DEFINE_VECTOR(AnsiString *, LPAStringVec, LPAStringIt); -#include "../../../xrServerEntities/xrEProps.h" -#include "Log.h" -#include "../ECore/editor/engine.h" -#include "defines.h" -#include "../../xrServerEntities/PropertiesListHelper.h" -#include "../xrEProps/PropertiesList.h" -#include "../xrEProps/ItemList.h" -#include "../xrEProps/ChoseForm.h" +#include "xrServerEntities/xrEProps.h" +#include "xrCore/Log.h" +#include "editors/ECore/Editor/engine.h" +#include "xrEngine/defines.h" +#include "xrServerEntities/PropertiesListHelper.h" +#include "editors/xrEProps/PropertiesList.h" +#include "editors/xrEProps/ItemList.h" +#include "editors/xrEProps/ChoseForm.h" struct str_pred : public std::binary_function { - IC bool operator()(LPCSTR x, LPCSTR y) const - { return strcmp(x,y)<0; } + IC + + bool operator()(LPCSTR x, LPCSTR y) const + { + return strcmp(x, y)<0; + } }; + struct astr_pred : public std::binary_function { - IC bool operator()(const AnsiString& x, const AnsiString& y) const - { return xEditorName(),".ini").c_str());} -#define DEFINE_INI(storage) {string_path buf; INI_NAME(buf); storage->IniFileName=buf;} +#define INI_NAME( buf ) { FS.update_path( buf, "$local_root$", EFS.ChangeFileExt( UI->EditorName(), ".ini" ).c_str() ); } +#define DEFINE_INI(storage) { string_path buf; INI_NAME(buf); storage->IniFileName=buf; } #define NONE_CAPTION "" #define MULTIPLESEL_CAPTION "" @@ -161,8 +190,8 @@ struct astr_pred : public std::binary_function Date: Fri, 4 Dec 2015 07:19:33 +0500 Subject: [PATCH 10/10] Delete all_editors_vs folder Everything was there included in solution --- src/all_editors_vs/all_editors_vs.sln | 34 - src/all_editors_vs/all_editors_vs.vcxproj | 213 ------ .../all_editors_vs.vcxproj.filters | 379 --------- src/all_editors_vs/le/le.vcxproj | 306 -------- src/all_editors_vs/le/le.vcxproj.filters | 724 ------------------ 5 files changed, 1656 deletions(-) delete mode 100644 src/all_editors_vs/all_editors_vs.sln delete mode 100644 src/all_editors_vs/all_editors_vs.vcxproj delete mode 100644 src/all_editors_vs/all_editors_vs.vcxproj.filters delete mode 100644 src/all_editors_vs/le/le.vcxproj delete mode 100644 src/all_editors_vs/le/le.vcxproj.filters diff --git a/src/all_editors_vs/all_editors_vs.sln b/src/all_editors_vs/all_editors_vs.sln deleted file mode 100644 index 1d10edc9d8c..00000000000 --- a/src/all_editors_vs/all_editors_vs.sln +++ /dev/null @@ -1,34 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ecore", "all_editors_vs.vcxproj", "{226C6807-BB48-4A07-BF13-806C38FD8FBE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "le", "le\le.vcxproj", "{136857E3-D61B-4A03-A4E9-7F73ED946C41}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ae", "ae\ae.vcproj", "{027C2413-9620-4C61-B7A0-84160D081826}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {226C6807-BB48-4A07-BF13-806C38FD8FBE}.Debug|Win32.ActiveCfg = Debug|Win32 - {226C6807-BB48-4A07-BF13-806C38FD8FBE}.Debug|Win32.Build.0 = Debug|Win32 - {226C6807-BB48-4A07-BF13-806C38FD8FBE}.Release|Win32.ActiveCfg = Release|Win32 - {226C6807-BB48-4A07-BF13-806C38FD8FBE}.Release|Win32.Build.0 = Release|Win32 - {136857E3-D61B-4A03-A4E9-7F73ED946C41}.Debug|Win32.ActiveCfg = Debug|Win32 - {136857E3-D61B-4A03-A4E9-7F73ED946C41}.Debug|Win32.Build.0 = Debug|Win32 - {136857E3-D61B-4A03-A4E9-7F73ED946C41}.Release|Win32.ActiveCfg = Release|Win32 - {136857E3-D61B-4A03-A4E9-7F73ED946C41}.Release|Win32.Build.0 = Release|Win32 - {027C2413-9620-4C61-B7A0-84160D081826}.Debug|Win32.ActiveCfg = Debug|Win32 - {027C2413-9620-4C61-B7A0-84160D081826}.Debug|Win32.Build.0 = Debug|Win32 - {027C2413-9620-4C61-B7A0-84160D081826}.Release|Win32.ActiveCfg = Release|Win32 - {027C2413-9620-4C61-B7A0-84160D081826}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/all_editors_vs/all_editors_vs.vcxproj b/src/all_editors_vs/all_editors_vs.vcxproj deleted file mode 100644 index be7182abbf3..00000000000 --- a/src/all_editors_vs/all_editors_vs.vcxproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - ecore - {226C6807-BB48-4A07-BF13-806C38FD8FBE} - all_editors_vs - - - - Application - v120 - MultiByte - true - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>12.0.30501.0 - - - $(xrBinDir) - $(xrIntDir)$(ProjectName)\ - - - $(xrBinDir) - $(xrIntDir)$(ProjectName)\ - - - - Disabled - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - EditAndContinue - - - true - MachineX86 - - - - - MultiThreadedDLL - Level3 - ProgramDatabase - - - true - true - true - MachineX86 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - $(IntDir)%(Filename)1.obj - $(IntDir)%(Filename)1.xdc - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/all_editors_vs/all_editors_vs.vcxproj.filters b/src/all_editors_vs/all_editors_vs.vcxproj.filters deleted file mode 100644 index bc4fee44b9c..00000000000 --- a/src/all_editors_vs/all_editors_vs.vcxproj.filters +++ /dev/null @@ -1,379 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {bd4da29f-ba45-4510-b9d6-597208ddcbb3} - - - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - engine - - - engine - - - engine - - - engine - - - engine - - - engine - - - engine - - - engine - - - engine - - - engine - - - engine - - - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - editor - - - engine - - - engine - - - engine - - - engine - - - engine - - - engine - - - engine - - - engine - - - engine - - - \ No newline at end of file diff --git a/src/all_editors_vs/le/le.vcxproj b/src/all_editors_vs/le/le.vcxproj deleted file mode 100644 index d0c546111d3..00000000000 --- a/src/all_editors_vs/le/le.vcxproj +++ /dev/null @@ -1,306 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {136857E3-D61B-4A03-A4E9-7F73ED946C41} - le - - - - Application - v120 - MultiByte - true - - - Application - v120 - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>12.0.30501.0 - - - $(xrBinDir) - $(xrIntDir)$(ProjectName)\ - - - $(xrBinDir) - $(xrIntDir)$(ProjectName)\ - - - - Disabled - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - EditAndContinue - - - true - MachineX86 - - - - - MultiThreadedDLL - Level3 - ProgramDatabase - - - true - true - true - MachineX86 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/all_editors_vs/le/le.vcxproj.filters b/src/all_editors_vs/le/le.vcxproj.filters deleted file mode 100644 index fca3448a013..00000000000 --- a/src/all_editors_vs/le/le.vcxproj.filters +++ /dev/null @@ -1,724 +0,0 @@ - - - - - {6af9e9d0-38ed-494f-b1ee-076edbdde750} - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {337acd83-09eb-48e0-a6f6-931a4bb52d34} - - - {9368490a-a99a-4d3d-b9e7-02677f8a1c77} - - - {c7127535-b32e-4e4a-9a9a-0d3ec7e26826} - - - {9568b8f9-99ff-401c-b3e2-6d77d320361a} - - - {2ef4d121-e4b8-439b-9443-f8324c0c876c} - - - {13c6df2e-df6f-42c8-9f76-322502e70c4c} - - - {1cc8111a-f6fe-4ca2-953f-447b6645996a} - - - {7e4b5281-3a19-4314-8434-6ecc16f6e7b7} - - - {a3db7cce-e836-4f2a-bcff-38ac34f3ca64} - - - {fe258006-8c69-45eb-9bd0-bdf281b0a5ee} - - - {65abe1c9-dc3c-421d-9308-304237326c64} - - - {fa9551af-80f1-4951-9a3c-483fce01d3a7} - - - {e7f57d27-0e61-4684-94f0-c41f69f180b3} - - - {b2edd218-0f18-41c3-9a9c-7edfda97e4cd} - - - {fa72d81d-b176-422c-9347-79b6154053c6} - - - {10f43cda-1fdf-4aa3-8b54-a794726571dc} - - - - - engine - - - engine - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - tools\aimap - - - tools\aimap - - - tools\aimap - - - tools\shape - - - tools\shape - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\do - - - tools\dummy - - - tools\Sound - - - tools\Sound - - - tools\Sound - - - tools\Sound - - - tools\sector&portal - - - tools\sector&portal - - - tools\sector&portal - - - tools\sector&portal - - - tools\sector&portal - - - tools\sector&portal - - - tools\spawn - - - tools\spawn - - - tools\spawn - - - tools\wallmark - - - tools\wallmark - - - tools\group - - - tools\group - - - tools\group - - - tools\way - - - tools\way - - - tools\way - - - tools\base & objects - - - tools\base & objects - - - tools\base & objects - - - tools\base & objects - - - tools\base & objects - - - Scene - - - Scene - - - Scene - - - Scene - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - frames - - - tools\aimap - - - tools\aimap - - - tools\aimap - - - tools\aimap - - - tools\aimap - - - tools\aimap - - - tools\aimap - - - tools\aimap - - - tools\shape - - - tools\shape - - - tools\shape - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\light glow & particles - - - tools\do - - - tools\dummy - - - tools\Sound - - - tools\Sound - - - tools\Sound - - - tools\Sound - - - tools\Sound - - - tools\Sound - - - tools\sector&portal - - - tools\sector&portal - - - tools\sector&portal - - - tools\sector&portal - - - tools\sector&portal - - - tools\sector&portal - - - tools\sector&portal - - - tools\sector&portal - - - tools\spawn - - - tools\spawn - - - tools\spawn - - - tools\spawn - - - tools\wallmark - - - tools\wallmark - - - tools\group - - - tools\group - - - tools\group - - - tools\group - - - tools\way - - - tools\way - - - tools\way - - - tools\way - - - tools\base & objects - - - tools\base & objects - - - tools\base & objects - - - tools\base & objects - - - tools\base & objects - - - tools\base & objects - - - tools\base & objects - - - builder - - - builder - - - builder - - - builder - - - builder - - - builder - - - builder - - - builder - - - Scene - - - Scene - - - Scene - - - Scene - - - Scene - - - Scene - - - Scene - - - Scene - - - Scene - - - Scene - - - Scene - - - Scene - - - \ No newline at end of file