From 62e441fb1d095fbaf8b1399cd902af44315c2599 Mon Sep 17 00:00:00 2001 From: jaynus Date: Sun, 10 May 2015 18:18:40 -0700 Subject: [PATCH] Animation parsing was completely broken. It was all incorrect. A3 is not variable length animations. --- extensions/common/p3d/animation.cpp | 13 ++-- extensions/tests/longrod_dxtk_test.txt | 4 +- extensions/tests/pbo_parser.cpp | 69 +++++++++++++++++++++ extensions/tests/pbo_search.cpp | 35 ++--------- extensions/vd/controller.cpp | 4 +- extensions/vd/debug/penetration_display.cpp | 8 +++ 6 files changed, 93 insertions(+), 40 deletions(-) create mode 100644 extensions/tests/pbo_parser.cpp diff --git a/extensions/common/p3d/animation.cpp b/extensions/common/p3d/animation.cpp index 54c30687d3..9d135053e1 100644 --- a/extensions/common/p3d/animation.cpp +++ b/extensions/common/p3d/animation.cpp @@ -20,15 +20,16 @@ namespace ace { stream_.read((char *)&min_phase, sizeof(float)); stream_.read((char *)&max_phase, sizeof(float)); - - - - - stream_.read((char *)&junk, sizeof(uint32_t)); - stream_.read((char *)&junk2, sizeof(uint32_t)); + //stream_.read((char *)&junk, sizeof(uint32_t)); + //stream_.read((char *)&junk2, sizeof(uint32_t)); stream_.read((char *)&source_address, sizeof(uint32_t)); + float buffer[4]; + stream_.read((char *)buffer, sizeof(float) * 4); + return; + // THIS IS ALL WRONG + // ARMA3 HAS FIXED 4-FLOAT TRANSFORMS switch (type) { // rotations diff --git a/extensions/tests/longrod_dxtk_test.txt b/extensions/tests/longrod_dxtk_test.txt index 0e9cde8fc9..92f95a7d4a 100644 --- a/extensions/tests/longrod_dxtk_test.txt +++ b/extensions/tests/longrod_dxtk_test.txt @@ -1,6 +1,6 @@ init: -#debug_render: -#register_vehicle:\A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d,2,4050.18;3802.55;5.075 +debug_render: +register_vehicle:\A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d,2,4050.18;3802.55;5.075 #hit:2,\A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d,[],2,Sh_120mm_APFSDS,650,27,19100,50,10,708.602;235.609;-85.6468,-2.1748;0.139648;-1.35955,0.942743;0.31346;-0.113925,-1;6.1914e-007;0.000794772,-2.17383;0.139404;-1.32366,708.602;235.609;-85.6468 #register_vehicle:\a3\structures_f\mil\BagFence\BagFence_Long_F.p3d,0,4050.18;3802.55;5.075 #hit:0,A3\Structures_F\Mil\BagFence\BagFence_Long_F.p3d,[],0,B_65x39_Caseless,1295,264,11300,0,0,-16.5091;729.003;-177.406,0.2854;-0.239258;0.0619297,-0.0219989;0.971421;-0.236342,0.00232643;-0.999479;0.0321913 \ No newline at end of file diff --git a/extensions/tests/pbo_parser.cpp b/extensions/tests/pbo_parser.cpp new file mode 100644 index 0000000000..cdbc42c2d0 --- /dev/null +++ b/extensions/tests/pbo_parser.cpp @@ -0,0 +1,69 @@ +#include "shared.hpp" +#include "pbo\archive.hpp" +#include "membuf.hpp" +#include "logging.hpp" +#include "p3d\model.hpp" + +INITIALIZE_EASYLOGGINGPP + + +int main(int argc, char **argv) { + //ace::p3d::parser _parser; + + el::Configurations log_conf; + log_conf.setGlobally(el::ConfigurationType::Filename, "logs/pbo_parser.log"); + +#ifdef _DEBUG + el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Format, "[%datetime] - %level - {%loc}t:%thread- %msg"); + //%d%M%Y-%H:%m:%s.%g +#else + el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Format, "%datetime-{%level}- %msg"); +#endif + std::fstream filestream; + ace::pbo::archive_p _archive = nullptr; + + if (argc < 2) { + LOG(ERROR) << "No pbo name provided"; + return -1; + } + + filestream.open(argv[1], std::ios::binary | std::ios::in); + if (!filestream.good()) { + LOG(ERROR) << "Cannot open file"; + return -1; + } + + _archive = std::make_shared(filestream); + + LOG(INFO) << "Archive opened: " << argv[1]; + LOG(INFO) << "\t" << _archive->info->name << "=" << _archive->info->data; + LOG(INFO) << "Entries: " << _archive->entries.size(); + + for (ace::pbo::entry_p & entry : _archive->entries) { + LOG(INFO) << "\t" << entry->filename; + LOG(INFO) << "\t\t" << "Size=" << entry->size << ", StorageSize=" << entry->storage_size << ", offset=" << entry->offset + _archive->begin_data_offset; + if (entry->filename == argv[2]) { + ace::pbo::file_p test_file = std::make_shared(); + bool result = _archive->get_file(filestream, entry, test_file); + + if (result) { + LOG(INFO) << "File Read"; + LOG(INFO) << "--------------------------------"; + ace::membuf _memory_buffer((char *)test_file->data, test_file->size); + std::istream _data_stream(&_memory_buffer); + + ace::p3d::model_p _model = std::make_shared(_data_stream); + LOG(INFO) << "--------------------------------"; + } else { + LOG(ERROR) << "READ OF TEST FILE FAILED!!!!"; + } + } + } + + + + + getchar(); + + return 0; +} \ No newline at end of file diff --git a/extensions/tests/pbo_search.cpp b/extensions/tests/pbo_search.cpp index 015ace1fe9..dd418924d4 100644 --- a/extensions/tests/pbo_search.cpp +++ b/extensions/tests/pbo_search.cpp @@ -1,8 +1,7 @@ #include "shared.hpp" -#include "pbo\archive.hpp" #include "membuf.hpp" #include "logging.hpp" -#include "p3d\model.hpp" +#include "pbo/search.hpp" INITIALIZE_EASYLOGGINGPP @@ -11,7 +10,7 @@ int main(int argc, char **argv) { //ace::p3d::parser _parser; el::Configurations log_conf; - log_conf.setGlobally(el::ConfigurationType::Filename, "logs/server.log"); + log_conf.setGlobally(el::ConfigurationType::Filename, "logs/pbo_search.log"); #ifdef _DEBUG el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Format, "[%datetime] - %level - {%loc}t:%thread- %msg"); @@ -33,36 +32,12 @@ int main(int argc, char **argv) { return -1; } - _archive = std::make_shared(filestream); - - LOG(INFO) << "Archive opened: " << argv[1]; - LOG(INFO) << "\t" << _archive->info->name << "=" << _archive->info->data; - LOG(INFO) << "Entries: " << _archive->entries.size(); + ace::pbo::search _pbo_searcher(".*\.p3d"); - for (ace::pbo::entry_p & entry : _archive->entries) { - LOG(INFO) << "\t" << entry->filename; - LOG(INFO) << "\t\t" << "Size=" << entry->size << ", StorageSize=" << entry->storage_size << ", offset=" << entry->offset + _archive->begin_data_offset; - if (entry->filename == argv[2]) { - ace::pbo::file_p test_file = std::make_shared(); - bool result = _archive->get_file(filestream, entry, test_file); - - if (result) { - LOG(INFO) << "File Read"; - LOG(INFO) << "--------------------------------"; - ace::membuf _memory_buffer((char *)test_file->data, test_file->size); - std::istream _data_stream(&_memory_buffer); - - ace::p3d::model_p _model = std::make_shared(_data_stream); - LOG(INFO) << "--------------------------------"; - } else { - LOG(ERROR) << "READ OF TEST FILE FAILED!!!!"; - } - } + for (auto & kv : _pbo_searcher.file_index()) { + LOG(INFO) << "Index: " << kv.first << " : " << kv.second; } - - - getchar(); return 0; diff --git a/extensions/vd/controller.cpp b/extensions/vd/controller.cpp index 1dfb0ad155..549ca44f14 100644 --- a/extensions/vd/controller.cpp +++ b/extensions/vd/controller.cpp @@ -73,8 +73,8 @@ namespace ace { bool controller::reset(const arguments &_args, std::string & result) { vehicles.clear(); - if (!ace::model_collection::get().ready()) { - ace::model_collection::get().init(); + if (!ace::model_collection::get().ready()) { + ace::model_collection::get().init(); } return true; diff --git a/extensions/vd/debug/penetration_display.cpp b/extensions/vd/debug/penetration_display.cpp index e7e644853c..ee990ccbde 100644 --- a/extensions/vd/debug/penetration_display.cpp +++ b/extensions/vd/debug/penetration_display.cpp @@ -60,6 +60,14 @@ namespace ace { } _BatchEffect->SetView(XMLoadFloat4x4(&_View)); _BatchEffect->SetProjection(XMLoadFloat4x4(&_Projection)); + + CommonStates states(_pd3dDevice); + _pImmediateContext->OMSetBlendState(states.Opaque(), nullptr, 0xFFFFFFFF); + _pImmediateContext->OMSetDepthStencilState(states.DepthNone(), 0); + _pImmediateContext->RSSetState(states.CullCounterClockwise()); + + _BatchEffect->Apply(_pImmediateContext); + _pImmediateContext->IASetInputLayout(_pBatchInputLayout); } bool penetration_display::step(void) {