World positional and directional transformations based on game data.

This commit is contained in:
jaynus 2015-05-13 23:24:46 -07:00
parent 4a41f8b9e2
commit 8ee499b7bc
5 changed files with 76 additions and 8 deletions

View File

@ -2,4 +2,6 @@
init:
debug_render:
register_vehicle:\A3\Armor_F_EPB\MBT_03\MBT_03_cannon_F.p3d, 1, 4046.21;3902.56;5.075
#set_animation_state:1,damageHide, 0, Wheel_kolL1, 0, Wheel_koloL1, 0, Wheel_podkoloL1, 1, Wheel_kolP1, 0, Wheel_koloP1, 0, Wheel_podkoloP1, 1, Wheel_kolL2, 0, Wheel_kolP2, 0, Wheel_koloL2, 0, Wheel_koloL3, 0, Wheel_koloL4, 0, Wheel_koloL5, 0, Wheel_koloL6, 0, Wheel_koloL7, 0, Wheel_koloP2, 0, Wheel_koloP3, 0, Wheel_koloP4, 0, Wheel_koloP5, 0, Wheel_koloP6, 0, Wheel_koloP7, 0, Wheel_podkoloL2, 1, Wheel_podkoloL3, 1, Wheel_podkoloL4, 1, Wheel_podkoloL5, 0, Wheel_podkoloL6, 0, Wheel_podkoloP2, 1, Wheel_podkoloP3, 1, Wheel_podkoloP4, 1, Wheel_podkoloP5, 0, Wheel_podkoloP6, 1, podkoloL1_hide_damage, 0, podkoloL2_hide_damage, 0, podkoloL3_hide_damage, 0, podkoloL4_hide_damage, 0, podkoloL5_hide_damage, 0, podkoloL6_hide_damage, 0, podkoloL7_hide_damage, 0, podkoloL8_hide_damage, 0, podkoloP1_hide_damage, 0, podkoloP2_hide_damage, 0, podkoloP3_hide_damage, 0, podkoloP4_hide_damage, 0, podkoloP5_hide_damage, 0, podkoloP6_hide_damage, 0, podkoloP7_hide_damage, 0, podkoloP8_hide_damage, 0, damageVez, 0, MainTurret, -3, MainGun, 0, Recoil, 0, ObsTurret, -0, ObsGun, 0, MainGunOptics, 0, Wheel_podkoloP7, 0, Wheel_podkoloL7, 0, HatchDriver, 0, HatchCommander, 0, HatchGunner, 0, damageVezVelitele, 0, poklop_commander_damage, 0, poklop_gunner_damage, 0, poklop_driver_damage, 0, zaslehROT_HMG, 101, zaslehROT_coax, 16, cannon_muzzle_flash, 0, zaslehROT_cannon, 956, HideHull, 1, HideTurret, 1, LockMuzzle, 0
#set_animation_state:1,damageHide, 0, Wheel_kolL1, 0, Wheel_koloL1, 0, Wheel_podkoloL1, 1, Wheel_kolP1, 0, Wheel_koloP1, 0, Wheel_podkoloP1, 1, Wheel_kolL2, 0, Wheel_kolP2, 0, Wheel_koloL2, 0, Wheel_koloL3, 0, Wheel_koloL4, 0, Wheel_koloL5, 0, Wheel_koloL6, 0, Wheel_koloL7, 0, Wheel_koloP2, 0, Wheel_koloP3, 0, Wheel_koloP4, 0, Wheel_koloP5, 0, Wheel_koloP6, 0, Wheel_koloP7, 0, Wheel_podkoloL2, 1, Wheel_podkoloL3, 1, Wheel_podkoloL4, 1, Wheel_podkoloL5, 0, Wheel_podkoloL6, 0, Wheel_podkoloP2, 1, Wheel_podkoloP3, 1, Wheel_podkoloP4, 1, Wheel_podkoloP5, 0, Wheel_podkoloP6, 1, podkoloL1_hide_damage, 0, podkoloL2_hide_damage, 0, podkoloL3_hide_damage, 0, podkoloL4_hide_damage, 0, podkoloL5_hide_damage, 0, podkoloL6_hide_damage, 0, podkoloL7_hide_damage, 0, podkoloL8_hide_damage, 0, podkoloP1_hide_damage, 0, podkoloP2_hide_damage, 0, podkoloP3_hide_damage, 0, podkoloP4_hide_damage, 0, podkoloP5_hide_damage, 0, podkoloP6_hide_damage, 0, podkoloP7_hide_damage, 0, podkoloP8_hide_damage, 0, damageVez, 0, MainTurret, -3, MainGun, 0, Recoil, 0, ObsTurret, -0, ObsGun, 0, MainGunOptics, 0, Wheel_podkoloP7, 0, Wheel_podkoloL7, 0, HatchDriver, 0, HatchCommander, 0, HatchGunner, 0, damageVezVelitele, 0, poklop_commander_damage, 0, poklop_gunner_damage, 0, poklop_driver_damage, 0, zaslehROT_HMG, 101, zaslehROT_coax, 16, cannon_muzzle_flash, 0, zaslehROT_cannon, 956, HideHull, 1, HideTurret, 1, LockMuzzle, 0
#hit:1,1,2,3,4,5,6,7,8,9,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,11,1,1,1,1,1,1
set_vehicle_state:1,0;-20;0,0;0;0,0;0;0

View File

