Пример #1
0
bool CAR::LoadLight(
	const PTree & cfg,
	ContentManager & content,
	std::ostream & error_output)
{
	float radius;
	std::string radiusstr;
	MATHVECTOR<float, 3> pos(0), col(0);
	if (!cfg.get("position", pos, error_output)) return false;
	if (!cfg.get("color", col, error_output)) return false;
	if (!cfg.get("radius", radius, error_output)) return false;
	cfg.get("radius", radiusstr);

	lights.push_back(LIGHT());

	SCENENODE & bodynoderef = topnode.GetNode(bodynode);
	lights.back().node = bodynoderef.AddNode();

	SCENENODE & node = bodynoderef.GetNode(lights.back().node);
	node.GetTransform().SetTranslation(MATHVECTOR<float,3>(pos[0], pos[1], pos[2]));

	std::tr1::shared_ptr<MODEL> mesh;
	if (!content.get("", "cube"+radiusstr, mesh))
	{
		VERTEXARRAY varray;
		varray.SetToUnitCube();
		varray.Scale(radius, radius, radius);
		content.load("", "cube"+radiusstr, varray, mesh);
	}
    models.push_back(mesh);

	keyed_container <DRAWABLE> & dlist = GetDrawlist(node, OMNI);
	lights.back().draw = dlist.insert(DRAWABLE());

	DRAWABLE & draw = dlist.get(lights.back().draw);
	draw.SetColor(col[0], col[1], col[2]);
	draw.SetModel(*mesh);
	draw.SetCull(true, true);
	draw.SetDrawEnable(false);

	return true;
}
Пример #2
0
bool CarGraphics::LoadLight(
	const PTree & cfg,
	ContentManager & content,
	std::ostream & error_output)
{
	float radius;
	std::string radiusstr;
	Vec3 pos(0), col(0);
	if (!cfg.get("position", pos, error_output)) return false;
	if (!cfg.get("color", col, error_output)) return false;
	if (!cfg.get("radius", radius, error_output)) return false;
	cfg.get("radius", radiusstr);

	lights.push_back(Light());

	SceneNode & bodynoderef = topnode.GetNode(bodynode);
	lights.back().node = bodynoderef.AddNode();

	SceneNode & node = bodynoderef.GetNode(lights.back().node);
	node.GetTransform().SetTranslation(Vec3(pos[0], pos[1], pos[2]));

	std::shared_ptr<Model> mesh;
	if (!content.get(mesh, "", "cube" + radiusstr))
	{
		VertexArray varray;
		varray.SetToUnitCube();
		varray.Scale(radius, radius, radius);
		content.load(mesh, "", "cube" + radiusstr, varray);
	}
	models.insert(mesh);

	keyed_container <Drawable> & dlist = node.GetDrawList().lights_omni;
	lights.back().draw = dlist.insert(Drawable());

	Drawable & draw = dlist.get(lights.back().draw);
	draw.SetColor(col[0], col[1], col[2]);
	draw.SetModel(*mesh);
	draw.SetCull(true);
	draw.SetDrawEnable(false);

	return true;
}