Skip to content

Commit

Permalink
add index to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
nickblock committed Jan 19, 2021
1 parent b5e0f89 commit 19fbc84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions osm2assimp/geomconvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace GeoUtils
}
}

aiMesh *GeomConvert::polygonFromSpline(const std::vector<glm::vec2> &vertices, float width)
aiMesh *GeomConvert::polygonFromSpline(const std::vector<glm::vec2> &vertices, float width, int index)
{
ClipperLib::ClipperOffset clipperOffset;

Expand Down Expand Up @@ -134,7 +134,7 @@ namespace GeoUtils
}
}

aiMesh *GeomConvert::extrude2dMesh(const vector<glm::vec2> &in_vertices, float height)
aiMesh *GeomConvert::extrude2dMesh(const vector<glm::vec2> &in_vertices, float height, int index)
{
using Edge = std::pair<glm::vec2, glm::vec2>;
using EdgeList = std::vector<Edge>;
Expand Down Expand Up @@ -310,10 +310,10 @@ namespace GeoUtils
float texCoordU = std::round(width / texCoordScale);
float texCoordV = std::round(height / texCoordScale);

texCoord[0] = {texCoordU, texCoordV, 0.f};
texCoord[1] = {0.f, texCoordV, 0.f};
texCoord[2] = {0.f, 0.f, 0.f};
texCoord[3] = {texCoordU, 0.f, 0.f};
texCoord[0] = {texCoordU, texCoordV, static_cast<float>(index)};
texCoord[1] = {0.f, texCoordV, static_cast<float>(index)};
texCoord[2] = {0.f, 0.f, static_cast<float>(index)};
texCoord[3] = {texCoordU, 0.f, static_cast<float>(index)};
}

aiFace &face = newMesh->mFaces[2 + f];
Expand Down
4 changes: 2 additions & 2 deletions osm2assimp/geomconvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ namespace GeoUtils
/// Given an enclosed loop of 2d points defining a polygon the function returns a 3d mesh
/// with the polygon as it's base and top extruded to the value of the given height
/// <summary>
static aiMesh *extrude2dMesh(const std::vector<glm::vec2> &baseVertices, float height);
static aiMesh *extrude2dMesh(const std::vector<glm::vec2> &baseVertices, float height, int index);

/// <summary>
/// Given a list of points as a spline, creates a flat mesh for the spline of the given width
/// </summary>
static aiMesh *polygonFromSpline(const std::vector<glm::vec2> &baseVertices, float width);
static aiMesh *polygonFromSpline(const std::vector<glm::vec2> &baseVertices, float width, int index);
};

} // namespace GeoUtils
4 changes: 2 additions & 2 deletions osm2assimp/osmdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ namespace GeoUtils
// if it's something that wants turning into a 3d mesh
else if (feature.type() & (OSMFeature::BUILDING | OSMFeature::WATER) && feature.type() & OSMFeature::CLOSED)
{
mesh = GeomConvert::extrude2dMesh(feature.coords(), feature.height());
mesh = GeomConvert::extrude2dMesh(feature.coords(), feature.height(), mCount);
}

// if it's something that wants turning into a polygon spline
else if (feature.type() & OSMFeature::HIGHWAY)
{
mesh = GeomConvert::polygonFromSpline(feature.coords(), 3.0);
mesh = GeomConvert::polygonFromSpline(feature.coords(), 3.0, mCount);
}

// if we made either kind of mesh successfully
Expand Down

0 comments on commit 19fbc84

Please sign in to comment.