bool LoadDrawable::operator()(
	const std::string & meshname,
	const std::vector<std::string> & texname,
	const PTree & cfg,
	SCENENODE & topnode,
	keyed_container<SCENENODE>::handle * nodeptr,
	keyed_container<DRAWABLE>::handle * drawptr)
{
	DRAWABLE drawable;

	// set textures
	TEXTUREINFO texinfo;
	texinfo.mipmap = true;
	texinfo.anisotropy = anisotropy;
	std::tr1::shared_ptr<TEXTURE> tex;
	if (texname.size() == 0)
	{
		error << "No texture defined" << std::endl;
		return false;
	}
	if (texname.size() > 0)
	{
		if (!content.load(path, texname[0], texinfo, tex)) return false;
		drawable.SetDiffuseMap(tex);
	}
	if (texname.size() > 1)
	{
		if (!content.load(path, texname[1], texinfo, tex)) return false;
		drawable.SetMiscMap1(tex);
	}
	if (texname.size() > 2)
	{
		if (!content.load(path, texname[2], texinfo, tex)) return false;
		drawable.SetMiscMap2(tex);
	}

	// set mesh
	std::tr1::shared_ptr<MODEL> mesh;
	if (!content.load(path, meshname, mesh)) return false;

	std::string scalestr;
	if (cfg.get("scale", scalestr) &&
		!content.get(path, meshname + scalestr, mesh))
	{
		MATHVECTOR<float, 3> scale;
		std::stringstream s(scalestr);
		s >> scale;

		VERTEXARRAY meshva = mesh->GetVertexArray();
		meshva.Scale(scale[0], scale[1], scale[2]);
		content.load(path, meshname + scalestr, meshva, mesh);
	}
Example #2
0
void TEXT_DRAW::SetText(
	DRAWABLE & draw,
	const FONT & font, const std::string & text,
	float x, float y, float scalex, float scaley,
	float r, float g, float b,
	VERTEXARRAY & output_array)
{
	RenderText(font, text, x, y, scalex, scaley, output_array);
	draw.SetDiffuseMap(font.GetFontTexture());
	draw.SetVertArray(&output_array);
	draw.SetCull(false, false);
	draw.SetColor(r, g, b, 1.0);
}