Skip to content

Commit

Permalink
ASE exporter seems to be working now
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jan 23, 2017
1 parent d02e322 commit 96311d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion plugins/model/AseExporter.cpp
Expand Up @@ -173,7 +173,8 @@ void AseExporter::exportToStream(std::ostream& stream)
{
const TexCoord2f& tex = surface.vertices[v].texcoord;

stream << "\t\t\t*MESH_TVERT " << v << "\t" << tex.x() << "\t" << tex.y() << "\t0.0000" << std::endl;
// Invert the T coordinate
stream << "\t\t\t*MESH_TVERT " << v << "\t" << tex.x() << "\t" << (-tex.y()) << "\t0.0000" << std::endl;
}

stream << "\t\t}" << std::endl;
Expand Down
10 changes: 7 additions & 3 deletions plugins/model/RenderablePicoSurface.cpp
Expand Up @@ -341,9 +341,13 @@ ModelPolygon RenderablePicoSurface::getPolygon(int polygonIndex) const

ModelPolygon poly;

poly.a = _vertices[_indices[polygonIndex*3]];
// For some reason, the PicoSurfaces are loaded such that the triangles have clockwise winding
// The common convention is to use CCW winding direction, so reverse the index order
// ASE models define tris in the usual CCW order, but it appears that the pm_ase.c file
// reverses the vertex indices during parsing.
poly.c = _vertices[_indices[polygonIndex*3]];
poly.b = _vertices[_indices[polygonIndex*3 + 1]];
poly.c = _vertices[_indices[polygonIndex*3 + 2]];
poly.a = _vertices[_indices[polygonIndex*3 + 2]];

return poly;
}
Expand Down Expand Up @@ -417,7 +421,7 @@ void RenderablePicoSurface::applyScale(const Vector3& scale, const RenderablePic
for (std::size_t i = 0; i < _vertices.size(); ++i)
{
_vertices[i].vertex = scaleMatrix.transformPoint(originalSurface._vertices[i].vertex);
_vertices[i].normal = invTranspScale.transformPoint(originalSurface._vertices[i].normal);
_vertices[i].normal = invTranspScale.transformPoint(originalSurface._vertices[i].normal).getNormalised();

// Expand the AABB to include this new vertex
_localAABB.includePoint(_vertices[i].vertex);
Expand Down

0 comments on commit 96311d4

Please sign in to comment.