mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-18 18:49:17 +00:00
Forced smoothed normals calculations for VMRML2 parser
This commit is contained in:
parent
ca9ada70a2
commit
b987445676
plugins/3d/vrml
v2
vrml2_appearance.cppvrml2_appearance.hvrml2_base.cppvrml2_base.hvrml2_box.cppvrml2_box.hvrml2_color.cppvrml2_color.hvrml2_coords.cppvrml2_coords.hvrml2_faceset.cppvrml2_faceset.hvrml2_lineset.cppvrml2_lineset.hvrml2_material.cppvrml2_material.hvrml2_node.hvrml2_norms.cppvrml2_norms.hvrml2_pointset.cppvrml2_pointset.hvrml2_shape.cppvrml2_shape.hvrml2_switch.cppvrml2_switch.hvrml2_transform.cppvrml2_transform.h
vrml.cppwrlfacet.cppwrlfacet.h@ -360,7 +360,7 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2APPEARANCE::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2APPEARANCE::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
if( NULL == material && NULL == texture )
|
||||
return NULL;
|
||||
@ -418,7 +418,7 @@ SGNODE* WRL2APPEARANCE::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
return m_sgNode;
|
||||
}
|
||||
|
||||
m_sgNode = material->TranslateToSG( aParent, calcNormals );
|
||||
m_sgNode = material->TranslateToSG( aParent );
|
||||
|
||||
return m_sgNode;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_APPEARANCE_H
|
||||
|
@ -910,7 +910,7 @@ bool WRL2BASE::readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
if( m_Children.empty() )
|
||||
return NULL;
|
||||
@ -967,7 +967,7 @@ SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
do
|
||||
{
|
||||
IFSG_TRANSFORM wrapper( topNode.GetRawPtr() );
|
||||
SGNODE* pshape = (*sC)->TranslateToSG( wrapper.GetRawPtr(), calcNormals );
|
||||
SGNODE* pshape = (*sC)->TranslateToSG( wrapper.GetRawPtr() );
|
||||
|
||||
if( NULL != pshape )
|
||||
test = true;
|
||||
@ -981,7 +981,7 @@ SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
case WRL2_TRANSFORM:
|
||||
case WRL2_SWITCH:
|
||||
|
||||
if( NULL != (*sC)->TranslateToSG( topNode.GetRawPtr(), calcNormals ) )
|
||||
if( NULL != (*sC)->TranslateToSG( topNode.GetRawPtr() ) )
|
||||
test = true;
|
||||
|
||||
break;
|
||||
|
@ -111,7 +111,7 @@ public:
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool SetParent( WRL2NODE* aParent );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_BASE_H
|
||||
|
@ -210,7 +210,7 @@ bool WRL2BOX::AddChildNode( WRL2NODE* aNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_BOX_H
|
||||
|
@ -192,7 +192,7 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2COLOR::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2COLOR::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// any data manipulation must be performed by the parent node
|
||||
return NULL;
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
|
||||
/**
|
||||
* Function HasColors
|
||||
|
@ -220,7 +220,7 @@ void WRL2COORDS::GetCoords( WRLVEC3F*& aCoordList, size_t& aListSize )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2COORDS::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2COORDS::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// any data manipulation must be performed by the parent node
|
||||
return NULL;
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
|
||||
void GetCoords( WRLVEC3F*& aCoordList, size_t& aListSize );
|
||||
};
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "vrml2_faceset.h"
|
||||
#include "vrml2_coords.h"
|
||||
#include "vrml2_color.h"
|
||||
#include "wrlfacet.h"
|
||||
#include "plugins/3dapi/ifsg_all.h"
|
||||
|
||||
|
||||
@ -78,7 +79,8 @@ void WRL2FACESET::setDefaults( void )
|
||||
normalPerVertex = true;
|
||||
solid = true;
|
||||
|
||||
creaseAngle = 0.0;
|
||||
creaseAngle = 0.5;
|
||||
creaseLimit = 0.878; // approx cos( 0.5 )
|
||||
}
|
||||
|
||||
|
||||
@ -476,6 +478,13 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( creaseAngle < 0.0 )
|
||||
creaseAngle = 0.0;
|
||||
else if( creaseAngle > M_PI_2 )
|
||||
creaseAngle = M_PI_2;
|
||||
|
||||
creaseLimit = cosf( creaseAngle );
|
||||
}
|
||||
else if( !glob.compare( "colorIndex" ) )
|
||||
{
|
||||
@ -587,7 +596,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
@ -633,12 +642,6 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
if( NULL == coord || vsize < 3 )
|
||||
return NULL;
|
||||
|
||||
// create the index list and make sure we have >3 points
|
||||
size_t idx;
|
||||
int i1 = coordIndex[0];
|
||||
int i2 = coordIndex[1];
|
||||
int i3 = coordIndex[2];
|
||||
|
||||
WRLVEC3F* pcoords;
|
||||
size_t coordsize;
|
||||
((WRL2COORDS*) coord)->GetCoords( pcoords, coordsize );
|
||||
@ -647,7 +650,7 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
return NULL;
|
||||
|
||||
// check that all indices are valid
|
||||
for( idx = 0; idx < vsize; ++idx )
|
||||
for( size_t idx = 0; idx < vsize; ++idx )
|
||||
{
|
||||
if( coordIndex[idx] < 0 )
|
||||
continue;
|
||||
@ -656,320 +659,129 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// if the indices are defective just give up
|
||||
if( i1 < 0 || i2 < 0 || i3 < 0
|
||||
|| i1 == i2 || i1 == i3 || i2 == i3 )
|
||||
return NULL;
|
||||
|
||||
std::vector< SGPOINT > lCPts; // coordinate points for SG node
|
||||
std::vector< int > lCIdx; // coordinate index list for SG node (must be triads)
|
||||
std::vector< SGVECTOR > lCNorm; // per-vertex normals
|
||||
std::vector< int > faces; // tracks the number of polygons for the entire set
|
||||
std::vector< SGCOLOR > lColors; // colors points (if any) for SG node
|
||||
int nfaces = 0; // number of triangles for each face in the list
|
||||
SHAPE lShape;
|
||||
FACET* fp = NULL;
|
||||
size_t iCoord;
|
||||
int idx; // coordinate index
|
||||
size_t cidx = 0; // color index
|
||||
SGCOLOR pc1;
|
||||
|
||||
if( NULL == color )
|
||||
{
|
||||
// assuming convex polygons, create triangles for the SG node
|
||||
for( idx = 3; idx <= vsize; )
|
||||
// no per-vertex colors; we can save a few CPU cycles
|
||||
for( iCoord = 0; iCoord < vsize; ++iCoord )
|
||||
{
|
||||
lCIdx.push_back( i1 );
|
||||
idx = coordIndex[iCoord];
|
||||
|
||||
if( ccw )
|
||||
if( idx < 0 )
|
||||
{
|
||||
lCIdx.push_back( i2 );
|
||||
lCIdx.push_back( i3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
lCIdx.push_back( i3 );
|
||||
lCIdx.push_back( i2 );
|
||||
}
|
||||
|
||||
++nfaces;
|
||||
i2 = i3;
|
||||
|
||||
if( idx == vsize )
|
||||
break;
|
||||
|
||||
i3 = coordIndex[idx++];
|
||||
|
||||
while( ( i1 < 0 || i2 < 0 || i3 < 0 ) && ( idx < vsize ) )
|
||||
{
|
||||
if( i3 < 0 )
|
||||
if( NULL != fp )
|
||||
{
|
||||
faces.push_back( nfaces );
|
||||
nfaces = 0;
|
||||
if( fp->HasMinPoints() )
|
||||
fp = NULL;
|
||||
else
|
||||
fp->Init();
|
||||
}
|
||||
|
||||
i1 = i2;
|
||||
i2 = i3;
|
||||
i3 = coordIndex[idx++];
|
||||
|
||||
// any invalid polygons shall void the entire faceset; this is a requirement
|
||||
// to ensure correct handling of the normals
|
||||
if( ( i1 < 0 && i2 < 0 ) || ( i1 < 0 && i3 < 0 ) || ( i2 < 0 && i3 < 0 ) )
|
||||
return NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( i1 < 0 || i2 < 0 || i3 < 0 )
|
||||
break;
|
||||
// if the coordinate is bad then skip it
|
||||
if( idx >= (int)coordsize )
|
||||
continue;
|
||||
|
||||
if( NULL == fp )
|
||||
fp = lShape.NewFacet();
|
||||
|
||||
// push the vertex value and index
|
||||
fp->AddVertex( pcoords[idx], idx );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int cIndex;
|
||||
WRL2COLOR* cn = (WRL2COLOR*) color;
|
||||
SGCOLOR pc1, pc2, pc3;
|
||||
WRLVEC3F tc;
|
||||
|
||||
if( colorPerVertex )
|
||||
for( iCoord = 0; iCoord < vsize; ++iCoord )
|
||||
{
|
||||
cIndex = 3;
|
||||
idx = coordIndex[iCoord];
|
||||
|
||||
if( colorIndex.empty() )
|
||||
if( idx < 0 )
|
||||
{
|
||||
cn->GetColor( coordIndex[0], tc.x, tc.y, tc.z );
|
||||
pc1.SetColor( tc.x, tc.y, tc.z );
|
||||
cn->GetColor( coordIndex[1], tc.x, tc.y, tc.z );
|
||||
pc2.SetColor( tc.x, tc.y, tc.z );
|
||||
cn->GetColor( coordIndex[2], tc.x, tc.y, tc.z );
|
||||
pc3.SetColor( tc.x, tc.y, tc.z );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( colorIndex.size() < coordIndex.size() )
|
||||
if( NULL != fp )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 )
|
||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
std::cerr << " * [INFO] bad file; colorIndex.size() < coordIndex.size()\n";
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
if( fp->HasMinPoints() )
|
||||
fp = NULL;
|
||||
else
|
||||
fp->Init();
|
||||
}
|
||||
|
||||
cn->GetColor( colorIndex[0], tc.x, tc.y, tc.z );
|
||||
pc1.SetColor( tc.x, tc.y, tc.z );
|
||||
cn->GetColor( colorIndex[1], tc.x, tc.y, tc.z );
|
||||
pc2.SetColor( tc.x, tc.y, tc.z );
|
||||
cn->GetColor( colorIndex[2], tc.x, tc.y, tc.z );
|
||||
pc3.SetColor( tc.x, tc.y, tc.z );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cIndex = 1;
|
||||
if( !colorPerVertex )
|
||||
++cidx;
|
||||
|
||||
if( colorIndex.empty() )
|
||||
{
|
||||
cn->GetColor( 0, tc.x, tc.y, tc.z );
|
||||
pc1.SetColor( tc.x, tc.y, tc.z );
|
||||
pc2.SetColor( tc.x, tc.y, tc.z );
|
||||
pc3.SetColor( tc.x, tc.y, tc.z );
|
||||
}
|
||||
else
|
||||
{
|
||||
cn->GetColor( colorIndex[0], tc.x, tc.y, tc.z );
|
||||
pc1.SetColor( tc.x, tc.y, tc.z );
|
||||
pc2.SetColor( tc.x, tc.y, tc.z );
|
||||
pc3.SetColor( tc.x, tc.y, tc.z );
|
||||
}
|
||||
}
|
||||
|
||||
// assuming convex polygons, create triangles for the SG node
|
||||
int cMaxIdx = (int) colorIndex.size();
|
||||
|
||||
for( idx = 3; idx <= vsize; )
|
||||
{
|
||||
lCIdx.push_back( i1 );
|
||||
lColors.push_back( pc1 );
|
||||
lColors.push_back( pc2 );
|
||||
lColors.push_back( pc3 );
|
||||
|
||||
if( ccw )
|
||||
{
|
||||
lCIdx.push_back( i2 );
|
||||
lCIdx.push_back( i3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
lCIdx.push_back( i3 );
|
||||
lCIdx.push_back( i2 );
|
||||
continue;
|
||||
}
|
||||
|
||||
++nfaces;
|
||||
i2 = i3;
|
||||
// if the coordinate is bad then skip it
|
||||
if( idx >= (int)coordsize )
|
||||
continue;
|
||||
|
||||
if( colorPerVertex && i1 >= 0 && i2 >= 0 && i3 >= 0 )
|
||||
if( NULL == fp )
|
||||
fp = lShape.NewFacet();
|
||||
|
||||
// push the vertex value and index
|
||||
fp->AddVertex( pcoords[idx], idx );
|
||||
|
||||
// push the color if appropriate
|
||||
if( !colorPerVertex )
|
||||
{
|
||||
pc1.SetColor( pc2 );
|
||||
pc2.SetColor( pc3 );
|
||||
|
||||
if( colorIndex.empty() )
|
||||
{
|
||||
cn->GetColor( coordIndex[idx], tc.x, tc.y, tc.z );
|
||||
cn->GetColor( cidx, tc.x, tc.y, tc.z );
|
||||
pc1.SetColor( tc.x, tc.y, tc.z );
|
||||
cn->GetColor( coordIndex[idx], tc.x, tc.y, tc.z );
|
||||
pc2.SetColor( tc.x, tc.y, tc.z );
|
||||
cn->GetColor( coordIndex[idx], tc.x, tc.y, tc.z );
|
||||
pc3.SetColor( tc.x, tc.y, tc.z );
|
||||
fp->AddColor( pc1 );
|
||||
}
|
||||
else
|
||||
cn->GetColor( colorIndex[cIndex++], tc.x, tc.y, tc.z );
|
||||
|
||||
pc3.SetColor( tc.x, tc.y, tc.z );
|
||||
}
|
||||
|
||||
if( idx == vsize )
|
||||
break;
|
||||
|
||||
i3 = coordIndex[idx++];
|
||||
|
||||
while( ( i1 < 0 || i2 < 0 || i3 < 0 ) && ( idx < vsize ) )
|
||||
{
|
||||
if( i3 < 0 )
|
||||
{
|
||||
faces.push_back( nfaces );
|
||||
nfaces = 0;
|
||||
|
||||
if( !colorPerVertex )
|
||||
{
|
||||
if( colorIndex.empty() || cIndex >= cMaxIdx )
|
||||
cn->GetColor( cIndex++, tc.x, tc.y, tc.z );
|
||||
else
|
||||
cn->GetColor( colorIndex[cIndex++], tc.x, tc.y, tc.z );
|
||||
|
||||
pc1.SetColor( tc.x, tc.y, tc.z );
|
||||
pc2.SetColor( tc.x, tc.y, tc.z );
|
||||
pc3.SetColor( tc.x, tc.y, tc.z );
|
||||
}
|
||||
}
|
||||
|
||||
i1 = i2;
|
||||
i2 = i3;
|
||||
|
||||
if( colorPerVertex )
|
||||
{
|
||||
pc1.SetColor( pc2 );
|
||||
pc2.SetColor( pc3 );
|
||||
|
||||
if( colorIndex.empty() )
|
||||
{
|
||||
cn->GetColor( coordIndex[idx], tc.x, tc.y, tc.z );
|
||||
pc1.SetColor( tc.x, tc.y, tc.z );
|
||||
cn->GetColor( coordIndex[idx], tc.x, tc.y, tc.z );
|
||||
pc2.SetColor( tc.x, tc.y, tc.z );
|
||||
cn->GetColor( coordIndex[idx], tc.x, tc.y, tc.z );
|
||||
pc3.SetColor( tc.x, tc.y, tc.z );
|
||||
}
|
||||
if( cidx < colorIndex.size() )
|
||||
cn->GetColor( colorIndex[cidx], tc.x, tc.y, tc.z );
|
||||
else
|
||||
cn->GetColor( colorIndex[cIndex++], tc.x, tc.y, tc.z );
|
||||
cn->GetColor( colorIndex.back(), tc.x, tc.y, tc.z );
|
||||
|
||||
pc3.SetColor( tc.x, tc.y, tc.z );
|
||||
}
|
||||
|
||||
i3 = coordIndex[idx++];
|
||||
|
||||
// any invalid polygons shall void the entire faceset; this is a requirement
|
||||
// to ensure correct handling of the normals
|
||||
if( ( i1 < 0 && i2 < 0 ) || ( i1 < 0 && i3 < 0 ) || ( i2 < 0 && i3 < 0 ) )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( i1 < 0 || i2 < 0 || i3 < 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( lCIdx.empty() )
|
||||
return NULL;
|
||||
|
||||
if( calcNormals || NULL == normal )
|
||||
{
|
||||
// create a vertex list for per-face per-vertex normals
|
||||
std::vector< int >::iterator sI = lCIdx.begin();
|
||||
std::vector< int >::iterator eI = lCIdx.end();
|
||||
|
||||
while( sI != eI )
|
||||
{
|
||||
lCPts.push_back( SGPOINT( pcoords[*sI].x, pcoords[*sI].y, pcoords[*sI].z ) );
|
||||
++sI;
|
||||
}
|
||||
|
||||
for( size_t i = 0; i < lCPts.size(); i += 3 )
|
||||
{
|
||||
SGVECTOR sv = S3D::CalcTriNorm( lCPts[i], lCPts[i+1], lCPts[i+2] );
|
||||
lCNorm.push_back( sv );
|
||||
lCNorm.push_back( sv );
|
||||
lCNorm.push_back( sv );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// XXX - TO IMPLEMENT
|
||||
return NULL;
|
||||
/*
|
||||
// use the vertex list as is
|
||||
if( normalPerVertex )
|
||||
{
|
||||
// normalPerVertex = TRUE
|
||||
// rules:
|
||||
// + if normalIndex is not EMPTY, it is used to select a normal for each vertex
|
||||
// + if normalIndex is EMPTY, the normal list is used in order per vertex
|
||||
|
||||
if( normalIndex.empty() )
|
||||
{
|
||||
for( size_t i = 0; i < coordsize; ++i )
|
||||
{
|
||||
lCPts.push_back( SGPOINT( pcoords[i].x, pcoords[i].y, pcoords[i].z ) );
|
||||
|
||||
// XXX - TO IMPLEMENT
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// XXX - TO IMPLEMENT: index the normals
|
||||
pc1.SetColor( tc.x, tc.y, tc.z );
|
||||
fp->AddColor( pc1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// normalPerVertex = FALSE
|
||||
// rules:
|
||||
// + if normalIndex is not EMPTY, it is used to select a normal for each face
|
||||
// + if normalIndex is EMPTY, the normal list is used in order per face
|
||||
if( colorIndex.empty() )
|
||||
{
|
||||
cn->GetColor( idx, tc.x, tc.y, tc.z );
|
||||
pc1.SetColor( tc.x, tc.y, tc.z );
|
||||
fp->AddColor( pc1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( iCoord < colorIndex.size() )
|
||||
cn->GetColor( colorIndex[iCoord], tc.x, tc.y, tc.z );
|
||||
else
|
||||
cn->GetColor( colorIndex.back(), tc.x, tc.y, tc.z );
|
||||
|
||||
pc1.SetColor( tc.x, tc.y, tc.z );
|
||||
fp->AddColor( pc1 );
|
||||
}
|
||||
}
|
||||
//*/
|
||||
}
|
||||
}
|
||||
|
||||
IFSG_FACESET fsNode( aParent );
|
||||
IFSG_COORDS cpNode( fsNode );
|
||||
cpNode.SetCoordsList( lCPts.size(), &lCPts[0] );
|
||||
IFSG_COORDINDEX ciNode( fsNode );
|
||||
SGNODE* np = NULL;
|
||||
|
||||
if( calcNormals || NULL == normal )
|
||||
{
|
||||
for( int i = 0; i < (int)lCPts.size(); ++i )
|
||||
ciNode.AddIndex( i );
|
||||
}
|
||||
if( ccw )
|
||||
np = lShape.CalcShape( aParent, NULL, ORD_CCW, creaseLimit, true );
|
||||
else
|
||||
{
|
||||
ciNode.SetIndices( lCIdx.size(), &lCIdx[0] );
|
||||
}
|
||||
np = lShape.CalcShape( aParent, NULL, ORD_CLOCKWISE, creaseLimit, true );
|
||||
|
||||
IFSG_NORMALS nmNode( fsNode );
|
||||
nmNode.SetNormalList( lCNorm.size(), &lCNorm[0] );
|
||||
|
||||
if( !lColors.empty() )
|
||||
{
|
||||
IFSG_COLORS nmColor( fsNode );
|
||||
nmColor.SetColorList( lColors.size(), &lColors[0] );
|
||||
}
|
||||
|
||||
m_sgNode = fsNode.GetRawPtr();
|
||||
|
||||
return m_sgNode;
|
||||
return np;
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,6 +58,7 @@ private:
|
||||
std::vector< int > normalIndex;
|
||||
|
||||
float creaseAngle;
|
||||
float creaseLimit;
|
||||
|
||||
|
||||
/**
|
||||
@ -87,7 +88,7 @@ public:
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
|
||||
/**
|
||||
* Function HasColors
|
||||
|
@ -377,7 +377,7 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2LINESET::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2LINESET::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// note: there are no plans to support drawing of lines
|
||||
return NULL;
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
|
||||
/**
|
||||
* Function HasColors
|
||||
|
@ -296,7 +296,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2MATERIAL::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2MATERIAL::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent );
|
||||
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_MATERIAL_H
|
||||
|
@ -185,7 +185,7 @@ public:
|
||||
* @param aParent is a pointer to the parent SG node
|
||||
* @return is non-NULL on success
|
||||
*/
|
||||
virtual SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals ) = 0;
|
||||
virtual SGNODE* TranslateToSG( SGNODE* aParent ) = 0;
|
||||
};
|
||||
|
||||
#endif // VRML2_NODE_H
|
||||
|
@ -192,7 +192,7 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2NORMS::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2NORMS::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// any data manipulation must be performed by the parent node
|
||||
return NULL;
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_NORMS_H
|
||||
|
@ -325,7 +325,7 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2POINTSET::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2POINTSET::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// note: there are no plans to support drawing of points
|
||||
return NULL;
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
|
||||
/**
|
||||
* Function HasColors
|
||||
|
@ -326,7 +326,7 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
if( NULL == geometry )
|
||||
return NULL;
|
||||
@ -401,11 +401,11 @@ SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
IFSG_SHAPE shNode( aParent );
|
||||
|
||||
SGNODE* pShape = shNode.GetRawPtr();
|
||||
SGNODE* pGeom = geometry->TranslateToSG( pShape, calcNormals );
|
||||
SGNODE* pGeom = geometry->TranslateToSG( pShape );
|
||||
SGNODE* pApp = NULL;
|
||||
|
||||
if( NULL != appearance )
|
||||
pApp = appearance->TranslateToSG( pShape, calcNormals );
|
||||
pApp = appearance->TranslateToSG( pShape );
|
||||
|
||||
if( ( NULL != appearance && NULL == pApp ) || NULL == pGeom )
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_SHAPE_H
|
||||
|
@ -273,7 +273,7 @@ bool WRL2SWITCH::readChildren( WRLPROC& proc, WRL2BASE* aTopNode )
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2SWITCH::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
SGNODE* WRL2SWITCH::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 )
|
||||
std::cerr << " * [INFO] Translating Switch with " << m_Children.size();
|
||||
@ -327,5 +327,5 @@ SGNODE* WRL2SWITCH::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return choices[whichChoice]->TranslateToSG( aParent, calcNormals );
|
||||
return choices[whichChoice]->TranslateToSG( aParent );
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent, bool calcNormals );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_SWITCH_H
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user