mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-14 17:33:25 +00:00
Fix object angles.
This commit is contained in:
parent
5f7c59e2eb
commit
ce1ba32d58
3 changed files with 55 additions and 15 deletions
|
|
@ -120,6 +120,30 @@ void write_mmo(Storage *storage, const mmo_storage &s)
|
|||
|
||||
auto this_map = storage->maps[map_id];
|
||||
|
||||
auto check_val = [](auto &v)
|
||||
{
|
||||
if (v > 1)
|
||||
{
|
||||
v = v - floor(v);
|
||||
std::cerr << /*object->name2 << */": yaw > 1\n";
|
||||
}
|
||||
if (v < -1)
|
||||
{
|
||||
v = v - ceil(v);
|
||||
std::cerr << /*object->name2 << */": yaw < -1\n";
|
||||
}
|
||||
};
|
||||
|
||||
auto calc_yaw = [&check_val](auto &v)
|
||||
{
|
||||
//check_val(v[0].x);
|
||||
//check_val(v[1].x);
|
||||
|
||||
auto yaw = atan2(v[1].x, v[0].x);
|
||||
yaw = RAD2GRAD(yaw);
|
||||
return -(yaw - 90);
|
||||
};
|
||||
|
||||
int inserted = 0;
|
||||
int exist = 0;
|
||||
for (auto &seg : s.objects.segments)
|
||||
|
|
@ -160,13 +184,28 @@ void write_mmo(Storage *storage, const mmo_storage &s)
|
|||
mb.z = ASSIGN(object->position.z, 0);
|
||||
mb.roll = 0;
|
||||
mb.pitch = 0;
|
||||
auto yaw = ASSIGN(object->m_rotate_z[0].x, 0);
|
||||
/*auto yaw = ASSIGN(object->m_rotate_z[0].x, 0);
|
||||
if (yaw > 1)
|
||||
{
|
||||
yaw = yaw - floor(yaw);
|
||||
std::cerr << object->name2 << ": yaw > 1\n";
|
||||
}
|
||||
if (yaw < -1)
|
||||
{
|
||||
yaw = yaw - ceil(yaw);
|
||||
std::cerr << object->name2 << ": yaw < -1\n";
|
||||
}
|
||||
mb.yaw = acos(yaw);
|
||||
RAD2GRAD(mb.yaw);
|
||||
// wrong 1
|
||||
/*if (mb.yaw < 90)
|
||||
mb.yaw += 90;
|
||||
else
|
||||
{
|
||||
mb.yaw -= 90;
|
||||
mb.yaw = -mb.yaw;
|
||||
}*/
|
||||
mb.yaw = calc_yaw(object->m_rotate_z);
|
||||
mb.scale = ASSIGN(object->m_rotate_z[2].z, 1);
|
||||
auto i = find_if(storage->mapBuildings.begin(), storage->mapBuildings.end(), [&](const auto &p)
|
||||
{
|
||||
|
|
@ -185,6 +224,7 @@ void write_mmo(Storage *storage, const mmo_storage &s)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (seg->segment_type == ObjectType::TREE ||
|
||||
seg->segment_type == ObjectType::STONE ||
|
||||
seg->segment_type == ObjectType::LAMP ||
|
||||
|
|
@ -221,13 +261,7 @@ void write_mmo(Storage *storage, const mmo_storage &s)
|
|||
mb.z = ASSIGN(object->position.z, 0);
|
||||
mb.roll = 0;
|
||||
mb.pitch = 0;
|
||||
auto yaw = ASSIGN(object->m_rotate_z[0].x, 0);
|
||||
if (yaw > 1)
|
||||
yaw = yaw - floor(yaw);
|
||||
if (yaw < -1)
|
||||
yaw = yaw - ceil(yaw);
|
||||
mb.yaw = acos(yaw);
|
||||
RAD2GRAD(mb.yaw);
|
||||
mb.yaw = calc_yaw(object->m_rotate_z) - 90;
|
||||
mb.scale = ASSIGN(object->m_rotate_z[2].z, 1);
|
||||
auto i = find_if(storage->mapObjects.begin(), storage->mapObjects.end(), [&](const auto &p)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ void mmp::load(const buffer &b)
|
|||
void mmp::load(const std::string &fn)
|
||||
{
|
||||
filename = fn;
|
||||
buffer b(read_file(filename));
|
||||
buffer b(read_file(filename, true));
|
||||
load(b);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -242,25 +242,26 @@ bool CreateScene(model &model, const std::string &name, FbxManager* pSdkManager,
|
|||
for (auto &v : b.vertices)
|
||||
{
|
||||
FbxVector4 x;
|
||||
x.Set(-v.coordinates.x * scale_mult, v.coordinates.y * scale_mult, -v.coordinates.z * scale_mult, v.coordinates.w);
|
||||
x.Set(v.coordinates.z * scale_mult, v.coordinates.y * scale_mult, v.coordinates.x * scale_mult, v.coordinates.w);
|
||||
c += x;
|
||||
}
|
||||
c /= b.vertices.size();
|
||||
|
||||
auto s = create_socket_named(name);
|
||||
if (mirror_x)
|
||||
c.mData[0] = -c.mData[0];
|
||||
c.mData[2] = -c.mData[2];
|
||||
s->LclTranslation.Set(c);
|
||||
};
|
||||
|
||||
//std::map<std::string,
|
||||
int socket_id = 0;
|
||||
int engine_id = 0;
|
||||
int fx_id = 0;
|
||||
for (auto &b : model.blocks)
|
||||
{
|
||||
//
|
||||
if (b.isEngineFx())
|
||||
{
|
||||
create_socket(b, "EngineFx_" + std::to_string(socket_id++));
|
||||
create_socket(b, "EngineFx_" + std::to_string(engine_id++));
|
||||
continue;
|
||||
}
|
||||
else if (b.h.name == "LIGHTGUN")
|
||||
|
|
@ -279,6 +280,11 @@ bool CreateScene(model &model, const std::string &name, FbxManager* pSdkManager,
|
|||
create_socket(b, "WeaponRocket");
|
||||
continue;
|
||||
}
|
||||
else if (b.h.name.find("FX") == 0)
|
||||
{
|
||||
create_socket(b, "Fx_" + std::to_string(fx_id++));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!b.canPrint())
|
||||
continue;
|
||||
|
|
@ -320,9 +326,9 @@ bool CreateScene(model &model, const std::string &name, FbxManager* pSdkManager,
|
|||
for (auto &v : b.vertices)
|
||||
{
|
||||
FbxVector4 x;
|
||||
x.Set(-v.coordinates.x * scale_mult, v.coordinates.z * scale_mult, v.coordinates.y * scale_mult, v.coordinates.w);
|
||||
x.Set(v.coordinates.z * scale_mult, v.coordinates.x * scale_mult, v.coordinates.y * scale_mult, v.coordinates.w);
|
||||
m->SetControlPointAt(x, i++);
|
||||
normal->GetDirectArray().Add(FbxVector4(-v.normal.x, -v.normal.z, v.normal.y));
|
||||
normal->GetDirectArray().Add(FbxVector4(v.normal.z, -v.normal.x, v.normal.y));
|
||||
|
||||
float f;
|
||||
auto uc = modf(fabs(v.texture_coordinates.u), &f);
|
||||
|
|
|
|||
Loading…
Reference in a new issue