devel/CSGLib/src/Solid.cpp
/**
 * Loads a coordinates file, setting vertices and indices 
 * 
 * @param solidFile file used to create the solid
 * @param color solid color
 */
Loads a coordinates file, setting vertices and indices

@param solidFile file used to create the solid
@param color solid color
Loads a coordinates file setting vertices and indices @param solidFile file used to create the solid @param color solid color
void Solid::loadCoordinateFile(const std::string & sFileName, const gxColor & colBase, int dRed, int dGreen, int dBlue)
{
	std::ifstream modelFile;
	modelFile.open(sFileName.c_str());
	g_nSolidLoadCount++;
	int nNumVertices = 0;
	modelFile >> nNumVertices;
	for(int i = 0; i < nNumVertices; i++)
	{
		int nVertexID = 0;
		mlVector3D vPosition;
		modelFile >> nVertexID;
		modelFile >> vPosition.x;
		modelFile >> vPosition.y;
		modelFile >> vPosition.z;
		vertices.AddVector(vPosition);
	}
	int nNumTriangles = 0;
	modelFile >> nNumTriangles;
	for(int i = 0; i < nNumTriangles; i++)
	{
		int nTriangleID = 0;
		int nTriIndex1 = 0;
		int nTriIndex2 = 0;
		int nTriIndex3 = 0;
		modelFile >> nTriangleID;
		modelFile >> nTriIndex1;
		modelFile >> nTriIndex2;
		modelFile >> nTriIndex3;
		indices.AddInt(nTriIndex1);
		indices.AddInt(nTriIndex2);
		indices.AddInt(nTriIndex3);
	}
	modelFile.close();
	for(int i = 0; i < nNumVertices; i++)
	{
		gxColor col = colBase;
		if(dRed < 0) col.red -= rand() % (-1*dRed); else if(dRed > 0) col.red += rand() % dRed;
		if(dGreen < 0) col.green -= rand() % (-1*dGreen); else if(dGreen > 0) col.green += rand() % dGreen;
		if(dBlue < 0) col.blue -= rand() % (-1*dBlue); else if(dBlue > 0) col.blue += rand() % dBlue;
		colors.AddColor(col);
	}
	defineGeometry();
}
void Solid :: loadCoordinateFile ( const std :: string & sFileName , const gxColor & colBase , int dRed , int dGreen , int dBlue ) { std :: ifstream modelFile ; modelFile . open ( sFileName . c_str ( ) ) ; g_nSolidLoadCount ++ ; int nNumVertices = 0 ; modelFile >> nNumVertices ; for ( int i = 0 ; i < nNumVertices ; i ++ ) { int nVertexID = 0 ; mlVector3D vPosition ; modelFile >> nVertexID ; modelFile >> vPosition . x ; modelFile >> vPosition . y ; modelFile >> vPosition . z ; vertices . AddVector ( vPosition ) ; } int nNumTriangles = 0 ; modelFile >> nNumTriangles ; for ( int i = 0 ; i < nNumTriangles ; i ++ ) { int nTriangleID = 0 ; int nTriIndex1 = 0 ; int nTriIndex2 = 0 ; int nTriIndex3 = 0 ; modelFile >> nTriangleID ; modelFile >> nTriIndex1 ; modelFile >> nTriIndex2 ; modelFile >> nTriIndex3 ; indices . AddInt ( nTriIndex1 ) ; indices . AddInt ( nTriIndex2 ) ; indices . AddInt ( nTriIndex3 ) ; } modelFile . close ( ) ; for ( int i = 0 ; i < nNumVertices ; i ++ ) { gxColor col = colBase ; if ( dRed < 0 ) col . red -= rand ( ) % ( -1 * dRed ) ; else if ( dRed > 0 ) col . red += rand ( ) % dRed ; if ( dGreen < 0 ) col . green -= rand ( ) % ( -1 * dGreen ) ; else if ( dGreen > 0 ) col . green += rand ( ) % dGreen ; if ( dBlue < 0 ) col . blue -= rand ( ) % ( -1 * dBlue ) ; else if ( dBlue > 0 ) col . blue += rand ( ) % dBlue ; colors . AddColor ( col ) ; } defineGeometry ( ) ; }
Loads a coordinates file, setting vertices and indices
Loads a coordinates file setting vertices and indices
// Read in a vector. // Now load up the indices.