コード例 #1
0
ファイル: widget_label.cpp プロジェクト: Bengt/vdrift
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);
}
コード例 #2
0
ファイル: guilabel.cpp プロジェクト: HaohaoLau/vdrift
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);
}
コード例 #3
0
void EcoreXRenderSurface::Init( Any surface )
{
  // see if there is a surface in Any surface
  unsigned int surfaceId  = GetSurfaceId( surface );

  // if the surface is empty, create a new one.
  if ( surfaceId == 0 )
  {
    // we own the surface about to created
    mOwnSurface = true;
    CreateXRenderable();
  }
  else
  {
    // XLib should already be initialized so no point in calling XInitThreads
    UseExistingRenderable( surfaceId );
  }

#ifdef DEBUG_ENABLED
  // prints out 'INFO: DALI: new EcoreXRenderSurface, used existing surface xx
  // we can not use LOG_INFO because the surface can be created before Dali Core is created.
  printf( "INFO: DALI: new EcoreXRenderSurface, %s surface %X \n",
          mOwnSurface?"created":"used existing",
          GetDrawable() );
#endif
}
コード例 #4
0
ファイル: FoldersTree.cpp プロジェクト: zenkovich/o2
	void AssetsFoldersTree::SetupFoldersTreeNode(TreeNode* node, UnknownPtr object)
	{
		AssetTree::AssetNode* assetTreeNode = (AssetTree::AssetNode*)(void*)object;
		String pathName = o2FileSystem.GetPathWithoutDirectories(assetTreeNode->path);

		node->name = pathName;

		auto nameLayer = node->layer["name"];
		if (nameLayer)
			((Text*)nameLayer->GetDrawable())->text = pathName;
	}
