Beispiel #1
0
void Scene::_parseViewPlane( ){
	size_t w, h, s;
  double p;
	_nextToken( );
	_checkToken( "ViewPlane");
	_nextToken( );
	_checkToken( "{");
	_nextToken( );
	_checkToken( "width");
	_nextToken( );
	w = _parseInt( );

	_nextToken( );
	_checkToken( "height" );
	_nextToken( );
	h = _parseInt( );

	_nextToken( );
	_checkToken( "pixelsize" );
	_nextToken( );
	p = _parseFloat( );
	
  _nextToken( );
  _checkToken( "sampleCount" );
  _nextToken( );
  s = _parseInt( );

	_nextToken( );
	_checkToken( "}" );

  // Fill me in!
}
Beispiel #2
0
void Scene::_parseMaterials( ){
  _nextToken( );
  _checkToken( "Materials" );
  _nextToken( );
  _checkToken( "{");
  _nextToken( );
  _checkToken( "numMaterials" );
  _nextToken( );
  int materialCount = _parseInt( );
  for( int i = 0; i < materialCount; i++ ){
    _nextToken( );

    if( std::strcmp( _currentToken, "PhongMaterial") == 0 ){
      _parsePhongMaterial(i);
    }else if( std::strcmp( _currentToken, "SomeOtherMaterial") == 0 ){
      assert(0 == 1);
    }else if( std::strcmp( _currentToken, "AnotherMaterial") == 0 ){
      assert(0 == 1);
    }else{
      _checkToken( "PhongMaterial | tbd");
    }
  }
  _nextToken( );
  _checkToken("}");
}
Beispiel #3
0
void Scene::_parseLights( ){
  _nextToken( );
  _checkToken( "Lights" );
  _nextToken( );
  _checkToken( "{");
  _nextToken( );
  _checkToken( "numLights" );
  _nextToken( );
  int lightCount = _parseInt( );
  for( int i = 0; i < lightCount; i++ ){
    _nextToken( );

    if( std::strcmp( _currentToken, "PointLight") == 0 ){
      _parsePointLight(i);
    }else if( std::strcmp( _currentToken, "DirectionalLight") == 0 ){
      _parseDirectionalLight(i);
    }else if( std::strcmp( _currentToken, "SomeOtherLight") == 0 ){
      assert(0 == 1);
    }else{
      _checkToken("PointLight | DirectionalLight");
    }
  }
  _nextToken( );
  _checkToken("}");
}
Beispiel #4
0
int OptionManager::_parseBool (const char *str, int &val)
{
   if (strcasecmp(str, "true") == 0 || strcasecmp(str, "on") == 0 ||
       strcasecmp(str, "yes") == 0) {
      val = 1;
      return 1;
   } else if (strcasecmp(str, "false") == 0 || strcasecmp(str, "off") == 0 ||
              strcasecmp(str, "no") == 0) {
      val = 0;
      return 1;
   } else
      return _parseInt(str, val);
}
Beispiel #5
0
void OptionManager::callOptionHandler (const char* name, const char* value) {
   if (!typeMap.find(name))
      throw Error("Property \"%s\" not defined", name);
   OPTION_TYPE type = typeMap.at(name);
   int x = 0, y = 0;
   float f = 0, r = 0, g = 0, b = 0;
   switch (type)
   {
   case OPTION_STRING:
      stringSetters.at(name)(value);
      break;
   case OPTION_INT:
      if (_parseInt(value, x) < 0)
         throw Error("Cannot recognize \"%s\" as an integer value", value);
      intSetters.at(name)(x);
      break;
   case OPTION_BOOL:
      if (_parseBool(value, x) < 0)
         throw Error("Cannot recognize \"%s\" as a boolean value", value);
      boolSetters.at(name)(x);
      break;
   case OPTION_FLOAT:
      if (_parseFloat(value, f) < 0)
         throw Error("Cannot recognize \"%s\" as a float value", value);
      floatSetters.at(name)(f);
      break;
   case OPTION_COLOR:
      if (_parseColor(value, r, g, b) < 0)
         throw Error("Cannot recognize \"%s\" as a color value", value);
      colorSetters.at(name)(r, g, b);
      break;
   case OPTION_XY:
      if (_parseSize(value, x, y) < 0)
         throw Error("Cannot recognize \"%s\" as a pair of integers", value);
      xySetters.at(name)(x, y);
      break;
   default:
      throw Error("Option type not supported");
   }
}
Beispiel #6
0
void Scene::_parseGroup( ){
	_nextToken( );
	_checkToken( "Group" );
	_nextToken( );
	_checkToken( "{");
	_nextToken( );
	_checkToken( "numObjects" );
  _nextToken( );
  int objectCount = _parseInt( );
  int i = 0;
  _nextToken( );
  while( i < objectCount ){
    if( std::strcmp( _currentToken, "MaterialIndex") == 0 ){
      _parseMaterialIndex( );
    }else if( std::strcmp( _currentToken, "Group") == 0 ){
      assert(0 == 1);
      _parseGroup( );
      i += 1;
    }else if( std::strcmp( _currentToken, "Transform") == 0 ){
      assert(0 == 1);
    }else if( std::strcmp( _currentToken, "Sphere") == 0 ){
      _parseSphere(i);
      i += 1;
    }else if( std::strcmp( _currentToken, "Plane") == 0 ){
      assert(0 == 1);
      i += 1;
    }else if( std::strcmp( _currentToken, "Triangle") == 0 ){
      assert(0 == 1);
      i += 1;
    }else if( std::strcmp( _currentToken, "TriangleMesh") == 0 ){
      assert(0 == 1);
      i += 1;
    }else{
      _checkToken( "Group | tbd");
    }
    _nextToken( );
  }
}
Beispiel #7
0
JValue* Parser::_parseValue() {
    switch(_cur_token.type()) {
        case TT_STRING:
            return _parseString();
        case TT_INTEGER:
            return _parseInt();
        case TT_REAL:
            return _parseReal();
        case TT_TRUE:
            return _parseTrue();
        case TT_FALSE:
            return _parseFalse();
        case TT_NULL:
            return _parseNull();
        case TT_ARRAY_OPEN_BRACE:
            return _parseArray();
        case TT_OBJECT_OPEN_BRACE:
            return _parseObject();
        default:
            _err = _instream->error();
            return NULL;
    }
}
void BMDVideohubClient::_parseline()	{
	int inputNum;
	int outputNum;
	int portNum;
	
	if (!strcmp(_linebuffer,""))	{
		_section = 0;
	} else if (!strcmp_P(_linebuffer,PSTR("PROTOCOL PREAMBLE:")))	{		//strcmp_P("RAM STRING", PSTR("FLASH STRING"));
		_section = 1;
	} else if (!strcmp_P(_linebuffer,PSTR("VIDEOHUB DEVICE:")))	{
		_section = 2;
	} 

	/*else if (!strcmp_P(_linebuffer,PSTR("INPUT LABELS:")))	{
		_section = 3;
	} else if (!strcmp_P(_linebuffer,PSTR("OUTPUT LABELS:")))	{
		_section = 4;
	} */

	  else if (!strcmp_P(_linebuffer,PSTR("VIDEO OUTPUT LOCKS:")))	{
		_section = 5;
	} else if (!strcmp_P(_linebuffer,PSTR("VIDEO OUTPUT ROUTING:")))	{
		_section = 6;
	} else {
		_linebufferParsePointer=0;
		switch(_section)	{
			case 2: 	// VIDEOHUB DEVICE
				if (_isFirstPartOfLinebuffer("Device present:"))	{
					_linebufferParsePointer+=15+1;
					_devicePresent = _isFirstPartOfLinebuffer("true");
				}
				if (_isFirstPartOfLinebuffer("Video inputs:"))	{
					_linebufferParsePointer+=13+1;
					_numInputs = _parseInt();
				}
				/*if (_isFirstPartOfLinebuffer("Video processing units:"))	{
					_linebufferParsePointer+=23+1;
					_numProcUnits = _parseInt();
				}*/
				if (_isFirstPartOfLinebuffer("Video outputs:"))	{
					_linebufferParsePointer+=14+1;
					_numOutputs = _parseInt();
				}
				/*if (_isFirstPartOfLinebuffer("Video monitoring outputs:"))	{
					_linebufferParsePointer+=25+1;
					_numMonOutputs = _parseInt();
				}*/
				/*if (_isFirstPartOfLinebuffer("Serial ports:"))	{
					_linebufferParsePointer+=13+1;
					_serialPorts = _parseInt();
				}*/
			break;
			case 3: 	// INPUT LABELS
                break;
			case 4:/* 	// OUTPUT LABELS
				portNum = _parseInt();
				if (portNum>=0 && portNum<=15)	{
					_linebufferParsePointer++;
					while(_linebufferParsePointer < _linebufferPointer)	{
						// Here: Traverse every char ofthe label.
						// For future implementation when I know where to store this information! Too little memory.
						//						Serial.print(_linebuffer[_linebufferParsePointer]);
						_linebufferParsePointer++;
					}
				}*/
			break;
			case 5: 	// VIDEO OUTPUT LOCKS
				outputNum = _parseInt();
				if (outputNum>=0 && outputNum<=_numOutputs-1)	{
					_outputLocks[outputNum] = _linebuffer[_linebufferParsePointer+1];
				}
			break;
			case 6: 	// VIDEO OUTPUT ROUTING
				outputNum = _parseInt();
				if (outputNum>=0 && outputNum<=39)	{
					_linebufferParsePointer++;	// Advance 
					inputNum = _parseInt();
					if (inputNum>=0 && inputNum<=39)	{
						_outputRouting[outputNum] = inputNum;
					}
				}
			break;
		}	
	}	
}
Beispiel #9
0
void Scene::_parseMaterialIndex( ){
  _checkToken( "MaterialIndex");
  _nextToken( );
  _currentMaterialIndex = _parseInt( );
}
/**
 * Parses a line from client
 */
void BMDSmartViewClient::_parseline()	{
	
	if (!strcmp(_linebuffer,""))	{
		_section = 0;
	} else if (!strcmp_P(_linebuffer,PSTR("PROTOCOL PREAMBLE:")))	{		//strcmp_P("RAM STRING", PSTR("FLASH STRING"));
		_section = 1;
	} else if (!strcmp_P(_linebuffer,PSTR("SMARTVIEW DEVICE:")))	{
		_section = 2;
	} else if (!strcmp_P(_linebuffer,PSTR("NETWORK:")))	{
		_section = 3;
	} else if (!strcmp_P(_linebuffer,PSTR("MONITOR A:")))	{
		_section = 4;
	} else if (!strcmp_P(_linebuffer,PSTR("MONITOR B:")))	{
		_section = 5;
	} else {

		_linebufferParsePointer = 0;

		switch(_section)	{
			case 4: 	// Monitor A or B:
			case 5:
				if (_isFirstPartOfLinebuffer_P(PSTR("Brightness:")))	{
					_linebufferParsePointer+=11+1;
					_Smart_brightness[_section-4] = _parseInt();
				}
				
				if (_isFirstPartOfLinebuffer_P(PSTR("Contrast:")))	{
					_linebufferParsePointer+=9+1;
					_Smart_contrast[_section-4] = _parseInt();
				}
				
				if (_isFirstPartOfLinebuffer_P(PSTR("Saturation:")))	{
					_linebufferParsePointer+=11+1;
					_Smart_saturation[_section-4] = _parseInt();
				}

				if (_isFirstPartOfLinebuffer_P(PSTR("Identify:")))	{
					_linebufferParsePointer+=9+1;
					if (_isFirstPartOfLinebuffer_P(PSTR("true")))	{
						_Smart_identify[_section-4] = true;
					} else {
						_Smart_identify[_section-4] = false;
					}
				}

				if (_isFirstPartOfLinebuffer_P(PSTR("Border:")))	{
					_linebufferParsePointer+=7+1;
					if (_isFirstPartOfLinebuffer_P(PSTR("None")))	{
						_Smart_border[_section-4] = 0;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("Red")))	{
						_Smart_border[_section-4] = 1;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("Green")))	{
						_Smart_border[_section-4] = 2;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("Blue")))	{
						_Smart_border[_section-4] = 3;
/*					} else if (_isFirstPartOfLinebuffer_P(PSTR("White")))	{	// Doesn't work yet?
						_Smart_border[_section-4] = 4;
*/					} else {
						_Smart_border[_section-4] = 255;
					}
				}

				if (_isFirstPartOfLinebuffer_P(PSTR("WidescreenSD:")))	{
					_linebufferParsePointer+=13+1;
					if (_isFirstPartOfLinebuffer_P(PSTR("auto")))	{
						_Smart_widescreenSD[_section-4] = 0;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("on")))	{
						_Smart_widescreenSD[_section-4] = 1;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("off")))	{
						_Smart_widescreenSD[_section-4] = 2;
					} else {
						_Smart_widescreenSD[_section-4] = 255;
					}
				}

				if (_isFirstPartOfLinebuffer_P(PSTR("ScopeMode:")))	{
					_linebufferParsePointer+=10+1;
					if (_isFirstPartOfLinebuffer_P(PSTR("Picture")))	{
						_Smart_scopeMode[_section-4] = 0;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("AudioDbfs")))	{
						_Smart_scopeMode[_section-4] = 1;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("AudioDbvu")))	{
						_Smart_scopeMode[_section-4] = 2;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("Histogram")))	{
						_Smart_scopeMode[_section-4] = 3;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("ParadeRGB")))	{
						_Smart_scopeMode[_section-4] = 4;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("ParadeYUV")))	{
						_Smart_scopeMode[_section-4] = 5;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("Vector100")))	{
						_Smart_scopeMode[_section-4] = 6;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("Vector75")))	{
						_Smart_scopeMode[_section-4] = 7;
					} else if (_isFirstPartOfLinebuffer_P(PSTR("WaveformLuma")))	{
						_Smart_scopeMode[_section-4] = 8;
					} else {
						_Smart_scopeMode[_section-4] = 255;
					}
				}
				
				if (_isFirstPartOfLinebuffer_P(PSTR("AudioChannel:")))	{
					_linebufferParsePointer+=13+1;
					_Smart_audioChannel[_section-4] = _parseInt();
				}
			break;
		}
	}
	
		// Content parsing:
	if (_serialOutput) Serial.print(_section);
	if (_serialOutput) Serial.print(F(": "));
	if (_serialOutput) Serial.println(_linebuffer);
	
	_resetLastIncomingMsg();
}