예제 #1
0
bool ReadColor (CRGBA &color, xmlNodePtr node)
{
	// Read the color
	float r = DEFAULT_PRIMITIVE_COLOR.R;
	float g = DEFAULT_PRIMITIVE_COLOR.G;
	float b = DEFAULT_PRIMITIVE_COLOR.B;
	float a = DEFAULT_PRIMITIVE_COLOR.A;

	// Read the value
	if (!ReadFloat ("R", r, node))
		return false;
	if (!ReadFloat ("G", g, node))
		return false;
	if (!ReadFloat ("B", b, node))
		return false;
	if (!ReadFloat ("A", a, node))
		a = 255;

	// Clamp
	clamp (r, 0.f, 255.f);
	clamp (g, 0.f, 255.f);
	clamp (b, 0.f, 255.f);
	clamp (a, 0.f, 255.f);

	// Set
	color.set((uint8)r, (uint8)g, (uint8)b, (uint8)a);
	return true;
}
예제 #2
0
// ***************************************************************************
void CVegetableApperancePage::OnDblclkListVegetableColor()
{
    CRGBA	color;

    // get the current color of the value.
    int		id= ColorList.GetCurSel();
    if(id!=LB_ERR)
    {
        color= ColorList.getValue(id);

        // Open a colorDialog.
        CColorDialog	colorDialog(RGB(color.R, color.G, color.B), CC_FULLOPEN);
        if( colorDialog.DoModal()==IDOK )
        {
            // update view
            COLORREF cref = colorDialog.GetColor();
            color.set(GetRValue(cref), GetGValue(cref), GetBValue(cref));
            ColorList.changeCurSelValue(color);
            // update vegetable
            writeToVegetableColor(_Vegetable);

            // update 3D view
            _VegetableDlg->refreshVegetableDisplay();
        }
    }
}
예제 #3
0
void cbUpdateCompass (CConfigFile::CVar &var)
{
	if (var.Name == "CompassPosX") CompassPosX = var.asFloat ();
	else if (var.Name == "CompassPosY") CompassPosY = var.asFloat ();
	else if (var.Name == "CompassRadius") CompassRadius = var.asFloat ();
	else if (var.Name == "CompassColor") 
	{
		CompassColor.set(var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
		CompassMaterial.setColor(CompassColor);
	}
	else nlwarning ("Unknown variable update %s", var.Name.c_str());
}
예제 #4
0
파일: radar.cpp 프로젝트: rbjarnason/Mayans
void cbUpdateRadar (CConfigFile::CVar &var)
{
	if (var.Name == "RadarPosX") RadarPosX = var.asFloat ();
	else if (var.Name == "RadarPosY") RadarPosY = var.asFloat ();
	else if (var.Name == "RadarWidth") RadarWidth = var.asFloat ();
	else if (var.Name == "RadarHeight") RadarHeight = var.asFloat ();
	else if (var.Name == "RadarBackColor") RadarBackColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
	else if (var.Name == "RadarFrontColor") RadarFrontColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
	else if (var.Name == "RadarSelfColor") RadarSelfColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
	else if (var.Name == "RadarOtherColor") RadarOtherColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
	else if (var.Name == "RadarDynamicColor") RadarDynamicColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
	else if (var.Name == "RadarPlaceColor") RadarPlaceColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
	else if (var.Name == "RadarEntitySize") RadarEntitySize = var.asFloat ();
	else if (var.Name == "RadarState") RadarState = var.asInt ();
	else if (var.Name == "RadarDistance") RadarDistance = var.asInt ();
	else if (var.Name == "RadarMinDistance") RadarMinDistance = var.asInt ();
	else if (var.Name == "RadarMaxDistance") RadarMaxDistance = var.asInt ();
	else if (var.Name == "URLSelectionTimeout") SelectionTimeOut = var.asInt ();
	else if (var.Name == "RadarParticularPlaces")
	{
		RadarParticularPlaces.clear ();
		for (sint i = 0; i < var.size(); i += 4)
		{
			RadarParticularPlaces.push_back (RadarParticularPlace(var.asFloat(i), var.asFloat(i+1), var.asString(i+2), var.asString(i+3)));
		}
	}
	else if (var.Name == "RadarFontSize") RadarFontSize = var.asInt ();
	else if (var.Name == "RadarLittlePosX") RadarLittlePosX = var.asFloat ();
	else if (var.Name == "RadarLittlePosY") RadarLittlePosY = var.asFloat ();
	else if (var.Name == "RadarLittleRadius") RadarLittleRadius = var.asFloat ();
	else nlwarning ("Unknown variable update %s", var.Name.c_str());
}
예제 #5
0
파일: graph.cpp 프로젝트: CCChaos/RyzomCore
void CGraph::renderGraph ()
{


	// Display the background
	uint32 w, h;
	CNELU::Driver->getWindowSize (w, h);
	float ScreenWidth = (float) w;
	float ScreenHeight = (float) h;
	if (w == 0 || h == 0) return;
	float iw = 1.f / w;
	float ih = 1.f / h;
	NL3D::CViewport vp;	
	CDRU::drawQuad(X * iw, Y * ih, (X+Width) * iw, (Y+Height) * ih, *CNELU::Driver, BackColor, vp);

	Peak = 0.0f;
	float sum = 0.0f;

	CRGBA lineCol;
	if ( LineMode )
	{
		lineCol.set (BackColor.R, BackColor.G, BackColor.B, 255);
	}
	else
	{
		lineCol.set (255,255,255,BackColor.A);
	}

	float pos = X+Width-1;
	uint i = 0;
	for (deque<float>::reverse_iterator it = Values.rbegin(); it != Values.rend(); it++)
	{
		float value = (*it) * Height / MaxValue;
		if (value > Height) value = Height;

		CVector vect1;
		if ( LineMode )
		{
			vect1.x = pos-1;
			vect1.y = PrevY;
		}
		else
		{
			vect1.x = pos;
			vect1.y = Y;
		}
		PrevY = Y + value;

		CDRU::drawLine(vect1.x * iw, vect1.y * ih, pos * iw, PrevY * ih, *CNELU::Driver, lineCol);

		pos--;
		if ((*it) > Peak) Peak = *it;
		sum += *it;
		i++;
	}


	// Display max
	float value = Peak * Height / MaxValue;
	if (value > Height) value = Height;
	float peakval = Y+value;
	CRGBA frontCol (min(BackColor.R*2,255),min(BackColor.G*2,255),min(BackColor.B*2,255),min(BackColor.A*2,255));
	CDRU::drawLine(X * iw, peakval * ih, (X+Width) * iw, peakval * ih, *CNELU::Driver, frontCol);

	// Display average
	float average = sum / (float)Values.size();
	value = average * Height / MaxValue;
	if (value > Height) value = Height;
	float avrval = Y+value;
	CDRU::drawLine(X * iw, avrval * ih, (X+Width) * iw, avrval * ih, *CNELU::Driver, frontCol);

}