mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-04-30 17:11:40 -04:00
Introduced voxel render lib written by Thomas Sneddon .
This commit is contained in:
parent
5648034cc5
commit
38ddc52d28
16 changed files with 329 additions and 215 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +1,6 @@
|
|||
[submodule "gtest-lib"]
|
||||
path = googletest
|
||||
url = ../gtest-lib.git
|
||||
[submodule "3rdParty/CncVxlRender"]
|
||||
path = 3rdParty/CncVxlRender
|
||||
url = ../CncVxlRenderText.git
|
||||
|
|
1
3rdParty/CncVxlRender
vendored
Submodule
1
3rdParty/CncVxlRender
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit ebea5a3718f27be0a57e717fafa8cc2afbede0e1
|
2
3rdParty/xcc/misc/cc_file.h
vendored
2
3rdParty/xcc/misc/cc_file.h
vendored
|
@ -191,5 +191,5 @@ private:
|
|||
bool m_is_open = false;
|
||||
int64_t m_p;
|
||||
const bool m_read_on_open;
|
||||
size_t m_size;
|
||||
int64_t m_size;
|
||||
};
|
||||
|
|
5
3rdParty/xcc/misc/tmp_ts_file.h
vendored
5
3rdParty/xcc/misc/tmp_ts_file.h
vendored
|
@ -34,7 +34,10 @@ public:
|
|||
bool is_valid() const
|
||||
{
|
||||
const t_tmp_ts_header& h = header();
|
||||
auto const size = get_size();
|
||||
if (get_size() < 0) {
|
||||
return false;
|
||||
}
|
||||
auto const size = static_cast<size_t>(get_size());
|
||||
if (sizeof(t_tmp_ts_header) > size ||
|
||||
!h.cblocks_x || !h.cblocks_y ||
|
||||
h.cx != 48 && h.cx != 60 ||
|
||||
|
|
|
@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MissionEditor", "MissionEditor\MissionEditor.vcxproj", "{9326D29A-6547-42B9-A668-519F3C0720A9}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A} = {5E445578-CB45-4D82-9A1C-FC7D3E8D866A}
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63} = {BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MissionEditorPackLib", "MissionEditorPackLib\MissionEditorPackLib.vcxproj", "{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}"
|
||||
|
@ -17,6 +18,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XCC Library", "3rdParty\xcc
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "UnitTest\UnitTest.vcxproj", "{75E18879-7564-4A2C-8C00-393A5A17171F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CncVxlRenderText", "3rdParty\CncVxlRender\CncVxlRenderText.vcxproj", "{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -39,6 +42,8 @@ Global
|
|||
Template|x64 = Template|x64
|
||||
Tests FinalAlertDebug YR|Win32 = Tests FinalAlertDebug YR|Win32
|
||||
Tests FinalAlertDebug YR|x64 = Tests FinalAlertDebug YR|x64
|
||||
Tool|Win32 = Tool|Win32
|
||||
Tool|x64 = Tool|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9326D29A-6547-42B9-A668-519F3C0720A9}.Debug|Win32.ActiveCfg = Tests FinalAlertDebug YR|Win32
|
||||
|
@ -81,6 +86,10 @@ Global
|
|||
{9326D29A-6547-42B9-A668-519F3C0720A9}.Tests FinalAlertDebug YR|Win32.Build.0 = Tests FinalAlertDebug YR|Win32
|
||||
{9326D29A-6547-42B9-A668-519F3C0720A9}.Tests FinalAlertDebug YR|x64.ActiveCfg = Tests FinalAlertDebug YR|x64
|
||||
{9326D29A-6547-42B9-A668-519F3C0720A9}.Tests FinalAlertDebug YR|x64.Build.0 = Tests FinalAlertDebug YR|x64
|
||||
{9326D29A-6547-42B9-A668-519F3C0720A9}.Tool|Win32.ActiveCfg = Template|Win32
|
||||
{9326D29A-6547-42B9-A668-519F3C0720A9}.Tool|Win32.Build.0 = Template|Win32
|
||||
{9326D29A-6547-42B9-A668-519F3C0720A9}.Tool|x64.ActiveCfg = Template|x64
|
||||
{9326D29A-6547-42B9-A668-519F3C0720A9}.Tool|x64.Build.0 = Template|x64
|
||||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
@ -121,6 +130,10 @@ Global
|
|||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}.Tests FinalAlertDebug YR|Win32.Build.0 = Debug|Win32
|
||||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}.Tests FinalAlertDebug YR|x64.ActiveCfg = Debug|x64
|
||||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}.Tests FinalAlertDebug YR|x64.Build.0 = Debug|x64
|
||||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}.Tool|Win32.ActiveCfg = Release|Win32
|
||||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}.Tool|Win32.Build.0 = Release|Win32
|
||||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}.Tool|x64.ActiveCfg = Release|x64
|
||||
{DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C}.Tool|x64.Build.0 = Release|x64
|
||||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
@ -161,6 +174,10 @@ Global
|
|||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}.Tests FinalAlertDebug YR|Win32.Build.0 = DebugMinimal|Win32
|
||||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}.Tests FinalAlertDebug YR|x64.ActiveCfg = Debug|x64
|
||||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}.Tests FinalAlertDebug YR|x64.Build.0 = Debug|x64
|
||||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}.Tool|Win32.ActiveCfg = Release|Win32
|
||||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}.Tool|Win32.Build.0 = Release|Win32
|
||||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}.Tool|x64.ActiveCfg = ReleaseMinimal|x64
|
||||
{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}.Tool|x64.Build.0 = ReleaseMinimal|x64
|
||||
{75E18879-7564-4A2C-8C00-393A5A17171F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{75E18879-7564-4A2C-8C00-393A5A17171F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{75E18879-7564-4A2C-8C00-393A5A17171F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
|
@ -201,6 +218,54 @@ Global
|
|||
{75E18879-7564-4A2C-8C00-393A5A17171F}.Tests FinalAlertDebug YR|Win32.Build.0 = Debug|Win32
|
||||
{75E18879-7564-4A2C-8C00-393A5A17171F}.Tests FinalAlertDebug YR|x64.ActiveCfg = Debug|x64
|
||||
{75E18879-7564-4A2C-8C00-393A5A17171F}.Tests FinalAlertDebug YR|x64.Build.0 = Debug|x64
|
||||
{75E18879-7564-4A2C-8C00-393A5A17171F}.Tool|Win32.ActiveCfg = Release|Win32
|
||||
{75E18879-7564-4A2C-8C00-393A5A17171F}.Tool|Win32.Build.0 = Release|Win32
|
||||
{75E18879-7564-4A2C-8C00-393A5A17171F}.Tool|x64.ActiveCfg = Release|x64
|
||||
{75E18879-7564-4A2C-8C00-393A5A17171F}.Tool|x64.Build.0 = Release|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Debug|x64.Build.0 = Debug|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertDebug YR|Win32.ActiveCfg = Debug|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertDebug YR|Win32.Build.0 = Debug|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertDebug YR|x64.ActiveCfg = Debug|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertDebug YR|x64.Build.0 = Debug|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertDebug|Win32.ActiveCfg = Debug|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertDebug|Win32.Build.0 = Debug|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertDebug|x64.ActiveCfg = Debug|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertDebug|x64.Build.0 = Debug|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertRelease YR|Win32.ActiveCfg = Release|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertRelease YR|Win32.Build.0 = Release|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertRelease YR|x64.ActiveCfg = Release|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertRelease YR|x64.Build.0 = Release|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertRelease|Win32.ActiveCfg = Release|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertRelease|Win32.Build.0 = Release|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertRelease|x64.ActiveCfg = Release|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalAlertRelease|x64.Build.0 = Release|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalSunDebug|Win32.ActiveCfg = Debug|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalSunDebug|Win32.Build.0 = Debug|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalSunDebug|x64.ActiveCfg = Debug|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalSunDebug|x64.Build.0 = Debug|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalSunRelease|Win32.ActiveCfg = Release|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalSunRelease|Win32.Build.0 = Release|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalSunRelease|x64.ActiveCfg = Release|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.FinalSunRelease|x64.Build.0 = Release|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Release|Win32.Build.0 = Release|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Release|x64.ActiveCfg = Release|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Release|x64.Build.0 = Release|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Template|Win32.ActiveCfg = Tool|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Template|Win32.Build.0 = Tool|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Template|x64.ActiveCfg = Tool|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Template|x64.Build.0 = Tool|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Tests FinalAlertDebug YR|Win32.ActiveCfg = Debug|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Tests FinalAlertDebug YR|Win32.Build.0 = Debug|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Tests FinalAlertDebug YR|x64.ActiveCfg = Debug|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Tests FinalAlertDebug YR|x64.Build.0 = Debug|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Tool|Win32.ActiveCfg = Tool|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Tool|Win32.Build.0 = Tool|Win32
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Tool|x64.ActiveCfg = Tool|x64
|
||||
{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}.Tool|x64.Build.0 = Tool|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "VoxelNormals.h"
|
||||
#include <format>
|
||||
#include "IniMega.h"
|
||||
#include "VoxelDrawer.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
|
@ -47,14 +48,6 @@
|
|||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
struct DrawRect
|
||||
{
|
||||
int X{};
|
||||
int Y{};
|
||||
int Width{};
|
||||
int Height{};
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Dialogfeld CLoading
|
||||
|
||||
|
@ -103,6 +96,7 @@ CLoading::CLoading(CWnd* pParent /*=NULL*/) :
|
|||
}
|
||||
|
||||
VXL_Reset();
|
||||
VoxelDrawer::Initalize();
|
||||
|
||||
errstream << "CLoading::CLoading() called" << endl;
|
||||
errstream.flush();
|
||||
|
@ -1578,129 +1572,47 @@ void CLoading::LoadBuilding(const CString& ID)
|
|||
CString TurName = rules.GetStringOr(ID, "TurretAnim", ID + "tur");
|
||||
CString BarlName = ID + "barl";
|
||||
|
||||
auto finder = [this](LPCTSTR lpFilename, char* pTheaterChar) {
|
||||
return this->FindFileInMix(lpFilename, reinterpret_cast<TheaterChar*>(pTheaterChar));
|
||||
};
|
||||
|
||||
//if (!DrawStuff::is_vpl_loaded()) {
|
||||
// DrawStuff::load_vpl("voxels.vpl");
|
||||
//}
|
||||
if (!VoxelDrawer::IsVPLLoaded()) {
|
||||
VoxelDrawer::LoadVPLFile("voxels.vpl", finder);
|
||||
}
|
||||
|
||||
unsigned char* pTurImages[8]{ nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr };
|
||||
unsigned char* pBarlImages[8]{ nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr };
|
||||
DrawRect turrect[8] = { 0 };
|
||||
int barlrect[8][4] = { 0 };
|
||||
VoxelRectangle turrect[8] = { 0 };
|
||||
VoxelRectangle barlrect[8] = { 0 };
|
||||
|
||||
|
||||
CString VXLName = BarlName + ".vxl";
|
||||
CString HVAName = BarlName + ".hva";
|
||||
|
||||
HMIXFILE hBarl = FindFileInMix(BarlName);
|
||||
if (hBarl && FSunPackLib::SetCurrentVXL(VXLName, hBarl)) {
|
||||
auto vnc = FSunPackLib::VoxelNormalClass::Unknown;
|
||||
std::vector<BYTE> vxlColors[8];
|
||||
std::vector<BYTE> vxlLighting[8];
|
||||
// we assume the voxel normal class is always the same for the combined voxels
|
||||
FSunPackLib::GetVXLSectionInfo(0, vnc);
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
float r_x, r_y, r_z;
|
||||
const int dir = i;
|
||||
r_x = 300;
|
||||
r_y = 0;
|
||||
r_z = 45 * dir + 90;
|
||||
|
||||
// convert
|
||||
const double pi = 3.141592654;
|
||||
const Vec3f rotation(r_x / 180.0f * pi, r_y / 180.0f * pi, r_z / 180.0f * pi);
|
||||
RECT r;
|
||||
int center_x, center_y;
|
||||
if (!FSunPackLib::LoadVXLImage(
|
||||
*m_voxelNormalTables,
|
||||
lightDirection,
|
||||
rotation,
|
||||
0,
|
||||
vxlColors[i],
|
||||
vxlLighting[i],
|
||||
¢er_x, ¢er_y,
|
||||
0, nullptr, nullptr, 0, 0, &r)) {
|
||||
break;
|
||||
if (VoxelDrawer::LoadVXLFile(VXLName, finder)) {
|
||||
if (VoxelDrawer::LoadHVAFile(HVAName, finder)) {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
// (13 - i) % 8 for facing fix
|
||||
bool result = VoxelDrawer::GetImageData((13 - i) % 8, pBarlImages[i], barlrect[i], turzadjust);
|
||||
if (!result)
|
||||
break;
|
||||
}
|
||||
|
||||
auto const x = center_x;
|
||||
auto const y = center_y;
|
||||
auto const width = r.right - r.left;
|
||||
auto const height = r.bottom - r.top;
|
||||
|
||||
VXL_Add(vxlColors[i].data(), x, y, width, height);
|
||||
VXL_Add(vxlLighting[i].data(), x, y, width, height);
|
||||
VXL_GetAndClear(pTurImages[i], nullptr, nullptr);
|
||||
barlrect[i] = { x, y, width, height };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VXLName = TurName + ".vxl";
|
||||
HVAName = TurName + ".hva";
|
||||
|
||||
HMIXFILE hVXL = FindFileInMix(VXLName);
|
||||
if (hVXL && FSunPackLib::SetCurrentVXL(VXLName, hVXL)) {
|
||||
auto vnc = FSunPackLib::VoxelNormalClass::Unknown;
|
||||
std::vector<BYTE> vxlColors[8];
|
||||
std::vector<BYTE> vxlLighting[8];
|
||||
// we assume the voxel normal class is always the same for the combined voxels
|
||||
FSunPackLib::GetVXLSectionInfo(0, vnc);
|
||||
if (VoxelDrawer::LoadVXLFile(VXLName, finder) && VoxelDrawer::LoadHVAFile(HVAName, finder)) {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
float r_x, r_y, r_z;
|
||||
const int dir = i;
|
||||
r_x = 300;
|
||||
r_y = 0;
|
||||
r_z = 45 * dir + 90;
|
||||
|
||||
// convert
|
||||
const double pi = 3.141592654;
|
||||
const Vec3f rotation(r_x / 180.0f * pi, r_y / 180.0f * pi, r_z / 180.0f * pi);
|
||||
RECT r;
|
||||
int center_x, center_y;
|
||||
if (!FSunPackLib::LoadVXLImage(
|
||||
*m_voxelNormalTables,
|
||||
lightDirection,
|
||||
rotation,
|
||||
Vec3f{},
|
||||
vxlColors[i],
|
||||
vxlLighting[i],
|
||||
¢er_x, ¢er_y,
|
||||
0, nullptr, nullptr, 0, 0, &r)) {
|
||||
// (13 - i) % 8 for facing fix
|
||||
bool result = VoxelDrawer::GetImageData((13 - i) % 8, pTurImages[i], turrect[i], pBarlImages[i] ? 0 : turzadjust);
|
||||
if (!result) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto const x = center_x;
|
||||
auto const y = center_y;
|
||||
auto const width = r.right - r.left;
|
||||
auto const height = r.bottom - r.top;
|
||||
|
||||
//Blit_PalD(lpT[i], destRect, turretColors[i].data(), srcRect, ddsd.dwWidth, head.cx, ddsd.dwHeight, head.cy);
|
||||
//Blit_PalD(lighting[i].data(), destRect, turretLighting[i].data(), srcRect, ddsd.dwWidth, head.cx, ddsd.dwHeight, head.cy, turretColors[i].data());
|
||||
//if (std::find_if(lighting[i].begin(), lighting[i].end(), [](const BYTE b) { return b != 255; }) != lighting[i].end())
|
||||
// p.lighting = std::shared_ptr<std::vector<BYTE>>(new std::vector<BYTE>(std::move(lighting[i])));
|
||||
|
||||
UnionSHP_Add(vxlColors[i].data(), width, height);
|
||||
UnionSHP_Add(vxlLighting[i].data(), width, height);
|
||||
UnionSHP_GetAndClear(pTurImages[i], nullptr, nullptr, false);
|
||||
//VXL_Add(vxlColors[i].data(), x, y, width, height);
|
||||
//VXL_Add(vxlLighting[i].data(), x, y, width, height);
|
||||
//VXL_GetAndClear(pTurImages[i], nullptr, nullptr);
|
||||
turrect[i] = { x, y, width, height };
|
||||
}
|
||||
}
|
||||
|
||||
//if (DrawStuff::load_vxl(VXLName) && DrawStuff::load_hva(HVAName)) {
|
||||
// for (int i = 0; i < 8; ++i) {
|
||||
// // (13 - i) % 8 for facing fix
|
||||
// bool result = DrawStuff::get_to_image((13 - i) % 8, pTurImages[i],
|
||||
// turrect[i][0], turrect[i][1], turrect[i][2], turrect[i][3], pBarlImages[i] ? 0 : turzadjust);
|
||||
// if (!result) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
auto pTempBuf = new(unsigned char[width * height]);
|
||||
memcpy_s(pTempBuf, width * height, pBuffer, width * height);
|
||||
|
@ -1720,9 +1632,8 @@ void CLoading::LoadBuilding(const CString& ID)
|
|||
pKey.Format("%sY%d", ID, (15 - i) % 8);
|
||||
int turdeltaY = g_data.GetInteger("BuildingVoxelTurretsRA2", pKey);
|
||||
|
||||
//VXL_Add(pTurImages[i], turretRect.X + turdeltaX, turretRect.Y + turdeltaY, turretRect.Width, turretRect.Height);
|
||||
UnionSHP_Add(pTurImages[i], turretRect.Width, turretRect.Height, turretRect.X + turdeltaX, turretRect.Y + turdeltaY);
|
||||
//delete[] pTurImages[i];
|
||||
VXL_Add(pTurImages[i], turretRect.X + turdeltaX, turretRect.Y + turdeltaY, turretRect.W, turretRect.H);
|
||||
delete[] pTurImages[i];
|
||||
|
||||
if (pBarlImages[i]) {
|
||||
pKey.Format("%sX%d", ID, (15 - i) % 8);
|
||||
|
@ -1730,15 +1641,15 @@ void CLoading::LoadBuilding(const CString& ID)
|
|||
pKey.Format("%sY%d", ID, (15 - i) % 8);
|
||||
int barldeltaY = g_data.GetInteger("BuildingVoxelBarrelsRA2", pKey);
|
||||
|
||||
VXL_Add(pBarlImages[i], barlRect[2] + barldeltaX, barlRect[3] + barldeltaY, barlRect[0], barlRect[1]);
|
||||
VXL_Add(pBarlImages[i], barlRect.X + barldeltaX, barlRect.Y + barldeltaY, barlRect.W, barlRect.H);
|
||||
delete[] pBarlImages[i];
|
||||
}
|
||||
}
|
||||
|
||||
//int nW = 0x100, nH = 0x100;
|
||||
//VXL_GetAndClear(pTurImages[i], &nW, &nH);
|
||||
int nW = 0x100, nH = 0x100;
|
||||
VXL_GetAndClear(pTurImages[i], &nW, &nH);
|
||||
|
||||
//UnionSHP_Add(pTurImages[i], 0x100, 0x100, deltaX, deltaY);
|
||||
UnionSHP_Add(pTurImages[i], 0x100, 0x100, deltaX, deltaY);
|
||||
|
||||
unsigned char* pImage;
|
||||
int width1, height1;
|
||||
|
@ -1897,13 +1808,17 @@ void CLoading::LoadVehicleOrAircraft(const CString& ID)
|
|||
return;
|
||||
}
|
||||
|
||||
auto finder = [this](LPCTSTR lpFilename, char* pTheaterChar) {
|
||||
return this->FindFileInMix(lpFilename, reinterpret_cast<TheaterChar*>(pTheaterChar));
|
||||
};
|
||||
|
||||
// As VXL
|
||||
CString FileName = ImageID + ".vxl";
|
||||
CString HVAName = ImageID + ".hva";
|
||||
|
||||
//if (!DrawStuff::is_vpl_loaded()) {
|
||||
// DrawStuff::load_vpl("voxels.vpl");
|
||||
//}
|
||||
if (!VoxelDrawer::IsVPLLoaded()) {
|
||||
VoxelDrawer::LoadVPLFile("voxels.vpl", finder);
|
||||
}
|
||||
|
||||
CString PaletteName = art.GetStringOr(ArtID, "Palette", "unit");
|
||||
GetFullPaletteName(PaletteName, cur_theat);
|
||||
|
@ -1911,9 +1826,9 @@ void CLoading::LoadVehicleOrAircraft(const CString& ID)
|
|||
unsigned char* pImage[8]{ nullptr,nullptr ,nullptr ,nullptr ,nullptr ,nullptr ,nullptr ,nullptr };
|
||||
unsigned char* pTurretImage[8]{ nullptr ,nullptr ,nullptr ,nullptr ,nullptr ,nullptr ,nullptr ,nullptr };
|
||||
unsigned char* pBarrelImage[8]{ nullptr ,nullptr ,nullptr ,nullptr ,nullptr ,nullptr ,nullptr ,nullptr };
|
||||
DrawRect rect[8];
|
||||
DrawRect turretrect[8];
|
||||
DrawRect barrelrect[8];
|
||||
VoxelRectangle rect[8];
|
||||
VoxelRectangle turretrect[8];
|
||||
VoxelRectangle barrelrect[8];
|
||||
|
||||
int nMix = this->FindFileInMix(FileName);
|
||||
if (!nMix || !FSunPackLib::SetCurrentVXL(FileName, nMix)) {
|
||||
|
@ -1923,52 +1838,18 @@ void CLoading::LoadVehicleOrAircraft(const CString& ID)
|
|||
std::vector<BYTE> vxlColors[8];
|
||||
std::vector<BYTE> vxlLighting[8];
|
||||
|
||||
//if (!DrawStuff::load_vxl(FileName)) {
|
||||
// return;
|
||||
//}
|
||||
//if (!DrawStuff::load_hva(HVAName)) {
|
||||
// return;
|
||||
//}
|
||||
if (!VoxelDrawer::LoadVXLFile(FileName, finder)) {
|
||||
return;
|
||||
}
|
||||
if (!VoxelDrawer::LoadHVAFile(HVAName, finder)) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
// (i+6) % 8 to fix the facing
|
||||
//bool result = DrawStuff::get_to_image((i + 6) % 8, pImage[i],
|
||||
// rect[i][0], rect[i][1], rect[i][2], rect[i][3]);
|
||||
//if (!result) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
float r_x, r_y, r_z;
|
||||
const int dir = i;
|
||||
r_x = 300;
|
||||
r_y = 0;
|
||||
r_z = 45 * dir + 90;
|
||||
|
||||
// convert
|
||||
const double pi = 3.141592654;
|
||||
const Vec3f rotation(r_x / 180.0f * pi, r_y / 180.0f * pi, r_z / 180.0f * pi);
|
||||
RECT r;
|
||||
int center_x, center_y;
|
||||
if (!FSunPackLib::LoadVXLImage(
|
||||
*m_voxelNormalTables,
|
||||
lightDirection,
|
||||
rotation,
|
||||
Vec3f{},
|
||||
vxlColors[i],
|
||||
vxlLighting[i],
|
||||
¢er_x, ¢er_y,
|
||||
0, nullptr, nullptr, 0, 0, &r)) {
|
||||
break;
|
||||
bool result = VoxelDrawer::GetImageData((i + 6) % 8, pImage[i], rect[i]);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto const x = center_x;
|
||||
auto const y = center_y;
|
||||
auto const width = r.right - r.left;
|
||||
auto const height = r.bottom - r.top;
|
||||
|
||||
VXL_Add(vxlColors[i].data(), x, y, width, height);
|
||||
VXL_Add(vxlLighting[i].data(), x, y, width, height);
|
||||
VXL_GetAndClear(pImage[i], nullptr, nullptr);
|
||||
rect[i] = { x,y,width,height };
|
||||
}
|
||||
|
||||
if (!bHasTurret) {
|
||||
|
@ -1979,7 +1860,7 @@ void CLoading::LoadVehicleOrAircraft(const CString& ID)
|
|||
unsigned char* outBuffer;
|
||||
int outW = 0x100, outH = 0x100;
|
||||
|
||||
VXL_Add(pImage[i], rect[i].X, rect[i].Y, rect[i].Width, rect[i].Height);
|
||||
VXL_Add(pImage[i], rect[i].X, rect[i].Y, rect[i].W, rect[i].H);
|
||||
delete[] pImage[i];
|
||||
VXL_GetAndClear(outBuffer, &outW, &outH);
|
||||
|
||||
|
@ -2000,38 +1881,42 @@ void CLoading::LoadVehicleOrAircraft(const CString& ID)
|
|||
|
||||
CString turFileName = ImageID + "tur.vxl";
|
||||
CString turHVAName = ImageID + "tur.hva";
|
||||
//if (DrawStuff::load_vxl(turFileName)) {
|
||||
// return;
|
||||
//}
|
||||
//if (DrawStuff::load_hva(turHVAName)) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (VoxelDrawer::LoadVXLFile(turFileName, finder)) {
|
||||
return;
|
||||
}
|
||||
if (VoxelDrawer::LoadHVAFile(turHVAName, finder)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
// (i+6) % 8 to fix the facing
|
||||
//bool result = DrawStuff::get_to_image((i + 6) % 8, pTurretImage[i],
|
||||
// turretrect[i][0], turretrect[i][1], turretrect[i][2], turretrect[i][3], F, L, H);
|
||||
bool result = VoxelDrawer::GetImageData((i + 6) % 8, pTurretImage[i],
|
||||
turretrect[i], F, L, H);
|
||||
|
||||
//if (!result) {
|
||||
// break;
|
||||
//}
|
||||
if (!result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CString barlFileName = ImageID + "barl.vxl";
|
||||
CString barlHVAName = ImageID + "barl.hva";
|
||||
//if (!DrawStuff::load_vxl(barlFileName)) {
|
||||
// return;
|
||||
//}
|
||||
//if (!DrawStuff::load_hva(barlHVAName)) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (!VoxelDrawer::LoadVXLFile(barlFileName, finder)) {
|
||||
return;
|
||||
}
|
||||
if (!VoxelDrawer::LoadHVAFile(barlHVAName, finder)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
// (i+6) % 8 to fix the facing
|
||||
//bool result = DrawStuff::get_to_image((i + 6) % 8, pBarrelImage[i],
|
||||
// barrelrect[i][0], barrelrect[i][1], barrelrect[i][2], barrelrect[i][3], F, L, H);
|
||||
bool result = VoxelDrawer::GetImageData((i + 6) % 8, pBarrelImage[i],
|
||||
barrelrect[i], F, L, H);
|
||||
|
||||
//if (!result) {
|
||||
// break;
|
||||
//}
|
||||
if (!result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
|
@ -2042,7 +1927,7 @@ void CLoading::LoadVehicleOrAircraft(const CString& ID)
|
|||
int outW = 0x100, outH = 0x100;
|
||||
|
||||
if (pImage[i]) {
|
||||
VXL_Add(pImage[i], rect[i].X, rect[i].Y, rect[i].Width, rect[i].Height);
|
||||
VXL_Add(pImage[i], rect[i].X, rect[i].Y, rect[i].W, rect[i].H);
|
||||
delete[] pImage[i];
|
||||
}
|
||||
CString pKey;
|
||||
|
@ -2051,7 +1936,7 @@ void CLoading::LoadVehicleOrAircraft(const CString& ID)
|
|||
int turdeltaX = g_data.GetInteger("VehicleVoxelTurretsRA2", pKey);
|
||||
pKey.Format("%sY%d", ID.operator LPCSTR(), i);
|
||||
int turdeltaY = g_data.GetInteger("VehicleVoxelTurretsRA2", pKey);
|
||||
VXL_Add(pTurretImage[i], turretrect[i].X + turdeltaX, turretrect[i].Y + turdeltaY, turretrect[i].Width, turretrect[i].Height);
|
||||
VXL_Add(pTurretImage[i], turretrect[i].X + turdeltaX, turretrect[i].Y + turdeltaY, turretrect[i].W, turretrect[i].H);
|
||||
delete[] pTurretImage[i];
|
||||
|
||||
if (pBarrelImage[i]) {
|
||||
|
@ -2060,7 +1945,7 @@ void CLoading::LoadVehicleOrAircraft(const CString& ID)
|
|||
pKey.Format("%sY%d", ID.operator LPCSTR(), i);
|
||||
int barldeltaY = g_data.GetInteger("VehicleVoxelBarrelsRA2", pKey);
|
||||
|
||||
VXL_Add(pBarrelImage[i], barrelrect[i].X + barldeltaX, barrelrect[i].Y + barldeltaY, barrelrect[i].Width, barrelrect[i].Height);
|
||||
VXL_Add(pBarrelImage[i], barrelrect[i].X + barldeltaX, barrelrect[i].Y + barldeltaY, barrelrect[i].W, barrelrect[i].H);
|
||||
delete[] pBarrelImage[i];
|
||||
}
|
||||
}
|
||||
|
@ -2522,6 +2407,7 @@ BOOL CLoading::InitMixFiles()
|
|||
CLoading::~CLoading()
|
||||
{
|
||||
Unload();
|
||||
VoxelDrawer::Finalize();
|
||||
}
|
||||
|
||||
void CLoading::Unload()
|
||||
|
@ -3481,7 +3367,7 @@ void CLoading::LoadOverlayGraphic(const CString& lpOvrlName_, int iOvrlNum)
|
|||
|
||||
FSunPackLib::SetTSPaletteEntry(hPalette, 0x10 + i, &rgbNew, &rgbOld[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FSunPackLib::LoadSHPImage(0, maxPics, lpT);
|
||||
|
@ -3562,9 +3448,9 @@ void CLoading::LoadOverlayGraphic(const CString& lpOvrlName_, int iOvrlNum)
|
|||
|
||||
|
||||
delete[] lpT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 0xFF; i++) {
|
||||
|
@ -3575,7 +3461,7 @@ void CLoading::LoadOverlayGraphic(const CString& lpOvrlName_, int iOvrlNum)
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CLoading::OnDestroy()
|
||||
|
@ -4043,21 +3929,21 @@ void CLoading::FreeAll()
|
|||
#endif
|
||||
|
||||
i->second.pic = NULL;
|
||||
} catch (...) {
|
||||
CString err;
|
||||
err = "Access violation while trying to release surface ";
|
||||
char c[6];
|
||||
itoa(e, c, 10);
|
||||
err += c;
|
||||
} catch (...) {
|
||||
CString err;
|
||||
err = "Access violation while trying to release surface ";
|
||||
char c[6];
|
||||
itoa(e, c, 10);
|
||||
err += c;
|
||||
|
||||
err += "\n";
|
||||
OutputDebugString(err);
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
err += "\n";
|
||||
OutputDebugString(err);
|
||||
continue;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
|
@ -4077,7 +3963,7 @@ void CLoading::FreeAll()
|
|||
} catch (...) {
|
||||
errstream << "Exception while freeing DirectDraw" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLoading::PostNcDestroy()
|
||||
{
|
||||
|
@ -4346,7 +4232,7 @@ void CLoading::LoadStrings()
|
|||
//CCStrings[*rules.GetSectionName(i)].SetString=rul
|
||||
CCStrings[*rules.GetSectionName(i)].SetString((LPSTR)(LPCSTR)rules.GetSection(i)->values["Name"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='FinalAlertDebug YR|x64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>NOMINMAX;RA2_MODE;YR_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\MissionEditorPackLib</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\MissionEditorPackLib;..\3rdParty\CncVxlRender\inc</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>RA2_MODE;YR_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -589,6 +589,7 @@
|
|||
<ClCompile Include="UserScriptsDlg.cpp" />
|
||||
<ClCompile Include="variables.cpp" />
|
||||
<ClCompile Include="ViewObjects.cpp" />
|
||||
<ClCompile Include="VoxelDrawer.cpp" />
|
||||
<ClCompile Include="WaypointID.cpp" />
|
||||
<ClCompile Include="MapCode.cpp" />
|
||||
</ItemGroup>
|
||||
|
@ -691,6 +692,7 @@
|
|||
<ClInclude Include="variables.h" />
|
||||
<ClInclude Include="Vec2.h" />
|
||||
<ClInclude Include="ViewObjects.h" />
|
||||
<ClInclude Include="VoxelDrawer.h" />
|
||||
<ClInclude Include="WaypointID.h" />
|
||||
<ClInclude Include="MapCode.h" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -288,6 +288,9 @@
|
|||
<ClCompile Include="Palettes.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VoxelDrawer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="MissionEditor.rc">
|
||||
|
@ -586,6 +589,9 @@
|
|||
<ClInclude Include="Palettes.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VoxelDrawer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\clifftoo.bmp">
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<Link>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>$(XccVcpkgDir)\lib</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>$(VxlLibDir);$(XccVcpkgDir)\lib</AdditionalLibraryDirectories>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<StackReserveSize>11194304</StackReserveSize>
|
||||
<StackCommitSize>11194304</StackCommitSize>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<PropertyGroup>
|
||||
<XccVcpkgDirTriplet>$(XccDir)\vcpkg_installed\$(Platform)-windows\$(Platform)-windows</XccVcpkgDirTriplet>
|
||||
<XccVcpkgDir>$(XccVcpkgDirTriplet)\debug</XccVcpkgDir>
|
||||
<VxlLibDir>$(SolutionDir)$(Platform)\Debug</VxlLibDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
|
@ -25,7 +26,7 @@
|
|||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ddraw.lib;dxguid.lib;winmm.lib;gdiplus.lib;lzo2.lib;bz2d.lib;zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>CncVxlRenderText.lib;ddraw.lib;dxguid.lib;winmm.lib;gdiplus.lib;lzo2.lib;bz2d.lib;zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<XccVcpkgBin Include="$(XccVcpkgDir)\bin\bz2*.dll" />
|
||||
<XccVcpkgBin Include="$(XccVcpkgDir)\bin\lzo2.dll" />
|
||||
<XccVcpkgBin Include="$(XccVcpkgDir)\bin\zlib*1.dll" />
|
||||
<VxlLibBin Include="$(VxlLibDir)\*.dll" />
|
||||
<InstallData Include="$(MSBuildThisFileDirectory)\..\data\shared\**\*" />
|
||||
<InstallData Include="$(MSBuildThisFileDirectory)\..\..\LICENSE.md" />
|
||||
<LicDir Include="$(XccDir)\COPYING" DestDir="xcc" />
|
||||
|
@ -29,6 +30,9 @@
|
|||
<Target Name="CopyDllFiles" AfterTargets="Build" BeforeTargets="BuildAndZipDistribution">
|
||||
<Copy SourceFiles="@(XccVcpkgBin)" DestinationFolder="$(OutDir)" />
|
||||
</Target>
|
||||
<Target Name="CopyDllFiles" AfterTargets="Build" BeforeTargets="BuildAndZipDistribution">
|
||||
<Copy SourceFiles="@(VxlLibBin)" DestinationFolder="$(OutDir)" />
|
||||
</Target>
|
||||
<Target Name="CopyDataFiles" AfterTargets="Build" BeforeTargets="BuildAndZipDistribution">
|
||||
<Copy SourceFiles="@(InstallData)" DestinationFolder="$(OutDir)\%(RecursiveDir)" />
|
||||
</Target>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<PropertyGroup>
|
||||
<XccVcpkgDirTriplet>$(XccDir)\vcpkg_installed\$(Platform)-windows\$(Platform)-windows</XccVcpkgDirTriplet>
|
||||
<XccVcpkgDir>$(XccVcpkgDirTriplet)</XccVcpkgDir>
|
||||
<VxlLibDir>$(SolutionDir)$(Platform)\Release</VxlLibDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
|
@ -25,7 +26,7 @@
|
|||
<PreprocessorDefinitions>NDEBUG;_AFXDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ddraw.lib;dxguid.lib;winmm.lib;gdiplus.lib;lzo2.lib;bz2.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>CncVxlRenderText.lib;ddraw.lib;dxguid.lib;winmm.lib;gdiplus.lib;lzo2.lib;bz2.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>libcmt.lib; libcmtd.lib; msvcrtd.lib</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
|
83
MissionEditor/VoxelDrawer.cpp
Normal file
83
MissionEditor/VoxelDrawer.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include "stdafx.h"
|
||||
#include "VoxelDrawer.h"
|
||||
#include <vxlapi.h>
|
||||
#include "variables.h"
|
||||
#include "MissionEditorPackLib.h"
|
||||
|
||||
CString makeFullPath(const CString& name)
|
||||
{
|
||||
return TSPath + name;
|
||||
}
|
||||
|
||||
std::pair<MemoryBuffer, bool> readFile(const CString& name, HMIXFILE hMix)
|
||||
{
|
||||
if (hMix == NULL) {
|
||||
return FSunPackLib::LoadCCFile(makeFullPath(name), NULL);
|
||||
}
|
||||
return FSunPackLib::LoadCCFile(name, hMix);
|
||||
}
|
||||
|
||||
void VoxelDrawer::Initalize()
|
||||
{
|
||||
CncImgCreate();
|
||||
CncImgSetMaxFacing(32);
|
||||
}
|
||||
|
||||
void VoxelDrawer::Finalize()
|
||||
{
|
||||
CncImgRelease();
|
||||
}
|
||||
|
||||
bool VoxelDrawer::LoadVPLFile(const CString& name, const FindFileInMixHandler& mixFindler)
|
||||
{
|
||||
bool result = false;
|
||||
auto const&& ret = readFile(name, mixFindler(name, nullptr));
|
||||
if (ret.second) {
|
||||
result = CncImgLoadVPLFile(reinterpret_cast<const BYTE*>(ret.first.data()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool VoxelDrawer::LoadVXLFile(const CString& name, const FindFileInMixHandler& mixFindler)
|
||||
{
|
||||
bool result = false;
|
||||
auto const&& ret = readFile(name, mixFindler(name, nullptr));
|
||||
if (ret.second) {
|
||||
if (CncImgIsVXLLoaded()) {
|
||||
CncImgClearCurrentVXL();
|
||||
}
|
||||
result = CncImgLoadVXLFile(reinterpret_cast<const BYTE*>(ret.first.data()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool VoxelDrawer::LoadHVAFile(const CString& name, const FindFileInMixHandler& mixFindler)
|
||||
{
|
||||
bool result = false;
|
||||
auto const&& ret = readFile(name, mixFindler(name, nullptr));
|
||||
if (ret.second) {
|
||||
result = CncImgLoadHVAFile(reinterpret_cast<const BYTE*>(ret.first.data()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool VoxelDrawer::GetImageData(unsigned int nFacing, unsigned char*& pBuffer, int& width,
|
||||
int& height, int& x, int& y, const int F, const int L, const int H)
|
||||
{
|
||||
const unsigned int nIndex = nFacing * 4;
|
||||
CncImgPrepareVXLCache(nIndex, F, L, H);
|
||||
CncImgGetImageFrame(nIndex, &width, &height, &x, &y);
|
||||
if (width < 0 || height < 0)
|
||||
return false;
|
||||
return CncImgGetImageData(nIndex, &pBuffer);
|
||||
}
|
||||
|
||||
bool VoxelDrawer::GetImageData(unsigned int nFacing, unsigned char*& pBuffer, VoxelRectangle& rect, const int F, const int L, const int H)
|
||||
{
|
||||
return GetImageData(nFacing, pBuffer, rect.W, rect.H, rect.X, rect.Y, F, L, H);
|
||||
}
|
||||
|
||||
bool VoxelDrawer::IsVPLLoaded()
|
||||
{
|
||||
return CncImgIsVPLLoaded();
|
||||
}
|
27
MissionEditor/VoxelDrawer.h
Normal file
27
MissionEditor/VoxelDrawer.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <afxcview.h>
|
||||
#include <functional>
|
||||
|
||||
using HMIXFILE = DWORD;
|
||||
using FindFileInMixHandler = std::function<HMIXFILE(LPCTSTR lpFilename, char* pTheaterChar)>;
|
||||
|
||||
struct VoxelRectangle
|
||||
{
|
||||
int X, Y, W, H;
|
||||
};
|
||||
|
||||
class VoxelDrawer
|
||||
{
|
||||
public:
|
||||
static void Initalize();
|
||||
static void Finalize();
|
||||
static bool LoadVPLFile(const CString& name, const FindFileInMixHandler& mixFindler);
|
||||
static bool LoadVXLFile(const CString& name, const FindFileInMixHandler& mixFindler);
|
||||
static bool LoadHVAFile(const CString& name, const FindFileInMixHandler& mixFindler);
|
||||
static bool GetImageData(unsigned int nFacing, unsigned char*& pBuffer,
|
||||
int& width, int& height, int& x, int& y, const int F = 0, const int L = 0, const int H = 0);
|
||||
static bool GetImageData(unsigned int nFacing, unsigned char*& pBuffer,
|
||||
VoxelRectangle& rect, const int F = 0, const int L = 0, const int H = 0);
|
||||
static bool IsVPLLoaded();
|
||||
};
|
|
@ -349,6 +349,35 @@ namespace FSunPackLib
|
|||
return pDDS->SetColorKey(DDCKEY_SRCBLT, &color_key);
|
||||
}
|
||||
|
||||
std::pair<MemoryBuffer, bool> LoadCCFile(LPCTSTR filepath, HMIXFILE hMix)
|
||||
{
|
||||
MemoryBuffer buffer;
|
||||
Ccc_file file(true);
|
||||
|
||||
if (hMix != NULL) {
|
||||
if (file.open(filepath, mixfiles[hMix - 1])) {
|
||||
return {};
|
||||
}
|
||||
} else {
|
||||
if (file.open(filepath)) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
auto const size = file.get_size();
|
||||
|
||||
if (size < 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
buffer.resize(size);
|
||||
|
||||
if (file.read(buffer.data(), size)) {
|
||||
return {};
|
||||
}
|
||||
return { std::move(buffer), true };
|
||||
}
|
||||
|
||||
BOOL XCC_Initialize(BOOL bLoadFromRegistry)
|
||||
{
|
||||
if (bLoadFromRegistry)
|
||||
|
|
|
@ -45,6 +45,8 @@ class VoxelNormalTables;
|
|||
typedef DWORD HMIXFILE;
|
||||
typedef DWORD HTSPALETTE;
|
||||
|
||||
using MemoryBuffer = std::vector<char>;
|
||||
|
||||
struct SHPHEADER
|
||||
{
|
||||
__int16 zero;// type
|
||||
|
@ -249,6 +251,7 @@ namespace FSunPackLib
|
|||
|
||||
HRESULT SetColorKey(IDirectDrawSurface4* pDDS, COLORREF rgb);
|
||||
|
||||
std::pair<MemoryBuffer, bool> LoadCCFile(LPCTSTR name, HMIXFILE hMix);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue