예제 #1
0
void OgreBuilding::configure()
{
  setAxiom("{BFER}");

  setInitialDirection(Vector(0,0,1));

  floorMaterial   = "Concrete";
  rooftopMaterial = "RoofTop";

  storeyHeight = 20;
  basementHeight = 20;
  spacerHeight = 5;
  tileWidth = 40;
}
예제 #2
0
void RedBuilding::configure()
{
  setAxiom("{BSFER}");

  //addRule('E', "FE");   // Next normal floor
  addRule('E', "LFE");  // Ledge, then floor
  //addRule('E', "R-FE"); // Setbacks

  setInitialDirection(Vector(0,0,1));

  Random generator;
  setMaxHeight(generator.generateInteger(20, 30) * 2.5 * OgreCity::meter);

  setupTextures();
}
예제 #3
0
OrganicRoadPattern::OrganicRoadPattern()
  : RoadLSystem()
{
  setAxiom("[[[-_E]+_E]_E]++_E");

  // Rules
  addRule('E', "[[-_E]+_E]_E");
//   addRule('E', "[[-_E]+_E]");
//   addRule('E', "_E");

  setInitialPosition(Point(0,0));
  setInitialDirection(Vector(1,0));

  setTurnAngle(60, 90);
}
예제 #4
0
GraphicLSystem::GraphicLSystem()
  : LSystem(), cursor(), graphicInformationForSymbols(0)
{
  graphicInformationForSymbols = new std::map<Symbol*, GraphicInformation*>;

  /* Symbols:
   *  [ - push current position
   *  ] - pop current position
   *  . - draw point
   *  _ - draw line forward FIXME of what length?
   */
  setAlphabet("[]._");

  // FIXME set axiom and copy it to producedString
  setAxiom(".");
}
// I/O
bool
	LSystem::Load( char* file)
{
	// STRUCTURE OF LSYS FILE:
	// =================
	// recursion levels separated by '-'
	// basic angle
	// thickness
	// lenght
	// PointSprites sizes separated by '-'
	// axiom
	// all other lines are rulez until "@" line
	unsigned long position = 0;
	string line;
	int val;
	float fval;

	ifstream f;

	// try to open the file
	f.open( file);
	if( ! f.good() )
		return false;

	////////////////////////////////
	// first we try to load recurse level	s
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	unsigned int j= 0;
	for( int i= 0; i< NUM_LVLS; i++)
	{
		val = 0;

		// check if there is what to load
		if( j > line.size( ) )
			return false;

		while( ( j < 8) && isdigit( line[ j]) )
		{
			val = ( val * 10) + line[ j] - '0';
			j++;
		}

		// recurson level
		m_recursionLevels[ i] = val;

		// if non zero increase active levels
		if( val)
			m_activeLevels++;

		// skip separator
		j++;
	}


	// check if there is at least nonzero in the first recLevel
	if( !m_recursionLevels[ 0])
		return false;

	////////////////////////////////
	// then m_defaultAngle
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	fval = ( float)atof( &line[ 0]);
	if( fval > 0)
		m_defaultAngle = fval;
	else
		return false;

	////////////////////////////////
	// then m_defaultThickness
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	fval = ( float)atof( &line[ 0]);
	if( fval > 0)
		m_defaultThick = fval;
	else
		return false;

	////////////////////////////////
	// default lenght
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	fval = ( float)atof( &line[ 0]);
	if( fval > 0)
		m_defLenght = fval;
	else
		return false;

	////////////////////////////////
	// PS Sizes
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	char tmp[ 32];
	j = 0;
	int k = 0;

	for( int i= 0; i< 4; i++)
	{
		while( ( j< line.size( )) && line[ j] != '-')
		{
			tmp[ k] = line[ j];
			k++; j++;
		}
		tmp[ k] = 0;

		// PS Size
		m_PSSizes[ i] = ( float)atof( tmp);

		// skip separator
		j++;

		k = 0;		
	}

	////////////////////////////////
	// AXIOM
	////////////////////////////////
	line.clear( );
	line = getLine( &f);
	// check if there is end of file
	if( line.size( ) == 0)
		return false;

	// are there any space? If yes then error
	for( unsigned int j= 0; j< line.size( ); j++)
		if( ( line[ j] == ' ') && ( line[ j] == '\n') && ( line[ j] == '\t') )
			return false;

	setAxiom( line);

	if( ! LoadRules( &f))
		return false;

	// close the file
	f.close( );
	
	return true;
}