Merge pull request #1018 from johnmaf/bugfix/obj-homogeneous_coords
Parse homogeneous vertex coordinates in OBJspull/1019/head
commit
0aab2aa96a
|
@ -140,6 +140,9 @@ void ObjFileParser::parseFile()
|
||||||
if (numComponents == 3) {
|
if (numComponents == 3) {
|
||||||
// read in vertex definition
|
// read in vertex definition
|
||||||
getVector3(m_pModel->m_Vertices);
|
getVector3(m_pModel->m_Vertices);
|
||||||
|
} else if (numComponents == 4) {
|
||||||
|
// read in vertex definition (homogeneous coords)
|
||||||
|
getHomogeneousVector3(m_pModel->m_Vertices);
|
||||||
} else if (numComponents == 6) {
|
} else if (numComponents == 6) {
|
||||||
// read vertex and vertex-color
|
// read vertex and vertex-color
|
||||||
getTwoVectors3(m_pModel->m_Vertices, m_pModel->m_VertexColors);
|
getTwoVectors3(m_pModel->m_Vertices, m_pModel->m_VertexColors);
|
||||||
|
@ -320,6 +323,26 @@ void ObjFileParser::getVector3( std::vector<aiVector3D> &point3d_array ) {
|
||||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjFileParser::getHomogeneousVector3( std::vector<aiVector3D> &point3d_array ) {
|
||||||
|
ai_real x, y, z, w;
|
||||||
|
copyNextWord(m_buffer, Buffersize);
|
||||||
|
x = (ai_real) fast_atof(m_buffer);
|
||||||
|
|
||||||
|
copyNextWord(m_buffer, Buffersize);
|
||||||
|
y = (ai_real) fast_atof(m_buffer);
|
||||||
|
|
||||||
|
copyNextWord( m_buffer, Buffersize );
|
||||||
|
z = ( ai_real ) fast_atof( m_buffer );
|
||||||
|
|
||||||
|
copyNextWord( m_buffer, Buffersize );
|
||||||
|
w = ( ai_real ) fast_atof( m_buffer );
|
||||||
|
|
||||||
|
ai_assert( w != 0 );
|
||||||
|
|
||||||
|
point3d_array.push_back( aiVector3D( x/w, y/w, z/w ) );
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Get values for two 3D vectors on the same line
|
// Get values for two 3D vectors on the same line
|
||||||
void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, std::vector<aiVector3D> &point3d_array_b ) {
|
void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, std::vector<aiVector3D> &point3d_array_b ) {
|
||||||
|
|
|
@ -89,6 +89,8 @@ private:
|
||||||
void getVector( std::vector<aiVector3D> &point3d_array );
|
void getVector( std::vector<aiVector3D> &point3d_array );
|
||||||
/// Stores the following 3d vector.
|
/// Stores the following 3d vector.
|
||||||
void getVector3( std::vector<aiVector3D> &point3d_array );
|
void getVector3( std::vector<aiVector3D> &point3d_array );
|
||||||
|
/// Stores the following homogeneous vector as a 3D vector
|
||||||
|
void getHomogeneousVector3( std::vector<aiVector3D> &point3d_array );
|
||||||
/// Stores the following two 3d vectors on the line.
|
/// Stores the following two 3d vectors on the line.
|
||||||
void getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, std::vector<aiVector3D> &point3d_array_b );
|
void getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, std::vector<aiVector3D> &point3d_array_b );
|
||||||
/// Stores the following 3d vector.
|
/// Stores the following 3d vector.
|
||||||
|
|
Loading…
Reference in New Issue