Пример #1
0
void Shape::configure() {
	if (m_bsdf == NULL) {
		ref<BSDF> bsdf = NULL;
		if (isEmitter() || isSensor() || hasSubsurface()) {
			/* Light source / sensor and no BSDF! -> set an all-absorbing BSDF */
			Properties props("diffuse");
			props.setSpectrum("reflectance", Spectrum(0.0f));
			bsdf = static_cast<BSDF *> (PluginManager::getInstance()->
				createObject(MTS_CLASS(BSDF), props));
		} else if (!isMediumTransition()) {
			/* A surface without BSDF, which is not a medium
			   transition/sensor/emitter/subsurface emitter doesn't make
			   much sense. Assign it a 0.5 Lambertian BRDF for convenience */
			Properties props("diffuse");
			props.setSpectrum("reflectance", Spectrum(0.5f));
			bsdf = static_cast<BSDF *> (PluginManager::getInstance()->
				createObject(MTS_CLASS(BSDF), props));
		} else {
			/* Assign a "null" BSDF */
			bsdf = static_cast<BSDF *> (PluginManager::getInstance()->
				createObject(MTS_CLASS(BSDF), Properties("null")));
		}
		bsdf->configure();
		addChild(bsdf);
	}

	if ((m_bsdf->getType() & BSDF::ENull) && (isEmitter() || isSensor() || hasSubsurface()))
		Log(EError, "Shape \"%s\" has an index-matched BSDF and an "
			"emitter/sensor/subsurface attachment. This is not allowed!", getName().c_str());
}
Пример #2
0
struct tankdef
readTankFromDir(char* path) {
  DIR* dp;
  if( (dp=opendir(path))==NULL ) {
    perror(path);
    exit(1);
  }

  struct tankdef theTank;
  initTank(&theTank);
  struct dirent* files;
  while( (files=readdir(dp)) != NULL ) {
    if( isNotRealDir(files) ) {
      continue;
    }
    char file[1000];
    sprintf(file, "%s/%s", path, files->d_name);
    if( isSensor(files->d_name) ) {
      int sensorId = files->d_name[strlen("sensor")]-'0';
      theTank.sensors[sensorId] = parseSensor(file);
    } else if( strcmp(files->d_name, "name") == MATCH ) {
      loadFileContent( theTank.name, file, max_size(NAME) );
    } else if( strcmp(files->d_name, "author") == MATCH ) {
      loadFileContent( theTank.author, file, max_size(AUTHOR) );
    } else if( strcmp(files->d_name, "program") == MATCH ) {
      loadFileContent( theTank.program, file, max_size(PROGRAM) );
    } else if( strcmp(files->d_name, "color") == MATCH ) {
      loadFileContent( theTank.color, file, max_size(COLOR) );
    }
  }
  closedir(dp);
  return theTank;
}
Пример #3
0
QString base_writer::write ( const Tiled::MapObject* pObj, int mapHeight, int mapWidth ) const {
    Q_UNUSED(mapWidth);
    return
        "\n<key>" + pObj->type() + pObj->name() + "</key>\n"
        + "<dict>\n"

        + buildFromValue ( x(), QString::number ( pObj->x() ), "real" )
        + buildFromValue ( y(), QString::number ( mapHeight - pObj->y() ), "real" )
        + buildFromProp  ( isSensor(), pObj->properties(), "" )
        + buildFromProp  ( isStatic(), pObj->properties(), "" )
        + buildFromProp  ( texture(),  pObj->properties(), "string"  )
        + buildFromProp  ( body(),	   pObj->properties(), "string"  )
        + buildFromProp  ( id(),	   pObj->properties(), "integer" )
        + auxParams ( pObj )

        + "</dict>\n";
}