@ -21,7 +21,7 @@ namespace ace {
}
if (fire_lod == -1) // @TODO: fallback on geo LOD
fire_lod = 0;
fire_lod = 0;
//fire_lod = 0;
assert(fire_lod != -1);
// Build the mesh from object faces
@ -45,9 +45,11 @@ namespace ace {
// @TODO: This is moving it in the bullet world for handling multiple collisions, instead our raytests need to ignore ALL but this type. How do we do that?
// For now this only works for single-object collisions then
//btTransform transform = bt_object->getWorldTransform();
//transform.setOrigin(btVector3(position_.x(), position_.y(), position_.z()));
//bt_object->setWorldTransform(transform);
// Set 3d world bullet position based on game position
btTransform transform = bt_object->getWorldTransform();
transform.setOrigin(btVector3(position_.x(), position_.y(), position_.z()));
bt_object->setWorldTransform(transform);
controller::get().bt_world->addCollisionObject(bt_object.get());
}

View File

@ -52,6 +52,7 @@ namespace ace {
#if defined(DEVEL) && defined(USE_DIRECTX)
_debug_display = std::make_unique<ace::vehicledamage::debug::penetration_display>();
bt_world->setDebugDrawer(dynamic_cast<btIDebugDraw *>(_debug_display.get()));
#endif
_ready = true;
@ -188,7 +189,7 @@ namespace ace {
vehicles[_args[0]]->direction = _args[1];
vehicles[_args[0]]->up = _args[2];
//vehicles[_args[0]]->transform();
vehicles[_args[0]]->transform();
return true;
}

View File

@ -20,6 +20,20 @@ namespace ace {
_active_hits.push_back(gamehit::create(args));
auto _vehicle = controller::get().vehicles.find(args[0]);
if (_vehicle == controller::get().vehicles.end())
return false;
btVector3 vectorFrom(5, 20, 0);
btVector3 vectorTo = _vehicle->second->bt_object->getWorldTransform().getOrigin();
btVector3 direction = vectorTo - vectorFrom;
XMVECTORF32 eyePos = { vectorFrom.x(), vectorFrom.y(), vectorFrom.z() };
XMVECTORF32 eyeDir = { direction.x(), direction.y(), direction.z() };
XMVECTORF32 up = { 0.f, 1.f, 0.f };
XMStoreFloat4x4(&_View, XMMatrixLookAtLH(eyePos, eyeDir, up));
return true;
}
bool penetration_display::register_vehicle(const arguments &args, std::string &result) {
@ -58,6 +72,7 @@ namespace ace {
if (FAILED(hr))
return hr;
}
_BatchEffect->SetView(XMLoadFloat4x4(&_View));
_BatchEffect->SetProjection(XMLoadFloat4x4(&_Projection));
@ -73,6 +88,7 @@ namespace ace {
bool penetration_display::step(void) {
_BatchEffect->Apply(_pImmediateContext);
_pImmediateContext->IASetInputLayout(_pBatchInputLayout);
const XMVECTORF32 xaxis = { 20.f, 0.f, 0.f };
@ -95,6 +111,14 @@ namespace ace {
_Batch->End();
// Draw the bullet world
// The BT debug drawing is a single batch
_Batch->Begin();
ace::vehicledamage::controller::get().bt_world->debugDrawWorld();
_Batch->End();
if (_active_vehicle) {
DrawObject(_active_vehicle->fire_lod, *_Batch, *_active_vehicle->object, Colors::Gray);
}
@ -246,6 +270,35 @@ namespace ace {
batch.End();
}
// Bullet debug functions
void penetration_display::drawLine(const btVector3& from, const btVector3& to, const btVector3& color) {
XMVECTORF32 v1 = { from.x(), from.y(), from.z() };
XMVECTORF32 v2 = { to.x(), to.y(), to.z() };
_Batch->DrawLine(VertexPositionColor(v1, Colors::LightCoral), VertexPositionColor(v2, Colors::LightCoral));
}
void penetration_display::drawContactPoint(const btVector3 &PointOnB, const btVector3 &normalOnB, btScalar distance, int lifeTime, const btVector3 &color) {
}
void penetration_display::reportErrorWarning(const char *warningString) {
LOG(WARNING) << "btWarning - {" << warningString << "}";
}
void penetration_display::draw3dText(const btVector3 &location, const char *textString) {
}
void penetration_display::setDebugMode(int debugMode) {
_bt_debug_mode = debugMode;
}
int penetration_display::getDebugMode() const {
return _bt_debug_mode;
}
}
}
}

View File

@ -20,6 +20,8 @@
#include "simulation/object.hpp"
#include "vehicle.hpp"
#include "LinearMath/btIDebugDraw.h"
#include "game.hpp"
using namespace ace::debug;
@ -29,7 +31,7 @@ namespace ace {
namespace vehicledamage {
namespace debug {
__declspec(align(16))
class penetration_display : public d3d_display, public dispatcher {
class penetration_display : public d3d_display, public dispatcher, public btIDebugDraw {
public:
penetration_display();
@ -37,6 +39,14 @@ namespace ace {
bool register_vehicle(const arguments &, std::string &);
bool show_hit(const arguments &, std::string &);
// bullet debug
virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& color);
virtual void drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color);
virtual void reportErrorWarning(const char* warningString);
virtual void draw3dText(const btVector3& location, const char* textString);
virtual void setDebugMode(int debugMode);
virtual int getDebugMode() const;
int _bt_debug_mode;
// End
bool init() override;
@ -54,7 +64,7 @@ namespace ace {
vehicle_p _active_vehicle;
std::vector<gamehit_p> _active_hits;
void DrawHits(uint32_t lod, PrimitiveBatch<VertexPositionColor>& batch, GXMVECTOR color);
void DrawCollisions(const std::vector<ace::vector3<float>> & collisions, PrimitiveBatch<VertexPositionColor>& batch, GXMVECTOR color);
void DrawObject(uint32_t lod, PrimitiveBatch<VertexPositionColor>& batch, ace::simulation::object & obj, GXMVECTOR color);