Skip to content

Commit

Permalink
Save/load connectors as simple vertices in WZM format (for now).
Browse files Browse the repository at this point in the history
  • Loading branch information
inodlite committed Jan 21, 2012
1 parent aa5b7fe commit a91dfd0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/formats/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ WZMVertex normalizeVector(const WZMVertex& ver)


WZMConnector::WZMConnector(GLfloat x, GLfloat y, GLfloat z):
m_pos(Vertex<GLfloat>(x, y, z))
m_pos(x, y, z)
{
}

WZMConnector::WZMConnector(const WZMVertex &pos):
m_pos(pos)
{
}

Expand Down Expand Up @@ -408,7 +413,6 @@ bool Mesh::read(std::istream& in)
{
std::string str;
unsigned i,vertices,indices;
GLfloat f;

clear();

Expand Down Expand Up @@ -533,19 +537,21 @@ bool Mesh::read(std::istream& in)
return false;
}

if ( i > 0)
if (i > 0)
{
// TODO: Connectors
WZMVertex con;

for(; i > 0; --i)
{
in >> str >> f >> f >> f >> f >> f >> f ;
in >> con.x() >> con.y() >> con.z();
}
if(in.fail())
if (in.fail())
{
std::cerr << "Mesh::read - Error reading connectors";
clear();
return false;
}
m_connectors.push_back(con);
}

recalculateBoundData();
Expand Down Expand Up @@ -595,8 +601,16 @@ void Mesh::write(std::ostream &out) const
<< indIt->c() << '\n';
}

// TODO: Frames and connectors
out <<"CONNECTORS 0\n";
out <<"CONNECTORS " << m_connectors.size() << "\n";
std::list<WZMConnector>::const_iterator conIt;
for (conIt = m_connectors.begin(); conIt != m_connectors.end(); ++conIt)
{
WZMVertex con = conIt->getPos();
out << '\t';
out << con.x() << ' '
<< con.y() << ' '
<< con.z() << '\n';
}
}

bool Mesh::importFromOBJ(const std::vector<OBJTri>& faces,
Expand Down
1 change: 1 addition & 0 deletions src/formats/Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class WZMConnector
friend class Mesh;
public:
WZMConnector(GLfloat x = 0., GLfloat y = 0., GLfloat z = 0.);
WZMConnector(const WZMVertex& pos);
virtual ~WZMConnector(){}

const WZMVertex& getPos() const;
Expand Down

0 comments on commit a91dfd0

Please sign in to comment.