Implemented per-vertex colors for VRML2 and SGNODE
This commit is contained in:
parent
6b873ed46b
commit
6f309a46c9
|
@ -131,7 +131,7 @@ bool SGCOLORS::AddChildNode( SGNODE* aNode )
|
||||||
|
|
||||||
bool SGCOLORS::GetColorList( size_t& aListSize, SGCOLOR*& aColorList )
|
bool SGCOLORS::GetColorList( size_t& aListSize, SGCOLOR*& aColorList )
|
||||||
{
|
{
|
||||||
if( colors.size() )
|
if( colors.empty() )
|
||||||
{
|
{
|
||||||
aListSize = 0;
|
aListSize = 0;
|
||||||
aColorList = NULL;
|
aColorList = NULL;
|
||||||
|
@ -144,7 +144,7 @@ bool SGCOLORS::GetColorList( size_t& aListSize, SGCOLOR*& aColorList )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SGCOLORS::SetColorList( size_t& aListSize, const SGCOLOR* aColorList )
|
void SGCOLORS::SetColorList( size_t aListSize, const SGCOLOR* aColorList )
|
||||||
{
|
{
|
||||||
colors.clear();
|
colors.clear();
|
||||||
|
|
||||||
|
@ -154,6 +154,8 @@ void SGCOLORS::SetColorList( size_t& aListSize, const SGCOLOR* aColorList )
|
||||||
for( size_t i = 0; i < aListSize; ++i )
|
for( size_t i = 0; i < aListSize; ++i )
|
||||||
colors.push_back( aColorList[i] );
|
colors.push_back( aColorList[i] );
|
||||||
|
|
||||||
|
std::cerr << "XXX: ncolors: " << colors.size() << "\n";
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +214,8 @@ bool SGCOLORS::WriteVRML( std::ofstream& aFile, bool aReuseFlag )
|
||||||
for( size_t i = 0; i < n; )
|
for( size_t i = 0; i < n; )
|
||||||
{
|
{
|
||||||
S3D::FormatColor( tmp, colors[i] );
|
S3D::FormatColor( tmp, colors[i] );
|
||||||
|
float r,g,b;
|
||||||
|
colors[i].GetColor(r, g, b);
|
||||||
aFile << tmp ;
|
aFile << tmp ;
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
bool AddChildNode( SGNODE* aNode );
|
bool AddChildNode( SGNODE* aNode );
|
||||||
|
|
||||||
bool GetColorList( size_t& aListSize, SGCOLOR*& aColorList );
|
bool GetColorList( size_t& aListSize, SGCOLOR*& aColorList );
|
||||||
void SetColorList( size_t& aListSize, const SGCOLOR* aColorList );
|
void SetColorList( size_t aListSize, const SGCOLOR* aColorList );
|
||||||
void AddColor( double aRedValue, double aGreenValue, double aBlueValue );
|
void AddColor( double aRedValue, double aGreenValue, double aBlueValue );
|
||||||
void AddColor( const SGCOLOR& aColor );
|
void AddColor( const SGCOLOR& aColor );
|
||||||
|
|
||||||
|
|
|
@ -654,7 +654,8 @@ bool SGSHAPE::Prepare( const glm::dmat4* aTransform,
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
std::cerr << " * [INFO] bad model; not enough colors per vertex\n";
|
std::cerr << " * [INFO] bad model; not enough colors per vertex (";
|
||||||
|
std::cerr << nColors << " vs " << nCoords << ")\n";
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -698,7 +699,7 @@ bool SGSHAPE::Prepare( const glm::dmat4* aTransform,
|
||||||
|
|
||||||
if( pc )
|
if( pc )
|
||||||
{
|
{
|
||||||
SFVEC3F* lColors = new SFVEC3F[vertices.size()];
|
lColors = new SFVEC3F[vertices.size()];
|
||||||
m.m_Color = lColors;
|
m.m_Color = lColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,8 +216,8 @@ void WRL2COLOR::GetColor( int aIndex, float& red, float& green, float& blue )
|
||||||
}
|
}
|
||||||
|
|
||||||
red = colors[aIndex].x;
|
red = colors[aIndex].x;
|
||||||
green = colors[aIndex].x;
|
green = colors[aIndex].y;
|
||||||
blue = colors[aIndex].x;
|
blue = colors[aIndex].z;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -855,6 +855,7 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent, bool calcNormals )
|
||||||
{
|
{
|
||||||
IFSG_COLORS nmColor( fsNode );
|
IFSG_COLORS nmColor( fsNode );
|
||||||
nmColor.SetColorList( lColors.size(), &lColors[0] );
|
nmColor.SetColorList( lColors.size(), &lColors[0] );
|
||||||
|
std::cerr << "XXX: colors: " << lColors.size() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sgNode = fsNode.GetRawPtr();
|
m_sgNode = fsNode.GetRawPtr();
|
||||||
|
|
Loading…
Reference in New Issue