void CloudsVisualSystemPaintBrush::selfInteractionStarted(CloudsInteractionEventArgs& args)
{
    Brush * newBrush;
    if (brushes.find(args.playerId) == brushes.end()) {
        // build a new Brush
        newBrush = new Brush();
        brushes[args.playerId] = newBrush;
    }
    else {
        ofLogError("PaintBrush::selfInteractionStarted") << "Brush " << args.playerId << " already exists!";
        newBrush = brushes[args.playerId];
    }
    
	newBrush->init(brushNumber);
    newBrush->setBrushWidth(brushWidth);
    newBrush->setLineWidth(lineWidth);
    
    newBrush->damp = brushDamp;
    newBrush->k = brushK;
    newBrush->repPct = brushRepPct;
    newBrush->repRad = brushRepRad;
    
    newBrush->begin();
    newBrush->set(args.position.x,args.position.y);
}
Beispiel #2
0
bool Brush_hasShader(const Brush& brush, const char* name)
{
  for(Brush::const_iterator i = brush.begin(); i != brush.end(); ++i)
  {
    if(shader_equal((*i)->GetShader(), name))
    {
      return true;
    }
  }
  return false;
}
Beispiel #3
0
BrushSplitType Brush_classifyPlane(const Brush& brush, const Plane3& plane) {
	brush.evaluateBRep();

	BrushSplitType split;
	for (Brush::const_iterator i(brush.begin()); i != brush.end(); ++i) {
		if ((*i)->contributes()) {
			split += (*i)->getWinding().classifyPlane(plane);
		}
	}

	return split;
}
void BrushByPlaneClipper::getMostUsedTexturing(const Brush& brush) const
{
	// Intercept this call to apply caulk to all faces when the registry key is set
	if (_useCaulk)
	{
		_mostUsedShader =  _caulkShader;
		return;
	}

	std::map<std::string, int> shaderCount;
	_mostUsedShader = "";
	int mostUsedShaderCount(0);
	_mostUsedProjection = TextureProjection();

	// greebo: Get the most used shader of this brush
	for (Brush::const_iterator i = brush.begin(); i != brush.end(); ++i)
	{
		// Get the shadername
		const std::string& shader = (*i)->getShader();

		// Insert counter, if necessary
		if (shaderCount.find(shader) == shaderCount.end()) {
			shaderCount[shader] = 0;
		}

		// Increase the counter
		shaderCount[shader]++;

		if (shaderCount[shader] > mostUsedShaderCount) {
			_mostUsedShader = shader;
			mostUsedShaderCount = shaderCount[shader];

			// Copy the TexDef from the face into the local member
			(*i)->GetTexdef(_mostUsedProjection);
		}
	}

	// Fall back to the default shader, if nothing found
	if (_mostUsedShader.empty() || mostUsedShaderCount == 1)
	{
		_mostUsedShader = GlobalTextureBrowser().getSelectedShader();
		_mostUsedProjection = _projection;
	}
}
Beispiel #5
0
// Returns true if fragments have been inserted into the given ret_fragments list
bool Brush_subtract(const BrushNodePtr& brush, const Brush& other, BrushPtrVector& ret_fragments)
{
	if (brush->getBrush().localAABB().intersects(other.localAABB()))
	{
		BrushPtrVector fragments;
		fragments.reserve(other.getNumFaces());

		BrushNodePtr back = std::dynamic_pointer_cast<BrushNode>(brush->clone());

		for (Brush::const_iterator i(other.begin()); i != other.end(); ++i)
		{
			const Face& face = *(*i);

			if (!face.contributes()) continue;

			BrushSplitType split = Brush_classifyPlane(back->getBrush(), face.plane3());

			if (split.counts[ePlaneFront] != 0 && split.counts[ePlaneBack] != 0)
			{
				fragments.push_back(std::dynamic_pointer_cast<BrushNode>(back->clone()));

				FacePtr newFace = fragments.back()->getBrush().addFace(face);

				if (newFace != 0)
				{
					newFace->flipWinding();
				}

				back->getBrush().addFace(face);
			}
			else if (split.counts[ePlaneBack] == 0)
			{
				return false;
			}
		}

		ret_fragments.insert(ret_fragments.end(), fragments.begin(), fragments.end());
		return true;
	}

	return false;
}