示例#1
0
void BoardTransition::addMove(const Square& source, const Square& target)
{
	Move move = { source, target };
	m_moves.append(move);

	addSquare(source);
	addSquare(target);
}
/*public*/
void
OffsetCurveBuilder::getLineCurve(const CoordinateSequence *inputPts,
		double distance, vector<CoordinateSequence*>& lineList)
{
	// a zero or negative width buffer of a line/point is empty
	if (distance<= 0.0) return;

	init(distance);

	if (inputPts->getSize() <= 1) {
		switch (bufParams.getEndCapStyle()) {
			case BufferParameters::CAP_ROUND:
				addCircle(inputPts->getAt(0), distance);
				break;
			case BufferParameters::CAP_SQUARE:
				addSquare(inputPts->getAt(0), distance);
				break;
			default:
				// default is for buffer to be empty
				// (e.g. for a butt line cap);
				break;
		}
	} else {
		computeLineBufferCurve(*inputPts);
	}

	// NOTE: we take ownership of lineCoord here ...
	CoordinateSequence *lineCoord=vertexList->getCoordinates();

	// ... and we give it away here
	lineList.push_back(lineCoord);
}
示例#3
0
/*public*/
void
OffsetCurveBuilder::getLineCurve(const CoordinateSequence *inputPts,
		double distance, vector<CoordinateSequence*>& lineList)
{
	// a zero or negative width buffer of a line/point is empty
	if (distance<= 0.0) return;

	init(distance);

	if (inputPts->getSize() < 2) {
		switch (endCapStyle) {
			case BufferOp::CAP_ROUND:
				addCircle(inputPts->getAt(0), distance);
				break;
			case BufferOp::CAP_SQUARE:
				addSquare(inputPts->getAt(0), distance);
				break;
			// default is for buffer to be empty (e.g. for a butt line cap);
		}
	} else {
		computeLineBufferCurve(*inputPts);
	}
	CoordinateSequence *lineCoord=vertexList->getCoordinates();
	lineList.push_back(lineCoord);
}
示例#4
0
void BoardTransition::addDrop(const Piece& piece, const Square& target)
{
	Drop drop = { piece, target };
	m_drops.append(drop);

	addSquare(target);
	addReservePiece(piece);
}
示例#5
0
void
addSquareCentered(Occluder * pOcc, float x, float y, float z, float w, float h, float d)
{
    x -= w / 2.0f;
    y -= h / 2.0f;
    z -= d / 2.0f;

    addSquare(pOcc, x, y, z, w, h, d);
}
示例#6
0
	void Terrain2D::addRoad(ZombieEntry tileEntry) {
		Position position = loadPoint(tileEntry.getChildEntry("geom").getString());
		std::string tileId = tileEntry.getChildEntry("tile_id").getString();
		int deg = tileEntry.getChildEntry("rotation").getInt();
		float size = tileEntry.getChildEntry("size").getFloat();
		mw::Sprite sprite;
		if (tileId == "turn") {
			switch (deg) {
				case 0:
					sprite = turn0_;
					break;
				case 90:
					sprite = turn90_;
					break;
				case 180:
					sprite = turn180_;
					break;
				case 270:
					sprite = turn270_;
					break;
			}
		} else if (tileId == "straight") {
			switch (deg) {
				case 0:
					sprite = straight0_;
					break;
				case 90:
					sprite = straight90_;
					break;
			}
		} else if (tileId == "tintersection") {
			switch (deg) {
				case 0:
					sprite = tintersection0_;
					break;
				case 90:
					sprite = tintersection90_;
					break;
				case 180:
					sprite = tintersection180_;
					break;
				case 270:
					sprite = tintersection270_;
					break;
			}
		} else { //if (tileId == "intersection") {
			sprite = intersection_;
		}
		
		// 4 float/vertices * 6 vertices.
		std::array<GLfloat, 4 * 6> data_;

		int index = 0;
		addSquare(data_.data(), index, position.x - size*0.5f, position.y - size*0.5f, size, size, sprite);
		roads_.insert(roads_.end(), data_.begin(), data_.end());
		numberVerticesRoads_ += 6;
	}
Reflectable* DeploymentZoneMetaClass::deserialize(const YAML::Node& in) const
{
    auto deploymentZone = new DeploymentZone();

    YAML::Node squareNodes = in["zone_"];
    for(auto squareNode : squareNodes)
    {
        deploymentZone->addSquare({squareNode["x"].as<int>(), squareNode["y"].as<int>()});
    }
    deploymentZone->setPlayerId(in["playerId"].as<int>());

    return deploymentZone;
}
示例#8
0
void Cylinder::initShape()
{
	auto getCylinderX = [&](const float theta) {
		return radius * cos(theta);
	};
	auto getCylinderY = [&](const float theta) {
		return radius * sin(theta);
	};
	auto getCylinderZ = [&](const float height) {
		return height;
	};

	for (int v = 0; v < heightDivisions; v++) {
		for (int u = 0; u < radialDivisions; u++) {
			float t0 = glm::mix(0.0f, TWO_PI, (u) / float(radialDivisions)),
				t1 = glm::mix(0.0f, TWO_PI, (u + 1) / float(radialDivisions)),
				h0 = glm::mix(-0.5f, 0.5f, (v) / float(heightDivisions)),
				h1 = glm::mix(-0.5f, 0.5f, (v + 1) / float(heightDivisions)),
				u0 = glm::mix(0.0f, 1.0f, u / float(radialDivisions)),
				u1 = glm::mix(0.0f, 1.0f, (u + 1) / float(radialDivisions)),
				v0 = glm::mix(0.0f, 1.0f, v / float(heightDivisions)),
				v1 = glm::mix(0.0f, 1.0f, (v + 1) / float(heightDivisions));

			Vertex vert0, vert1, vert2, vert3;
			vert0.position = { getCylinderX(t0), getCylinderY(t0), getCylinderZ(h0) };
			vert0.normal = {};
			vert0.texCoords = { u0, v0 };

			vert1.position = { getCylinderX(t1), getCylinderY(t1), getCylinderZ(h0) };
			vert1.normal = {};
			vert1.texCoords = { u1, v0 };

			vert2.position = { getCylinderX(t0), getCylinderY(t0), getCylinderZ(h1) };
			vert2.normal = {};
			vert2.texCoords = { u1, v1 };

			vert3.position = { getCylinderX(t1), getCylinderY(t1), getCylinderZ(h1) };
			vert3.normal = {};
			vert3.texCoords = { u0, v1 };

			addSquare(vert0, vert1, vert2, vert3);
		}
	}
	for (int u = 0; u < radialDivisions; u++) {
		float t0 = glm::mix(0.0f, TWO_PI, (u) / float(radialDivisions)),
			t1 = glm::mix(0.0f, TWO_PI, (u + 1) / float(radialDivisions)),
			u0 = glm::mix(0.0f, 1.0f, u / float(radialDivisions)),
			u1 = glm::mix(0.0f, 1.0f, (u + 1) / float(radialDivisions));

		Vertex vert0, vert1, vert2, vert3;
		vert0.position = { 0.0f, 0.0f, 0.5f };
		vert0.normal = {};
		vert0.texCoords = { u0, u0 };

		vert1.position = { getCylinderX(t0), getCylinderY(t0), 0.5f };
		vert1.normal = {};
		vert1.texCoords = { u0, u1 };

		vert2.position = { getCylinderX(t1), getCylinderY(t1), 0.5f };
		vert2.normal = {};
		vert2.texCoords = { u1, u1 };

		addTriangle(vert0, vert1, vert2);
		vert0.position.z = vert1.position.z = vert2.position.z = -0.5f;
		addTriangle(vert0, vert1, vert2);
	}
}