summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-02-21 16:43:56 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-21 16:48:04 +0000
commit605db8cd3778bd2f58a956a0776c1001d7286def (patch)
treef7cad28fb8480cf6b7f11353907c4fed9856f04c
parentfix.arc (diff)
downloadilt-605db8cd3778bd2f58a956a0776c1001d7286def.tar.bz2
ilt-605db8cd3778bd2f58a956a0776c1001d7286def.tar.xz
ilt-605db8cd3778bd2f58a956a0776c1001d7286def.zip
Named model parts, fix bogie spelling, new brush47 model
-rw-r--r--game/network/rail.cpp2
-rw-r--r--game/vehicles/railloco.cpp36
-rw-r--r--game/vehicles/railloco.h6
-rw-r--r--gfx/models/obj.h9
-rw-r--r--gfx/models/obj.impl.cpp14
-rw-r--r--res/brush47.obj288
-rw-r--r--res/brush47.pngbin98156 -> 111263 bytes
-rw-r--r--test/test-obj.cpp22
8 files changed, 212 insertions, 165 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 77d53e4..bf1d71d 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -13,7 +13,7 @@
#include <type_traits>
#include <utility>
-constexpr std::size_t RAIL_CROSSSECTION_VERTICES {5};
+constexpr auto RAIL_CROSSSECTION_VERTICES {5U};
constexpr glm::vec3 RAIL_HEIGHT {0, .25F, 0};
RailLinks::RailLinks() : texture {Texture::cachedTexture.get("rails.jpg")} { }
diff --git a/game/vehicles/railloco.cpp b/game/vehicles/railloco.cpp
index c9ba9f9..bc62d43 100644
--- a/game/vehicles/railloco.cpp
+++ b/game/vehicles/railloco.cpp
@@ -10,6 +10,7 @@
#include <glm/glm.hpp>
#include <iterator>
#include <lib/resource.h>
+#include <map>
#include <maths.h>
#include <memory>
#include <random>
@@ -21,9 +22,9 @@ void
RailVehicle::render(const Shader & shader) const
{
texture->Bind();
- for (const auto & bogey : bogeys) {
- shader.setModel(bogey.location.GetModel());
- bogey.mesh->Draw();
+ for (const auto & bogie : bogies) {
+ shader.setModel(bogie.location.GetModel());
+ bogie.mesh->Draw();
}
shader.setModel(location.GetModel());
bodyMesh->Draw();
@@ -54,7 +55,7 @@ RailLoco::move(TickDuration dur)
}
Transform
-RailLoco::getBogeyPosition(float linkDist, float dist) const
+RailLoco::getBogiePosition(float linkDist, float dist) const
{
float b2linkDist {};
const auto b2Link = linkHist.getAt(dist - linkDist, &b2linkDist);
@@ -65,8 +66,8 @@ void
RailLoco::updateRailVehiclePosition(RailVehicle * w, float trailBy) const
{
const auto overhang {(w->length - w->wheelBase) / 2};
- const auto & b1Pos = w->bogeys[0].location = getBogeyPosition(linkDist, trailBy += overhang);
- const auto & b2Pos = w->bogeys[1].location = getBogeyPosition(linkDist, trailBy + wheelBase);
+ const auto & b1Pos = w->bogies[0].location = getBogiePosition(linkDist, trailBy += overhang);
+ const auto & b2Pos = w->bogies[1].location = getBogiePosition(linkDist, trailBy + wheelBase);
const auto diff = glm::normalize(b2Pos.GetPos() - b1Pos.GetPos());
w->location.GetPos() = (b1Pos.GetPos() + b2Pos.GetPos()) / 2.F;
w->location.GetRot() = {-vector_pitch(diff), vector_yaw(diff), 0};
@@ -95,10 +96,10 @@ RailLoco::updateWagons() const
void RailWagon::tick(TickDuration) { }
void
-bogeyOffset(ObjParser & o)
+bogieOffset(ObjParser & o)
{
- // offset bogey positions so they can be set directly
- for (int b = 1; b < 3; b++) { // bogey object index
+ // offset bogie positions so they can be set directly
+ for (int b = 1; b < 3; b++) { // bogie object index
std::set<std::pair<float, int>> vertexIds;
for (const auto & face : o.objects[b].second) {
for (const auto & faceElement : face) {
@@ -115,25 +116,26 @@ bogeyOffset(ObjParser & o)
Brush47::Brush47(const LinkPtr & l) : RailLoco(l, 0)
{
ObjParser o {Resource::mapPath("brush47.obj")};
- bogeyOffset(o);
+ bogieOffset(o);
const auto m = o.createMeshes();
- bodyMesh = m[0].second;
- bogeys[0].mesh = m[1].second;
- bogeys[1].mesh = m[2].second;
+ bodyMesh = m.at("Body");
+ bogies[0].mesh = m.at("Bogie1");
+ bogies[1].mesh = m.at("Bogie2");
texture = Texture::cachedTexture.get(Resource::mapPath("brush47.png"));
wheelBase = 12.F;
length = 20.F;
+ speed = 33.6F;
linkDist = wheelBase;
}
Brush47Wagon::Brush47Wagon(const LinkPtr & l) : RailWagon(l, 0)
{
ObjParser o {Resource::mapPath("brush47.obj")};
- bogeyOffset(o);
+ bogieOffset(o);
const auto m = o.createMeshes();
- bodyMesh = m[0].second;
- bogeys[0].mesh = m[1].second;
- bogeys[1].mesh = m[2].second;
+ bodyMesh = m.at("Body");
+ bogies[0].mesh = m.at("Bogie1");
+ bogies[1].mesh = m.at("Bogie2");
texture = Texture::cachedTexture.get(Resource::mapPath("brush47.png"));
wheelBase = 12.F;
length = 20.F;
diff --git a/game/vehicles/railloco.h b/game/vehicles/railloco.h
index df5f970..ddc706f 100644
--- a/game/vehicles/railloco.h
+++ b/game/vehicles/railloco.h
@@ -12,7 +12,7 @@ class Shader;
class Texture;
class RailVehicle : public Vehicle {
public:
- struct Bogey {
+ struct Bogie {
Transform location;
MeshPtr mesh;
};
@@ -20,7 +20,7 @@ public:
using Vehicle::Vehicle;
void render(const Shader & shader) const override;
- std::array<Bogey, 2> bogeys;
+ std::array<Bogie, 2> bogies;
MeshPtr bodyMesh;
std::shared_ptr<Texture> texture;
float wheelBase;
@@ -45,7 +45,7 @@ public:
private:
void move(TickDuration dur);
- [[nodiscard]] Transform getBogeyPosition(float linkDist, float dist) const;
+ [[nodiscard]] Transform getBogiePosition(float linkDist, float dist) const;
void updateRailVehiclePosition(RailVehicle *, float trailBy) const;
void updateWagons() const;
};
diff --git a/gfx/models/obj.h b/gfx/models/obj.h
index 71733fe..a2d874f 100644
--- a/gfx/models/obj.h
+++ b/gfx/models/obj.h
@@ -8,6 +8,7 @@
#include <filesystem>
#include <fstream>
#include <glm/glm.hpp>
+#include <map>
#include <memory>
#include <vector>
@@ -39,10 +40,10 @@ public:
std::vector<Object> objects;
glm::length_t axis {0};
- using NamedMeshData = std::pair<std::string, std::pair<std::vector<Vertex>, std::vector<unsigned int>>>;
- [[nodiscard]] std::vector<NamedMeshData> createMeshData() const;
- using NamedMesh = std::pair<std::string, std::shared_ptr<const Mesh>>;
- [[nodiscard]] std::vector<NamedMesh> createMeshes() const;
+ using NamedMeshesData = std::map<std::string, std::pair<std::vector<Vertex>, std::vector<unsigned int>>>;
+ [[nodiscard]] NamedMeshesData createMeshData() const;
+ using NamedMeshes = std::map<std::string, std::shared_ptr<const Mesh>>;
+ [[nodiscard]] NamedMeshes createMeshes() const;
};
#endif
diff --git a/gfx/models/obj.impl.cpp b/gfx/models/obj.impl.cpp
index 5ac15ac..330e851 100644
--- a/gfx/models/obj.impl.cpp
+++ b/gfx/models/obj.impl.cpp
@@ -4,27 +4,27 @@
#include <gfx/models/vertex.hpp>
#include <glm/glm.hpp>
#include <iterator>
+#include <map>
#include <memory>
#include <utility>
#include <vector>
-std::vector<ObjParser::NamedMesh>
+ObjParser::NamedMeshes
ObjParser::createMeshes() const
{
- std::vector<ObjParser::NamedMesh> out;
+ NamedMeshes out;
const auto data {createMeshData()};
- std::transform(data.begin(), data.end(), std::back_inserter(out), [](auto && obj) {
+ std::transform(data.begin(), data.end(), std::inserter(out, out.end()), [](auto && obj) {
return std::make_pair(obj.first, std::make_shared<Mesh>(obj.second.first, obj.second.second));
});
return out;
}
-std::vector<ObjParser::NamedMeshData>
+ObjParser::NamedMeshesData
ObjParser::createMeshData() const
{
- std::vector<ObjParser::NamedMeshData> out;
- out.reserve(objects.size());
- std::transform(objects.begin(), objects.end(), std::back_inserter(out), [this](auto && obj) {
+ NamedMeshesData out;
+ std::transform(objects.begin(), objects.end(), std::inserter(out, out.end()), [this](auto && obj) {
std::vector<Vertex> overtices;
std::vector<ObjParser::FaceElement> vertexOrder;
std::vector<unsigned int> indices;
diff --git a/res/brush47.obj b/res/brush47.obj
index 3f23a80..8fcb2b1 100644
--- a/res/brush47.obj
+++ b/res/brush47.obj
@@ -18,14 +18,11 @@ v -1.345000 2.723224 9.690000
v 1.345000 2.723224 9.690000
v 1.345000 2.723224 -9.690000
v -1.345000 2.723224 -9.690000
-v 1.340000 0.200000 9.600000
-v -1.340000 0.200000 9.600000
-v 1.340000 1.200000 9.600000
-v -1.340000 1.200000 9.600000
-v -1.340000 0.200000 -9.600000
-v 1.340000 0.200000 -9.600000
-v -1.340000 1.200000 -9.600000
-v 1.340000 1.200000 -9.600000
+v 1.340000 0.500000 9.600000
+v -1.340000 0.500000 9.600000
+v -1.340000 1.200000 9.690000
+v -1.340000 0.500000 -9.600000
+v 1.340000 0.500000 -9.600000
v -1.300000 0.200000 -2.250000
v -1.300000 1.200000 -2.250000
v -1.300000 0.200000 2.250000
@@ -34,46 +31,26 @@ v 1.300000 0.200000 -2.250000
v 1.300000 1.200000 -2.250000
v 1.300000 0.200000 2.250000
v 1.300000 1.200000 2.250000
+v 1.345000 1.200000 8.236500
+v 1.345000 1.200000 -8.236500
+v -1.345000 1.200000 -8.236500
+v -1.345000 1.200000 8.236500
vt 0.025174 0.662500
vt 0.025174 0.831250
vt 0.037326 0.925000
vt 0.957465 0.927083
vt 0.971354 0.833333
vt 0.971354 0.662500
+vt 0.900391 0.662500
+vt 0.096137 0.662500
vt 0.025174 0.662500
vt 0.025174 0.831250
vt 0.037326 0.925000
vt 0.957465 0.927083
vt 0.971354 0.833333
vt 0.971354 0.662500
-vt 0.002604 0.014583
-vt 0.002604 0.081250
-vt 0.043403 0.081250
-vt 0.043403 0.014583
-vt 0.926215 0.527083
-vt 0.926215 0.612500
-vt 0.834201 0.612500
-vt 0.834201 0.527083
-vt 0.834201 0.527083
-vt 0.834201 0.612500
-vt 0.927083 0.612500
-vt 0.927083 0.527083
-vt 0.114583 0.293750
-vt 0.114583 0.414583
-vt 0.010417 0.414583
-vt 0.010417 0.293750
-vt 0.010417 0.293750
-vt 0.010417 0.414583
-vt 0.114583 0.414583
-vt 0.114583 0.293750
-vt 0.043403 0.081250
-vt 0.043403 0.014583
-vt 0.002604 0.014583
-vt 0.002604 0.081250
-vt 0.043403 0.081250
-vt 0.043403 0.014583
-vt 0.002604 0.014583
-vt 0.002604 0.081250
+vt 0.900391 0.662500
+vt 0.096137 0.662500
vt 0.605035 0.456250
vt 0.605035 0.581250
vt 0.359375 0.581250
@@ -82,10 +59,18 @@ vt 0.605035 0.581250
vt 0.605035 0.456250
vt 0.359375 0.581250
vt 0.359375 0.456250
+vt 0.026042 0.593750
+vt 0.971354 0.593750
+vt 0.026042 0.593750
+vt 0.971354 0.593750
vt 0.088542 0.089583
vt 0.088542 0.206250
vt 0.918403 0.206250
vt 0.918403 0.089583
+vt 0.926215 0.527083
+vt 0.926215 0.612500
+vt 0.834201 0.612500
+vt 0.834201 0.527083
vt 0.083333 0.989583
vt 0.913194 0.989583
vt 0.037326 0.927083
@@ -100,119 +85,176 @@ vt 0.152778 0.364583
vt 0.197049 0.364583
vt 0.204861 0.310417
vt 0.144965 0.310417
+vt 0.834201 0.527083
+vt 0.834201 0.612500
+vt 0.927083 0.612500
+vt 0.927083 0.527083
+vt 0.114583 0.293750
+vt 0.114583 0.414583
+vt 0.010417 0.414583
+vt 0.010417 0.293750
+vt 0.010417 0.293750
+vt 0.010417 0.414583
+vt 0.114583 0.414583
+vt 0.114583 0.293750
+vt 0.043403 0.014583
+vt 0.002604 0.014583
+vt 0.002604 0.081250
+vt 0.043403 0.081250
+vt 0.043403 0.014583
+vt 0.002604 0.014583
+vt 0.002604 0.081250
+vt 0.043403 0.081250
vn -1.0000 0.0000 0.0000
vn 1.0000 0.0000 0.0000
-vn 0.0000 1.0000 0.0000
-vn -0.0000 -0.2906 -0.9569
-vn 0.0000 -0.2906 0.9569
-vn -0.0000 0.0000 -1.0000
+vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
+vn -1.0000 0.0071 0.0000
+vn 1.0000 0.0071 -0.0000
vn -0.3335 -0.9344 -0.1252
vn 0.3335 -0.9344 -0.1252
vn 0.3335 -0.9344 0.1252
vn -0.3335 -0.9344 0.1252
+vn 0.6755 -0.1083 -0.7294
vn 0.6276 -0.5509 -0.5500
-vn 0.6276 -0.5509 0.5500
vn -0.6276 -0.5509 -0.5500
+vn -0.6755 -0.1083 -0.7294
+vn 0.6276 -0.5509 0.5500
vn -0.6276 -0.5509 0.5500
+vn -0.6755 -0.1083 0.7294
+vn 0.6755 -0.1083 0.7294
+vn 0.8867 0.0030 -0.4622
+vn -0.6937 0.0482 -0.7186
+vn -0.6937 0.0482 0.7186
+vn 0.6937 0.0482 0.7186
+vn -0.6128 0.1051 -0.7832
+vn 0.6145 0.1049 -0.7819
+vn 0.0000 0.1275 -0.9918
+vn 0.6128 0.1051 0.7832
+vn -0.6128 0.1051 0.7832
usemtl Brush47
s off
-f 4/1/1 14/2/1 12/3/1 10/4/1 15/5/1 3/6/1
-f 1/7/2 16/8/2 6/9/2 8/10/2 13/11/2 2/12/2
-f 2/13/3 4/14/3 3/15/3 1/16/3
-f 13/17/4 8/18/4 12/19/4 14/20/4
-f 15/21/5 10/22/5 6/23/5 16/24/5
-f 2/25/6 13/26/6 14/27/6 4/28/6
-f 3/29/7 15/30/7 16/31/7 1/32/7
-f 17/33/6 18/34/6 20/35/6 19/36/6
-f 21/37/7 22/38/7 24/39/7 23/40/7
-f 25/41/2 26/42/2 28/43/2 27/44/2
-f 27/44/6 28/43/6 32/45/6 31/46/6
-f 31/46/1 32/45/1 30/47/1 29/48/1
-f 29/48/7 30/47/7 26/42/7 25/41/7
+f 4/1/1 14/2/1 12/3/1 10/4/1 15/5/1 3/6/1 31/7/1 30/8/1
+f 1/9/2 16/10/2 6/11/2 8/12/2 13/13/2 2/14/2 33/15/2 32/16/2
+f 22/17/2 23/18/2 25/19/2 24/20/2
+f 24/20/3 25/19/3 29/21/3 28/22/3
+f 28/22/1 29/21/1 27/23/1 26/24/1
+f 26/24/4 27/23/4 23/18/4 22/17/4
+f 4/1/5 30/8/5 17/25/5
+f 31/7/5 3/6/5 21/26/5
+f 1/9/6 32/16/6 20/27/6
+f 33/15/6 2/14/6 18/28/6
s 1
-f 11/49/8 7/50/9 5/51/10 9/52/11
-f 5/53/10 7/54/9 8/10/12 6/55/13
-f 7/56/9 11/57/8 12/58/14 8/59/12
-f 11/60/8 9/61/11 10/4/15 12/62/14
-f 9/63/11 5/64/10 6/65/13 10/66/15
-o Bogey2
-v -1.326000 0.100000 -2.700000
-v -1.326000 0.100000 -9.300000
-v -1.326000 1.100000 -9.300000
-v -1.326000 1.100000 -2.700000
-v 1.326000 0.100000 -2.700000
-v 1.326000 1.100000 -2.700000
-v 1.326000 0.100000 -9.300000
-v 1.326000 1.100000 -9.300000
-vt 0.342014 0.435417
+f 11/29/7 7/30/8 5/31/9 9/32/10
+f 13/33/11 8/34/12 12/35/13 14/36/14
+f 5/37/9 7/38/8 8/12/12 6/39/15
+f 7/40/8 11/41/7 12/42/13 8/43/12
+f 11/44/7 9/45/10 10/4/16 12/46/13
+f 9/47/10 5/48/9 6/49/15 10/50/16
+f 15/51/17 10/52/16 6/53/15 16/54/18
+f 2/55/19 13/56/11 14/57/14 4/58/20
+f 3/59/21 15/60/17 16/61/18 1/62/22
+f 17/63/23 18/64/24 19/65/25 4/66/20
+f 20/67/26 21/68/27 3/69/21 1/70/22
+o Bogie2
+v -0.717500 0.000000 -2.700000
+v -0.717500 0.000000 -9.300000
+v -0.717500 1.200000 -2.700000
+v 0.717500 1.200000 -2.700000
+v 0.717500 0.000000 -2.700000
+v 0.717500 0.000000 -9.300000
+v 1.017500 1.200000 -2.700000
+v 1.017500 0.000000 -2.700000
+v 1.017500 0.000000 -9.300000
+v -1.017500 0.000000 -9.300000
+v -1.017501 0.000000 -2.700000
+v -1.017501 1.200000 -2.700000
+v -0.717500 0.654015 -9.300000
+v -0.717500 1.200000 -8.236500
+v -0.717500 0.661560 -9.285304
+v 0.717500 1.200000 -8.236500
+v 0.717500 0.654015 -9.300000
+v 1.017500 1.200000 -8.236500
+v 1.017500 0.654015 -9.300000
+v -1.017500 0.654015 -9.300000
+v -1.017500 1.200000 -8.236500
vt 0.342014 0.591667
-vt 0.006076 0.591667
+vt 0.342014 0.435417
+vt 0.006076 0.435417
+vt 0.006076 0.520575
+vt 0.006824 0.521557
+vt 0.060208 0.591667
vt 0.006076 0.435417
-vt 0.043403 0.014583
-vt 0.002604 0.014583
-vt 0.002604 0.081250
-vt 0.043403 0.081250
vt 0.342014 0.435417
vt 0.342014 0.591667
-vt 0.006076 0.591667
-vt 0.006076 0.435417
-vt 0.043403 0.014583
-vt 0.002604 0.014583
-vt 0.002604 0.081250
-vt 0.043403 0.081250
-vt 0.043403 0.081250
-vt 0.043403 0.014583
-vn 1.0000 0.0000 0.0000
-vn 0.0000 0.0000 -1.0000
+vt 0.060208 0.591667
+vt 0.006076 0.520575
+vt 0.217014 0.270833
+vt 0.552951 0.270833
+vt 0.552951 0.427083
+vt 0.271146 0.427083
+vt 0.217014 0.355992
+vt 0.552083 0.429167
+vt 0.552083 0.272917
+vt 0.216146 0.272917
+vt 0.216146 0.358075
+vt 0.270278 0.429167
+vn 1.0000 0.0000 -0.0000
vn -1.0000 0.0000 0.0000
-vn 0.0000 0.0000 1.0000
-vn 0.0000 -1.0000 0.0000
usemtl Brush47
s off
-f 34/67/16 35/68/16 36/69/16 33/70/16
-f 33/71/17 36/72/17 38/73/17 37/74/17
-f 37/75/18 38/76/18 40/77/18 39/78/18
-f 39/79/19 40/80/19 35/81/19 34/82/19
-f 38/73/20 36/83/20 35/84/20 40/80/20
-o Bogey1
-v 1.326000 0.100000 2.700000
-v 1.326000 1.100000 2.700000
-v 1.326000 0.100000 9.300000
-v 1.326000 1.100000 9.300000
-v -1.326000 0.100000 2.700000
-v -1.326000 1.100000 2.700000
-v -1.326000 0.100000 9.300000
-v -1.326000 1.100000 9.300000
+f 36/71/28 34/72/28 35/73/28 46/74/28 48/75/28 47/76/28
+f 39/77/29 38/78/29 37/79/29 49/80/29 50/81/29
+f 42/82/29 41/83/29 40/84/29 51/85/29 52/86/29
+f 45/87/28 44/88/28 43/89/28 53/90/28 54/91/28
+o Bogie1
+v 0.717500 0.000000 2.700000
+v 0.717500 1.200000 2.700000
+v 0.717500 0.000000 9.300000
+v -0.717500 0.000000 2.700000
+v -0.717500 1.200000 2.700000
+v -0.717500 0.000000 9.300000
+v 1.017500 0.000000 2.700001
+v 1.017500 1.200000 2.700001
+v 1.017500 0.000000 9.300000
+v -1.017500 0.000000 2.700000
+v -1.017500 1.200000 2.700000
+v -1.017500 0.000000 9.300000
+v 0.717500 0.654015 9.300000
+v 0.717500 1.200000 8.236500
+v 1.017500 0.654015 9.300000
+v 1.017500 1.200000 8.236500
+v -0.717500 1.200000 8.236500
+v -0.717500 0.661372 9.285670
+v -0.717500 0.654015 9.300000
+v -1.017500 1.200000 8.236500
+v -1.017500 0.654015 9.300000
vt 0.342014 0.435417
vt 0.006076 0.435417
-vt 0.006076 0.591667
+vt 0.006076 0.520575
+vt 0.060208 0.591667
vt 0.342014 0.591667
-vt 0.987847 0.602083
-vt 0.987847 0.464583
-vt 0.931424 0.464583
-vt 0.931424 0.602083
+vt 0.006076 0.520575
vt 0.006076 0.435417
vt 0.342014 0.435417
vt 0.342014 0.591667
-vt 0.006076 0.591667
-vt 0.987847 0.602083
-vt 0.987847 0.464583
-vt 0.931424 0.464583
-vt 0.931424 0.602083
-vt 0.043403 0.081250
-vt 0.043403 0.014583
-vt 0.002604 0.014583
-vt 0.002604 0.081250
+vt 0.060208 0.591667
+vt 0.006806 0.521533
+vt 0.552083 0.270833
+vt 0.216146 0.270833
+vt 0.216146 0.355992
+vt 0.270278 0.427083
+vt 0.552083 0.427083
+vt 0.215278 0.355992
+vt 0.215278 0.270833
+vt 0.552083 0.270833
+vt 0.552083 0.427083
+vt 0.269549 0.427083
vn -1.0000 0.0000 -0.0000
-vn 0.0000 0.0000 -1.0000
-vn 1.0000 0.0000 0.0000
-vn 0.0000 0.0000 1.0000
-vn 0.0000 -1.0000 0.0000
+vn 1.0000 -0.0000 0.0000
usemtl Brush47
s off
-f 41/85/21 43/86/21 44/87/21 42/88/21
-f 43/89/22 47/90/22 48/91/22 44/92/22
-f 47/93/23 45/94/23 46/95/23 48/96/23
-f 45/97/24 41/98/24 42/99/24 46/100/24
-f 48/101/25 46/102/25 42/103/25 44/104/25
+f 55/92/30 57/93/30 67/94/30 68/95/30 56/96/30
+f 73/97/31 60/98/31 58/99/31 59/100/31 71/101/31 72/102/31
+f 61/103/30 63/104/30 69/105/30 70/106/30 62/107/30
+f 75/108/31 66/109/31 64/110/31 65/111/31 74/112/31
diff --git a/res/brush47.png b/res/brush47.png
index 97fd77d..3d435d6 100644
--- a/res/brush47.png
+++ b/res/brush47.png
Binary files differ
diff --git a/test/test-obj.cpp b/test/test-obj.cpp
index 4adc961..963a9ad 100644
--- a/test/test-obj.cpp
+++ b/test/test-obj.cpp
@@ -5,6 +5,7 @@
#include <gfx/models/obj.h>
#include <gfx/models/vertex.hpp>
#include <glm/glm.hpp>
+#include <map>
#include <memory>
#include <utility>
#include <vector>
@@ -12,15 +13,15 @@
BOOST_AUTO_TEST_CASE(objparse)
{
ObjParser op {"/home/randomdan/dev/game/res/brush47.obj"};
- BOOST_CHECK_EQUAL(48, op.vertices.size());
- BOOST_CHECK_EQUAL(104, op.texCoords.size());
- BOOST_CHECK_EQUAL(25, op.normals.size());
+ BOOST_CHECK_EQUAL(75, op.vertices.size());
+ BOOST_CHECK_EQUAL(112, op.texCoords.size());
+ BOOST_CHECK_EQUAL(31, op.normals.size());
BOOST_CHECK_EQUAL(3, op.objects.size());
const auto & object {op.objects.front()};
BOOST_CHECK_EQUAL("Body", object.first);
- BOOST_CHECK_EQUAL(18, object.second.size());
- BOOST_CHECK_EQUAL(6, object.second[0].size());
- BOOST_CHECK_EQUAL(6, object.second[1].size());
+ BOOST_CHECK_EQUAL(21, object.second.size());
+ BOOST_CHECK_EQUAL(8, object.second[0].size());
+ BOOST_CHECK_EQUAL(8, object.second[1].size());
BOOST_CHECK_EQUAL(4, object.second[12].size());
}
@@ -29,9 +30,10 @@ BOOST_AUTO_TEST_CASE(create_meshes)
ObjParser op {"/home/randomdan/dev/game/res/brush47.obj"};
const auto ms = op.createMeshData();
BOOST_REQUIRE_EQUAL(3, ms.size());
- BOOST_REQUIRE_EQUAL("Body", ms.front().first);
- BOOST_REQUIRE_EQUAL(76, ms.front().second.first.size());
- const auto & v = ms.front().second.first.front();
+ BOOST_REQUIRE_EQUAL("Body", ms.begin()->first);
+ const auto & o = ms.at("Body");
+ BOOST_REQUIRE_EQUAL(88, o.first.size());
+ const auto & v = o.first.front();
BOOST_REQUIRE_CLOSE(1.345, v.pos.x, 1);
- BOOST_REQUIRE_EQUAL(120, ms.front().second.second.size());
+ BOOST_REQUIRE_EQUAL(138, o.second.size());
}