Commit 0d92361a authored by Gauvain Roussel-Tarbouriech's avatar Gauvain Roussel-Tarbouriech
Browse files

Sanity checks + switching to meson

parent b2a696a1
WCXX = i686-w64-mingw32-g++
CXX = g++
CF = clang-format
all: format linux
format:
$(CF) -i obj2kh2v.cpp
linux:
$(CXX) -g -std=c++11 obj2kh2v.cpp -o obj2kh2v
clean:
rm -rf *.kh2v *.o *.dsm *.exe obj2kh2v
windows:
$(WCXX) -std=c++11 -static-libgcc -static-libstdc++ obj2kh2v.cpp -o obj2kh2v.exe
project('obj2kh2v', 'cpp')
src = ['obj2kh2v.cpp']
executable('obj2kh2v', src)
cleaner = find_program('clang-format')
r = run_command(cleaner, '-i', src)
......@@ -19,7 +19,6 @@ int max(int x, int y, int z) {
}
int main(int argc, char *argv[]) {
long ap, vp, hp;
// max uv buffer, should be enough for an entire set of obj vertices
int uvs[8192];
int uv_count = 0;
......@@ -138,7 +137,6 @@ int main(int argc, char *argv[]) {
while (getline(input, line)) {
if (line.substr(0, 2) == "f ") {
long cur_pos = 0;
std::istringstream s(line.substr(2));
std::string i, n, u;
int ii, inn, iu;
......@@ -208,11 +206,10 @@ int main(int argc, char *argv[]) {
while (getline(input, line)) {
if (line.substr(0, 2) == "v ") {
std::istringstream s(line.substr(2));
float x, y, z, w;
float x, y, z;
s >> x;
s >> y;
s >> z;
w = 1.0f;
line = ".float " + std::to_string(x) + ", " +
std::to_string(y) + ", " + std::to_string(z);
dsm_mem.push_back(line);
......@@ -227,14 +224,14 @@ int main(int argc, char *argv[]) {
dsm_mem.push_back("unpack[r] V4_32, ,*; Vertex affiliation header");
// printf("%lu", bones.size());
vertex_affiliation = dsm_mem.size() - 1;
for (int i = 0; i < ceil(float(bones.size()) / 4); i++) {
for (unsigned int i = 0; i < ceil(float(bones.size()) / 4); i++) {
line = ".int " + std::to_string(bones[(i * 4)]);
int z = 1;
unsigned int z = 1;
while ((i * 4) + z < bones.size() && z < 4) {
line += ", " + std::to_string(bones[(i * 4) + z]);
z++;
}
for (z; z < 4; z++) {
for (; z < 4; z++) {
line += ", 0";
}
dsm_mem.push_back(line);
......@@ -275,7 +272,7 @@ int main(int argc, char *argv[]) {
" ,*; Vertex affiliation header";
dsm_mem[vertex_affiliation] = line;
for (int i = 0; i < dsm_mem.size(); i++) {
for (unsigned int i = 0; i < dsm_mem.size(); i++) {
dsm << dsm_mem[i] << std::endl;
}
dsm.close();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment