示例#1
0
void Level::replaceSquare(Vec2 pos, PSquare square, bool storePrevious) {
  squares[pos]->onConstructNewSquare(square.get());
  Creature* c = squares[pos]->getCreature();
  if (c)
    squares[pos]->removeCreature();
  for (Item* it : copyOf(squares[pos]->getItems()))
    square->dropItem(squares[pos]->removeItem(it));
  addLightSource(pos, squares[pos]->getLightEmission(), -1);
  square->setPosition(pos);
  square->setLevel(this);
  for (PTrigger& t : squares[pos]->removeTriggers())
    square->addTrigger(std::move(t));
  square->setBackground(squares[pos].get());
  if (const Tribe* tribe = squares[pos]->getForbiddenTribe())
    square->forbidMovementForTribe(tribe);
  if (storePrevious)
    oldSquares[pos] = std::move(squares[pos]);
  squares[pos] = std::move(square);
  if (c) {
    squares[pos]->setCreature(c);
  }
  addLightSource(pos, squares[pos]->getLightEmission(), 1);
  updateVisibility(pos);
  squares[pos]->updateSunlightMovement(isInSunlight(pos));
  updateConnectivity(pos);
}
示例#2
0
void Level::updateVisibility(Vec2 changedSquare) {
  for (Vec2 pos : getVisibleTilesNoDarkness(changedSquare, VisionInfo::NORMAL))
    addLightSource(pos, squares[pos]->getLightEmission(), -1);
  for (auto& elem : fieldOfView)
    elem.squareChanged(changedSquare);
  for (Vec2 pos : getVisibleTilesNoDarkness(changedSquare, VisionInfo::NORMAL))
    addLightSource(pos, squares[pos]->getLightEmission(), 1);
}
示例#3
0
/***********************************************************************
     * MapGenerator
     * genSewersDecors

***********************************************************************/
void fired::MapGenerator::genSewersDecors() {
	addDecor(119, 38, "box");
	addDecor(121, 38, "box");
	addDecor(120, 36, "box");

	addDecor(143, 38, "barrel");
	addDecor(148, 38, "barrel");
	addDecor(150, 38, "barrel");

	addLightSource(142, 33, "wall.lamp.red");
	addLightSource(157, 33, "wall.lamp.blue");

	addLightSource(43 , 62, "wall.lamp");
	addLightSource(85 , 62, "wall.lamp");
	addLightSource(64 , 57, "wall.lamp");
}
示例#4
0
void Level::updateVisibility(Vec2 changedSquare) {
  for (Vec2 pos : getVisibleTilesNoDarkness(changedSquare, VisionId::NORMAL)) {
    addLightSource(pos, squares[pos]->getLightEmission(), -1);
    if (Creature* c = squares[pos]->getCreature())
      if (c->isDarknessSource())
        addDarknessSource(pos, darknessRadius, -1);
  }
  for (VisionId vision : ENUM_ALL(VisionId))
    fieldOfView[vision].squareChanged(changedSquare);
  for (Vec2 pos : getVisibleTilesNoDarkness(changedSquare, VisionId::NORMAL)) {
    addLightSource(pos, squares[pos]->getLightEmission(), 1);
    if (Creature* c = squares[pos]->getCreature())
      if (c->isDarknessSource())
        addDarknessSource(pos, darknessRadius, 1);
  }
}
示例#5
0
int PovrayMaker::render()
{
	addCamera();

	addLightSource(scale, scale, scale);

	double axLen=1.5*scale;
	double axThick=0.005*scale;
	addCylinder(0, 0,0,axLen, 0,0, axThick,1);
	addCylinder(0, 0,0,0, axLen,0, axThick,2);
	addCylinder(0, 0,0,0, 0,axLen, axThick,3);

	file->close();

	QFile iniFile(fileName+QString("%1.ini").arg(dnum));

	QString processor("D:\\Program\" \"Files\\POVRAY\\bin\\pvengine /EXIT ");
//	QString processor("notepad ");

	if(iniFile.exists())
		Povray.start(processor+fileName+QString("%1.ini").arg(dnum));
	else
		Povray.start(processor+fileName+QString("%1.pov").arg(dnum));

     if (!Povray.waitForStarted())
         return 1;
     if (!Povray.waitForFinished(-1))
         return 2;

	 if(!file->open(QIODevice::Append  | QIODevice::Text))
		 return 3;
	textOut.setDevice(file);
	 return 0;
}
示例#6
0
void Level::replaceSquare(Vec2 pos, PSquare square) {
  squares[pos]->onConstructNewSquare(square.get());
  Creature* c = squares[pos]->getCreature();
  for (Item* it : squares[pos]->getItems())
    square->dropItem(squares[pos]->removeItem(it));
  addLightSource(pos, squares[pos]->getLightEmission(), -1);
  square->setPosition(pos);
  square->setLevel(this);
  for (PTrigger& t : squares[pos]->removeTriggers())
    square->addTrigger(std::move(t));
  square->setBackground(squares[pos].get());
  squares[pos] = std::move(square);
  if (c) {
    squares[pos]->putCreatureSilently(c);
  }
  addLightSource(pos, squares[pos]->getLightEmission(), 1);
  updateVisibility(pos);
}
示例#7
0
void Level::replaceSquare(Vec2 pos, PSquare square) {
  if (contains(tickingSquares, getSquare(pos)))
    removeElement(tickingSquares, getSquare(pos));
  Creature* c = squares[pos]->getCreature();
  for (Item* it : squares[pos]->getItems())
    square->dropItem(squares[pos]->removeItem(it));
  squares[pos]->onConstructNewSquare(square.get());
  addLightSource(pos, squares[pos]->getLightEmission(), -1);
  square->setCovered(squares[pos]->isCovered());
  square->addLight(squares[pos]->getTotalLight());
  square->setBackground(squares[pos].get());
  squares[pos] = std::move(square);
  squares[pos]->setPosition(pos);
  squares[pos]->setLevel(this);
  if (c) {
    squares[pos]->putCreatureSilently(c);
  }
  addLightSource(pos, squares[pos]->getLightEmission(), 1);
  updateVisibility(pos);
}
示例#8
0
PovrayMaker::~PovrayMaker()
{
	addCamera();

	addLightSource(scale, scale, scale);

	double axLen=1.5*scale;
	double axThick=0.005*scale;
	addCylinder(0, 0,0,axLen, 0,0, axThick,1);
	addCylinder(0, 0,0,0, axLen,0, axThick,2);
	addCylinder(0, 0,0,0, 0,axLen, axThick,3);
}
示例#9
0
Level::Level(Table<PSquare> s, Model* m, vector<Location*> l, const string& message, const string& n,
    Table<CoverInfo> covers) 
    : squares(std::move(s)), locations(l), model(m), entryMessage(message), name(n), coverInfo(std::move(covers)),
      bucketMap(squares.getBounds().getW(), squares.getBounds().getH(), FieldOfView::sightRange),
      lightAmount(squares.getBounds(), 0) {
  for (Vec2 pos : squares.getBounds()) {
    squares[pos]->setLevel(this);
    Optional<pair<StairDirection, StairKey>> link = squares[pos]->getLandingLink();
    if (link)
      landingSquares[*link].push_back(pos);
  }
  for (Location *l : locations)
    l->setLevel(this);
  for (Vision* vision : Vision::getAll())
    fieldOfView.emplace(vision, FieldOfView(squares, vision));
  for (Vec2 pos : squares.getBounds())
    addLightSource(pos, squares[pos]->getLightEmission(), 1);
}
示例#10
0
Level::Level(Table<PSquare> s, Model* m, vector<Location*> l, const string& message, const string& n,
    Table<CoverInfo> covers, int id) 
    : squares(std::move(s)), oldSquares(squares.getBounds()), locations(l), model(m), entryMessage(message),
      name(n), coverInfo(std::move(covers)), bucketMap(squares.getBounds().getW(), squares.getBounds().getH(),
      FieldOfView::sightRange), lightAmount(squares.getBounds(), 0), lightCapAmount(squares.getBounds(), 1),
      levelId(id) {
  for (Vec2 pos : squares.getBounds()) {
    squares[pos]->setLevel(this);
    optional<StairKey> link = squares[pos]->getLandingLink();
    if (link)
      landingSquares[*link].push_back(Position(pos, this));
  }
  for (Location *l : locations)
    l->setLevel(this);
  for (VisionId vision : ENUM_ALL(VisionId))
    fieldOfView[vision] = FieldOfView(squares, vision);
  for (Vec2 pos : squares.getBounds())
    addLightSource(pos, squares[pos]->getLightEmission(), 1);
  updateSunlightMovement();
}
示例#11
0
void Level::removeLightSource(Vec2 pos, double radius) {
  addLightSource(pos, radius, -1);
}
示例#12
0
void Level::addLightSource(Vec2 pos, double radius) {
  addLightSource(pos, radius, 1);
}
示例#13
0
文件: Scene.cpp 项目: Tug/RayTracer
void Scene::addLightSources(std::vector<LightSource *> & lightsources) {
	for(std::vector<LightSource *>::iterator it = lightsources.begin(); it != lightsources.end(); it++) {
		addLightSource(*it);
	}
}
示例#14
0
		GLvoid CLightingManager::addLightSource(vector2i position, string lightSourceName)
		{
			addLightSource(position,lightSourceNameToTypeIndex(lightSourceName));
		}