2016-01-05 21:29:13 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
2021-07-18 14:06:48 +00:00
|
|
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-01-05 21:29:13 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
2016-02-23 00:20:34 +00:00
|
|
|
#include <sstream>
|
|
|
|
#include <wx/log.h>
|
2016-01-05 21:29:13 +00:00
|
|
|
|
|
|
|
#include "vrml1_base.h"
|
|
|
|
#include "vrml1_faceset.h"
|
|
|
|
#include "vrml1_coords.h"
|
2016-01-06 04:34:14 +00:00
|
|
|
#include "vrml1_material.h"
|
2016-02-01 06:27:50 +00:00
|
|
|
#include "wrlfacet.h"
|
2016-01-05 21:29:13 +00:00
|
|
|
#include "plugins/3dapi/ifsg_all.h"
|
|
|
|
|
|
|
|
|
|
|
|
WRL1FACESET::WRL1FACESET( NAMEREGISTER* aDictionary ) : WRL1NODE( aDictionary )
|
|
|
|
{
|
2021-03-11 00:02:39 +00:00
|
|
|
m_Type = WRL1NODES::WRL1_INDEXEDFACESET;
|
2016-01-05 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WRL1FACESET::WRL1FACESET( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) :
|
|
|
|
WRL1NODE( aDictionary )
|
|
|
|
{
|
2021-03-11 00:02:39 +00:00
|
|
|
m_Type = WRL1NODES::WRL1_INDEXEDFACESET;
|
2016-01-05 21:29:13 +00:00
|
|
|
m_Parent = aParent;
|
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr != m_Parent )
|
2016-01-05 21:29:13 +00:00
|
|
|
m_Parent->AddChildNode( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WRL1FACESET::~WRL1FACESET()
|
|
|
|
{
|
2021-07-28 01:06:24 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Destroying IndexedFaceSet with %zu children, "
|
|
|
|
"%zu references, and %zu back pointers." ),
|
2021-07-24 17:27:35 +00:00
|
|
|
m_Children.size(), m_Refs.size(), m_BackPointers.size() );
|
2016-01-05 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL1FACESET::AddRefNode( WRL1NODE* aNode )
|
|
|
|
{
|
|
|
|
// this node may not own or reference any other node
|
2021-07-24 17:27:35 +00:00
|
|
|
wxCHECK_MSG( false, false, wxT( "AddRefNode is not applicable." ) );
|
2016-01-05 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL1FACESET::AddChildNode( WRL1NODE* aNode )
|
|
|
|
{
|
|
|
|
// this node may not own or reference any other node
|
2021-07-24 17:27:35 +00:00
|
|
|
wxCHECK_MSG( false, false, wxT( "AddChildNode is not applicable." ) );
|
2016-01-05 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode )
|
|
|
|
{
|
|
|
|
char tok = proc.Peek();
|
|
|
|
|
|
|
|
if( proc.eof() )
|
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin,
|
|
|
|
wxT( "%s:%s:%d\n"
|
|
|
|
" * [INFO] bad file format; unexpected eof %s." ),
|
|
|
|
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-05 21:29:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( '{' != tok )
|
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin,
|
|
|
|
wxT( "%s:%s:%d\n"
|
|
|
|
" * [INFO] bad file format; expecting '{' but got '%s' %s." ),
|
|
|
|
__FILE__, __FUNCTION__, __LINE__, tok, proc.GetFilePosition() );
|
2016-01-05 21:29:13 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
proc.Pop();
|
|
|
|
std::string glob;
|
|
|
|
|
|
|
|
while( true )
|
|
|
|
{
|
|
|
|
if( proc.Peek() == '}' )
|
|
|
|
{
|
|
|
|
proc.Pop();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !proc.ReadName( glob ) )
|
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n%s" ),
|
|
|
|
__FILE__, __FUNCTION__, __LINE__, proc.GetError() );
|
2016-01-05 21:29:13 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// expecting one of:
|
|
|
|
// coordIndex[]
|
|
|
|
// materialIndex[]
|
|
|
|
|
|
|
|
if( !glob.compare( "coordIndex" ) )
|
|
|
|
{
|
|
|
|
if( !proc.ReadMFInt( coordIndex ) )
|
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin,
|
|
|
|
wxT( "%s:%s:%d\n"
|
|
|
|
" * [INFO] invalid coordIndex %s.\n"
|
|
|
|
" * [INFO] file: '%s'\n"
|
|
|
|
"%s" ),
|
|
|
|
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
|
|
|
proc.GetFileName(), proc.GetError() );
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-05 21:29:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( !glob.compare( "materialIndex" ) )
|
|
|
|
{
|
|
|
|
if( !proc.ReadMFInt( matIndex ) )
|
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin,
|
|
|
|
wxT( "%s:%s:%d\n"
|
|
|
|
" * [INFO] invalid materialIndex %s.\n"
|
|
|
|
" * [INFO] file: '%s'\n"
|
|
|
|
"%s" ),
|
|
|
|
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
|
|
|
proc.GetFileName(), proc.GetError() );
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-05 21:29:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-01-06 04:34:14 +00:00
|
|
|
else if( !glob.compare( "normalIndex" ) )
|
|
|
|
{
|
|
|
|
if( !proc.ReadMFInt( normIndex ) )
|
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin,
|
|
|
|
wxT( "%s:%s:%d\n"
|
|
|
|
" * [INFO] invalid normalIndex %s\n"
|
|
|
|
" * [INFO] file: '%s'\n"
|
|
|
|
"%s" ),
|
|
|
|
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
|
|
|
proc.GetFileName(), proc.GetError() );
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-06 04:34:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( !glob.compare( "textureCoordIndex" ) )
|
|
|
|
{
|
|
|
|
if( !proc.ReadMFInt( texIndex ) )
|
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin,
|
|
|
|
wxT( "%s:%s:%d\n"
|
|
|
|
" * [INFO] invalid textureCoordIndex %s.\n"
|
|
|
|
" * [INFO] file: '%s'\n"
|
|
|
|
"%s" ),
|
|
|
|
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
|
|
|
proc.GetFileName(), proc.GetError() );
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-06 04:34:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-01-05 21:29:13 +00:00
|
|
|
else
|
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin,
|
|
|
|
wxT( "%s:%s:%d\n"
|
|
|
|
" * [INFO] invalid IndexedFaceSet %s.\n"
|
|
|
|
" * [INFO] file: '%s'" ),
|
|
|
|
__FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition(),
|
|
|
|
proc.GetFileName() );
|
2016-01-05 21:29:13 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} // while( true ) -- reading contents of IndexedFaceSet{}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-08 05:23:42 +00:00
|
|
|
SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp )
|
2016-01-05 21:29:13 +00:00
|
|
|
{
|
2016-01-08 05:23:42 +00:00
|
|
|
// note: m_sgNode is unused because we cannot manage everything
|
|
|
|
// with a single reused transform due to the fact that VRML1
|
|
|
|
// may use a MatrixTransformation entity which is impossible to
|
2021-07-18 14:06:48 +00:00
|
|
|
// decompose into Rotate,Scale,Transform via an analytic expression.
|
2016-01-08 05:23:42 +00:00
|
|
|
if( !m_Parent )
|
2016-01-06 04:34:14 +00:00
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin, " * [INFO] bad model: no parent node." );
|
2016-01-06 04:34:14 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2016-01-06 04:34:14 +00:00
|
|
|
}
|
2016-01-08 05:23:42 +00:00
|
|
|
else
|
2016-01-05 21:29:13 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr == sp )
|
2016-01-08 05:23:42 +00:00
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin, " * [INFO] bad model: no base data given." );
|
2016-01-05 21:29:13 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2016-01-08 05:23:42 +00:00
|
|
|
}
|
2016-01-05 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
2016-01-08 05:23:42 +00:00
|
|
|
m_current = *sp;
|
|
|
|
|
2021-07-24 17:27:35 +00:00
|
|
|
if( nullptr == m_current.coord )
|
2016-01-08 05:23:42 +00:00
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin, " * [INFO] bad model: no vertex set." );
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-01-08 05:23:42 +00:00
|
|
|
|
2021-07-24 17:27:35 +00:00
|
|
|
if( nullptr == m_current.mat )
|
|
|
|
{
|
|
|
|
wxLogTrace( traceVrmlPlugin, " * [INFO] bad model: no material set." );
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2016-01-08 05:23:42 +00:00
|
|
|
}
|
2016-01-06 04:34:14 +00:00
|
|
|
|
2016-01-06 07:02:21 +00:00
|
|
|
WRLVEC3F* pcoords;
|
|
|
|
size_t coordsize;
|
|
|
|
|
|
|
|
m_current.coord->GetCoords( pcoords, coordsize );
|
|
|
|
size_t vsize = coordIndex.size();
|
|
|
|
|
|
|
|
if( coordsize < 3 || vsize < 3 )
|
2016-01-08 05:23:42 +00:00
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin,
|
2021-07-28 01:06:24 +00:00
|
|
|
wxT( " * [INFO] bad model: coordsize = %zu, indexsize = %zu" ),
|
2021-07-24 17:27:35 +00:00
|
|
|
coordsize, vsize );
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
return nullptr;
|
2016-01-08 05:23:42 +00:00
|
|
|
}
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2016-01-06 04:34:14 +00:00
|
|
|
// 1. create the vertex/normals/colors lists
|
2021-07-18 14:06:48 +00:00
|
|
|
SGNODE* sgcolor = nullptr;
|
2016-01-19 04:21:00 +00:00
|
|
|
WRL1_BINDING mbind = m_current.matbind;
|
2016-02-01 06:27:50 +00:00
|
|
|
size_t matSize = matIndex.size();
|
2016-01-19 04:21:00 +00:00
|
|
|
|
|
|
|
switch( mbind )
|
2016-01-05 21:29:13 +00:00
|
|
|
{
|
2021-03-10 23:52:21 +00:00
|
|
|
case WRL1_BINDING::BIND_PER_FACE:
|
|
|
|
case WRL1_BINDING::BIND_PER_VERTEX:
|
|
|
|
case WRL1_BINDING::BIND_PER_VERTEX_INDEXED:
|
2016-01-06 07:02:21 +00:00
|
|
|
break;
|
|
|
|
|
2021-03-10 23:52:21 +00:00
|
|
|
case WRL1_BINDING::BIND_PER_FACE_INDEXED:
|
2016-01-06 07:02:21 +00:00
|
|
|
|
|
|
|
if( matIndex.empty() )
|
2016-01-08 05:23:42 +00:00
|
|
|
{
|
2021-07-24 17:27:35 +00:00
|
|
|
wxLogTrace( traceVrmlPlugin,
|
|
|
|
wxT( " * [INFO] bad model: per face indexed but no indices" ) );
|
2016-01-12 07:03:17 +00:00
|
|
|
|
2016-01-19 04:21:00 +00:00
|
|
|
// support bad models by temporarily switching bindings
|
2021-03-10 23:52:21 +00:00
|
|
|
mbind = WRL1_BINDING::BIND_OVERALL;
|
2016-01-19 04:21:00 +00:00
|
|
|
sgcolor = m_current.mat->GetAppearance( 0 );
|
2016-01-08 05:23:42 +00:00
|
|
|
}
|
2016-01-06 07:02:21 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2016-01-06 04:34:14 +00:00
|
|
|
default:
|
|
|
|
|
2016-01-07 00:24:11 +00:00
|
|
|
// use the first appearance definition
|
|
|
|
sgcolor = m_current.mat->GetAppearance( 0 );
|
2016-01-06 04:34:14 +00:00
|
|
|
break;
|
2016-01-05 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
// copy the data into FACET structures
|
2016-01-05 21:29:13 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
SHAPE lShape;
|
2021-07-18 14:06:48 +00:00
|
|
|
FACET* fp = nullptr;
|
2016-02-01 06:27:50 +00:00
|
|
|
size_t iCoord;
|
|
|
|
int idx; // coordinate index
|
|
|
|
size_t cidx = 0; // color index
|
|
|
|
SGCOLOR pc1;
|
2016-01-05 21:29:13 +00:00
|
|
|
|
2021-03-10 23:52:21 +00:00
|
|
|
if( mbind == WRL1_BINDING::BIND_OVERALL || mbind == WRL1_BINDING::BIND_DEFAULT )
|
2016-01-07 00:24:11 +00:00
|
|
|
{
|
2016-02-01 06:27:50 +00:00
|
|
|
// no per-vertex colors; we can save a few CPU cycles
|
|
|
|
for( iCoord = 0; iCoord < vsize; ++iCoord )
|
2016-01-05 21:29:13 +00:00
|
|
|
{
|
2016-02-01 06:27:50 +00:00
|
|
|
idx = coordIndex[iCoord];
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
if( idx < 0 )
|
2016-01-06 07:02:21 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr != fp )
|
2016-01-06 07:02:21 +00:00
|
|
|
{
|
2016-02-01 06:27:50 +00:00
|
|
|
if( fp->HasMinPoints() )
|
2021-07-18 14:06:48 +00:00
|
|
|
fp = nullptr;
|
2016-02-01 06:27:50 +00:00
|
|
|
else
|
|
|
|
fp->Init();
|
2016-01-06 07:02:21 +00:00
|
|
|
}
|
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
// if the coordinate is bad then skip it
|
|
|
|
if( idx >= (int)coordsize )
|
|
|
|
continue;
|
2016-01-08 05:23:42 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr == fp )
|
2016-02-01 06:27:50 +00:00
|
|
|
fp = lShape.NewFacet();
|
2016-01-08 05:23:42 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
// push the vertex value and index
|
|
|
|
WRLVEC3F vf;
|
|
|
|
glm::vec4 pt = glm::vec4( pcoords[idx].x, pcoords[idx].y, pcoords[idx].z, 1.0 );
|
|
|
|
pt = m_current.txmatrix * pt;
|
|
|
|
vf.x = pt.x;
|
|
|
|
vf.y = pt.y;
|
|
|
|
vf.z = pt.z;
|
|
|
|
|
|
|
|
fp->AddVertex( vf, idx );
|
2016-01-05 21:29:13 +00:00
|
|
|
}
|
2016-01-06 07:02:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-01 06:27:50 +00:00
|
|
|
for( iCoord = 0; iCoord < vsize; ++iCoord )
|
2016-01-05 21:29:13 +00:00
|
|
|
{
|
2016-02-01 06:27:50 +00:00
|
|
|
idx = coordIndex[iCoord];
|
2016-01-05 21:29:13 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
if( idx < 0 )
|
2016-01-05 21:29:13 +00:00
|
|
|
{
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr != fp )
|
2016-02-01 06:27:50 +00:00
|
|
|
{
|
|
|
|
if( fp->HasMinPoints() )
|
2021-07-18 14:06:48 +00:00
|
|
|
fp = nullptr;
|
2016-02-01 06:27:50 +00:00
|
|
|
else
|
|
|
|
fp->Init();
|
|
|
|
}
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2021-03-10 23:52:21 +00:00
|
|
|
if( mbind == WRL1_BINDING::BIND_PER_FACE
|
|
|
|
|| mbind == WRL1_BINDING::BIND_PER_FACE_INDEXED )
|
2016-02-01 06:27:50 +00:00
|
|
|
++cidx;
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
// if the coordinate is bad then skip it
|
|
|
|
if( idx >= (int)coordsize )
|
|
|
|
continue;
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2021-07-18 14:06:48 +00:00
|
|
|
if( nullptr == fp )
|
2016-02-01 06:27:50 +00:00
|
|
|
fp = lShape.NewFacet();
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
// push the vertex value and index
|
|
|
|
WRLVEC3F vf;
|
|
|
|
glm::vec4 pt = glm::vec4( pcoords[idx].x, pcoords[idx].y, pcoords[idx].z, 1.0 );
|
|
|
|
pt = m_current.txmatrix * pt;
|
|
|
|
vf.x = pt.x;
|
|
|
|
vf.y = pt.y;
|
|
|
|
vf.z = pt.z;
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
fp->AddVertex( vf, idx );
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
// push the color if appropriate
|
|
|
|
switch( mbind )
|
2016-01-07 07:03:07 +00:00
|
|
|
{
|
2021-03-10 23:52:21 +00:00
|
|
|
case WRL1_BINDING::BIND_PER_FACE:
|
2016-01-07 07:03:07 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
if( !fp->HasColors() )
|
|
|
|
{
|
|
|
|
m_current.mat->GetColor( &pc1, cidx );
|
|
|
|
fp->AddColor( pc1 );
|
|
|
|
}
|
2016-01-07 07:03:07 +00:00
|
|
|
|
|
|
|
break;
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2021-03-10 23:52:21 +00:00
|
|
|
case WRL1_BINDING::BIND_PER_VERTEX:
|
2016-02-01 06:27:50 +00:00
|
|
|
m_current.mat->GetColor( &pc1, idx );
|
|
|
|
fp->AddColor( pc1 );
|
2016-01-08 05:23:42 +00:00
|
|
|
break;
|
|
|
|
|
2021-03-10 23:52:21 +00:00
|
|
|
case WRL1_BINDING::BIND_PER_FACE_INDEXED:
|
2021-07-18 14:06:48 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
if( !fp->HasColors() )
|
2016-01-06 07:02:21 +00:00
|
|
|
{
|
2016-02-01 06:27:50 +00:00
|
|
|
if( cidx >= matSize )
|
|
|
|
m_current.mat->GetColor( &pc1, matIndex.back() );
|
|
|
|
else
|
|
|
|
m_current.mat->GetColor( &pc1, matIndex[cidx] );
|
|
|
|
|
|
|
|
fp->AddColor( pc1 );
|
2016-01-06 07:02:21 +00:00
|
|
|
}
|
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
break;
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2021-03-10 23:52:21 +00:00
|
|
|
case WRL1_BINDING::BIND_PER_VERTEX_INDEXED:
|
2016-02-01 06:27:50 +00:00
|
|
|
|
|
|
|
if( matIndex.empty() )
|
2016-01-06 07:02:21 +00:00
|
|
|
{
|
2021-02-02 05:25:35 +00:00
|
|
|
m_current.mat->GetColor( &pc1, idx );
|
2016-01-06 07:02:21 +00:00
|
|
|
}
|
2016-02-01 06:27:50 +00:00
|
|
|
else
|
2016-01-08 05:23:42 +00:00
|
|
|
{
|
2016-02-01 06:27:50 +00:00
|
|
|
if( iCoord >= matSize )
|
|
|
|
m_current.mat->GetColor( &pc1, matIndex.back() );
|
|
|
|
else
|
|
|
|
m_current.mat->GetColor( &pc1, matIndex[iCoord] );
|
2016-01-08 05:23:42 +00:00
|
|
|
}
|
2016-01-05 21:29:13 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
fp->AddColor( pc1 );
|
2016-01-08 05:23:42 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
break;
|
2016-01-07 07:03:07 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
default:
|
|
|
|
break;
|
2016-01-07 07:03:07 +00:00
|
|
|
}
|
2016-01-05 21:29:13 +00:00
|
|
|
}
|
2016-01-06 08:45:49 +00:00
|
|
|
}
|
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
// extract the final data set
|
2016-02-02 00:23:15 +00:00
|
|
|
SGNODE* np = lShape.CalcShape( aParent, sgcolor, m_current.order, m_current.creaseLimit );
|
2016-01-06 07:02:21 +00:00
|
|
|
|
2016-02-01 06:27:50 +00:00
|
|
|
return np;
|
2016-01-05 21:29:13 +00:00
|
|
|
}
|