Replaced placeholder texdef with actual
This commit is contained in:
parent
7747fd32fb
commit
d33b9d8639
@ -1,5 +1,7 @@
|
||||
#include "brushdef.hpp"
|
||||
#include "libraries.h"
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
// e.g GTK Radiant or older level editors.
|
||||
@ -25,6 +27,41 @@ void brushdef_gtk(std::stringstream &x, const vector<TPlanePoints> &y) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string texdef_net(const TPlanePoints &b) {
|
||||
// Reflex's material files haven't been reversed so there isn't actually a texture file to make use of
|
||||
#define REFLEX_TEXRES_PLACEHOLDER 64
|
||||
#define MIN_PRECISION 6
|
||||
float inverse_xscale = 0;
|
||||
if (b.hscale != 0) {
|
||||
inverse_xscale = 1 / (b.hscale * REFLEX_TEXRES_PLACEHOLDER); // WIDTH
|
||||
}
|
||||
float inverse_yscale = 0;
|
||||
if (b.vscale != 0) {
|
||||
inverse_yscale = 1 / (b.vscale * -REFLEX_TEXRES_PLACEHOLDER); // HEIGHT
|
||||
}
|
||||
// a lot of reflex's values for rotation are 0.0 or 1.0
|
||||
// likely values are stored in radians.
|
||||
float c = cos(b.rotation);
|
||||
float s = sin(b.rotation);
|
||||
|
||||
// horizontal values for texture definition
|
||||
float h1, h2, h3;
|
||||
h1 = c * inverse_xscale;
|
||||
h2 = s * inverse_yscale;
|
||||
h3 = b.hshift / REFLEX_TEXRES_PLACEHOLDER; // WIDTH
|
||||
|
||||
float v1, v2, v3;
|
||||
v1 = -s * inverse_xscale;
|
||||
v2 = c * inverse_yscale;
|
||||
v3 = -b.vshift / -REFLEX_TEXRES_PLACEHOLDER; // HEIGHT
|
||||
|
||||
std::stringstream ss;
|
||||
ss << std::setprecision(6)
|
||||
<< "( " << h1 << ' ' << h2 << ' ' << h3 << " ) "
|
||||
<< "( " << v1 << ' ' << v2 << ' ' << v3 << " )";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
// e.g Net Radiant and anything else based on it.
|
||||
void brushdef_net(std::stringstream &x, const vector<TPlanePoints> &y) {
|
||||
if (y.size()) {
|
||||
@ -37,9 +74,9 @@ void brushdef_net(std::stringstream &x, const vector<TPlanePoints> &y) {
|
||||
x << "( " << z.m_C[X] << " " << z.m_C[Z] << " " << z.m_C[Y] << " ) ";
|
||||
if (z.m_material.length()) {
|
||||
// placeholder values, for now only concerned with geometry
|
||||
x << " ( ( 0 0 0 ) ( 0 0 0 ) ) " << z.m_material << " 0 0 0" << std::endl;
|
||||
x << " ( " << texdef_net(z) << " ) " << z.m_material << " 0 0 0" << std::endl;
|
||||
} else {
|
||||
x << " ( ( 0 0 0 ) ( 0 0 0 ) ) common/caulk 0 0 0" << std::endl;
|
||||
x << " ( " << texdef_net(z) << " ) common/caulk 0 0 0" << std::endl;
|
||||
}
|
||||
}
|
||||
x << "}" << std::endl;
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "worldspawn.h"
|
||||
#include "planes.h"
|
||||
|
||||
std::string texdef_net(const TPlanePoints&);
|
||||
|
||||
void brushdef_gtk(std::stringstream&, const std::vector<TPlanePoints>&);
|
||||
|
||||
void brushdef_net(std::stringstream&, const std::vector<TPlanePoints>&);
|
||||
|
@ -90,11 +90,15 @@ std::vector<TPlanePoints> GetBrushPlanes(const TBrush& _krBrush)
|
||||
}
|
||||
TPlanePoints PP = GetPlanePoints(Verts.data(), Verts.size());
|
||||
PP.m_material = krFace.m_Material;
|
||||
if (!krFace.hex.empty()) {
|
||||
if (!krFace.hex.empty() && !krFace.m_Material.empty()) {
|
||||
PP.m_material.append("+" + krFace.hex);
|
||||
}
|
||||
PP.hscale = krFace.m_fXScale;
|
||||
PP.hshift = krFace.m_fXOffset;
|
||||
PP.vscale = krFace.m_fYScale;
|
||||
PP.vshift = krFace.m_fYOffset;
|
||||
PP.rotation = krFace.m_fRotation;
|
||||
Planes.push_back(PP);
|
||||
}
|
||||
|
||||
return(Planes);
|
||||
}
|
||||
|
@ -10,6 +10,9 @@ struct TPlanePoints {
|
||||
Eigen::Vector3f m_B;
|
||||
Eigen::Vector3f m_C;
|
||||
std::string m_material;
|
||||
float hscale, hshift; // horizontal
|
||||
float vscale, vshift; // vertical
|
||||
float rotation;
|
||||
};
|
||||
|
||||
Eigen::Vector3f get_polygon_normal(const Eigen::Vector3f*, const size_t);
|
||||
|
Loading…
Reference in New Issue
Block a user