コード例 #5
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);
}
コード例 #6
0
void GUIIMAGE::Update(SCENENODE & scene, float dt)
{
	if (m_update)
	{
		assert(m_content);
		TEXTUREINFO texinfo;
		texinfo.mipmap = false;
		texinfo.repeatu = false;
		texinfo.repeatv = false;
		std::tr1::shared_ptr<TEXTURE> texture;
		if (m_content->load(m_imagepath, m_imagename, texinfo, texture))
			GetDrawable(scene).SetDiffuseMap(texture);
		
		GUIWIDGET::Update(scene, dt);
	}
}
コード例 #7
0
ファイル: guilabel.cpp プロジェクト: JanneSalokoski/vdrift
void GuiLabel::SetupDrawable(
    SceneNode & scene,
    const Font & font, int align,
    float scalex, float scaley,
    float xywh[4], float z)
{
    m_font = &font;
    m_x = xywh[0];
    m_y = xywh[1];
    m_w = xywh[2];
    m_h = xywh[3];
    m_scalex = scalex;
    m_scaley = scaley;
    m_align = align;

    m_draw = scene.GetDrawList().text.insert(Drawable());
    Drawable & drawref = GetDrawable(scene);
    drawref.SetDrawOrder(z);

    m_text_draw.Set(drawref, font, m_text, m_x, m_y, scalex, scaley, m_rgb[0], m_rgb[1], m_rgb[2]);
}
コード例 #8
0
ファイル: hud.cpp プロジェクト: linksblackmask/vdrift
bool HUD::Init(
	const std::string & texturepath,
	ContentManager & content,
	FONT & lcdfont,
	FONT & sansfont,
    FONT & sansfont_noshader,
	float displaywidth,
	float displayheight,
	bool debugon,
	std::ostream & error_output)
{
	const float opacity = 0.8;
	const float screenhwratio = displayheight / displaywidth;
	const float barheight = 64.0 / displayheight;
	const float barwidth = 256.0 / displaywidth;

	TEXTUREINFO texinfo;
	texinfo.mipmap = false;
	texinfo.repeatu = false;
	texinfo.repeatv = false;

	float timerbox_lowery = 0;
	{
		timernode = hudroot.AddNode();
		SCENENODE & timernoderef = hudroot.GetNode(timernode);

		float timerboxdimx = 96.0 / displaywidth;
		float timerboxdimy = 64.0 / displayheight;
		timerboxdraw = AddDrawable(timernoderef);
		DRAWABLE & timerboxdrawref = GetDrawable(timernoderef, timerboxdraw);

		TEXTUREINFO timerboxtexinfo;
		timerboxtexinfo.mipmap = false;
		timerboxtexinfo.repeatu = true;
		timerboxtexinfo.repeatv = false;
		std::tr1::shared_ptr<TEXTURE> timerboxtex;
		if (!content.load(texturepath, "timerbox.png", timerboxtexinfo, timerboxtex)) return false;

		float totalsizex = timerboxdimx * 6.05;
		float totalsizey = timerboxdimy * 2.0;
		float x = totalsizex * 0.5 - timerboxdimx * 0.65;
		float y = totalsizey * 0.5 - timerboxdimy * 0.25;
		float w = totalsizex - timerboxdimx * 2;
		float h = totalsizey - timerboxdimy * 2;
		timerboxverts.SetTo2DBox(x, y, w, h, timerboxdimx, timerboxdimy);
		timerbox_lowery = y + timerboxdimy * 0.5;

		timerboxdrawref.SetDiffuseMap(timerboxtex);
		timerboxdrawref.SetVertArray(&timerboxverts);
		timerboxdrawref.SetCull(false, false);
		timerboxdrawref.SetColor(1, 1, 1, opacity);
		timerboxdrawref.SetDrawOrder(0.1);

		float fontscaley = timerboxdimy * 0.4;
		float fontscalex = fontscaley * screenhwratio;
		float startx = timerboxdimx * 0.45 - timerboxdimx * 0.15;
		float xinc = timerboxdimx * 1.5;

		laptime_label.Init(timernoderef, sansfont, "Lap time:", startx, timerboxdimy*0.9-timerboxdimy*0.3, fontscalex, fontscaley);
		laptime_label.SetDrawOrder(timernoderef, 0.2);

		lastlaptime_label.Init(timernoderef, sansfont, "Last lap:", startx+xinc, timerboxdimy*.9-timerboxdimy*0.3, fontscalex, fontscaley);
		lastlaptime_label.SetDrawOrder(timernoderef, 0.2);

		bestlaptime_label.Init(timernoderef, sansfont, "Best lap:", startx+xinc*2.0, timerboxdimy*.9-timerboxdimy*0.3, fontscalex, fontscaley);
		bestlaptime_label.SetDrawOrder(timernoderef, 0.2);

		laptime.Init(timernoderef, lcdfont, "", startx, timerboxdimy*1.2-timerboxdimy*0.3, fontscalex, fontscaley);
		laptime.SetDrawOrder(timernoderef, 0.2);

		lastlaptime.Init(timernoderef, lcdfont, "", startx+xinc, timerboxdimy*1.2-timerboxdimy*0.3, fontscalex, fontscaley);
		lastlaptime.SetDrawOrder(timernoderef, 0.2);

		bestlaptime.Init(timernoderef, lcdfont, "", startx+xinc*2.0, timerboxdimy*1.2-timerboxdimy*0.3, fontscalex, fontscaley);
		bestlaptime.SetDrawOrder(timernoderef, 0.2);
	}

	{
		float fontscaley = barheight * 0.5;
		float fontscalex = screenhwratio * fontscaley;
		float x = fontscalex * 0.25;
		float y = timerbox_lowery + fontscaley;
		driftscoreindicator.Init(hudroot, sansfont, "", x, y, fontscalex, fontscaley);
		driftscoreindicator.SetDrawOrder(hudroot, 0.2);
	}

	{
		float fontscaley = barheight * 0.5;
		float fontscalex = screenhwratio * fontscaley;
		float x = fontscalex * 0.25;
		float y = timerbox_lowery + fontscaley * 2;
		lapindicator.Init(hudroot, sansfont, "", x, y, fontscalex, fontscaley);
		lapindicator.SetDrawOrder(hudroot, 0.2);
	}

	{
		float fontscaley = barheight * 0.5;
		float fontscalex = screenhwratio * fontscaley;
		float x = fontscalex * 0.25;
		float y = timerbox_lowery + fontscaley * 3;
		placeindicator.Init(hudroot, sansfont, "", x, y, fontscalex, fontscaley);
		placeindicator.SetDrawOrder(hudroot, 0.2);
	}

	{
		float fontscaley = barheight * 0.5;
		float fontscalex = screenhwratio * fontscaley;
		float x = 0.5;
		float y = 0.5;
		raceprompt.Init(hudroot, sansfont, "", x, y, fontscalex, fontscaley);
		raceprompt.SetDrawOrder(hudroot, 1.0);
		raceprompt.SetColor(hudroot, 1, 0, 0);
	}

	{
		float fontscaley = 0.02;
		float fontscalex = screenhwratio * fontscaley;

		debugnode = hudroot.AddNode();
		SCENENODE & debugnoderef = hudroot.GetNode(debugnode);
		debugtextdraw1 = SetupText(debugnoderef, sansfont, debugtext1, "", 0.01, fontscaley, fontscalex, fontscaley, 1, 1, 1, 10);
		debugtextdraw2 = SetupText(debugnoderef, sansfont, debugtext2, "", 0.25, fontscaley, fontscalex, fontscaley, 1, 1, 1, 10);
		debugtextdraw3 = SetupText(debugnoderef, sansfont, debugtext3, "", 0.5, fontscaley, fontscalex, fontscaley, 1, 1, 1, 10);
		debugtextdraw4 = SetupText(debugnoderef, sansfont, debugtext4, "", 0.75, fontscaley, fontscalex, fontscaley, 1, 1, 1, 10);
	}

#ifndef GAUGES
	std::tr1::shared_ptr<TEXTURE> bartex, progbartex;
	if (!content.load(texturepath, "hudbox.png", texinfo, bartex)) return false;
	if (!content.load(texturepath, "progressbar.png", texinfo, progbartex)) return false;

	rpmbar = AddDrawable(hudroot);
	rpmredbar = AddDrawable(hudroot);
	rpmbox = AddDrawable(hudroot);

	DRAWABLE & rpmboxref = GetDrawable(hudroot, rpmbox);
	rpmboxref.SetDiffuseMap(progbartex);
	rpmboxref.SetVertArray(&rpmboxverts);
	rpmboxref.SetDrawOrder(2);
	rpmboxref.SetCull(false, false);
	rpmboxref.SetColor(0.3, 0.3, 0.3, 0.4);

	DRAWABLE & rpmbarref = GetDrawable(hudroot, rpmbar);
	rpmbarref.SetDiffuseMap(progbartex);
	rpmbarref.SetVertArray(&rpmbarverts);
	rpmbarref.SetDrawOrder(3);
	rpmbarref.SetCull(false, false);
	rpmbarref.SetColor(1.0, 1.0, 1.0, 0.7);

	DRAWABLE & rpmredbarref = GetDrawable(hudroot, rpmredbar);
	rpmredbarref.SetDiffuseMap(progbartex);
	rpmredbarref.SetVertArray(&rpmredbarverts);
	rpmredbarref.SetColor(1.0, 0.2, 0.2, 0.7);
	rpmredbarref.SetDrawOrder(3);
	rpmredbarref.SetCull(false, false);

	//lower left bar
	bars.push_back(HUDBAR());
	bars.back().Set(hudroot, bartex, 0.0 + barwidth * 0.5, 1.0-barheight*0.5, barwidth, barheight, opacity, false);

	//lower right bar
	bars.push_back(HUDBAR());
	bars.back().Set(hudroot, bartex, 1.0 - barwidth * 0.175, 1.0-barheight*0.5, barwidth, barheight, opacity, false);

	{
		float fontscaley = barheight * 0.5;
		float fontscalex = screenhwratio * fontscaley;
		float y = 1.0 - fontscaley * 0.5;
		float x0 = screenhwratio * 0.02;
		float x1 = 1.0 - screenhwratio * 0.02;

		geartextdraw = SetupText(hudroot, lcdfont, geartext, "N", x0, y, fontscalex, fontscaley, 1, 1, 1, 4);
		mphtextdraw = SetupText(hudroot, lcdfont, mphtext, "0", x1, y, fontscalex, fontscaley, 1, 1, 1, 4);
	}

	{
		float fontscaley = barheight * 0.25;
		float fontscalex = screenhwratio * fontscaley;
		float x0 = 1 - barwidth * 0.6;
		float x1 = 1 - barwidth * 0.7;
		float y0 = 1 - fontscaley * 1.25;
		float y1 = 1 - fontscaley * 0.5;

		abs.Init(hudroot, sansfont, "ABS", x0, y0, fontscalex, fontscaley);
		abs.SetDrawOrder(hudroot, 4);
		abs.SetColor(hudroot, 0, 1, 0);

		tcs.Init(hudroot, sansfont, "TCS", x0, y1, fontscalex, fontscaley);
		tcs.SetDrawOrder(hudroot, 4);
		tcs.SetColor(hudroot, 1, 0.77, 0.23);

		gas.Init(hudroot, sansfont, "GAS", x1, y0, fontscalex, fontscaley);
		gas.SetDrawOrder(hudroot, 4);
		gas.SetColor(hudroot, 1, 0, 0);

		nos.Init(hudroot, sansfont, "NOS", x1, y1, fontscalex, fontscaley);
		nos.SetDrawOrder(hudroot, 4);
		nos.SetColor(hudroot, 0, 1, 0);
	}
#else
	{
        FONT & gaugefont = sansfont_noshader;

		// gauge texture
		char white[] = {255, 255, 255, 255};
		TEXTUREINFO tinfo;
		tinfo.data = white;
		tinfo.width = 1;
		tinfo.height = 1;
		tinfo.bytespp = 4;
		tinfo.mipmap = false;
		std::tr1::shared_ptr<TEXTURE> texture;
		content.load("", "white1x1", tinfo, texture);

		float r = 0.12;
		float x0 = 0.15;
		float x1 = 0.85;
		float y0 = 0.85;
		float h0 = r * 0.25;
		float w0 = screenhwratio * h0;
		float angle_min = 315.0 / 180.0 * M_PI;
		float angle_max = 45.0 / 180.0 * M_PI;

		rpmgauge.Set(hudroot, texture, gaugefont, screenhwratio, x0, y0, r,
			angle_min, angle_max, 0, maxrpm * 0.001, 1);

		speedgauge.Set(hudroot, texture, gaugefont, screenhwratio, x1, y0, r,
			angle_min, angle_max, 0, maxspeed * speedscale, 10);

		float w = w0;
		float h = h0;
		float x = x0 - gaugefont.GetWidth("rpm") * w * 0.5;
		float y = y0 - r * 0.5;
		DRAWABLE & rpmd = GetDrawable(hudroot, AddDrawable(hudroot));
		rpmlabel.Set(rpmd, gaugefont, "rpm", x, y, w, h, 1, 1, 1);

		w = w0 * 0.65;
		h = h0 * 0.65;
		x = x0 - gaugefont.GetWidth("x1000") * w * 0.5;
		y = y0 - r * 0.5 + h;
		DRAWABLE & x1000d = GetDrawable(hudroot, AddDrawable(hudroot));
		rpmxlabel.Set(x1000d, gaugefont, "x1000", x, y, w, h, 1, 1, 1);

		w = w0;
		h = h0;
		x = x1 - gaugefont.GetWidth("kph") * w * 0.5;
		y = y0 - r * 0.5;
		DRAWABLE & spdd = GetDrawable(hudroot, AddDrawable(hudroot));
		speedlabel.Set(spdd, gaugefont, "kph", x, y, w, h, 1, 1, 1);

		w = w0 * 2;
		h = h0 * 2;
		x = x0 - w * 0.25;
		y = y0 + r * 0.64;
		geartextdraw = SetupText(hudroot, gaugefont, geartext, "N", x, y, w, h, 1, 1, 1);

		w = w0 * 1.5;
		h = h0 * 1.5;
		x = x1 - w * 0.3;
		y = y0 + r * 0.68;
		mphtextdraw = SetupText(hudroot, gaugefont, mphtext, "0", x, y, w, h, 1, 1, 1);
	}

	{
		float fontscaley = barheight * 0.25;
		float fontscalex = screenhwratio * fontscaley;
		float x0 = 1 - barwidth * 0.6;
		float x1 = 1 - barwidth * 0.7;
		float y0 = 1 - fontscaley * 1.25;
		float y1 = 1 - fontscaley * 0.5;

		abs.Init(hudroot, sansfont, "ABS", x0, y0, fontscalex, fontscaley);
		abs.SetDrawOrder(hudroot, 4);
		abs.SetColor(hudroot, 0, 1, 0);

		tcs.Init(hudroot, sansfont, "TCS", x0, y1, fontscalex, fontscaley);
		tcs.SetDrawOrder(hudroot, 4);
		tcs.SetColor(hudroot, 1, 0.77, 0.23);

		gas.Init(hudroot, sansfont, "GAS", x1, y0, fontscalex, fontscaley);
		gas.SetDrawOrder(hudroot, 4);
		gas.SetColor(hudroot, 1, 0, 0);

		nos.Init(hudroot, sansfont, "NOS", x1, y1, fontscalex, fontscaley);
		nos.SetDrawOrder(hudroot, 4);
		nos.SetColor(hudroot, 0, 1, 0);
	}
#endif

	SetVisible(false);

	debug_hud_info = debugon;

	return true;
}
コード例 #9
0
ファイル: hudgauge.cpp プロジェクト: lwllovewf2010/vdrift
void HudGauge::Set(
	SceneNode & parent,
	const std::tr1::shared_ptr<Texture> & texture,
	const Font & font,
	float hwratio,
	float centerx,
	float centery,
	float radius,
	float startangle,
	float endangle,
	float startvalue,
	float endvalue,
	float valuedelta)
{
	assert(texture);

	// calculate number of segments (max 9)
	float segments = (endvalue - startvalue) / valuedelta;
	float factor = ceil(segments / 9.0f);
	segments = ceil(segments / factor);
	valuedelta = valuedelta * factor;
	endvalue = startvalue + segments * valuedelta;

	this->texture = texture;
	this->centerx = centerx;
	this->centery = centery;
	this->scalex = radius * hwratio;
	this->scaley = radius;
	this->startangle = startangle;
	this->endangle = endangle;
	this->scale = (endangle - startangle) / (endvalue - startvalue);

	// reset
	EraseTextDrawable(parent, dialnum_draw);
	EraseDrawable(parent, pointer_draw);
	EraseDrawable(parent, dial_draw);
	pointer_rotated.Clear();
	pointer.Clear();
	dial_label.Clear();
	dial_marks.Clear();

	// dial marks
	{
		// big marker
		float pb[] = {-0.02, 1, 0, 0.02, 1, 0, 0.02, 0.92, 0, -0.02, 0.92, 0};
		float t[] = {0, 0, 1, 0, 1, 1, 0, 1};
		int f[] = {0, 2, 1, 0, 3, 2};
		VertexArray bm;
		bm.SetVertices(pb, 12);
		bm.SetTexCoordSets(1);
		bm.SetTexCoords(0, t, 8);
		bm.SetFaces(f, 6);

		// small marker
		float ps[] = {-0.01, 1, 0, 0.01, 1, 0, 0.01, 0.95, 0, -0.01, 0.95, 0};
		VertexArray sm;
		sm.SetVertices(ps, 12);
		sm.SetTexCoordSets(1);
		sm.SetTexCoords(0, t, 8);
		sm.SetFaces(f, 6);

		float delta = (endangle - startangle) / (3.0 * segments);
		float angle = startangle;
		for (int i = 0; i <= 3 * segments; ++i)
		{
			VertexArray temp = (i % 3) ? sm : bm;
			temp.Rotate(angle, 0, 0, -1);
			dial_marks = dial_marks + temp;
			angle = angle + delta;
		}
		dial_marks.Scale(radius * hwratio, radius, 1);
		dial_marks.Translate(centerx, centery, 0.0);

		dial_draw = AddDrawable(parent);
		Drawable & drawref = GetDrawable(parent, dial_draw);
		drawref.SetTextures(texture->GetID());
		drawref.SetVertArray(&dial_marks);
		drawref.SetCull(false, false);
		//drawref.SetColor(1, 1, 1, 0.5);
		drawref.SetDrawOrder(1);
	}

	// dial label
	{
		VertexArray temp;
		float w = 0.25 * radius * hwratio;
		float h = 0.25 * radius;
		float angle = startangle;
		float angle_delta = (endangle - startangle) / segments;
		float value = startvalue;
		float value_delta = (endvalue - startvalue) / segments;
		for (int i = 0; i <= segments; ++i)
		{
			std::stringstream sstr;
			std::string text;
			sstr << value;
			sstr >> text;
			float x = centerx + 0.75 * sin(angle) * radius * hwratio;
			float y = centery + 0.75 * cos(angle) * radius;
			float xn = TextDraw::RenderText(font, text, x, y, w, h, temp);
			temp.Translate((x - xn) * 0.5, 0, 0);
			dial_label = dial_label + temp;
			angle += angle_delta;
			value += value_delta;
		}

		dialnum_draw = AddTextDrawable(parent);
		Drawable & drawref = GetTextDrawable(parent, dialnum_draw);
		drawref.SetTextures(font.GetFontTexture()->GetID());
		drawref.SetVertArray(&dial_label);
		drawref.SetCull(false, false);
		//drawref.SetColor(1, 1, 1, 0.5);
		drawref.SetDrawOrder(1);
	}

	// pointer
	{
		float p[] = {-0.015, 0.92, 0, 0.015, 0.92, 0, 0.025, -0.1, 0, -0.025, -0.1, 0};
		float t[] = {0, 0, 1, 0, 1, 1, 0, 1};
		int f[] = {0, 2, 1, 0, 3, 2};
		pointer.SetVertices(p, 12);
		pointer.SetTexCoordSets(1);
		pointer.SetTexCoords(0, t, 8);
		pointer.SetFaces(f, 6);

		pointer_draw = AddDrawable(parent);
		Drawable & drawref = GetDrawable(parent, pointer_draw);
		drawref.SetTextures(texture->GetID());
		drawref.SetVertArray(&pointer_rotated);
		drawref.SetCull(false, false);
		//drawref.SetColor(1, 1, 1, 0.5);
		drawref.SetDrawOrder(2);
	}
}
コード例 #10
0
static void RunFragment(const boost::filesystem::path& path)
{
	std::wstring fileNameStr = path.wstring();
	const wchar_t* fileName = fileNameStr.c_str();

	rage::five::ResourceFlags flags;
	rage::five::BlockMap* bm = UnwrapRSC7(fileName, &flags);

	if (!bm)
	{
		wprintf(L"couldn't open input file %s...\n", path.filename().c_str());
		return;
	}

	rage::five::pgStreamManager::SetBlockInfo(bm);

	auto fragType = (rage::five::fragType*)bm->blocks[0].data;

	{
		std::vector<rage::five::rmcDrawable*> drawables;
		drawables.push_back(fragType->GetPrimaryDrawable());

		for (size_t i = 0; i < fragType->GetNumDrawables(); i++)
		{
			drawables.push_back(fragType->GetDrawable(i));
		}

		auto physLod = fragType->GetLodGroup()->GetLod(0);

		for (size_t i = 0; i < physLod->GetNumChildren(); i++)
		{
			drawables.push_back(physLod->GetChild(i)->GetDrawable());

			auto dr = physLod->GetChild(i)->GetDrawable2();

			if (dr)
			{
				drawables.push_back(physLod->GetChild(i)->GetDrawable2());
			}
		}

		for (auto& dr : drawables)
		{
			const auto& mp = dr->GetLodGroup().GetMaxPoint();

			if (dr->GetLodGroup().GetModel(1) != nullptr)
			{
				dr->GetLodGroup().SetModel(1, nullptr);
				dr->GetLodGroup().SetModel(2, nullptr);
			}
		}
	}

	auto p2 = path;
	p2 = p2.replace_extension(".new.yft");

	FILE* f = _wfopen(p2.wstring().c_str(), L"wb");

	if (!f)
	{
		printf("... couldn't open output file for writing.\n");
		return;
	}

	size_t outputSize = 0;

	bm->Save(162, [&](const void* d, size_t s)
	{
		fwrite(d, 1, s, f);

		outputSize += s;
	}, &flags);

	printf("written successfully - out size %d\n", outputSize);

	fclose(f);

	for (int i = 0; i < bm->physicalLen + bm->virtualLen; i++)
	{
		delete bm->blocks[i].data;
	}

	delete bm;
}
コード例 #11
0
ファイル: hudgauge.cpp プロジェクト: Bengt/vdrift
void HUDGAUGE::Set(
	SCENENODE & parent,
	const FONT & font,
	const std::string & name,
	float hwratio,
	float centerx,
	float centery,
	float radius,
	float startangle,
	float endangle,
	float startvalue,
	float endvalue,
	float valuedelta)
{
	// calculate number of segments (max 9)
	float segments = (endvalue - startvalue) / valuedelta;
	float factor = ceil(segments / 9.0f);
	segments = ceil(segments / factor);
	valuedelta = valuedelta * factor;
	endvalue = startvalue + segments * valuedelta;

	this->centerx = centerx;
	this->centery = centery;
	this->scalex = radius * hwratio;
	this->scaley = radius;
	this->offset = startangle;
	this->scale = (endangle - startangle) / (endvalue - startvalue);

	// reset
	Erase(parent, pointer_draw);
	Erase(parent, dialnum_draw);
	Erase(parent, dial_draw);
	pointer_rotated.Clear();
	pointer.Clear();
	dial_label.Clear();
	dial_marks.Clear();

	// dial marks
	{
		// big marker
		float pb[] = {-0.02, 1, 0, 0.02, 1, 0, 0.02, 0.92, 0, -0.02, 0.92, 0};
		float t[] = {0, 0, 1, 0, 1, 1, 0, 1};
		int f[] = {0, 2, 1, 0, 3, 2};
		VERTEXARRAY bm;
		bm.SetVertices(pb, 12);
		bm.SetTexCoordSets(1);
		bm.SetTexCoords(0, t, 8);
		bm.SetFaces(f, 6);

		// small marker
		float ps[] = {-0.01, 1, 0, 0.01, 1, 0, 0.01, 0.95, 0, -0.01, 0.95, 0};
		VERTEXARRAY sm;
		sm.SetVertices(ps, 12);
		sm.SetTexCoordSets(1);
		sm.SetTexCoords(0, t, 8);
		sm.SetFaces(f, 6);

		float delta = (endangle - startangle) / (3 * segments);
		float angle = startangle;
		for (int i = 0; i <= 3 * segments; ++i)
		{
			VERTEXARRAY temp = (i % 3) ? sm : bm;
			temp.Rotate(angle, 0, 0, -1);
			dial_marks = dial_marks + temp;
			angle = angle + delta;
		}
		dial_marks.Scale(radius * hwratio, radius, 1);
		dial_marks.Translate(centerx, centery, 0.0);

		dial_draw = AddDrawable(parent);
		DRAWABLE & drawref = GetDrawable(parent, dial_draw);
		drawref.SetVertArray(&dial_marks);
		drawref.SetCull(false, false);
		drawref.SetColor(1, 1, 1, 0.5);
		drawref.SetDrawOrder(1);
	}

	// dial label
	{
		VERTEXARRAY temp;
		float w = 0.25 * radius * hwratio;
		float h = 0.25 * radius;
		float x = centerx;
		float y = centery - 0.5 * radius;
		float xn = TEXT_DRAW::RenderText(font, name, x, y, w, h, temp);
		temp.Translate((x - xn) * 0.5, 0, 0);
		dial_label = dial_label + temp;

		float angle = startangle;
		float angle_delta = (endangle - startangle) / segments;
		float value = startvalue;
		float value_delta = (endvalue - startvalue) / segments;
		for (int i = 0; i <= segments; ++i)
		{
			std::stringstream sstr;
			std::string text;
			sstr << value;
			sstr >> text;
			x = centerx + 0.75 * sin(angle) * radius * hwratio;
			y = centery + 0.75 * cos(angle) * radius;
			xn = TEXT_DRAW::RenderText(font, text, x, y, w, h, temp);
			temp.Translate((x - xn) * 0.5, 0, 0);
			dial_label = dial_label + temp;
			angle += angle_delta;
			value += value_delta;
		}

		dialnum_draw = AddDrawable(parent);
		DRAWABLE & drawref = GetDrawable(parent, dialnum_draw);
		drawref.SetDiffuseMap(font.GetFontTexture());
		drawref.SetVertArray(&dial_label);
		drawref.SetCull(false, false);
		drawref.SetColor(1, 1, 1, 0.5);
		drawref.SetDrawOrder(1);
	}

	// pointer
	{
		float p[] = {-0.015, 0.92, 0, 0.015, 0.92, 0, 0.025, -0.1, 0, -0.025, -0.1, 0};
		float t[] = {0, 0, 1, 0, 1, 1, 0, 1};
		int f[] = {0, 2, 1, 0, 3, 2};
		pointer.SetVertices(p, 12);
		pointer.SetTexCoordSets(1);
		pointer.SetTexCoords(0, t, 8);
		pointer.SetFaces(f, 6);
/*		pointer.Scale(radius, radius, 1);

		pointer_node = parent.AddNode();
		SCENENODE & noderef = parent.GetNode(pointer_node);
		QUATERNION<float> rot(startangle, 0, 0, 1);
		MATHVECTOR<float,3> pos(centerx, centery, 0);
		noderef.GetTransform().SetRotation(rot);
		noderef.GetTransform().SetTranslation(pos);
*/
		pointer_draw = AddDrawable(parent);//noderef);
		DRAWABLE & drawref = GetDrawable(parent, pointer_draw);//noderef, pointer_draw);
		drawref.SetVertArray(&pointer_rotated);//pointer);
		drawref.SetCull(false, false);
		drawref.SetColor(1, 1, 1, 0.5);
		drawref.SetDrawOrder(2);
	}
}
コード例 #12
0
ファイル: widget_label.cpp プロジェクト: Bengt/vdrift
void WIDGET_LABEL::SetVisible(SCENENODE & scene, bool newvis)
{
	GetDrawable(scene).SetDrawEnable(newvis);
}
コード例 #13
0
ファイル: widget_label.cpp プロジェクト: Bengt/vdrift
void WIDGET_LABEL::SetAlpha(SCENENODE & scene, float newalpha)
{
	GetDrawable(scene).SetColor(r, g, b, newalpha);
}