2014-07-30 09:01:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Mario Luzeiro <mrluzeiro@gmail.com>
|
2015-01-18 11:49:32 +00:00
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-07-30 09:01:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file vrml_v1_modelparser.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <fctsys.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <info3d_visu.h>
|
|
|
|
|
|
|
|
#include "3d_struct.h"
|
|
|
|
#include "modelparsers.h"
|
|
|
|
#include "vrml_aux.h"
|
|
|
|
|
2015-03-05 19:46:38 +00:00
|
|
|
#define BUFLINE_SIZE 512
|
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
VRML1_MODEL_PARSER::VRML1_MODEL_PARSER( S3D_MASTER* aMaster ) :
|
|
|
|
S3D_MODEL_PARSER( aMaster )
|
|
|
|
{
|
|
|
|
m_model = NULL;
|
2014-08-16 18:01:00 +00:00
|
|
|
m_file = NULL;
|
2015-02-28 20:50:35 +00:00
|
|
|
m_Materials = NULL;
|
|
|
|
m_normalPerVertex = true;
|
|
|
|
colorPerVertex = true;
|
2014-07-30 09:01:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VRML1_MODEL_PARSER::~VRML1_MODEL_PARSER()
|
|
|
|
{
|
|
|
|
for( unsigned int idx = 0; idx < childs.size(); idx++ )
|
2014-08-16 18:01:00 +00:00
|
|
|
delete childs[idx];
|
2014-07-30 09:01:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-21 11:59:57 +00:00
|
|
|
void VRML1_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Dunits )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2015-03-05 19:46:38 +00:00
|
|
|
char text[BUFLINE_SIZE];
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-21 11:59:57 +00:00
|
|
|
// DBG( printf( "Load %s\n", GetChars(aFilename) ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
m_file = wxFopen( aFilename, wxT( "rt" ) );
|
|
|
|
|
|
|
|
if( m_file == NULL )
|
|
|
|
return;
|
|
|
|
|
2014-08-21 11:59:57 +00:00
|
|
|
float vrmlunits_to_3Dunits = aVrmlunits_to_3Dunits;
|
2014-07-31 07:01:30 +00:00
|
|
|
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y,
|
|
|
|
GetMaster()->m_MatScale.z );
|
|
|
|
glm::vec3 matRot( GetMaster()->m_MatRotation.x, GetMaster()->m_MatRotation.y,
|
|
|
|
GetMaster()->m_MatRotation.z );
|
|
|
|
glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y,
|
|
|
|
GetMaster()->m_MatPosition.z );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
// glPushMatrix();
|
2014-07-30 09:01:25 +00:00
|
|
|
glTranslatef( matPos.x * SCALE_3D_CONV, matPos.y * SCALE_3D_CONV, matPos.z * SCALE_3D_CONV );
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
glRotatef( -matRot.z, 0.0f, 0.0f, 1.0f );
|
|
|
|
glRotatef( -matRot.y, 0.0f, 1.0f, 0.0f );
|
|
|
|
glRotatef( -matRot.x, 1.0f, 0.0f, 0.0f );
|
2014-08-09 18:18:04 +00:00
|
|
|
|
|
|
|
glScalef( matScale.x, matScale.y, matScale.z );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-21 11:59:57 +00:00
|
|
|
LOCALE_IO toggle; // Switch the locale to standard C
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
childs.clear();
|
|
|
|
|
2015-02-20 00:21:34 +00:00
|
|
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2015-01-18 11:49:32 +00:00
|
|
|
if( ( *text == '}' ) || ( *text == ']' ) )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strcmp( text, "Separator" ) == 0 )
|
|
|
|
{
|
|
|
|
m_model = new S3D_MESH();
|
|
|
|
childs.push_back( m_model );
|
|
|
|
read_separator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose( m_file );
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( "chils size:%lu\n", childs.size() ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
if( GetMaster()->IsOpenGlAllowed() )
|
|
|
|
{
|
|
|
|
for( unsigned int idx = 0; idx < childs.size(); idx++ )
|
|
|
|
{
|
|
|
|
childs[idx]->openGL_RenderAllChilds();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
int VRML1_MODEL_PARSER::read_separator()
|
|
|
|
{
|
2015-03-05 19:46:38 +00:00
|
|
|
char text[BUFLINE_SIZE];
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( "Separator\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2015-02-20 00:21:34 +00:00
|
|
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
if( strcmp( text, "Material" ) == 0 )
|
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
readMaterial();
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( text, "Coordinate3" ) == 0 )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
readCoordinate3();
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( text, "IndexedFaceSet" ) == 0 )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
readIndexedFaceSet();
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( text, "Separator" ) == 0 )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
S3D_MESH* parent = m_model;
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
S3D_MESH* new_mesh_model = new S3D_MESH();
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
m_model->childs.push_back( new_mesh_model );
|
|
|
|
|
|
|
|
m_model = new_mesh_model;
|
|
|
|
|
|
|
|
// recursive
|
|
|
|
read_separator();
|
|
|
|
|
|
|
|
m_model = parent;
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
2014-08-16 18:01:00 +00:00
|
|
|
else if( ( *text != '}' ) )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( "read_NotImplemented %s\n", text ) );
|
|
|
|
read_NotImplemented( m_file, '}' );
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
|
|
|
else
|
2014-07-30 09:01:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int VRML1_MODEL_PARSER::readMaterial()
|
|
|
|
{
|
2015-03-05 19:46:38 +00:00
|
|
|
char text[BUFLINE_SIZE];
|
2014-07-30 09:01:25 +00:00
|
|
|
S3D_MATERIAL* material = NULL;
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readMaterial\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
wxString mat_name;
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
material = new S3D_MATERIAL( GetMaster(), mat_name );
|
|
|
|
|
|
|
|
GetMaster()->Insert( material );
|
|
|
|
|
|
|
|
m_model->m_Materials = material;
|
|
|
|
|
2015-02-20 00:21:34 +00:00
|
|
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2015-01-18 11:49:32 +00:00
|
|
|
if( *text == ']' )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-11-15 13:43:23 +00:00
|
|
|
if( *text == '}' )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strcmp( text, "ambientColor" ) == 0 )
|
|
|
|
{
|
|
|
|
readMaterial_ambientColor();
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( text, "diffuseColor" ) == 0 )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
readMaterial_diffuseColor();
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( text, "emissiveColor" ) == 0 )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
readMaterial_emissiveColor();
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( text, "specularColor" ) == 0 )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
readMaterial_specularColor();
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( text, "shininess" ) == 0 )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
readMaterial_shininess();
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( text, "transparency" ) == 0 )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
readMaterial_transparency();
|
2014-07-30 09:01:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
int VRML1_MODEL_PARSER::readCoordinate3()
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2015-03-05 19:46:38 +00:00
|
|
|
char text[BUFLINE_SIZE];
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readCoordinate3\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2015-02-20 00:21:34 +00:00
|
|
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2015-01-18 11:49:32 +00:00
|
|
|
if( *text == ']' )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-11-15 13:43:23 +00:00
|
|
|
if( *text == '}' )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strcmp( text, "point" ) == 0 )
|
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
readCoordinate3_point();
|
2014-07-30 09:01:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
int VRML1_MODEL_PARSER::readIndexedFaceSet()
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2015-03-05 19:46:38 +00:00
|
|
|
char text[BUFLINE_SIZE];
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readIndexedFaceSet\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2015-02-20 00:21:34 +00:00
|
|
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2015-01-18 11:49:32 +00:00
|
|
|
if( *text == ']' )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-11-15 13:43:23 +00:00
|
|
|
if( *text == '}' )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( strcmp( text, "coordIndex" ) == 0 )
|
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
readIndexedFaceSet_coordIndex();
|
2014-08-09 18:18:04 +00:00
|
|
|
}
|
|
|
|
else if( strcmp( text, "materialIndex" ) == 0 )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
readIndexedFaceSet_materialIndex();
|
2014-07-30 09:01:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
|
|
|
|
int VRML1_MODEL_PARSER::readMaterial_ambientColor()
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readMaterial_ambientColor\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
return parseVertexList( m_file, m_model->m_Materials->m_AmbientColor );
|
2014-07-30 09:01:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
int VRML1_MODEL_PARSER::readMaterial_diffuseColor()
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readMaterial_diffuseColor\n" ) );
|
2014-08-09 18:18:04 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
return parseVertexList( m_file, m_model->m_Materials->m_DiffuseColor );
|
2014-07-30 09:01:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
int VRML1_MODEL_PARSER::readMaterial_emissiveColor()
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readMaterial_emissiveColor\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
int ret = parseVertexList( m_file, m_model->m_Materials->m_EmissiveColor );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
if( GetMaster()->m_use_modelfile_emissiveColor == false )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
m_model->m_Materials->m_EmissiveColor.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int VRML1_MODEL_PARSER::readMaterial_specularColor()
|
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readMaterial_specularColor\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
int ret = parseVertexList( m_file, m_model->m_Materials->m_SpecularColor );
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
if( GetMaster()->m_use_modelfile_specularColor == false )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
m_model->m_Materials->m_SpecularColor.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
int VRML1_MODEL_PARSER::readMaterial_shininess()
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readMaterial_shininess\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
m_model->m_Materials->m_Shininess.clear();
|
|
|
|
|
|
|
|
float shininess_value;
|
2014-08-09 18:18:04 +00:00
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
while( fscanf( m_file, "%f,", &shininess_value ) )
|
|
|
|
{
|
|
|
|
// VRML value is normalized and openGL expects a value 0 - 128
|
|
|
|
shininess_value = shininess_value * 128.0f;
|
|
|
|
m_model->m_Materials->m_Shininess.push_back( shininess_value );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( GetMaster()->m_use_modelfile_shininess == false )
|
|
|
|
{
|
|
|
|
m_model->m_Materials->m_Shininess.clear();
|
|
|
|
}
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " m_Shininess.size: %ld\n", m_model->m_Materials->m_Shininess.size() ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int VRML1_MODEL_PARSER::readMaterial_transparency()
|
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readMaterial_transparency\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
m_model->m_Materials->m_Transparency.clear();
|
|
|
|
|
|
|
|
float tmp;
|
2014-08-09 18:18:04 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
while( fscanf( m_file, "%f,", &tmp ) )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
|
|
|
m_model->m_Materials->m_Transparency.push_back( tmp );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( GetMaster()->m_use_modelfile_transparency == false )
|
|
|
|
{
|
|
|
|
m_model->m_Materials->m_Transparency.clear();
|
|
|
|
}
|
2014-08-09 18:18:04 +00:00
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " m_Transparency.size: %ld\n", m_model->m_Materials->m_Transparency.size() ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int VRML1_MODEL_PARSER::readCoordinate3_point()
|
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readCoordinate3_point\n" ) );
|
2014-08-09 18:18:04 +00:00
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
if( parseVertexList( m_file, m_model->m_Point ) == 0 )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int VRML1_MODEL_PARSER::readIndexedFaceSet_coordIndex()
|
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readIndexedFaceSet_coordIndex\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
m_model->m_CoordIndex.clear();
|
|
|
|
|
|
|
|
glm::ivec3 coord;
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
int dummy; // should be -1
|
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
while( fscanf( m_file, "%d,%d,%d,%d,", &coord[0], &coord[1], &coord[2], &dummy ) )
|
|
|
|
{
|
|
|
|
std::vector<int> coord_list;
|
|
|
|
|
|
|
|
coord_list.resize( 3 );
|
|
|
|
coord_list[0] = coord[0];
|
|
|
|
coord_list[1] = coord[1];
|
|
|
|
coord_list[2] = coord[2];
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
if( (coord[0] == coord[1])
|
|
|
|
|| (coord[0] == coord[2])
|
|
|
|
|| (coord[2] == coord[1]) )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " invalid coordIndex at index %lu (%d, %d, %d, %d)\n", m_model->m_CoordIndex.size()+1,coord[0], coord[1], coord[2], dummy ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
}
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
if( dummy != -1 )
|
2014-07-30 09:01:25 +00:00
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " Error at index %lu, -1 Expected, got %d\n", m_model->m_CoordIndex.size()+1, dummy ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
}
|
2014-08-16 18:01:00 +00:00
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
m_model->m_CoordIndex.push_back( coord_list );
|
|
|
|
}
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " m_CoordIndex.size: %ld\n", m_model->m_CoordIndex.size() ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int VRML1_MODEL_PARSER::readIndexedFaceSet_materialIndex()
|
|
|
|
{
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " readIndexedFaceSet_materialIndex\n" ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
m_model->m_MaterialIndex.clear();
|
|
|
|
|
|
|
|
int index;
|
2014-08-16 18:01:00 +00:00
|
|
|
|
2014-07-30 09:01:25 +00:00
|
|
|
while( fscanf( m_file, "%d,", &index ) )
|
|
|
|
{
|
|
|
|
m_model->m_MaterialIndex.push_back( index );
|
|
|
|
}
|
|
|
|
|
2014-08-16 18:01:00 +00:00
|
|
|
// DBG( printf( " m_MaterialIndex.size: %ld\n", m_model->m_MaterialIndex.size() ) );
|
2014-07-30 09:01:25 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|