Ejemplo n.º 1
0
void ROADPATCH::AddRacinglineScenenode(
	SCENENODE & node,
	const ROADPATCH & nextpatch,
	std::tr1::shared_ptr<TEXTURE> racingline_texture)
{
	//Create racing line scenenode
	keyed_container <DRAWABLE>::handle drawhandle = node.GetDrawlist().normal_blend.insert(DRAWABLE());
	DRAWABLE & draw = node.GetDrawlist().normal_blend.get(drawhandle);

	draw.SetDiffuseMap(racingline_texture);
	draw.SetDecal(true);
	draw.SetVertArray(&racingline_vertexarray);

	const MATHVECTOR <float, 3> & r0 = patch.GetRacingLine();
	const MATHVECTOR <float, 3> & r1 = nextpatch.patch.GetRacingLine();
	MATHVECTOR <float, 3> v0 = r0 + (patch.GetPoint(0,0) - r0).Normalize()*0.1;
	MATHVECTOR <float, 3> v1 = r0 + (patch.GetPoint(0,3) - r0).Normalize()*0.1;
	MATHVECTOR <float, 3> v2 = r1 + (nextpatch.GetPatch().GetPoint(0,3) - r1).Normalize()*0.1;
	MATHVECTOR <float, 3> v3 = r1 + (nextpatch.GetPatch().GetPoint(0,0) - r1).Normalize()*0.1;

	float trackoffset = 0.1;
	v0[2] += trackoffset;
	v1[2] += trackoffset;
	v2[2] += trackoffset;
	v3[2] += trackoffset;

	float vcorners[12];
	float uvs[8];
	int bfaces[6];

	vcorners[0] = v0[0]; vcorners[1] = v0[1]; vcorners[2] = v0[2];
	vcorners[3] = v1[0]; vcorners[4] = v1[1]; vcorners[5] = v1[2];
	vcorners[6] = v2[0]; vcorners[7] = v2[1]; vcorners[8] = v2[2];
	vcorners[9] = v3[0]; vcorners[10] = v3[1]; vcorners[11] = v3[2];

	uvs[0] = 0;
	uvs[1] = 0;
	uvs[2] = 1;
	uvs[3] = 0;
	uvs[4] = 1;
	uvs[5] = (v2-v1).Magnitude();
	uvs[6] = 0;
	uvs[7] = (v2-v1).Magnitude();

	bfaces[0] = 0;
	bfaces[1] = 2;
	bfaces[2] = 1;
	bfaces[3] = 0;
	bfaces[4] = 3;
	bfaces[5] = 2;

	racingline_vertexarray.SetFaces(bfaces, 6);
	racingline_vertexarray.SetVertices(vcorners, 12);
	racingline_vertexarray.SetTexCoordSets(1);
	racingline_vertexarray.SetTexCoords(0, uvs, 8);
}
Ejemplo n.º 2
0
Archivo: ai.cpp Proyecto: mutnig/vdrift
void ConfigureDrawable(keyed_container <DRAWABLE>::handle & ref, SCENENODE & topnode, float r, float g, float b)
{
	if (!ref.valid())
	{
		ref = topnode.GetDrawlist().normal_noblend.insert(DRAWABLE());
		DRAWABLE & d = topnode.GetDrawlist().normal_noblend.get(ref);
		d.SetColor(r,g,b,1);
		d.SetDecal(true);
	}
}
Ejemplo n.º 3
0
static keyed_container <DRAWABLE>::handle SetupText(
	SCENENODE & parent, FONT & font,
	TEXT_DRAW & textdraw, const std::string & str,
	float x, float y, float scalex, float scaley,
	float r, float g , float b, float zorder = 0)
{
	keyed_container<DRAWABLE>::handle draw = parent.GetDrawlist().text.insert(DRAWABLE());
	DRAWABLE & drawref = parent.GetDrawlist().text.get(draw);
	textdraw.Set(drawref, font, str, x, y, scalex, scaley, r, g, b);
	drawref.SetDrawOrder(zorder);
	return draw;
}
Ejemplo n.º 4
0
void GUILABEL::SetupDrawable(
	SCENENODE & scene,
	const FONT & font,
	int align,
	float scalex, float scaley,
	float x, float y,
	float w, float h, float z)
{
	m_font = &font;
	m_x = x;
	m_y = y;
	m_w = w;
	m_h = h;
	m_scalex = scalex;
	m_scaley = scaley;
	m_align = align;

	m_draw = scene.GetDrawlist().text.insert(DRAWABLE());
	DRAWABLE & drawref = GetDrawable(scene);
	drawref.SetDrawOrder(z);

	float textw = 0;
	if (align == -1) x -= w * 0.5;
	else if (align == 0) x -= textw * 0.5;
	else if (align == 1) x -= (textw - w * 0.5);
	m_text_draw.Set(drawref, font, m_text, x, y, scalex, scaley, m_r, m_g, m_b);
}
Ejemplo n.º 5
0
void WIDGET_LABEL::SetupDrawable(
	SCENENODE & scene,
	const FONT & font,
	const std::string & text,
	float x, float y,
	float scalex, float scaley,
	float nr, float ng, float nb,
	float z, bool centered)
{
	savedfont = &font;
	r = nr;
	b = nb;
	g = ng;
	saved_x = x;
	saved_y = y;
	saved_scalex = scalex;
	saved_scaley = scaley;
	saved_centered = centered;

	draw = scene.GetDrawlist().text.insert(DRAWABLE());
	DRAWABLE & drawref = GetDrawable(scene);
	drawref.SetDrawOrder(z);

	if (centered) x = x - savedfont->GetWidth(text) * saved_scalex * 0.5;
	text_draw.Set(drawref, font, text, x, y, scalex, scaley, r, g, b);
}
Ejemplo n.º 6
0
static void EraseTextDrawable(SCENENODE & node, keyed_container<DRAWABLE>::handle & drawhandle)
{
	if (drawhandle.valid())
	{
		node.GetDrawlist().twodim.erase(drawhandle);
		drawhandle.invalidate();
	}
}
Ejemplo n.º 7
0
void HUDBAR::Set(
	SCENENODE & parent,
	std::tr1::shared_ptr<TEXTURE> bartex,
	float x, float y, float w, float h,
	float opacity,
	bool flip)
{
	draw = parent.GetDrawlist().twodim.insert(DRAWABLE());
	DRAWABLE & drawref = parent.GetDrawlist().twodim.get(draw);

	drawref.SetDiffuseMap(bartex);
	drawref.SetVertArray(&verts);
	drawref.SetCull(false, false);
	drawref.SetColor(1,1,1,opacity);
	drawref.SetDrawOrder(1);

	verts.SetTo2DButton(x, y, w, h, h*0.75, flip);
}
Ejemplo n.º 8
0
void GUIIMAGE::SetupDrawable(
	SCENENODE & scene,
	ContentManager & content,
	const std::string & imagepath,
	float x, float y, float w, float h, float z)
{
	m_content = &content;
	m_imagepath = imagepath;
	m_varray.SetToBillboard(x - w * 0.5f, y - h * 0.5f, x + w * 0.5f, y + h * 0.5f);

	m_draw = scene.GetDrawlist().twodim.insert(DRAWABLE());
	DRAWABLE & drawref = GetDrawable(scene);
	drawref.SetVertArray(&m_varray);
	drawref.SetCull(false, false);
	drawref.SetDrawOrder(z);
}
Ejemplo n.º 9
0
static keyed_container<DRAWABLE>::handle AddDrawable(SCENENODE & node)
{
	return node.GetDrawlist().twodim.insert(DRAWABLE());
}
Ejemplo n.º 10
0
void HUDBAR::SetVisible(SCENENODE & parent, bool newvis)
{
	DRAWABLE & drawref = parent.GetDrawlist().twodim.get(draw);
	drawref.SetDrawEnable(newvis);
}
Ejemplo n.º 11
0
inline void Erase(SCENENODE & node, keyed_container <DRAWABLE>::handle & drawhandle)
{
	if (drawhandle.valid()) node.GetDrawlist().twodim.erase(drawhandle);
}
Ejemplo n.º 12
0
void ROADPATCH::AddRacinglineScenenode(
	SCENENODE & node,
	const ROADPATCH & nextpatch,
	std::tr1::shared_ptr<TEXTURE> racingline_texture)
{
	//Create racing line scenenode
	keyed_container <DRAWABLE>::handle drawhandle = node.GetDrawlist().normal_blend.insert(DRAWABLE());
	DRAWABLE & draw = node.GetDrawlist().normal_blend.get(drawhandle);

	draw.SetDiffuseMap(racingline_texture);
	draw.SetDecal(true);
	draw.SetVertArray(&racingline_vertexarray);

	MATHVECTOR <float, 3> v0 = racing_line + (patch.GetPoint(0,0) - racing_line).Normalize()*0.1;
	MATHVECTOR <float, 3> v1 = racing_line + (patch.GetPoint(0,3) - racing_line).Normalize()*0.1;
	MATHVECTOR <float, 3> v2 = nextpatch.racing_line + (nextpatch.GetPatch().GetPoint(0,3) - nextpatch.racing_line).Normalize()*0.1;
	MATHVECTOR <float, 3> v3 = nextpatch.racing_line + (nextpatch.GetPatch().GetPoint(0,0) - nextpatch.racing_line).Normalize()*0.1;

	//transform from bezier space into world space
	v0.Set(v0[2],v0[0],v0[1]);
	v1.Set(v1[2],v1[0],v1[1]);
	v2.Set(v2[2],v2[0],v2[1]);
	v3.Set(v3[2],v3[0],v3[1]);

	float trackoffset = 0.1;
	v0[2] += trackoffset;
	v1[2] += trackoffset;
	v2[2] += trackoffset;
	v3[2] += trackoffset;

	float vcorners[12];
	float uvs[8];
	int bfaces[6];

	//std::cout << v0 << std::endl;

	vcorners[0] = v0[0]; vcorners[1] = v0[1]; vcorners[2] = v0[2];
	vcorners[3] = v1[0]; vcorners[4] = v1[1]; vcorners[5] = v1[2];
	vcorners[6] = v2[0]; vcorners[7] = v2[1]; vcorners[8] = v2[2];
	vcorners[9] = v3[0]; vcorners[10] = v3[1]; vcorners[11] = v3[2];

	//std::cout << v0 << endl;
	//std::cout << racing_line << endl;

	uvs[0] = 0;
	uvs[1] = 0;
	uvs[2] = 1;
	uvs[3] = 0;
	uvs[4] = 1;
	uvs[5] = (v2-v1).Magnitude();
	uvs[6] = 0;
	uvs[7] = (v2-v1).Magnitude();

	bfaces[0] = 0;
	bfaces[1] = 2;
	bfaces[2] = 1;
	bfaces[3] = 0;
	bfaces[4] = 3;
	bfaces[5] = 2;

	racingline_vertexarray.SetFaces(bfaces, 6);
	racingline_vertexarray.SetVertices(vcorners, 12);
	racingline_vertexarray.SetTexCoordSets(1);
	racingline_vertexarray.SetTexCoords(0, uvs, 8);
}