完成武器子弹出生点

This commit is contained in:
aozhiwei 2022-09-11 10:07:50 +08:00
parent ab509ec6e9
commit 55147805ae
3 changed files with 46 additions and 0 deletions

View File

@ -13,6 +13,17 @@
#include "trigger.h"
#include "car.h"
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/vec2.hpp>
static const auto hero_transform =
glm::rotate(
glm::mat4(1.0),
glm::radians(65.0f),
glm::vec3(0.0, 0.0, 1.0)
);
struct BulletInfo
{
CreatureWeakPtr c;
@ -200,6 +211,37 @@ void InternalShot(Creature* c,
}
}
bullet_dir.Rotate(bullet_angle / 180.0f);
#if 1
{
auto transform = glm::rotate(hero_transform,
bullet_born_angle * A8_PI,
glm::vec3(0.0, 1.0, 0.0));
glm::vec4 gun_muzzle_position(0.0, 0.0, 0.0, 0.0);
if (weapon_meta->gun_muzzle_position) {
gun_muzzle_position =
glm::vec4(
std::get<0>(*weapon_meta->gun_muzzle_position.get()),
std::get<1>(*weapon_meta->gun_muzzle_position.get()),
std::get<2>(*weapon_meta->gun_muzzle_position.get()),
0
);
}
glm::vec4 v = transform * gun_muzzle_position;
bullet_born_offset = a8::Vec2(v.x *10*1, v.z*10*1);
bullet_born_pos = c->GetPos() + bullet_born_offset;
if (c->IsPlayer()) {
a8::XPrintf("offset:%f,%f angle:%f angle_xy:%f,%f %f %f\n",
{bullet_born_offset.x,
bullet_born_offset.y,
bullet_born_angle,
c->GetAttackDir().x,
c->GetAttackDir().y,
(bullet_born_angle * A8_PI) / 3.14 *180,
(bullet_born_angle * A8_PI - glm::radians(90.0f)) / 3.14 *180
});
}
}
#endif
{
BulletInfo bullet_info;
bullet_info.c = c->GetWeakPtrRef();

View File

@ -99,6 +99,7 @@ namespace MetaData
//0,0,0,0,后座力
std::vector<std::tuple<float, float, float, int, int>> bullet_born_offset;
std::vector<std::tuple<int, a8::Vec2>> shoot_offsets;
std::shared_ptr<std::tuple<float, float, float>> gun_muzzle_position;
std::array<int, IS_END> volume = {};
int int_param1 = 0;
float float_param1 = 0;

View File

@ -462,6 +462,9 @@ Human* Room::FindEnemy(Human* hum)
void Room::FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg)
{
msg.set_team_mode(msg.team_mode());
#if 0
msg.set_adjust_bullet(1);
#endif
}
void Room::ScatterDrop(a8::Vec2 center, int drop_id)